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\nThe Ohgas are a prestigious family based on Hachioji. The head of the family, Mr. Nemochi Ohga, a famous wealthy man, wishes to increase his fortune by depositing his money to an operation company. You are asked to help M...
[{"type": "stdin_stdout", "input": "4\n1000000\n8\n2\n0 0.7358189007888192 3000\n1 0.17615020446016216 3825\n6620000\n7\n2\n0 0.6920348397011968 48227\n0 0.0740966796875 40942\n56271855\n4\n4\n0 0.19624457693261887 30754\n1 0.00634765625 26165\n0 1.6296802800223897 27575\n0 0.8924194187554844 10932\n6380784\n0\n4\n1 0....
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nComrade Dujikov is busy choosing artists for Timofey's birthday and is recieving calls from Taymyr from Ilia-alpinist.\n\nIlia-alpinist calls every n minutes, i.e. in minutes n, 2n, 3n and so on. Artists come to the comra...
[{"type": "stdin_stdout", "input": "10000 10000 10000\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "10000 10000 10000\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "1 10000 10000\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "10000 1 10000\n", "output": "1\n"}, {"type": "stdin_stdout", "i...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a string S.\n\nTakahashi can insert the character `A` at any position in this string any number of times.\n\nCan he change S into `AKIHABARA`?\n\nConstraints\n\n* 1 \\leq |S| \\leq 50\n* S consists of upperc...
[{"type": "stdin_stdout", "input": "ARAABHAIKAA", "output": "NO\n"}, {"type": "stdin_stdout", "input": "AR@ABHAIKAA", "output": "NO\n"}, {"type": "stdin_stdout", "input": "AR@ABHAIJAA", "output": "NO\n"}, {"type": "stdin_stdout", "input": "AAJIAHBA@RA", "output": "NO\n"}, {"type": "stdin_stdout", "input": "AAIJAHBA@RA"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nBash wants to become a Pokemon master one day. Although he liked a lot of Pokemon, he has always been fascinated by Bulbasaur the most. Soon, things started getting serious and his fascination turned into an obsession. Si...
[{"type": "stdin_stdout", "input": "BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBbbbbbbbbbbbbbbbbbbbbuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuullllllllllllllllllllssssssssssssssssssssaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPari has a friend who loves palindrome numbers. A palindrome number is a number that reads the same forward or backward. For example 12321, 100001 and 1 are palindrome numbers, while 112 and 1021 are not.\n\nPari is tryin...
[{"type": "stdin_stdout", "input": "11635543554796045289140983157483950524203250955411464324183518580611424141988904394156045071683009945\n", "output": "11635543554796045289140983157483950524203250955411464324183518580611424141988904394156045071683009945549900386170540651493409889141424116085815381423464114559052302425...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nProblem Statement\n\nYou want to compete in ICPC (Internet Contest of Point Collection). In this contest, we move around in $N$ websites, numbered $1$ through $N$, within a time limit and collect points as many as possibl...
[{"type": "stdin_stdout", "input": "5 4 10\n4 3 1\n6 4 3\n3 2 4\n2 2 1\n0 5 3\n1 2\n2 1\n3 4\n4 5\n3 3 1000\n1000 2 100\n1 7 100\n10 9 100\n1 2\n1 1\n3 2\n1 0 5\n25 25 2\n1 -1 25\n25 25 2\n5 5 100\n1 1 20\n1 1 20\n10 1 1\n10 1 1\n10 1 0\n1 2\n2 1\n3 4\n4 5\n5 3\n3 3 100\n70 17 10\n50 16 20\n90 10 10\n1 2\n2 2\n2 3\n0 0...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPetya has recently started working as a programmer in the IT city company that develops computer games.\n\nBesides game mechanics implementation to create a game it is necessary to create tool programs that can be used by...
[{"type": "stdin_stdout", "input": "870 396 187 223 444 202 222 732\n", "output": "999.7945324433952405951409048 550.7817151597707949206572664\n699.8933625471825917263579697 538.6454762496719970710223890\n784.9466812735912958354234092 467.3227381248359985355111945\n314.6021379638620081853339627 -93.56941780067005040577...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIn some country there are exactly n cities and m bidirectional roads connecting the cities. Cities are numbered with integers from 1 to n. If cities a and b are connected by a road, then in an hour you can go along this r...
[{"type": "stdin_stdout", "input": "10 11\n1 3\n2 3\n3 4\n4 5\n4 6\n3 7\n3 10\n4 9\n4 10\n7 9\n8 10\n1 1 3\n6 2 3\n", "output": "8\n"}, {"type": "stdin_stdout", "input": "10 11\n1 3\n2 3\n3 4\n4 5\n4 6\n3 7\n3 10\n4 9\n4 10\n7 9\n8 10\n1 1 3\n6 2 5\n", "output": "8\n"}, {"type": "stdin_stdout", "input": "10 11\n1 3\n2 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given an infinite checkered field. You should get from a square (x1; y1) to a square (x2; y2). Using the shortest path is not necessary. You can move on the field squares in four directions. That is, when you are ...
[{"type": "stdin_stdout", "input": "999999999 1000000000 1000000000 -999999999 -1000000000 999999999\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "101304499 148554333 -590787464 -890180401 -117457421 997140710\n", "output": "12\n"}, {"type": "stdin_stdout", "input": "1000000000 1000000000 871940474 991768763...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAfter a successful year of milk production, Farmer John is rewarding his cows with their favorite treat: tasty grass!\n\nOn the field, there is a row of n units of grass, each with a sweetness s_i. Farmer John has m cows,...
[{"type": "stdin_stdout", "input": "20 8\n7 4 9 6 4 10 5 12 6 13 20 16 11 1 12 10 11 2 3 18\n6 1\n20 4\n10 6\n2 9\n10 17\n13 19\n1 5\n3 1\n", "output": "2 3"}, {"type": "stdin_stdout", "input": "20 8\n7 4 9 6 4 10 5 12 6 13 20 2 11 1 12 10 11 2 3 18\n6 1\n20 4\n10 6\n2 9\n10 17\n13 19\n1 5\n3 1\n", "output": "2 3"}, {"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are N people, conveniently numbered 1 through N.\nThey were standing in a row yesterday, but now they are unsure of the order in which they were standing.\nHowever, each person remembered the following fact: the abs...
[{"type": "stdin_stdout", "input": "8\n7 5 1 1 7 3 5 3\n", "output": "16\n"}, {"type": "stdin_stdout", "input": "7\n-10 4 1 -2 3 -2 1", "output": "0\n"}, {"type": "stdin_stdout", "input": "7\n-10 4 1 -2 3 -2 0", "output": "0\n"}, {"type": "stdin_stdout", "input": "7\n-20 4 1 -2 3 -2 0", "output": "0\n"}, {"type": "stdi...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nChef loves research! Now he is looking for subarray of maximal length with non-zero product.\nChef has an array A with N elements: A1, A2, ..., AN. \n\nSubarray Aij of array A is elements from index i to index j: Ai, Ai+1...
[{"type": "stdin_stdout", "input": "6\n1 0 2 3 0 4\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "6\n-1 0 2 3 0 6", "output": "2\n"}, {"type": "stdin_stdout", "input": "6\n-1 0 4 3 0 6", "output": "2\n"}, {"type": "stdin_stdout", "input": "6\n-1 0 4 4 0 6", "output": "2\n"}, {"type": "stdin_stdout", "input": ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nFormula One championship consists of series of races called Grand Prix. After every race drivers receive points according to their final position. Only the top 10 drivers receive points in the following order 25, 18, 15, ...
[{"type": "stdin_stdout", "input": "1\n50\nJamesHunt\nNakajima\nHakkinen\nScheckter\nJones\nHill\nHawthorn\nVettel\nHulkenberg\nSutil\nGlock\nWebber\nAlbertoAscari\nMensel\nBuemi\nKubica\ndiGrassi\nJimClark\nKovalainen\nTrulli\nBarichelo\nSurtees\nJackieStewert\nLauda\nRaikkonen\nVilleneuve\nFangio\nButton\nDeLaRosa\nP...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nShubham has a binary string $s$. A binary string is a string containing only characters \"0\" and \"1\".\n\nHe can perform the following operation on the string any amount of times: Select an index of the string, and fl...
[{"type": "stdin_stdout", "input": "18\n010\n100100011010\n001\n010101\n101\n1100111101101110\n101100\n0001100101001100\n111110101100\n01100\n0110111100\n110101\n10000011001010010001\n0011\n00001010110100000101\n11011101110\n011000011101000010\n1001111110001000\n", "output": "1\n4\n0\n2\n1\n4\n1\n6\n2\n1\n2\n2\n6\n0\n6...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a string $s$ consisting of the characters '0', '1', and '?'. You need to replace all the characters with '?' in the string $s$ by '0' or '1' so that the string becomes a palindrome and has exactly $a$ charac...
[{"type": "stdin_stdout", "input": "9\n4 4\n0????1?0\n3 3\n??????\n1 0\n?\n2 2\n1001\n2 2\n01?0\n0 1\n0\n0 3\n?11\n2 2\n?00?\n4 3\n??010?0\n", "output": "00111100\n-1\n0\n1001\n0110\n-1\n111\n1001\n0101010\n"}, {"type": "stdin_stdout", "input": "9\n4 4\n0?????10\n3 3\n??????\n1 0\n?\n2 2\n0110\n2 2\n01?0\n0 1\n0\n0 3\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nCucumber boy is fan of Kyubeat, a famous music game.\n\nKyubeat has 16 panels for playing arranged in 4 × 4 table. When a panel lights up, he has to press that panel.\n\nEach panel has a timing to press (the preffered tim...
[{"type": "stdin_stdout", "input": "4\n15168\n..7.\n.7..\n7...\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "1\n.135\n1247\n3468\n5789\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "5\n..1.\n1111\n..1.\n..1.\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "1\n....\n....\n....\n....\n"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nRead problems statements in Mandarin Chinese and Russian as well. \n\n\tMike is given an undirected graph G of N vertices and M edges. A non-negative integer X_{i} is assigned to the i'th vertex of G, for 1 ≤ i ≤ N.\n\n\t...
[{"type": "stdin_stdout", "input": "11 0 1\n3 4 1\n3 1 9\n0 15 0\n3 4 1", "output": "0 0 0 0 0 0 0 0 0 0 0\n"}, {"type": "stdin_stdout", "input": "10 0 0\n2 4 9\n6 1 1\n0 0 0\n-1 10 1", "output": "0 0 0 0 0 0 0 0 0 -1\n"}, {"type": "stdin_stdout", "input": "10 0 1\n4 4 9\n3 1 8\n0 8 0\n4 10 1", "output": "0 0 0 0 0 0 0...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are $n$ persons located on a plane. The $i$-th person is located at the point $(x_i, y_i)$ and initially looks at the point $(u_i, v_i)$.\n\nAt the same moment of time, all persons will start to rotate clockwise syn...
[{"type": "stdin_stdout", "input": "2\n2\n1000000000 1000000000 -1000000000 -1685444969\n-1000000000 -1073004450 1000010100 1000100000\n2\n1100000000 1000000000 -1000000000 -1742607922\n-1854126016 -1929941902 1000000000 1000000000\n", "output": "0\n0\n"}, {"type": "stdin_stdout", "input": "2\n2\n1000000000 1000000000 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSelection of Participants of an Experiment\n\nDr. Tsukuba has devised a new method of programming training. In order to evaluate the effectiveness of this method, he plans to carry out a control experiment. Having two stu...
[{"type": "stdin_stdout", "input": "5\n10 0 1 10 14\n5\n1 5 25 9 11\n7\n10 20 83 43 143 31 62\n0", "output": "0\n2\n10\n"}, {"type": "stdin_stdout", "input": "5\n10 10 10 10 10\n5\n1 5 8 9 11\n7\n11 34 83 47 44 29 70\n0", "output": "0\n1\n3\n"}, {"type": "stdin_stdout", "input": "5\n10 10 10 1 10\n5\n1 5 8 13 11\n7\n11...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nTakahashi is a teacher responsible for a class of N students.\nThe students are given distinct student numbers from 1 to N.\nToday, all the students entered the classroom at different times.\nAccording to Takahashi's reco...
[{"type": "stdin_stdout", "input": "91\n13 42 58 64 76 15 46 37 62 71 25 14 3 61 2 75 44 45 65 74 79 48 41 72 1 10 73 8 63 83 47 36 40 33 87 7 23 38 54 28 60 29 35 57 80 5 11 43 66 50 30 21 12 20 19 51 27 82 69 70 4 68 89 78 17 18 67 26 91 56 9 53 49 32 6 39 84 22 88 59 55 86 24 34 81 85 52 77 31 90 16\n", "output": "2...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given an integer $n$.\n\nYou can perform any of the following operations with this number an arbitrary (possibly, zero) number of times: Replace $n$ with $\\frac{n}{2}$ if $n$ is divisible by $2$; Replace $n$ w...
[{"type": "stdin_stdout", "input": "7\n1\n14\n73\n30\n14\n39\n1000000000000000000\n", "output": "0\n-1\n-1\n6\n-1\n-1\n72\n"}, {"type": "stdin_stdout", "input": "7\n1\n7\n73\n52\n14\n39\n1000000000000000000\n", "output": "0\n-1\n-1\n-1\n-1\n-1\n72\n"}, {"type": "stdin_stdout", "input": "7\n1\n14\n73\n30\n14\n27\n100000...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAfter a long day, Alice and Bob decided to play a little game. The game board consists of $n$ cells in a straight line, numbered from $1$ to $n$, where each cell contains a number $a_i$ between $1$ and $n$. Furthermore, n...
[{"type": "stdin_stdout", "input": "40\n5 40 6 27 39 37 17 34 3 30 28 13 12 8 11 10 31 4 1 16 38 22 29 35 33 23 7 9 24 14 18 26 19 21 15 36 2 20 32 25\n", "output": "ABABBBABABAAAAAABAAABBBBBBAAAABABBABABBB\n"}, {"type": "stdin_stdout", "input": "40\n5 40 6 27 39 37 17 34 3 30 28 13 12 8 11 10 31 4 1 16 38 22 29 35 33 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nFactorize a given integer n.\n\nConstraints\n\n* 2 ≤ n ≤ 109\n\nInput\n\n\nn\n\n\nAn integer n is given in a line.\n\nOutput\n\nPrint the given integer n and :. Then, print prime factors in ascending order. If n is divisi...
[{"type": "stdin_stdout", "input": "128", "output": "128: 2 2 2 2 2 2 2\n"}, {"type": "stdin_stdout", "input": "216", "output": "216: 2 2 2 3 3 3\n"}, {"type": "stdin_stdout", "input": "64", "output": "64: 2 2 2 2 2 2\n"}, {"type": "stdin_stdout", "input": "112", "output": "112: 2 2 2 2 7\n"}, {"type": "stdin_stdout", ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are n people taking part in auction today. The rules of auction are classical. There were n bids made, though it's not guaranteed they were from different people. It might happen that some people made no bids at all...
[{"type": "stdin_stdout", "input": "5\n3 4\n1 14\n4 20\n3 22\n5 28\n31\n1 1\n1 2\n2 1 2\n1 3\n2 1 3\n2 2 3\n3 1 2 3\n1 4\n2 1 4\n2 2 4\n3 1 2 4\n2 3 4\n3 1 3 4\n3 2 3 4\n4 1 2 3 4\n1 5\n2 1 5\n2 2 5\n3 1 2 5\n2 3 5\n3 1 3 5\n3 2 3 5\n4 1 2 3 5\n2 4 5\n3 1 4 5\n3 2 4 5\n4 1 2 4 5\n3 3 4 5\n4 1 3 4 5\n4 2 3 4 5\n5 1 2 3 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given an array $a$ consisting of $n$ non-negative integers. You have to choose a non-negative integer $x$ and form a new array $b$ of size $n$ according to the following rule: for all $i$ from $1$ to $n$, $b_i = a...
[{"type": "stdin_stdout", "input": "100\n74 88 64 8 9 27 63 64 79 97 92 38 26 1 4 4 2 64 53 62 24 82 76 40 48 58 40 59 3 56 35 37 0 30 93 71 14 97 49 37 96 59 56 55 70 88 77 99 51 55 71 25 10 31 26 50 61 18 35 55 49 33 86 25 65 74 89 99 5 27 2 9 67 29 76 68 66 22 68 59 63 16 62 25 35 57 63 35 41 68 86 22 91 67 61 3 92 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA schoolboy named Vasya loves reading books on programming and mathematics. He has recently read an encyclopedia article that described the method of median smoothing (or median filter) and its many applications in scienc...
[{"type": "stdin_stdout", "input": "168\n0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 1 0 1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 0 1 0 1 0 1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIn 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 n...
[{"type": "stdin_stdout", "input": "100\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIn Takahashi Kingdom, which once existed, there are N cities, and some pairs of cities are connected bidirectionally by roads.\nThe following are known about the road network:\n - People traveled between cities only throu...
[{"type": "stdin_stdout", "input": "3\n0 1000000000 1000000000\n1000000000 0 1000000000\n1000000000 1000000000 0\n", "output": "3000000000\n"}, {"type": "stdin_stdout", "input": "3\n0 1000000000 1000000000\n1000000000 0 1000000000\n1000000000 1000000000 0", "output": "3000000000"}, {"type": "stdin_stdout", "input": "5\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nNow that Chef has finished baking and frosting his cupcakes, it's time to package them. Chef has N cupcakes, and needs to decide how many cupcakes to place in each package. Each package must contain the same number of cup...
[{"type": "stdin_stdout", "input": "2\n2\n137", "output": "2\n69\n"}, {"type": "stdin_stdout", "input": "2\n14\n35", "output": "8\n18\n"}, {"type": "stdin_stdout", "input": "2\n16\n35", "output": "9\n18\n"}, {"type": "stdin_stdout", "input": "2\n12\n35", "output": "7\n18\n"}, {"type": "stdin_stdout", "input": "2\n7\n26...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nDisclaimer: there are lots of untranslateable puns in the Russian version of the statement, so there is one more reason for you to learn Russian :)\n\nRick and Morty like to go to the ridge High Cry for crying loudly — th...
[{"type": "stdin_stdout", "input": "228\n1 3 1 7 1 3 1 15 1 3 1 7 1 3 1 31 1 3 1 7 1 3 1 15 1 3 1 7 1 3 1 63 1 3 1 7 1 3 1 15 1 3 1 7 1 3 1 31 1 3 1 7 1 3 1 15 1 3 1 7 1 3 1 127 1 3 1 7 1 3 1 15 1 3 1 7 1 3 1 31 1 3 1 7 1 3 1 15 1 3 1 7 1 3 1 63 1 3 1 7 1 3 1 15 0 3 1 13 1 3 1 31 1 3 1 7 1 3 1 15 1 3 1 7 1 3 1 255 1 3 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA frog is about to return to the burrow. The burrow is D centimeters ahead of the frog, and the frog goes straight toward the burrow. There are only two actions that a frog can do:\n\n* Large jump (go forward L centimeter...
[{"type": "stdin_stdout", "input": "115 172", "output": "115\n"}, {"type": "stdin_stdout", "input": "135 191", "output": "135\n"}, {"type": "stdin_stdout", "input": "170 176", "output": "170\n"}, {"type": "stdin_stdout", "input": "208 133", "output": "76\n"}, {"type": "stdin_stdout", "input": "194 102", "output": "93\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAlexandra has a paper strip with n numbers on it. Let's call them ai from left to right.\n\nNow Alexandra wants to split it into some pieces (possibly 1). For each piece of strip, it must satisfy:\n\n * Each piece should...
[{"type": "stdin_stdout", "input": "2 1000000000 2\n-1000000000 1000000000\n", "output": "-1\n"}, {"type": "stdin_stdout", "input": "2 1000000000 1\n-1000000000 1000000000\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "2 1000000000 4\n-1000000000 1000000000\n", "output": "-1"}, {"type": "stdin_stdout", "input...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nProblem\n\nThe popular video posting site \"ZouTube\" is now in the midst of an unprecedented \"virtual ZouTuber\" boom. Among them, the one that has been attracting particular attention recently is the junior virtual Zou...
[{"type": "stdin_stdout", "input": "110000", "output": "110000\n"}, {"type": "stdin_stdout", "input": "100010", "output": "100000\n"}, {"type": "stdin_stdout", "input": "121470", "output": "121000\n"}, {"type": "stdin_stdout", "input": "101101", "output": "101000\n"}, {"type": "stdin_stdout", "input": "113193", "output...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThis morning Chef wants to jump a little. In a few minutes he will arrive at the point 0. Then he will perform a lot of jumps in such a sequence: 1-jump, 2-jump, 3-jump, 1-jump, 2-jump, 3-jump, 1-jump, and so on.\n1-jump ...
[{"type": "stdin_stdout", "input": "-114", "output": "yes\n"}, {"type": "stdin_stdout", "input": "-138", "output": "yes\n"}, {"type": "stdin_stdout", "input": "-119", "output": "yes\n"}, {"type": "stdin_stdout", "input": "-17", "output": "yes\n"}, {"type": "stdin_stdout", "input": "-11", "output": "yes\n"}, {"type": "s...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIahub is a big fan of tourists. He wants to become a tourist himself, so he planned a trip. There are n destinations on a straight road that Iahub wants to visit. Iahub starts the excursion from kilometer 0. The n destina...
[{"type": "stdin_stdout", "input": "50\n3987477 8934938 4067156 6712855 7269334 5039822 9533601 9335400 5992073 2619268 438734 8620973 4347619 4307947 2249161 815221 7615258 8244100 8341666 5908546 6646952 4812769 6215114 7479369 6290438 5623785 6466133 9953199 3525873 4326034 3510072 8117068 2342953 1717542 9766539 65...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a multiset (i. e. a set that can contain multiple equal integers) containing $2n$ integers. Determine if you can split it into exactly $n$ pairs (i. e. each element should be in exactly one pair) so that the...
[{"type": "stdin_stdout", "input": "2\n28\n15 72 79 36 2 43 100 11 236 94 76 83 90 20 58 39 47 57 37 88 92 92 59 80 97 22 20 47 9 88 21 82 94 71 25 38 45 51 23 76 58 5 39 11 15 9 11 24 9 84 90 58 0 37 54 65\n43\n79 24 82 7 26 19 63 22 94 22 4 72 19 5 92 92 83 93 35 19 45 87 40 61 58 65 21 48 96 85 63 100 86 63 30 50 58...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPolycarpus has an array, consisting of n integers a_1, a_2, ..., a_{n}. Polycarpus likes it when numbers in an array match. That's why he wants the array to have as many equal numbers as possible. For that Polycarpus perf...
[{"type": "stdin_stdout", "input": "100\n968 793 -628 -416 942 -308 977 168 728 -879 952 781 -425 -475 -480 738 -740 142 -319 -116 -701 -183 41 324 -918 -391 -176 781 763 888 475 -617 134 -802 -133 -211 855 -869 -236 503 550 387 137 -221 -957 -800 -56 -673 440 -791 -217 -959 -892 886 -593 427 890 223 -425 -342 -262 693...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nMasha has $n$ types of tiles of size $2 \\times 2$. Each cell of the tile contains one integer. Masha has an infinite number of tiles of each type.\n\nMasha decides to construct the square of size $m \\times m$ consisting...
[{"type": "stdin_stdout", "input": "6\n3 4\n1 2\n5 6\n5 7\n7 4\n8 9\n9 8\n2 5\n1 1\n1 1\n2 2\n2 2\n1 100\n10 10\n10 10\n1 2\n4 5\n8 4\n2 2\n1 1\n1 1\n1 2\n3 4\n1 2\n1 1\n1 1\n", "output": "YES\nNO\nYES\nNO\nYES\nYES\n"}, {"type": "stdin_stdout", "input": "6\n3 4\n0 2\n5 6\n5 7\n7 4\n8 9\n9 8\n2 5\n1 1\n1 1\n2 2\n2 2\n1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nMary has just graduated from one well-known University and is now attending celebration party. Students like to dream of a beautiful life, so they used champagne glasses to construct a small pyramid. The height of the pyr...
[{"type": "stdin_stdout", "input": "10 10000\n", "output": "55\n"}, {"type": "stdin_stdout", "input": "10 10000\n", "output": "55\n"}, {"type": "stdin_stdout", "input": "10 1022\n", "output": "53\n"}, {"type": "stdin_stdout", "input": "10 1023\n", "output": "55\n"}, {"type": "stdin_stdout", "input": "10 1024\n", "outpu...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\n\"Pizza At\", a fast food chain, offers three kinds of pizza: \"A-pizza\", \"B-pizza\" and \"AB-pizza\". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza com...
[{"type": "stdin_stdout", "input": "1500 2000 500 90000 100000\n", "output": "100000000\n"}, {"type": "stdin_stdout", "input": "1143 3132 1087 90000 100000", "output": "217400000\n"}, {"type": "stdin_stdout", "input": "1500 2445 500 90000 100000", "output": "100000000\n"}, {"type": "stdin_stdout", "input": "1500 3132 7...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSnuke had N cards numbered 1 through N.\nEach card has an integer written on it; written on Card i is a_i.\nSnuke did the following procedure:\n - Let X and x be the maximum and minimum values written on Snuke's cards, re...
[{"type": "stdin_stdout", "input": "7961\n570641734 802212645 776309598 809873412 803841293 359931843 792939994 233099102 401692872 600486353 217303985 108107734 560874418 799955982 883190766 630019949 636623822 273032982 235540677 331099668 777155291 724397459 613181400 534080974 922902142 15555595 732730818 469781636...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nBaby Ehab was toying around with arrays. He has an array $a$ of length $n$. He defines an array to be good if there's no way to partition it into $2$ subsequences such that the sum of the elements in the first is equal to...
[{"type": "stdin_stdout", "input": "100\n2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYui Hirasawa, who attends private Sakuragaoka Girls' High School, has to make a career hope by the day after tomorrow, but the trouble is that she hasn't decided anything yet. When I consulted with my friend Wa, I knew th...
[{"type": "stdin_stdout", "input": "3\n49 128 67 78 41\n29 59 100 45 84\n50 36 40 95 66\n2\n100 000 100 100 110\n0 0 -1 0 0\n1\n89 90 85 120 82\n0", "output": "363 287\n410 -1\n466 466\n"}, {"type": "stdin_stdout", "input": "3\n49 128 67 78 19\n29 59 100 45 84\n50 36 40 95 66\n2\n100 000 100 100 110\n0 0 -1 0 0\n1\n89 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are N people numbered 1 to N. Each person wears a red hat or a blue hat.\n\nYou are given a string s representing the colors of the people. Person i wears a red hat if s_i is `R`, and a blue hat if s_i is `B`.\n\nDe...
[{"type": "stdin_stdout", "input": "4\nRBRR", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "4\nRRCR", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "4\nRRAR", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "4\nRARR", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "4\nRCRR", "output": "Yes...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nDuring cleaning the coast, Alice found $n$ piles of stones. The $i$-th pile has $a_i$ stones.\n\nPiles $i$ and $i + 1$ are neighbouring for all $1 \\leq i \\leq n - 1$. If pile $i$ becomes empty, piles $i - 1$ and $i + 1$...
[{"type": "stdin_stdout", "input": "5\n3\n1 2 1\n3\n1 1 2\n5\n2 2 2 1 3\n5\n2100 1900 1600 3000 1600\n2\n2443 2445\n", "output": "\nYES\nYES\nYES\nYES\nNO\n"}, {"type": "stdin_stdout", "input": "5\n3\n1 2 1\n3\n1 1 2\n5\n2 2 2 1 3\n5\n2100 1900 1600 3000 1600\n2\n2443 2445\n", "output": "YES\nYES\nYES\nYES\nNO\n"}, {"t...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIn the building of Jewelry Art Gallery (JAG), there is a long corridor in the east-west direction. There is a window on the north side of the corridor, and $N$ windowpanes are attached to this window. The width of each wi...
[{"type": "stdin_stdout", "input": "8 10 18\n2 12 16 14 18 4 17 10", "output": "430\n"}, {"type": "stdin_stdout", "input": "8 10 18\n2 12 16 14 18 6 17 10", "output": "410\n"}, {"type": "stdin_stdout", "input": "8 10 18\n2 12 16 14 18 4 17 11", "output": "420\n"}, {"type": "stdin_stdout", "input": "8 10 18\n2 12 18 14 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAt the pancake shop you work for, pancake dough is lined up in a row on an elongated iron plate and baked. Pancakes can be completed by turning them over with a spatula several times. How many times you turn it over to co...
[{"type": "stdin_stdout", "input": "3\n5 4423 -1", "output": "8846\n"}, {"type": "stdin_stdout", "input": "3\n4 1618 1", "output": "3236\n"}, {"type": "stdin_stdout", "input": "3\n4 2801 1", "output": "5602\n"}, {"type": "stdin_stdout", "input": "3\n5 4573 2", "output": "9146\n"}, {"type": "stdin_stdout", "input": "3\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a convex polygon P with n distinct vertices p_1, p_2, ..., p_{n}. Vertex p_{i} has coordinates (x_{i}, y_{i}) in the 2D plane. These vertices are listed in clockwise order.\n\nYou can choose a real number D ...
[{"type": "stdin_stdout", "input": "19\n449447997 711296339\n530233434 692216537\n535464528 613140435\n535533467 100893188\n530498867 -265063956\n519107979 -271820709\n482156929 -287792333\n-303730271 -287970295\n-416935204 -263348201\n-443613873 -249980523\n-453444829 -173903413\n-462102798 -80789280\n-462064673 -1322...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nTakahashi loves takoyaki - a ball-shaped snack.\nWith a takoyaki machine, he can make at most X pieces of takoyaki at a time, taking T minutes regardless of the number of pieces to make.\nHow long does it take to make N t...
[{"type": "stdin_stdout", "input": "1000 1 1000\n", "output": "1000000\n"}, {"type": "stdin_stdout", "input": "999 10 1000\n", "output": "100000\n"}, {"type": "stdin_stdout", "input": "1000 1 1100", "output": "1100000\n"}, {"type": "stdin_stdout", "input": "1010 1 1100", "output": "1111000\n"}, {"type": "stdin_stdout",...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nVova, the Ultimate Thule new shaman, wants to build a pipeline. As there are exactly n houses in Ultimate Thule, Vova wants the city to have exactly n pipes, each such pipe should be connected to the water supply. A pipe ...
[{"type": "stdin_stdout", "input": "499999998500000001 1000000000\n", "output": "999955279\n"}, {"type": "stdin_stdout", "input": "499999998500000000 1000000000\n", "output": "999955279\n"}, {"type": "stdin_stdout", "input": "499999999500000000 1000000000\n", "output": "999999998\n"}, {"type": "stdin_stdout", "input": ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nMr. A is planning to travel alone on a highway bus (hereinafter referred to as \"bus\") during his high school holidays. First, Mr. A chose the town he wanted to visit the most and made it his destination. Next, you have ...
[{"type": "stdin_stdout", "input": "1 3 3 1 3\n1 3 2000\n1 2 1000\n2 3 1001\n2 3 3 1 3\n1 3 2300\n1 2 1000\n2 3 1200\n2 6 6 5 1\n1 2 1500\n1 3 4500\n2 6 2000\n5 4 1000\n6 4 2200\n3 5 3000\n0 0 0 0 0", "output": "1000\n1100\n3750\n"}, {"type": "stdin_stdout", "input": "1 3 3 1 3\n1 3 2000\n1 2 1000\n2 3 1001\n2 3 3 1 3\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLet A = {a1, a2, ..., an} be any permutation of the first n natural numbers {1, 2, ..., n}. You are given a positive integer k and another sequence B = {b1, b2, ..., bn}, where bi is the number of elements aj in A to the ...
[{"type": "stdin_stdout", "input": "130 32\n72 56 81 71 45 17 65 13 87 22 17 75 72 80 68 76 62 35 14 53 49 72 19 55 10 57 28 35 66 59 45 24 37 65 46 31 34 1 30 12 37 13 40 41 39 6 31 28 30 0 2 7 23 32 0 34 21 0 23 3 18 33 7 6 20 19 21 10 27 28 19 23 5 15 22 13 14 1 3 14 0 5 1 14 0 0 7 11 10 1 1 1 6 5 3 3 0 1 0 0 0 0 0 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nI decided to create a program that displays a \"round and round pattern\". The \"round and round pattern\" is as follows.\n\n* If the length of one side is n, it is displayed as a character string with n rows and n column...
[{"type": "stdin_stdout", "input": "2\n9\n64", "output": "#########\n# #\n# ##### #\n# # # #\n# # # # #\n# # # # #\n# # ### #\n# # #\n# #######\n\n################################################################\n# #\n# ###########################...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA multi-subject competition is coming! The competition has $m$ different subjects participants can choose from. That's why Alex (the coach) should form a competition delegation among his students. \n\nHe has $n$ candidate...
[{"type": "stdin_stdout", "input": "19 2\n1 2\n1 -3\n1 -1\n1 -2\n2 0\n1 -2\n1 -3\n2 -2\n2 -4\n2 -3\n2 0\n1 2\n1 -1\n1 -2\n1 -3\n1 -4\n2 2\n1 1\n1 -4\n", "output": "7\n"}, {"type": "stdin_stdout", "input": "19 2\n1 2\n1 -3\n1 -1\n1 -2\n2 0\n1 -2\n1 -3\n2 -2\n2 -4\n2 -3\n2 0\n1 2\n1 -1\n1 -2\n1 -3\n1 -4\n2 2\n1 1\n1 -4\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIn the city, there are two pastry shops. One shop was very popular because its cakes are pretty tasty. However, there was a man who is displeased at the shop. He was an owner of another shop. Although cause of his shop's ...
[{"type": "stdin_stdout", "input": "2\n-1\n3\n26 4 2\n0", "output": "-1\n16\n"}, {"type": "stdin_stdout", "input": "2\n-1\n3\n26 4 1\n0", "output": "-1\n15\n"}, {"type": "stdin_stdout", "input": "2\n-1\n4\n1 -1 1\n0", "output": "-1\n0\n"}, {"type": "stdin_stdout", "input": "2\n1\n54\n13 9 10\n0", "output": "1\n0\n"}, {...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are an all-powerful being and you have created a rectangular world. In fact, your world is so bland that it could be represented by a $r \\times c$ grid. Each cell on the grid represents a country. Each country has a ...
[{"type": "stdin_stdout", "input": "4\n7 8\nAAP@AABA\nPPPPAAAA\nPPPPAAAA\nAPAAPPPP\nAPAPPAPP\nAAAAPPAP\nAAAAPPAA\n6 5\nAAAAA\nAAAAA\nAAPAA\nAAPAP\nAAAPP\nAAAOP\n4 4\nPPPP\nPPPP\nPPPP\nPPPP\n1 4\nPPPP\nPA@P\nPPPP\n", "output": "2\n1\nMORTAL\nMORTAL\n"}, {"type": "stdin_stdout", "input": "4\n7 8\nAAPAAAAA\nPPPPAAAA\nPPPP...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nVasya has found a strange device. On the front panel of a device there are: a red button, a blue button and a display showing some positive integer. After clicking the red button, device multiplies the displayed number by...
[{"type": "stdin_stdout", "input": "9999 10000\n", "output": "5000\n"}, {"type": "stdin_stdout", "input": "9999 10000\n", "output": "5000\n"}, {"type": "stdin_stdout", "input": "9998 10000\n", "output": "4999\n"}, {"type": "stdin_stdout", "input": "9998 10000\n", "output": "4999\n"}, {"type": "stdin_stdout", "input": "...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWe have a sequence of length N consisting of non-negative integers. Consider performing the following operation on this sequence until the largest element in this sequence becomes N-1 or smaller. (The operation is the sam...
[{"type": "stdin_stdout", "input": "10\n1000 193 256 777 -1 3 2173 4898286181422 34 221", "output": "4898286186026\n"}, {"type": "stdin_stdout", "input": "10\n1000 193 256 777 -2 3 1355 4898286181422 34 224", "output": "4898286185212\n"}, {"type": "stdin_stdout", "input": "10\n1000 193 256 777 -2 3 2159 4898286181422 3...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a sequence of $n$ integers $a_1, a_2, \\ldots, a_n$.\n\nYou have to construct two sequences of integers $b$ and $c$ with length $n$ that satisfy: for every $i$ ($1\\leq i\\leq n$) $b_i+c_i=a_i$ $b$ is non-...
[{"type": "stdin_stdout", "input": "6\n-18 -12 -9 -10 -6 4\n3\n1 6 -9\n1 3 -10\n6 6 -3\n", "output": "3\n-2\n-2\n-4\n"}, {"type": "stdin_stdout", "input": "6\n-9 -12 -9 -6 -6 4\n3\n1 6 -9\n1 2 -10\n4 6 -3\n", "output": "4\n-1\n-1\n-2\n"}, {"type": "stdin_stdout", "input": "6\n-9 -12 -9 -10 -6 4\n3\n1 6 -9\n1 3 -10\n6 6...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nMultiplication of Big Integers II\n\nGiven two integers $A$ and $B$, compute the product, $A \\times B$.\n\nInput\n\nTwo integers $A$ and $B$ separated by a space character are given in a line.\n\nOutput\n\nPrint the prod...
[{"type": "stdin_stdout", "input": "-15 87", "output": "-1305\n"}, {"type": "stdin_stdout", "input": "-81 -15", "output": "1215\n"}, {"type": "stdin_stdout", "input": "-1 -111", "output": "111\n"}, {"type": "stdin_stdout", "input": "-23 -15", "output": "345\n"}, {"type": "stdin_stdout", "input": "-46 -15", "output": "6...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe marmots have prepared a very easy problem for this year's HC^2 – this one. It involves numbers n, k and a sequence of n positive integers a_1, a_2, ..., a_{n}. They also came up with a beautiful and riveting story for...
[{"type": "stdin_stdout", "input": "100 60\n1443 3849 6174 8249 696 8715 3461 9159 4468 2496 3044 2301 2437 7559 7235 7956 8959 2036 4399 9595 8664 9743 7688 3730 3705 1203 12615 7088 8563 3860 2794 8014 6951 1160 8616 970 9885 2421 17193 4885 5246 6146 8849 5141 8602 9486 7257 3300 8323 4797 4082 7135 80 9622 4543 656...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nzscoder loves simple strings! A string t is called simple if every pair of adjacent characters are distinct. For example ab, aba, zscoder are simple whereas aa, add are not simple.\n\nzscoder is given a string s. He wants...
[{"type": "stdin_stdout", "input": "rxxxrrxrxxxxxrrrrrxxxxrrrrxrxxrxxrxrxrrrxrrxrrxrxxxrxrrxrrxrxrxxxxxrxxxxrrrxrxxrxxrxxxrrrrrxrrxrrxrr\n", "output": "rxaxraxrxaxaxrararxaxararaxrxarxarxrxrarxraxraxrxaxrxraxraxrxrxaxaxrxaxararxrxarxarxaxrararxraxraxra\n"}, {"type": "stdin_stdout", "input": "xxxxrrxrxxxxxrrrrrxxxxrrrrx...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given two integers n and d. You need to construct a rooted binary tree consisting of n vertices with a root at the vertex 1 and the sum of depths of all vertices equals to d.\n\nA tree is a connected graph without...
[{"type": "stdin_stdout", "input": "9\n6 9\n5 7\n4 6\n4 4\n612 4624\n53 311\n8 25\n3 3\n6 11\n", "output": "YES\n1 1 2 2 4 \nYES\n1 1 2 4 \nYES\n1 2 3 \nYES\n1 1 2 \nYES\n1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23 24 24 25 25 26 26 27 27 28 28...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nDuring a normal walk in the forest, Katie has stumbled upon a mysterious code! However, the mysterious code had some characters unreadable. She has written down this code as a string c consisting of lowercase English char...
[{"type": "stdin_stdout", "input": "********************************************************************************************************************************************************************************************************************************************************************************************...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nproblem\n\nTaro often shop at JOI general stores. At JOI general stores, there are enough coins of 500 yen, 100 yen, 50 yen, 10 yen, 5 yen, and 1 yen, and we always pay the change so that the number of coins is the smalle...
[{"type": "stdin_stdout", "input": "380\n-48\n0", "output": "4\n10\n"}, {"type": "stdin_stdout", "input": "380\n10\n0", "output": "4\n10\n"}, {"type": "stdin_stdout", "input": "380\n12\n0", "output": "4\n13\n"}, {"type": "stdin_stdout", "input": "380\n16\n0", "output": "4\n13\n"}, {"type": "stdin_stdout", "input": "380...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nOnce Bob took a paper stripe of n squares (the height of the stripe is 1 square). In each square he wrote an integer number, possibly negative. He became interested in how many ways exist to cut this stripe into two piece...
[{"type": "stdin_stdout", "input": "100\n-4 2 4 4 1 3 -3 -3 2 1 -4 0 0 2 3 -1 -4 -3 4 -2 -3 -3 -3 -1 -2 -3 -1 -4 0 4 0 -1 4 0 -4 -4 4 -4 -2 1 -4 1 -3 -2 3 -4 4 0 -1 3 -1 4 -1 4 -1 3 -3 -3 -2 -2 4 -3 -3 4 -3 -2 -1 0 -2 4 0 -3 -1 -2 -3 1 -4 1 -3 -3 -3 -2 -3 0 1 -2 -2 -4 -3 -1 2 3 -1 1 1 0 3 -3 -1 -2\n", "output": "1\n"},...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nBaby Ehab has a piece of Cut and Stick with an array a of length n written on it. He plans to grab a pair of scissors and do the following to it:\n\n * pick a range (l, r) and cut out every element a_l, a_{l + 1}, ..., a...
[{"type": "stdin_stdout", "input": "100 1\n1 2 2 2 2 2 2 2 2 1 2 2 2 2 2 2 2 1 2 1 2 1 1 1 2 2 1 2 2 2 2 1 1 2 1 1 1 2 2 1 1 1 2 2 1 2 2 2 2 2 2 2 2 2 2 2 2 1 2 2 2 2 2 2 2 1 2 2 2 2 2 2 2 2 2 2 2 1 2 2 2 1 1 2 2 2 1 1 2 2 2 1 1 2 2 2 1 2 2 2\n1 100\n", "output": "46\n"}, {"type": "stdin_stdout", "input": "100 1\n1 1 2...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAs Sherlock Holmes was investigating a crime, he identified n suspects. He knows for sure that exactly one of them committed the crime. To find out which one did it, the detective lines up the suspects and numbered them f...
[{"type": "stdin_stdout", "input": "64 28\n+54\n+44\n+55\n-3\n+33\n-54\n-54\n-7\n+33\n+54\n+54\n+26\n-54\n+14\n-54\n-47\n+25\n-54\n-54\n-54\n-52\n+54\n+54\n+54\n+54\n+20\n+7\n+54\n+4\n+32\n+46\n-54\n-47\n+15\n+32\n-54\n+7\n+62\n-16\n-54\n+3\n+54\n+54\n+54\n+54\n-54\n+54\n-54\n+54\n-52\n+27\n-7\n+54\n-5\n-54\n-18\n+1\n+...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a string $s$ consisting only of lowercase Latin letters.\n\nYou can rearrange all letters of this string as you wish. Your task is to obtain a good string by rearranging the letters of the given string or re...
[{"type": "stdin_stdout", "input": "100\naa\nb\ncbc\nc\nbab\nc\nbdb\ndd\nhfh\nebe\nb\nf\ngg\na\nm\nkkk\nqq\ni\noo\nss\ntt\nere\njgj\nqiq\nkk\nn\naaa\nb\naa\nb\nc\na\nf\ne\na\naa\nff\ne\na\nafa\no\nmom\nqq\nf\niii\nh\njj\njj\nkgk\nbb\nhih\nj\na\naaa\nbb\nbab\ne\naa\nd\nb\nfdf\nibi\nbb\nfhf\ncc\nf\ngig\nene\nbob\na\nrcr\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLapindrome is defined as a string which when split in the middle, gives two halves having the same characters and same frequency of each character. If there are odd number of characters in the string, we ignore the middle...
[{"type": "stdin_stdout", "input": "6\ngaga\nabcde\nrotor\nxyzxy\nabbbab\nababc", "output": "YES\nNO\nYES\nYES\nYES\nNO\n"}, {"type": "stdin_stdout", "input": "6\ngaga\nedcca\nrouos\nxyzxy\nabbbab\nabbab", "output": "YES\nNO\nNO\nYES\nYES\nYES\n"}, {"type": "stdin_stdout", "input": "6\ngaga\nabcde\nrosor\nxyzxy\nabbbab...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou have a matrix $2 \\times 2$ filled with distinct integers. You want your matrix to become beautiful. The matrix is beautiful if the following two conditions are satisfied:\n\nin each row, the first element is smaller ...
[{"type": "stdin_stdout", "input": "6\n1 3\n5 7\n8 10\n3 4\n8 10\n4 3\n6 1\n9 2\n7 5\n4 2\n1 2\n4 3\n", "output": "YES\nYES\nNO\nYES\nYES\nNO\n"}, {"type": "stdin_stdout", "input": "1\n13 54\n91 10\n", "output": "NO\n"}, {"type": "stdin_stdout", "input": "1\n14 54\n91 11\n", "output": "NO\n"}, {"type": "stdin_stdout", ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIn AtCoder City, there are three stations numbered 1, 2, and 3.\nEach of these stations is operated by one of the two railway companies, A and B. A string S of length 3 represents which company operates each station. If S...
[{"type": "stdin_stdout", "input": "ABA\n", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "BBA\n", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "BAB\n", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "AAB\n", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "ABB\n", "output": "Yes\n"}, {"ty...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nOne cold winter evening Alice and her older brother Bob was sitting at home near the fireplace and giving each other interesting problems to solve. When it was Alice's turn, she told the number n to Bob and said:\n\n—Shuf...
[{"type": "stdin_stdout", "input": "918273645\n546372819\n", "output": "WRONG_ANSWER\n"}, {"type": "stdin_stdout", "input": "111111111\n111110111\n", "output": "WRONG_ANSWER\n"}, {"type": "stdin_stdout", "input": "987235645\n206049167\n", "output": "WRONG_ANSWER\n"}, {"type": "stdin_stdout", "input": "918273645\n278718...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLet's call an undirected graph of n vertices p-interesting, if the following conditions fulfill: \n\n * the graph contains exactly 2n + p edges; \n * the graph doesn't contain self-loops and multiple edges; \n * for an...
[{"type": "stdin_stdout", "input": "5\n24 228\n24 228\n24 228\n24 228\n24 228\n", "output": "1 2\n1 3\n1 4\n1 5\n1 6\n1 7\n1 8\n1 9\n1 10\n1 11\n1 12\n1 13\n1 14\n1 15\n1 16\n1 17\n1 18\n1 19\n1 20\n1 21\n1 22\n1 23\n1 24\n2 3\n2 4\n2 5\n2 6\n2 7\n2 8\n2 9\n2 10\n2 11\n2 12\n2 13\n2 14\n2 15\n2 16\n2 17\n2 18\n2 19\n2 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe problem describes the properties of a command line. The description somehow resembles the one you usually see in real operating systems. However, there are differences in the behavior. Please make sure you've read the...
[{"type": "stdin_stdout", "input": "\"RUn.exe O\" \"\" \" 2ne, \" two! . \" \"\n", "output": "<RUn.exe O>\n<>\n< 2ne, >\n<two!>\n<.>\n< >\n"}, {"type": "stdin_stdout", "input": "\"RUn.exe O\" \"\" \" 2ne, \" two! . \" \"\n", "output": "<RUn.exe O>\n<>\n< 2ne, >\n<two!>\n<.>\n< >\n"}, {"type": "stdin_stdout", "i...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are an adventurer currently journeying inside an evil temple. After defeating a couple of weak zombies, you arrived at a square room consisting of tiles forming an n × n grid. The rows are numbered 1 through n from to...
[{"type": "stdin_stdout", "input": "17\n.EEEEE...EEEE..EE\nEEE..E...EEEEE..E\n.E..E..EEE.EE...E\n.EEE.EE..EE...E..\nE..EEEEEE.EE.....\nE.EE...EEEEEEE.E.\nEEEE....EE..E.EEE\n...EEEEE.E..EE...\nEEE.E..EEEE.EEE..\n..E.E....EEE.....\nEE..E..E.E..EEEEE\nEEE..E.EEEEE.E...\n..EEEEE.E..EE.EE.\nEE.E...E..E..E.EE\n..E.EEE.EE..EE...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given an integer k and an undirected tree, consisting of n vertices.\n\nThe length of a simple path (a path in which each vertex appears at most once) between some pair of vertices is the number of edges in this p...
[{"type": "stdin_stdout", "input": "20 2\n3 14\n13 1\n4 3\n13 5\n12 20\n19 12\n6 3\n12 15\n11 2\n11 17\n9 5\n19 7\n6 11\n17 5\n16 18\n16 7\n12 8\n19 11\n16 10\n", "output": "122844\n"}, {"type": "stdin_stdout", "input": "20 2\n6 14\n13 1\n4 3\n13 5\n12 20\n19 12\n6 3\n12 15\n11 2\n11 17\n9 5\n19 7\n6 11\n17 5\n16 18\n1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a sequence A_1, A_2, ..., A_N and an integer K.\n\nPrint the maximum possible length of a sequence B that satisfies the following conditions:\n\n* B is a (not necessarily continuous) subsequence of A.\n* For...
[{"type": "stdin_stdout", "input": "10 3\n1\n5\n2\n1\n1\n6\n11\n11\n4\n2", "output": "6\n"}, {"type": "stdin_stdout", "input": "10 3\n0\n5\n4\n3\n14\n11\n9\n5\n3\n4", "output": "6\n"}, {"type": "stdin_stdout", "input": "10 3\n0\n5\n4\n3\n11\n11\n9\n7\n6\n1", "output": "5\n"}, {"type": "stdin_stdout", "input": "10 1\n2\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given two matrices $A$ and $B$. Each matrix contains exactly $n$ rows and $m$ columns. Each element of $A$ is either $0$ or $1$; each element of $B$ is initially $0$.\n\nYou may perform some operations with matrix...
[{"type": "stdin_stdout", "input": "5 50\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\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\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 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nChef Shifu and Chef Po are participating in the Greatest Dumpling Fight of 2012.\nOf course, Masterchef Oogway has formed the rules of the fight.\n\nThere is a long horizontal rope of infinite length with a center point P...
[{"type": "stdin_stdout", "input": "3\n2 4 3 8 12\n1 4 0 2 -1\n11 22 10 18 16", "output": "13\n-1\n1\n"}, {"type": "stdin_stdout", "input": "3\n2 4 3 8 12\n1 4 4 2 -1\n10 22 12 9 16", "output": "13\n-1\n5\n"}, {"type": "stdin_stdout", "input": "3\n2 4 3 8 12\n1 4 0 2 -1\n11 22 10 7 16", "output": "13\n-1\n3\n"}, {"type...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWe have N balance beams numbered 1 to N. The length of each beam is 1 meters. Snuke walks on Beam i at a speed of 1/A_i meters per second, and Ringo walks on Beam i at a speed of 1/B_i meters per second.\n\nSnuke and Ring...
[{"type": "stdin_stdout", "input": "10\n1375710043 178537096\n1332309236 80797230\n164044598 544580992\n117241210 865935868\n383133839 231371336\n378371075 681212831\n304570952 16537461\n1789737664 267238505\n844917655 218662351\n662961957 100386692", "output": "1121712759 3406064155"}, {"type": "stdin_stdout", "input"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nStudents love to celebrate their holidays. Especially if the holiday is the day of the end of exams!\n\nDespite the fact that Igor K., unlike his groupmates, failed to pass a programming test, he decided to invite them to...
[{"type": "stdin_stdout", "input": "50 1000 49\n", "output": "YES\n1 1000.00000000000000000000 2 20.40816326530612201395 \n2 979.59183673469385666976 3 40.81632653061224402791 \n3 959.18367346938771333953 4 61.22448979591836604186 \n4 938.77551020408168369613 5 81.63265306122448805581 \n5 918.36734693877554036590 6 102...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nKicker (table football) is a board game based on football, in which players control the footballers' figures mounted on rods by using bars to get the ball into the opponent's goal. When playing two on two, one player of e...
[{"type": "stdin_stdout", "input": "1 100\n100 1\n99 99\n99 99\n", "output": "Team 1\n"}, {"type": "stdin_stdout", "input": "80 79\n79 30\n80 81\n40 80\n", "output": "Team 2\n"}, {"type": "stdin_stdout", "input": "48 41\n15 47\n11 38\n19 31\n", "output": "Team 1\n"}, {"type": "stdin_stdout", "input": "51 54\n95 28\n42 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nProfessor GukiZ is concerned about making his way to school, because massive piles of boxes are blocking his way. \n\nIn total there are n piles of boxes, arranged in a line, from left to right, i-th pile (1 ≤ i ≤ n) cont...
[{"type": "stdin_stdout", "input": "5 3\n999999999 999999999 999999999 999999999 19992232\n", "output": " 1339997413"}, {"type": "stdin_stdout", "input": "19 100000\n1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1\n", "output": " ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nDid you hear about the Nibiru collision ? It is a supposed disastrous encounter between the earth and a large planetary object. Astronomers reject this idea. But why listen to other people's beliefs and opinions. We are c...
[{"type": "stdin_stdout", "input": "3\n-1 0 R\n2\n1 -1 U\n1 1 D\n1 1 U\n1\n1 0 U\n0 0 R\n1\n4 -1 L", "output": "SAFE\nSAFE\nSAFE\n"}, {"type": "stdin_stdout", "input": "3\n0 0 R\n2\n1 -4 U\n2 3 D\n1 2 U\n1\n2 -1 U\n0 0 R\n1\n7 1 L", "output": "SAFE\nSAFE\nSAFE\n"}, {"type": "stdin_stdout", "input": "3\n0 0 R\n2\n1 -4 U...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe great hero guards the country where Homer lives. The hero has attack power $A$ and initial health value $B$. There are $n$ monsters in front of the hero. The $i$-th monster has attack power $a_i$ and initial health va...
[{"type": "stdin_stdout", "input": "10\n1 1000000000 1\n1\n1000000000\n1 1000000000 1\n1\n1000000000\n1 1000000000 1\n1\n1000000000\n1 1000000000 1\n1\n1000000000\n1 1000000000 1\n1\n1000000000\n1 1000000000 1\n1\n1000000000\n1 1000000000 1\n1\n1000000000\n1 1000000000 1\n1\n1000000000\n1 1000000000 1\n1\n1000000000\n1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSonya was unable to think of a story for this problem, so here comes the formal description.\n\nYou are given the array containing n positive integers. At one turn you can pick any element and increase or decrease it by 1...
[{"type": "stdin_stdout", "input": "75\n392 1038 98 533 515 448 220 310 386 28 539 294 208 828 75 534 875 493 94 205 656 105 546 493 60 188 222 108 788 504 809 621 934 455 307 178 630 298 938 62 850 421 839 134 950 256 934 817 209 559 866 67 990 835 534 672 468 768 757 516 959 893 275 136 692 927 321 554 801 805 885 12...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given two circles. Find the area of their intersection.\n\n\n-----Input-----\n\nThe first line contains three integers x_1, y_1, r_1 ( - 10^9 ≤ x_1, y_1 ≤ 10^9, 1 ≤ r_1 ≤ 10^9) — the position of the center and the...
[{"type": "stdin_stdout", "input": "368831644 125127030 959524552\n690900461 -368007601 1000000000\n", "output": "1877639096067727828.75000000000000000000\n"}, {"type": "stdin_stdout", "input": "368831644 125127030 959524552\n690900461 -368007601 1000000000\n", "output": "1877639096067727828.62500000000000000000"}, {"t...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are two 100-story buildings, called A and B. (In this problem, the ground floor is called the first floor.)\nFor each i = 1,\\dots, 100, the i-th floor of A and that of B are connected by a corridor.\nAlso, for each...
[{"type": "stdin_stdout", "input": "1 100 100 100\n", "output": "10000\n"}, {"type": "stdin_stdout", "input": "1 100 50 100\n", "output": "9950\n"}, {"type": "stdin_stdout", "input": "1 100 33 65\n", "output": "6468\n"}, {"type": "stdin_stdout", "input": "1 100 33 67\n", "output": "6567\n"}, {"type": "stdin_stdout", "i...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIn order to participate in the Asian Regional Qualifiers of the International Collegiate Programming Contest held every year in Japan, we must break through the strict domestic qualifiers.\n\nEven though it is a universit...
[{"type": "stdin_stdout", "input": "6\n1 1 6 200\n2 1 11 300\n3 0 1 400\n4 0 5 1200\n5 0 5 1674\n10 4 4 6\n3\n1015 1 5 84\n1343 2 4 20\n123 3 6 500\n2\n4 1 3 100\n1 1 1 100\n0", "output": "2\n1\n4\n5\n10\n3\n123\n1015\n1343\n4\n1\n"}, {"type": "stdin_stdout", "input": "6\n1 1 6 200\n2 1 11 300\n3 0 1 400\n4 0 5 1200\n5...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA game field is a strip of 1 × n square cells. In some cells there are Packmen, in some cells — asterisks, other cells are empty.\n\nPackman can move to neighboring cell in 1 time unit. If there is an asterisk in the targ...
[{"type": "stdin_stdout", "input": "100\n************************************************************P***************************************\n", "output": "138\n"}, {"type": "stdin_stdout", "input": "100\n************************************************************P***************************************\n", "output":...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPetya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.\n\...
[{"type": "stdin_stdout", "input": "1334146180889758954\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "123456789123456789\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "999999999999994744\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "446486416781684178\n", "output": "YES\n"}, {"type...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPolycarpus has a sequence, consisting of n non-negative integers: a_1, a_2, ..., a_{n}.\n\nLet's define function f(l, r) (l, r are integer, 1 ≤ l ≤ r ≤ n) for sequence a as an operation of bitwise OR of all the sequence e...
[{"type": "stdin_stdout", "input": "10\n375813 659427 484038 348181 432640 368050 271089 721588 345312 630771\n", "output": "29\n"}, {"type": "stdin_stdout", "input": "10\n375813 873836 484038 348181 432640 368050 271089 721588 345312 630771\n", "output": "30\n"}, {"type": "stdin_stdout", "input": "10\n375813 873836 48...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSorting algorithms for sorting data are basic algorithms indispensable in computer science. For example, as shown in the figure below, the operation of \"sorting the elements of an array of integer values ​​in ascending o...
[{"type": "stdin_stdout", "input": "5\n5\n1\n2\n-1\n0\n4\n1\n6\n2\n4\n4\n22\n3\n4\n1\n-1\n0", "output": "8\n2\n5\n0\n"}, {"type": "stdin_stdout", "input": "5\n10\n1\n4\n-1\n0\n8\n0\n3\n9\n7\n5\n22\n3\n4\n1\n-1\n0", "output": "8\n11\n0\n"}, {"type": "stdin_stdout", "input": "5\n5\n1\n2\n-1\n0\n8\n1\n6\n2\n4\n5\n22\n3\n4...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nValera considers a number beautiful, if it equals 2^{k} or -2^{k} for some integer k (k ≥ 0). Recently, the math teacher asked Valera to represent number n as the sum of beautiful numbers. As Valera is really greedy, he w...
[{"type": "stdin_stdout", "input": "10001100101100101000100101000100100111100001111001000011101001010001100111001010011111100101110101010011101101110000111111010100100111110000011111000100011000000010111011000110010110001100010011111100110011100001110011011110000011101111000110100010000111011010011101100101010010110011...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIn Disgaea as in most role-playing games, characters have skills that determine the character's ability to use certain weapons or spells. If the character does not have the necessary skill, he cannot use it. The skill lev...
[{"type": "stdin_stdout", "input": "20 1 0.78\nxc 6799\nztrfjsq 3023\nkhbcbsaztwigxeidh 2974\nkksvbmtjiiqlguwv 188\nwvqzzjrpmxsdbfvua 4547\niqkqqwtqifdpxfhslpv 6264\nwarmknju 9472\nfheisuiufwmtagl 292\nwge 4338\nzaklermeji 6733\nfcn 6282\nbjyjzgzkgzy 1778\ngufpvhdnsesyfuegef 4998\nxnhuhwzzxqbaphktqbc 8485\ncokabaqahfw ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nVasya has got many devices that work on electricity. He's got n supply-line filters to plug the devices, the i-th supply-line filter has a_{i} sockets.\n\nOverall Vasya has got m devices and k electrical sockets in his fl...
[{"type": "stdin_stdout", "input": "50 50 2\n2 2 4 5 2 1 5 4 5 4 5 2 1 2 3 3 5 1 2 2 1 3 4 5 5 4 3 2 2 1 3 2 3 2 4 4 1 3 5 4 3 2 4 3 4 4 4 4 3 4\n", "output": "14\n"}, {"type": "stdin_stdout", "input": "50 30 1\n2 1 2 1 2 3 3 1 2 2 3 2 1 3 1 3 1 2 2 3 2 1 3 1 1 2 3 2 2 1 1 3 3 2 2 2 3 2 3 3 3 3 1 1 3 1 1 3 1 3\n", "out...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPolycarp often uses his smartphone. He has already installed $n$ applications on it. Application with number $i$ takes up $a_i$ units of memory.\n\nPolycarp wants to free at least $m$ units of memory (by removing some app...
[{"type": "stdin_stdout", "input": "5\n5 13\n6 4 2 2 2\n2 1 1 2 1\n1 3\n2\n1\n5 10\n2 3 10 2 3\n1 1 2 2 1\n4 10\n4 1 3 1\n1 2 1 2\n4 9\n2 2 1 2\n1 1 2 1\n", "output": "5\n-1\n2\n-1\n-1\n"}, {"type": "stdin_stdout", "input": "5\n5 7\n6 4 2 2 2\n2 1 1 2 1\n1 3\n2\n1\n5 10\n2 3 10 2 3\n1 1 2 2 1\n4 10\n4 1 3 1\n1 2 1 2\n4...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given n points on a line with their coordinates x_{i}. Find the point x so the sum of distances to the given points is minimal.\n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 3·10^5) — the numb...
[{"type": "stdin_stdout", "input": "100\n457 827 807 17 871 935 907 -415 536 170 551 -1454 865 758 -457 -892 -875 -488 684 19 0 555 -807 -624 -239 826 318 811 20 -732 -91 460 551 -610 555 -493 -154 442 -141 946 -913 -104 704 -380 699 32 106 -455 -518 214 -464 -861 243 -798 -472 559 529 -844 -32 871 -459 236 387 626 -31...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nTwo little greedy bears have found two pieces of cheese in the forest of weight a and b grams, correspondingly. The bears are so greedy that they are ready to fight for the larger piece. That's where the fox comes in and ...
[{"type": "stdin_stdout", "input": "1488496828 607500000\n", "output": "-1\n"}, {"type": "stdin_stdout", "input": "1183431925 540244525\n", "output": "-1\n"}, {"type": "stdin_stdout", "input": "1270836736 387420489\n", "output": "-1\n"}, {"type": "stdin_stdout", "input": "100000007 800000011\n", "output": "-1\n"}, {"ty...
code_stdio