messages
listlengths
1
1
ground_truth
stringlengths
88
726k
dataset
stringclasses
1 value
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given two integers $a$ and $b$. Moreover, you are given a sequence $s_0, s_1, \\dots, s_{n}$. All values in $s$ are integers $1$ or $-1$. It's known that sequence is $k$-periodic and $k$ divides $n+1$. In other wo...
[{"type": "stdin_stdout", "input": "904132655 827386249 118827660 334\n+++-+++++--+++----+-+-+-+-+--+-+---++--++--++--+-+-+++-+++--+-+-+----+-+-++++-----+--++++------+++-+-+-++-++++++++-+-++-+++--+--++------+--+-+++--++--+---++-++-+-+-++---++-++--+-+-++-+------+-+----+++-+++--+-+-+--+--+--+------+--+---+--+-++--+++---+...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA one-dimensional Japanese crossword can be represented as a binary string of length x. An encoding of this crossword is an array a of size n, where n is the number of segments formed completely of 1's, and a_{i} is the l...
[{"type": "stdin_stdout", "input": "10 1\n5 78 3 87 4 9 5 8 9 1235\n", "output": "NO\n"}, {"type": "stdin_stdout", "input": "10 1\n5 78 3 87 4 9 5 8 9 1235\n", "output": "NO\n"}, {"type": "stdin_stdout", "input": "10 1\n5 24 3 87 4 9 5 8 9 1235\n", "output": "NO\n"}, {"type": "stdin_stdout", "input": "10 1\n5 24 3 0 4 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given an undirected unweighted graph with N vertices and M edges that contains neither self-loops nor double edges.\n\nHere, a self-loop is an edge where a_i = b_i (1≤i≤M), and double edges are two edges where (a_...
[{"type": "stdin_stdout", "input": "8 28\n1 2\n1 3\n1 4\n1 5\n1 6\n1 7\n1 8\n2 3\n2 4\n2 5\n2 6\n2 7\n2 8\n3 4\n3 5\n3 6\n3 7\n3 8\n4 5\n4 6\n4 7\n4 8\n5 6\n5 7\n5 8\n6 7\n6 8\n7 8\n", "output": "5040\n"}, {"type": "stdin_stdout", "input": "8 27\n1 2\n1 3\n1 4\n1 5\n1 6\n1 7\n1 8\n2 3\n2 4\n2 5\n2 6\n2 7\n3 4\n3 5\n3 6...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nExample\n\nInput\n\nmmemewwemeww\n\n\nOutput\n\nCat\n\nThe input will be stdin and you should print your solution to stdout\n\n\nNow solve the problem and return the code.\n\nWrite Python code to solve this problem. Your ...
[{"type": "stdin_stdout", "input": "mmemwweemeww", "output": "Rabbit\n"}, {"type": "stdin_stdout", "input": "wwemeewwmemm", "output": "Rabbit\n"}, {"type": "stdin_stdout", "input": "mmemwweeneww", "output": "Rabbit\n"}, {"type": "stdin_stdout", "input": "mnemwweeneww", "output": "Rabbit\n"}, {"type": "stdin_stdout", "i...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nDevu has an array A consisting of N positive integers. He would like to perform following operation on array.\n\n- Pick some two elements a, b in the array (a could be same as b, but their corresponding indices in the arr...
[{"type": "stdin_stdout", "input": "2 4\n1 18\n1\n2\n5\n4", "output": "Yes\nYes\nYes\nYes\n"}, {"type": "stdin_stdout", "input": "2 4\n1 3\n1\n2\n3\n4\n", "output": "Yes\nYes\nYes\nNo\n"}, {"type": "stdin_stdout", "input": "2 4\n1 3\n1\n2\n3\n3", "output": "Yes\nYes\nYes\nYes\n"}, {"type": "stdin_stdout", "input": "2 4...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou've come to your favorite store Infinitesco to buy some ice tea.\n\nThe store sells ice tea in bottles of different volumes at different costs. Specifically, a 0.25-liter bottle costs Q yen, a 0.5-liter bottle costs H ...
[{"type": "stdin_stdout", "input": "12345678 87654321 12345678 87654321\n226515686", "output": "2796489721305108\n"}, {"type": "stdin_stdout", "input": "12345678 87654321 12873114 87654321\n226515686", "output": "2915962248666204\n"}, {"type": "stdin_stdout", "input": "12345678 87654321 12345678 87654321\n123456789", "...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe Physical education teacher at SESC is a sort of mathematician too. His most favorite topic in mathematics is progressions. That is why the teacher wants the students lined up in non-decreasing height form an arithmeti...
[{"type": "stdin_stdout", "input": "100\n246 485 -940 -186 -841 -98 711 429 -154 164 -244 -111 886 -447 22 480 224 -132 927 812 -243 -152 -843 403 -320 -346 -407 827 645 -903 -172 540 -359 498 270 18 374 -52 -983 -164 -707 -242 -159 -825 -889 661 -629 212 849 -891 -622 810 957 897 -110 -293 -257 822 690 369 -914 212 -3...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a non-empty string s=s_1s_2... s_n, which consists only of lowercase Latin letters. Polycarp does not like a string if it contains at least one string \"one\" or at least one string \"two\" (or both at the s...
[{"type": "stdin_stdout", "input": "10\nonetwonetwooneooonetwooo\ntwo\none\ntwooooo\nttttwo\nttwwoo\neoono\nonnne\noneeeee\noneeeeeeetwooooo\n", "output": "6\n2 6 10 13 18 21 \n1\n2 \n1\n2 \n1\n2 \n1\n5 \n0\n\n0\n\n0\n\n1\n2 \n2\n2 11 \n"}, {"type": "stdin_stdout", "input": "10\nonetwonetwooneooonetwooo\nuwo\none\ntwoo...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nGiven an integer N, find the base -2 representation of N.\nHere, S is the base -2 representation of N when the following are all satisfied:\n - S is a string consisting of 0 and 1.\n - Unless S = 0, the initial character ...
[{"type": "stdin_stdout", "input": "-1000000000\n", "output": "11000101101001010100101000000000\n"}, {"type": "stdin_stdout", "input": "-790013317\n", "output": "11010001001111101010111110001111\n"}, {"type": "stdin_stdout", "input": "1000000000\n", "output": "1001100111011111101111000000000\n"}, {"type": "stdin_stdout...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLittle Vasya has received a young builder’s kit. The kit consists of several wooden bars, the lengths of all of them are known. The bars can be put one on the top of the other if their lengths are the same.\n\nVasya wants...
[{"type": "stdin_stdout", "input": "123\n112 277 170 247 252 115 157 293 256 143 196 90 12 164 164 42 8 223 167 109 175 232 239 111 148 51 9 254 93 32 268 162 231 91 47 162 161 191 195 145 247 292 129 199 230 94 144 217 18 205 176 20 143 198 121 243 211 262 230 277 195 255 108 290 220 275 158 2 286 200 60 267 278 207 1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nTreeland is a country in which there are n towns connected by n - 1 two-way road such that it's possible to get from any town to any other town. \n\nIn Treeland there are 2k universities which are located in different tow...
[{"type": "stdin_stdout", "input": "35 15\n6 12 32 18 11 10 29 9 30 27 31 14 8 24 28 25 19 15 21 3 4 1 33 22 23 17 16 13 7 2\n1 2\n20 3\n1 4\n20 5\n20 6\n1 7\n13 8\n4 9\n1 10\n1 11\n1 12\n1 13\n18 14\n10 15\n1 16\n16 17\n1 18\n1 19\n1 20\n20 21\n1 22\n27 23\n25 24\n1 25\n20 26\n20 27\n18 28\n4 29\n13 30\n4 31\n1 32\n20...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nMonocarp is playing a computer game. He's going to kill $n$ monsters, the $i$-th of them has $h_i$ health.\n\nMonocarp's character has two spells, either of which he can cast an arbitrary number of times (possibly, zero) ...
[{"type": "stdin_stdout", "input": "1\n43\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\n", "output": "22\n"}, {"type": "stdin_stdout", "input": "1\n30\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\n", "output": "15\n"}, {"type": "stdin_stdout", "input": "3\n4\n1 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nMad 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 pro...
[{"type": "stdin_stdout", "input": "+--+--+------+++++++-+-+++--++---+--+-+---+--+++-+++-------+++++-+-++++--+-+-+++++++----+----+++----+-+++-+++-----+++-+-++-+-+++++-+--++----+--+-++-----+-+-++++---+++---+-+-+-++++--+--+++---+++++-+---+-----+++-++--+++---++-++-+-+++-+-+-+---+++--+--++++-+-+--++-------+--+---++-----+++...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nNick has n bottles of soda left after his birthday. Each bottle is described by two values: remaining amount of soda a_{i} and bottle volume b_{i} (a_{i} ≤ b_{i}).\n\nNick has decided to pour all remaining soda into minim...
[{"type": "stdin_stdout", "input": "90\n4 2 21 69 53 39 2 2 8 58 7 5 2 82 7 9 13 10 2 44 1 7 2 1 50 42 36 17 14 46 19 1 50 20 51 46 9 59 73 61 76 4 19 22 1 43 53 2 5 5 32 7 5 42 30 14 32 6 6 15 20 24 13 8 5 19 9 9 7 20 7 2 55 36 5 33 64 20 22 22 9 30 67 38 68 2 13 19 2 9\n48 4 39 85 69 70 11 42 65 77 61 6 60 84 67 15 9...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nMike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to n from left to right. i-th bear is exactly a_...
[{"type": "stdin_stdout", "input": "20\n452405440 586588704 509061481 392584366 16115810 148658854 66743034 290624691 677780684 519361360 208050516 401554301 954478790 989443769 387546138 832279893 1081316002 80960260 846049648 588066499\n", "output": "1081316002 954478790 452405440 392584366 387546138 387546138 208050...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAdilbek's house is located on a street which can be represented as the OX axis. This street is really dark, so Adilbek wants to install some post lamps to illuminate it. Street has $n$ positions to install lamps, they cor...
[{"type": "stdin_stdout", "input": "20 16 16\n1 2 3 4 5 6 8 9 10 11 13 14 15 16 18 19\n2 1 1 1 1 1 3 3 2 2 1 3 3 3 3 2\n", "output": "3\n"}, {"type": "stdin_stdout", "input": "20 16 16\n1 2 3 4 5 6 8 9 10 11 13 14 15 16 18 19\n2 1 1 1 1 1 3 3 2 2 1 3 3 3 3 2\n", "output": "3\n"}, {"type": "stdin_stdout", "input": "20 1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIf the girl doesn't go to Denis, then Denis will go to the girl. Using this rule, the young man left home, bought flowers and went to Nastya. \n\nOn the way from Denis's house to the girl's house is a road of $n$ lines. T...
[{"type": "stdin_stdout", "input": "30 8\n0 1 7 10 23 24 26 30\n40 13\n", "output": "30\n"}, {"type": "stdin_stdout", "input": "30 8\n0 1 7 10 23 24 26 30\n40 7\n", "output": "30\n"}, {"type": "stdin_stdout", "input": "30 8\n0 1 7 12 23 24 26 30\n40 7\n", "output": "30\n"}, {"type": "stdin_stdout", "input": "30 8\n0 2 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSnuke has an integer sequence A of length N.\nHe will make three cuts in A and divide it into four (non-empty) contiguous subsequences B, C, D and E.\nThe positions of the cuts can be freely chosen.\nLet P,Q,R,S be the su...
[{"type": "stdin_stdout", "input": "5574\n150872158 2 6 1 3 8 10 4 9 3 5 2 10 2 8 4 2 3 10 8 4 3 1 8 3 5 8 3 7 3 10 7 4 6 1 1 8 10 1 1 10 9 7 9 1 3 7 7 8 6 7 8 6 10 5 2 1 2 2 2 6 10 3 6 6 2 8 1 9 3 6 8 10 10 5 1 8 4 5 1 6 2 7 7 5 3 6 10 6 9 2 9 9 10 1 10 9 10 5 3 10 8 6 10 2 3 1 7 2 7 2 5 8 7 10 3 10 4 1 2 2 1 2 9 2 3 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA sequence of $n$ numbers is called a permutation if it contains all integers from $1$ to $n$ exactly once. For example, the sequences [$3, 1, 4, 2$], [$1$] and [$2,1$] are permutations, but [$1,2,1$], [$0,1$] and [$1,3,4...
[{"type": "stdin_stdout", "input": "1\n50 870\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 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "5\n3 13\n3 1 4\n1 1\n1\n3 3\n1 4 2\n2 1\n4 3\n5 6\n1 2 3 4 5\n", "output"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain.\n\nWrite a program which prints \"YES\" if a point $P$ $(x_p, y_p)$ is in the triangle and \"NO\" if not.\n\nConstraints\n\nY...
[{"type": "stdin_stdout", "input": "2.5236948660396488 1.2449675008007697 3.467160130839816 2.2489154237675044 4.3267713977209254 3.696599910445261 2.778529750649784 0.5428461273225557\n0.3648696681668867 1.6775294144371997 2.646749575901687 5.368903351235283 5.958977255484857 4.673632823800934 -0.048505034276450476 4....
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given N integers; the i-th of them is A_i. Find the maximum possible sum of the absolute differences between the adjacent elements after arranging these integers in a row in any order you like.\n\nConstraints\n\n*...
[{"type": "stdin_stdout", "input": "5\n52\n-1\n-2\n-2\n-1", "output": "110\n"}, {"type": "stdin_stdout", "input": "5\n89\n-1\n-2\n-2\n-1", "output": "184\n"}, {"type": "stdin_stdout", "input": "5\n46\n-1\n-4\n-2\n-1", "output": "102\n"}, {"type": "stdin_stdout", "input": "5\n115\n-1\n0\n-2\n-1", "output": "236\n"}, {"t...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a permutation of integers from 1 to n. Exactly once you apply the following operation to this permutation: pick a random segment and shuffle its elements. Formally: Pick a random segment (continuous subsequ...
[{"type": "stdin_stdout", "input": "100\n30 99 96 51 67 72 33 35 93 70 25 24 6 9 22 83 86 5 79 46 29 88 66 20 87 47 45 71 48 52 61 37 19 40 44 11 8 42 63 92 31 94 2 4 28 77 21 75 13 95 76 14 53 69 54 38 59 60 98 55 39 68 85 23 15 18 58 78 43 49 16 1 82 91 7 84 34 89 17 27 90 26 36 81 64 74 50 57 10 73 12 62 3 100 80 32...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are two standard ways to represent a graph $G = (V, E)$, where $V$ is a set of vertices and $E$ is a set of edges; Adjacency list representation and Adjacency matrix representation.\n\nAn adjacency-list representati...
[{"type": "stdin_stdout", "input": "4\n1 1 0 4\n2 1 1\n-1 -1\n4 1 2", "output": "0 0 0 1\n1 0 0 0\n0 0 0 0\n0 1 0 0\n"}, {"type": "stdin_stdout", "input": "4\n1 2 2 4\n2 1 4\n3 -1\n4 1 3", "output": "0 1 0 1\n0 0 0 1\n0 0 0 0\n0 0 1 0\n"}, {"type": "stdin_stdout", "input": "4\n1 2 1 4\n2 1 4\n1 -1\n4 1 3", "output": "1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nGiven are integers A, B, and N.\nFind the maximum possible value of floor(Ax/B) - A × floor(x/B) for a non-negative integer x not greater than N.\nHere floor(t) denotes the greatest integer not greater than the real numbe...
[{"type": "stdin_stdout", "input": "1000000 1000000000000 1000000000000\n", "output": "999999\n"}, {"type": "stdin_stdout", "input": "1000000 948240928204 329810943092\n", "output": "347813\n"}, {"type": "stdin_stdout", "input": "133333 329230329032 493028310923\n", "output": "133332\n"}, {"type": "stdin_stdout", "inpu...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nEverybody seems to think that the Martians are green, but it turns out they are metallic pink and fat. Ajs has two bags of distinct nonnegative integers. The bags are disjoint, and the union of the sets of numbers in the ...
[{"type": "stdin_stdout", "input": "36 81\n4 5 7 8 13 14 16 17 22 23 25 26 31 32 34 35 40 41 43 44 49 50 52 53 58 59 61 62 67 68 70 71 76 77 79 80\n", "output": "9\n3 12 21 30 39 48 57 66 75\n"}, {"type": "stdin_stdout", "input": "36 156\n8 1 8 9 26 14 13 33 22 32 24 70 31 32 34 35 40 41 52 44 49 50 36 53 46 56 61 62 9...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nProfessor Pathfinder is a distinguished authority on the structure of hyperlinks in the World Wide Web. For establishing his hypotheses, he has been developing software agents, which automatically traverse hyperlinks and ...
[{"type": "stdin_stdout", "input": "5 6\n/home/ACM/index.html\nlmth.xedni/CPCI/\n/ICPC/general.html\n/ICPC/japanese/index.html\n/ICPC/secret/confidential/2005/index.html\n/home/ACM/\n/ho/e/ICPC/..mACM/\n/ICPC/secret/\n/ICPC/secret/index.html\n/ICPC\n/ICPC/../ICPC/index.html\n/ICPC\n/ICPC/general.html\n/ICPC/japanese/.....
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nUtkarsh is forced to play yet another one of Ashish's games. The game progresses turn by turn and as usual, Ashish moves first.\n\nConsider the 2D plane. There is a token which is initially at $(0,0)$. In one move a playe...
[{"type": "stdin_stdout", "input": "5\n16 1\n3 2\n9 1\n65 19\n14195 55\n", "output": "Utkarsh\nUtkarsh\nUtkarsh\nUtkarsh\nUtkarsh\n"}, {"type": "stdin_stdout", "input": "5\n10 1\n3 2\n9 1\n65 19\n14195 55\n", "output": "Utkarsh\nUtkarsh\nUtkarsh\nUtkarsh\nUtkarsh\n"}, {"type": "stdin_stdout", "input": "5\n16 1\n4 2\n9 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSnuke loves constructing integer sequences.\nThere are N piles of stones, numbered 1 through N.\nThe pile numbered i consists of a_i stones.\nSnuke will construct an integer sequence s of length Σa_i, as follows:\n - Amon...
[{"type": "stdin_stdout", "input": "10\n1 3 2 6 2 4 4 5 8 1", "output": "10\n14\n0\n10\n0\n0\n0\n0\n2\n0\n"}, {"type": "stdin_stdout", "input": "10\n1 3 1 6 3 4 6 6 4 1", "output": "10\n14\n0\n11\n0\n0\n0\n0\n0\n0\n"}, {"type": "stdin_stdout", "input": "10\n1 4 0 1 1 4 4 0 22 1", "output": "8\n12\n0\n0\n0\n0\n0\n0\n18\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nFor given three integers $a, b, c$, print the minimum value and the maximum value.\n\nConstraints\n\n* $-1,000,000,000 \\leq a, b, c \\leq 1,000,000,000$\n\nInput\n\nThe input is given in the following format.\n\n\n$a \\;...
[{"type": "stdin_stdout", "input": "-30 -1 -1", "output": "-30 -1\n"}, {"type": "stdin_stdout", "input": "-22 -1 -1", "output": "-22 -1\n"}, {"type": "stdin_stdout", "input": "-22 -2 -2", "output": "-22 -2\n"}, {"type": "stdin_stdout", "input": "-2 10 -1", "output": "-2 10\n"}, {"type": "stdin_stdout", "input": "-2 28 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAnia has a large integer S. Its decimal representation has length n and doesn't contain any leading zeroes. Ania is allowed to change at most k digits of S. She wants to do it in such a way that S still won't contain any ...
[{"type": "stdin_stdout", "input": "400 224\n34034718296316650556302576767095880542740697596682657060609028712014739414658241556774411582749368771597248873201583574900424227251655547840887764275893533353440635216728376201808545879398359535670372855472971530695051695650262058940466340529417646357776899296790403916961389...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nDetermine if we can choose K different integers between 1 and N (inclusive) so that no two of them differ by 1.\n\nConstraints\n\n* 1\\leq N,K\\leq 100\n* N and K are integers.\n\nInput\n\nInput is given from Standard Inp...
[{"type": "stdin_stdout", "input": "135 27", "output": "YES\n"}, {"type": "stdin_stdout", "input": "135 47", "output": "YES\n"}, {"type": "stdin_stdout", "input": "149 47", "output": "YES\n"}, {"type": "stdin_stdout", "input": "149 50", "output": "YES\n"}, {"type": "stdin_stdout", "input": "151 50", "output": "YES\n"},...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe Chef has prepared the appetizers in the shapes of letters to spell a special message for the guests. There are n appetizers numbered from 0 to n-1 such that if the appetizers are arrayed in this order, they will displ...
[{"type": "stdin_stdout", "input": "2\n2 chef\n4 eipelpparuoyojne", "output": "cehf\nerlopopniupjeyae\n"}, {"type": "stdin_stdout", "input": "2\n2 chef\n4 enjoyourappmepie", "output": "cehf\neayejpuinpopomre\n"}, {"type": "stdin_stdout", "input": "2\n2 cief\n4 enjoyourappmepie", "output": "ceif\neayejpuinpopomre\n"}, {...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are N observatories in AtCoder Hill, called Obs. 1, Obs. 2, ..., Obs. N. The elevation of Obs. i is H_i.\nThere are also M roads, each connecting two different observatories. Road j connects Obs. A_j and Obs. B_j.\n...
[{"type": "stdin_stdout", "input": "6 5\n8 6 9 1 2 1\n1 3\n4 2\n4 3\n4 6\n4 6\n", "output": "3\n"}, {"type": "stdin_stdout", "input": "6 5\n8 6 18 1 4 1\n1 3\n4 0\n4 0\n4 6\n4 6", "output": "3\n"}, {"type": "stdin_stdout", "input": "6 5\n8 6 18 1 4 0\n1 3\n4 0\n4 0\n4 6\n4 6", "output": "4\n"}, {"type": "stdin_stdout",...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nGiven is a positive integer L.\nFind the maximum possible volume of a rectangular cuboid whose sum of the dimensions (not necessarily integers) is L.\n\n-----Constraints-----\n - 1 ≤ L ≤ 1000\n - L is an integer.\n\n-----...
[{"type": "stdin_stdout", "input": "1000\n", "output": "37037037.037037037313\n"}, {"type": "stdin_stdout", "input": "999\n", "output": "36926037.000000000000\n"}, {"type": "stdin_stdout", "input": "430\n", "output": "2944703.703703703824\n"}, {"type": "stdin_stdout", "input": "392\n", "output": "2230973.629629629664\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nRecently you have bought a snow walking robot and brought it home. Suppose your home is a cell $(0, 0)$ on an infinite grid.\n\nYou also have the sequence of instructions of this robot. It is written as the string $s$ con...
[{"type": "stdin_stdout", "input": "6\nLRU\nDURLDRUDRULRDURDDL\nLRUDDLRUDRUL\nLLLLRRRR\nURDUR\nLLL\n", "output": "2\nLR\n14\nLLLUUUURRRDDDD\n12\nLLLUUURRRDDD\n2\nLR\n2\nUD\n0\n\n"}, {"type": "stdin_stdout", "input": "6\nLRU\nDURLDRUDRULRDURDDL\nLRUDDLRUDRUL\nLLLLRRRR\nURDUR\nLLL\n", "output": "2\nLR\n14\nLLLUUUURRRDDDD...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nMaxim has opened his own restaurant! The restaurant has got a huge table, the table's length is p meters.\n\nMaxim has got a dinner party tonight, n guests will come to him. Let's index the guests of Maxim's restaurant fr...
[{"type": "stdin_stdout", "input": "50\n15 28 34 29 17 21 20 34 37 17 10 20 37 10 18 25 31 25 16 1 37 27 39 3 5 18 2 32 10 35 20 17 29 20 3 29 3 25 9 32 37 5 25 23 25 33 35 8 31 29\n39\n", "output": "1.4997987526\n"}, {"type": "stdin_stdout", "input": "50\n15 28 34 29 17 21 20 34 37 17 10 20 37 10 18 25 31 25 16 1 37 2...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nBritish mathematician John Littlewood once said about Indian mathematician Srinivasa Ramanujan that \"every positive integer was one of his personal friends.\"\n\nIt turns out that positive integers can also be friends wi...
[{"type": "stdin_stdout", "input": "1\n69\n2 4 10 16 22 28 19 40 37 52 92 43 70 76 118 88 94 100 106 112 118 124 130 200 142 148 154 160 166 324 178 184 190 196 300 208 214 129 226 167 238 244 250 209 262 322 274 280 286 462 298 304 310 316 322 328 169 110 591 352 358 364 370 376 382 388 391 397 403\n", "output": "25\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nOur hardworking chef is bored of sleeping in his restaurants. He has decided to settle down. The first thing he must do is to find a suitable location to build a palatial home. \n\nThink of the city as a two-dimensional g...
[{"type": "stdin_stdout", "input": "3\n5\n0 0\n-1 -1\n2 0\n-1 1\n0 -2\n5\n31 11\n30 -41\n20 13\n25 28\n25 38\n2\n-1 0\n1 2", "output": "1\n1\n9\n"}, {"type": "stdin_stdout", "input": "3\n5\n-1 0\n-1 0\n1 4\n0 0\n0 -1\n5\n31 11\n52 -41\n18 1\n25 18\n25 60\n2\n-1 -1\n2 5", "output": "1\n1\n28\n"}, {"type": "stdin_stdout"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSagheer 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 ...
[{"type": "stdin_stdout", "input": "21\n6194737 6429360 6047962 1014039 9196042 2483033 9232471 5444322 4437778 6614229 4791649 7417126 7679607 790939 3062370 174847 8404336 832859 2083127 9041108 3074902\n1 2 3 4 4 6 7 2 9 10 9 12 12 1 15 1 17 1 19 19\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "21\n619473...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nCompute A + B.\n\nConstraints\n\n* -1000 ≤ A, B ≤ 1000\n\nInput\n\nThe input will consist of a series of pairs of integers A and B separated by a space, one pair of integers per line. The input will be terminated by EOF.\...
[{"type": "stdin_stdout", "input": "1 2\n10 5\n101 20", "output": "3\n15\n121\n"}, {"type": "stdin_stdout", "input": "1 2\n10 4\n101 20", "output": "3\n14\n121\n"}, {"type": "stdin_stdout", "input": "1 2\n10 4\n101 37", "output": "3\n14\n138\n"}, {"type": "stdin_stdout", "input": "1 2\n11 4\n101 37", "output": "3\n15\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIn the city of Saint Petersburg, a day lasts for $2^{100}$ minutes. From the main station of Saint Petersburg, a train departs after $1$ minute, $4$ minutes, $16$ minutes, and so on; in other words, the train departs at t...
[{"type": "stdin_stdout", "input": "1000010011100010111000001101000011001010011101011001101100000001011011000000101101101011101111011011\n", "output": "50\n"}, {"type": "stdin_stdout", "input": "1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111\n", "output": "50\n"}, {...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a rooted tree consisting of $n$ vertices numbered from $1$ to $n$. The root of the tree is a vertex number $1$.\n\nA tree is a connected undirected graph with $n-1$ edges.\n\nYou are given $m$ queries. The $...
[{"type": "stdin_stdout", "input": "10 6\n1 2\n1 3\n1 4\n2 5\n2 6\n5 7\n7 8\n7 9\n9 10\n4 3 8 9 10\n3 2 4 6\n3 4 1 5\n3 4 8 2\n2 6 10\n3 5 4 7\n", "output": "YES\nYES\nYES\nYES\nYES\nYES\n"}, {"type": "stdin_stdout", "input": "10 6\n1 2\n1 3\n1 4\n2 5\n2 6\n5 7\n7 8\n7 9\n9 10\n4 3 8 9 10\n3 2 4 6\n3 4 1 5\n3 4 8 1\n2 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nTwo positive integers a and b have a sum of s and a bitwise XOR of x. How many possible values are there for the ordered pair (a, b)?\n\n\n-----Input-----\n\nThe first line of the input contains two integers s and x (2 ≤ ...
[{"type": "stdin_stdout", "input": "549755813887 549755813887\n", "output": "549755813886\n"}, {"type": "stdin_stdout", "input": "549755813888 549755813886\n", "output": "274877906944\n"}, {"type": "stdin_stdout", "input": "547616456703 547599679487\n", "output": "68719476736\n"}, {"type": "stdin_stdout", "input": "274...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nKoto Municipal Subway\n\nKoto Municipal Subway\n\nKoto City is a famous city whose roads are in a grid pattern, as shown in the figure below. The roads extending from north to south and the roads extending from east to we...
[{"type": "stdin_stdout", "input": "2 1\n11 5\n7 6\n5 0\n76 1\n1 41\n0 0", "output": "0.414213562373\n2.81024967591\n0.0827625302982\n3.60555127546\n52.7401153702\n40.0\n"}, {"type": "stdin_stdout", "input": "2 1\n14 6\n5 4\n7 7\n76 3\n9 000\n0 0", "output": "0.414213562373\n3.89949493661\n0.123105625618\n0.0\n50.74011...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are N slimes standing on a number line. The i-th slime from the left is at position x_i.\n\nIt is guaruanteed that 1 \\leq x_1 < x_2 < \\ldots < x_N \\leq 10^{9}.\n\nNiwango will perform N-1 operations. The i-th ope...
[{"type": "stdin_stdout", "input": "12\n367101616 467388357 159541726 1477792495 1190847685 1723370727 668687333 270216579 135685914 125686970 1191846896 1765707086", "output": "469392584\n"}, {"type": "stdin_stdout", "input": "12\n367101616 467388357 127795962 1640220090 1190847685 1723370727 402149677 270216579 13568...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA binary string is a string that consists of characters $0$ and $1$.\n\nLet $\\operatorname{MEX}$ of a binary string be the smallest digit among $0$, $1$, or $2$ that does not occur in the string. For example, $\\operator...
[{"type": "stdin_stdout", "input": "6\n01\n1111\n01100\n101\n0000\n01010\n", "output": "1\n0\n2\n1\n1\n2\n"}, {"type": "stdin_stdout", "input": "6\n01\n1111\n01100\n100\n0000\n01010\n", "output": "1\n0\n2\n1\n1\n2\n"}, {"type": "stdin_stdout", "input": "6\n01\n1011\n01100\n100\n0000\n01010\n", "output": "1\n1\n2\n1\n1\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA Bingo game is played by one gamemaster and several players. At the beginning of a game, each player is given a card with M × M numbers in a matrix (See Figure 10).\n\n<image>\n\nAs the game proceeds, the gamemaster anno...
[{"type": "stdin_stdout", "input": "4 3\n10 25 11 20 6 2 1 15 23\n5 21 1 12 23 17 7 26 2\n8 18 4 22 13 27 16 5 11\n19 9 24 2 11 5 14 28 16\n4 3\n12 13 20 24 28 32 15 16 17\n12 13 21 25 29 33 16 17 18\n12 13 22 26 30 34 17 18 15\n12 13 23 27 31 35 18 15 16\n4 3\n11 12 13 14 15 16 17 18 19\n21 22 23 24 25 26 27 28 29\n31...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe average miner Vaganych took refresher courses. As soon as a miner completes the courses, he should take exams. The hardest one is a computer test called \"Testing Pants for Sadness\".\n\nThe test consists of n questio...
[{"type": "stdin_stdout", "input": "50\n515844718 503470143 928669067 209884122 322869098 241621928 844696197 105586164 552680307 968792756 135928721 842094825 298782438 829020472 791637138 285482545 811025527 428952878 887796419 11883658 546401594 6272027 100292274 308219869 372132044 955814846 644008184 521195760 919...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nArpa is taking a geometry exam. Here is the last problem of the exam.\n\nYou are given three points a, b, c.\n\nFind a point and an angle such that if we rotate the page around the point by the angle, the new position of ...
[{"type": "stdin_stdout", "input": "-947393823 -495674431 211535284 -877153626 -522763219 -778236665\n", "output": "No\n"}, {"type": "stdin_stdout", "input": "-947393823 -495674431 211535284 -877153626 -522763219 -778236665\n", "output": "No\n"}, {"type": "stdin_stdout", "input": "-211700879 -495674431 211535284 -87715...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nFind the number of ways to choose a pair of an even number and an odd number from the positive integers between 1 and K (inclusive). The order does not matter.\n\n-----Constraints-----\n - 2\\leq K\\leq 100\n - K is an in...
[{"type": "stdin_stdout", "input": "-2373", "output": "1407782\n"}, {"type": "stdin_stdout", "input": "-1265", "output": "400056\n"}, {"type": "stdin_stdout", "input": "-1867", "output": "871422\n"}, {"type": "stdin_stdout", "input": "-1056", "output": "278784\n"}, {"type": "stdin_stdout", "input": "-1235", "output": "...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are n kangaroos with pockets. Each kangaroo has a size (integer number). A kangaroo can go into another kangaroo's pocket if and only if the size of kangaroo who hold the kangaroo is at least twice as large as the s...
[{"type": "stdin_stdout", "input": "100\n154\n60\n97\n638\n139\n150\n570\n579\n601\n647\n804\n237\n245\n549\n288\n347\n778\n282\n916\n441\n974\n145\n957\n1006\n655\n702\n930\n618\n132\n520\n972\n48\n94\n54\n682\n433\n896\n134\n845\n636\n242\n842\n125\n141\n240\n130\n409\n666\n948\n938\n604\n110\n474\n484\n364\n40\n807\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nJohny likes numbers n and k very much. Now Johny wants to find the smallest integer x greater than n, so it is divisible by the number k.\n\n\n-----Input-----\n\nThe only line contains two integers n and k (1 ≤ n, k ≤ 10^...
[{"type": "stdin_stdout", "input": "1000000000 1000000000\n", "output": "2000000000\n"}, {"type": "stdin_stdout", "input": "1000000010 1000000000\n", "output": "2000000000\n"}, {"type": "stdin_stdout", "input": "1398941105 1000000001\n", "output": "2000000002\n"}, {"type": "stdin_stdout", "input": "1000100010 100001000...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nTakahashi is not good at problems about trees in programming contests, and Aoki is helping him practice.\n\nFirst, Takahashi created a tree with N vertices numbered 1 through N, and wrote 0 at each edge.\n\nThen, Aoki gav...
[{"type": "stdin_stdout", "input": "10 0\n1 1\n2 6\n11 2\n-1 4\n0 10", "output": "YES\n"}, {"type": "stdin_stdout", "input": "10 -1\n1 1\n2 6\n11 2\n-1 5\n0 5", "output": "YES\n"}, {"type": "stdin_stdout", "input": "10 -1\n1 1\n2 3\n11 2\n-1 5\n0 5", "output": "YES\n"}, {"type": "stdin_stdout", "input": "10 0\n1 1\n11 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe city of Fishtopia can be imagined as a grid of 4 rows and an odd number of columns. It has two main villages; the first is located at the top-left cell (1,1), people who stay there love fishing at the Tuna pond at the...
[{"type": "stdin_stdout", "input": "100 80\n", "output": "YES\n....................................................................................................\n.########################################...........................................................\n.########################################...............
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nVasya is about to take his first university exam in about several minutes. And it's not just some ordinary exam, it's on mathematical analysis. Of course, right now Vasya can only think of one thing: what the result of hi...
[{"type": "stdin_stdout", "input": "100 1\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 99\n1\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 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe only difference between easy and hard versions is constraints.\n\nIf you write a solution in Python, then prefer to send it in PyPy to speed up execution time.\n\nA session has begun at Beland State University. Many s...
[{"type": "stdin_stdout", "input": "10 50\n10 10 10 10 10 10 10 10 10 10\n", "output": "0 0 0 0 0 1 2 3 4 5 \n"}, {"type": "stdin_stdout", "input": "10 50\n10 10 10 10 10 10 10 10 10 10\n", "output": "0 0 0 0 0 1 2 3 4 5 "}, {"type": "stdin_stdout", "input": "10 71\n10 10 10 10 10 10 10 10 10 10\n", "output": "0 0 0 0 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nDima got into number sequences. Now he's got sequence a_1, a_2, ..., a_{n}, consisting of n positive integers. Also, Dima has got a function f(x), which can be defined with the following recurrence: f(0) = 0; f(2·x) = f...
[{"type": "stdin_stdout", "input": "8\n851991424 32517099 310793856 776130403 342626527 58796623 49544509 517126753\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "8\n851991424 32517099 310793856 771296843 342626527 58796623 49544509 517126753\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "8\n8519914...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nRead problems statements in Mandarin Chinese , Russian and Vietnamese as well. \n\nChef belongs to a very rich family which owns many gold mines. Today, he brought N gold coins and decided to form a triangle using these c...
[{"type": "stdin_stdout", "input": "3\n5\n13\n106", "output": "2\n4\n14\n"}, {"type": "stdin_stdout", "input": "3\n5\n13\n68", "output": "2\n4\n11\n"}, {"type": "stdin_stdout", "input": "3\n5\n1\n106", "output": "2\n1\n14\n"}, {"type": "stdin_stdout", "input": "3\n5\n1\n122", "output": "2\n1\n15\n"}, {"type": "stdin_st...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nMisha and Vanya have played several table tennis sets. Each set consists of several serves, each serve is won by one of the players, he receives one point and the loser receives nothing. Once one of the players scores exa...
[{"type": "stdin_stdout", "input": "1 1000000000 1000000000\n", "output": "2000000000\n"}, {"type": "stdin_stdout", "input": "1000000000 1000000000 1000000000\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "2 1000000000 1000000000\n", "output": "1000000000\n"}, {"type": "stdin_stdout", "input": "1000000000 999...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThis problem consists of three subproblems: for solving subproblem F1 you will receive 8 points, for solving subproblem F2 you will receive 15 points, and for solving subproblem F3 you will receive 10 points.\n\nManao has...
[{"type": "stdin_stdout", "input": "10 4\n2\n7\n1\n9\n8\n10\n5\n10\n1\n20\n", "output": "38\n"}, {"type": "stdin_stdout", "input": "10 4\n1\n7\n1\n9\n8\n10\n5\n10\n1\n20\n", "output": "39\n"}, {"type": "stdin_stdout", "input": "10 5\n2\n13\n3\n9\n8\n7\n9\n7\n1\n18\n", "output": "36\n"}, {"type": "stdin_stdout", "input"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThis is the easy version of the problem. The difference between the versions is in the number of possible operations that can be made. You can make hacks if and only if you solved both versions of the problem.\n\nYou are ...
[{"type": "stdin_stdout", "input": "5\n2 2\n10\n11\n3 3\n011\n101\n110\n4 4\n1111\n0110\n0110\n1111\n5 5\n01011\n11001\n00010\n11011\n10000\n2 3\n011\n101\n", "output": "1\n1 1 2 1 2 2 \n6\n1 1 1 2 2 2 \n1 1 2 1 2 2 \n1 2 1 3 2 2 \n1 2 2 2 2 3 \n2 1 2 2 3 1 \n2 1 2 2 3 2 \n20\n1 1 1 2 2 2 \n1 2 1 3 2 2 \n1 2 2 2 2 3 \n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nFor a finite set of integers X, let f(X)=\\max X - \\min X.\nGiven are N integers A_1,...,A_N.\nWe will choose K of them and let S be the set of the integers chosen. If we distinguish elements with different indices even ...
[{"type": "stdin_stdout", "input": "10 6\n1000000000 1000000000 1000000000 1000000000 1000000000 0 0 0 0 0\n", "output": "999998537\n"}, {"type": "stdin_stdout", "input": "10 8\n1000000000 1100000000 1000001010 1000000000 1000000000 0 0 -2 0 0", "output": "600007816\n"}, {"type": "stdin_stdout", "input": "10 8\n1000000...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSome time ago Leonid have known about idempotent functions. Idempotent function defined on a set {1, 2, ..., n} is such function $g : \\{1,2, \\ldots, n \\} \\rightarrow \\{1,2, \\ldots, n \\}$, that for any $x \\in \\{1,...
[{"type": "stdin_stdout", "input": "142\n34 88 88 88 88 88 131 53 88 130 131 88 88 130 88 131 53 130 130 34 88 88 131 130 53 88 88 34 131 130 88 131 130 34 130 53 53 34 53 34 130 34 88 88 130 88 131 130 34 53 88 34 53 88 130 53 34 53 88 131 130 34 88 88 130 88 130 130 131 131 130 53 131 130 131 130 53 34 131 34 88 53 8...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nHow Many Divisors?\n\nWrite a program which reads three integers a, b and c, and prints the number of divisors of c between a and b.\n\nConstraints\n\n* 1 ≤ a, b, c ≤ 10000\n* a ≤ b\n\nInput\n\nThree integers a, b and c a...
[{"type": "stdin_stdout", "input": "4 32 120", "output": "10\n"}, {"type": "stdin_stdout", "input": "13 14 107", "output": "0\n"}, {"type": "stdin_stdout", "input": "5 14 149", "output": "0\n"}, {"type": "stdin_stdout", "input": "13 14 80", "output": "0\n"}, {"type": "stdin_stdout", "input": "5 14 241", "output": "0\n"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nGilbert is the network admin of Ginkgo company. His boss is mad about the messy network cables on the floor. He finally walked up to Gilbert and asked the lazy network admin to illustrate how computers and switches are co...
[{"type": "stdin_stdout", "input": "4\n 0 2 2 2\n 2 0 2 2\n 2 2 -1 2\n 2 2 2 0\n4\n -1 2 4 4\n 2 -1 4 4\n 4 4 -1 2\n 4 4 2 0\n2\n 0 12\n 12 0\n0", "output": "4\n2 3 3\n2 2 2 2 2 2 2 2 2 2 2\n"}, {"type": "stdin_stdout", "input": "4\n -1 2 2 2\n 2 0 2 2\n 2 2 -1 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAccording to a new ISO standard, a flag of every country should have, strangely enough, a chequered field n × m, each square should be wholly painted one of 26 colours. The following restrictions are set: \n\n * In each ...
[{"type": "stdin_stdout", "input": "1 500\nwljexjwjwsxhascgpyezfotqyieywzyzpnjzxqebroginhlpsvtbgmbckgqixkdveraxlgleieeagubywaacncxoouibbhwyxhjiczlymscsqlttecvundzjqtuizqwsjalmizgeekugacatlwhiiyaamjuiafmyzxadbxsgwhfawotawfxkpyzyoceiqfppituvaqmgfjinulkbkgpnibaefqaqiptctoqhcnnfihmzijnwpxdikwefpxicbspdkppznpiqrpkyvcxapoaof...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nCan you imagine our life if we removed all zeros from it? For sure we will have many problems.\n\nIn this problem we will have a simple example if we removed all zeros from our life, it's the addition operation. Let's ass...
[{"type": "stdin_stdout", "input": "1000000000\n1000000000\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "1000000000\n1000010000\n", "output": "NO\n"}, {"type": "stdin_stdout", "input": "1000000000\n1001010000\n", "output": "NO\n"}, {"type": "stdin_stdout", "input": "999999999\n999999999\n", "output": "YES\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSereja loves all sorts of algorithms. He has recently come up with a new algorithm, which receives a string as an input. Let's represent the input string of the algorithm as q = q_1q_2... q_{k}. The algorithm consists of ...
[{"type": "stdin_stdout", "input": "yxzyzxzzxyyzzxxxzyyzzyzxxzxyzyyzxyzxyxxyzxyxzyzxyzxyyxzzzyzxyyxyzxxy\n10\n17 67\n6 35\n12 45\n56 56\n14 30\n25 54\n1 1\n46 54\n3 33\n19 40\n", "output": "NO\nNO\nNO\nYES\nYES\nNO\nYES\nNO\nNO\nYES\n"}, {"type": "stdin_stdout", "input": "yxzyzxzzxyyzzxxxzyyzzyzxxzxyzyyzxyzxyxxyzxyxzyz...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nTakahashi, who is a novice in competitive programming, wants to learn M algorithms.\nInitially, his understanding level of each of the M algorithms is 0.\nTakahashi is visiting a bookstore, where he finds N books on algor...
[{"type": "stdin_stdout", "input": "12 12 48311\n2997 79802 84238 34346 35199 2284 77696 46340 54797 36702 97764 42765 11582\n82923 47331 39508 81928 63775 90952 64439 99662 74546 15843 11552 23897 87476\n26261 21259 714 72469 92132 94958 69101 38760 4916 38769 60706 90149 70017\n35433 97674 53722 44881 95786 42614 799...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe All-Berland National Olympiad in Informatics has just ended! Now Vladimir wants to upload the contest from the Olympiad as a gym to a popular Codehorses website.\n\nUnfortunately, the archive with Olympiad's data is a...
[{"type": "stdin_stdout", "input": "20\nphp8vy 1\nkeeona 0\n8 0\nwzf4eb 0\n16 1\n9 0\nf2548d 0\n11 0\nyszsig 0\nyyf4q2 0\n1pon1p 1\njvpwuo 0\nd9stsx 0\ne14bkx 1\n5 0\n17 0\nsbklx4 0\nsfms2u 1\n6 0\n18 1\n", "output": "16\nmove 16 1\nmove 18 2\nmove 5 20\nmove 6 19\nmove php8vy 3\nmove 1pon1p 4\nmove e14bkx 5\nmove sfms...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA renowned abstract artist Sasha, drawing inspiration from nowhere, decided to paint a picture entitled \"Special Olympics\". He justly thought that, if the regular Olympic games have five rings, then the Special ones wil...
[{"type": "stdin_stdout", "input": "-100 -97 20 40\n-151 -97 30 100\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "-123 -29 20 40\n-39 -19 99 100\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "-100 -97 20 40\n-90 -97 30 100\n", "output": "2"}, {"type": "stdin_stdout", "input": "-45 -93 20 40\n-36 -9...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nFennec and Snuke are playing a board game.\nOn the board, there are N cells numbered 1 through N, and N-1 roads, each connecting two cells. Cell a_i is adjacent to Cell b_i through the i-th road. Every cell can be reached...
[{"type": "stdin_stdout", "input": "7\n3 6\n1 2\n3 1\n7 4\n5 7\n1 4\n", "output": "Fennec\n"}, {"type": "stdin_stdout", "input": "7\n3 6\n2 2\n3 1\n7 4\n5 7\n1 4", "output": "Fennec\n"}, {"type": "stdin_stdout", "input": "7\n3 6\n2 2\n3 1\n7 4\n4 7\n1 4", "output": "Fennec\n"}, {"type": "stdin_stdout", "input": "7\n3 6...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nConsider the following equation: \n\n<image> where sign [a] represents the integer part of number a.\n\nLet's find all integer z (z > 0), for which this equation is unsolvable in positive integers. The phrase \"unsolvable...
[{"type": "stdin_stdout", "input": "14\n", "output": " 373391776\n"}, {"type": "stdin_stdout", "input": "38\n", "output": " 90046024\n"}, {"type": "stdin_stdout", "input": "25\n", "output": " ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nProblem statement\n\nThere is a rational number sequence $ X_0, X_1, X_2, ..., X_N $. Each term is defined as follows.\n\n\n1. $ X_0 = 0 $\n2. $ X_i = X_ {i-1} $ $ op_i $ $ Y_i $ ($ 1 \\ leq i \\ leq N $). However, $ op_i...
[{"type": "stdin_stdout", "input": "4\n-1 2\n12 0\n1 -3\n3 13", "output": "-39\n"}, {"type": "stdin_stdout", "input": "4\n-2 4\n7 1\n-1 8\n2 25", "output": "-25\n"}, {"type": "stdin_stdout", "input": "4\n-1 -2\n2 3\n3 2\n2 22", "output": "-28\n"}, {"type": "stdin_stdout", "input": "4\n-1 -2\n2 5\n3 2\n2 22", "output": ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nMarcin is a coach in his university. There are $n$ students who want to attend a training camp. Marcin is a smart coach, so he wants to send only the students that can work calmly with each other.\n\nLet's focus on the st...
[{"type": "stdin_stdout", "input": "10\n206158430208 206162624513 68719476737 137506062337 206162624513 4194305 68719476737 206225539072 137443147777 109376694609\n202243898 470292528 170057449 290025540 127995253 514454151 607963029 768676450 611202521 68834463\n", "output": "2704208829\n"}, {"type": "stdin_stdout", "...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nOnce 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 p...
[{"type": "stdin_stdout", "input": "1256336691\n", "output": "2931452299 10050693537\n"}, {"type": "stdin_stdout", "input": "1359531323\n", "output": "6797656627 10876250593\n"}, {"type": "stdin_stdout", "input": "1544906479\n", "output": "1581910903 12359251841\n"}, {"type": "stdin_stdout", "input": "1278463385\n", "o...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nRecently, on the course of algorithms and data structures, Valeriy learned how to use a deque. He built a deque filled with $n$ elements. The $i$-th element is $a_i$ ($i$ = $1, 2, \\ldots, n$). He gradually takes the firs...
[{"type": "stdin_stdout", "input": "71 57\n9 26 80 2 65 60 63 1 15 109 114 1 58 27 41 97 42 9 42 56 87 22 10 28 34 90 13 70 71 56 65 21 0 78 47 96 56 77 32 83 28 16 10 41 0 18 118 12 27 112 4 67 21 41 111 20 21 52 74 10 83 74 43 123 2 15 0 63 68 7 72\n81\n47\n81\n81\n5\n9\n41\n76\n81\n92\n95\n94\n78\n93\n47\n30\n152\n3...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are an environmental activist at heart but the reality is harsh and you are just a cashier in a cinema. But you can still do something!\n\nYou have n tickets to sell. The price of the i-th ticket is p_i. As a teller, ...
[{"type": "stdin_stdout", "input": "4\n1\n100\n50 2\n49 1\n100\n8\n100 200 100 200 100 200 100 100\n16 2\n15 3\n107\n3\n1000000000 1000000000 1000000000\n50 1\n50 1\n4850788900\n5\n200 100 100 100 100\n105 5\n31 1\n90\n", "output": "-1\n6\n-1\n2\n"}, {"type": "stdin_stdout", "input": "4\n1\n100\n50 2\n49 1\n100\n8\n100...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou've been in love with Coronavirus-chan for a long time, but you didn't know where she lived until now. And just now you found out that she lives in a faraway place called Naha. \n\nYou immediately decided to take a vac...
[{"type": "stdin_stdout", "input": "48 14\n1 1 1 1 1 6 1 1 1 1 1 1 3 3 1 1 1 1 1 2 2 2 1 1 1 1 1 1 2 1 4 1 1 1 1 1 1 1 1 1 1 7 1 1 1 1 1 5\n", "output": "42\n"}, {"type": "stdin_stdout", "input": "48 14\n1 1 1 1 1 6 1 1 1 1 1 1 3 3 1 1 2 1 1 2 2 2 1 1 1 1 1 1 2 1 4 1 1 1 1 1 1 1 1 1 1 7 1 1 1 1 1 5\n", "output": "42\n"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nImagine that there is a group of three friends: A, B and С. A owes B 20 rubles and B owes C 20 rubles. The total sum of the debts is 40 rubles. You can see that the debts are not organized in a very optimal manner. Let's ...
[{"type": "stdin_stdout", "input": "100 48\n1 56 6\n2 42 3\n3 52 1\n9 26 8\n10 96 8\n11 39 2\n12 51 6\n12 68 7\n13 40 5\n14 18 10\n14 70 6\n15 37 8\n15 38 8\n15 82 6\n15 85 5\n16 48 3\n16 50 9\n16 71 9\n17 18 3\n17 100 10\n20 73 3\n22 32 9\n22 89 9\n23 53 3\n24 53 1\n27 78 10\n30 50 5\n33 94 8\n34 87 9\n35 73 3\n36 51 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are N Snuke Cats numbered 1, 2, \\ldots, N, where N is even.\nEach Snuke Cat wears a red scarf, on which his favorite non-negative integer is written.\nRecently, they learned the operation called xor (exclusive OR)....
[{"type": "stdin_stdout", "input": "4\n141 1 -1 2", "output": "-4 -144 142 -141\n"}, {"type": "stdin_stdout", "input": "4\n102 2 -1 2", "output": "-1 -101 102 -101\n"}, {"type": "stdin_stdout", "input": "4\n102 2 -1 1", "output": "-4 -104 101 -101\n"}, {"type": "stdin_stdout", "input": "4\n13 -17 0 0", "output": "-17 1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSomething happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found tha...
[{"type": "stdin_stdout", "input": "100\n23 64 60 -45 -36 -64 -59 15 -75 69 -30 -7 -20 17 -77 58 93 -76 -98 -22 -31 16 -50 6 -20 -85 1 64 -88 -8 -15 -6 -57 25 91 10 2 -90 74 -66 -42 73 28 49 -85 59 96 79 -25 49 -59 -89 -75 12 -96 -33 -65 -8 -100 -81 17 99 -91 -5 7 -21 1 85 63 86 -26 85 -31 11 -75 35 -82 15 98 93 -55 66...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nRamesses came to university to algorithms practice, and his professor, who is a fairly known programmer, gave him the following task.\n\nYou are given two matrices $A$ and $B$ of size $n \\times m$, each of which consists...
[{"type": "stdin_stdout", "input": "10 10\n1 1 1 0 1 1 0 0 0 1\n1 1 1 1 0 0 0 0 0 1\n0 1 0 0 0 0 0 0 1 0\n0 0 0 0 0 1 0 0 0 0\n0 1 1 1 0 1 1 1 0 0\n0 0 0 1 1 1 0 1 0 0\n0 0 0 0 1 1 0 0 1 1\n0 0 0 1 1 0 1 1 1 1\n1 1 0 1 1 0 1 1 0 0\n1 0 0 0 0 0 0 0 1 0\n0 1 0 1 0 1 1 1 0 0\n0 1 1 0 0 0 0 0 0 1\n0 1 0 0 0 1 0 0 0 0\n0 1 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nNew Year is coming in Tree World! In this world, as the name implies, there are n cities connected by n - 1 roads, and for any two distinct cities there always exists a path between them. The cities are numbered by intege...
[{"type": "stdin_stdout", "input": "10\n1 2 938\n1 6 23\n1 10 727\n1 9 814\n9 5 644\n8 5 39\n2 7 999\n1 3 666\n5 4 577\n10\n9 1099\n5 64\n4 318\n3 373\n4 548\n7 219\n5 43\n5 27\n3 155\n8 359\n", "output": "5336.333333333333\n4524.333333333333\n3730.733333333333\n3518.3333333333335\n3886.3333333333335\n3418.333333333333...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nOn March 14, the day of the number $\\pi$ is celebrated all over the world. This is a very important mathematical constant equal to the ratio of the circumference of a circle to its diameter.\n\nPolycarp was told at schoo...
[{"type": "stdin_stdout", "input": "9\n000\n3\n4141592653\n141592653589793238462643383279\n31420\n31415\n314159265358\n27182\n314159265358979323846264338327\n", "output": "0\n1\n0\n0\n3\n5\n12\n0\n30\n"}, {"type": "stdin_stdout", "input": "3\n314\n315\n314\n", "output": "3\n2\n3\n"}, {"type": "stdin_stdout", "input": "...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nShubham has an array $a$ of size $n$, and wants to select exactly $x$ elements from it, such that their sum is odd. These elements do not have to be consecutive. The elements of the array are not guaranteed to be distinct...
[{"type": "stdin_stdout", "input": "4\n3 1\n16 11 12\n10 3\n13 12 9 1 9 8 4 19 16 19\n3 2\n3 2 6\n9 7\n11 14 1 6 3 12 3 20 16\n", "output": "Yes\nYes\nYes\nYes\n"}, {"type": "stdin_stdout", "input": "4\n3 1\n16 11 12\n10 3\n13 12 9 1 9 8 4 19 16 19\n3 2\n3 2 6\n9 7\n11 14 1 6 3 12 3 20 16\n", "output": "YES\nYES\nYES\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThis problem consists of three subproblems: for solving subproblem C1 you will receive 4 points, for solving subproblem C2 you will receive 4 points, and for solving subproblem C3 you will receive 8 points.\n\nManao decid...
[{"type": "stdin_stdout", "input": "40 3\n1 62395\n5 40319\n4 165445\n10 137479\n10 47829\n8 9741\n5 148106\n10 25494\n10 162856\n2 106581\n0 194523\n9 148086\n1 100862\n6 147600\n6 107486\n6 166873\n7 16721\n4 22192\n0 8827\n1 197146\n10 8949\n0 150443\n9 148348\n3 143935\n1 139371\n7 128821\n10 107760\n4 141821\n1 35...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWith the motto \"Creating your own path,\" a shrine created a fortune-telling fortune with its own hands. Ask the person who draws the lottery to throw six stones first, then the line segment connecting the first and seco...
[{"type": "stdin_stdout", "input": "-1 -2 9 6\n3 -2 7 6\n-1 0 9 0\n2 2 0 -1\n1 2 2 0\n-3 -1 3 1\n0 0 0 0", "output": "syo-kichi\nsyo-kichi\n"}, {"type": "stdin_stdout", "input": "-1 -2 22 6\n3 -2 7 10\n-1 0 9 0\n3 2 0 -1\n1 1 2 1\n-3 -1 3 1\n0 0 0 0", "output": "syo-kichi\nkyo\n"}, {"type": "stdin_stdout", "input": "-1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a 4-character string S consisting of uppercase English letters.\nDetermine if S consists of exactly two kinds of characters which both appear twice in S.\n\n-----Constraints-----\n - The length of S is 4.\n ...
[{"type": "stdin_stdout", "input": "ASSA\n", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "FFEE\n", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "AVVA\n", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "HHTT\n", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "ILIL\n", "output": "Yes\n"},...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nUnlike Knights of a Round Table, Knights of a Polygonal Table deprived of nobility and happy to kill each other. But each knight has some power and a knight can kill another knight if and only if his power is greater than...
[{"type": "stdin_stdout", "input": "11 10\n1 2 3 4 5 6 7 8 9 10 11\n1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000\n", "output": "1000000000 2000000000 3000000000 4000000000 5000000000 6000000000 7000000000 8000000000 9000000000 10000000000 11000...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere is a tree T with N vertices, numbered 1 through N. For each 1 ≤ i ≤ N - 1, the i-th edge connects vertices a_i and b_i.\n\nSnuke is constructing a directed graph T' by arbitrarily assigning direction to each edge in...
[{"type": "stdin_stdout", "input": "10\n2 4\n2 5\n8 3\n10 7\n1 7\n2 8\n9 10\n8 6\n10 8", "output": "220\n"}, {"type": "stdin_stdout", "input": "10\n1 4\n2 5\n1 3\n10 1\n1 6\n4 8\n9 8\n7 10\n10 2", "output": "122\n"}, {"type": "stdin_stdout", "input": "10\n2 4\n2 5\n2 3\n10 7\n1 6\n2 10\n9 5\n8 7\n10 6", "output": "194\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAs you very well know, the whole Universe traditionally uses three-dimensional Cartesian system of coordinates. In this system each point corresponds to three real coordinates (x, y, z). In this coordinate system, the dis...
[{"type": "stdin_stdout", "input": "1\n1000 1010 1000\n", "output": "0.33222591362126247 0.33554817275747506 0.33222591362126247\n"}, {"type": "stdin_stdout", "input": "1\n1000 1011 1000\n", "output": "0.33211557622052473 0.33576884755895053 0.33211557622052473\n"}, {"type": "stdin_stdout", "input": "1000\n1319 1000 99...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nRational numbers are numbers represented by ratios of two integers. For a prime number p, one of the elementary theorems in the number theory is that there is no rational number equal to √p. Such numbers are called irrati...
[{"type": "stdin_stdout", "input": "2 10\n5 10\n19 111\n0 0", "output": "10/7 7/5\n9/4 2/1\n109/25 61/14\n"}, {"type": "stdin_stdout", "input": "11 5\n10 10\n5 100\n0 0", "output": "4/1 3/1\n10/3 3/1\n85/38 38/17\n"}, {"type": "stdin_stdout", "input": "2 5\n3 14\n26 111\n0 0", "output": "3/2 4/3\n7/4 12/7\n51/10 107/21...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA lighthouse keeper Peter commands an army of $n$ battle lemmings. He ordered his army to stand in a line and numbered the lemmings from $1$ to $n$ from left to right. Some of the lemmings hold shields. Each lemming canno...
[{"type": "stdin_stdout", "input": "80\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n", "output": "1776 1805 1832 1857 1880 1901 1920 1937 1953 1967 1980 1991 2001 2009 2016 2021 2025 2027 2028 2028 2028 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nChef's new hobby is painting, but he learned the fact that it's not easy to paint 2D pictures in a hard way, after wasting a lot of canvas paper, paint and of course time. From now on, he decided to paint 1D pictures only...
[{"type": "stdin_stdout", "input": "3\n4\n1 5 5 5\n4\n1 1 1 5\n3\n5 5 2\n\n", "output": "Yes\nYes\nNo\n"}, {"type": "stdin_stdout", "input": "3\n4\n1 6 4 -2\n0\n0 9 -1 10\n0\n-1 3 6", "output": "No\nNo\nNo\n"}, {"type": "stdin_stdout", "input": "3\n4\n1 6 4 0\n0\n-1 9 -1 10\n0\n-1 3 6", "output": "No\nNo\nNo\n"}, {"typ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nMr. Takahashi has a string s consisting of lowercase English letters. He repeats the following operation on s exactly K times.\n\n* Choose an arbitrary letter on s and change that letter to the next alphabet. Note that th...
[{"type": "stdin_stdout", "input": "codefestival\n101", "output": "aaaafeaaiaal\n"}, {"type": "stdin_stdout", "input": "cdoeffstival\n101", "output": "aaaaffaaiaal\n"}, {"type": "stdin_stdout", "input": "cdoeffstival\n111", "output": "aaaaafativam\n"}, {"type": "stdin_stdout", "input": "lavitsffeodc\n111", "output": "a...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIt is only six months until Christmas, and AtCoDeer the reindeer is now planning his travel to deliver gifts.\n\nThere are N houses along TopCoDeer street. The i-th house is located at coordinate a_i. He has decided to de...
[{"type": "stdin_stdout", "input": "8\n121 1 -1 -1 -3 3 0 1", "output": "124\n"}, {"type": "stdin_stdout", "input": "8\n0 -4 -1 21 -2 -15 4 2", "output": "36\n"}, {"type": "stdin_stdout", "input": "8\n0 -3 -1 27 -6 -18 4 2", "output": "45\n"}, {"type": "stdin_stdout", "input": "8\n-2 -1 0 1 3 -143 0 1", "output": "146\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nInna is a great piano player and Dima is a modest guitar player. Dima has recently written a song and they want to play it together. Of course, Sereja wants to listen to the song very much. \n\nA song is a sequence of not...
[{"type": "stdin_stdout", "input": "10\n2 2 2 4 10 6 7 16 9 17\n1 2 3 5 5 6 7 8 18 10\n", "output": "157\n"}, {"type": "stdin_stdout", "input": "10\n1 2 0 4 10 4 7 16 9 17\n1 2 3 5 5 6 7 8 18 10\n", "output": "154\n"}, {"type": "stdin_stdout", "input": "10\n1 2 2 4 10 6 7 16 9 17\n1 2 3 5 5 6 7 8 18 10\n", "output": "1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIvan wants to make a necklace as a present to his beloved girl. A necklace is a cyclic sequence of beads of different colors. Ivan says that necklace is beautiful relative to the cut point between two adjacent beads, if t...
[{"type": "stdin_stdout", "input": "20\n19259 5236 2272 7238 560 938 6209 91 1540 2821 35 6097 12593 1092 6181 7553 4095 280 12810 2723\n", "output": "0\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nMany years have passed, and n friends met at a party again. Technologies have leaped forward since the last meeting, cameras with timer appeared and now it is not obligatory for one of the friends to stand with a camera, ...
[{"type": "stdin_stdout", "input": "10\n489 685\n857 870\n736 221\n687 697\n166 360\n265 200\n738 519\n393 760\n66 176\n798 160\n", "output": "3231747\n"}, {"type": "stdin_stdout", "input": "10\n489 685\n857 870\n736 221\n687 697\n166 360\n265 200\n738 519\n393 760\n66 176\n798 160\n", "output": "3231747\n"}, {"type": ...
code_stdio