Search is not available for this dataset
problem_id
stringlengths 32
32
| name
stringlengths 2
112
| problem
stringlengths 200
14k
| test_cases
stringlengths 33
79.2M
| difficulty
stringclasses 33
values | language
sequencelengths 1
1
| source
stringclasses 14
values | num_solutions
int64 2
1.9M
| starter_code
stringlengths 0
1.47k
| subset
stringclasses 3
values |
---|---|---|---|---|---|---|---|---|---|
f992f4c7e4d9227cecb52b2bd79864d2 | Grandfather Dovlet’s calculator | Once Max found an electronic calculator from his grandfather Dovlet's chest. He noticed that the numbers were written with seven-segment indicators ([https://en.wikipedia.org/wiki/Seven-segment_display](https://en.wikipedia.org/wiki/Seven-segment_display)).
Max starts to type all the values from *a* to *b*. After typing each number Max resets the calculator. Find the total number of segments printed on the calculator.
For example if *a*<==<=1 and *b*<==<=3 then at first the calculator will print 2 segments, then — 5 segments and at last it will print 5 segments. So the total number of printed segments is 12.
The only line contains two integers *a*,<=*b* (1<=≤<=*a*<=≤<=*b*<=≤<=106) — the first and the last number typed by Max.
Print the only integer *a* — the total number of printed segments.
Sample Input
1 3
10 15
Sample Output
12
39
| {"inputs": ["1 3", "10 15", "1 100", "100 10000", "213 221442", "1 1000000", "1000000 1000000", "222145 353252", "2 1000000", "1 999999", "192 200"], "outputs": ["12", "39", "928", "188446", "5645356", "28733372", "38", "3860750", "28733370", "28733334", "122"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 111 | codeforces |
|
f9a7d083273864ce5cfc8a3db52acfc5 | Strongly Connected City | Imagine a city with *n* horizontal streets crossing *m* vertical streets, forming an (*n*<=-<=1)<=×<=(*m*<=-<=1) grid. In order to increase the traffic flow, mayor of the city has decided to make each street one way. This means in each horizontal street, the traffic moves only from west to east or only from east to west. Also, traffic moves only from north to south or only from south to north in each vertical street. It is possible to enter a horizontal street from a vertical street, or vice versa, at their intersection.
The mayor has received some street direction patterns. Your task is to check whether it is possible to reach any junction from any other junction in the proposed street direction pattern.
The first line of input contains two integers *n* and *m*, (2<=≤<=*n*,<=*m*<=≤<=20), denoting the number of horizontal streets and the number of vertical streets.
The second line contains a string of length *n*, made of characters '<' and '>', denoting direction of each horizontal street. If the *i*-th character is equal to '<', the street is directed from east to west otherwise, the street is directed from west to east. Streets are listed in order from north to south.
The third line contains a string of length *m*, made of characters '^' and 'v', denoting direction of each vertical street. If the *i*-th character is equal to '^', the street is directed from south to north, otherwise the street is directed from north to south. Streets are listed in order from west to east.
If the given pattern meets the mayor's criteria, print a single line containing "YES", otherwise print a single line containing "NO".
Sample Input
3 3
><>
v^v
4 6
<><>
v^v^v^
Sample Output
NO
YES
| {"inputs": ["3 3\n><>\nv^v", "4 6\n<><>\nv^v^v^", "2 2\n<>\nv^", "2 2\n>>\n^v", "3 3\n>><\n^^v", "3 4\n>><\n^v^v", "3 8\n>><\nv^^^^^^^", "7 2\n<><<<<>\n^^", "4 5\n><<<\n^^^^v", "2 20\n><\n^v^^v^^v^^^v^vv^vv^^", "2 20\n<>\nv^vv^v^^vvv^^^v^vvv^", "20 2\n<><<><<>><<<>><><<<<\n^^", "20 2\n><>><>><>><<<><<><><\n^v", "11 12\n><<<><><<>>\nvv^^^^vvvvv^", "4 18\n<<>>\nv^v^v^^vvvv^v^^vv^", "16 11\n<<<<>><><<<<<><<\nvv^v^vvvv^v", "14 7\n><<<<>>>>>>><<\nvv^^^vv", "5 14\n<<><>\nv^vv^^vv^v^^^v", "8 18\n>>>><>>>\nv^vv^v^^^^^vvv^^vv", "18 18\n<<><>><<>><>><><<<\n^^v^v^vvvv^v^vv^vv", "4 18\n<<<>\n^^^^^vv^vv^^vv^v^v", "19 18\n><><>>><<<<<>>><<<>\n^^v^^v^^v^vv^v^vvv", "14 20\n<<<><><<>><><<\nvvvvvvv^v^vvvv^^^vv^", "18 18\n><>>><<<>><><>>>><\nvv^^^^v^v^^^^v^v^^", "8 18\n<><<<>>>\n^^^^^^v^^^vv^^vvvv", "11 12\n><><><<><><\n^^v^^^^^^^^v", "4 18\n<<>>\nv^v^v^^vvvv^v^^vv^", "16 11\n>><<><<<<>>><><<\n^^^^vvvv^vv", "14 7\n<><><<<>>>><>>\nvv^^v^^", "5 14\n>>>><\n^v^v^^^vv^vv^v", "8 18\n<<<><>>>\nv^^vvv^^v^v^vvvv^^", "18 18\n><><<><><>>><>>>><\n^^vvv^v^^^v^vv^^^v", "4 18\n<<>>\nv^v^v^^vvvv^v^^vv^", "19 18\n>>>><><<>>><<<><<<<\n^v^^^^vv^^v^^^^v^v", "14 20\n<>><<<><<>>>>>\nvv^^v^^^^v^^vv^^vvv^", "18 18\n><><<><><>>><>>>><\n^^vvv^v^^^v^vv^^^v", "8 18\n<<<><>>>\nv^^vvv^^v^v^vvvv^^", "20 19\n<><>>>>><<<<<><<>>>>\nv^vv^^vvvvvv^vvvv^v", "20 19\n<<<><<<>><<<>><><><>\nv^v^vvv^vvv^^^vvv^^", "19 20\n<><<<><><><<<<<<<<>\n^v^^^^v^^vvvv^^^^vvv", "19 20\n>>>>>>>><>>><><<<><\n^v^v^^^vvv^^^v^^vvvv", "20 20\n<<<>>>><>><<>><<>>>>\n^vvv^^^^vv^^^^^v^^vv", "20 20\n>>><><<><<<<<<<><<><\nvv^vv^vv^^^^^vv^^^^^", "20 20\n><<><<<<<<<>>><>>><<\n^^^^^^^^vvvv^vv^vvvv", "20 20\n<>>>>>>>><>>><>><<<>\nvv^^vv^^^^v^vv^v^^^^", "20 20\n><>><<>><>>>>>>>><<>\n^^v^vv^^^vvv^v^^^vv^", "20 20\n<<<<><<>><><<<>><<><\nv^^^^vvv^^^vvvv^v^vv", "20 20\n><<<><<><>>><><<<<<<\nvv^^vvv^^v^^v^vv^vvv", "20 20\n<<>>><>>>><<<<>>><<>\nv^vv^^^^^vvv^^v^^v^v", "20 20\n><<><<><<<<<<>><><>>\nv^^^v^vv^^v^^vvvv^vv", "20 20\n<<<<<<<<><>><><>><<<\n^vvv^^^v^^^vvv^^^^^v", "20 20\n>>><<<<<>>><><><<><<\n^^^vvv^^^v^^v^^v^vvv", "20 20\n<><<<><><>><><><<<<>\n^^^vvvv^vv^v^^^^v^vv", "20 20\n>>>>>>>>>><>>><>><>>\n^vvv^^^vv^^^^^^vvv^v", "20 20\n<><>><><<<<<>><<>>><\nv^^^v^v^v^vvvv^^^vv^", "20 20\n><<<><<<><<<><>>>><<\nvvvv^^^^^vv^v^^vv^v^", "20 20\n<<><<<<<<>>>>><<<>>>\nvvvvvv^v^vvv^^^^^^^^", "20 20\n><<><<>>>>><><>><>>>\nv^^^^vvv^^^^^v^v^vv^", "20 20\n<<>>><>><<>>>><<<><<\n^^vvv^^vvvv^vv^^v^v^", "20 20\n><<>><>>>><<><>><><<\n^v^^^^^^vvvv^v^v^v^^", "20 20\n<<><<<<><><<>>><>>>>\n^^vvvvv^v^^^^^^^vvv^", "20 20\n>><<<<<<><>>>><>>><>\n^^^v^v^vv^^vv^vvv^^^", "20 20\n>>>>>>>>>>>>>>>>>>>>\nvvvvvvvvvvvvvvvvvvvv", "2 2\n><\nv^", "2 2\n<>\n^v", "3 3\n>><\nvvv", "2 3\n<>\nv^^", "4 4\n>>><\nvvv^", "20 20\n<><><><><><><><><><>\nvvvvvvvvvvvvvvvvvvvv", "4 4\n<>>>\nv^^^", "20 20\n<><><><><><><><><><>\nv^v^v^v^v^v^v^v^v^v^", "2 3\n<>\n^v^", "4 3\n<><>\n^vv", "3 3\n<<>\nvv^", "2 3\n><\nvv^", "7 6\n>>><>><\n^vv^vv", "2 2\n<<\nv^", "3 3\n>><\n^^^", "3 3\n<><\nv^v", "20 20\n><><><><><><><><><><\n^v^v^v^v^v^v^v^v^v^v", "4 4\n<>>>\nvvv^"], "outputs": ["NO", "YES", "YES", "NO", "YES", "YES", "NO", "NO", "YES", "NO", "YES", "NO", "YES", "NO", "YES", "NO", "NO", "NO", "NO", "NO", "NO", "NO", "NO", "NO", "NO", "YES", "YES", "YES", "YES", "YES", "YES", "YES", "YES", "YES", "YES", "YES", "YES", "NO", "YES", "NO", "YES", "NO", "NO", "YES", "YES", "NO", "NO", "NO", "NO", "NO", "NO", "YES", "NO", "NO", "NO", "NO", "YES", "NO", "NO", "NO", "NO", "NO", "NO", "NO", "NO", "NO", "YES", "NO", "NO", "YES", "YES", "NO", "NO", "YES", "NO", "YES", "NO", "NO", "NO", "YES", "YES"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 129 | codeforces |
|
f9a85cbfe549efd66c2fb1f532902fe2 | Jamie and Binary Sequence (changed after round) | Jamie is preparing a Codeforces round. He has got an idea for a problem, but does not know how to solve it. Help him write a solution to the following problem:
Find *k* integers such that the sum of two to the power of each number equals to the number *n* and the largest integer in the answer is as small as possible. As there may be multiple answers, you are asked to output the lexicographically largest one.
To be more clear, consider all integer sequence with length *k* (*a*1,<=*a*2,<=...,<=*a**k*) with . Give a value to each sequence. Among all sequence(s) that have the minimum *y* value, output the one that is the lexicographically largest.
For definitions of powers and lexicographical order see notes.
The first line consists of two integers *n* and *k* (1<=≤<=*n*<=≤<=1018,<=1<=≤<=*k*<=≤<=105) — the required sum and the length of the sequence.
Output "No" (without quotes) in a single line if there does not exist such sequence. Otherwise, output "Yes" (without quotes) in the first line, and *k* numbers separated by space in the second line — the required sequence.
It is guaranteed that the integers in the answer sequence fit the range [<=-<=1018,<=1018].
Sample Input
23 5
13 2
1 2
Sample Output
Yes
3 3 2 1 0
No
Yes
-1 -1
| {"inputs": ["23 5", "13 2", "1 2", "1 1", "1000000000000000000 100000", "7 2", "7 3", "7 4", "521325125150442808 10", "498518679725149504 1000", "464823731286228582 100000", "1 4", "9 4", "3 4", "144 4", "59 4", "78 4", "192 4", "107 4", "552 5", "680 5", "808 5", "1528 5", "1656 5", "26972 8", "23100 8", "19228 8", "22652 8", "26076 8", "329438 10", "12862 10", "96286 10", "12414 10", "95838 10", "1728568411 16", "611684539 16", "84735259 16", "6967851387 16", "2145934811 16", "6795804571172 20", "1038982654596 20", "11277865770724 20", "5525338821444 20", "15764221937572 20", "922239521698513045 30", "923065764876596469 30", "923892008054679893 30", "924718251232763317 30", "925544490115879445 30", "926370733293962869 30", "927196976472046293 30", "928023215355162421 30", "928849458533245845 30", "855969764271400156 30", "856796007449483580 30", "857622246332599708 30", "858448489510683132 30", "859274728393799260 30", "860100975866849980 30", "860927214749966108 30", "861753457928049532 30", "862579701106132957 30", "863405944284216381 30", "374585535361966567 30", "4 1", "4 9", "4 3", "4 144", "4 59", "4 78", "4 192", "4 107", "5 552", "5 680", "5 808", "5 1528", "5 1656", "8 26972", "8 23100", "8 19228", "8 22652", "8 26076", "23 19354", "23 35482", "23 18906", "23 2330", "23 85754", "23 1882", "23 85306", "23 68730", "23 84859", "23 45148", "281474976710656 5", "288230376151973890 5", "36029346774812736 5", "901283150305558530 5", "288318372649779720 50", "513703875844698663 50", "287632104387196918 50", "864690028406636543 58", "576460752303423487 60", "141012366262272 1", "1100585377792 4", "18598239186190594 9", "18647719372456016 19", "9297478914673158 29", "668507368948226 39", "1143595340402690 49", "35527987183872 59", "324634416758413825 9", "577030480059438572 19", "185505960265024385 29", "57421517433081233 39", "90131572647657641 49", "732268459757413905 59", "226111453445787190 9", "478818723873062027 19", "337790572680259391 29", "168057637182978458 39", "401486559567818547 49", "828935109688089201 59", "954687629161163764 9", "287025268967992526 19", "844118423640988373 29", "128233154575908599 39", "792058388714085231 49", "827183623566145225 59", "846113779983498737 9", "780248358343081983 19", "576460580458522095 29", "540145805193625598 39", "576388182371377103 49", "567448991726268409 59", "576460752303423487 9", "576460752303423487 19", "864691128455135231 29", "864691128455135231 39", "576460752303423487 49", "864691128455135231 59", "628839188486443015 2412", "558445254282313727 89558", "576460752303423487 100000", "1 100000", "99997 100000", "99998 100000", "99999 100000", "100000 100000", "100001 100000", "100002 100000", "100003 100000", "12 202", "1 4", "2 64", "2 8", "1 5", "1 7", "19 5", "1 30"], "outputs": ["Yes\n3 3 2 1 0 ", "No", "Yes\n-1 -1 ", "Yes\n0 ", "Yes\n44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44...", "No", "Yes\n2 1 0 ", "Yes\n1 1 1 0 ", "No", "Yes\n49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49...", "Yes\n43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43...", "Yes\n-2 -2 -2 -2 ", "Yes\n2 2 -1 -1 ", "Yes\n0 0 -1 -1 ", "Yes\n6 6 3 3 ", "No", "Yes\n6 3 2 1 ", "Yes\n6 6 5 5 ", "No", "Yes\n8 8 5 2 2 ", "Yes\n8 8 7 5 3 ", "Yes\n8 8 8 5 3 ", "No", "No", "Yes\n14 13 11 8 6 4 3 2 ", "Yes\n14 12 11 9 5 4 3 2 ", "Yes\n13 13 11 9 8 4 3 2 ", "Yes\n14 12 11 6 5 4 3 2 ", "No", "Yes\n18 16 10 9 7 6 4 3 2 1 ", "Yes\n12 12 12 9 5 4 3 2 0 0 ", "Yes\n15 15 14 13 12 11 4 3 2 1 ", "Yes\n12 12 12 6 5 4 3 2 0 0 ", "No", "No", "Yes\n28 28 26 22 21 20 18 16 15 12 7 5 4 3 1 0 ", "Yes\n25 25 24 19 18 15 14 13 12 10 8 4 3 1 -1 -1 ", "No", "No", "Yes\n41 41 41 37 35 34 33 30 26 24 23 18 14 13 12 10 9 5 1 1 ", "Yes\n38 38 38 37 36 32 31 30 29 27 21 20 16 13 11 9 7 1 0 0 ", "No", "No", "No", "Yes\n58 58 58 55 54 51 50 46 45 44 41 40 39 38 37 36 34 32 30 29 28 23 21 19 17 15 7 4 2 0 ", "No", "No", "Yes\n58 58 58 55 54 52 50 48 46 41 38 36 35 32 31 29 25 19 18 15 12 11 10 8 7 5 4 2 -1 -1 ", "Yes\n59 58 55 54 52 51 45 44 40 39 38 35 34 33 32 30 28 27 26 24 21 19 18 16 14 12 9 4 2 0 ", "Yes\n57 57 57 57 57 57 55 54 52 51 49 48 45 40 38 34 33 28 27 22 19 18 17 10 9 6 5 4 2 0 ", "No", "Yes\n58 58 58 55 54 53 48 37 36 33 31 27 26 25 23 19 18 17 16 14 13 11 10 9 8 5 4 2 -1 -1 ", "No", "No", "No", "Yes\n58 58 57 56 55 54 53 50 49 47 46 45 41 39 38 37 33 32 31 29 21 15 11 10 8 7 4 3 1 1 ", "No", "Yes\n59 57 56 55 54 53 51 50 47 46 40 39 38 36 28 26 25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8 -8 -8 -8 -8 -8 -8 -8 -8 -8 -8 -8 -8 -8 -8 -8 -8 -8 -8 -8 -8 -8 -8 -8 -8 -8 -8 -8 -8 -8 -8 -8 -8 -8 -8 -8 -8 -8 -8 -8 -8 -8 -8 -8 -8 -8 -8 -8 -8 -8 -8 -8 -8 -8 -8 -8 -8 -8 -8 -8 -8 -8 -8 -8 -8 -8 -8 -8 -8 -8 -8 -8 -8 -8 -8 -8 -8 -8 -8 -8 -8 -8 -8 -8 -8 -8 -8 -8 -8 -8 -8 -8 -8 -8 -8 -8 -8 -8 -8 -8 -8 -8 -8 -8 -8 -8 -8 -8 -8...", "Yes\n-11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -1...", "Yes\n-11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -1...", "Yes\n-11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -1...", "Yes\n-11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -1...", "Yes\n-11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -1...", "Yes\n-9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9...", "Yes\n-10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 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 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6...", "Yes\n-11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -1...", "Yes\n-6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6...", "Yes\n-11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -1...", "Yes\n-11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -1...", "Yes\n-11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -11 -1...", "Yes\n-10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -1...", "Yes\n46 46 46 45 45 ", "Yes\n57 57 18 0 0 ", "Yes\n55 39 15 11 6 ", "No", "Yes\n53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 46 44 35 30 27 17 14 9 2 1 0 -1 -2 -3 -4 -5 -6 -6 ", "Yes\n55 55 55 55 55 55 55 55 55 55 55 55 55 55 53 48 43 41 39 38 37 36 34 27 26 25 24 22 21 20 18 17 15 14 13 12 9 5 2 1 -1 -2 -3 -4 -5 -6 -7 -8 -9 -9 ", "Yes\n57 56 55 54 53 52 51 50 48 47 46 44 43 42 41 40 39 38 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 13 12 10 9 8 7 6 5 4 2 1 ", "Yes\n58 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 39 38 37 36 35 34 33 32 31 30 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 ", "Yes\n57 57 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 ", "No", "Yes\n39 39 30 13 ", "Yes\n54 49 44 41 40 21 18 8 1 ", "Yes\n51 51 51 51 51 51 51 51 49 46 31 24 20 16 6 3 2 1 1 ", "Yes\n49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 48 43 33 18 11 9 2 0 -1 -2 -3 -4 -4 ", "Yes\n45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 32 22 16 15 9 0 -1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -13 ", "Yes\n45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 44 36 35 27 25 19 12 0 -1 -2 -3 -4 -5 -6 -7 -8 -8 ", "Yes\n40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 38 36 24 19 18 17 14 7 6 5 4 3 2 1 0 -1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -11 ", "No", "Yes\n59 49 42 41 37 35 33 28 26 23 18 12 10 8 7 6 5 3 2 ", "Yes\n54 54 54 54 54 54 54 54 54 54 52 49 48 43 42 39 37 36 29 24 22 20 15 9 8 7 -1 -2 -2 ", "Yes\n52 52 52 52 52 52 52 52 52 52 52 52 51 50 39 36 31 30 28 27 26 24 20 11 10 8 7 4 -1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -10 ", "Yes\n52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 45 44 42 41 37 36 28 25 23 21 20 18 17 7 5 3 -1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -12 ", "Yes\n54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 53 51 48 47 43 41 38 35 31 30 28 20 13 10 9 4 -1 -2 -2 ", "No", "No", "Yes\n58 55 53 52 44 41 39 37 36 35 34 30 29 28 26 24 20 18 16 13 10 9 8 5 4 3 2 1 0 ", "Yes\n54 54 54 54 54 54 54 54 54 52 50 48 43 42 41 40 39 34 33 32 31 30 28 26 25 20 18 16 13 12 11 8 7 4 3 0 -1 -2 -2 ", "Yes\n54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 52 49 46 44 43 42 40 39 38 37 34 33 28 26 24 21 17 13 11 10 9 8 5 4 1 -1 -1 ", "Yes\n55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 47 46 45 44 43 36 34 33 32 29 25 23 22 19 18 17 15 14 12 11 9 6 5 4 -1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -11 ", "No", "No", "No", "Yes\n56 55 54 50 49 48 47 44 41 40 38 36 35 34 33 32 31 30 29 27 25 23 22 21 19 18 15 13 12 11 10 9 7 6 5 4 2 1 0 ", "Yes\n56 56 56 56 56 56 56 56 56 56 55 54 53 52 51 50 48 47 46 45 44 42 39 38 37 35 30 29 28 26 23 21 19 17 16 15 14 12 11 9 8 6 5 3 2 1 -1 -2 -2 ", "Yes\n55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 54 53 52 51 49 47 45 44 43 42 41 40 36 35 34 33 32 30 29 28 27 26 25 23 21 19 18 17 13 12 10 9 7 6 3 -1 -1 ", "No", "No", "No", "No", "Yes\n58 57 56 55 54 53 52 51 50 49 48 47 45 44 43 42 40 39 38 37 36 35 34 33 32 30 29 28 27 26 25 23 22 21 20 19 17 15 12 11 10 9 8 7 6 3 2 1 0 ", "Yes\n56 56 56 56 56 56 56 55 54 52 51 50 49 48 47 46 45 44 43 41 40 39 38 36 35 32 31 30 29 28 27 25 24 23 22 21 20 19 18 17 16 14 13 11 10 9 8 7 6 5 4 3 -1 -2 -3 -4 -5 -6 -6 ", "No", "No", "No", "No", "No", "Yes\n59 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 ", "Yes\n48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48...", "Yes\n43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43...", "Yes\n43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43...", "Yes\n-16 -16 -16 -16 -16 -16 -16 -16 -16 -16 -16 -16 -16 -16 -16 -16 -16 -16 -16 -16 -16 -16 -16 -16 -16 -16 -16 -16 -16 -16 -16 -16 -16 -16 -16 -16 -16 -16 -16 -16 -16 -16 -16 -16 -16 -16 -16 -16 -16 -16 -16 -16 -16 -16 -16 -16 -16 -16 -16 -16 -16 -16 -16 -16 -16 -16 -16 -16 -16 -16 -16 -16 -16 -16 -16 -16 -16 -16 -16 -16 -16 -16 -16 -16 -16 -16 -16 -16 -16 -16 -16 -16 -16 -16 -16 -16 -16 -16 -16 -16 -16 -16 -16 -16 -16 -16 -16 -16 -16 -16 -16 -16 -16 -16 -16 -16 -16 -16 -16 -16 -16 -16 -16 -16 -16 -16 -1...", "Yes\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0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-16 -17 -18 -18 "]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 8 | codeforces |
|
f9c5a5763559e747e28b34dcacc8f6e9 | Difference Row | You want to arrange *n* integers *a*1,<=*a*2,<=...,<=*a**n* in some order in a row. Let's define the value of an arrangement as the sum of differences between all pairs of adjacent integers.
More formally, let's denote some arrangement as a sequence of integers *x*1,<=*x*2,<=...,<=*x**n*, where sequence *x* is a permutation of sequence *a*. The value of such an arrangement is (*x*1<=-<=*x*2)<=+<=(*x*2<=-<=*x*3)<=+<=...<=+<=(*x**n*<=-<=1<=-<=*x**n*).
Find the largest possible value of an arrangement. Then, output the lexicographically smallest sequence *x* that corresponds to an arrangement of the largest possible value.
The first line of the input contains integer *n* (2<=≤<=*n*<=≤<=100). The second line contains *n* space-separated integers *a*1, *a*2, ..., *a**n* (|*a**i*|<=≤<=1000).
Print the required sequence *x*1,<=*x*2,<=...,<=*x**n*. Sequence *x* should be the lexicographically smallest permutation of *a* that corresponds to an arrangement of the largest possible value.
Sample Input
5
100 -100 50 0 -50
Sample Output
100 -50 0 50 -100
| {"inputs": ["5\n100 -100 50 0 -50", "10\n764 -367 0 963 -939 -795 -26 -49 948 -282", "20\n262 -689 -593 161 -678 -555 -633 -697 369 258 673 50 833 737 -650 198 -651 -621 -396 939", "50\n-262 -377 -261 903 547 759 -800 -53 670 92 758 109 547 877 152 -901 -318 -527 -388 24 139 -227 413 -135 811 -886 -22 -526 -643 -431 284 609 -745 -62 323 -441 743 -800 86 862 587 -513 -468 -651 -760 197 141 -414 -909 438", "100\n144 -534 -780 -1 -259 -945 -992 -967 -679 -239 -22 387 130 -908 140 -270 16 646 398 599 -631 -231 687 -505 89 77 584 162 124 132 33 271 212 734 350 -678 969 43 487 -689 -432 -225 -603 801 -828 -684 349 318 109 723 33 -247 719 368 -286 217 260 77 -618 955 408 994 -313 -341 578 609 60 900 222 -779 -507 464 -147 -789 -477 -235 -407 -432 35 300 -53 -896 -476 927 -293 -869 -852 -566 -759 95 506 -914 -405 -621 319 -622 -49 -334 328 -104", "100\n-790 341 910 905 -779 279 696 -375 525 -21 -2 751 -887 764 520 -844 850 -537 -882 -183 139 -397 561 -420 -991 691 587 -93 -701 -957 -89 227 233 545 934 309 -26 454 -336 -994 -135 -840 -320 -387 -943 650 628 -583 701 -708 -881 287 -932 -265 -312 -757 695 985 -165 -329 -4 -462 -627 798 -124 -539 843 -492 -967 -782 879 -184 -351 -385 -713 699 -477 828 219 961 -170 -542 877 -718 417 152 -905 181 301 920 685 -502 518 -115 257 998 -112 -234 -223 -396", "100\n720 331 -146 -935 399 248 525 -669 614 -245 320 229 842 -894 -73 584 -458 -975 -604 -78 607 -120 -377 409 -743 862 -969 980 105 841 -795 996 696 -759 -482 624 -578 421 -717 -553 -652 -268 405 426 642 870 -650 -812 178 -882 -237 -737 -724 358 407 714 759 779 -899 -726 398 -663 -56 -736 -825 313 -746 117 -457 330 -925 497 332 -794 -506 -811 -990 -799 -343 -380 598 926 671 967 -573 -687 741 484 -641 -698 -251 -391 23 692 337 -639 126 8 -915 -386", "100\n-657 320 -457 -472 -423 -227 -902 -520 702 -27 -103 149 268 -922 307 -292 377 730 117 1000 935 459 -502 796 -494 892 -523 866 166 -248 57 -606 -96 -948 988 194 -687 832 -425 28 -356 -884 688 353 225 204 -68 960 -929 -312 -479 381 512 -274 -505 -260 -506 572 226 -822 -13 325 -370 403 -714 494 339 283 356 327 159 -151 -13 -760 -159 -991 498 19 -159 583 178 -50 -421 -679 -978 334 688 -99 117 -988 371 693 946 -58 -699 -133 62 693 535 -375", "100\n853 752 931 -453 -943 -118 -772 -814 791 191 -83 -373 -748 -136 -286 250 627 292 -48 -896 -296 736 -628 -376 -246 -495 366 610 228 664 -951 -952 811 192 -730 -377 319 799 753 166 827 501 157 -834 -776 424 655 -827 549 -487 608 -643 419 349 -88 95 231 -520 -508 -105 -727 568 -241 286 586 -956 -880 892 866 22 658 832 -216 -54 491 -500 -687 393 24 129 946 303 931 563 -269 -203 -251 647 -824 -163 248 -896 -133 749 -619 -212 -2 491 287 219", "100\n9 857 227 -593 -983 -439 17 -523 -354 -189 780 -267 771 -981 943 620 -832 79 761 -943 218 -966 75 131 -596 534 51 796 -612 -381 -690 -353 -170 648 804 -256 257 -16 964 -728 310 50 453 737 -228 -625 618 841 -102 974 -850 -641 -788 231 -982 -84 -917 942 -913 -768 -83 298 388 447 -490 271 -949 976 -820 -876 -822 -188 -306 877 219 854 561 -307 -920 916 -925 -591 -149 -166 -572 860 -217 -831 -552 822 355 -150 203 -710 530 910 889 964 -125 -597", "2\n-1000 1000", "2\n1000 -1000", "2\n0 0", "5\n1 2 3 4 5", "6\n1 1 1 2 2 2", "3\n-1 -1 -1"], "outputs": ["100 -50 0 50 -100 ", "963 -795 -367 -282 -49 -26 0 764 948 -939 ", "939 -689 -678 -651 -650 -633 -621 -593 -555 -396 50 161 198 258 262 369 673 737 833 -697 ", "903 -901 -886 -800 -800 -760 -745 -651 -643 -527 -526 -513 -468 -441 -431 -414 -388 -377 -318 -262 -261 -227 -135 -62 -53 -22 24 86 92 109 139 141 152 197 284 323 413 438 547 547 587 609 670 743 758 759 811 862 877 -909 ", "994 -967 -945 -914 -908 -896 -869 -852 -828 -789 -780 -779 -759 -689 -684 -679 -678 -631 -622 -621 -618 -603 -566 -534 -507 -505 -477 -476 -432 -432 -407 -405 -341 -334 -313 -293 -286 -270 -259 -247 -239 -235 -231 -225 -147 -104 -53 -49 -22 -1 16 33 33 35 43 60 77 77 89 95 109 124 130 132 140 144 162 212 217 222 260 271 300 318 319 328 349 350 368 387 398 408 464 487 506 578 584 599 609 646 687 719 723 734 801 900 927 955 969 -992 ", "998 -991 -967 -957 -943 -932 -905 -887 -882 -881 -844 -840 -790 -782 -779 -757 -718 -713 -708 -701 -627 -583 -542 -539 -537 -502 -492 -477 -462 -420 -397 -396 -387 -385 -375 -351 -336 -329 -320 -312 -265 -234 -223 -184 -183 -170 -165 -135 -124 -115 -112 -93 -89 -26 -21 -4 -2 139 152 181 219 227 233 257 279 287 301 309 341 417 454 518 520 525 545 561 587 628 650 685 691 695 696 699 701 751 764 798 828 843 850 877 879 905 910 920 934 961 985 -994 ", "996 -975 -969 -935 -925 -915 -899 -894 -882 -825 -812 -811 -799 -795 -794 -759 -746 -743 -737 -736 -726 -724 -717 -698 -687 -669 -663 -652 -650 -641 -639 -604 -578 -573 -553 -506 -482 -458 -457 -391 -386 -380 -377 -343 -268 -251 -245 -237 -146 -120 -78 -73 -56 8 23 105 117 126 178 229 248 313 320 330 331 332 337 358 398 399 405 407 409 421 426 484 497 525 584 598 607 614 624 642 671 692 696 714 720 741 759 779 841 842 862 870 926 967 980 -990 ", "1000 -988 -978 -948 -929 -922 -902 -884 -822 -760 -714 -699 -687 -679 -657 -606 -523 -520 -506 -505 -502 -494 -479 -472 -457 -425 -423 -421 -375 -370 -356 -312 -292 -274 -260 -248 -227 -159 -159 -151 -133 -103 -99 -96 -68 -58 -50 -27 -13 -13 19 28 57 62 117 117 149 159 166 178 194 204 225 226 268 283 307 320 325 327 334 339 353 356 371 377 381 403 459 494 498 512 535 572 583 688 688 693 693 702 730 796 832 866 892 935 946 960 988 -991 ", "946 -952 -951 -943 -896 -896 -880 -834 -827 -824 -814 -776 -772 -748 -730 -727 -687 -643 -628 -619 -520 -508 -500 -495 -487 -453 -377 -376 -373 -296 -286 -269 -251 -246 -241 -216 -212 -203 -163 -136 -133 -118 -105 -88 -83 -54 -48 -2 22 24 95 129 157 166 191 192 219 228 231 248 250 286 287 292 303 319 349 366 393 419 424 491 491 501 549 563 568 586 608 610 627 647 655 658 664 736 749 752 753 791 799 811 827 832 853 866 892 931 931 -956 ", "976 -982 -981 -966 -949 -943 -925 -920 -917 -913 -876 -850 -832 -831 -822 -820 -788 -768 -728 -710 -690 -641 -625 -612 -597 -596 -593 -591 -572 -552 -523 -490 -439 -381 -354 -353 -307 -306 -267 -256 -228 -217 -189 -188 -170 -166 -150 -149 -125 -102 -84 -83 -16 9 17 50 51 75 79 131 203 218 219 227 231 257 271 298 310 355 388 447 453 530 534 561 618 620 648 737 761 771 780 796 804 822 841 854 857 860 877 889 910 916 942 943 964 964 974 -983 ", "1000 -1000 ", "1000 -1000 ", "0 0 ", "5 2 3 4 1 ", "2 1 1 2 2 1 ", "-1 -1 -1 "]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 144 | codeforces |
|
f9e30533a717a56cf7677d43d0cff780 | Ball | *N* ladies attend the ball in the King's palace. Every lady can be described with three values: beauty, intellect and richness. King's Master of Ceremonies knows that ladies are very special creatures. If some lady understands that there is other lady at the ball which is more beautiful, smarter and more rich, she can jump out of the window. He knows values of all ladies and wants to find out how many probable self-murderers will be on the ball. Lets denote beauty of the *i*-th lady by *B**i*, her intellect by *I**i* and her richness by *R**i*. Then *i*-th lady is a probable self-murderer if there is some *j*-th lady that *B**i*<=<<=*B**j*,<=*I**i*<=<<=*I**j*,<=*R**i*<=<<=*R**j*. Find the number of probable self-murderers.
The first line contains one integer *N* (1<=≤<=*N*<=≤<=500000). The second line contains *N* integer numbers *B**i*, separated by single spaces. The third and the fourth lines contain sequences *I**i* and *R**i* in the same format. It is guaranteed that 0<=≤<=*B**i*,<=*I**i*,<=*R**i*<=≤<=109.
Output the answer to the problem.
Sample Input
3
1 4 2
4 3 2
2 5 3
Sample Output
1
| {"inputs": ["3\n1 4 2\n4 3 2\n2 5 3", "5\n2 8 10 0 7\n7 7 3 0 10\n2 8 3 2 2", "5\n3 0 0 2 0\n7 10 7 4 0\n9 1 6 1 9", "5\n5 4 0 2 5\n8 3 1 0 10\n4 5 0 0 5", "5\n9 7 0 2 10\n8 6 5 5 9\n1 9 3 0 1", "10\n7 7 10 1 2 1 7 1 5 9\n9 10 6 2 5 6 7 7 5 5\n2 7 4 0 7 10 5 6 2 2", "10\n7 7 0 1 2 6 0 10 3 5\n5 8 4 0 3 4 7 10 5 0\n0 10 3 1 5 8 6 10 10 6", "10\n18 4 6 16 16 6 4 13 16 4\n10 4 18 13 5 13 8 13 7 0\n15 11 0 4 7 17 3 9 10 4", "10\n12 16 11 13 6 18 6 14 4 2\n11 6 4 13 10 1 6 3 8 19\n1 3 1 9 4 17 18 1 14 13", "10\n10 19 4 1 11 6 1 20 11 13\n2 7 17 8 10 3 20 16 10 8\n15 9 9 2 20 9 0 15 0 4", "10\n458 661 509 753 634 129 533 730 153 92\n86 5 877 484 356 41 694 941 198 327\n112 217 654 737 166 298 500 439 329 778", "10\n443 356 907 383 590 544 775 382 77 323\n657 44 756 189 294 932 441 293 373 90\n889 358 653 867 148 33 2 152 598 634"], "outputs": ["1", "1", "1", "2", "2", "4", "7", "5", "4", "6", "5", "7"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 2 | codeforces |
|
f9eb516e2cbf8e42e3e834b5fb2eebba | The Child and Homework | Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct.
Fortunately the child knows how to solve such complicated test. The child will follow the algorithm:
- If there is some choice whose description at least twice shorter than all other descriptions, or at least twice longer than all other descriptions, then the child thinks the choice is great. - If there is exactly one great choice then the child chooses it. Otherwise the child chooses C (the child think it is the luckiest choice).
You are given a multiple-choice questions, can you predict child's choose?
The first line starts with "A." (without quotes), then followed the description of choice A. The next three lines contains the descriptions of the other choices in the same format. They are given in order: B, C, D. Please note, that the description goes after prefix "X.", so the prefix mustn't be counted in description's length.
Each description is non-empty and consists of at most 100 characters. Each character can be either uppercase English letter or lowercase English letter, or "_".
Print a single line with the child's choice: "A", "B", "C" or "D" (without quotes).
Sample Input
A.VFleaKing_is_the_author_of_this_problem
B.Picks_is_the_author_of_this_problem
C.Picking_is_the_author_of_this_problem
D.Ftiasch_is_cute
A.ab
B.abcde
C.ab
D.abc
A.c
B.cc
C.c
D.c
Sample Output
D
C
B
| {"inputs": ["A.VFleaKing_is_the_author_of_this_problem\nB.Picks_is_the_author_of_this_problem\nC.Picking_is_the_author_of_this_problem\nD.Ftiasch_is_cute", "A.ab\nB.abcde\nC.ab\nD.abc", "A.c\nB.cc\nC.c\nD.c", "A.He_nan_de_yang_guang_zhao_yao_zhe_wo_men_mei_guo_ren_lian_shang_dou_xiao_kai_yan_wahaaaaaaaaaaaaaaaa\nB.Li_bai_li_bai_fei_liu_zhi_xia_san_qian_chi_yi_si_yin_he_luo_jiu_tian_li_bai_li_bai_li_bai_li_bai_shi\nC.Peng_yu_xiang_shi_zai_tai_shen_le_jian_zhi_jiu_shi_ye_jie_du_liu_a_si_mi_da_zhen_shi_tai_shen_le_a_a\nD.Wo_huo_le_si_shi_er_nian_zhen_de_shi_cong_lai_ye_mei_you_jian_guo_zhe_me_biao_zhun_de_yi_bai_ge_zi_a", "A.a___FXIcs_gB____dxFFzst_p_P_Xp_vS__cS_C_ei_\nB.fmnmkS_SeZYx_tSys_d__Exbojv_a_YPEL_BPj__I_aYH\nC._nrPx_j\nD.o_A_UwmNbC_sZ_AXk_Y___i_SN_U_UxrBN_qo_____", "A.G_R__iT_ow_Y__Sm_al__u_____l_ltK\nB.CWRe__h__cbCF\nC._QJ_dVHCL_g_WBsMO__LC____hMNE_DoO__xea_ec\nD.___Zh_", "A.a___FXIcs_gB____dxFFzst_p_P_Xp_vS__cS_C_ei_\nB.fmnmkS_SeZYx_tSys_d__Exbojv_a_YPEL_BPj__I_aYH\nC._nrPx_j\nD.o_A_UwmNbC_sZ_AXk_Y___i_SN_U_UxrBN_qo_____", "A.G_R__iT_ow_Y__Sm_al__u_____l_ltK\nB.CWRe__h__cbCF\nC._QJ_dVHCL_g_WBsMO__LC____hMNE_DoO__xea_ec\nD.___Zh_", "A.ejQ_E_E_G_e_SDjZ__lh_f_K__Z_i_B_U__S__S_EMD_ZEU_Sq\nB.o_JpInEdsrAY_T__D_S\nC.E_Vp_s\nD.a_AU_h", "A.PN_m_P_qgOAMwDyxtbH__Yc__bPOh_wYH___n_Fv_qlZp_\nB._gLeDU__rr_vjrm__O_jl_R__DG___u_XqJjW_\nC.___sHLQzdTzT_tZ_Gs\nD.sZNcVa__M_To_bz_clFi_mH_", "A.bR___cCYJg_Wbt____cxfXfC____c_O_\nB.guM\nC.__bzsH_Of__RjG__u_w_i__PXQL_U_Ow_U_n\nD._nHIuZsu_uU_stRC_k___vD_ZOD_u_z_c_Zf__p_iF_uD_Hdg", "A.x_\nB.__RSiDT_\nC.Ci\nD.KLY_Hc_YN_xXg_DynydumheKTw_PFHo_vqXwm_DY_dA___OS_kG___", "A.yYGJ_C__NYq_\nB.ozMUZ_cKKk_zVUPR_b_g_ygv_HoM__yAxvh__iE\nC.sgHJ___MYP__AWejchRvjSD_o\nD.gkfF_GiOqW_psMT_eS", "A._LYm_nvl_E__RCFZ_IdO\nB.k__qIPO_ivvZyIG__L_\nC.D_SabLm_R___j_HS_t__\nD._adj_R_ngix____GSe_aw__SbOOl_", "A.h_WiYTD_C_h___z_Gn_Th_uNh__g___jm\nB.__HeQaudCJcYfVi__Eg_vryuQrDkb_g__oy_BwX_Mu_\nC._MChdMhQA_UKrf_LGZk_ALTo_mnry_GNNza_X_D_u____ueJb__Y_h__CNUNDfmZATck_ad_XTbG\nD.NV___OoL__GfP_CqhD__RB_____v_T_xi", "A.____JGWsfiU\nB.S_LMq__MpE_oFBs_P\nC.U_Rph_VHpUr____X_jWXbk__ElJTu_Z_wlBpKLTD\nD.p_ysvPNmbrF__", "A.ejQ_E_E_G_e_SDjZ__lh_f_K__Z_i_B_U__S__S_EMD_ZEU_Sq\nB.o_JpInEdsrAY_T__D_S\nC.E_Vp_s\nD.a_AU_h", "A.PN_m_P_qgOAMwDyxtbH__Yc__bPOh_wYH___n_Fv_qlZp_\nB._gLeDU__rr_vjrm__O_jl_R__DG___u_XqJjW_\nC.___sHLQzdTzT_tZ_Gs\nD.sZNcVa__M_To_bz_clFi_mH_", "A.bR___cCYJg_Wbt____cxfXfC____c_O_\nB.guM\nC.__bzsH_Of__RjG__u_w_i__PXQL_U_Ow_U_n\nD._nHIuZsu_uU_stRC_k___vD_ZOD_u_z_c_Zf__p_iF_uD_Hdg", "A.x_\nB.__RSiDT_\nC.Ci\nD.KLY_Hc_YN_xXg_DynydumheKTw_PFHo_vqXwm_DY_dA___OS_kG___", "A.yYGJ_C__NYq_\nB.ozMUZ_cKKk_zVUPR_b_g_ygv_HoM__yAxvh__iE\nC.sgHJ___MYP__AWejchRvjSD_o\nD.gkfF_GiOqW_psMT_eS", "A._LYm_nvl_E__RCFZ_IdO\nB.k__qIPO_ivvZyIG__L_\nC.D_SabLm_R___j_HS_t__\nD._adj_R_ngix____GSe_aw__SbOOl_", "A.h_WiYTD_C_h___z_Gn_Th_uNh__g___jm\nB.__HeQaudCJcYfVi__Eg_vryuQrDkb_g__oy_BwX_Mu_\nC._MChdMhQA_UKrf_LGZk_ALTo_mnry_GNNza_X_D_u____ueJb__Y_h__CNUNDfmZATck_ad_XTbG\nD.NV___OoL__GfP_CqhD__RB_____v_T_xi", "A.____JGWsfiU\nB.S_LMq__MpE_oFBs_P\nC.U_Rph_VHpUr____X_jWXbk__ElJTu_Z_wlBpKLTD\nD.p_ysvPNmbrF__", "A.aaaaaa\nB.aaa\nC.aaa\nD.aaa", "A.aaa\nB.aaaaaa\nC.aaaaaa\nD.aaaaaa", "A.a\nB.b\nC.c\nD.d", "A._\nB.__\nC.____\nD.________", "A.____\nB.________\nC.________\nD._______", "A.h\nB.asdf\nC.asqw\nD.qwertasdfg", "A.aa\nB.aaaaa\nC.aaaaaa\nD.aaaaaaaaaaaaa", "A.ccc\nB.ccccccc\nC.ccc\nD.c", "A.c\nB.ccc\nC.cccccccccccccccccc\nD.cccccc", "A.aa\nB.bb\nC.cc\nD.ddd", "A.QW\nB.WERT\nC.QWER\nD.QWERTYUI"], "outputs": ["D", "C", "B", "C", "C", "D", "C", "D", "A", "C", "B", "D", "C", "C", "C", "C", "A", "C", "B", "D", "C", "C", "C", "C", "A", "A", "C", "C", "C", "C", "C", "C", "C", "C", "C"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 142 | codeforces |
|
f9ee988bce99481ccbaa17ab2d8b86b1 | Mysterious numbers - 2 | The only line of input contains three integers *a*1,<=*a*2,<=*a*3 (1<=≤<=*a*1,<=*a*2,<=*a*3<=≤<=20), separated by spaces.
Output a single integer.
The only line of input contains three integers *a*1,<=*a*2,<=*a*3 (1<=≤<=*a*1,<=*a*2,<=*a*3<=≤<=20), separated by spaces.
Output a single integer.
Sample Input
2 3 2
13 14 1
14 5 9
17 18 3
Sample Output
5
14
464
53
| {"inputs": ["2 3 2", "13 14 1", "14 5 9", "17 18 3", "1 1 1", "4 6 7", "1 1 20", "20 20 1", "20 20 20", "12 9 18", "1 19 15", "5 5 5", "10 11 12", "3 7 17", "8 2 9"], "outputs": ["5", "14", "464", "53", "1", "110", "10946", "20", "218920", "42420", "11967", "40", "2474", "14140", "236"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 17 | codeforces |
|
f9fcb4af74ccacc29497705beb13400c | One-Way Reform | There are *n* cities and *m* two-way roads in Berland, each road connects two cities. It is known that there is no more than one road connecting each pair of cities, and there is no road which connects the city with itself. It is possible that there is no way to get from one city to some other city using only these roads.
The road minister decided to make a reform in Berland and to orient all roads in the country, i.e. to make each road one-way. The minister wants to maximize the number of cities, for which the number of roads that begins in the city equals to the number of roads that ends in it.
The first line contains a positive integer *t* (1<=≤<=*t*<=≤<=200) — the number of testsets in the input.
Each of the testsets is given in the following way. The first line contains two integers *n* and *m* (1<=≤<=*n*<=≤<=200, 0<=≤<=*m*<=≤<=*n*·(*n*<=-<=1)<=/<=2) — the number of cities and the number of roads in Berland.
The next *m* lines contain the description of roads in Berland. Each line contains two integers *u* and *v* (1<=≤<=*u*,<=*v*<=≤<=*n*) — the cities the corresponding road connects. It's guaranteed that there are no self-loops and multiple roads. It is possible that there is no way along roads between a pair of cities.
It is guaranteed that the total number of cities in all testset of input data doesn't exceed 200.
Pay attention that for hacks, you can only use tests consisting of one testset, so *t* should be equal to one.
For each testset print the maximum number of such cities that the number of roads that begins in the city, is equal to the number of roads that ends in it.
In the next *m* lines print oriented roads. First print the number of the city where the road begins and then the number of the city where the road ends. If there are several answers, print any of them. It is allowed to print roads in each test in arbitrary order. Each road should be printed exactly once.
Sample Input
2
5 5
2 1
4 5
2 3
1 3
3 5
7 2
3 7
4 2
Sample Output
3
1 3
3 5
5 4
3 2
2 1
3
2 4
3 7
| {"inputs": ["2\n5 5\n2 1\n4 5\n2 3\n1 3\n3 5\n7 2\n3 7\n4 2", "4\n9 17\n3 6\n2 6\n6 9\n4 1\n2 8\n1 9\n7 9\n8 5\n1 7\n4 9\n6 7\n3 4\n9 3\n8 4\n2 1\n3 8\n2 7\n5 6\n2 5\n3 4\n1 3\n4 5\n5 3\n2 3\n12 8\n10 2\n9 2\n6 9\n10 6\n8 2\n4 10\n11 2\n4 11\n19 10\n6 2\n3 12\n17 7\n2 19\n17 4\n1 13\n7 1\n13 7\n6 8\n11 7", "1\n200 0", "1\n13 9\n13 12\n3 11\n12 10\n12 9\n2 11\n3 8\n1 3\n2 13\n13 11", "1\n4 6\n1 3\n4 1\n3 2\n1 2\n4 3\n4 2", "1\n6 7\n3 2\n3 1\n6 4\n1 2\n5 4\n3 4\n5 6", "1\n5 4\n1 2\n2 3\n2 4\n2 5"], "outputs": ["3\n1 3\n3 5\n5 4\n3 2\n2 1\n3\n2 4\n3 7", "7\n1 9\n9 7\n7 6\n6 9\n5 8\n8 4\n4 9\n9 3\n3 8\n8 2\n2 7\n7 1\n1 4\n4 3\n3 6\n6 2\n2 1\n3\n5 4\n4 3\n3 5\n5 2\n2 3\n3 1\n10\n2 11\n11 4\n4 10\n10 6\n6 9\n9 2\n2 10\n8 2\n13\n1 13\n13 7\n7 17\n17 4\n11 7\n7 1\n2 19\n8 6\n6 2\n3 12", "200", "5\n1 3\n3 11\n11 13\n11 2\n2 13\n13 12\n12 10\n12 9\n8 3", "0\n1 4\n4 2\n4 3\n3 1\n3 2\n2 1", "4\n1 3\n3 4\n4 6\n6 5\n5 4\n3 2\n2 1", "1\n3 2\n2 5\n4 2\n2 1"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 2 | codeforces |
|
fa0b50fbf360b509f5fb8c307ce28ba4 | Strings of Power | Volodya likes listening to heavy metal and (occasionally) reading. No wonder Volodya is especially interested in texts concerning his favourite music style.
Volodya calls a string powerful if it starts with "heavy" and ends with "metal". Finding all powerful substrings (by substring Volodya means a subsequence of consecutive characters in a string) in a given text makes our hero especially joyful. Recently he felt an enormous fit of energy while reading a certain text. So Volodya decided to count all powerful substrings in this text and brag about it all day long. Help him in this difficult task. Two substrings are considered different if they appear at the different positions in the text.
For simplicity, let us assume that Volodya's text can be represented as a single string.
Input contains a single non-empty string consisting of the lowercase Latin alphabet letters. Length of this string will not be greater than 106 characters.
Print exactly one number — the number of powerful substrings of the given string.
Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams or the %I64d specifier.
Sample Input
heavymetalisheavymetal
heavymetalismetal
trueheavymetalissotruewellitisalsosoheavythatyoucanalmostfeeltheweightofmetalonyou
Sample Output
323 | {"inputs": ["heavymetalisheavymetal", "heavymetalismetal", "trueheavymetalissotruewellitisalsosoheavythatyoucanalmostfeeltheweightofmetalonyou", "fpgzbvhheavymheheavyzmheavyavyebknkhheavyhsbqmmetheavyalmetalheavyyomtua", "metametaheavyetalalmetalavylkeoheavyhemetaleavycdk", "hg"], "outputs": ["3", "2", "3", "5", "3", "0"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 9 | codeforces |
|
fa95baebd3d1219835ac38b5de362bb9 | Roma and Changing Signs | Roma works in a company that sells TVs. Now he has to prepare a report for the last year.
Roma has got a list of the company's incomes. The list is a sequence that consists of *n* integers. The total income of the company is the sum of all integers in sequence. Roma decided to perform exactly *k* changes of signs of several numbers in the sequence. He can also change the sign of a number one, two or more times.
The operation of changing a number's sign is the operation of multiplying this number by -1.
Help Roma perform the changes so as to make the total income of the company (the sum of numbers in the resulting sequence) maximum. Note that Roma should perform exactly *k* changes.
The first line contains two integers *n* and *k* (1<=≤<=*n*,<=*k*<=≤<=105), showing, how many numbers are in the sequence and how many swaps are to be made.
The second line contains a non-decreasing sequence, consisting of *n* integers *a**i* (|*a**i*|<=≤<=104).
The numbers in the lines are separated by single spaces. Please note that the given sequence is sorted in non-decreasing order.
In the single line print the answer to the problem — the maximum total income that we can obtain after exactly *k* changes.
Sample Input
3 2
-1 -1 1
3 1
-1 -1 1
Sample Output
3
1
| {"inputs": ["3 2\n-1 -1 1", "3 1\n-1 -1 1", "17 27\n257 320 676 1136 2068 2505 2639 4225 4951 5786 7677 7697 7851 8337 8429 8469 9343", "69 28\n-9822 -9264 -9253 -9221 -9139 -9126 -9096 -8981 -8521 -8313 -8257 -8253 -7591 -7587 -7301 -7161 -7001 -6847 -6441 -6241 -5949 -5896 -5713 -5692 -5644 -5601 -5545 -5525 -5331 -5253 -5041 -5000 -4951 -4855 -4384 -4293 -4251 -4001 -3991 -3762 -3544 -3481 -3261 -2983 -2882 -2857 -2713 -2691 -2681 -2653 -2221 -2043 -2011 -1997 -1601 -1471 -1448 -1363 -1217 -1217 -1129 -961 -926 -801 -376 -327 -305 -174 -91", "12 28\n-6652 -6621 -6471 -5559 -5326 -4551 -4401 -4326 -3294 -1175 -1069 -43", "78 13\n-9961 -9922 -9817 -9813 -9521 -9368 -9361 -9207 -9153 -9124 -9008 -8981 -8951 -8911 -8551 -8479 -8245 -8216 -7988 -7841 -7748 -7741 -7734 -7101 -6846 -6804 -6651 -6526 -6519 -6463 -6297 -6148 -6090 -5845 -5209 -5201 -5161 -5061 -4537 -4529 -4433 -4370 -4266 -4189 -4125 -3945 -3843 -3777 -3751 -3476 -3461 -3279 -3205 -3001 -2889 -2761 -2661 -2521 -2481 -2305 -2278 -2269 -2225 -1648 -1524 -1476 -1353 -1097 -867 -785 -741 -711 -692 -440 -401 -225 -65 -41", "4 1\n218 3441 4901 7601", "73 26\n-8497 -8363 -7603 -7388 -6830 -6827 -6685 -6389 -6237 -6099 -6013 -5565 -5465 -4965 -4947 -4201 -3851 -3793 -3421 -3410 -3201 -3169 -3156 -2976 -2701 -2623 -2321 -2169 -1469 -1221 -950 -926 -9 47 236 457 773 1321 1485 1545 1671 1736 2014 2137 2174 2301 2625 3181 3536 3851 4041 4685 4981 4987 5145 5163 5209 5249 6011 6337 6790 7254 7361 7407 7969 7982 8083 8251 8407 8735 9660 9855 9957", "53 5\n-9821 -9429 -9146 -8973 -8807 -8801 -8321 -7361 -7222 -7161 -6913 -5961 -4877 -4756 -4753 -4661 -3375 -3031 -2950 -2661 -2161 -2041 -1111 -1071 -905 -697 -397 323 772 1617 1752 2736 2737 3201 3465 4029 4121 4463 4561 4637 4814 6119 6610 6641 6961 7217 7523 8045 8610 8915 9004 9265 9576", "1 1\n0", "1 1\n10000", "1 2\n-1", "2 1\n0 1", "2 2\n-1 0", "5 6\n-3 -2 -1 5 6", "3 3\n-50 -10 30", "4 4\n-100 -90 -80 1", "4 3\n-3 -2 1 2", "6 4\n-6 -3 -2 1 2 3", "5 6\n-10 -9 -8 1 2", "1 2\n1", "2 2\n-1 3", "4 7\n-3 -2 1 6", "4 3\n-7 -6 1 5", "4 4\n-5 -1 1 2"], "outputs": ["3", "1", "81852", "102443", "49488", "-147832", "15725", "315919", "92703", "0", "-10000", "-1", "1", "1", "15", "70", "269", "6", "15", "28", "1", "2", "10", "17", "9"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 79 | codeforces |
|
fa9e6b7e16715652317cbfb661c3b1f5 | none | Stepan likes to repeat vowel letters when he writes words. For example, instead of the word "pobeda" he can write "pobeeeedaaaaa".
Sergey does not like such behavior, so he wants to write a program to format the words written by Stepan. This program must combine all consecutive equal vowels to a single vowel. The vowel letters are "a", "e", "i", "o", "u" and "y".
There are exceptions: if letters "e" or "o" repeat in a row exactly 2 times, like in words "feet" and "foot", the program must skip them and do not transform in one vowel. For example, the word "iiiimpleeemeentatiioon" must be converted to the word "implemeentatioon".
Sergey is very busy and asks you to help him and write the required program.
The first line contains the integer *n* (1<=≤<=*n*<=≤<=100<=000) — the number of letters in the word written by Stepan.
The second line contains the string *s* which has length that equals to *n* and contains only lowercase English letters — the word written by Stepan.
Print the single string — the word written by Stepan converted according to the rules described in the statement.
Sample Input
13
pobeeeedaaaaa
22
iiiimpleeemeentatiioon
18
aeiouyaaeeiioouuyy
24
aaaoooiiiuuuyyyeeeggghhh
Sample Output
pobeda
implemeentatioon
aeiouyaeeioouy
aoiuyeggghhh
| {"inputs": ["13\npobeeeedaaaaa", "22\niiiimpleeemeentatiioon", "18\naeiouyaaeeiioouuyy", "24\naaaoooiiiuuuyyyeeeggghhh", "36\naeiouyaaeeiioouuyyaaaeeeiiiooouuuyyy", "100\noiyufyyyioueoudosizoryuoedatenougiuaeuouuyoiimaeigeeycewuooyovacoiyuaygfuuaiaeuahuieeafxsciylaebeufi", "200\nmmffggzvuuzzlkafduueqocuybiiaaeeoiioouaaurccuqoouuooooooyjjtyyxxiipneeueyuuoyxxhhkaaooooyaaauuoppzabuuoiiuuggcciissuugejjiirruummsiifaauyypauwoofiemzaeeeeeeiioozzttyyidaaaiggizzerkooooeeepueeauuppthhb", "1\no", "1\ne", "1\nf", "1\na", "2\nee", "2\noo", "4\neeoo", "7\nooeeeee", "75\noiaaaiiioyoeuauieeeeyauioyaiuyueeoaiiyeauyuauuyueoioueieeaaeyiyeyyaiooouyoo", "5\noooee", "8\neeeaaeee", "10\noaaoooaaoo", "5\nooeoo", "3\neoo", "3\nooo"], "outputs": ["pobeda", "implemeentatioon", "aeiouyaeeioouy", "aoiuyeggghhh", "aeiouyaeeioouyaeiouy", "oiyufyioueoudosizoryuoedatenougiuaeuouyoimaeigeeycewuooyovacoiyuaygfuaiaeuahuieeafxsciylaebeufi", "mmffggzvuzzlkafdueqocuybiaeeoioouaurccuqoouoyjjtyxxipneeueyuoyxxhhkaoyauoppzabuoiuggccissugejjirrummsifauypauwoofiemzaeioozzttyidaiggizzerkoepueeauppthhb", "o", "e", "f", "a", "ee", "oo", "eeoo", "ooe", "oiaioyoeuauieyauioyaiuyueeoaiyeauyuauyueoioueieeaeyiyeyaiouyoo", "oee", "eae", "oaoaoo", "ooeoo", "eoo", "o"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 48 | codeforces |
|
faad69b01b68c5b762c9f2b9f2e0453f | Anti-Palindromize | A string *a* of length *m* is called antipalindromic iff *m* is even, and for each *i* (1<=≤<=*i*<=≤<=*m*) *a**i*<=≠<=*a**m*<=-<=*i*<=+<=1.
Ivan has a string *s* consisting of *n* lowercase Latin letters; *n* is even. He wants to form some string *t* that will be an antipalindromic permutation of *s*. Also Ivan has denoted the beauty of index *i* as *b**i*, and the beauty of *t* as the sum of *b**i* among all indices *i* such that *s**i*<==<=*t**i*.
Help Ivan to determine maximum possible beauty of *t* he can get.
The first line contains one integer *n* (2<=≤<=*n*<=≤<=100, *n* is even) — the number of characters in *s*.
The second line contains the string *s* itself. It consists of only lowercase Latin letters, and it is guaranteed that its letters can be reordered to form an antipalindromic string.
The third line contains *n* integer numbers *b*1, *b*2, ..., *b**n* (1<=≤<=*b**i*<=≤<=100), where *b**i* is the beauty of index *i*.
Print one number — the maximum possible beauty of *t*.
Sample Input
8
abacabac
1 1 1 1 1 1 1 1
8
abaccaba
1 2 3 4 5 6 7 8
8
abacabca
1 2 3 4 4 3 2 1
Sample Output
8
26
17
| {"inputs": ["8\nabacabac\n1 1 1 1 1 1 1 1", "8\nabaccaba\n1 2 3 4 5 6 7 8", "8\nabacabca\n1 2 3 4 4 3 2 1", "100\nbaaacbccbccaccaccaaabcabcabccacaabcbccbccabbabcbcbbaacacbacacacaacccbcbbbbacccababcbacacbacababcacbc\n28 28 36 36 9 53 7 54 66 73 63 30 55 53 54 74 60 2 34 36 72 56 13 63 99 4 44 54 29 75 9 68 80 49 74 94 42 22 43 4 41 88 87 44 85 76 20 5 5 36 50 90 78 63 84 93 47 33 64 60 11 67 70 7 14 45 48 88 12 95 65 53 37 15 49 50 47 57 15 84 96 18 63 23 93 14 85 26 55 58 8 49 54 94 3 10 61 24 68 1", "100\ncccccaacccbaaababacbbacbbbcbccaccaccbcccbbaabababcacbccaacacaababacbcbcccabcacbccccbccaaabcabcaaabcc\n95 91 11 97 2 16 42 33 22 1 26 52 47 45 96 96 53 99 38 61 27 53 6 13 12 77 76 19 69 60 88 85 61 29 81 65 52 47 23 12 93 76 46 30 71 11 96 3 80 79 71 93 17 57 57 20 71 75 58 41 34 99 54 27 88 12 37 37 3 73 72 25 28 35 35 55 37 56 61 1 11 59 89 52 81 13 13 53 7 83 90 61 36 58 77 4 41 33 13 84", "100\ncabaabbacacabbbababcbcbccaccbcaabcbbcabbacccbacbaabbaccabcaccbaacacaaabbaababbcababcbcbacbcacbbccbaa\n68 65 4 76 17 74 33 92 47 72 10 17 20 4 20 57 99 47 7 17 32 46 8 47 89 75 33 27 64 74 36 90 62 77 23 62 35 68 82 80 55 29 53 41 26 81 75 90 65 97 90 15 43 55 31 48 69 86 43 15 23 21 1 23 93 53 93 88 47 22 13 61 69 98 54 69 87 7 23 70 29 40 50 41 85 79 14 44 44 46 27 59 65 89 81 52 39 53 45 7", "100\nbaaabbccbadabbaccdbbdacacaacbcccbbbacbabbaacabbbbaddaacbbdcdccaaddddbbadcddbbbabdccbcadbbdcaccabdbad\n76 26 64 3 47 52 77 89 81 23 38 18 27 57 17 96 72 29 84 39 89 80 54 90 66 28 19 45 35 16 44 96 55 39 73 3 5 8 57 44 38 27 5 22 9 67 37 14 91 6 94 13 82 48 87 3 30 17 32 99 40 38 65 45 58 48 44 86 69 45 63 68 46 24 43 75 73 1 8 85 56 87 34 74 38 73 38 25 65 38 6 6 75 96 25 98 30 21 97 74", "100\nbaccccbcbdcddcddbbdcacaddabdbaaaacbadabdbcbbababddadbacddabdcddbcaadadbcbdcdbabbbcbbbadadcaacdbaaacd\n49 100 65 90 73 14 68 48 5 94 21 91 99 7 45 57 13 82 48 95 91 66 56 28 46 22 87 56 29 34 88 2 60 74 23 7 92 25 16 13 4 76 16 29 67 33 16 13 76 24 8 35 13 45 61 35 28 24 16 69 29 48 13 33 58 89 88 37 14 90 3 3 86 83 62 80 11 48 66 63 78 68 83 67 42 51 34 12 6 100 44 7 100 36 32 45 28 37 29 85", "10\ncaabacddad\n86 47 85 37 79 63 55 19 62 27", "100\nadebebcdacabaadcbcdebcccdaadaeeedecdbcbdeddcbcaeedbecaeeabaabbdccaebdebabbabdcebbbdaabdbddcadaddadad\n52 62 28 18 100 84 16 53 43 52 49 92 10 64 50 95 90 52 21 14 60 3 94 63 31 70 74 62 93 75 100 96 58 36 76 40 62 74 91 77 92 78 65 11 50 18 79 29 10 25 4 24 44 39 4 91 81 63 97 65 50 65 77 51 19 87 43 31 40 8 57 14 67 17 47 94 96 46 59 69 96 11 75 100 87 36 70 1 22 92 31 50 2 35 68 95 19 96 89 52", "100\nebccbbebeeedaedeeaaeebcaabbebaceaaaccbddcbbaecddaadacbedbbbeeeddeaabbedecdaceaeeddeebdcdbdaeeacddabd\n21 36 34 1 18 50 15 12 68 24 37 57 83 18 78 60 36 13 90 69 53 85 4 96 7 72 34 86 91 90 45 2 58 83 26 36 53 95 46 42 50 26 72 21 9 89 53 20 87 51 23 58 70 32 83 19 83 70 85 35 39 83 32 43 27 25 99 90 84 58 98 45 8 80 59 100 39 93 9 47 14 92 32 85 95 14 71 84 60 54 64 51 31 75 80 43 25 13 13 67", "10\nbbddcaabcb\n26 91 79 74 6 80 78 77 80 72", "100\nbcddacdbcffebdbfbadbfbabfcfddddffbdfbdddcfecadafdeabfbcfbbfeeaecaaafefeeffaadbbbcfbebdabeefbeffaeadc\n24 97 93 28 45 24 55 9 5 70 65 55 98 67 83 95 13 83 67 88 22 18 46 39 84 21 21 92 62 39 57 8 60 41 79 81 20 47 29 5 41 25 16 7 91 70 16 45 21 48 27 44 1 26 30 75 36 9 62 32 56 92 84 61 84 27 54 84 7 72 44 48 89 5 47 6 20 92 6 53 41 31 20 14 45 8 99 69 80 46 48 94 41 78 16 92 8 76 73 38", "100\ndaebebaffffcbbacbccabeadaeeecffacdeffceafbdcdffbfbeabdafceaeaddcbeddbffcabaabacbdbfecfefcffadccabefa\n97 63 94 11 71 90 50 68 22 45 52 19 62 26 7 56 55 36 27 55 28 4 44 73 60 15 85 4 49 54 9 14 60 84 30 78 10 64 80 70 7 77 27 10 46 40 95 32 6 78 41 78 28 23 13 7 30 16 50 2 45 14 40 57 84 69 6 36 51 21 88 92 29 76 67 20 71 34 64 31 63 20 77 3 53 78 3 60 17 17 85 91 63 17 19 40 17 96 100 53", "10\nafbabeffdb\n77 35 69 7 17 1 92 32 98 20", "100\ndddfagdfaabgfebfccgfddbdfdfbcabbdbffeadbgefffcgadgffddefecacbacgaddeacebgagageefdfefebgbfbgeggdggaae\n97 25 58 38 97 60 94 65 68 4 80 25 81 74 8 94 32 18 8 66 85 37 94 8 50 64 71 22 20 99 13 16 54 42 79 18 73 4 64 38 87 75 75 96 36 22 61 52 32 75 42 63 63 17 56 63 91 55 35 94 66 18 4 79 49 67 61 33 78 43 38 90 7 2 56 26 48 29 53 33 81 63 68 40 94 72 27 40 49 9 68 46 72 21 64 90 97 59 52 16", "100\ngccacggcaecdebedbfeadceadaddagedeefdaecaggcdabacfegbdbacfefgbedebddbedgdcaadagagccgdgbfgabedbggdfcba\n78 99 63 21 16 22 85 32 84 75 60 86 42 37 40 59 73 66 69 29 90 23 91 38 26 61 32 29 14 13 66 21 62 94 29 19 68 25 19 7 53 24 82 98 95 92 40 55 17 1 64 89 89 14 30 91 81 58 23 60 55 41 51 63 49 4 10 85 22 89 79 34 47 65 71 39 95 75 7 15 3 44 26 25 2 46 28 28 87 71 6 36 98 64 71 38 6 80 88 35", "10\nccgccbdged\n17 78 59 44 44 10 15 90 20 65", "100\nadbgaebehfhffghahfgbgbghedgecaaafachecfgegbcebhbbffgdggbgghfdbebecaadfaaddbhgbgbfadddheedehgfhfcfagb\n85 61 23 48 50 100 33 29 26 22 87 95 61 81 40 94 46 37 54 44 47 61 42 85 7 10 18 40 86 59 70 27 52 52 82 63 30 74 2 67 36 34 27 92 77 74 99 71 43 2 56 87 32 8 86 46 46 93 1 53 76 53 7 85 18 99 60 83 45 7 29 28 28 98 64 41 76 74 3 17 29 87 5 62 56 31 52 12 7 63 89 82 8 68 3 87 90 43 36 98", "100\nahddfeaacehehhcfcdaccddgfddbdgchabhhgfdfbagabfdfdhhcbcgefdgbcddhdhbdcdfddcffgadfabgdchacbhbdeecacdeb\n54 39 24 35 65 66 32 88 43 97 71 64 33 44 64 54 88 97 10 3 48 42 39 14 79 4 78 59 76 73 22 33 61 91 33 60 21 95 53 35 98 75 38 91 36 44 81 62 24 28 75 9 50 1 56 78 36 4 89 27 73 68 63 73 18 44 13 38 93 52 69 76 65 57 84 51 23 21 54 99 47 68 62 51 60 9 60 100 44 26 26 84 29 7 18 35 95 63 72 21", "10\ncbhhcbehge\n56 18 50 82 55 27 33 44 38 10", "100\necffafibcdedacabcidegiecgfdabcbeedidebighfciafcebfddecdeigcbebhcdabdhadcbciadhhgigcgegabbhagcaeadgca\n57 96 87 63 95 37 72 81 85 51 7 61 40 93 73 93 65 67 87 18 17 80 90 53 68 53 65 69 40 23 26 39 55 53 86 96 88 35 28 91 89 81 86 81 15 25 44 82 58 29 75 98 90 99 7 34 93 39 74 19 82 80 23 95 87 35 71 36 7 75 23 74 46 83 68 53 8 19 50 1 66 7 54 88 5 3 88 88 65 22 10 26 43 7 55 84 79 22 28 84", "100\ndbbhgbhgicfdhcehfffhaiebcdicdggbecidcbecdihbdbeiaidiggihbfffecgddadgdgheadachaigccbdbbdbfeichehfihci\n31 74 93 49 18 3 71 44 5 23 82 26 12 43 97 66 7 24 56 82 15 65 87 83 44 51 33 81 42 37 78 41 63 96 28 1 78 52 87 60 56 25 93 79 73 95 23 73 39 55 97 28 16 92 82 62 95 50 62 89 79 2 78 91 87 84 24 87 60 24 64 6 86 46 80 67 51 66 9 75 88 96 11 73 9 81 85 68 2 80 47 28 68 50 58 28 84 39 56 3", "10\ndgfcifihdc\n100 70 48 19 78 45 56 98 64 63", "100\ncaeebfcicgjdfaagafcbbegghaigchaddifajfaadgedcgfdijajchhebbgccgiegaheeccejdhedajfadfaieegbigbajfejibj\n8 6 57 3 53 18 83 23 87 53 67 32 93 27 67 49 91 47 52 89 9 71 37 15 52 40 45 2 23 31 92 41 55 94 41 71 67 25 47 92 65 74 83 19 35 17 12 98 11 44 36 69 8 8 4 68 19 67 84 96 30 68 68 42 92 22 60 64 11 13 49 25 41 10 33 25 80 16 92 27 30 30 90 54 57 42 45 13 56 33 9 71 44 85 51 83 20 62 77 65", "100\ngeacehcgiidjfbdddeecbggfijfdehcbceiajghhehjiiefdcechfijccebhfchcbhgedgfgehcidhcbejbhbgicbdadbeejhfhd\n81 81 58 98 80 79 74 86 12 28 51 1 61 85 91 22 32 99 17 57 7 56 35 45 24 34 5 21 17 54 44 46 67 37 88 72 62 46 6 61 27 14 90 22 94 87 95 89 96 66 54 87 30 2 79 4 9 82 72 66 20 86 23 30 5 67 12 23 59 62 97 69 81 69 53 31 22 54 50 5 52 19 47 47 61 20 46 4 93 96 54 76 66 24 62 35 21 82 1 80", "10\naigfbdghac\n30 50 75 93 67 6 61 60 56 56", "100\nkjgfjaiegkcheceibggeffagekkjgfbhgegbdchidacfhjkihakciejkgheihbfiiigkfcdedjkdafagbgfiebbkeajeejeijhec\n84 42 18 17 10 58 22 83 46 75 83 99 72 30 100 61 10 77 90 75 76 90 85 91 5 83 91 31 85 95 56 48 53 99 45 12 25 86 81 21 10 24 43 7 85 69 58 9 30 71 54 89 62 95 34 59 73 17 57 63 40 3 76 48 61 62 67 13 78 80 43 71 58 99 42 33 4 61 39 15 78 58 38 80 15 14 82 81 17 88 26 23 79 24 2 80 9 37 60 47", "100\nbdbjgdgabbbkcebhjeikhdjbckabejahidcckjjeakbcfkedifddjeigddfhdjdkdjjkckhehbbiahejfickdedebkegjkkkjiga\n53 16 19 4 25 16 21 38 70 46 58 63 41 92 24 26 51 30 62 31 81 71 83 21 81 80 56 43 79 17 100 54 61 42 91 13 15 4 44 90 76 65 50 18 39 39 36 100 7 93 77 11 92 96 5 88 68 28 45 29 26 13 31 48 62 11 20 72 26 30 92 11 99 58 61 47 54 100 93 89 96 39 95 69 23 92 78 72 54 50 71 20 1 71 2 32 10 57 92 62", "10\nfabkafeicj\n70 98 70 22 86 23 88 15 74 100", "100\nacaliggfdidgfcdjdlglklgiigddbblcdhcagclfjlbfacgfalajccdaaeaigaghkdacjiecljchhiglbhfbhabdabkgabbcgfbi\n56 78 86 23 63 90 61 35 8 5 90 65 60 41 29 60 20 100 35 49 38 9 25 60 70 29 42 57 46 55 13 64 55 100 48 46 78 56 20 53 56 71 94 100 22 20 99 17 41 90 77 1 23 94 56 39 32 63 22 29 46 30 95 66 30 1 74 62 41 48 34 10 76 92 50 53 36 98 77 92 14 82 83 2 64 77 6 61 83 42 50 67 15 71 50 78 2 21 44 25", "100\nagcaklffhchjdiggfjeigjadbkeibibacadiebihgccljkgbkgffdhlhhfhijjjbjfikikjfdjcfldlhelefjiekkeidlglfcbia\n29 44 87 18 78 56 52 6 32 76 78 30 24 100 57 21 74 61 96 5 43 98 31 90 46 23 2 69 41 77 57 66 63 44 86 42 73 77 79 22 22 20 1 2 81 91 81 16 26 20 95 30 53 83 30 75 22 74 10 95 36 52 42 58 31 47 19 25 97 93 82 53 16 55 62 66 78 45 40 74 36 63 40 91 72 55 11 44 8 5 95 69 32 2 53 30 99 37 76 48", "10\nihhcegchje\n9 45 68 63 14 32 14 73 92 41", "100\nealhkjmlhihghiahefljahkihjkfckfccblijhddimjmciebmeecbfdjalmbicddfkmmhmljgkgjamilmadkgckkcidlgmkllcam\n33 5 47 38 8 26 100 3 70 35 10 39 39 48 53 60 43 31 81 27 100 28 73 37 24 72 89 75 4 15 69 72 57 10 44 87 35 25 54 82 9 22 53 88 63 68 44 40 52 17 88 20 92 77 73 31 79 1 87 87 52 56 99 76 91 37 81 15 8 12 25 52 98 80 46 68 60 40 32 76 63 6 28 28 22 41 35 28 40 1 67 11 42 13 89 79 91 4 28 15", "100\nkeccabkciaeigflgffeaefmicmhkihdkklhldmcijmjjkjfiibdmdeekgjfcgmalekaglhedlfbihgbagegbbmkmhcbmfhdkhacf\n10 79 48 29 30 88 91 58 95 6 85 100 12 11 81 24 93 84 37 79 2 21 71 67 100 74 57 98 98 41 13 74 58 49 90 87 30 42 17 51 79 70 60 99 22 42 15 27 38 43 6 50 19 70 60 55 77 12 75 53 42 79 54 60 96 75 30 75 56 61 77 87 46 51 70 78 2 94 87 58 85 95 89 17 30 15 39 20 77 59 12 5 71 45 1 27 88 25 60 26", "10\njljdgdlklc\n53 89 58 93 25 49 29 27 14 94", "100\njhjmkfbgehjcfldijgijlckjdkickikjlfmdaflbbblhcecjcmjggdhmjenbeikigfehaemnmlahmehbbemafjfalgffdfimjbme\n17 41 12 56 61 66 39 55 29 52 25 5 23 59 86 59 62 62 22 1 71 55 21 5 85 22 44 4 70 79 26 84 56 7 43 28 93 82 92 15 55 72 1 81 4 20 78 47 71 44 10 40 50 64 3 11 34 47 60 54 62 83 14 86 60 77 84 64 79 79 19 94 19 77 55 80 84 89 79 60 3 38 65 50 71 9 63 96 98 51 91 55 81 56 41 85 79 88 12 93", "100\nfbfjleaghhnibkgfagaaecfgegndidgliffdfbdkajcflajfalhmnmadgdkflbbdimnengldfcbaggahbkgcefdfhicmacbdjkgh\n90 15 17 39 71 32 30 18 53 28 1 70 91 10 10 20 11 18 79 57 68 41 19 35 65 12 4 16 68 1 70 89 56 46 93 29 83 4 43 75 25 21 20 87 55 94 56 42 49 62 25 61 76 61 82 47 32 62 49 20 52 6 69 78 61 18 37 28 27 29 68 30 68 36 74 94 34 35 37 34 21 15 26 39 79 87 68 88 35 26 33 53 99 92 40 32 77 8 44 4", "10\nkhkenaljlf\n88 29 49 34 52 70 51 85 28 39", "100\nbfhbfaokkkildhjgliejmbkokladgdleddhbmbaifooanfbflcikgmjjlkdieifbelhihdblfakhkaidnhdekfdblbelhcnlobcg\n89 76 77 66 2 2 74 15 91 86 33 68 2 70 19 58 76 97 56 75 33 74 73 82 42 69 90 34 28 38 82 91 58 16 46 69 54 52 26 47 4 19 64 69 49 72 23 59 78 71 25 59 11 55 25 95 89 93 26 16 72 10 26 100 22 17 87 13 45 47 10 36 41 73 63 4 16 34 22 44 40 62 14 68 32 72 96 76 59 13 8 100 12 95 88 78 68 63 100 83", "100\noogjlibiflmemkgkbnlhohemmfmdkiifofnihgndadjececkamlmlcfcmagccdjiolbmgcilkmngmhgakdahoekhkehnahhkadlc\n63 51 78 49 24 64 73 78 16 57 16 36 74 21 43 23 26 45 24 35 39 60 67 12 18 63 47 42 26 61 34 97 58 59 97 66 41 73 81 12 70 72 71 80 96 46 1 49 68 89 39 81 38 56 4 27 87 8 14 86 62 32 73 88 30 54 36 77 93 92 58 72 89 32 79 13 58 73 80 18 62 47 75 57 37 50 97 60 96 76 53 97 42 34 92 26 66 84 35 94", "10\noggdlibbii\n32 72 39 67 63 88 66 48 50 83", "100\nlnfilfbkmbpdfpkpanpdmbocnbnjllfepodgjpigngkmaobiaikmkiinchogopgelcnlheepfmbmmhmaifclikggooljcolcpjdf\n66 12 41 76 54 42 13 75 53 4 44 34 82 70 44 62 95 15 97 49 96 97 21 55 7 12 33 52 97 2 34 95 56 13 50 2 11 21 64 76 58 70 20 66 91 23 64 78 93 98 40 71 73 46 55 82 44 39 95 75 78 45 41 10 91 57 98 63 16 15 4 82 54 58 71 19 40 79 77 28 88 95 58 90 82 36 33 48 17 68 33 44 39 34 28 75 57 47 87 61", "100\nljpobnapiihcpannkdbdbcdcobkgdjpdchapdkoebipdnkmmkleipnipiencginckiggocjkmmmleojllfndhckmejffcdibembg\n39 86 46 63 69 8 8 38 78 79 28 7 54 32 76 19 45 68 66 9 1 83 15 85 84 5 97 72 84 24 91 1 60 65 96 7 94 42 16 45 20 18 31 68 45 97 43 69 79 16 62 1 99 43 29 10 46 46 83 41 68 59 92 98 91 94 43 22 64 64 53 14 3 21 83 29 90 22 27 2 6 67 15 79 86 14 29 27 50 30 74 45 69 81 35 23 55 67 19 72", "10\nmmojgklhgb\n72 16 29 8 82 5 88 98 68 32", "100\nqchhfaocnbignfamnmlgkgifcimjoloqjfebfkdcacjhchmmladcihiiaibfpbqegjlbnakbahqnbejbpgmjdpbqkgioiehdcqdf\n38 48 6 86 7 78 56 35 12 34 63 12 73 77 76 57 14 46 42 32 58 16 61 31 61 62 88 82 51 58 91 3 58 23 53 39 69 83 99 100 3 29 75 54 28 75 6 89 12 25 62 90 42 36 80 66 99 77 60 41 84 72 53 20 52 93 2 12 83 78 91 17 76 55 68 31 76 16 24 12 28 15 7 16 39 8 53 16 74 22 49 88 79 81 75 73 46 30 71 43", "100\ncccjqikgocbhqqabapmjbidalibmbpcbiqejqnickjokmqfkegafpjfgolplnlahpqjicfjhkhkchnfilcgfdmjbkniichojlooe\n19 14 7 69 26 40 47 90 40 5 43 73 33 40 100 22 59 3 7 91 60 98 55 61 41 56 44 93 53 84 43 9 59 66 99 44 51 4 50 69 73 69 82 65 83 49 84 80 86 43 81 16 56 30 55 98 93 92 48 7 74 94 100 16 52 34 54 75 31 28 43 60 24 18 87 45 14 63 78 86 46 91 64 1 43 86 50 3 11 89 95 89 4 20 83 21 48 47 3 54", "10\nlpfilflalm\n19 68 23 38 1 14 10 56 86 77", "100\noeqfroknnkrllpjdgoddflgecpkimoijhiceacnaoloilqagmoirchgjjcopgrgjbegpoqccicqdjfpaklfiacijbdjiikqkqmaa\n27 75 71 97 52 18 91 87 70 56 71 74 53 88 5 61 36 81 84 6 29 32 9 4 26 1 35 7 17 18 47 15 57 24 57 85 22 52 29 37 53 75 30 50 65 27 51 96 19 44 73 10 100 23 6 54 54 27 25 8 98 95 64 34 21 33 9 61 54 50 85 55 97 43 76 47 100 62 67 88 73 39 44 38 89 67 86 88 40 77 70 36 6 24 19 70 35 6 55 29", "100\needhjnnfpanpjcikblbnarprhrhjqeoqqgcqohfnfrpbfmiaqribpqqcbjelmknbbnibbmhqhqnjdmimahhkpgcrbedqjbjbdoii\n92 53 76 84 78 88 90 58 87 31 58 39 25 47 33 34 78 30 52 69 26 17 3 38 2 7 95 19 7 40 99 20 57 71 95 81 17 69 88 6 19 20 41 49 24 1 29 91 9 70 95 36 26 17 81 82 48 38 13 74 84 17 11 23 21 74 61 24 2 95 34 2 46 10 95 64 38 8 25 70 95 27 1 27 97 49 86 75 69 39 15 29 35 63 30 18 37 26 87 40", "10\nqjrifrkfbg\n63 7 14 79 20 31 33 10 9 26", "100\nfcrrgsbklknkqisnclphsgnoamneddiqnnqbcomjpnnqchgphjgiklabrmgbrckhdpedkrgalpbmoahqneesgkmbgiekarielrih\n99 11 36 11 1 54 30 55 32 85 86 41 32 95 30 64 51 4 25 80 91 55 57 73 83 51 90 37 78 82 4 22 51 29 60 26 79 17 63 70 98 26 94 39 6 78 92 12 34 71 95 21 57 14 24 38 9 73 98 62 4 26 79 40 90 73 16 14 13 13 76 97 27 40 80 66 24 7 22 72 13 71 93 64 46 39 14 64 1 31 91 84 49 67 67 68 28 89 47 12", "100\nllaghdksecpacjoqdlfoekkaajpejpqsnhskkkasqodrdcbgoplsnbkdpjjdsiepprpnabsglffflkkmsimkakjfkhpedninkjim\n72 89 37 2 19 20 28 10 49 57 66 5 4 50 66 29 97 60 94 43 97 36 51 7 60 45 42 49 73 4 56 28 59 68 98 23 70 42 22 30 68 63 1 46 65 49 75 7 20 97 10 55 87 11 7 70 99 84 87 32 93 44 23 33 90 10 60 73 69 59 24 40 68 99 100 72 74 54 72 54 31 48 46 49 54 13 19 47 38 94 36 74 74 10 74 15 34 10 66 22", "10\nqjqepaqjrc\n2 51 12 8 47 48 47 69 31 67", "100\ndegqiqqsppfhidrmerftiignrihnsdooflhaonjtcdiofhjrntcifdbpgsoqrcgpllbfilejbblgkrfaakdoqqbfksiipsjlqqfi\n74 8 48 17 23 12 46 40 54 33 32 97 52 59 28 3 47 15 8 94 95 65 67 91 42 96 56 100 45 83 98 41 2 40 38 54 88 76 16 62 13 85 86 78 6 96 7 75 41 63 66 92 97 79 40 70 30 55 50 85 53 19 56 46 41 74 19 20 61 53 93 74 100 22 47 64 27 66 62 49 18 87 87 62 35 51 37 50 22 71 10 100 79 84 3 85 40 81 92 39", "100\nlilbbnecoretoaanhaharbpqoaikpnriehqaaigjtsniclfblkqageojndfmilbngmkfhfblqmhmgakipgjslmemabgfcdsrettm\n55 82 49 12 46 70 45 3 79 4 16 69 24 9 64 64 89 64 77 62 100 58 65 25 22 90 24 8 31 10 50 47 2 83 92 63 79 97 75 27 68 21 93 80 64 66 86 74 23 81 84 18 24 84 15 98 24 66 38 56 38 41 12 39 46 15 72 75 9 11 33 9 48 89 63 77 69 13 24 23 36 76 36 59 39 17 33 37 59 37 48 2 9 27 10 33 38 6 24 50", "10\ntaoqkbocpc\n29 14 83 94 69 16 18 4 49 46", "100\nfekusmuhtflqkbhbcbadjtsaqhnfdqonsmunndlaftfdfibcuiqdabohaujklkhfttknjefjksnktfkekgkrrcodquqcttnqkeiq\n54 43 13 35 76 48 81 100 17 59 52 71 35 66 57 2 62 38 49 73 61 88 15 68 99 47 11 26 3 47 54 53 96 41 41 99 42 46 50 87 59 27 41 62 55 47 44 95 48 90 80 11 59 78 58 50 85 5 23 52 63 46 76 56 98 14 26 65 28 25 87 8 21 15 51 83 51 11 16 33 55 19 23 88 85 14 61 22 88 33 27 48 19 31 50 82 29 69 75 17", "100\nsdsahsjliuojtidnhauithsrrmseagoiijjsulhblbnblhisodfircuaefgqbemhgmfiigekkuorqantauijtagssflkmmeokuqm\n27 9 14 22 91 10 76 63 41 34 27 36 3 20 89 67 8 99 14 36 62 81 13 1 75 41 67 37 1 70 6 55 4 93 92 96 37 67 13 52 25 68 52 77 13 18 31 86 38 8 95 37 85 71 37 90 75 12 11 18 48 68 23 49 7 55 75 20 72 78 28 52 70 82 67 89 93 58 63 7 77 96 80 77 97 88 70 9 17 96 64 46 44 70 50 30 27 89 7 32", "10\ngterthaonk\n73 58 73 27 84 37 40 66 71 94", "100\novkihhgldgfmibpnlptjcgrtgbcrleflheanrmvteivsrvenrvrugggfvhfbnnachgddvlojtsjtmnmgpfbugvltfjhbngotjagd\n34 71 77 50 21 88 24 60 79 84 59 33 15 65 89 2 81 69 91 47 23 7 55 36 60 89 58 47 69 7 18 64 94 51 45 36 99 15 88 15 4 78 5 58 96 99 90 2 63 8 99 27 28 65 84 41 32 51 88 18 69 81 79 66 68 54 29 18 98 89 78 50 43 11 56 91 79 57 59 10 3 43 72 10 42 74 94 98 45 87 52 93 46 74 98 88 18 52 59 95", "100\nmqumjalldekakrqjhrvqomtstthcnmsnusfvfopiohggmlkpdqdkidupkaotgurecjohsthgiaorqafmctuitrnbdujekprnjtqd\n4 45 78 33 43 46 15 23 4 56 43 2 87 28 21 63 22 21 59 10 29 100 61 70 40 91 18 67 55 29 63 66 7 90 83 37 90 36 47 84 70 27 8 61 55 69 68 97 49 35 17 57 54 58 58 65 30 58 76 84 58 95 35 59 68 91 82 69 42 42 18 94 87 74 71 9 25 3 18 92 17 20 29 99 46 52 94 81 82 50 85 90 75 17 1 35 16 73 91 18", "10\nnujfpdhamo\n20 2 63 68 7 46 54 17 89 35", "100\ngselleupvmwtigmmjjctmvawlnscmoodqpidohgcfqcoavtvjsnbtfcgibcngrrkbduuuklwlqcguqmamhbduminclasseomtoun\n7 6 42 56 70 25 63 20 42 10 71 99 94 76 14 1 99 100 32 21 94 30 3 13 17 40 9 73 26 67 75 72 97 56 40 77 52 76 23 52 54 29 52 47 33 51 35 13 78 35 22 46 86 56 10 21 87 89 53 77 75 8 95 76 37 94 32 67 65 52 68 92 64 100 64 11 11 2 6 94 43 67 17 36 91 46 18 66 3 42 68 41 81 17 37 85 7 36 39 85", "100\natgmmdpwlqtlwojdfaudwllahadnbruidpovejfpahttggnpghtvlgqoumssipncrowwftrbloqbkumsftnubijwcbpoanhchkwu\n88 80 43 43 88 87 54 75 66 85 58 64 62 39 50 66 45 52 5 84 87 15 1 47 6 30 65 85 21 89 19 78 5 95 86 74 47 97 86 21 16 77 63 58 92 21 14 12 56 62 36 68 12 45 84 57 85 96 41 43 64 30 50 73 37 31 89 23 9 10 9 36 5 63 84 24 49 48 64 76 61 52 74 25 4 24 27 57 40 4 5 34 3 60 41 33 9 52 75 100", "10\nroacnkpldg\n64 53 53 2 30 63 81 79 7 84", "100\nklpftlppaerfaqmhfafthvnuptjomiaejcbtfwsejksngtabnablefgxirtkfbcfacogolqwkawutbxadqarbxcaaijlodgtgdog\n83 42 7 70 23 65 98 72 100 40 86 78 86 83 47 5 18 22 78 7 52 53 51 82 83 79 55 3 92 31 27 84 99 57 44 23 10 46 61 77 7 75 16 39 74 3 80 37 89 58 28 66 43 39 39 13 42 35 26 39 81 31 6 95 2 30 44 16 36 20 63 34 86 96 68 34 30 47 53 78 80 95 66 58 49 9 55 37 60 96 89 77 16 60 89 82 96 12 31 63", "100\nsxatqdotddqukjhmighutxddqloluxtkusflwjqtouxesplvpclpkkwspwcgvsjdxxxrfbfajqbclxemvakrixwwwkdpniebswvg\n60 16 8 57 41 23 97 43 25 11 66 38 46 46 75 73 64 83 42 58 58 34 49 15 55 80 12 14 82 53 75 90 7 96 90 19 4 67 12 45 65 28 19 46 29 73 59 23 79 80 50 88 73 40 10 37 40 46 15 9 70 53 54 79 2 71 88 72 80 77 3 70 27 55 80 36 85 90 7 52 2 72 15 47 57 83 51 25 1 59 26 78 42 91 88 30 98 32 59 78", "10\nxvugurpobl\n3 93 52 39 45 80 99 41 33 29", "100\nxjapcegkgtabkhmfcggmqttvxelnvorbuvhyssftxsjlveftfhuuvxdjvvnlnemmopkolcljibvhxdyyonynhgaguovxxjydgroo\n64 78 72 80 68 1 37 40 62 62 93 40 61 94 80 100 33 53 23 81 19 72 3 58 36 29 98 25 50 91 84 92 1 62 47 52 67 15 95 9 53 26 71 28 24 50 18 44 4 85 51 85 4 33 61 93 97 81 92 6 94 61 22 1 67 74 43 70 95 87 53 77 8 81 69 42 62 84 4 62 28 20 99 76 98 73 87 5 22 51 10 25 51 3 36 76 89 91 19 53", "100\nbdhnnkoxmwsxaxgwykdphvdefqhmfjsvpeqacsrjuixikfnngcmwoodtersdarwtyfuiklorgfsmepthgtmhrubcymjhfqmsxkkb\n37 52 73 63 94 63 32 95 87 37 85 9 33 45 8 73 82 6 80 37 24 58 97 92 20 19 66 40 48 13 36 97 9 6 93 53 58 32 46 74 19 75 82 39 74 24 96 35 86 7 69 7 31 31 36 29 91 92 80 76 84 80 73 89 67 11 99 21 47 41 94 12 48 56 88 60 5 31 54 36 46 100 60 73 14 51 84 97 59 13 47 22 73 38 40 24 87 15 50 68", "10\nhqdoyutwyj\n39 37 42 72 68 97 22 87 51 69", "100\ndoreokncntzjcupgknnzekjpggwljnbvdhlemfldzputshtaxuizswyareobpngbsxfgljvilaxijygemqmoauuhhmridjrbzvfk\n40 13 36 91 24 33 80 92 25 91 13 6 44 98 13 12 47 84 61 55 81 91 51 35 1 72 53 50 19 50 40 3 95 64 46 93 28 76 33 42 2 85 26 20 57 2 63 55 19 12 69 97 74 24 79 72 56 27 65 72 100 96 25 11 36 2 54 19 66 55 44 19 29 77 77 62 90 29 47 46 69 44 47 98 56 41 8 81 75 5 30 69 83 49 76 73 82 79 2 32", "100\nrnbmepccstmpkhsnymuuuauhbtxercmqqwuqgosdwtdafvkcfnqnhjqajldxjohjrlbjcrjvuvwdzxlyxuzsnqykqxxwlakdvahf\n9 79 37 86 39 95 71 55 49 63 92 71 13 56 41 76 97 41 21 15 87 77 45 69 78 70 9 62 6 73 92 9 96 7 97 90 15 93 84 7 68 25 29 27 16 76 42 46 97 34 84 27 96 13 65 8 46 30 53 38 90 7 81 7 36 47 6 74 10 12 88 54 70 40 92 75 29 76 9 20 87 28 8 87 64 23 8 64 16 76 67 75 8 81 83 21 79 99 34 47", "10\npogfjssywv\n83 76 36 1 83 14 44 49 73 22", "10\nababbbaaab\n2 1 1 1 2 2 2 1 1 1", "10\nadbccdcaca\n3 3 3 1 4 1 3 4 5 3", "10\nadaecdbeec\n1 2 2 2 2 2 2 1 2 1", "10\ndacaccddde\n4 5 5 1 3 5 5 5 5 4", "10\ndbdebedfdc\n2 2 1 1 1 1 2 2 1 1", "10\ndcedcffbfd\n3 4 3 3 3 1 4 4 5 4", "10\ncdeacbbdcb\n2 2 2 2 1 1 1 2 2 1", "10\nafefedgebc\n4 3 3 3 2 4 1 1 3 3", "10\nhafhfdcfbd\n1 2 1 1 1 1 1 1 1 1", "10\nhgcafgabef\n1 2 1 3 2 5 3 5 3 4", "10\ncabgcdaegf\n2 1 2 2 2 2 1 1 2 1", "10\naeddcccegh\n2 2 3 4 5 3 5 2 3 4", "10\nijjfjiahce\n1 1 1 2 1 1 2 2 1 1", "10\nadiedbcbgb\n1 5 4 3 2 5 4 4 1 2", "10\ndghgjfkddi\n2 2 2 1 2 2 2 2 2 1", "10\njdcbjeidee\n2 4 2 3 3 4 1 3 2 1", "10\nhdieiihkcd\n1 2 1 2 2 2 2 2 1 1", "10\nhajbjgjcfk\n5 4 4 3 5 4 3 4 2 1", "10\naelglcjlll\n2 2 2 1 2 1 2 1 2 1", "10\nijambflljl\n1 3 4 4 2 5 5 3 4 1", "10\nhgcbafgfff\n1 1 1 1 1 1 1 1 1 1", "10\njgneghedig\n4 3 1 5 5 3 1 5 5 5", "10\ndninghgoeo\n2 1 2 2 1 1 1 2 2 1", "10\namklleahme\n5 4 4 1 1 4 1 3 2 1", "10\nkgbkloodei\n1 1 1 1 1 2 1 2 1 1", "10\nklolmjmpgl\n1 3 3 2 3 3 3 1 3 1", "10\nambqhimjpp\n2 1 2 2 2 2 1 2 2 1", "10\nlqobdfadbc\n4 1 1 2 4 3 5 4 4 2", "10\nkprqbgdere\n1 2 1 1 2 2 2 1 2 1", "10\nmlgnrefmnl\n5 1 4 3 1 2 1 1 1 3", "10\nkoomdonsge\n2 2 2 2 2 1 2 1 1 1", "10\nrehnprefra\n3 3 3 2 4 2 4 5 1 3", "10\nsjjndgohos\n1 2 2 1 2 1 2 2 1 2", "10\nogggmeqlef\n5 4 5 1 4 2 1 2 5 4", "10\nsabqfmegtd\n2 2 1 2 1 1 2 2 2 2", "10\nchqsbejbfe\n5 5 2 3 5 2 3 1 2 4", "10\nvbaulnfvbs\n1 2 2 1 1 2 2 2 2 2", "10\ncqeoetddrd\n3 3 2 3 2 1 1 2 3 4", "10\noprburkdvg\n2 1 1 2 1 2 1 1 1 2", "10\nhvrcowvwri\n4 3 5 3 4 1 4 1 3 4", "10\nrusgkmmixt\n1 1 2 2 2 1 1 1 2 2", "10\njrhxthkmso\n1 3 3 4 1 1 2 3 1 1", "10\njxymsqowvh\n2 1 1 1 2 1 1 1 1 2", "10\nokcdifchye\n5 4 2 4 3 5 4 1 1 2", "10\ncaezgakpiw\n1 1 2 2 2 1 1 2 2 2", "10\nlbtsfgylki\n5 3 5 5 1 5 1 3 3 2", "8\ncdcddcda\n4 1 4 1 4 3 9 6"], "outputs": ["8", "26", "17", "4382", "4494", "4540", "4466", "4425", "486", "5112", "4758", "631", "4486", "4044", "448", "5144", "4651", "373", "4956", "4813", "359", "5234", "5375", "641", "4555", "5009", "554", "5128", "4985", "646", "5089", "4961", "369", "4597", "5345", "492", "5174", "4378", "525", "5115", "5369", "608", "5301", "4866", "498", "5046", "5221", "392", "4895", "4574", "292", "4938", "4635", "382", "5419", "4671", "422", "4867", "4763", "623", "5552", "5119", "401", "4936", "4862", "516", "5145", "4850", "514", "5401", "5196", "584", "4957", "5072", "481", "11", "26", "17", "38", "14", "30", "16", "25", "9", "25", "16", "28", "13", "31", "18", "25", "13", "35", "14", "28", "10", "35", "15", "23", "12", "23", "17", "30", "15", "22", "16", "30", "14", "33", "17", "32", "14", "24", "14", "32", "15", "20", "13", "31", "16", "33", "23"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 2 | codeforces |
|
fab2904a98f86333c60dab6a407ca40b | Coloring a Tree | You are given a rooted tree with *n* vertices. The vertices are numbered from 1 to *n*, the root is the vertex number 1.
Each vertex has a color, let's denote the color of vertex *v* by *c**v*. Initially *c**v*<==<=0.
You have to color the tree into the given colors using the smallest possible number of steps. On each step you can choose a vertex *v* and a color *x*, and then color all vectices in the subtree of *v* (including *v* itself) in color *x*. In other words, for every vertex *u*, such that the path from root to *u* passes through *v*, set *c**u*<==<=*x*.
It is guaranteed that you have to color each vertex in a color different from 0.
You can learn what a rooted tree is using the link: [https://en.wikipedia.org/wiki/Tree_(graph_theory)](https://en.wikipedia.org/wiki/Tree_(graph_theory)).
The first line contains a single integer *n* (2<=≤<=*n*<=≤<=104) — the number of vertices in the tree.
The second line contains *n*<=-<=1 integers *p*2,<=*p*3,<=...,<=*p**n* (1<=≤<=*p**i*<=<<=*i*), where *p**i* means that there is an edge between vertices *i* and *p**i*.
The third line contains *n* integers *c*1,<=*c*2,<=...,<=*c**n* (1<=≤<=*c**i*<=≤<=*n*), where *c**i* is the color you should color the *i*-th vertex into.
It is guaranteed that the given graph is a tree.
Print a single integer — the minimum number of steps you have to perform to color the tree into given colors.
Sample Input
6
1 2 2 1 5
2 1 1 1 1 1
7
1 1 2 3 1 4
3 3 1 1 1 2 3
Sample Output
3
5
| {"inputs": ["6\n1 2 2 1 5\n2 1 1 1 1 1", "7\n1 1 2 3 1 4\n3 3 1 1 1 2 3", "2\n1\n2 2", "3\n1 1\n2 2 2", "4\n1 2 1\n1 2 3 4", "4\n1 2 3\n4 1 2 4", "5\n1 2 1 4\n1 1 1 2 2", "3\n1 2\n2 1 1", "4\n1 1 1\n3 1 3 1", "4\n1 1 2\n4 1 4 1", "4\n1 2 2\n3 1 2 3", "3\n1 1\n1 2 2"], "outputs": ["3", "5", "1", "1", "4", "4", "2", "2", "3", "2", "4", "3"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 136 | codeforces |
|
fb0053531c0e388ce49fc51a56856d5c | Coprime Arrays | Let's call an array *a* of size *n* coprime iff *gcd*(*a*1,<=*a*2,<=...,<=*a**n*)<==<=1, where *gcd* is the greatest common divisor of the arguments.
You are given two numbers *n* and *k*. For each *i* (1<=≤<=*i*<=≤<=*k*) you have to determine the number of coprime arrays *a* of size *n* such that for every *j* (1<=≤<=*j*<=≤<=*n*) 1<=≤<=*a**j*<=≤<=*i*. Since the answers can be very large, you have to calculate them modulo 109<=+<=7.
The first line contains two integers *n* and *k* (1<=≤<=*n*,<=*k*<=≤<=2·106) — the size of the desired arrays and the maximum upper bound on elements, respectively.
Since printing 2·106 numbers may take a lot of time, you have to output the answer in such a way:
Let *b**i* be the number of coprime arrays with elements in range [1,<=*i*], taken modulo 109<=+<=7. You have to print , taken modulo 109<=+<=7. Here denotes bitwise xor operation (^ in C++ or Java, xor in Pascal).
Sample Input
3 4
2000000 8
Sample Output
82
339310063
| {"inputs": ["3 4", "2000000 8", "1000 1000", "400000 400000", "1000 2000", "400000 800000", "1000 3000", "400000 1200000", "1000 4000", "400000 1600000", "1000 5000", "400000 2000000", "2000 1000", "800000 400000", "2000 2000", "800000 800000", "2000 3000", "800000 1200000", "2000 4000", "800000 1600000", "2000 5000", "800000 2000000", "3000 1000", "1200000 400000", "3000 2000", "1200000 800000", "3000 3000", "1200000 1200000", "3000 4000", "1200000 1600000", "3000 5000", "1200000 2000000", "4000 1000", "1600000 400000", "4000 2000", "1600000 800000", "4000 3000", "1600000 1200000", "4000 4000", "1600000 1600000", "4000 5000", "1600000 2000000", "5000 1000", "2000000 400000", "5000 2000", "2000000 800000", "5000 3000", "2000000 1200000", "5000 4000", "2000000 1600000", "5000 5000", "2000000 2000000", "1 1", "1 2000000", "2000000 1"], "outputs": ["82", "339310063", "293255159", "641589365", "946090030", "700177418", "599681537", "599314521", "369962559", "383930351", "792761486", "581254555", "895983599", "194918098", "993145929", "959396582", "801808235", "456936609", "531261925", "58127171", "460721768", "607152577", "547188062", "535771854", "612556768", "925258449", "113732600", "468573037", "81501584", "549284678", "674745410", "340808789", "312642124", "180485439", "467116350", "990942172", "441359443", "186789429", "927028696", "373782836", "107116959", "160805957", "834732252", "313670498", "273324715", "204745061", "649058184", "749062788", "332100759", "267687597", "785334012", "219072617", "0", "986000", "0"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 3 | codeforces |
|
fb0ee76ebf2e3c8996349f51635551f9 | Heads or Tails | Petya and Vasya are tossing a coin. Their friend Valera is appointed as a judge. The game is very simple. First Vasya tosses a coin *x* times, then Petya tosses a coin *y* times. If the tossing player gets head, he scores one point. If he gets tail, nobody gets any points. The winner is the player with most points by the end of the game. If boys have the same number of points, the game finishes with a draw.
At some point, Valera lost his count, and so he can not say exactly what the score is at the end of the game. But there are things he remembers for sure. He remembers that the entire game Vasya got heads at least *a* times, and Petya got heads at least *b* times. Moreover, he knows that the winner of the game was Vasya. Valera wants to use this information to know every possible outcome of the game, which do not contradict his memories.
The single line contains four integers *x*,<=*y*,<=*a*,<=*b* (1<=≤<=*a*<=≤<=*x*<=≤<=100,<=1<=≤<=*b*<=≤<=*y*<=≤<=100). The numbers on the line are separated by a space.
In the first line print integer *n* — the number of possible outcomes of the game. Then on *n* lines print the outcomes. On the *i*-th line print a space-separated pair of integers *c**i*, *d**i* — the number of heads Vasya and Petya got in the *i*-th outcome of the game, correspondingly. Print pairs of integers (*c**i*,<=*d**i*) in the strictly increasing order.
Let us remind you that the pair of numbers (*p*1,<=*q*1) is less than the pair of numbers (*p*2,<=*q*2), if *p*1<=<<=*p*2, or *p*1<==<=*p*2 and also *q*1<=<<=*q*2.
Sample Input
3 2 1 1
2 4 2 2
Sample Output
3
2 1
3 1
3 2
0
| {"inputs": ["3 2 1 1", "2 4 2 2", "1 1 1 1", "4 5 2 3", "10 6 3 4", "10 10 1 1", "9 7 4 7", "5 5 3 2", "10 10 1 1", "20 10 1 8", "10 20 4 6", "50 50 1 30", "60 50 30 40", "100 100 1 1", "100 99 10 13", "99 100 20 7", "100 90 100 83", "80 100 1 50", "100 39 70 5", "70 80 30 80", "100 100 1 1", "100 100 100 5", "99 99 1 1"], "outputs": ["3\n2 1\n3 1\n3 2", "0", "0", "1\n4 3", "15\n5 4\n6 4\n6 5\n7 4\n7 5\n7 6\n8 4\n8 5\n8 6\n9 4\n9 5\n9 6\n10 4\n10 5\n10 6", "45\n2 1\n3 1\n3 2\n4 1\n4 2\n4 3\n5 1\n5 2\n5 3\n5 4\n6 1\n6 2\n6 3\n6 4\n6 5\n7 1\n7 2\n7 3\n7 4\n7 5\n7 6\n8 1\n8 2\n8 3\n8 4\n8 5\n8 6\n8 7\n9 1\n9 2\n9 3\n9 4\n9 5\n9 6\n9 7\n9 8\n10 1\n10 2\n10 3\n10 4\n10 5\n10 6\n10 7\n10 8\n10 9", "2\n8 7\n9 7", "6\n3 2\n4 2\n4 3\n5 2\n5 3\n5 4", "45\n2 1\n3 1\n3 2\n4 1\n4 2\n4 3\n5 1\n5 2\n5 3\n5 4\n6 1\n6 2\n6 3\n6 4\n6 5\n7 1\n7 2\n7 3\n7 4\n7 5\n7 6\n8 1\n8 2\n8 3\n8 4\n8 5\n8 6\n8 7\n9 1\n9 2\n9 3\n9 4\n9 5\n9 6\n9 7\n9 8\n10 1\n10 2\n10 3\n10 4\n10 5\n10 6\n10 7\n10 8\n10 9", "33\n9 8\n10 8\n10 9\n11 8\n11 9\n11 10\n12 8\n12 9\n12 10\n13 8\n13 9\n13 10\n14 8\n14 9\n14 10\n15 8\n15 9\n15 10\n16 8\n16 9\n16 10\n17 8\n17 9\n17 10\n18 8\n18 9\n18 10\n19 8\n19 9\n19 10\n20 8\n20 9\n20 10", "10\n7 6\n8 6\n8 7\n9 6\n9 7\n9 8\n10 6\n10 7\n10 8\n10 9", "210\n31 30\n32 30\n32 31\n33 30\n33 31\n33 32\n34 30\n34 31\n34 32\n34 33\n35 30\n35 31\n35 32\n35 33\n35 34\n36 30\n36 31\n36 32\n36 33\n36 34\n36 35\n37 30\n37 31\n37 32\n37 33\n37 34\n37 35\n37 36\n38 30\n38 31\n38 32\n38 33\n38 34\n38 35\n38 36\n38 37\n39 30\n39 31\n39 32\n39 33\n39 34\n39 35\n39 36\n39 37\n39 38\n40 30\n40 31\n40 32\n40 33\n40 34\n40 35\n40 36\n40 37\n40 38\n40 39\n41 30\n41 31\n41 32\n41 33\n41 34\n41 35\n41 36\n41 37\n41 38\n41 39\n41 40\n42 30\n42 31\n42 32\n42 33\n42 34\n42 35\n42...", "165\n41 40\n42 40\n42 41\n43 40\n43 41\n43 42\n44 40\n44 41\n44 42\n44 43\n45 40\n45 41\n45 42\n45 43\n45 44\n46 40\n46 41\n46 42\n46 43\n46 44\n46 45\n47 40\n47 41\n47 42\n47 43\n47 44\n47 45\n47 46\n48 40\n48 41\n48 42\n48 43\n48 44\n48 45\n48 46\n48 47\n49 40\n49 41\n49 42\n49 43\n49 44\n49 45\n49 46\n49 47\n49 48\n50 40\n50 41\n50 42\n50 43\n50 44\n50 45\n50 46\n50 47\n50 48\n50 49\n51 40\n51 41\n51 42\n51 43\n51 44\n51 45\n51 46\n51 47\n51 48\n51 49\n51 50\n52 40\n52 41\n52 42\n52 43\n52 44\n52 45\n52...", "4950\n2 1\n3 1\n3 2\n4 1\n4 2\n4 3\n5 1\n5 2\n5 3\n5 4\n6 1\n6 2\n6 3\n6 4\n6 5\n7 1\n7 2\n7 3\n7 4\n7 5\n7 6\n8 1\n8 2\n8 3\n8 4\n8 5\n8 6\n8 7\n9 1\n9 2\n9 3\n9 4\n9 5\n9 6\n9 7\n9 8\n10 1\n10 2\n10 3\n10 4\n10 5\n10 6\n10 7\n10 8\n10 9\n11 1\n11 2\n11 3\n11 4\n11 5\n11 6\n11 7\n11 8\n11 9\n11 10\n12 1\n12 2\n12 3\n12 4\n12 5\n12 6\n12 7\n12 8\n12 9\n12 10\n12 11\n13 1\n13 2\n13 3\n13 4\n13 5\n13 6\n13 7\n13 8\n13 9\n13 10\n13 11\n13 12\n14 1\n14 2\n14 3\n14 4\n14 5\n14 6\n14 7\n14 8\n14 9\n14 10\n14 11\n...", "3828\n14 13\n15 13\n15 14\n16 13\n16 14\n16 15\n17 13\n17 14\n17 15\n17 16\n18 13\n18 14\n18 15\n18 16\n18 17\n19 13\n19 14\n19 15\n19 16\n19 17\n19 18\n20 13\n20 14\n20 15\n20 16\n20 17\n20 18\n20 19\n21 13\n21 14\n21 15\n21 16\n21 17\n21 18\n21 19\n21 20\n22 13\n22 14\n22 15\n22 16\n22 17\n22 18\n22 19\n22 20\n22 21\n23 13\n23 14\n23 15\n23 16\n23 17\n23 18\n23 19\n23 20\n23 21\n23 22\n24 13\n24 14\n24 15\n24 16\n24 17\n24 18\n24 19\n24 20\n24 21\n24 22\n24 23\n25 13\n25 14\n25 15\n25 16\n25 17\n25 18\n2...", "4200\n20 7\n20 8\n20 9\n20 10\n20 11\n20 12\n20 13\n20 14\n20 15\n20 16\n20 17\n20 18\n20 19\n21 7\n21 8\n21 9\n21 10\n21 11\n21 12\n21 13\n21 14\n21 15\n21 16\n21 17\n21 18\n21 19\n21 20\n22 7\n22 8\n22 9\n22 10\n22 11\n22 12\n22 13\n22 14\n22 15\n22 16\n22 17\n22 18\n22 19\n22 20\n22 21\n23 7\n23 8\n23 9\n23 10\n23 11\n23 12\n23 13\n23 14\n23 15\n23 16\n23 17\n23 18\n23 19\n23 20\n23 21\n23 22\n24 7\n24 8\n24 9\n24 10\n24 11\n24 12\n24 13\n24 14\n24 15\n24 16\n24 17\n24 18\n24 19\n24 20\n24 21\n24 22\n24...", "8\n100 83\n100 84\n100 85\n100 86\n100 87\n100 88\n100 89\n100 90", "465\n51 50\n52 50\n52 51\n53 50\n53 51\n53 52\n54 50\n54 51\n54 52\n54 53\n55 50\n55 51\n55 52\n55 53\n55 54\n56 50\n56 51\n56 52\n56 53\n56 54\n56 55\n57 50\n57 51\n57 52\n57 53\n57 54\n57 55\n57 56\n58 50\n58 51\n58 52\n58 53\n58 54\n58 55\n58 56\n58 57\n59 50\n59 51\n59 52\n59 53\n59 54\n59 55\n59 56\n59 57\n59 58\n60 50\n60 51\n60 52\n60 53\n60 54\n60 55\n60 56\n60 57\n60 58\n60 59\n61 50\n61 51\n61 52\n61 53\n61 54\n61 55\n61 56\n61 57\n61 58\n61 59\n61 60\n62 50\n62 51\n62 52\n62 53\n62 54\n62 55\n62...", "1085\n70 5\n70 6\n70 7\n70 8\n70 9\n70 10\n70 11\n70 12\n70 13\n70 14\n70 15\n70 16\n70 17\n70 18\n70 19\n70 20\n70 21\n70 22\n70 23\n70 24\n70 25\n70 26\n70 27\n70 28\n70 29\n70 30\n70 31\n70 32\n70 33\n70 34\n70 35\n70 36\n70 37\n70 38\n70 39\n71 5\n71 6\n71 7\n71 8\n71 9\n71 10\n71 11\n71 12\n71 13\n71 14\n71 15\n71 16\n71 17\n71 18\n71 19\n71 20\n71 21\n71 22\n71 23\n71 24\n71 25\n71 26\n71 27\n71 28\n71 29\n71 30\n71 31\n71 32\n71 33\n71 34\n71 35\n71 36\n71 37\n71 38\n71 39\n72 5\n72 6\n72 7\n72 8\n7...", "0", "4950\n2 1\n3 1\n3 2\n4 1\n4 2\n4 3\n5 1\n5 2\n5 3\n5 4\n6 1\n6 2\n6 3\n6 4\n6 5\n7 1\n7 2\n7 3\n7 4\n7 5\n7 6\n8 1\n8 2\n8 3\n8 4\n8 5\n8 6\n8 7\n9 1\n9 2\n9 3\n9 4\n9 5\n9 6\n9 7\n9 8\n10 1\n10 2\n10 3\n10 4\n10 5\n10 6\n10 7\n10 8\n10 9\n11 1\n11 2\n11 3\n11 4\n11 5\n11 6\n11 7\n11 8\n11 9\n11 10\n12 1\n12 2\n12 3\n12 4\n12 5\n12 6\n12 7\n12 8\n12 9\n12 10\n12 11\n13 1\n13 2\n13 3\n13 4\n13 5\n13 6\n13 7\n13 8\n13 9\n13 10\n13 11\n13 12\n14 1\n14 2\n14 3\n14 4\n14 5\n14 6\n14 7\n14 8\n14 9\n14 10\n14 11\n...", "95\n100 5\n100 6\n100 7\n100 8\n100 9\n100 10\n100 11\n100 12\n100 13\n100 14\n100 15\n100 16\n100 17\n100 18\n100 19\n100 20\n100 21\n100 22\n100 23\n100 24\n100 25\n100 26\n100 27\n100 28\n100 29\n100 30\n100 31\n100 32\n100 33\n100 34\n100 35\n100 36\n100 37\n100 38\n100 39\n100 40\n100 41\n100 42\n100 43\n100 44\n100 45\n100 46\n100 47\n100 48\n100 49\n100 50\n100 51\n100 52\n100 53\n100 54\n100 55\n100 56\n100 57\n100 58\n100 59\n100 60\n100 61\n100 62\n100 63\n100 64\n100 65\n100 66\n100 67\n100 68\n...", "4851\n2 1\n3 1\n3 2\n4 1\n4 2\n4 3\n5 1\n5 2\n5 3\n5 4\n6 1\n6 2\n6 3\n6 4\n6 5\n7 1\n7 2\n7 3\n7 4\n7 5\n7 6\n8 1\n8 2\n8 3\n8 4\n8 5\n8 6\n8 7\n9 1\n9 2\n9 3\n9 4\n9 5\n9 6\n9 7\n9 8\n10 1\n10 2\n10 3\n10 4\n10 5\n10 6\n10 7\n10 8\n10 9\n11 1\n11 2\n11 3\n11 4\n11 5\n11 6\n11 7\n11 8\n11 9\n11 10\n12 1\n12 2\n12 3\n12 4\n12 5\n12 6\n12 7\n12 8\n12 9\n12 10\n12 11\n13 1\n13 2\n13 3\n13 4\n13 5\n13 6\n13 7\n13 8\n13 9\n13 10\n13 11\n13 12\n14 1\n14 2\n14 3\n14 4\n14 5\n14 6\n14 7\n14 8\n14 9\n14 10\n14 11\n..."]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 67 | codeforces |
|
fb100470ea9dd5ea633506679773b01e | Poster | The R1 company has recently bought a high rise building in the centre of Moscow for its main office. It's time to decorate the new office, and the first thing to do is to write the company's slogan above the main entrance to the building.
The slogan of the company consists of *n* characters, so the decorators hung a large banner, *n* meters wide and 1 meter high, divided into *n* equal squares. The first character of the slogan must be in the first square (the leftmost) of the poster, the second character must be in the second square, and so on.
Of course, the R1 programmers want to write the slogan on the poster themselves. To do this, they have a large (and a very heavy) ladder which was put exactly opposite the *k*-th square of the poster. To draw the *i*-th character of the slogan on the poster, you need to climb the ladder, standing in front of the *i*-th square of the poster. This action (along with climbing up and down the ladder) takes one hour for a painter. The painter is not allowed to draw characters in the adjacent squares when the ladder is in front of the *i*-th square because the uncomfortable position of the ladder may make the characters untidy. Besides, the programmers can move the ladder. In one hour, they can move the ladder either a meter to the right or a meter to the left.
Drawing characters and moving the ladder is very tiring, so the programmers want to finish the job in as little time as possible. Develop for them an optimal poster painting plan!
The first line contains two integers, *n* and *k* (1<=≤<=*k*<=≤<=*n*<=≤<=100) — the number of characters in the slogan and the initial position of the ladder, correspondingly. The next line contains the slogan as *n* characters written without spaces. Each character of the slogan is either a large English letter, or digit, or one of the characters: '.', '!', ',', '?'.
In *t* lines, print the actions the programmers need to make. In the *i*-th line print:
- "LEFT" (without the quotes), if the *i*-th action was "move the ladder to the left"; - "RIGHT" (without the quotes), if the *i*-th action was "move the ladder to the right"; - "PRINT *x*" (without the quotes), if the *i*-th action was to "go up the ladder, paint character *x*, go down the ladder".
The painting time (variable *t*) must be minimum possible. If there are multiple optimal painting plans, you can print any of them.
Sample Input
2 2
R1
2 1
R1
6 4
GO?GO!
Sample Output
PRINT 1
LEFT
PRINT R
PRINT R
RIGHT
PRINT 1
RIGHT
RIGHT
PRINT !
LEFT
PRINT O
LEFT
PRINT G
LEFT
PRINT ?
LEFT
PRINT O
LEFT
PRINT G
| {"inputs": ["2 2\nR1", "2 1\nR1", "6 4\nGO?GO!", "7 3\nME,YOU.", "10 1\nEK5JQMS5QN", "85 84\n73IW80UODC8B,UR7S8WMNATV0JSRF4W0B2VV8LCAX6SGCYY8?LHDKJEO29WXQWT9.WY1VY7408S1W04GNDZPK", "59 53\n7NWD!9PC11C8S4TQABBTJO,?CO6YGOM!W0QR94CZJBD9U1YJY23YB354,8F", "100 79\nF2.58O.L4A!QX!,.,YQUE.RZW.ENQCZKUFNG?.J6FT?L59BIHKFB?,44MAHSTD8?Z.UP3N!76YW6KVI?4AKWDPP0?3HPERM3PCUR", "1 1\n!", "34 20\n.C0QPPSWQKGBSH0,VGM!N,5SX.M9Q,D1DT", "99 98\nR8MZTEG240LNHY33H7.2CMWM73ZK,P5R,RGOA,KYKMIOG7CMPNHV3R2KM,N374IP8HN97XVMG.PSIPS8H3AXFGK0CJ76,EVKRZ9", "98 72\n.1?7CJ!EFZHO5WUKDZV,0EE92PTAGY078WKN!!41E,Q7381U60!9C,VONEZ6!SFFNDBI86MACX0?D?9!U2UV7S,977PNDSF0HY", "97 41\nGQSPZGGRZ0KWUMI79GOXP7!RR9E?Z5YO?6WUL!I7GCXRS8T,PEFQM7CZOUG8HLC7198J1?C69JD00Q!QY1AK!27I?WB?UAUIG", "96 28\nZCF!PLS27YGXHK8P46H,C.A7MW90ED,4BA!T0!XKIR2GE0HD..YZ0O20O8TA7E35G5YT3L4W5ESSYBHG8.TIQENS4I.R8WE,", "15 3\n!..!?!,!,..,?!.", "93 81\nGMIBVKYLURQLWHBGTFNJZZAZNUJJTPQKCPGDMGCDTTGXOANWKTDZSIYBUPFUXGQHCMVIEQCTINRTIUSPGMVZPGWBHPIXC", "88 30\n5847857685475132927321580125243001071762130696139249809763381765504146602574972381323476", "100 50\n5B2N,CXCWOIWH71XV!HCFEUCN3U88JDRIFRO2VHY?!N.RGH.?W14X5S.Y00RIY6YA19BPD0T,WECXYI,O2RF1U4NX9,F5AVLPOYK", "100 51\n!X85PT!WJDNS9KA6D2SJBR,U,G7M914W07EK3EAJ4XG..UHA3KOOFYJ?M0MEFDC6KNCNGKS0A!S,C02H4TSZA1U7NDBTIY?,7XZ4", "100 52\n!MLPE.0K72RW9XKHR60QE?69ILFSIKYSK5AG!TA5.02VG5OMY0967G2RI.62CNK9L8G!7IG9F0XNNCGSDOTFD?I,EBP31HRERZSX", "100 49\n86C0NR7V,BE09,7,ER715OQ3GZ,P014H4BSQ5YS?OFNDD7YWI?S?UMKIWHSBDZ4398?SSDZLTDU1L?G4QVAB53HNDS!4PYW5C!VI", "100 48\nFO,IYI4AAV?4?N5PWMZX1AINZLKAUJCKMDWU4CROT?.LYWYLYU5S80,15A6VGP!V0N,O.70CP?GEA52WG59UYWU1MMMU4BERVY.!", "100 100\nE?F,W.,,O51!!G13ZWP?YHWRT69?RQPW7,V,EM3336F1YAIKJIME1M45?LJM42?45V7221?P.DIO9FK245LXKMR4ALKPDLA5YI2Y", "100 1\nJJ0ZOX4CY,SQ9L0K!2C9TM3C6K.6R21717I37VDSXGHBMR2!J820AI75D.O7NYMT6F.AGJ8R0RDETWOACK3P6UZAUYRKMKJ!G3WF", "99 50\nLQJ!7GDFJ,SKQ8J2R?I4VA0K2.NDY.AZ?7K275NA81.YK!DO,PCQCJYL6BUU30XQ300FP0,LB!5TYTRSGOB4ELZ8IBKGVDNW8?B", "99 51\nD9QHZXG46IWHHLTD2E,AZO0.M40R4B1WU6F,0QNZ37NQ0ACSU6!7Z?H02AD?0?9,5N5RG6PVOWIE6YA9QBCOHVNU??YT6,29SAC", "99 49\nOLUBX0Q3VPNSH,QCAWFVSKZA3NUURJ9PXBS3?72PMJ,27QTA7Z1N?6Q2CSJE,W0YX8XWS.W6B?K?M!PYAD30BX?8.VJCC,P8QL9", "99 48\nW0GU5MNE5!JVIOO2SR5OO7RWLHDFH.HLCCX89O21SLD9!CU0MFG3RFZUFT!R0LWNVNSS.W54.67N4VAN1Q2J9NMO9Q6.UE8U6B8", "2 1\nOA", "2 2\nGW", "3 1\n.VP", "3 2\nUD0", "3 3\nMYE", "4 1\nC5EJ", "4 2\n5QSW", "4 3\n!F3D", "4 4\nS!?Y", "5 1\nIP4!N", "5 2\nI7??5", "5 3\nASNUW", "5 4\n3?,4L", "5 5\n30COA", "4 2\nABCD"], "outputs": ["PRINT 1\nLEFT\nPRINT R", "PRINT R\nRIGHT\nPRINT 1", "RIGHT\nRIGHT\nPRINT !\nLEFT\nPRINT O\nLEFT\nPRINT G\nLEFT\nPRINT ?\nLEFT\nPRINT O\nLEFT\nPRINT G", "LEFT\nLEFT\nPRINT M\nRIGHT\nPRINT E\nRIGHT\nPRINT ,\nRIGHT\nPRINT Y\nRIGHT\nPRINT O\nRIGHT\nPRINT U\nRIGHT\nPRINT .", "PRINT E\nRIGHT\nPRINT K\nRIGHT\nPRINT 5\nRIGHT\nPRINT J\nRIGHT\nPRINT Q\nRIGHT\nPRINT M\nRIGHT\nPRINT S\nRIGHT\nPRINT 5\nRIGHT\nPRINT Q\nRIGHT\nPRINT N", "RIGHT\nPRINT K\nLEFT\nPRINT P\nLEFT\nPRINT Z\nLEFT\nPRINT D\nLEFT\nPRINT N\nLEFT\nPRINT G\nLEFT\nPRINT 4\nLEFT\nPRINT 0\nLEFT\nPRINT W\nLEFT\nPRINT 1\nLEFT\nPRINT S\nLEFT\nPRINT 8\nLEFT\nPRINT 0\nLEFT\nPRINT 4\nLEFT\nPRINT 7\nLEFT\nPRINT Y\nLEFT\nPRINT V\nLEFT\nPRINT 1\nLEFT\nPRINT Y\nLEFT\nPRINT W\nLEFT\nPRINT .\nLEFT\nPRINT 9\nLEFT\nPRINT T\nLEFT\nPRINT W\nLEFT\nPRINT Q\nLEFT\nPRINT X\nLEFT\nPRINT W\nLEFT\nPRINT 9\nLEFT\nPRINT 2\nLEFT\nPRINT O\nLEFT\nPRINT E\nLEFT\nPRINT J\nLEFT\nPRINT K\nLEFT\nPRINT D\n...", "RIGHT\nRIGHT\nRIGHT\nRIGHT\nRIGHT\nRIGHT\nPRINT F\nLEFT\nPRINT 8\nLEFT\nPRINT ,\nLEFT\nPRINT 4\nLEFT\nPRINT 5\nLEFT\nPRINT 3\nLEFT\nPRINT B\nLEFT\nPRINT Y\nLEFT\nPRINT 3\nLEFT\nPRINT 2\nLEFT\nPRINT Y\nLEFT\nPRINT J\nLEFT\nPRINT Y\nLEFT\nPRINT 1\nLEFT\nPRINT U\nLEFT\nPRINT 9\nLEFT\nPRINT D\nLEFT\nPRINT B\nLEFT\nPRINT J\nLEFT\nPRINT Z\nLEFT\nPRINT C\nLEFT\nPRINT 4\nLEFT\nPRINT 9\nLEFT\nPRINT R\nLEFT\nPRINT Q\nLEFT\nPRINT 0\nLEFT\nPRINT W\nLEFT\nPRINT !\nLEFT\nPRINT M\nLEFT\nPRINT O\nLEFT\nPRINT G\nLEFT\nPRIN...", "RIGHT\nRIGHT\nRIGHT\nRIGHT\nRIGHT\nRIGHT\nRIGHT\nRIGHT\nRIGHT\nRIGHT\nRIGHT\nRIGHT\nRIGHT\nRIGHT\nRIGHT\nRIGHT\nRIGHT\nRIGHT\nRIGHT\nRIGHT\nRIGHT\nPRINT R\nLEFT\nPRINT U\nLEFT\nPRINT C\nLEFT\nPRINT P\nLEFT\nPRINT 3\nLEFT\nPRINT M\nLEFT\nPRINT R\nLEFT\nPRINT E\nLEFT\nPRINT P\nLEFT\nPRINT H\nLEFT\nPRINT 3\nLEFT\nPRINT ?\nLEFT\nPRINT 0\nLEFT\nPRINT P\nLEFT\nPRINT P\nLEFT\nPRINT D\nLEFT\nPRINT W\nLEFT\nPRINT K\nLEFT\nPRINT A\nLEFT\nPRINT 4\nLEFT\nPRINT ?\nLEFT\nPRINT I\nLEFT\nPRINT V\nLEFT\nPRINT K\nLEFT\nPRIN...", "PRINT !", "RIGHT\nRIGHT\nRIGHT\nRIGHT\nRIGHT\nRIGHT\nRIGHT\nRIGHT\nRIGHT\nRIGHT\nRIGHT\nRIGHT\nRIGHT\nRIGHT\nPRINT T\nLEFT\nPRINT D\nLEFT\nPRINT 1\nLEFT\nPRINT D\nLEFT\nPRINT ,\nLEFT\nPRINT Q\nLEFT\nPRINT 9\nLEFT\nPRINT M\nLEFT\nPRINT .\nLEFT\nPRINT X\nLEFT\nPRINT S\nLEFT\nPRINT 5\nLEFT\nPRINT ,\nLEFT\nPRINT N\nLEFT\nPRINT !\nLEFT\nPRINT M\nLEFT\nPRINT G\nLEFT\nPRINT V\nLEFT\nPRINT ,\nLEFT\nPRINT 0\nLEFT\nPRINT H\nLEFT\nPRINT S\nLEFT\nPRINT B\nLEFT\nPRINT G\nLEFT\nPRINT K\nLEFT\nPRINT Q\nLEFT\nPRINT W\nLEFT\nPRINT S\n...", "RIGHT\nPRINT 9\nLEFT\nPRINT Z\nLEFT\nPRINT R\nLEFT\nPRINT K\nLEFT\nPRINT V\nLEFT\nPRINT E\nLEFT\nPR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\nLEFT\nLEFT\nLEFT\nLEFT\nLEFT\nLEFT\nLEFT\nLEFT\nLEFT\nLEFT\nLEFT\nLEFT\nLEFT\nLEFT\nLEFT\nLEFT\nLEFT\nLEFT\nLEFT\nLEFT\nPRINT F\nRIGHT\nPRINT O\nRIGHT\nPRINT ,\nRIGHT\nPRINT I\nRIGHT\nPRINT Y\nRIGHT\nPRINT I\nRIGHT\nPRINT 4\nRIGHT\nPRINT A\nRIGHT\nPRINT A\nRIGHT\nPRINT V\nRIGHT\nPRINT ?\nRIGHT\nPRINT 4\nRIGHT\nPRINT ?\nRIGHT\nPRINT N\nRIGHT\nPRINT...", "PRINT Y\nLEFT\nPRINT 2\nLEFT\nPRINT I\nLEFT\nPRINT Y\nLEFT\nPRINT 5\nLEFT\nPRINT A\nLEFT\nPRINT L\nLEFT\nPRINT D\nLEFT\nPRINT P\nLEFT\nPRINT K\nLEFT\nPRINT L\nLEFT\nPRINT A\nLEFT\nPRINT 4\nLEFT\nPRINT R\nLEFT\nPRINT M\nLEFT\nPRINT K\nLEFT\nPRINT X\nLEFT\nPRINT L\nLEFT\nPRINT 5\nLEFT\nPRINT 4\nLEFT\nPRINT 2\nLEFT\nPRINT K\nLEFT\nPRINT F\nLEFT\nPRINT 9\nLEFT\nPRINT O\nLEFT\nPRINT I\nLEFT\nPRINT D\nLEFT\nPRINT .\nLEFT\nPRINT P\nLEFT\nPRINT ?\nLEFT\nPRINT 1\nLEFT\nPRINT 2\nLEFT\nPRINT 2\nLEFT\nPRINT 7\nLEFT\nP...", "PRINT J\nRIGHT\nPRINT J\nRIGHT\nPRINT 0\nRIGHT\nPRINT Z\nRIGHT\nPRINT O\nRIGHT\nPRINT X\nRIGHT\nPRINT 4\nRIGHT\nPRINT C\nRIGHT\nPRINT Y\nRIGHT\nPRINT ,\nRIGHT\nPRINT S\nRIGHT\nPRINT Q\nRIGHT\nPRINT 9\nRIGHT\nPRINT L\nRIGHT\nPRINT 0\nRIGHT\nPRINT K\nRIGHT\nP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RIGHT\nPRINT 5\nRIGHT\nPRINT M\nRIGHT\nPRINT N\nRIGHT\nPRINT E\nRIGHT\nPRINT 5\nRIGHT\nPRINT !\nRIGHT\nPRINT J\nRIGHT\nPRINT V\nRIGHT\nPRINT I\nRIGHT\nPRINT O\nRIGHT\nPRINT...", "PRINT O\nRIGHT\nPRINT A", "PRINT W\nLEFT\nPRINT G", "PRINT .\nRIGHT\nPRINT V\nRIGHT\nPRINT P", "RIGHT\nPRINT 0\nLEFT\nPRINT D\nLEFT\nPRINT U", "PRINT E\nLEFT\nPRINT Y\nLEFT\nPRINT M", "PRINT C\nRIGHT\nPRINT 5\nRIGHT\nPRINT E\nRIGHT\nPRINT J", "LEFT\nPRINT 5\nRIGHT\nPRINT Q\nRIGHT\nPRINT S\nRIGHT\nPRINT W", "RIGHT\nPRINT D\nLEFT\nPRINT 3\nLEFT\nPRINT F\nLEFT\nPRINT !", "PRINT Y\nLEFT\nPRINT ?\nLEFT\nPRINT !\nLEFT\nPRINT S", "PRINT I\nRIGHT\nPRINT P\nRIGHT\nPRINT 4\nRIGHT\nPRINT !\nRIGHT\nPRINT N", "LEFT\nPRINT I\nRIGHT\nPRINT 7\nRIGHT\nPRINT ?\nRIGHT\nPRINT ?\nRIGHT\nPRINT 5", "RIGHT\nRIGHT\nPRINT W\nLEFT\nPRINT U\nLEFT\nPRINT N\nLEFT\nPRINT S\nLEFT\nPRINT A", "RIGHT\nPRINT L\nLEFT\nPRINT 4\nLEFT\nPRINT ,\nLEFT\nPRINT ?\nLEFT\nPRINT 3", "PRINT A\nLEFT\nPRINT O\nLEFT\nPRINT C\nLEFT\nPRINT 0\nLEFT\nPRINT 3", "LEFT\nPRINT A\nRIGHT\nPRINT B\nRIGHT\nPRINT C\nRIGHT\nPRINT D"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 110 | codeforces |
|
fb31e30d59f65c09b714f42e0893a6fa | Birds | Apart from plush toys, Imp is a huge fan of little yellow birds!
To summon birds, Imp needs strong magic. There are *n* trees in a row on an alley in a park, there is a nest on each of the trees. In the *i*-th nest there are *c**i* birds; to summon one bird from this nest Imp needs to stay under this tree and it costs him *cost**i* points of mana. However, for each bird summoned, Imp increases his mana capacity by *B* points. Imp summons birds one by one, he can summon any number from 0 to *c**i* birds from the *i*-th nest.
Initially Imp stands under the first tree and has *W* points of mana, and his mana capacity equals *W* as well. He can only go forward, and each time he moves from a tree to the next one, he restores *X* points of mana (but it can't exceed his current mana capacity). Moving only forward, what is the maximum number of birds Imp can summon?
The first line contains four integers *n*, *W*, *B*, *X* (1<=≤<=*n*<=≤<=103,<=0<=≤<=*W*,<=*B*,<=*X*<=≤<=109) — the number of trees, the initial points of mana, the number of points the mana capacity increases after a bird is summoned, and the number of points restored when Imp moves from a tree to the next one.
The second line contains *n* integers *c*1,<=*c*2,<=...,<=*c**n* (0<=≤<=*c**i*<=≤<=104) — where *c**i* is the number of birds living in the *i*-th nest. It is guaranteed that .
The third line contains *n* integers *cost*1,<=*cost*2,<=...,<=*cost**n* (0<=≤<=*cost**i*<=≤<=109), where *cost**i* is the mana cost to summon a bird from the *i*-th nest.
Print a single integer — the maximum number of birds Imp can summon.
Sample Input
2 12 0 4
3 4
4 2
4 1000 10 35
1 2 4 5
1000 500 250 200
2 10 7 11
2 10
6 1
Sample Output
6
5
11
| {"inputs": ["2 12 0 4\n3 4\n4 2", "4 1000 10 35\n1 2 4 5\n1000 500 250 200", "2 10 7 11\n2 10\n6 1", "5 1 4 6\n3 4 6 5 1\n3 0 10 2 9", "75 262 870 596\n22 13 37 6 15 25 5 1 2 13 6 3 14 7 8 15 6 15 10 3 1 21 33 2 7 14 17 7 4 9 16 29 31 4 31 16 3 11 13 38 3 14 8 18 9 3 1 10 1 5 10 16 7 5 33 9 24 9 8 13 3 31 8 18 33 17 22 15 34 22 14 23 9 11 1\n15 988 494 954 185 43 341 392 828 364 464 33 443 279 410 559 648 522 221 630 446 910 720 680 299 949 898 528 344 530 33 705 562 718 378 603 752 729 874 835 271 809 687 485 383 203 211 967 937 641 222 519 30 437 573 94 818 740 711 628 631 699 803 289 804 722 986 917 286 358 564 740 280 625 104", "1 1000000000 1000000000 1000000000\n10000\n1000000000", "11 182265379 943880823 541186655\n118 395 182 912 3055 1198 972 499 1295 423 951\n919515674 183547374 713185799 495395101 460570056 865323757 856004539 172194086 29017055 573281401 94884106", "30 813763087 667301398 788083179\n358 1 942 255 371 86 22 313 62 220 227 301 164 238 30 18 26 517 1904 293 110 1171 709 412 221 27 355 386 180 81\n364514724 369447241 943009487 777239405 675813054 769495455 824525249 132802164 98954464 131625205 59567398 4498864 777027802 875631890 510915516 4505995 568141671 175640086 253104977 173981164 846365879 8456432 819645904 478042655 137080723 401949614 630869423 140199951 566654245 49531216", "29 248541711 775857221 991640811\n456 358 735 868 213 24 583 174 381 1357 63 180 903 180 106 56 166 479 434 171 111 200 499 110 16 23 371 525 258\n510246598 566510289 914900360 823548934 762398202 571897078 102256870 717967541 568392967 330484503 755710752 232910352 371570614 781299711 733550623 337438470 36696592 158396947 254877244 719491526 148294199 754511298 655210216 895287270 535726298 235308442 905006463 142116705 96440782", "17 839860324 388827729 364896640\n417 2 8 930 648 3105 434 435 1 1450 58 50 277 646 221 274 1044\n416664151 309840428 823560106 653486427 281743349 81844030 406321182 683147664 445891025 323452426 204464623 21209374 112902821 403197845 977337836 263883864 161229864"], "outputs": ["6", "5", "11", "10", "221", "1", "30", "1648", "313", "95"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1 | codeforces |
|
fb358ff1430bb7b1c364bc7027e80b87 | Leaving the Bar | For a vector $\vec{v} = (x, y)$, define $|v| = \sqrt{x^2 + y^2}$.
Allen had a bit too much to drink at the bar, which is at the origin. There are $n$ vectors $\vec{v_1}, \vec{v_2}, \cdots, \vec{v_n}$. Allen will make $n$ moves. As Allen's sense of direction is impaired, during the $i$-th move he will either move in the direction $\vec{v_i}$ or $-\vec{v_i}$. In other words, if his position is currently $p = (x, y)$, he will either move to $p + \vec{v_i}$ or $p - \vec{v_i}$.
Allen doesn't want to wander too far from home (which happens to also be the bar). You need to help him figure out a sequence of moves (a sequence of signs for the vectors) such that his final position $p$ satisfies $|p| \le 1.5 \cdot 10^6$ so that he can stay safe.
The first line contains a single integer $n$ ($1 \le n \le 10^5$) — the number of moves.
Each of the following lines contains two space-separated integers $x_i$ and $y_i$, meaning that $\vec{v_i} = (x_i, y_i)$. We have that $|v_i| \le 10^6$ for all $i$.
Output a single line containing $n$ integers $c_1, c_2, \cdots, c_n$, each of which is either $1$ or $-1$. Your solution is correct if the value of $p = \sum_{i = 1}^n c_i \vec{v_i}$, satisfies $|p| \le 1.5 \cdot 10^6$.
It can be shown that a solution always exists under the given constraints.
Sample Input
3
999999 0
0 999999
999999 0
1
-824590 246031
8
-67761 603277
640586 -396671
46147 -122580
569609 -2112
400 914208
131792 309779
-850150 -486293
5272 721899
Sample Output
1 1 -1
1
1 1 1 1 1 1 1 -1
| {"inputs": ["3\n999999 0\n0 999999\n999999 0", "1\n-824590 246031", "8\n-67761 603277\n640586 -396671\n46147 -122580\n569609 -2112\n400 914208\n131792 309779\n-850150 -486293\n5272 721899", "6\n1000000 0\n1000000 0\n-1000000 0\n0 1000000\n0 -1000000\n0 -1000000", "8\n-411248 143802\n300365 629658\n363219 343742\n396148 -94037\n-722124 467785\n-178147 -931253\n265458 73307\n-621502 -709713", "3\n1000000 0\n0 999999\n600000 -600000", "5\n140239 46311\n399464 -289055\n-540174 823360\n538102 -373313\n326189 933934", "3\n1000000 0\n0 999999\n300000 -300000", "9\n1000000 0\n0 -999999\n600000 600000\n600000 600000\n600000 600000\n-600000 -600000\n600000 600000\n600000 600000\n-700000 710000", "2\n1 999999\n1 -999999", "2\n999999 1\n999999 -1", "2\n-1 999999\n-1 -999999", "2\n-999999 -1\n-999999 1", "2\n999999 1\n-999999 1", "2\n999999 -1\n-999999 -1", "2\n1 999999\n-1 999999", "2\n1 -999999\n-1 -999999", "4\n1000000 0\n-1 999999\n600000 -600000\n0 0", "2\n999999 -1\n-1 999999"], "outputs": ["1 1 -1 ", "1 ", "1 1 1 1 1 1 1 -1 ", "1 1 1 1 1 1 ", "1 1 1 1 1 1 1 -1 ", "-1 1 1 ", "1 1 1 1 -1 ", "1 1 -1 ", "1 1 1 -1 1 1 1 -1 1 ", "1 1 ", "1 -1 ", "1 1 ", "1 -1 ", "1 1 ", "1 1 ", "1 -1 ", "1 -1 ", "-1 1 1 1 ", "1 1 "]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 3 | codeforces |
|
fb35ad5ba58debd68f0aba5949e0c149 | Little Artem and Presents | Little Artem got *n* stones on his birthday and now wants to give some of them to Masha. He knows that Masha cares more about the fact of receiving the present, rather than the value of that present, so he wants to give her stones as many times as possible. However, Masha remembers the last present she received, so Artem can't give her the same number of stones twice in a row. For example, he can give her 3 stones, then 1 stone, then again 3 stones, but he can't give her 3 stones and then again 3 stones right after that.
How many times can Artem give presents to Masha?
The only line of the input contains a single integer *n* (1<=≤<=*n*<=≤<=109) — number of stones Artem received on his birthday.
Print the maximum possible number of times Artem can give presents to Masha.
Sample Input
1
2
3
4
Sample Output
1
1
2
3
| {"inputs": ["1", "2", "3", "4", "100", "101", "102", "1000000000", "5", "6", "999999999", "999999998", "999999997", "999999996", "999999995", "999999994", "999999993", "999999992", "999999991", "1000", "10000", "100000", "1000000", "10000000", "100000000", "7"], "outputs": ["1", "1", "2", "3", "67", "67", "68", "666666667", "3", "4", "666666666", "666666665", "666666665", "666666664", "666666663", "666666663", "666666662", "666666661", "666666661", "667", "6667", "66667", "666667", "6666667", "66666667", "5"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 365 | codeforces |
|
fb4f19ca832f912bcbe6c0aec5b2d3cd | Chat Online | Little X and Little Z are good friends. They always chat online. But both of them have schedules.
Little Z has fixed schedule. He always online at any moment of time between *a*1 and *b*1, between *a*2 and *b*2, ..., between *a**p* and *b**p* (all borders inclusive). But the schedule of Little X is quite strange, it depends on the time when he gets up. If he gets up at time 0, he will be online at any moment of time between *c*1 and *d*1, between *c*2 and *d*2, ..., between *c**q* and *d**q* (all borders inclusive). But if he gets up at time *t*, these segments will be shifted by *t*. They become [*c**i*<=+<=*t*,<=*d**i*<=+<=*t*] (for all *i*).
If at a moment of time, both Little X and Little Z are online simultaneosly, they can chat online happily. You know that Little X can get up at an integer moment of time between *l* and *r* (both borders inclusive). Also you know that Little X wants to get up at the moment of time, that is suitable for chatting with Little Z (they must have at least one common moment of time in schedules). How many integer moments of time from the segment [*l*,<=*r*] suit for that?
The first line contains four space-separated integers *p*,<=*q*,<=*l*,<=*r* (1<=≤<=<=*p*,<=*q*<=≤<=50; 0<=≤<=*l*<=≤<=*r*<=≤<=1000).
Each of the next *p* lines contains two space-separated integers *a**i*,<=*b**i* (0<=≤<=*a**i*<=<<=*b**i*<=≤<=1000). Each of the next *q* lines contains two space-separated integers *c**j*,<=*d**j* (0<=≤<=*c**j*<=<<=*d**j*<=≤<=1000).
It's guaranteed that *b**i*<=<<=*a**i*<=+<=1 and *d**j*<=<<=*c**j*<=+<=1 for all valid *i* and *j*.
Output a single integer — the number of moments of time from the segment [*l*,<=*r*] which suit for online conversation.
Sample Input
1 1 0 4
2 3
0 1
2 3 0 20
15 17
23 26
1 4
7 11
15 17
Sample Output
3
20
| {"inputs": ["1 1 0 4\n2 3\n0 1", "2 3 0 20\n15 17\n23 26\n1 4\n7 11\n15 17", "5 2 27 452\n148 154\n421 427\n462 470\n777 786\n969 978\n245 247\n313 322", "3 6 25 785\n273 275\n391 397\n775 783\n84 89\n348 354\n480 483\n552 556\n711 716\n838 844", "1 6 364 421\n649 688\n31 39\n438 441\n516 524\n609 615\n708 710\n850 851", "7 10 87 239\n8 23\n325 374\n516 540\n633 658\n728 742\n833 839\n960 995\n99 114\n213 232\n264 269\n321 327\n492 540\n551 559\n587 590\n625 637\n704 723\n750 764", "33 17 295 791\n41 49\n66 73\n95 102\n118 126\n157 158\n189 198\n228 237\n247 251\n301 307\n318 326\n328 333\n356 363\n373 381\n454 460\n463 466\n471 477\n500 501\n505 510\n559 566\n585 588\n597 604\n675 684\n688 695\n699 705\n749 755\n780 788\n869 873\n879 888\n890 892\n909 918\n953 954\n973 978\n993 996\n53 60\n68 74\n102 105\n149 153\n191 206\n230 242\n249 252\n320 325\n483 488\n509 513\n523 524\n544 560\n651 655\n670 672\n691 708\n742 748\n920 939", "5 4 520 527\n257 263\n309 315\n434 439\n540 541\n759 763\n168 176\n313 316\n546 548\n880 881", "11 40 58 976\n14 22\n85 92\n110 112\n173 181\n188 190\n212 218\n494 498\n530 531\n647 656\n943 948\n960 968\n2 16\n20 31\n40 86\n90 91\n93 96\n103 118\n128 155\n170 173\n176 192\n205 207\n210 217\n237 245\n250 280\n302 304\n311 328\n332 376\n387 419\n422 442\n449 454\n462 491\n496 498\n501 516\n525 552\n556 565\n567 573\n577 578\n586 635\n651 677\n688 699\n704 714\n718 719\n733 766\n768 769\n773 811\n822 826\n830 870\n885 917\n937 961\n971 981\n991 1000", "10 28 435 847\n48 57\n86 95\n186 188\n297 304\n500 506\n594 600\n602 609\n802 811\n906 911\n916 921\n20 22\n115 118\n139 141\n170 171\n184 188\n193 197\n227 230\n232 235\n250 252\n256 260\n271 275\n322 324\n326 328\n379 381\n433 434\n528 529\n563 565\n583 584\n614 615\n617 619\n631 632\n726 729\n750 754\n814 817\n853 855\n881 882\n946 947\n981 984", "13 42 292 733\n304 308\n362 365\n396 397\n686 688\n719 722\n815 816\n901 902\n904 905\n921 924\n929 933\n953 954\n977 980\n982 985\n28 30\n36 37\n108 112\n123 127\n134 135\n151 153\n160 162\n203 205\n208 212\n240 243\n261 264\n271 274\n294 297\n356 358\n383 385\n408 412\n415 418\n435 439\n444 447\n500 502\n507 511\n515 519\n525 529\n541 543\n566 569\n577 579\n606 609\n618 622\n655 656\n715 718\n744 745\n767 771\n798 802\n828 830\n839 840\n842 845\n893 894\n897 898\n902 906\n958 960\n981 983\n988 992", "5 46 211 943\n367 371\n405 408\n639 642\n821 825\n974 978\n13 14\n31 34\n36 39\n48 51\n82 86\n173 174\n193 196\n227 230\n249 250\n259 261\n292 294\n325 327\n329 330\n352 353\n380 383\n390 391\n398 399\n411 414\n418 420\n424 427\n478 479\n488 489\n500 502\n511 514\n534 535\n548 552\n581 584\n596 600\n609 611\n618 622\n641 642\n656 657\n674 678\n707 709\n718 720\n746 748\n752 755\n771 773\n775 777\n865 869\n892 896\n910 911\n946 948\n963 964\n977 978\n986 990", "1 8 169 472\n63 553\n32 65\n75 204\n263 277\n289 326\n342 441\n452 911\n945 956\n971 986", "2 1 17 179\n159 202\n579 602\n115 126", "1 1 0 1000\n0 1000\n0 1000", "10 11 201 515\n2 3\n102 103\n202 203\n302 304\n401 402\n502 503\n600 603\n701 702\n800 803\n900 902\n1 2\n103 104\n201 202\n302 304\n400 404\n501 504\n600 601\n603 604\n701 704\n800 801\n900 902", "1 7 140 478\n400 404\n3 4\n100 105\n301 304\n403 405\n504 506\n600 605\n904 906", "9 8 453 552\n5 18\n23 28\n125 132\n208 209\n215 230\n516 527\n808 819\n906 913\n926 929\n4 18\n221 229\n316 330\n403 424\n506 516\n805 828\n904 914\n916 917", "9 1 24 52\n63 94\n150 164\n244 275\n379 385\n413 420\n441 490\n506 545\n614 661\n752 776\n531 534", "1 1 0 0\n1 3\n2 5"], "outputs": ["3", "20", "54", "99", "0", "151", "497", "0", "909", "284", "412", "428", "304", "55", "1001", "26", "16", "49", "0", "1"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 8 | codeforces |
|
fb638f1ba3ca020d1c377de702d1dada | Substrings Sort | You are given $n$ strings. Each string consists of lowercase English letters. Rearrange (reorder) the given strings in such a way that for every string, all strings that are placed before it are its substrings.
String $a$ is a substring of string $b$ if it is possible to choose several consecutive letters in $b$ in such a way that they form $a$. For example, string "for" is contained as a substring in strings "codeforces", "for" and "therefore", but is not contained as a substring in strings "four", "fofo" and "rof".
The first line contains an integer $n$ ($1 \le n \le 100$) — the number of strings.
The next $n$ lines contain the given strings. The number of letters in each string is from $1$ to $100$, inclusive. Each string consists of lowercase English letters.
Some strings might be equal.
If it is impossible to reorder $n$ given strings in required order, print "NO" (without quotes).
Otherwise print "YES" (without quotes) and $n$ given strings in required order.
Sample Input
5
a
aba
abacaba
ba
aba
5
a
abacaba
ba
aba
abab
3
qwerty
qwerty
qwerty
Sample Output
YES
a
ba
aba
aba
abacaba
NO
YES
qwerty
qwerty
qwerty
| {"inputs": ["5\na\naba\nabacaba\nba\naba", "5\na\nabacaba\nba\naba\nabab", "3\nqwerty\nqwerty\nqwerty", "1\nwronganswer", "3\na\nb\nab", "2\nababaab\nabaab", "2\nq\nqq", "5\nabab\nbab\nba\nab\na", "3\nb\nc\nd", "3\naba\nbab\nababa", "4\na\nba\nabacabac\nb", "4\nab\nba\nabab\na", "3\naaa\naab\naaab", "2\nac\nabac", "2\na\nb", "3\nbaa\nbaaaaaaaab\naaaaaa", "3\naaab\naab\naaaab", "2\naaba\naba", "10\na\nb\nc\nd\nab\nbc\ncd\nabc\nbcd\nabcd", "5\na\nab\nae\nabcd\nabcde", "3\nv\nab\nvab", "4\na\nb\nc\nabc", "2\nab\naab", "3\nabc\na\nc", "2\nabaab\nababaab", "3\ny\nxx\nxxy", "4\naaaa\naaaa\naaaa\nab", "3\nbad\naba\nabad", "3\nabcabc\nab\nbc", "2\naaaab\naaaaab", "5\nab\naba\naba\naba\nabd", "4\nded\nd\ne\nd", "5\nekgetterherforme\ner\nter\nher\ntter", "3\naa\nbba\ncbba", "3\nab\naa\naab", "6\naaaa\naaaa\naaaa\naaaaab\nab\nab", "3\na\nbcd\nabcd", "3\naa\nab\naab", "3\nabcde\nab\ncde", "4\nanoop\np\nan\noop", "3\nab\ncd\nabcd", "3\nafaba\nafab\nfaba", "3\nababc\nabababc\nab", "3\na\nba\nbbab", "2\naabaa\naba", "3\nbc\nbca\na", "2\naba\nabba", "7\na\nb\nc\nab\nac\nac\nac", "2\naa\nmmmmmmmammmmmmmm"], "outputs": ["YES\na\nba\naba\naba\nabacaba", "NO", "YES\nqwerty\nqwerty\nqwerty", "YES\nwronganswer", "NO", "YES\nabaab\nababaab", "YES\nq\nqq", "NO", "NO", "NO", "NO", "NO", "NO", "YES\nac\nabac", "NO", "NO", "YES\naab\naaab\naaaab", "YES\naba\naaba", "NO", "NO", "NO", "NO", "YES\nab\naab", "NO", "YES\nabaab\nababaab", "NO", "NO", "NO", "NO", "YES\naaaab\naaaaab", "NO", "NO", "NO", "NO", "NO", "NO", "NO", "NO", "NO", "NO", "NO", "NO", "YES\nab\nababc\nabababc", "YES\na\nba\nbbab", "YES\naba\naabaa", "NO", "NO", "NO", "NO"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 169 | codeforces |
|
fb72cf1ab655d21cc8e2271adda07ca1 | Guess the Permutation | Bob has a permutation of integers from 1 to *n*. Denote this permutation as *p*. The *i*-th element of *p* will be denoted as *p**i*. For all pairs of distinct integers *i*,<=*j* between 1 and *n*, he wrote the number *a**i*,<=*j*<==<=*min*(*p**i*,<=*p**j*). He writes *a**i*,<=*i*<==<=0 for all integer *i* from 1 to *n*.
Bob gave you all the values of *a**i*,<=*j* that he wrote down. Your job is to reconstruct any permutation that could have generated these values. The input will be formed so that it is guaranteed that there is at least one solution that is consistent with the information given.
The first line of the input will contain a single integer *n* (2<=≤<=*n*<=≤<=50).
The next *n* lines will contain the values of *a**i*,<=*j*. The *j*-th number on the *i*-th line will represent *a**i*,<=*j*. The *i*-th number on the *i*-th line will be 0. It's guaranteed that *a**i*,<=*j*<==<=*a**j*,<=*i* and there is at least one solution consistent with the information given.
Print *n* space separated integers, which represents a permutation that could have generated these values. If there are multiple possible solutions, print any of them.
Sample Input
2
0 1
1 0
5
0 2 2 1 2
2 0 4 1 3
2 4 0 1 3
1 1 1 0 1
2 3 3 1 0
Sample Output
2 1
2 5 4 1 3
| {"inputs": ["2\n0 1\n1 0", "5\n0 2 2 1 2\n2 0 4 1 3\n2 4 0 1 3\n1 1 1 0 1\n2 3 3 1 0", "10\n0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7 12 3 8 11 9 1"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 123 | codeforces |
|
fb74f0c531da115dd79246f7353102f6 | Ace It! | The only line of the input is a string of 7 characters. The first character is letter A, followed by 6 digits. The input is guaranteed to be valid (for certain definition of "valid").
Output a single integer.
The only line of the input is a string of 7 characters. The first character is letter A, followed by 6 digits. The input is guaranteed to be valid (for certain definition of "valid").
Output a single integer.
Sample Input
A221033
A223635
A232726
Sample Output
21
22
23
| {"inputs": ["A221033", "A223635", "A232726", "A102210", "A231010", "A222222", "A555555", "A102222", "A234567", "A987654", "A101010", "A246810", "A210210", "A458922", "A999999", "A888888", "A232232", "A222210", "A710210", "A342987", "A987623", "A109109", "A910109", "A292992", "A388338", "A764598", "A332567", "A108888", "A910224", "A321046", "A767653", "A101099", "A638495"], "outputs": ["21", "22", "23", "25", "26", "13", "31", "19", "28", "40", "31", "31", "25", "31", "55", "49", "15", "19", "30", "34", "36", "39", "39", "34", "34", "40", "27", "43", "28", "26", "35", "39", "36"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 43 | codeforces |
|
fb9cfeffe8719c2c83cb84f4009cb5d2 | Little Elephant and Broken Sorting | The Little Elephant loves permutations of integers from 1 to *n* very much. But most of all he loves sorting them. To sort a permutation, the Little Elephant repeatedly swaps some elements. As a result, he must receive a permutation 1,<=2,<=3,<=...,<=*n*.
This time the Little Elephant has permutation *p*1,<=*p*2,<=...,<=*p**n*. Its sorting program needs to make exactly *m* moves, during the *i*-th move it swaps elements that are at that moment located at the *a**i*-th and the *b**i*-th positions. But the Little Elephant's sorting program happened to break down and now on every step it can equiprobably either do nothing or swap the required elements.
Now the Little Elephant doesn't even hope that the program will sort the permutation, but he still wonders: if he runs the program and gets some permutation, how much will the result of sorting resemble the sorted one? For that help the Little Elephant find the mathematical expectation of the number of permutation inversions after all moves of the program are completed.
We'll call a pair of integers *i*,<=*j* (1<=≤<=*i*<=<<=*j*<=≤<=*n*) an inversion in permutatuon *p*1,<=*p*2,<=...,<=*p**n*, if the following inequality holds: *p**i*<=><=*p**j*.
The first line contains two integers *n* and *m* (1<=≤<=*n*,<=*m*<=≤<=1000,<=*n*<=><=1) — the permutation size and the number of moves. The second line contains *n* distinct integers, not exceeding *n* — the initial permutation. Next *m* lines each contain two integers: the *i*-th line contains integers *a**i* and *b**i* (1<=≤<=*a**i*,<=*b**i*<=≤<=*n*,<=*a**i*<=≠<=*b**i*) — the positions of elements that were changed during the *i*-th move.
In the only line print a single real number — the answer to the problem. The answer will be considered correct if its relative or absolute error does not exceed 10<=-<=6.
Sample Input
2 1
1 2
1 2
4 3
1 3 2 4
1 2
2 3
1 4
Sample Output
0.500000000
3.000000000
| {"inputs": ["2 1\n1 2\n1 2", "4 3\n1 3 2 4\n1 2\n2 3\n1 4", "7 4\n7 6 4 2 1 5 3\n1 3\n2 1\n7 2\n3 5", "10 1\n1 2 3 4 5 6 7 8 9 10\n1 10", "9 20\n9 8 7 6 5 4 3 2 1\n4 6\n9 4\n5 9\n6 8\n1 9\n5 8\n6 9\n7 3\n1 9\n8 3\n4 5\n9 6\n3 8\n4 1\n1 2\n3 2\n4 9\n6 7\n7 5\n9 6", "20 7\n3 17 7 14 11 4 1 18 20 19 13 12 5 6 15 16 9 2 8 10\n19 13\n20 6\n19 11\n12 3\n10 19\n14 10\n3 16", "100 1\n78 52 95 76 96 49 53 59 77 100 64 11 9 48 15 17 44 46 21 54 39 68 43 4 32 28 73 6 16 62 72 84 65 86 98 75 33 45 25 3 91 82 2 92 63 88 7 50 97 93 14 22 20 42 60 55 80 85 29 34 56 71 83 38 26 47 90 70 51 41 40 31 37 12 35 99 67 94 1 87 57 8 61 19 23 79 36 18 66 74 5 27 81 69 24 58 13 10 89 30\n17 41", "125 8\n111 69 3 82 24 38 4 39 42 22 92 6 16 10 8 45 17 91 84 53 5 46 124 47 18 57 43 73 114 102 121 105 118 95 104 98 72 20 56 60 123 80 103 70 65 107 67 112 101 108 99 49 12 94 2 68 119 109 59 40 86 116 88 63 110 14 13 120 41 64 89 71 15 35 81 51 113 90 55 122 1 75 54 33 28 7 125 9 100 115 19 58 61 83 117 52 106 87 11 50 93 32 21 96 26 78 48 79 23 36 66 27 31 62 25 77 30 74 76 44 97 85 29 34 37\n33 17\n84 103\n71 33\n5 43\n23 15\n65 34\n125 58\n51 69", "100 2\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100\n88 90\n62 77"], "outputs": ["0.500000000", "3.000000000", "11.250000000", "8.500000000", "20.105407715", "102.250000000", "2659.500000000", "3919.000000000", "16.000000000"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1 | codeforces |
|
fbd08e2f563c304ba65fe1928a5c64af | none | You are given set of *n* points in 5-dimensional space. The points are labeled from 1 to *n*. No two points coincide.
We will call point *a* bad if there are different points *b* and *c*, not equal to *a*, from the given set such that angle between vectors and is acute (i.e. strictly less than ). Otherwise, the point is called good.
The angle between vectors and in 5-dimensional space is defined as , where is the scalar product and is length of .
Given the list of points, print the indices of the good points in ascending order.
The first line of input contains a single integer *n* (1<=≤<=*n*<=≤<=103) — the number of points.
The next *n* lines of input contain five integers *a**i*,<=*b**i*,<=*c**i*,<=*d**i*,<=*e**i* (|*a**i*|,<=|*b**i*|,<=|*c**i*|,<=|*d**i*|,<=|*e**i*|<=≤<=103) — the coordinates of the i-th point. All points are distinct.
First, print a single integer *k* — the number of good points.
Then, print *k* integers, each on their own line — the indices of the good points in ascending order.
Sample Input
6
0 0 0 0 0
1 0 0 0 0
0 1 0 0 0
0 0 1 0 0
0 0 0 1 0
0 0 0 0 1
3
0 0 1 2 0
0 0 9 2 0
0 0 5 9 0
Sample Output
1
1
0
| {"inputs": ["6\n0 0 0 0 0\n1 0 0 0 0\n0 1 0 0 0\n0 0 1 0 0\n0 0 0 1 0\n0 0 0 0 1", "3\n0 0 1 2 0\n0 0 9 2 0\n0 0 5 9 0", "1\n0 0 0 0 0", "2\n0 1 2 3 4\n5 6 7 8 9", "10\n0 -110 68 -51 -155\n-85 -110 68 -51 -155\n85 -70 51 68 -230\n0 -40 51 68 75\n0 5 -51 -68 -190\n85 0 0 0 0\n85 -115 -68 51 35\n85 -75 -187 34 -40\n-85 -110 -136 102 -155\n85 -110 -17 119 -155", "6\n-305 -390 638 -623 343\n479 755 -343 144 89\n-268 843 -461 989 -301\n-986 -274 347 -847 -728\n278 718 -372 -674 270\n-477 562 -489 -858 611", "10\n-705 38 170 -768 689\n-705 86 248 -768 709\n-705 86 170 -742 709\n-705 86 144 -768 709\n-705 86 170 -820 709\n-705 106 170 -768 661\n-822 86 170 -768 709\n-705 98 170 -768 714\n-705 86 170 -768 709\n-601 86 170 -768 709", "11\n358 -724 -232 53 -520\n486 -554 -328 53 -220\n358 -554 -232 -372 -520\n358 -554 -232 308 -520\n868 -554 448 53 -520\n478 -554 -322 53 -600\n358 296 -232 53 -520\n256 -554 -368 53 -520\n230 -554 -136 53 -820\n-182 -554 173 53 -160\n358 -554 -232 53 -520", "8\n-559 581 509 257 343\n-544 451 569 277 343\n-451 451 434 401 343\n-559 451 509 257 83\n-664 451 89 117 343\n-559 451 509 257 993\n-715 451 509 374 343\n-811 451 684 -79 343", "11\n8 8 8 8 8\n2 2 2 2 2\n0 0 0 0 0\n6 6 6 6 6\n7 7 7 7 7\n10 10 10 10 10\n9 9 9 9 9\n3 3 3 3 3\n1 1 1 1 1\n5 5 5 5 5\n4 4 4 4 4", "7\n49 457 -650 325 -325\n0 0 325 325 0\n253 204 -325 0 -325\n204 -253 325 325 325\n408 -506 -325 -325 325\n49 457 -650 325 -650\n0 0 0 650 -325", "11\n1 0 0 0 0\n-1 0 0 0 0\n0 1 0 0 0\n0 -1 0 0 0\n0 0 1 0 0\n0 0 -1 0 0\n0 0 0 1 0\n0 0 0 -1 0\n0 0 0 0 1\n0 0 0 0 -1\n0 0 0 0 0", "4\n0 0 0 0 0\n1 0 0 0 0\n0 1 0 0 0\n0 1 1 0 0"], "outputs": ["1\n1", "0", "1\n1", "2\n1\n2", "0", "0", "1\n9", "1\n11", "0", "0", "0", "1\n11", "0"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 24 | codeforces |
|
fbd8081c2cfde92f282508744d168fcb | Bulls and Cows | The "Bulls and Cows" game needs two people to play. The thinker thinks of a number and the guesser tries to guess it.
The thinker thinks of a four-digit number in the decimal system. All the digits in the number are different and the number may have a leading zero. It can't have more than one leading zero, because all it's digits should be different. The guesser tries to guess the number. He makes a series of guesses, trying experimental numbers and receives answers from the first person in the format "*x* bulls *y* cows". *x* represents the number of digits in the experimental number that occupy the same positions as in the sought number. *y* represents the number of digits of the experimental number that present in the sought number, but occupy different positions. Naturally, the experimental numbers, as well as the sought number, are represented by four-digit numbers where all digits are different and a leading zero can be present.
For example, let's suppose that the thinker thought of the number 0123. Then the guessers' experimental number 1263 will receive a reply "1 bull 2 cows" (3 occupies the same positions in both numbers and 1 and 2 are present in both numbers but they occupy different positions). Also, the answer to number 8103 will be "2 bulls 1 cow" (analogically, 1 and 3 occupy the same positions and 0 occupies a different one).
When the guesser is answered "4 bulls 0 cows", the game is over.
Now the guesser has already made several guesses and wants to know whether his next guess can possibly be the last one.
The first input line contains an integer *n* (1<=≤<=*n*<=≤<=10) which represents the number of already made guesses. Then follow *n* lines in the form of "*a**i* *b**i* *c**i*", where *a**i* is the *i*-th experimental number, *b**i* is the number of bulls, *c**i* is the number of cows (1<=≤<=*i*<=≤<=*n*, 0<=≤<=*b**i*,<=*c**i*,<=*b**i*<=+<=*c**i*<=≤<=4). The experimental numbers are correct, i.e., each of them contains exactly four digits, in each of them all the four digits are different, and there can be a leading zero. All the experimental numbers are different. As the guesser hasn't guessed the number yet, the answer "4 bulls 0 cows" is not present.
If the input data is enough to determine the sought number, print the number with four digits on a single line. If it has less than four digits, add leading zero. If the data is not enough, print "Need more data" without the quotes. If the thinker happens to have made a mistake in his replies, print "Incorrect data" without the quotes.
Sample Input
2
1263 1 2
8103 2 1
2
1234 2 2
1256 0 2
2
0123 1 1
4567 1 2
Sample Output
Need more data2134Incorrect data | {"inputs": ["2\n1263 1 2\n8103 2 1", "2\n1234 2 2\n1256 0 2", "2\n0123 1 1\n4567 1 2", "1\n1234 0 0", "4\n4789 1 0\n7189 1 0\n7829 1 0\n7893 1 0", "4\n1789 1 0\n7198 1 0\n9817 1 0\n8971 1 0", "6\n1234 3 0\n1235 3 0\n1236 3 0\n1237 3 0\n1238 3 0\n1239 3 0", "3\n0123 0 4\n1230 0 4\n3012 0 4", "1\n0714 1 1", "2\n0159 1 0\n0153 1 0", "3\n9703 3 0\n0925 0 2\n3059 0 3", "4\n1689 0 1\n0159 0 2\n4326 0 1\n9048 0 2", "5\n9084 1 0\n4615 0 1\n0826 0 2\n1275 0 3\n5631 0 1", "6\n1586 0 2\n6105 1 1\n5382 0 1\n8164 0 2\n0647 0 1\n6059 1 1", "7\n7401 0 2\n1524 0 0\n1495 0 0\n9230 0 2\n9874 1 0\n9574 1 0\n4693 1 1", "8\n7954 0 1\n5638 0 1\n8204 0 2\n8293 1 1\n3598 0 1\n0894 0 1\n6324 1 2\n0572 0 1", "9\n8742 0 1\n5183 1 1\n6149 1 0\n3568 0 2\n9258 1 2\n5193 1 2\n7403 0 1\n9124 0 2\n3058 0 2", "10\n7098 2 1\n7693 1 1\n6428 0 2\n5209 0 2\n1683 0 2\n0432 0 1\n5697 1 1\n2437 0 0\n4593 1 0\n1784 0 1", "10\n8795 0 3\n4971 1 1\n5032 0 1\n5479 0 3\n2501 0 1\n9052 1 0\n3649 0 1\n1927 1 0\n9173 0 1\n8014 0 2", "10\n0459 2 0\n2371 0 1\n5209 2 1\n1306 0 0\n0213 1 0\n4173 0 0\n5076 0 1\n9674 0 1\n2894 0 3\n3527 0 2", "10\n0132 0 1\n6801 0 1\n8749 1 1\n8036 0 0\n7384 0 2\n8594 1 1\n9307 1 0\n7390 0 1\n6127 1 1\n0381 0 1", "10\n9360 0 1\n5208 0 2\n7861 1 0\n8916 0 1\n5937 1 1\n7082 0 1\n3402 0 2\n7230 1 0\n1794 0 1\n8293 0 2", "2\n3794 2 2\n8647 0 4", "2\n9726 3 1\n6583 1 1", "3\n6093 3 0\n7902 2 0\n2305 2 1", "3\n6108 0 3\n4975 1 1\n0981 1 2", "4\n7153 2 1\n5810 1 0\n8439 0 2\n2794 1 3", "4\n4259 1 3\n1985 0 3\n5263 2 2\n5703 3 1", "5\n9784 3 0\n2657 0 3\n7536 1 0\n0762 1 3\n2014 1 1", "5\n2746 0 3\n1509 3 0\n4135 2 0\n7536 0 4\n1825 3 0", "6\n5132 1 0\n3085 3 0\n0523 1 3\n6912 3 0\n7406 2 1\n3179 2 1", "6\n1034 3 0\n0514 2 2\n1092 2 2\n0814 0 4\n9182 2 0\n9534 0 0", "7\n9230 3 1\n7401 3 1\n6073 0 0\n1495 0 0\n9574 2 0\n4693 2 2\n1524 1 2", "4\n0789 1 0\n7189 1 0\n7829 1 0\n7893 1 0", "1\n1234 3 1", "2\n1234 0 0\n5678 0 0", "2\n1340 0 0\n2435 0 0", "3\n1024 0 1\n5678 3 0\n1542 0 0", "3\n1234 0 4\n2413 0 4\n4123 0 4", "5\n0123 0 1\n4567 0 1\n8901 0 1\n6789 0 1\n2345 0 1", "1\n1234 2 2", "2\n1234 2 2\n2134 2 2", "3\n6789 0 2\n1234 0 2\n3467 0 0", "3\n6789 0 2\n1234 2 0\n3467 0 0", "4\n0123 1 0\n0342 1 0\n5678 2 0\n2981 0 1", "3\n1234 3 0\n5678 0 0\n1239 3 0", "6\n3102 3 0\n4102 3 0\n5102 3 0\n6102 3 0\n7102 3 0\n8102 3 0", "4\n0123 1 3\n3012 1 3\n2301 2 2\n1230 0 4", "10\n0231 2 2\n3021 2 2\n2301 2 2\n0451 2 2\n5041 2 2\n4501 2 2\n0671 2 2\n7061 2 2\n8901 2 2\n0891 2 2", "8\n1023 2 2\n1032 2 2\n1045 2 2\n1054 2 2\n1067 2 2\n1076 2 2\n1089 2 2\n1098 2 2", "2\n5678 1 3\n5432 1 3", "2\n2034 2 2\n2056 0 2", "6\n0132 2 2\n0321 2 2\n3120 2 2\n0213 2 2\n2103 2 2\n1023 2 2", "3\n0235 3 0\n0236 3 0\n7894 1 0", "2\n1234 0 0\n5678 0 0", "2\n1234 3 1\n1253 3 1", "5\n3210 0 4\n0789 1 0\n7189 1 0\n7829 1 0\n7893 1 0", "2\n1234 3 1\n1253 3 1", "2\n1234 0 0\n5678 0 0"], "outputs": ["Need more data", "2134", "Incorrect data", "Need more data", "4123", "Incorrect data", "1230", "2301", "Need more data", "Need more data", "Need more data", "Need more data", "Need more data", "Need more data", "6073", "Need more data", "5239", "8096", "4857", "8259", "1547", "4835", "Incorrect data", "Incorrect data", "Incorrect data", "Incorrect data", "Incorrect data", "Incorrect data", "Incorrect data", "Incorrect data", "Incorrect data", "Incorrect data", "Incorrect data", "0123", "Incorrect data", "Incorrect data", "Need more data", "0678", "Incorrect data", "Incorrect data", "Need more data", "Incorrect data", "Need more data", "1298", "0679", "1230", "9102", "Incorrect data", "Incorrect data", "Incorrect data", "Incorrect data", "0234", "0123", "0234", "Incorrect data", "Incorrect data", "0123", "Incorrect data", "Incorrect data"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 14 | codeforces |
|
fbe7c79a79bced6e28d91c1e7989b060 | Fortune Telling | Marina loves Sasha. But she keeps wondering whether Sasha loves her. Of course, the best way to know it is fortune telling. There are many ways of telling fortune, but Marina has picked the easiest one. She takes in her hand one or several camomiles and tears off the petals one by one. After each petal she pronounces alternatively "Loves" and "Doesn't love", at that Marina always starts with "Loves". There are *n* camomiles growing in the field, possessing the numbers of petals equal to *a*1,<=*a*2,<=... *a**n*. Marina wants to pick a bouquet with the maximal possible total number of petals so that the result would still be "Loves". Help her do that; find the maximal number of petals possible in the bouquet.
The first line contains an integer *n* (1<=≤<=*n*<=≤<=100), which is the number of flowers growing in the field. The second line contains *n* integers *a**i* (1<=≤<=*a**i*<=≤<=100) which represent the number of petals on a given *i*-th camomile.
Print a single number which is the maximal number of petals in the bouquet, the fortune telling on which would result in "Loves". If there are no such bouquet, print 0 instead. The bouquet may consist of a single flower.
Sample Input
1
1
1
2
3
5 6 7
Sample Output
1
0
13
| {"inputs": ["1\n1", "1\n2", "3\n5 6 7", "2\n5 7", "3\n1 2 3", "4\n4 3 1 2", "10\n90 72 76 60 22 87 5 67 17 65", "10\n18 42 20 68 88 10 87 37 55 51", "100\n25 43 35 79 53 13 91 91 45 65 83 57 9 41 39 85 45 71 51 61 59 31 13 63 39 25 21 79 39 91 67 21 61 97 75 93 83 29 79 59 97 11 37 63 51 39 55 91 23 21 17 47 23 35 75 49 5 69 99 5 7 41 17 25 89 15 79 21 63 53 81 43 91 59 91 69 99 85 15 91 51 49 37 65 7 89 81 21 93 61 63 97 93 45 17 13 69 57 25 75", "100\n22 93 43 39 5 39 55 89 97 7 35 63 75 85 97 75 35 91 5 29 97 69 23 97 95 59 23 81 87 67 85 95 33 41 57 9 39 25 55 9 87 57 69 31 23 27 13 81 51 11 61 35 69 59 51 33 73 29 77 75 9 15 41 93 65 89 69 37 51 11 57 21 97 95 13 67 23 69 3 29 83 97 7 49 13 51 65 33 99 9 27 99 55 47 37 11 37 13 91 79", "100\n82 6 42 34 4 32 12 50 16 58 48 92 44 94 36 94 96 50 68 38 78 10 18 88 38 66 60 72 76 24 60 62 86 8 16 14 74 54 38 100 88 28 44 78 90 42 20 24 90 21 81 29 53 95 75 5 57 31 37 69 55 65 1 67 61 71 17 99 15 15 67 77 19 95 79 87 29 97 13 95 61 91 45 77 91 79 55 81 37 81 15 89 67 61 19 25 97 53 7 95", "100\n64 16 64 48 12 88 18 38 12 14 90 82 68 40 90 78 66 50 56 50 78 12 18 100 14 92 70 96 90 26 60 94 88 26 70 100 34 86 8 38 72 24 32 80 56 28 32 48 92 52 71 43 95 23 71 89 51 93 61 39 75 3 19 79 71 11 33 21 61 29 13 55 61 23 17 45 93 11 15 29 45 91 43 9 41 37 99 67 25 33 83 55 59 85 59 41 67 67 37 17", "100\n12 84 30 14 36 18 4 82 26 22 10 88 96 84 50 100 88 40 70 94 94 58 16 50 80 38 94 100 34 20 22 54 34 58 92 18 6 8 22 92 82 28 42 54 96 8 18 40 64 90 58 63 97 89 17 11 21 55 71 91 47 93 55 95 39 81 51 7 77 13 25 65 51 47 47 49 19 35 67 5 7 65 65 65 79 33 71 15 17 91 13 43 81 31 7 17 17 93 9 25", "100\n64 58 12 86 50 16 48 32 30 2 30 36 4 6 96 84 58 94 14 50 28 100 32 84 54 76 26 100 42 100 76 32 86 72 84 16 36 10 26 82 54 64 78 66 62 30 4 80 28 16 44 82 8 2 24 56 28 98 20 92 30 10 28 32 44 18 58 2 12 64 14 4 12 84 16 14 8 78 94 98 34 16 28 76 82 50 40 78 28 16 60 58 64 68 56 46 24 72 72 69", "100\n92 46 50 24 68 60 70 30 52 22 18 74 68 98 20 82 4 46 26 68 100 78 84 58 74 98 38 88 68 86 64 80 82 100 20 22 98 98 52 6 94 10 48 68 2 18 38 22 22 82 44 20 66 72 36 58 64 6 36 60 4 96 76 64 12 90 10 58 64 60 74 28 90 26 24 60 40 58 2 16 76 48 58 36 82 60 24 44 4 78 28 38 8 12 40 16 38 6 66 24", "99\n49 37 55 57 97 79 53 25 89 13 15 77 91 51 73 39 29 83 13 43 79 15 89 97 67 25 23 77 71 41 15 83 39 13 43 1 51 49 1 11 95 57 65 7 79 43 51 33 33 71 97 73 3 65 73 55 21 7 37 75 39 9 21 47 31 97 33 11 61 79 67 63 81 21 77 57 73 19 21 47 55 11 37 31 71 5 15 73 23 93 83 25 37 17 23 75 77 97 93", "99\n26 77 13 25 33 67 89 57 49 35 7 15 17 5 1 73 53 19 35 83 31 49 51 1 25 23 3 63 19 9 53 25 65 43 27 71 3 95 77 89 95 85 67 27 93 3 11 45 99 31 21 35 83 31 43 93 75 93 3 51 11 29 73 3 33 63 57 71 43 15 69 55 53 7 13 73 7 5 57 61 97 53 13 39 79 19 35 71 27 97 19 57 39 51 89 63 21 47 53", "99\n50 22 22 94 100 18 74 2 98 16 66 54 14 90 38 26 12 30 32 66 26 54 44 36 52 30 54 56 36 16 16 34 22 40 64 94 18 2 40 42 76 56 24 18 36 64 14 96 50 69 53 9 27 61 81 37 29 1 21 79 17 81 41 23 89 29 47 65 17 11 95 21 19 71 1 73 45 25 19 83 93 27 21 31 25 3 91 89 59 35 35 7 9 1 97 55 25 65 93", "99\n86 16 38 20 68 60 84 16 28 88 60 48 80 28 4 92 70 60 46 46 20 34 12 100 76 2 40 10 8 86 6 80 50 66 12 34 14 28 26 70 46 64 34 96 10 90 98 96 56 88 49 73 69 93 1 93 23 65 67 45 21 29 5 9 63 31 87 13 97 99 63 57 49 17 49 49 7 37 7 15 53 1 59 53 61 83 91 97 3 71 65 25 13 87 99 15 9 5 87", "99\n82 36 50 30 80 2 48 48 92 10 70 46 72 46 4 60 60 40 4 78 98 8 88 82 70 44 76 50 64 48 82 74 50 100 98 8 60 72 26 50 94 54 58 20 10 66 20 72 26 20 22 29 21 17 31 69 75 91 77 93 81 71 93 91 65 37 41 69 19 15 67 79 39 9 53 69 73 93 85 45 51 5 73 87 49 95 35 71 1 3 65 81 61 59 73 89 79 73 25", "99\n28 50 100 90 56 60 54 16 54 62 48 6 2 14 40 48 28 48 58 68 90 74 82 2 98 4 74 64 34 98 94 24 44 74 50 18 40 100 80 96 10 42 66 46 26 26 84 34 68 84 74 48 8 90 2 36 40 32 18 76 90 64 38 92 86 84 56 84 74 90 4 2 50 34 18 28 30 2 18 80 52 34 10 86 96 76 30 64 88 76 74 4 50 22 20 96 90 12 42", "99\n58 100 2 54 80 84 74 46 92 74 90 4 92 92 18 88 100 80 42 34 80 62 92 94 8 48 98 44 4 74 48 22 26 90 98 44 14 54 80 24 60 50 58 62 94 18 20 4 56 58 52 80 88 82 10 40 36 46 14 22 54 10 36 10 20 76 48 98 2 68 26 96 16 92 50 78 28 8 80 84 82 26 62 20 60 84 2 80 70 98 50 30 64 6 92 58 16 88 27", "42\n26 24 14 18 96 30 56 72 10 32 94 62 68 11 75 45 39 49 37 29 9 1 63 47 81 67 79 81 93 31 69 61 73 67 81 7 37 87 61 17 21 65", "42\n62 46 24 100 68 48 6 4 16 60 48 52 26 56 52 20 100 14 72 80 72 52 76 15 17 23 1 91 71 39 93 5 93 47 59 77 37 17 33 51 39 85", "50\n88 68 16 44 72 6 2 50 2 36 26 98 16 30 6 10 88 76 50 90 44 28 84 28 100 57 59 91 51 37 19 79 69 79 95 81 75 89 19 87 31 49 77 35 79 7 85 41 83 91", "1\n31", "1\n44", "2\n21 63", "2\n90 95", "2\n54 28", "10\n68 96 32 50 55 67 27 93 81 77", "5\n36 56 38 6 28", "6\n34 72 80 5 47 9", "100\n99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99", "100\n100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100", "100\n100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 99 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100", "100\n100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 99 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 99 100 100 100 100 100", "100\n100 100 100 100 100 100 100 100 100 1 100 100 100 100 100 100 100 100 100 100 100 1 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 3 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100", "5\n6 6 6 6 6", "4\n2 3 5 8", "4\n2 4 6 8", "4\n2 3 5 4", "3\n5 7 9"], "outputs": ["1", "0", "13", "7", "5", "9", "561", "439", "5355", "5193", "5445", "5217", "4945", "4725", "0", "4893", "4451", "4333", "4849", "5439", "0", "5353", "2085", "2047", "2723", "31", "0", "63", "185", "0", "619", "0", "247", "9801", "0", "9999", "9899", "9705", "0", "15", "0", "11", "21"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 58 | codeforces |
|
fc15856b0b1fce8b88f14daf45f5346a | Painting Fence | Bizon the Champion isn't just attentive, he also is very hardworking.
Bizon the Champion decided to paint his old fence his favorite color, orange. The fence is represented as *n* vertical planks, put in a row. Adjacent planks have no gap between them. The planks are numbered from the left to the right starting from one, the *i*-th plank has the width of 1 meter and the height of *a**i* meters.
Bizon the Champion bought a brush in the shop, the brush's width is 1 meter. He can make vertical and horizontal strokes with the brush. During a stroke the brush's full surface must touch the fence at all the time (see the samples for the better understanding). What minimum number of strokes should Bizon the Champion do to fully paint the fence? Note that you are allowed to paint the same area of the fence multiple times.
The first line contains integer *n* (1<=≤<=*n*<=≤<=5000) — the number of fence planks. The second line contains *n* space-separated integers *a*1,<=*a*2,<=...,<=*a**n* (1<=≤<=*a**i*<=≤<=109).
Print a single integer — the minimum number of strokes needed to paint the whole fence.
Sample Input
5
2 2 1 2 1
2
2 2
1
5
Sample Output
3
2
1
| {"inputs": ["5\n2 2 1 2 1", "2\n2 2", "1\n5", "5\n2 2 1 2 2", "5\n2 2 1 5 1", "1\n1", "1\n1000000000", "2\n999635584 999595693", "10\n3 3 6 4 2 3 2 2 3 3", "14\n1 1 3 1 1 4 4 4 4 4 4 4 4 4", "6\n100 100 100 100 100 1", "7\n5 5 1 5 5 4 1", "4\n3 4 5 6", "4\n2 3 4 5", "8\n5000 5000 5 5000 5000 5000 5000 5000", "10\n4 4 4 3 4 4 3 4 4 4", "9\n4 4 4 4 20 4 4 4 4", "30\n1 4 5 3 9 7 8 4 5 9 2 3 4 2 3 4 5 5 6 8 1 2 9 4 3 7 2 6 5 4", "6\n3 3 3 3 1 3", "12\n10 10 1 1 1 3 3 3 3 3 3 3", "9\n3 4 5 6 1 9 6 5 3"], "outputs": ["3", "2", "1", "3", "3", "1", "1", "2", "7", "5", "6", "6", "4", "4", "8", "6", "5", "26", "4", "5", "9"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 5 | codeforces |
|
fc1b001cfed3da5734fdd1993f262d18 | Demiurges Play Again | Demiurges Shambambukli and Mazukta love to watch the games of ordinary people. Today, they noticed two men who play the following game.
There is a rooted tree on *n* nodes, *m* of which are leaves (a leaf is a nodes that does not have any children), edges of the tree are directed from parent to children. In the leaves of the tree integers from 1 to *m* are placed in such a way that each number appears exactly in one leaf.
Initially, the root of the tree contains a piece. Two players move this piece in turns, during a move a player moves the piece from its current nodes to one of its children; if the player can not make a move, the game ends immediately. The result of the game is the number placed in the leaf where a piece has completed its movement. The player who makes the first move tries to maximize the result of the game and the second player, on the contrary, tries to minimize the result. We can assume that both players move optimally well.
Demiurges are omnipotent, so before the game they can arbitrarily rearrange the numbers placed in the leaves. Shambambukli wants to rearrange numbers so that the result of the game when both players play optimally well is as large as possible, and Mazukta wants the result to be as small as possible. What will be the outcome of the game, if the numbers are rearranged by Shambambukli, and what will it be if the numbers are rearranged by Mazukta? Of course, the Demiurges choose the best possible option of arranging numbers.
The first line contains a single integer *n* — the number of nodes in the tree (1<=≤<=*n*<=≤<=2·105).
Each of the next *n*<=-<=1 lines contains two integers *u**i* and *v**i* (1<=≤<=*u**i*,<=*v**i*<=≤<=*n*) — the ends of the edge of the tree; the edge leads from node *u**i* to node *v**i*. It is guaranteed that the described graph is a rooted tree, and the root is the node 1.
Print two space-separated integers — the maximum possible and the minimum possible result of the game.
Sample Input
5
1 2
1 3
2 4
2 5
6
1 2
1 3
3 4
1 5
5 6
Sample Output
3 2
3 3
| {"inputs": ["5\n1 2\n1 3\n2 4\n2 5", "6\n1 2\n1 3\n3 4\n1 5\n5 6", "1", "2\n1 2", "3\n1 2\n1 3", "10\n1 2\n1 3\n3 4\n3 5\n4 6\n1 7\n3 8\n2 9\n6 10", "50\n1 2\n2 3\n3 4\n4 5\n5 6\n6 7\n7 8\n8 9\n9 10\n10 11\n11 12\n12 13\n13 14\n14 15\n15 16\n16 17\n17 18\n18 19\n19 20\n20 21\n21 22\n22 23\n23 24\n24 25\n25 26\n26 27\n27 28\n28 29\n29 30\n30 31\n31 32\n32 33\n33 34\n34 35\n35 36\n36 37\n37 38\n38 39\n39 40\n40 41\n41 42\n42 43\n43 44\n44 45\n45 46\n46 47\n47 48\n48 49\n49 50", "22\n1 2\n2 3\n3 4\n1 5\n1 6\n1 7\n7 8\n8 9\n9 10\n10 11\n1 12\n12 13\n12 14\n14 15\n1 16\n16 17\n1 18\n18 19\n1 20\n20 21\n1 22"], "outputs": ["3 2", "3 3", "1 1", "1 1", "2 2", "5 3", "1 1", "10 9"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1 | codeforces |
|
fc3f5cc330553f4dda9bd40e698161f3 | Quantity of Strings | Just in case somebody missed it: this winter is totally cold in Nvodsk! It is so cold that one gets funny thoughts. For example, let's say there are strings with the length exactly *n*, based on the alphabet of size *m*. Any its substring with length equal to *k* is a palindrome. How many such strings exist? Your task is to find their quantity modulo 1000000007 (109<=+<=7). Be careful and don't miss a string or two!
Let us remind you that a string is a palindrome if it can be read the same way in either direction, from the left to the right and from the right to the left.
The first and only line contains three integers: *n*, *m* and *k* (1<=≤<=*n*,<=*m*,<=*k*<=≤<=2000).
Print a single integer — the number of strings of the described type modulo 1000000007 (109<=+<=7).
Sample Input
1 1 1
5 2 4
Sample Output
1
2
| {"inputs": ["1 1 1", "5 2 4", "7 4 20", "8 13 9", "10 23 9", "10 25 8", "997 1752 1000", "784 1 1999", "341 9 342", "777 1 777", "542 13 542", "1501 893 1501", "1321 95 2", "2000 1000 3", "1769 849 1000", "1000 2 1", "345 1777 1", "1999 2000 2000", "1984 1847 1992", "2000 2000 2000", "1451 239 1451", "2000 2000 1", "1230 987 1", "1764 305 843", "1999 98 132", "2000 2 10", "2000 1999 1999", "1678 1999 1234", "7 10 7", "15 1 15", "2000 2000 1000", "1 2000 2000", "10 10 90", "100 100 1", "6 6 6", "10 10 1", "100 10 100", "5 4 5", "5 2 5", "1000 1000 1000", "5 5 1", "1000 1000 1", "4 256 1", "5 5 5", "10 10 10", "100 100 100", "5 2 1", "4 4 4", "15 5 1", "1000 2 1001", "100 7 3", "8 2 8", "200 200 200", "4 4 1", "1999 1999 1999", "17 5 1", "100 5 1", "10 5 1", "11 2 11", "100 1000 1", "3 1000 3", "3 3 3", "3 5 3", "20 3 3", "10 2 1", "7 2 7", "13 9 1", "11 2 5", "13 13 13", "239 123 239"], "outputs": ["1", "2", "16384", "815730721", "529", "25", "184834849", "1", "320920086", "1", "490685740", "889854713", "95", "1000000", "849", "688423210", "756253754", "675798323", "345702953", "321179016", "968856942", "596636543", "890209975", "93025", "98", "2", "3996001", "1999", "10000", "1", "2000", "2000", "999999937", "424090053", "216", "999999937", "319300014", "64", "8", "850431726", "3125", "524700271", "294967268", "125", "100000", "226732710", "32", "16", "517577915", "688423210", "49", "16", "104842676", "256", "21610777", "939447791", "146981449", "9765625", "64", "327648028", "1000000", "9", "25", "9", "1024", "16", "865810542", "4", "62748517", "221051222"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 15 | codeforces |
|
fc5b374c0c467d1243d8dce71f849633 | Remove Duplicates | Petya has an array $a$ consisting of $n$ integers. He wants to remove duplicate (equal) elements.
Petya wants to leave only the rightmost entry (occurrence) for each element of the array. The relative order of the remaining unique elements should not be changed.
The first line contains a single integer $n$ ($1 \le n \le 50$) — the number of elements in Petya's array.
The following line contains a sequence $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 1\,000$) — the Petya's array.
In the first line print integer $x$ — the number of elements which will be left in Petya's array after he removed the duplicates.
In the second line print $x$ integers separated with a space — Petya's array after he removed the duplicates. For each unique element only the rightmost entry should be left.
Sample Input
6
1 5 5 1 6 1
5
2 4 2 4 4
5
6 6 6 6 6
Sample Output
3
5 6 1
2
2 4
1
6
| {"inputs": ["6\n1 5 5 1 6 1", "5\n2 4 2 4 4", "5\n6 6 6 6 6", "7\n1 2 3 4 2 2 3", "9\n100 100 100 99 99 99 100 100 100", "27\n489 489 487 488 750 230 43 645 42 42 489 42 973 42 973 750 645 355 868 112 868 489 750 489 887 489 868", "40\n151 421 421 909 117 222 909 954 227 421 227 954 954 222 421 227 421 421 421 151 421 227 222 222 222 222 421 183 421 227 421 954 222 421 954 421 222 421 909 421", "48\n2 2 2 903 903 2 726 2 2 2 2 2 2 2 2 2 2 726 2 2 2 2 2 2 2 726 2 2 2 2 62 2 2 2 2 2 2 2 2 726 62 726 2 2 2 903 903 2", "1\n1", "13\n5 37 375 5 37 33 37 375 37 2 3 3 2", "50\n1 2 3 4 5 4 3 2 1 2 3 2 1 4 5 5 4 3 2 1 1 2 3 4 5 4 3 2 1 2 3 2 1 4 5 5 4 3 2 1 4 3 2 5 1 6 6 6 6 6", "47\n233 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1", "47\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1", "2\n964 964", "2\n1000 1000", "1\n1000", "45\n991 991 996 996 992 992 999 1000 998 1000 992 999 996 999 991 991 999 993 992 999 1000 997 992 999 996 991 994 996 991 999 1000 993 999 997 999 992 991 997 991 998 998 995 998 994 993", "6\n994 993 1000 998 991 994", "48\n992 995 992 991 994 992 995 999 996 993 999 995 993 992 1000 992 997 996 991 993 992 998 998 998 999 995 992 992 993 992 992 995 996 995 997 991 997 991 999 994 994 997 1000 998 1000 992 1000 999", "3\n6 6 3", "36\n999 1000 993 993 1000 999 996 997 998 995 995 997 999 995 1000 998 998 994 993 998 994 999 1000 995 996 994 991 991 999 996 993 999 996 998 991 997", "49\n991 997 995 991 995 998 994 996 997 991 998 993 992 999 996 995 991 991 999 997 995 993 997 1000 997 993 993 994 999 994 992 991 1000 996 994 996 996 999 992 992 1000 991 997 993 991 994 997 991 996", "2\n1000 999", "28\n997 994 991 994 994 995 1000 992 995 994 994 995 991 996 991 996 991 999 999 993 994 997 995 992 991 992 998 1000", "15\n991 995 995 1000 991 993 997 998 1000 994 1000 992 991 995 992", "6\n1000 1 1000 2 1000 1", "6\n1000 1 1000 2 1 1000", "7\n1 1000 1 999 1000 1 2"], "outputs": ["3\n5 6 1 ", "2\n2 4 ", "1\n6 ", "4\n1 4 2 3 ", "2\n99 100 ", "13\n487 488 230 43 42 973 645 355 112 750 887 489 868 ", "8\n117 151 183 227 954 222 909 421 ", "4\n62 726 903 2 ", "1\n1 ", "6\n5 33 375 37 3 2 ", "6\n4 3 2 5 1 6 ", "2\n233 1 ", "1\n1 ", "1\n964 ", "1\n1000 ", "1\n1000 ", "10\n996 1000 999 992 997 991 995 998 994 993 ", "5\n993 1000 998 991 994 ", "10\n993 996 995 991 994 997 998 992 1000 999 ", "2\n6 3 ", "9\n1000 995 994 993 999 996 998 991 997 ", "10\n998 995 999 992 1000 993 994 997 991 996 ", "2\n1000 999 ", "10\n996 999 993 994 997 995 991 992 998 1000 ", "8\n993 997 998 994 1000 991 995 992 ", "3\n2 1000 1 ", "3\n2 1 1000 ", "4\n999 1000 1 2 "]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 191 | codeforces |
|
fc7661143e4b4a08461bb4de57185e76 | Connecting Universities | Treeland is a country in which there are *n* towns connected by *n*<=-<=1 two-way road such that it's possible to get from any town to any other town.
In Treeland there are 2*k* universities which are located in different towns.
Recently, the president signed the decree to connect universities by high-speed network.The Ministry of Education understood the decree in its own way and decided that it was enough to connect each university with another one by using a cable. Formally, the decree will be done!
To have the maximum sum in the budget, the Ministry decided to divide universities into pairs so that the total length of the required cable will be maximum. In other words, the total distance between universities in *k* pairs should be as large as possible.
Help the Ministry to find the maximum total distance. Of course, each university should be present in only one pair. Consider that all roads have the same length which is equal to 1.
The first line of the input contains two integers *n* and *k* (2<=≤<=*n*<=≤<=200<=000, 1<=≤<=*k*<=≤<=*n*<=/<=2) — the number of towns in Treeland and the number of university pairs. Consider that towns are numbered from 1 to *n*.
The second line contains 2*k* distinct integers *u*1,<=*u*2,<=...,<=*u*2*k* (1<=≤<=*u**i*<=≤<=*n*) — indices of towns in which universities are located.
The next *n*<=-<=1 line contains the description of roads. Each line contains the pair of integers *x**j* and *y**j* (1<=≤<=*x**j*,<=*y**j*<=≤<=*n*), which means that the *j*-th road connects towns *x**j* and *y**j*. All of them are two-way roads. You can move from any town to any other using only these roads.
Print the maximum possible sum of distances in the division of universities into *k* pairs.
Sample Input
7 2
1 5 6 2
1 3
3 2
4 5
3 7
4 3
4 6
9 3
3 2 1 6 5 9
8 9
3 2
2 7
3 4
7 6
4 5
2 1
2 8
Sample Output
6
9
| {"inputs": ["7 2\n1 5 6 2\n1 3\n3 2\n4 5\n3 7\n4 3\n4 6", "9 3\n3 2 1 6 5 9\n8 9\n3 2\n2 7\n3 4\n7 6\n4 5\n2 1\n2 8", "41 3\n11 10 15 35 34 6\n28 2\n25 3\n9 4\n11 5\n7 6\n24 7\n19 8\n1 9\n34 10\n23 11\n17 12\n32 13\n32 14\n32 15\n33 16\n8 17\n19 18\n40 19\n15 20\n6 21\n41 22\n35 23\n13 24\n6 25\n22 26\n4 27\n31 28\n34 29\n41 30\n15 31\n4 32\n41 33\n23 34\n21 35\n13 36\n2 37\n22 38\n34 39\n29 40\n34 41", "2 1\n1 2\n1 2", "2 1\n2 1\n1 2", "3 1\n2 1\n1 2\n2 3", "4 1\n3 2\n1 2\n2 3\n2 4", "4 2\n1 3 2 4\n1 2\n4 3\n1 4", "5 1\n2 3\n1 2\n5 3\n1 4\n4 5", "5 2\n1 2 3 4\n1 2\n2 3\n2 4\n1 5", "6 1\n4 6\n5 2\n1 3\n1 4\n4 5\n3 6", "6 2\n6 5 4 1\n3 2\n1 3\n5 4\n3 5\n1 6", "6 3\n4 5 2 3 6 1\n4 2\n2 3\n1 4\n4 5\n5 6", "6 1\n4 5\n1 2\n1 3\n1 4\n1 5\n1 6", "6 2\n4 5 3 2\n1 2\n1 3\n6 4\n1 5\n1 6", "6 3\n4 5 2 6 3 1\n6 2\n1 3\n1 4\n1 5\n1 6", "6 1\n4 1\n5 2\n1 3\n3 4\n4 5\n5 6", "6 2\n6 4 2 5\n3 2\n1 3\n2 4\n1 5\n5 6", "6 3\n3 4 2 6 1 5\n3 2\n6 3\n3 4\n2 5\n1 6", "30 6\n15 17 2 14 6 30 13 8 10 24 1 19\n23 2\n26 3\n22 4\n7 5\n1 6\n17 7\n29 8\n30 9\n4 10\n28 11\n13 12\n6 13\n23 14\n23 15\n5 16\n30 17\n2 18\n11 19\n19 20\n4 21\n3 22\n16 23\n11 24\n29 25\n27 26\n13 27\n5 28\n23 29\n4 30", "35 15\n6 12 32 18 11 10 29 9 30 27 31 14 8 24 28 25 19 15 21 3 4 1 33 22 23 17 16 13 7 2\n1 2\n20 3\n1 4\n20 5\n20 6\n1 7\n13 8\n4 9\n1 10\n1 11\n1 12\n1 13\n18 14\n10 15\n1 16\n16 17\n1 18\n1 19\n1 20\n20 21\n1 22\n27 23\n25 24\n1 25\n20 26\n20 27\n18 28\n4 29\n13 30\n4 31\n1 32\n20 33\n1 34\n4 35", "5 1\n1 2\n1 2\n2 3\n3 4\n4 5"], "outputs": ["6", "9", "16", "1", "1", "1", "1", "4", "4", "3", "3", "6", "7", "2", "5", "6", "2", "8", "7", "59", "46", "1"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 7 | codeforces |
|
fc7f2f0fe3c4df9f28490f80781ce3fe | The Tag Game | Alice got tired of playing the tag game by the usual rules so she offered Bob a little modification to it. Now the game should be played on an undirected rooted tree of *n* vertices. Vertex 1 is the root of the tree.
Alice starts at vertex 1 and Bob starts at vertex *x* (*x*<=≠<=1). The moves are made in turns, Bob goes first. In one move one can either stay at the current vertex or travel to the neighbouring one.
The game ends when Alice goes to the same vertex where Bob is standing. Alice wants to minimize the total number of moves and Bob wants to maximize it.
You should write a program which will determine how many moves will the game last.
The first line contains two integer numbers *n* and *x* (2<=≤<=*n*<=≤<=2·105, 2<=≤<=*x*<=≤<=*n*).
Each of the next *n*<=-<=1 lines contains two integer numbers *a* and *b* (1<=≤<=*a*,<=*b*<=≤<=*n*) — edges of the tree. It is guaranteed that the edges form a valid tree.
Print the total number of moves Alice and Bob will make.
Sample Input
4 3
1 2
2 3
2 4
5 2
1 2
2 3
3 4
2 5
Sample Output
4
6
| {"inputs": ["4 3\n1 2\n2 3\n2 4", "5 2\n1 2\n2 3\n3 4\n2 5", "2 2\n2 1", "3 3\n2 1\n3 1", "3 3\n1 2\n3 2", "10 4\n5 4\n8 3\n4 6\n5 3\n7 9\n1 3\n5 10\n2 9\n9 8", "10 7\n8 7\n2 8\n2 3\n10 6\n4 6\n4 1\n10 5\n7 5\n9 8", "8 3\n2 1\n3 1\n4 3\n5 1\n6 1\n7 1\n8 6", "34 33\n2 1\n3 2\n4 3\n5 2\n6 3\n7 2\n8 5\n9 7\n10 8\n11 7\n12 7\n13 8\n14 2\n15 10\n16 1\n17 9\n18 14\n19 1\n20 2\n21 8\n22 21\n23 9\n24 6\n25 2\n26 20\n27 5\n28 20\n29 2\n30 10\n31 14\n32 12\n33 15\n34 8"], "outputs": ["4", "6", "2", "2", "4", "8", "16", "4", "12"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 13 | codeforces |
|
fc8112700bb19b73b5f2cb0b6e677aac | Robot Arm | Roger is a robot. He has an arm that is a series of *n* segments connected to each other. The endpoints of the *i*-th segment are initially located at points (*i*<=-<=1,<=0) and (*i*,<=0). The endpoint at (*i*<=-<=1,<=0) is colored red and the endpoint at (*i*,<=0) is colored blue for all segments. Thus, the blue endpoint of the *i*-th segment is touching the red endpoint of the (*i*<=+<=1)-th segment for all valid *i*.
Roger can move his arm in two different ways:
1. He can choose some segment and some value. This is denoted as choosing the segment number *i* and picking some positive *l*. This change happens as follows: the red endpoint of segment number *i* and segments from 1 to *i*<=-<=1 are all fixed in place. Imagine a ray from the red endpoint to the blue endpoint. The blue endpoint and segments *i*<=+<=1 through *n* are translated *l* units in the direction of this ray. In this picture, the red point labeled *A* and segments before *A* stay in place, while the blue point labeled *B* and segments after *B* gets translated.1. He can choose a segment and rotate it. This is denoted as choosing the segment number *i*, and an angle *a*. The red endpoint of the *i*-th segment will stay fixed in place. The blue endpoint of that segment and segments *i*<=+<=1 to *n* will rotate clockwise by an angle of *a* degrees around the red endpoint. In this picture, the red point labeled *A* and segments before *A* stay in place, while the blue point labeled *B* and segments after *B* get rotated around point *A*.
Roger will move his arm *m* times. These transformations are a bit complicated, and Roger easily loses track of where the blue endpoint of the last segment is. Help him compute the coordinates of the blue endpoint of the last segment after applying each operation. Note that these operations are cumulative, and Roger's arm may intersect itself arbitrarily during the moves.
The first line of the input will contain two integers *n* and *m* (1<=≤<=*n*,<=*m*<=≤<=300<=000) — the number of segments and the number of operations to perform.
Each of the next *m* lines contains three integers *x**i*, *y**i* and *z**i* describing a move. If *x**i*<==<=1, this line describes a move of type 1, where *y**i* denotes the segment number and *z**i* denotes the increase in the length. If *x**i*<==<=2, this describes a move of type 2, where *y**i* denotes the segment number, and *z**i* denotes the angle in degrees. (1<=≤<=*x**i*<=≤<=2,<=1<=≤<=*y**i*<=≤<=*n*,<=1<=≤<=*z**i*<=≤<=359)
Print *m* lines. The *i*-th line should contain two real values, denoting the coordinates of the blue endpoint of the last segment after applying operations 1,<=...,<=*i*. Your answer will be considered correct if its absolute or relative error does not exceed 10<=-<=4.
Namely, let's assume that your answer for a particular value of a coordinate is *a* and the answer of the jury is *b*. The checker program will consider your answer correct if for all coordinates.
Sample Input
5 4
1 1 3
2 3 90
2 5 48
1 4 1
Sample Output
8.0000000000 0.0000000000
5.0000000000 -3.0000000000
4.2568551745 -2.6691306064
4.2568551745 -3.6691306064
| {"inputs": ["5 4\n1 1 3\n2 3 90\n2 5 48\n1 4 1", "1 1\n2 1 302", "50 50\n1 41 261\n2 47 324\n1 41 256\n1 31 339\n2 23 116\n2 44 184\n2 32 115\n1 40 301\n2 40 303\n1 29 309\n2 49 348\n2 47 356\n1 41 263\n2 42 276\n1 45 135\n1 33 226\n2 31 166\n1 50 171\n2 47 166\n2 50 284\n2 25 324\n2 48 307\n2 41 176\n1 50 353\n1 45 323\n2 50 343\n1 47 200\n2 48 261\n2 45 280\n1 38 211\n2 47 357\n1 33 318\n1 43 332\n2 38 259\n1 33 242\n1 50 241\n1 50 318\n2 25 308\n1 47 356\n1 48 293\n2 37 335\n2 47 307\n2 46 208\n1 46 220\n2 46 323\n1 48 336\n1 32 289\n2 47 223\n1 40 287\n2 49 145"], "outputs": ["8.0000000000 0.0000000000\n5.0000000000 -3.0000000000\n4.2568551745 -2.6691306064\n4.2568551745 -3.6691306064", "0.5299192642 0.8480480962", "311.0000000000 0.0000000000\n310.2360679775 2.3511410092\n566.2360679775 2.3511410092\n905.2360679775 2.3511410092\n-363.0720164637 -794.8779917553\n-361.3696095871 -781.6662148115\n-457.9608423365 94.5701567479\n-647.3862800425 328.4910911465\n-946.9345047082 -389.9182128351\n-1082.3911890661 -667.6455731415\n-1082.6816353539 -667.3448072059\n-1082.8813719249 -667.1519238413\n-1344.4406304068 -694.6429096807\n-1350.5642099870 -693.5458590935\n-1341.1470860315 -558.8747123084\n-1483.3734944088 -383.2397250..."]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1 | codeforces |
|
fc94946d03aa4b544ec22213ebaed643 | Jury Size | In 2013, the writers of Berland State University should prepare problems for *n* Olympiads. We will assume that the Olympiads are numbered with consecutive integers from 1 to *n*. For each Olympiad we know how many members of the jury must be involved in its preparation, as well as the time required to prepare the problems for her. Namely, the Olympiad number *i* should be prepared by *p**i* people for *t**i* days, the preparation for the Olympiad should be a continuous period of time and end exactly one day before the Olympiad. On the day of the Olympiad the juries who have prepared it, already do not work on it.
For example, if the Olympiad is held on December 9th and the preparation takes 7 people and 6 days, all seven members of the jury will work on the problems of the Olympiad from December, 3rd to December, 8th (the jury members won't be working on the problems of this Olympiad on December 9th, that is, some of them can start preparing problems for some other Olympiad). And if the Olympiad is held on November 3rd and requires 5 days of training, the members of the jury will work from October 29th to November 2nd.
In order not to overload the jury the following rule was introduced: one member of the jury can not work on the same day on the tasks for different Olympiads. Write a program that determines what the minimum number of people must be part of the jury so that all Olympiads could be prepared in time.
The first line contains integer *n* — the number of Olympiads in 2013 (1<=≤<=*n*<=≤<=100). Each of the following *n* lines contains four integers *m**i*, *d**i*, *p**i* and *t**i* — the month and day of the Olympiad (given without leading zeroes), the needed number of the jury members and the time needed to prepare the *i*-th Olympiad (1<=≤<=*m**i*<=≤<=12, *d**i*<=≥<=1, 1<=≤<=*p**i*,<=*t**i*<=≤<=100), *d**i* doesn't exceed the number of days in month *m**i*. The Olympiads are given in the arbitrary order. Several Olympiads can take place in one day.
Use the modern (Gregorian) calendar in the solution. Note that all dates are given in the year 2013. This is not a leap year, so February has 28 days. Please note, the preparation of some Olympiad can start in 2012 year.
Print a single number — the minimum jury size.
Sample Input
2
5 23 1 2
3 13 2 3
3
12 9 2 1
12 8 1 3
12 8 2 2
1
1 10 1 13
Sample Output
2
3
1
| {"inputs": ["2\n5 23 1 2\n3 13 2 3", "3\n12 9 2 1\n12 8 1 3\n12 8 2 2", "1\n1 10 1 13", "3\n3 16 25 1\n3 15 9 34\n3 14 90 87", "4\n2 15 52 53\n2 15 35 81\n2 15 39 96\n2 14 87 7", "5\n3 6 40 89\n3 4 24 64\n2 28 83 1\n3 3 15 32\n3 8 54 28", "10\n8 8 4 18\n8 10 100 36\n8 9 17 51\n8 10 90 8\n8 10 64 45\n8 10 90 81\n8 11 20 86\n8 10 5 41\n8 9 3 91\n8 10 20 68", "15\n10 15 100 22\n9 19 26 16\n9 24 72 99\n9 29 54 83\n9 18 17 6\n9 6 51 59\n9 28 55 77\n9 1 8 89\n11 17 87 21\n9 14 39 93\n9 17 49 37\n10 28 78 84\n8 24 73 5\n11 22 34 59\n10 7 42 96", "20\n6 1 65 16\n5 24 34 85\n5 25 35 53\n5 15 2 63\n5 16 90 38\n5 17 86 79\n5 19 93 59\n5 21 74 87\n5 25 43 99\n5 24 81 66\n5 13 17 91\n5 25 45 46\n5 29 52 22\n5 31 38 56\n5 27 73 20\n5 13 36 13\n5 30 59 89\n5 27 98 44\n5 31 40 1\n5 28 29 21", "20\n10 1 90 91\n10 20 22 46\n10 1 73 39\n9 16 47 65\n10 17 65 68\n10 2 45 10\n10 15 17 60\n10 14 97 95\n10 21 91 62\n9 17 38 19\n9 7 46 82\n10 10 24 26\n9 21 7 54\n9 19 35 29\n10 20 17 24\n10 10 45 62\n9 27 11 29\n10 17 87 39\n10 7 36 56\n10 14 22 78", "25\n6 16 72 38\n6 16 88 2\n6 18 81 85\n6 15 86 24\n6 16 78 16\n6 19 63 25\n6 19 47 11\n6 18 8 81\n6 18 81 41\n6 15 73 89\n6 16 2 82\n6 16 55 39\n6 17 41 80\n6 18 97 16\n6 17 94 53\n6 17 60 10\n6 18 2 80\n6 15 100 26\n6 16 13 97\n6 18 24 99\n6 18 28 83\n6 18 11 32\n6 16 38 16\n6 15 42 45\n6 17 100 40", "25\n4 25 70 67\n8 13 28 53\n11 1 91 37\n8 27 13 66\n5 10 38 96\n10 11 22 30\n8 7 59 14\n2 19 71 67\n11 8 58 6\n6 1 11 11\n3 16 34 55\n8 13 91 75\n2 1 59 22\n5 14 11 19\n5 14 20 25\n7 28 75 72\n11 2 27 72\n5 2 67 22\n7 21 70 95\n3 11 37 41\n3 30 69 78\n9 4 96 80\n3 27 39 29\n3 31 18 63\n9 17 87 11", "25\n1 18 59 56\n1 19 82 8\n2 6 8 2\n1 17 92 33\n1 25 26 36\n2 22 37 96\n2 5 42 22\n2 12 82 49\n1 20 57 44\n1 30 11 61\n2 4 14 15\n2 7 40 93\n2 15 59 77\n1 20 89 17\n2 5 81 36\n2 3 54 83\n1 19 67 1\n2 15 6 70\n2 15 64 21\n1 22 77 21\n2 4 62 85\n2 23 81 17\n2 1 47 51\n2 5 56 19\n1 29 73 57", "40\n2 20 53 27\n2 20 19 50\n2 20 80 69\n2 20 55 44\n2 20 26 27\n2 20 19 48\n2 20 64 15\n2 20 44 76\n2 20 22 88\n2 20 74 99\n2 20 32 38\n2 20 27 22\n2 20 2 50\n2 20 37 79\n2 20 15 48\n2 20 15 46\n2 20 69 57\n2 20 99 49\n2 20 7 89\n2 20 52 72\n2 20 15 78\n2 20 91 55\n2 20 52 36\n2 20 36 69\n2 20 17 78\n2 20 12 57\n2 20 84 53\n2 20 97 30\n2 20 82 8\n2 20 2 75\n2 20 19 11\n2 20 96 95\n2 20 98 49\n2 20 38 29\n2 20 39 30\n2 20 90 92\n2 20 9 70\n2 20 57 93\n2 20 47 92\n2 20 5 44", "40\n10 10 48 86\n10 10 34 79\n10 9 85 56\n10 8 60 27\n10 7 36 17\n10 7 23 48\n10 7 56 96\n10 8 10 2\n10 7 24 54\n10 10 10 23\n10 7 53 77\n10 10 70 10\n10 9 51 41\n10 8 99 100\n10 6 82 45\n10 10 7 22\n10 7 56 33\n10 9 12 70\n10 8 33 35\n10 6 58 77\n10 9 71 52\n10 9 9 73\n10 8 92 30\n10 10 58 73\n10 9 93 12\n10 9 90 83\n10 6 29 99\n10 10 59 58\n10 9 27 59\n10 8 78 21\n10 8 5 93\n10 10 4 99\n10 6 38 85\n10 8 52 33\n10 10 83 31\n10 10 31 46\n10 6 7 65\n10 10 25 6\n10 9 84 71\n10 9 16 51", "40\n10 23 54 73\n11 10 58 84\n11 9 65 84\n11 20 45 92\n11 11 35 96\n11 6 66 16\n11 12 1 13\n11 15 8 18\n11 18 72 86\n10 24 62 38\n10 27 79 12\n11 11 24 59\n11 14 6 99\n11 6 33 100\n11 10 37 60\n11 10 67 8\n11 6 73 25\n11 8 91 3\n10 28 45 32\n11 14 64 37\n11 21 15 79\n10 29 79 53\n11 13 29 29\n10 23 76 76\n11 18 90 94\n10 30 99 49\n11 21 97 78\n10 24 27 8\n10 23 58 11\n11 3 16 30\n11 17 14 53\n11 6 13 59\n11 10 21 20\n11 15 60 24\n11 2 18 59\n11 14 69 21\n11 19 69 53\n10 26 34 43\n11 11 50 17\n11 7 50 47", "40\n10 30 51 50\n9 16 29 39\n9 30 84 87\n9 9 6 22\n10 12 95 1\n9 2 37 64\n8 17 8 96\n9 15 23 7\n11 1 8 68\n10 7 29 81\n8 19 96 50\n9 6 14 25\n9 25 3 98\n11 4 62 17\n8 30 8 9\n8 18 93 81\n10 29 94 31\n8 10 28 69\n8 30 89 63\n10 15 40 8\n10 15 59 91\n11 15 46 89\n9 6 59 8\n11 13 42 60\n10 13 57 50\n10 23 81 71\n11 1 63 85\n9 4 9 14\n10 7 5 92\n8 26 43 81\n9 27 56 95\n9 15 65 17\n9 12 81 41\n8 10 50 58\n10 27 5 64\n11 15 88 16\n9 25 17 81\n9 21 97 96\n11 13 88 95\n9 19 54 14", "2\n10 25 31 91\n11 14 4 85", "3\n4 20 49 95\n4 19 74 81\n4 20 85 50", "1\n9 30 34 20", "2\n1 1 1 100\n1 1 1 100", "2\n1 1 5 66\n1 1 7 55", "2\n1 5 7 3\n1 1 10 6"], "outputs": ["2", "3", "1", "99", "213", "216", "413", "521", "985", "807", "1384", "373", "1076", "1797", "1848", "1683", "1095", "35", "208", "34", "2", "12", "10"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 9 | codeforces |
|
fcc1dd7c8d355e18d211514350671eac | Curriculum Vitae | Hideo Kojima has just quit his job at Konami. Now he is going to find a new place to work. Despite being such a well-known person, he still needs a CV to apply for a job.
During all his career Hideo has produced *n* games. Some of them were successful, some were not. Hideo wants to remove several of them (possibly zero) from his CV to make a better impression on employers. As a result there should be no unsuccessful game which comes right after successful one in his CV.
More formally, you are given an array *s*1,<=*s*2,<=...,<=*s**n* of zeros and ones. Zero corresponds to an unsuccessful game, one — to a successful one. Games are given in order they were produced, and Hideo can't swap these values. He should remove some elements from this array in such a way that no zero comes right after one.
Besides that, Hideo still wants to mention as much games in his CV as possible. Help this genius of a man determine the maximum number of games he can leave in his CV.
The first line contains one integer number *n* (1<=≤<=*n*<=≤<=100).
The second line contains *n* space-separated integer numbers *s*1,<=*s*2,<=...,<=*s**n* (0<=≤<=*s**i*<=≤<=1). 0 corresponds to an unsuccessful game, 1 — to a successful one.
Print one integer — the maximum number of games Hideo can leave in his CV so that no unsuccessful game comes after a successful one.
Sample Input
4
1 1 0 1
6
0 1 0 0 1 0
1
0
Sample Output
3
4
1
| {"inputs": ["4\n1 1 0 1", "6\n0 1 0 0 1 0", "1\n0", "100\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0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 1 0 0 1 0 0 0 0 1 0 1 0 0 1 0", "4\n1 0 0 1", "2\n0 1", "5\n0 1 0 0 1", "3\n1 0 1", "3\n1 1 0", "16\n1 1 1 1 1 0 0 0 0 0 1 0 1 0 0 1"], "outputs": ["3", "4", "1", "100", "80", "1", "53", "100", "2", "6", "52", "42", "3", "2", "4", "2", "2", "9"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 88 | codeforces |
|
fccff7b6eaf8ac7a2e50f9817666b74d | Flowers | We saw the little game Marmot made for Mole's lunch. Now it's Marmot's dinner time and, as we all know, Marmot eats flowers. At every dinner he eats some red and white flowers. Therefore a dinner can be represented as a sequence of several flowers, some of them white and some of them red.
But, for a dinner to be tasty, there is a rule: Marmot wants to eat white flowers only in groups of size *k*.
Now Marmot wonders in how many ways he can eat between *a* and *b* flowers. As the number of ways could be very large, print it modulo 1000000007 (109<=+<=7).
Input contains several test cases.
The first line contains two integers *t* and *k* (1<=≤<=*t*,<=*k*<=≤<=105), where *t* represents the number of test cases.
The next *t* lines contain two integers *a**i* and *b**i* (1<=≤<=*a**i*<=≤<=*b**i*<=≤<=105), describing the *i*-th test.
Print *t* lines to the standard output. The *i*-th line should contain the number of ways in which Marmot can eat between *a**i* and *b**i* flowers at dinner modulo 1000000007 (109<=+<=7).
Sample Input
3 2
1 3
2 3
4 4
Sample Output
6
5
5
| {"inputs": ["3 2\n1 3\n2 3\n4 4", "1 1\n1 3", "1 2\n64329 79425"], "outputs": ["6\n5\n5", "14", "0"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 28 | codeforces |
|
fcd19da2696717da4756587afbd33c82 | Epic Game | Simon and Antisimon play a game. Initially each player receives one fixed positive integer that doesn't change throughout the game. Simon receives number *a* and Antisimon receives number *b*. They also have a heap of *n* stones. The players take turns to make a move and Simon starts. During a move a player should take from the heap the number of stones equal to the greatest common divisor of the fixed number he has received and the number of stones left in the heap. A player loses when he cannot take the required number of stones (i. e. the heap has strictly less stones left than one needs to take).
Your task is to determine by the given *a*, *b* and *n* who wins the game.
The only string contains space-separated integers *a*, *b* and *n* (1<=≤<=*a*,<=*b*,<=*n*<=≤<=100) — the fixed numbers Simon and Antisimon have received correspondingly and the initial number of stones in the pile.
If Simon wins, print "0" (without the quotes), otherwise print "1" (without the quotes).
Sample Input
3 5 9
1 1 100
Sample Output
01 | {"inputs": ["3 5 9", "1 1 100", "23 12 16", "95 26 29", "73 32 99", "1 1 1", "41 12 65", "13 61 100", "100 100 10", "12 24 26", "73 21 96", "17 22 81", "14 88 97", "42 81 17", "34 36 19", "21 87 12", "97 92 98", "49 25 62", "29 17 44", "10 1 10", "99 98 100", "100 100 1", "11 99 55", "8 13 21", "34 55 89", "21 34 55", "13 21 34", "34 21 55", "10 20 84", "4 2 5", "3 2 3", "31 23 1", "100 100 100", "100 1 100", "1 100 100", "1 1 100", "17 23 100", "99 98 100", "1 1 2", "2 1 1", "1 2 1", "2 1 2", "10 10 3", "2 2 1", "9 5 1"], "outputs": ["0", "1", "1", "1", "1", "0", "1", "1", "0", "1", "1", "1", "1", "0", "1", "1", "1", "1", "1", "0", "1", "0", "0", "0", "0", "1", "1", "0", "1", "0", "0", "0", "0", "0", "1", "1", "1", "1", "1", "0", "0", "0", "1", "0", "0"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 780 | codeforces |
|
fcf8b343a907be0b2bab4149edfec28a | Valhalla Siege | Ivar the Boneless is a great leader. He is trying to capture Kattegat from Lagertha. The war has begun and wave after wave Ivar's warriors are falling in battle.
Ivar has $n$ warriors, he places them on a straight line in front of the main gate, in a way that the $i$-th warrior stands right after $(i-1)$-th warrior. The first warrior leads the attack.
Each attacker can take up to $a_i$ arrows before he falls to the ground, where $a_i$ is the $i$-th warrior's strength.
Lagertha orders her warriors to shoot $k_i$ arrows during the $i$-th minute, the arrows one by one hit the first still standing warrior. After all Ivar's warriors fall and all the currently flying arrows fly by, Thor smashes his hammer and all Ivar's warriors get their previous strengths back and stand up to fight again. In other words, if all warriors die in minute $t$, they will all be standing to fight at the end of minute $t$.
The battle will last for $q$ minutes, after each minute you should tell Ivar what is the number of his standing warriors.
The first line contains two integers $n$ and $q$ ($1 \le n, q \leq 200\,000$) — the number of warriors and the number of minutes in the battle.
The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \leq a_i \leq 10^9$) that represent the warriors' strengths.
The third line contains $q$ integers $k_1, k_2, \ldots, k_q$ ($1 \leq k_i \leq 10^{14}$), the $i$-th of them represents Lagertha's order at the $i$-th minute: $k_i$ arrows will attack the warriors.
Output $q$ lines, the $i$-th of them is the number of standing warriors after the $i$-th minute.
Sample Input
5 5
1 2 1 2 1
3 10 1 1 1
4 4
1 2 3 4
9 1 10 6
Sample Output
3
5
4
4
3
1
4
4
1
| {"inputs": ["5 5\n1 2 1 2 1\n3 10 1 1 1", "4 4\n1 2 3 4\n9 1 10 6", "10 3\n1 1 1 1 1 1 1 1 1 1\n10 10 5", "1 1\n56563128\n897699770", "100 55\n1 2 4 4 3 5 5 2 3 4 2 1 1 2 3 5 1 5 4 2 5 4 4 3 3 5 3 4 4 5 5 2 3 3 4 4 3 4 5 5 5 5 3 5 1 2 4 3 4 5 3 3 2 1 4 5 3 4 4 1 5 1 5 2 2 1 4 5 3 3 1 4 2 5 4 5 3 2 5 5 2 3 2 3 2 2 3 4 4 4 1 4 2 4 5 3 1 3 3 1\n5 2 1 4 3 4 3 1 4 4 1 2 3 2 1 5 5 4 5 4 2 5 2 1 5 1 4 4 3 5 4 5 1 4 4 1 5 3 1 5 2 4 1 3 2 5 4 5 4 3 4 2 2 4 3"], "outputs": ["3\n5\n4\n4\n3", "1\n4\n4\n1", "10\n10\n5", "1", "98\n97\n97\n96\n95\n94\n94\n94\n92\n91\n91\n90\n87\n86\n86\n85\n83\n82\n80\n80\n79\n78\n77\n77\n75\n75\n74\n73\n72\n71\n70\n69\n69\n67\n66\n66\n65\n64\n63\n62\n62\n61\n61\n60\n60\n59\n58\n57\n54\n54\n52\n52\n51\n51\n50"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 129 | codeforces |
|
fd02ef2593cc46942a3abcb5c85a76c8 | Case of Matryoshkas | Andrewid the Android is a galaxy-famous detective. He is now investigating the case of vandalism at the exhibition of contemporary art.
The main exhibit is a construction of *n* matryoshka dolls that can be nested one into another. The matryoshka dolls are numbered from 1 to *n*. A matryoshka with a smaller number can be nested in a matryoshka with a higher number, two matryoshkas can not be directly nested in the same doll, but there may be chain nestings, for example, 1<=→<=2<=→<=4<=→<=5.
In one second, you can perform one of the two following operations:
- Having a matryoshka *a* that isn't nested in any other matryoshka and a matryoshka *b*, such that *b* doesn't contain any other matryoshka and is not nested in any other matryoshka, you may put *a* in *b*; - Having a matryoshka *a* directly contained in matryoshka *b*, such that *b* is not nested in any other matryoshka, you may get *a* out of *b*.
According to the modern aesthetic norms the matryoshka dolls on display were assembled in a specific configuration, i.e. as several separate chains of nested matryoshkas, but the criminal, following the mysterious plan, took out all the dolls and assembled them into a single large chain (1<=→<=2<=→<=...<=→<=*n*). In order to continue the investigation Andrewid needs to know in what minimum time it is possible to perform this action.
The first line contains integers *n* (1<=≤<=*n*<=≤<=105) and *k* (1<=≤<=*k*<=≤<=105) — the number of matryoshkas and matryoshka chains in the initial configuration.
The next *k* lines contain the descriptions of the chains: the *i*-th line first contains number *m**i* (1<=≤<=*m**i*<=≤<=*n*), and then *m**i* numbers *a**i*1,<=*a**i*2,<=...,<=*a**im**i* — the numbers of matryoshkas in the chain (matryoshka *a**i*1 is nested into matryoshka *a**i*2, that is nested into matryoshka *a**i*3, and so on till the matryoshka *a**im**i* that isn't nested into any other matryoshka).
It is guaranteed that *m*1<=+<=*m*2<=+<=...<=+<=*m**k*<==<=*n*, the numbers of matryoshkas in all the chains are distinct, in each chain the numbers of matryoshkas follow in the ascending order.
In the single line print the minimum number of seconds needed to assemble one large chain from the initial configuration.
Sample Input
3 2
2 1 2
1 3
7 3
3 1 3 7
2 2 5
2 4 6
Sample Output
1
10
| {"inputs": ["3 2\n2 1 2\n1 3", "7 3\n3 1 3 7\n2 2 5\n2 4 6", "1 1\n1 1", "3 2\n1 2\n2 1 3", "5 3\n1 4\n3 1 2 3\n1 5", "8 5\n2 1 2\n2 3 4\n1 5\n2 6 7\n1 8", "10 10\n1 5\n1 4\n1 10\n1 3\n1 7\n1 1\n1 8\n1 6\n1 9\n1 2", "20 6\n3 8 9 13\n3 4 14 20\n2 15 17\n3 2 5 11\n5 7 10 12 18 19\n4 1 3 6 16", "50 10\n6 17 21 31 42 45 49\n6 11 12 15 22 26 38\n3 9 29 36\n3 10 23 43\n5 14 19 28 46 48\n2 30 39\n6 13 20 24 33 37 47\n8 1 2 3 4 5 6 7 8\n7 16 18 25 27 34 40 44\n4 32 35 41 50", "13 8\n1 5\n2 8 10\n1 13\n4 1 2 3 11\n1 7\n2 6 12\n1 4\n1 9", "21 13\n1 18\n2 8 13\n1 21\n1 17\n2 7 9\n1 20\n1 19\n1 4\n1 16\n2 5 6\n3 12 14 15\n3 1 2 3\n2 10 11", "50 50\n1 2\n1 5\n1 28\n1 46\n1 42\n1 24\n1 3\n1 37\n1 33\n1 50\n1 23\n1 40\n1 43\n1 26\n1 49\n1 34\n1 8\n1 45\n1 15\n1 1\n1 22\n1 18\n1 27\n1 25\n1 13\n1 39\n1 38\n1 10\n1 44\n1 6\n1 17\n1 47\n1 7\n1 35\n1 20\n1 36\n1 31\n1 21\n1 32\n1 29\n1 4\n1 12\n1 19\n1 16\n1 11\n1 41\n1 9\n1 14\n1 30\n1 48", "100 3\n45 1 2 3 4 5 6 7 8 9 19 21 24 27 28 30 34 35 37 39 40 41 42 43 46 47 48 51 52 55 58 59 61 63 64 66 69 71 76 80 85 86 88 89 94 99\n26 10 11 15 18 23 29 31 33 36 38 44 49 54 56 60 62 65 75 78 82 83 84 95 96 97 98\n29 12 13 14 16 17 20 22 25 26 32 45 50 53 57 67 68 70 72 73 74 77 79 81 87 90 91 92 93 100", "100 19\n6 62 72 83 91 94 97\n3 61 84 99\n1 63\n5 46 53 56 69 78\n5 41 43 49 74 89\n5 55 57 79 85 87\n3 47 59 98\n3 64 76 82\n3 48 66 75\n2 60 88\n2 67 77\n4 40 51 73 95\n41 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 44 71 81\n4 58 65 90 93\n1 100\n5 39 45 52 80 86\n2 50 68\n1 92\n4 42 54 70 96"], "outputs": ["1", "10", "0", "3", "2", "8", "9", "33", "75", "13", "24", "49", "180", "106"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 36 | codeforces |
|
fd0688f764c0b19252d911aef21b9a3b | AND-permutations | Given an integer *N*, find two permutations:
1. Permutation *p* of numbers from 1 to *N* such that *p**i*<=≠<=*i* and *p**i*<=&<=*i*<==<=0 for all *i*<==<=1,<=2,<=...,<=*N*. 1. Permutation *q* of numbers from 1 to *N* such that *q**i*<=≠<=*i* and *q**i*<=&<=*i*<=≠<=0 for all *i*<==<=1,<=2,<=...,<=*N*.
& is the [bitwise AND operation](https://en.wikipedia.org/wiki/Bitwise_operation#AND).
The input consists of one line containing a single integer *N* (1<=≤<=*N*<=≤<=105).
For each subtask, if the required permutation doesn't exist, output a single line containing the word "NO"; otherwise output the word "YES" in the first line and *N* elements of the permutation, separated by spaces, in the second line. If there are several possible permutations in a subtask, output any of them.
Sample Input
3
6
Sample Output
NO
NO
YES
6 5 4 3 2 1
YES
3 6 2 5 1 4
| {"inputs": ["3", "6", "100000", "15", "16", "17", "1", "2", "4", "5", "7", "8", "9", "10", "31", "32", "33", "63", "64", "65", "127", "128", "129", "255", "256", "257", "511", "512", "513", "1023", "1024", "1025", "2047", "2048", "2049", "4095", "4096", "4097", "8191", "8192", "8193", "16383", "16384", "16385", "32767", "32768", "32769", "65535", "65536", "65537", "53387", "47607", "21151", "83195", "38763", "94960", "53020", "78210", "77860", "30600", "28302", "63472", "26562", "25970", "36028", "81982", "89018", "11650", "2710", "30102"], "outputs": ["NO\nNO", "YES\n6 5 4 3 2 1 \nYES\n3 6 2 5 1 4", "YES\n30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 32 31 94 93 92 91 90 89 88 87 86 85 84 83 82 81 80 79 78 77 76 75 74 73 72 71 70 69 68 67 66 65 64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 160 159 158 157 156 155 154 153 152 151 150 149 148 147 146 145 144 143 142 141 140 139 138 137 136 135 134 133 132 131 130 129 128 127 126 125 124 123 122 121 120 119 118 117 116 115 114 113 112 111 110 109 108 107 106 105 104 103 1...", "NO\nYES\n7 3 6 5 1 2 4 9 10 11 12 13 14 15 8", "YES\n14 13 12 11 10 9 8 7 6 5 4 3 2 1 16 15 \nNO", "NO\nYES\n7 3 6 5 1 2 4 9 10 11 12 13 14 15 8 17 16", "NO\nNO", "YES\n2 1 \nNO", "YES\n2 1 4 3 \nNO", "NO\nNO", "NO\nYES\n7 3 6 5 1 2 4", "YES\n6 5 4 3 2 1 8 7 \nNO", "NO\nYES\n7 3 6 5 1 2 4 9 8", "YES\n2 1 4 3 10 9 8 7 6 5 \nYES\n7 3 6 5 1 2 4 9 10 8", "NO\nYES\n7 3 6 5 1 2 4 9 10 11 12 13 14 15 8 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 16", "YES\n30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 32 31 \nNO", "NO\nYES\n7 3 6 5 1 2 4 9 10 11 12 13 14 15 8 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 16 33 32", "NO\nYES\n7 3 6 5 1 2 4 9 10 11 12 13 14 15 8 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 16 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 32", "YES\n62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 64 63 \nNO", "NO\nYES\n7 3 6 5 1 2 4 9 10 11 12 13 14 15 8 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 16 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 32 65 64", "NO\nYES\n7 3 6 5 1 2 4 9 10 11 12 13 14 15 8 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 16 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 32 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 64", "YES\n126 125 124 123 122 121 120 119 118 117 116 115 114 113 112 111 110 109 108 107 106 105 104 103 102 101 100 99 98 97 96 95 94 93 92 91 90 89 88 87 86 85 84 83 82 81 80 79 78 77 76 75 74 73 72 71 70 69 68 67 66 65 64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 128 127 \nNO", "NO\nYES\n7 3 6 5 1 2 4 9 10 11 12 13 14 15 8 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 16 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 32 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 64 129 128", "NO\nYES\n7 3 6 5 1 2 4 9 10 11 12 13 14 15 8 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 16 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 32 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 64 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 15...", "YES\n254 253 252 251 250 249 248 247 246 245 244 243 242 241 240 239 238 237 236 235 234 233 232 231 230 229 228 227 226 225 224 223 222 221 220 219 218 217 216 215 214 213 212 211 210 209 208 207 206 205 204 203 202 201 200 199 198 197 196 195 194 193 192 191 190 189 188 187 186 185 184 183 182 181 180 179 178 177 176 175 174 173 172 171 170 169 168 167 166 165 164 163 162 161 160 159 158 157 156 155 154 153 152 151 150 149 148 147 146 145 144 143 142 141 140 139 138 137 136 135 134 133 132 131 130 129 12...", "NO\nYES\n7 3 6 5 1 2 4 9 10 11 12 13 14 15 8 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 16 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 32 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 64 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 15...", "NO\nYES\n7 3 6 5 1 2 4 9 10 11 12 13 14 15 8 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 16 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 32 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 64 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 15...", "YES\n510 509 508 507 506 505 504 503 502 501 500 499 498 497 496 495 494 493 492 491 490 489 488 487 486 485 484 483 482 481 480 479 478 477 476 475 474 473 472 471 470 469 468 467 466 465 464 463 462 461 460 459 458 457 456 455 454 453 452 451 450 449 448 447 446 445 444 443 442 441 440 439 438 437 436 435 434 433 432 431 430 429 428 427 426 425 424 423 422 421 420 419 418 417 416 415 414 413 412 411 410 409 408 407 406 405 404 403 402 401 400 399 398 397 396 395 394 393 392 391 390 389 388 387 386 385 38...", "NO\nYES\n7 3 6 5 1 2 4 9 10 11 12 13 14 15 8 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 16 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 32 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 64 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 15...", "NO\nYES\n7 3 6 5 1 2 4 9 10 11 12 13 14 15 8 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 16 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 32 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 64 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 15...", "YES\n1022 1021 1020 1019 1018 1017 1016 1015 1014 1013 1012 1011 1010 1009 1008 1007 1006 1005 1004 1003 1002 1001 1000 999 998 997 996 995 994 993 992 991 990 989 988 987 986 985 984 983 982 981 980 979 978 977 976 975 974 973 972 971 970 969 968 967 966 965 964 963 962 961 960 959 958 957 956 955 954 953 952 951 950 949 948 947 946 945 944 943 942 941 940 939 938 937 936 935 934 933 932 931 930 929 928 927 926 925 924 923 922 921 920 919 918 917 916 915 914 913 912 911 910 909 908 907 906 905 904 903 902...", "NO\nYES\n7 3 6 5 1 2 4 9 10 11 12 13 14 15 8 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 16 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 32 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 64 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 15...", "NO\nYES\n7 3 6 5 1 2 4 9 10 11 12 13 14 15 8 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 16 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 32 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 64 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 15...", "YES\n2046 2045 2044 2043 2042 2041 2040 2039 2038 2037 2036 2035 2034 2033 2032 2031 2030 2029 2028 2027 2026 2025 2024 2023 2022 2021 2020 2019 2018 2017 2016 2015 2014 2013 2012 2011 2010 2009 2008 2007 2006 2005 2004 2003 2002 2001 2000 1999 1998 1997 1996 1995 1994 1993 1992 1991 1990 1989 1988 1987 1986 1985 1984 1983 1982 1981 1980 1979 1978 1977 1976 1975 1974 1973 1972 1971 1970 1969 1968 1967 1966 1965 1964 1963 1962 1961 1960 1959 1958 1957 1956 1955 1954 1953 1952 1951 1950 1949 1948 1947 1946 1...", "NO\nYES\n7 3 6 5 1 2 4 9 10 11 12 13 14 15 8 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 16 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 32 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 64 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 15...", "NO\nYES\n7 3 6 5 1 2 4 9 10 11 12 13 14 15 8 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 16 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 32 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 64 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 15...", "YES\n4094 4093 4092 4091 4090 4089 4088 4087 4086 4085 4084 4083 4082 4081 4080 4079 4078 4077 4076 4075 4074 4073 4072 4071 4070 4069 4068 4067 4066 4065 4064 4063 4062 4061 4060 4059 4058 4057 4056 4055 4054 4053 4052 4051 4050 4049 4048 4047 4046 4045 4044 4043 4042 4041 4040 4039 4038 4037 4036 4035 4034 4033 4032 4031 4030 4029 4028 4027 4026 4025 4024 4023 4022 4021 4020 4019 4018 4017 4016 4015 4014 4013 4012 4011 4010 4009 4008 4007 4006 4005 4004 4003 4002 4001 4000 3999 3998 3997 3996 3995 3994 3...", "NO\nYES\n7 3 6 5 1 2 4 9 10 11 12 13 14 15 8 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 16 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 32 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 64 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 15...", "NO\nYES\n7 3 6 5 1 2 4 9 10 11 12 13 14 15 8 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 16 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 32 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 64 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 15...", "YES\n8190 8189 8188 8187 8186 8185 8184 8183 8182 8181 8180 8179 8178 8177 8176 8175 8174 8173 8172 8171 8170 8169 8168 8167 8166 8165 8164 8163 8162 8161 8160 8159 8158 8157 8156 8155 8154 8153 8152 8151 8150 8149 8148 8147 8146 8145 8144 8143 8142 8141 8140 8139 8138 8137 8136 8135 8134 8133 8132 8131 8130 8129 8128 8127 8126 8125 8124 8123 8122 8121 8120 8119 8118 8117 8116 8115 8114 8113 8112 8111 8110 8109 8108 8107 8106 8105 8104 8103 8102 8101 8100 8099 8098 8097 8096 8095 8094 8093 8092 8091 8090 8...", "NO\nYES\n7 3 6 5 1 2 4 9 10 11 12 13 14 15 8 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 16 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 32 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 64 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 15...", "NO\nYES\n7 3 6 5 1 2 4 9 10 11 12 13 14 15 8 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 16 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 32 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 64 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 15...", "YES\n16382 16381 16380 16379 16378 16377 16376 16375 16374 16373 16372 16371 16370 16369 16368 16367 16366 16365 16364 16363 16362 16361 16360 16359 16358 16357 16356 16355 16354 16353 16352 16351 16350 16349 16348 16347 16346 16345 16344 16343 16342 16341 16340 16339 16338 16337 16336 16335 16334 16333 16332 16331 16330 16329 16328 16327 16326 16325 16324 16323 16322 16321 16320 16319 16318 16317 16316 16315 16314 16313 16312 16311 16310 16309 16308 16307 16306 16305 16304 16303 16302 16301 16300 16299 16...", "NO\nYES\n7 3 6 5 1 2 4 9 10 11 12 13 14 15 8 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 16 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 32 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 64 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 15...", "NO\nYES\n7 3 6 5 1 2 4 9 10 11 12 13 14 15 8 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 16 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 32 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 64 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 15...", "YES\n32766 32765 32764 32763 32762 32761 32760 32759 32758 32757 32756 32755 32754 32753 32752 32751 32750 32749 32748 32747 32746 32745 32744 32743 32742 32741 32740 32739 32738 32737 32736 32735 32734 32733 32732 32731 32730 32729 32728 32727 32726 32725 32724 32723 32722 32721 32720 32719 32718 32717 32716 32715 32714 32713 32712 32711 32710 32709 32708 32707 32706 32705 32704 32703 32702 32701 32700 32699 32698 32697 32696 32695 32694 32693 32692 32691 32690 32689 32688 32687 32686 32685 32684 32683 32...", "NO\nYES\n7 3 6 5 1 2 4 9 10 11 12 13 14 15 8 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 16 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 32 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 64 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 15...", "NO\nYES\n7 3 6 5 1 2 4 9 10 11 12 13 14 15 8 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 16 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 32 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 64 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 15...", "YES\n65534 65533 65532 65531 65530 65529 65528 65527 65526 65525 65524 65523 65522 65521 65520 65519 65518 65517 65516 65515 65514 65513 65512 65511 65510 65509 65508 65507 65506 65505 65504 65503 65502 65501 65500 65499 65498 65497 65496 65495 65494 65493 65492 65491 65490 65489 65488 65487 65486 65485 65484 65483 65482 65481 65480 65479 65478 65477 65476 65475 65474 65473 65472 65471 65470 65469 65468 65467 65466 65465 65464 65463 65462 65461 65460 65459 65458 65457 65456 65455 65454 65453 65452 65451 65...", "NO\nYES\n7 3 6 5 1 2 4 9 10 11 12 13 14 15 8 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 16 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 32 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 64 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 15...", "NO\nYES\n7 3 6 5 1 2 4 9 10 11 12 13 14 15 8 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 16 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 32 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 64 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 15...", "NO\nYES\n7 3 6 5 1 2 4 9 10 11 12 13 14 15 8 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 16 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 32 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 64 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 15...", "NO\nYES\n7 3 6 5 1 2 4 9 10 11 12 13 14 15 8 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 16 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 32 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 64 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 15...", "NO\nYES\n7 3 6 5 1 2 4 9 10 11 12 13 14 15 8 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 16 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 32 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 64 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 15...", "NO\nYES\n7 3 6 5 1 2 4 9 10 11 12 13 14 15 8 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 16 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 32 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 64 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 15...", "YES\n14 13 12 11 10 9 8 7 6 5 4 3 2 1 240 239 238 237 236 235 234 233 232 231 230 229 228 227 226 225 224 223 222 221 220 219 218 217 216 215 214 213 212 211 210 209 208 207 206 205 204 203 202 201 200 199 198 197 196 195 194 193 192 191 190 189 188 187 186 185 184 183 182 181 180 179 178 177 176 175 174 173 172 171 170 169 168 167 166 165 164 163 162 161 160 159 158 157 156 155 154 153 152 151 150 149 148 147 146 145 144 143 142 141 140 139 138 137 136 135 134 133 132 131 130 129 128 127 126 125 124 123 1...", "YES\n2 1 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 226 225 224 223 222 221 220 219 218 217 216 215 214 213 212 211 210 209 208 207 206 205 204 203 202 201 200 199 198 197 196 195 194 193 192 191 190 189 188 187 186 185 184 183 182 181 180 179 178 177 176 175 174 173 172 171 170 169 168 167 166 165 164 163 162 161 160 159 158 157 156 155 154 153 152 151 150 149 148 147 146 145 144 143 142 141 140 139 138 137 136 135 134 133 132 131 130 129 128 127 126 125 124 123 122 121 120 119...", "YES\n2 1 124 123 122 121 120 119 118 117 116 115 114 113 112 111 110 109 108 107 106 105 104 103 102 101 100 99 98 97 96 95 94 93 92 91 90 89 88 87 86 85 84 83 82 81 80 79 78 77 76 75 74 73 72 71 70 69 68 67 66 65 64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 386 385 384 383 382 381 380 379 378 377 376 375 374 373 372 371 370 369 368 367 366 365 364 363 362 361 360 359 358 35...", "YES\n2 1 4 3 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 36 35 34 33 32 31 30 29 28 27 4058 4057 4056 4055 4054 4053 4052 4051 4050 4049 4048 4047 4046 4045 4044 4043 4042 4041 4040 4039 4038 4037 4036 4035 4034 4033 4032 4031 4030 4029 4028 4027 4026 4025 4024 4023 4022 4021 4020 4019 4018 4017 4016 4015 4014 4013 4012 4011 4010 4009 4008 4007 4006 4005 4004 4003 4002 4001 4000 3999 3998 3997 3996 3995 3994 3993 3992 3991 3990 3989 3988 3987 3986 3985 3984 3983 3982 3981 3980 3979 3978 39...", "YES\n6 5 4 3 2 1 8 7 118 117 116 115 114 113 112 111 110 109 108 107 106 105 104 103 102 101 100 99 98 97 96 95 94 93 92 91 90 89 88 87 86 85 84 83 82 81 80 79 78 77 76 75 74 73 72 71 70 69 68 67 66 65 64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 1928 1927 1926 1925 1924 1923 1922 1921 1920 1919 1918 1917 1916 1915 1914 1913 1912 1911 1910 1909 1908 1907 1906 1905 1904 1903 1902 1901 19...", "YES\n14 13 12 11 10 9 8 7 6 5 4 3 2 1 112 111 110 109 108 107 106 105 104 103 102 101 100 99 98 97 96 95 94 93 92 91 90 89 88 87 86 85 84 83 82 81 80 79 78 77 76 75 74 73 72 71 70 69 68 67 66 65 64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 142 141 140 139 138 137 136 135 134 133 132 131 130 129 128 127 126 125 124 123 122 121 120 119 118 117 116 115 114 113 368 367 366 365 364 363 362 361 360 359 358 35...", "YES\n14 13 12 11 10 9 8 7 6 5 4 3 2 1 2032 2031 2030 2029 2028 2027 2026 2025 2024 2023 2022 2021 2020 2019 2018 2017 2016 2015 2014 2013 2012 2011 2010 2009 2008 2007 2006 2005 2004 2003 2002 2001 2000 1999 1998 1997 1996 1995 1994 1993 1992 1991 1990 1989 1988 1987 1986 1985 1984 1983 1982 1981 1980 1979 1978 1977 1976 1975 1974 1973 1972 1971 1970 1969 1968 1967 1966 1965 1964 1963 1962 1961 1960 1959 1958 1957 1956 1955 1954 1953 1952 1951 1950 1949 1948 1947 1946 1945 1944 1943 1942 1941 1940 1939 193...", "YES\n2 1 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 1986 1985 1984 1983 1982 1981 1980 1979 1978 1977 1976 1975 1974 1973 1972 1971 1970 1969 1968 1967 1966 1965 1964 1963 1962 1961 1960 1959 1958 1957 1956 1955 1954 1953 1952 1951 1950 1949 1948 1947 1946 1945 1944 1943 1942 1941 1940 1939 1938 1937 1936 1935 1934 1933 1932 1931 1930 1929 1928 1927 1926 1925 1924 1923 1922 1921 1920 ...", "YES\n2 1 12 11 10 9 8 7 6 5 4 3 114 113 112 111 110 109 108 107 106 105 104 103 102 101 100 99 98 97 96 95 94 93 92 91 90 89 88 87 86 85 84 83 82 81 80 79 78 77 76 75 74 73 72 71 70 69 68 67 66 65 64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 140 139 138 137 136 135 134 133 132 131 130 129 128 127 126 125 124 123 122 121 120 119 118 117 116 115 370 369 368 367 366 365 364 363 362 361 360 359 358 35...", "YES\n2 1 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 66 65 64 63 62 61 188 187 186 185 184 183 182 181 180 179 178 177 176 175 174 173 172 171 170 169 168 167 166 165 164 163 162 161 160 159 158 157 156 155 154 153 152 151 150 149 148 147 146 145 144 143 142 141 140 139 138 137 136 135 134 133 132 131 130 129 128 127 126 125 124 123 122 121 120 119 118 117 116 115 114 113 112 111 110 1...", "YES\n62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 16320 16319 16318 16317 16316 16315 16314 16313 16312 16311 16310 16309 16308 16307 16306 16305 16304 16303 16302 16301 16300 16299 16298 16297 16296 16295 16294 16293 16292 16291 16290 16289 16288 16287 16286 16285 16284 16283 16282 16281 16280 16279 16278 16277 16276 16275 16274 16273 16272 16271 16270 16269 16268 16267 16266...", "YES\n2 1 4 3 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 68 67 66 65 64 63 62 61 60 59 954 953 952 951 950 949 948 947 946 945 944 943 942 941 940 939 938 937 936 935 934 933 932 931 930 929 928 927 926 925 924 923 922 921 920 919 918 917 916 915 914 913 912 911 910 909 908 907 906 905 904 903 902 901 900 899 898 897 896 895 894 893 892 891 890 889 888 887 886 885 884 883 882 881 880 879 878 877...", "YES\n2 1 124 123 122 121 120 119 118 117 116 115 114 113 112 111 110 109 108 107 106 105 104 103 102 101 100 99 98 97 96 95 94 93 92 91 90 89 88 87 86 85 84 83 82 81 80 79 78 77 76 75 74 73 72 71 70 69 68 67 66 65 64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 386 385 384 383 382 381 380 379 378 377 376 375 374 373 372 371 370 369 368 367 366 365 364 363 362 361 360 359 358 35...", "YES\n6 5 4 3 2 1 8 7 22 21 20 19 18 17 16 15 14 13 12 11 10 9 104 103 102 101 100 99 98 97 96 95 94 93 92 91 90 89 88 87 86 85 84 83 82 81 80 79 78 77 76 75 74 73 72 71 70 69 68 67 66 65 64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 150 149 148 147 146 145 144 143 142 141 140 139 138 137 136 135 134 133 132 131 130 129 128 127 126 125 124 123 122 121 120 119 118 117 116 115 114 113 112 111 110 109 108 107 106 105 360 359 358 35...", "YES\n6 5 4 3 2 1 8 7 22 21 20 19 18 17 16 15 14 13 12 11 10 9 104 103 102 101 100 99 98 97 96 95 94 93 92 91 90 89 88 87 86 85 84 83 82 81 80 79 78 77 76 75 74 73 72 71 70 69 68 67 66 65 64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 406 405 404 403 402 401 400 399 398 397 396 395 394 393 392 391 390 389 388 387 386 385 384 383 382 381 380 379 378 377 376 375 374 373 372 371 370 369 368 367 366 365 364 363 362 361 360 359 358 35..."]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1 | codeforces |
|
fd06e19867352ee76d0b1a3b9ab11217 | Ann and Books | In Ann's favorite book shop are as many as *n* books on math and economics. Books are numbered from 1 to *n*. Each of them contains non-negative number of problems.
Today there is a sale: any subsegment of a segment from *l* to *r* can be bought at a fixed price.
Ann decided that she wants to buy such non-empty subsegment that the sale operates on it and the number of math problems is greater than the number of economics problems exactly by *k*. Note that *k* may be positive, negative or zero.
Unfortunately, Ann is not sure on which segment the sale operates, but she has *q* assumptions. For each of them she wants to know the number of options to buy a subsegment satisfying the condition (because the time she spends on choosing depends on that).
Currently Ann is too busy solving other problems, she asks you for help. For each her assumption determine the number of subsegments of the given segment such that the number of math problems is greaten than the number of economics problems on that subsegment exactly by *k*.
The first line contains two integers *n* and *k* (1<=≤<=*n*<=≤<=100<=000, <=-<=109<=≤<=*k*<=≤<=109) — the number of books and the needed difference between the number of math problems and the number of economics problems.
The second line contains *n* integers *t*1,<=*t*2,<=...,<=*t**n* (1<=≤<=*t**i*<=≤<=2), where *t**i* is 1 if the *i*-th book is on math or 2 if the *i*-th is on economics.
The third line contains *n* integers *a*1,<=*a*2,<=...,<=*a**n* (0<=≤<=*a**i*<=≤<=109), where *a**i* is the number of problems in the *i*-th book.
The fourth line contains a single integer *q* (1<=≤<=*q*<=≤<=100<=000) — the number of assumptions.
Each of the next *q* lines contains two integers *l**i* and *r**i* (1<=≤<=*l**i*<=≤<=*r**i*<=≤<=*n*) describing the *i*-th Ann's assumption.
Print *q* lines, in the *i*-th of them print the number of subsegments for the *i*-th Ann's assumption.
Sample Input
4 1
1 1 1 2
1 1 1 1
4
1 2
1 3
1 4
3 4
4 0
1 2 1 2
0 0 0 0
1
1 4
Sample Output
2
3
4
1
10
| {"inputs": ["4 1\n1 1 1 2\n1 1 1 1\n4\n1 2\n1 3\n1 4\n3 4", "4 0\n1 2 1 2\n0 0 0 0\n1\n1 4", "10 10\n2 1 1 1 1 1 1 1 1 2\n0 10 10 0 0 10 10 10 10 0\n10\n4 10\n3 7\n9 9\n2 9\n10 10\n5 5\n2 2\n6 8\n3 4\n1 3", "10 -10\n1 2 1 2 1 1 2 2 2 1\n7 7 10 3 7 10 6 8 0 1\n10\n2 6\n10 10\n6 9\n5 8\n7 10\n2 7\n2 9\n2 7\n5 6\n2 8", "10 10\n1 1 1 1 1 2 1 2 1 2\n7 10 2 5 0 1 8 10 1 8\n10\n4 5\n1 3\n6 7\n8 10\n5 10\n1 8\n5 6\n1 5\n2 8\n9 10", "2 0\n1 2\n43 43\n3\n1 2\n2 2\n1 1"], "outputs": ["2\n3\n4\n1", "10", "7\n7\n1\n10\n0\n0\n1\n3\n2\n3", "0\n0\n0\n0\n0\n0\n0\n0\n0\n0", "0\n1\n0\n0\n0\n1\n0\n1\n1\n0", "1\n0\n0"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 2 | codeforces |
|
fd09090ef729ff93446db38cf1352d0b | Autocomplete | Autocomplete is a program function that enables inputting the text (in editors, command line shells, browsers etc.) completing the text by its inputted part. Vasya is busy working on a new browser called 'BERowser'. He happens to be working on the autocomplete function in the address line at this very moment. A list consisting of *n* last visited by the user pages and the inputted part *s* are known. Your task is to complete *s* to make it an address of one of the pages from the list. You have to find the lexicographically smallest address having a prefix *s*.
The first line contains the *s* line which is the inputted part. The second line contains an integer *n* (1<=≤<=*n*<=≤<=100) which is the number of visited pages. Then follow *n* lines which are the visited pages, one on each line. All the lines have lengths of from 1 to 100 symbols inclusively and consist of lowercase Latin letters only.
If *s* is not the beginning of any of *n* addresses of the visited pages, print *s*. Otherwise, print the lexicographically minimal address of one of the visited pages starting from *s*.
The lexicographical order is the order of words in a dictionary. The lexicographical comparison of lines is realized by the '<' operator in the modern programming languages.
Sample Input
next
2
nextpermutation
nextelement
find
4
find
findfirstof
findit
fand
find
4
fondfind
fondfirstof
fondit
fand
Sample Output
nextelement
find
find
| {"inputs": ["next\n2\nnextpermutation\nnextelement", "find\n4\nfind\nfindfirstof\nfindit\nfand", "find\n4\nfondfind\nfondfirstof\nfondit\nfand", "kudljmxcse\n4\nkudljmxcse\nszjebdoad\nchz\na", "ntqwpa\n5\nvvepyowvn\nntqwpakay\nhh\nygiafasda\nntqwpadm", "aflb\n6\nsaej\nujxsiijg\npp\nhgoprw\ncp\nnt", "dzwzyj\n7\nwvixktp\ndzwzyjuhn\ndzwzyjqrbd\ndzwzyji\ndzwzyjyfys\ndzwzyjrcb\nxptb", "wmblbphwdjjskzmlsyiznluiudelhlvcpyrooajvbwudnnstdhesauyxjugdwhrrwg\n1\nwjhsbxrrhadgtnybsugdtprncwerwezxuaxnqfpnosbispmnymnaqssdkjeynrnn", "hzkqvwliymwjbejfpnydrbwskhyrtrlsdinfrgwmnbdpwytcnjeoowxrfgfuaffzayjylvzu\n1\nhzkqvwliymwjbejfpnydrbwskhyrtrlsdinfrgwmnbdpwytcnjeoowxrfgfuaffzayjylvzubwjlvhhsfurqb", "msjnqudojxtzvpc\n2\nvlxclsvqbucmbrkwwtoxek\nmsjnqudojxtzvpcldwjyystsxrtexfhllzhnkidmhmyxpld"], "outputs": ["nextelement", "find", "find", "kudljmxcse", "ntqwpadm", "aflb", "dzwzyji", "wmblbphwdjjskzmlsyiznluiudelhlvcpyrooajvbwudnnstdhesauyxjugdwhrrwg", "hzkqvwliymwjbejfpnydrbwskhyrtrlsdinfrgwmnbdpwytcnjeoowxrfgfuaffzayjylvzubwjlvhhsfurqb", "msjnqudojxtzvpcldwjyystsxrtexfhllzhnkidmhmyxpld"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 135 | codeforces |
|
fd0a5d9f400dd636829e4e517f91376f | Friends and Presents | You have two friends. You want to present each of them several positive integers. You want to present *cnt*1 numbers to the first friend and *cnt*2 numbers to the second friend. Moreover, you want all presented numbers to be distinct, that also means that no number should be presented to both friends.
In addition, the first friend does not like the numbers that are divisible without remainder by prime number *x*. The second one does not like the numbers that are divisible without remainder by prime number *y*. Of course, you're not going to present your friends numbers they don't like.
Your task is to find such minimum number *v*, that you can form presents using numbers from a set 1,<=2,<=...,<=*v*. Of course you may choose not to present some numbers at all.
A positive integer number greater than 1 is called prime if it has no positive divisors other than 1 and itself.
The only line contains four positive integers *cnt*1, *cnt*2, *x*, *y* (1<=≤<=*cnt*1,<=*cnt*2<=<<=109; *cnt*1<=+<=*cnt*2<=≤<=109; 2<=≤<=*x*<=<<=*y*<=≤<=3·104) — the numbers that are described in the statement. It is guaranteed that numbers *x*, *y* are prime.
Print a single integer — the answer to the problem.
Sample Input
3 1 2 3
1 3 2 3
Sample Output
5
4
| {"inputs": ["3 1 2 3", "1 3 2 3", "916200 69682 2 3", "808351 17767 433 509", "8851 901 20897 26183", "5099 2895 16273 29473", "5099 2895 16273 29473", "4969 694 293 2347", "683651932 161878530 2 5", "325832598 637961741 2 3", "999999999 1 2 3", "11006 976 6287 9007", "150064728 173287472 439 503", "819712074 101394406 6173 7307", "67462086 313228052 15131 29027", "500000000 500000000 29983 29989", "500000000 500000000 2 3", "500000000 500000000 29959 29983", "999999999 1 29983 29989", "1 999999999 29983 29989", "1 999999999 2 3", "999999998 1 2 3", "999999998 2 2 3", "9999999 10000 29983 29989", "1000 9999999 29983 29989", "110 40 1567 7681", "197 2 6361 18223", "39 154 1033 18947", "126 51 26249 29443", "14 179 19699 29303", "14797 3593 13147 13933", "782 5750 7079 23957", "10876 8828 12487 16607", "16860 2201 6427 23327", "4901 563 1997 15053", "1277613 596606 10427 29387", "1513389 40825 5641 10009", "1749165 72848 9743 20023", "954386 580262 4993 15629", "159606 875491 43 19121", "139694297 21147406 8819 28499", "26941620 135675892 4093 28979", "9156260 174697920 8171 29863", "191370899 1962652 3517 24023", "78618222 88031575 28289 29023", "1 1 2 3", "1 2 2 3", "1 2 29983 29989", "1 1 29983 29989", "2 1 2 3"], "outputs": ["5", "4", "1832399", "826121", "9752", "7994", "7994", "5663", "1367303863", "1156553206", "1999999997", "11982", "323353664", "921106500", "380690138", "1000000001", "1199999999", "1000000001", "1000033352", "1000033345", "1499999998", "1999999995", "1999999995", "10009999", "10000999", "150", "199", "193", "177", "193", "18390", "6532", "19704", "19061", "5464", "1874219", "1554214", "1822013", "1534648", "1035098", "160841703", "162617513", "183854180", "193333553", "166649797", "2", "3", "3", "2", "3"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 33 | codeforces |
|
fd147d05260e80bd25ba2a334bf9f277 | Comparing Two Long Integers | You are given two very long integers *a*,<=*b* (leading zeroes are allowed). You should check what number *a* or *b* is greater or determine that they are equal.
The input size is very large so don't use the reading of symbols one by one. Instead of that use the reading of a whole line or token.
As input/output can reach huge size it is recommended to use fast input/output methods: for example, prefer to use scanf/printf instead of cin/cout in C++, prefer to use BufferedReader/PrintWriter instead of Scanner/System.out in Java. Don't use the function input() in Python2 instead of it use the function raw_input().
The first line contains a non-negative integer *a*.
The second line contains a non-negative integer *b*.
The numbers *a*,<=*b* may contain leading zeroes. Each of them contains no more than 106 digits.
Print the symbol "<" if *a*<=<<=*b* and the symbol ">" if *a*<=><=*b*. If the numbers are equal print the symbol "=".
Sample Input
9
10
11
10
00012345
12345
0123
9
0123
111
Sample Output
<
>
=
>
>
| {"inputs": ["9\n10", "11\n10", "00012345\n12345", "0123\n9", "0123\n111", "9\n9", "0\n0000", "1213121\n1213121", "8631749422082281871941140403034638286979613893271246118706788645620907151504874585597378422393911017\n1460175633701201615285047975806206470993708143873675499262156511814213451040881275819636625899967479", "6421902501252475186372406731932548506197390793597574544727433297197476846519276598727359617092494798\n8", "9\n3549746075165939381145061479392284958612916596558639332310874529760172204736013341477640605383578772", "11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111\n11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111", "0000000001\n2", "1000000000000000000000000000000000\n1000000000000000000000000000000001", "123456123456123456123456123456123456123456123456123456123456123456\n123456123456123456123456123456123456123456123456123456123456123456123456123456", "1111111111111111111111111111111111111111\n2222222222222222222222222222222222222222", "123456789999999\n123456789999999", "111111111111111111111111111111\n222222222222222222222222222222", "1111111111111111111111111111111111111111111111111111111111111111111111\n1111111111111111111111111111111111111111111111111111111111111111111111", "587345873489573457357834\n47957438573458347574375348", "1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111\n33333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333", "11111111111111111111111111111111111\n44444444444444444444444444444444444", "11111111111111111111111111111111111\n22222222222222222222222222222222222", "9999999999999999999999999999999999999999999999999999999999999999999\n99999999999999999999999999999999999999999999999999999999999999999999999999999999999999", "1\n2", "9\n0", "222222222222222222222222222222222222222222222222222222222\n22222222222222222222222222222222222222222222222222222222222", "66646464222222222222222222222222222222222222222222222222222222222222222\n111111111111111111111111111111111111111111111111111111111111111111111111111111111111", "222222222222222222222222222222222222222222222222222\n111111111111111111111111111111111111111111111111111111111111111", "11111111111111111111111111111111111111\n44444444444444444444444444444444444444", "01\n2", "00\n01", "99999999999999999999999999999999999999999999999\n99999999999999999999999999999999999999999999999", "43278947323248843213443272432\n793439250984509434324323453435435", "0\n1", "010\n011", "999999999999999999999999999999999999999999999999\n999999999999999999999999999999999999999999999999", "0001001\n0001010", "1111111111111111111111111111111111111111111111111111111111111\n1111111111111111111111111111111111111111111111111111111111111", "00000\n00", "999999999999999999999999999\n999999999999999999999999999", "999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\n999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999", "001\n000000000010", "01\n10", "555555555555555555555555555555555555555555555555555555555555\n555555555555555555555555555555555555555555555555555555555555", "5555555555555555555555555555555555555555555555555\n5555555555555555555555555555555555555555555555555", "01\n02", "001111\n0001111", "55555555555555555555555555555555555555555555555555\n55555555555555555555555555555555555555555555555555", "1029301293019283091283091283091280391283\n1029301293019283091283091283091280391283", "001\n2", "000000000\n000000000", "000000\n10", "000000000000000\n001", "0000001\n2", "0000\n123", "951\n960", "002\n0001", "0000001\n01", "99999999999999999999999999999999999999999999999999999999999999\n99999999999999999999999999999999999999999999999999999999999999", "12345678901234567890123456789012345678901234567890123456789012\n12345678901234567890123456789012345678901234567890123456789012", "02\n01", "00000111111\n00000110111", "0123\n123", "123771237912798378912\n91239712798379812897389123123123123", "00001\n002", "0000000000000000000000000000000000000000000000000000000000000\n000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "000000001\n00002", "00002\n00003", "000123456\n123457", "01\n00", "00\n0", "10\n11", "0011\n12", "00\n1", "0\n0", "00\n10", "011\n10", "00011111111111111111111111111111111111000000000000000000000000000000000000000000000000000210000000000000000000000000000000000000000011000\n11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111112091", "0000001\n00", "01\n1", "010\n001", "100\n111", "1\n0", "000000\n000000000000000000000", "010101\n010101", "00000000000000000001111111111111111111111111111111111111111111111111111111\n11111111111111111111111", "0000000\n0", "187923712738712879387912839182381\n871279397127389781927389718923789178923897123", "0010\n030"], "outputs": ["<", ">", "=", ">", ">", "=", "=", "=", ">", ">", "<", "=", "<", "<", "<", "<", "=", "<", "=", "<", "<", "<", "<", "<", "<", ">", "<", "<", "<", "<", "<", "<", "=", "<", "<", "<", "=", "<", "=", "=", "=", "=", "<", "<", "=", "=", "<", "=", "=", "=", "<", "=", "<", "<", "<", "<", "<", ">", "=", "=", "=", ">", ">", "=", "<", "<", "=", "<", "<", "<", ">", "=", "<", "<", "<", "=", "<", ">", "<", ">", "=", ">", "<", ">", "=", "=", ">", "=", "<", "<"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 93 | codeforces |
|
fd1ce315ca7b872f90047714c866c036 | Inventory | Companies always have a lot of equipment, furniture and other things. All of them should be tracked. To do this, there is an inventory number assigned with each item. It is much easier to create a database by using those numbers and keep the track of everything.
During an audit, you were surprised to find out that the items are not numbered sequentially, and some items even share the same inventory number! There is an urgent need to fix it. You have chosen to make the numbers of the items sequential, starting with 1. Changing a number is quite a time-consuming process, and you would like to make maximum use of the current numbering.
You have been given information on current inventory numbers for *n* items in the company. Renumber items so that their inventory numbers form a permutation of numbers from 1 to *n* by changing the number of as few items as possible. Let us remind you that a set of *n* numbers forms a permutation if all the numbers are in the range from 1 to *n*, and no two numbers are equal.
The first line contains a single integer *n* — the number of items (1<=≤<=*n*<=≤<=105).
The second line contains *n* numbers *a*1,<=*a*2,<=...,<=*a**n* (1<=≤<=*a**i*<=≤<=105) — the initial inventory numbers of the items.
Print *n* numbers — the final inventory numbers of the items in the order they occur in the input. If there are multiple possible answers, you may print any of them.
Sample Input
3
1 3 2
4
2 2 3 3
1
2
Sample Output
1 3 2
2 1 3 4
1
| {"inputs": ["3\n1 3 2", "4\n2 2 3 3", "1\n2", "3\n3 3 1", "5\n1 1 1 1 1", "5\n5 3 4 4 2", "5\n19 11 8 8 10", "15\n2 2 1 2 1 2 3 3 1 3 2 1 2 3 2", "18\n3 11 5 9 5 4 6 4 5 7 5 1 8 11 11 2 1 9", "42\n999 863 440 1036 1186 908 330 265 382 417 858 286 834 922 42 569 79 158 312 1175 1069 188 21 1207 985 375 59 417 256 595 732 742 629 737 25 699 484 517 37 1134 472 720", "111\n15 45 14 65 49 25 102 86 14 80 54 73 43 78 42 32 47 60 55 66 84 69 49 22 26 72 89 52 26 80 71 35 56 2 88 23 23 53 65 92 46 73 29 65 88 99 19 99 87 10 47 96 109 20 60 89 63 105 29 92 109 20 95 65 31 89 107 3 3 50 58 9 28 39 104 42 41 36 70 49 59 96 16 9 3 108 38 42 2 67 32 86 20 6 101 70 101 91 38 10 74 3 27 15 103 63 51 60 62 10 70", "7\n45301 14370 61599 42695 46301 24556 26812", "22\n70150 17718 11731 6488 72633 41249 12141 71465 88562 6167 71659 34151 60508 24942 77343 35882 80424 67225 92746 55412 79 53642", "2\n1 4"], "outputs": ["1 3 2 ", "2 1 3 4 ", "1 ", "3 2 1 ", "1 2 3 4 5 ", "5 3 4 1 2 ", "1 2 3 4 5 ", "2 4 1 5 6 7 3 8 9 10 11 12 13 14 15 ", "3 11 5 9 10 4 6 12 13 7 14 1 8 15 16 2 17 18 ", "1 2 3 4 5 6 7 8 9 10 11 12 13 14 42 15 16 17 18 19 20 22 21 23 24 26 27 28 29 30 31 32 33 34 25 35 36 38 37 39 40 41 ", "15 45 14 65 49 25 102 86 1 80 54 73 43 78 42 32 47 60 55 66 84 69 4 22 26 72 89 52 5 7 71 35 56 2 88 23 8 53 11 92 46 12 29 13 17 99 19 18 87 10 21 96 109 20 24 30 63 105 33 34 37 40 95 44 31 48 107 3 57 50 58 9 28 39 104 61 41 36 70 64 59 68 16 75 76 108 38 77 79 67 81 82 83 6 101 85 90 91 93 94 74 97 27 98 103 100 51 106 62 110 111 ", "1 2 3 4 5 6 7 ", "1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 ", "1 2 "]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 88 | codeforces |
|
fd83dbf0a860282e31913add3b44f5c3 | Permutations | A permutation is a sequence of integers from 1 to *n* of length *n* containing each number exactly once. For example, (1), (4,<=3,<=5,<=1,<=2), (3,<=2,<=1) are permutations, and (1,<=1), (4,<=3,<=1), (2,<=3,<=4) are not.
There are many tasks on permutations. Today you are going to solve one of them. Let’s imagine that somebody took several permutations (perhaps, with a different number of elements), wrote them down consecutively as one array and then shuffled the resulting array. The task is to restore the initial permutations if it is possible.
The first line contains an integer *n* (1<=≤<=*n*<=≤<=105). The next line contains the mixed array of *n* integers, divided with a single space. The numbers in the array are from 1 to 105.
If this array can be split into several permutations so that every element of the array belongs to exactly one permutation, print in the first line the number of permutations. The second line should contain *n* numbers, corresponding to the elements of the given array. If the *i*-th element belongs to the first permutation, the *i*-th number should be 1, if it belongs to the second one, then its number should be 2 and so on. The order of the permutations’ numbering is free.
If several solutions are possible, print any one of them. If there’s no solution, print in the first line <=-<=1.
Sample Input
9
1 2 3 1 2 1 4 2 5
4
4 3 2 1
4
1 2 2 3
Sample Output
3
3 1 2 1 2 2 2 3 2
1
1 1 1 1 -1
| {"inputs": ["9\n1 2 3 1 2 1 4 2 5", "4\n4 3 2 1", "4\n1 2 2 3", "1\n1", "1\n2", "5\n1 1 1 1 1", "3\n2 1 1", "6\n3 3 2 2 1 1", "2\n1000 1", "5\n2 2 1 1 3", "10\n2 1 2 4 6 1 5 3 7 1", "10\n4 1 2 1 3 3 1 2 2 1", "10\n1 2 5 1 1 1 4 1 3 2", "20\n2 7 3 8 4 6 3 7 6 4 13 5 1 12 1 10 2 11 5 9", "20\n1 1 1 2 3 1 5 9 5 8 4 6 7 3 1 2 2 1 3 4", "20\n2 10 3 3 2 1 14 13 2 15 1 4 5 12 7 11 9 1 6 8", "20\n1 7 2 3 1 1 8 1 6 1 9 11 5 10 1 4 2 3 1 2", "30\n6 1 2 3 6 4 1 8 1 2 2 5 5 1 1 3 9 1 5 8 1 2 7 7 4 3 1 3 4 2", "30\n2 6 2 3 3 1 4 2 1 3 3 2 1 2 1 8 1 2 4 1 1 1 5 1 4 7 1 9 1 1", "30\n1 3 2 5 9 4 16 14 2 2 4 11 7 17 1 15 13 3 6 12 6 19 8 1 20 5 18 4 10 3", "10\n2 2 6 3 1 4 5 3 7 7", "20\n4 6 6 4 5 4 3 2 5 7 3 2 4 1 3 1 1 4 1 7", "30\n2 8 3 3 7 4 2 9 4 3 5 6 1 5 3 5 8 1 9 6 6 7 2 7 1 1 1 10 2 1", "30\n8 7 9 6 2 3 7 1 1 5 7 2 3 1 7 4 5 6 3 9 4 9 4 2 3 1 1 2 2 10", "50\n7 1 6 5 15 3 13 7 1 1 4 2 4 3 2 1 11 9 4 2 3 7 1 1 1 14 3 14 5 2 5 4 1 8 2 2 2 2 1 1 4 1 2 3 6 12 1 1 5 1", "50\n1 1 4 1 1 1 1 1 1 3 1 1 3 2 1 1 1 1 5 2 1 1 1 1 1 3 1 1 1 1 1 1 2 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1", "100\n2 13 10 4 13 8 22 11 5 3 4 6 19 4 8 8 6 1 16 4 11 17 5 18 7 7 4 5 3 7 2 16 5 6 10 1 6 12 14 6 8 7 9 7 1 2 1 8 5 5 9 21 7 11 6 1 12 10 6 23 10 9 8 4 1 2 3 13 2 14 15 1 1 12 3 9 12 3 13 9 8 1 12 5 2 3 11 7 11 9 3 14 1 2 15 2 10 4 14 20", "100\n9 6 3 28 10 2 2 11 2 1 25 3 13 5 14 13 4 14 2 16 12 27 8 1 7 9 8 19 33 23 4 1 15 6 7 12 2 8 30 4 1 31 6 1 15 5 18 3 2 24 7 3 1 20 10 8 26 22 3 3 9 6 1 10 1 5 1 3 7 6 11 10 1 16 19 5 9 4 4 4 2 18 12 21 11 5 2 32 17 29 2 4 8 1 7 5 3 2 17 1", "100\n12 18 1 1 14 23 1 1 22 5 7 9 7 1 1 1 3 8 4 2 1 6 9 1 3 2 11 1 11 2 3 2 1 4 2 7 1 16 3 4 2 13 3 1 5 11 2 10 20 24 3 21 5 2 6 2 1 10 10 5 17 1 1 4 19 8 5 5 3 9 4 2 7 8 10 4 9 1 3 3 9 7 6 4 4 3 6 8 12 1 3 6 2 1 8 4 1 15 2 5", "100\n10 1 13 1 5 2 5 5 9 10 3 8 4 1 3 5 6 4 1 4 9 8 1 1 1 1 8 2 3 1 1 2 5 1 1 12 6 4 5 3 1 3 18 10 1 2 3 2 6 2 3 15 1 3 5 3 9 7 1 6 11 7 7 8 6 17 11 7 6 1 4 4 1 1 3 1 2 6 7 14 4 4 5 1 11 1 4 2 8 4 2 7 16 12 1 1 2 2 1 2"], "outputs": ["3\n1 1 1 2 2 3 1 3 1 ", "1\n1 1 1 1 ", "-1", "1\n1 ", "-1", "5\n1 2 3 4 5 ", "2\n1 1 2 ", "2\n1 2 1 2 1 2 ", "-1", "2\n1 2 1 2 1 ", "3\n1 1 2 1 1 2 1 1 1 3 ", "4\n1 1 1 2 1 2 3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 2 5 3 12 1 4 3 6 1 5 13 2 3 7 1 1 1 6 1 3 8 2 9 14 2 3 4 1 15 16 4 1 2 5 6 7 3 5 10 4 3 4 6 4 17 8 9 5 5 3 7 8 10 4 4 2 18 11 5 11 19 5 9 20 1 12 7 ", "25\n1 1 1 2 1 1 2 3 1 2 1 1 1 3 2 4 1 2 4 3 2 2 5 6 7 8 3 2 3 9 10 3 5 11 12 1 2 4 6 4 13 5 1 3 14 4 6 5 3 6 7 1 15 8 7 9 3 1 16 4 1 2 3 4 5 1 2 4 6 17 5 6 18 19 10 20 7 7 5 1 7 8 8 21 3 22 9 8 5 10 9 6 1 2 23 24 10 11 25 12 "]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 19 | codeforces |
|
fd8886c6850c1ea1e514d52a6f360e82 | Autocompletion | Arcady is a copywriter. His today's task is to type up an already well-designed story using his favorite text editor.
Arcady types words, punctuation signs and spaces one after another. Each letter and each sign (including line feed) requires one keyboard click in order to be printed. Moreover, when Arcady has a non-empty prefix of some word on the screen, the editor proposes a possible autocompletion for this word, more precisely one of the already printed words such that its prefix matches the currently printed prefix if this word is unique. For example, if Arcady has already printed «codeforces», «coding» and «codeforces» once again, then there will be no autocompletion attempt for «cod», but if he proceeds with «code», the editor will propose «codeforces».
With a single click Arcady can follow the editor's proposal, i.e. to transform the current prefix to it. Note that no additional symbols are printed after the autocompletion (no spaces, line feeds, etc). What is the minimum number of keyboard clicks Arcady has to perform to print the entire text, if he is not allowed to move the cursor or erase the already printed symbols?
A word here is a contiguous sequence of latin letters bordered by spaces, punctuation signs and line/text beginnings/ends. Arcady uses only lowercase letters. For example, there are 20 words in «it's well-known that tic-tac-toe is a paper-and-pencil game for two players, x and o.».
The only line contains Arcady's text, consisting only of lowercase latin letters, spaces, line feeds and the following punctuation signs: «.», «,», «?», «!», «'» and «-». The total amount of symbols doesn't exceed 3·105. It's guaranteed that all lines are non-empty.
Print a single integer — the minimum number of clicks.
Sample Input
snow affects sports such as skiing, snowboarding, and snowmachine travel.
snowboarding is a recreational activity and olympic and paralympic sport.
'co-co-co, codeforces?!'
thun-thun-thunder, thunder, thunder
thunder, thun-, thunder
thun-thun-thunder, thunder
thunder, feel the thunder
lightning then the thunder
thunder, feel the thunder
lightning then the thunder
thunder, thunder
Sample Output
141
25
183
| {"inputs": ["snow affects sports such as skiing, snowboarding, and snowmachine travel.\nsnowboarding is a recreational activity and olympic and paralympic sport.", "'co-co-co, codeforces?!'", "thun-thun-thunder, thunder, thunder\nthunder, thun-, thunder\nthun-thun-thunder, thunder\nthunder, feel the thunder\nlightning then the thunder\nthunder, feel the thunder\nlightning then the thunder\nthunder, thunder", "a'b-c-aa'ab.ac.ba!bb-bc-ca?cb-cc.aaa,aab'aac'aba-abb'abc-aca.acb!acc?baa'bab'bac!bba-bbb.bbc.bca", "aaa!bbb'ccc?aaaaaa,aaabbb.aaaccc,bbbaaa-bbbbbb-bbbccc,cccaaa,cccbbb.cccccc'aaaaaaaaa-aaaaaabbb", "bca'bbc,bbb!bba!bac'bab.baa,acc?acb.aca'abc?abb?aba?aac,aab?aaa?cc?cb'ca'bc!bb.ba-ac!ab.aa!c,b.a", "a'aa!aaa.aab,aac,ab!aba,abb.abc'ac.aca'acb,acc!b'ba.baa.bab,bac!bb.bba,bbb,bbc,bc,bca'c?ca.cb,cc", "aaa?c?ba,ac?cc?b.abb-bab.cb-a'aac'bb'aab-bbc'bca.ca.acb-baa.acc-aba?aa-bbb.bac?bc,aca-bba!abc!ab", "baacbcaac-bcaabbaabaacccacc'acbb.b!-ababcab!b'a'aacaccaacbab!c\nb\nbca'bbcc!!", "aaa aaaaaa"], "outputs": ["141", "25", "183", "97", "91", "97", "97", "97", "76", "10"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1 | codeforces |
|
fd92b19e89743bc74823f16a399a7d87 | none | Hamed has recently found a string *t* and suddenly became quite fond of it. He spent several days trying to find all occurrences of *t* in other strings he had. Finally he became tired and started thinking about the following problem. Given a string *s* how many ways are there to extract *k*<=≥<=1 non-overlapping substrings from it such that each of them contains string *t* as a substring? More formally, you need to calculate the number of ways to choose two sequences *a*1,<=*a*2,<=...,<=*a**k* and *b*1,<=*b*2,<=...,<=*b**k* satisfying the following requirements:
- *k*<=≥<=1 - - - - *t* is a substring of string *s**a**i**s**a**i*<=+<=1... *s**b**i* (string *s* is considered as 1-indexed).
As the number of ways can be rather large print it modulo 109<=+<=7.
Input consists of two lines containing strings *s* and *t* (1<=≤<=|*s*|,<=|*t*|<=≤<=105). Each string consists of lowercase Latin letters.
Print the answer in a single line.
Sample Input
ababa
aba
welcometoroundtwohundredandeightytwo
d
ddd
d
Sample Output
5
274201
12
| {"inputs": ["ababa\naba", "welcometoroundtwohundredandeightytwo\nd", "ddd\nd", "vnssnssnssnssnssnssnssnssnssnssnssnssnssnssnssnssn\nnssnssns", "kpjmawawawawawawawawawawawawawawawawawawawawawawaw\nwawawawa", "vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv\nvvvvvvvv", "a\na", "a\naa", "a\nb", "ababababab\nabab"], "outputs": ["5", "274201", "12", "943392", "834052", "2728075", "1", "0", "0", "35"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 3 | codeforces |
|
fdcea445eb25dcf698ddd83d96b0a8bf | Sysadmin Bob | Email address in Berland is a string of the form *A*@*B*, where *A* and *B* are arbitrary strings consisting of small Latin letters.
Bob is a system administrator in «Bersoft» company. He keeps a list of email addresses of the company's staff. This list is as a large string, where all addresses are written in arbitrary order, separated by commas. The same address can be written more than once.
Suddenly, because of unknown reasons, all commas in Bob's list disappeared. Now Bob has a string, where all addresses are written one after another without any separators, and there is impossible to determine, where the boundaries between addresses are. Unfortunately, on the same day his chief asked him to bring the initial list of addresses. Now Bob wants to disjoin addresses in some valid way. Help him to do that.
The first line contains the list of addresses without separators. The length of this string is between 1 and 200, inclusive. The string consists only from small Latin letters and characters «@».
If there is no list of the valid (according to the Berland rules) email addresses such that after removing all commas it coincides with the given string, output No solution. In the other case, output the list. The same address can be written in this list more than once. If there are several solutions, output any of them.
Sample Input
a@aa@a
a@a@a
@aa@a
Sample Output
a@a,a@a
No solution
No solution
| {"inputs": ["a@aa@a", "a@a@a", "@aa@a", "aba@caba@daba", "asd@qwasd@qwasd@qwasd@qwasd@qw", "qwer@ty", "@", "g", "@@", "@@@", "r@@", "@@r", "@r@", "w@", "@e", "jj", "@gh", "n@m", "kl@", "fpm", "@@@@", "q@@@", "@d@@", "@@v@", "@@@c", "@@zx", "@x@a", "@pq@", "w@@e", "e@s@", "ec@@", "@hjk", "e@vb", "tg@q", "jkl@", "werb", "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@", "duk@rufrxjzqbwkfrzf@sjp@mdpyrokdfmcmexxtjqaalruvtzwfsqabi@tjkxilrhkwzfeuqm@lpwnxgebirdvwplsvrtxvhmzv", "umegsn@qlmkpkyrmuclefdpfhzuhyjcoqthnvpwzhkwrdvlzfbrqpzlg@ebzycyaofyyetwcepe@nxjwyeaqbuxxbohfzrnmebuy", "l@snuoytgflrtuexpx@txzhhdwbakfhfro@syxistypegfvdmurvuubrj@grsznzhcotagqueuxtnjgfaywzkbglwwiptjyocxcs", "crvjlke@yqsdofatzuuspt@@uumdkiwhtg@crxiabnujfmcquylyklxaedniwnq@@f@@rfnsjtylurexmdaaykvxmgeij@jkjsyi", "ukpcivvjubgalr@bdxangokpaxzxuxe@qlemwpvywfudffafsqlmmhhalaaolktmgmhmrwvkdcvwxcfbytnz@jgmbhpwqcmecnxc", "mehxghlvnnazggvpnjdbchdolqguiurrfghwxpwhphdbhloltwnnqovsnsdmfevlikmrlvwvkcqysefvoraorhamchghqaooxaxz", "whazbewtogyre@wqlsswhygx@osevwzytuaukqpp@gfjbtwnhpnlxwci@ovaaat@ookd@@o@bss@wyrrwzysubw@utyltkk@hlkx", "vpulcessdotvylvmkeonzbpncjxaaigotkyvngsbkicomikyavpsjcphlznjtdmvbqiroxvfcmcczfmqbyedujvrupzlaswbzanv", "mhxapzklriiincpnysmegjzaxdngifbowkzivvgisqbekprdmdoqezdsrsrwwmht@hwywjqflvqdevpqisncwbftlttfkgsyetop", "dxzqftcghawwcwh@iepanbiclstbsxbrsoep@@jwhrptgiu@zfykoravtaykvkzseqfnlsbvjnsgiajgjtgucvewlpxmqwvkghlo", "erierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtgh@", "@rierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghd", "e@ierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghd", "erierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtg@d", "erierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjt@h@", "@r@erjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghd", "e@i@rjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghd", "erierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierj@g@d", "erierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtg@@", "@@ierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghd", "e@@erjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghd", "erierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjt@@d", "erierjtghderierjtghderierj@@dderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghd", "a@rierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderirjtghderierjtghderierjtghderierjthderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtgh@a", "d@nt@om@zz@ut@tr@ta@ap@ou@sy@sv@fg@el@rp@qr@nl@j", "a@mc@ks@gu@rl@gq@zq@iz@da@uq@mi@nf@zs@hi@we@ej@ke@vb@az@yz@yl@rr@gh@um@nv@qe@qq@de@dy@op@gt@vx@ak@q", "c@ir@xf@ap@fk@sp@wm@ec@qw@vg@by@iu@tr@wu@pv@lj@dd@tc@qj@ok@hm@bs@ul@ez@cg@ht@xf@ag@tr@hz@ap@tx@ly@dg@hu@nd@uv@il@ii@cn@nc@nb@cy@kp@dk@xa@da@ta@yr@yv@qg@db@je@wz@rn@yh@xi@mj@kc@uj@yu@cf@ps@ao@fo@le@d", "m@us@ru@mg@rq@ed@ot@gt@fo@gs@lm@cx@au@rq@zt@zk@jr@xd@oa@py@kf@lk@zr@ko@lj@wv@fl@yl@gk@cx@px@kl@ic@sr@xn@hm@xs@km@tk@ui@ya@pa@xx@ze@py@ir@xj@cr@dq@lr@cm@zu@lt@bx@kq@kx@fr@lu@vb@rz@hg@iw@dl@pf@pl@wv@z", "gjkjqjrks@eyqiia@qfijelnmigoditxjrtuhukalfl@nmwancimlqtfekzkxgjioedhtdivqajwbmu@hpdxuiwurpgenxaiqaqkcqimcvitljuisfiojlylveie@neqdjzeqdbiatjpuhujgykl@gmmlrhnlghsoeyrccygigtkjrjxdwmnkouaiaqpquluwcdqlxqb", "uakh@chpowdmvdywosakyyknpriverjjgklmdrgwufpawgvhabjbnemimjktgbkx@fzvqcodbceqnihl@kpsslhwwndad@@yavjafrwkqyt@urhnwgnqamn@xkc@vngzlssmtheuxkpzjlbbjq@mwiojmvpilm@hlrmxheszskhxritsieubjjazrngxlqeedfkiuwny", "usmjophufnkamnvowbauu@wfoyceknkgeaejlbbqhtucbl@wurukjezj@irhdgrfhyfkz@fbmqgxvtxcebztirvwjf@fnav@@f@paookujny@z@fmcxgvab@@kpqbwuxxwxhsrbivlbunmdjzk@afjznrjjtkq@cafetoinfleecjqvlzpkqlspoufwmidvoblti@jbg", "axkxcgcmlxq@v@ynnjximcujikloyls@lqvxiyca@feimaioavacmquasneqbrqftknpbrzpahtcc@ijwqmyzsuidqkm@dffuiitpugbvty@izbnqxhdjasihhlt@gjrol@vy@vnqpxuqbofzzwl@toywomxopbuttczszx@fuowtjmtqy@gypx@la@@tweln@jgyktb", "mplxc@crww@gllecngcsbmxmksrgcb@lbrcnkwxclkcgvfeqeoymproppxhxbgm@q@bfxxvuymnnjolqklabcinwpdlxj@jcevvilhmpyiwggvlmdanfhhlgbkobnmei@bvqtdq@osijfdsuouvcqpcjxjqiuhgts@xapp@cpqvlhlfrxtgunbbjwhuafovbcbqyhmlu", "aglvesxsmivijisod@mxcnbfcfgqfwjouidlsueaswf@obehqpvbkmukxkicyoknkbol@kutunggpoxxfpbe@qkhv@llddqqoyjeex@byvtlhbifqmvlukmrvgvpwrscwfhpuwyknwchqhrdqgarmnsdlqgf@lseltghg@bhuwbfjpsvayzk@fvwow@zapklumefauly", "gbllovyerhudm@aluhtnstcp@uwgvejnmqpt@nez@ltzqjrcgwkkpzicb@ihh@wldhvjbrl@efbdzbeg@zyovsta@n@c@jutail@nclsbcihabzr@snowxeyl@jewen@aduffvhr@ifufzzt@i@kptygveumwaknmrn@edsapqpcwsqypmutggztum@ewzakeamobzxt", "dokshhqwmtbefrynupvusfxroggoqkjqfyabzkbccjmavumncorbcoairybeknhnpnwftrlbopsvqlgjbrowmfmoeebqseneabvgbcxmujmcqomoawrooixmqmyspfgafudfdfyrnujhgnbtsehgsnvdztjdpnskyquwdtkbfjtvrfjcqzmourvqsnfgjfqjgndydpch", "jrlhtwmotdhtgcqokodparuqypwlkbhfsxvmdpfiraokekrolwtlsqjzcuvjfnvblznyngasauzln@gjypvjcwljnotgjlxketfgtntbotwjehea@vppouyoujujlhjrxbhvltfdslaqwynwjefbdbnuehmipqmtsrivlnippgftgnkhdgqiqbfvgrtoxrznncncqcvf", "oxkvgnggznlfhminxkkhictpiaokdsfrewnxiujpjpstlyxovfwugrsqnpooalknjnfugxojozizlicwvnbflhdevpvnvwztnfiapairpigexbaeshondqdecduewmfrxunphikvlfwmrpsxrhxyjlsgqfiaqnwzlzxcyuudhzr@twllmhyfclybxqazhrmxdtokxawc"], "outputs": ["a@a,a@a", "No solution", "No solution", "aba@c,aba@daba", "asd@q,wasd@q,wasd@q,wasd@q,wasd@qw", "qwer@ty", "No solution", "No solution", "No solution", "No solution", "No solution", "No solution", "No solution", "No solution", "No solution", "No solution", "No solution", "n@m", "No solution", "No solution", "No solution", "No solution", "No solution", "No solution", "No solution", "No solution", "No solution", "No solution", "No solution", "No solution", "No solution", "No solution", "e@vb", "tg@q", "No solution", "No solution", "No solution", "No solution", "duk@r,ufrxjzqbwkfrzf@s,jp@m,dpyrokdfmcmexxtjqaalruvtzwfsqabi@t,jkxilrhkwzfeuqm@lpwnxgebirdvwplsvrtxvhmzv", "umegsn@q,lmkpkyrmuclefdpfhzuhyjcoqthnvpwzhkwrdvlzfbrqpzlg@e,bzycyaofyyetwcepe@nxjwyeaqbuxxbohfzrnmebuy", "l@s,nuoytgflrtuexpx@t,xzhhdwbakfhfro@s,yxistypegfvdmurvuubrj@grsznzhcotagqueuxtnjgfaywzkbglwwiptjyocxcs", "No solution", "ukpcivvjubgalr@b,dxangokpaxzxuxe@q,lemwpvywfudffafsqlmmhhalaaolktmgmhmrwvkdcvwxcfbytnz@jgmbhpwqcmecnxc", "No solution", "No solution", "No solution", "mhxapzklriiincpnysmegjzaxdngifbowkzivvgisqbekprdmdoqezdsrsrwwmht@hwywjqflvqdevpqisncwbftlttfkgsyetop", "No solution", "No solution", "No solution", "e@ierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghd", "erierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtg@d", "No solution", "No solution", "No solution", "No solution", "No solution", "No solution", "No solution", "No solution", "No solution", "a@r,ierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderirjtghderierjtghderierjtghderierjthderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtghderierjtgh@a", "d@n,t@o,m@z,z@u,t@t,r@t,a@a,p@o,u@s,y@s,v@f,g@e,l@r,p@q,r@n,l@j", "a@m,c@k,s@g,u@r,l@g,q@z,q@i,z@d,a@u,q@m,i@n,f@z,s@h,i@w,e@e,j@k,e@v,b@a,z@y,z@y,l@r,r@g,h@u,m@n,v@q,e@q,q@d,e@d,y@o,p@g,t@v,x@a,k@q", "c@i,r@x,f@a,p@f,k@s,p@w,m@e,c@q,w@v,g@b,y@i,u@t,r@w,u@p,v@l,j@d,d@t,c@q,j@o,k@h,m@b,s@u,l@e,z@c,g@h,t@x,f@a,g@t,r@h,z@a,p@t,x@l,y@d,g@h,u@n,d@u,v@i,l@i,i@c,n@n,c@n,b@c,y@k,p@d,k@x,a@d,a@t,a@y,r@y,v@q,g@d,b@j,e@w,z@r,n@y,h@x,i@m,j@k,c@u,j@y,u@c,f@p,s@a,o@f,o@l,e@d", "m@u,s@r,u@m,g@r,q@e,d@o,t@g,t@f,o@g,s@l,m@c,x@a,u@r,q@z,t@z,k@j,r@x,d@o,a@p,y@k,f@l,k@z,r@k,o@l,j@w,v@f,l@y,l@g,k@c,x@p,x@k,l@i,c@s,r@x,n@h,m@x,s@k,m@t,k@u,i@y,a@p,a@x,x@z,e@p,y@i,r@x,j@c,r@d,q@l,r@c,m@z,u@l,t@b,x@k,q@k,x@f,r@l,u@v,b@r,z@h,g@i,w@d,l@p,f@p,l@w,v@z", "gjkjqjrks@e,yqiia@q,fijelnmigoditxjrtuhukalfl@n,mwancimlqtfekzkxgjioedhtdivqajwbmu@h,pdxuiwurpgenxaiqaqkcqimcvitljuisfiojlylveie@n,eqdjzeqdbiatjpuhujgykl@gmmlrhnlghsoeyrccygigtkjrjxdwmnkouaiaqpquluwcdqlxqb", "No solution", "No solution", "No solution", "No solution", "aglvesxsmivijisod@m,xcnbfcfgqfwjouidlsueaswf@o,behqpvbkmukxkicyoknkbol@k,utunggpoxxfpbe@q,khv@l,lddqqoyjeex@b,yvtlhbifqmvlukmrvgvpwrscwfhpuwyknwchqhrdqgarmnsdlqgf@l,seltghg@b,huwbfjpsvayzk@f,vwow@zapklumefauly", "No solution", "No solution", "jrlhtwmotdhtgcqokodparuqypwlkbhfsxvmdpfiraokekrolwtlsqjzcuvjfnvblznyngasauzln@g,jypvjcwljnotgjlxketfgtntbotwjehea@vppouyoujujlhjrxbhvltfdslaqwynwjefbdbnuehmipqmtsrivlnippgftgnkhdgqiqbfvgrtoxrznncncqcvf", "oxkvgnggznlfhminxkkhictpiaokdsfrewnxiujpjpstlyxovfwugrsqnpooalknjnfugxojozizlicwvnbflhdevpvnvwztnfiapairpigexbaeshondqdecduewmfrxunphikvlfwmrpsxrhxyjlsgqfiaqnwzlzxcyuudhzr@twllmhyfclybxqazhrmxdtokxawc"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 22 | codeforces |
|
fdd530dfaa50125be7d4251073dd47dd | Hiring Staff | A new Berland businessman Vitaly is going to open a household appliances' store. All he's got to do now is to hire the staff.
The store will work seven days a week, but not around the clock. Every day at least *k* people must work in the store.
Berland has a law that determines the order of working days and non-working days. Namely, each employee must work for exactly *n* consecutive days, then rest for exactly *m* days, then work for *n* more days and rest for *m* more, and so on. Vitaly doesn't want to break the law. Fortunately, there is a loophole: the law comes into force on the day when the employee is hired. For example, if an employee is hired on day *x*, then he should work on days [*x*,<=*x*<=+<=1,<=...,<=*x*<=+<=*n*<=-<=1], [*x*<=+<=*m*<=+<=*n*,<=*x*<=+<=*m*<=+<=*n*<=+<=1,<=...,<=*x*<=+<=*m*<=+<=2*n*<=-<=1], and so on. Day *x* can be chosen arbitrarily by Vitaly.
There is one more thing: the key to the store. Berland law prohibits making copies of keys, so there is only one key. Vitaly is planning to entrust the key to the store employees. At the same time on each day the key must be with an employee who works that day — otherwise on this day no one can get inside the store. During the day the key holder can give the key to another employee, if he also works that day. The key will handed to the first hired employee at his first working day.
Each employee has to be paid salary. Therefore, Vitaly wants to hire as few employees as possible provided that the store can operate normally on each day from 1 to infinity. In other words, on each day with index from 1 to infinity, the store must have at least *k* working employees, and one of the working employees should have the key to the store.
Help Vitaly and determine the minimum required number of employees, as well as days on which they should be hired.
The first line contains three integers *n*, *m* and *k* (1<=≤<=*m*<=≤<=*n*<=≤<=1000, *n*<=≠<=1, 1<=≤<=*k*<=≤<=1000).
In the first line print a single integer *z* — the minimum required number of employees.
In the second line print *z* positive integers, separated by spaces: the *i*-th integer *a**i* (1<=≤<=*a**i*<=≤<=104) should represent the number of the day, on which Vitaly should hire the *i*-th employee.
If there are multiple answers, print any of them.
Sample Input
4 3 2
3 3 1
Sample Output
4
1 1 4 53
1 3 5 | {"inputs": ["4 3 2", "3 3 1", "5 5 3", "7 6 8", "8 3 2", "5 1 1", "6 5 1", "2 1 1", "2 2 1", "3 1 1", "3 2 1", "3 3 1", "4 1 1", "4 2 1", "4 3 1", "4 4 1", "183 1 1", "284 282 1", "359 358 1", "801 801 1", "1000 1 1", "1000 999 1", "1000 1000 1", "2 1 2", "2 2 2", "3 1 2", "3 2 2", "3 3 2", "4 1 2", "4 2 2", "4 3 2", "4 4 2", "17 1 3", "38 15 10", "193 192 113", "384 384 384", "1000 1 2", "1000 485 2", "1000 999 2", "1000 1000 2", "1000 1 183", "1000 2 855", "1000 245 583", "1000 999 475", "1000 1000 334", "2 1 1000", "2 2 1000", "3 1 1000", "3 2 1000", "3 3 1000", "4 1 1000", "4 2 1000", "4 3 1000", "4 4 1000", "385 1 1000", "283 34 1000", "347 346 1000", "485 485 1000", "1000 999 1000", "1000 1000 1000", "2 2 5"], "outputs": ["4\n1 1 4 5", "3\n1 3 5", "7\n1 1 1 5 6 6 7", "16\n1 1 1 1 1 1 1 1 7 7 7 7 7 7 7 8", "4\n1 1 8 9", "2\n1 5", "3\n1 6 7", "3\n1 2 3", "4\n1 2 3 4", "2\n1 3", "3\n1 3 4", "3\n1 3 5", "2\n1 4", "2\n1 4", "3\n1 4 5", "3\n1 4 6", "2\n1 183", "2\n1 284", "3\n1 359 360", "3\n1 801 803", "2\n1 1000", "3\n1 1000 1001", "3\n1 1000 1002", "4\n1 1 2 3", "5\n1 1 2 3 4", "4\n1 1 3 4", "4\n1 1 3 4", "5\n1 1 3 4 5", "4\n1 1 4 5", "4\n1 1 4 5", "4\n1 1 4 5", "5\n1 1 4 5 6", "6\n1 1 1 17 17 18", "20\n1 1 1 1 1 1 1 1 1 1 38 38 38 38 38 38 38 38 38 39", "226\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 193 193 193 193 193 193 193 193 193 193 193 193 193 193 193 193 193 193 193 193 193 193 193 193 193 193 193 193 193 193 193 193 193 193 193 193 193 193 193 193 193 193 193 193 193 193 193 193 193 193 193 193 193 193 193 193 193 193 193 193 193 193 193 193 193 193 193 193 193 193 ...", "769\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1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 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...", "11\n1 1 1 1 1 2 3 3 3 3 4"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 6 | codeforces |
|
fde4f9235dd44012d3470d60a923de13 | Sereja and Intervals | Sereja is interested in intervals of numbers, so he has prepared a problem about intervals for you. An interval of numbers is a pair of integers [*l*,<=*r*] (1<=≤<=*l*<=≤<=*r*<=≤<=*m*). Interval [*l*1,<=*r*1] belongs to interval [*l*2,<=*r*2] if the following condition is met: *l*2<=≤<=*l*1<=≤<=*r*1<=≤<=*r*2.
Sereja wants to write out a sequence of *n* intervals [*l*1,<=*r*1], [*l*2,<=*r*2], ..., [*l**n*,<=*r**n*] on a piece of paper. At that, no interval in the sequence can belong to some other interval of the sequence. Also, Sereja loves number *x* very much and he wants some (at least one) interval in the sequence to have *l**i*<==<=*x*. Sereja wonders, how many distinct ways to write such intervals are there?
Help Sereja and find the required number of ways modulo 1000000007 (109<=+<=7).
Two ways are considered distinct if there is such *j* (1<=≤<=*j*<=≤<=*n*), that the *j*-th intervals in two corresponding sequences are not equal.
The first line contains integers *n*, *m*, *x* (1<=≤<=*n*·*m*<=≤<=100000,<=1<=≤<=*x*<=≤<=*m*) — the number of segments in the sequence, the constraints on the numbers in segments and Sereja's favourite number.
In a single line print the answer modulo 1000000007 (109<=+<=7).
Sample Input
1 1 1
3 5 1
2 3 3
Sample Output
1
240
6
| {"inputs": ["1 1 1", "3 5 1", "2 3 3", "11 79 54", "18 46 26", "8 96 61", "154 5 3", "34 22 8", "29 27 7", "12 68 35", "23 12 10", "6 42 23", "143 645 43", "14 724 55", "166 36 1", "273 41 17", "54 806 191", "6159 7 7", "115 624 37", "8 967 200", "112 440 258", "490 119 1", "745 116 85", "52 978 871", "37 746 303", "106 778 175", "100000 1 1", "1 100000 1", "100 1000 1", "200 500 10", "300 300 300", "2 50000 10", "50000 2 1", "180 199 1", "170 198 10", "1 3 1", "1 100000 100000", "2 50000 50000", "2 50000 25000", "3 33333 1123", "33333 3 2", "50000 2 2", "12322 6 4", "33333 3 1", "33333 3 3"], "outputs": ["1", "240", "6", "311673892", "592264671", "725548575", "0", "0", "0", "757116948", "0", "440655547", "980235015", "565782537", "0", "0", "560287707", "0", "813921941", "655825701", "253936997", "0", "0", "185630114", "869839736", "849234414", "0", "100000", "152986652", "584649848", "419467694", "337716274", "0", "216804476", "123501313", "3", "1", "499949986", "291333331", "446062009", "0", "0", "0", "0", "0"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1 | codeforces |
|
fe12c51426fe404f0b6fb444fa11ed53 | Convex Shape | Consider an *n*<=×<=*m* grid. Initially all the cells of the grid are colored white. Lenny has painted some of the cells (at least one) black. We call a painted grid convex if one can walk from any black cell to any another black cell using a path of side-adjacent black cells changing his direction at most once during the path. In the figure below, the left grid is convex while the right one is not convex, because there exist two cells which need more than one time to change direction in their path.
You're given a painted grid in the input. Tell Lenny if the grid is convex or not.
The first line of the input contains two integers *n* and *m* (1<=≤<=*n*,<=*m*<=≤<=50) — the size of the grid. Each of the next *n* lines contains *m* characters "B" or "W". Character "B" denotes a black cell of the grid and "W" denotes a white cell of the grid.
It's guaranteed that the grid has at least one black cell.
On the only line of the output print "YES" if the grid is convex, otherwise print "NO". Do not print quotes.
Sample Input
3 4
WWBW
BWWW
WWWB
3 1
B
B
W
Sample Output
NO
YES
| {"inputs": ["3 4\nWWBW\nBWWW\nWWWB", "3 1\nB\nB\nW", "1 1\nB", "1 2\nBB", "2 1\nB\nB", "1 2\nBW", "2 1\nW\nB", "5 5\nWBBBW\nWBBBW\nWBBWW\nWBBBW\nWWWWW", "5 5\nWBBWW\nBBBWW\nBBBWW\nBBBWW\nBBBBB", "5 5\n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", "NO", "YES", "YES", "NO", "YES", "YES", "YES", "YES", "YES", "NO", "YES", "YES", "YES", "YES", "YES", "NO", "YES", "YES", "NO", "NO"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 7 | codeforces |
|
feaa637b31fdce3c496608b4398a079b | Tricky Function | Iahub and Sorin are the best competitive programmers in their town. However, they can't both qualify to an important contest. The selection will be made with the help of a single problem. Blatnatalag, a friend of Iahub, managed to get hold of the problem before the contest. Because he wants to make sure Iahub will be the one qualified, he tells Iahub the following task.
You're given an (1-based) array *a* with *n* elements. Let's define function *f*(*i*,<=*j*) (1<=≤<=*i*,<=*j*<=≤<=*n*) as (*i*<=-<=*j*)2<=+<=*g*(*i*,<=*j*)2. Function g is calculated by the following pseudo-code:
Find a value *min**i*<=≠<=*j* *f*(*i*,<=*j*).
Probably by now Iahub already figured out the solution to this problem. Can you?
The first line of input contains a single integer *n* (2<=≤<=*n*<=≤<=100000). Next line contains *n* integers *a*[1], *a*[2], ..., *a*[*n*] (<=-<=104<=≤<=*a*[*i*]<=≤<=104).
Output a single integer — the value of *min**i*<=≠<=*j* *f*(*i*,<=*j*).
Sample Input
4
1 0 0 -1
2
1 -1
Sample Output
1
2
| {"inputs": ["4\n1 0 0 -1", "2\n1 -1", "100\n-57 -64 83 76 80 27 60 76 -80 -56 52 72 -17 92 -96 87 41 -88 94 89 12 42 36 34 -100 -43 -42 62 3 87 -69 -6 -27 -59 -7 5 -90 -23 63 -87 -60 -92 -40 54 -16 -47 67 -64 10 33 -19 53 -7 -62 16 -74 -36 4 -75 -55 92 3 -22 43 -30 48 -27 88 -58 41 36 8 -40 -30 -18 16 22 -66 -91 -46 48 -60 -45 -89 37 -76 52 81 81 15 1 -43 -45 -19 9 -75 -75 -63 41 29", "100\n-1 -3 -3 0 -1 -1 -1 1 2 1 0 -1 -2 0 -2 -2 3 -2 -1 -2 2 -2 -2 3 0 2 3 -1 2 -1 -2 2 -3 2 1 0 -1 1 3 -1 0 2 -3 -2 2 2 3 -2 2 3 0 -3 -2 1 -1 0 3 0 2 0 1 1 0 -3 1 -3 3 0 -1 -3 3 3 1 -2 2 -2 -3 -1 -2 2 -1 0 2 1 2 -1 2 3 -2 -1 0 -3 0 -1 3 2 -2 2 3 0", "4\n200 100 -200 100", "2\n3 -9", "3\n0 -10 10", "2\n10000 10000", "2\n5 5", "3\n10 10 -10", "6\n10000 10000 10000 10000 10000 6904", "3\n0 10000 -10000", "3\n0 2 3", "2\n0 1", "5\n5865 6072 -4563 5913 -7926", "2\n1 10000", "5\n10 11 12 13 -40", "21\n10 10 10 10 10 10 10 10 10 10 -95 10 10 10 10 10 10 10 10 10 10", "5\n0 4 10 -5 -5", "2\n0 10000", "4\n0 100 100 -200", "4\n0 10 -5 -5", "4\n10 10 -10 -10", "3\n1 10 10", "3\n1000 1000 -800", "3\n0 10 -10", "2\n0 100"], "outputs": ["1", "2", "2", "1", "9", "82", "4", "100000001", "26", "4", "47665217", "4", "5", "2", "254032", "100000001", "32", "101", "9", "100000001", "9", "9", "4", "101", "40004", "4", "10001"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 4 | codeforces |
|
feb6b1e03e665a72ca3cb3f0ccfc5ca2 | Two Arithmetic Progressions | You are given two arithmetic progressions: *a*1*k*<=+<=*b*1 and *a*2*l*<=+<=*b*2. Find the number of integers *x* such that *L*<=≤<=*x*<=≤<=*R* and *x*<==<=*a*1*k*'<=+<=*b*1<==<=*a*2*l*'<=+<=*b*2, for some integers *k*',<=*l*'<=≥<=0.
The only line contains six integers *a*1,<=*b*1,<=*a*2,<=*b*2,<=*L*,<=*R* (0<=<<=*a*1,<=*a*2<=≤<=2·109,<=<=-<=2·109<=≤<=*b*1,<=*b*2,<=*L*,<=*R*<=≤<=2·109,<=*L*<=≤<=*R*).
Print the desired number of integers *x*.
Sample Input
2 0 3 3 5 21
2 4 3 0 6 17
Sample Output
3
2
| {"inputs": ["2 0 3 3 5 21", "2 4 3 0 6 17", "2 0 4 2 -39 -37", "1 9 3 11 49 109", "3 81 5 72 -1761 501", "8 -89 20 67 8771 35222", "1 -221 894 86403 -687111 141371", "1 -1074 271 17741 -2062230 1866217", "3 2408 819 119198 -8585197 7878219", "1 341 8581 3946733 -59420141 33253737", "1 10497 19135 2995296 -301164547 -180830773", "8 40306 2753 1809818 254464419 340812028", "2 21697 9076 1042855 -319348358 236269755", "4 2963 394 577593 125523962 628140505", "75 61736 200 200511 160330870 609945842", "34 64314 836 5976 591751179 605203191", "1 30929 25249 95822203 -1076436442 705164517", "3 -1208 459 933808 603490653 734283665", "1 35769 16801 47397023 -82531776 1860450454", "1 -3078 36929 51253687 -754589746 -53412627", "1 -32720 3649 7805027 408032642 925337350", "1 -2000000000 1 -2000000000 -2000000000 2000000000", "1 -2000000000 2 -2000000000 -2000000000 2000000000", "3 -2000000000 2 -2000000000 -2000000000 2000000000", "999999999 999999998 1000000000 999999999 1 10000", "1 -2000000000 1 2000000000 1 10", "1 -2000000000 2 2000000000 -2000000000 2000000000", "2 0 2 1 0 1000000000", "1000000000 0 1 0 0 2000000000", "4 0 4 1 5 100", "1000000000 1 999999999 0 1 100000000", "1 30929 1 1 1 1", "1 1 1 1 -2000000000 2000000000", "4 0 4 1 0 100", "1 -2000000000 1 2000000000 5 5", "51 -1981067352 71 -414801558 -737219217 1160601982", "2 -1500000000 4 -1499999999 1600000000 1700000000", "135 -1526277729 32 1308747737 895574 1593602399", "1098197640 6 994625382 6 -474895292 -101082478", "12 -696575903 571708420 236073275 2 14", "1 -9 2 -10 -10 -9", "2 -11 2 -9 -11 -9", "40 54 15 74 -180834723 1373530127", "2 57 1 56 -1773410854 414679043", "9 12 1 40 624782492 883541397", "4 -1000000000 2 4 100 1000", "66 90 48 84 -1709970247 1229724777", "1000000000 1 2000000000 0 -2000000000 200000000", "2 0 2 1 -1000000000 1000000000", "2 -1000000000 2 -999999999 -1000000000 1000000000", "26 1885082760 30 -1612707510 -1113844607 1168679422", "76 -19386 86 -6257 164862270 1443198941", "5 -2000000000 5 1000000000 1000000000 2000000000", "505086589 -4 1288924334 -4 -5 -4", "91 -193581878 2 1698062870 -819102473 1893630769", "8 11047 45 12730 -45077355 1727233357", "35 8673 6 -19687 -111709844 1321584980", "71 1212885043 55 1502412287 970234397 1952605611", "274497829 -12 9 -445460655 -5 4", "1509527550 3 7 -134101853 2 7", "43 -1478944506 45 494850401 634267177 1723176461", "25 479638866 50 -874479027 -2000000000 2000000000", "11 -10 1 -878946597 -11127643 271407906", "15 -738862158 12 -3 -3 12", "70 -835526513 23 687193329 -1461506792 1969698938", "124 1413 15321 312133 3424 1443242", "75 -13580 14 4508 -67634192 1808916097", "915583842 -15 991339476 -12 -15 -5", "85 -18257 47 -7345 -76967244 1349252598", "178 331734603 162 -73813367 -577552570 1005832995", "8 -17768 34 963 -2000000000 2000000000", "26 1885082760 30 -1612707510 -2000000000 2000000000", "4 -1999999999 6 -1999999998 -999999999 1999999999", "121826 1323 1327 304172 -1521910750 860413213", "36281 170 1917 927519 -1767064448 -177975414", "37189 -436 464 797102 -1433652908 1847752465", "81427 -688 1720 -221771 -77602716 1593447723", "11 -1609620737 1315657088 -7 -162162918 287749240", "1480269313 -1048624081 1314841531 -8 295288505 358226461", "13 -15 19 -2 -334847526 1334632952", "1254161381 -7 821244830 -7 -698761303 941496965", "1269100557 -5 6 -5 -12 -6", "847666888 -6 1327933031 -6 -5 -2", "1465846675 1002489474 9 -1250811979 1030017372 1391560043", "8 -1915865359 867648990 9 -5 -4", "3 -1164702220 906446587 -1868913852 222249893 1493113759", "15 -8 17 3 -393290856 231975525", "734963978 0 17 0 -12 -5", "1090004357 5 1124063714 -840327001 -448110704 128367602", "18 -1071025614 1096150070 0 -6 0", "451525105 -8 1256335024 -8 -718788747 928640626", "4 3 5 -1292190012 -97547955 250011754", "14 -7 14 -1488383431 -1044342357 842171605", "1384140089 5 16 -1661922737 442287491 1568124284", "16 -11 14 -1466771835 -1192555694 -2257860", "1676164235 -1589020998 1924931103 1189158232 6 12", "15 16 12 -5 11 23", "16 -16 5 20 -9 7", "4 -9 1 -2 -13 -1", "18 -17 9 -17 -29 17", "735463638 620656007 878587644 536507630 -1556948056 1714374073", "1789433851 -633540112 1286318222 -1728151682 1438333624 1538194890", "15 -1264610276 1157160166 -336457087 -496892962 759120142", "831644204 422087925 17 -1288230412 -1090082747 1271113499", "17 -13 223959272 -1081245422 -1756575771 38924201", "1228969457 -1826233120 11 -1063855654 -819177202 1039858319", "1186536442 -1691684240 17 -1 -702600351 1121394816", "1132421757 -1481846636 515765656 -12 -622203577 552143596", "18 -1123473160 1826212361 -10 -12 1", "1197045662 7 15 -1445473718 -1406137199 800415943", "18 565032929 13 735553852 107748471 1945959489", "1734271904 1 19 -1826828681 0 4", "1614979757 -1237127436 12 75067457 -933537920 451911806", "8 -335942902 1179386720 -723257398 -13 -12", "989432982 2 9 366779468 -1427636085 985664909", "7 -1390956935 1404528667 -4 -15 0", "1370475975 841789607 733784598 467967887 -7 15", "6 -7 9 -1 -10 1", "960716652 1417038753 1222139305 -4 -1570098546 -931528535", "1744394473 5 1523286739 629247513 -6 1", "2627 -4960 2627 -4960 -4960 4960", "6 -364562196 7 -803430276 0 11", "1955378240 -837482305 1743607821 -1623988108 -653286850 178227154", "9 -1642366642 1499382371 -6 -822052389 1405478033", "9 -1 8 -1 -711474975 237571596", "1497677869 -1313800455 11 12 -1157529918 1754001465", "11 -80049925 1600186381 -1454831688 -1384227392 1621203975", "1042015302 -56794440 1727095321 -1037110962 -9 11", "13 0 1419591662 -1360930956 343359607 1283114457", "752411560 -6 857048450 -405514986 -5 0", "12 2 18 2 -6 3", "11 -1 15 -1 -13 2", "1446642133 -7 9 -1719422944 -916435667 36154654", "1689390799 501112014 13 -1621132473 398367938 709483101", "1932547151 -725726769 782679113 -10 -184530763 498112212"], "outputs": ["3", "2", "0", "20", "28", "661", "62", "6821", "9474", "3416", "0", "3921", "25918", "637839", "749358", "946", "24134", "284952", "107914", "0", "141766", "4000000001", "2000000001", "666666667", "0", "0", "1", "0", "3", "0", "0", "0", "2000000000", "0", "0", "435075", "0", "65938", "0", "0", "0", "1", "11446084", "207339494", "28750990", "226", "2329024", "0", "0", "0", "0", "0", "200000001", "1", "1074549", "4797835", "6293220", "115287", "0", "1", "562743", "0", "24673447", "1", "796587", "0", "1722773", "0", "337737", "46754", "0", "294660", "0", "5", "0", "107", "11", "0", "0", "5403373", "1", "0", "0", "0", "0", "0", "909708", "0", "0", "1", "1", "12500588", "0", "0", "0", "0", "0", "0", "1", "2", "0", "0", "0", "1", "1", "0", "1", "0", "1", "1", "5172673", "1", "1", "0", "0", "1", "0", "1", "0", "0", "4", "0", "0", "0", "3299606", "1", "0", "0", "0", "0", "1", "1", "1", "0", "0"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 9 | codeforces |
|
febea4f23d6799418a46ea0af82f70af | Permutation | You are given a permutation of numbers from 1 to *n*. Determine whether there's a pair of integers *a*,<=*b* (1<=≤<=*a*,<=*b*<=≤<=*n*; *a*<=≠<=*b*) such that the element (note, that it is usual division, not integer one) is between *a* and *b* in this permutation.
First line consists of a single integer *n* (1<=≤<=*n*<=≤<=300000) — the size of permutation.
Second line contains *n* integers — the permutation itself.
Print "YES", if such a pair exists, "NO" otherwise (in both cases without quotes, the answer is case insensitive).
Sample Input
4
1 3 4 2
5
1 5 2 4 3
Sample Output
NO
YES
| {"inputs": ["4\n1 3 4 2", "5\n1 5 2 4 3", "100\n17 41 19 23 46 16 10 31 82 12 77 32 11 71 83 25 98 18 34 59 13 73 80 65 37 22 6 2 24 5 94 42 51 63 52 92 97 26 93 38 36 87 64 70 14 43 68 85 33 44 74 89 56 1 69 88 20 49 48 21 84 90 7 47 39 55 81 86 76 57 3 62 15 78 100 60 61 66 91 30 58 35 99 96 54 27 79 9 29 50 45 72 75 4 67 40 8 53 95 28", "100\n1 65 33 97 17 81 49 9 73 41 25 89 57 5 69 37 21 85 53 13 77 45 29 93 61 3 67 35 99 19 83 51 11 75 43 27 91 59 7 71 39 23 87 55 15 79 47 31 95 63 2 66 34 98 18 82 50 10 74 42 26 90 58 6 70 38 22 86 54 14 78 46 30 94 62 4 68 36 100 20 84 52 12 76 44 28 92 60 8 72 40 24 88 56 16 80 48 32 96 64", "100\n22 78 19 70 81 33 15 72 40 51 18 62 36 24 37 20 97 65 89 75 14 55 23 53 1 67 50 99 54 76 41 16 44 60 2 90 7 28 79 43 47 64 71 27 25 8 46 92 95 80 31 100 42 96 86 66 52 63 98 4 56 91 34 83 85 3 84 17 94 11 73 29 6 58 61 68 57 88 10 32 82 93 26 13 87 39 30 5 12 59 9 48 69 35 77 21 45 38 49 74", "100\n75 28 8 98 60 16 40 89 90 39 44 88 51 9 95 42 27 63 92 15 67 3 19 81 54 2 97 61 45 93 58 84 70 83 79 78 21 12 94 87 64 11 56 4 10 49 25 1 33 86 62 72 69 74 96 48 6 46 29 66 23 73 50 37 5 18 41 34 22 7 82 99 35 57 38 26 31 100 55 17 91 85 24 71 43 13 52 65 76 77 36 47 53 32 14 30 20 68 59 80", "100\n1 65 33 97 17 81 49 9 73 41 25 89 57 5 69 37 21 85 53 13 77 45 29 93 61 3 67 35 99 19 83 51 11 75 43 27 91 59 7 71 39 23 87 55 15 79 47 31 95 63 2 66 34 98 18 82 50 10 74 42 26 90 58 6 70 38 22 86 54 14 78 46 30 94 62 4 68 36 100 20 84 52 12 76 44 28 92 60 8 72 40 24 88 56 16 80 48 32 96 64", "100\n1 65 33 97 17 81 49 9 73 41 25 89 57 5 69 37 21 85 53 13 77 45 29 93 61 3 67 35 99 19 83 51 11 75 43 27 91 59 7 71 39 23 87 55 15 79 47 31 95 63 2 66 34 98 18 82 50 10 74 42 26 90 58 6 70 38 22 86 54 14 78 46 30 94 62 4 68 36 100 20 84 52 12 76 44 28 92 60 8 72 40 24 88 56 16 80 48 32 96 64", "100\n1 65 33 97 17 81 49 9 73 41 25 89 57 5 69 37 21 85 53 13 77 45 29 93 61 3 67 35 99 19 83 51 11 75 43 27 91 59 7 71 39 23 87 55 15 79 47 31 95 2 63 66 34 98 18 82 50 10 74 42 26 90 58 6 70 38 22 86 54 14 78 46 30 94 62 4 68 36 100 20 84 52 12 76 44 28 92 60 8 72 40 24 88 56 16 80 48 32 96 64", "100\n1 65 33 97 17 81 49 9 73 41 25 89 57 5 69 37 21 85 53 13 77 45 29 93 61 3 67 35 99 19 83 51 11 75 43 27 91 59 7 71 39 23 87 55 15 79 47 31 95 2 63 66 34 98 18 82 50 10 74 42 26 90 58 6 70 38 22 86 54 14 78 46 30 94 62 4 68 36 100 20 84 52 12 76 44 28 92 60 8 72 40 24 88 56 16 80 48 32 96 64", "100\n1 65 33 97 17 81 49 9 73 41 25 89 57 5 69 37 21 85 53 13 77 45 29 93 61 3 67 35 99 19 83 51 11 75 43 27 91 59 7 71 39 23 87 55 15 79 47 31 95 63 2 66 34 98 18 82 50 10 74 42 26 90 58 6 70 38 22 86 54 14 78 46 30 94 62 4 68 36 100 20 84 52 12 76 44 28 92 60 8 72 40 24 88 56 16 80 48 32 96 64", "100\n1 65 33 97 17 81 49 9 73 41 25 89 57 5 69 37 21 85 53 13 77 45 29 93 61 3 67 35 99 19 83 51 11 75 43 27 91 59 7 71 39 23 87 55 15 79 47 31 95 2 63 66 34 98 18 82 50 10 74 42 26 90 58 6 70 38 22 86 54 14 78 46 30 94 62 4 68 36 100 20 84 52 12 76 44 28 92 60 8 72 40 24 88 56 16 80 48 32 96 64", "100\n1 65 33 97 17 81 49 9 73 41 25 89 57 5 69 37 21 85 53 13 77 45 29 93 61 3 67 35 99 19 83 51 11 75 43 27 91 59 7 71 39 23 87 55 15 79 47 31 95 2 63 66 34 98 18 82 50 10 74 42 26 90 58 6 70 38 22 86 54 14 78 46 30 94 62 4 68 36 100 20 84 52 12 76 44 28 92 60 8 72 40 24 88 56 16 80 48 32 96 64", "100\n1 65 33 97 17 81 49 9 73 41 25 89 57 5 69 37 21 85 53 13 77 45 29 93 61 3 67 35 99 19 83 51 11 75 43 27 91 59 7 71 39 23 87 55 15 79 47 31 95 63 2 66 34 98 18 82 50 10 74 42 26 90 58 6 70 38 22 86 54 14 78 46 30 94 62 4 68 36 100 20 84 52 12 76 44 28 92 60 8 72 40 24 88 56 16 80 48 32 96 64", "100\n1 65 33 97 17 81 49 9 73 41 25 89 57 5 69 37 21 85 53 13 77 45 29 93 61 3 67 35 99 19 83 51 11 75 43 27 91 59 7 71 39 23 87 55 15 79 47 31 2 95 63 66 34 98 18 82 50 10 74 42 26 90 58 6 70 38 22 86 54 14 78 46 30 94 62 4 68 36 100 20 84 52 12 76 44 28 92 60 8 72 40 24 88 56 16 80 48 32 96 64", "100\n1 65 33 97 17 81 49 9 73 41 25 89 57 5 69 37 21 85 53 13 77 45 29 93 61 3 67 35 99 19 83 51 11 75 43 27 91 59 7 71 39 23 87 55 15 79 47 2 31 66 95 34 63 98 18 82 50 10 74 42 26 90 58 6 70 38 22 86 54 14 78 46 30 94 62 4 68 36 100 20 84 52 12 76 44 28 92 60 8 72 40 24 88 56 16 80 48 32 96 64", "100\n1 65 33 97 17 81 49 9 73 41 25 89 57 5 69 37 21 85 53 13 77 45 29 93 61 3 67 35 99 19 83 51 11 75 43 27 91 59 7 71 39 23 87 55 15 79 47 2 31 95 66 34 63 98 18 82 50 10 74 42 26 90 58 6 70 38 22 86 54 14 78 46 30 94 62 4 68 36 100 20 84 52 12 76 44 28 92 60 8 72 40 24 88 56 16 80 48 32 96 64", "4\n3 4 1 2", "5\n3 5 4 1 2", "14\n7 11 9 13 10 3 1 14 12 5 2 6 4 8", "6\n6 2 4 1 3 5"], "outputs": ["NO", "YES", "YES", "NO", "YES", "YES", "NO", "NO", "NO", "NO", "NO", "NO", "NO", "NO", "NO", "YES", "YES", "NO", "NO", "NO", "YES"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1 | codeforces |
|
fecd3371aac8091bff48bc8e2f52941c | Kalevitch and Chess | A famous Berland's painter Kalevitch likes to shock the public. One of his last obsessions is chess. For more than a thousand years people have been playing this old game on uninteresting, monotonous boards. Kalevitch decided to put an end to this tradition and to introduce a new attitude to chessboards.
As before, the chessboard is a square-checkered board with the squares arranged in a 8<=×<=8 grid, each square is painted black or white. Kalevitch suggests that chessboards should be painted in the following manner: there should be chosen a horizontal or a vertical line of 8 squares (i.e. a row or a column), and painted black. Initially the whole chessboard is white, and it can be painted in the above described way one or more times. It is allowed to paint a square many times, but after the first time it does not change its colour any more and remains black. Kalevitch paints chessboards neatly, and it is impossible to judge by an individual square if it was painted with a vertical or a horizontal stroke.
Kalevitch hopes that such chessboards will gain popularity, and he will be commissioned to paint chessboards, which will help him ensure a comfortable old age. The clients will inform him what chessboard they want to have, and the painter will paint a white chessboard meeting the client's requirements.
It goes without saying that in such business one should economize on everything — for each commission he wants to know the minimum amount of strokes that he has to paint to fulfill the client's needs. You are asked to help Kalevitch with this task.
The input file contains 8 lines, each of the lines contains 8 characters. The given matrix describes the client's requirements, W character stands for a white square, and B character — for a square painted black.
It is guaranteed that client's requirments can be fulfilled with a sequence of allowed strokes (vertical/column or horizontal/row).
Output the only number — the minimum amount of rows and columns that Kalevitch has to paint on the white chessboard to meet the client's requirements.
Sample Input
WWWBWWBW
BBBBBBBB
WWWBWWBW
WWWBWWBW
WWWBWWBW
WWWBWWBW
WWWBWWBW
WWWBWWBW
WWWWWWWW
BBBBBBBB
WWWWWWWW
WWWWWWWW
WWWWWWWW
WWWWWWWW
WWWWWWWW
WWWWWWWW
Sample Output
3
1
| {"inputs": ["WWWBWWBW\nBBBBBBBB\nWWWBWWBW\nWWWBWWBW\nWWWBWWBW\nWWWBWWBW\nWWWBWWBW\nWWWBWWBW", "WWWWWWWW\nBBBBBBBB\nWWWWWWWW\nWWWWWWWW\nWWWWWWWW\nWWWWWWWW\nWWWWWWWW\nWWWWWWWW", "WWWWWWWW\nWWWWWWWW\nWWWWWWWW\nWWWWWWWW\nWWWWWWWW\nWWWWWWWW\nWWWWWWWW\nWWWWWWWW", "BBBBBBBB\nBBBBBBBB\nBBBBBBBB\nBBBBBBBB\nBBBBBBBB\nBB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BWBBWWWW\nBBBBBBBB\nBBBBBBBB\nBBBBBBBB\nBWBBWWWW\nBBBBBBBB"], "outputs": ["3", "1", "0", "8", "14", "14", "9", "9", "8", "8", "7", "9", "11", "10", "10", "6", "10", "9", "9", "8", "6", "10", "11", "9", "9", "10", "12", "7", "6", "7"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 170 | codeforces |
|
fed340b160e4eb32c6a5954134630705 | Hierarchy | Nick's company employed *n* people. Now Nick needs to build a tree hierarchy of «supervisor-surbodinate» relations in the company (this is to say that each employee, except one, has exactly one supervisor). There are *m* applications written in the following form: «employee *a**i* is ready to become a supervisor of employee *b**i* at extra cost *c**i*». The qualification *q**j* of each employee is known, and for each application the following is true: *q**a**i*<=><=*q**b**i*.
Would you help Nick calculate the minimum cost of such a hierarchy, or find out that it is impossible to build it.
The first input line contains integer *n* (1<=≤<=*n*<=≤<=1000) — amount of employees in the company. The following line contains *n* space-separated numbers *q**j* (0<=≤<=*q**j*<=≤<=106)— the employees' qualifications. The following line contains number *m* (0<=≤<=*m*<=≤<=10000) — amount of received applications. The following *m* lines contain the applications themselves, each of them in the form of three space-separated numbers: *a**i*, *b**i* and *c**i* (1<=≤<=*a**i*,<=*b**i*<=≤<=*n*, 0<=≤<=*c**i*<=≤<=106). Different applications can be similar, i.e. they can come from one and the same employee who offered to become a supervisor of the same person but at a different cost. For each application *q**a**i*<=><=*q**b**i*.
Output the only line — the minimum cost of building such a hierarchy, or -1 if it is impossible to build it.
Sample Input
4
7 2 3 1
4
1 2 5
2 4 1
3 4 1
1 3 5
3
1 2 3
2
3 1 2
3 1 3
Sample Output
11
-1
| {"inputs": ["4\n7 2 3 1\n4\n1 2 5\n2 4 1\n3 4 1\n1 3 5", "3\n1 2 3\n2\n3 1 2\n3 1 3", "1\n2\n0", "2\n5 3\n4\n1 2 0\n1 2 5\n1 2 0\n1 2 7", "3\n9 4 5\n5\n3 2 4\n1 2 4\n3 2 8\n1 3 5\n3 2 5", "3\n2 5 9\n5\n3 1 7\n2 1 1\n2 1 6\n2 1 2\n3 1 5", "3\n6 2 9\n5\n1 2 10\n3 1 4\n1 2 5\n1 2 2\n3 1 4", "4\n10 6 7 4\n5\n1 3 1\n3 4 1\n3 2 2\n1 2 6\n1 4 7", "4\n2 7 0 6\n8\n4 3 5\n2 3 7\n4 3 1\n2 1 9\n1 3 1\n1 3 3\n2 3 1\n1 3 2", "5\n6 8 5 9 0\n8\n4 2 2\n2 3 10\n2 3 6\n4 5 4\n1 3 1\n4 3 4\n3 5 1\n2 3 8", "5\n10 9 5 0 3\n9\n1 5 1\n1 4 7\n1 4 0\n1 4 6\n3 4 6\n2 3 1\n1 2 2\n1 2 9\n2 3 9", "5\n3 9 2 1 8\n9\n2 5 10\n1 3 8\n3 4 9\n5 4 2\n2 1 4\n5 1 4\n2 4 2\n1 4 7\n5 1 2", "5\n6 10 7 8 5\n10\n3 1 5\n2 4 1\n2 3 2\n4 5 9\n3 5 0\n4 1 9\n4 5 2\n1 5 8\n2 3 7\n1 5 1", "7\n10 0 4 7 3 8 6\n10\n3 2 4\n6 4 3\n6 5 1\n1 2 1\n6 7 6\n7 3 9\n1 6 3\n3 2 1\n6 4 4\n1 4 4", "6\n10 2 4 3 1 6\n10\n1 4 7\n1 6 9\n6 4 1\n4 2 5\n4 5 7\n6 3 10\n3 2 3\n3 4 3\n6 5 2\n1 3 2", "1\n10\n0", "2\n10 5\n0", "2\n1000000 999999\n1\n1 2 1000000", "4\n3 2 2 1\n5\n1 2 1\n1 3 1\n1 4 500\n2 4 1\n3 4 2"], "outputs": ["11", "-1", "0", "0", "9", "-1", "6", "4", "-1", "-1", "4", "22", "8", "23", "17", "0", "-1", "1000000", "3"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 85 | codeforces |
|
fee1c0d82e0df1ec46bbb228704921c3 | Relatively Prime Graph | Let's call an undirected graph $G = (V, E)$ relatively prime if and only if for each edge $(v, u) \in E$ $GCD(v, u) = 1$ (the greatest common divisor of $v$ and $u$ is $1$). If there is no edge between some pair of vertices $v$ and $u$ then the value of $GCD(v, u)$ doesn't matter. The vertices are numbered from $1$ to $|V|$.
Construct a relatively prime graph with $n$ vertices and $m$ edges such that it is connected and it contains neither self-loops nor multiple edges.
If there exists no valid graph with the given number of vertices and edges then output "Impossible".
If there are multiple answers then print any of them.
The only line contains two integers $n$ and $m$ ($1 \le n, m \le 10^5$) — the number of vertices and the number of edges.
If there exists no valid graph with the given number of vertices and edges then output "Impossible".
Otherwise print the answer in the following format:
The first line should contain the word "Possible".
The $i$-th of the next $m$ lines should contain the $i$-th edge $(v_i, u_i)$ of the resulting graph ($1 \le v_i, u_i \le n, v_i \neq u_i$). For each pair $(v, u)$ there can be no more pairs $(v, u)$ or $(u, v)$. The vertices are numbered from $1$ to $n$.
If there are multiple answers then print any of them.
Sample Input
5 6
6 12
Sample Output
Possible
2 5
3 2
5 1
3 4
4 1
5 4
Impossible
| {"inputs": ["5 6", "6 12", "572 99643", "571 99403", "100 3043", "10 31", "1 1", "2 1", "100000 1", "100000 99999", "100000 100000", "1000 100000", "572 99644", "571 99404", "100 3044", "10 32", "100000 99998", "55910 88645", "72050 72069", "53599 55493", "56557 100000", "1001 100000", "50000 100000", "530 100000", "46133 100000", "2 2", "3 2", "1 1", "1 2", "1 3", "1 4", "1 5", "2 1", "2 2", "2 3", "2 4", "2 5", "3 1", "3 2", "3 3", "3 4", "3 5", "4 1", "4 2", "4 3", "4 4", "4 5", "5 1", "5 2", "5 3", "5 4", "5 5"], "outputs": ["Possible\n2 1\n3 1\n4 1\n5 1\n3 2\n5 2", "Impossible", "Possible\n2 1\n3 1\n4 1\n5 1\n6 1\n7 1\n8 1\n9 1\n10 1\n11 1\n12 1\n13 1\n14 1\n15 1\n16 1\n17 1\n18 1\n19 1\n20 1\n21 1\n22 1\n23 1\n24 1\n25 1\n26 1\n27 1\n28 1\n29 1\n30 1\n31 1\n32 1\n33 1\n34 1\n35 1\n36 1\n37 1\n38 1\n39 1\n40 1\n41 1\n42 1\n43 1\n44 1\n45 1\n46 1\n47 1\n48 1\n49 1\n50 1\n51 1\n52 1\n53 1\n54 1\n55 1\n56 1\n57 1\n58 1\n59 1\n60 1\n61 1\n62 1\n63 1\n64 1\n65 1\n66 1\n67 1\n68 1\n69 1\n70 1\n71 1\n72 1\n73 1\n74 1\n75 1\n76 1\n77 1\n78 1\n79 1\n80 1\n81 1\n82 1\n83 1\n84 1\n85 1\n86 1\n...", "Possible\n2 1\n3 1\n4 1\n5 1\n6 1\n7 1\n8 1\n9 1\n10 1\n11 1\n12 1\n13 1\n14 1\n15 1\n16 1\n17 1\n18 1\n19 1\n20 1\n21 1\n22 1\n23 1\n24 1\n25 1\n26 1\n27 1\n28 1\n29 1\n30 1\n31 1\n32 1\n33 1\n34 1\n35 1\n36 1\n37 1\n38 1\n39 1\n40 1\n41 1\n42 1\n43 1\n44 1\n45 1\n46 1\n47 1\n48 1\n49 1\n50 1\n51 1\n52 1\n53 1\n54 1\n55 1\n56 1\n57 1\n58 1\n59 1\n60 1\n61 1\n62 1\n63 1\n64 1\n65 1\n66 1\n67 1\n68 1\n69 1\n70 1\n71 1\n72 1\n73 1\n74 1\n75 1\n76 1\n77 1\n78 1\n79 1\n80 1\n81 1\n82 1\n83 1\n84 1\n85 1\n86 1\n...", "Possible\n2 1\n3 1\n4 1\n5 1\n6 1\n7 1\n8 1\n9 1\n10 1\n11 1\n12 1\n13 1\n14 1\n15 1\n16 1\n17 1\n18 1\n19 1\n20 1\n21 1\n22 1\n23 1\n24 1\n25 1\n26 1\n27 1\n28 1\n29 1\n30 1\n31 1\n32 1\n33 1\n34 1\n35 1\n36 1\n37 1\n38 1\n39 1\n40 1\n41 1\n42 1\n43 1\n44 1\n45 1\n46 1\n47 1\n48 1\n49 1\n50 1\n51 1\n52 1\n53 1\n54 1\n55 1\n56 1\n57 1\n58 1\n59 1\n60 1\n61 1\n62 1\n63 1\n64 1\n65 1\n66 1\n67 1\n68 1\n69 1\n70 1\n71 1\n72 1\n73 1\n74 1\n75 1\n76 1\n77 1\n78 1\n79 1\n80 1\n81 1\n82 1\n83 1\n84 1\n85 1\n86 1\n...", "Possible\n2 1\n3 1\n4 1\n5 1\n6 1\n7 1\n8 1\n9 1\n10 1\n3 2\n5 2\n7 2\n9 2\n4 3\n5 3\n7 3\n8 3\n10 3\n5 4\n7 4\n9 4\n6 5\n7 5\n8 5\n9 5\n7 6\n8 7\n9 7\n10 7\n9 8\n10 9", "Impossible", "Possible\n2 1", "Impossible", "Possible\n2 1\n3 1\n4 1\n5 1\n6 1\n7 1\n8 1\n9 1\n10 1\n11 1\n12 1\n13 1\n14 1\n15 1\n16 1\n17 1\n18 1\n19 1\n20 1\n21 1\n22 1\n23 1\n24 1\n25 1\n26 1\n27 1\n28 1\n29 1\n30 1\n31 1\n32 1\n33 1\n34 1\n35 1\n36 1\n37 1\n38 1\n39 1\n40 1\n41 1\n42 1\n43 1\n44 1\n45 1\n46 1\n47 1\n48 1\n49 1\n50 1\n51 1\n52 1\n53 1\n54 1\n55 1\n56 1\n57 1\n58 1\n59 1\n60 1\n61 1\n62 1\n63 1\n64 1\n65 1\n66 1\n67 1\n68 1\n69 1\n70 1\n71 1\n72 1\n73 1\n74 1\n75 1\n76 1\n77 1\n78 1\n79 1\n80 1\n81 1\n82 1\n83 1\n84 1\n85 1\n86 1\n...", "Possible\n2 1\n3 1\n4 1\n5 1\n6 1\n7 1\n8 1\n9 1\n10 1\n11 1\n12 1\n13 1\n14 1\n15 1\n16 1\n17 1\n18 1\n19 1\n20 1\n21 1\n22 1\n23 1\n24 1\n25 1\n26 1\n27 1\n28 1\n29 1\n30 1\n31 1\n32 1\n33 1\n34 1\n35 1\n36 1\n37 1\n38 1\n39 1\n40 1\n41 1\n42 1\n43 1\n44 1\n45 1\n46 1\n47 1\n48 1\n49 1\n50 1\n51 1\n52 1\n53 1\n54 1\n55 1\n56 1\n57 1\n58 1\n59 1\n60 1\n61 1\n62 1\n63 1\n64 1\n65 1\n66 1\n67 1\n68 1\n69 1\n70 1\n71 1\n72 1\n73 1\n74 1\n75 1\n76 1\n77 1\n78 1\n79 1\n80 1\n81 1\n82 1\n83 1\n84 1\n85 1\n86 1\n...", "Possible\n2 1\n3 1\n4 1\n5 1\n6 1\n7 1\n8 1\n9 1\n10 1\n11 1\n12 1\n13 1\n14 1\n15 1\n16 1\n17 1\n18 1\n19 1\n20 1\n21 1\n22 1\n23 1\n24 1\n25 1\n26 1\n27 1\n28 1\n29 1\n30 1\n31 1\n32 1\n33 1\n34 1\n35 1\n36 1\n37 1\n38 1\n39 1\n40 1\n41 1\n42 1\n43 1\n44 1\n45 1\n46 1\n47 1\n48 1\n49 1\n50 1\n51 1\n52 1\n53 1\n54 1\n55 1\n56 1\n57 1\n58 1\n59 1\n60 1\n61 1\n62 1\n63 1\n64 1\n65 1\n66 1\n67 1\n68 1\n69 1\n70 1\n71 1\n72 1\n73 1\n74 1\n75 1\n76 1\n77 1\n78 1\n79 1\n80 1\n81 1\n82 1\n83 1\n84 1\n85 1\n86 1\n...", "Impossible", "Impossible", "Impossible", "Impossible", "Impossible", "Possible\n2 1\n3 1\n4 1\n5 1\n6 1\n7 1\n8 1\n9 1\n10 1\n11 1\n12 1\n13 1\n14 1\n15 1\n16 1\n17 1\n18 1\n19 1\n20 1\n21 1\n22 1\n23 1\n24 1\n25 1\n26 1\n27 1\n28 1\n29 1\n30 1\n31 1\n32 1\n33 1\n34 1\n35 1\n36 1\n37 1\n38 1\n39 1\n40 1\n41 1\n42 1\n43 1\n44 1\n45 1\n46 1\n47 1\n48 1\n49 1\n50 1\n51 1\n52 1\n53 1\n54 1\n55 1\n56 1\n57 1\n58 1\n59 1\n60 1\n61 1\n62 1\n63 1\n64 1\n65 1\n66 1\n67 1\n68 1\n69 1\n70 1\n71 1\n72 1\n73 1\n74 1\n75 1\n76 1\n77 1\n78 1\n79 1\n80 1\n81 1\n82 1\n83 1\n84 1\n85 1\n86 1\n...", "Possible\n2 1\n3 1\n4 1\n5 1\n6 1\n7 1\n8 1\n9 1\n10 1\n11 1\n12 1\n13 1\n14 1\n15 1\n16 1\n17 1\n18 1\n19 1\n20 1\n21 1\n22 1\n23 1\n24 1\n25 1\n26 1\n27 1\n28 1\n29 1\n30 1\n31 1\n32 1\n33 1\n34 1\n35 1\n36 1\n37 1\n38 1\n39 1\n40 1\n41 1\n42 1\n43 1\n44 1\n45 1\n46 1\n47 1\n48 1\n49 1\n50 1\n51 1\n52 1\n53 1\n54 1\n55 1\n56 1\n57 1\n58 1\n59 1\n60 1\n61 1\n62 1\n63 1\n64 1\n65 1\n66 1\n67 1\n68 1\n69 1\n70 1\n71 1\n72 1\n73 1\n74 1\n75 1\n76 1\n77 1\n78 1\n79 1\n80 1\n81 1\n82 1\n83 1\n84 1\n85 1\n86 1\n...", "Possible\n2 1\n3 1\n4 1\n5 1\n6 1\n7 1\n8 1\n9 1\n10 1\n11 1\n12 1\n13 1\n14 1\n15 1\n16 1\n17 1\n18 1\n19 1\n20 1\n21 1\n22 1\n23 1\n24 1\n25 1\n26 1\n27 1\n28 1\n29 1\n30 1\n31 1\n32 1\n33 1\n34 1\n35 1\n36 1\n37 1\n38 1\n39 1\n40 1\n41 1\n42 1\n43 1\n44 1\n45 1\n46 1\n47 1\n48 1\n49 1\n50 1\n51 1\n52 1\n53 1\n54 1\n55 1\n56 1\n57 1\n58 1\n59 1\n60 1\n61 1\n62 1\n63 1\n64 1\n65 1\n66 1\n67 1\n68 1\n69 1\n70 1\n71 1\n72 1\n73 1\n74 1\n75 1\n76 1\n77 1\n78 1\n79 1\n80 1\n81 1\n82 1\n83 1\n84 1\n85 1\n86 1\n...", "Possible\n2 1\n3 1\n4 1\n5 1\n6 1\n7 1\n8 1\n9 1\n10 1\n11 1\n12 1\n13 1\n14 1\n15 1\n16 1\n17 1\n18 1\n19 1\n20 1\n21 1\n22 1\n23 1\n24 1\n25 1\n26 1\n27 1\n28 1\n29 1\n30 1\n31 1\n32 1\n33 1\n34 1\n35 1\n36 1\n37 1\n38 1\n39 1\n40 1\n41 1\n42 1\n43 1\n44 1\n45 1\n46 1\n47 1\n48 1\n49 1\n50 1\n51 1\n52 1\n53 1\n54 1\n55 1\n56 1\n57 1\n58 1\n59 1\n60 1\n61 1\n62 1\n63 1\n64 1\n65 1\n66 1\n67 1\n68 1\n69 1\n70 1\n71 1\n72 1\n73 1\n74 1\n75 1\n76 1\n77 1\n78 1\n79 1\n80 1\n81 1\n82 1\n83 1\n84 1\n85 1\n86 1\n...", "Possible\n2 1\n3 1\n4 1\n5 1\n6 1\n7 1\n8 1\n9 1\n10 1\n11 1\n12 1\n13 1\n14 1\n15 1\n16 1\n17 1\n18 1\n19 1\n20 1\n21 1\n22 1\n23 1\n24 1\n25 1\n26 1\n27 1\n28 1\n29 1\n30 1\n31 1\n32 1\n33 1\n34 1\n35 1\n36 1\n37 1\n38 1\n39 1\n40 1\n41 1\n42 1\n43 1\n44 1\n45 1\n46 1\n47 1\n48 1\n49 1\n50 1\n51 1\n52 1\n53 1\n54 1\n55 1\n56 1\n57 1\n58 1\n59 1\n60 1\n61 1\n62 1\n63 1\n64 1\n65 1\n66 1\n67 1\n68 1\n69 1\n70 1\n71 1\n72 1\n73 1\n74 1\n75 1\n76 1\n77 1\n78 1\n79 1\n80 1\n81 1\n82 1\n83 1\n84 1\n85 1\n86 1\n...", "Possible\n2 1\n3 1\n4 1\n5 1\n6 1\n7 1\n8 1\n9 1\n10 1\n11 1\n12 1\n13 1\n14 1\n15 1\n16 1\n17 1\n18 1\n19 1\n20 1\n21 1\n22 1\n23 1\n24 1\n25 1\n26 1\n27 1\n28 1\n29 1\n30 1\n31 1\n32 1\n33 1\n34 1\n35 1\n36 1\n37 1\n38 1\n39 1\n40 1\n41 1\n42 1\n43 1\n44 1\n45 1\n46 1\n47 1\n48 1\n49 1\n50 1\n51 1\n52 1\n53 1\n54 1\n55 1\n56 1\n57 1\n58 1\n59 1\n60 1\n61 1\n62 1\n63 1\n64 1\n65 1\n66 1\n67 1\n68 1\n69 1\n70 1\n71 1\n72 1\n73 1\n74 1\n75 1\n76 1\n77 1\n78 1\n79 1\n80 1\n81 1\n82 1\n83 1\n84 1\n85 1\n86 1\n...", "Impossible", "Possible\n2 1\n3 1\n4 1\n5 1\n6 1\n7 1\n8 1\n9 1\n10 1\n11 1\n12 1\n13 1\n14 1\n15 1\n16 1\n17 1\n18 1\n19 1\n20 1\n21 1\n22 1\n23 1\n24 1\n25 1\n26 1\n27 1\n28 1\n29 1\n30 1\n31 1\n32 1\n33 1\n34 1\n35 1\n36 1\n37 1\n38 1\n39 1\n40 1\n41 1\n42 1\n43 1\n44 1\n45 1\n46 1\n47 1\n48 1\n49 1\n50 1\n51 1\n52 1\n53 1\n54 1\n55 1\n56 1\n57 1\n58 1\n59 1\n60 1\n61 1\n62 1\n63 1\n64 1\n65 1\n66 1\n67 1\n68 1\n69 1\n70 1\n71 1\n72 1\n73 1\n74 1\n75 1\n76 1\n77 1\n78 1\n79 1\n80 1\n81 1\n82 1\n83 1\n84 1\n85 1\n86 1\n...", "Impossible", "Possible\n2 1\n3 1", "Impossible", "Impossible", "Impossible", "Impossible", "Impossible", "Possible\n2 1", "Impossible", "Impossible", "Impossible", "Impossible", "Impossible", "Possible\n2 1\n3 1", "Possible\n2 1\n3 1\n3 2", "Impossible", "Impossible", "Impossible", "Impossible", "Possible\n2 1\n3 1\n4 1", "Possible\n2 1\n3 1\n4 1\n3 2", "Possible\n2 1\n3 1\n4 1\n3 2\n4 3", "Impossible", "Impossible", "Impossible", "Possible\n2 1\n3 1\n4 1\n5 1", "Possible\n2 1\n3 1\n4 1\n5 1\n3 2"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 28 | codeforces |
|
fef0dc43ecff47f600561e8599217ddf | Bookshelves | Mr Keks is a typical white-collar in Byteland.
He has a bookshelf in his office with some books on it, each book has an integer positive price.
Mr Keks defines the value of a shelf as the sum of books prices on it.
Miraculously, Mr Keks was promoted and now he is moving into a new office.
He learned that in the new office he will have not a single bookshelf, but exactly $k$ bookshelves. He decided that the beauty of the $k$ shelves is the [bitwise AND](https://en.wikipedia.org/wiki/Bitwise_operation#AND) of the values of all the shelves.
He also decided that he won't spend time on reordering the books, so he will place several first books on the first shelf, several next books on the next shelf and so on. Of course, he will place at least one book on each shelf. This way he will put all his books on $k$ shelves in such a way that the beauty of the shelves is as large as possible. Compute this maximum possible beauty.
The first line contains two integers $n$ and $k$ ($1 \leq k \leq n \leq 50$) — the number of books and the number of shelves in the new office.
The second line contains $n$ integers $a_1, a_2, \ldots a_n$, ($0 < a_i < 2^{50}$) — the prices of the books in the order they stand on the old shelf.
Print the maximum possible beauty of $k$ shelves in the new office.
Sample Input
10 4
9 14 28 1 7 13 15 29 2 31
7 3
3 14 15 92 65 35 89
Sample Output
24
64
| {"inputs": ["10 4\n9 14 28 1 7 13 15 29 2 31", "7 3\n3 14 15 92 65 35 89", "40 5\n6 18 24 5 14 16 31 9 15 5 25 2 18 12 19 27 10 23 23 18 22 14 1 14 6 14 17 28 11 21 8 23 10 30 21 5 17 11 26 16", "20 15\n927353279298143 655102800384382 40376603048780 1008958973042960 1123049780860278 853122601026128 154596679092462 200013924385343 591199113039915 140875624438732 924096460433635 609326666846280 639191601375336 868486002971126 338452290857190 947205016908287 1091731324024232 315465850740682 804685495436596 1102057294815123", "10 4\n318346909478488 165408439052762 201407789817026 481299976321209 960738945073700 249445428976993 1096588610084096 605348669136305 817617728356976 256799633127974", "50 15\n10 30 15 11 9 5 7 16 4 3 29 28 14 20 9 10 21 16 1 7 30 19 16 25 12 29 12 5 3 23 27 16 11 25 21 18 22 12 23 16 24 27 19 7 11 12 30 1 24 11", "20 8\n29 25 19 16 26 18 25 9 5 2 17 16 19 16 3 16 4 17 7 20", "30 4\n893642632982367 772277951746295 510759449350295 826812150840579 1060893142351815 525992742241552 154832018679993 645715002371268 27232975419720 475004229372388 200177708355593 810661468479466 49618609534806 301608930846726 97042172725806 441637617418914 594900693592862 626510702147446 653604971179679 51832188158797 771139366286148 604472775724297 543106972286801 854107321252442 958411818162963 419377189839607 595529582510881 663396887427244 543023709380824 1078875721144944", "40 5\n22 16 24 23 3 18 20 12 25 26 29 4 10 31 31 30 2 7 11 16 24 8 2 24 19 17 5 17 20 7 15 26 1 16 26 21 27 4 19 25", "20 9\n162679258761381 497029570950369 441562370676165 658883349839306 803660720071652 397337645985983 1098171846564844 578539182000384 612361670323974 773464823371908 133451479483291 1053028311550002 812258927376098 1012522114357354 692621870999109 73882870347249 783703450776904 897456103589081 217535031946368 318888756116976", "50 12\n22 12 31 3 3 12 19 19 21 15 24 25 31 18 9 3 8 5 3 24 6 26 30 25 14 25 9 25 3 29 9 6 11 3 12 12 15 6 1 28 28 28 26 9 15 12 17 2 18 18", "16 7\n1103813397013349 727264530801741 378049079598082 630901233315595 518569339136212 532452143552615 428093804691193 371529237344587 940308912730366 704551472087683 631663816743474 29306660032804 583388823624504 1109142272484691 257363549141980 1089402363164001", "30 2\n26 8 26 25 27 18 6 13 10 22 25 19 7 14 20 4 10 22 9 10 30 30 11 7 27 8 23 13 17 21", "10 3\n30 15 26 16 21 13 25 5 27 11", "10 6\n977831009728918 953593140925615 784863715891337 774777129376154 384491823368699 788094311512692 223966626677969 1066171741163060 119044778274639 876388748099519", "20 9\n2 3 15 8 17 7 23 12 30 23 4 23 16 21 11 6 7 16 3 3", "20 8\n483137921056907 768218083275243 207834138817392 354531452905166 963403044757413 833232873786483 582872528360258 514660235281883 1011861985723061 459485641216220 942598735621775 873490204734628 649359794076787 543622431653711 10411517577635 91729283882125 291509560140622 287260200844128 879410314598283 206118644453476", "30 9\n21 6 19 18 27 3 14 18 1 5 7 9 11 13 9 26 8 12 14 31 21 6 9 3 3 10 2 24 22 24", "30 22\n73306162994949 868677001959133 1106639997936963 879122920975808 161227935543926 760034092541884 1120594333824270 1054807665792407 476276883119188 271363692993319 440885048025850 7074457876332 636209225974410 221086579024023 1009685779703594 647498280909980 816934931718733 452863796888983 1061332951888385 942660914590384 365185997676754 112920162715865 178172288962138 810584030647354 923637556325003 1102808429103893 1118229467600088 1074261154123678 839042706865637 352292698714231", "23 10\n935459645688325 899894863244863 776172843769766 986122540485649 248016433194357 475375806620409 20513751182830 421086691387167 247543829168446 155673663632778 415875856906302 128486751653325 849753391760463 1083573552851049 244133940871958 934119204927643 1085966359617308 577156229051957 1081049229814148 935408354841926 1093470105244215 288440615891778 467185550898222", "40 5\n2 20 10 21 4 30 27 12 17 20 5 21 11 12 28 12 24 20 20 31 19 2 1 27 31 1 14 8 1 21 10 2 29 22 29 9 12 29 21 7", "10 4\n22 21 18 7 16 14 12 11 18 5", "50 24\n19 14 27 12 29 18 26 24 16 23 23 22 3 28 18 11 27 14 24 19 25 23 14 7 25 31 20 7 23 10 21 9 30 3 25 17 11 16 27 28 3 25 8 19 17 27 21 19 26 31", "10 4\n23 12 4 5 7 10 22 18 1 6", "4 2\n158042378809438 929800196167200 663932725437382 1056705514263205", "20 8\n8 29 23 29 3 24 21 4 2 8 12 17 22 8 14 15 21 18 2 22", "1 1\n1", "50 50\n1 3 7 15 31 63 127 255 511 1023 2047 4095 8191 16383 32767 65535 131071 262143 524287 1048575 2097151 4194303 8388607 16777215 33554431 67108863 134217727 268435455 536870911 1073741823 2147483647 4294967295 8589934591 17179869183 34359738367 68719476735 137438953471 274877906943 549755813887 1099511627775 2199023255551 4398046511103 8796093022207 17592186044415 35184372088831 70368744177663 140737488355327 281474976710655 562949953421311 1125899906842623", "1 1\n847523811295364", "16 4\n874317845770206 387621540079007 155991277344382 691438508026243 930771471405935 572771476513435 743983828305226 4504492981600 163201683368400 839227763533133 66330553316499 1019586586453035 361344913793137 983404846165187 1054785536664003 328380935299964", "8 3\n1091780344011621 940196424994342 1122602056403610 446348279968546 844618893669060 630726534256806 583591612685392 410152590972252", "4 2\n162835105872970 116592879151848 139965176195127 395498533500931", "2 1\n209353646212060 198207100745412", "16 14\n104025519164115 388661629481441 867118235830760 833392737978583 446248951095413 1075527144295046 1065273356416483 60098918081731 29503418096534 995667681082455 1087347063175248 131807733936246 235096689659338 202086293947852 889771265698655 384926479287439", "8 5\n173728498114277 92445238671418 136142198208213 974561146026363 1099401507969061 180377338638143 458779251007513 55384960555288", "4 3\n266761283825161 255669386891250 772637301427796 659604966525743", "8 1\n562949953421312 562949953421312 562949953421312 562949953421312 562949953421312 562949953421312 562949953421312 562949953421312", "16 1\n562949953421312 562949953421312 562949953421312 562949953421312 562949953421312 562949953421312 562949953421312 562949953421312 562949953421312 562949953421312 562949953421312 562949953421312 562949953421312 562949953421312 562949953421312 562949953421312", "17 1\n1125899906842623 1125899906842623 1125899906842623 1125899906842623 1125899906842623 1125899906842623 1125899906842623 1125899906842623 1125899906842623 1125899906842623 1125899906842623 1125899906842623 1125899906842623 1125899906842623 1125899906842623 1125899906842623 16"], "outputs": ["24", "64", "80", "16777216", "563104572248080", "32", "16", "3940649673949202", "106", "571746046443520", "36", "572020924350465", "125", "33", "562949953683460", "16", "562951027164160", "36", "2097152", "562950087639040", "80", "16", "16", "4", "594152991508074", "16", "1", "1", "847523811295364", "1214153029059594", "633396032195072", "392680337115137", "407560746957472", "0", "140737555464192", "19928690198528", "4503599627370496", "9007199254740992", "18014398509481984"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 12 | codeforces |
|
fefe761d353a35a1825f8de3622e0e44 | Phone numbers | Phone number in Berland is a sequence of *n* digits. Often, to make it easier to memorize the number, it is divided into groups of two or three digits. For example, the phone number 1198733 is easier to remember as 11-987-33. Your task is to find for a given phone number any of its divisions into groups of two or three digits.
The first line contains integer *n* (2<=≤<=*n*<=≤<=100) — amount of digits in the phone number. The second line contains *n* digits — the phone number to divide into groups.
Output any of divisions of the given phone number into groups of two or three digits. Separate groups by single character -. If the answer is not unique, output any.
Sample Input
6
549871
7
1198733
Sample Output
54-98-7111-987-33
| {"inputs": ["6\n549871", "7\n1198733", "2\n74", "2\n33", "3\n074", "3\n081", "4\n3811", "5\n21583", "8\n33408349", "9\n988808426", "10\n0180990956", "15\n433488906230138", "22\n7135498415686025907059", "49\n2429965524999668169991253653390090510755018570235", "72\n491925337784111770500147619881727525570039735507439360627744863794794290", "95\n32543414456047900690980198395035321172843693417425457554204776648220562494524275489599199209210", "97\n9362344595153688016434451101547661156123505108492010669557671355055642365998461003851354321478898", "98\n65521815795893886057122984634320900545031770769333931308009346017867969790810907868670369236928568", "99\n455213856470326729480192345541970106407563996625458559297407682539801838244443866898560852503660390", "100\n4004223124942730640235383244438257614581534320356060987241659784249551110165034719443327659510644224"], "outputs": ["54-98-71", "119-87-33", "74", "33", "074", "081", "38-11", "215-83", "33-40-83-49", "988-80-84-26", "01-80-99-09-56", "433-48-89-06-23-01-38", "71-35-49-84-15-68-60-25-90-70-59", "242-99-65-52-49-99-66-81-69-99-12-53-65-33-90-09-05-10-75-50-18-57-02-35", "49-19-25-33-77-84-11-17-70-50-01-47-61-98-81-72-75-25-57-00-39-73-55-07-43-93-60-62-77-44-86-37-94-79-42-90", "325-43-41-44-56-04-79-00-69-09-80-19-83-95-03-53-21-17-28-43-69-34-17-42-54-57-55-42-04-77-66-48-22-05-62-49-45-24-27-54-89-59-91-99-20-92-10", "936-23-44-59-51-53-68-80-16-43-44-51-10-15-47-66-11-56-12-35-05-10-84-92-01-06-69-55-76-71-35-50-55-64-23-65-99-84-61-00-38-51-35-43-21-47-88-98", "65-52-18-15-79-58-93-88-60-57-12-29-84-63-43-20-90-05-45-03-17-70-76-93-33-93-13-08-00-93-46-01-78-67-96-97-90-81-09-07-86-86-70-36-92-36-92-85-68", "455-21-38-56-47-03-26-72-94-80-19-23-45-54-19-70-10-64-07-56-39-96-62-54-58-55-92-97-40-76-82-53-98-01-83-82-44-44-38-66-89-85-60-85-25-03-66-03-90", "40-04-22-31-24-94-27-30-64-02-35-38-32-44-43-82-57-61-45-81-53-43-20-35-60-60-98-72-41-65-97-84-24-95-51-11-01-65-03-47-19-44-33-27-65-95-10-64-42-24"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 157 | codeforces |
|
ff10d04958977d2d3ed41f2c817605a8 | String Compression | Ivan wants to write a letter to his friend. The letter is a string *s* consisting of lowercase Latin letters.
Unfortunately, when Ivan started writing the letter, he realised that it is very long and writing the whole letter may take extremely long time. So he wants to write the compressed version of string *s* instead of the string itself.
The compressed version of string *s* is a sequence of strings *c*1,<=*s*1,<=*c*2,<=*s*2,<=...,<=*c**k*,<=*s**k*, where *c**i* is the decimal representation of number *a**i* (without any leading zeroes) and *s**i* is some string consisting of lowercase Latin letters. If Ivan writes string *s*1 exactly *a*1 times, then string *s*2 exactly *a*2 times, and so on, the result will be string *s*.
The length of a compressed version is |*c*1|<=+<=|*s*1|<=+<=|*c*2|<=+<=|*s*2|... |*c**k*|<=+<=|*s**k*|. Among all compressed versions Ivan wants to choose a version such that its length is minimum possible. Help Ivan to determine minimum possible length.
The only line of input contains one string *s* consisting of lowercase Latin letters (1<=≤<=|*s*|<=≤<=8000).
Output one integer number — the minimum possible length of a compressed version of *s*.
Sample Input
aaaaaaaaaa
abcab
cczabababab
Sample Output
3
6
7
| {"inputs": ["aaaaaaaaaa", "abcab", "cczabababab", "kbyjorwqjk", "baaabbbaba", "aaaaaaaaaa", "cbbbcccbbc", "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "hltcdvuobkormkxkbmpfjniilublkrckmvvxemcyietgxcyjgrjwsdsgsfmoqnmbxozfavxopklhldhnsjpxhejxaxuctxeifglx", "agdmdjkbfnleldamiiedfheefgaimecnllgkjdkdcfejainklmhaklcjkgkimgfiiajiiihhdngjedgmefnjmbglghjjejfjkaha", "aaaaaaabaaaabbbbaaaaaaabbaaaaaaaaaabbabaaaaaabaaaaabaaaaaaaabaaaaaaaaaaaaaaaabaaaaaabaaaaaaaaabbaaabaaaaabbaaabaaaaabaaabaaaaaabaaaaaaaaaaabaabaaabaaaaabbbbaaaaaaaaaaaaaaabaaaaaaaaababaaabaaaaaaaaaabaaaaaaaabaaaabbbbaaaaaaabbaaaaaaaaaabbabaaaaaabaaaaabaaaaaaaabaaaaaaaaaaaaaaaabaaaaaabaaaaaaaaabbaaabaaaaabbaaabaaaaabaaabaaaaaabaaaaaaaaaaabaabaaabaaaaabbbbaaaaaaaaaaaaaaabaaaaaaaaababaaabaaaaaaaaaaba", "mulzibhhlxawrjqunzww"], "outputs": ["3", "6", "7", "11", "9", "3", "10", "4", "101", "101", "191", "21"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 3 | codeforces |
|
ff140e99d830432ae85962a533046d13 | Feed the cat | After waking up at *hh*:*mm*, Andrew realised that he had forgotten to feed his only cat for yet another time (guess why there's only one cat). The cat's current hunger level is *H* points, moreover each minute without food increases his hunger by *D* points.
At any time Andrew can visit the store where tasty buns are sold (you can assume that is doesn't take time to get to the store and back). One such bun costs *C* roubles and decreases hunger by *N* points. Since the demand for bakery drops heavily in the evening, there is a special 20% discount for buns starting from 20:00 (note that the cost might become rational). Of course, buns cannot be sold by parts.
Determine the minimum amount of money Andrew has to spend in order to feed his cat. The cat is considered fed if its hunger level is less than or equal to zero.
The first line contains two integers *hh* and *mm* (00<=≤<=*hh*<=≤<=23,<=00<=≤<=*mm*<=≤<=59) — the time of Andrew's awakening.
The second line contains four integers *H*, *D*, *C* and *N* (1<=≤<=*H*<=≤<=105,<=1<=≤<=*D*,<=*C*,<=*N*<=≤<=102).
Output the minimum amount of money to within three decimal digits. You answer is considered correct, if its absolute or relative error does not exceed 10<=-<=4.
Formally, let your answer be *a*, and the jury's answer be *b*. Your answer is considered correct if .
Sample Input
19 00
255 1 100 1
17 41
1000 6 15 11
Sample Output
25200.0000
1365.0000
| {"inputs": ["19 00\n255 1 100 1", "17 41\n1000 6 15 11", "16 34\n61066 14 50 59", "18 18\n23331 86 87 41", "10 48\n68438 8 18 29", "08 05\n63677 9 83 25", "00 00\n100000 100 100 100", "20 55\n100000 100 100 100", "23 59\n100000 100 100 100", "00 00\n1 100 100 100", "21 26\n33193 54 97 66", "20 45\n33756 24 21 1", "14 33\n92062 59 89 72", "01 24\n92730 5 35 29", "20 58\n93398 43 86 99", "23 04\n37170 81 32 64", "01 38\n70542 27 74 26", "04 28\n38505 65 25 95", "00 10\n33077 21 40 22", "10 44\n66449 67 90 83", "05 51\n10220 5 33 48", "20 19\n68886 28 48 94", "01 49\n11621 55 78 46", "21 28\n78549 91 4 98", "18 06\n88580 22 35 59", "22 28\n55507 53 61 11", "18 58\n22434 84 91 59", "15 36\n32466 27 22 15", "17 31\n9603 53 73 74", "14 53\n76530 92 4 22", "18 31\n10753 23 30 74", "17 43\n16290 46 90 94", "18 38\n3652 11 53 94", "19 57\n3 4 7 6"], "outputs": ["25200.0000", "1365.0000", "43360.0000", "49590.0000", "36187.2000", "186252.0000", "100000.0000", "80000.0000", "80000.0000", "100.0000", "39032.8000", "567100.8000", "110146.4000", "94920.0000", "64947.2000", "14873.6000", "200836.0000", "10150.0000", "60160.0000", "72090.0000", "7029.0000", "28147.2000", "19734.0000", "2566.4000", "43232.0000", "246293.6000", "34143.2000", "46464.0000", "9490.0000", "13916.0000", "4152.0000", "15660.0000", "2067.0000", "7.0000"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 144 | codeforces |
|
ff421c3540ee1df661234b450f1c7093 | Chip Play | Let's consider the following game. We have a rectangular field *n*<=×<=*m* in size. Some squares of the field contain chips.
Each chip has an arrow painted on it. Thus, each chip on the field points in one of the following directions: up, down, left or right.
The player may choose a chip and make a move with it.
The move is the following sequence of actions. The chosen chip is marked as the current one. After that the player checks whether there are more chips in the same row (or in the same column) with the current one that are pointed by the arrow on the current chip. If there is at least one chip then the closest of them is marked as the new current chip and the former current chip is removed from the field. After that the check is repeated. This process can be repeated several times. If a new chip is not found, then the current chip is removed from the field and the player's move ends.
By the end of a move the player receives several points equal to the number of the deleted chips.
By the given initial chip arrangement determine the maximum number of points that a player can receive during one move. Also determine the number of such moves.
The first line contains two integers *n* and *m* (1<=≤<=*n*,<=*m*,<=*n*<=×<=*m*<=≤<=5000). Then follow *n* lines containing *m* characters each — that is the game field description. "." means that this square is empty. "L", "R", "U", "D" mean that this square contains a chip and an arrow on it says left, right, up or down correspondingly.
It is guaranteed that a field has at least one chip.
Print two numbers — the maximal number of points a player can get after a move and the number of moves that allow receiving this maximum number of points.
Sample Input
4 4
DRLD
U.UL
.UUR
RDDL
3 5
.D...
RRRLL
.U...
Sample Output
10 16 2 | {"inputs": ["4 4\nDRLD\nU.UL\n.UUR\nRDDL", "2 2\nRD\nUL", "5 5\nUD..L\nRRD..\n..RDD\nUUL..\nDDLRR", "10 10\n.L.....R..\n.........U\n..D....D..\n.R......L.\n....L.....\n.........D\n......U...\nD....R....\n...U......\n........L.", "17 13\n...LD.UR.RUU.\nLDLULDUDRRDRL\nDD.RRLRUR.UD.\nRU...D...LD..\n.UR.R...URUUD\n.RURD.RLR.D.R\n.UUU.RU...UR.\nUUUU.R.......\nRL.LRU.UD.DUD\nLD.DRURRLRDRL\n.DR..UULUDDR.\nLRLURRUUDDLUR\n.LRDDLLR.L.DU\nDRUDLLD.LRRU.\n..DL.UDL.DUL.\nU.DL..D..U.RD\nRR.R...RL.L..", "11 29\nURRUUDDLURLRDDLLRLDUDR.UDLLD.\nLRRUDLUDLDULUDL.DURDRR.RRLLRR\nD.DUDDURLRDDULDUDDUDDURRDLD.L\n.RULURURRDLRRRLUUUU.RDLDLRRRL\n.RLDDU.UUULUURURRLLUU.RLDRDUD\nLRL.URRRDDURUURUDRRDLDDULRDRL\nRLULDU.LRDUDRLDLRDDDDRUUDRDLL\nDLUDURRDDUDLLDLLUURLDRUURRLUL\nL.RRURRDDRRURRRDDUDRRDULR.LUR\nLDLRULURRUULRDUUULLU.LLU.LLLL\nDUURDULDDUDLRUUDRUULURLD.RL.U", "1 1\nU", "1 10\nLLLLLRRRRR", "3 3\n...\n...\n..R", "5 5\nDD..D\n.....\nLU...\nU...U\n.UL.U"], "outputs": ["10 1", "4 4", "8 3", "2 2", "24 2", "94 1", "1 1", "5 2", "1 1", "4 1"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1 | codeforces |
|
ff63427e0a246e9a8c857186864b88ce | k-String | A string is called a *k*-string if it can be represented as *k* concatenated copies of some string. For example, the string "aabaabaabaab" is at the same time a 1-string, a 2-string and a 4-string, but it is not a 3-string, a 5-string, or a 6-string and so on. Obviously any string is a 1-string.
You are given a string *s*, consisting of lowercase English letters and a positive integer *k*. Your task is to reorder the letters in the string *s* in such a way that the resulting string is a *k*-string.
The first input line contains integer *k* (1<=≤<=*k*<=≤<=1000). The second line contains *s*, all characters in *s* are lowercase English letters. The string length *s* satisfies the inequality 1<=≤<=|*s*|<=≤<=1000, where |*s*| is the length of string *s*.
Rearrange the letters in string *s* in such a way that the result is a *k*-string. Print the result on a single output line. If there are multiple solutions, print any of them.
If the solution doesn't exist, print "-1" (without quotes).
Sample Input
2
aazz
3
abcabcabz
Sample Output
azaz
-1
| {"inputs": ["2\naazz", "3\nabcabcabz", "1\na", "2\nabba", "2\naaab", "7\nabacaba", "5\naaaaa", "3\naabaaaaabb", "2\naaab", "2\nbabac", "3\nbbbccc", "2\naa", "250\ncececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececece", "15\nabaabbbcababaaaabaabbbcababaaaabaabbbcababaaaabaabbbcababaaaabaabbbcababaaaabaabbbcababaaaabaabbbcababaaaabaabbbcababaaaabaabbbcababaaaabaabbbcababaaaabaabbbcababaaaabaabbbcababaaaabaabbbcababaaaabaabbbcababaaaabaabbbcababaaa", "1\naaa", "1\naabaab", "2\naabbbbccccccdddddddd", "3\naaaaaaaaacccdddddd", "3\naaaaaaaaacccbbbbbb", "2\naazzzz", "2\naaaa", "2\naaaazz", "2\naaaabb", "2\naabbbb", "2\naaaazzzz", "2\naaazz", "2\nbbbbaa", "2\naaaaaabbbb", "2\naaaaaazz", "2\naaaabbbb", "2\naabaab", "1\naaaaa", "2\nbbaaaa", "2\nacaccc"], "outputs": ["azaz", "-1", "a", "abab", "-1", "-1", "aaaaa", "-1", "-1", "-1", "bcbcbc", "aa", "cececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececece", "aaaaaaaabbbbbbcaaaaaaaabbbbbbcaaaaaaaabbbbbbcaaaaaaaabbbbbbcaaaaaaaabbbbbbcaaaaaaaabbbbbbcaaaaaaaabbbbbbcaaaaaaaabbbbbbcaaaaaaaabbbbbbcaaaaaaaabbbbbbcaaaaaaaabbbbbbcaaaaaaaabbbbbbcaaaaaaaabbbbbbcaaaaaaaabbbbbbcaaaaaaaabbbbbbc", "aaa", "aaaabb", "abbcccddddabbcccdddd", "aaacddaaacddaaacdd", "aaabbcaaabbcaaabbc", "azzazz", "aaaa", "aazaaz", "aabaab", "abbabb", "aazzaazz", "-1", "abbabb", "aaabbaaabb", "aaazaaaz", "aabbaabb", "aabaab", "aaaaa", "aabaab", "accacc"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 324 | codeforces |
|
ff80a5b10d8a65e60f520fb16ca6252b | none | Fox Ciel is participating in a party in Prime Kingdom. There are *n* foxes there (include Fox Ciel). The i-th fox is *a**i* years old.
They will have dinner around some round tables. You want to distribute foxes such that:
1. Each fox is sitting at some table. 1. Each table has at least 3 foxes sitting around it. 1. The sum of ages of any two adjacent foxes around each table should be a prime number.
If *k* foxes *f*1, *f*2, ..., *f**k* are sitting around table in clockwise order, then for 1<=≤<=*i*<=≤<=*k*<=-<=1: *f**i* and *f**i*<=+<=1 are adjacent, and *f*1 and *f**k* are also adjacent.
If it is possible to distribute the foxes in the desired manner, find out a way to do that.
The first line contains single integer *n* (3<=≤<=*n*<=≤<=200): the number of foxes in this party.
The second line contains *n* integers *a**i* (2<=≤<=*a**i*<=≤<=104).
If it is impossible to do this, output "Impossible".
Otherwise, in the first line output an integer *m* (): the number of tables.
Then output *m* lines, each line should start with an integer *k* -=– the number of foxes around that table, and then *k* numbers — indices of fox sitting around that table in clockwise order.
If there are several possible arrangements, output any of them.
Sample Input
4
3 4 8 9
5
2 2 2 2 2
12
2 3 4 5 6 7 8 9 10 11 12 13
24
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
Sample Output
1
4 1 2 4 3
Impossible
1
12 1 2 3 6 5 12 9 8 7 10 11 4
3
6 1 2 3 6 5 4
10 7 8 9 12 15 14 13 16 11 10
8 17 18 23 22 19 20 21 24
| {"inputs": ["4\n3 4 8 9", "5\n2 2 2 2 2", "12\n2 3 4 5 6 7 8 9 10 11 12 13", "24\n2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25", "4\n2 2 9973 9967", "30\n2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31", "20\n76 38 74 176 106 134 12 88 66 178 63 105 199 99 29 67 135 29 101 47", "20\n12 4 12 12 2 10 4 12 18 14 21 21 15 7 17 11 5 11 3 13", "152\n29 23 17 25 13 29 29 29 25 23 25 29 19 25 13 25 13 23 21 27 15 29 29 25 27 17 17 19 25 19 13 19 15 13 19 13 17 17 19 17 17 13 25 21 17 13 21 17 25 21 19 23 17 17 29 15 15 17 25 13 25 13 21 13 19 19 13 13 21 25 23 19 19 21 29 29 26 30 22 20 22 28 24 28 18 16 22 18 16 20 12 26 16 20 12 24 20 28 16 16 16 16 12 20 22 12 20 12 22 18 22 12 22 22 24 22 30 28 20 24 30 14 18 12 16 14 18 18 16 22 16 20 20 20 28 30 20 24 12 24 24 28 22 30 24 18 12 20 22 24 12 12", "92\n5 5 3 5 3 3 5 3 5 3 5 5 5 3 3 5 3 5 3 5 3 5 3 5 3 3 3 5 3 5 5 5 5 5 5 3 5 3 3 5 3 5 5 3 3 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4", "15\n3 3 3 3 3 3 3 4 2 4 2 2 2 4 2", "88\n29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 28 28 30 30 28 28 30 28 28 28 30 30 30 30 28 30 30 28 28 28 30 28 30 30 30 30 28 30 30 30 28 30 28 28 28 30 30 30 30 28 30 28 30 28", "52\n11 33 37 51 27 59 57 55 73 67 13 47 45 39 27 21 23 61 37 35 39 63 69 53 61 55 44 34 64 30 54 48 32 66 32 62 50 44 38 24 22 30 14 54 12 28 40 40 50 54 64 56", "102\n87 73 87 81 71 83 71 91 75 87 87 79 77 85 83 71 91 83 85 81 79 81 81 91 91 87 79 81 91 81 77 87 71 87 91 89 89 77 87 91 87 75 83 87 75 73 83 81 79 77 91 76 76 88 82 88 78 86 72 84 86 72 74 74 88 84 86 80 84 90 80 88 84 82 80 84 74 72 86 86 76 82 80 86 74 84 88 74 82 90 72 86 72 80 80 82 86 88 82 78 72 88", "10\n119 289 109 185 251 184 224 588 360 518", "76\n7 7 9 9 9 11 9 11 7 7 9 7 9 9 9 7 11 11 7 11 7 11 7 7 9 11 7 7 7 7 11 7 9 11 11 9 9 11 8 10 8 8 8 10 10 10 10 8 8 8 8 10 10 10 8 8 8 10 8 8 8 8 8 8 10 8 8 10 10 10 10 10 8 10 10 10", "12\n1751 1909 1655 1583 1867 1841 1740 1584 1518 1806 1664 1518", "146\n3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 2 4 2 4 2 4 2 4 2 2 2 4 2 4 2 4 4 2 4 4 2 2 4 2 2 2 4 4 2 2 2 2 2 2 2 4 4 4 4 4 2 2 4 2 2 2 2 4 4 2 4 4 2 2 2 2 2 2 4 4 4 4 4 4 2 2 2 2 2 2 4 4 4", "78\n159 575 713 275 463 365 461 537 301 439 669 165 555 267 571 383 495 375 321 605 367 481 619 675 115 193 447 303 263 421 189 491 591 673 635 309 301 391 379 736 652 704 634 258 708 206 476 408 702 630 650 236 546 328 348 86 96 628 668 426 640 170 434 486 168 640 260 426 186 272 650 616 252 372 442 178 266 464", "10\n5 5 7 7 5 6 6 6 6 6", "148\n73 53 49 49 65 69 61 67 57 55 53 57 57 59 69 59 71 55 71 49 51 67 57 73 71 55 59 59 61 55 73 69 63 55 59 51 69 73 67 55 61 53 49 69 53 63 71 71 65 63 61 63 65 69 61 63 63 71 71 65 57 63 61 69 49 53 59 51 73 61 55 73 63 65 70 68 68 66 64 56 68 50 68 56 68 70 68 54 70 60 62 68 64 56 52 66 66 64 72 58 70 58 52 50 56 50 56 50 50 72 70 64 50 62 58 70 72 62 62 72 64 52 50 54 56 54 72 64 62 62 72 70 66 70 62 64 50 72 62 58 58 58 56 72 58 52 60 72", "80\n5599 5365 6251 3777 6887 5077 4987 6925 3663 5457 5063 4077 3531 6359 4293 6305 4585 3641 6737 6403 6863 4839 3765 3767 5807 6657 7275 5625 3635 3939 7035 6945 7167 5023 5949 4295 4899 4595 5725 3863 3750 4020 5096 5232 6566 6194 5524 3702 6876 4464 3720 5782 5160 3712 7028 6204 5378 5896 5494 7084 5290 6784 6408 5410 4260 5082 4210 5336 4110 5064 3664 4964 5202 5410 5634 3990 5034 6774 4956 4806", "16\n5 7 7 7 11 11 9 5 4 6 6 10 6 4 10 6", "74\n3 3 5 3 5 5 3 5 3 3 5 5 3 5 3 3 3 3 3 3 3 5 5 3 5 3 5 3 3 5 5 5 5 3 3 5 3 4 6 6 6 6 4 4 4 6 6 6 6 4 6 4 4 6 6 4 6 4 4 6 6 4 4 4 6 4 4 4 4 6 4 4 4 4", "70\n763 657 799 713 667 531 829 675 799 721 741 549 793 553 723 579 853 713 835 833 581 801 683 551 617 733 611 699 607 565 579 693 897 543 607 848 774 602 544 846 710 722 568 740 548 702 908 572 572 806 834 794 648 770 908 778 748 692 704 624 580 746 780 666 678 822 834 640 548 788", "98\n5 5 3 3 3 3 3 5 3 5 3 5 3 3 5 5 5 5 3 5 5 3 3 5 3 3 5 3 3 3 5 5 3 5 3 3 3 5 5 5 3 5 5 5 3 5 5 3 3 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4", "30\n25 43 41 17 15 29 29 39 17 19 23 9 39 19 25 26 32 38 12 42 44 44 12 22 26 20 34 12 30 16", "90\n11 9 11 9 9 11 9 9 11 9 11 9 11 11 9 11 11 11 11 9 9 11 11 11 9 9 9 11 11 9 11 11 9 11 9 9 11 11 11 11 9 11 11 11 11 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10", "6\n681 673 659 656 650 644", "38\n5 7 7 5 7 7 7 5 7 5 7 5 7 5 7 7 5 7 7 4 6 4 8 4 4 8 4 8 4 6 6 8 6 8 6 4 8 6", "81\n7627 7425 8929 7617 5649 7853 4747 6267 4997 6447 5411 7707 5169 5789 8011 9129 8045 7463 6139 8263 7547 7453 7993 8343 5611 7039 9001 5569 9189 7957 5537 8757 8795 4963 9149 5845 9203 5459 8501 7273 9152 7472 8050 8568 6730 8638 4938 9000 9230 5464 5950 6090 7394 5916 4890 6246 4816 4920 8638 4706 6308 6816 7570 8940 5060 7368 5252 6526 9072 5168 7420 5336 4734 8076 7048 8504 5696 9266 8966 7416 5162", "98\n575 581 569 571 571 583 573 581 569 589 579 575 575 577 585 569 569 571 581 577 583 573 575 589 585 569 579 585 585 579 579 577 575 575 577 585 583 569 571 589 571 583 569 587 575 585 585 583 581 572 568 568 576 580 582 570 576 580 582 588 572 584 576 580 576 582 568 574 588 580 572 586 568 574 578 568 568 584 576 588 588 574 578 586 588 570 568 568 568 580 586 576 574 586 582 584 570 572", "124\n135 161 147 135 137 153 145 159 147 129 131 157 163 161 127 129 141 133 133 151 147 169 159 137 137 153 165 137 139 151 149 161 157 149 147 139 145 129 159 155 133 129 139 151 155 145 135 155 135 137 157 141 169 151 163 151 159 129 171 169 129 159 154 142 158 152 172 142 172 164 142 158 156 128 144 128 140 160 154 144 126 140 166 134 146 148 130 166 160 168 172 138 148 126 138 144 156 130 172 130 164 136 130 132 142 126 138 164 158 154 166 160 164 168 128 160 162 168 158 172 150 130 132 172", "60\n9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 8 10 10 10 10 8 10 10 8 10 8 8 10 8 8 10 10 10 8 8 8 8 10 8 10 8 8 8 8 10", "62\n37 45 41 45 49 37 47 41 39 43 43 39 45 41 43 47 37 41 47 37 47 49 43 39 37 45 45 47 37 47 43 34 42 36 48 36 44 48 44 46 48 44 44 48 36 42 40 38 36 48 48 38 46 48 34 34 46 42 34 36 34 36", "128\n3 3 5 3 5 3 5 3 5 5 3 5 3 5 3 5 3 5 5 5 5 5 5 5 5 3 3 3 5 3 5 3 3 3 3 5 3 5 5 3 3 3 3 5 5 5 5 3 5 3 3 5 5 3 5 3 3 5 3 3 5 3 3 3 6 6 6 4 4 4 4 4 6 6 6 6 6 6 4 6 6 4 6 6 4 4 4 6 4 6 6 4 6 4 4 6 4 4 6 4 6 4 6 6 6 6 6 6 4 6 4 6 6 4 4 6 4 6 6 4 6 4 6 4 6 6 4 6", "60\n633 713 645 745 641 685 731 645 655 633 703 715 633 739 657 755 657 671 567 699 743 737 667 701 649 721 671 699 697 675 570 570 570 648 684 732 598 558 674 766 720 692 702 756 756 646 568 630 668 742 604 628 628 764 636 600 678 734 638 758", "178\n5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6"], "outputs": ["1\n4 1 2 4 3", "Impossible", "1\n12 1 2 3 6 5 12 9 8 7 10 11 4", "3\n6 1 2 3 6 5 4\n10 7 8 9 12 15 14 13 16 11 10\n8 17 18 23 22 19 20 21 24", "Impossible", "3\n16 1 2 3 26 19 22 23 28 29 30 27 24 21 20 25 4\n6 5 6 9 8 7 10\n8 11 16 13 14 15 12 17 18", "Impossible", "3\n6 1 14 3 16 4 15\n10 2 13 10 17 8 18 9 20 7 19\n4 5 11 6 12", "17\n30 1 126 45 122 41 120 42 121 46 123 51 124 48 77 58 134 63 137 69 143 66 142 65 141 64 140 62 138 60 136\n40 2 80 3 92 74 149 73 81 4 82 5 84 9 86 11 87 13 91 14 89 15 88 18 90 10 85 12 83 8 78 7 150 6 147 72 79 70 146 71 148\n12 16 93 17 98 21 99 24 103 23 96 22 95\n4 19 94 20 97\n4 25 100 31 101\n4 26 104 27 107\n4 28 105 29 106\n18 30 108 37 112 38 117 40 115 39 118 43 114 35 113 33 111 32 109\n4 34 102 36 110\n4 44 116 47 119\n4 49 125 50 129\n4 52 127 55 128\n4 53 132 54 133\n4 56 130 57 131\n4 5...", "Impossible", "Impossible", "Impossible", "4\n10 1 33 4 52 2 28 22 51 21 49\n10 3 29 10 30 6 32 8 31 9 34\n28 5 35 7 37 14 38 15 43 17 27 24 50 26 46 18 45 20 44 12 40 11 42 19 41 16 39 13 36\n4 23 47 25 48", "8\n4 1 94 44 95\n72 2 60 49 102 51 101 50 63 9 64 13 68 11 58 20 55 4 53 10 52 3 97 5 57 7 100 46 90 43 88 37 86 36 85 31 79 28 74 25 78 27 87 29 82 30 89 35 91 38 93 40 96 48 99 45 98 42 56 21 54 24 72 19 65 17 70 47 73 15 77 18 76\n4 6 66 12 69\n4 8 59 14 62\n4 16 71 26 75\n4 22 61 23 67\n6 32 80 33 83 34 81\n4 39 84 41 92", "Impossible", "9\n4 1 40 2 76\n4 3 41 4 42\n44 5 43 6 48 7 49 8 50 11 51 13 55 14 56 15 57 17 59 18 60 20 61 22 62 26 63 25 65 24 58 23 54 21 53 19 52 16 47 12 46 10 45 9 44\n4 27 68 28 69\n4 29 70 30 71\n4 31 64 34 66\n4 32 72 33 74\n4 35 67 38 73\n4 36 39 37 75", "Impossible", "36\n6 1 74 73 145 72 146\n4 2 75 3 76\n4 4 77 5 78\n4 6 79 7 80\n4 8 81 9 82\n4 10 83 11 84\n4 12 85 13 86\n4 14 87 15 88\n4 16 89 17 90\n4 18 91 19 92\n4 20 93 21 94\n4 22 95 23 96\n4 24 97 25 98\n4 26 99 27 100\n4 28 101 29 102\n4 30 103 31 104\n4 32 105 33 106\n4 34 107 35 108\n4 36 109 37 110\n4 38 111 39 112\n4 40 113 41 114\n4 42 115 43 116\n4 44 117 45 118\n4 46 119 47 120\n4 48 121 49 122\n4 50 123 51 124\n4 52 125 53 126\n4 54 127 55 128\n4 56 129 57 130\n4 58 131 59 132\n4 60 133 61 134\n4 62 135...", "1\n78 1 42 2 69 30 66 27 63 24 58 17 59 16 53 15 55 23 61 14 52 19 62 11 54 13 47 12 77 32 74 4 49 7 50 10 41 37 75 39 76 38 73 35 70 33 40 34 72 28 71 31 78 36 67 29 44 3 65 25 68 26 60 22 64 21 57 20 56 18 43 5 45 9 48 6 46 8 51", "2\n6 1 6 5 9 4 10\n4 2 7 3 8", "13\n76 1 133 63 134 70 75 7 78 5 139 60 138 67 83 64 81 54 135 53 131 49 130 44 129 37 119 36 118 32 114 21 95 23 101 22 99 27 104 28 106 33 108 42 109 46 112 38 115 34 117 35 110 30 103 29 111 41 116 51 122 55 132 61 125 59 76 62 137 73 77 57 123 56 128 3 136\n4 2 80 9 82\n26 4 79 8 90 11 84 12 86 13 89 15 91 6 85 14 87 16 88 18 146 71 148 74 144 10 140\n4 17 92 19 94\n4 20 93 24 98\n4 25 96 47 97\n4 26 100 31 102\n4 39 120 40 127\n4 43 124 45 126\n4 48 105 58 107\n4 50 113 52 121\n6 65 141 68 143 66 147\n...", "5\n40 1 41 21 77 6 49 7 42 3 44 5 50 2 79 38 78 36 75 34 76 24 73 29 46 31 57 27 58 26 62 28 72 32 68 33 43 18 80 39 70\n28 4 45 40 56 19 69 20 65 25 66 8 48 16 63 17 59 22 60 12 54 23 52 10 74 30 64 13 61\n4 9 47 15 55\n4 11 51 14 53\n4 35 67 37 71", "4\n4 1 10 5 11\n4 2 9 3 12\n4 4 14 7 15\n4 6 13 8 16", "18\n6 1 38 37 73 35 74\n4 2 43 4 44\n4 3 39 5 40\n4 6 41 8 42\n4 7 45 9 50\n4 10 52 13 53\n4 11 46 12 47\n4 14 48 22 49\n4 15 56 16 58\n4 17 59 18 62\n4 19 63 20 64\n4 21 66 24 67\n4 23 51 25 54\n4 26 68 28 69\n4 27 55 30 57\n4 29 71 34 72\n4 31 60 32 61\n4 33 65 36 70", "4\n6 1 57 26 67 30 64\n6 2 48 6 49 16 52\n52 3 53 20 63 5 60 19 56 13 51 25 50 8 47 18 54 33 59 31 70 32 62 34 69 23 36 21 42 22 58 11 45 12 44 4 41 15 43 10 46 7 39 14 40 17 37 35 61 29 66 9 68\n6 24 55 28 38 27 65", "Impossible", "1\n30 1 20 6 19 4 16 9 25 5 18 3 17 13 26 12 24 10 23 7 21 8 22 11 29 2 30 15 28 14 27", "Impossible", "Impossible", "1\n38 1 23 4 26 8 28 10 32 12 34 14 37 17 35 16 33 15 31 13 30 11 29 9 27 7 25 6 24 5 22 3 21 2 20 19 36 18 38", "Impossible", "11\n32 1 60 42 51 21 89 37 88 36 87 29 77 28 76 25 52 48 67 6 73 15 72 20 79 14 53 34 85 45 92 44 63\n10 2 56 8 50 11 61 19 86 49 97\n14 3 59 26 62 17 55 16 96 43 95 9 78 38 66\n10 4 64 18 58 41 70 39 54 5 90\n4 7 75 22 83\n4 10 82 40 93\n4 12 65 13 69\n4 23 80 33 81\n8 24 68 31 98 30 71 27 74\n4 32 57 35 84\n4 46 91 47 94", "9\n88 1 68 56 64 54 117 60 118 53 114 46 111 3 70 9 122 55 121 51 116 59 112 44 104 50 106 45 65 40 95 37 99 39 93 27 91 23 86 22 92 29 98 30 94 33 97 2 123 5 75 13 63 12 81 24 82 25 84 28 85 32 73 14 66 11 107 43 110 42 108 38 101 35 100 36 103 41 102 47 105 52 67 7 69 8 72 4 71\n4 6 74 10 76\n6 15 79 16 77 17 83\n4 18 78 19 80\n6 20 87 26 89 21 88\n4 31 90 34 96\n4 48 109 49 119\n4 57 120 62 124\n4 58 113 61 115", "15\n4 1 31 2 32\n4 3 33 4 34\n4 5 35 6 36\n4 7 37 8 38\n4 9 39 10 40\n4 11 41 12 42\n4 13 43 14 44\n4 15 45 16 46\n4 17 47 18 48\n4 19 49 20 50\n4 21 51 22 52\n4 23 53 24 54\n4 25 55 26 56\n4 27 57 28 58\n4 29 59 30 60", "Impossible", "Impossible", "3\n48 1 49 13 47 14 52 20 51 6 55 27 60 30 42 19 46 17 50 15 40 12 36 24 38 9 34 5 41 11 37 10 39 3 54 8 59 21 48 22 45 18 44 16 57 25 53 28 58\n4 2 32 23 33\n8 4 35 29 56 26 31 7 43", "44\n6 1 90 89 177 88 178\n4 2 91 3 92\n4 4 93 5 94\n4 6 95 7 96\n4 8 97 9 98\n4 10 99 11 100\n4 12 101 13 102\n4 14 103 15 104\n4 16 105 17 106\n4 18 107 19 108\n4 20 109 21 110\n4 22 111 23 112\n4 24 113 25 114\n4 26 115 27 116\n4 28 117 29 118\n4 30 119 31 120\n4 32 121 33 122\n4 34 123 35 124\n4 36 125 37 126\n4 38 127 39 128\n4 40 129 41 130\n4 42 131 43 132\n4 44 133 45 134\n4 46 135 47 136\n4 48 137 49 138\n4 50 139 51 140\n4 52 141 53 142\n4 54 143 55 144\n4 56 145 57 146\n4 58 147 59 148\n4 60 149 ..."]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1 | codeforces |
|
ff9235cd44659116788a8be5c260fa52 | Lucky Permutation | Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
One day Petya dreamt of a lexicographically *k*-th permutation of integers from 1 to *n*. Determine how many lucky numbers in the permutation are located on the positions whose indexes are also lucky numbers.
The first line contains two integers *n* and *k* (1<=≤<=*n*,<=*k*<=≤<=109) — the number of elements in the permutation and the lexicographical number of the permutation.
If the *k*-th permutation of numbers from 1 to *n* does not exist, print the single number "-1" (without the quotes). Otherwise, print the answer to the problem: the number of such indexes *i*, that *i* and *a**i* are both lucky numbers.
Sample Input
7 4
4 7
Sample Output
1
1
| {"inputs": ["7 4", "4 7", "7 1", "7 5040", "10 1023", "7 7477", "10 10000", "3 7", "27 1", "40 8544", "47 1", "47 8547744", "50 1000000000", "64 87", "98 854555", "100 1", "9985 5888454", "1 1", "1 2", "2 1000000000", "10 1000000000", "20 1000000000", "777777 1", "777777 2", "777474 10000", "1000000000 1", "777777777 5", "777777777 1", "777477774 1", "444747744 1000000000", "475 88555458", "12 855448", "20 1000000000", "47 99998544", "49 1000000000", "854459 95554455", "77777779 1000000000", "77 47", "6999 85488877", "7479 58884598", "1000000000 1000000000", "7 1000", "7 124", "7 2048", "7 3001", "7 127", "7 980", "7 5000", "7 4095", "7 3856", "7 5032", "7 4999", "2 3", "2 4", "7 985", "4 25", "6 121", "11 39916801", "29 1000000000", "10 4589", "10 100000", "10 98564", "10 1", "10 100000009"], "outputs": ["1", "1", "2", "1", "0", "-1", "1", "-1", "2", "2", "4", "3", "4", "4", "6", "6", "30", "0", "-1", "-1", "-1", "2", "126", "125", "120", "1022", "1021", "1022", "989", "554", "8", "1", "2", "2", "2", "126", "508", "5", "22", "24", "1022", "0", "1", "1", "1", "1", "1", "0", "2", "0", "0", "0", "-1", "-1", "1", "-1", "1", "-1", "2", "1", "1", "1", "2", "-1"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 5 | codeforces |
|
ffffc0199ae7229539d28ba0d02e9047 | Mr. Kitayuta's Gift | Mr. Kitayuta has kindly given you a string *s* consisting of lowercase English letters. You are asked to insert exactly one lowercase English letter into *s* to make it a palindrome. A palindrome is a string that reads the same forward and backward. For example, "noon", "testset" and "a" are all palindromes, while "test" and "kitayuta" are not.
You can choose any lowercase English letter, and insert it to any position of *s*, possibly to the beginning or the end of *s*. You have to insert a letter even if the given string is already a palindrome.
If it is possible to insert one lowercase English letter into *s* so that the resulting string will be a palindrome, print the string after the insertion. Otherwise, print "NA" (without quotes, case-sensitive). In case there is more than one palindrome that can be obtained, you are allowed to print any of them.
The only line of the input contains a string *s* (1<=≤<=|*s*|<=≤<=10). Each character in *s* is a lowercase English letter.
If it is possible to turn *s* into a palindrome by inserting one lowercase English letter, print the resulting string in a single line. Otherwise, print "NA" (without quotes, case-sensitive). In case there is more than one solution, any of them will be accepted.
Sample Input
revive
ee
kitayuta
Sample Output
reviver
eyeNA
| {"inputs": ["revive", "ee", "kitayuta", "evima", "a", "yutampo", "fft", "shuseki", "lsdijfjisl", "ewcdcwerp", "noon", "add", "iq", "hogloid", "yosupo", "stat", "level", "iwiwi", "racecar", "dog", "squirrel", "slime", "palindrome", "nqwcvcwqn", "lsdijfjisl", "jewiiwefj", "vnwmvvmonv", "zennyuu", "mrtoudai", "z", "babccba", "battaba", "bbb", "zaa", "abbabab", "racecar", "zzz", "eviver", "aaaaa", "eee"], "outputs": ["reviver", "eee", "NA", "NA", "aa", "NA", "tfft", "NA", "lsdijfjidsl", "NA", "nooon", "adda", "qiq", "NA", "NA", "stats", "levvel", "iwiiwi", "raceecar", "NA", "NA", "NA", "NA", "nqwcvvcwqn", "lsdijfjidsl", "jfewiiwefj", "NA", "NA", "NA", "zz", "babccbab", "abattaba", "bbbb", "zaaz", "NA", "raceecar", "zzzz", "reviver", "aaaaaa", "eeee"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 108 | codeforces |