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
listlengths
1
1
source
stringclasses
14 values
num_solutions
int64
2
1.9M
starter_code
stringlengths
0
1.47k
subset
stringclasses
3 values
b7bb00724e30ca5e030171a98d9c0d0c
Polo the Penguin and Houses
Little penguin Polo loves his home village. The village has *n* houses, indexed by integers from 1 to *n*. Each house has a plaque containing an integer, the *i*-th house has a plaque containing integer *p**i* (1<=≤<=*p**i*<=≤<=*n*). Little penguin Polo loves walking around this village. The walk looks like that. Firs...
{"inputs": ["5 2", "7 4", "8 5", "8 1", "10 7", "12 8", "50 2", "100 8", "1000 8", "999 7", "685 7", "975 8", "475 5", "227 6", "876 8", "1000 1", "1000 2", "1000 3", "1000 4", "1000 5", "1000 6", "657 3", "137 5", "8 8", "9 8", "1 1", "2 1", "2 2", "3 3", "473 4"], "outputs": ["54", "1728", "16875", "823543", "3176523...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
23
codeforces
b7ce3faab689d1f84c1a04272bc4d6e8
Classroom Watch
Eighth-grader Vova is on duty today in the class. After classes, he went into the office to wash the board, and found on it the number *n*. He asked what is this number and the teacher of mathematics Inna Petrovna answered Vova that *n* is the answer to the arithmetic task for first-graders. In the textbook, a certain ...
{"inputs": ["21", "20", "1", "2", "3", "100000001", "1000000000", "999999979", "9", "10", "11", "39", "66", "75", "100", "101", "2014", "999999994"], "outputs": ["1\n15", "0", "0", "1\n1", "0", "2\n99999937\n100000000", "1\n999999932", "2\n999999899\n999999908", "0", "1\n5", "1\n10", "1\n33", "1\n60", "0", "1\n86", "2\...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
172
codeforces
b7d07bbf111bba1f3ecb254e4e9c03d1
Isomorphic Strings
You are given a string *s* of length *n* consisting of lowercase English letters. For two given strings *s* and *t*, say *S* is the set of distinct characters of *s* and *T* is the set of distinct characters of *t*. The strings *s* and *t* are isomorphic if their lengths are equal and there is a one-to-one mapping (bi...
{"inputs": ["7 4\nabacaba\n1 1 1\n1 4 2\n2 1 3\n2 4 3", "1 2\nz\n1 1 1\n1 1 1", "36 4\naababcbbcbczaaawwwwwaaaabbbbtestbest\n1 7 6\n13 18 5\n23 26 3\n29 33 4", "4 1\nabac\n1 2 3", "5 10\ncaabc\n5 4 1\n5 4 1\n1 5 1\n4 2 2\n1 3 1\n5 5 1\n4 4 1\n4 3 2\n1 4 1\n5 1 1", "10 30\naccbaaccac\n6 8 3\n2 9 1\n6 8 3\n10 5 1\n6 2 2\...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
3
codeforces
b7d321c69eff68ca61b821eff8437223
Median
A median in an array with the length of *n* is an element which occupies position number after we sort the elements in the non-decreasing order (the array elements are numbered starting with 1). A median of an array (2,<=6,<=1,<=2,<=3) is the number 2, and a median of array (0,<=96,<=17,<=23) — the number 17. We defi...
{"inputs": ["3 10\n10 20 30", "3 4\n1 2 3", "2 2\n3 2", "5 1\n1 1 2 1 2", "5 4\n5 5 4 3 5", "10 2\n2 2 1 3 2 1 2 1 1 3", "10 55749\n46380 58202 54935 26290 18295 83040 6933 89652 75187 93963", "10 809\n949 31 175 118 640 588 809 398 792 743", "50 1\n1 2 1 2 1 1 1 2 2 2 2 2 1 1 2 2 2 2 1 2 2 2 1 2 1 1 2 1 1 1 2 2 2 2 2 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
27
codeforces
b7da26f8d4b9ae6a92c5d977a88d7616
Balancer
Petya has *k* matches, placed in *n* matchboxes lying in a line from left to right. We know that *k* is divisible by *n*. Petya wants all boxes to have the same number of matches inside. For that, he can move a match from its box to the adjacent one in one move. How many such moves does he need to achieve the desired c...
{"inputs": ["6\n1 6 2 5 3 7", "6\n6 6 6 0 0 0", "6\n0 0 0 6 6 6", "6\n6 6 0 0 6 6", "5\n0 0 0 0 0", "10\n0 100 0 100 0 100 0 100 0 100", "1\n0", "2\n0 0", "3\n0 0 0", "4\n0 0 0 0", "2\n921 29111", "2\n0 1000000000", "2\n291911 1", "2\n20180000 0", "10\n10 9 7 13 7 5 13 15 10 11", "100\n6 3 4 5 3 4 2 4 1 2 4 1 8 5 2 2 4...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
19
codeforces
b7dcd21ec503ab2edf961df1c3ec9de6
k-rounding
For a given positive integer *n* denote its *k*-rounding as the minimum positive integer *x*, such that *x* ends with *k* or more zeros in base 10 and is divisible by *n*. For example, 4-rounding of 375 is 375·80<==<=30000. 30000 is the minimum integer such that it ends with 4 or more zeros and is divisible by 375. W...
{"inputs": ["375 4", "10000 1", "38101 0", "123456789 8", "1 0", "2 0", "100 0", "1000000000 0", "160 2", "3 0", "10 0", "1 1", "2 1", "3 1", "4 1", "5 1", "6 1", "7 1", "8 1", "9 1", "10 1", "11 1", "12 1", "16 2", "2 2", "1 2", "5 2", "15 2", "36 2", "1 8", "8 8", "96 8", "175 8", "9999995 8", "999999999 8", "1234567...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
250
codeforces
b7f25d647ca43fead8becd81059cb693
Bear in the Field
Our bear's forest has a checkered field. The checkered field is an *n*<=×<=*n* table, the rows are numbered from 1 to *n* from top to bottom, the columns are numbered from 1 to *n* from left to right. Let's denote a cell of the field on the intersection of row *x* and column *y* by record (*x*,<=*y*). Each cell of the ...
{"inputs": ["5 1 2 0 1 2", "1 1 1 -1 -1 2", "1 1 1 1 1 0", "2 2 1 -2 -2 5", "1000000000 1 1 1 1 1000000000000000000", "1000000000 1 2 -100 -100 1", "3 2 2 -100 -100 2", "1000000000 1000000000 1000000000 100 -100 1000000000000000000", "907122235 107269653 309181328 26 -64 242045007473044676", "804 658 177 -95 37 9", "2 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
codeforces
b7fb6e57a6651eb7e580fa89cf2c426c
Cutting Rectangle
A rectangle with sides $A$ and $B$ is cut into rectangles with cuts parallel to its sides. For example, if $p$ horizontal and $q$ vertical cuts were made, $(p + 1) \cdot (q + 1)$ rectangles were left after the cutting. After the cutting, rectangles were of $n$ different types. Two rectangles are different if at least o...
{"inputs": ["1\n1 1 9", "2\n2 3 20\n2 4 40", "2\n1 2 5\n2 3 5"], "outputs": ["3", "6", "0"]}
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
codeforces
b81d6b2d5370a2792e2da862c3adb452
Two Squares
You are given two squares, one with sides parallel to the coordinate axes, and another one with sides at 45 degrees to the coordinate axes. Find whether the two squares intersect. The interior of the square is considered to be part of the square, i.e. if one square is completely inside another, they intersect. If the ...
{"inputs": ["0 0 6 0 6 6 0 6\n1 3 3 5 5 3 3 1", "0 0 6 0 6 6 0 6\n7 3 9 5 11 3 9 1", "6 0 6 6 0 6 0 0\n7 4 4 7 7 10 10 7", "0 0 6 0 6 6 0 6\n8 4 4 8 8 12 12 8", "2 2 4 2 4 4 2 4\n0 3 3 6 6 3 3 0", "-5 -5 5 -5 5 5 -5 5\n-5 7 0 2 5 7 0 12", "-5 -5 5 -5 5 5 -5 5\n-5 12 0 7 5 12 0 17", "-5 -5 5 -5 5 5 -5 5\n6 0 0 6 -6 0 0 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
54
codeforces
b82293c0815f13d9f04492522106193c
Cows and Sequence
Bessie and the cows are playing with sequences and need your help. They start with a sequence, initially containing just the number 0, and perform *n* operations. Each operation is one of the following: 1. Add the integer *x**i* to the first *a**i* elements of the sequence. 1. Append an integer *k**i* to the end of ...
{"inputs": ["5\n2 1\n3\n2 3\n2 1\n3", "6\n2 1\n1 2 20\n2 2\n1 2 -3\n3\n3", "1\n1 1 1", "1\n2 1", "2\n2 1\n1 2 1", "5\n2 1\n1 2 1\n2 1\n2 1\n1 2 1", "5\n1 1 7\n1 1 7\n1 1 7\n2 5\n1 2 2", "5\n1 1 -48\n1 1 19\n1 1 -35\n2 -67\n1 2 -13", "1\n1 1 0", "1\n2 0", "5\n2 -980\n1 2 -156\n2 641\n2 -253\n2 -514"], "outputs": ["0.500...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
22
codeforces
b85848958f173f58de6def1bf136ec8e
A Heap of Heaps
Andrew skipped lessons on the subject 'Algorithms and Data Structures' for the entire term. When he came to the final test, the teacher decided to give him a difficult task as a punishment. The teacher gave Andrew an array of *n* numbers *a*1, ..., *a**n*. After that he asked Andrew for each *k* from 1 to *n*<=-<=1 to...
{"inputs": ["5\n1 5 4 3 2", "6\n2 2 2 2 2 2", "2\n0 0", "2\n1 2", "2\n10 -1", "5\n934 235 171 111 197", "100\n0 1 1 1 0 0 0 2 1 2 2 1 2 2 2 0 0 2 1 2 0 1 1 0 2 0 1 2 2 0 2 0 1 0 1 2 0 2 1 1 0 1 0 1 0 0 1 2 2 2 2 1 1 1 0 2 1 0 0 0 0 0 1 0 2 0 1 0 0 2 0 2 2 1 0 2 2 0 2 0 2 1 2 1 1 1 0 2 1 0 2 1 1 2 1 2 0 1 2 2", "2\n-492...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
codeforces
b8647a7e2926935660a06e9ef1fce9ea
Declined Finalists
This year, as in previous years, MemSQL is inviting the top 25 competitors from the Start[c]up qualification round to compete onsite for the final round. Not everyone who is eligible to compete onsite can afford to travel to the office, though. Initially the top 25 contestants are invited to come onsite. Each eligible ...
{"inputs": ["25\n2 3 4 5 6 7 8 9 10 11 12 14 15 16 17 18 19 20 21 22 23 24 25 26 28", "5\n16 23 8 15 4", "3\n14 15 92", "1\n1000000", "25\n1000000 999999 999998 999997 999996 999995 999994 999993 999992 999991 999990 999989 999988 999987 999986 999985 999984 999983 999982 999981 999980 999979 999978 999977 999976", "25...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
279
codeforces
b86e30843c84440849b6b0560eb93808
st-Spanning Tree
You are given an undirected connected graph consisting of *n* vertices and *m* edges. There are no loops and no multiple edges in the graph. You are also given two distinct vertices *s* and *t*, and two values *d**s* and *d**t*. Your task is to build any spanning tree of the given graph (note that the graph is not wei...
{"inputs": ["3 3\n1 2\n2 3\n3 1\n1 2 1 1", "7 8\n7 4\n1 3\n5 4\n5 7\n3 2\n2 4\n6 1\n1 2\n6 4 1 4", "10 15\n4 1\n5 10\n2 1\n5 7\n9 2\n4 6\n6 7\n9 1\n6 9\n8 4\n8 3\n9 8\n3 9\n2 3\n7 10\n10 1 2 3", "10 10\n1 3\n10 3\n6 1\n2 7\n1 7\n1 9\n9 5\n2 10\n10 8\n4 3\n9 5 2 4", "4 4\n1 4\n4 2\n1 3\n4 3\n3 4 3 3", "3 2\n3 1\n2 3\n1 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
codeforces
b8a883f6d70b75a151dc0664da41aa54
Counting Rectangles is Fun
There is an *n*<=×<=*m* rectangular grid, each cell of the grid contains a single integer: zero or one. Let's call the cell on the *i*-th row and the *j*-th column as (*i*,<=*j*). Let's define a "rectangle" as four integers *a*,<=*b*,<=*c*,<=*d* (1<=≤<=*a*<=≤<=*c*<=≤<=*n*; 1<=≤<=*b*<=≤<=*d*<=≤<=*m*). Rectangle denotes...
{"inputs": ["5 5 5\n00101\n00000\n00001\n01000\n00001\n1 2 2 4\n4 5 4 5\n1 2 5 2\n2 2 4 5\n4 2 5 3", "4 7 5\n0000100\n0000010\n0011000\n0000000\n1 7 2 7\n3 1 3 1\n2 3 4 5\n1 2 2 7\n2 2 4 7", "10 10 10\n0010001010\n0011011010\n0100001110\n0010100000\n0000100011\n0100000001\n0000010100\n1000000010\n0000010000\n0110010000...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
codeforces
b8bf78afb79fadde1f00b79f93ba318c
none
Карта звёздного неба представляет собой прямоугольное поле, состоящее из *n* строк по *m* символов в каждой строке. Каждый символ — это либо «.» (означает пустой участок неба), либо «*» (означает то, что в этом месте на небе есть звезда). Новое издание карты звёздного неба будет напечатано на квадратных листах, поэто...
{"inputs": ["4 4\n....\n..*.\n...*\n..**", "1 3\n*.*", "2 1\n.\n*", "1 1\n*", "1 2\n.*", "1 2\n*.", "1 2\n**", "2 1\n.\n*", "2 1\n*\n.", "2 1\n*\n*", "5 3\n..*\n.**\n..*\n...\n..*", "1 1\n*", "1 2\n*.", "1 2\n**", "1 3\n.**", "1 3\n*.*", "1 4\n..**", "1 4\n*..*", "1 5\n.*.**", "1 5\n.*..*", "2 1\n*\n.", "2 1\n*\n*", "2...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
8
codeforces
b8d8b73277f7749e7852f8884ff19b71
Subtractions
You've got two numbers. As long as they are both larger than zero, they go through the same operation: subtract the lesser number from the larger one. If they equal substract one number from the another. For example, one operation transforms pair (4,17) to pair (4,13), it transforms (5,5) to (0,5). You've got some num...
{"inputs": ["2\n4 17\n7 987654321", "10\n7 987654321\n7 987654321\n7 987654321\n7 987654321\n7 987654321\n7 987654321\n7 987654321\n7 987654321\n7 987654321\n7 987654321", "1\n536870912 32", "20\n1000000000 999999999\n1000000000 999999999\n1000000000 999999999\n1000000000 999999999\n1000000000 999999999\n1000000000 999...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
242
codeforces
b8de50a62a5672e6b2de556a0385efe3
none
Note that girls in Arpa’s land are really attractive. Arpa loves overnight parties. In the middle of one of these parties Mehrdad suddenly appeared. He saw *n* pairs of friends sitting around a table. *i*-th pair consisted of a boy, sitting on the *a**i*-th chair, and his girlfriend, sitting on the *b**i*-th chair. Th...
{"inputs": ["3\n1 4\n2 5\n3 6", "6\n3 2\n5 11\n7 12\n6 9\n8 4\n1 10", "19\n30 27\n6 38\n10 28\n20 5\n14 18\n32 2\n36 29\n12 1\n31 24\n15 4\n35 11\n3 7\n21 17\n25 19\n16 8\n23 22\n37 33\n13 9\n34 26", "4\n4 2\n6 8\n5 1\n3 7", "17\n11 12\n17 22\n34 7\n3 1\n5 24\n18 20\n27 30\n16 33\n23 21\n19 4\n2 15\n29 28\n9 8\n13 25\n...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
4
codeforces
b8e4040e30b7e2f49655da687a4e31d4
Bash's Big Day
Bash has set out on a journey to become the greatest Pokemon master. To get his first Pokemon, he went to Professor Zulu's Lab. Since Bash is Professor Zulu's favourite student, Zulu allows him to take as many Pokemon from his lab as he pleases. But Zulu warns him that a group of *k*<=&gt;<=1 Pokemon with strengths {*...
{"inputs": ["3\n2 3 4", "5\n2 3 4 6 7", "3\n5 6 4", "8\n41 74 4 27 85 39 100 36", "6\n89 20 86 81 62 23", "71\n23 84 98 8 14 4 42 56 83 87 28 22 32 50 5 96 90 1 59 74 77 88 71 38 62 36 85 97 99 6 81 20 49 57 66 9 45 41 29 68 35 19 27 76 78 72 55 25 46 48 26 53 39 31 94 34 63 37 64 16 79 24 82 17 12 3 89 61 80 30 10", "...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
39
codeforces
b8ec3437ad5a9b841daa2d404ddece70
Chat Servers Outgoing Traffic
Polycarp is working on a new project called "Polychat". Following modern tendencies in IT, he decided, that this project should contain chat as well. To achieve this goal, Polycarp has spent several hours in front of his laptop and implemented a chat server that can process three types of commands: - Include a person...
{"inputs": ["+Mike\nMike:hello\n+Kate\n+Dmitry\n-Dmitry\nKate:hi\n-Kate", "+Mike\n-Mike\n+Mike\nMike:Hi I am here\n-Mike\n+Kate\n-Kate", "+Dmitry\n+Mike\nDmitry:All letters will be used\nDmitry:qwertyuiopasdfghjklzxcvbnm QWERTYUIOPASDFGHJKLZXCVBNM\nDmitry:And digits too\nDmitry:1234567890 0987654321\n-Dmitry", "+Dmit...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
219
codeforces
b8fffd9ad83f41df8f97739b5e939e71
Make a Permutation!
Ivan has an array consisting of *n* elements. Each of the elements is an integer from 1 to *n*. Recently Ivan learned about permutations and their lexicographical order. Now he wants to change (replace) minimum number of elements in his array in such a way that his array becomes a permutation (i.e. each of the integer...
{"inputs": ["4\n3 2 2 3", "6\n4 5 6 3 2 1", "10\n6 8 4 6 7 1 6 3 4 5", "6\n5 5 5 6 4 6", "50\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", "50\n1 1 2 1 1 1 1 1 1 1 1 1 2 1 2 1 1 2 1 1 1 1 1 1 1 1 1 2 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1", "50\n2 4 1 2 3 7 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
31
codeforces
b90159b3b2c41c91a4086c3dd7b577d5
Vladik and Memorable Trip
Vladik often travels by trains. He remembered some of his trips especially well and I would like to tell you about one of these trips: Vladik is at initial train station, and now *n* people (including Vladik) want to get on the train. They are already lined up in some order, and for each of them the city code *a**i* i...
{"inputs": ["6\n4 4 2 5 2 3", "9\n5 1 3 1 5 2 4 2 5", "5\n1558 4081 3591 1700 3232", "10\n3838 1368 4825 2068 4755 2048 1342 4909 2837 4854", "10\n4764 4867 2346 1449 1063 2002 2577 2089 1566 614", "10\n689 3996 3974 4778 1740 3481 2916 2744 294 1376", "100\n1628 4511 4814 3756 4625 1254 906 1033 2420 2622 2640 3225 35...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
12
codeforces
b93fdbb19a50d95418de5887b98a8017
Sasha and Sticks
It's one more school day now. Sasha doesn't like classes and is always bored at them. So, each day he invents some game and plays in it alone or with friends. Today he invented one simple game to play with Lena, with whom he shares a desk. The rules are simple. Sasha draws *n* sticks in a row. After that the players t...
{"inputs": ["1 1", "10 4", "251656215122324104 164397544865601257", "963577813436662285 206326039287271924", "1000000000000000000 1", "253308697183523656 25332878317796706", "669038685745448997 501718093668307460", "116453141993601660 87060381463547965", "766959657 370931668", "255787422422806632 146884995820359999", "...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
350
codeforces
b9435cb564d17c1f2aae1353c4f988ab
Hobbits' Party
Everyone knows that hobbits love to organize all sorts of parties and celebrations. There are *n* hobbits living in the Shire. They decided to organize the Greatest Party (GP) that would last for several days. Next day the hobbits wrote a guest list, some non-empty set containing all the inhabitants of the Shire. To en...
{"inputs": ["4", "5", "6", "7", "8", "9", "10", "11", "14", "15", "16", "20", "21", "44", "45", "189", "190", "191", "209", "210", "230", "231", "251", "252", "253", "254", "255", "3", "9000", "9100", "9200", "9300", "9400", "9500", "9600", "9700", "9800", "9900", "9998", "9999", "10000", "9868", "9869", "9870", "9871"...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
8
codeforces
b95a8706627d77a638a45e9ced72df03
none
This is an interactive problem. Natasha is going to fly to Mars. Finally, Natasha sat in the rocket. She flies, flies... but gets bored. She wishes to arrive to Mars already! So she decides to find something to occupy herself. She couldn't think of anything better to do than to calculate the distance to the red planet...
{"inputs": ["5 2 3\n1 0", "1 1 1\n1", "3 2 3\n1 0", "6 3 5\n1 1 1", "10 4 3\n0 0 1 0", "30 5 16\n0 1 1 1 0", "60 6 21\n1 0 0 1 0 1", "100 7 73\n0 0 0 1 0 1 1", "1000000000 29 958572235\n1 1 0 1 1 1 1 0 1 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 1 1 1 0 0", "738009704 30 116044407\n0 0 1 1 0 0 1 0 0 0 1 0 0 0 1 0 0 1 1 0 1 0 1 1 0...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
27
codeforces
b9622c31d50bf23062fb84ae34d8743b
New Year Book Reading
New Year is coming, and Jaehyun decided to read many books during 2015, unlike this year. He has *n* books numbered by integers from 1 to *n*. The weight of the *i*-th (1<=≤<=*i*<=≤<=*n*) book is *w**i*. As Jaehyun's house is not large enough to have a bookshelf, he keeps the *n* books by stacking them vertically. Whe...
{"inputs": ["3 5\n1 2 3\n1 3 2 3 1", "3 3\n10 20 30\n1 2 3", "2 2\n10 12\n2 1", "10 10\n61 59 97 16 2 94 57 48 91 93\n2 8 6 5 3 1 3 4 9 10", "50 50\n75 71 23 37 28 23 69 75 5 62 3 11 96 100 13 50 57 51 8 90 4 6 84 27 11 89 95 81 10 62 48 52 69 87 97 95 30 74 21 42 36 64 31 80 81 50 56 53 33 99\n26 30 5 33 35 29 6 15 36...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
6
codeforces
b97db026ba1258b019779e2780f685b7
Lie or Truth
Vasya has a sequence of cubes and exactly one integer is written on each cube. Vasya exhibited all his cubes in a row. So the sequence of numbers written on the cubes in the order from the left to the right equals to *a*1,<=*a*2,<=...,<=*a**n*. While Vasya was walking, his little brother Stepan played with Vasya's cub...
{"inputs": ["5 2 4\n3 4 2 3 1\n3 2 3 4 1", "3 1 2\n1 2 3\n3 1 2", "4 2 4\n1 1 1 1\n1 1 1 1", "5 1 3\n2 2 2 1 2\n2 2 2 1 2", "7 1 4\n2 5 5 5 4 3 4\n2 5 5 5 4 3 4", "10 1 10\n6 7 6 1 10 10 9 5 3 9\n7 10 9 6 1 5 9 3 10 6", "1 1 1\n1\n1", "4 3 4\n1 2 3 4\n2 1 3 4", "7 2 4\n1 2 3 4 5 7 6\n1 2 3 4 5 6 7", "5 1 2\n1 2 3 4 5\n...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
56
codeforces
b9872594d263a975d2c53559931b8334
Little Pony and Expected Maximum
Twilight Sparkle was playing Ludo with her friends Rainbow Dash, Apple Jack and Flutter Shy. But she kept losing. Having returned to the castle, Twilight Sparkle became interested in the dice that were used in the game. The dice has *m* faces: the first face of the dice contains a dot, the second one contains two dots...
{"inputs": ["6 1", "6 3", "2 2", "5 4", "5 8", "3 10", "3 6", "1 8", "24438 9", "94444 9", "8 66716", "4 25132", "51520 73331", "54230 31747", "24236 90163", "26946 99523", "50323 7", "53033 3", "55743 5", "59964 79", "1 1", "1 1", "3 1", "1 2", "53513 34040", "100000 100000", "1 100000", "100000 1", "2 100000", "10000...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
192
codeforces
b98a21fa072aed9a5f1c1c67eb2c1ce9
Create a Maze
ZS the Coder loves mazes. Your job is to create one so that he can play with it. A maze consists of *n*<=×<=*m* rooms, and the rooms are arranged in *n* rows (numbered from the top to the bottom starting from 1) and *m* columns (numbered from the left to the right starting from 1). The room in the *i*-th row and *j*-th...
{"inputs": ["3", "4", "576460752303423488", "576460752303423487", "99999988898898889", "989466010702279111", "1000000000000000000", "1", "2", "201620162016201600", "138944482508455329", "327543848458922240", "516143210114421854", "481370539210112956", "639733286738742273", "604960615834433375", "793559981784900286", "9...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
2
codeforces
b9a4afd6adac4ec8d2a946362c08d270
Chloe and pleasant prizes
Generous sponsors of the olympiad in which Chloe and Vladik took part allowed all the participants to choose a prize for them on their own. Christmas is coming, so sponsors decided to decorate the Christmas tree with their prizes. They took *n* prizes for the contestants and wrote on each of them a unique id (integer...
{"inputs": ["8\n0 5 -1 4 3 2 6 5\n1 2\n2 4\n2 5\n1 3\n3 6\n6 7\n6 8", "4\n1 -5 1 1\n1 2\n1 4\n2 3", "1\n-1", "10\n3 2 -4 2 0 3 3 3 3 4\n10 8\n4 2\n4 9\n3 5\n5 2\n7 4\n2 6\n1 8\n10 9", "10\n-1 2 -2 -3 -1 -1 0 -4 -5 -4\n4 6\n6 9\n1 2\n6 2\n7 8\n7 9\n5 10\n6 3\n10 1", "10\n4 -4 2 5 -1 3 -1 1 4 5\n1 8\n7 1\n4 1\n9 6\n1 2\n...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
3
codeforces
b9ad6ca1fc6d03437f5d46ec93ad89c2
Inna and Sweet Matrix
Inna loves sweets very much. That's why she decided to play a game called "Sweet Matrix". Inna sees an *n*<=×<=*m* matrix and *k* candies. We'll index the matrix rows from 1 to *n* and the matrix columns from 1 to *m*. We'll represent the cell in the *i*-th row and *j*-th column as (*i*,<=*j*). Two cells (*i*,<=*j*) a...
{"inputs": ["4 4 4", "1 1 1", "1 50 50", "50 1 50", "50 50 1", "4 4 9", "10 10 10", "10 10 100", "10 10 50", "10 10 25", "10 10 75", "50 50 1000", "50 50 2500", "50 50 1", "50 50 10", "50 50 100", "50 50 500", "50 50 200", "50 50 1000", "50 50 1500", "50 50 2000", "50 50 2499", "30 30 56", "30 30 800", "2 2 3", "1 2 1"...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
codeforces
b9b279d1b0b471a11dcd0b7afc2c685e
Searching for Graph
Let's call an undirected graph of *n* vertices *p*-interesting, if the following conditions fulfill: - the graph contains exactly 2*n*<=+<=*p* edges; - the graph doesn't contain self-loops and multiple edges; - for any integer *k* (1<=≤<=*k*<=≤<=*n*), any subgraph consisting of *k* vertices contains at most 2*k*<=...
{"inputs": ["1\n6 0", "1\n5 0", "5\n6 0\n5 0\n7 0\n8 0\n9 0", "5\n6 1\n5 0\n7 1\n8 1\n9 1", "5\n24 0\n23 0\n22 0\n21 0\n24 1", "5\n24 1\n23 1\n22 1\n21 1\n20 1", "5\n20 0\n19 0\n18 0\n17 0\n16 0", "5\n15 0\n14 0\n13 0\n12 0\n11 0", "5\n10 0\n20 0\n24 0\n19 0\n17 0", "5\n24 0\n23 0\n24 1\n23 1\n22 0", "5\n24 0\n24 0\n24...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
62
codeforces
b9b2cf2e122e6b22549b44b01e380445
Vasya and Wrestling
Vasya has become interested in wrestling. In wrestling wrestlers use techniques for which they are awarded points by judges. The wrestler who gets the most points wins. When the numbers of points of both wrestlers are equal, the wrestler whose sequence of points is lexicographically greater, wins. If the sequences of...
{"inputs": ["5\n1\n2\n-3\n-4\n3", "3\n-1\n-2\n3", "2\n4\n-4", "7\n1\n2\n-3\n4\n5\n-6\n7", "14\n1\n2\n3\n4\n5\n6\n7\n-8\n-9\n-10\n-11\n-12\n-13\n-14", "4\n16\n12\n19\n-98", "5\n-6\n-1\n-1\n5\n3", "11\n1\n-1\n1\n-1\n1\n-1\n1\n-1\n1\n-1\n1", "1\n-534365", "1\n10253033", "3\n-1\n-2\n3", "8\n1\n-2\n-3\n4\n5\n-6\n-7\n8", "2\...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
157
codeforces
b9b4e52303af6ee09e25948b343ce56f
Where Are My Flakes?
One morning the Cereal Guy found out that all his cereal flakes were gone. He found a note instead of them. It turned out that his smart roommate hid the flakes in one of *n* boxes. The boxes stand in one row, they are numbered from 1 to *n* from the left to the right. The roommate left hints like "Hidden to the left o...
{"inputs": ["2 1\nTo the left of 2", "3 2\nTo the right of 1\nTo the right of 2", "3 1\nTo the left of 3", "3 2\nTo the left of 2\nTo the right of 1", "3 0", "2 2\nTo the left of 2\nTo the left of 2", "5 0", "6 2\nTo the right of 2\nTo the left of 4", "8 6\nTo the right of 3\nTo the left of 4\nTo the left of 4\nTo the ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
46
codeforces
b9ce4117c8187dc8b1c2b57344133486
Case of Fake Numbers
Andrewid the Android is a galaxy-famous detective. He is now investigating a case of frauds who make fake copies of the famous Stolp's gears, puzzles that are as famous as the Rubik's cube once was. Its most important components are a button and a line of *n* similar gears. Each gear has *n* teeth containing all numbe...
{"inputs": ["3\n1 0 0", "5\n4 2 1 4 3", "4\n0 2 3 1", "1\n0", "2\n1 0", "5\n2 4 4 1 1", "10\n0 1 2 3 4 5 6 7 8 9", "10\n1 5 1 0 6 1 3 5 9 9", "20\n10 11 12 13 14 15 16 17 18 19 0 1 2 3 4 5 6 7 8 9", "20\n2 15 18 0 3 12 4 16 13 7 17 9 8 2 15 18 19 17 5 8", "50\n38 13 40 15 42 17 44 19 46 21 48 23 0 25 2 27 4 29 6 31 8 3...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
18
codeforces
b9e45bc4775a8d7761b45f8ab27508bc
Прокат велосипедов
Как известно, в теплую погоду многие жители крупных городов пользуются сервисами городского велопроката. Вот и Аркадий сегодня будет добираться от школы до дома, используя городские велосипеды. Школа и дом находятся на одной прямой улице, кроме того, на той же улице есть *n* точек, где можно взять велосипед в прокат и...
{"inputs": ["4 4\n3 6 8 10", "2 9\n10 20", "12 3\n4 6 7 9 10 11 13 15 17 18 20 21", "2 1\n11164 11165", "3 7\n45823 45825 45829", "2 100000\n0 100000", "50 15001\n1269 1580 5431 5916 6642 14145 15760 19922 20589 22062 24138 33454 33505 35916 37012 42577 43140 49457 54720 55188 56205 56639 56870 57997 58379 59088 59297 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
103
codeforces
b9ea26d8fd625c2e46bc6f4fbe356598
George and Round
George decided to prepare a Codesecrof round, so he has prepared *m* problems for the round. Let's number the problems with integers 1 through *m*. George estimates the *i*-th problem's complexity by integer *b**i*. To make the round good, he needs to put at least *n* problems there. Besides, he needs to have at least...
{"inputs": ["3 5\n1 2 3\n1 2 2 3 3", "3 5\n1 2 3\n1 1 1 1 1", "3 1\n2 3 4\n1", "29 100\n20 32 41 67 72 155 331 382 399 412 465 470 484 511 515 529 616 637 679 715 733 763 826 843 862 903 925 979 989\n15 15 15 17 18 19 19 20 21 21 22 24 25 26 26 27 28 31 32 32 37 38 38 39 39 40 41 42 43 43 45 45 46 47 49 49 50 50 50 51 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
225
codeforces
b9ec62d47e98670266215b759dd020f0
Sagheer and Nubian Market
On his trip to Luxor and Aswan, Sagheer went to a Nubian market to buy some souvenirs for his friends and relatives. The market has some strange rules. It contains *n* different items numbered from 1 to *n*. The *i*-th item has base cost *a**i* Egyptian pounds. If Sagheer buys *k* items with indices *x*1,<=*x*2,<=...,<...
{"inputs": ["3 11\n2 3 5", "4 100\n1 2 5 6", "1 7\n7", "1 7\n5", "1 1\n1", "4 33\n4 3 2 1", "86 96\n89 48 14 55 5 35 7 79 49 70 74 18 64 63 35 93 63 97 90 77 33 11 100 75 60 99 54 38 3 6 55 1 7 64 56 90 21 76 35 16 61 78 38 78 93 21 89 1 58 53 34 77 56 37 46 59 30 5 85 1 52 87 84 99 97 9 15 66 29 60 17 16 59 23 88 93 3...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
135
codeforces
b9ffc730bfcf1d8951e5290a7cc2ca24
Divisibility by 25
You are given an integer $n$ from $1$ to $10^{18}$ without leading zeroes. In one move you can swap any two adjacent digits in the given number in such a way that the resulting number will not contain leading zeroes. In other words, after each move the number you have cannot contain any leading zeroes. What is the mi...
{"inputs": ["5071", "705", "1241367", "7501", "507", "17010", "52231", "50267", "574196831896431419", "1", "10", "123456123450", "1000000000000000000", "100000000000762582", "123456789987654321", "213716413141380147", "5284691", "750000000000000001", "101", "275257725752725722", "50932", "50272", "25", "52", "57", "75"...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
4
codeforces
ba27c1ae25a9c6f3a632edc8ad96ab06
none
Santa Claus has Robot which lives on the infinite grid and can move along its lines. He can also, having a sequence of *m* points *p*1,<=*p*2,<=...,<=*p**m* with integer coordinates, do the following: denote its initial location by *p*0. First, the robot will move from *p*0 to *p*1 along one of the shortest paths betwe...
{"inputs": ["4\nRURD", "6\nRRULDD", "26\nRRRULURURUULULLLDLDDRDRDLD", "3\nRLL", "4\nLRLR", "5\nLRDLR", "10\nDDRDUULUDD", "1\nD"], "outputs": ["2", "2", "7", "2", "4", "4", "3", "1"]}
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
107
codeforces
ba4d78b29a18d60849c1647760ddd911
Arpa and a game with Mojtaba
Mojtaba and Arpa are playing a game. They have a list of *n* numbers in the game. In a player's turn, he chooses a number *p**k* (where *p* is a prime number and *k* is a positive integer) such that *p**k* divides at least one number in the list. For each number in the list divisible by *p**k*, call it *x*, the player...
{"inputs": ["4\n1 1 1 1", "4\n1 1 17 17", "4\n1 1 17 289", "5\n1 2 3 4 5", "10\n10 14 16 9 17 13 12 4 6 10", "10\n13 13 18 3 8 9 19 12 20 14", "10\n10 18 16 10 8 20 8 4 4 2", "10\n1 4 15 1 16 14 7 17 11 8", "10\n9 19 4 1 20 7 19 18 11 11", "100\n80 35 113 179 195 92 143 152 125 55 68 121 71 147 172 153 87 68 143 133 32...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
codeforces
ba5f27a8af10e0175f956f2fcf748134
Grandma Laura and Apples
Grandma Laura came to the market to sell some apples. During the day she sold all the apples she had. But grandma is old, so she forgot how many apples she had brought to the market. She precisely remembers she had *n* buyers and each of them bought exactly half of the apples she had at the moment of the purchase and ...
{"inputs": ["2 10\nhalf\nhalfplus", "3 10\nhalfplus\nhalfplus\nhalfplus", "10 328\nhalf\nhalfplus\nhalfplus\nhalf\nhalfplus\nhalf\nhalf\nhalf\nhalfplus\nhalfplus", "1 2\nhalfplus", "5 6\nhalf\nhalf\nhalfplus\nhalf\nhalfplus", "10 2\nhalfplus\nhalfplus\nhalfplus\nhalf\nhalfplus\nhalf\nhalfplus\nhalf\nhalfplus\nhalfplus"...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
80
codeforces
ba60028702652ff2df427b79f2f6558d
Functions again
Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried about maximum values of the Main Uzhlyandian Function *f*, which is defined ...
{"inputs": ["5\n1 4 2 3 1", "4\n1 5 4 7", "8\n16 14 12 10 8 100 50 0", "2\n1 1", "50\n-5 -9 0 44 -10 37 34 -49 11 -22 -26 44 8 -13 23 -46 34 12 -24 2 -40 -15 -28 38 -40 -42 -42 7 -43 5 2 -11 10 43 9 49 -13 36 2 24 46 50 -15 -26 -6 -6 8 4 -44 -3", "100\n23 64 60 -45 -36 -64 -59 15 -75 69 -30 -7 -20 17 -77 58 93 -76 -98 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
112
codeforces
ba61328e541f4203d3920b0fb7fb0ea3
Wormhouse
Arnie the Worm has finished eating an apple house yet again and decided to move. He made up his mind on the plan, the way the rooms are located and how they are joined by corridors. He numbered all the rooms from 1 to *n*. All the corridors are bidirectional. Arnie wants the new house to look just like the previous on...
{"inputs": ["3 3\n1 2 3 1", "3 3\n1 3 2 1", "4 4\n1 2 4 3 1", "6 7\n3 2 4 1 6 5 1 3", "8 12\n4 6 5 1 4 3 1 8 3 7 8 5 4", "5 6\n3 4 1 2 5 1 3", "7 9\n3 2 7 3 5 1 2 6 1 3", "6 7\n1 5 6 1 4 3 2 1", "4 3\n1 2 3 1", "10 40\n10 3 8 4 10 2 8 1 2 6 3 5 7 6 10 8 9 7 8 5 4 9 1 3 7 2 5 10 9 2 4 3 9 6 5 1 4 6 1 7 10", "30 100\n8 2...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
codeforces
ba6e2b6a7239ac8f2e8a5c94037059f3
Special Task
Special Agent Smart Beaver works in a secret research department of ABBYY. He's been working there for a long time and is satisfied with his job, as it allows him to eat out in the best restaurants and order the most expensive and exotic wood types there. The content special agent has got an important task: to get th...
{"inputs": ["AJ", "1?AA", "?", "7", "A", "BBB?", "BC??", "CC", "CB?", "B??C?", "BB?C?", "?BCB?", "?C", "??C?C", "???2", "9???", "GJH2?", "7I9G4", "JG50?", "CDEFG"], "outputs": ["81", "100", "9", "1", "9", "90", "8100", "9", "810", "81000", "8100", "8100", "90", "9000", "900", "1000", "6480", "90", "810", "27216"]}
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
53
codeforces
baddb954f5f204cdf827de7b355fa03f
Dima and Lisa
Dima loves representing an odd number as the sum of multiple primes, and Lisa loves it when there are at most three primes. Help them to represent the given number as the sum of at most than three primes. More formally, you are given an odd numer *n*. Find a set of numbers *p**i* (1<=≤<=*i*<=≤<=*k*), such that 1. 1<=...
{"inputs": ["27", "3", "25", "9", "91", "57", "31", "555", "700000001", "5", "7", "11", "13", "15", "17", "19", "21", "23", "29", "79", "99", "27", "55", "79", "585", "245", "793", "133", "681", "981399", "867773", "654141", "202985", "784533", "370359", "396831", "492211", "838347", "1098945", "1313565", "1349631", "1...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
9
codeforces
bafeb7c12c0d4cc7009ce0f7dfa473fc
Bear and Colors
Bear Limak has *n* colored balls, arranged in one long row. Balls are numbered 1 through *n*, from left to right. There are *n* possible colors, also numbered 1 through *n*. The *i*-th ball has color *t**i*. For a fixed interval (set of consecutive elements) of balls we can define a dominant color. It's a color occurr...
{"inputs": ["4\n1 2 1 2", "3\n1 1 1", "10\n9 1 5 2 9 2 9 2 1 1", "50\n17 13 19 19 19 34 32 24 24 13 34 17 19 19 7 32 19 13 13 30 19 34 34 28 41 24 24 47 22 34 21 21 30 7 22 21 32 19 34 19 34 22 7 28 6 13 19 30 13 30", "150\n28 124 138 71 71 18 78 136 138 93 145 93 18 15 71 47 47 64 18 72 138 72 18 150 7 71 109 149 18 1...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
11
codeforces
bb1e3bb6c310b0882dcd8872d6ac76d1
Games
Manao works on a sports TV. He's spent much time watching the football games of some country. After a while he began to notice different patterns. For example, each team has two sets of uniforms: home uniform and guest uniform. When a team plays a game at home, the players put on the home uniform. When a team plays as ...
{"inputs": ["3\n1 2\n2 4\n3 4", "4\n100 42\n42 100\n5 42\n100 5", "2\n1 2\n1 2", "7\n4 7\n52 55\n16 4\n55 4\n20 99\n3 4\n7 52", "10\n68 42\n1 35\n25 70\n59 79\n65 63\n46 6\n28 82\n92 62\n43 96\n37 28", "30\n10 39\n89 1\n78 58\n75 99\n36 13\n77 50\n6 97\n79 28\n27 52\n56 5\n93 96\n40 21\n33 74\n26 37\n53 59\n98 56\n61 6...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
925
codeforces
bb4f21e3fb5d468b2df9010b6f3af889
Last Chance
Having read half of the book called "Storm and Calm" on the IT lesson, Innocentius was absolutely determined to finish the book on the maths lessons. All was fine until the math teacher Ms. Watkins saw Innocentius reading fiction books instead of solving equations of the fifth degree. As during the last maths class Inn...
{"inputs": ["Abo", "OEIS", "auBAAbeelii", "AaaBRAaaCAaaDAaaBRAaa", "EA", "BBBAABAABAABBBB", "b", "AABAABAABAA", "aaaaaaa", "AAAAAAABBB", "aabaaaaaaaaaaaaaaab", "aaaaabaaaaabaaaaabaaaaabaaaaabaaaaabaaaaabaaaaabaaaaabaaaaabaaaaabaaaaabaaaaabaaaaabaaaaabaaaaabaaaaabaaaaabaaaaabaaaaabaaaaab", "aaaaabaaaaabaaaaabaaaaabaaaaa...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
4
codeforces
bb53026b93847d7813469885cb9da1cf
Helga Hufflepuff's Cup
Harry, Ron and Hermione have figured out that Helga Hufflepuff's cup is a horcrux. Through her encounter with Bellatrix Lestrange, Hermione came to know that the cup is present in Bellatrix's family vault in Gringott's Wizarding Bank. The Wizarding bank is in the form of a tree with total *n* vaults where each vault ...
{"inputs": ["4 2\n1 2\n2 3\n1 4\n1 2", "3 3\n1 2\n1 3\n2 1", "3 1\n1 2\n1 3\n1 1", "3 1000000000\n2 3\n3 1\n585430050 9", "4 50000\n2 1\n4 2\n2 3\n42169 9", "15 100000\n9 7\n15 13\n1 13\n14 5\n6 10\n5 12\n4 14\n4 6\n8 3\n8 2\n9 3\n10 15\n11 8\n10 3\n16283 7"], "outputs": ["1", "13", "0", "91592837", "542369366", "77019...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
2
codeforces
bb6533d1cf6db1f3d3ef4bc882371c7c
none
An expedition group flew from planet ACM-1 to Earth in order to study the bipedal species (its representatives don't even have antennas on their heads!). The flying saucer, on which the brave pioneers set off, consists of three sections. These sections are connected by a chain: the 1-st section is adjacent only to the...
{"inputs": ["1 10", "3 8", "8 12", "4 84", "9 95", "331358794 820674098", "5 56", "10 22", "8 73", "7 63", "1 57", "6 5", "6 25", "1 39", "3 60", "2 81", "5 35", "8 100", "6 29", "7 90", "1 37", "7 34", "3 49", "1 38", "7 88", "9 30", "333734901 647005907", "140068687 419634856", "725891944 969448805", "792362041 42349...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
24
codeforces
bb658a7df66938411259566bbf53ad8e
Links and Pearls
A necklace can be described as a string of links ('-') and pearls ('o'), with the last link or pearl connected to the first one. You can remove a link or a pearl and insert it between two other existing links or pearls (or between a link and a pearl) on the necklace. This process can be repeated as many times as you l...
{"inputs": ["-o-o--", "-o---", "-o---o-", "ooo", "---", "--o-o-----o----o--oo-o-----ooo-oo---o--", "-o--o-oo---o-o-o--o-o----oo------oo-----o----o-o-o--oo-o--o---o--o----------o---o-o-oo---o--o-oo-o--", "-ooo--", "---o--", "oo-ooo", "------o-o--o-----o--", "--o---o----------o----o----------o--o-o-----o-oo---oo--oo---o-...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
216
codeforces
bb6f8901c7e3ad27813fe9d022d7ed4d
Water The Garden
It is winter now, and Max decided it's about time he watered the garden. The garden can be represented as *n* consecutive garden beds, numbered from 1 to *n*. *k* beds contain water taps (*i*-th tap is located in the bed *x**i*), which, if turned on, start delivering water to neighbouring beds. If the tap on the bed *...
{"inputs": ["3\n5 1\n3\n3 3\n1 2 3\n4 1\n1", "26\n1 1\n1\n2 1\n2\n2 1\n1\n2 2\n1 2\n3 1\n3\n3 1\n2\n3 2\n2 3\n3 1\n1\n3 2\n1 3\n3 2\n1 2\n3 3\n1 2 3\n4 1\n4\n4 1\n3\n4 2\n3 4\n4 1\n2\n4 2\n2 4\n4 2\n2 3\n4 3\n2 3 4\n4 1\n1\n4 2\n1 4\n4 2\n1 3\n4 3\n1 3 4\n4 2\n1 2\n4 3\n1 2 4\n4 3\n1 2 3\n4 4\n1 2 3 4", "31\n5 1\n5\n5 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
132
codeforces
bb71d6ab1355a5ce318f88adc38bf033
Little Xor
Little Petya likes arrays that consist of non-negative integers a lot. Recently his mom has presented him one such array consisting of *n* elements. Petya immediately decided to find there a segment of consecutive elements, such that the *xor* of all numbers from this segment was maximal possible. Help him with that. ...
{"inputs": ["5\n1 2 1 1 2", "3\n1 2 7", "4\n4 2 4 8", "5\n1 1 1 1 1", "16\n0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15", "20\n1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10", "100\n28 20 67 103 72 81 82 83 7 109 122 30 50 118 83 89 108 82 92 17 97 3 62 12 9 100 14 11 99 106 10 8 60 101 88 119 104 62 76 6 5 57 32 94 60 50 58 97 1 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
71
codeforces
bb883e074b47c2bd5d1d4f497d9eb006
Inversions problem
You are given a permutation of *n* numbers *p*1,<=*p*2,<=...,<=*p**n*. We perform *k* operations of the following type: choose uniformly at random two indices *l* and *r* (*l*<=≤<=*r*) and reverse the order of the elements *p**l*,<=*p**l*<=+<=1,<=...,<=*p**r*. Your task is to find the expected value of the number of in...
{"inputs": ["3 1\n1 2 3", "3 4\n1 3 2", "6 1\n4 2 5 1 3 6", "6 2\n1 4 6 5 2 3", "4 4\n2 3 1 4", "4 1\n3 4 2 1", "4 3\n3 1 2 4", "4 4\n4 2 3 1", "4 1\n1 2 4 3", "5 4\n4 3 2 5 1", "5 2\n3 1 2 5 4", "5 1\n3 5 1 2 4", "6 1\n5 2 3 4 1 6", "5 2\n4 3 2 1 5", "6 1\n5 3 4 6 2 1", "6 4\n1 2 3 4 5 6", "6 4\n6 5 4 3 2 1", "1 1\n1"...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
9
codeforces
bb9dcfed83c01117e82f8dc14ff02c18
Equalize the Remainders
You are given an array consisting of $n$ integers $a_1, a_2, \dots, a_n$, and a positive integer $m$. It is guaranteed that $m$ is a divisor of $n$. In a single move, you can choose any position $i$ between $1$ and $n$ and increase $a_i$ by $1$. Let's calculate $c_r$ ($0 \le r \le m-1)$ — the number of elements havin...
{"inputs": ["6 3\n3 2 0 6 10 12", "4 2\n0 1 2 3", "1 1\n1000000000", "6 3\n3 2 0 6 10 11", "100 25\n6745 2075 7499 7517 1776 5164 2335 2745 4465 1457 7565 2232 2486 9025 8059 9646 8017 7662 9690 3352 2306 366 7422 1073 7169 8966 4506 8225 5614 8628 2908 7452 9625 9332 7097 353 1043 8118 5794 4486 626 971 6731 6618 887 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
17
codeforces
bbad5c3797c66cec0db1fc0f3434ac7b
Whose sentence is it?
One day, liouzhou_101 got a chat record of Freda and Rainbow. Out of curiosity, he wanted to know which sentences were said by Freda, and which were said by Rainbow. According to his experience, he thought that Freda always said "lala." at the end of her sentences, while Rainbow always said "miao." at the beginning of ...
{"inputs": ["5\nI will go to play with you lala.\nwow, welcome.\nmiao.lala.\nmiao.\nmiao .", "10\nLpAEKiHVJrzSZqBVSSyY\nYECGBlala.\nUZeGpeM.UCwiHmmA\nqt_,.b_.LSwJtJ.\nFAnXZtHlala.\nmiao.iapelala.\nCFPlbUgObrXLejPNu.F\nZSUfvisiHyrIMjMlala.\nmiao. lala.\nd,IWSeumytrVlala.", "10\nmiao.,taUvXPVlala.\nmiao.txEeId.X_lala.\nL...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
81
codeforces
bbbbaaae57ce7ca35845708495dd1699
Mishap in Club
Polycarpus just has been out of luck lately! As soon as he found a job in the "Binary Cat" cafe, the club got burgled. All ice-cream was stolen. On the burglary night Polycarpus kept a careful record of all club visitors. Each time a visitor entered the club, Polycarpus put down character "+" in his notes. Similarly, ...
{"inputs": ["+-+-+", "---", "-", "--", "---", "----", "---+", "--+-", "--++", "-+--", "-++", "-++-", "+", "+-", "+--", "+--+", "++--", "-+++--+-++--+-+--+-+", "++-++--+++++-+++++---+++-++-++-", "----+-+--++---++---++-+-----+--", "-+++---+++++++++++++-++-++++++-++-+-+++-", "++++++++++++++++++++++++++++++++++++++++++++++...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
40
codeforces
bbd37e23be19f61cce43427551e0e712
The Same Calendar
The girl Taylor has a beautiful calendar for the year *y*. In the calendar all days are given with their days of week: Monday, Tuesday, Wednesday, Thursday, Friday, Saturday and Sunday. The calendar is so beautiful that she wants to know what is the next year after *y* when the calendar will be exactly the same. Help ...
{"inputs": ["2016", "2000", "50501", "1000", "1900", "1899", "99999", "50000", "99900", "12345", "1004", "2100", "1313", "1872", "2098", "2072", "2002", "1179", "2096", "1096", "1796", "2014", "2006", "1874", "1884", "2342", "2010", "2097", "1072", "1191", "2896", "1797", "1002", "99988", "1788", "1994", "5094", "99996...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
43
codeforces
bbda5083b762ef3b2b0b127c37da519c
Jumping Jack
Jack is working on his jumping skills recently. Currently he's located at point zero of the number line. He would like to get to the point *x*. In order to train, he has decided that he'll first jump by only one unit, and each subsequent jump will be exactly one longer than the previous one. He can go either left or ri...
{"inputs": ["2", "6", "0", "-1000000000", "999961560", "999961561", "999961559", "-488979819", "-865918189", "-278253406", "-87275307", "103702792", "294680891", "485658989", "676637088", "867615187", "-941406715", "-897912263", "-706934164", "-790244010", "16417015", "823078041", "-517744582", "288916443", "-904422532...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
61
codeforces
bbfbef8cfdb66fcb1844230b423e42e2
XOR and OR
The Bitlandians are quite weird people. They do everything differently. They have a different alphabet so they have a different definition for a string. A Bitlandish string is a string made only of characters "0" and "1". BitHaval (the mayor of Bitland) loves to play with Bitlandish strings. He takes some Bitlandish ...
{"inputs": ["11\n10", "1\n01", "000\n101", "1101\n1111", "11000001\n00000001", "01\n10", "0000\n1110", "010101\n101010", "0\n1", "1\n1", "0\n0", "1\n0", "100\n11111", "1000000000000000000000000000000000000011111111000000000000\n0111111111100000000000111111111000000000000000111111110001", "000000000000000000000000000000...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
2
codeforces
bc00254d261298878bf4229043d2b405
Hamburgers
Polycarpus loves hamburgers very much. He especially adores the hamburgers he makes with his own hands. Polycarpus thinks that there are only three decent ingredients to make hamburgers from: a bread, sausage and cheese. He writes down the recipe of his favorite "Le Hamburger de Polycarpus" as a string of letters 'B' (...
{"inputs": ["BBBSSC\n6 4 1\n1 2 3\n4", "BBC\n1 10 1\n1 10 1\n21", "BSC\n1 1 1\n1 1 3\n1000000000000", "B\n1 1 1\n1 1 1\n381", "BSC\n3 5 6\n7 3 9\n100", "BSC\n100 1 1\n100 1 1\n100", "SBBCCSBB\n1 50 100\n31 59 21\n100000", "BBBBCCCCCCCCCCCCCCCCCCCCSSSSBBBBBBBBSS\n100 100 100\n1 1 1\n3628800", "BBBBBBBBBBCCCCCCCCCCCCCCCC...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
187
codeforces
bc032e5d3c2c75050a8a48f992de8d6e
Fibonacci Sums
Fibonacci numbers have the following form: Let's consider some non-empty set *S*<==<={*s*1,<=*s*2,<=...,<=*s**k*}, consisting of different Fibonacci numbers. Let's find the sum of values of this set's elements: Let's call the set *S* a number *n*'s decomposition into Fibonacci sum. It's easy to see that several num...
{"inputs": ["2\n13\n16", "10\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10", "10\n24\n37\n42\n58\n60\n73\n79\n84\n92\n99", "5\n484775665757\n968685776575\n687675666422\n348587665784\n373875686864", "1\n123456789101112", "22\n304056783818718320\n491974210728665289\n187917426909946968\n796030994547383610\n912170329762608884\n9839524503...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
codeforces
bc4528d68579e1604b5cfcbe0e276380
Candies
After passing a test, Vasya got himself a box of $n$ candies. He decided to eat an equal amount of candies each morning until there are no more candies. However, Petya also noticed the box and decided to get some candies for himself. This means the process of eating candies is the following: in the beginning Vasya cho...
{"inputs": ["68", "1", "2", "42", "43", "756", "999999972", "999999973", "1000000000000000000", "6", "3", "4", "5", "66", "67", "1000", "10000", "100500", "1000000", "10000000", "100000000", "123456789", "543212345", "505050505", "777777777", "888888871", "1000000000", "999999999999999973", "999999999999999998", "99999...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
56
codeforces
bc613d8c5d133aa3218104a12bd2c957
Ant colony
Mole is hungry again. He found one ant colony, consisting of *n* ants, ordered in a row. Each ant *i* (1<=≤<=*i*<=≤<=*n*) has a strength *s**i*. In order to make his dinner more interesting, Mole organizes a version of «Hunger Games» for the ants. He chooses two numbers *l* and *r* (1<=≤<=*l*<=≤<=*r*<=≤<=*n*) and each...
{"inputs": ["5\n1 3 2 4 2\n4\n1 5\n2 5\n3 5\n4 5"], "outputs": ["4\n4\n1\n1"]}
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
3
codeforces
bc64e74229636684b4bed21608cbda11
Billiard
Consider a [billiard table](https://en.wikipedia.org/wiki/Billiard_table) of rectangular size $n \times m$ with four pockets. Let's introduce a coordinate system with the origin at the lower left corner (see the picture). There is one ball at the point $(x, y)$ currently. Max comes to the table and strikes the ball. ...
{"inputs": ["4 3 2 2 -1 1", "4 4 2 0 1 1", "10 10 10 1 -1 0", "1000000000 1000000000 1 1000000000 0 1", "2 1 1 0 -1 -1", "4 2 1 2 1 1", "5 3 4 3 1 -1", "15 9 1 1 1 1", "15 9 1 1 -1 -1", "15 9 2 1 1 1", "15 9 2 1 -1 1", "1000000000 999999999 999999998 999999999 -1 -1", "1000000000 999999999 999999998 999999999 -1 1", "1...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
5
codeforces
bc675e3dd359f3855d27c61fbbe05bb0
Bear and Strings
The bear has a string *s*<==<=*s*1*s*2... *s*|*s*| (record |*s*| is the string's length), consisting of lowercase English letters. The bear wants to count the number of such pairs of indices *i*,<=*j* (1<=≤<=*i*<=≤<=*j*<=≤<=|*s*|), that string *x*(*i*,<=*j*)<==<=*s**i**s**i*<=+<=1... *s**j* contains at least one string...
{"inputs": ["bearbtear", "bearaabearc", "pbearbearhbearzqbearjkterasjhy", "pbearjbearbebearnbabcffbearbearwubearjezpiorrbearbearjbdlbearbearqbearjbearwipmsbearoaftrsebearzsnqb", "bear", "a", "be"], "outputs": ["6", "20", "291", "4419", "1", "0", "0"]}
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
145
codeforces
bc6d7c53a34b7bb783f08170fd4f3ffb
Subsequences
For the given sequence with *n* different elements find the number of increasing subsequences with *k*<=+<=1 elements. It is guaranteed that the answer is not greater than 8·1018. First line contain two integer values *n* and *k* (1<=≤<=*n*<=≤<=105,<=0<=≤<=*k*<=≤<=10) — the length of sequence and the number of elements...
{"inputs": ["5 2\n1\n2\n3\n5\n4", "1 0\n1", "2 1\n1\n2", "2 1\n2\n1", "3 2\n1\n2\n3", "3 1\n1\n3\n2", "3 1\n2\n1\n3", "3 1\n2\n3\n1", "3 1\n3\n1\n2", "3 2\n3\n2\n1", "10 2\n6\n10\n9\n7\n1\n2\n8\n5\n4\n3", "100 7\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n25\n26\n27\n28\n29\n...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
6
codeforces
bc958cdf56381e768a6fa20968b74312
Congruence Equation
Given an integer $x$. Your task is to find out how many positive integers $n$ ($1 \leq n \leq x$) satisfy $$n \cdot a^n \equiv b \quad (\textrm{mod}\;p),$$ where $a, b, p$ are all known constants. The only line contains four integers $a,b,p,x$ ($2 \leq p \leq 10^6+3$, $1 \leq a,b &lt; p$, $1 \leq x \leq 10^{12}$). It i...
{"inputs": ["2 3 5 8", "4 6 7 13", "233 233 10007 1", "338792 190248 339821 152634074578", "629260 663548 739463 321804928248", "656229 20757 818339 523535590429", "1000002 1000002 1000003 1000000000000", "345 2746 1000003 5000000", "802942 824238 836833 605503824329", "1 1 2 880336470888", "2 2 3 291982585081", "69960...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
3
codeforces
bca8f2c3bacf7b7637b3e7c60e95a021
Fly, freebies, fly!
Everyone loves a freebie. Especially students. It is well-known that if in the night before exam a student opens window, opens the student's record-book and shouts loudly three times "Fly, freebie, fly!" — then flown freebie helps him to pass the upcoming exam. In the night before the exam on mathematical analysis *n...
{"inputs": ["6\n4 1 7 8 3 8\n1", "4\n4 2 1 5\n2", "10\n4 7 1 3 8 5 2 1 8 4\n3", "8\n39 49 37 28 40 17 50 2\n10", "2\n1 1\n1", "2\n1 1\n2", "2\n1 1\n1000", "2\n1 2\n2", "2\n450 826\n1000", "3\n3 1 1\n1", "3\n3 1 2\n2", "3\n3 4 3\n1", "3\n3 4 3\n1", "100\n63 69 36 40 74 31 86 42 81 95 60 55 98 98 2 16 84 37 61 47 81 91 8...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
36
codeforces
bcbdca7bed3cf5b0c900d268a0fbb27e
Casinos and travel
John has just bought a new car and is planning a journey around the country. Country has *N* cities, some of which are connected by bidirectional roads. There are *N*<=-<=1 roads and every city is reachable from any other city. Cities are labeled from 1 to *N*. John first has to select from which city he will start hi...
{"inputs": ["2\n1 2", "3\n1 2\n2 3", "4\n1 2\n2 3\n3 4"], "outputs": ["4", "10", "24"]}
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
6
codeforces
bcbfe74a23a31ba03505e0c77eeef23c
Alena And The Heater
"We've tried solitary confinement, waterboarding and listening to Just In Beaver, to no avail. We need something extreme." "Little Alena got an array as a birthday present..." The array *b* of length *n* is obtained from the array *a* of length *n* and two integers *l* and *r* (*l*<=≤<=*r*) using the following proced...
{"inputs": ["5\n1 2 3 4 5\n00001", "10\n-10 -9 -8 -7 -6 6 7 8 9 10\n0000111110", "10\n-8 -9 -9 -7 -10 -10 -8 -8 -9 -10\n0000000011", "11\n226 226 226 226 226 227 1000000000 1000000000 228 1000000000 1000000000\n00001111110", "95\n-97 -98 -92 -93 94 96 91 98 95 85 90 86 84 83 81 79 82 79 73 -99 -91 -93 -92 -97 -85 -88 -...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
23
codeforces
bcc97263183979d209e5ab6a23185300
Field expansion
In one of the games Arkady is fond of the game process happens on a rectangular field. In the game process Arkady can buy extensions for his field, each extension enlarges one of the field sizes in a particular number of times. Formally, there are *n* extensions, the *i*-th of them multiplies the width or the length (b...
{"inputs": ["3 3 2 4 4\n2 5 4 10", "3 3 3 3 5\n2 3 5 4 2", "5 5 1 2 3\n2 2 3", "3 4 1 1 3\n2 3 2", "572 540 6 2 12\n2 3 2 2 2 3 3 3 2 2 2 2", "375 905 1 1 17\n2 2 3 3 3 3 3 3 2 2 2 2 3 2 2 2 3", "37 23 4 1 16\n2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2", "20 19 6 8 18\n3 4 2 3 4 3 2 4 2 2 4 2 4 3 2 4 4 2", "11 11 5 3 11\n4 4 2 4 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
codeforces
bcce2d002f657ac7dccfcbef1ce7137d
Average Numbers
You are given a sequence of positive integers *a*1,<=*a*2,<=...,<=*a**n*. Find all such indices *i*, that the *i*-th element equals the arithmetic mean of all other elements (that is all elements except for this one). The first line contains the integer *n* (2<=≤<=*n*<=≤<=2·105). The second line contains elements of th...
{"inputs": ["5\n1 2 3 4 5", "4\n50 50 50 50", "3\n2 3 1", "2\n4 2", "2\n1 1", "10\n3 3 3 3 3 4 3 3 3 2", "10\n15 7 10 7 7 7 4 4 7 2", "6\n2 2 2 2 2 2", "6\n3 3 3 3 3 3", "4\n6 6 6 7", "2\n1 2", "3\n3 3 4", "5\n7 6 6 6 6", "4\n3 5 5 9", "3\n99 100 99", "4\n5 6 5 5", "6\n1 1 2 1 1 1", "2\n4 5", "4\n1 1 1 2", "3\n1 2 4", ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
130
codeforces
bcd6a289c4ca64bddbb3a92d687dfda3
Sum of Nestings
Recall that the bracket sequence is considered regular if it is possible to insert symbols '+' and '1' into it so that the result is a correct arithmetic expression. For example, a sequence "(()())" is regular, because we can get correct arithmetic expression insering symbols '+' and '1': "((1+1)+(1+1))". Also the foll...
{"inputs": ["3 1", "4 6", "2 5", "1 0", "2 0", "2 1", "3 0", "10 42", "3 2", "3 3", "4 1", "4 2", "4 0", "4 3", "4 4", "4 5", "20 132", "5 0", "5 1", "5 2", "5 3", "5 4", "5 5", "5 6", "5 7", "5 8", "5 9", "5 10", "5 11", "50 282", "100 4298", "201 19557", "301 43259", "333 3286", "400 14432", "500 12169", "1000 101063...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
9
codeforces
bce21ee8b1160c20c0b326ab3867d800
none
Squirrel Liss lived in a forest peacefully, but unexpected trouble happens. Stones fall from a mountain. Initially Squirrel Liss occupies an interval [0,<=1]. Next, *n* stones will fall and Liss will escape from the stones. The stones are numbered from 1 to *n* in order. The stones always fall to the center of Liss's ...
{"inputs": ["llrlr", "rrlll", "lrlrr", "lllrlrllrl", "llrlrrrlrr", "rlrrrllrrr", "lrrlrrllrrrrllllllrr", "rlrrrlrrrllrrllrlrll", "lllrrlrlrllrrrrrllrl", "rrrllrrrlllrlllrlrrr", "rrlllrrrlrrlrrrlllrlrlrrrlllrllrrllrllrrlrlrrllllrlrrrrlrlllrlrrrlrlrllrlrlrrlrrllrrrlrlrlllrrllllrl", "llrlrlllrrllrllllrlrrlrlrrllrlrlrrlrrr...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
145
codeforces
bcf965fe41db5c767e712d73903ad8b4
IQ Test
Petya is preparing for IQ test and he has noticed that there many problems like: you are given a sequence, find the next number. Now Petya can solve only problems with arithmetic or geometric progressions. Arithmetic progression is a sequence *a*1, *a*1<=+<=*d*, *a*1<=+<=2*d*, ..., *a*1<=+<=(*n*<=-<=1)*d*, where *a*1 ...
{"inputs": ["836 624 412 200", "1 334 667 1000", "501 451 400 350", "836 624 412 200", "1 334 667 1000", "11 234 457 680", "640 431 222 13", "1 1 1 1", "1 10 100 1000", "3 18 108 648", "512 384 288 216", "891 297 99 33", "64 160 400 1000", "501 451 400 350", "501 450 400 350", "4 32 48 64", "9 8 7 5", "992 994 998 1000...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
15
codeforces
bcfaa0ca75d2308244afef49d1cea846
Eight Point Sets
Gerald is very particular to eight point sets. He thinks that any decent eight point set must consist of all pairwise intersections of three distinct integer vertical straight lines and three distinct integer horizontal straight lines, except for the average of these nine points. In other words, there must be three int...
{"inputs": ["0 0\n0 1\n0 2\n1 0\n1 2\n2 0\n2 1\n2 2", "0 0\n1 0\n2 0\n3 0\n4 0\n5 0\n6 0\n7 0", "1 1\n1 2\n1 3\n2 1\n2 2\n2 3\n3 1\n3 2", "0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0", "1000000 1000000\n1000000 999999\n1000000 999998\n999999 1000000\n999999 999998\n999998 1000000\n999998 999999\n999998 999998", "0 0\n1 0\n0...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
36
codeforces
bd184280a9f5454d5dab9c2732b3319e
Login Verification
When registering in a social network, users are allowed to create their own convenient login to make it easier to share contacts, print it on business cards, etc. Login is an arbitrary sequence of lower and uppercase latin letters, digits and underline symbols («_»). However, in order to decrease the number of frauds ...
{"inputs": ["1_wat\n2\n2_wat\nwat_1", "000\n3\n00\nooA\noOo", "_i_\n3\n__i_\n_1_\nI", "La0\n3\n2a0\nLa1\n1a0", "abc\n1\naBc", "0Lil\n2\nLIL0\n0Ril", "iloO\n3\niIl0\noIl0\nIooO", "L1il0o1L1\n5\niLLoLL\noOI1Io10il\nIoLLoO\nO01ilOoI\nI10l0o", "ELioO1lOoOIOiLoooi1iolul1O\n7\nOoEIuOIl1ui1010uiooOoi0Oio001L0EoEolO0\nOLIoOEuo...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
193
codeforces
bd2451122914e33f4f8c5309b0ce78a4
Ralph And His Magic Field
Ralph has a magic field which is divided into *n*<=×<=*m* blocks. That is to say, there are *n* rows and *m* columns on the field. Ralph can put an integer in each block. However, the magic field doesn't always work properly. It works only if the product of integers in each row and each column equals to *k*, where *k* ...
{"inputs": ["1 1 -1", "1 3 1", "3 3 -1", "2 7 1", "1 1 1", "2 4 -1", "173 69 -1", "110 142 1", "162 162 -1", "49 153 -1", "94 182 1", "106666666 233333333 1", "2 2 1", "146 34 -1", "94 86 -1", "2529756051797760 2682355969139391 -1", "3126690179932000 2474382898739836 -1", "3551499873841921 2512677762780671 -1", "361345...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
18
codeforces
bd3cadf754cab70e6a2d233db4f043b8
Educational Game
The Smart Beaver from ABBYY began to develop a new educational game for children. The rules of the game are fairly simple and are described below. The playing field is a sequence of *n* non-negative integers *a**i* numbered from 1 to *n*. The goal of the game is to make numbers *a*1,<=*a*2,<=...,<=*a**k* (i.e. some pr...
{"inputs": ["4\n1 0 1 2", "8\n1 2 3 4 5 6 7 8", "5\n4 1 4 7 6", "9\n13 13 7 11 3 9 3 5 5", "30\n8 17 20 15 18 15 20 10 5 13 5 4 15 9 11 14 18 15 7 16 18 9 17 7 10 9 5 13 17 16", "80\n72 66 82 46 44 22 63 92 71 65 5 30 45 84 29 73 9 90 25 19 26 15 12 29 33 19 85 92 91 66 83 39 100 53 20 99 11 81 26 41 36 51 21 72 28 100...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
76
codeforces
bd4762d12fc7e77b0c0d4de102cb8527
Toy Cars
Little Susie, thanks to her older brother, likes to play with cars. Today she decided to set up a tournament between them. The process of a tournament is described in the next paragraph. There are *n* toy cars. Each pair collides. The result of a collision can be one of the following: no car turned over, one car turne...
{"inputs": ["3\n-1 0 0\n0 -1 1\n0 2 -1", "4\n-1 3 3 3\n3 -1 3 3\n3 3 -1 3\n3 3 3 -1", "1\n-1", "2\n-1 0\n0 -1", "2\n-1 1\n2 -1", "2\n-1 2\n1 -1", "2\n-1 3\n3 -1"], "outputs": ["2\n1 3 ", "0", "1\n1 ", "2\n1 2 ", "1\n2 ", "1\n1 ", "0"]}
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
18
codeforces
bd5208069eb280e2184f0cb0354c9f46
Roman Digits
Let's introduce a number system which is based on a roman digits. There are digits I, V, X, L which correspond to the numbers $1$, $5$, $10$ and $50$ respectively. The use of other roman digits is not allowed. Numbers in this system are written as a sequence of one or more digits. We define the value of the sequence s...
{"inputs": ["1", "2", "10", "1000", "2000", "5000", "10000", "111199", "101232812", "1000000000", "3", "4", "5", "6", "7", "8", "9", "11", "12", "13", "55", "100", "150", "1200", "9999999", "100000000", "500000000", "600000000", "709000900", "999999999", "12", "10", "20", "35", "56", "83", "116", "155", "198", "244", "...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
61
codeforces
bd719ab213ef0b26f27fe550275da0a6
Bishwock
Bishwock is a chess figure that consists of three squares resembling an "L-bar". This figure can be rotated by 90, 180 and 270 degrees so it can have four possible states: Bishwocks don't attack any squares and can even occupy on the adjacent squares as long as they don't occupy the same square. Vasya has a board wi...
{"inputs": ["00\n00", "00X00X0XXX0\n0XXX0X00X00", "0X0X0\n0X0X0", "0XXX0\n00000", "0\n0", "0\nX", "X\n0", "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\nXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", "0000X0X...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
64
codeforces
bd87b63d0f16726a4b3413a926b48787
Colliders
By 2312 there were *n* Large Hadron Colliders in the inhabited part of the universe. Each of them corresponded to a single natural number from 1 to *n*. However, scientists did not know what activating several colliders simultaneously could cause, so the colliders were deactivated. In 2312 there was a startling discov...
{"inputs": ["10 10\n+ 6\n+ 10\n+ 5\n- 10\n- 5\n- 6\n+ 10\n+ 3\n+ 6\n+ 3", "7 5\n+ 7\n+ 6\n+ 4\n+ 3\n- 7", "10 5\n+ 2\n- 8\n- 4\n- 10\n+ 1", "10 10\n+ 1\n+ 10\n- 1\n- 10\n+ 1\n- 1\n+ 7\n+ 8\n+ 6\n- 7", "15 15\n+ 12\n+ 6\n+ 13\n- 13\n+ 7\n+ 14\n+ 8\n+ 13\n- 13\n+ 15\n+ 4\n+ 10\n+ 11\n+ 2\n- 14", "2 20\n+ 1\n+ 2\n- 2\n+ 2...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
15
codeforces
bd93876715337bec98a7dcf52670749a
Selection of Personnel
One company of IT City decided to create a group of innovative developments consisting from 5 to 7 people and hire new employees for it. After placing an advertisment the company received *n* resumes. Now the HR department has to evaluate each possible group composition and select one of them. Your task is to count the...
{"inputs": ["7", "8", "9", "10", "321", "624", "666", "700", "776", "777"], "outputs": ["29", "92", "246", "582", "66715035255088", "7147161340917624", "11292070960994226", "16017044425409540", "33019955679376860", "33319741730082870"]}
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
22
codeforces
bd9edbfd06ea3a9c193aa506376798d5
Queue at the School
During the break the schoolchildren, boys and girls, formed a queue of *n* people in the canteen. Initially the children stood in the order they entered the canteen. However, after a while the boys started feeling awkward for standing in front of the girls in the queue and they started letting the girls move forward ea...
{"inputs": ["5 1\nBGGBG", "5 2\nBGGBG", "4 1\nGGGB", "2 1\nBB", "2 1\nBG", "6 2\nBBGBBG", "8 3\nBBGBGBGB", "10 3\nBBGBBBBBBG", "22 7\nGBGGBGGGGGBBBGGBGBGBBB", "50 4\nGBBGBBBGGGGGBBGGBBBBGGGBBBGBBBGGBGGBGBBBGGBGGBGGBG", "50 8\nGGGGBGGBGGGBGBBBGGGGGGGGBBGBGBGBBGGBGGBGGGGGGGGBBG", "50 30\nBGGGGGGBGGBGBGGGGBGBBGBBBGGBBBGBG...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
274
codeforces
bda0355b3e14ac689c64b4f8e787b398
Fedor and Essay
After you had helped Fedor to find friends in the «Call of Soldiers 3» game, he stopped studying completely. Today, the English teacher told him to prepare an essay. Fedor didn't want to prepare the essay, so he asked Alex for help. Alex came to help and wrote the essay for Fedor. But Fedor didn't like the essay at all...
{"inputs": ["3\nAbRb r Zz\n4\nxR abRb\naA xr\nzz Z\nxr y", "2\nRuruRu fedya\n1\nruruRU fedor", "1\nffff\n1\nffff r", "2\nYURA YUrA\n1\nyura fedya", "5\nhello my name is fedya\n2\nhello hi\nis i", "5\nawiuegjsrkjshegkjshegseg g soeigjseg www s\n3\nwww s\nawiuegjsrkjshegkjshegseg wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
4
codeforces
bdb9dc8c6e0599d351c32f5631a32ceb
Igor and his way to work
Woken up by the alarm clock Igor the financial analyst hurried up to the work. He ate his breakfast and sat in his car. Sadly, when he opened his GPS navigator, he found that some of the roads in Bankopolis, the city where he lives, are closed due to road works. Moreover, Igor has some problems with the steering wheel,...
{"inputs": ["5 5\nS....\n****.\n.....\n.****\n..T..", "1 2\nST", "3 1\nS\n*\nT", "3 3\n*..\n...\nTS.", "3 3\nT.*\n*.*\n*S*", "7 7\n.S.****\n...*.*.\n.****..\n.*.**.*\n..T*...\n***..*.\n*******", "3 3\n**T\n*S*\n***", "2 2\nST\n*.", "2 2\nS.\n.T", "2 2\nTS\n.*", "2 2\n.T\nS*"], "outputs": ["NO", "YES", "NO", "YES", "YES...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
16
codeforces
bdbd3d0e9509abf077169578711b6d9d
Cookies
Olga came to visit the twins Anna and Maria and saw that they have many cookies. The cookies are distributed into bags. As there are many cookies, Olga decided that it's no big deal if she steals a bag. However, she doesn't want the sisters to quarrel because of nothing when they divide the cookies. That's why Olga wan...
{"inputs": ["1\n1", "10\n1 2 2 3 4 4 4 2 2 2", "11\n2 2 2 2 2 2 2 2 2 2 99", "2\n1 1", "2\n2 2", "2\n1 2", "7\n7 7 7 7 7 7 7", "8\n1 2 3 4 5 6 7 8", "100\n1 1 1 1 1 2 2 2 2 2 1 1 1 1 1 2 2 2 2 2 1 1 1 1 1 2 2 2 2 2 1 1 1 1 1 2 2 2 2 2 1 1 1 1 1 2 2 2 2 2 1 1 1 1 1 2 2 2 2 2 1 1 1 1 1 2 2 2 2 2 1 1 1 1 1 2 2 2 2 2 1 1 1...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
729
codeforces
bdc6c256029b80385a04823c5aed31f5
Stages
Natasha is going to fly to Mars. She needs to build a rocket, which consists of several stages in some order. Each of the stages is defined by a lowercase Latin letter. This way, the rocket can be described by the string — concatenation of letters, which correspond to the stages. There are $n$ stages available. The ro...
{"inputs": ["5 3\nxyabd", "7 4\nproblem", "2 2\nab", "12 1\nabaabbaaabbb", "50 13\nqwertyuiopasdfghjklzxcvbnmaaaaaaaaaaaaaaaaaaaaaaaa", "50 14\nqwertyuiopasdfghjklzxcvbnmaaaaaaaaaaaaaaaaaaaaaaaa", "1 1\na", "50 1\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "50 2\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
213
codeforces
bdccebbc59ea21c3a871ae1558ed6845
The Sum of the k-th Powers
There are well-known formulas: , , . Also mathematicians found similar formulas for higher degrees. Find the value of the sum modulo 109<=+<=7 (so you should find the remainder after dividing the answer by the value 109<=+<=7). The only line contains two integers *n*,<=*k* (1<=≤<=*n*<=≤<=109,<=0<=≤<=*k*<=≤<=106). Pri...
{"inputs": ["4 1", "4 2", "4 3", "4 0", "10 0", "1 1", "1 0", "1 1000000", "1000000000 0", "100 100", "10000 100", "100 10000", "1000000000 1000000", "1000000 1000000", "999999 1000000", "77674473 447444", "333312494 795258", "761637147 673329", "335185991 514401", "203702132 355473", "1000000000 999935"], "outputs": [...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
5
codeforces
bdd1384c3c4e5c12f47e15657aa8931f
Square and Rectangles
You are given *n* rectangles. The corners of rectangles have integer coordinates and their edges are parallel to the *Ox* and *Oy* axes. The rectangles may touch each other, but they do not overlap (that is, there are no points that belong to the interior of more than one rectangle). Your task is to determine if the ...
{"inputs": ["5\n0 0 2 3\n0 3 3 5\n2 0 5 2\n3 2 5 5\n2 2 3 3", "4\n0 0 2 3\n0 3 3 5\n2 0 5 2\n3 2 5 5", "5\n0 0 10000 20000\n10000 0 15000 19999\n10000 19999 14999 20000\n0 20000 15000 31400\n15000 0 31400 31400", "5\n0 0 10000 20000\n10000 0 15000 19999\n10000 19999 15000 20000\n0 20000 15000 31400\n15000 0 31400 31400...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
10
codeforces
bde75bac39cbfe4af0d371bb6c7c6336
Encryption (easy)
Rebel spy Heidi has just obtained the plans for the Death Star from the Empire and, now on her way to safety, she is trying to break the encryption of the plans (of course they are encrypted – the Empire may be evil, but it is not stupid!). The encryption has several levels of security, and here is how the first one lo...
{"inputs": ["4 10\n3 4 7 2", "10 12\n16 3 24 13 9 8 7 5 12 12", "2 2\n9 9", "2 2\n8 8", "5 50\n1 1 1 1 1", "5 50\n100 150 200 100 50"], "outputs": ["16", "13", "2", "0", "5", "0"]}
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
52
codeforces
bdfe2b1e3fe543e13b9b8077113d91f6
Oleg and shares
Oleg the bank client checks share prices every day. There are *n* share prices he is interested in. Today he observed that each second exactly one of these prices decreases by *k* rubles (note that each second exactly one price changes, but at different seconds different prices can change). Prices can become negative. ...
{"inputs": ["3 3\n12 9 15", "2 2\n10 9", "4 1\n1 1000000000 1000000000 1000000000", "1 11\n123", "20 6\n38 86 86 50 98 62 32 2 14 62 98 50 2 50 32 38 62 62 8 14", "20 5\n59 54 19 88 55 100 54 3 6 13 99 38 36 71 59 6 64 85 45 54", "100 10\n340 70 440 330 130 120 340 210 440 110 410 120 180 40 50 230 70 110 310 360 480 7...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
171
codeforces
be28a9f0e51e26043794e8ef4aac3703
Work Group
One Big Software Company has *n* employees numbered from 1 to *n*. The director is assigned number 1. Every employee of the company except the director has exactly one immediate superior. The director, of course, doesn't have a superior. We will call person *a* a subordinates of another person *b*, if either *b* is an...
{"inputs": ["7\n-1 3\n1 2\n1 1\n1 4\n4 5\n4 3\n5 2", "1\n-1 42", "2\n-1 3\n1 2", "3\n-1 3\n1 1\n1 2", "3\n-1 1\n1 2\n1 3", "3\n-1 3\n1 2\n2 1", "20\n-1 100\n1 10\n2 26\n2 33\n3 31\n2 28\n1 47\n6 18\n6 25\n9 2\n4 17\n6 18\n6 2\n6 30\n13 7\n5 25\n7 11\n11 7\n17 40\n12 43", "20\n-1 100\n1 35\n2 22\n3 28\n3 2\n4 8\n3 17\n2...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
codeforces
be357e1a04067eead63b9cf1cc2b9af5
Little Frog
Once upon a time a little frog whose name was Vasya decided to travel around his home swamp. Overall there are *n* mounds on the swamp, located on one line. The distance between the neighboring mounds is one meter. Vasya wants to visit all the mounds in one day; besides, he wants to visit each one exactly once. For tha...
{"inputs": ["2", "3", "4", "5", "6", "1", "9149", "2877", "2956", "3035", "3114", "3193", "3273", "7000", "7079", "4653", "9995", "9996", "9997", "9998", "9999", "10000"], "outputs": ["1 2 ", "1 3 2 ", "1 4 2 3 ", "1 5 2 4 3 ", "1 6 2 5 3 4 ", "1 ", "1 9149 2 9148 3 9147 4 9146 5 9145 6 9144 7 9143 8 9142 9 9141 10 914...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
123
codeforces
be67cd8ea92d99b084fd6081677642af
Tree of Life (easy)
Heidi has finally found the mythical Tree of Life – a legendary combinatorial structure which is said to contain a prophecy crucially needed to defeat the undead armies. On the surface, the Tree of Life is just a regular undirected tree well-known from computer science. This means that it is a collection of *n* points...
{"inputs": ["4\n1 2\n1 3\n1 4", "5\n1 2\n2 3\n3 4\n3 5", "2\n1 2", "3\n2 1\n3 2", "10\n5 1\n1 2\n9 3\n10 5\n6 3\n8 5\n2 7\n2 3\n9 4"], "outputs": ["3", "4", "0", "1", "11"]}
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
24
codeforces
be8d9759934859ff03c9d87c8f9ded2f
Friends
One day Igor K. stopped programming and took up math. One late autumn evening he was sitting at a table reading a book and thinking about something. The following statement caught his attention: "Among any six people there are either three pairwise acquainted people or three pairwise unacquainted people" Igor just c...
{"inputs": ["4\n1 3\n2 3\n1 4\n5 3", "5\n1 2\n2 3\n3 4\n4 5\n5 1", "1\n4 3", "6\n1 3\n2 3\n1 2\n5 3\n4 2\n4 5", "2\n1 3\n2 5", "3\n5 3\n4 3\n4 5", "5\n1 3\n3 2\n2 4\n5 4\n1 5", "7\n1 3\n5 1\n1 4\n2 1\n5 3\n4 5\n2 5", "5\n5 1\n4 1\n2 3\n4 5\n3 1", "0", "10\n1 2\n1 3\n1 4\n1 5\n2 3\n2 4\n2 5\n3 4\n3 5\n4 5", "4\n1 2\n2 3...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
65
codeforces
beb216e4c28803c082eec7de44f0dd98
none
Petya loves lucky numbers very much. Everybody knows that lucky numbers are positive integers whose decimal record contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Petya has two strings *a* and *b* of the same length *n*. The strings consist only of lucky digits...
{"inputs": ["47\n74", "774\n744", "777\n444", "74747474\n77777777", "444444444444\n777777777777", "4744744447774474447474774\n4477774777444444444777447", "7\n4", "4\n7", "7777777777\n7777777774", "47777777777\n77777777774", "47747477747744447774774444444777444747474747777774\n4477744477447744777744477447777747777444447...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
110
codeforces
bec9ea76bca8acdbb8400cd3fe1e396f
The Artful Expedient
Rock... Paper! After Karen have found the deterministic winning (losing?) strategy for rock-paper-scissors, her brother, Koyomi, comes up with a new game as a substitute. The game works as follows. A positive integer *n* is decided first. Both Koyomi and Karen independently choose *n* distinct positive integers, deno...
{"inputs": ["3\n1 2 3\n4 5 6", "5\n2 4 6 8 10\n9 7 5 3 1", "1\n1\n2000000", "2\n97153 2000000\n1999998 254", "15\n31 30 29 28 27 26 25 24 23 22 21 20 19 18 17\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15", "30\n79656 68607 871714 1858841 237684 1177337 532141 161161 1111201 527235 323345 1979059 665353 507265 1290761 610606 12...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
84
codeforces