problem_id
stringlengths
32
32
name
stringlengths
2
112
problem
stringlengths
200
14k
test_cases
stringlengths
33
79.2M
difficulty
stringclasses
34 values
language
listlengths
1
1
source
stringclasses
15 values
num_solutions
int64
1
1.12M
starter_code
stringlengths
0
1.47k
subset
stringclasses
4 values
1aae09d59fdc0c4399e58e8469772e31
Equation
You are given an equation: Your task is to find the number of distinct roots of the equation and print all of them in ascending order. The first line contains three integer numbers *A*,<=*B* and *C* (<=-<=105<=≤<=*A*,<=*B*,<=*C*<=≤<=105). Any coefficient may be equal to 0. In case of infinite root count print the onl...
{"inputs": ["1 -5 6", "1 1 1", "1 2 1", "0 0 0", "0 -2 1", "0 -2 0", "0 0 1", "0 0 -100000", "0 10000 -100000", "1 100000 -100000", "0 3431 43123", "100 200 100", "50000 100000 50000", "-1 10 20", "-50000 100000 -50000", "1 -2 1", "1000 -5000 6000", "0 -100000 0", "1 -100000 0", "1223 -23532 1232", "-1 -2 -1", "1 0 0",...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
36
codeforces
1adf051fd4437e5a6984d9c248647615
Drazil and Date
Someday, Drazil wanted to go on date with Varda. Drazil and Varda live on Cartesian plane. Drazil's home is located in point (0,<=0) and Varda's home is located in point (*a*,<=*b*). In each step, he can move in a unit distance in horizontal or vertical direction. In other words, from position (*x*,<=*y*) he can go to ...
{"inputs": ["5 5 11", "10 15 25", "0 5 1", "0 0 2", "999999999 999999999 2000000000", "-606037695 998320124 820674098", "948253616 -83299062 1031552680", "711980199 216568284 928548487", "-453961301 271150176 725111473", "0 0 2000000000", "0 0 1999999999", "1000000000 1000000000 2000000000", "-1000000000 1000000000 200...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
146
codeforces
1b086a205dcde6ba4c9ab03dfd1792b0
Two strings
You are given two strings *a* and *b*. You have to remove the minimum possible number of consecutive (standing one after another) characters from string *b* in such a way that it becomes a subsequence of string *a*. It can happen that you will not need to remove any characters at all, or maybe you will have to remove a...
{"inputs": ["hi\nbob", "abca\naccepted", "abacaba\nabcdcba", "lo\neuhaqdhhzlnkmqnakgwzuhurqlpmdm", "aaeojkdyuilpdvyewjfrftkpcobhcumwlaoiocbfdtvjkhgda\nmlmarpivirqbxcyhyerjoxlslyfzftrylpjyouypvk", "npnkmawey\nareakefvowledfriyjejqnnaeqheoh", "fdtffutxkujflswyddvhusfcook\nkavkhnhphcvckogqqqqhdmgwjdfenzizrebefsbuhzzwhzvc"...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
8
codeforces
1b36d9af899bb91e38c9a85d7cb7a906
Data Recovery
Not so long ago company R2 bought company R1 and consequently, all its developments in the field of multicore processors. Now the R2 laboratory is testing one of the R1 processors. The testing goes in *n* steps, at each step the processor gets some instructions, and then its temperature is measured. The head engineer ...
{"inputs": ["2 1 1 2\n1", "3 1 1 3\n2", "2 1 1 3\n2", "3 1 1 5\n3", "3 2 1 5\n1 5", "3 2 1 5\n1 1", "3 2 1 5\n5 5", "3 2 1 5\n1 6", "3 2 5 10\n1 10", "6 5 3 6\n4 4 4 4 4", "100 50 68 97\n20 42 93 1 98 6 32 11 48 46 82 96 24 73 40 100 99 10 55 87 65 80 97 54 59 48 30 22 16 92 66 2 22 60 23 81 64 60 34 60 99 99 4 70 91 9...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
38
codeforces
1b5ef8cfd69d5dc48a7f392e465d3a59
A Colourful Prospect
Firecrackers scare Nian the monster, but they're wayyyyy too noisy! Maybe fireworks make a nice complement. Little Tommy is watching a firework show. As circular shapes spread across the sky, a splendid view unfolds on the night of Lunar New Year's eve. A wonder strikes Tommy. How many regions are formed by the circl...
{"inputs": ["3\n0 0 1\n2 0 1\n4 0 1", "3\n0 0 2\n3 0 2\n6 0 2", "3\n0 0 2\n2 0 2\n1 1 2", "1\n0 0 10", "2\n-10 10 1\n10 -10 1", "2\n-6 6 9\n3 -6 6", "2\n-10 -10 10\n10 10 10", "3\n-4 1 5\n-7 7 10\n-3 -4 8", "3\n-2 8 10\n3 -2 5\n3 1 3", "3\n0 0 2\n0 0 4\n3 0 2", "3\n8 5 7\n7 3 7\n5 2 5", "3\n-6 5 7\n1 -2 7\n7 9 7", "3\n...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
codeforces
1b67757cd76a83e0896376acaf8af9eb
Vacations
Vasya has *n* days of vacations! So he decided to improve his IT skills and do sport. Vasya knows the following information about each of this *n* days: whether that gym opened and whether a contest was carried out in the Internet on that day. For the *i*-th day there are four options: 1. on this day the gym is close...
{"inputs": ["4\n1 3 2 0", "7\n1 3 3 2 1 2 3", "2\n2 2", "1\n0", "10\n0 0 1 1 0 0 0 0 1 0", "100\n3 2 3 3 3 2 3 1 3 2 2 3 2 3 3 3 3 3 3 1 2 2 3 1 3 3 2 2 2 3 1 0 3 3 3 2 3 3 1 1 3 1 3 3 3 1 3 1 3 0 1 3 2 3 2 1 1 3 2 3 3 3 2 3 1 3 3 3 3 2 2 2 1 3 1 3 3 3 3 1 3 2 3 3 0 3 3 3 3 3 1 0 2 1 3 3 0 2 3 3", "10\n2 3 0 1 3 1 2 2 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
490
codeforces
1ba3cfe4997ee8dcd640bb7f5ff1c2d8
Orange
The first line of the input is a string (between 1 and 50 characters long, inclusive). Each character will be a letter of English alphabet, lowercase or uppercase. The second line of the input is an integer between 0 and 26, inclusive. Output the required string. Sample Input AprilFool 14 Sample Output AprILFooL
{"inputs": ["AprilFool\n14", "abcdefabc\n3", "fgWjSAlPOvcAbCdDEFjz\n7", "sm\n26", "GnlFOqPeZtPiBkvvLhaDvGPgFqBTnLgMT\n12", "sPWSFWWqZBPon\n3", "fQHHXCdeaintxHWcFcaSGWFvqnYMEByMlSNKumiFgnJB\n0", "RtsUOGkraqKyjTktAXloOEmQj\n18", "DuFhhnq\n4", "RvpuYTxsbDiJDOLauRlfatcfwvtnDzKyaewGrZ\n22", "isfvbcBEEPaXUDhbVhwddjEutVQqNdli...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
16
codeforces
1ba91a102a7f37aac8832718ae66b16b
Biridian Forest
You're a mikemon breeder currently in the middle of your journey to become a mikemon master. Your current obstacle is go through the infamous Biridian Forest. The forest The Biridian Forest is a two-dimensional grid consisting of *r* rows and *c* columns. Each cell in Biridian Forest may contain a tree, or may be vac...
{"inputs": ["5 7\n000E0T3\nT0TT0T0\n010T0T0\n2T0T0T0\n0T0S000", "1 4\nSE23", "3 3\n000\nS0E\n000", "5 5\nS9999\nTTTT9\n99999\n9TTTT\n9999E", "1 10\n9T9TSET9T9", "10 1\nS\n9\n9\n9\n9\nE\n9\n9\n9\n9", "4 3\nS01\n234\n567\n89E", "2 2\nE9\nS4", "3 3\n920\n752\nE8S", "5 1\n9\nT\nE\n6\nS", "1 5\n78S6E", "9 8\n38030772\n697T8...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
8
codeforces
1bbc1b8f93c00a8c754ecaa1479f9bbf
Lesha and array splitting
One spring day on his way to university Lesha found an array *A*. Lesha likes to split arrays into several parts. This time Lesha decided to split the array *A* into several, possibly one, new arrays so that the sum of elements in each of the new arrays is not zero. One more condition is that if we place the new arrays...
{"inputs": ["3\n1 2 -3", "8\n9 -12 3 4 -4 -10 7 3", "1\n0", "4\n1 2 3 -5", "6\n0 0 0 0 0 0", "100\n507 -724 -243 -846 697 -569 -786 472 756 -272 731 -534 -664 202 592 -381 161 -668 -895 296 472 -868 599 396 -617 310 -283 -118 829 -218 807 939 -152 -343 -96 692 -570 110 442 159 -446 -631 -881 784 894 -3 -792 654 -273 -7...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
88
codeforces
1bc2b438bd8b82a4aa536af61323166e
Magazine Ad
The main city magazine offers its readers an opportunity to publish their ads. The format of the ad should be like this: There are space-separated non-empty words of lowercase and uppercase Latin letters. There are hyphen characters '-' in some words, their positions set word wrapping points. Word can include more th...
{"inputs": ["4\ngarage for sa-le", "4\nEdu-ca-tion-al Ro-unds are so fun", "1\nj", "10\nb", "1\nQGVsfZevMD", "1\nqUOYCytbKgoGRgaqhjrohVRxKTKjjOUPPnEjiXJWlvpCyqiRzbnpyNqDylWverSTrcgZpEoDKhJCrOOvsuXHzkPtbXeKCKMwUTVk", "100000\nBGRHXGrqgjMxCBCdQTCpQyHNMkraTRxhyZBztkxXNFEKnCNjHWeCWmmrRjiczJAdfQqdQfnuupPqzRhEKnpuTCsVPNVTIMi...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
25
codeforces
1bc3e611b56cd450a7fb71b37744f2d8
Sagheer and Apple Tree
Sagheer is playing a game with his best friend Soliman. He brought a tree with *n* nodes numbered from 1 to *n* and rooted at node 1. The *i*-th node has *a**i* apples. This tree has a special property: the lengths of all paths from the root to any leaf have the same parity (i.e. all paths have even length or all paths...
{"inputs": ["3\n2 2 3\n1 1", "3\n1 2 3\n1 1", "8\n7 2 2 5 4 3 1 1\n1 1 1 4 4 5 6", "6\n7 7 7 7 7 7\n1 1 1 1 1", "6\n3 1 1 1 2 2\n1 1 1 1 1", "6\n1 2 3 4 5 6\n1 2 3 4 5", "7\n15 3 5 1 2 4 8\n1 1 2 2 3 3", "7\n15 3 5 1 2 4 9\n1 1 2 2 3 3", "7\n15 16 32 1 2 4 9\n1 1 2 2 3 3", "6\n49 70 74 18 64 63\n1 2 2 1 5", "9\n15 17 6...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
3
codeforces
1bd2de89b88911f54537f09932bbfcf9
Degenerate Matrix
The determinant of a matrix 2<=×<=2 is defined as follows: A matrix is called degenerate if its determinant is equal to zero. The norm ||*A*|| of a matrix *A* is defined as a maximum of absolute values of its elements. You are given a matrix . Consider any degenerate matrix *B* such that norm ||*A*<=-<=*B*|| is min...
{"inputs": ["1 2\n3 4", "1 0\n0 1", "1000000000 0\n0 1000000000", "8205 9482\n11 -63", "0 0\n0 0", "1000000000 -1000000000\n1000000000 1000000000", "1000000000 1000000000\n1000000000 -1000000000", "-1 -1\n1 0", "5 2\n-15 -6", "2 -5\n-3 2", "-5 -2\n-1 -3", "-5 8\n1 6", "1 3\n3 2", "-42 63\n77 -32", "91 -7\n-21 91", "-67...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
19
codeforces
1be5e5a36186928a169b53c3d91ce365
Nephren Runs a Cinema
Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) There are three t...
{"inputs": ["4 97 2 3", "4 100 0 4", "13 143 6 11", "999 998244353 666 777", "23333 1000000007 0 23333", "100000 100160063 2332 99774", "100000 996991027 54321 67890", "1 1 0 0", "1 1 0 1", "1 233332 0 0", "1 999888663 0 1", "1 2000000000 1 1", "2 14 0 0", "2 39 0 1", "2 1999999999 0 2", "2 15 1 1", "2 2 1 2", "2 3 2 2...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
codeforces
1c3d7c7c251da6bd6d5318dc55816483
On Segment's Own Points
Our old friend Alexey has finally entered the University of City N — the Berland capital. Alexey expected his father to get him a place to live in but his father said it was high time for Alexey to practice some financial independence. So, Alexey is living in a dorm. The dorm has exactly one straight dryer — a 100 ce...
{"inputs": ["3\n0 5\n2 8\n1 6", "3\n0 10\n1 5\n7 15", "1\n0 100", "2\n1 9\n1 9", "2\n1 9\n5 10", "2\n1 9\n3 5", "2\n3 5\n1 9", "10\n43 80\n39 75\n26 71\n4 17\n11 57\n31 42\n1 62\n9 19\n27 76\n34 53", "50\n33 35\n98 99\n1 2\n4 6\n17 18\n63 66\n29 30\n35 37\n44 45\n73 75\n4 5\n39 40\n92 93\n96 97\n23 27\n49 50\n2 3\n60 6...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
80
codeforces
1c41a03010f966e896c90f173d265027
PLEASE
As we all know Barney's job is "PLEASE" and he has not much to do at work. That's why he started playing "cups and key". In this game there are three identical cups arranged in a line from left to right. Initially key to Barney's heart is under the middle cup. Then at one turn Barney swaps the cup in the middle with a...
{"inputs": ["1\n2", "3\n1 1 1", "1\n983155795040951739", "2\n467131402341701583 956277077729692725", "10\n217673221404542171 806579927281665969 500754531396239406 214319484250163112 328494187336342674 427465830578952934 951554014286436941 664022909283791499 653206814724654845 66704816231807388", "8\n137264686188377169 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
7
codeforces
1c9df2f477b8d47d31cf463f5a731156
Joty and Chocolate
Little Joty has got a task to do. She has a line of *n* tiles indexed from 1 to *n*. She has to paint them in a strange pattern. An unpainted tile should be painted Red if it's index is divisible by *a* and an unpainted tile should be painted Blue if it's index is divisible by *b*. So the tile with the number divisibl...
{"inputs": ["5 2 3 12 15", "20 2 3 3 5", "1 1 1 1 1", "1 2 2 2 2", "2 1 3 3 3", "3 1 1 3 3", "4 1 5 4 3", "8 8 1 1 1", "15 14 32 65 28", "894 197 325 232 902", "8581 6058 3019 2151 4140", "41764 97259 54586 18013 75415", "333625 453145 800800 907251 446081", "4394826 2233224 609367 3364334 898489", "13350712 76770926 6...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
107
codeforces
1cc716b77421e3d6b18974cbc830152f
Hard problem
Vasiliy is fond of solving different tasks. Today he found one he wasn't able to solve himself, so he asks you to help. Vasiliy is given *n* strings consisting of lowercase English letters. He wants them to be sorted in lexicographical order (as in the dictionary), but he is not allowed to swap any of them. The only o...
{"inputs": ["2\n1 2\nba\nac", "3\n1 3 1\naa\nba\nac", "2\n5 5\nbbb\naaa", "2\n3 3\naaa\naa", "4\n0 0 8 6\nbi\nqp\nbt\nya", "5\n8 0 4 8 2\nac\ncl\ngg\ngm\nfs", "10\n7 7 0 0 0 1 6 6 7 3\ndv\ngb\nvg\nxg\nkt\nml\nqm\nnq\nrt\nxn", "3\n999999999 999999999 999999999\nxosbqqnmxq\nsdbvjhvytx\naydpuidgvy", "3\n228 1488 228\nkek\...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
10
codeforces
1cc7f991569d0b44661ef185c3842674
Party Lemonade
A New Year party is not a New Year party without lemonade! As usual, you are expecting a lot of guests, and buying lemonade has already become a pleasant necessity. Your favorite store sells lemonade in bottles of *n* different volumes at different costs. A single bottle of type *i* has volume 2*i*<=-<=1 liters and co...
{"inputs": ["4 12\n20 30 70 90", "4 3\n10000 1000 100 10", "4 3\n10 100 1000 10000", "5 787787787\n123456789 234567890 345678901 456789012 987654321", "30 792520535\n528145579 682850171 79476920 178914057 180053263 538638086 433143781 299775597 723428544 177615223 959893339 639448861 506106572 807471834 42398440 347390...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
46
codeforces
1cdc43323dd7fe34277766feb4665594
Gargari and Bishops
Gargari is jealous that his friend Caisa won the game from the previous problem. He wants to prove that he is a genius. He has a *n*<=×<=*n* chessboard. Each cell of the chessboard has a number written on it. Gargari wants to place two bishops on the chessboard in such a way that there is no cell that is attacked by b...
{"inputs": ["4\n1 1 1 1\n2 1 1 0\n1 1 1 0\n1 0 0 1", "10\n48 43 75 80 32 30 65 31 18 91\n99 5 12 43 26 90 54 91 4 88\n8 87 68 95 73 37 53 46 53 90\n50 1 85 24 32 16 5 48 98 74\n38 49 78 2 91 3 43 96 93 46\n35 100 84 2 94 56 90 98 54 43\n88 3 95 72 78 78 87 82 25 37\n8 15 85 85 68 27 40 10 22 84\n7 8 36 90 10 81 98 51 7...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
10
codeforces
1ce225768b73b495b489addb4d0fd10a
Okabe and Boxes
Okabe and Super Hacker Daru are stacking and removing boxes. There are *n* boxes numbered from 1 to *n*. Initially there are no boxes on the stack. Okabe, being a control freak, gives Daru 2*n* commands: *n* of which are to add a box to the top of the stack, and *n* of which are to remove a box from the top of the sta...
{"inputs": ["3\nadd 1\nremove\nadd 2\nadd 3\nremove\nremove", "7\nadd 3\nadd 2\nadd 1\nremove\nadd 4\nremove\nremove\nremove\nadd 6\nadd 7\nadd 5\nremove\nremove\nremove", "4\nadd 1\nadd 3\nremove\nadd 4\nadd 2\nremove\nremove\nremove", "2\nadd 1\nremove\nadd 2\nremove", "1\nadd 1\nremove", "15\nadd 12\nadd 7\nadd 10\n...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
33
codeforces
1cec334a5ccee5eb45955d9a63427621
Graph Coloring
You are given an undirected graph that consists of *n* vertices and *m* edges. Initially, each edge is colored either red or blue. Each turn a player picks a single vertex and switches the color of all edges incident to it. That is, all red edges with an endpoint in this vertex change the color to blue, while all blue ...
{"inputs": ["3 3\n1 2 B\n3 1 R\n3 2 B", "6 5\n1 3 R\n2 3 R\n3 4 B\n4 5 R\n4 6 R", "4 5\n1 2 R\n1 3 R\n2 3 B\n3 4 B\n1 4 B", "6 6\n1 2 R\n1 3 R\n2 3 R\n4 5 B\n4 6 B\n5 6 B", "3 3\n1 2 R\n1 3 R\n2 3 R", "11 7\n1 2 B\n1 3 R\n3 2 R\n4 5 R\n6 7 R\n8 9 R\n10 11 R", "2 1\n1 2 B"], "outputs": ["1\n2 ", "2\n3 4 ", "-1", "-1", "...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
codeforces
1cf5b764b7c020a63fed240ea3c9ed09
Pasha and Phone
Pasha has recently bought a new phone jPager and started adding his friends' phone numbers there. Each phone number consists of exactly *n* digits. Also Pasha has a number *k* and two sequences of length *n*<=/<=*k* (*n* is divisible by *k*) *a*1,<=*a*2,<=...,<=*a**n*<=/<=*k* and *b*1,<=*b*2,<=...,<=*b**n*<=/<=*k*. Le...
{"inputs": ["6 2\n38 56 49\n7 3 4", "8 2\n1 22 3 44\n5 4 3 2", "2 1\n9 9\n9 9", "2 1\n9 9\n0 9", "4 1\n4 3 2 1\n1 2 3 4", "18 9\n2 3\n0 4", "4 4\n1122\n2", "10 5\n8378 11089\n7 5", "10 5\n52057 11807\n0 1", "10 1\n3 1 1 4 8 7 5 6 4 1\n0 0 0 5 5 6 8 8 4 0", "100 4\n388 2056 122 1525 2912 1465 3066 257 5708 3604 3039 618...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
30
codeforces
1cfd8e00daefe70b7d76fc42938a21b8
New Password
Innokentiy decides to change the password in the social net "Contact!", but he is too lazy to invent a new password by himself. That is why he needs your help. Innokentiy decides that new password should satisfy the following conditions: - the length of the password must be equal to *n*, - the password should cons...
{"inputs": ["4 3", "6 6", "5 2", "3 2", "10 2", "26 13", "100 2", "100 10", "3 3", "6 3", "10 3", "50 3", "90 2", "6 2", "99 3", "4 2", "100 3", "40 22", "13 8", "16 15", "17 17", "19 4", "100 26", "100 25", "26 26", "27 26", "2 2", "26 25", "99 2", "99 26", "4 4", "5 3", "5 4", "5 5", "24 22", "26 14", "26 15", "30 12...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
611
codeforces
1d1a1e0764f53ad7c036de5671142880
Sad powers
You're given *Q* queries of the form (*L*,<=*R*). For each query you have to find the number of such *x* that *L*<=≤<=*x*<=≤<=*R* and there exist integer numbers *a*<=&gt;<=0, *p*<=&gt;<=1 such that *x*<==<=*a**p*. The first line contains the number of queries *Q* (1<=≤<=*Q*<=≤<=105). The next *Q* lines contains two...
{"inputs": ["6\n1 4\n9 9\n5 7\n12 29\n137 591\n1 1000000", "20\n862 928\n758 964\n541 789\n622 943\n328 900\n14 764\n217 972\n461 847\n442 468\n900 986\n518 529\n938 993\n549 851\n690 944\n484 601\n320 910\n98 868\n816 915\n765 880\n551 770"], "outputs": ["2\n1\n0\n3\n17\n1111", "1\n4\n5\n6\n14\n32\n20\n9\n0\n2\n1\n1\n...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
2
codeforces
1d43ed69859cb281bfafbf1d2a06eb3f
Promocodes with Mistakes
During a New Year special offer the "Sudislavl Bars" offered *n* promo codes. Each promo code consists of exactly six digits and gives right to one free cocktail at the bar "Mosquito Shelter". Of course, all the promocodes differ. As the "Mosquito Shelter" opens only at 9, and partying in Sudislavl usually begins at a...
{"inputs": ["2\n000000\n999999", "6\n211111\n212111\n222111\n111111\n112111\n121111", "1\n123456", "2\n000000\n099999", "2\n000000\n009999", "2\n000000\n000999", "2\n000000\n000099", "2\n000000\n000009", "1\n000000", "1\n999999", "10\n946965\n781372\n029568\n336430\n456975\n119377\n179098\n925374\n878716\n461563", "10\...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
15
codeforces
1d8453764c751d2f477673148a740919
Points and Segments (easy)
Iahub isn't well prepared on geometry problems, but he heard that this year there will be a lot of geometry problems on the IOI selection camp. Scared, Iahub locked himself in the basement and started thinking of new problems of this kind. One of them is the following. Iahub wants to draw *n* distinct points and *m* s...
{"inputs": ["3 3\n3 7 14\n1 5\n6 10\n11 15", "3 4\n1 2 3\n1 2\n2 3\n5 6\n2 2", "10 10\n3 4 2 6 1 9 0 5 8 7\n5 7\n2 6\n0 1\n5 6\n3 4\n2 5\n2 10\n4 6\n3 6\n3 7", "3 3\n50 51 52\n1 5\n6 10\n11 15", "3 1\n1 2 3\n2 3"], "outputs": ["0 0 0", "1 0 1 ", "0 1 1 1 0 0 1 0 1 0 ", "1 0 1 ", "1 0 1 "]}
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
29
codeforces
1d95be69ba194a67b9185fef152c655f
Army Creation
As you might remember from our previous rounds, Vova really likes computer games. Now he is playing a strategy game known as Rage of Empires. In the game Vova can hire *n* different warriors; *i*th warrior has the type *a**i*. Vova wants to create a balanced army hiring some subset of warriors. An army is called balan...
{"inputs": ["6 2\n1 1 1 2 2 2\n5\n1 6\n4 3\n1 1\n2 6\n2 6", "5 5\n3 4 4 2 1\n5\n5 5\n5 4\n5 4\n3 4\n5 5", "5 5\n2 1 2 4 1\n5\n5 3\n1 1\n5 1\n2 1\n2 3", "10 5\n4 5 7 3 5 6 6 8 10 9\n5\n10 8\n9 8\n7 5\n8 10\n5 8", "20 5\n9 5 4 10 2 1 8 9 7 4 1 5 4 9 8 10 5 8 4 10\n5\n9 13\n17 13\n6 12\n13 11\n8 8", "100 5\n45 51 23 10 62...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
codeforces
1dad4aab8c75f71ea2952a36002504ad
Predict Outcome of the Game
There are *n* games in a football tournament. Three teams are participating in it. Currently *k* games had already been played. You are an avid football fan, but recently you missed the whole *k* games. Fortunately, you remember a guess of your friend for these *k* games. Your friend did not tell exact number of wins...
{"inputs": ["5\n3 0 0 0\n3 3 0 0\n6 4 1 0\n6 3 3 0\n3 3 3 2"], "outputs": ["yes\nyes\nyes\nno\nno"]}
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
codeforces
1df64825d70c19acab8be693fb95a789
Bear and Three Musketeers
Do you know a story about the three musketeers? Anyway, you will learn about its origins now. Richelimakieu is a cardinal in the city of Bearis. He is tired of dealing with crime by himself. He needs three brave warriors to help him to fight against bad guys. There are *n* warriors. Richelimakieu wants to choose thre...
{"inputs": ["5 6\n1 2\n1 3\n2 3\n2 4\n3 4\n4 5", "7 4\n2 1\n3 6\n5 1\n1 7", "5 0", "7 14\n3 6\n2 3\n5 2\n5 6\n7 5\n7 4\n6 2\n3 5\n7 1\n4 1\n6 1\n7 6\n6 4\n5 4", "15 15\n4 15\n12 1\n15 6\n11 6\n15 7\n6 8\n15 10\n6 12\n12 8\n15 8\n15 3\n11 9\n7 3\n6 4\n12 11", "12 66\n9 12\n1 4\n8 4\n5 3\n10 5\n12 2\n3 2\n2 7\n1 7\n3 7\n...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
101
codeforces
1e05c048abf89b10b87662857fb3d340
Porcelain
During her tantrums the princess usually smashes some collectable porcelain. Every furious shriek is accompanied with one item smashed. The collection of porcelain is arranged neatly on *n* shelves. Within each shelf the items are placed in one row, so that one can access only the outermost items — the leftmost or the...
{"inputs": ["2 3\n3 3 7 2\n3 4 1 5", "1 3\n4 4 3 1 2", "1 4\n6 5 1 10 1 1 5", "3 2\n1 10\n1 2\n1 5", "1 68\n100 26 58 15 8 69 66 49 97 18 74 27 39 19 76 37 25 4 88 75 17 79 41 21 44 39 7 42 63 82 92 87 41 85 25 30 43 80 95 70 98 88 16 15 97 74 81 76 33 19 64 3 14 72 17 36 33 21 34 59 38 75 48 1 57 20 81 56 74 67 14 89 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
codeforces
1e20de0e4e64dcaf65977de7275cd6b7
Array
Vitaly has an array of *n* distinct integers. Vitaly wants to divide this array into three non-empty sets so as the following conditions hold: 1. The product of all numbers in the first set is less than zero (<=&lt;<=0). 1. The product of all numbers in the second set is greater than zero (<=&gt;<=0). 1. The produ...
{"inputs": ["3\n-1 2 0", "4\n-1 -2 -3 0", "5\n-1 -2 1 2 0", "100\n-64 -51 -75 -98 74 -26 -1 -8 -99 -76 -53 -80 -43 -22 -100 -62 -34 -5 -65 -81 -18 -91 -92 -16 -23 -95 -9 -19 -44 -46 -79 52 -35 4 -87 -7 -90 -20 -71 -61 -67 -50 -66 -68 -49 -27 -32 -57 -85 -59 -30 -36 -3 -77 86 -25 -94 -56 60 -24 -37 -72 -41 -31 11 -48 28...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
248
codeforces
1e526c78e232fa1191bd872a5767a30a
Maximum Control (easy)
The Resistance is trying to take control over all planets in a particular solar system. This solar system is shaped like a tree. More precisely, some planets are connected by bidirectional hyperspace tunnels in such a way that there is a path between every pair of the planets, but removing any tunnel would disconnect s...
{"inputs": ["5\n4 1\n4 2\n1 3\n1 5", "4\n1 2\n4 3\n1 4", "10\n4 3\n2 6\n10 1\n5 7\n5 8\n10 6\n5 9\n9 3\n2 9"], "outputs": ["3", "2", "4"]}
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
104
codeforces
1e55fccee6224084c321804a4e02e995
Forecast
The Department of economic development of IT City created a model of city development till year 2100. To prepare report about growth perspectives it is required to get growth estimates from the model. To get the growth estimates it is required to solve a quadratic equation. Since the Department of economic developmen...
{"inputs": ["1 30 200", "1 1 -1", "-1 1 1", "1000 1 -1", "-1 1000 1", "1000 1000 -999", "633 304 -186", "-181 -227 368", "-779 -814 321", "1 1 0", "1 0 -9"], "outputs": ["-10.000000000000000\n-20.000000000000000", "0.618033988749895\n-1.618033988749895", "1.618033988749895\n-0.618033988749895", "0.031126729201737\n-0.0...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
10
codeforces
1e5d848978933dde5b192f0f60219f6d
Credit Card
Recenlty Luba got a credit card and started to use it. Let's consider *n* consecutive days Luba uses the card. She starts with 0 money on her account. In the evening of *i*-th day a transaction *a**i* occurs. If *a**i*<=&gt;<=0, then *a**i* bourles are deposited to Luba's account. If *a**i*<=&lt;<=0, then *a**i* bour...
{"inputs": ["5 10\n-1 5 0 -5 3", "3 4\n-10 0 20", "5 10\n-5 0 10 -11 0", "5 13756\n-2 -9 -10 0 10", "20 23036\n-1 1 -1 -1 -1 -1 1 -1 -1 0 0 1 1 0 0 1 0 0 -1 -1", "12 82016\n1 -2 -1 -1 -2 -1 0 -2 -1 1 -2 2", "7 8555\n-2 -3 -2 3 0 -2 0", "16 76798\n-1 11 -7 -4 0 -11 -12 3 0 -7 6 -4 8 6 5 -10", "20 23079\n0 1 1 -1 1 0 -1 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
4
codeforces
1e69e3da1ef219365379e87e1145a53c
Crosses
There is a board with a grid consisting of *n* rows and *m* columns, the rows are numbered from 1 from top to bottom and the columns are numbered from 1 from left to right. In this grid we will denote the cell that lies on row number *i* and column number *j* as (*i*,<=*j*). A group of six numbers (*a*,<=*b*,<=*c*,<=*...
{"inputs": ["2 2 1", "3 4 5", "2 2 3", "5 1 3", "9 7 55", "5 10 25", "20 12 101", "21 10 155", "49 7 105", "74 99 5057", "9 10 5", "10 14 47", "6 14 23", "27 9 57", "20 17 319", "2 20 37", "10 4 33", "30 8 53", "48 76 2921", "2 78 117", "2 55 9", "56 54 2639", "72 65 2843", "32 71 297", "48 81 2573", "1 1 1", "100 100 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
codeforces
1e6b1ebdeec5065319d5165cebc63f4d
Robbers' watch
Robbers, who attacked the Gerda's cab, are very successful in covering from the kingdom police. To make the goal of catching them even harder, they use their own watches. First, as they know that kingdom police is bad at math, robbers use the positional numeral system with base 7. Second, they divide one day in *n* ho...
{"inputs": ["2 3", "8 2", "1 1", "1 2", "8 8", "50 50", "344 344", "282475250 282475250", "8 282475250", "1000000000 1000000000", "16808 7", "2402 50", "343 2401", "1582 301", "421414245 4768815", "2401 343", "2 1", "282475250 8", "8 7", "50 7", "16808 8", "2402 49", "123 123", "123 456", "1 9", "1 10", "50 67", "7 117...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
14
codeforces
1e74392cb55352ace00ff81a62ba0aa3
Calculating Function
For a positive integer *n* let's define a function *f*: *f*(*n*)<==<=<=-<=1<=+<=2<=-<=3<=+<=..<=+<=(<=-<=1)*n**n* Your task is to calculate *f*(*n*) for a given integer *n*. The single line contains the positive integer *n* (1<=≤<=*n*<=≤<=1015). Print *f*(*n*) in a single line. Sample Input 4 5 Sample Output 2 -3
{"inputs": ["4", "5", "1000000000", "1000000001", "1000000000000000", "100", "101", "102", "103", "104", "105", "106", "107", "108", "109", "208170109961052", "46017661651072", "4018154546667", "288565475053", "3052460231", "29906716", "87897701693326", "8240", "577935", "62", "1", "2", "9999999999999", "1000000000000"...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
371
codeforces
1ebe3a50c08a441116f53867534813de
A Serial Killer
Our beloved detective, Sherlock is currently trying to catch a serial killer who kills a person each day. Using his powers of deduction, he came to know that the killer has a strategy for selecting his next victim. The killer starts with two potential victims on his first day, selects one of these two, kills selected ...
{"inputs": ["ross rachel\n4\nross joey\nrachel phoebe\nphoebe monica\nmonica chandler", "icm codeforces\n1\ncodeforces technex", "a b\n3\na c\nb d\nd e", "ze udggmyop\n4\nze szhrbmft\nudggmyop mjorab\nszhrbmft ojdtfnzxj\nojdtfnzxj yjlkg", "q s\n10\nq b\nb j\ns g\nj f\nf m\ng c\nc a\nm d\nd z\nz o", "iii iiiiii\n7\niii ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
264
codeforces
1ebfd6c2cb572ab66eb2884fa508a34f
k-Interesting Pairs Of Integers
Vasya has the sequence consisting of *n* integers. Vasya consider the pair of integers *x* and *y* k-interesting, if their binary representation differs from each other exactly in *k* bits. For example, if *k*<==<=2, the pair of integers *x*<==<=5 and *y*<==<=3 is k-interesting, because their binary representation *x*=...
{"inputs": ["4 1\n0 3 2 1", "6 0\n200 100 100 100 200 200", "2 0\n1 1", "2 0\n0 0", "2 0\n10000 10000", "2 0\n0 10000", "2 1\n0 1", "2 1\n0 2", "3 1\n0 1 2", "3 2\n0 3 3", "3 2\n3 3 3", "10 0\n1 1 1 1 1 1 1 1 1 1", "100 14\n8192 8192 8192 8192 8191 8192 8192 8192 8192 8192 8191 8191 8191 8192 8191 8191 8191 8192 8192 8...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
3
codeforces
1ec7fb216711d8f95bde17bc32969245
Clear Symmetry
Consider some square matrix *A* with side *n* consisting of zeros and ones. There are *n* rows numbered from 1 to *n* from top to bottom and *n* columns numbered from 1 to *n* from left to right in this matrix. We'll denote the element of the matrix which is located at the intersection of the *i*-row and the *j*-th col...
{"inputs": ["4", "9", "10", "12", "1", "19", "3", "2", "5", "6", "7", "8", "11", "13", "14", "15", "16", "17", "18", "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
20
codeforces
1ed6ca77cf602d8ebffe43cfd3e5166b
Party
To celebrate the second ABBYY Cup tournament, the Smart Beaver decided to throw a party. The Beaver has a lot of acquaintances, some of them are friends with each other, and some of them dislike each other. To make party successful, the Smart Beaver wants to invite only those of his friends who are connected by friends...
{"inputs": ["9\n8\n1 2\n1 3\n2 3\n4 5\n6 7\n7 8\n8 9\n9 6\n2\n1 6\n7 9", "2\n1\n1 2\n0", "2\n0\n1\n1 2", "3\n2\n1 2\n1 3\n1\n2 3", "3\n3\n1 3\n2 1\n2 3\n0", "4\n3\n1 2\n2 3\n3 1\n3\n1 4\n4 2\n3 4", "7\n8\n1 2\n1 3\n1 4\n1 5\n2 4\n2 5\n3 4\n5 6\n3\n2 6\n5 7\n6 7", "14\n20\n1 2\n4 5\n4 6\n4 11\n5 7\n5 8\n5 13\n5 14\n7 8\...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
13
codeforces
1f1dcedf1144203ac39ca0e477b614f3
Pasha Maximizes
Pasha has a positive integer *a* without leading zeroes. Today he decided that the number is too small and he should make it larger. Unfortunately, the only operation Pasha can do is to swap two adjacent decimal digits of the integer. Help Pasha count the maximum number he can get if he has the time to make at most *k...
{"inputs": ["1990 1", "300 0", "1034 2", "9090000078001234 6", "1234 3", "5 100", "1234 5", "1234 6", "9022 2", "66838 4", "39940894417248510 10", "5314 4", "1026 9", "4529 8", "83811284 3", "92153348 6", "5846059 3", "521325125110071928 4", "39940894417248510 10", "77172428736634377 29", "337775999910796051 37", "1169...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
90
codeforces
1f4cbe261ba5bc12af16f0c6bfe7bd72
Load Testing
Polycarp plans to conduct a load testing of its new project Fakebook. He already agreed with his friends that at certain points in time they will send requests to Fakebook. The load testing will last *n* minutes and in the *i*-th minute friends will send *a**i* requests. Polycarp plans to test Fakebook under a special...
{"inputs": ["5\n1 4 3 2 5", "5\n1 2 2 2 1", "7\n10 20 40 50 70 90 30", "1\n1", "2\n1 15", "4\n36 54 55 9", "5\n984181411 215198610 969039668 60631313 85746445", "10\n12528139 986722043 1595702 997595062 997565216 997677838 999394520 999593240 772077 998195916", "100\n9997 9615 4045 2846 7656 2941 2233 9214 837 2369 583...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
8
codeforces
1f4e69ed4131031462be5f829f047a10
Sonya and Exhibition
Sonya decided to organize an exhibition of flowers. Since the girl likes only roses and lilies, she decided that only these two kinds of flowers should be in this exhibition. There are $n$ flowers in a row in the exhibition. Sonya can put either a rose or a lily in the $i$-th position. Thus each of $n$ positions shoul...
{"inputs": ["5 3\n1 3\n2 4\n2 5", "6 3\n5 6\n1 4\n4 6", "10 4\n3 3\n1 6\n9 9\n10 10", "1 1\n1 1", "1000 10\n3 998\n2 1000\n1 999\n2 1000\n3 998\n2 1000\n3 998\n1 1000\n2 1000\n3 999", "1000 20\n50 109\n317 370\n710 770\n440 488\n711 757\n236 278\n314 355\n131 190\n115 162\n784 834\n16 56\n677 730\n802 844\n632 689\n23 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
202
codeforces
1f5631011a2485df36b8c0ae1a556024
Peculiar apple-tree
In Arcady's garden there grows a peculiar apple-tree that fruits one time per year. Its peculiarity can be explained in following way: there are *n* inflorescences, numbered from 1 to *n*. Inflorescence number 1 is situated near base of tree and any other inflorescence with number *i* (*i*<=&gt;<=1) is situated at the ...
{"inputs": ["3\n1 1", "5\n1 2 2 2", "18\n1 1 1 4 4 3 2 2 2 10 8 9 9 9 10 10 4", "2\n1", "3\n1 2", "20\n1 1 1 1 1 4 1 2 4 1 2 1 7 1 2 2 9 7 1", "20\n1 2 1 2 2 1 2 4 1 6 2 2 4 3 2 6 2 5 9", "20\n1 1 1 4 2 4 3 1 2 8 3 2 11 13 15 1 12 13 12", "20\n1 2 2 4 3 5 5 6 6 9 11 9 9 12 13 10 15 13 15", "20\n1 2 3 4 5 6 7 8 9 6 11 1...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
60
codeforces
1fa51f9955817acd74ac1d152389d2d2
Correct Bracket Sequence Editor
Recently Polycarp started to develop a text editor that works only with correct bracket sequences (abbreviated as CBS). Note that a bracket sequence is correct if it is possible to get a correct mathematical expression by adding "+"-s and "1"-s to it. For example, sequences "(())()", "()" and "(()(()))" are correct, ...
{"inputs": ["8 4 5\n(())()()\nRDLD", "12 5 3\n((()())(()))\nRRDLD", "8 8 8\n(())()()\nLLLLLLDD", "4 2 2\n()()\nLD", "6 4 1\n()()()\nDRRD", "8 2 4\n(())()()\nRR", "10 7 3\n(()())()()\nRDLRDRD", "12 10 11\n(())()()()()\nDLRDLRDDLR", "14 8 13\n((())())((()))\nDLRLLRLR", "16 2 10\n(((())())())()()\nLD", "18 8 11\n((()))(()...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
3
codeforces
1fb3786e6d9b85eeaa60c2c28a859b75
Sail
The polar bears are going fishing. They plan to sail from (*s**x*,<=*s**y*) to (*e**x*,<=*e**y*). However, the boat can only sail by wind. At each second, the wind blows in one of these directions: east, south, west or north. Assume the boat is currently at (*x*,<=*y*). - If the wind blows to the east, the boat will ...
{"inputs": ["5 0 0 1 1\nSESNW", "10 5 3 3 6\nNENSWESNEE", "19 -172106364 -468680119 -172106365 -468680119\nSSEEESSSESESWSEESSS", "39 -1000000000 -1000000000 -999999997 -1000000000\nENEENWSWSSWESNSSEESNSESWSWNSWESNENWNWEE", "41 -264908123 -86993764 -264908123 -86993723\nNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "34 -1...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
225
codeforces
1fc7fba6d45b4304f5f03ecf43c6b69a
Yet Another Problem On a Subsequence
The sequence of integers $a_1, a_2, \dots, a_k$ is called a good array if $a_1 = k - 1$ and $a_1 &gt; 0$. For example, the sequences $[3, -1, 44, 0], [1, -99]$ are good arrays, and the sequences $[3, 7, 8], [2, 5, 4, 1], [0]$ — are not. A sequence of integers is called good if it can be divided into a positive number ...
{"inputs": ["3\n2 1 1", "4\n1 1 1 1", "1\n0", "1\n1"], "outputs": ["2", "7", "0", "0"]}
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
2
codeforces
1ffbf62bfc508f4f29980f6d780c61fa
Anton and Danik
Anton likes to play chess, and so does his friend Danik. Once they have played *n* games in a row. For each game it's known who was the winner — Anton or Danik. None of the games ended with a tie. Now Anton wonders, who won more games, he or Danik? Help him determine this. The first line of the input contains a singl...
{"inputs": ["6\nADAAAA", "7\nDDDAADA", "6\nDADADA", "10\nDDDDADDADD", "40\nAAAAAAAAADDAAAAAAAAAAADADDAAAAAAAAAAADAA", "200\nDDDDDDDADDDDDDAADADAADAAADAADADAAADDDADDDDDDADDDAADDDAADADDDDDADDDAAAADAAADDDDDAAADAADDDAAAADDADADDDAADDAADAAADAADAAAADDAADDADAAAADADDDAAAAAADDAADAADAADADDDAAADAAAADADDADAAAAAADADADDDADDDAADDADDDA...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
731
codeforces
203a84df1d79d9a67272cb7eb7e52e97
Sale
Once Bob got to a sale of old TV sets. There were *n* TV sets at that sale. TV set with index *i* costs *a**i* bellars. Some TV sets have a negative price — their owners are ready to pay Bob if he buys their useless apparatus. Bob can «buy» any TV sets he wants. Though he's very strong, Bob can carry at most *m* TV set...
{"inputs": ["5 3\n-6 0 35 -2 4", "4 2\n7 0 0 -7", "6 6\n756 -611 251 -66 572 -818", "5 5\n976 437 937 788 518", "5 3\n-2 -2 -2 -2 -2", "5 1\n998 997 985 937 998", "2 2\n-742 -187", "3 3\n522 597 384", "4 2\n-215 -620 192 647", "10 6\n557 605 685 231 910 633 130 838 -564 -85", "20 14\n932 442 960 943 624 624 955 998 631...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
841
codeforces
205ab1b2596b19d0ff35371ea3cf18a1
Mashmokh and Lights
Mashmokh works in a factory. At the end of each day he must turn off all of the lights. The lights on the factory are indexed from 1 to *n*. There are *n* buttons in Mashmokh's room indexed from 1 to *n* as well. If Mashmokh pushes button with index *i*, then each light with index not less than *i* that is still turn...
{"inputs": ["5 4\n4 3 1 2", "5 5\n5 4 3 2 1", "16 11\n8 5 12 10 14 2 6 3 15 9 1", "79 22\n76 32 48 28 33 44 58 59 1 51 77 13 15 64 49 72 74 21 61 12 60 57", "25 19\n3 12 21 11 19 6 5 15 4 16 20 8 9 1 22 23 25 18 13", "48 8\n42 27 40 1 18 3 19 2", "44 19\n13 20 7 10 9 14 43 17 18 39 21 42 37 1 33 8 35 4 6", "80 29\n79 5...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
214
codeforces
2069be9dcf332b37be07c41ab9a6cbe3
Prime Number
Simon has a prime number *x* and an array of non-negative integers *a*1,<=*a*2,<=...,<=*a**n*. Simon loves fractions very much. Today he wrote out number on a piece of paper. After Simon led all fractions to a common denominator and summed them up, he got a fraction: , where number *t* equals *x**a*1<=+<=*a*2<=+<=......
{"inputs": ["2 2\n2 2", "3 3\n1 2 3", "2 2\n29 29", "4 5\n0 0 0 0", "1 2\n1000000000", "26 2\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 2", "26 7\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 2", "3 2\n0 1 1", "1 127\n1000000000", "1 800000011\n800000011", "1 800000011\n999999999", "3 3\n1 1 1"], "outputs"...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
13
codeforces
207eede200d9ba24f994330c2b8cfabe
Pearls in a Row
There are *n* pearls in a row. Let's enumerate them with integers from 1 to *n* from the left to the right. The pearl number *i* has the type *a**i*. Let's call a sequence of consecutive pearls a segment. Let's call a segment good if it contains two pearls of the same type. Split the row of the pearls to the maximal ...
{"inputs": ["5\n1 2 3 4 1", "5\n1 2 3 4 5", "7\n1 2 1 3 1 2 1", "9\n1 2 1 2 1 2 1 2 1", "11\n1 1 2 1 2 1 2 1 2 1 1", "1\n576560149", "10\n460626451 460626451 460626451 460626451 460626451 460626451 460626451 460626451 460626451 460626451", "10\n933677171 80672280 80672280 933677171 933677171 933677171 933677171 8067228...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
39
codeforces
208e0d102a4aff006ad18836092a1fd9
Jeff and Digits
Jeff's got *n* cards, each card contains either digit 0, or digit 5. Jeff can choose several cards and put them in a line so that he gets some number. What is the largest possible number divisible by 90 Jeff can make from the cards he's got? Jeff must make the number without leading zero. At that, we assume that numbe...
{"inputs": ["4\n5 0 5 0", "11\n5 5 5 5 5 5 5 5 0 5 5", "7\n5 5 5 5 5 5 5", "1\n5", "1\n0", "11\n5 0 5 5 5 0 0 5 5 5 5", "23\n5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 0 0 0 0 0", "9\n5 5 5 5 5 5 5 5 5", "24\n5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 0 0 0 0 0", "10\n0 0 0 0 0 0 0 0 0 0", "10\n5 5 5 5 5 0 0 5 0 5", "3\n5 5 0", "5...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
159
codeforces
2098cd490c69f659d881f9271b7531fc
String Game
Little Nastya has a hobby, she likes to remove some letters from word, to obtain another word. But it turns out to be pretty hard for her, because she is too young. Therefore, her brother Sergey always helps her. Sergey gives Nastya the word *t* and wants to get the word *p* out of it. Nastya removes letters in a cert...
{"inputs": ["ababcba\nabb\n5 3 4 1 7 6 2", "bbbabb\nbb\n1 6 3 4 2 5", "cacaccccccacccc\ncacc\n10 9 14 5 1 7 15 3 6 12 4 8 11 13 2", "aaaabaaabaabaaaaaaaa\naaaa\n18 5 4 6 13 9 1 3 7 8 16 10 12 19 17 15 14 11 20 2", "aaaaaaaadbaaabbbbbddaaabdadbbbbbdbbabbbabaabdbbdababbbddddbdaabbddbbbbabbbbbabadaadabaaaadbbabbbaddb\naaa...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
82
codeforces
20bba2c3e5ff8b9338dc245960535aab
Vanya and Triangles
Vanya got bored and he painted *n* distinct points on the plane. After that he connected all the points pairwise and saw that as a result many triangles were formed with vertices in the painted points. He asks you to count the number of the formed triangles with the non-zero area. The first line contains integer *n* (1...
{"inputs": ["4\n0 0\n1 1\n2 0\n2 2", "3\n0 0\n1 1\n2 0", "1\n1 1", "5\n0 0\n1 1\n2 2\n3 3\n4 4", "5\n0 0\n1 1\n2 3\n3 6\n4 10", "4\n-100 -100\n-100 100\n100 -100\n100 100", "5\n-100 -100\n-100 100\n100 -100\n100 100\n0 0", "4\n1 -100\n2 -100\n100 -99\n99 -99", "25\n26 -54\n16 56\n-42 -51\n92 -58\n100 52\n57 -98\n-84 -2...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
11
codeforces
20bfb8b140bbbbc6164f4c0a84a2dc05
Sonya and Problem Wihtout a Legend
Sonya was unable to think of a story for this problem, so here comes the formal description. You are given the array containing *n* positive integers. At one turn you can pick any element and increase or decrease it by 1. The goal is the make the array strictly increasing by making the minimum possible number of opera...
{"inputs": ["7\n2 1 5 11 5 9 11", "5\n5 4 3 2 1", "2\n1 1000", "2\n1000 1", "5\n100 80 60 70 90", "10\n10 16 17 11 1213 1216 1216 1209 3061 3062", "20\n103 103 110 105 107 119 113 121 116 132 128 124 128 125 138 137 140 136 154 158", "1\n1", "5\n1 1 1 2 3", "1\n1000", "50\n499 780 837 984 481 526 944 482 862 136 265 60...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
14
codeforces
20c1e9422796af441c387c631d2715ab
Code Parsing
Little Vitaly loves different algorithms. Today he has invented a new algorithm just for you. Vitaly's algorithm works with string *s*, consisting of characters "x" and "y", and uses two following operations at runtime: 1. Find two consecutive characters in the string, such that the first of them equals "y", and the ...
{"inputs": ["x", "yxyxy", "xxxxxy", "yxyyxyyx", "yxxyxyx", "xxx", "xxyxx", "xxxyx", "yxxxx", "xyyxyyyyyxxxxxxxyxyxyyxyyxyyxxyxyxyxxxyxxy", "xyyxyyyyyxxxxxxxyxyxyyxyyxyyxxyxyxyxxxyxxy", "xxxxxxxxxxxyxyyxxxxyxxxxxyxxxxxyxxxxxxxxyx", "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", "yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
54
codeforces
20c573c0f46f02b35925d1e59ce6fc1e
Voting
There are *n* employees in Alternative Cake Manufacturing (ACM). They are now voting on some very important question and the leading world media are trying to predict the outcome of the vote. Each of the employees belongs to one of two fractions: depublicans or remocrats, and these two fractions have opposite opinions...
{"inputs": ["5\nDDRRR", "6\nDDRRRR", "1\nD", "1\nR", "2\nDR", "3\nRDD", "3\nDRD", "4\nDRRD", "4\nDRRR", "4\nRDRD", "5\nDRDRR", "4\nRRRR", "5\nRDDRD", "5\nDDRRD", "5\nDRRRD", "5\nDDDDD", "6\nDRRDDR", "7\nRDRDRDD", "7\nRDRDDRD", "7\nRRRDDDD", "8\nRRRDDDDD", "9\nRRRDDDDDR", "9\nRRDDDRRDD", "9\nRRDDDRDRD", "10\nDDRRRDRRDD"...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
11
codeforces
20ca84dc7382a495acdf33245bff71ca
Bear and Fair Set
Limak is a grizzly bear. He is big and dreadful. You were chilling in the forest when you suddenly met him. It's very unfortunate for you. He will eat all your cookies unless you can demonstrate your mathematical skills. To test you, Limak is going to give you a puzzle to solve. It's a well-known fact that Limak, as e...
{"inputs": ["10 20 1\n10 10", "10 20 3\n15 10\n5 0\n10 5", "10 20 2\n15 3\n20 10", "15 27 2\n6 4\n23 5", "50 7654 4\n1273 11\n6327 38\n1244 3\n5208 22", "50 7654 4\n2899 15\n3848 26\n2718 12\n5511 36", "50 7654 4\n4881 20\n4957 6\n4764 50\n944 44", "50 6457 1\n945 41", "500 5000 5\n1289 221\n694 178\n2179 454\n160 11\n...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
3
codeforces
20e1b109cf2c373246172c975ecfd79e
Polo the Penguin and Matrix
Little penguin Polo has an *n*<=×<=*m* matrix, consisting of integers. Let's index the matrix rows from 1 to *n* from top to bottom and let's index the columns from 1 to *m* from left to right. Let's represent the matrix element on the intersection of row *i* and column *j* as *a**ij*. In one move the penguin can add ...
{"inputs": ["2 2 2\n2 4\n6 8", "1 2 7\n6 7", "3 2 1\n5 7\n1 2\n5 100", "3 3 3\n5 8 5\n11 11 17\n14 5 2", "3 3 3\n5 8 5\n11 11 17\n14 5 3", "2 2 4\n5 5\n5 5", "7 4 5\n7 7 7 12\n7 12 12 7\n7 7 7 7\n7 7 12 7\n7 7 12 12\n12 12 7 12\n7 7 7 7", "7 7 47\n91 91 91 91 91 91 91\n91 91 91 91 91 91 91\n91 91 91 91 91 91 91\n91 91 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
200
codeforces
20f1c94c1e992cb8f01b83ea4ed216fb
none
Bob recently read about bitwise operations used in computers: AND, OR and XOR. He have studied their properties and invented a new game. Initially, Bob chooses integer *m*, bit depth of the game, which means that all numbers in the game will consist of *m* bits. Then he asks Peter to choose some *m*-bit number. After ...
{"inputs": ["3 3\na := 101\nb := 011\nc := ? XOR b", "5 1\na := 1\nbb := 0\ncx := ? OR a\nd := ? XOR ?\ne := d AND bb", "2 10\nb := 0100101101\na := ? XOR b", "1 10\na := 0110110011", "1 6\na := ? OR ?", "13 6\na := 111010\nb := 100100\nc := 001110\nd := b AND b\ne := c AND ?\nf := e OR c\ng := 011110\nh := d XOR ?\ni ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
6
codeforces
20fd49f9c64735d6bfb5a2ded627b23d
Shifts
You are given a table consisting of *n* rows and *m* columns. Each cell of the table contains a number, 0 or 1. In one move we can choose some row of the table and cyclically shift its values either one cell to the left, or one cell to the right. To cyclically shift a table row one cell to the right means to move the ...
{"inputs": ["3 6\n101010\n000100\n100000", "2 3\n111\n000", "1 1\n1", "1 1\n0", "3 1\n1\n1\n0", "6 2\n10\n11\n01\n01\n10\n11", "3 3\n001\n010\n100", "4 4\n0001\n0100\n0010\n1000", "5 5\n10000\n01000\n00100\n00010\n00001", "5 5\n10001\n00100\n01000\n01001\n11111", "5 5\n11111\n11111\n11111\n11111\n00000", "5 10\n0001000...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
9
codeforces
20fee0d2046c45179bcd2f922d225aae
Queue
There are *n* walruses standing in a queue in an airport. They are numbered starting from the queue's tail: the 1-st walrus stands at the end of the queue and the *n*-th walrus stands at the beginning of the queue. The *i*-th walrus has the age equal to *a**i*. The *i*-th walrus becomes displeased if there's a younger...
{"inputs": ["6\n10 8 5 3 50 45", "7\n10 4 6 3 2 8 15", "5\n10 3 1 10 11", "13\n18 9 8 9 23 20 18 18 33 25 31 37 36", "10\n15 21 17 22 27 21 31 26 32 30", "10\n18 20 18 17 17 13 22 20 34 29", "13\n16 14 12 9 11 28 30 21 35 30 32 31 43", "15\n18 6 18 21 14 20 13 9 18 20 28 13 19 25 21", "11\n15 17 18 18 26 22 23 33 33 21...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
51
codeforces
20ffe02488c708a6ac25d6687efe45a2
Snacktower
According to an old legeng, a long time ago Ankh-Morpork residents did something wrong to miss Fortune, and she cursed them. She said that at some time *n* snacks of distinct sizes will fall on the city, and the residents should build a Snacktower of them by placing snacks one on another. Of course, big snacks should b...
{"inputs": ["3\n3 1 2", "5\n4 5 1 2 3", "1\n1", "2\n1 2", "10\n5 1 6 2 8 3 4 10 9 7", "30\n16 10 4 29 5 28 12 21 11 30 18 6 14 3 17 22 20 15 9 1 27 19 24 26 13 25 2 23 8 7", "100\n98 52 63 2 18 96 31 58 84 40 41 45 66 100 46 71 26 48 81 20 73 91 68 76 13 93 17 29 64 95 79 21 55 75 19 85 54 51 89 78 15 87 43 59 36 1 90 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
283
codeforces
2107d7677a31fc3b2e3f2f48f90ea65d
Coach
A programming coach has *n* students to teach. We know that *n* is divisible by 3. Let's assume that all students are numbered from 1 to *n*, inclusive. Before the university programming championship the coach wants to split all students into groups of three. For some pairs of students we know that they want to be on ...
{"inputs": ["3 0", "6 4\n1 2\n2 3\n3 4\n5 6", "3 3\n1 2\n2 3\n1 3", "6 3\n1 2\n3 4\n5 6", "15 9\n1 4\n1 6\n2 7\n2 11\n4 6\n5 12\n7 11\n9 14\n13 15", "3 1\n1 3", "15 13\n1 9\n1 11\n2 7\n2 12\n3 8\n3 15\n4 10\n5 6\n5 14\n6 14\n7 12\n8 15\n9 11", "36 27\n1 34\n2 18\n2 20\n3 9\n3 21\n4 5\n4 25\n5 25\n6 13\n6 22\n8 23\n8 31...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
17
codeforces
210b0dcb71762d4b15aa74549a099ce5
Compote
Nikolay has *a* lemons, *b* apples and *c* pears. He decided to cook a compote. According to the recipe the fruits should be in the ratio 1:<=2:<=4. It means that for each lemon in the compote should be exactly 2 apples and exactly 4 pears. You can't crumble up, break up or cut these fruits into pieces. These fruits — ...
{"inputs": ["2\n5\n7", "4\n7\n13", "2\n3\n2", "1\n1\n1", "1\n2\n4", "1000\n1000\n1000", "1\n1\n4", "1\n2\n3", "1\n1000\n1000", "1000\n1\n1000", "1000\n2\n1000", "1000\n500\n1000", "1000\n1000\n4", "1000\n1000\n3", "4\n8\n12", "10\n20\n40", "100\n200\n399", "200\n400\n800", "199\n400\n800", "201\n400\n800", "200\n399\n8...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
334
codeforces
21597ff5cde4d9dc159f25a26dd6a0ce
Directed Roads
ZS the Coder and Chris the Baboon has explored Udayland for quite some time. They realize that it consists of *n* towns numbered from 1 to *n*. There are *n* directed roads in the Udayland. *i*-th of them goes from town *i* to some other town *a**i* (*a**i*<=≠<=*i*). ZS the Coder can flip the direction of any road in...
{"inputs": ["3\n2 3 1", "4\n2 1 1 1", "5\n2 4 2 5 3", "4\n2 1 4 3", "7\n2 3 4 1 6 5 4", "20\n2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 1", "2\n2 1", "84\n2 50 67 79 71 45 43 40 57 20 25 8 60 47 52 10 37 23 1 28 22 26 3 42 11 63 61 68 49 32 55 18 5 24 31 70 66 27 38 41 54 12 65 51 15 34 30 35 77 74 21 62 33 16 81...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
8
codeforces
216626f8e3129d6463eb791d51eaa0ad
Permutation Cycle
For a permutation *P*[1... *N*] of integers from 1 to *N*, function *f* is defined as follows: Let *g*(*i*) be the minimum positive integer *j* such that *f*(*i*,<=*j*)<==<=*i*. We can show such *j* always exists. For given *N*,<=*A*,<=*B*, find a permutation *P* of integers from 1 to *N* such that for 1<=≤<=*i*<=≤<=...
{"inputs": ["9 2 5", "3 2 1", "7 4 4", "1000000 999998 3", "1 1 1", "993012 997 1001", "1000000 2017 881", "390612 20831 55790", "689292 69319 96267", "99929 99929 2", "807990 72713 11616", "514004 50866 26101", "631610 7702 63553", "391861 47354 60383", "822954 53638 55936", "794948 794948 85946", "786009 37429 59524"...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
21
codeforces
21675d66e7006d324b0336d4ffb917d7
Almost Permutation
Recently Ivan noticed an array *a* while debugging his code. Now Ivan can't remember this array, but the bug he was trying to fix didn't go away, so Ivan thinks that the data from this array might help him to reproduce the bug. Ivan clearly remembers that there were *n* elements in the array, and each element was not ...
{"inputs": ["3 0", "3 1\n1 1 3 2", "3 2\n1 1 3 2\n2 1 3 2", "3 2\n1 1 3 2\n2 1 3 1", "50 0", "50 1\n2 31 38 25", "50 2\n2 38 41 49\n1 19 25 24", "50 10\n2 4 24 29\n1 14 49 9\n2 21 29 12\n2 2 46 11\n2 4 11 38\n2 3 36 8\n1 24 47 28\n2 23 40 32\n1 16 50 38\n1 31 49 38", "50 20\n1 14 22 40\n1 23 41 3\n1 32 39 26\n1 8 47 25...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
4
codeforces
216b7c32d3e33f332f60bc12ab2da822
Logo Turtle
A lot of people associate Logo programming language with turtle graphics. In this case the turtle moves along the straight line and accepts commands "T" ("turn around") and "F" ("move 1 unit forward"). You are given a list of commands that will be given to the turtle. You have to change exactly *n* commands from the l...
{"inputs": ["FT\n1", "FFFTFFF\n2", "F\n1", "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF\n50", "FTFTFTFFFFTFTFTTTTTTFFTTTTFFTFFFTFTFTFFTFTFTFFFTTTFTTFTTTTTFFFFTTT\n12", "TTFFTFTTFTTTFFFTFTFFTFFTTFFTFTFTFTFFTTTFTFFTFFTTTTFTTTFFT\n46", "TTFFFFFFFTTTTFTTFTFFTTFFFTFTT...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
7
codeforces
217e38012c7854256183c07a6bdc62c5
Petya's Exams
Petya studies at university. The current academic year finishes with $n$ special days. Petya needs to pass $m$ exams in those special days. The special days in this problem are numbered from $1$ to $n$. There are three values about each exam: - $s_i$ — the day, when questions for the $i$-th exam will be published, -...
{"inputs": ["5 2\n1 3 1\n1 5 1", "3 2\n1 3 1\n1 2 1", "10 3\n4 7 2\n1 10 3\n8 9 1", "2 1\n1 2 1", "3 1\n1 2 2", "3 1\n1 3 2", "100 1\n1 100 99", "100 1\n1 100 100", "100 1\n1 100 98", "100 2\n1 100 49\n1 99 49", "10 2\n3 7 4\n6 10 1", "10 4\n2 5 1\n1 4 2\n4 7 1\n7 10 2", "20 5\n6 16 3\n4 14 4\n3 13 1\n1 11 1\n10 20 4",...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
10
codeforces
2189a2c8e311addc29b933b2d542edfc
Circle of Numbers
*n* evenly spaced points have been marked around the edge of a circle. There is a number written at each point. You choose a positive real number *k*. Then you may repeatedly select a set of 2 or more points which are evenly spaced, and either increase all numbers at points in the set by *k* or decrease all numbers at ...
{"inputs": ["30\n000100000100000110000000001100", "6\n314159", "3\n000", "15\n522085220852208", "300\n51849955123882532841766314023795544655059625429948511546532555041357758442089311502553567597180892645169105593021958599780734407001184543473352601711893354858975964992001656857820176956422821004573923066450696828141422...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
codeforces
218df72e4efbe2b7cc341ffe3d16707e
Rebranding
The name of one small but proud corporation consists of *n* lowercase English letters. The Corporation has decided to try rebranding — an active marketing strategy, that includes a set of measures to change either the brand (both for the company and the goods it produces) or its components: the name, the logo, the slog...
{"inputs": ["6 1\npolice\np m", "11 6\nabacabadaba\na b\nb c\na d\ne g\nf a\nb b", "1 1\nf\nz h", "1 1\na\na b", "10 10\nlellelleel\ne l\ne l\ne l\ne l\ne l\ne e\nl l\nl e\nl l\ne e"], "outputs": ["molice", "cdcbcdcfcdc", "f", "b", "lellelleel"]}
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
119
codeforces
219366dfd3d5a68d977c0efa6cb0721a
DZY Loves Sequences
DZY has a sequence *a*, consisting of *n* integers. We'll call a sequence *a**i*,<=*a**i*<=+<=1,<=...,<=*a**j* (1<=≤<=*i*<=≤<=*j*<=≤<=*n*) a subsegment of the sequence *a*. The value (*j*<=-<=*i*<=+<=1) denotes the length of the subsegment. Your task is to find the longest subsegment of *a*, such that it is possible ...
{"inputs": ["6\n7 2 3 1 5 6", "10\n424238336 649760493 681692778 714636916 719885387 804289384 846930887 957747794 596516650 189641422", "50\n804289384 846930887 681692778 714636916 957747794 424238336 719885387 649760493 596516650 189641422 25202363 350490028 783368691 102520060 44897764 967513927 365180541 540383427 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
59
codeforces
21981a6dd776117fe98a2f0d77c136c9
Average Sleep Time
It's been almost a week since Polycarp couldn't get rid of insomnia. And as you may already know, one week in Berland lasts *k* days! When Polycarp went to a doctor with his problem, the doctor asked him about his sleeping schedule (more specifically, the average amount of hours of sleep per week). Luckily, Polycarp k...
{"inputs": ["3 2\n3 4 7", "1 1\n10", "8 2\n1 2 4 100000 123 456 789 1", "1 1\n1", "1 1\n100000", "3 1\n1 2 3", "10 4\n11 3 5 20 12 7 9 2 2 20", "10 5\n15 9 3 2 17 10 9 18 4 19", "10 6\n19 3 20 16 14 10 1 13 7 3", "10 7\n8 16 2 13 15 9 5 13 9 2", "10 4\n127 1459 718 1183 880 1044 1857 1340 725 1496", "10 5\n1384 1129 17...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
97
codeforces
21b7de902f49277b20a3051ca8ba9528
Rook, Bishop and King
Little Petya is learning to play chess. He has already learned how to move a king, a rook and a bishop. Let us remind you the rules of moving chess pieces. A chessboard is 64 square fields organized into an 8<=×<=8 table. A field is represented by a pair of integers (*r*,<=*c*) — the number of the row and the number of...
{"inputs": ["4 3 1 6", "5 5 5 6", "1 1 8 8", "1 1 8 1", "1 1 1 8", "8 1 1 1", "8 1 1 8", "7 7 6 6", "8 1 8 8", "1 8 1 1", "1 8 8 1", "1 8 8 8", "8 8 1 1", "8 8 1 8", "8 8 8 1", "1 3 1 6", "1 3 1 4", "1 3 1 5", "3 3 2 4", "3 3 1 5", "1 6 2 1", "1 5 6 4", "1 3 3 7", "1 1 8 1", "1 7 5 4", "1 5 2 7", "1 4 6 2", "1 2 3 5", ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
217
codeforces
21c7afb1480e78ad47c23361b6dbbc61
Valera and Plates
Valera is a lazy student. He has *m* clean bowls and *k* clean plates. Valera has made an eating plan for the next *n* days. As Valera is lazy, he will eat exactly one dish per day. At that, in order to eat a dish, he needs exactly one clean plate or bowl. We know that Valera can cook only two types of dishes. He can...
{"inputs": ["3 1 1\n1 2 1", "4 3 1\n1 1 1 1", "3 1 2\n2 2 2", "8 2 2\n1 2 1 2 1 2 1 2", "2 100 100\n2 2", "1 1 1\n2", "233 100 1\n2 2 1 1 1 2 2 2 2 1 1 2 2 2 1 2 2 1 1 1 2 2 1 1 1 1 2 1 2 2 1 1 2 2 1 2 2 1 2 1 2 1 2 2 2 1 1 1 1 2 1 2 1 1 2 1 1 2 2 1 2 1 2 1 1 1 1 1 1 1 1 1 2 1 2 2 2 1 1 2 2 1 1 1 1 2 1 1 2 1 2 2 2 1 1 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
223
codeforces
21c80b84de37c0a6a459ebd411c862bc
Maxim and Discounts
Maxim always goes to the supermarket on Sundays. Today the supermarket has a special offer of discount systems. There are *m* types of discounts. We assume that the discounts are indexed from 1 to *m*. To use the discount number *i*, the customer takes a special basket, where he puts exactly *q**i* items he buys. Unde...
{"inputs": ["1\n2\n4\n50 50 100 100", "2\n2 3\n5\n50 50 50 50 50", "1\n1\n7\n1 1 1 1 1 1 1", "60\n7 4 20 15 17 6 2 2 3 18 13 14 16 11 13 12 6 10 14 1 16 6 4 9 10 8 10 15 16 13 13 9 16 11 5 4 11 1 20 5 11 20 19 9 14 13 10 6 6 9 2 13 11 4 1 6 8 18 10 3\n26\n2481 6519 9153 741 9008 6601 6117 1689 5911 2031 2538 5553 1358 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
35
codeforces
21d3086ee327553584f533280fdd7ad2
Broken checker
"This problem is rubbish! There is not statement, and there are only 5 test cases. The problemsetter took liberties with this problem!" — people complained in the comments to one round on Codeforces. And even more... No, wait, the checker for the problem was alright, that's a mercy. The only line of the input contains ...
{"inputs": ["3", "1", "4", "2", "5"], "outputs": ["1", "2", "2", "3", "1"]}
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
39
codeforces
21daae042f23778474d174e49a3103bf
DravDe saves the world
How horrible! The empire of galactic chickens tries to conquer a beautiful city "Z", they have built a huge incubator that produces millions of chicken soldiers a day, and fenced it around. The huge incubator looks like a polygon on the plane *Oxy* with *n* vertices. Naturally, DravDe can't keep still, he wants to dest...
{"inputs": ["4\n0 0\n1 0\n1 1\n0 1\n0 -1\n1 0 1\n-1\n0 1 -1", "4\n0 0\n0 1\n1 1\n1 0\n0 -1\n-1 -1 1\n-1\n0 1 -1", "4\n0 0\n1 0\n1 1\n0 1\n0 -1\n1 1 1\n-1\n1 1 -1", "3\n-3 4\n5 -1\n-1 0\n-4 3\n4 4 5\n-3\n0 -3 -4", "4\n-2 1\n3 3\n2 -4\n0 -5\n-4 3\n2 4 4\n-4\n2 5 -4", "5\n10 10\n9 10\n8 9\n9 8\n10 9\n-10 -10\n1 1 1\n-1\n0...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
codeforces
21e1ee2d6df8c4908bb9a6d812841345
Word Folding
You will receive 5 points for solving this problem. Manao has invented a new operation on strings that is called folding. Each fold happens between a pair of consecutive letters and places the second part of the string above first part, running in the opposite direction and aligned to the position of the fold. Using t...
{"inputs": ["ABRACADABRA", "ABBBCBDB", "AB", "ABBCDEFB", "THISISATEST", "Z", "ZZ", "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "ABACBCABACACB", "LEHLLLLLLHAFGEGLLHAFDLHHLLLLLDGGEHGGHLLLLLLLLDFLCBLLEFLLCBLLCGLEDLGGLECLDGLEHLLLGELLLEGLLLLGDLLLDALD", "THISISTHELASTTEST"], "outputs": ["3", "3", "1", "3", "3", "1", "2", "1", "4", "49", "...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
2
codeforces
21fc26573a8d903daa076191d191a0f5
Unbearable Controversy of Being
Tomash keeps wandering off and getting lost while he is walking along the streets of Berland. It's no surprise! In his home town, for any pair of intersections there is exactly one way to walk from one intersection to the other one. The capital of Berland is very different! Tomash has noticed that even simple cases of...
{"inputs": ["5 4\n1 2\n2 3\n1 4\n4 3", "4 12\n1 2\n1 3\n1 4\n2 1\n2 3\n2 4\n3 1\n3 2\n3 4\n4 1\n4 2\n4 3", "1 0", "10 20\n6 10\n4 2\n1 5\n6 1\n8 9\n1 3\n2 6\n9 7\n4 5\n3 7\n9 2\n3 9\n4 8\n1 10\n6 9\n8 5\n7 6\n1 8\n8 10\n5 6", "3000 0", "1 0", "2 0", "2 1\n1 2", "2 2\n1 2\n2 1", "3 0", "3 6\n1 2\n1 3\n2 1\n2 3\n3 1\n3 2...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
2
codeforces
22091ef7481b60323c746ca6fbc97fc7
Vitya in the Countryside
Every summer Vitya comes to visit his grandmother in the countryside. This summer, he got a huge wart. Every grandma knows that one should treat warts when the moon goes down. Thus, Vitya has to catch the moment when the moon is down. Moon cycle lasts 30 days. The size of the visible part of the moon (in Vitya's units...
{"inputs": ["5\n3 4 5 6 7", "7\n12 13 14 15 14 13 12", "1\n8", "44\n7 8 9 10 11 12 13 14 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 14 13 12 11 10", "92\n3 4 5 6 7 8 9 10 11 12 13 14 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
123
codeforces
22198e3a7c0abd019255159882cb5048
Eevee
You are solving the crossword problem K from IPSC 2014. You solved all the clues except for one: who does Eevee evolve into? You are not very into pokemons, but quick googling helped you find out, that Eevee can evolve into eight different pokemons: Vaporeon, Jolteon, Flareon, Espeon, Umbreon, Leafeon, Glaceon, and Syl...
{"inputs": ["7\n...feon", "7\n.l.r.o.", "6\n.s..o.", "7\nglaceon", "8\n.a.o.e.n", "7\n.laceon", "7\n..lveon", "7\n.l.ceon", "7\n..areon"], "outputs": ["leafeon", "flareon", "espeon", "glaceon", "vaporeon", "glaceon", "sylveon", "glaceon", "flareon"]}
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
172
codeforces
2233068987c95f8e6f31d0648e88a1bb
Gena's Code
It's the year 4527 and the tanks game that we all know and love still exists. There also exists Great Gena's code, written in 2016. The problem this code solves is: given the number of tanks that go into the battle from each country, find their product. If it is turns to be too large, then the servers might have not en...
{"inputs": ["3\n5 10 1", "4\n1 1 10 11", "5\n0 3 1 100 1", "40\n10 100 10 1 10 10 100 10 10 100 10 100 100 10 1824868942 100 100 1 10 100 100 10 100 100 10 100 10 1 10 100 100 100 10 1 10 1 10 10 100 100", "6\n1000000000000000000000000000000000000 6643573784 1000000000000000000000000000000000000 10000000000000000000000...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
81
codeforces
22c337ec8ce9b0fba407e3224879d095
Consecutive Subsequence
You are given an integer array of length $n$. You have to choose some subsequence of this array of maximum length such that this subsequence forms a increasing sequence of consecutive integers. In other words the required sequence should be equal to $[x, x + 1, \dots, x + k - 1]$ for some value $x$ and length $k$. Su...
{"inputs": ["7\n3 3 4 7 5 6 8", "6\n1 3 5 2 4 6", "4\n10 9 8 7", "9\n6 7 8 3 4 5 9 10 11", "1\n1337", "2\n456 123", "7\n100 3 4 7 5 6 8", "7\n3 3 4 5 6 7 8", "12\n1 2 3 4 5 6 7 8 9 10 11 12"], "outputs": ["4\n2 3 5 6 ", "2\n1 4 ", "1\n1 ", "6\n1 2 3 7 8 9 ", "1\n1 ", "1\n1 ", "4\n2 3 5 6 ", "6\n2 3 4 5 6 7 ", "12\n1 2 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
5
codeforces
22e73f576e0a29ac8f1acaad7b95ca42
Kuriyama Mirai's Stones
Kuriyama Mirai has killed many monsters and got many (namely *n*) stones. She numbers the stones from 1 to *n*. The cost of the *i*-th stone is *v**i*. Kuriyama Mirai wants to know something about these stones so she will ask you two kinds of questions: 1. She will tell you two numbers, *l* and *r* (1<=≤<=*l*<=≤<=*r*...
{"inputs": ["6\n6 4 2 7 2 7\n3\n2 3 6\n1 3 4\n1 1 6", "4\n5 5 2 3\n10\n1 2 4\n2 1 4\n1 1 1\n2 1 4\n2 1 2\n1 1 1\n1 3 3\n1 1 3\n1 4 4\n1 2 2", "4\n2 2 3 6\n9\n2 2 3\n1 1 3\n2 2 3\n2 2 3\n2 2 2\n1 1 3\n1 1 3\n2 1 4\n1 1 2", "18\n26 46 56 18 78 88 86 93 13 77 21 84 59 61 5 74 72 52\n25\n1 10 10\n1 9 13\n2 13 17\n1 8 14\n2...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
467
codeforces
23300678e886bea71fe9a35c71bc04e8
R2D2 and Droid Army
An army of *n* droids is lined up in one row. Each droid is described by *m* integers *a*1,<=*a*2,<=...,<=*a**m*, where *a**i* is the number of details of the *i*-th type in this droid's mechanism. R2-D2 wants to destroy the sequence of consecutive droids of maximum length. He has *m* weapons, the *i*-th weapon can aff...
{"inputs": ["5 2 4\n4 0\n1 2\n2 1\n0 2\n1 3", "3 2 4\n1 2\n1 3\n2 2", "1 1 0\n0", "1 1 0\n1", "1 1 1\n0", "4 5 33\n2 10 2 3 2\n10 6 4 5 0\n3 1 7 3 2\n4 4 2 1 5", "4 5 40\n0 10 9 0 4\n10 5 5 7 4\n9 9 5 5 2\n6 7 9 4 3", "31 2 1913\n845 576\n862 325\n914 283\n431 837\n193 171\n30 248\n290 488\n810 552\n463 74\n765 469\n78...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
codeforces
233f32c704219a8929d73e179f9d4a8f
Little Pony and Crystal Mine
Twilight Sparkle once got a crystal from the Crystal Mine. A crystal of size *n* (*n* is odd; *n*<=&gt;<=1) is an *n*<=×<=*n* matrix with a diamond inscribed into it. You are given an odd integer *n*. You need to draw a crystal of size *n*. The diamond cells of the matrix should be represented by character "D". All ot...
{"inputs": ["3", "5", "7", "11", "15", "21", "33", "57", "69", "81", "91", "101"], "outputs": ["*D*\nDDD\n*D*", "**D**\n*DDD*\nDDDDD\n*DDD*\n**D**", "***D***\n**DDD**\n*DDDDD*\nDDDDDDD\n*DDDDD*\n**DDD**\n***D***", "*****D*****\n****DDD****\n***DDDDD***\n**DDDDDDD**\n*DDDDDDDDD*\nDDDDDDDDDDD\n*DDDDDDDDD*\n**DDDDDDD**\n*...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
308
codeforces
23522805b8d87a2adfb4a95b8c4ba94f
Functions On The Segments
You have an array *f* of *n* functions.The function *f**i*(*x*) (1<=≤<=*i*<=≤<=*n*) is characterized by parameters: *x*1,<=*x*2,<=*y*1,<=*a*,<=*b*,<=*y*2 and take values: - *y*1, if *x*<=≤<=*x*1. - *a*·*x*<=+<=*b*, if *x*1<=&lt;<=*x*<=≤<=*x*2. - *y*2, if *x*<=&gt;<=*x*2. There are *m* queries. Each query is deter...
{"inputs": ["1\n1 2 1 4 5 10\n1\n1 1 2", "3\n2 5 1 1 1 4\n3 6 8 2 5 7\n1 3 5 1 4 10\n3\n1 3 3\n2 3 2\n1 2 5", "7\n4 8 562244866 6 8 140807945\n5 7 415374420 7 6 596093578\n3 4 766370993 3 7 973128805\n4 6 841321398 3 2 893107667\n4 9 968214628 5 8 329310838\n0 10 64315145 9 4 716996081\n1 6 568407659 3 0 22184171\n15\n...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
codeforces
23782452cf5313c2d3b5626ea74e0e61
Water Taps
Consider a system of *n* water taps all pouring water into the same container. The *i*-th water tap can be set to deliver any amount of water from 0 to *a**i* ml per second (this amount may be a real number). The water delivered by *i*-th tap has temperature *t**i*. If for every you set *i*-th tap to deliver exactly ...
{"inputs": ["2 100\n3 10\n50 150", "3 9\n5 5 30\n6 6 10", "2 12\n1 3\n10 15", "20 30\n70 97 14 31 83 22 83 56 19 87 59 7 7 89 24 82 34 40 6 24\n10 4 47 46 11 18 32 55 16 32 53 37 43 32 41 46 57 14 60 44", "1 1\n1000000\n1", "1 200\n1000000\n100", "1 1000000\n1000000\n1000000"], "outputs": ["6.000000000000000", "40.0000...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
3
codeforces
237ca36d287733e0a58c9626c31d87aa
Businessmen Problems
Two famous competing companies ChemForces and TopChemist decided to show their sets of recently discovered chemical elements on an exhibition. However they know that no element should be present in the sets of both companies. In order to avoid this representatives of both companies decided to make an agreement on the ...
{"inputs": ["3\n1 2\n7 2\n3 10\n4\n1 4\n2 4\n3 4\n4 4", "1\n1000000000 239\n3\n14 15\n92 65\n35 89", "10\n598654597 488228616\n544064902 21923894\n329635457 980089248\n988262691 654502493\n967529230 543358150\n835120075 128123793\n809901567 613170206\n152157661 479980560\n859252956 318029856\n614959273 735298093\n10\n8...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
212
codeforces
2397732f27101ac11fd5369b72448274
Epidemic in Monstropolis
There was an epidemic in Monstropolis and all monsters became sick. To recover, all monsters lined up in queue for an appointment to the only doctor in the city. Soon, monsters became hungry and began to eat each other. One monster can eat other monster if its weight is strictly greater than the weight of the monste...
{"inputs": ["6\n1 2 2 2 1 2\n2\n5 5", "5\n1 2 3 4 5\n1\n15", "5\n1 1 1 3 3\n3\n2 1 6", "5\n1 1 1 1 2\n3\n1 1 4", "5\n1 1 1 1 1\n4\n1 1 2 1", "6\n2 1 2 2 1 2\n2\n5 5", "8\n2 5 3 1 4 2 3 4\n3\n10 6 8", "1\n959139\n1\n470888", "3\n2 2 1\n1\n5", "3\n1 2 2\n1\n5", "5\n1 2 3 4 5\n1\n10", "5\n325539 329221 106895 882089 71867...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
3
codeforces
239a5762998495b0fe4bf42d3952fd48
Tea Queue
Recently *n* students from city S moved to city P to attend a programming camp. They moved there by train. In the evening, all students in the train decided that they want to drink some tea. Of course, no two people can use the same teapot simultaneously, so the students had to form a queue to get their tea. *i*-th s...
{"inputs": ["2\n2\n1 3\n1 4\n3\n1 5\n1 1\n2 3", "19\n1\n1 1\n1\n1 2\n1\n1 1000\n1\n1 2000\n1\n2 2\n1\n2 3\n1\n2 1000\n1\n2 2000\n1\n1999 1999\n1\n1999 2000\n1\n2000 2000\n2\n1 1\n1 1\n2\n1 1\n1 2\n2\n1 2\n1 1\n2\n1 2000\n1 1\n2\n1 1\n1 2000\n2\n1 2000\n2 2\n2\n2 2000\n2 2\n2\n2 2\n2 2000", "1\n11\n1 1\n1 1\n1 1\n1 1\n1...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
72
codeforces
23c012a6f7008cf0064bf7ecf55b2fd3
Antichain
You have a directed acyclic graph *G*, consisting of *n* vertexes, numbered from 0 to *n*<=-<=1. The graph contains *n* edges numbered from 0 to *n*<=-<=1. An edge with number *i* connects vertexes *i* and (*i*<=+<=1) *mod* *n*, and it can be directed in either direction (from *i* to (*i*<=+<=1) *mod* *n*, or vise vers...
{"inputs": ["001", "110010", "0010011110", "0111001010101110001100000010011000100101110010001100111110101110001110101010111000010010011000000110", "0110101100", "0111110110", "0001011111", "0000011010101001001100101111111011100000011000101001011001000111110000010000100011011011101101100110", "00001000001100101000100101...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
codeforces
23c3c1aedb4a37389c4a191f8443ae42
Interesting drink
Vasiliy likes to rest after a hard work, so you may often meet him in some bar nearby. As all programmers do, he loves the famous drink "Beecola", which can be bought in *n* different shops in the city. It's known that the price of one bottle in the shop *i* is equal to *x**i* coins. Vasiliy plans to buy his favorite ...
{"inputs": ["5\n3 10 8 6 11\n4\n1\n10\n3\n11", "5\n868 987 714 168 123\n10\n424\n192\n795\n873\n117\n914\n735\n158\n631\n471", "3\n435 482 309\n7\n245\n241\n909\n745\n980\n29\n521", "1\n653\n9\n903\n980\n80\n770\n965\n874\n381\n657\n969", "12\n35345 58181 32223 84621 35905 73863 99537 30666 67771 39229 36847 29038\n23\...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
284
codeforces
23ebcca15bd46dead8f1b185628d3dc9
Packmen
A game field is a strip of 1<=×<=*n* square cells. In some cells there are Packmen, in some cells — asterisks, other cells are empty. Packman can move to neighboring cell in 1 time unit. If there is an asterisk in the target cell then Packman eats it. Packman doesn't spend any time to eat an asterisk. In the initial ...
{"inputs": ["7\n*..P*P*", "10\n.**PP.*P.*", "19\n**P.*..*..P..*.*P**", "12\nP**.*P*P*P**", "58\n..P.P*.P*.P...PPP...P*....*..*.**......*P.*P.....**P...*P*", "10\n..P*.P.*.*", "10\n***.*.*..P", "15\nP***..PPP..P*.P", "20\n.P**P**P**PP.PP**PP*", "20\n.....*.**..........P", "25\n...*..**..*.....*..*...P.", "30\n*P.*...*.*...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
7
codeforces
23eee3079293ce0dc454eed8b1e186ab
Let's Play Osu!
You're playing a game called Osu! Here's a simplified version of it. There are *n* clicks in a game. For each click there are two outcomes: correct or bad. Let us denote correct as "O", bad as "X", then the whole play can be encoded as a sequence of *n* characters "O" and "X". Using the play sequence you can calculate...
{"inputs": ["3\n0.5 0.5 0.5", "4\n0.7 0.2 0.1 0.9", "5\n1 1 1 1 1", "10\n0.684846 0.156794 0.153696 0.714526 0.281868 0.628256 0.745339 0.123854 0.748936 0.856333", "10\n0.684488 0.834971 0.834886 0.643646 0.162710 0.119851 0.659401 0.743950 0.220986 0.839665", "10\n0.684416 0.170607 0.491124 0.469470 0.458879 0.658170...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
14
codeforces
23f7e534541a11b5794fceedb3aa1919
Road Map
There are *n* cities in Berland. Each city has its index — an integer number from 1 to *n*. The capital has index *r*1. All the roads in Berland are two-way. The road system is such that there is exactly one path from the capital to each city, i.e. the road map looks like a tree. In Berland's chronicles the road map is...
{"inputs": ["3 2 3\n2 2", "6 2 4\n6 1 2 4 2", "7 7 6\n7 7 5 5 7 7", "4 2 3\n2 1 3", "5 5 4\n5 4 1 5", "6 2 1\n4 1 2 2 2", "2 1 2\n1", "2 2 1\n2", "3 1 3\n1 2", "10 4 3\n5 6 9 10 1 9 6 8 4", "100 62 42\n45 66 13 18 93 47 83 19 41 66 5 70 16 29 54 28 65 91 92 24 90 54 7 40 77 53 68 58 70 65 68 30 94 80 16 18 69 21 94 1 9...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
12
codeforces