messages
listlengths
1
1
ground_truth
stringlengths
88
726k
dataset
stringclasses
2 values
[ { "content": "Solve the following coding problem using the programming language python:\n\nValera takes part in the Berland Marathon. The marathon race starts at the stadium that can be represented on the plane as a square whose lower left corner is located at point with coordinates (0, 0) and the length of the...
[{"type": "stdin_stdout", "input": "22635.8777 74922.1758\n10\n", "output": "0.0000000000 15621.3350000000\n8606.7923000000 22635.8777000000\n22635.8777000000 21043.6281000000\n22635.8777000000 5422.2931000000\n12436.8358000000 0.0000000000\n0.0000000000 3184.4992000000\n0.0000000000 18805.8342000000\n11791.2915000000 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nBob is a competitive programmer. He wants to become red, and for that he needs a strict training regime. He went to the annual meeting of grandmasters and asked $n$ of them how much effort they needed to reach red.\n\n\"O...
[{"type": "stdin_stdout", "input": "15\n5318008\n379009\n06\n79153975193751375917591379919397337913333535330\n791539751937513759175913799193973379133301353533\n123456789023487138475693874561834576138495713485673485364857638475673465873457346581495713641\n7915397519375137511917591379919397337913333535330\n31553555535353...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nТри брата договорились о встрече. Пронумеруем братьев следующим образом: пусть старший брат имеет номер 1, средний брат имеет номер 2, а младший брат — номер 3. \n\nКогда пришло время встречи, один из братьев опоздал. По ...
[{"type": "stdin_stdout", "input": "3 1\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "2 1\n", "output": "3\n"}, {"type": "stdin_stdout", "input": "2 3\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "1 2\n", "output": "3\n"}, {"type": "stdin_stdout", "input": "1 3\n", "output": "2\n"}, {"type": "stdi...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nOmkar is building a waterslide in his water park, and he needs your help to ensure that he does it as efficiently as possible.\n\nOmkar currently has $n$ supports arranged in a line, the $i$-th of which has height $a_i$. ...
[{"type": "stdin_stdout", "input": "3\n4\n5 3 2 5\n5\n1 2 3 5 3\n3\n1 1 1\n", "output": "3\n2\n0\n"}, {"type": "stdin_stdout", "input": "2\n2\n1 3\n2\n3 1\n", "output": "0\n2\n"}, {"type": "stdin_stdout", "input": "1\n1\n943795198\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "1\n5\n4 4 1 1 1\n", "output": "3...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given $n$ pairs of integers $(a_1, b_1), (a_2, b_2), \\ldots, (a_n, b_n)$. All of the integers in the pairs are distinct and are in the range from $1$ to $2 \\cdot n$ inclusive.\n\nLet's call a sequence of integer...
[{"type": "stdin_stdout", "input": "5\n1 7\n6 4\n2 10\n9 8\n3 5\n", "output": "3\n5 3 1 \n"}, {"type": "stdin_stdout", "input": "3\n5 4\n3 2\n6 1\n", "output": "3\n3 2 1 \n"}, {"type": "stdin_stdout", "input": "3\n1 4\n2 5\n3 6\n", "output": "3\n3 2 1 \n"}, {"type": "stdin_stdout", "input": "2\n1 3\n2 4\n", "output": "...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given $n$ positive integers $a_1, \\ldots, a_n$, and an integer $k \\geq 2$. Count the number of pairs $i, j$ such that $1 \\leq i < j \\leq n$, and there exists an integer $x$ such that $a_i \\cdot a_j = x^k$.\n\...
[{"type": "stdin_stdout", "input": "100 3\n94 94 83 27 80 73 61 38 34 95 72 96 59 36 78 15 83 78 39 22 21 57 54 59 9 32 81 64 94 90 67 41 18 57 93 76 44 62 77 61 31 70 39 73 81 57 43 31 27 85 36 26 44 26 75 23 66 53 3 14 40 67 53 19 70 81 98 12 91 15 92 90 89 86 58 30 67 73 72 69 68 47 30 7 89 35 17 93 45 6 4 23 73 36 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nChubby Yang is studying linear equations right now. He came up with a nice problem. In the problem you are given an n × n matrix W, consisting of integers, and you should find two n × n matrices A and B, all the following...
[{"type": "stdin_stdout", "input": "3\n1 2 3\n4 5 6\n7 8 9\n", "output": "1.00000000 3.00000000 5.00000000\n3.00000000 5.00000000 7.00000000\n5.00000000 7.00000000 9.00000000\n0.00000000 -1.00000000 -2.00000000\n1.00000000 0.00000000 -1.00000000\n2.00000000 1.00000000 0.00000000\n"}, {"type": "stdin_stdout", "input": "...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nEgor is a famous Russian singer, rapper, actor and blogger, and finally he decided to give a concert in the sunny Republic of Dagestan.\n\nThere are $n$ cities in the republic, some of them are connected by $m$ directed r...
[{"type": "stdin_stdout", "input": "20 40\n2 6 1\n17 6 1\n1 15 0\n7 5 1\n14 18 1\n13 4 0\n9 10 0\n12 7 1\n7 9 0\n12 5 0\n11 4 0\n2 15 0\n19 12 0\n9 5 1\n13 14 1\n3 14 0\n17 8 0\n18 20 0\n4 3 0\n11 14 1\n10 4 0\n6 7 1\n1 2 1\n6 9 0\n5 11 0\n10 11 1\n15 19 1\n3 18 1\n15 6 0\n8 10 1\n8 10 0\n5 13 1\n4 3 1\n16 20 0\n14 16 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given two integers $x$ and $y$. You can perform two types of operations: Pay $a$ dollars and increase or decrease any of these integers by $1$. For example, if $x = 0$ and $y = 7$ there are four possible outcome...
[{"type": "stdin_stdout", "input": "3\n1 3\n391 555\n129 8437\n9 4\n321 654\n3 4\n", "output": "1337\n75288\n2283\n"}, {"type": "stdin_stdout", "input": "2\n1 3\n391 555\n129 8437\n9 4\n", "output": "1337\n75288\n"}, {"type": "stdin_stdout", "input": "2\n1 3\n391 555\n0 0\n9 4\n", "output": "1337\n0\n"}, {"type": "stdi...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIvan has got an array of n non-negative integers a_1, a_2, ..., a_{n}. Ivan knows that the array is sorted in the non-decreasing order. \n\nIvan wrote out integers 2^{a}_1, 2^{a}_2, ..., 2^{a}_{n} on a piece of paper. Now...
[{"type": "stdin_stdout", "input": "26\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 2\n", "output": "5\n"}, {"type": "stdin_stdout", "input": "1\n2000000000\n", "output": "2000000000\n"}, {"type": "stdin_stdout", "input": "4\n0 1 1 1\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "1\n3\n", "output": "3\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nDexterina and Womandark have been arch-rivals since they’ve known each other. Since both are super-intelligent teenage girls, they’ve always been trying to solve their disputes in a peaceful and nonviolent way. After god ...
[{"type": "stdin_stdout", "input": "1000000 50\n0.034403 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.033928 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.071853 0.000000 0.000000 0.016440 0.000000 0.000000 0.000000 0.000000 0.023167 0.067938 0.000000 0.000000 0.000000 0.000000 0....
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nDaniel has a string s, consisting of lowercase English letters and period signs (characters '.'). Let's define the operation of replacement as the following sequence of steps: find a substring \"..\" (two consecutive peri...
[{"type": "stdin_stdout", "input": "2 7\nab\n1 w\n2 w\n1 c\n2 .\n2 .\n1 .\n2 b\n", "output": "0\n0\n0\n0\n0\n1\n0\n"}, {"type": "stdin_stdout", "input": "1 5\n.\n1 .\n1 w\n1 w\n1 .\n1 .\n", "output": "0\n0\n0\n0\n0\n"}, {"type": "stdin_stdout", "input": "10 3\n.b..bz....\n1 h\n3 c\n9 f\n", "output": "4\n3\n1\n"}, {"typ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a multiset S consisting of positive integers (initially empty). There are two kind of queries: Add a positive integer to S, the newly added integer is not less than any number in it. Find a subset s of th...
[{"type": "stdin_stdout", "input": "25\n1 134292126\n2\n1 218916741\n1 237556189\n2\n1 259193070\n2\n2\n1 397804479\n1 430795002\n2\n1 483338629\n1 626042215\n2\n1 658608263\n1 715368294\n2\n2\n2\n2\n1 833121838\n2\n1 863192433\n2\n1 966351027\n", "output": "0.0000000000\n51632031.5000000000\n62450472.0000000000\n62450...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nBimokh is Mashmokh's boss. For the following n days he decided to pay to his workers in a new way. At the beginning of each day he will give each worker a certain amount of tokens. Then at the end of each day each worker ...
[{"type": "stdin_stdout", "input": "10 1 100000000\n999999999 999999999 999999999 999999999 999999999 999999999 999999999 999999999 999999999 999999999\n", "output": "99999999 99999999 99999999 99999999 99999999 99999999 99999999 99999999 99999999 99999999 "}, {"type": "stdin_stdout", "input": "1 1 1000000000\n99999999...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nRebel spy Heidi has just obtained the plans for the Death Star from the Empire and, now on her way to safety, she is trying to break the encryption of the plans (of course they are encrypted – the Empire may be evil, but ...
[{"type": "stdin_stdout", "input": "10 12\n16 3 24 13 9 8 7 5 12 12\n", "output": "13\n"}, {"type": "stdin_stdout", "input": "5 50\n100 150 200 100 50\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "5 50\n1 1 1 1 1\n", "output": "5\n"}, {"type": "stdin_stdout", "input": "4 10\n3 4 7 2\n", "output": "16\n"}, {"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAmr bought a new video game \"Guess Your Way Out! II\". The goal of the game is to find an exit from the maze that looks like a perfect binary tree of height h. The player is initially standing at the root of the tree and...
[{"type": "stdin_stdout", "input": "4 2\n3 4 6 1\n4 12 15 1\n", "output": "Data not sufficient!"}, {"type": "stdin_stdout", "input": "4 2\n3 4 5 1\n2 3 3 1\n", "output": "Game cheated!"}, {"type": "stdin_stdout", "input": "4 3\n4 10 14 1\n3 6 6 0\n2 3 3 1\n", "output": "14"}, {"type": "stdin_stdout", "input": "1 1\n1 1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nVladimir would like to prepare a present for his wife: they have an anniversary! He decided to buy her exactly $n$ flowers.\n\nVladimir went to a flower shop, and he was amazed to see that there are $m$ types of flowers b...
[{"type": "stdin_stdout", "input": "1\n7 7\n873108721 195635452\n42649954 997221147\n873108721 801676035\n787324511 873108721\n873108720 541066719\n873108721 372607189\n1000000000 427003887\n", "output": "6152868116\n"}, {"type": "stdin_stdout", "input": "1\n7 7\n10122721 121764855\n397678435 423586551\n203091798 45523...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPeople in the Tomskaya region like magic formulas very much. You can see some of them below.\n\nImagine you are given a sequence of positive integer numbers p_1, p_2, ..., p_{n}. Lets write down some magic formulas:$q_{i}...
[{"type": "stdin_stdout", "input": "25\n39226529 640445129 936289624 364461191 1096077769 573427707 1919403410 950067229 1217479531 455229458 1574949468 397268319 1267289585 995220637 1920919164 501015483 1815262670 1197059269 86947741 1137410885 667368575 733666398 1536581408 611239452 947487746\n", "output": "2596546...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are n points marked on the plane. The points are situated in such a way that they form a regular polygon (marked points are its vertices, and they are numbered in counter-clockwise order). You can draw n - 1 segment...
[{"type": "stdin_stdout", "input": "10\n0 0 0 0 0 0 1 0 0 0\n0 0 0 0 0 0 0 0 0 0\n0 0 0 1 0 0 0 0 0 0\n0 0 1 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0\n1 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "4\n0 1 1 1\n1 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\n\"The zombies are lurking outside. Waiting. Moaning. And when they come...\"\n\n\"When they come?\"\n\n\"I hope the Wall is high enough.\"\n\nZombie attacks have hit the Wall, our line of defense in the North. Its protect...
[{"type": "stdin_stdout", "input": "10 7\n.......\n.......\n.......\n.......\n.......\n.......\n.......\n.......\n...B...\nB.BB.B.\n", "output": "3\n"}, {"type": "stdin_stdout", "input": "8 8\n........\n........\n........\n........\n.B......\n.B.....B\n.B.....B\n.BB...BB\n", "output": "2\n"}, {"type": "stdin_stdout", "...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nMike and !Mike are old childhood rivals, they are opposite in everything they do, except programming. Today they have a problem they cannot solve on their own, but together (with you) — who knows? \n\nEvery one of them ha...
[{"type": "stdin_stdout", "input": "17\n714413739 -959271262 714413739 -745891378 926207665 -404845105 -404845105 -959271262 -189641729 -670860364 714413739 -189641729 192457837 -745891378 -670860364 536388097 -959271262\n-417715348 -959271262 -959271262 714413739 -189641729 571055593 571055593 571055593 -417715348 -41...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAyush and Ashish play a game on an unrooted tree consisting of $n$ nodes numbered $1$ to $n$. Players make the following move in turns: Select any leaf node in the tree and remove it together with any edge which has thi...
[{"type": "stdin_stdout", "input": "10\n8 2\n1 5\n7 4\n8 5\n5 6\n8 7\n2 8\n1 3\n10 5\n10 1\n4 7\n6 4\n4 3\n8 1\n1 2\n1 4\n5 1\n1 9\n2 2\n2 1\n9 3\n9 6\n1 7\n2 6\n7 3\n6 8\n1 6\n5 1\n6 4\n8 6\n3 1\n8 6\n2 4\n5 7\n8 4\n1 8\n5 6\n10 3\n5 9\n10 1\n5 10\n6 1\n4 10\n1 2\n3 7\n2 3\n10 8\n4 1\n1 4\n1 3\n2 1\n5 5\n4 5\n1 3\n1 5...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSmart Beaver recently got interested in a new word game. The point is as follows: count the number of distinct good substrings of some string s. To determine if a string is good or not the game uses rules. Overall there a...
[{"type": "stdin_stdout", "input": "aaajiajqjvehgzqjssaebbqzhggehreiihhrjeehzeaeiiigavjsqbszghavijavqszgbjhjzvvjqhvqvrhehhjjbsezsbraiiabrzvgvzvhrisjzhehaqehqerrvieseheavbigihahbqv\n0\n", "output": "10115\n"}, {"type": "stdin_stdout", "input": "nysnvneyavzcebsbsvrsbcvzsrcr\n5\nycaa 1 3\nzsayyyvseccsbcbvzrr 5 16\nznz 1 3...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nFind an n × n matrix with different numbers from 1 to n^2, so the sum in each row, column and both main diagonals are odd.\n\n\n-----Input-----\n\nThe only line contains odd integer n (1 ≤ n ≤ 49).\n\n\n-----Output-----\n...
[{"type": "stdin_stdout", "input": "11\n", "output": "2 4 6 8 10 1 12 14 16 18 20\n22 24 26 28 3 5 7 30 32 34 36\n38 40 42 9 11 13 15 17 44 46 48\n50 52 19 21 23 25 27 29 31 54 56\n58 33 35 37 39 41 43 45 47 49 60\n51 53 55 57 59 61 63 65 67 69 71\n62 73 75 77 79 81 83 85 87 89 64\n66 68 91 93 95 97 99 101 103 70 72\n7...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA binary matrix is called good if every even length square sub-matrix has an odd number of ones. \n\nGiven a binary matrix $a$ consisting of $n$ rows and $m$ columns, determine the minimum number of cells you need to chan...
[{"type": "stdin_stdout", "input": "2 58\n1100001110010010100001000000000110110001101001100010101110\n1110110010101111001110010001100010001010100011111110110100\n", "output": "27"}, {"type": "stdin_stdout", "input": "7 15\n000100001010010\n100111010110001\n101101111100100\n010000111111010\n111010010100001\n000011001111...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSonya decided to organize an exhibition of flowers. Since the girl likes only roses and lilies, she decided that only these two kinds of flowers should be in this exhibition.\n\nThere are $n$ flowers in a row in the exhib...
[{"type": "stdin_stdout", "input": "10 4\n3 3\n1 6\n9 9\n10 10\n", "output": "0101010101\n"}, {"type": "stdin_stdout", "input": "6 3\n5 6\n1 4\n4 6\n", "output": "010101\n"}, {"type": "stdin_stdout", "input": "5 3\n1 3\n2 4\n2 5\n", "output": "01010\n"}, {"type": "stdin_stdout", "input": "6 2\n1 6\n1 4\n", "output": "0...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nValera has got a rectangle table consisting of n rows and m columns. Valera numbered the table rows starting from one, from top to bottom and the columns – starting from one, from left to right. We will represent cell tha...
[{"type": "stdin_stdout", "input": "7 5 17\n", "output": "2 1 1 1 2\n2 1 3 1 4\n2 1 5 2 5\n2 2 4 2 3\n2 2 2 2 1\n2 3 1 3 2\n2 3 3 3 4\n2 3 5 4 5\n2 4 4 4 3\n2 4 2 4 1\n2 5 1 5 2\n2 5 3 5 4\n2 5 5 6 5\n2 6 4 6 3\n2 6 2 6 1\n2 7 1 7 2\n3 7 3 7 4 7 5\n"}, {"type": "stdin_stdout", "input": "2 15 3\n", "output": "2 1 1 1 2\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a positive integer $D$. Let's build the following graph from it: each vertex is a divisor of $D$ (not necessarily prime, $1$ and $D$ itself are also included); two vertices $x$ and $y$ ($x > y$) have an u...
[{"type": "stdin_stdout", "input": "18\n36\n1 1\n1 2\n1 3\n1 6\n1 9\n1 18\n2 1\n2 2\n2 3\n2 6\n2 9\n2 18\n3 1\n3 2\n3 3\n3 6\n3 9\n3 18\n6 1\n6 2\n6 3\n6 6\n6 9\n6 18\n9 1\n9 2\n9 3\n9 6\n9 9\n9 18\n18 1\n18 2\n18 3\n18 6\n18 9\n18 18\n", "output": "1\n1\n1\n2\n1\n3\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n2\n2\n1\n1\n1\n1\n1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nGeneral Payne has a battalion of n soldiers. The soldiers' beauty contest is coming up, it will last for k days. Payne decided that his battalion will participate in the pageant. Now he has choose the participants.\n\nAll...
[{"type": "stdin_stdout", "input": "10 27\n17 53 94 95 57 36 47 68 48 16\n", "output": "1 95 \n1 94 \n1 68 \n1 57 \n1 53 \n1 48 \n1 47 \n1 36 \n1 17 \n1 16 \n2 95 94 \n2 95 68 \n2 95 57 \n2 95 53 \n2 95 48 \n2 95 47 \n2 95 36 \n2 95 17 \n2 95 16 \n3 95 94 68 \n3 95 94 57 \n3 95 94 53 \n3 95 94 48 \n3 95 94 47 \n3 95 94...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given an integer $n$ and an integer $k$.\n\nIn one step you can do one of the following moves: decrease $n$ by $1$; divide $n$ by $k$ if $n$ is divisible by $k$. \n\nFor example, if $n = 27$ and $k = 3$ you can...
[{"type": "stdin_stdout", "input": "93\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are $n$ emotes in very popular digital collectible card game (the game is pretty famous so we won't say its name). The $i$-th emote increases the opponent's happiness by $a_i$ units (we all know that emotes in this ...
[{"type": "stdin_stdout", "input": "69 10 2\n2 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\n", "output": "697\n"}, {"type": "stdin_stdout", "input": "3 1000000000 1\n1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou a captain of a ship. Initially you are standing in a point $(x_1, y_1)$ (obviously, all positions in the sea can be described by cartesian plane) and you want to travel to a point $(x_2, y_2)$. \n\nYou know the weathe...
[{"type": "stdin_stdout", "input": "0 0\n1000000000 1000000000\n2\nDR\n", "output": "2000000000\n"}, {"type": "stdin_stdout", "input": "0 0\n4 6\n3\nUUU\n", "output": "5\n"}, {"type": "stdin_stdout", "input": "0 3\n0 0\n3\nUDD\n", "output": "3\n"}, {"type": "stdin_stdout", "input": "0 0\n0 1\n1\nL\n", "output": "-1\n"}...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nNow Serval is a junior high school student in Japari Middle School, and he is still thrilled on math as before. \n\nAs a talented boy in mathematics, he likes to play with numbers. This time, he wants to play with numbers...
[{"type": "stdin_stdout", "input": "100\n0 1 0 0 1 0 1 0 0 0 0 0 1 0 0 1 1 1 1 0 0 1 0 1 1 0 1 0 0 0 0 1 0 1 1 1 1 0 0 1 0 1 0 0 1 0 0 1 0 0 0 0 0 0 1 0 0 1 0 0 0 0 1 0 0 0 1 1 1 1 0 0 0 0 1 1 1 0 1 0 0 1 1 0 0 1 0 0 1 1 0 0 0 1 1 1 0 0 0 1\n1 2 3 4 2 6 5 5 4 8 10 8 1 14 5 16 3 11 13 11 12 8 11 22 8 17 19 5 15 27 14 13...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPaladin Manao caught the trail of the ancient Book of Evil in a swampy area. This area contains n settlements numbered from 1 to n. Moving through the swamp is very difficult, so people tramped exactly n - 1 paths. Each o...
[{"type": "stdin_stdout", "input": "50 2 5\n9 14\n46 34\n40 35\n44 30\n32 16\n1 38\n48 2\n17 14\n50 25\n6 1\n45 19\n21 15\n22 11\n15 33\n8 28\n2 32\n10 22\n37 3\n43 39\n25 16\n9 19\n16 3\n28 32\n20 45\n24 32\n4 18\n49 39\n13 45\n26 4\n11 33\n14 37\n42 19\n31 45\n38 3\n34 8\n18 29\n35 34\n29 16\n7 46\n19 28\n27 33\n30 9...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nXenia the beginner programmer has a sequence a, consisting of 2^{n} non-negative integers: a_1, a_2, ..., a_2^{n}. Xenia is currently studying bit operations. To better understand how they work, Xenia decided to calculate...
[{"type": "stdin_stdout", "input": "2 10\n15 27 17 18\n2 12\n4 19\n2 3\n4 1\n3 15\n3 11\n2 5\n1 26\n1 17\n3 18\n", "output": "28\n28\n28\n30\n0\n4\n4\n20\n30\n6\n"}, {"type": "stdin_stdout", "input": "1 10\n22 17\n2 15\n2 12\n1 6\n1 16\n2 24\n1 21\n2 19\n2 25\n2 19\n2 1\n", "output": "31\n30\n14\n28\n24\n29\n23\n29\n23...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a simple weighted connected undirected graph, consisting of $n$ vertices and $m$ edges.\n\nA path in the graph of length $k$ is a sequence of $k+1$ vertices $v_1, v_2, \\dots, v_{k+1}$ such that for each $i$...
[{"type": "stdin_stdout", "input": "15 15 23\n13 10 12\n11 14 12\n2 15 5\n4 10 8\n10 2 4\n10 7 5\n3 10 1\n5 6 11\n1 13 8\n9 15 4\n4 2 9\n11 15 1\n11 12 14\n10 8 12\n3 6 11\n", "output": "3250\n"}, {"type": "stdin_stdout", "input": "5 10 10000000\n2 4 798\n1 5 824\n5 2 558\n4 1 288\n3 4 1890\n3 1 134\n2 3 1485\n4 5 284\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nVolodya likes listening to heavy metal and (occasionally) reading. No wonder Volodya is especially interested in texts concerning his favourite music style.\n\nVolodya calls a string powerful if it starts with \"heavy\" a...
[{"type": "stdin_stdout", "input": "trueheavymetalissotruewellitisalsosoheavythatyoucanalmostfeeltheweightofmetalonyou\n", "output": "3"}, {"type": "stdin_stdout", "input": "fpgzbvhheavymheheavyzmheavyavyebknkhheavyhsbqmmetheavyalmetalheavyyomtua\n", "output": "5"}, {"type": "stdin_stdout", "input": "metametaheavyetala...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nDuring one of the space missions, humans have found an evidence of previous life at one of the planets. They were lucky enough to find a book with birth and death years of each individual that had been living at this plan...
[{"type": "stdin_stdout", "input": "4\n3 4\n4 5\n4 6\n8 10\n", "output": "4 2\n"}, {"type": "stdin_stdout", "input": "1\n1 1000000000\n", "output": "1 1\n"}, {"type": "stdin_stdout", "input": "3\n1 5\n2 4\n5 6\n", "output": "2 2\n"}, {"type": "stdin_stdout", "input": "3\n1 2\n2 4\n2 4\n", "output": "2 2\n"}, {"type": "...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nMahmoud has an array a consisting of n integers. He asked Ehab to find another array b of the same length such that:\n\n b is lexicographically greater than or equal to a. b_{i} ≥ 2. b is pairwise coprime: for every 1 ...
[{"type": "stdin_stdout", "input": "10\n5 3 2 2 3 3 3 4 2 5\n", "output": "5 3 2 7 11 13 17 19 23 29 "}, {"type": "stdin_stdout", "input": "7\n20 9 7 6 7 9 15\n", "output": "20 9 7 11 13 17 19 "}, {"type": "stdin_stdout", "input": "5\n7 10 2 5 5\n", "output": "7 10 3 11 13 "}, {"type": "stdin_stdout", "input": "5\n2 3 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nGerald has n younger brothers and their number happens to be even. One day he bought n^2 candy bags. One bag has one candy, one bag has two candies, one bag has three candies and so on. In fact, for each integer k from 1 ...
[{"type": "stdin_stdout", "input": "12\n", "output": "1 144 2 143 3 142 4 141 5 140 6 139\n7 138 8 137 9 136 10 135 11 134 12 133\n13 132 14 131 15 130 16 129 17 128 18 127\n19 126 20 125 21 124 22 123 23 122 24 121\n25 120 26 119 27 118 28 117 29 116 30 115\n31 114 32 113 33 112 34 111 35 110 36 109\n37 108 38 107 39 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou have $n$ sticks of the given lengths.\n\nYour task is to choose exactly four of them in such a way that they can form a rectangle. No sticks can be cut to pieces, each side of the rectangle must be formed by a single ...
[{"type": "stdin_stdout", "input": "10\n20\n10 14 10 14 10 7 10 10 14 10 7 9 10 8 14 10 10 8 14 9\n12\n7 2 2 2 2 16 16 7 18 17 17 18\n5\n7 13 17 13 7\n6\n10 10 9 9 10 10\n6\n17 19 17 19 14 14\n10\n10 13 5 18 13 13 13 10 18 5\n11\n3 4 16 4 4 3 4 13 4 16 13\n7\n17 19 1 17 17 1 19\n5\n17 17 19 17 19\n9\n13 15 13 18 13 18 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThis problem is different from the hard version. In this version Ujan makes exactly one exchange. You can hack this problem only if you solve both problems.\n\nAfter struggling and failing many times, Ujan decided to try ...
[{"type": "stdin_stdout", "input": "10\n11\nartiovnldnp\nartiovsldsp\n2\naa\nzz\n2\naa\nxy\n2\nab\nba\n2\nza\nzz\n3\nabc\nbca\n16\naajjhdsjfdsfkadf\naajjhjsjfdsfkajf\n2\nix\nii\n2\noo\nqo\n2\npp\npa\n", "output": "Yes\nYes\nNo\nNo\nNo\nNo\nYes\nNo\nNo\nNo\n"}, {"type": "stdin_stdout", "input": "4\n5\nsouse\nhouhe\n3\nc...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWe have a point $A$ with coordinate $x = n$ on $OX$-axis. We'd like to find an integer point $B$ (also on $OX$-axis), such that the absolute difference between the distance from $O$ to $B$ and the distance from $A$ to $B$...
[{"type": "stdin_stdout", "input": "6\n4 0\n5 8\n0 1000000\n0 0\n1 0\n1000000 1000000\n", "output": "0\n3\n1000000\n0\n1\n0\n"}, {"type": "stdin_stdout", "input": "1\n1000000 0\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "1\n15 0\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "1\n3 0\n", "output": ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA new innovative ticketing systems for public transport is introduced in Bytesburg. Now there is a single travel card for all transport. To make a trip a passenger scan his card and then he is charged according to the far...
[{"type": "stdin_stdout", "input": "10\n13\n45\n46\n60\n103\n115\n126\n150\n256\n516\n", "output": "20\n20\n10\n0\n20\n0\n0\n20\n20\n10\n"}, {"type": "stdin_stdout", "input": "7\n100\n138\n279\n308\n396\n412\n821\n", "output": "20\n20\n20\n20\n20\n20\n0\n"}, {"type": "stdin_stdout", "input": "8\n0\n2\n51\n63\n69\n75\n8...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are n banks in the city where Vasya lives, they are located in a circle, such that any two banks are neighbouring if their indices differ by no more than 1. Also, bank 1 and bank n are neighbours if n > 1. No bank i...
[{"type": "stdin_stdout", "input": "50\n108431864 128274949 -554057370 -384620666 -202862975 -803855410 -482167063 -55139054 -215901009 0 0 0 0 0 94325701 730397219 358214459 -673647271 -131397668 -377892440 0 0 0 0 0 -487994257 -360271553 639988328 489338210 -281060728 250208758 0 993242346 -213071841 -59752620 -86435...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nKuro has just learned about permutations and he is really excited to create a new permutation type. He has chosen $n$ distinct positive integers and put all of them in a set $S$. Now he defines a magical permutation to be...
[{"type": "stdin_stdout", "input": "4\n1 2 3 4", "output": "3\n0 1 3 2 6 7 5 4"}, {"type": "stdin_stdout", "input": "3\n1 2 3", "output": "2\n0 1 3 2"}, {"type": "stdin_stdout", "input": "2\n2 3", "output": "2\n0 2 1 3"}, {"type": "stdin_stdout", "input": "2\n2 4", "output": "0\n0"}, {"type": "stdin_stdout", "input": "...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nTwilight Sparkle once got a crystal from the Crystal Mine. A crystal of size n (n is odd; n > 1) is an n × n matrix with a diamond inscribed into it.\n\nYou are given an odd integer n. You need to draw a crystal of size n...
[{"type": "stdin_stdout", "input": "21\n", "output": "**********D**********\n*********DDD*********\n********DDDDD********\n*******DDDDDDD*******\n******DDDDDDDDD******\n*****DDDDDDDDDDD*****\n****DDDDDDDDDDDDD****\n***DDDDDDDDDDDDDDD***\n**DDDDDDDDDDDDDDDDD**\n*DDDDDDDDDDDDDDDDDDD*\nDDDDDDDDDDDDDDDDDDDDD\n*DDDDDDDDDDDD...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nMishka got a six-faced dice. It has integer numbers from $2$ to $7$ written on its faces (all numbers on faces are different, so this is an almost usual dice).\n\nMishka wants to get exactly $x$ points by rolling his dice...
[{"type": "stdin_stdout", "input": "100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nOne of Arkady's friends works at a huge radio telescope. A few decades ago the telescope has sent a signal $s$ towards a faraway galaxy. Recently they've received a response $t$ which they believe to be a response from al...
[{"type": "stdin_stdout", "input": "01\nzbrronwaofovklkopelo\n", "output": "19\n"}, {"type": "stdin_stdout", "input": "010\nojwprcaaaaaaaaaab\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "010\ngvmorcaaaaaaaaaab\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "010\nugkircaaaaaaaaaab\n", "output": "0\n...
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 3 4 5 6 7 8 9 10\n2 2 3 4 5 6 7 8 9 10\n", "output": "96\n"}, {"type": "stdin_stdout", "input": "10\n1 2 3 4 5 6 7 8 9 10\n1 2 3 4 5 6 7 8 9 10\n", "output": "94\n"}, {"type": "stdin_stdout", "input": "3\n10000 10000 10000\n5000 5000 1\n", "output": "12499999\n"}, {"type": "s...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nGiven is a string S consisting of digits from 1 through 9.\nFind the number of pairs of integers (i,j) (1 ≤ i ≤ j ≤ |S|) that satisfy the following condition:\nCondition: In base ten, the i-th through j-th characters of S...
[{"type": "stdin_stdout", "input": "17363411548681837295128261415319567339781353176864449667411811151437528238242154453591258857339631698313648443916861223514163135267434612598561425414167173299132999132912477426521378378857571251998814421613836117444161875651252375139311654156139512913688822685276844411124583145973751...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLimak is a little polar bear. He loves connecting with other bears via social networks. He has n friends and his relation with the i-th of them is described by a unique integer t_{i}. The bigger this value is, the better ...
[{"type": "stdin_stdout", "input": "20 2 15\n12698951 55128070 116962690 156763505 188535242 194018601 269939893 428710623 442819431 483000923 516768937 552903993 633087286 656092270 671535141 714291344 717660646 846508634 879748146 937368929\n2 7\n1 2\n2 4\n1 19\n1 12\n1 5\n2 18\n2 11\n1 16\n2 1\n2 3\n2 19\n1 17\n2 9\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe employees of the R1 company often spend time together: they watch football, they go camping, they solve contests. So, it's no big deal that sometimes someone pays for someone else.\n\nToday is the day of giving out mo...
[{"type": "stdin_stdout", "input": "10 45\n10 5\n10 7\n6 1\n5 8\n3 5\n6 5\n1 2\n6 10\n2 9\n9 5\n4 1\n7 5\n1 8\n6 8\n10 9\n7 2\n7 9\n4 10\n7 3\n4 8\n10 3\n10 8\n2 10\n8 2\n4 2\n5 2\n9 1\n4 5\n1 3\n9 6\n3 8\n5 1\n6 4\n4 7\n8 7\n7 1\n9 3\n3 4\n6 2\n3 2\n6 7\n6 3\n4 9\n8 9\n1 10\n", "output": "2 3 1 5 7 8 4 6 9 10 \n"}, {"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are n cities and n - 1 roads in the Seven Kingdoms, each road connects two cities and we can reach any city from any other by the roads.\n\nTheon and Yara Greyjoy are on a horse in the first city, they are starting ...
[{"type": "stdin_stdout", "input": "70\n1 25\n57 1\n18 1\n65 1\n38 1\n1 41\n1 5\n1 69\n1 3\n31 1\n1 8\n1 9\n53 1\n70 1\n45 1\n1 24\n1 42\n1 30\n1 12\n1 37\n64 1\n1 28\n1 58\n1 22\n11 1\n1 4\n1 27\n1 16\n1 21\n54 1\n1 51\n1 43\n29 1\n56 1\n1 39\n32 1\n1 15\n1 17\n1 19\n1 40\n36 1\n48 1\n63 1\n1 7\n1 47\n1 13\n1 46\n60 1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere is a special offer in Vasya's favourite supermarket: if the customer buys $a$ chocolate bars, he or she may take $b$ additional bars for free. This special offer can be used any number of times.\n\nVasya currently h...
[{"type": "stdin_stdout", "input": "16\n1 1 1 1\n1 1 1 1000000000\n1 1 1000000000 1\n1 1 1000000000 1000000000\n1 1000000000 1 1\n1 1000000000 1 1000000000\n1 1000000000 1000000000 1\n1 1000000000 1000000000 1000000000\n1000000000 1 1 1\n1000000000 1 1 1000000000\n1000000000 1 1000000000 1\n1000000000 1 1000000000 1000...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nFurther research on zombie thought processes yielded interesting results. As we know from the previous problem, the nervous system of a zombie consists of n brains and m brain connectors joining some pairs of brains toget...
[{"type": "stdin_stdout", "input": "10 9\n5 1\n1 2\n9 3\n10 5\n6 3\n8 5\n2 7\n2 3\n9 4\n", "output": "6"}, {"type": "stdin_stdout", "input": "5 4\n1 2\n2 3\n3 4\n3 5\n", "output": "3"}, {"type": "stdin_stdout", "input": "4 3\n1 2\n1 3\n1 4\n", "output": "2"}, {"type": "stdin_stdout", "input": "3 2\n2 1\n3 2\n", "output...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSince Sonya is interested in robotics too, she decided to construct robots that will read and recognize numbers.\n\nSonya has drawn $n$ numbers in a row, $a_i$ is located in the $i$-th position. She also has put a robot a...
[{"type": "stdin_stdout", "input": "15\n1 2 2 1 2 4 2 1 1 6 6 4 2 5 4\n", "output": "20\n"}, {"type": "stdin_stdout", "input": "10\n2 2 4 4 3 1 1 2 3 2\n", "output": "14\n"}, {"type": "stdin_stdout", "input": "7\n1 2 1 1 1 3 2\n", "output": "7\n"}, {"type": "stdin_stdout", "input": "5\n1 5 4 1 3\n", "output": "9\n"}, {...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nOmkar is playing his favorite pixelated video game, Bed Wars! In Bed Wars, there are $n$ players arranged in a circle, so that for all $j$ such that $2 \\leq j \\leq n$, player $j - 1$ is to the left of the player $j$, an...
[{"type": "stdin_stdout", "input": "5\n4\nRLRL\n6\nLRRRRL\n8\nRLLRRRLL\n12\nLLLLRRLRRRLL\n5\nRRRRR\n", "output": "0\n1\n1\n3\n2\n"}, {"type": "stdin_stdout", "input": "1\n31\nLLLLRRLRLRRRRLRLLLLLLRRRRLLLLLL\n", "output": "7\n"}, {"type": "stdin_stdout", "input": "1\n28\nLLLLLLLLLLLLLLLRRRRLRRLLRLRL\n", "output": "6\n"}...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nMr. Kitayuta has just bought an undirected graph consisting of n vertices and m edges. The vertices of the graph are numbered from 1 to n. Each edge, namely edge i, has a color c_{i}, connecting vertex a_{i} and b_{i}.\n\...
[{"type": "stdin_stdout", "input": "5 7\n1 5 1\n2 5 1\n3 5 1\n4 5 1\n1 2 2\n2 3 2\n3 4 2\n5\n1 5\n5 1\n2 5\n1 5\n1 4\n", "output": "1\n1\n1\n1\n2\n"}, {"type": "stdin_stdout", "input": "4 5\n1 2 1\n1 2 2\n2 3 1\n2 3 3\n2 4 3\n3\n1 2\n3 4\n1 4\n", "output": "2\n1\n0\n"}, {"type": "stdin_stdout", "input": "2 5\n1 2 1\n1 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nVladik had started reading a complicated book about algorithms containing n pages. To improve understanding of what is written, his friends advised him to read pages in some order given by permutation P = [p_1, p_2, ..., ...
[{"type": "stdin_stdout", "input": "20 20\n18 17 2 3 16 15 1 9 12 8 20 11 13 14 4 5 19 7 10 6\n13 15 15\n1 1 1\n2 2 2\n11 14 13\n10 11 10\n2 8 6\n12 18 16\n4 8 8\n2 2 2\n5 11 11\n4 9 9\n5 6 6\n3 20 12\n8 8 8\n6 16 11\n9 18 18\n8 18 17\n1 1 1\n2 6 5\n1 4 3\n", "output": "No\nYes\nYes\nNo\nYes\nYes\nNo\nNo\nYes\nYes\nNo\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWe just discovered a new data structure in our research group: a suffix three!\n\nIt's very useful for natural language processing. Given three languages and three suffixes, a suffix three can determine which language a s...
[{"type": "stdin_stdout", "input": "30\nmnidamnida\nopmnida\nadinm_masu\nusam_masu\nuseddesu\nadinmmasu\nmnida_po\ndnmnida\nmasumnida\nusam_po\nmnidadesu\nused_masu\nmnida_mnida\nadinm_mnida\nusammasu\nmasu_desu\nusammnida\ngenki_desu\nmm_mnida\nadinmmnida\nop_mnida\nadinm_desu\nused_desu\nusam_desu\nadinmdesu\nsarangh...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nVasya has a sequence $a$ consisting of $n$ integers $a_1, a_2, \\dots, a_n$. Vasya may pefrom the following operation: choose some number from the sequence and swap any pair of bits in its binary representation. For examp...
[{"type": "stdin_stdout", "input": "5\n1000000000000000000 352839520853234088 175235832528365792 753467583475385837 895062156280564685\n", "output": "3\n"}, {"type": "stdin_stdout", "input": "4\n1 2 1 16\n", "output": "4\n"}, {"type": "stdin_stdout", "input": "3\n6 7 14\n", "output": "2\n"}, {"type": "stdin_stdout", "i...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLunar New Year is approaching, and Bob decides to take a wander in a nearby park.\n\nThe park can be represented as a connected graph with $n$ nodes and $m$ bidirectional edges. Initially Bob is at the node $1$ and he rec...
[{"type": "stdin_stdout", "input": "10 10\n1 4\n6 8\n2 5\n3 7\n9 4\n5 6\n3 4\n8 10\n8 9\n1 10\n", "output": "1 4 3 7 9 8 6 5 2 10 \n"}, {"type": "stdin_stdout", "input": "5 5\n1 4\n3 4\n5 4\n3 2\n1 5\n", "output": "1 4 3 2 5 \n"}, {"type": "stdin_stdout", "input": "3 2\n1 2\n1 3\n", "output": "1 2 3 \n"}, {"type": "std...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are the gym teacher in the school.\n\nThere are $n$ students in the row. And there are two rivalling students among them. The first one is in position $a$, the second in position $b$. Positions are numbered from $1$ t...
[{"type": "stdin_stdout", "input": "22\n100 100 100 1\n100 100 1 100\n100 0 100 1\n100 0 1 100\n2 0 1 2\n2 100 1 2\n2 0 2 1\n2 100 2 1\n100 0 1 2\n100 98 1 2\n100 97 1 2\n100 0 2 1\n100 98 2 1\n100 97 2 1\n100 0 99 100\n100 98 99 100\n100 97 99 100\n100 0 100 99\n100 98 100 99\n100 97 100 99\n100 0 13 37\n100 0 66 11\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nMadeline has an array $a$ of $n$ integers. A pair $(u, v)$ of integers forms an inversion in $a$ if:\n\n $1 \\le u < v \\le n$. $a_u > a_v$. \n\nMadeline recently found a magical paper, which allows her to write two ind...
[{"type": "stdin_stdout", "input": "5\n3 4 3 1 2\n", "output": "7\n1 5\n3 5\n2 5\n1 4\n3 4\n2 4\n2 3\n"}, {"type": "stdin_stdout", "input": "4\n1 8 1 6\n", "output": "2\n2 4\n2 3\n"}, {"type": "stdin_stdout", "input": "3\n3 1 2\n", "output": "2\n1 3\n1 2\n"}, {"type": "stdin_stdout", "input": "5\n1 1 1 2 2\n", "output"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIahub recently has learned Bubble Sort, an algorithm that is used to sort a permutation with n elements a_1, a_2, ..., a_{n} in ascending order. He is bored of this so simple algorithm, so he invents his own graph. The gr...
[{"type": "stdin_stdout", "input": "100\n36 48 92 87 28 85 42 10 44 41 39 3 79 9 14 56 1 16 46 35 93 8 82 26 100 59 60 2 96 52 13 98 70 81 71 94 54 91 17 88 33 30 19 50 18 73 65 29 78 21 61 7 99 97 45 89 57 27 76 11 49 72 84 69 43 62 4 22 75 6 66 83 38 34 86 15 40 51 37 74 67 31 20 63 77 80 12 53 5 25 58 90 68 24 64 23...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe HR manager was disappointed again. The last applicant failed the interview the same way as 24 previous ones. \"Do I give such a hard task?\" — the HR manager thought. \"Just raise number 5 to the power of n and get la...
[{"type": "stdin_stdout", "input": "1000000000000000000\n", "output": "25"}, {"type": "stdin_stdout", "input": "2000000000000000000\n", "output": "25"}, {"type": "stdin_stdout", "input": "987654321012345678\n", "output": "25"}, {"type": "stdin_stdout", "input": "2\n", "output": "25"}, {"type": "stdin_stdout", "input": ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe semester is already ending, so Danil made an effort and decided to visit a lesson on harmony analysis to know how does the professor look like, at least. Danil was very bored on this lesson until the teacher gave the ...
[{"type": "stdin_stdout", "input": "4\n", "output": "++++++++++++++++\n+*+*+*+*+*+*+*+*\n++**++**++**++**\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\nIn Aramic language words can only represent objects.\n\nWords in Aramic have special properties: A word is a root if it does not contain the same letter more than once. A root and all its permutations represent the sam...
[{"type": "stdin_stdout", "input": "10\nbda bbb cda dca dda dcb bcd dcb ada ddd\n", "output": "6"}, {"type": "stdin_stdout", "input": "2\nbcdfghimn efghijlmo\n", "output": "2"}, {"type": "stdin_stdout", "input": "5\na aa aaa ab abb\n", "output": "2"}, {"type": "stdin_stdout", "input": "2\nfhjlqs aceginpr\n", "output": ...
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 556\n5 64\n9 318\n3 373\n4 548\n7 219\n5 43\n5 27\n3 155\n8 359\n", "output": "5010.5333333333\n4198.5333333333\n4055.7333333333\n3843.3333333333\n3417.7333333333\n2949.7333333333\n2920.33333333...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYour math teacher gave you the following problem:\n\nThere are $n$ segments on the $x$-axis, $[l_1; r_1], [l_2; r_2], \\ldots, [l_n; r_n]$. The segment $[l; r]$ includes the bounds, i.e. it is a set of such $x$ that $l \\...
[{"type": "stdin_stdout", "input": "1\n10\n132182352 630066892\n323711215 923129673\n259700817 882571434\n226161845 398771294\n243750814 771888758\n322757488 771114163\n241900265 761492222\n197067927 815099563\n33872533 895781009\n271628366 729808874\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "4\n1\n1 1000...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nVus the Cossack has two binary strings, that is, strings that consist only of \"0\" and \"1\". We call these strings $a$ and $b$. It is known that $|b| \\leq |a|$, that is, the length of $b$ is at most the length of $a$.\...
[{"type": "stdin_stdout", "input": "10010110100000101100\n11101\n", "output": "6\n"}, {"type": "stdin_stdout", "input": "1011101100\n1100001\n", "output": "3\n"}, {"type": "stdin_stdout", "input": "1010111110\n0110\n", "output": "4\n"}, {"type": "stdin_stdout", "input": "01100010\n00110\n", "output": "3\n"}, {"type": "...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nInzane finally found Zane with a lot of money to spare, so they together decided to establish a country of their own.\n\nRuling a country is not an easy job. Thieves and terrorists are always ready to ruin the country's p...
[{"type": "stdin_stdout", "input": "11 1 5\n6\n1 2\n2 3\n3 4\n4 5\n5 6\n6 7\n7 8\n8 9\n9 10\n10 11\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "10 1 5\n5\n1 2\n2 3\n3 4\n4 5\n5 6\n6 7\n7 8\n8 9\n9 10\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "6 3 2\n1 5 6\n1 2\n1 3\n1 4\n1 5\n5 6\n", "output":...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe name of one small but proud corporation consists of n lowercase English letters. The Corporation has decided to try rebranding — an active marketing strategy, that includes a set of measures to change either the brand...
[{"type": "stdin_stdout", "input": "10 10\nlellelleel\ne l\ne l\ne l\ne l\ne l\ne e\nl l\nl e\nl l\ne e\n", "output": "lellelleel\n"}, {"type": "stdin_stdout", "input": "11 6\nabacabadaba\na b\nb c\na d\ne g\nf a\nb b\n", "output": "cdcbcdcfcdc\n"}, {"type": "stdin_stdout", "input": "6 1\npolice\np m\n", "output": "mol...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a string $s$ such that each its character is either 1, 2, or 3. You have to choose the shortest contiguous substring of $s$ such that it contains each of these three characters at least once.\n\nA contiguous...
[{"type": "stdin_stdout", "input": "12\n11111122222222222223\n122222222222222222333\n33333333331111111122\n11111111133333333333333332\n111111111123333333333\n1\n2\n3\n12\n23\n123\n1111111111111111211111111111111111111111111111111113\n", "output": "15\n19\n10\n18\n3\n0\n0\n0\n0\n0\n3\n36\n"}, {"type": "stdin_stdout", "i...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThis year in Equestria was a year of plenty, so Applejack has decided to build some new apple storages. According to the advice of the farm designers, she chose to build two storages with non-zero area: one in the shape o...
[{"type": "stdin_stdout", "input": "1\n1\n34\n- 1\n+ 1\n+ 1\n+ 1\n+ 1\n+ 1\n+ 1\n+ 1\n+ 1\n+ 1\n- 1\n- 1\n- 1\n- 1\n- 1\n+ 2\n+ 2\n+ 2\n+ 2\n- 1\n+ 2\n+ 2\n- 1\n+ 2\n- 1\n+ 3\n+ 3\n+ 1\n- 2\n- 2\n- 2\n- 2\n+ 1\n+ 3\n", "output": "NO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nYES\nYES\nYES\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nYES\nNO\nNO\nYE...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nHeidi has finally found the mythical Tree of Life – a legendary combinatorial structure which is said to contain a prophecy crucially needed to defeat the undead armies.\n\nOn the surface, the Tree of Life is just a regul...
[{"type": "stdin_stdout", "input": "10\n5 1\n1 2\n9 3\n10 5\n6 3\n8 5\n2 7\n2 3\n9 4\n", "output": "11"}, {"type": "stdin_stdout", "input": "5\n1 2\n2 3\n3 4\n3 5\n", "output": "4"}, {"type": "stdin_stdout", "input": "4\n1 2\n1 3\n1 4\n", "output": "3"}, {"type": "stdin_stdout", "input": "3\n2 1\n3 2\n", "output": "1"}...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIn this problem at each moment you have a set of intervals. You can move from interval (a, b) from our set to interval (c, d) from our set if and only if c < a < d or c < b < d. Also there is a path from interval I_1 from...
[{"type": "stdin_stdout", "input": "20\n1 1208 1583\n1 -258 729\n1 -409 1201\n1 194 1938\n1 -958 1575\n1 -1466 1752\n2 1 2\n2 1 2\n2 6 5\n1 -1870 1881\n1 -2002 2749\n1 -2002 2984\n1 -2002 3293\n2 2 4\n2 8 10\n2 9 6\n1 -2002 3572\n1 -2002 4175\n1 -2002 4452\n1 -2002 4605\n", "output": "YES\nYES\nYES\nYES\nYES\nNO\n"}, {...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou have a simple undirected graph consisting of $n$ vertices and $m$ edges. The graph doesn't contain self-loops, there is at most one edge between a pair of vertices. The given graph can be disconnected.\n\nLet's make a...
[{"type": "stdin_stdout", "input": "6 11\n1 2\n1 3\n1 4\n1 5\n1 6\n2 4\n2 5\n2 6\n3 4\n3 5\n3 6\n", "output": "1 2 2 3 3 3 "}, {"type": "stdin_stdout", "input": "6 9\n1 4\n1 5\n1 6\n2 4\n2 5\n2 6\n3 4\n3 5\n3 6\n", "output": "-1\n"}, {"type": "stdin_stdout", "input": "4 6\n1 2\n1 3\n1 4\n2 3\n2 4\n3 4\n", "output": "-1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nConsider a conveyor belt represented using a grid consisting of $n$ rows and $m$ columns. The cell in the $i$-th row from the top and the $j$-th column from the left is labelled $(i,j)$. \n\nEvery cell, except $(n,m)$, ha...
[{"type": "stdin_stdout", "input": "10\n1 2\nRC\n1 2\nDC\n2 1\nR\nC\n2 1\nD\nC\n7 6\nDRDDRR\nRDDDRR\nDRRRDD\nRRDRRR\nDDRRRR\nRRDRDR\nDDRDRC\n8 5\nDRDRD\nDRRRR\nRDRRD\nDDDRR\nRDDRR\nRRDDD\nDDRRR\nDDDRC\n8 3\nDDD\nDDR\nDRD\nRRR\nDRR\nDRD\nRRR\nRDC\n6 6\nDRDDDR\nDDDRDR\nRDDRRD\nDRRRRR\nRRRRRR\nDRDRRC\n6 8\nRRDDDRRR\nRDRDD...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIt's a walking tour day in SIS.Winter, so $t$ groups of students are visiting Torzhok. Streets of Torzhok are so narrow that students have to go in a row one after another.\n\nInitially, some students are angry. Let's des...
[{"type": "stdin_stdout", "input": "16\n4\nPPPP\n4\nAPPP\n4\nPAPP\n4\nAAPP\n4\nPPAP\n4\nAPAP\n4\nPAAP\n4\nAAAP\n4\nPPPA\n4\nAPPA\n4\nPAPA\n4\nAAPA\n4\nPPAA\n4\nAPAA\n4\nPAAA\n4\nAAAA\n", "output": "0\n3\n2\n2\n1\n1\n1\n1\n0\n2\n1\n1\n0\n1\n0\n0\n"}, {"type": "stdin_stdout", "input": "1\n100\nPAPPPAPAAPAAPAAPPAAAPPAPPAP...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nVasya has a string $s$ of length $n$ consisting only of digits 0 and 1. Also he has an array $a$ of length $n$. \n\nVasya performs the following operation until the string becomes empty: choose some consecutive substring ...
[{"type": "stdin_stdout", "input": "99\n101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1000000000 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 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA permutation of size n is an array of size n such that each integer from 1 to n occurs exactly once in this array. An inversion in a permutation p is a pair of indices (i, j) such that i > j and a_{i} < a_{j}. For exampl...
[{"type": "stdin_stdout", "input": "1\n1\n10\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n", "output": "even\neven\neven\neven\neven\neven\neven\neven\neven\neven\n"}, {"type": "stdin_stdout", "input": "7\n2 6 1 7 4 5 3\n5\n4 5\n7 7\n5 6\n4 5\n4 5\n", "output": "odd\nodd\neven\nodd\neven\n"}, {"type": "stdin_stdo...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nGiven a positive integer $m$, we say that a sequence $x_1, x_2, \\dots, x_n$ of positive integers is $m$-cute if for every index $i$ such that $2 \\le i \\le n$ it holds that $x_i = x_{i - 1} + x_{i - 2} + \\dots + x_1 + ...
[{"type": "stdin_stdout", "input": "10\n55 112 1\n13 1047113 2\n81 1130992 1\n1 1350 3\n51 449093 5\n17 79 4\n79 1697922 2\n28 1874623 5\n11 1709 3\n51 1062565 5\n", "output": "3 55 56 112 \n-1\n-1\n11 1 3 5 11 21 42 84 169 338 675 1350 \n15 51 55 110 219 439 877 1754 3509 7017 14034 28068 56137 112273 224547 449093 \n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere is a programing contest named SnakeUp, 2n people want to compete for it. In order to attend this contest, people need to form teams of exactly two people. You are given the strength of each possible combination of t...
[{"type": "stdin_stdout", "input": "3\n1000000\n999999 999998\n999997 999996 999995\n999994 999993 999992 999991\n999990 999989 999988 999987 999986\n", "output": "2 1 4 3 6 5\n"}, {"type": "stdin_stdout", "input": "3\n487060\n3831 161856\n845957 794650 976977\n83847 50566 691206 498447\n698377 156232 59015 382455 6269...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLet's denote a $k$-step ladder as the following structure: exactly $k + 2$ wooden planks, of which\n\n two planks of length at least $k+1$ — the base of the ladder; $k$ planks of length at least $1$ — the steps of the l...
[{"type": "stdin_stdout", "input": "4\n4\n1 3 1 3\n3\n3 3 2\n5\n2 3 3 4 2\n3\n1 1 2\n", "output": "2\n1\n2\n0\n"}, {"type": "stdin_stdout", "input": "2\n3\n1 2 3\n6\n1 1 3 2 10000 1000\n", "output": "1\n4\n"}, {"type": "stdin_stdout", "input": "1\n6\n100 50 50 50 50 50\n", "output": "4\n"}, {"type": "stdin_stdout", "in...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou have array a that contains all integers from 1 to n twice. You can arbitrary permute any numbers in a.\n\nLet number i be in positions x_{i}, y_{i} (x_{i} < y_{i}) in the permuted array a. Let's define the value d_{i}...
[{"type": "stdin_stdout", "input": "10\n", "output": "1 3 5 7 9 9 7 5 3 1 2 4 6 8 10 8 6 4 2 10\n"}, {"type": "stdin_stdout", "input": "4\n", "output": "1 3 3 1 2 4 2 4\n"}, {"type": "stdin_stdout", "input": "3\n", "output": "1 3 1 2 2 3\n"}, {"type": "stdin_stdout", "input": "2\n", "output": "1 1 2 2\n"}, {"type": "st...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nToday, Mezo is playing a game. Zoma, a character in that game, is initially at position $x = 0$. Mezo starts sending $n$ commands to Zoma. There are two possible commands: 'L' (Left) sets the position $x: =x - 1$; 'R' (...
[{"type": "stdin_stdout", "input": "13\nLRLLLLRRLLRLR\n", "output": "14\n"}, {"type": "stdin_stdout", "input": "4\nLRLR\n", "output": "5\n"}, {"type": "stdin_stdout", "input": "2\nLR\n", "output": "3\n"}, {"type": "stdin_stdout", "input": "1\nL\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "1\nR\n", "output":...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe marmots need to prepare k problems for HC^2 over n days. Each problem, once prepared, also has to be printed.\n\nThe preparation of a problem on day i (at most one per day) costs a_{i} CHF, and the printing of a probl...
[{"type": "stdin_stdout", "input": "13 13\n93 19 58 34 96 7 35 46 60 5 36 40 41\n57 3 42 68 26 85 25 45 50 21 60 23 79\n", "output": "1154"}, {"type": "stdin_stdout", "input": "12 1\n49 49 4 16 79 20 86 94 43 55 45 17\n15 36 51 20 83 6 83 80 72 22 66 100\n", "output": "10"}, {"type": "stdin_stdout", "input": "10 6\n60 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAn IPv6-address is a 128-bit number. For convenience, this number is recorded in blocks of 16 bits in hexadecimal record, the blocks are separated by colons — 8 blocks in total, each block has four hexadecimal digits. Her...
[{"type": "stdin_stdout", "input": "10\n1::7\n0:0::1\n::1ed\n::30:44\n::eaf:ff:000b\n56fe::\ndf0:3df::\nd03:ab:0::\n85::0485:0\n::\n", "output": "0001:0000:0000:0000:0000:0000:0000:0007\n0000:0000:0000:0000:0000:0000:0000:0001\n0000:0000:0000:0000:0000:0000:0000:01ed\n0000:0000:0000:0000:0000:0000:0030:0044\n0000:0000:...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThis is the easy version of the problem. The difference is constraints on the number of wise men and the time limit. You can make hacks only if all versions of this task are solved.\n\n$n$ wise men live in a beautiful cit...
[{"type": "stdin_stdout", "input": "5\n01001\n10110\n01010\n01101\n10010\n", "output": "2 2 6 2 6 14 10 6 2 6 14 14 2 14 6 14 \n"}, {"type": "stdin_stdout", "input": "4\n0101\n1000\n0001\n1010\n", "output": "2 2 6 2 2 6 2 2 \n"}, {"type": "stdin_stdout", "input": "3\n011\n101\n110\n", "output": "0 0 0 6 \n"}, {"type": ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a string $s$. Each character is either 0 or 1.\n\nYou want all 1's in the string to form a contiguous subsegment. For example, if the string is 0, 1, 00111 or 01111100, then all 1's form a contiguous subsegm...
[{"type": "stdin_stdout", "input": "7\n0\n0\n0\n0\n0\n0\n0\n", "output": "0\n0\n0\n0\n0\n0\n0\n"}, {"type": "stdin_stdout", "input": "3\n010011\n0\n1111000\n", "output": "2\n0\n0\n"}, {"type": "stdin_stdout", "input": "1\n00101111100\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "2\n01010\n0\n", "output": "1\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAshish has $n$ elements arranged in a line. \n\nThese elements are represented by two integers $a_i$ — the value of the element and $b_i$ — the type of the element (there are only two possible types: $0$ and $1$). He want...
[{"type": "stdin_stdout", "input": "10\n8\n94616 28275 43594 47466 68030 82703 84250 96281\n1 0 0 0 0 0 0 0\n5\n28821 83833 51486 69723 77684\n1 1 0 1 1\n8\n63740 94805 71389 67802 43519 34364 17842 98783\n0 1 0 1 0 1 0 0\n3\n63630 83145 89435\n1 1 1\n5\n66195 67879 10777 54269 80789\n1 1 1 1 0\n8\n42696 26113 2424 339...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIvar the Boneless is a great leader. He is trying to capture Kattegat from Lagertha. The war has begun and wave after wave Ivar's warriors are falling in battle.\n\nIvar has $n$ warriors, he places them on a straight line...
[{"type": "stdin_stdout", "input": "100 55\n1 2 4 4 3 5 5 2 3 4 2 1 1 2 3 5 1 5 4 2 5 4 4 3 3 5 3 4 4 5 5 2 3 3 4 4 3 4 5 5 5 5 3 5 1 2 4 3 4 5 3 3 2 1 4 5 3 4 4 1 5 1 5 2 2 1 4 5 3 3 1 4 2 5 4 5 3 2 5 5 2 3 2 3 2 2 3 4 4 4 1 4 2 4 5 3 1 3 3 1\n5 2 1 4 3 4 3 1 4 4 1 2 3 2 1 5 5 4 5 4 2 5 2 1 5 1 4 4 3 5 4 5 1 4 4 1 5 3...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou're given an undirected graph with $n$ nodes and $m$ edges. Nodes are numbered from $1$ to $n$.\n\nThe graph is considered harmonious if and only if the following property holds: For every triple of integers $(l, m, r...
[{"type": "stdin_stdout", "input": "500 5\n100 300\n200 400\n420 440\n430 450\n435 460\n", "output": "335\n"}, {"type": "stdin_stdout", "input": "14 8\n1 2\n2 7\n3 4\n6 3\n5 7\n3 8\n6 8\n11 12\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "200000 1\n1 200000\n", "output": "199998\n"}, {"type": "stdin_stdout",...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nToday, as a friendship gift, Bakry gave Badawy $n$ integers $a_1, a_2, \\dots, a_n$ and challenged him to choose an integer $X$ such that the value $\\underset{1 \\leq i \\leq n}{\\max} (a_i \\oplus X)$ is minimum possibl...
[{"type": "stdin_stdout", "input": "5\n1073741823 1073741823 1073741823 1073741823 1073741823\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "2\n0 1073741823\n", "output": "536870912\n"}, {"type": "stdin_stdout", "input": "1\n1073741823\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "3\n1 2 3\n", "out...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAyush, Ashish and Vivek are busy preparing a new problem for the next Codeforces round and need help checking if their test cases are valid.\n\nEach test case consists of an integer $n$ and two arrays $a$ and $b$, of size...
[{"type": "stdin_stdout", "input": "24\n4\n1 2 3 4\n1 2 3 4\n4\n1 2 3 4\n1 2 4 3\n4\n1 2 3 4\n1 3 2 4\n4\n1 2 3 4\n1 3 4 2\n4\n1 2 3 4\n1 4 2 3\n4\n1 2 3 4\n1 4 3 2\n4\n1 2 3 4\n2 1 3 4\n4\n1 2 3 4\n2 1 4 3\n4\n1 2 3 4\n2 3 1 4\n4\n1 2 3 4\n2 3 4 1\n4\n1 2 3 4\n2 4 1 3\n4\n1 2 3 4\n2 4 3 1\n4\n1 2 3 4\n3 1 2 4\n4\n1 2 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nDora the explorer has decided to use her money after several years of juicy royalties to go shopping. What better place to shop than Nlogonia?\n\nThere are $n$ stores numbered from $1$ to $n$ in Nlogonia. The $i$-th of th...
[{"type": "stdin_stdout", "input": "10 100\n4 51 22 73 78\n1 52\n5 49 74 100 14 80\n1 6\n2 98 65\n5 79 13 47 24 77\n6 47 57 35 24 59 94\n9 89 11 3 67 80 70 44 75 6\n7 12 9 92 30 10 29 70\n8 99 34 89 87 63 2 96 25\n", "output": "impossible\n"}, {"type": "stdin_stdout", "input": "3 10\n4 6 10 1 9\n9 6 1 8 10 4 9 5 7 2\n8...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLittle Artem has invented a time machine! He could go anywhere in time, but all his thoughts of course are with computer science. He wants to apply this time machine to a well-known data structure: multiset.\n\nArtem want...
[{"type": "stdin_stdout", "input": "10\n1 1 1000000000\n1 4 1000000000\n2 2 1000000000\n1 5 1000000000\n1 8 1000000000\n2 15 1000000000\n3 3 1000000000\n3 10 1000000000\n3 6 1000000000\n3 7 1000000000\n", "output": "0\n3\n2\n2\n"}, {"type": "stdin_stdout", "input": "20\n1 1 1\n1 2 2\n1 3 3\n1 4 4\n1 5 5\n2 11 5\n2 12 4...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given an array a consisting of n positive integers. You pick two integer numbers l and r from 1 to n, inclusive (numbers are picked randomly, equiprobably and independently). If l > r, then you swap values of l an...
[{"type": "stdin_stdout", "input": "20\n49 33 9 8 50 21 12 44 23 39 24 10 17 4 17 40 24 19 27 21\n", "output": "7.010000\n"}, {"type": "stdin_stdout", "input": "10\n9 6 8 5 5 2 8 9 2 2\n", "output": "3.100000\n"}, {"type": "stdin_stdout", "input": "1\n1000000\n", "output": "1.000000\n"}, {"type": "stdin_stdout", "input...
code_stdio