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
d154b5f96fbc09054a93df0a65532334
Prefixes and Suffixes
You have a string *s*<==<=*s*1*s*2...*s*|*s*|, where |*s*| is the length of string *s*, and *s**i* its *i*-th character. Let's introduce several definitions: - A substring *s*[*i*..*j*] (1<=≤<=*i*<=≤<=*j*<=≤<=|*s*|) of string *s* is string *s**i**s**i*<=+<=1...*s**j*. - The prefix of string *s* of length *l* (1<=≤...
{"inputs": ["ABACABA", "AAA", "A", "AAAAAAAAAAAAAAAAXAAAAAAAAAAAAAAAAAAAAAAA", "AB", "AXAXA", "CODEFORCES", "GERALDPAVELGERALDPAVEL", "ZZ"], "outputs": ["3\n1 4\n3 2\n7 1", "3\n1 3\n2 2\n3 1", "1\n1 1", "17\n1 39\n2 37\n3 35\n4 33\n5 31\n6 29\n7 27\n8 25\n9 23\n10 21\n11 19\n12 17\n13 15\n14 13\n15 11\n16 9\n40 1", "1\...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
14
codeforces
d15b551ae8fabd1bdc627749b5d8d626
Lucky String
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Petya recently learned to determine whether a string of lowercase Latin letters is lucky. For each i...
{"inputs": ["5", "3", "8", "10", "16", "64", "128", "100", "47", "74", "477", "1000", "1024", "512", "747", "2075", "9475", "10000", "47589", "9999", "85475", "77777", "100000", "99994", "785", "1", "2", "7", "4", "99", "6", "9"], "outputs": ["abcda", "abc", "abcdabcd", "abcdabcdab", "abcdabcdabcdabcd", "abcdabcdabcdab...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
8
codeforces
d15d1f4a8fbfb34fdfd3b6f396e66f1a
Find Pair
You've got another problem dealing with arrays. Let's consider an arbitrary sequence containing *n* (not necessarily different) integers *a*1, *a*2, ..., *a**n*. We are interested in all possible pairs of numbers (*a**i*, *a**j*), (1<=≤<=*i*,<=*j*<=≤<=*n*). In other words, let's consider all *n*2 pairs of numbers, pick...
{"inputs": ["2 4\n2 1", "3 2\n3 1 5", "3 3\n1 1 2", "1 1\n-4", "3 7\n5 4 3", "3 6\n10 1 3", "4 12\n-1 -2 -3 -4", "5 10\n1 2 2 1 3", "5 13\n3 3 3 4 5", "8 26\n4 4 1 1 1 3 3 5", "10 90\n2 1 1 1 1 1 2 1 2 2", "10 6\n3 1 1 3 2 2 2 3 3 3", "10 18\n1 1 1 3 4 4 4 1 2 3", "50 622\n4 9 8 1 3 7 1 2 3 8 9 8 8 5 2 10 5 8 1 3 1 8 2...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
codeforces
d16620d13a8ade89313bb0547f8d9d8d
none
Valery is a PE teacher at a school in Berland. Soon the students are going to take a test in long jumps, and Valery has lost his favorite ruler! However, there is no reason for disappointment, as Valery has found another ruler, its length is *l* centimeters. The ruler already has *n* marks, with which he can make mea...
{"inputs": ["3 250 185 230\n0 185 250", "4 250 185 230\n0 20 185 250", "2 300 185 230\n0 300", "4 300 4 5\n0 6 7 300", "2 100 30 70\n0 100", "2 300 140 160\n0 300", "4 300 1 2\n0 298 299 300", "3 350 150 160\n0 310 350", "4 300 4 5\n0 298 299 300", "19 180 117 148\n0 1 19 20 21 28 57 65 68 70 78 88 100 116 154 157 173 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
codeforces
d172ac41a846604f1c877ea449cf1b55
Buy Low Sell High
You can perfectly predict the price of a certain stock for the next *N* days. You would like to profit on this knowledge, but only want to transact one share of stock per day. That is, each day you will either buy one share, sell one share, or do nothing. Initially you own zero shares, and you cannot sell shares when y...
{"inputs": ["9\n10 5 4 7 9 12 6 2 10", "20\n3 1 4 1 5 9 2 6 5 3 5 8 9 7 9 3 2 3 8 4", "20\n9 29 8 9 13 4 14 27 16 11 27 14 4 29 23 17 3 9 30 19", "100\n411 642 560 340 276 440 515 519 182 314 35 227 390 136 97 5 502 584 567 79 543 444 413 463 455 316 545 329 437 443 9 435 291 384 328 501 603 234 285 297 453 587 550 72 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
16
codeforces
d175d48a79770638f1ab5c9a7b472225
Broken Monitor
Innocentius has a problem — his computer monitor has broken. Now some of the pixels are "dead", that is, they are always black. As consequence, Innocentius can't play the usual computer games. He is recently playing the following game with his younger brother Polycarpus. Innocentius is touch-typing a program that pain...
{"inputs": ["4 8\n..w..w..\n........\n........\n..w..w..", "2 4\n....\n.w..", "2 6\nw..w.w\n...w..", "9 4\n....\n....\n....\n....\n....\n..w.\n....\n....\n.w..", "1 1\nw", "2 1\nw\n.", "2 1\nw\nw", "1 2\nww", "2 2\nww\n..", "2 2\n.w\n.w", "2 2\n..\nww", "2 2\nw.\nw.", "2 2\nw.\n.w", "2 2\n..\nw.", "3 3\n...\n..w\nw..",...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
codeforces
d184fb3f320d8dcb999611f7b0d120ec
none
Santa Claus is the first who came to the Christmas Olympiad, and he is going to be the first to take his place at a desk! In the classroom there are *n* lanes of *m* desks each, and there are two working places at each of the desks. The lanes are numbered from 1 to *n* from the left to the right, the desks in a lane ar...
{"inputs": ["4 3 9", "4 3 24", "2 4 4", "3 10 24", "10 3 59", "10000 10000 160845880", "1 1 1", "1 1 2", "1 10000 1", "1 10000 20000", "10000 1 1", "10000 1 10000", "10000 1 20000", "3 2 1", "3 2 2", "3 2 3", "3 2 4", "3 2 5", "3 2 6", "3 2 7", "3 2 8", "3 2 9", "3 2 10", "3 2 11", "3 2 12", "300 2000 1068628", "300 20...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
336
codeforces
d1852fd6497c284277904fff7cf01797
Weak Subsequence
Little Petya very much likes strings. Recently he has received a voucher to purchase a string as a gift from his mother. The string can be bought in the local shop. One can consider that the shop has all sorts of strings over the alphabet of fixed size. The size of the alphabet is equal to *k*. However, the voucher has...
{"inputs": ["2 2", "3 5", "2 139", "5 6", "1000 1002", "131 132", "4 4", "3 2", "1 1000000000", "666 888888888", "1000000 1000000000", "1000000 1000000", "1000000 2", "2 1000000000", "1000000 500000", "12345 543210123", "1 2", "1 3", "1 4", "1 5", "1 6", "1 7", "1 8", "2 3", "2 4", "2 5", "2 6", "2 7", "2 8", "3 3", "3...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
codeforces
d1946a1f3c70a6557cd0eba06be837de
The Red Button
Piegirl found the red button. You have one last chance to change the inevitable end. The circuit under the button consists of *n* nodes, numbered from 0 to *n* - 1. In order to deactivate the button, the *n* nodes must be disarmed in a particular order. Node 0 must be disarmed first. After disarming node *i*, the next...
{"inputs": ["2", "3", "4", "16", "5", "7", "32", "255", "65536", "99999", "9", "6", "8", "10", "12", "20", "25", "30", "32", "45", "50", "100", "126", "513", "514", "800", "1000", "2500", "6400", "23105", "24002", "29024", "36002", "55555", "65534", "77776", "88888", "99494", "99998", "90248", "99994", "100000", "98300...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
codeforces
d19a5d2d40c3191166b3cebf9ec2503a
The penguin's game
Pay attention: this problem is interactive. Penguin Xoriy came up with a new game recently. He has *n* icicles numbered from 1 to *n*. Each icicle has a temperature — an integer from 1 to 109. Exactly two of these icicles are special: their temperature is *y*, while a temperature of all the others is *x*<=≠<=*y*. You ...
{"inputs": ["4 2 1 1 3", "6 1 2 5 6", "2 4523 4235 1 2", "511 42 1000000000 255 511", "666 536870911 268435455 13 133", "999 536870912 536870911 1 999", "1000 123 321 1 513", "1000 1000000000 1 36 1000", "1000 15 16 511 512", "1000 16 15 511 512", "50 276891238 128284616 2 28", "100 745880634 179094068 84 99", "150 481...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
4
codeforces
d1a4489d4ae1ae49f2006c2a331b20f2
Palindromic Cut
Kolya has a string *s* of length *n* consisting of lowercase and uppercase Latin letters and digits. He wants to rearrange the symbols in *s* and cut it into the minimum number of parts so that each part is a palindrome and all parts have the same lengths. A palindrome is a string which reads the same backward as forw...
{"inputs": ["6\naabaac", "8\n0rTrT022", "2\naA", "1\ns", "10\n6IIC6CCIIC", "20\nqqqoqqoqMoqMMMqqMMqM", "45\nf3409ufEFU32rfsFJSKDFJ234234ASkjffjsdfsdfsj33", "30\n8M8MMMMMlrMlMMrMMllMMrllMMrMrl", "40\nTddTddddTddddddTdddTdddddddddddddddddddd", "45\nRRNRRRRRRRRRNRRRRRRRRRRRRRRNRRRRRRRRRRRNRRRRR", "115\nz9c2f5fxz9z999c9z99...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
6
codeforces
d1a4bc4ff7233cca17c240867693a8ff
Slime Combining
Your friend recently gave you some slimes for your birthday. You have *n* slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other *n*<=-<=1 slimes one by one. When you add a slime, you place it at the right of...
{"inputs": ["1", "2", "3", "8", "100000", "12345", "32", "70958", "97593", "91706", "85371", "97205", "34768", "12705", "30151", "4974", "32728", "8192", "65536", "32", "256", "4096", "33301", "16725", "149", "16277", "99701"], "outputs": ["1", "2", "2 1", "4", "17 16 11 10 8 6", "14 13 6 5 4 1", "6", "17 13 11 9 6 4 3...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
215
codeforces
d1b115caf00a7ad2e19bbdbf6e96df46
Book Reading
Recently Luba bought a very interesting book. She knows that it will take *t* seconds to read the book. Luba wants to finish reading as fast as she can. But she has some work to do in each of *n* next days. The number of seconds that Luba has to spend working during *i*-th day is *a**i*. If some free time remains, she...
{"inputs": ["2 2\n86400 86398", "2 86400\n0 86400", "2 86400\n1 86399", "100 1000000\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0", "1 1\n86399", "6 1200\n86400 864...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
396
codeforces
d1cb8e128dce4bdba12b0eb1c2f27fc2
k-Factorization
Given a positive integer *n*, find *k* integers (not necessary distinct) such that all these integers are strictly greater than 1, and their product is equal to *n*. The first line contains two integers *n* and *k* (2<=≤<=*n*<=≤<=100000, 1<=≤<=*k*<=≤<=20). If it's impossible to find the representation of *n* as a produ...
{"inputs": ["100000 2", "100000 20", "1024 5", "100000 10", "99999 3", "99999 4", "99999 5", "1024 10", "1024 11", "2048 11", "2 1", "2 2", "2 3", "2 4", "2 5", "2 1", "3 1", "3 2", "349 2", "8 1", "66049 2", "6557 2", "9 2", "4 2", "2 2", "4 4", "12 1", "17 1", "8 2", "14 2", "99991 1", "30 2", "97 1", "92 2", "4 1", ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
96
codeforces
d1f7ca2f5bc4490ad9a2954490f49833
Tidying Up
Smart Beaver is careful about his appearance and pays special attention to shoes so he has a huge number of pairs of shoes from the most famous brands of the forest. He's trying to handle his shoes carefully so that each pair stood side by side. But by the end of the week because of his very active lifestyle in his dre...
{"inputs": ["2 3\n1 1 2\n2 3 3", "3 4\n1 3 2 6\n2 1 5 6\n4 4 5 3", "2 2\n1 2\n1 2", "2 2\n1 1\n2 2", "2 2\n2 1\n1 2", "3 4\n1 1 6 6\n2 2 4 4\n3 3 5 5", "3 4\n5 3 3 2\n6 1 4 2\n6 1 5 4", "5 4\n9 9 10 10\n7 7 5 5\n2 2 3 3\n1 1 8 8\n4 4 6 6", "4 5\n7 9 9 10 10\n7 5 5 3 3\n8 1 1 2 2\n8 6 6 4 4", "5 4\n6 4 4 3\n10 8 5 1\n10...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
codeforces
d21e0b3207ee3c755958cfc2ee170922
Leha and another game about graph
Leha plays a computer game, where is on each level is given a connected graph with *n* vertices and *m* edges. Graph can contain multiple edges, but can not contain self loops. Each vertex has an integer *d**i*, which can be equal to 0, 1 or <=-<=1. To pass the level, he needs to find a «good» subset of edges of the gr...
{"inputs": ["1 0\n1", "4 5\n0 0 0 -1\n1 2\n2 3\n3 4\n1 4\n2 4", "2 1\n1 1\n1 2", "3 3\n0 -1 1\n1 2\n2 3\n1 3", "10 10\n-1 -1 -1 -1 -1 -1 -1 -1 -1 -1\n6 7\n8 3\n6 4\n4 2\n9 2\n5 10\n9 8\n10 7\n5 1\n6 2", "3 2\n1 0 1\n1 2\n2 3"], "outputs": ["-1", "0", "1\n1", "1\n2", "0", "2\n2\n1"]}
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
codeforces
d2370e5d51e7c7104ac917dd0c1ee297
Home Numbers
The main street of Berland is a straight line with *n* houses built along it (*n* is an even number). The houses are located at both sides of the street. The houses with odd numbers are at one side of the street and are numbered from 1 to *n*<=-<=1 in the order from the beginning of the street to the end (in the pictur...
{"inputs": ["4 2", "8 5", "2 1", "2 2", "10 1", "10 10", "100000 100000", "100000 2", "100000 3", "100000 99999", "100 100", "3000 34", "2000 1", "100000 1", "24842 1038", "1628 274", "16186 337", "24562 2009", "9456 3443", "5610 332", "1764 1288", "28588 13902", "92480 43074", "40022 26492", "85766 64050", "67808 6180...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
120
codeforces
d24e0144ab5b191851e3d3b0c9dc7679
Three displays
It is the middle of 2018 and Maria Stepanovna, who lives outside Krasnokamensk (a town in Zabaikalsky region), wants to rent three displays to highlight an important problem. There are $n$ displays placed along a road, and the $i$-th of them can display a text with font size $s_i$ only. Maria Stepanovna wants to rent ...
{"inputs": ["5\n2 4 5 4 10\n40 30 20 10 40", "3\n100 101 100\n2 4 5", "10\n1 2 3 4 5 6 7 8 9 10\n10 13 11 14 15 12 13 13 18 13", "3\n1 2 3\n100000000 100000000 100000000", "3\n999999998 999999999 1000000000\n100000000 100000000 99999999", "10\n802030518 598196518 640274071 983359971 71550121 96204862 799843967 44617360...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
104
codeforces
d29152b2c4baf0df2caf31c9d71faa80
Sums of Digits
Vasya had a strictly increasing sequence of positive integers *a*1, ..., *a**n*. Vasya used it to build a new sequence *b*1, ..., *b**n*, where *b**i* is the sum of digits of *a**i*'s decimal representation. Then sequence *a**i* got lost and all that remained is sequence *b**i*. Vasya wonders what the numbers *a**i* c...
{"inputs": ["3\n1\n2\n3", "3\n3\n2\n1", "10\n1\n2\n3\n4\n5\n6\n7\n8\n9\n1", "10\n8\n8\n5\n1\n2\n7\n3\n8\n9\n4", "10\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1", "100\n1\n2\n3\n4\n5\n6\n7\n8\n9\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n5\n6\n7\n...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
2
codeforces
d2b5986193f7609c75ca4859225eff13
Mahmoud and a Dictionary
Mahmoud wants to write a new dictionary that contains *n* words and relations between them. There are two types of relations: synonymy (i. e. the two words mean the same) and antonymy (i. e. the two words mean the opposite). From time to time he discovers a new relation between two words. He know that if two words hav...
{"inputs": ["3 3 4\nhate love like\n1 love like\n2 love hate\n1 hate like\nlove like\nlove hate\nlike hate\nhate like", "8 6 5\nhi welcome hello ihateyou goaway dog cat rat\n1 hi welcome\n1 ihateyou goaway\n2 hello ihateyou\n2 hi goaway\n2 hi hello\n1 hi hello\ndog cat\ndog hi\nhi hello\nihateyou goaway\nwelcome ihatey...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
4
codeforces
d3197ae780b3073cca1cf30089f232ea
Pacifist frogs
Thumbelina has had an accident. She has found herself on a little island in the middle of a swamp and wants to get to the shore very much. One can get to the shore only by hills that are situated along a straight line that connects the little island with the shore. Let us assume that the hills are numbered from 1 to *...
{"inputs": ["5 3 5\n2 3 4\n1 2 3 4 5", "1000000000 2 3\n2 5\n999999995 999999998 999999996", "1 1 1\n1\n1", "2 2 1\n2 1\n1", "3 2 2\n2 4\n3 2", "10 3 6\n5 2 8\n5 6 7 8 9 10", "10 10 9\n10 9 8 7 6 5 4 3 2 1\n10 9 8 7 5 4 3 2 1", "20 3 5\n2 3 5\n2 5 6 10 15", "20 4 8\n1 2 3 4\n2 4 6 8 10 12 14 16", "10 5 5\n1 5 3 5 1\n1 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
39
codeforces
d33ed0a7470768868bc662f77d990f03
Three matrices
Chubby Yang is studying linear equations right now. He came up with a nice problem. In the problem you are given an *n*<=×<=*n* matrix *W*, consisting of integers, and you should find two *n*<=×<=*n* matrices *A* and *B*, all the following conditions must hold: - *A**ij*<==<=*A**ji*, for all *i*,<=*j* (1<=≤<=*i*,<=*...
{"inputs": ["2\n1 4\n3 2", "3\n1 2 3\n4 5 6\n7 8 9", "8\n62 567 1382 1279 728 1267 1262 568\n77 827 717 1696 774 248 822 1266\n563 612 995 424 1643 1197 338 1141\n1579 806 1254 468 184 1571 716 772\n1087 182 1312 772 605 1674 720 1349\n1393 988 873 157 403 301 1519 1192\n1085 625 1395 1087 847 1360 1004 594\n1368 1056 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
34
codeforces
d34fce590c9ab5f1c4b730f672fac6e8
Friends Meeting
Two friends are on the coordinate axis *Ox* in points with integer coordinates. One of them is in the point *x*1<==<=*a*, another one is in the point *x*2<==<=*b*. Each of the friends can move by one along the line in any direction unlimited number of times. When a friend moves, the tiredness of a friend changes acco...
{"inputs": ["3\n4", "101\n99", "5\n10", "1\n2", "1\n1000", "999\n1000", "1000\n999", "1000\n1", "2\n1", "2\n999", "2\n998", "999\n2", "998\n2", "2\n1000", "1000\n2", "1\n999", "999\n1", "188\n762", "596\n777", "773\n70", "825\n729", "944\n348", "352\n445", "529\n656", "19\n315", "138\n370", "546\n593", "285\n242", "773...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
607
codeforces
d35468d66b47dffb57a8ada4ba7221e5
Vanya and Fence
Vanya and his friends are walking along the fence of height *h* and they do not want the guard to notice them. In order to achieve this the height of each of the friends should not exceed *h*. If the height of some person is greater than *h* he can bend down and then he surely won't be noticed by the guard. The height ...
{"inputs": ["3 7\n4 5 14", "6 1\n1 1 1 1 1 1", "6 5\n7 6 8 9 10 5", "10 420\n214 614 297 675 82 740 174 23 255 15", "10 561\n657 23 1096 487 785 66 481 554 1000 821", "100 342\n478 143 359 336 162 333 385 515 117 496 310 538 469 539 258 676 466 677 1 296 150 560 26 213 627 221 255 126 617 174 279 178 24 435 70 145 619 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
889
codeforces
d3765fa3113a54c91060c293e49d86cc
Strange Calculation and Cats
Gosha's universe is a table consisting of *n* rows and *m* columns. Both the rows and columns are numbered with consecutive integers starting with 1. We will use (*r*,<=*c*) to denote a cell located in the row *r* and column *c*. Gosha is often invited somewhere. Every time he gets an invitation, he first calculates t...
{"inputs": ["1 3 3\n2 1 2 3\n3 1 2 5\n1 1 1 7", "3 3 3\n2 2 2 2\n1 3 3 5\n1 3 3 7", "4 5 5\n2 2 5 3\n2 2 4 6\n3 2 4 9\n1 4 4 13\n1 4 4 15", "1 1 1\n1 1 1 2", "3 3 1\n1 3 3 5", "2 2 5\n2 1 1 8\n3 1 1 12345\n2 1 2 22345\n3 1 2 31243\n1 2 2 111115", "1 2 3\n1 1 1 2\n1 1 2 5\n1 1 1 19", "1 1 4\n2 1 1 2\n3 1 1 5\n1 1 1 7\n1...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
codeforces
d377f3b3aaa38b4a7edac7027b9c009a
Selling Souvenirs
After several latest reforms many tourists are planning to visit Berland, and Berland people understood that it's an opportunity to earn money and changed their jobs to attract tourists. Petya, for example, left the IT corporation he had been working for and started to sell souvenirs at the market. This morning, as us...
{"inputs": ["1 1\n2 1", "2 2\n1 3\n2 2", "4 3\n3 10\n2 7\n2 8\n1 1", "5 5\n3 5\n2 6\n3 2\n1 1\n1 6", "6 6\n1 6\n1 4\n1 8\n3 2\n3 2\n2 8", "6 12\n1 7\n1 10\n2 8\n1 2\n2 9\n3 5", "6 18\n3 3\n1 10\n2 10\n3 6\n1 3\n2 3", "20 25\n2 13\n3 11\n1 32\n1 43\n3 85\n1 14\n2 57\n1 54\n1 38\n2 96\n2 89\n3 64\n1 79\n2 73\n1 73\n2 34\...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
4
codeforces
d37c153e46473b00ba4e801f4917d3d7
Bulbs
Vasya wants to turn on Christmas lights consisting of *m* bulbs. Initially, all bulbs are turned off. There are *n* buttons, each of them is connected to some set of bulbs. Vasya can press any of these buttons. When the button is pressed, it turns on all the bulbs it's connected to. Can Vasya light up all the bulbs? I...
{"inputs": ["3 4\n2 1 4\n3 1 3 1\n1 2", "3 3\n1 1\n1 2\n1 1", "3 4\n1 1\n1 2\n1 3", "1 5\n5 1 2 3 4 5", "1 5\n5 4 4 1 2 3", "1 5\n5 1 1 1 1 5", "2 5\n4 3 1 4 2\n4 2 3 4 5", "5 7\n2 6 7\n5 1 1 1 1 1\n3 6 5 4\n0\n4 4 3 2 1", "100 100\n0\n0\n0\n1 53\n0\n0\n1 34\n1 54\n0\n1 14\n0\n1 33\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n1 82\n...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
439
codeforces
d3891b505ee7f8ab84e9bc52c21e7b57
none
Manao is taking part in a quiz. The quiz consists of *n* consecutive questions. A correct answer gives one point to the player. The game also has a counter of consecutive correct answers. When the player answers a question correctly, the number on this counter increases by 1. If the player answers a question incorrectl...
{"inputs": ["5 3 2", "5 4 2", "300 300 3", "300 282 7", "1000000000 1000000000 1000000000", "1000000000 800000000 2", "2 0 2", "2 1 2", "2 2 2", "3 2 2", "3 3 2", "10 7 3", "10 8 3", "10 8 5", "10 9 5", "972 100 2", "972 600 2", "972 900 2", "972 900 4", "972 900 5", "12345 11292 3", "120009 70955 2", "120009 100955 2"...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
6
codeforces
d38fb1c489d4cbf930b0337c192c450b
Interactive LowerBound
This is an interactive problem. You are given a sorted in increasing order singly linked list. You should find the minimum integer in the list which is greater than or equal to *x*. More formally, there is a singly liked list built on an array of *n* elements. Element with index *i* contains two integers: *value**i* ...
{"inputs": ["5 3 80\n97 -1\n58 5\n16 2\n81 1\n79 4", "5 1 6\n1 2\n2 3\n3 4\n4 5\n5 -1", "1 1 0\n0 -1", "1 1 2\n0 -1", "1 1 1000000000\n0 -1", "5 3 3\n3 5\n2 1\n0 4\n1 2\n4 -1", "5 3 145337745\n619347297 5\n344132479 1\n122841322 4\n169280018 2\n740666615 -1", "5 3 315433300\n411188472 5\n316581280 1\n200698791 4\n31488...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
8
codeforces
d39d202a68a2cf02ae6f18f45fddeaca
Renting Bikes
A group of *n* schoolboys decided to ride bikes. As nobody of them has a bike, the boys need to rent them. The renting site offered them *m* bikes. The renting price is different for different bikes, renting the *j*-th bike costs *p**j* rubles. In total, the boys' shared budget is *a* rubles. Besides, each of them ha...
{"inputs": ["2 2 10\n5 5\n7 6", "4 5 2\n8 1 1 2\n6 3 7 5 2", "1 1 2\n1\n2", "4 1 1\n3 2 3 2\n3", "1 4 1\n3\n2 4 5 5", "3 3 3\n1 1 2\n3 5 6", "4 5 6\n5 1 7 2\n8 7 3 9 8", "4 8 10\n2 1 2 2\n10 12 10 8 7 9 10 9", "8 4 18\n9 4 2 2 7 5 1 1\n11 12 8 9", "6 6 2\n6 1 5 3 10 1\n11 4 7 8 11 7", "10 10 7\n6 7 15 1 3 1 14 6 7 4\n1...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
4
codeforces
d39f143028f8d494421257e9610a63a2
Inna and Choose Options
There always is something to choose from! And now, instead of "Noughts and Crosses", Inna choose a very unusual upgrade of this game. The rules of the game are given below: There is one person playing the game. Before the beginning of the game he puts 12 cards in a row on the table. Each card contains a character: "X"...
{"inputs": ["4\nOXXXOXOOXOOX\nOXOXOXOXOXOX\nXXXXXXXXXXXX\nOOOOOOOOOOOO", "2\nOOOOOOOOOOOO\nXXXXXXXXXXXX", "13\nXXXXXXXXXXXX\nXXXXXXXXXXXX\nXXXXXXXXXXXX\nXXXXXXXXXXXX\nXXXXXXXXXXXX\nXXXXXXXXXXXX\nXXXXXXXXXXXX\nXXXXXXXXXXXX\nXXXXXXXXXXXX\nXXXXXXXXXXXX\nXXXXXXXXXXXX\nXXXXXXXXXXXX\nXXXXXXXXXXXX"], "outputs": ["3 1x12 2x6 4...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
92
codeforces
d3cc84d8a4738925b046a983cf21b4b1
Left-handers, Right-handers and Ambidexters
You are at a water bowling training. There are *l* people who play with their left hand, *r* people, who play with their right hand, and *a* ambidexters, who can play with left or right hand. The coach decided to form a team of even number of players, exactly half of the players should play with their right hand, and ...
{"inputs": ["1 4 2", "5 5 5", "0 2 0", "30 70 34", "89 32 24", "89 44 77", "0 0 0", "100 100 100", "1 1 1", "30 70 35", "89 44 76", "0 100 100", "100 0 100", "100 1 100", "1 100 100", "100 100 0", "100 100 1", "1 2 1", "0 0 100", "0 100 0", "100 0 0", "10 8 7", "45 47 16", "59 43 100", "34 1 30", "14 81 1", "53 96 94",...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
404
codeforces
d3d3a53758643400bf3241186c9e43bb
Regular Bridge
An undirected graph is called *k*-regular, if the degrees of all its vertices are equal *k*. An edge of a connected graph is called a bridge, if after removing it the graph is being split into two connected components. Build a connected undirected *k*-regular graph containing at least one bridge, or else state that su...
{"inputs": ["1", "3", "11", "10", "2", "4", "5", "6", "7", "8", "9", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "50", "51", "52", "53",...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
2
codeforces
d3de88c38870d2f1361cde69bf370df5
Partial Teacher
A teacher decides to give toffees to his students. He asks *n* students to stand in a queue. Since the teacher is very partial, he follows the following rule to distribute toffees. He looks at the first two students and gives more toffees to the student having higher marks than the other one. If they have the same mar...
{"inputs": ["5\nLRLR", "5\n=RRR", "6\nRLRL=", "3\nR=", "7\nRR==RR", "166\nR===RL=LRRR=RRRL=LRR=R=RR==L=R=R=RRR=RR=RLLRRL=LLRL==L=R==RLR==RL=RR=LR==R=R=LLRLRLR=RR=RLLRLR=RRLL==L=LR=RR=RRRL=RLLLR==L=RRLRLLLLLLLRL===LRLRLRLRRLL=LRLL===LRLRR==", "333\nLL=LR=R=RRR=L=LRR=RLRLLLR=LRL=RRLRRRLLRRLL====RL=L====LLRL=RR==L==RLL==L...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
13
codeforces
d3e51e02198078824b0169caf85d97d6
Till I Collapse
Rick and Morty want to find MR. PBH and they can't do it alone. So they need of Mr. Meeseeks. They Have generated *n* Mr. Meeseeks, standing in a line numbered from 1 to *n*. Each of them has his own color. *i*-th Mr. Meeseeks' color is *a**i*. Rick and Morty are gathering their army and they want to divide Mr. Meese...
{"inputs": ["5\n1 3 4 3 3", "8\n1 5 7 8 1 7 6 1", "10\n4 1 2 6 8 5 3 9 3 9", "85\n23 11 69 1 49 10 7 13 66 35 81 4 51 2 62 55 31 18 85 34 59 44 20 28 27 5 6 79 43 78 45 64 61 56 12 40 54 52 24 14 26 65 75 72 30 46 67 80 38 70 25 60 50 8 17 84 41 71 58 76 19 47 73 29 3 48 82 33 39 63 15 37 83 36 9 32 16 57 68 53 21 77 2...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
2
codeforces
d3e540e3910727f7dcf520e39d57d44d
Irrational problem
Little Petya was given this problem for homework: You are given function (here represents the operation of taking the remainder). His task is to count the number of integers *x* in range [*a*;*b*] with property *f*(*x*)<==<=*x*. It is a pity that Petya forgot the order in which the remainders should be taken and wr...
{"inputs": ["2 7 1 8 2 8", "20 30 40 50 0 100", "31 41 59 26 17 43", "1 2 3 4 0 0", "1 2 3 4 1 1", "1 2 999 1000 30 40", "17 18 19 20 17 20", "17 18 19 20 16 20", "41 449 328 474 150 709", "467 329 936 440 117 700", "258 811 952 491 931 993", "823 431 359 590 153 899", "292 370 404 698 699 876", "442 705 757 527 868 89...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
63
codeforces
d41eccdddbe3022c0a46f60c8badcf60
Abbreviation
You are given a text consisting of $n$ space-separated words. There is exactly one space character between any pair of adjacent words. There are no spaces before the first word and no spaces after the last word. The length of text is the number of letters and spaces in it. $w_i$ is the $i$-th word of text. All words co...
{"inputs": ["6\nto be or not to be", "10\na ab a a b ab a a b c", "6\naa bb aa aa bb bb", "45\nxr l pl sx c c u py sv j f x h u y w w bs u cp e ad ib b tz gy lm e s n ln kg fs rd ln v f sh t z r b j w of", "250\nf r s d b f f k d e k v m b t k k j t t a o m m s n d w l v g e k x d w k v a j h c a g x s d e t z z w q z ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
3
codeforces
d44b54a5c176b8db281df28c230f992d
Beautiful Numbers
Vitaly is a very weird man. He's got two favorite digits *a* and *b*. Vitaly calls a positive integer good, if the decimal representation of this integer only contains digits *a* and *b*. Vitaly calls a good number excellent, if the sum of its digits is a good number. For example, let's say that Vitaly's favourite dig...
{"inputs": ["1 3 3", "2 3 10", "6 8 14215", "4 9 104671", "6 7 78755", "1 8 265", "3 9 37413", "1 7 49055", "3 4 11028", "2 6 32377", "3 5 80791", "4 8 11857", "1 3 10785", "4 6 11808", "1 2 11857", "2 4 88193", "1 4 37226", "2 5 53049", "3 6 1000000", "7 9 999999", "8 9 999999", "3 8 1000000", "2 8 999999", "1 6 99769...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
54
codeforces
d45fb32c9fa52c71f3024a033629d604
Shift It!
There is a square box 6<=×<=6 in size. It contains 36 chips 1<=×<=1 in size. Those chips contain 36 different characters — "0"-"9" and "A"-"Z". There is exactly one chip with each character. You are allowed to make the following operations: you may choose one of 6 rows or one of 6 columns and cyclically shift the chip...
{"inputs": ["01W345\n729AB6\nCD8FGH\nIJELMN\nOPKRST\nUVQXYZ", "012345\n6789AB\nCDEFGH\nIJKLMN\nOPQRST\nUVWXYZ", "102345\n6789AB\nCDEFGH\nIJKLMN\nOPQRST\nUVWXYZ", "234501\n789AB6\nGHCDEF\nIJKLMN\nRSTOPQ\nZUVWXY", "2X4501\n6783AB\nDE9GHC\nIJKFMN\nOPQLST\nZUVWRY", "0123A5\n67894B\nCDEFGH\nIKJLMN\nOPQRST\nUVWXZY", "ZYXWVU\...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
codeforces
d4606777a789a26895f0e249ec9f7499
Kyoya and Permutation
Let's define the permutation of length *n* as an array *p*<==<=[*p*1,<=*p*2,<=...,<=*p**n*] consisting of *n* distinct integers from range from 1 to *n*. We say that this permutation maps value 1 into the value *p*1, value 2 into the value *p*2 and so on. Kyota Ootori has just learned about cyclic representation of a ...
{"inputs": ["4 3", "10 1", "1 1", "50 1", "10 57", "50 20365011074", "20 9999", "49 12586269025", "49 1", "10 89", "10 1", "5 8", "5 1", "25 121393", "25 1", "1 1", "2 2", "3 3", "4 2", "5 8", "6 10", "7 20", "8 24", "9 1", "10 24", "11 77", "12 101", "13 240", "14 356", "15 463", "16 747", "17 734", "18 1809", "19 859...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
21
codeforces
d462df4068f05173ec26a6fb99d24783
Right Triangles
You are given a *n*<=×<=*m* field consisting only of periods ('.') and asterisks ('*'). Your task is to count all right triangles with two sides parallel to the square sides, whose vertices are in the centers of '*'-cells. A right triangle is a triangle in which one angle is a right angle (that is, a 90 degree angle). ...
{"inputs": ["2 2\n**\n*.", "3 4\n*..*\n.**.\n*.**", "3 2\n..\n..\n*.", "1 2\n**", "1 3\n*.*", "5 2\n*.\n**\n.*\n..\n.*", "2 3\n...\n..*", "10 9\n..*..**..\n*.*...**.\n.*...*.*.\n.*****.*.\n.*.*.**.*\n.**.*....\n**.......\n**..*.*.*\n*.*.**.*.\n*.*.*.*.*", "2 3\n.*.\n**.", "5 3\n**.\n..*\n*.*\n*.*\n*..", "4 2\n**\n**\n....
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
22
codeforces
d4718bd75cf416c1554ff23d9d429005
About Bacteria
Qwerty the Ranger took up a government job and arrived on planet Mars. He should stay in the secret lab and conduct some experiments on bacteria that have funny and abnormal properties. The job isn't difficult, but the salary is high. At the beginning of the first experiment there is a single bacterium in the test tub...
{"inputs": ["3 1 3 5", "1 4 4 7", "2 2 4 100", "1 2 3 100", "10 10 10 123456", "847 374 283 485756", "37 1 283475 8347", "1 1 1 1", "1 1 1 1000000", "1 1 1000000 1", "1 1 1000000 1000000", "1 1000000 1 1", "1 1000000 1 1000000", "1 1000000 1000000 1", "1 1000000 1000000 1000000", "1000000 1 1 1", "1000000 1 1 1000000",...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
23
codeforces
d475b1db315b445f2e098c807d2d52c1
New Skateboard
Max wants to buy a new skateboard. He has calculated the amount of money that is needed to buy a new skateboard. He left a calculator on the floor and went to ask some money from his parents. Meanwhile his little brother Yusuf came and started to press the keys randomly. Unfortunately Max has forgotten the number which...
{"inputs": ["124", "04", "5810438174", "1", "039", "97247", "5810438174", "12883340691714056185860211260984431382156326935244", "2144315253572020279108092911160072328496568665545836825277616363478721946398140227406814602154768031", "801246490140549710812136081378174660462546524926277418604782585582063971131982328238598...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
270
codeforces
d484895805b8041afab5927ffdb460e2
New Year Candles
Vasily the Programmer loves romance, so this year he decided to illuminate his room with candles. Vasily has *a* candles.When Vasily lights up a new candle, it first burns for an hour and then it goes out. Vasily is smart, so he can make *b* went out candles into a new candle. As a result, this new candle can be used ...
{"inputs": ["4 2", "6 3", "1000 1000", "123 5", "1000 2", "1 2", "1 3", "1 4", "2 2", "3 2", "3 3", "999 2", "1000 3", "1000 4", "1 1000", "80 970", "80 970", "80 970", "80 970", "80 970", "80 970", "10 4", "4 3", "91 5", "777 17", "100 4", "5 3", "6 4", "26 8", "9 4", "20 3", "17 3"], "outputs": ["7", "8", "1001", "15...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
472
codeforces
d499e64d29c12399b541b19d5ace8193
Chat
There are times you recall a good old friend and everything you've come through together. Luckily there are social networks — they store all your message history making it easy to know what you argued over 10 years ago. More formal, your message history is a sequence of messages ordered by time sent numbered from 1 to...
{"inputs": ["6 0\n0 1 1 2 3 2", "10 1\n0 1 0 3 4 5 2 3 7 0", "2 2\n0 1", "1 1\n0", "5 2\n0 1 2 3 1", "30 1\n0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 0 0 0 0 0 2 0 0 0 0 0 2 1 0", "100 5\n0 1 1 1 0 5 6 6 8 8 9 11 12 11 8 0 0 14 6 16 7 21 15 23 15 24 0 0 0 28 0 29 26 27 19 0 0 21 37 32 40 30 37 34 39 38 34 38 0 0 41 24 45 47 0 33...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
52
codeforces
d4adf413afcc5e9f6dbc13ec73736099
Vowels
Iahubina is tired of so many complicated languages, so she decided to invent a new, simple language. She already made a dictionary consisting of *n* 3-words. A 3-word is a sequence of exactly 3 lowercase letters of the first 24 letters of the English alphabet (*a* to *x*). She decided that some of the letters are vowel...
{"inputs": ["5\nabc\naaa\nada\nbcd\ndef", "100\namd\namj\natr\nbcp\nbjm\ncna\ncpj\ncse\ndij\ndjp\ndlv\nebk\nedf\nelw\nfbr\nfcl\nfhs\nflo\nfmj\ngcg\ngen\nghg\ngvb\ngxx\nhbe\nhbf\nhgu\nhlv\nhqa\nibg\nifp\nima\nitt\nivl\nixu\njle\njli\nket\nkit\nkws\nlep\nles\nleu\nmbp\nmci\nmdv\nmhf\nmih\nmll\nmop\nndp\nnfs\nngl\nnng\noi...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
codeforces
d4bcfbf18441008f1ac0b108ef216426
Cow Program
Farmer John has just given the cows a program to play with! The program contains two integer variables, *x* and *y*, and performs the following operations on a sequence *a*1,<=*a*2,<=...,<=*a**n* of positive integers: 1. Initially, *x*<==<=1 and *y*<==<=0. If, after any step, *x*<=≤<=0 or *x*<=&gt;<=*n*, the program ...
{"inputs": ["4\n2 4 1", "3\n1 2", "5\n2 2 1 3", "2\n1", "8\n7 6 2 6 2 6 6", "8\n4 5 3 2 3 3 3", "3\n1 1", "5\n3 2 4 2", "92\n79 52 17 45 47 64 48 49 650617238 32 9 74 12 80 39 41 73 22 25 73 79 51 85 21 3 56 255371563 2 986959075 17 30 70 577324422 84 7 39 85 18 6 63 44 52 37 5 36 9 12 34 9 60 56 1 491072951 57 7 91 76...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
2
codeforces
d4c9f2251593a3c8a9c4136b405c21e0
Runner's Problem
You are running through a rectangular field. This field can be represented as a matrix with 3 rows and *m* columns. (*i*,<=*j*) denotes a cell belonging to *i*-th row and *j*-th column. You start in (2,<=1) and have to end your path in (2,<=*m*). From the cell (*i*,<=*j*) you may advance to: - (*i*<=-<=1,<=*j*<=+<=1...
{"inputs": ["2 5\n1 3 4\n2 2 3", "50 100\n3 24 49\n2 10 12\n1 87 92\n2 19 60\n2 53 79\n3 65 82\n3 10 46\n1 46 86\n2 55 84\n1 50 53\n3 80 81\n3 66 70\n2 35 52\n1 63 69\n2 65 87\n3 68 75\n1 33 42\n1 56 90\n3 73 93\n2 20 26\n2 42 80\n2 83 87\n3 99 99\n1 14 79\n2 94 97\n1 66 85\n1 7 73\n1 50 50\n2 16 40\n2 76 94\n1 71 98\n...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
2
codeforces
d4e0927d80d36c92d3c5e2af89871259
Forming Teams
One day *n* students come to the stadium. They want to play football, and for that they need to split into teams, the teams must have an equal number of people. We know that this group of people has archenemies. Each student has at most two archenemies. Besides, if student *A* is an archenemy to student *B*, then stud...
{"inputs": ["5 4\n1 2\n2 4\n5 3\n1 4", "6 2\n1 4\n3 4", "6 6\n1 2\n2 3\n3 1\n4 5\n5 6\n6 4", "5 1\n1 2", "8 8\n1 2\n2 3\n3 4\n4 5\n5 6\n6 7\n7 8\n8 1", "28 3\n15 3\n10 19\n17 25", "2 1\n1 2", "3 1\n2 3", "3 2\n1 2\n3 2", "3 3\n1 2\n1 3\n2 3", "4 1\n1 4", "4 2\n4 1\n2 1", "4 3\n1 3\n3 2\n2 4", "4 3\n3 2\n4 2\n4 3", "5 3...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
28
codeforces
d4eccfcdc4a1ce493b2358cdc4f24618
Cableway
A group of university students wants to get to the top of a mountain to have a picnic there. For that they decided to use a cableway. A cableway is represented by some cablecars, hanged onto some cable stations by a cable. A cable is scrolled cyclically between the first and the last cable stations (the first of them ...
{"inputs": ["1 3 2", "3 2 1", "3 5 2", "10 10 10", "29 7 24", "28 94 13", "90 89 73", "0 0 1", "0 0 2", "0 1 0", "0 1 1", "0 1 2", "0 2 0", "0 2 1", "0 2 2", "1 0 0", "1 0 1", "1 0 2", "1 1 0", "1 1 1", "1 1 2", "1 2 0", "1 2 1", "1 2 2", "2 0 0", "2 0 1", "2 0 2", "2 1 0", "2 1 1", "2 1 2", "2 2 0", "2 2 1", "2 2 2", ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
133
codeforces
d4f238414fd52248994773b270d7e1bb
Routine Problem
Manao has a monitor. The screen of the monitor has horizontal to vertical length ratio *a*:*b*. Now he is going to watch a movie. The movie's frame has horizontal to vertical length ratio *c*:*d*. Manao adjusts the view in such a way that the movie preserves the original frame ratio, but also occupies as much space on ...
{"inputs": ["1 1 3 2", "4 3 2 2", "3 4 2 3", "4 4 5 5", "1 1 1 1", "1000 1000 1000 1000", "125 992 14 25", "999 998 997 996", "984 286 976 284", "999 1000 1000 999", "999 1000 998 999", "1 1000 1000 1", "1 999 1000 1", "50 80 6 3", "114 891 20 3", "10 13 75 57", "21 35 34 51", "41 95 82 30", "123 150 82 60", "100 175 1...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
13
codeforces
d4f7e1eed1a5f669bc061ada8368101c
Merge Equals
You are given an array of positive integers. While there are at least two equal elements, we will perform the following operation. We choose the smallest value $x$ that occurs in the array $2$ or more times. Take the first two occurrences of $x$ in this array (the two leftmost occurrences). Remove the left of these two...
{"inputs": ["7\n3 4 1 2 2 1 1", "5\n1 1 3 1 1", "5\n10 40 20 50 30", "100\n10 10 15 12 15 13 15 12 10 10 15 11 13 14 13 14 10 13 12 10 14 12 13 11 14 15 12 11 11 15 12 12 11 14 14 14 15 10 10 15 15 13 13 15 10 12 14 10 12 13 11 15 11 13 14 12 10 12 11 14 13 15 13 15 13 14 14 11 12 13 11 14 10 10 15 10 15 12 15 12 13 10...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
44
codeforces
d4fcaa5a12e174eeb47b6b1519863b94
Initial Bet
There are five people playing a game called "Generosity". Each person gives some non-zero number of coins *b* as an initial bet. After all players make their bets of *b* coins, the following operation is repeated for several times: a coin is passed from one player to some other player. Your task is to write a program ...
{"inputs": ["2 5 4 0 4", "4 5 9 2 1", "0 0 0 0 0", "1 2 1 2 3", "100 0 0 0 0", "2 3 4 5 6", "1 1 1 1 1", "0 1 2 3 4", "100 100 100 100 100", "93 100 99 90 98", "99 99 99 99 99", "99 98 98 99 100", "43 83 1 0 23", "43 83 1 100 23", "57 83 11 4 93", "87 38 19 33 100", "56 0 0 0 4", "0 0 0 0 1", "99 100 100 100 100"], "ou...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
46
codeforces
d505dd4a88f3b77f441d522c3490d39d
Well played!
Recently Max has got himself into popular CCG "BrainStone". As "BrainStone" is a pretty intellectual game, Max has to solve numerous hard problems during the gameplay. Here is one of them: Max owns *n* creatures, *i*-th of them can be described with two numbers — its health *hp**i* and its damage *dmg**i*. Max also ha...
{"inputs": ["2 1 1\n10 15\n6 1", "3 0 3\n10 8\n7 11\n5 2", "1 0 0\n2 1", "1 0 200000\n1 2", "7 5 7\n29 25\n84 28\n34 34\n14 76\n85 9\n40 57\n99 88", "7 6 7\n11 75\n61 90\n22 14\n100 36\n29 48\n69 52\n16 3", "7 8 7\n88 29\n30 44\n14 1\n83 95\n73 88\n10 42\n29 26", "12 7 7\n78 189\n614 271\n981 510\n37 762\n803 106\n78 3...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
8
codeforces
d50bdeed886902a60096918dfa119f35
Order Book
In this task you need to process a set of stock exchange orders and use them to create order book. An order is an instruction of some participant to buy or sell stocks on stock exchange. The order number *i* has price *p**i*, direction *d**i* — buy or sell, and integer *q**i*. This means that the participant is ready ...
{"inputs": ["6 2\nB 10 3\nS 50 2\nS 40 1\nS 50 6\nB 20 4\nB 25 10", "2 1\nB 7523 5589\nS 69799 1711", "1 1\nB 48259 991", "1 50\nB 47828 7726", "1 1\nS 95992 7257", "1 50\nS 72218 8095", "2 50\nB 758 9290\nS 86168 3367", "3 3\nB 5878 1568\nS 60238 4895\nS 76276 1905", "6 2\nB 0 1\nS 1 1\nS 1 1\nS 1 1\nB 0 1\nB 0 1", "2...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
30
codeforces
d51744512d657fc8c49daa2a291bf799
Property
Bill is a famous mathematician in BubbleLand. Thanks to his revolutionary math discoveries he was able to make enough money to build a beautiful house. Unfortunately, for not paying property tax on time, court decided to punish Bill by making him lose a part of his property. Bill’s property can be observed as a convex...
{"inputs": ["3\n0 1 2", "10\n0 1 2 3 4 5 6 7 8 9", "10\n1 7 3 6 8 2 4 5 0 9", "10\n4 9 7 2 3 5 6 1 8 0", "5\n1 2 3 0 4", "5\n3 0 2 1 4", "5\n2 4 3 0 1", "17\n0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16", "17\n5 13 12 8 4 7 15 6 0 1 2 10 9 14 3 16 11", "17\n7 10 12 11 13 0 9 6 4 2 15 3 5 8 14 16 1", "50\n15 14 37 47 44 7 1...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
codeforces
d536f2dd4edadb347b7f5b76e5bebc9f
Shower Line
Many students live in a dormitory. A dormitory is a whole new world of funny amusements and possibilities but it does have its drawbacks. There is only one shower and there are multiple students who wish to have a shower in the morning. That's why every morning there is a line of five people in front of the dormitory...
{"inputs": ["0 0 0 0 9\n0 0 0 0 0\n0 0 0 0 0\n0 0 0 0 0\n7 0 0 0 0", "0 43 21 18 2\n3 0 21 11 65\n5 2 0 1 4\n54 62 12 0 99\n87 64 81 33 0", "0 4 2 4 9\n6 0 2 5 0\n2 5 0 6 3\n6 3 3 0 10\n0 3 1 3 0", "0 65 90 2 32\n69 0 9 97 67\n77 97 0 16 84\n18 50 94 0 63\n69 12 82 16 0", "0 70 10 0 0\n70 0 50 90 0\n10 50 0 80 0\n0 90 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
44
codeforces
d58e0be64698471a23413eaf7d77d0a6
Subway Innovation
Berland is going through tough times — the dirt price has dropped and that is a blow to the country's economy. Everybody knows that Berland is the top world dirt exporter! The President of Berland was forced to leave only *k* of the currently existing *n* subway stations. The subway stations are located on a straight...
{"inputs": ["3\n1 100 101\n2", "5\n11 21 30 40 50\n3", "3\n0 -4 -3\n2", "4\n5 -7 8 1\n2", "5\n-4 -2 10 -9 -10\n2", "6\n9 8 4 -4 -6 -8\n2", "7\n10 -6 0 -5 -2 -8 7\n2", "5\n-10 -5 3 4 -3\n3", "6\n8 -7 1 5 -8 4\n3", "7\n-5 1 3 2 -9 -1 -4\n3", "100\n237 -708 796 -645 75 387 992 343 -219 -696 777 -722 844 -409 6 989 39 -151...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
codeforces
d5a66051eeab79f22b63335aaf627de6
Pocket Book
One day little Vasya found mom's pocket book. The book had *n* names of her friends and unusually enough, each name was exactly *m* letters long. Let's number the names from 1 to *n* in the order in which they are written. As mom wasn't home, Vasya decided to play with names: he chose three integers *i*, *j*, *k* (1<=...
{"inputs": ["2 3\nAAB\nBAA", "4 5\nABABA\nBCGDG\nAAAAA\nYABSA", "1 1\nE", "2 2\nNS\nPD", "3 4\nPJKD\nNFJX\nFGFK", "4 5\nSXFMY\nATHLM\nKDDQW\nZWGDS", "20 14\nJNFKBBBJYZHWQE\nLBOKZCPFNKDBJY\nXKNWGHQHIOXUPF\nDDNRUKVUGHWMXW\nMTIZFNAAFEAPHX\nIXBQOOHEULZYHU\nMRCSREUEOOMUUN\nHJTSQWKUFYZDQU\nGMCMUZCOPRVEIQ\nXBKKGGJECOBLTH\nXXH...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
184
codeforces
d5a92f290c7eb0059d54b3a0e3c0ae3e
Ilya and Matrix
Ilya is a very good-natured lion. He likes maths. Of all mathematical objects, his favourite one is matrices. Now he's faced a complicated matrix problem he needs to solve. He's got a square 2*n*<=×<=2*n*-sized matrix and 4*n* integers. You need to arrange all these numbers in the matrix (put each number in a single i...
{"inputs": ["1\n13", "4\n1 2 3 4", "16\n978618343 473608041 799158564 800910753 461479363 520477481 780529176 678879534 118274424 720632652 639921017 582019792 143353286 537373229 944668919 758615621", "16\n521848329 105907607 414661942 473600423 264555612 186332345 774233687 736918178 456150336 216550357 568433949 135...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
codeforces
d5d2dd5f9cafc5c383631833e295d5a4
Pasha and Tea
Pasha decided to invite his friends to a tea party. For that occasion, he has a large teapot with the capacity of *w* milliliters and 2*n* tea cups, each cup is for one of Pasha's friends. The *i*-th cup can hold at most *a**i* milliliters of water. It turned out that among Pasha's friends there are exactly *n* boys a...
{"inputs": ["2 4\n1 1 1 1", "3 18\n4 4 4 2 2 2", "1 5\n2 3", "1 1\n1000000000 1000000000", "4 1000000000\n1 1 1 1 1 1 1 1", "4 1000000000\n1 1 1 1 2 2 2 2", "4 1\n3 3 3 3 4 4 4 4", "2 19\n3 3 5 5", "3 31\n3 3 3 5 5 5", "5 15\n2 3 4 1 2 4 5 3 5 10", "5 14\n2 3 4 1 2 4 5 3 5 10", "5 16\n2 3 4 1 2 4 5 3 5 10", "1 100\n1 2...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
183
codeforces
d607231391bb9d0f6146c5ed8354c0e9
Logical Expression
You are given a boolean function of three variables which is defined by its truth table. You need to find an expression of minimum length that equals to this function. The expression may consist of: - Operation AND ('&amp;', ASCII code 38) - Operation OR ('|', ASCII code 124) - Operation NOT ('!', ASCII code 33) -...
{"inputs": ["4\n00110011\n00000111\n11110000\n00011111", "1\n11001110", "2\n11001110\n01001001", "3\n10001001\n10111011\n10111101", "4\n11000010\n11000010\n11001110\n10001001", "5\n01111000\n00110110\n00011100\n01110111\n01010011"], "outputs": ["y\n(y|z)&x\n!x\nx|y&z", "!y|!z&x", "!y|!z&x\n!(!x&!z|x&z|y)|x&y&z", "!y&!z...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
codeforces
d6120d945ca2dd06ce7ce99e1cd247bb
Door Frames
Petya has equal wooden bars of length *n*. He wants to make a frame for two equal doors. Each frame has two vertical (left and right) sides of length *a* and one top side of length *b*. A solid (i.e. continuous without breaks) piece of bar is needed for each side. Determine a minimal number of wooden bars which are ne...
{"inputs": ["8\n1\n2", "5\n3\n4", "6\n4\n2", "20\n5\n6", "1\n1\n1", "3\n1\n2", "3\n2\n1", "1000\n1\n1", "1000\n1000\n1000", "1000\n1\n999", "1000\n1\n498", "1000\n1\n998", "31\n5\n6", "400\n100\n2", "399\n100\n2", "800\n401\n400", "141\n26\n11", "717\n40\n489", "293\n47\n30", "165\n59\n40", "404\n5\n183", "828\n468\n72...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
25
codeforces
d62618023e53f0985f2111be3942064e
Bayan Bus
The final round of Bayan Programming Contest will be held in Tehran, and the participants will be carried around with a yellow bus. The bus has 34 passenger seats: 4 seats in the last row and 3 seats in remaining rows. The event coordinator has a list of *k* participants who should be picked up at the airport. When a...
{"inputs": ["9", "20", "30", "5", "0", "1", "2", "3", "4", "6", "7", "8", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "21", "22", "23", "24", "25", "26", "27", "28", "29", "31", "32", "33", "34"], "outputs": ["+------------------------+\n|O.O.O.#.#.#.#.#.#.#.#.|D|)\n|O.O.O.#.#.#.#.#.#.#.#.|.|\n|O..........
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
63
codeforces
d63bc03ec2d750bf0a79a037180d8b83
Yaroslav and Permutations
Yaroslav has an array that consists of *n* integers. In one second Yaroslav can swap two neighboring array elements. Now Yaroslav is wondering if he can obtain an array where any two neighboring elements would be distinct in a finite time. Help Yaroslav. The first line contains integer *n* (1<=≤<=*n*<=≤<=100) — the nu...
{"inputs": ["1\n1", "3\n1 1 2", "4\n7 7 7 7", "4\n479 170 465 146", "5\n996 437 605 996 293", "6\n727 539 896 668 36 896", "7\n674 712 674 674 674 674 674", "8\n742 742 742 742 742 289 742 742", "9\n730 351 806 806 806 630 85 757 967", "10\n324 539 83 440 834 640 440 440 440 440", "7\n925 830 925 98 987 162 356", "68\n...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
440
codeforces
d6450d9766b2a425003aff887bf2eda8
Pyramid of Glasses
Mary has just graduated from one well-known University and is now attending celebration party. Students like to dream of a beautiful life, so they used champagne glasses to construct a small pyramid. The height of the pyramid is *n*. The top level consists of only 1 glass, that stands on 2 glasses on the second level (...
{"inputs": ["3 5", "4 8", "1 1", "10 10000", "1 10000", "10 1", "1 0", "10 0", "10 1022", "10 1023", "10 1024", "1 2", "1 200", "7 128", "8 198", "2 2", "2 3", "2 4", "2 100", "2 10000", "3 7", "3 6", "3 8", "3 12", "3 1", "4 15", "4 14", "4 10", "4 16", "4 999", "4 9", "5 31", "5 30", "5 28", "5 25", "5 15", "5 32", "...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
39
codeforces
d6524006b988fe4a1c2e7fe334ad52cc
Jabber ID
Jabber ID on the national Berland service «Babber» has a form &lt;username&gt;@&lt;hostname&gt;[/resource], where - &lt;username&gt; — is a sequence of Latin letters (lowercase or uppercase), digits or underscores characters «_», the length of &lt;username&gt; is between 1 and 16, inclusive. - &lt;hostname&gt; — is...
{"inputs": ["mike@codeforces.com", "john.smith@codeforces.ru/contest.icpc/12", "test@test.ri/abacaba", "@ops", "this-is-the-test", "mike@codeforces.commike@codeforces.com", "oooop/oooop", "w@S8/XU.5._R7fHq.@../e.WP!54Ey1L\u007f.9jv", "lNC9D1L5U@.L!_!CcAOEEx.0z.aiW/S430sbQT", "@/YTd.K1@lD", "Fyi!d1l@.OesGopTnRn.81xdSb8q...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
28
codeforces
d6a099aefd615f395445dd46e03cae87
Noldbach problem
Nick is interested in prime numbers. Once he read about Goldbach problem. It states that every even integer greater than 2 can be expressed as the sum of two primes. That got Nick's attention and he decided to invent a problem of his own and call it Noldbach problem. Since Nick is interested only in prime numbers, Nold...
{"inputs": ["27 2", "45 7", "2 0", "15 1", "17 1", "34 5", "37 4", "43 5", "47 7", "50 5", "57 6", "60 8", "62 7", "76 9", "69 7", "113 10", "141 11", "207 16", "231 18", "296 19", "332 20", "378 24", "428 23", "497 27", "640 32", "798 35", "802 35", "864 40", "953 44", "995 44", "1000 44", "1000 0", "1000 1000", "2 10...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
238
codeforces
d6a3ee2245008b12cf3816a9aeb24318
Treasure
Malek has recently found a treasure map. While he was looking for a treasure he found a locked door. There was a string *s* written on the door consisting of characters '(', ')' and '#'. Below there was a manual on how to open the door. After spending a long time Malek managed to decode the manual and found out that th...
{"inputs": ["(((#)((#)", "()((#((#(#()", "#", "(#)", "(((((#(#(#(#()", "#))))", "((#(()#(##", "##((((((()", "(((((((((((((((((((###################", "((#)(", "((#)((#)((#)((#)((#)((#)((#)((#)((#)((#)((#)((#)((#)((#)((#)((##", ")((##((###", "(#))(#(#)((((#(##((#(#((((#(##((((((#((()(()(())((()#((((#((()((((#(((((#(##)(...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
41
codeforces
d6b80df56f0740882baccaea55763e55
Binary Blocks
You are given an image, that can be represented with a 2-d *n* by *m* grid of pixels. Each pixel of the image is either on or off, denoted by the characters "0" or "1", respectively. You would like to compress this image. You want to choose an integer *k*<=&gt;<=1 and split the image into *k* by *k* blocks. If *n* and ...
{"inputs": ["3 5\n00100\n10110\n11001"], "outputs": ["5"]}
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
4
codeforces
d6fd979c02770bacad2724d75d957157
none
Dreamoon likes to play with sets, integers and . is defined as the largest positive integer that divides both *a* and *b*. Let *S* be a set of exactly four distinct integers greater than 0. Define *S* to be of rank *k* if and only if for all pairs of distinct elements *s**i*, *s**j* from *S*, . Given *k* and *n*, Dr...
{"inputs": ["1 1", "2 2", "7 7", "13 7", "15 27", "19 21", "113 97", "10000 100", "10000 1", "1 100", "9252 39", "8096 59", "4237 87", "3081 11", "9221 39", "770 59", "5422 87", "1563 15", "407 39", "6518 18", "1171 46", "7311 70", "6155 94", "7704 18", "3844 46", "1 10"], "outputs": ["5\n1 3 4 5", "22\n2 6 8 10\n14 18...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
12
codeforces
d70abc6e8f9f2a1e2b0c2d7894d9ea5d
Ostap and Grasshopper
On the way to Rio de Janeiro Ostap kills time playing with a grasshopper he took with him in a special box. Ostap builds a line of length *n* such that some cells of this line are empty and some contain obstacles. Then, he places his grasshopper to one of the empty cells and a small insect in another empty cell. The gr...
{"inputs": ["5 2\n#G#T#", "6 1\nT....G", "7 3\nT..#..G", "6 2\n..GT..", "2 1\nGT", "100 5\nG####.####.####.####.####.####.####.####.####.####.####.####.####.####.####.####.####.####.####T####", "100 5\nG####.####.####.####.####.####.####.####.####.####.####.####.####.#########.####.####.####.####T####", "2 1\nTG", "99 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
254
codeforces
d72a89e9db8adcfc03dadf9a643d3dcd
Playing with Superglue
Two players play a game. The game is played on a rectangular board with *n*<=×<=*m* squares. At the beginning of the game two different squares of the board have two chips. The first player's goal is to shift the chips to the same square. The second player aims to stop the first one with a tube of superglue. We'll des...
{"inputs": ["1 6 1 2 1 6", "6 5 4 3 2 1", "10 10 1 1 10 10", "1 2 1 1 1 2", "4 4 1 4 4 1", "25 32 17 18 20 19", "30 1 10 1 20 1", "28 17 20 10 27 2", "5 5 1 1 5 5", "5 4 1 4 5 1", "95 28 50 12 50 13", "7 41 3 5 3 6", "45 62 28 48 28 50", "57 17 12 7 12 10", "73 88 30 58 30 62", "33 13 12 1 12 6", "49 34 38 19 38 25", "...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
2
codeforces
d73ca18f12aeb17663480d60129a16fa
Sagheer, the Hausmeister
Some people leave the lights at their workplaces on when they leave that is a waste of resources. As a hausmeister of DHBW, Sagheer waits till all students and professors leave the university building, then goes and turns all the lights off. The building consists of *n* floors with stairs at the left and the right sid...
{"inputs": ["2 2\n0010\n0100", "3 4\n001000\n000010\n000010", "4 3\n01110\n01110\n01110\n01110", "3 2\n0000\n0100\n0100", "1 89\n0000000000000000000000000000000100000000000000010000000000010000000000000000000000000000000", "2 73\n000000000000000000000000000000000000000000000000000000000000000000000000000\n0000000000000...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
28
codeforces
d766f3f2527be1fa3b8d7c99ab891efc
Eugeny and Array
Eugeny has array *a*<==<=*a*1,<=*a*2,<=...,<=*a**n*, consisting of *n* integers. Each integer *a**i* equals to -1, or to 1. Also, he has *m* queries: - Query number *i* is given as a pair of integers *l**i*, *r**i* (1<=≤<=*l**i*<=≤<=*r**i*<=≤<=*n*). - The response to the query will be integer 1, if the elements of a...
{"inputs": ["2 3\n1 -1\n1 1\n1 2\n2 2", "5 5\n-1 1 1 1 -1\n1 1\n2 3\n3 5\n2 5\n1 5", "3 3\n1 1 1\n2 2\n1 1\n1 1", "4 4\n-1 -1 -1 -1\n1 3\n1 2\n1 2\n1 1", "5 5\n-1 -1 -1 -1 -1\n1 1\n1 1\n3 4\n1 1\n1 4", "6 6\n-1 -1 1 -1 -1 1\n1 1\n3 4\n1 1\n1 1\n1 3\n1 4", "7 7\n-1 -1 -1 1 -1 -1 -1\n1 1\n2 7\n1 3\n1 5\n4 7\n1 7\n6 7", "...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
60
codeforces
d7919219ff4ad6a38979999432fab8f8
Two Paths
As you know, Bob's brother lives in Flatland. In Flatland there are *n* cities, connected by *n*<=-<=1 two-way roads. The cities are numbered from 1 to *n*. You can get from one city to another moving along the roads. The «Two Paths» company, where Bob's brother works, has won a tender to repair two paths in Flatland....
{"inputs": ["4\n1 2\n2 3\n3 4", "7\n1 2\n1 3\n1 4\n1 5\n1 6\n1 7", "6\n1 2\n2 3\n2 4\n5 4\n6 4", "2\n2 1", "3\n3 1\n1 2", "3\n1 3\n2 1", "4\n4 2\n2 3\n2 1", "4\n2 3\n1 3\n2 4", "4\n3 2\n3 4\n1 4", "5\n1 5\n5 2\n4 2\n3 1", "5\n2 4\n2 5\n1 5\n2 3", "5\n1 2\n5 1\n3 2\n3 4", "5\n5 3\n3 1\n4 1\n4 2", "6\n1 2\n2 5\n4 5\n4 6\...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
16
codeforces
d794d52aeb02422c0b71909eeaae5488
Email address
Sometimes one has to spell email addresses over the phone. Then one usually pronounces a dot as dot, an at sign as at. As a result, we get something like vasyaatgmaildotcom. Your task is to transform it into a proper email address ([[email protected]](/cdn-cgi/l/email-protection)). It is known that a proper email add...
{"inputs": ["vasyaatgmaildotcom", "dotdotdotatdotdotat", "aatt", "zdotdotatdotz", "dotdotdotdotatdotatatatdotdotdot", "taatta", "doatdt", "catdotdotdotatatdotdotdotnatjdotatdotdotdoteatatoatatatoatatatdotdotatdotdotwxrdotatfatgfdotuatata", "hmatcxatxatdotatlyucjatdothatdotcatatatdotqatatdotdotdotdotatjddotdotdotqdotdot...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
42
codeforces
d79706d0befbed03f9a2c3c0383c9b22
Petya and Coloring
Little Petya loves counting. He wants to count the number of ways to paint a rectangular checkered board of size *n*<=×<=*m* (*n* rows, *m* columns) in *k* colors. Besides, the coloring should have the following property: for any vertical line that passes along the grid lines and divides the board in two non-empty part...
{"inputs": ["2 2 1", "2 2 2", "3 2 2", "7 8 15", "5 3 1", "5 100 1", "5 20 25", "6 6 8", "1 1 1000000", "3 3 2", "1000 1000 1000000", "1000 2 1000000", "1000 1 992929", "997 752 10001", "994 2 999999", "1 1000 298298", "2 1000 100202", "3 997 999997", "777 777 777777", "105 3 2", "105 3 3", "126 125 440715", "755 51 70...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
codeforces
d7bf7d8f27e219e6e217db033c1b8e5d
Touchy-Feely Palindromes
The only line of the input contains a string of digits. The length of the string is between 1 and 10, inclusive. Output "Yes" or "No". The only line of the input contains a string of digits. The length of the string is between 1 and 10, inclusive. Output "Yes" or "No". Sample Input 373 121 436 Sample Output Yes No Ye...
{"inputs": ["373", "121", "436", "7", "8", "4357087936", "806975480", "3333333333", "90785", "7467467", "64", "584609", "69154", "363567", "557654", "772961", "788958", "992045", "116325", "320432", "314729", "531816", "673902416", "880089713", "004176110"], "outputs": ["Yes", "No", "Yes", "Yes", "No", "Yes", "Yes", "Y...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
11
codeforces
d7c0e156ffc26e831fc39e4852202444
HQ
The famous joke programming language HQ9+ has only 4 commands. In this problem we will explore its subset — a language called HQ... The only line of the input is a string between 1 and 106 characters long. Output "Yes" or "No". Sample Input HHHH HQHQH HHQHHQH HHQQHHQQHH Sample Output Yes No No Yes
{"inputs": ["HHHH", "HQHQH", "HHQHHQH", "HHQQHHQQHH", "Q", "HHHHHHHHHHQHHH", "HHQHQQQHHH", "QQQQQQHQQQQQQQQQQHQQQQQQQQQQHQQQQQQQQQQHQQQQQQQQQQHQQQQQQQQQQHQQQQHQQQQQQHQQQQQQQQQQHQQQQQQQQQQHQQQQQQQQQQHQQQQ", "QHQHHQQQQQQQQQQQHQQHQHQQQQQQHQHQQQQQQQQQQQHQQQQQQQHQQHQQHQQQQQQQQQQQQQQQQQQQQHHQQQQQQQQQQHQQQQHHQHQQHQQQQQHQQQQQQ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
codeforces
d7c14ba7d0d268bccc5cdb4f6d715a9e
George and Sleep
George woke up and saw the current time *s* on the digital clock. Besides, George knows that he has slept for time *t*. Help George! Write a program that will, given time *s* and *t*, determine the time *p* when George went to bed. Note that George could have gone to bed yesterday relatively to the current time (see ...
{"inputs": ["05:50\n05:44", "00:00\n01:00", "00:01\n00:00", "23:59\n23:59", "23:44\n23:55", "00:00\n13:12", "12:00\n23:59", "12:44\n12:44", "05:55\n07:12", "07:12\n05:55", "22:22\n22:22", "22:22\n22:23", "23:24\n23:23", "00:00\n00:00", "23:30\n00:00", "01:00\n00:00", "05:44\n06:00", "00:00\n23:59", "21:00\n01:00", "21:...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
174
codeforces
d7c490b20064d171af4f83b4f37404d4
Is your horseshoe on the other hoof?
Valera the Horse is going to the party with friends. He has been following the fashion trends for a while, and he knows that it is very popular to wear all horseshoes of different color. Valera has got four horseshoes left from the last year, but maybe some of them have the same color. In this case he needs to go to th...
{"inputs": ["1 7 3 3", "7 7 7 7", "81170865 673572653 756938629 995577259", "3491663 217797045 522540872 715355328", "251590420 586975278 916631563 586975278", "259504825 377489979 588153796 377489979", "652588203 931100304 931100304 652588203", "391958720 651507265 391958720 651507265", "90793237 90793237 90793237 907...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
957
codeforces
d7c8cf60a201788ba8180140d2bc22a2
Cells Not Under Attack
Vasya has the square chessboard of size *n*<=×<=*n* and *m* rooks. Initially the chessboard is empty. Vasya will consequently put the rooks on the board one after another. The cell of the field is under rook's attack, if there is at least one rook located in the same row or in the same column with this cell. If there ...
{"inputs": ["3 3\n1 1\n3 1\n2 2", "5 2\n1 5\n5 1", "100000 1\n300 400", "10 4\n2 8\n1 8\n9 8\n6 9", "30 30\n3 13\n27 23\n18 24\n18 19\n14 20\n7 10\n27 13\n20 27\n11 1\n21 10\n2 9\n28 12\n29 19\n28 27\n27 29\n30 12\n27 2\n4 5\n8 19\n21 2\n24 27\n14 22\n20 3\n18 3\n23 9\n28 6\n15 12\n2 2\n16 27\n1 14", "70 31\n22 39\n33 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
143
codeforces
d7e7fbc84916c4ba69a3a51b3f1490a9
none
Tavas is a strange creature. Usually "zzz" comes out of people's mouth while sleeping, but string *s* of length *n* comes out from Tavas' mouth instead. Today Tavas fell asleep in Malekas' place. While he was sleeping, Malekas did a little process on *s*. Malekas has a favorite string *p*. He determined all positions ...
{"inputs": ["6 2\nioi\n1 3", "5 2\nioi\n1 2", "173700 6\nbcabcbcbcbaaacaccaacaccaabacabaacbcacbbccaccbcacbabcaccccccaacacabbbbbacabbaaacbcbbaccaccabbbbaabbacacbabccaabcabbbcacaaccbabbcaaaaaabccbbcabcacbcbcabcbcbbaabacaaccccabacaaaccacaaabbacacabbcccacbaabcacacbbaaaccaccbaccccccbccaabcacaacabaccababacabcccbcbbacbabacbcb...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
codeforces
d7edd56a5eee20eab6b6d09fdcfa9b83
Partial Sums
You've got an array *a*, consisting of *n* integers. The array elements are indexed from 1 to *n*. Let's determine a two step operation like that: 1. First we build by the array *a* an array *s* of partial sums, consisting of *n* elements. Element number *i* (1<=≤<=*i*<=≤<=*n*) of array *s* equals . The operation *x*...
{"inputs": ["3 1\n1 2 3", "5 0\n3 14 15 92 6", "1 1\n3", "1 0\n0", "1 0\n123", "1 1\n0", "4 1\n3 20 3 4", "5 20\n11 5 6 8 11", "17 239\n663 360 509 307 311 501 523 370 302 601 541 42 328 200 196 110 573", "13 666\n84 89 29 103 128 233 190 122 117 208 119 97 200", "42 42\n42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
6
codeforces
d82160a9327225936bababa5b49ea27a
Plane of Tanks: Pro
Vasya has been playing Plane of Tanks with his friends the whole year. Now it is time to divide the participants into several categories depending on their results. A player is given a non-negative integer number of points in each round of the Plane of Tanks. Vasya wrote results for each round of the last year. He ha...
{"inputs": ["5\nvasya 100\nvasya 200\nartem 100\nkolya 200\nigor 250", "3\nvasya 200\nkolya 1000\nvasya 1000", "1\nvasya 1000", "5\nvasya 1000\nvasya 100\nkolya 200\npetya 300\noleg 400", "10\na 1\nb 2\nc 3\nd 4\ne 5\nf 6\ng 7\nh 8\ni 9\nj 10", "10\nj 10\ni 9\nh 8\ng 7\nf 6\ne 5\nd 4\nc 3\nb 2\na 1", "1\ntest 0"], "out...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
10
codeforces
d828a1ebc83918c509c284ac5175b86f
Infinity Gauntlet
You took a peek on Thanos wearing Infinity Gauntlet. In the Gauntlet there is a place for six Infinity Gems: - the Power Gem of purple color, - the Time Gem of green color, - the Space Gem of blue color, - the Soul Gem of orange color, - the Reality Gem of red color, - the Mind Gem of yellow color. Using colors...
{"inputs": ["4\nred\npurple\nyellow\norange", "0", "6\npurple\nblue\nyellow\nred\ngreen\norange", "1\npurple", "3\nblue\norange\npurple", "2\nyellow\nred", "1\ngreen", "2\npurple\ngreen", "1\nblue", "2\npurple\nblue", "2\ngreen\nblue", "3\npurple\ngreen\nblue", "1\norange", "2\npurple\norange", "2\norange\ngreen", "3\n...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
452
codeforces
d84f506511837749a50dc95afd9a9b7e
Watering Flowers
A flowerbed has many flowers and two fountains. You can adjust the water pressure and set any values *r*1(*r*1<=≥<=0) and *r*2(*r*2<=≥<=0), giving the distances at which the water is spread from the first and second fountain respectively. You have to set such *r*1 and *r*2 that all the flowers are watered, that is, fo...
{"inputs": ["2 -1 0 5 3\n0 2\n5 2", "4 0 0 5 0\n9 4\n8 3\n-1 0\n1 4", "5 -6 -4 0 10\n-7 6\n-9 7\n-5 -1\n-2 1\n-8 10", "10 -68 10 87 22\n30 89\n82 -97\n-52 25\n76 -22\n-20 95\n21 25\n2 -3\n45 -7\n-98 -56\n-15 16", "1 -10000000 -10000000 -10000000 -9999999\n10000000 10000000"], "outputs": ["6", "33", "100", "22034", "799...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
codeforces
d85233139efbd43e85b826d96e5960b8
Tram
Linear Kingdom has exactly one tram line. It has *n* stops, numbered from 1 to *n* in the order of tram's movement. At the *i*-th stop *a**i* passengers exit the tram, while *b**i* passengers enter it. The tram is empty before it arrives at the first stop. Also, when the tram arrives at the last stop, all passengers ex...
{"inputs": ["4\n0 3\n2 5\n4 2\n4 0", "5\n0 4\n4 6\n6 5\n5 4\n4 0", "10\n0 5\n1 7\n10 8\n5 3\n0 5\n3 3\n8 8\n0 6\n10 1\n9 0", "3\n0 1\n1 1\n1 0", "4\n0 1\n0 1\n1 0\n1 0", "3\n0 0\n0 0\n0 0", "3\n0 1000\n1000 1000\n1000 0", "5\n0 73\n73 189\n189 766\n766 0\n0 0", "5\n0 0\n0 0\n0 0\n0 1\n1 0", "5\n0 917\n917 923\n904 992\...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1,051
codeforces
d868b148d0994ff39d9a316418f8fd80
Numbers
Little Petya likes numbers a lot. He found that number 123 in base 16 consists of two digits: the first is 7 and the second is 11. So the sum of digits of 123 in base 16 is equal to 18. Now he wonders what is an average value of sum of digits of the number *A* written in all bases from 2 to *A*<=-<=1. Note that all c...
{"inputs": ["5", "3", "1000", "927", "260", "131", "386", "277", "766", "28", "406", "757", "6", "239", "322", "98", "208", "786", "879", "702", "948", "537", "984", "934", "726", "127", "504", "125", "604", "115", "27", "687", "880", "173", "264", "785", "399", "514", "381", "592", "417", "588", "852", "959", "841", "...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
200
codeforces
d87d73991024db39a19d5ff2ebaac5eb
Word
Vasya is very upset that many people on the Net mix uppercase and lowercase letters in one word. That's why he decided to invent an extension for his favorite browser that would change the letters' register in every word so that it either only consisted of lowercase letters or, vice versa, only of uppercase ones. At th...
{"inputs": ["HoUse", "ViP", "maTRIx", "BNHWpnpawg", "VTYGP", "CHNenu", "ERPZGrodyu", "KSXBXWpebh", "qvxpqullmcbegsdskddortcvxyqlbvxmmkhevovnezubvpvnrcajpxraeaxizgaowtfkzywvhnbgzsxbhkaipcmoumtikkiyyaiv", "Amnhaxtaopjzrkqlbroiyipitndczpunwygstmzevgyjdzyanxkdqnvgkikfabwouwkkbzuiuvgvxgpizsvqsbwepktpdrgdkmfd", "ISAGFJFARYFB...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
5,171
codeforces
d87fa0907cbb094c1645c41452b5fceb
Game with Points
You are playing the following game. There are *n* points on a plane. They are the vertices of a regular *n*-polygon. Points are labeled with integer numbers from 1 to *n*. Each pair of distinct points is connected by a diagonal, which is colored in one of 26 colors. Points are denoted by lowercase English letters. Ther...
{"inputs": ["4\n2 3 4\n*aba\na*ab\nba*b\nabb*", "4\n2 3 4\n*abc\na*ab\nba*b\ncbb*", "3\n1 2 3\n*aa\na*a\naa*", "10\n9 8 6\n*abbbababb\na*babbaaaa\nbb*bbaabab\nbab*bbbaab\nbbbb*baaab\nababb*baaa\nbaabab*bba\naabaaab*ab\nbaaaaaba*a\nbabbbaaba*", "10\n3 9 5\n*aabbbaaaa\na*abbaaaaa\naa*baaaabb\nbbb*bbbaba\nbbab*babaa\nbaab...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
codeforces
d8a91763417050f3c37bf81e2019ac08
Mr. Kitayuta, the Treasure Hunter
The Shuseki Islands are an archipelago of 30001 small islands in the Yutampo Sea. The islands are evenly spaced along a line, numbered from 0 to 30000 from the west to the east. These islands are known to contain many treasures. There are *n* gems in the Shuseki Islands in total, and the *i*-th gem is located on island...
{"inputs": ["4 10\n10\n21\n27\n27", "8 8\n9\n19\n28\n36\n45\n55\n66\n78", "13 7\n8\n8\n9\n16\n17\n17\n18\n21\n23\n24\n24\n26\n30", "8 4\n9\n15\n15\n16\n22\n25\n25\n28", "1 30000\n30000", "1 12345\n23456", "1 1\n30000", "5 4\n4\n5\n9\n21\n25", "8 7\n8\n15\n18\n19\n23\n24\n25\n27", "11 15\n15\n18\n19\n19\n21\n23\n24\n26\...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
6
codeforces
d8ae5fce78d6970e097ff460a8ea8ae4
Fly
Natasha is going to fly on a rocket to Mars and return to Earth. Also, on the way to Mars, she will land on $n - 2$ intermediate planets. Formally: we number all the planets from $1$ to $n$. $1$ is Earth, $n$ is Mars. Natasha will make exactly $n$ flights: $1 \to 2 \to \ldots n \to 1$. Flight from $x$ to $y$ consists ...
{"inputs": ["2\n12\n11 8\n7 5", "3\n1\n1 4 1\n2 5 3", "6\n2\n4 6 3 3 5 6\n2 6 3 6 5 3", "3\n3\n1 2 1\n2 2 2", "4\n4\n2 3 2 2\n2 3 4 3", "5\n2\n1 2 2 1 2\n4 5 1 4 1", "7\n7\n3 2 6 2 2 2 5\n4 7 5 6 2 2 2", "2\n1000\n12 34\n56 78", "8\n4\n1 1 4 1 3 1 8 1\n1 1 1 1 1 3 1 2", "9\n2\n8 7 1 1 3 7 1 2 4\n4 1 1 8 7 7 1 1 5", "10...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
116
codeforces
d8c9a461ab8269197b4cbd138999561f
Bender Problem
Robot Bender decided to make Fray a birthday present. He drove *n* nails and numbered them from 1 to *n* in some order. Bender decided to make a picture using metal rods. The picture is a closed polyline, which vertices should be nails (in the given order). The segments of the polyline should be parallel to the coordin...
{"inputs": ["4 2\n0 0\n0 2\n2 2\n2 0\n4 4", "6 3\n0 0\n1 0\n1 1\n2 1\n2 2\n0 2\n3 2 3", "6 3\n0 0\n1 0\n1 1\n2 1\n2 2\n0 2\n2 2 3", "4 4\n0 0\n0 1\n1 1\n1 0\n1 1 1 1", "6 2\n0 0\n1 0\n1 1\n2 1\n2 2\n0 2\n2 2", "6 3\n0 0\n2 0\n2 2\n1 2\n1 1\n0 1\n4 2 2", "4 4\n-8423 7689\n6902 7689\n6902 2402\n-8423 2402\n20612 20612 91...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
9
codeforces
d8d102de0b8305a5013c4be7d50a80f4
Jzzhu and Sequences
Jzzhu has invented a kind of sequences, they meet the following property: You are given *x* and *y*, please calculate *f**n* modulo 1000000007 (109<=+<=7). The first line contains two integers *x* and *y* (|*x*|,<=|*y*|<=≤<=109). The second line contains a single integer *n* (1<=≤<=*n*<=≤<=2·109). Output a single inte...
{"inputs": ["2 3\n3", "0 -1\n2", "-9 -11\n12345", "0 0\n1000000000", "-1000000000 1000000000\n2000000000", "-12345678 12345678\n1912345678", "728374857 678374857\n1928374839", "278374837 992837483\n1000000000", "-693849384 502938493\n982838498", "-783928374 983738273\n992837483", "-872837483 -682738473\n999999999", "-8...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
166
codeforces
d8def71219429750efca943f33e2929e
Two Bags of Potatoes
Valera had two bags of potatoes, the first of these bags contains *x* (*x*<=≥<=1) potatoes, and the second — *y* (*y*<=≥<=1) potatoes. Valera — very scattered boy, so the first bag of potatoes (it contains *x* potatoes) Valera lost. Valera remembers that the total amount of potatoes (*x*<=+<=*y*) in the two bags, first...
{"inputs": ["10 1 10", "10 6 40", "10 1 20", "1 10000 1000000000", "84817 1 33457", "21 37 99", "78 7 15", "74 17 27", "79 23 43", "32 33 3", "55 49 44", "64 59 404", "61 69 820", "17 28 532", "46592 52 232", "1541 58 648", "15946 76 360", "30351 86 424", "1 2 37493", "1 3 27764", "10 4 9174", "33 7 4971", "981 1 3387"...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
278
codeforces
d8f8774e428312b2de356559e7c80362
View Angle
Flatland has recently introduced a new type of an eye check for the driver's licence. The check goes like that: there is a plane with mannequins standing on it. You should tell the value of the minimum angle with the vertex at the origin of coordinates and with all mannequins standing inside or on the boarder of this a...
{"inputs": ["2\n2 0\n0 2", "3\n2 0\n0 2\n-2 2", "4\n2 0\n0 2\n-2 0\n0 -2", "2\n2 1\n1 2", "1\n1 1", "10\n9 7\n10 7\n6 5\n6 10\n7 6\n5 10\n6 7\n10 9\n5 5\n5 8", "10\n-1 28\n1 28\n1 25\n0 23\n-1 24\n-1 22\n1 27\n0 30\n1 22\n1 21", "10\n-5 9\n-10 6\n-8 8\n-9 9\n-6 5\n-8 9\n-5 7\n-6 6\n-5 10\n-8 7", "10\n6 -9\n9 -5\n10 -5\...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
41
codeforces
d8fedd0313ef52a71b02caf1971f7059
2Char
Andrew often reads articles in his favorite magazine 2Char. The main feature of these articles is that each of them uses at most two distinct letters. Andrew decided to send an article to the magazine, but as he hasn't written any article, he just decided to take a random one from magazine 26Char. However, before sendi...
{"inputs": ["4\nabb\ncacc\naaa\nbbb", "5\na\na\nbcbcb\ncdecdecdecdecdecde\naaaa", "1\na", "2\nz\nz", "5\nabcde\nfghij\nklmno\npqrst\nuvwxy", "6\ngggggg\ngggggg\ngggggg\ngggggg\ngggggg\ngggggg", "6\naaaaaa\naaaaaa\nbbbbbb\nbbbbbb\naaabbb\nababab", "1\nabc", "2\nabc\nbca", "3\nab\nba\nzzz", "3\nab\nba\nzzzzz", "5\nzzz\nz...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
104
codeforces
d912639c658962fc49408726816d8926
Vanya and Food Processor
Vanya smashes potato in a vertical food processor. At each moment of time the height of the potato in the processor doesn't exceed *h* and the processor smashes *k* centimeters of potato each second. If there are less than *k* centimeters remaining, than during this second processor smashes all the remaining potato. V...
{"inputs": ["5 6 3\n5 4 3 2 1", "5 6 3\n5 5 5 5 5", "5 6 3\n1 2 1 1 1", "10 100 80\n76 75 73 71 76 74 73 70 78 75", "10 100 88\n11 23 69 6 71 15 25 1 43 37", "10 100 81\n100 97 96 98 98 95 100 97 97 99", "10 1000000000 34\n262467899 490831561 793808758 450543931 364178715 95212706 14245051 92006075 424282318 436927280"...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
7
codeforces