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
f12339773992c002ec45b994955d599d
PolandBall and Gifts
It's Christmas time! PolandBall and his friends will be giving themselves gifts. There are *n* Balls overall. Each Ball has someone for whom he should bring a present according to some permutation *p*, *p**i*<=≠<=*i* for all *i*. Unfortunately, Balls are quite clumsy. We know earlier that exactly *k* of them will forg...
{"inputs": ["5 2\n3 4 1 5 2", "10 1\n2 3 4 5 6 7 8 9 10 1", "5 4\n3 1 4 5 2", "3 0\n2 3 1", "4 3\n2 3 4 1", "2 0\n2 1", "2 1\n2 1", "2 2\n2 1", "3 0\n2 3 1", "3 1\n2 3 1", "3 2\n2 3 1", "3 3\n2 3 1", "5 1\n2 3 4 5 1", "6 3\n2 3 1 5 6 4", "9 5\n3 4 5 2 7 8 1 9 6", "6 2\n4 5 6 2 1 3", "2 2\n2 1", "9 2\n8 6 7 5 2 3 1 9 4"...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
codeforces
f1358e5820183e8ec8f2e3b61ee5ef36
The number on the board
Some natural number was written on the board. Its sum of digits was not less than *k*. But you were distracted a bit, and someone changed this number to *n*, replacing some digits with others. It's known that the length of the number didn't change. You have to find the minimum number of digits in which these two numbe...
{"inputs": ["3\n11", "3\n99", "10\n5205602270", "70\n3326631213", "200\n1000000010000000000000000000010000000000000001000001000000000000000000000000000000000000000000000000", "500\n1899337170458531693764539600958943248270674811247191310452938511077656066239840703432499357537079035", "700\n930721675640459016214334490155...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
86
codeforces
f15218a1d52d8afdb6e5afd7f1b1934b
Spy Syndrome 2
After observing the results of Spy Syndrome, Yash realised the errors of his ways. He now believes that a super spy such as Siddhant can't use a cipher as basic and ancient as Caesar cipher. After many weeks of observation of Siddhant’s sentences, Yash determined a new cipher technique. For a given sentence, the ciphe...
{"inputs": ["30\nariksihsidlihcdnaehsetahgnisol\n10\nKira\nhates\nis\nhe\nlosing\ndeath\nchildish\nL\nand\nNote", "12\niherehtolleh\n5\nHI\nHo\nthere\nHeLLo\nhello", "71\nbaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n8\na\naa\naaa\naaaa\naaaaa\naaaaaa\naaaaaaa\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
2
codeforces
f16748607c785c0b98dd1acfb1db8b04
Two Seals
One very important person has a piece of paper in the form of a rectangle *a*<=×<=*b*. Also, he has *n* seals. Each seal leaves an impression on the paper in the form of a rectangle of the size *x**i*<=×<=*y**i*. Each impression must be parallel to the sides of the piece of paper (but seal can be rotated by 90 degrees...
{"inputs": ["2 2 2\n1 2\n2 1", "4 10 9\n2 3\n1 1\n5 10\n9 11", "3 10 10\n6 6\n7 7\n20 5", "2 1 1\n1 1\n1 1", "2 1 2\n1 1\n1 1", "2 100 100\n100 100\n1 1", "2 100 100\n50 100\n100 50", "2 100 100\n100 100\n87 72", "5 100 100\n100 100\n100 100\n100 100\n100 100\n100 100", "15 50 50\n9 36\n28 14\n77 74\n35 2\n20 32\n83 85...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
34
codeforces
f1713e8c1a645361ed6d91822ead2758
Depression
Do you remember a kind cartoon "Beauty and the Beast"? No, no, there was no firing from machine guns or radiation mutants time-travels! There was a beauty named Belle. Once she had violated the Beast's order and visited the West Wing. After that she was banished from the castle... Everybody was upset. The beautiful ...
{"inputs": ["12:00", "04:30", "08:17", "07:20", "09:55", "11:59", "01:23", "11:00", "00:00", "12:30", "23:59", "20:00", "23:45", "07:14", "15:15", "16:05", "19:55", "23:58", "14:33", "18:00", "00:24", "19:45", "20:05", "21:13", "08:04", "07:40", "19:12", "06:36", "06:16", "11:49", "18:45", "06:44", "20:45", "17:48", "0...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
36
codeforces
f19ce5e43cad559a41626683b26478cf
Indian Summer
Indian summer is such a beautiful time of the year! A girl named Alyona is walking in the forest and picking a bouquet from fallen leaves. Alyona is very choosy — she doesn't take a leaf if it matches the color and the species of the tree of one of the leaves she already has. Find out how many leaves Alyona has picked....
{"inputs": ["5\nbirch yellow\nmaple red\nbirch yellow\nmaple yellow\nmaple green", "3\noak yellow\noak yellow\noak yellow", "5\nxbnbkzn hp\nkaqkl vrgzbvqstu\nj aqidx\nhos gyul\nwefxmh tygpluae", "1\nqvwli hz", "4\nsrhk x\nsrhk x\nqfoe vnrjuab\nqfoe vnrjuab", "4\nsddqllmmpk syded\nfprsq fnenjnaz\nn hdej\nsddqllmmpk syde...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
623
codeforces
f1a35742b0a9a1e287eebb34373efa86
Longest k-Good Segment
The array *a* with *n* integers is given. Let's call the sequence of one or more consecutive elements in *a* segment. Also let's call the segment k-good if it contains no more than *k* different values. Find any longest k-good segment. As the input/output can reach huge size it is recommended to use fast input/output...
{"inputs": ["5 5\n1 2 3 4 5", "9 3\n6 5 1 2 3 2 1 4 5", "3 1\n1 2 3", "1 1\n747391", "5 2\n171230 171230 171230 171230 171230", "10 3\n512008 512008 452221 512008 314256 123232 314256 512008 314256 123232", "6 1\n1 1 2 1 1 1", "5 4\n1 2 3 4 0", "5 4\n2 3 4 5 0", "2 2\n0 1", "2 2\n0 0", "5 4\n1 2 3 45 0"], "outputs": ["...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
54
codeforces
f1cdb30715841ea0612c3bcf79aecec7
Wilbur and Swimming Pool
After making bad dives into swimming pools, Wilbur wants to build a swimming pool in the shape of a rectangle in his backyard. He has set up coordinate axes, and he wants the sides of the rectangle to be parallel to them. Of course, the area of the rectangle must be positive. Wilbur had all four vertices of the planned...
{"inputs": ["2\n0 0\n1 1", "1\n1 1", "1\n-188 17", "1\n71 -740", "4\n-56 -858\n-56 -174\n778 -858\n778 -174", "2\n14 153\n566 -13", "2\n-559 894\n314 127", "1\n-227 -825", "2\n-187 583\n25 13", "2\n-337 451\n32 -395", "4\n-64 -509\n-64 960\n634 -509\n634 960", "2\n-922 -505\n712 -683", "2\n-1000 -1000\n-1000 0", "2\n-1...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
130
codeforces
f1e893d735a5a95becb2ba80e08851fe
Matchmaker
Polycarpus has *n* markers and *m* marker caps. Each marker is described by two numbers: *x**i* is the color and *y**i* is the diameter. Correspondingly, each cap is described by two numbers: *a**j* is the color and *b**j* is the diameter. Cap (*a**j*,<=*b**j*) can close marker (*x**i*,<=*y**i*) only if their diameters...
{"inputs": ["3 4\n1 2\n3 4\n2 4\n5 4\n2 4\n1 1\n1 2", "2 2\n1 2\n2 1\n3 4\n5 1", "6 7\n2 1\n2 2\n2 1\n1 1\n2 1\n1 2\n2 2\n2 2\n2 2\n1 2\n2 2\n1 1\n1 2", "6 7\n2 1\n1 1\n2 2\n1 2\n1 1\n1 2\n2 1\n1 1\n1 1\n1 1\n1 2\n2 2\n1 1", "6 7\n2 1\n2 2\n1 1\n1 2\n2 2\n1 2\n1 2\n1 1\n1 2\n2 2\n2 2\n2 2\n1 1", "6 7\n1 1\n1 1\n1 2\n1 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
21
codeforces
f1f9f715455d8c3f24e570cb59b1a3cb
Rats
Rats have bred to hundreds and hundreds in the basement of the store, owned by Vasily Petrovich. Vasily Petrovich may have not noticed their presence, but they got into the habit of sneaking into the warehouse and stealing food from there. Vasily Petrovich cannot put up with it anymore, he has to destroy the rats in th...
{"inputs": ["4 4 1\nXXXX\nXR.X\nX.RX\nXXXX", "9 14 5\nXXXXXXXXXXXXXX\nX....R...R...X\nX..R.........X\nX....RXR..R..X\nX..R...X.....X\nXR.R...X.....X\nX....XXR.....X\nX....R..R.R..X\nXXXXXXXXXXXXXX", "7 7 1\nXXXXXXX\nX.R.R.X\nX.....X\nX..X..X\nX..R..X\nX....RX\nXXXXXXX", "7 7 2\nXXXXXXX\nX.....X\nXRXR..X\nX.....X\nXR......
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
codeforces
f1facf569ffcf5bc4df80b22352296b4
Xor-Paths
There is a rectangular grid of size $n \times m$. Each cell has a number written on it; the number on the cell ($i, j$) is $a_{i, j}$. Your task is to calculate the number of paths from the upper-left cell ($1, 1$) to the bottom-right cell ($n, m$) meeting the following constraints: - You can move to the right or to ...
{"inputs": ["3 3 11\n2 1 5\n7 10 0\n12 6 4", "3 4 2\n1 3 3 3\n0 3 3 2\n3 0 1 1", "3 4 1000000000000000000\n1 3 3 3\n0 3 3 2\n3 0 1 1", "1 1 1000000000000000000\n1000000000000000000", "1 1 1000000000000000000\n999999999999999999", "1 1 1\n1", "1 2 3\n1 2", "1 10 1023\n1 2 4 8 16 32 64 128 256 512", "1 20 1048575\n1 2 4 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
9
codeforces
f206f390408b8469f5ead1d5a0d4ef6f
Ilya And The Tree
Ilya is very fond of graphs, especially trees. During his last trip to the forest Ilya found a very interesting tree rooted at vertex 1. There is an integer number written on each vertex of the tree; the number written on vertex *i* is equal to *a**i*. Ilya believes that the beauty of the vertex *x* is the greatest co...
{"inputs": ["2\n6 2\n1 2", "3\n6 2 3\n1 2\n1 3", "1\n10", "10\n2 3 4 5 6 7 8 9 10 11\n1 2\n2 3\n3 4\n4 5\n5 6\n6 7\n4 8\n8 9\n9 10", "4\n6 2 3 2\n1 2\n2 3\n3 4"], "outputs": ["6 6 ", "6 6 6 ", "10 ", "2 3 2 1 1 1 1 1 1 1 ", "6 6 3 2 "]}
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
codeforces
f20f51e123ce54994ea16251d4a30538
Hexadecimal's theorem
Recently, a chaotic virus Hexadecimal advanced a new theorem which will shake the Universe. She thinks that each Fibonacci number can be represented as sum of three not necessary different Fibonacci numbers. Let's remember how Fibonacci numbers can be calculated. *F*0<==<=0, *F*1<==<=1, and all the next numbers are *F...
{"inputs": ["3", "13", "0", "1", "2", "1597", "0", "1", "1", "2", "3", "5", "8", "13", "21", "34", "55", "89", "144", "233", "377", "610", "987", "1597", "2584", "4181", "6765", "10946", "17711", "28657", "46368", "75025", "121393", "196418", "317811", "514229", "832040", "1346269", "2178309", "3524578", "5702887", "92...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
437
codeforces
f23516b21bb43236372be770896daf03
Martian Clock
Having stayed home alone, Petya decided to watch forbidden films on the Net in secret. "What ungentlemanly behavior!" — you can say that, of course, but don't be too harsh on the kid. In his country films about the Martians and other extraterrestrial civilizations are forbidden. It was very unfair to Petya as he adored...
{"inputs": ["11:20", "2A:13", "000B:00001", "00000:00000", "70:00", "00:21", "02:130", "123:A", "N8HYJ:042JW", "N:7", "00000:00021", "00002:00130", "00394:00321", "0000P:0000E", "0000F:0002G", "0000N:00007", "000G6:000GD", "000B3:00098", "100:0101", "00101:0101", "00001:00001", "00A:00A", "10101:000", "0010:00000", "00...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
4
codeforces
f2643261d115329182a78ea3b0e7a79f
none
Родители Васи хотят, чтобы он как можно лучше учился. Поэтому если он получает подряд три положительные оценки («четвёрки» или «пятёрки»), они дарят ему подарок. Соответственно, оценки «единица», «двойка» и «тройка» родители Васи считают плохими. Когда Вася получает подряд три хорошие оценки, ему сразу вручают подарок,...
{"inputs": ["6\n4 5 4 5 4 4", "14\n1 5 4 5 2 4 4 5 5 4 3 4 5 5", "3\n4 5 4", "3\n4 5 1", "4\n5 4 3 5", "10\n4 4 5 4 4 5 5 5 4 4", "20\n5 5 5 4 5 4 5 5 5 5 5 4 4 5 3 4 4 4 5 4", "30\n4 4 5 5 5 4 5 5 4 5 4 4 5 4 4 4 5 4 4 4 5 5 5 5 4 5 5 5 4 4", "40\n5 4 4 5 5 5 1 5 4 4 4 4 4 2 4 4 4 4 4 4 5 4 4 4 5 5 3 4 4 5 5 5 4 4 4 4...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
22
codeforces
f26fc951cce2e4c8216142310433c9ea
Coder
Iahub likes chess very much. He even invented a new chess piece named Coder. A Coder can move (and attack) one square horizontally or vertically. More precisely, if the Coder is located at position (*x*,<=*y*), he can move to (or attack) positions (*x*<=+<=1,<=*y*), (*x*–1,<=*y*), (*x*,<=*y*<=+<=1) and (*x*,<=*y*–1). ...
{"inputs": ["2", "3", "4", "10", "15", "100", "101", "500", "501", "755", "888", "998", "999", "1000", "1"], "outputs": ["2\nC.\n.C", "5\nC.C\n.C.\nC.C", "8\nC.C.\n.C.C\nC.C.\n.C.C", "50\nC.C.C.C.C.\n.C.C.C.C.C\nC.C.C.C.C.\n.C.C.C.C.C\nC.C.C.C.C.\n.C.C.C.C.C\nC.C.C.C.C.\n.C.C.C.C.C\nC.C.C.C.C.\n.C.C.C.C.C", "113\nC.C.C...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
297
codeforces
f28494b1bb4a51fe0632070103000036
Restoring Numbers
Vasya had two arrays consisting of non-negative integers: *a* of size *n* and *b* of size *m*. Vasya chose a positive integer *k* and created an *n*<=×<=*m* matrix *v* using the following formula: Vasya wrote down matrix *v* on a piece of paper and put it in the table. A year later Vasya was cleaning his table when h...
{"inputs": ["2 3\n1 2 3\n2 3 4", "2 2\n1 2\n2 0", "2 2\n1 2\n2 1", "2 2\n2 3\n1 2", "2 2\n2 0\n1 2", "2 2\n2 1\n0 2", "2 2\n0 2\n2 1", "2 3\n1 3 3\n3 0 1", "3 2\n1 3\n3 0\n3 1", "2 3\n3 0 1\n1 3 3", "3 2\n3 0\n3 1\n1 3", "3 2\n3 1\n3 0\n1 3", "3 2\n3 0\n1 3\n3 1", "2 2\n0 1000000000\n1000000000 0", "2 2\n0 1000000000\n...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
2
codeforces
f2b5de567aac6e94f6ed4a324fabb0a8
Cup Trick
The employees of the F company have lots of ways to entertain themselves. Today they invited a famous magician who shows a trick with plastic cups and a marble. The point is to trick the spectator's attention. Initially, the spectator stands in front of a line of *n* plastic cups. Then the magician places a small marb...
{"inputs": ["2 1\n2 1", "3 2\n1 2\n1 1", "3 3\n1 3\n2 3\n1 3", "3 2\n1 1\n3 2", "5 2\n3 3\n3 1", "5 3\n3 1\n4 3\n5 4", "7 3\n4 4\n5 4\n2 4", "10 3\n7 10\n8 7\n5 5", "100 50\n11 28\n11 1\n98 58\n38 27\n24 27\n67 37\n90 48\n91 14\n43 29\n3 64\n24 6\n53 19\n97 65\n13 27\n75 53\n37 82\n69 75\n94 99\n1 26\n95 60\n45 27\n100...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
codeforces
f2bde5c509c9733a406a6e0eff989a26
Mr. Kitayuta's Colorful Graph
Mr. Kitayuta has just bought an undirected graph consisting of *n* vertices and *m* edges. The vertices of the graph are numbered from 1 to *n*. Each edge, namely edge *i*, has a color *c**i*, connecting vertex *a**i* and *b**i*. Mr. Kitayuta wants you to process the following *q* queries. In the *i*-th query, he giv...
{"inputs": ["4 5\n1 2 1\n1 2 2\n2 3 1\n2 3 3\n2 4 3\n3\n1 2\n3 4\n1 4", "5 7\n1 5 1\n2 5 1\n3 5 1\n4 5 1\n1 2 2\n2 3 2\n3 4 2\n5\n1 5\n5 1\n2 5\n1 5\n1 4", "2 1\n1 2 1\n1\n1 2", "2 3\n1 2 3\n1 2 2\n1 2 1\n1\n1 2", "2 5\n1 2 1\n1 2 2\n1 2 3\n1 2 4\n1 2 5\n1\n1 2"], "outputs": ["2\n1\n0", "1\n1\n1\n1\n2", "1", "3", "5"]}
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
125
codeforces
f2d46ff61caf83aa5c9d524ad3d861b9
Terse princess
«Next please», — the princess called and cast an estimating glance at the next groom. The princess intends to choose the most worthy groom, this is, the richest one. Whenever she sees a groom who is more rich than each of the previous ones, she says a measured «Oh...». Whenever the groom is richer than all previous on...
{"inputs": ["10 2 3", "5 0 0", "5 2 2", "6 2 2", "10 9 0", "1 0 0", "10 0 9", "42 10 13", "7 3 3", "12 0 0", "19 1 0", "17 2 3", "7 3 1", "19 3 1", "10 4 4", "11 5 4", "8 0 2", "19 5 1", "100 9 0", "2 0 1", "2 1 0", "3 0 2", "3 1 1", "3 2 0", "4 0 0", "4 0 1", "4 0 2", "4 0 3", "4 1 0", "4 2 0", "4 3 0", "4 1 1", "4 1 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
codeforces
f2de2e39564f4a23db850d2627d473bd
Friends and Subsequences
Mike and !Mike are old childhood rivals, they are opposite in everything they do, except programming. Today they have a problem they cannot solve on their own, but together (with you) — who knows? Every one of them has an integer sequences *a* and *b* of length *n*. Being given a query of the form of pair of integers...
{"inputs": ["6\n1 2 3 2 1 4\n6 7 1 2 3 2", "3\n3 3 3\n1 1 1", "17\n714413739 -959271262 714413739 -745891378 926207665 -404845105 -404845105 -959271262 -189641729 -670860364 714413739 -189641729 192457837 -745891378 -670860364 536388097 -959271262\n-417715348 -959271262 -959271262 714413739 -189641729 571055593 5710555...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
2
codeforces
f2f920d63727a5da8738e73b9c49da84
Psychos in a Line
There are *n* psychos standing in a line. Each psycho is assigned a unique integer from 1 to *n*. At each step every psycho who has an id greater than the psycho to his right (if exists) kills his right neighbor in the line. Note that a psycho might kill and get killed at the same step. You're given the initial arran...
{"inputs": ["10\n10 9 7 8 6 5 3 4 2 1", "6\n1 2 3 4 5 6", "6\n6 5 4 3 2 1", "10\n10 7 4 2 5 8 9 6 3 1", "15\n15 9 5 10 7 11 14 6 2 3 12 1 8 13 4", "100\n61 96 25 10 50 71 38 77 76 75 59 100 89 66 6 99 2 13 3 23 91 93 22 92 4 86 90 44 39 31 9 47 28 95 18 54 1 73 94 78 60 20 42 84 97 83 16 81 67 64 74 46 82 5 88 80 14 48...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
10
codeforces
f30a23a3a1dd6e38a255a088067f20fc
Chess Placing
You are given a chessboard of size 1<=×<=*n*. It is guaranteed that *n* is even. The chessboard is painted like this: "BWBW...BW". Some cells of the board are occupied by the chess pieces. Each cell contains no more than one chess piece. It is known that the total number of pieces equals to . In one step you can move...
{"inputs": ["6\n1 2 6", "10\n1 2 3 4 5", "2\n2", "100\n2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40 42 44 46 48 50 52 54 56 58 60 62 64 66 68 70 72 74 76 78 80 82 84 86 88 90 92 94 96 98 100", "100\n93 54 57 61 68 66 70 96 64 82 80 75 69 77 76 94 67 86 90 73 74 58 100 83 92 89 56 99 88 59 95 72 81 51 85 71 9...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
94
codeforces
f33131958c663e5a2ee1b0463cbe2016
Bus
A bus moves along the coordinate line *Ox* from the point *x*<==<=0 to the point *x*<==<=*a*. After starting from the point *x*<==<=0, it reaches the point *x*<==<=*a*, immediately turns back and then moves to the point *x*<==<=0. After returning to the point *x*<==<=0 it immediately goes back to the point *x*<==<=*a* ...
{"inputs": ["6 9 2 4", "6 10 2 4", "6 5 4 3", "2 2 1 1", "10 4 6 10", "3 1 1 1", "2 1 1 1", "1000000 51923215 2302 10000", "10 11 3 2", "20 50 10 25", "10 10 5 20", "15 65 5 50", "10 19 1 5", "10 19 9 5", "23 46 12 2", "23 46 12 3", "20 20 19 1", "20 23 17 2", "100 70 50 1", "100 70 70 2", "140 480 139 40", "1000000 10...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
31
codeforces
f353ac7a2ae46c10fac90cbe25b2a7fb
Second price auction
Nowadays, most of the internet advertisements are not statically linked to a web page. Instead, what will be shown to the person opening a web page is determined within 100 milliseconds after the web page is opened. Usually, multiple companies compete for each ad slot on the web page in an auction. Each of them receive...
{"inputs": ["3\n4 7\n8 10\n5 5", "3\n2 5\n3 4\n1 6", "5\n1 10000\n1 10000\n1 10000\n1 10000\n1 10000", "2\n1 2\n1 2", "2\n1 3\n1 3", "5\n1 7\n2 5\n3 9\n4 8\n5 6", "5\n17 9999\n19 9992\n1 10000\n6 9\n34 99", "5\n3778 9170\n2657 6649\n4038 9722\n3392 7255\n4890 8961", "5\n2194 6947\n2062 8247\n4481 8430\n3864 9409\n3784 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
7
codeforces
f35e9fe9adbb9f6f5fa5aa441e337afe
Ants on a Circle
*n* ants are on a circle of length *m*. An ant travels one unit of distance per one unit of time. Initially, the ant number *i* is located at the position *s**i* and is facing in the direction *d**i* (which is either L or R). Positions are numbered in counterclockwise order starting from some point. Positions of the al...
{"inputs": ["2 4 8\n1 R\n3 L", "4 8 6\n6 R\n5 L\n1 R\n8 L", "4 8 2\n1 R\n5 L\n6 L\n8 R", "10 10 90\n2 R\n1 R\n3 L\n4 R\n7 L\n8 L\n6 R\n9 R\n5 R\n10 L", "10 20 85\n6 L\n12 R\n2 L\n20 R\n18 L\n8 R\n16 R\n14 L\n10 L\n4 R", "10 20 59\n1 R\n15 L\n7 L\n13 R\n5 R\n17 R\n3 L\n9 R\n11 L\n19 L", "2 2 0\n2 L\n1 R", "2 2 0\n2 L\n1...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
3
codeforces
f364ca2a099e8d455d001a8fa0bf3be0
Martian Food
Have you ever tasted Martian food? Well, you should. Their signature dish is served on a completely black plate with the radius of *R*, flat as a pancake. First, they put a perfectly circular portion of the Golden Honduras on the plate. It has the radius of *r* and is located as close to the edge of the plate as poss...
{"inputs": ["2\n4 3 1\n4 2 2", "1\n4 2 2", "1\n7 2 1", "1\n8 7 2", "1\n2 1 1", "1\n1000 999 2", "1\n1000 1 2", "1\n1000 998 1000", "1\n1000 1 1000", "1\n1000 500 123", "1\n1000 999 1", "1\n1000 1 1"], "outputs": ["0.9230769231\n0.6666666667", "0.6666666667", "1.7948717949", "0.9333333333", "0.6666666667", "0.9999959960...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
4
codeforces
f391d73d45dd1d927cf8e993cb4dccc5
Balls and Boxes
Little Vasya had *n* boxes with balls in the room. The boxes stood in a row and were numbered with numbers from 1 to *n* from left to right. Once Vasya chose one of the boxes, let's assume that its number is *i*, took all balls out from it (it is guaranteed that this box originally had at least one ball), and began pu...
{"inputs": ["4 4\n4 3 1 6", "5 2\n3 2 0 2 7", "3 3\n2 3 1", "10 3\n1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000", "5 4\n0 554459682 978416312 784688178 954779973", "5 2\n1 554459683 978416312 784688178 954779974", "10 8\n994538714 617271264 168716105 9159...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
17
codeforces
f3a1a7fd9526cd12c40b83d70cf25ffd
On Sum of Fractions
Let's assume that - *v*(*n*) is the largest prime number, that does not exceed *n*;- *u*(*n*) is the smallest prime number strictly greater than *n*. Find . The first line contains integer *t* (1<=≤<=*t*<=≤<=500) — the number of testscases. Each of the following *t* lines of the input contains integer *n* (2<=≤<...
{"inputs": ["2\n2\n3", "1\n1000000000", "5\n3\n6\n9\n10\n5", "5\n5\n8\n18\n17\n17", "5\n7\n40\n37\n25\n4", "5\n72\n72\n30\n75\n11", "5\n79\n149\n136\n194\n124", "6\n885\n419\n821\n635\n63\n480", "1\n649580447"], "outputs": ["1/6\n7/30", "999999941999999673/1999999887999999118", "7/30\n5/14\n61/154\n9/22\n23/70", "23/70...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
3
codeforces
f3be2edd00eefa041c20c29eb293b913
Panoramix's Prediction
A prime number is a number which has exactly two distinct divisors: one and itself. For example, numbers 2, 7, 3 are prime, and 1, 6, 4 are not. The next prime number after *x* is the smallest prime number greater than *x*. For example, the next prime number after 2 is 3, and the next prime number after 3 is 5. Note t...
{"inputs": ["3 5", "7 11", "7 9", "2 3", "2 4", "3 4", "3 5", "5 7", "7 11", "11 13", "13 17", "17 19", "19 23", "23 29", "29 31", "31 37", "37 41", "41 43", "43 47", "2 5", "2 7", "2 6", "2 11", "3 6", "3 7", "3 9", "5 6", "5 9", "5 11", "5 13", "5 15", "7 8", "7 13", "13 15", "13 17", "19 21", "13 20", "41 49", "43 4...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
706
codeforces
f3befb56bb448c975b4759d7d190e4cb
Counting-out Rhyme
*n* children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to *n*. In the beginning, the first child is considered the leader. The game is played in *k* steps. In the *i*-th step the leader counts out *a**i* people in clockwise order, starting from the next person. T...
{"inputs": ["7 5\n10 4 11 4 1", "3 2\n2 5", "2 1\n1", "2 1\n2", "2 1\n3", "10 7\n5 10 4 3 8 10 6", "10 8\n12 6 12 15 20 8 17 12", "12 10\n76 58 82 54 97 46 17 40 36 15", "12 6\n76 61 94 15 66 26", "90 10\n1045 8705 6077 3282 1459 9809 383 6206 2674 7274", "100 30\n601771 913885 829106 91674 465657 367068 142461 873149 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
129
codeforces
f3d62dd60c00cd2fd042a33e2c83f89b
Asphalting Roads
City X consists of *n* vertical and *n* horizontal infinite roads, forming *n*<=×<=*n* intersections. Roads (both vertical and horizontal) are numbered from 1 to *n*, and the intersections are indicated by the numbers of the roads that form them. Sand roads have long been recognized out of date, so the decision was ma...
{"inputs": ["2\n1 1\n1 2\n2 1\n2 2", "1\n1 1", "2\n1 1\n2 2\n1 2\n2 1", "2\n1 2\n2 2\n2 1\n1 1", "3\n2 2\n1 2\n3 2\n3 3\n1 1\n2 3\n1 3\n3 1\n2 1", "3\n1 3\n3 1\n2 1\n1 1\n1 2\n2 2\n3 2\n3 3\n2 3", "4\n1 3\n2 3\n2 4\n4 4\n3 1\n1 1\n3 4\n2 1\n1 4\n4 3\n4 1\n3 2\n1 2\n4 2\n2 2\n3 3", "4\n3 3\n4 2\n2 3\n3 4\n4 4\n1 2\n3 2\...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
262
codeforces
f3d7158f8e0792de72e5f73a3a3af603
Trip For Meal
Winnie-the-Pooh likes honey very much! That is why he decided to visit his friends. Winnie has got three best friends: Rabbit, Owl and Eeyore, each of them lives in his own house. There are winding paths between each pair of houses. The length of a path between Rabbit's and Owl's houses is *a* meters, between Rabbit's ...
{"inputs": ["3\n2\n3\n1", "1\n2\n3\n5", "10\n1\n8\n3", "7\n10\n5\n6", "9\n9\n7\n5", "9\n37\n85\n76", "76\n46\n77\n11", "80\n42\n1\n37", "8\n80\n55\n1", "10\n13\n72\n17", "9\n24\n1\n63", "65\n5\n8\n7", "56\n8\n9\n3", "59\n8\n1\n2", "75\n50\n50\n5", "75\n54\n76\n66", "73\n71\n69\n66", "83\n58\n88\n16", "74\n31\n11\n79", ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
234
codeforces
f3dbac550b76e20c952e310e24ea589c
Spyke Chatting
The R2 company has *n* employees working for it. The work involves constant exchange of ideas, sharing the stories of success and upcoming challenging. For that, R2 uses a famous instant messaging program Spyke. R2 has *m* Spyke chats just to discuss all sorts of issues. In each chat, some group of employees exchanges...
{"inputs": ["3 4 5\n1 1 1 1\n1 0 1 1\n1 1 0 0\n1 1\n3 1\n1 3\n2 4\n3 2", "4 3 4\n0 1 1\n1 0 1\n1 1 1\n0 0 0\n1 2\n2 1\n3 1\n1 3", "2 1 1\n1\n1\n1 1", "3 3 1\n1 1 1\n1 1 1\n1 1 1\n3 1", "3 2 1\n0 1\n1 0\n1 1\n1 2", "5 5 5\n0 1 1 1 0\n1 1 0 1 1\n1 1 1 1 1\n0 1 1 1 1\n1 0 0 1 1\n4 5\n4 5\n1 3\n5 4\n1 2", "4 5 6\n1 1 1 1 1...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
20
codeforces
f42402e6c70bf58ecf9462382be78531
Martian Luck
You know that the Martians use a number system with base *k*. Digit *b* (0<=≤<=*b*<=&lt;<=*k*) is considered lucky, as the first contact between the Martians and the Earthlings occurred in year *b* (by Martian chronology). A digital root *d*(*x*) of number *x* is a number that consists of a single digit, resulting aft...
{"inputs": ["10 5 6\n3 2 0 5 6 1", "7 6 4\n3 5 0 4", "257 0 3\n0 0 256", "2 1 1\n0", "2 0 20\n1 1 1 0 1 1 1 1 0 0 0 0 1 0 0 0 0 1 0 1", "100 29 33\n28 89 23 14 97 97 66 56 55 60 47 29 9 79 26 80 63 78 83 60 41 29 52 10 82 26 47 88 99 75 52 1 31", "3 2 100\n2 0 0 0 0 2 1 1 1 2 0 1 1 1 1 2 0 0 1 0 1 1 2 0 2 0 1 0 1 0 0 2...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
4
codeforces
f431895a1a729fdbd0c3ad3f22be56ce
Professor GukiZ and Two Arrays
Professor GukiZ has two arrays of integers, a and b. Professor wants to make the sum of the elements in the array a *s**a* as close as possible to the sum of the elements in the array b *s**b*. So he wants to minimize the value *v*<==<=|*s**a*<=-<=*s**b*|. In one operation professor can swap some element from the arra...
{"inputs": ["5\n5 4 3 2 1\n4\n1 1 1 1", "5\n1 2 3 4 5\n1\n15", "5\n1 2 3 4 5\n4\n1 2 3 4", "1\n-42\n1\n-86", "1\n-21\n10\n-43 6 -46 79 -21 93 -36 -38 -67 1", "10\n87 -92 -67 -100 -88 80 -82 -59 81 -72\n10\n-50 30 30 77 65 92 -60 -76 -29 -15", "6\n1 2 3 4 5 11\n1\n3", "2\n-2 -17\n2\n11 -9"], "outputs": ["1\n2\n1 1\n4 2"...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
codeforces
f43a0ddbf858622f14a65dfa900d98f3
Holidays
School holidays come in Berland. The holidays are going to continue for *n* days. The students of school №*N* are having the time of their lives and the IT teacher Marina Sergeyevna, who has spent all the summer busy checking the BSE (Berland State Examination) results, has finally taken a vacation break! Some people a...
{"inputs": ["10 5\n1 2\n3 3\n4 6\n7 7\n8 10", "10 5\n1 2\n2 3\n4 5\n7 8\n9 10", "10 5\n1 2\n3 3\n5 7\n7 7\n7 10", "5 4\n1 1\n2 2\n3 3\n4 5", "100 50\n1 2\n3 3\n4 5\n6 8\n9 10\n11 11\n12 14\n15 15\n16 16\n17 17\n18 18\n19 19\n20 21\n22 23\n24 24\n25 26\n27 30\n31 34\n35 37\n38 38\n39 40\n41 43\n44 46\n47 53\n54 54\n55 5...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
32
codeforces
f43a2e0a33c8f44633805b0dd90f0796
Cupboard and Balloons
A girl named Xenia has a cupboard that looks like an arc from ahead. The arc is made of a semicircle with radius *r* (the cupboard's top) and two walls of height *h* (the cupboard's sides). The cupboard's depth is *r*, that is, it looks like a rectangle with base *r* and height *h*<=+<=*r* from the sides. The figure be...
{"inputs": ["1 1", "1 2", "2 1", "2 2", "2 3", "4 1", "5 1", "5 2", "5 3", "5 4", "5 5", "5 6", "5 9", "5 10", "5 11", "674098 1358794", "3983458 7761504", "4841874 9131511", "667586 5534221", "1526002 6904227", "4835362 5823289", "5693778 7001807", "6552194 8371814", "2377906 4774524", "4365659 4738707", "98 1358794",...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
14
codeforces
f453f02226d9971eb7bbf5becec6b38f
Find Marble
Petya and Vasya are playing a game. Petya's got *n* non-transparent glasses, standing in a row. The glasses' positions are indexed with integers from 1 to *n* from left to right. Note that the positions are indexed but the glasses are not. First Petya puts a marble under the glass in position *s*. Then he performs som...
{"inputs": ["4 2 1\n2 3 4 1", "4 3 3\n4 1 3 2", "4 3 4\n1 2 3 4", "3 1 3\n2 1 3", "1 1 1\n1", "10 6 7\n10 7 8 1 5 6 2 9 4 3", "10 3 6\n5 6 7 3 8 4 2 1 10 9", "10 10 4\n4 2 6 9 5 3 8 1 10 7", "100 90 57\n19 55 91 50 31 23 60 84 38 1 22 51 27 76 28 98 11 44 61 63 15 93 52 3 66 16 53 36 18 62 35 85 78 37 73 64 87 74 46 26...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
222
codeforces
f456a5b7865384e367c56b0d2407ffe7
Composing Of String
Stepan has a set of *n* strings. Also, he has a favorite string *s*. Stepan wants to do the following. He will take some strings of his set and write them down one after another. It is possible that he will take some strings more than once, and will not take some of them at all. Your task is to determine the minimum...
{"inputs": ["3\na\naa\na\naaa", "4\nab\naab\naa\nbb\nbaaab", "2\naaa\nbbb\naaacbbb", "4\naab\naa\nbb\naba\nbaaab", "2\naaaaaaaa\nabbaaaaaaa\nbbbbbbbbbabbbbbbbbbbbbbbbbbbbbabbbbbbbbbbbbbbbbbbbbbbbbabbbbbabbabbbbbbbbbbbbbbbbbbbabbabbbbababbbbbbbbabbbbb", "1\nlol\nlol"], "outputs": ["2", "3", "-1", "2", "52", "1"]}
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
codeforces
f469a19052b871efa652018267416bc5
Regular Bracket Sequence
A bracket sequence is called regular if it is possible to obtain correct arithmetic expression by inserting characters «+» and «1» into this sequence. For example, sequences «(())()», «()» and «(()(()))» are regular, while «)(», «(()» and «(()))(» are not. One day Johnny got bracket sequence. He decided to remove some...
{"inputs": ["(()))(", "((()())", "(", ")", ")(()(", "))))))(", "()()(()(((", "()))(()((((()(())", "())))((()())())))))())", ")))((((())(()((()((((()()())((", "))()()((()()))())()(((((((())((((((((())()()((())(", "))())))))))())))))()()))()()))))())))))()))))))))))))(()))())(()))))(()))))())))((((()()))))()))()))"], "ou...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
207
codeforces
f46e2bd58d7931a2564157375a75ebe5
Pasha and Stick
Pasha has a wooden stick of some positive integer length *n*. He wants to perform exactly three cuts to get four parts of the stick. Each part must have some positive integer length and the sum of these lengths will obviously be *n*. Pasha likes rectangles but hates squares, so he wonders, how many ways are there to ...
{"inputs": ["6", "20", "1", "2", "3", "4", "2000000000", "1924704072", "73740586", "1925088820", "593070992", "1925473570", "629490186", "1980649112", "36661322", "1943590793", "71207034", "1757577394", "168305294", "1934896224", "297149088", "1898001634", "176409698", "1873025522", "5714762", "1829551192", "16269438",...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
381
codeforces
f48a1384754b692e29f1b10ca139a643
none
You have an array *a* with length *n*, you can perform operations. Each operation is like this: choose two adjacent elements from *a*, say *x* and *y*, and replace one of them with *gcd*(*x*,<=*y*), where *gcd* denotes the [greatest common divisor](https://en.wikipedia.org/wiki/Greatest_common_divisor). What is the mi...
{"inputs": ["5\n2 2 3 4 6", "4\n2 4 6 8", "3\n2 6 9", "15\n10 10 10 10 10 10 21 21 21 21 21 21 21 21 21", "12\n10 10 14 14 14 14 14 14 14 14 21 21", "5\n10 10 14 21 21", "9\n10 10 10 10 10 14 14 21 21", "9\n10 10 10 10 10 10 10 10 21", "13\n10 10 10 15 15 15 15 15 15 15 15 21 21", "15\n10 10 10 10 10 10 10 10 10 10 10 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
91
codeforces
f49929c441933b89f099ad18f063b303
Two TVs
Polycarp is a great fan of television. He wrote down all the TV programs he is interested in for today. His list contains *n* shows, *i*-th of them starts at moment *l**i* and ends at moment *r**i*. Polycarp owns two TVs. He can watch two different shows simultaneously with two TVs but he can only watch one show at a...
{"inputs": ["3\n1 2\n2 3\n4 5", "4\n1 2\n2 3\n2 3\n1 2", "4\n0 1\n1 2\n2 3\n3 4", "3\n1 2\n2 3\n2 4", "3\n0 100\n0 100\n0 100", "1\n0 1000000000", "2\n0 1\n0 1", "3\n2 3\n4 5\n1 6", "5\n1 3\n1 4\n4 10\n5 8\n9 11", "3\n1 2\n1 2\n2 3", "4\n1 100\n10 15\n20 25\n30 35", "3\n1 8\n6 7\n8 11", "5\n1 2\n3 5\n4 7\n8 9\n5 10", "...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
81
codeforces
f4a2baf1989ae44e47e1d466007d7165
Contest Balloons
One tradition of ACM-ICPC contests is that a team gets a balloon for every solved problem. We assume that the submission time doesn't matter and teams are sorted only by the number of balloons they have. It means that one's place is equal to the number of teams with more balloons, increased by 1. For example, if there ...
{"inputs": ["8\n20 1000\n32 37\n40 1000\n45 50\n16 16\n16 16\n14 1000\n2 1000", "7\n4 4\n4 4\n4 4\n4 4\n4 4\n4 4\n5 5", "7\n14000000003 1000000000000000000\n81000000000 88000000000\n5000000000 7000000000\n15000000000 39000000000\n46000000000 51000000000\n0 1000000000\n0 0", "2\n100 150\n5 100000", "9\n4 70\n32 56\n32 6...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
5
codeforces
f4dc21b1bc1016c05753a806dc7c6a21
Office Keys
There are *n* people and *k* keys on a straight line. Every person wants to get to the office which is located on the line as well. To do that, he needs to reach some point with a key, take the key and then go to the office. Once a key is taken by somebody, it couldn't be taken by anybody else. You are to determine th...
{"inputs": ["2 4 50\n20 100\n60 10 40 80", "1 2 10\n11\n15 7", "2 5 15\n10 4\n29 23 21 22 26", "3 10 1500\n106 160 129\n1333 1532 1181 1091 1656 1698 1291 1741 1242 1163", "5 20 1\n314 316 328 323 321\n30 61 11 83 19 63 97 87 14 79 43 57 75 48 47 95 41 27 8 88", "20 20 1000000000\n911196469 574676950 884047241 98421870...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
25
codeforces
f4f8a3dbed3bce393863f09f59c5e587
none
You are given a string *s*, consisting of small Latin letters. Let's denote the length of the string as |*s*|. The characters in the string are numbered starting from 1. Your task is to find out if it is possible to rearrange characters in string *s* so that for any prime number *p*<=≤<=|*s*| and for any integer *i* ...
{"inputs": ["abc", "abcd", "xxxyxxx", "xxxjddyxduquybxdxx", "jjjjjjjjjjzjjjjjjjjjjjjjjjj", "mggnngggnjgnggggngnggpnggumggpg", "hfihihhfh", "ppppppopppionpppppppppwppppppppppppppppppppppb", "jntnnnnnnngnnnnntnnennannnnnnnnnnnnnnnnjnnnnngnnnnannnnnnnnnq", "dattqddidyddddmriftkdddddddddqvedwddfdrdiaddiokdddodyqqddddtdddvd...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
14
codeforces
f53c2e77b713b9fecc9d1983adaae7e8
Sereja and Stairs
Sereja loves integer sequences very much. He especially likes stairs. Sequence *a*1,<=*a*2,<=...,<=*a*|*a*| (|*a*| is the length of the sequence) is stairs if there is such index *i* (1<=≤<=*i*<=≤<=|*a*|), that the following condition is met: For example, sequences [1, 2, 3, 2] and [4, 2] are stairs and sequence [3,...
{"inputs": ["5\n1 2 3 4 5", "6\n1 1 2 2 3 3", "47\n3 4 5 3 1 4 4 3 4 6 1 5 1 3 5 3 6 5 1 4 3 2 6 5 3 1 4 6 4 6 2 1 1 1 4 3 6 1 6 6 3 5 1 4 6 4 4", "13\n8 23 26 8 15 13 35 36 28 8 4 33 6", "17\n15 29 28 23 20 12 9 30 4 13 1 25 11 20 6 23 10", "31\n189 73 300 133 414 23 150 301 252 21 274 272 316 291 339 356 201 267 257 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
13
codeforces
f53de49dea0cc731a12013a4ca367818
Indivisibility
IT City company developing computer games decided to upgrade its way to reward its employees. Now it looks the following way. After a new game release users start buying it actively, and the company tracks the number of sales with precision to each transaction. Every time when the next number of sales is not divisible ...
{"inputs": ["12", "2519", "2521", "1", "314159265", "718281828459045235", "1000000000000000000", "987654321234567890", "3628800", "504000000000000000"], "outputs": ["2", "576", "577", "1", "71807832", "164178703647781768", "228571428571428571", "225749559139329804", "829440", "115200000000000000"]}
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
9
codeforces
f54731867043ce86f02c1fd79631d7cf
Bear and Up-Down
The life goes up and down, just like nice sequences. Sequence *t*1,<=*t*2,<=...,<=*t**n* is called nice if the following two conditions are satisfied: - *t**i*<=&lt;<=*t**i*<=+<=1 for each odd *i*<=&lt;<=*n*; - *t**i*<=&gt;<=*t**i*<=+<=1 for each even *i*<=&lt;<=*n*. For example, sequences (2,<=8), (1,<=5,<=1) and...
{"inputs": ["5\n2 8 4 7 7", "4\n200 150 100 50", "10\n3 2 1 4 1 4 1 4 1 4", "9\n1 2 3 4 5 6 7 8 9", "5\n1 1 1 4 3", "10\n7 7 8 10 5 10 1 5 2 6", "50\n11836 28308 72527 92281 139289 93797 134555 148444 40866 111317 21564 87813 65466 20541 99238 2287 74647 128071 18163 61672 39766 55589 138385 147443 138100 142683 60703 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
7
codeforces
f555f0260b3c8873cba4bcd572c3085a
Bracket Sequence
A bracket sequence is a string, containing only characters "(", ")", "[" and "]". A correct bracket sequence is a bracket sequence that can be transformed into a correct arithmetic expression by inserting characters "1" and "+" between the original characters of the sequence. For example, bracket sequences "()[]", "([...
{"inputs": ["([])", "(((", "(][)", "(()[))()[]", "(][](](][[(][", "((])(]]))(](((()[[()[[[)([]()])[(]][)]])[]]()[()[[[[(([[)", "](]][)]()][[])[()(][)]))[)[]()()])[([((([[(([)][(])](][])([([)())))([(([][))[)()]][[])()[)](][[((]](](])]][(][[()(]][[)][])(][]))[])[)[(])[)()()[[))((()]]([([[(]))][(]())))))[[]]][][))[)])])()...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
8
codeforces
f556bf48bdfac471314a32265c949ac9
Tanya and Toys
In Berland recently a new collection of toys went on sale. This collection consists of 109 types of toys, numbered with integers from 1 to 109. A toy from the new collection of the *i*-th type costs *i* bourles. Tania has managed to collect *n* different types of toys *a*1,<=*a*2,<=...,<=*a**n* from the new collection...
{"inputs": ["3 7\n1 3 4", "4 14\n4 6 12 8", "5 6\n97746 64770 31551 96547 65684", "10 10\n94125 56116 29758 94024 29289 31663 99794 35076 25328 58656", "30 38\n9560 64176 75619 53112 54160 68775 12655 13118 99502 89757 78434 42521 19210 1927 34097 5416 56110 44786 59126 44266 79240 65567 54602 25325 37171 2879 89291 89...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
93
codeforces
f5636aa985f73a0c339b33d720a5f31e
Datatypes
Tattah's youngest brother, Tuftuf, is new to programming. Since his older brother is such a good programmer, his biggest dream is to outshine him. Tuftuf is a student at the German University in Cairo (GUC) where he learns to write programs in Gava. Today, Tuftuf was introduced to Gava's unsigned integer datatypes. G...
{"inputs": ["3\n64 16 32", "4\n4 2 1 3", "5\n1 5 3 3 2", "52\n474 24 24 954 9 234 474 114 24 114 234 24 114 114 234 9 9 24 9 54 234 54 9 954 474 9 54 54 54 234 9 114 24 54 114 954 954 474 24 54 54 234 234 474 474 24 114 9 954 954 954 474", "56\n43 641 626 984 107 521 266 835 707 220 402 406 558 199 988 685 843 808 182 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
20
codeforces
f5677e201ea80926f44a9e2ca0e950ce
Running with Obstacles
A sportsman starts from point *x**start*<==<=0 and runs to point with coordinate *x**finish*<==<=*m* (on a straight line). Also, the sportsman can jump — to jump, he should first take a run of length of not less than *s* meters (in this case for these *s* meters his path should have no obstacles), and after that he can...
{"inputs": ["3 10 1 3\n3 4 7", "2 9 2 3\n6 4", "10 100 2 8\n93 35 24 87 39 46 86 37 73 33", "10 1000000000 8905990 20319560\n233244997 997992814 242452779 497363176 572234096 126615858 886769539 662035052 989086824 716655858", "100 1000 1 4\n228 420 360 642 442 551 940 343 24 83 928 110 663 548 704 461 942 799 283 746 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
5
codeforces
f56798c29ee8a6da3eda8faa5ae6e069
Reducing Fractions
To confuse the opponents, the Galactic Empire represents fractions in an unusual format. The fractions are represented as two sets of integers. The product of numbers from the first set gives the fraction numerator, the product of numbers from the second set gives the fraction denominator. However, it turned out that t...
{"inputs": ["3 2\n100 5 2\n50 10", "4 3\n2 5 10 20\n100 1 3", "2 3\n50 10\n100 5 2", "1 1\n1\n1", "3 2\n100 5 2\n10 100", "5 3\n16 24 36 54 81\n4 6 9", "10 10\n2 5 11 17 23 31 41 47 59 67\n3 7 13 19 29 37 43 53 61 71", "5 5\n2 9 8 3 5\n5 7 8 1 1", "10 11\n7 43 39 13 25 23 33 40 5 2\n42 22 39 1 23 37 12 48 46 2 2", "1 5...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
4
codeforces
f5720d2aa74a1670c2180f6deeffec02
Beads
One Martian boy called Zorg wants to present a string of beads to his friend from the Earth — Masha. He knows that Masha likes two colours: blue and red, — and right in the shop where he has come, there is a variety of adornments with beads of these two colours. All the strings of beads have a small fastener, and if on...
{"inputs": ["4 4", "2 1", "2 2", "3 1", "3 2", "3 3", "4 1", "4 2", "4 3", "4 4", "4 5", "4 6", "5 1", "5 2", "5 3", "5 4", "5 5", "5 6", "5 7", "5 8", "5 9", "5 10", "6 1", "6 2", "6 3", "6 4", "6 5", "6 6", "6 7", "6 8", "6 9", "6 10", "6 11", "6 12", "6 13", "6 14", "6 15", "6 16", "6 17", "6 18", "6 19", "6 20", "7...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
4
codeforces
f5785293d81f3553abdcb79b2d447963
Divide by three, multiply by two
Polycarp likes to play with numbers. He takes some integer number $x$, writes it down on the board, and then performs with it $n - 1$ operations of the two kinds: - divide the number $x$ by $3$ ($x$ must be divisible by $3$); - multiply the number $x$ by $2$. After each operation, Polycarp writes down the result o...
{"inputs": ["6\n4 8 6 3 12 9", "4\n42 28 84 126", "2\n1000000000000000000 3000000000000000000", "19\n46875000000000000 732421875000000 5859375000000000 11444091796875 2929687500000000 187500000000000000 91552734375000 11718750000000000 3000000000000000000 22888183593750 1464843750000000 375000000000000000 4577636718750...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
14
codeforces
f58134faa67baff47e60249ea62a672c
Dexterina’s Lab
Dexterina and Womandark have been arch-rivals since they’ve known each other. Since both are super-intelligent teenage girls, they’ve always been trying to solve their disputes in a peaceful and nonviolent way. After god knows how many different challenges they’ve given to one another, their score is equal and they’re ...
{"inputs": ["2 2\n0.500000 0.250000 0.250000", "9 9\n0.100000 0.100000 0.100000 0.100000 0.100000 0.100000 0.100000 0.100000 0.100000 0.100000", "1000001 5\n0.000000 0.300000 0.000000 0.500000 0.000000 0.200000", "1000000 5\n0.000000 0.000000 1.000000 0.000000 0.000000 0.000000", "100 20\n0.065682 0.015963 0.024840 0.0...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
2
codeforces
f597a081a3acc7008f50eae51fc18f00
Lost in Transliteration
There are some ambiguities when one writes Berland names with the letters of the Latin alphabet. For example, the Berland sound u can be written in the Latin alphabet as "u", and can be written as "oo". For this reason, two words "ulyana" and "oolyana" denote the same name. The second ambiguity is about the Berland s...
{"inputs": ["10\nmihail\noolyana\nkooooper\nhoon\nulyana\nkoouper\nmikhail\nkhun\nkuooper\nkkkhoon", "9\nhariton\nhkariton\nbuoi\nkkkhariton\nboooi\nbui\nkhariton\nboui\nboi", "2\nalex\nalex", "40\nuok\nkuu\nku\no\nkku\nuh\nu\nu\nhh\nk\nkh\nh\nh\nou\nokh\nukk\nou\nuhk\nuo\nuko\nu\nuu\nh\nh\nhk\nuhu\nuoh\nooo\nk\nh\nuk\...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
88
codeforces
f5a3f39afda2c439a842a8a0e82872d9
Start of the session
Before the start of the football season in Berland a strange magic ritual is held. The most experienced magicians have to find a magic matrix of the size *n*<=×<=*n* (*n* is even number). Gods will never allow to start the championship without it. Matrix should contain integers from 0 to *n*<=-<=1, main diagonal should...
{"inputs": ["2", "4", "6", "8", "10", "12", "14", "16", "18", "20", "32", "40", "666", "66", "80", "88", "96", "100", "128", "144", "250", "284", "332", "400", "600", "700", "780", "846", "902", "1000"], "outputs": ["0 1\n1 0", "0 1 3 2\n1 0 2 3\n3 2 0 1\n2 3 1 0", "0 1 4 2 5 3\n1 0 2 5 3 4\n4 2 0 3 1 5\n2 5 3 0 4 1\n5...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
6
codeforces
f5adec5d79907a5e2e386a91f8277578
Choosing Capital for Treeland
The country Treeland consists of *n* cities, some pairs of them are connected with unidirectional roads. Overall there are *n*<=-<=1 roads in the country. We know that if we don't take the direction of the roads into consideration, we can get from any city to any other one. The council of the elders has recently decid...
{"inputs": ["3\n2 1\n2 3", "4\n1 4\n2 4\n3 4", "2\n1 2", "8\n1 2\n3 2\n4 3\n4 5\n6 5\n6 7\n8 7", "10\n2 3\n1 8\n9 5\n5 4\n6 10\n4 8\n5 6\n7 6\n5 3", "10\n9 3\n3 8\n4 3\n3 5\n7 8\n10 3\n2 3\n6 2\n3 1", "10\n5 4\n6 5\n10 1\n2 5\n9 8\n1 3\n7 10\n2 3\n5 9", "10\n2 3\n1 8\n9 5\n5 4\n6 10\n4 8\n5 6\n7 6\n5 3", "11\n3 10\n4 7...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
15
codeforces
f5b1edc2123050877e37a9fcb3209b4a
George and Number
George is a cat, so he really likes to play. Most of all he likes to play with his array of positive integers *b*. During the game, George modifies the array by using special changes. Let's mark George's current array as *b*1,<=*b*2,<=...,<=*b*|*b*| (record |*b*| denotes the current length of the array). Then one chang...
{"inputs": ["9555", "10000000005", "800101", "45", "1000000000000001223300003342220044555", "19992000", "310200", "63100605000394089000505000600600062000170273350000", "20900000000090009000070069000026000000000000020008", "60000000000000000000000000000000000000000000000000", "7", "69442629156526594581255999781161144587...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
10
codeforces
f5beda691ed3a24d56dfc8e156695d38
Anagram Search
A string *t* is called an anagram of the string *s*, if it is possible to rearrange letters in *t* so that it is identical to the string *s*. For example, the string "aab" is an anagram of the string "aba" and the string "aaa" is not. The string *t* is called a substring of the string *s* if it can be read starting fr...
{"inputs": ["bb??x???\naab", "ab?c\nacb", "ccaac\ncbcbca", "?bba?\nbba", "aaaaa??a?a\naaa", "?bba?b?aaa\nabb", "?b?aaabaa?\naaa", "aaaaa?ab??\naab", "?bab?a?aab\naaa", "??fb???a??\ndeeefc", "?\na", "a\na", "?\ncb", "a\naa"], "outputs": ["2", "2", "0", "3", "8", "6", "3", "5", "3", "0", "1", "1", "0", "0"]}
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
3
codeforces
f5de91435f10ae345408623b2344c3b1
Maximize!
You are given a multiset *S* consisting of positive integers (initially empty). There are two kind of queries: 1. Add a positive integer to *S*, the newly added integer is not less than any number in it. 1. Find a subset *s* of the set *S* such that the value is maximum possible. Here *max*(*s*) means maximum valu...
{"inputs": ["6\n1 3\n2\n1 4\n2\n1 8\n2", "4\n1 1\n1 4\n1 5\n2", "8\n1 7\n1 26\n1 40\n1 45\n1 64\n2\n1 88\n1 94", "9\n1 35\n2\n2\n1 45\n1 58\n2\n2\n2\n1 100", "15\n1 300022520\n1 542407315\n2\n2\n2\n1 622764928\n1 706078395\n1 715915848\n1 933742920\n1 942115408\n2\n2\n2\n2\n2", "25\n1 134292126\n2\n1 218916741\n1 23755...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
8
codeforces
f6050dd5b349336b7c103efd3295fa88
Dasha and friends
Running with barriers on the circle track is very popular in the country where Dasha lives, so no wonder that on her way to classes she saw the following situation: The track is the circle with length *L*, in distinct points of which there are *n* barriers. Athlete always run the track in counterclockwise direction if...
{"inputs": ["3 8\n2 4 6\n1 5 7", "4 9\n2 3 5 8\n0 1 3 6", "2 4\n1 3\n1 2", "5 9\n0 2 5 6 7\n1 3 6 7 8", "5 60\n7 26 27 40 59\n14 22 41 42 55", "20 29\n0 1 2 4 5 8 9 12 14 15 17 19 20 21 22 23 25 26 27 28\n0 2 4 5 6 7 8 10 11 12 13 14 15 16 18 19 22 23 26 28", "35 41\n0 1 2 3 4 5 6 7 9 10 11 12 13 14 18 19 20 21 22 23 2...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
92
codeforces
f61d78de4dfc8f9ad1757133850be363
Fixed Points
A permutation of length *n* is an integer sequence such that each integer from 0 to (*n*<=-<=1) appears exactly once in it. For example, sequence [0,<=2,<=1] is a permutation of length 3 while both [0,<=2,<=2] and [1,<=2,<=3] are not. A fixed point of a function is a point that is mapped to itself by the function. A p...
{"inputs": ["5\n0 1 3 4 2", "10\n6 9 4 7 8 2 3 5 0 1", "100\n99 5 40 32 4 31 38 57 94 47 26 16 89 72 9 80 55 86 78 90 42 41 46 74 56 97 21 48 66 27 93 85 88 59 64 95 10 45 12 22 84 60 8 98 62 51 14 65 39 30 11 71 92 19 76 43 87 54 15 53 37 6 25 18 96 35 13 91 2 3 0 23 1 7 49 75 81 33 50 52 63 44 69 36 17 61 24 20 68 34...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
111
codeforces
f6259d8cdf46697bf882fbfca39bdc34
Number With The Given Amount Of Divisors
Given the number *n*, find the smallest positive integer which has exactly *n* divisors. It is guaranteed that for the given *n* the answer will not exceed 1018. The first line of the input contains integer *n* (1<=≤<=*n*<=≤<=1000). Output the smallest positive integer with exactly *n* divisors. Sample Input 4 6 Sampl...
{"inputs": ["1", "7", "8", "9", "10", "15", "20", "47", "59", "100", "159", "265", "312", "473", "637", "500", "720", "902", "940", "1000", "999", "118"], "outputs": ["1", "64", "24", "36", "48", "144", "240", "70368744177664", "288230376151711744", "45360", "40532396646334464", "364791569817010176", "14192640", "25970...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
36
codeforces
f662d236d019258c2096118a6174c09f
Bear and Elections
Limak is a grizzly bear who desires power and adoration. He wants to win in upcoming elections and rule over the Bearland. There are *n* candidates, including Limak. We know how many citizens are going to vote for each candidate. Now *i*-th candidate would get *a**i* votes. Limak is candidate number 1. To win in elect...
{"inputs": ["5\n5 1 11 2 8", "4\n1 8 8 8", "2\n7 6", "2\n1 1", "10\n100 200 57 99 1 1000 200 200 200 500", "16\n7 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000", "100\n47 64 68 61 68 66 69 61 69 65 69 63 62 60 68 65 64 65 65 62 63 68 60 70 63 63 65 67 70 69 68 69 61 65 63 60 60 65 61 60 70 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
165
codeforces
f66884c846d9ab53effb39a95437459d
Race Against Time
Have you ever tried to explain to the coordinator, why it is eight hours to the contest and not a single problem has been prepared yet? Misha had. And this time he has a really strong excuse: he faced a space-time paradox! Space and time replaced each other. The entire universe turned into an enormous clock face with ...
{"inputs": ["12 30 45 3 11", "12 0 1 12 1", "3 47 0 4 9", "10 22 59 6 10", "3 1 13 12 3", "11 19 28 9 10", "9 38 22 6 1", "5 41 11 5 8", "11 2 53 10 4", "9 41 17 10 1", "6 54 48 12 6", "12 55 9 5 1", "8 55 35 9 3", "3 21 34 3 10", "2 52 1 12 3", "7 17 11 1 7", "11 6 37 6 4", "9 6 22 8 1", "3 10 5 5 9", "7 12 22 11 2", ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
67
codeforces
f67e84e95f79dcc728e8824d78e742f1
Necklace
Ivan wants to make a necklace as a present to his beloved girl. A necklace is a cyclic sequence of beads of different colors. Ivan says that necklace is beautiful relative to the cut point between two adjacent beads, if the chain of beads remaining after this cut is a palindrome (reads the same forward and backward). ...
{"inputs": ["3\n4 2 1", "1\n4", "2\n1 1", "1\n2", "1\n3", "1\n5", "2\n2 2", "3\n1 2 4", "3\n3 3 3", "3\n3 3 6", "3\n6 6 6", "3\n6 6 9", "26\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", "3\n7 7 21", "2\n95 50", "3\n30 30 15", "3\n1 50 70", "2\n70 10", "10\n100 100 100 50 20 300 400 300 350 320", "4\n1100 220 6...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
3
codeforces
f6b787869ae37c46c36ee88999a86ba8
Kuro and Walking Route
Kuro is living in a country called Uberland, consisting of $n$ towns, numbered from $1$ to $n$, and $n - 1$ bidirectional roads connecting these towns. It is possible to reach each town from any other. Each road connects two towns $a$ and $b$. Kuro loves walking and he is planning to take a walking marathon, in which h...
{"inputs": ["3 1 3\n1 2\n2 3", "3 1 3\n1 2\n1 3", "61 26 12\n33 38\n32 8\n27 59\n1 21\n61 57\n61 22\n35 18\n61 14\n39 56\n50 10\n1 42\n21 43\n61 41\n31 30\n35 9\n23 28\n39 34\n39 4\n39 25\n27 60\n45 51\n1 11\n35 26\n29 15\n23 44\n31 2\n35 27\n39 20\n1 24\n1 53\n35 58\n39 37\n61 13\n61 16\n1 12\n32 17\n1 40\n33 47\n29 5...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
14
codeforces
f6ed80837137f82f9377e02bf1061dd1
Median on Segments (Permutations Edition)
You are given a permutation $p_1, p_2, \dots, p_n$. A permutation of length $n$ is a sequence such that each integer between $1$ and $n$ occurs exactly once in the sequence. Find the number of pairs of indices $(l, r)$ ($1 \le l \le r \le n$) such that the value of the median of $p_l, p_{l+1}, \dots, p_r$ is exactly t...
{"inputs": ["5 4\n2 4 5 3 1", "5 5\n1 2 3 4 5", "15 8\n1 15 2 14 3 13 4 8 12 5 11 6 10 7 9", "1 1\n1", "2 1\n1 2", "2 1\n2 1", "2 2\n1 2", "2 2\n2 1", "3 1\n1 2 3", "3 1\n1 3 2", "3 1\n2 1 3", "3 1\n2 3 1", "3 1\n3 1 2", "3 1\n3 2 1", "5 2\n2 1 3 4 5", "6 3\n3 6 1 4 2 5", "7 4\n1 7 6 4 2 3 5", "8 7\n2 3 6 8 7 5 4 1", "...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
17
codeforces
f6efa3da33b7fe29692c702f81aaa53e
Cut Ribbon
Polycarpus has a ribbon, its length is *n*. He wants to cut the ribbon in a way that fulfils the following two conditions: - After the cutting each ribbon piece should have length *a*, *b* or *c*. - After the cutting the number of ribbon pieces should be maximum. Help Polycarpus and find the number of ribbon piece...
{"inputs": ["5 5 3 2", "7 5 5 2", "4 4 4 4", "1 1 1 1", "4000 1 2 3", "4000 3 4 5", "10 3 4 5", "100 23 15 50", "3119 3515 1021 7", "918 102 1327 1733", "3164 42 430 1309", "3043 317 1141 2438", "26 1 772 2683", "370 2 1 15", "734 12 6 2", "418 18 14 17", "18 16 28 9", "14 6 2 17", "29 27 18 2", "29 12 7 10", "27 23 4 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
168
codeforces
f6f6f7f83556081cb3f54ab634ecbaef
Jumping on Walls
Vasya plays a computer game with ninjas. At this stage Vasya's ninja should get out of a deep canyon. The canyon consists of two vertical parallel walls, their height is *n* meters. Let's imagine that we split these walls into 1 meter-long areas and number them with positive integers from 1 to *n* from bottom to top. ...
{"inputs": ["7 3\n---X--X\n-X--XX-", "6 2\n--X-X-\nX--XX-", "10 1\n-X-X-X-X-X\nX-X-X-X-X-", "5 4\n-X---\n----X", "6 2\n--X--X\nXX-X-X", "50 4\n-X-X-X--X--X--X-XX-----XX--X--------------XXX-X-X-\n--XX---XXXXXXX----XX--X--XXX--XXXX-XX--X--X--X----", "1 1\n-\nX", "2 1\n-X\nX-", "2 1\n-X\n-X", "1 20\n-\n-", "1 100000\n-\n-...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
12
codeforces
f7024bf1d013c03844cb96bcc9fa93bb
Chamber of Secrets
"The Chamber of Secrets has been opened again" — this news has spread all around Hogwarts and some of the students have been petrified due to seeing the basilisk. Dumbledore got fired and now Harry is trying to enter the Chamber of Secrets. These aren't good news for Lord Voldemort. The problem is, he doesn't want anyb...
{"inputs": ["3 3\n.#.\n...\n.#.", "4 3\n##.\n...\n.#.\n.#.", "3 3\n###\n###\n###", "3 4\n..##\n....\n..#.", "4 3\n#.#\n...\n...\n.##", "4 4\n##..\n..#.\n...#\n...#", "5 5\n...#.\n.....\n.....\n.....\n..#.#", "5 5\n.....\n.#...\n.....\n.....\n#.###", "5 5\n.....\n.###.\n..##.\n..##.\n...#.", "5 5\n.##..\n.##..\n.#.#.\n....
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
9
codeforces
f717d6d18d0b83f713963b87aacd0bcb
Five-In-a-Row
Alice and Bob play 5-in-a-row game. They have a playing field of size 10<=×<=10. In turns they put either crosses or noughts, one at a time. Alice puts crosses and Bob puts noughts. In current match they have made some turns and now it's Alice's turn. She wonders if she can put cross in such empty cell that she wins i...
{"inputs": ["O.......O.\n.....O.X..\n......O...\n....X.O...\n.O.O.....X\n.XO.....XX\n...X...X.O\n........O.\n........O.\n.X.X.....X", "....OX....\n..........\n.O..X...X.\nXXO..XO..O\nO.......X.\n...XX.....\n..O.O...OX\n.........X\n.....X..OO\n........O.", "..O..X.X..\n.O..X...O.\n........O.\n...O..O...\nX.XX....X.\n..O...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
45
codeforces
f718d17fcf33e09f943d8d3f2aa51ab5
A Good Contest
Codeforces user' handle color depends on his rating — it is red if his rating is greater or equal to 2400; it is orange if his rating is less than 2400 but greater or equal to 2200, etc. Each time participant takes part in a rated contest, his rating is changed depending on his performance. Anton wants the color of hi...
{"inputs": ["3\nBurunduk1 2526 2537\nBudAlNik 2084 2214\nsubscriber 2833 2749", "3\nApplejack 2400 2400\nFluttershy 2390 2431\nPinkie_Pie -2500 -2450", "1\nDb -3373 3591", "5\nQ2bz 960 2342\nhmX 2710 -1348\ngbAe -1969 -963\nE -160 196\npsi 2665 -3155", "9\nmwAz9lQ 1786 -1631\nnYgYFXZQfY -1849 -1775\nKU4jF -1773 -3376\n...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
365
codeforces
f76189f114131cbaa9af76123ee3508a
Red-Green Towers
There are *r* red and *g* green blocks for construction of the red-green tower. Red-green tower can be built following next rules: - Red-green tower is consisting of some number of levels; - Let the red-green tower consist of *n* levels, then the first level of this tower should consist of *n* blocks, second level —...
{"inputs": ["4 6", "9 7", "1 1", "3 3", "2 19", "18 3", "100000 1", "1 100000", "6 6", "10 10", "200000 200000", "0 1", "1 0", "0 200000", "200000 0", "199396 0", "199395 0", "0 199397", "121147 78249", "78250 121147", "121146 78249", "199585 199586", "199586 199586", "199585 199585", "107344 159729", "2954 1977", "255...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
2
codeforces
f7633c6db0a40963f948f432f5ef18b8
Three Garlands
Mishka is decorating the Christmas tree. He has got three garlands, and all of them will be put on the tree. After that Mishka will switch these garlands on. When a garland is switched on, it periodically changes its state — sometimes it is lit, sometimes not. Formally, if *i*-th garland is switched on during *x*-th s...
{"inputs": ["2 2 3", "4 2 3", "1499 1498 1500", "1500 1500 1500", "100 4 1", "4 2 4", "3 3 3", "2 3 6", "2 3 3", "4 4 2", "1 1 1", "2 11 2", "4 4 4", "4 4 5", "3 3 2", "3 6 6", "2 3 2", "1 1 3", "3 3 4", "2 4 4", "2 2 2", "2 10 10", "3 4 4", "2 5 5", "2 4 5", "228 2 2", "2 998 1000", "2 6 6", "6 4 7", "2 5 2", "2 100 1...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
75
codeforces
f7641ca673ddd74e3ceea30537a93912
Word Cut
Let's consider one interesting word game. In this game you should transform one word into another through special operations. Let's say we have word *w*, let's split this word into two non-empty parts *x* and *y* so, that *w*<==<=*xy*. A split operation is transforming word *w*<==<=*xy* into word *u*<==<=*yx*. For ex...
{"inputs": ["ab\nab\n2", "ababab\nababab\n1", "ab\nba\n2", "aaa\naaa\n0", "hi\nhi\n1", "abcd\ncbad\n5", "ab\nba\n10", "voodoo\ndoovoo\n100000", "ababab\nbababa\n100000", "abcdefgh\ncdefghab\n666", "aaaabaaaaaaaaaaabaaaaaaa\naaaaaaaaaabaaaaaaaaabaaa\n7477", "ssgqcodnqgfbhqsgineioafkkhcmmmihbiefialidgkffrhaiekebpieqgpplm...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
24
codeforces
f77027b5a8bdd60ddf914fe8d79e9619
Coprime Subsequences
Let's call a non-empty sequence of positive integers *a*1,<=*a*2... *a**k* coprime if the greatest common divisor of all elements of this sequence is equal to 1. Given an array *a* consisting of *n* positive integers, find the number of its coprime subsequences. Since the answer may be very large, print it modulo 109<...
{"inputs": ["3\n1 2 3", "4\n1 1 1 1", "7\n1 3 5 15 3 105 35", "1\n1", "1\n100000", "5\n10 8 6 4 6", "5\n5 1 3 5 4", "5\n5 1 6 6 6", "10\n9 6 8 5 5 2 8 9 2 2", "10\n2 2 16 16 14 1 9 12 15 13", "50\n17 81 20 84 6 86 11 33 19 46 70 79 23 64 40 99 78 70 3 10 32 42 18 73 35 36 69 90 81 81 8 25 87 23 76 100 53 11 36 19 87 89...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
16
codeforces
f787e15865d3fc919c7733bf0d10c0ca
none
Some time ago Mister B detected a strange signal from the space, which he started to study. After some transformation the signal turned out to be a permutation *p* of length *n* or its cyclic shift. For the further investigation Mister B need some basis, that's why he decided to choose cyclic shift of this permutation...
{"inputs": ["3\n1 2 3", "3\n2 3 1", "3\n3 2 1", "2\n1 2", "2\n2 1", "10\n10 1 9 2 8 3 7 4 6 5", "108\n1 102 33 99 6 83 4 20 61 100 76 71 44 9 24 87 57 2 81 82 90 85 12 30 66 53 47 36 43 29 31 64 96 84 77 23 93 78 58 68 42 55 13 70 62 19 92 14 10 65 63 75 91 48 11 105 37 50 32 94 18 26 52 89 104 106 86 97 80 95 17 72 40...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
3
codeforces
f792ab42d078f44a187ba4dbaad41927
Breaking Good
Breaking Good is a new video game which a lot of gamers want to have. There is a certain level in the game that is really difficult even for experienced gamers. Walter William, the main character of the game, wants to join a gang called Los Hermanos (The Brothers). The gang controls the whole country which consists of...
{"inputs": ["2 1\n1 2 0", "4 4\n1 2 1\n1 3 0\n2 3 1\n3 4 1", "8 9\n1 2 0\n8 3 0\n2 3 1\n1 4 1\n8 7 0\n1 5 1\n4 6 1\n5 7 0\n6 8 0", "9 10\n1 2 0\n2 3 0\n1 4 1\n4 5 1\n4 6 1\n6 7 1\n1 7 0\n1 8 0\n7 8 0\n9 7 1", "5 6\n1 2 0\n3 2 0\n5 1 1\n1 3 1\n5 3 0\n4 3 1", "15 31\n6 2 0\n5 15 1\n2 3 1\n6 9 1\n13 12 0\n2 7 0\n15 3 0\n3...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
2
codeforces
f7aa8d7390b43237f204ef5ed371668b
Hometask
Sergey attends lessons of the *N*-ish language. Each lesson he receives a hometask. This time the task is to translate some sentence to the *N*-ish language. Sentences of the *N*-ish language can be represented as strings consisting of lowercase Latin letters without spaces or punctuation marks. Sergey totally forgot ...
{"inputs": ["ababa\n1\nab", "codeforces\n2\ndo\ncs", "nllnrlrnll\n1\nrl", "aludfbjtwnkgnfl\n1\noy", "pgpgppgggpbbnnn\n2\npg\nnb", "eepeeeeppppppeepeppe\n1\npe", "vefneyamdzoytemupniw\n13\nve\nfg\noi\nan\nck\nwx\npq\nml\nbt\nud\nrz\nsj\nhy", "drvwfaacccwnncfwuptsorrrvvvrgdzytrwweeexzyyyxuwuuk\n13\nld\nac\nnp\nrv\nmo\njh...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
16
codeforces
f7b93766b035c712017b0bdc774bdecf
Chess Tourney
Berland annual chess tournament is coming! Organizers have gathered 2·*n* chess players who should be divided into two teams with *n* people each. The first team is sponsored by BerOil and the second team is sponsored by BerMobile. Obviously, organizers should guarantee the win for the team of BerOil. Thus, organizer...
{"inputs": ["2\n1 3 2 4", "1\n3 3", "5\n1 1 1 1 2 2 3 3 3 3", "5\n1 1 1 1 1 2 2 2 2 2", "10\n1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000", "1\n2 3", "100\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...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
131
codeforces
f7ecc31f6717583a02c3bf8945146bfa
Worms Evolution
Professor Vasechkin is studying evolution of worms. Recently he put forward hypotheses that all worms evolve by division. There are *n* forms of worms. Worms of these forms have lengths *a*1, *a*2, ..., *a**n*. To prove his theory, professor needs to find 3 different forms that the length of the first form is equal to ...
{"inputs": ["5\n1 2 3 5 7", "5\n1 8 1 5 1", "4\n303 872 764 401", "6\n86 402 133 524 405 610", "8\n217 779 418 895 996 473 3 22", "10\n858 972 670 15 662 114 33 273 53 310", "100\n611 697 572 770 603 870 128 245 49 904 468 982 788 943 549 288 668 796 803 515 999 735 912 49 298 80 412 841 494 434 543 298 17 571 271 105 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
131
codeforces
f811d54f672bee985c0aacecb9dada21
Report
Each month Blake gets the report containing main economic indicators of the company "Blake Technologies". There are *n* commodities produced by the company. For each of them there is exactly one integer in the final report, that denotes corresponding revenue. Before the report gets to Blake, it passes through the hands...
{"inputs": ["3 1\n1 2 3\n2 2", "4 2\n1 2 4 3\n2 3\n1 2", "4 1\n4 3 2 1\n1 4", "5 1\n1 2 3 4 5\n2 5", "6 2\n3 1 2 6 4 5\n1 6\n2 3", "10 3\n6 4 0 2 -3 7 8 -9 1 5\n1 8\n1 4\n2 2", "100 30\n65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
29
codeforces
f853095fb8e1806dff3305c2c7f1356a
Two Heaps
Valera has 2·*n* cubes, each cube contains an integer from 10 to 99. He arbitrarily chooses *n* cubes and puts them in the first heap. The remaining cubes form the second heap. Valera decided to play with cubes. During the game he takes a cube from the first heap and writes down the number it has. Then he takes a cub...
{"inputs": ["1\n10 99", "2\n13 24 13 45", "5\n21 60 18 21 17 39 58 74 62 34", "10\n26 43 29 92 22 27 95 56 72 55 93 51 91 30 70 77 32 69 87 98", "20\n80 56 58 61 75 60 25 49 59 15 43 39 21 73 67 13 75 31 18 87 32 44 53 15 53 76 79 94 85 80 27 25 48 78 32 18 20 78 46 37", "50\n49 13 81 20 73 62 19 49 65 95 32 84 24 96 5...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
9
codeforces
f862e4461b9c0bb971a8c79bb1c73e64
Not Wool Sequences
A sequence of non-negative integers *a*1,<=*a*2,<=...,<=*a**n* of length *n* is called a wool sequence if and only if there exists two integers *l* and *r* (1<=≤<=*l*<=≤<=*r*<=≤<=*n*) such that . In other words each wool sequence contains a subsequence of consecutive elements with xor equal to 0. The expression means...
{"inputs": ["3 2", "4 2", "1 2", "4 11", "5 100", "5444 31525", "60282 92611", "62600 39199", "14095 86011", "78606 36436", "25063 54317", "86232 41348", "94882 95834", "83781 52238", "21857 94145", "7413 87155", "7683 65667", "88201 96978", "50664 46559", "60607 63595", "85264 15318", "100000 100000", "100000 16", "10...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
8
codeforces
f871e22e89df88a072982b9d30fa1a08
Petya and Post
Little Vasya's uncle is a postman. The post offices are located on one circular road. Besides, each post office has its own gas station located next to it. Petya's uncle works as follows: in the morning he should leave the house and go to some post office. In the office he receives a portion of letters and a car. Then ...
{"inputs": ["4\n1 7 2 3\n8 1 1 3", "8\n1 2 1 2 1 2 1 2\n2 1 2 1 2 1 2 1", "20\n31 16 20 30 19 35 8 11 20 45 10 26 21 39 29 52 8 10 37 49\n16 33 41 32 43 24 35 48 19 37 28 26 7 10 23 48 18 2 1 25", "20\n10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10\n10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
2
codeforces
f87bced97729877cde26614688d8cc40
Online Meeting
Nearly each project of the F company has a whole team of developers working on it. They often are in different rooms of the office in different cities and even countries. To keep in touch and track the results of the project, the F company conducts shared online meetings in a Spyke chat. One day the director of the F ...
{"inputs": ["5 4\n+ 1\n+ 2\n- 2\n- 1", "3 2\n+ 1\n- 2", "2 4\n+ 1\n- 1\n+ 2\n- 2", "5 6\n+ 1\n- 1\n- 3\n+ 3\n+ 4\n- 4", "2 4\n+ 1\n- 2\n+ 2\n- 1", "1 1\n+ 1", "2 1\n- 2", "3 5\n- 1\n+ 1\n+ 2\n- 2\n+ 3", "10 8\n+ 1\n- 1\n- 2\n- 3\n+ 3\n+ 7\n- 7\n+ 9", "5 5\n+ 5\n+ 2\n+ 3\n+ 4\n+ 1", "5 4\n+ 1\n- 1\n+ 1\n+ 2", "10 3\n+ 1...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
codeforces
f88938594102e07665a6daf0fe883b8d
Make Palindrome
A string is called palindrome if it reads the same from left to right and from right to left. For example "kazak", "oo", "r" and "mikhailrubinchikkihcniburliahkim" are palindroms, but strings "abb" and "ij" are not. You are given string *s* consisting of lowercase Latin letters. At once you can choose any position in ...
{"inputs": ["aabc", "aabcd", "u", "ttttt", "xxxvvvxxvv", "wrwrwfrrfrffrrwwwffffwrfrrwfrrfrwwfwfrwfwfwffwrrwfrrrwwwfrrrwfrrfwrwwrwrrrffffwrrrwrwfffwrffrwwwrwww", "aabbcccdd", "baaab", "aaabbbhhlhlugkjgckj", "aabcc", "bbbcccddd", "zzzozzozozozoza", "aaabb", "zza", "azzzbbb", "bbaaccddc", "aaabbbccc", "aaaaabbccdd", "aaab...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
32
codeforces
f8a456e2fbac83b186fed6c3beb0157b
School Marks
Little Vova studies programming in an elite school. Vova and his classmates are supposed to write *n* progress tests, for each test they will get a mark from 1 to *p*. Vova is very smart and he can write every test for any mark, but he doesn't want to stand out from the crowd too much. If the sum of his marks for all t...
{"inputs": ["5 3 5 18 4\n3 5 4", "5 3 5 16 4\n5 5 5", "5 3 5 17 4\n5 5 5", "5 3 5 12 1\n5 5 1", "5 3 5 13 1\n5 5 1", "7 4 5 26 5\n5 2 4 5", "7 4 5 27 5\n5 2 4 5", "1 0 1000 999 1000", "1 0 1000 1000 1000", "1 0 1000 1000 999", "995 1 1000 1772 2\n1", "993 0 1000 63930 1", "5 3 5 25 4\n3 3 3", "7 4 5 25 5\n5 5 4 5", "7 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
7
codeforces
f8b348afc539834c64b2f852cbcc0b6e
Increasing Sequence
A sequence *a*0,<=*a*1,<=...,<=*a**t*<=-<=1 is called increasing if *a**i*<=-<=1<=&lt;<=*a**i* for each *i*:<=0<=&lt;<=*i*<=&lt;<=*t*. You are given a sequence *b*0,<=*b*1,<=...,<=*b**n*<=-<=1 and a positive integer *d*. In each move you may choose one element of the given sequence and add *d* to it. What is the least...
{"inputs": ["4 2\n1 3 3 2", "2 1\n1 1", "2 1\n2 5", "2 1\n1 2", "2 1\n1 1", "2 7\n10 20", "2 7\n1 1", "3 3\n18 1 9", "3 3\n15 17 9", "3 3\n10 9 12", "10 3\n2 1 17 10 5 16 8 4 15 17", "10 3\n6 11 4 12 22 15 23 26 24 26", "10 3\n10 24 13 15 18 14 15 26 33 35", "100 3\n529 178 280 403 326 531 671 427 188 866 669 646 421 8...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
229
codeforces
f8e254217a50cd8cfe9726c4fd64f082
Game of Credit Cards
After the fourth season Sherlock and Moriary have realized the whole foolishness of the battle between them and decided to continue their competitions in peaceful game of Credit Cards. Rules of this game are simple: each player bring his favourite *n*-digit credit card. Then both players name the digits written on the...
{"inputs": ["3\n123\n321", "2\n88\n00", "1\n4\n5", "1\n8\n7", "2\n55\n55", "3\n534\n432", "3\n486\n024", "5\n22222\n22222", "5\n72471\n05604", "5\n72471\n72471", "5\n72471\n41772", "8\n99999999\n99999999", "8\n01234567\n01234567", "8\n07070707\n76543210", "8\n88888888\n98769876", "8\n23456789\n01234567", "5\n11222\n221...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
174
codeforces
f915e41a0bd233ff98b58882ba47ed03
Problems for Round
There are *n* problems prepared for the next Codeforces round. They are arranged in ascending order by their difficulty, and no two problems have the same difficulty. Moreover, there are *m* pairs of similar problems. Authors want to split problems between two division according to the following rules: - Problemset ...
{"inputs": ["5 2\n1 4\n5 2", "3 3\n1 2\n2 3\n1 3", "3 2\n3 1\n3 2", "2 0", "2 1\n1 2", "3 0", "3 1\n1 2", "3 1\n1 3", "100000 0", "4 2\n1 2\n3 4", "3 1\n2 3", "3 2\n1 2\n1 3", "3 2\n1 2\n2 3", "4 0", "100000 1\n100000 1", "100000 1\n26711 97965", "100000 10\n99562 479\n643 99684\n593 99867\n99529 175\n99738 616\n99523 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
34
codeforces
f92c029ea391d554908f59e9e6fabd23
Circle Line
The circle line of the Berland subway has *n* stations. We know the distances between all pairs of neighboring stations: - *d*1 is the distance between the 1-st and the 2-nd station;- *d*2 is the distance between the 2-nd and the 3-rd station;...- *d**n*<=-<=1 is the distance between the *n*<=-<=1-th and the *n*-th ...
{"inputs": ["4\n2 3 4 9\n1 3", "4\n5 8 2 100\n4 1", "3\n1 1 1\n3 1", "3\n31 41 59\n1 1", "5\n16 13 10 30 15\n4 2", "6\n89 82 87 32 67 33\n4 4", "7\n2 3 17 10 2 2 2\n4 2", "3\n4 37 33\n3 3", "8\n87 40 96 7 86 86 72 97\n6 8", "10\n91 94 75 99 100 91 79 86 79 92\n2 8", "19\n1 1 1 1 2 1 1 1 1 1 2 1 3 2 2 1 1 1 2\n7 7", "34...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
295
codeforces
f93d8e4fa0765000b58f5a3f530474f7
Kay and Snowflake
After the piece of a devilish mirror hit the Kay's eye, he is no longer interested in the beauty of the roses. Now he likes to watch snowflakes. Once upon a time, he found a huge snowflake that has a form of the tree (connected acyclic graph) consisting of *n* nodes. The root of tree has index 1. Kay is very intereste...
{"inputs": ["7 4\n1 1 3 3 5 3\n1\n2\n3\n5", "2 2\n1\n1\n2"], "outputs": ["3\n2\n3\n6", "2\n2"]}
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
2
codeforces
f948aec78c25fd48780db400dd2e905b
Rank List
Another programming contest is over. You got hold of the contest's final results table. The table has the following data. For each team we are shown two numbers: the number of problems and the total penalty time. However, for no team we are shown its final place. You know the rules of comparing the results of two give...
{"inputs": ["7 2\n4 10\n4 10\n4 10\n3 20\n2 1\n2 1\n1 10", "5 4\n3 1\n3 1\n5 3\n3 1\n3 1", "5 1\n2 2\n1 1\n1 1\n1 1\n2 2", "6 3\n2 2\n3 1\n2 2\n4 5\n2 2\n4 5", "5 5\n3 1\n10 2\n2 2\n1 10\n10 2", "3 2\n3 3\n3 3\n3 3", "4 3\n10 3\n6 10\n5 2\n5 2", "5 3\n10 10\n10 10\n1 1\n10 10\n4 3", "3 1\n2 1\n1 1\n1 2", "1 1\n28 28", ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
143
codeforces
f971e5a1ca10583a10bfb7fe8f0d6ebd
Points on Line
Little Petya likes points a lot. Recently his mom has presented him *n* points lying on the line *OX*. Now Petya is wondering in how many ways he can choose three distinct points so that the distance between the two farthest of them doesn't exceed *d*. Note that the order of the points inside the group of three chosen...
{"inputs": ["4 3\n1 2 3 4", "4 2\n-3 -2 -1 0", "5 19\n1 10 20 30 50", "10 5\n31 36 43 47 48 50 56 69 71 86", "10 50\n1 4 20 27 65 79 82 83 99 100", "10 90\n24 27 40 41 61 69 73 87 95 97", "100 100\n-98 -97 -96 -93 -92 -91 -90 -87 -86 -84 -81 -80 -79 -78 -76 -75 -73 -71 -69 -67 -65 -64 -63 -62 -61 -54 -51 -50 -49 -48 -4...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
271
codeforces