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
8cae00fef4c1eedada77f2a75ddf67f4
Inverse Function
Petya wrote a programme on C++ that calculated a very interesting function *f*(*n*). Petya ran the program with a certain value of *n* and went to the kitchen to have some tea. The history has no records concerning how long the program had been working. By the time Petya returned, it had completed the calculations and ...
{"inputs": ["17\nint f(int n)\n{\nif (n < 100) return 17;\nif (n > 99) return 27;\n}", "13\nint f(int n)\n{\nif (n == 0) return 0;\nreturn f(n - 1) + 1;\n}", "144\nint f(int n)\n{\nif (n == 0) return 0;\nif (n == 1) return n;\nreturn f(n - 1) + f(n - 2);\n}", "32767\nint f(int n)\n{\nreturn n;\n}", "27926\nint f(int n)...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
codeforces
8cd687a88783833ff1c31127372696fe
George and Accommodation
George has recently entered the BSUCP (Berland State University for Cool Programmers). George has a friend Alex who has also entered the university. Now they are moving into a dormitory. George and Alex want to live in the same room. The dormitory has *n* rooms in total. At the moment the *i*-th room has *p**i* peopl...
{"inputs": ["3\n1 1\n2 2\n3 3", "3\n1 10\n0 10\n10 10", "2\n36 67\n61 69", "3\n21 71\n10 88\n43 62", "3\n1 2\n2 3\n3 4", "10\n0 10\n0 20\n0 30\n0 40\n0 50\n0 60\n0 70\n0 80\n0 90\n0 100", "13\n14 16\n30 31\n45 46\n19 20\n15 17\n66 67\n75 76\n95 97\n29 30\n37 38\n0 2\n36 37\n8 9", "19\n66 67\n97 98\n89 91\n67 69\n67 68\...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
648
codeforces
8d058a1cf69c59bf09f0190d5dc2e875
Football
One day, at the "Russian Code Cup" event it was decided to play football as an out of competition event. All participants was divided into *n* teams and played several matches, two teams could not play against each other more than once. The appointed Judge was the most experienced member — Pavel. But since he was the ...
{"inputs": ["3 1", "7 3", "4 1", "5 2", "5 2", "11 6", "11 5", "1 1", "2 1", "3 1", "1 2", "2 2", "3 2", "531 265", "775 388", "648 581", "57 13", "131 65", "609 305", "197 182", "248 54", "137 68", "47 24", "947 868", "205 50", "863 431", "445 223", "786 393", "122 52", "629 314", "571 286", "980 680", "869 239", "999...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
16
codeforces
8d337c19b31a325a4e2c5679c23c0f2a
Fools and Roads
They say that Berland has exactly two problems, fools and roads. Besides, Berland has *n* cities, populated by the fools and connected by the roads. All Berland roads are bidirectional. As there are many fools in Berland, between each pair of cities there is a path (or else the fools would get upset). Also, between eac...
{"inputs": ["5\n1 2\n1 3\n2 4\n2 5\n2\n1 4\n3 5", "5\n3 4\n4 5\n1 4\n2 4\n3\n2 3\n1 3\n3 5"], "outputs": ["2 1 1 1 ", "3 1 1 1 "]}
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
2
codeforces
8d65492fc90cdeead7cd95db3a21418d
none
Young Teodor enjoys drawing. His favourite hobby is drawing segments with integer borders inside his huge [1;*m*] segment. One day Teodor noticed that picture he just drawn has one interesting feature: there doesn't exist an integer point, that belongs each of segments in the picture. Having discovered this fact, Teodo...
{"inputs": ["2 4\n1 2\n3 4", "4 6\n1 3\n2 3\n4 6\n5 6", "43 1319\n750 1030\n857 946\n941 1203\n407 1034\n947 1290\n546 585\n630 1201\n72 342\n693 1315\n34 719\n176 1097\n36 931\n198 973\n5 1025\n892 1054\n461 1287\n195 1273\n832 1039\n308 955\n642 866\n770 838\n440 777\n289 948\n98 814\n458 768\n82 265\n300 596\n182 70...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
codeforces
8d7482c6a683d3296ea22a704783715b
Om Nom and Necklace
One day Om Nom found a thread with *n* beads of different colors. He decided to cut the first several beads from this thread to make a bead necklace and present it to his girlfriend Om Nelly. Om Nom knows that his girlfriend loves beautiful patterns. That's why he wants the beads on the necklace to form a regular patt...
{"inputs": ["7 2\nbcabcab", "21 2\nababaababaababaababaa", "321 2\nabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaa...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
2
codeforces
8d8fab3e7d35cb8634eaf569edcf87b7
Rain and Umbrellas
Polycarp lives on a coordinate line at the point $x = 0$. He goes to his friend that lives at the point $x = a$. Polycarp can move only from left to right, he can pass one unit of length each second. Now it's raining, so some segments of his way are in the rain. Formally, it's raining on $n$ non-intersecting segments,...
{"inputs": ["10 2 4\n3 7\n8 10\n0 10\n3 4\n8 1\n1 2", "10 1 1\n0 9\n0 5", "10 1 1\n0 9\n1 5", "1 1 1\n0 1\n1 100000", "1 1 1\n0 1\n0 100000", "2000 1 1\n0 1\n2000 33303", "2000 1 1\n1999 2000\n0 18898", "100 50 1\n1 2\n3 4\n5 6\n7 8\n9 10\n11 12\n13 14\n15 16\n17 18\n19 20\n21 22\n23 24\n25 26\n27 28\n29 30\n31 32\n33 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
5
codeforces
8d9078b0a36ff7bd5d993ae41b3780b0
Rounding
Vasya has a non-negative integer *n*. He wants to round it to nearest integer, which ends up with 0. If *n* already ends up with 0, Vasya considers it already rounded. For example, if *n*<==<=4722 answer is 4720. If *n*<==<=5 Vasya can round it to 0 or to 10. Both ways are correct. For given *n* find out to which int...
{"inputs": ["5", "113", "1000000000", "5432359", "999999994", "10", "9", "1", "0", "3", "4", "6", "7", "8", "19", "100", "997", "9994", "10002", "100000", "99999", "999999999", "999999998", "999999995", "999999990", "1000000", "1000010", "10000010", "100000011", "400000003", "234234", "675621", "43532", "4576453", "657...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
461
codeforces
8d9b9f436834145197b35fe3b1a4ec79
Help Far Away Kingdom
In a far away kingdom lived the King, the Prince, the Shoemaker, the Dressmaker and many other citizens. They lived happily until great trouble came into the Kingdom. The ACMers settled there. Most damage those strange creatures inflicted upon the kingdom was that they loved high precision numbers. As a result, the Ki...
{"inputs": ["0.0", "1.49", "1.50", "2.71828182845904523536", "3.14159265358979323846", "12345678901234567890.1", "123456789123456789.999", "12345678901234567890.9", "123456789123456788.999", "9.000", "0.1", "0.2", "0.3", "0.4", "0.5", "0.6", "0.7", "0.8", "0.9", "1.0", "1.1", "1.2", "1.3", "1.4", "1.5", "1.6", "1.7", "...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
202
codeforces
8daea05e984def6f793db9d374212130
Segments
You are given an integer *N*. Consider all possible segments on the coordinate axis with endpoints at integer points with coordinates between 0 and *N*, inclusive; there will be of them. You want to draw these segments in several layers so that in each layer the segments don't overlap (they might touch at the endpoin...
{"inputs": ["2", "3", "4", "21", "100", "1", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "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"...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
157
codeforces
8db0bc286b569043a28bd31c19f4c65b
Shaass and Oskols
Shaass has decided to hunt some birds. There are *n* horizontal electricity wires aligned parallel to each other. Wires are numbered 1 to *n* from top to bottom. On each wire there are some oskols sitting next to each other. Oskol is the name of a delicious kind of birds in Shaass's territory. Supposed there are *a**i*...
{"inputs": ["5\n10 10 10 10 10\n5\n2 5\n3 13\n2 12\n1 13\n4 6", "3\n2 4 1\n1\n2 2", "5\n58 51 45 27 48\n5\n4 9\n5 15\n4 5\n5 8\n1 43", "10\n48 53 10 28 91 56 81 2 67 52\n2\n2 40\n6 51", "2\n72 45\n6\n1 69\n2 41\n1 19\n2 7\n1 5\n2 1", "10\n95 54 36 39 98 30 19 24 14 12\n3\n9 5\n8 15\n7 5", "100\n95 15 25 18 64 62 23 59 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
397
codeforces
8dbf384ae645ced530cdc48451343e58
Pipeline
Vova, the Ultimate Thule new shaman, wants to build a pipeline. As there are exactly *n* houses in Ultimate Thule, Vova wants the city to have exactly *n* pipes, each such pipe should be connected to the water supply. A pipe can be connected to the water supply if there's water flowing out of it. Initially Vova has onl...
{"inputs": ["4 3", "5 5", "8 4", "1000000000000000000 1000000000", "499999998500000001 1000000000", "499999998500000000 1000000000", "499999999500000000 1000000000", "499999999500000001 1000000000", "525 34", "223265034477 726990", "15597035789572051 185473109", "499999999500000002 1000000000", "1 1000000000", "1000000...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
50
codeforces
8dd48a95d077948b9426c6505bdbe45c
none
This is an interactive problem. Jury has hidden a permutation *p* of integers from 0 to *n*<=-<=1. You know only the length *n*. Remind that in permutation all integers are distinct. Let *b* be the inverse permutation for *p*, i.e. *p**b**i*<==<=*i* for all *i*. The only thing you can do is to ask xor of elements *p*...
{"inputs": ["3\n0 1 2", "4\n3 1 2 0", "4\n3 2 1 0", "8\n2 3 0 1 4 5 6 7", "1\n0", "10\n0 1 2 3 4 5 6 7 8 9", "6\n0 1 2 4 3 5", "2\n0 1", "10\n6 7 4 5 0 1 8 9 2 3", "10\n9 8 1 7 6 4 5 2 0 3", "64\n0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
codeforces
8e200e66a6bc8b339fc2303f84d097ff
Geometrical Progression
For given *n*, *l* and *r* find the number of distinct geometrical progression, each of which contains *n* distinct integers not less than *l* and not greater than *r*. In other words, for each progression the following must hold: *l*<=≤<=*a**i*<=≤<=*r* and *a**i*<=≠<=*a**j* , where *a*1,<=*a*2,<=...,<=*a**n* is the ge...
{"inputs": ["1 1 10", "2 6 9", "3 1 10", "3 3 10", "1 25 845", "2 25 845", "3 25 845", "4 25 845", "5 25 845", "6 25 845", "7 25 845", "8 25 845", "1 1 10000000", "2 1 10000000", "3 1 10000000", "4 1 10000000", "5 1 10000000", "6 1 10000000", "7 1 10000000", "8 1 10000000", "9 1 10000000", "10 1 10000000", "11 1 100000...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
codeforces
8e2fa585a4cce90d151115947a7dfe76
Maximal Binary Matrix
You are given matrix with *n* rows and *n* columns filled with zeroes. You should put *k* ones in it in such a way that the resulting matrix is symmetrical with respect to the main diagonal (the diagonal that goes from the top left to the bottom right corner) and is lexicographically maximal. One matrix is lexicograph...
{"inputs": ["2 1", "3 2", "2 5", "1 0", "1 1", "20 398", "20 401", "100 3574", "100 10000", "100 10001", "2 3", "4 5", "5 6", "5 24", "2 0", "3 5", "3 3", "5 10", "3 4", "4 3", "1 1000000", "3 6", "1 2", "1 0", "1 1", "1 2", "1 3", "1 4", "1 5", "1 6", "1 7", "1 8", "1 9", "1 10", "1 11", "1 12", "1 13", "1 14", "1 15"...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
99
codeforces
8e4411543e2b85f1a8bb736483bfdbcb
Beautiful Divisors
Recently Luba learned about a special kind of numbers that she calls beautiful numbers. The number is called beautiful iff its binary representation consists of *k*<=+<=1 consecutive ones, and then *k* consecutive zeroes. Some examples of beautiful numbers: - 12 (110); - 1102 (610); - 11110002 (12010); - 1111100...
{"inputs": ["3", "992", "81142", "76920", "2016", "1", "6", "32640", "12096", "55948", "47262", "22876", "96120", "42160", "38304", "89408", "97920", "55493", "38021", "21445", "100000", "497", "240", "21204", "65536", "364", "1024", "36", "28", "14400", "10080", "9", "2", "42", "83160", "65534", "1026", "1025", "1027"...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
83
codeforces
8e47b70b8fb09fa94b3f2521cab6ba43
Longest Regular Bracket Sequence
This is yet another problem dealing with regular bracket sequences. We should remind you that a bracket sequence is called regular, if by inserting «+» and «1» into it we can get a correct mathematical expression. For example, sequences «(())()», «()» and «(()(()))» are regular, while «)(», «(()» and «(()))(» are not....
{"inputs": [")((())))(()())", "))(", "()(())()", "((((()(((", "))))()())))", "(()())()(())()()())())()((()(()(())()()())((()(())()(()()()()))()(())()(((()())()(()((())()(())(()))", ")(()(((((())))))(((()))))))((()(((((((())())()))))((((((((())))((((((())))))(()((((()))))(()))))))))", "())(((((())())((((()))(())))())())...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
149
codeforces
8e4c196a1d858d4cb674277d1f33267d
Bit++
The classic programming language of Bitland is Bit++. This language is so peculiar and complicated. The language is that peculiar as it has exactly one variable, called *x*. Also, there are two operations: - Operation ++ increases the value of variable *x* by 1. - Operation -- decreases the value of variable *x* by...
{"inputs": ["1\n++X", "2\nX++\n--X", "3\n++X\n++X\n++X", "2\n--X\n--X", "5\n++X\n--X\n++X\n--X\n--X", "28\nX--\n++X\nX++\nX++\nX++\n--X\n--X\nX++\nX--\n++X\nX++\n--X\nX--\nX++\nX--\n++X\n++X\nX++\nX++\nX++\nX++\n--X\n++X\n--X\n--X\n--X\n--X\nX++", "94\nX++\nX++\n++X\n++X\nX--\n--X\nX++\n--X\nX++\n++X\nX++\n++X\n--X\n--...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
497
codeforces
8e50612d70a28d84b770df9166669c6b
The Monster
As Will is stuck in the Upside Down, he can still communicate with his mom, Joyce, through the Christmas lights (he can turn them on and off with his mind). He can't directly tell his mom where he is, because the monster that took him to the Upside Down will know and relocate him. Thus, he came up with a puzzle to te...
{"inputs": ["((?))", "??()??", "?????)(???", "()()((?(()(((()()(())(((()((())))(()))(()(((((())))()))(((()()()))))))(((((()))))))))", "))((()(()((((()))())()())((())())(((()()(())))))((())()()(()()(())()))()()(()()()(((()(()(()(()))))(", "?????????????????????????????????????????????????????????????????????????????????...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
10
codeforces
8e64f356f5e4e4ae535eb42d9e1ea3df
Fancy Fence
Emuskald needs a fence around his farm, but he is too lazy to build it himself. So he purchased a fence-building robot. He wants the fence to be a regular polygon. The robot builds the fence along a single path, but it can only make fence corners at a single angle *a*. Will the robot be able to build the fence Emuska...
{"inputs": ["3\n30\n60\n90", "6\n1\n2\n3\n170\n179\n25"], "outputs": ["NO\nYES\nYES", "NO\nNO\nNO\nYES\nYES\nNO"]}
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
625
codeforces
8e719483e5e5418e54575f188ffb7458
Holes
Little Petya likes to play a lot. Most of all he likes to play a game «Holes». This is a game for one person with following rules: There are *N* holes located in a single row and numbered from left to right with numbers from 1 to *N*. Each hole has it's own power (hole number *i* has the power *a**i*). If you throw a ...
{"inputs": ["8 5\n1 1 1 1 1 2 8 2\n1 1\n0 1 3\n1 1\n0 3 4\n1 2", "10 10\n5 1 2 4 1 7 3 8 10 8\n0 5 6\n1 8\n1 1\n0 10 3\n1 5\n1 3\n1 2\n0 6 1\n1 9\n1 1"], "outputs": ["8 7\n8 5\n7 3", "8 1\n6 2\n5 1\n5 2\n5 3\n9 1\n10 4"]}
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
2
codeforces
8e83fc290467bbae2f2bbd15052cee39
Long number
Consider the following grammar: - &lt;expression&gt; ::= &lt;term&gt; | &lt;expression&gt; '+' &lt;term&gt;- &lt;term&gt; ::= &lt;number&gt; | &lt;number&gt; '-' &lt;number&gt; | &lt;number&gt; '(' &lt;expression&gt; ')'- &lt;number&gt; ::= &lt;pos_digit&gt; | &lt;number&gt; &lt;digit&gt;- &lt;digit&gt; ::= '0' | &...
{"inputs": ["8-11", "2(2-4+1)+2(2(17))", "1234-5678", "1+2+3+4-5+6+7-9", "598777", "49603501749575096738857", "11-57", "7177-57797", "4510812433666-7741104736713", "4778066503(27032-80044+16+51+58(9)+5668114736297420472+2336+6-117+8495(7265))", "9678329648012859556810940272201-70370609657815505164700664074744+288702310...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
codeforces
8e884a3f9a82d8283675daa517424cea
Buying A House
Zane the wizard had never loved anyone before, until he fell in love with a girl, whose name remains unknown to us. The girl lives in house *m* of a village. There are *n* houses in that village, lining in a straight line from left to right: house 1, house 2, ..., house *n*. The village is also well-structured: house ...
{"inputs": ["5 1 20\n0 27 32 21 19", "7 3 50\n62 0 0 0 99 33 22", "10 5 100\n1 0 1 0 0 0 0 0 1 1", "5 3 1\n1 1 0 0 1", "5 5 5\n1 0 5 6 0", "15 10 50\n20 0 49 50 50 50 50 50 50 0 50 50 49 0 20", "7 5 1\n0 100 2 2 0 2 1", "100 50 100\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
329
codeforces
8e997023d723a3471ac07fd67fc26280
Gargari and Permutations
Gargari got bored to play with the bishops and now, after solving the problem about them, he is trying to do math homework. In a math book he have found *k* permutations. Each of them consists of numbers 1,<=2,<=...,<=*n* in some order. Now he should find the length of the longest common subsequence of these permutatio...
{"inputs": ["4 3\n1 4 2 3\n4 1 2 3\n1 2 4 3", "6 3\n2 5 1 4 6 3\n5 1 4 3 2 6\n5 4 2 6 3 1", "41 4\n24 15 17 35 13 41 4 14 23 5 8 16 21 18 30 36 6 22 11 29 26 1 40 31 7 3 32 10 28 38 12 20 39 37 34 19 33 27 2 25 9\n22 13 25 24 38 35 29 12 15 8 11 37 3 19 4 23 18 32 30 40 36 21 16 34 27 9 5 41 39 2 14 17 31 33 26 7 1 10 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
9
codeforces
8ea2947adf1fbbc23b60a162d770b3ba
Alyona and flowers
Little Alyona is celebrating Happy Birthday! Her mother has an array of *n* flowers. Each flower has some mood, the mood of *i*-th flower is *a**i*. The mood can be positive, zero or negative. Let's define a subarray as a segment of consecutive flowers. The mother suggested some set of subarrays. Alyona wants to choos...
{"inputs": ["5 4\n1 -2 1 3 -4\n1 2\n4 5\n3 4\n1 4", "4 3\n1 2 3 4\n1 3\n2 4\n1 1", "2 2\n-1 -2\n1 1\n1 2", "5 6\n1 1 1 -1 0\n2 4\n1 3\n4 5\n1 5\n1 4\n4 5", "8 3\n5 -4 -2 5 3 -4 -2 6\n3 8\n4 6\n2 3", "10 10\n0 0 0 0 0 0 0 0 0 0\n5 9\n1 9\n5 7\n3 8\n1 6\n1 9\n1 6\n6 9\n1 10\n3 8", "3 6\n0 0 0\n1 1\n1 1\n1 3\n3 3\n2 3\n1 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
209
codeforces
8ed90872b9454656dda60a242d493820
Ebony and Ivory
Dante is engaged in a fight with "The Savior". Before he can fight it with his sword, he needs to break its shields. He has two guns, Ebony and Ivory, each of them is able to perform any non-negative number of shots. For every bullet that hits the shield, Ebony deals *a* units of damage while Ivory deals *b* units of ...
{"inputs": ["4 6 15", "3 2 7", "6 11 6", "3 12 15", "5 5 10", "6 6 7", "1 1 20", "12 14 19", "15 12 26", "2 4 8", "4 5 30", "4 5 48", "2 17 105", "10 25 282", "6 34 323", "2 47 464", "4 53 113", "6 64 546", "1 78 725", "1 84 811", "3 100 441", "20 5 57", "14 19 143", "17 23 248", "11 34 383", "20 47 568", "16 58 410", ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
192
codeforces
8f150d098d84cde9f7d73b00f0091443
none
Astronaut Natasha arrived on Mars. She knows that the Martians are very poor aliens. To ensure a better life for the Mars citizens, their emperor decided to take tax from every tourist who visited the planet. Natasha is the inhabitant of Earth, therefore she had to pay the tax to enter the territory of Mars. There are...
{"inputs": ["2 8\n12 20", "3 10\n10 20 30", "5 10\n20 16 4 16 2", "10 5\n4 6 8 6 4 10 2 10 8 6", "20 25\n15 10 5 20 10 5 15 5 15 10 15 5 5 5 5 10 15 20 20 20", "30 30\n11 23 7 30 13 6 25 29 1 15 20 5 28 15 19 22 21 5 27 25 29 10 1 4 12 19 1 5 8 10", "40 30\n16 12 12 22 18 28 32 24 36 26 12 30 22 16 32 30 36 18 20 16 12...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
35
codeforces
8f1d925cbfe50cd21d804490a288b86a
Memory and Scores
Memory and his friend Lexa are competing to get higher score in one popular computer game. Memory starts with score *a* and Lexa starts with score *b*. In a single turn, both Memory and Lexa get some integer in the range [<=-<=*k*;*k*] (i.e. one integer among <=-<=*k*,<=<=-<=*k*<=+<=1,<=<=-<=*k*<=+<=2,<=...,<=<=-<=2,<=...
{"inputs": ["1 2 2 1", "1 1 1 2", "2 12 3 1", "4 6 2 1", "4 6 2 2", "6 4 2 2", "10 1 3 3", "5 3 1 1", "50 22 5 5", "6 20 1 1", "42 42 2 3", "42 42 3 2", "45 54 4 5", "6 5 4 3", "42 42 42 42", "1 100 42 42", "1 100 1000 100", "1 1 1000 100", "100 100 1000 100", "1 8 1 4", "9 4 5 2", "2 6 6 2", "7 8 5 9", "3 7 8 6", "69 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
4
codeforces
8f5411ecdb281373c50db07fac8679e9
Lefthanders and Righthanders
One fine October day a mathematics teacher Vasily Petrov went to a class and saw there *n* pupils who sat at the desks, two people at each desk. Vasily quickly realized that number *n* is even. Like all true mathematicians, Vasily has all students numbered from 1 to *n*. But Vasily Petrov did not like the way the chi...
{"inputs": ["6\nLLRLLL", "4\nRRLL", "4\nLLRR", "6\nRLLRRL", "8\nLRLRLLLR", "10\nRLLRLRRRLL", "12\nLRRRRRLRRRRL", "14\nRLLRLLLLRLLLRL", "16\nLLLRRRLRRLLRRLLL", "18\nRRRLLLLRRRLRLRLLRL", "20\nRLRLLRLRRLLRRRRRRLRL", "22\nRLLLRLLLRRLRRRLRLLLLLL", "24\nLRRRLRLLRLRRRRLLLLRRLRLR", "26\nRLRRLLRRLLRLRRLLRLLRRLRLRR", "28\nLLLRRR...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
40
codeforces
8f73f953a8856ca3a4c9cf3d04b14148
TL
Valera wanted to prepare a Codesecrof round. He's already got one problem and he wants to set a time limit (TL) on it. Valera has written *n* correct solutions. For each correct solution, he knows its running time (in seconds). Valera has also wrote *m* wrong solutions and for each wrong solution he knows its running ...
{"inputs": ["3 6\n4 5 2\n8 9 6 10 7 11", "3 1\n3 4 5\n6", "2 5\n45 99\n49 41 77 83 45", "50 50\n18 13 5 34 10 36 36 12 15 11 16 17 14 36 23 45 32 24 31 18 24 32 7 1 31 3 49 8 16 23 3 39 47 43 42 38 40 22 41 1 49 47 9 8 19 15 29 30 16 18\n91 58 86 51 94 94 73 84 98 69 74 56 52 80 88 61 53 99 88 50 55 95 65 84 87 79 51 5...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
305
codeforces
8f7bee73b29e1a11e67f9279a1507384
The Child and Set
At the children's day, the child came to Picks's house, and messed his house up. Picks was angry at him. A lot of important things were lost, in particular the favorite set of Picks. Fortunately, Picks remembers something about his set *S*: - its elements were distinct integers from 1 to *limit*; - the value of wa...
{"inputs": ["5 5", "4 3", "5 1", "54321 12345", "1997 508", "100000 30000", "100000 100000", "1 100000", "29985 15678", "83451 17526", "96024 12472", "21741 3575", "40287 17817", "58934 6404", "62658 10881", "89829 8298", "5499 1023", "5499 1024", "53689 10552", "247 3270", "58413 1253", "47283 15757", "93145 14496", "...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
104
codeforces
8f93f9bd8f9064af561ecdf39f5a1e37
Alternating Current
Mad scientist Mike has just finished constructing a new device to search for extraterrestrial intelligence! He was in such a hurry to launch it for the first time that he plugged in the power wires without giving it a proper glance and started experimenting right away. After a while Mike observed that the wires ended u...
{"inputs": ["-++-", "+-", "++", "-", "+-+-", "-+-", "-++-+--+", "+", "-+", "--", "+++", "--+", "++--++", "+-++-+", "+-+--+", "--++-+", "-+-+--", "+-+++-", "-+-+-+", "-++-+--++--+-++-", "+-----+-++---+------+++-++++", "-+-++--+++-++++---+--+----+--+-+-+++-+++-+---++-++++-+--+--+--+-+-++-+-+-++++++---++--+++++-+--++--+-+...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
189
codeforces
8fa59503460967189c33fd84aaf7e67c
Help Farmer
Once upon a time in the Kingdom of Far Far Away lived Sam the Farmer. Sam had a cow named Dawn and he was deeply attached to her. Sam would spend the whole summer stocking hay to feed Dawn in winter. Sam scythed hay and put it into haystack. As Sam was a bright farmer, he tried to make the process of storing hay simple...
{"inputs": ["4", "7", "12", "1", "6", "8", "9", "14", "15", "16", "18", "20", "299999771", "54", "96", "348", "748", "908", "1026", "1985", "4472", "20845", "50480", "62497", "646055", "790620", "989903", "7033800", "7661860", "7834243", "45134118", "89054701", "99264891", "127039320", "206898748", "231136953", "257259...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
17
codeforces
8fa6e1aca0e2b6bce302b0b112f22de6
Letter
A boy Bob likes to draw. Not long ago he bought a rectangular graph (checked) sheet with *n* rows and *m* columns. Bob shaded some of the squares on the sheet. Having seen his masterpiece, he decided to share it with his elder brother, who lives in Flatland. Now Bob has to send his picture by post, but because of the w...
{"inputs": ["6 7\n.......\n..***..\n..*....\n..***..\n..*....\n..***..", "3 3\n***\n*.*\n***", "1 1\n*", "2 1\n*\n*", "5 1\n.\n*\n.\n.\n.", "1 6\n*****.", "2 2\n..\n*.", "8 2\n..\n..\n..\n..\n..\n*.\n..\n..", "50 1\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n*\n.\n*\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
218
codeforces
8fc062d952d56f65554254a2fbe9f3e8
none
Petya loves lucky numbers very much. Everybody knows that lucky numbers are positive integers whose decimal record contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Petya loves long lucky numbers very much. He is interested in the minimum lucky number *d* that me...
{"inputs": ["2 2 1 1", "4 7 3 1", "4 7 4 7", "1 1 1 1", "2 2 1 2", "2 1 2 1", "2 2 2 1", "3 3 1 1", "3 2 1 2", "2 1 3 1", "7 7 1 1", "4 7 2 1", "3 3 2 2", "4 3 2 1", "4 4 2 2", "1000000 1000000 1 1", "1000000 1 1 1", "10 10 3 5", "10 10 3 7", "1 7 1 1", "8 3 2 1", "1000000 1000000 1000000 1000000", "4584 45854 25 685",...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
6
codeforces
8fca4ffe8f07d1e257b834639a4873d8
Hulk
Dr. Bruce Banner hates his enemies (like others don't). As we all know, he can barely talk when he turns into the incredible Hulk. That's why he asked you to help him to express his feelings. Hulk likes the Inception so much, and like that his feelings are complicated. They have *n* layers. The first layer is hate, se...
{"inputs": ["1", "2", "3", "4", "5", "10", "18", "19", "76", "77", "81", "82", "85", "86", "100", "99", "98", "33", "34", "57", "100"], "outputs": ["I hate it", "I hate that I love it", "I hate that I love that I hate it", "I hate that I love that I hate that I love it", "I hate that I love that I hate that I love that...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
532
codeforces
8fd162f8011e9ed6789a81a11aa77d54
Winter is here
Winter is here at the North and the White Walkers are close. John Snow has an army consisting of *n* soldiers. While the rest of the world is fighting for the Iron Throne, he is going to get ready for the attack of the White Walkers. He has created a method to know how strong his army is. Let the *i*-th soldier’s stre...
{"inputs": ["3\n3 3 1", "4\n2 3 4 6"], "outputs": ["12", "39"]}
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
5
codeforces
902081dac1e789e7037f497776442362
Recover Polygon (easy)
The zombies are gathering in their secret lair! Heidi will strike hard to destroy them once and for all. But there is a little problem... Before she can strike, she needs to know where the lair is. And the intel she has is not very good. Heidi knows that the lair can be represented as a rectangle on a lattice, with si...
{"inputs": ["6\n000000\n000000\n012100\n024200\n012100\n000000", "6\n000000\n012210\n024420\n012210\n000000\n000000", "6\n000100\n001210\n002420\n001210\n000000\n000000", "10\n0000000000\n0122210000\n0244420100\n0122210000\n0000000000\n0000000000\n0000000000\n0000000000\n0000000000\n0000000000", "10\n0000000000\n000000...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
5
codeforces
903195a712890e0984e95392fc3fad6d
Positions in Permutations
Permutation *p* is an ordered set of integers *p*1,<=<=*p*2,<=<=...,<=<=*p**n*, consisting of *n* distinct positive integers, each of them doesn't exceed *n*. We'll denote the *i*-th element of permutation *p* as *p**i*. We'll call number *n* the size or the length of permutation *p*1,<=<=*p*2,<=<=...,<=<=*p**n*. We'l...
{"inputs": ["1 0", "2 1", "3 2", "4 1", "7 4", "7 7", "8 4", "8 5", "10 3", "20 0", "100 99", "13 13", "100 100", "1000 0", "1000 1", "1000 2", "1000 10", "1000 99", "1000 500", "1000 700", "1000 900", "1000 999", "1000 998", "1000 1000", "999 0", "999 1", "999 5", "999 13", "999 300", "999 600", "999 999", "999 989", ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
2
codeforces
903758cfd129ec5da50a446fab0de40f
Mahmoud and Ehab and the function
Dr. Evil is interested in math and functions, so he gave Mahmoud and Ehab array *a* of length *n* and array *b* of length *m*. He introduced a function *f*(*j*) which is defined for integers *j*, which satisfy 0<=≤<=*j*<=≤<=*m*<=-<=*n*. Suppose, *c**i*<==<=*a**i*<=-<=*b**i*<=+<=*j*. Then *f*(*j*)<==<=|*c*1<=-<=*c*2<=+<...
{"inputs": ["5 6 3\n1 2 3 4 5\n1 2 3 4 5 6\n1 1 10\n1 1 -9\n1 5 -1", "1 1 1\n937982044\n179683049\n1 1 821220804"], "outputs": ["0\n9\n0\n0", "758298995\n1579519799"]}
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
codeforces
904ddf9a4d594b95a85d8cf3bef73636
Turn Off The TV
Luba needs your help again! Luba has *n* TV sets. She knows that *i*-th TV set will be working from moment of time *l**i* till moment *r**i*, inclusive. Luba wants to switch off one of TV sets in order to free the socket. Let's call some TV set redundant if after switching it off the number of integer moments of time ...
{"inputs": ["3\n1 3\n4 6\n1 7", "2\n0 10\n0 10", "3\n1 2\n3 4\n6 8", "3\n1 2\n2 3\n3 4", "3\n0 500000000\n500000001 1000000000\n0 1000000000", "3\n1 5\n2 4\n6 10", "10\n4 4\n5 9\n5 7\n2 8\n6 10\n4 10\n1 3\n8 9\n0 0\n5 7", "2\n1 3\n2 4", "1\n8 9", "8\n13 17\n83 89\n31 33\n7 13\n52 52\n88 89\n29 30\n16 22", "4\n63 63\n12...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
9
codeforces
9051057a015389e58fc1a40a5b2455e2
Mail Stamps
One day Bob got a letter in an envelope. Bob knows that when Berland's post officers send a letter directly from city «A» to city «B», they stamp it with «A B», or «B A». Unfortunately, often it is impossible to send a letter directly from the city of the sender to the city of the receiver, that's why the letter is sen...
{"inputs": ["2\n1 100\n100 2", "3\n3 1\n100 2\n3 2", "3\n458744979 589655889\n248228386 824699605\n458744979 824699605", "4\n90104473 221011623\n18773664 221011623\n90104473 74427905\n74427905 186329050", "5\n695442143 421284135\n641835294 542627184\n852367357 120042890\n641835294 852367357\n542627184 421284135", "6\n2...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
25
codeforces
909a49d6c60a9180e265a01863223410
PFAST Inc.
When little Petya grew up and entered the university, he started to take part in АСМ contests. Later he realized that he doesn't like how the АСМ contests are organised: the team could only have three members (and he couldn't take all his friends to the competitions and distribute the tasks between the team members eff...
{"inputs": ["3 1\nPetya\nVasya\nMasha\nPetya Vasya", "3 0\nPasha\nLesha\nVanya", "7 12\nPasha\nLesha\nVanya\nTaras\nNikita\nSergey\nAndrey\nPasha Taras\nPasha Nikita\nPasha Andrey\nPasha Sergey\nLesha Taras\nLesha Nikita\nLesha Andrey\nLesha Sergey\nVanya Taras\nVanya Nikita\nVanya Andrey\nVanya Sergey", "2 0\nAndrey\n...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
28
codeforces
90b3babebf9e99d1cac2b06764636584
none
You are given a rectangular parallelepiped with sides of positive integer lengths $A$, $B$ and $C$. Find the number of different groups of three integers ($a$, $b$, $c$) such that $1\leq a\leq b\leq c$ and parallelepiped $A\times B\times C$ can be paved with parallelepipeds $a\times b\times c$. Note, that all small p...
{"inputs": ["4\n1 1 1\n1 6 1\n2 2 2\n100 100 100", "10\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1", "10\n9 6 8\n5 5 2\n8 9 2\n2 7 9\n6 4 10\n1 1 8\n2 8 1\n10 6 3\n7 5 2\n9 5 4", "1\n100000 100000 100000"], "outputs": ["1\n4\n4\n165", "1\n1\n1\n1\n1\n1\n1\n1\n1\n1", "41\n6\n21\n12\n39\n4\n7\n2...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
2
codeforces
90c3ae3432be76316c44df8b294d09fc
Money Transfers
There are *n* banks in the city where Vasya lives, they are located in a circle, such that any two banks are neighbouring if their indices differ by no more than 1. Also, bank 1 and bank *n* are neighbours if *n*<=&gt;<=1. No bank is a neighbour of itself. Vasya has an account in each bank. Its balance may be negative...
{"inputs": ["3\n5 0 -5", "4\n-1 0 1 0", "4\n1 2 3 -6", "1\n0", "50\n108431864 128274949 -554057370 -384620666 -202862975 -803855410 -482167063 -55139054 -215901009 0 0 0 0 0 94325701 730397219 358214459 -673647271 -131397668 -377892440 0 0 0 0 0 -487994257 -360271553 639988328 489338210 -281060728 250208758 0 993242346...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
28
codeforces
90c94d1f5e83e4c8b0d3186dacb5a837
Good Number
Let's call a number *k*-good if it contains all digits not exceeding *k* (0,<=...,<=*k*). You've got a number *k* and an array *a* containing *n* numbers. Find out how many *k*-good numbers are in *a* (count each number every time it occurs in array *a*). The first line contains integers *n* and *k* (1<=≤<=*n*<=≤<=100,...
{"inputs": ["10 6\n1234560\n1234560\n1234560\n1234560\n1234560\n1234560\n1234560\n1234560\n1234560\n1234560", "2 1\n1\n10", "1 0\n1000000000", "1 1\n1000000000", "6 0\n10\n102\n120\n1032\n1212103\n1999999", "1 3\n1000000000", "1 9\n1000000000", "1 0\n1", "1 1\n1", "1 3\n1", "1 9\n1", "2 8\n123456780\n123", "2 8\n123456...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
318
codeforces
90e34ecfae4b0a43ec885c28e8b50ef6
Фото на память - 2 (round version)
Прошло много лет, и на вечеринке снова встретились *n* друзей. С момента последней встречи техника шагнула далеко вперёд, появились фотоаппараты с автоспуском, и теперь не требуется, чтобы один из друзей стоял с фотоаппаратом, и, тем самым, оказывался не запечатлённым на снимке. Упрощенно процесс фотографирования можн...
{"inputs": ["3\n10 1\n20 2\n30 3", "3\n3 1\n2 2\n4 3", "1\n5 10", "10\n168 538\n836 439\n190 873\n206 47\n891 591\n939 481\n399 898\n859 466\n701 777\n629 222", "42\n13 62\n114 242\n265 839\n756 349\n298 476\n533 704\n348 277\n554 573\n654 112\n429 836\n574 766\n909 415\n163 891\n532 983\n873 457\n719 117\n1 302\n170 6...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
7
codeforces
912f39a3ff6a9f5dd8230e1c50920c4f
none
Little Chris is very keen on his toy blocks. His teacher, however, wants Chris to solve more problems, so he decided to play a trick on Chris. There are exactly *s* blocks in Chris's set, each block has a unique number from 1 to *s*. Chris's teacher picks a subset of blocks *X* and keeps it to himself. He will give th...
{"inputs": ["3\n1 4 5", "1\n1", "1\n1000000", "2\n2 999999", "9\n1 2 3 100 500000 500001 999901 999997 999999", "3\n999998 999999 1000000", "3\n1 2 3", "3\n5 345435 999996", "6\n1 10 100 1000 10000 1000000", "2\n1 1000000", "2\n500000 500001", "4\n1 2 999999 1000000", "10\n63649 456347 779 458642 201571 534312 583774 2...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
codeforces
9136cb00808749220dc6c0007520b499
Insomnia cure
«One dragon. Two dragon. Three dragon», — the princess was counting. She had trouble falling asleep, and she got bored of counting lambs when she was nine. However, just counting dragons was boring as well, so she entertained herself at best she could. Tonight she imagined that all dragons were here to steal her, and ...
{"inputs": ["1\n2\n3\n4\n12", "2\n3\n4\n5\n24", "1\n1\n1\n1\n100000", "10\n9\n8\n7\n6", "8\n4\n4\n3\n65437", "8\n4\n1\n10\n59392", "4\n1\n8\n7\n44835", "6\n1\n7\n2\n62982", "2\n7\n4\n9\n56937", "2\n9\n8\n1\n75083", "8\n7\n7\n6\n69038", "4\n4\n2\n3\n54481", "6\n4\n9\n8\n72628", "9\n7\n8\n10\n42357", "5\n6\n4\n3\n60504",...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
410
codeforces
913a723377dcbcee617e84424051c006
Guess the Array
This is an interactive problem. You should use flush operation after each printed line. For example, in C++ you should use fflush(stdout), in Java you should use System.out.flush(), and in Pascal — flush(output). In this problem you should guess an array *a* which is unknown for you. The only information you have init...
{"inputs": ["5\n4 6 1 5 5", "3\n1 1 1", "4\n100 1 100 1", "10\n9 5 10 7 4 4 8 5 10 5", "3\n1 1 1", "3\n100000 100000 100000", "3\n91906 50782 19777", "15\n5 10 10 7 7 6 4 6 8 10 8 4 10 9 4", "30\n2 3 3 4 3 2 4 4 4 3 3 2 4 2 3 4 4 2 4 3 4 2 2 4 3 3 4 4 4 4", "35\n4 2 2 2 4 4 3 2 4 2 2 4 2 2 3 2 3 4 4 2 3 2 2 4 3 3 3 3 4...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
109
codeforces
9143317c9ec97376be9a5c100718a323
Passwords
Vanya is managed to enter his favourite site Codehorses. Vanya uses *n* distinct passwords for sites at all, however he can't remember which one exactly he specified during Codehorses registration. Vanya will enter passwords in order of non-decreasing their lengths, and he will enter passwords of same length in arbitr...
{"inputs": ["5 2\ncba\nabc\nbb1\nabC\nABC\nabc", "4 100\n11\n22\n1\n2\n22", "1 1\na1\na1", "1 100\na1\na1", "2 1\nabc\nAbc\nAbc", "2 2\nabc\nAbc\nabc", "2 1\nab\nabc\nab", "2 2\nab\nabc\nab", "2 1\nab\nabc\nabc", "2 2\nab\nabc\nabc", "10 3\nOIbV1igi\no\nZS\nQM\n9woLzI\nWreboD\nQ7yl\nA5Rb\nS9Lno72TkP\nfT97o\no", "10 3\n...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
104
codeforces
91615ecf5e80dbea491e2b190588ef2c
none
Little Artem found a grasshopper. He brought it to his house and constructed a jumping area for him. The area looks like a strip of cells 1<=×<=*n*. Each cell contains the direction for the next jump and the length of that jump. Grasshopper starts in the first cell and follows the instructions written on the cells. Gr...
{"inputs": ["2\n><\n1 2", "3\n>><\n2 1 1", "1\n>\n1000000000", "1\n<\n1000000000", "2\n>>\n1 1", "5\n>><><\n1 2 3 1 2", "5\n>><><\n1 2 2 1 2", "10\n>>>>>>>>><\n1 1 1 1 1 1 1 1 1 10", "10\n>>>>>>>>><\n1 1 1 1 1 1 1 1 1 5", "10\n>>>>>>>>><\n1 1 1 1 1 1 1 1 1 1", "3\n><<\n2 1 1", "10\n>>>>>>>>>>\n1 1 1 1 1 1 1 1 1 100", "...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
96
codeforces
9168c9068c3cb16956fa2cc4c969c235
none
A ski base is planned to be built in Walrusland. Recently, however, the project is still in the constructing phase. A large land lot was chosen for the construction. It contains *n* ski junctions, numbered from 1 to *n*. Initially the junctions aren't connected in any way. In the constructing process *m* bidirectional...
{"inputs": ["3 4\n1 3\n2 3\n1 2\n1 2", "15 29\n6 11\n14 3\n10 4\n14 7\n6 14\n7 15\n13 8\n10 13\n4 14\n15 8\n12 7\n3 5\n6 7\n8 1\n4 5\n11 5\n10 6\n11 3\n13 14\n7 10\n3 12\n7 14\n8 11\n7 15\n15 8\n12 7\n4 3\n9 4\n8 10", "34 27\n19 10\n8 31\n26 22\n2 30\n32 26\n30 4\n34 1\n2 31\n4 18\n33 11\n10 13\n20 23\n4 32\n23 27\n30 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
2
codeforces
916e1fdc90023043052db3e6738ca240
Chores
Luba has to do *n* chores today. *i*-th chore takes *a**i* units of time to complete. It is guaranteed that for every the condition *a**i*<=≥<=*a**i*<=-<=1 is met, so the sequence is sorted. Also Luba can work really hard on some chores. She can choose not more than *k* any chores and do each of them in *x* units of ...
{"inputs": ["4 2 2\n3 6 7 10", "5 2 1\n100 100 100 100 100", "1 1 1\n100", "100 1 99\n100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 10...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
291
codeforces
9172cd6361befbdd0dd7efc95b7a917d
Haiku
Haiku is a genre of Japanese traditional poetry. A haiku poem consists of 17 syllables split into three phrases, containing 5, 7 and 5 syllables correspondingly (the first phrase should contain exactly 5 syllables, the second phrase should contain exactly 7 syllables, and the third phrase should contain exactly 5 syll...
{"inputs": ["on codeforces \nbeta round is running\n a rustling of keys ", "how many gallons\nof edo s rain did you drink\n cuckoo", " hatsu shigure\n saru mo komino wo\nhoshige nari", "o vetus stagnum\n rana de ripa salit\n ac sonant aquae", " furuike ya\nkawazu...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
426
codeforces
9193fd7c419ef9dff9dc9dcd79640cdc
Card Game Again
Vova again tries to play some computer card game. The rules of deck creation in this game are simple. Vova is given an existing deck of *n* cards and a magic number *k*. The order of the cards in the deck is fixed. Each card has a number written on it; number *a**i* is written on the *i*-th card in the deck. After re...
{"inputs": ["3 4\n6 2 8", "3 6\n9 1 14", "5 1\n1 3 1 3 1", "5 1\n5 5 5 5 5", "5 1\n5 4 4 4 4", "100 1\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1", "100 1\n3 3 2 1...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
3
codeforces
919a173054ff13c4de2e0f84f05b8cbb
The Labyrinth
You are given a rectangular field of *n*<=×<=*m* cells. Each cell is either empty or impassable (contains an obstacle). Empty cells are marked with '.', impassable cells are marked with '*'. Let's call two empty cells adjacent if they share a side. Let's call a connected component any non-extendible set of cells such ...
{"inputs": ["3 3\n*.*\n.*.\n*.*", "4 5\n**..*\n..***\n.*.*.\n*.*.*", "1 1\n*", "1 1\n.", "1 10\n**********", "1 10\n*.***.**.*", "10 1\n*\n*\n*\n*\n*\n.\n*\n.\n*\n*", "10 1\n.\n.\n.\n.\n.\n.\n.\n.\n.\n."], "outputs": ["3.3\n.5.\n3.3", "46..3\n..732\n.6.4.\n5.4.3", "1", ".", "1111111111", "2.212.22.2", "1\n1\n1\n1\n2\n....
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
10
codeforces
91b19792c755370d0bb363b9e826e496
Message
Dr. Moriarty is about to send a message to Sherlock Holmes. He has a string *s*. String *p* is called a substring of string *s* if you can read it starting from some position in the string *s*. For example, string "aba" has six substrings: "a", "b", "a", "ab", "ba", "aba". Dr. Moriarty plans to take string *s* and c...
{"inputs": ["aaaaa\naaa", "abcabc\nbcd", "abcdef\nklmnopq", "aaabbbaaa\naba", "a\na", "z\nz", "a\nz", "d\nt", "o\nu", "a\nm", "t\nv", "n\ng", "c\nh", "r\ni", "h\nb", "r\na", "c\np", "wbdbzf\nfpvlerhsuf", "zafsqbsu\nhl", "juhlp\nycqugugk", "ladfasxt\ncpvtd", "ally\ncjidwuj", "rgug\npgqwslo", "wmjwu\nrfew", "cpnwcdqff\nq...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
12
codeforces
91c3babe38f68cd3ad2fb4f40f35e2f3
Restoring Table
Recently Polycarpus has learned the "bitwise AND" operation (which is also called "AND") of non-negative integers. Now he wants to demonstrate the school IT teacher his superb manipulation with the learned operation. For that Polycarpus came to school a little earlier and wrote on the board a sequence of non-negative ...
{"inputs": ["1\n-1", "3\n-1 18 0\n18 -1 0\n0 0 -1", "4\n-1 128 128 128\n128 -1 148 160\n128 148 -1 128\n128 160 128 -1", "5\n-1 0 0 0 0\n0 -1 1 0 0\n0 1 -1 0 0\n0 0 0 -1 0\n0 0 0 0 -1", "6\n-1 1835024 1966227 34816 68550800 34832\n1835024 -1 18632728 306185992 324272924 289412624\n1966227 18632728 -1 40 555155640 16846...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
12
codeforces
91c49eb218a529b816dfd941b351be69
Queue
Little girl Susie went shopping with her mom and she wondered how to improve service quality. There are *n* people in the queue. For each person we know time *t**i* needed to serve him. A person will be disappointed if the time he waits is more than the time needed to serve him. The time a person waits is the total t...
{"inputs": ["5\n15 2 1 5 3", "15\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1", "10\n13 2 5 55 21 34 1 8 1 3", "10\n8 256 16 1 2 1 64 4 128 32", "10\n10000 40000 10000 50000 20000 100000 10000 100 30000 500", "1\n1000000000", "15\n9 11 45 86 52 65 35 3 93 7 21 45 15 11 39", "20\n16839799 17525904 91276752 42650694 60106463 12243176 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
158
codeforces
91ddbbe8aa042ec08491c7c25d7aba7b
Triangle
At a geometry lesson Bob learnt that a triangle is called right-angled if it is nondegenerate and one of its angles is right. Bob decided to draw such a triangle immediately: on a sheet of paper he drew three points with integer coordinates, and joined them with segments of straight lines, then he showed the triangle t...
{"inputs": ["0 0 2 0 0 1", "2 3 4 5 6 6", "-1 0 2 0 0 1", "27 74 85 23 100 99", "-97 -19 17 62 30 -76", "28 -15 86 32 98 -41", "-66 24 8 -29 17 62", "-83 40 -80 52 -71 43", "-88 67 -62 37 -49 75", "58 45 6 22 13 79", "75 86 -82 89 -37 -35", "34 74 -2 -95 63 -33", "-7 63 78 74 -39 -30", "-49 -99 7 92 61 -28", "-90 90 87...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
36
codeforces
91e81a621aec1c42e9fa4f1997c14bf9
Luck is in Numbers
Vasya has been collecting transport tickets for quite a while now. His collection contains several thousands of tram, trolleybus and bus tickets. Vasya is already fed up with the traditional definition of what a lucky ticket is. Thus, he's looking for new perspectives on that. Besides, Vasya cannot understand why all t...
{"inputs": ["13", "2345", "88", "682444", "685116", "576079", "569631", "662302", "453066", "659821", "26592659", "47699969", "09980988", "69886888", "9588995888", "39930089893999008989", "84163081988476808998", "88898888988889888898", "01273988890029888889", "18858998881886898888", "8259988583", "5898888944", "8558898...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
codeforces
91f7cff482b2b493374285494a5a7025
Beautiful Sets of Points
Manao has invented a new mathematical term — a beautiful set of points. He calls a set of points on a plane beautiful if it meets the following conditions: 1. The coordinates of each point in the set are integers. 1. For any two points from the set, the distance between them is a non-integer. Consider all points (*...
{"inputs": ["2 2", "4 3", "21 21", "10 1", "4 4", "1 1", "5 5", "100 100", "96 96", "99 100", "67 58", "67 59", "80 91", "100 11", "16 55", "13 71", "30 40", "77 77", "6 6", "37 42", "88 88", "95 99", "93 70", "4 6", "1 4", "2 10", "6 7", "28 28", "10 6", "85 48", "9 6", "2 6", "6 4", "6 10", "16 5", "7 6", "3 4", "13 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
20
codeforces
92033556eb9354fb8e42ff803e338e16
Polycarp at the Radio
Polycarp is a music editor at the radio station. He received a playlist for tomorrow, that can be represented as a sequence *a*1,<=*a*2,<=...,<=*a**n*, where *a**i* is a band, which performs the *i*-th song. Polycarp likes bands with the numbers from 1 to *m*, but he doesn't really like others. We define as *b**j* th...
{"inputs": ["4 2\n1 2 3 2", "7 3\n1 3 2 2 2 2 1", "4 4\n1000000000 100 7 1000000000", "1 1\n1", "1 1\n381183829", "2 1\n234089514 461271539", "5 4\n3 1 495987801 522279660 762868488", "10 2\n20515728 1 580955166 856585851 1 738372422 1 2 1 900189620", "20 3\n3 2 2 3 3 3 2 3 3 3 2 748578511 149249674 844954396 321901094...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
3
codeforces
9220b32c3435f2ebc62e4b87277d09cc
Ciel and Robot
Fox Ciel has a robot on a 2D plane. Initially it is located in (0, 0). Fox Ciel code a command to it. The command was represented by string *s*. Each character of *s* is one move operation. There are four move operations at all: - 'U': go up, (x, y) <=→<= (x, y+1); - 'D': go down, (x, y) <=→<= (x, y-1); - 'L': go l...
{"inputs": ["2 2\nRU", "1 2\nRU", "-1 1000000000\nLRRLU", "0 0\nD", "0 0\nUURRDL", "987654321 987654321\nUURRDL", "4 2\nUURRDL", "4 3\nUURRDL", "4 4\nUURRDL", "4 6\nUURRDL", "4 7\nUURRDL", "1000000000 1000000000\nUURRDL", "-1 -1\nUR", "1 1\nUURRDDLL", "987654321 2\nUURDD", "0 123456789\nRRULL", "4 4\nUUUURRRRDDDDLLLL",...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
8
codeforces
9220f6088bde1e658f48d2c43eca3a2e
Transformation: from A to B
Vasily has a number *a*, which he wants to turn into a number *b*. For this purpose, he can do two types of operations: - multiply the current number by 2 (that is, replace the number *x* by 2·*x*); - append the digit 1 to the right of current number (that is, replace the number *x* by 10·*x*<=+<=1). You need to he...
{"inputs": ["2 162", "4 42", "100 40021", "1 111111111", "1 1000000000", "999999999 1000000000", "1 2", "1 536870912", "11111 11111111", "59139 946224", "9859 19718", "25987 51974222", "9411 188222222", "25539 510782222", "76259 610072", "92387 184774", "8515 85151111", "91939 9193911", "30518 610361", "46646 373168844...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
275
codeforces
9244db8730fb75772e42e09626cc70a0
Lucky Transformation
Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Petya has a number consisting of *n* digits without leading zeroes. He represented it as an array of...
{"inputs": ["7 4\n4727447", "4 2\n4478", "7 7\n4211147", "7 6\n4747477", "10 2\n9474444474", "10 47\n4214777477", "3 99\n447", "4 1000000000\n7747", "3 1000000000\n447", "3 100\n447", "7 74\n4777774", "10 200\n6860544593", "10 477\n5837934237", "47 7477\n83492039276961836565341994102530448486552156001", "100 0\n9179665...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
7
codeforces
924ee6af45d93e3e9e8d31fd75d78f25
Palindromic Supersequence
You are given a string *A*. Find a string *B*, where *B* is a palindrome and *A* is a subsequence of *B*. A subsequence of a string is a string that can be derived from it by deleting some (not necessarily consecutive) characters without changing the order of the remaining characters. For example, "cotst" is a subsequ...
{"inputs": ["aba", "ab", "krnyoixirslfszfqivgkaflgkctvbvksipwomqxlyqxhlbceuhbjbfnhofcgpgwdseffycthmlpcqejgskwjkbkbbmifnurnwyhevsoqzmtvzgfiqajfrgyuzxnrtxectcnlyoisbglpdbjbslxlpoymrcxmdtqhcnlvtqdwftuzgbdxsyscwbrguostbelnvtaqdmkmihmoxqtqlxvlsssisvqvvzotoyqryuyqwoknnqcqggysrqpkrccvyhxsjmhoqoyocwcriplarjoyiqrmmpmueqbsbljddw...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
316
codeforces
925e553c109453d152cad07257492d18
Correct Solution?
One cold winter evening Alice and her older brother Bob was sitting at home near the fireplace and giving each other interesting problems to solve. When it was Alice's turn, she told the number *n* to Bob and said: —Shuffle the digits in this number in order to obtain the smallest possible number without leading zeroe...
{"inputs": ["3310\n1033", "4\n5", "40\n04", "12\n12", "432\n234", "17109\n01179", "888\n888", "912\n9123", "0\n00", "11110\n1111", "7391\n1397", "201\n102", "111111111\n111111111", "32352320\n22203335", "1000000000\n1", "994321\n123499", "10101\n10101", "666\n0666", "2\n02", "313\n133", "987235645\n234556789", "90812\n...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
95
codeforces
92637dfd121876c5454d4403888576c8
Flow Control
You have to handle a very complex water distribution system. The system consists of $n$ junctions and $m$ pipes, $i$-th pipe connects junctions $x_i$ and $y_i$. The only thing you can do is adjusting the pipes. You have to choose $m$ integer numbers $f_1$, $f_2$, ..., $f_m$ and use them as pipe settings. $i$-th pipe w...
{"inputs": ["4\n3 -10 6 1\n5\n1 2\n3 2\n2 4\n3 4\n3 1", "4\n3 -10 6 4\n5\n1 2\n3 2\n2 4\n3 4\n3 1", "1\n0\n0", "1\n123\n0", "2\n-1 1\n1\n1 2", "2\n-1 1\n1\n2 1"], "outputs": ["Possible\n-3\n-6\n1\n0\n0", "Impossible", "Possible", "Impossible", "Possible\n1", "Possible\n-1"]}
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
2
codeforces
92666187f65dafd187e08ecca21dfb68
Servers
There are *n* servers in a laboratory, each of them can perform tasks. Each server has a unique id — integer from 1 to *n*. It is known that during the day *q* tasks will come, the *i*-th of them is characterized with three integers: *t**i* — the moment in seconds in which the task will come, *k**i* — the number of se...
{"inputs": ["4 3\n1 3 2\n2 2 1\n3 4 3", "3 2\n3 2 3\n5 1 2", "8 6\n1 3 20\n4 2 1\n6 5 5\n10 1 1\n15 3 6\n21 8 8", "4 1\n6 1 1", "1 10\n4 1 1\n9 1 1\n10 1 1\n12 1 1\n13 1 1\n15 1 1\n16 1 1\n18 1 1\n19 1 1\n20 1 1", "4 10\n1 1 1\n3 1 2\n4 1 2\n6 1 2\n8 1 2\n13 1 2\n16 1 1\n17 1 2\n19 3 1\n20 1 1", "100 1\n1000000 100 100...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
26
codeforces
926f692c16a1c9cdb53c696bf20cd7b4
Lucky Common Subsequence
In mathematics, a subsequence is a sequence that can be derived from another sequence by deleting some elements without changing the order of the remaining elements. For example, the sequence BDF is a subsequence of ABCDEF. A substring of a string is a continuous subsequence of the string. For example, BCD is a substri...
{"inputs": ["AJKEQSLOBSROFGZ\nOVGURWZLWVLUXTH\nOZ", "AA\nA\nA", "PWBJTZPQHA\nZJMKLWSROQ\nUQ", "QNHRPFYMAAPJDUHBAEXNEEZSTMYHVGQPYKNMVKMBVSVLIYGUVMJHEFLJEPIWFHSLISTGOKRXNMSCXYKMAXBPKCOCNTIRPCUEPHXM\nRRFCZUGFDRKKMQTOETNELXMEWGOCDHFKIXOPVHHEWTCDNXVFKFKTKNWKEIKTCMHMHDNCLLVQSGKHBCDDYVVVQIRPZEOPUGQUGRHH\nR", "CGPWTAPEVBTGANLC...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
9
codeforces
92860c2d54613a5f2fb815cb46e37e60
Shooshuns and Sequence
One day shooshuns found a sequence of *n* integers, written on a blackboard. The shooshuns can perform one operation with it, the operation consists of two steps: 1. Find the number that goes *k*-th in the current sequence and add the same number to the end of the sequence; 1. Delete the first number of the current ...
{"inputs": ["3 2\n3 1 1", "3 1\n3 1 1", "1 1\n1", "2 1\n1 1", "2 1\n2 1", "4 4\n1 2 3 4", "4 3\n1 2 3 4", "5 3\n2 1 1 1 1", "5 3\n1 1 1 1 1", "5 5\n1 1 1 1 1", "10 1\n1 1 1 1 1 1 1 1 1 1", "10 1\n1 2 1 1 1 1 1 1 1 1", "10 1\n2 1 1 1 1 1 1 1 1 1", "10 2\n2 1 1 1 1 1 1 1 1 1", "10 2\n1 2 1 1 1 1 1 1 1 1", "10 3\n3 2 1 1 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
134
codeforces
929c86cf60c47745d6a36689f25fc604
Digital Root
Not long ago Billy came across such a problem, where there were given three natural numbers *A*, *B* and *C* from the range [1,<=*N*], and it was asked to check whether the equation *AB*<==<=*C* is correct. Recently Billy studied the concept of a digital root of a number. We should remind you that a digital root *d*(*x...
{"inputs": ["4", "5", "6", "7", "1", "8", "10", "15", "16", "20", "50", "100", "127", "202", "333", "404", "411", "571", "600", "771", "10000", "20000", "30000", "50000", "99999", "200000", "400000", "600000", "800000", "1000000", "828282", "729761", "653451", "987572", "167590", "358712", "498138", "983242", "312433",...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
18
codeforces
92c08c69d538b4c2e5079bb390c72c27
Little Elephant and Magic Square
Little Elephant loves magic squares very much. A magic square is a 3<=×<=3 table, each cell contains some positive integer. At that the sums of integers in all rows, columns and diagonals of the table are equal. The figure below shows the magic square, the sum of integers in all its rows, columns and diagonals equals ...
{"inputs": ["0 1 1\n1 0 1\n1 1 0", "0 3 6\n5 0 5\n4 7 0", "0 4 4\n4 0 4\n4 4 0", "0 54 48\n36 0 78\n66 60 0", "0 17 14\n15 0 15\n16 13 0", "0 97 56\n69 0 71\n84 43 0", "0 1099 1002\n1027 0 1049\n1074 977 0", "0 98721 99776\n99575 0 99123\n98922 99977 0", "0 6361 2304\n1433 0 8103\n7232 3175 0", "0 99626 99582\n99766 0 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
246
codeforces
92ccbd5c5653fc913a6ad45681e3a8df
String Mark
At the Byteland State University marks are strings of the same length. Mark *x* is considered better than *y* if string *y* is lexicographically smaller than *x*. Recently at the BSU was an important test work on which Vasya recived the mark *a*. It is very hard for the teacher to remember the exact mark of every stud...
{"inputs": ["abc\nddd", "abcdef\nabcdeg", "abacaba\nubuduba", "aac\nbbb", "aaaccc\nbbbbbb", "aaaaaa\nzzzzzz", "abcde\nzzzzz", "a\nc", "aaa\nccc", "abacabadaba\ndabacabaaba", "ujfawuezgiy\nvuqvvsivvwe", "jvmzmvqexcqycjcpuqimvyovcffrdwtexpqhxswzytoaokvnexkzgycpmbgvsnyifkwvfbirtwnprmrlotlnhkogjlmxmgruklcuqstwfwoswux\nvzsm...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
2
codeforces
92e4245cc1e7a150805ac581d4a69a8b
Producing Snow
Alice likes snow a lot! Unfortunately, this year's winter is already over, and she can't expect to have any more of it. Bob has thus bought her a gift — a large snow maker. He plans to make some amount of snow every day. On day *i* he will make a pile of snow of volume *V**i* and put it in her garden. Each day, every ...
{"inputs": ["3\n10 10 5\n5 7 2", "5\n30 25 20 15 10\n9 10 12 4 13", "4\n0 0 0 0\n1 2 3 4", "10\n11 39 16 34 25 3 12 11 31 16\n10 0 4 9 8 9 7 8 9 2", "10\n20 35 4 0 6 29 4 9 17 10\n0 9 4 7 5 1 4 3 9 4", "1\n4\n5", "1\n5\n4", "1\n5\n5", "2\n9 3\n8 2", "2\n9 3\n4 4", "2\n9 3\n10 2", "13\n1 1 1 1 1 1 1 1 1 1 1 1 1\n1 1 1 1...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
35
codeforces
92e6dae987b75873174241e50e0bd7e4
Beautiful Matrix
You've got a 5<=×<=5 matrix, consisting of 24 zeroes and a single number one. Let's index the matrix rows by numbers from 1 to 5 from top to bottom, let's index the matrix columns by numbers from 1 to 5 from left to right. In one move, you are allowed to apply one of the two following transformations to the matrix: 1....
{"inputs": ["0 0 0 0 0\n0 0 0 0 1\n0 0 0 0 0\n0 0 0 0 0\n0 0 0 0 0", "0 0 0 0 0\n0 0 0 0 0\n0 1 0 0 0\n0 0 0 0 0\n0 0 0 0 0", "0 0 0 0 0\n0 0 0 0 0\n0 0 1 0 0\n0 0 0 0 0\n0 0 0 0 0", "0 0 0 0 0\n0 0 0 0 0\n0 0 0 0 0\n0 0 0 0 0\n0 0 0 0 1", "0 1 0 0 0\n0 0 0 0 0\n0 0 0 0 0\n0 0 0 0 0\n0 0 0 0 0", "1 0 0 0 0\n0 0 0 0 0\n...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
832
codeforces
92f49e48728895bf9355b6b25cadd38b
Quiz League
A team quiz game called "What? Where? When?" is very popular in Berland. The game is centered on two teams competing. They are the team of six Experts versus the team of the Audience. A person from the audience asks a question and the experts are allowed a minute on brainstorming and finding the right answer to the que...
{"inputs": ["5 5\n0 1 0 1 0", "2 1\n1 1", "3 2\n1 0 0", "3 3\n0 1 0", "1 1\n1", "6 3\n0 0 1 1 0 1", "3 1\n0 1 0", "3 3\n1 0 1", "4 4\n1 0 1 0", "5 3\n0 1 0 1 1", "6 4\n1 0 0 0 0 1", "7 5\n1 0 0 0 0 0 1", "101 81\n1 0 1 1 1 1 0 0 1 1 1 1 1 0 0 1 0 1 0 1 1 1 1 1 1 1 0 1 1 0 1 1 1 0 1 0 0 1 0 1 0 1 1 0 1 0 0 1 0 0 0 1 0 0...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
36
codeforces
93036ead36690dea9ad6cf7ba98801a7
Hit the Lottery
Allen has a LOT of money. He has $n$ dollars in the bank. For security reasons, he wants to withdraw it in cash (we will not disclose the reasons here). The denominations for dollar bills are $1$, $5$, $10$, $20$, $100$. What is the minimum number of bills Allen could receive after withdrawing his entire balance? The f...
{"inputs": ["125", "43", "1000000000", "4", "5", "1", "74", "31", "59", "79", "7", "55", "40", "719", "847", "225", "4704", "1132", "7811", "7981", "82655", "6364", "74611", "45391", "620448", "265145", "671704", "365173", "7130872", "9628747", "8898399", "9497953", "19070947", "20185520", "91402248", "27035533", "2271...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
853
codeforces
9309776dd3ce513a2e83a90222c7ae3d
Anthem of Berland
Berland has a long and glorious history. To increase awareness about it among younger citizens, King of Berland decided to compose an anthem. Though there are lots and lots of victories in history of Berland, there is the one that stand out the most. King wants to mention it in the anthem as many times as possible. H...
{"inputs": ["winlose???winl???w??\nwin", "glo?yto?e??an?\nor", "??c?????\nabcab", "ddddd\nd", "ww?ww\nw", "?????\nn", "xznxr\nxznxr", "wnfbhg?dkhdbh?hdmfjkcunzbh?hdbjjrbh?hddmh?zubhgh?qbjbhghdpwr?bhghdfjnjf?qbhghdqq?qebhgh?umvbhghdivvj\nbhghd", "emnd?t??m?gd?t?p?s??m?dp??t???m?????m?d?ydo????????i??u?d??dp??h??d?tdp???...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
2
codeforces
931258d7701c6fe0dd407a74d1675d06
Twins
Imagine that you have a twin brother or sister. Having another person that looks exactly like you seems very unusual. It's hard to say if having something of an alter ego is good or bad. And if you do have a twin, then you very well know what it's like. Now let's imagine a typical morning in your family. You haven't w...
{"inputs": ["2\n3 3", "3\n2 1 2", "1\n5", "5\n4 2 2 2 2", "7\n1 10 1 2 1 1 1", "5\n3 2 3 3 1", "2\n2 1", "3\n2 1 3", "6\n1 1 1 1 1 1", "7\n10 10 5 5 5 5 1", "20\n2 1 2 2 2 1 1 2 1 2 2 1 1 1 1 2 1 1 1 1", "20\n4 2 4 4 3 4 2 2 4 2 3 1 1 2 2 3 3 3 1 4", "20\n35 26 41 40 45 46 22 26 39 23 11 15 47 42 18 15 27 10 45 40", "2...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
600
codeforces
93133b96b5b3070a160ab0df19ac93d9
Minesweeper 1D
Game "Minesweeper 1D" is played on a line of squares, the line's height is 1 square, the line's width is *n* squares. Some of the squares contain bombs. If a square doesn't contain a bomb, then it contains a number from 0 to 2 — the total number of bombs in adjacent squares. For example, the correct field to play look...
{"inputs": ["?01???", "?", "**12", "1", "?01*??****", "0", "2", "*", "0*", "0?", "01", "1*", "1?", "?1?", "12", "2*", "2?", "2??", "?2?", "?2*?2*??1*2**?2*1???*2???100?????*???*?*????0????2?*?*?1??1??*?01**2**1001??**??**??1*?*???00??**??*", "00***???01", "21?20*0000?2?22??0001*?1??12?20020200?**0*12?*221*0*1200*?0*11?...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
8
codeforces
932312c3309f5b145d6fe3168330ff4b
Buses Between Cities
Buses run between the cities *A* and *B*, the first one is at 05:00 AM and the last one departs not later than at 11:59 PM. A bus from the city *A* departs every *a* minutes and arrives to the city *B* in a *t**a* minutes, and a bus from the city *B* departs every *b* minutes and arrives to the city *A* in a *t**b* min...
{"inputs": ["10 30\n10 35\n05:20", "60 120\n24 100\n13:00", "30 60\n60 60\n22:30", "30 60\n10 60\n23:30", "5 45\n4 60\n21:00", "1 1\n1 1\n10:28", "4 1\n5 4\n18:40", "8 8\n1 1\n13:24", "20 4\n1 20\n06:20", "15 24\n23 6\n21:15", "30 19\n21 4\n10:30", "31 15\n36 25\n07:04", "24 3\n54 9\n18:12", "18 69\n62 54\n08:00", "33 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
35
codeforces
933534e531757a47f23e4d8f9ec7fa10
Hexagons
Ayrat is looking for the perfect code. He decided to start his search from an infinite field tiled by hexagons. For convenience the coordinate system is introduced, take a look at the picture to see how the coordinates of hexagon are defined: Ayrat is searching through the field. He started at point (0,<=0) and is ...
{"inputs": ["3", "7", "39", "14", "94", "60", "60", "59", "181994", "486639", "34514", "826594", "1000000000000000000", "854460", "164960", "618459", "496181994", "1000000000", "228939226", "973034514", "984826594", "19164960", "249781780", "851838979", "978618459", "871854460", "302486639", "0", "1", "2", "3", "4", "5...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
2
codeforces
934ea466a846bb3ce21dc7df2779105b
The Festive Evening
It's the end of July – the time when a festive evening is held at Jelly Castle! Guests from all over the kingdom gather here to discuss new trends in the world of confectionery. Yet some of the things discussed here are not supposed to be disclosed to the general public: the information can cause discord in the kingdom...
{"inputs": ["5 1\nAABBB", "5 1\nABABB", "26 1\nABCDEFGHIJKLMNOPQRSTUVWXYZ", "27 1\nABCDEFGHIJKLMNOPQRSTUVWXYZA", "5 2\nABACA", "6 2\nABCABC", "8 3\nABCBCDCA", "73 2\nDEBECECBBADAADEAABEAEEEAEBEAEBCDDBABBAEBACCBEEBBAEADEECACEDEEDABACDCDBBBD", "44 15\nHGJIFCGGCDGIJDHBIBGAEABCIABIGBDEADBBBAGDFDHA", "41 19\nTMEYYIIELFDCMBD...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
115
codeforces
9360f296a2c7948139a477124eb2a1da
Caisa and Pylons
Caisa solved the problem with the sugar and now he is on the way back to home. Caisa is playing a mobile game during his path. There are (*n*<=+<=1) pylons numbered from 0 to *n* in this game. The pylon with number 0 has zero height, the pylon with number *i* (*i*<=&gt;<=0) has height *h**i*. The goal of the game is ...
{"inputs": ["5\n3 4 3 2 4", "3\n4 4 4", "99\n1401 2019 1748 3785 3236 3177 3443 3772 2138 1049 353 908 310 2388 1322 88 2160 2783 435 2248 1471 706 2468 2319 3156 3506 2794 1999 1983 2519 2597 3735 537 344 3519 3772 3872 2961 3895 2010 10 247 3269 671 2986 942 758 1146 77 1545 3745 1547 2250 2565 217 1406 2070 3010 340...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
361
codeforces
93611e04f3cfd79e75355cf9c18f8e2d
LRU
While creating high loaded systems one should pay a special attention to caching. This problem will be about one of the most popular caching algorithms called LRU (Least Recently Used). Suppose the cache may store no more than *k* objects. At the beginning of the workflow the cache is empty. When some object is querie...
{"inputs": ["3 1\n0.3 0.2 0.5", "2 1\n0.0 1.0", "3 2\n0.3 0.2 0.5", "3 3\n0.2 0.3 0.5", "1 1\n1.0", "10 1\n0.12 0.14 0.13 0.08 0.15 0.10 0.15 0.04 0.02 0.07", "10 5\n0.02 0.17 0.04 0.07 0.21 0.06 0.09 0.11 0.17 0.06", "10 10\n0.02 0.03 0.12 0.21 0.07 0.15 0.21 0.14 0.01 0.04", "20 10\n0.07 0.03 0.02 0.02 0.09 0.07 0.07...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
codeforces
9361fef31b3894cff7eb733b7f116acf
Quadcopter Competition
Polycarp takes part in a quadcopter competition. According to the rules a flying robot should: - start the race from some point of a field, - go around the flag, - close cycle returning back to the starting point. Polycarp knows the coordinates of the starting point (*x*1,<=*y*1) and the coordinates of the point w...
{"inputs": ["1 5\n5 2", "0 1\n0 0", "-100 -100\n100 100", "-100 -100\n-100 100", "-100 -100\n100 -100", "100 -100\n-100 -100", "100 -100\n-100 100", "100 -100\n100 100", "-100 100\n-100 -100", "-100 100\n100 -100", "-100 100\n100 100", "100 100\n-100 -100", "100 100\n-100 100", "100 100\n100 -100", "45 -43\n45 -44", "7...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
124
codeforces
93962dd461fd0469c9158c0a4409dddc
Vasya and Digital Root
Vasya has recently found out what a digital root of a number is and he decided to share his knowledge with you. Let's assume that *S*(*n*) is the sum of digits of number *n*, for example, *S*(4098)<==<=4<=+<=0<=+<=9<=+<=8<==<=21. Then the digital root of number *n* equals to: 1. *dr*(*n*)<==<=*S*(*n*), if *S*(*n*)<...
{"inputs": ["4 4", "5 1", "1 0", "8 7", "487 0", "1000 5", "22 9", "1 1", "1 9", "13 5", "100 4", "123 6", "1000 1", "2 0", "734 9", "678 8", "955 7", "893 3", "998 2", "960 6"], "outputs": ["5881", "36172", "0", "49722154", "No solution", "8541939554067890866522280268745476436249986028349767396372181155840878549622667...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
120
codeforces
93a967c27d1e68ac71fb2f506e4822a5
Books
When Valera has got some free time, he goes to the library to read some books. Today he's got *t* free minutes to read. That's why Valera took *n* books in the library and for each book he estimated the time he is going to need to read it. Let's number the books by integers from 1 to *n*. Valera needs *a**i* minutes to...
{"inputs": ["4 5\n3 1 2 1", "3 3\n2 2 3", "1 3\n5", "1 10\n4", "2 10\n6 4", "6 10\n2 3 4 2 1 1", "7 13\n6 8 14 9 4 11 10", "10 15\n10 9 1 1 5 10 5 3 7 2", "20 30\n8 1 2 6 9 4 1 9 9 10 4 7 8 9 5 7 1 8 7 4", "30 60\n16 13 22 38 13 35 17 17 20 38 12 19 9 22 20 3 35 34 34 21 35 40 22 3 27 19 12 4 8 19", "100 100\n75 92 18 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
308
codeforces
93aa6c82a42a61f509b47c9cafa68e5b
Ann and Half-Palindrome
Tomorrow Ann takes the hardest exam of programming where she should get an excellent mark. On the last theoretical class the teacher introduced the notion of a half-palindrome. String *t* is a half-palindrome, if for all the odd positions *i* () the following condition is held: *t**i*<==<=*t*|*t*|<=-<=*i*<=+<=1, wh...
{"inputs": ["abbabaab\n7", "aaaaa\n10", "bbaabb\n13", "a\n1", "b\n1", "ababbbbbbbaaaaaaaabbbbbb\n23", "aa\n3", "aa\n1", "aa\n2", "ab\n1", "ab\n2", "aaa\n1", "aaa\n2", "aaa\n3", "aaa\n4", "aaa\n5", "aaa\n6", "abb\n1", "abb\n2", "abb\n3", "abb\n4", "aba\n4", "aba\n3", "aba\n2", "aba\n1"], "outputs": ["abaa", "aaa", "bbaa...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
codeforces
93e73b0ba3ef401390253ad421d7995a
Progress Bar
A progress bar is an element of graphical interface that displays the progress of a process for this very moment before it is completed. Let's take a look at the following form of such a bar. A bar is represented as *n* squares, located in line. To add clarity, let's number them with positive integers from 1 to *n* fr...
{"inputs": ["10 10 54", "11 13 37", "9 25 50", "43 47 77", "20 1 43", "17 4 61", "10 16 0", "17 13 100", "11 9 1", "9 11 99", "6 17 1", "6 17 99", "17 6 1", "17 6 99", "99 1 1", "99 1 99", "1 1 0", "1 1 37", "1 1 50", "1 1 51", "1 1 99", "1 1 100", "1 17 35", "1 31 88", "1 100 0", "1 100 38", "1 100 99", "1 100 100", "...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
5
codeforces
93ed3cd729c322a66d7fe44bf787cab4
No to Palindromes!
Paul hates palindromes. He assumes that string *s* is tolerable if each its character is one of the first *p* letters of the English alphabet and *s* doesn't contain any palindrome contiguous substring of length 2 or more. Paul has found a tolerable string *s* of length *n*. Help him find the lexicographically next to...
{"inputs": ["3 3\ncba", "3 4\ncba", "4 4\nabcd", "2 2\nab", "2 2\nba", "1 2\na", "1 2\nb", "1 1\na", "3 4\ncdb", "7 26\nzyxzyxz", "10 5\nabcabcabca", "10 10\nfajegfaicb", "1 26\no", "1 2\nb", "1 26\nz", "3 3\ncab", "3 26\nyzx", "5 5\naceba", "10 3\ncbacbacbac", "11 3\nabcabcabcab", "12 10\nabcabcabcabc", "13 7\ngfegfeg...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
20
codeforces
93f371930641819822b183ffc5533b6f
Population Size
Polycarpus develops an interesting theory about the interrelation of arithmetic progressions with just everything in the world. His current idea is that the population of the capital of Berland changes over time like an arithmetic progression. Well, or like multiple arithmetic progressions. Polycarpus believes that if...
{"inputs": ["9\n8 6 4 2 1 4 7 10 2", "9\n-1 6 -1 2 -1 4 7 -1 2", "5\n-1 -1 -1 -1 -1", "7\n-1 -1 4 5 1 2 3", "1\n1", "1\n65", "1\n1000000000", "1\n-1", "2\n1000000000 1000000000", "2\n1000000000 -1", "2\n-1 1000000000", "2\n-1 -1", "3\n999999999 1000000000 -1", "3\n999999999 -1 1000000000", "3\n1000000000 999999999 1000...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
codeforces
9423c1bacb4232559c8da48975cfd38d
none
Little Chris is a huge fan of linear algebra. This time he has been given a homework about the unusual square of a square matrix. The dot product of two integer number vectors *x* and *y* of size *n* is the sum of the products of the corresponding components of the vectors. The unusual square of an *n*<=×<=*n* square ...
{"inputs": ["3\n1 1 1\n0 1 1\n1 0 0\n12\n3\n2 3\n3\n2 2\n2 2\n1 3\n3\n3\n1 2\n2 1\n1 1\n3", "1\n1\n9\n1 1\n3\n1 1\n1 1\n3\n1 1\n3\n1 1\n3", "3\n1 0 1\n0 1 1\n1 0 1\n4\n3\n3\n3\n3", "1\n0\n5\n1 1\n3\n1 1\n1 1\n3", "2\n0 0\n0 0\n9\n3\n1 2\n2 2\n1 1\n2 1\n3\n1 2\n1 1\n3", "2\n0 1\n1 0\n7\n3\n3\n2 2\n3\n2 2\n2 1\n3", "5\n1...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
2
codeforces
942dda7f65cceb57b7d6d092f3bb32d3
Castle Defense
Today you are going to lead a group of elven archers to defend the castle that is attacked by an army of angry orcs. Three sides of the castle are protected by impassable mountains and the remaining side is occupied by a long wall that is split into *n* sections. At this moment there are exactly *a**i* archers located ...
{"inputs": ["5 0 6\n5 4 3 4 9", "4 2 0\n1 2 3 4", "5 1 1\n2 1 2 1 2", "1 0 0\n0", "1 0 1000000000000000000\n1000000000", "1 1 10\n23", "2 0 100\n98 2", "3 1 1000\n0 0 0", "100 0 0\n607 169 477 518 368 54 15 471 604 138 982 836 563 886 466 118 366 670 257 37 868 142 14 666 670 624 427 281 995 133 914 413 356 852 63 894 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
codeforces
942ec18dc47325413b71a977730c10fe
Very Interesting Game
In a very ancient country the following game was popular. Two people play the game. Initially first player writes a string *s*1, consisting of exactly nine digits and representing a number that does not exceed *a*. After that second player looks at *s*1 and writes a string *s*2, consisting of exactly nine digits and re...
{"inputs": ["1 10 7", "4 0 9", "10 7 8", "6 4 10", "4 1 4", "4 7 9", "13 4 51", "0 0 1", "1 0 1", "2 1 3", "0 2 2", "2 3 1", "3 0 3", "1 1 2", "3 2 1", "0 3 3", "4 0 13", "1 2 13", "4 3 12", "1 2 11", "4 3 12", "815 216 182", "218 550 593", "116482865 344094604 3271060", "19749161 751031022 646204", "70499104 10483793 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
2
codeforces
945fb097d72ffaca116be20ac37527ef
President's Office
President of Berland has a very vast office-room, where, apart from him, work his subordinates. Each subordinate, as well as President himself, has his own desk of a unique colour. Each desk is rectangular, and its sides are parallel to the office walls. One day President decided to establish an assembly, of which all ...
{"inputs": ["3 4 R\nG.B.\n.RR.\nTTT.", "3 3 Z\n...\n.H.\n..Z", "1 1 C\nC", "2 2 W\nKW\nKW", "1 10 H\n....DDHHHH", "3 2 W\nOO\nWW\nWW", "3 3 U\nUOO\nUVV\nUVV", "4 5 Z\n...ZZ\nUU.ZZ\nUUTT.\n..TT.", "4 4 X\nT..R\nTJJJ\nDJJJ\nXJJJ", "5 5 O\nCQGAV\nIHTUD\nRFPZO\nMYSKX\nJEWBN", "5 4 O\n.O.J\nWOBJ\nWOBJ\nDDBJ\nDD.J", "7 7 Q\n...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
148
codeforces
947a2b4f73b2035009e5a5f2fe0b5929
Counting Rhombi
You have two positive integers *w* and *h*. Your task is to count the number of rhombi which have the following properties: - Have positive area. - With vertices at integer points. - All vertices of the rhombi are located inside or on the border of the rectangle with vertices at points (0,<=0), (*w*,<=0), (*w*,<=*...
{"inputs": ["2 2", "1 2", "1 4000", "4000 1", "4000 4000", "15 10", "7 9", "17 17", "7 13", "9 14", "3 10", "14 2", "4 6", "18 2858", "14 1274", "25 2986", "13 1402", "2955 21", "1665 27", "3671 19", "2541 25", "1913 3980", "3727 2044", "2437 460", "1499 2172", "1 1"], "outputs": ["1", "0", "0", "0", "16000000000000", ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
7
codeforces