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\nAndrzej was given a task:\nThere are n jars with pills. In every jar there is a different type of pill and the amount of pills in each jar is infinite. One type of pill makes a person glow about 30 minutes after taking an...
[{"input": "16", "output": "[3]", "fn_name": "friends"}, {"input": "0", "output": "[0]", "fn_name": "friends"}, {"input": "1", "output": "[0]", "fn_name": "friends"}, {"input": "2", "output": "[0]", "fn_name": "friends"}, {"input": "4", "output": "[1]", "fn_name": "friends"}, {"input": "3", "output": "[1]", "fn_name": ...
code_functional
[ { "content": "Solve the following coding problem using the programming language python:\n\nWe make a tower by stacking up blocks. The tower consists of several stages and each stage is constructed by connecting blocks horizontally. Each block is of the same weight and is tough enough to withstand the weight equ...
[{"type": "stdin_stdout", "input": "11 16", "output": "11\n"}, {"type": "stdin_stdout", "input": "31 16", "output": "24\n"}, {"type": "stdin_stdout", "input": "27 16", "output": "22\n"}, {"type": "stdin_stdout", "input": "23 60", "output": "23\n"}, {"type": "stdin_stdout", "input": "31 23", "output": "27\n"}, {"type": ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nDecades have passed since the beginning of AtCoder Beginner Contest.\nThe contests are labeled as ABC001, ABC002, ... from the first round, but after the 999-th round ABC999, a problem occurred: how the future rounds shou...
[{"type": "stdin_stdout", "input": "1000\n", "output": "ABD\n"}, {"type": "stdin_stdout", "input": "1481\n", "output": "ABD\n"}, {"type": "stdin_stdout", "input": "1998\n", "output": "ABD\n"}, {"type": "stdin_stdout", "input": "1513\n", "output": "ABD\n"}, {"type": "stdin_stdout", "input": "1285\n", "output": "ABD\n"},...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nBerland National Library has recently been built in the capital of Berland. In addition, in the library you can take any of the collected works of Berland leaders, the library has a reading room.\n\nToday was the pilot la...
[{"type": "stdin_stdout", "input": "50\n+ 100\n- 100\n+ 100\n- 100\n+ 100\n- 100\n+ 100\n- 100\n+ 100\n- 100\n+ 100\n- 100\n+ 100\n- 100\n+ 100\n- 100\n+ 100\n- 100\n+ 100\n- 100\n+ 100\n- 100\n+ 100\n- 100\n+ 100\n- 100\n+ 100\n- 100\n+ 100\n- 100\n+ 100\n- 100\n+ 100\n- 100\n+ 100\n- 100\n+ 100\n- 100\n+ 100\n- 100\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nEmuskald is addicted to Codeforces, and keeps refreshing the main page not to miss any changes in the \"recent actions\" list. He likes to read thread conversations where each thread consists of multiple messages.\n\nRece...
[{"type": "stdin_stdout", "input": "132\n13 7 33 124 118 76 94 92 16 107 130 1 46 58 28 119 42 53 102 81 99 29 57 70 125 45 100 68 10 63 34 38 19 49 56 30 103 72 106 3 121 110 78 2 31 129 128 24 77 61 87 47 15 21 88 60 5 101 82 108 84 41 86 66 79 75 54 97 55 12 69 44 83 131 9 95 11 85 52 35 115 80 111 27 109 36 39 104 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe Little Elephant loves to play with color cards.\n\nHe has n cards, each has exactly two colors (the color of the front side and the color of the back side). Initially, all the cards lay on the table with the front sid...
[{"type": "stdin_stdout", "input": "100\n1 2\n2 1\n2 1\n1 2\n1 1\n1 2\n2 1\n1 1\n2 2\n2 1\n2 1\n1 1\n1 1\n2 1\n2 1\n2 1\n2 1\n2 1\n1 1\n2 1\n1 1\n1 1\n2 2\n1 2\n1 2\n1 2\n2 2\n1 2\n1 2\n2 1\n1 2\n2 1\n1 2\n2 2\n1 1\n2 1\n1 2\n2 1\n2 1\n1 2\n2 1\n2 1\n1 2\n2 1\n1 1\n1 2\n1 1\n1 1\n2 2\n2 2\n2 1\n2 1\n1 2\n2 2\n1 1\n2 1\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIn order to make the \"Sea Battle\" game more interesting, Boris decided to add a new ship type to it. The ship consists of two rectangles. The first rectangle has a width of $w_1$ and a height of $h_1$, while the second ...
[{"type": "stdin_stdout", "input": "100000000 100000000 100000000 100000000\n", "output": "600000004\n"}, {"type": "stdin_stdout", "input": "100000000 100000000 100000000 100000000\n", "output": "600000004\n"}, {"type": "stdin_stdout", "input": "100000000 100000000 99999999 100000000\n", "output": "600000004\n"}, {"typ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a sequence $a_1, a_2, \\dots, a_n$ consisting of $n$ non-zero integers (i.e. $a_i \\ne 0$). \n\nYou have to calculate two following values: the number of pairs of indices $(l, r)$ $(l \\le r)$ such that $a_...
[{"type": "stdin_stdout", "input": "10\n-27433367 -21216390 1 303383863 -799030648 -1 160141051 -1 -342089574 -215298491\n", "output": "28 27\n"}, {"type": "stdin_stdout", "input": "10\n-27433367 -21216390 1 303383863 -799030648 -1 160141051 -1 -342089574 -215298491\n", "output": "28 27\n"}, {"type": "stdin_stdout", "i...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWrite a program which reads relations in a SNS (Social Network Service), and judges that given pairs of users are reachable each other through the network.\n\nConstraints\n\n* $2 \\leq n \\leq 100,000$\n* $0 \\leq m \\leq...
[{"type": "stdin_stdout", "input": "16 9\n0 1\n0 2\n3 4\n5 7\n5 2\n3 7\n6 13\n11 12\n8 9\n3\n0 1\n5 9\n1 3", "output": "yes\nno\nyes\n"}, {"type": "stdin_stdout", "input": "16 9\n0 1\n0 2\n3 4\n5 7\n5 2\n3 7\n6 13\n7 8\n8 9\n3\n0 1\n5 9\n1 3", "output": "yes\nyes\nyes\n"}, {"type": "stdin_stdout", "input": "16 9\n0 1\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given an array a of size n, and q queries to it. There are queries of two types: 1 l_{i} r_{i} β€” perform a cyclic shift of the segment [l_{i}, r_{i}] to the right. That is, for every x such that l_{i} ≀ x < r_{i...
[{"type": "stdin_stdout", "input": "6 3 5\n1 2 3 4 10 6\n2 1 3\n2 3 6\n1 1 6\n2 2 1 5 3\n", "output": "3 3 1 10 2\n"}, {"type": "stdin_stdout", "input": "6 3 5\n1 2 3 4 5 12\n2 1 3\n2 3 6\n1 1 6\n2 2 1 5 4\n", "output": "3 3 1 5 12\n"}, {"type": "stdin_stdout", "input": "6 3 5\n1 2 3 4 10 6\n2 2 3\n2 3 6\n1 1 6\n2 2 1 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLo and Behold! For you may be surprised by what our chief chef Noodle has in mind for this season! Today, Noodle announced one of his most extra-ordinary ideas ever - Project Spoon. \nNoodle plans to deploy large spoons i...
[{"type": "stdin_stdout", "input": "2\n18\n229", "output": "6\n10\n"}, {"type": "stdin_stdout", "input": "2\n18\n344", "output": "6\n11\n"}, {"type": "stdin_stdout", "input": "2\n128\n46", "output": "10\n8\n"}, {"type": "stdin_stdout", "input": "2\n11\n493", "output": "6\n12\n"}, {"type": "stdin_stdout", "input": "2\n2...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given an integer N. Among the integers between 1 and N (inclusive), how many Shichi-Go-San numbers (literally \"Seven-Five-Three numbers\") are there?\nHere, a Shichi-Go-San number is a positive integer that satis...
[{"type": "stdin_stdout", "input": "999999999\n", "output": "26484\n"}, {"type": "stdin_stdout", "input": "500000000\n", "output": "14384\n"}, {"type": "stdin_stdout", "input": "777757375\n", "output": "26423\n"}, {"type": "stdin_stdout", "input": "777777752\n", "output": "26483\n"}, {"type": "stdin_stdout", "input": "...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nGiven is an integer N. Find the number of positive integers less than or equal to N that have an odd number of digits (in base ten without leading zeros).\n\n-----Constraints-----\n - 1 \\leq N \\leq 10^5\n\n-----Input---...
[{"type": "stdin_stdout", "input": "100000\n", "output": "90909\n"}, {"type": "stdin_stdout", "input": "45901\n", "output": "36811\n"}, {"type": "stdin_stdout", "input": "99924\n", "output": "90834\n"}, {"type": "stdin_stdout", "input": "99999\n", "output": "90909\n"}, {"type": "stdin_stdout", "input": "100010", "outpu...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nTernary numeric notation is quite popular in Berland. To telegraph the ternary number the Borze alphabet is used. Digit 0 is transmitted as Β«.Β», 1 as Β«-.Β» and 2 as Β«--Β». You are to decode the Borze code, i.e. to find out ...
[{"type": "stdin_stdout", "input": "..---.-.--.-..-.-.---...--.-------..-.---.-...-.-----...-.-.....-..--.---.-.-.-----.-.-.-..----.-.----.-.---.--.-..-.----..---.-..--..------.-.-.---.-.-...--....-.--.--.-.-.-..-..-...--..---.-.------.\n", "output": "00211201011210020222101211001221001100001020211122111102201220121201...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given an array $A$ of length $N$ weights of masses $A_1$, $A_2$...$A_N$.β€―No two weights have the same mass. You can put every weight on one side of the balance (left or right).β€―Youβ€―don't have to putβ€―weightsβ€―in ord...
[{"type": "stdin_stdout", "input": "5\n4 11 1 9 12\nLLRLL\n", "output": "9 L\n4 R\n11 R\n12 L\n1 L\n"}, {"type": "stdin_stdout", "input": "5\n5 8 2 15 10\nLLRLL\n", "output": "8 L\n5 R\n10 R\n15 L\n2 L\n"}, {"type": "stdin_stdout", "input": "5\n4 14 1 9 12\nLLRLL\n", "output": "9 L\n4 R\n12 R\n14 L\n1 L\n"}, {"ty...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\n# Task\n You are given a string `s`. Every letter in `s` appears once. \n \n Consider all strings formed by rearranging the letters in `s`. After ordering these strings in dictionary order, return the middle term. (If the...
[{"input": "\"abcdxgz\"", "output": "[\"dczxgba\"]", "fn_name": "middle_permutation"}, {"input": "\"abcdxg\"", "output": "[\"cxgdba\"]", "fn_name": "middle_permutation"}, {"input": "\"abcdx\"", "output": "[\"cbxda\"]", "fn_name": "middle_permutation"}, {"input": "\"abcd\"", "output": "[\"bdca\"]", "fn_name": "middle_pe...
code_functional
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given an array $a$ of length $n$ and array $b$ of length $m$ both consisting of only integers $0$ and $1$. Consider a matrix $c$ of size $n \\times m$ formed by following rule: $c_{i, j} = a_i \\cdot b_j$ (i.e. $a...
[{"type": "stdin_stdout", "input": "50 50 6\n1 0 0 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 0 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 0 1 1 1 0 1\n1 1 0 1 0 1 1 0 1 1 1 1 1 1 0 1 1 0 1 0 0 1 1 1 1 0 0 1 0 1 1 1 0 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 0\n", "output": "2153\n"}, {"type": "stdin_stdout", "input": "50 50 6\n1 0 0...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSanta Claus has received letters from $n$ different kids throughout this year. Of course, each kid wants to get some presents from Santa: in particular, the $i$-th kid asked Santa to give them one of $k_i$ different items...
[{"type": "stdin_stdout", "input": "10\n5 48258 84644 992412 548310 132019\n5 132019 556600 548310 94345 992412\n6 132019 771663 523582 548310 463969 556600\n7 556600 132019 992412 523582 548310 70239 84644\n4 504172 548310 523582 286042\n7 548310 84644 771663 556600 132019 463969 48258\n5 556600 771663 463969 523582 8...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSmallR is an archer. SmallR is taking a match of archer with Zanoes. They try to shoot in the target in turns, and SmallR shoots first. The probability of shooting the target each time is $\\frac{a}{b}$ for SmallR while $...
[{"type": "stdin_stdout", "input": "125 1283 234 1112\n", "output": "0.33904754471037046\n"}, {"type": "stdin_stdout", "input": "719 1275 626 1265\n", "output": "0.7232359328271274\n"}, {"type": "stdin_stdout", "input": "125 1283 148 603\n", "output": "0.30545998322249646\n"}, {"type": "stdin_stdout", "input": "125 128...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou have a given integer $n$. Find the number of ways to fill all $3 \\times n$ tiles with the shape described in the picture below. Upon filling, no empty spaces are allowed. Shapes cannot overlap. $\\square$ This pictur...
[{"type": "stdin_stdout", "input": "60\n", "output": "1073741824"}, {"type": "stdin_stdout", "input": "60\n", "output": "1073741824"}, {"type": "stdin_stdout", "input": "54\n", "output": "134217728\n"}, {"type": "stdin_stdout", "input": "58\n", "output": "536870912\n"}, {"type": "stdin_stdout", "input": "56\n", "output...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYoung boy Artem tries to paint a picture, and he asks his mother Medina to help him. Medina is very busy, that's why she asked for your help.\n\nArtem wants to paint an $n \\times m$ board. Each cell of the board should b...
[{"type": "stdin_stdout", "input": "19\n15 73\n16 92\n22 97\n13 64\n49 127\n79 79\n66 13\n49 48\n173 75\n64 77\n27 95\n27 156\n29 53\n48 10\n265 151\n26 37\n13 2\n44 13\n85 70\n", "output": "WBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB\nBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIn 2020, AtCoder Inc. with an annual sales of more than one billion yen (the currency of Japan) has started a business in programming education.\n\nOne day, there was an exam where a one-year-old child must write a progra...
[{"type": "stdin_stdout", "input": "1\n", "output": "Hello World\n"}, {"type": "stdin_stdout", "input": "2\n-2\n116", "output": "114\n"}, {"type": "stdin_stdout", "input": "2\n-2\n178", "output": "176\n"}, {"type": "stdin_stdout", "input": "2\n-2\n184", "output": "182\n"}, {"type": "stdin_stdout", "input": "2\n-2\n143"...
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\nThe Little Elephant has an integer a, written in the binary notation. He wants to write this number on a piece of paper.\n\nTo make sure that the number a fits on the piece of paper, the Little Elephant ought to delete ex...
[{"type": "stdin_stdout", "input": "11100010010010000110101101101100111111001010001101101001001111010110010111001011010000001100110101000101111000001111101111110010000010101110011110101101010110001100011101111011100010011101100111110010111111100110101000000111101000000000110100100101111101000110101010101101001110001110...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA direced graph is strongly connected if every two nodes are reachable from each other. In a strongly connected component of a directed graph, every two nodes of the component are mutually reachable.\n\nConstraints\n\n* 1...
[{"type": "stdin_stdout", "input": "9 6\n1 1\n1 0\n1 4\n2 4\n4 3\n4 2\n4\n1 1\n-1 3\n2 -1\n3 4", "output": "1\n0\n0\n0\n"}, {"type": "stdin_stdout", "input": "5 6\n0 1\n1 0\n1 0\n2 4\n4 1\n3 2\n4\n0 1\n-1 0\n2 0\n3 4", "output": "1\n0\n0\n0\n"}, {"type": "stdin_stdout", "input": "9 6\n0 1\n1 0\n1 2\n2 4\n4 3\n4 2\n4\n1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nINTERCAL is the oldest of esoteric programming languages. One of its many weird features is the method of character-based output, known as Turing Tape method. It converts an array of unsigned 8-bit integers into a sequenc...
[{"type": "stdin_stdout", "input": "aMCT]:0hDJ*Up5g_l:O&>>%gjQkZkb(mi&;\\7dL\"nWOGz/;,6h*@Q0R53MS2<}F~+Ms\\\"cF-lgF0>C&y7)72\\.T\"8*#VO=|^OtYs\n", "output": "122\n212\n240\n152\n112\n94\n80\n246\n244\n208\n254\n170\n156\n98\n198\n236\n196\n218\n106\n142\n232\n0\n216\n190\n144\n204\n180\n124\n132\n144\n50\n94\n32\n50\n1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nOverlooking the captivating blend of myriads of vernal hues, Arkady the painter lays out a long, long canvas.\n\nArkady has a sufficiently large amount of paint of three colours: cyan, magenta, and yellow. On the one-dime...
[{"type": "stdin_stdout", "input": "100\nC?M?M?M?YM??YMYC?MCYMYM??Y??YC?CYC???YM?YM??MYMY?CYCYMYC?YC?C?CYCMY??CMC?YMCMYCYCYMYM?CYM?M?MCMCMY?Y\n", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "100\n????????????????????????????????????????????????????????????????????????????????????????????????????\n", "output":...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given $n$ integers $w_i (i = 0, 1, ..., n-1)$ to be sorted in ascending order. You can swap two integers $w_i$ and $w_j$. Each swap operation has a cost, which is the sum of the two integers $w_i + w_j$. You can p...
[{"type": "stdin_stdout", "input": "5\n0 91 14 2 11", "output": "120\n"}, {"type": "stdin_stdout", "input": "5\n0 91 14 3 11", "output": "122\n"}, {"type": "stdin_stdout", "input": "5\n1 25 13 2 11", "output": "55\n"}, {"type": "stdin_stdout", "input": "5\n0 91 9 2 11", "output": "106\n"}, {"type": "stdin_stdout", "inp...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA [Narcissistic Number](https://en.wikipedia.org/wiki/Narcissistic_number) is a positive number which is the sum of its own digits, each raised to the power of the number of digits in a given base. In this Kata, we will r...
[{"input": "1634", "output": "[true]", "fn_name": "narcissistic"}, {"input": "153", "output": "[true]", "fn_name": "narcissistic"}, {"input": "370", "output": "[true]", "fn_name": "narcissistic"}, {"input": "371", "output": "[true]", "fn_name": "narcissistic"}, {"input": "1", "output": "[true]", "fn_name": "narcissisti...
code_functional
[ { "content": "Solve the following coding problem using the programming language python:\n\nPolycarp is preparing the first programming contest for robots. There are $n$ problems in it, and a lot of robots are going to participate in it. Each robot solving the problem $i$ gets $p_i$ points, and the score of each...
[{"type": "stdin_stdout", "input": "100\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 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\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 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nMobile phones are equipped with a function that displays input candidates in order to efficiently input texts such as emails. This records frequently used words and presents words that have the entered letters as initial ...
[{"type": "stdin_stdout", "input": "1\nben mikes bananas eht best among many fruits bec`use bananas are sweet and cheao\nb\n1\nwinners get to visit aizu and eht uvinersity of ahuz amd maje amnx friends as wlel\na\n3\nask alex about\nthe answer for the\nassignmdnt pn diordn` `pps\na\n2\ngnimmargorp si both\na sport aod ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nVova's house is an array consisting of $n$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $i$-th element of the array is $1$ if...
[{"type": "stdin_stdout", "input": "187 64\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 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 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIt is known that there are k fish species in the polar ocean, numbered from 1 to k. They are sorted by non-decreasing order of their weight, which is a positive number. Let the weight of the i-th type of fish be wi, then ...
[{"type": "stdin_stdout", "input": "100 50 11\n7 15 0 1 6 7 9 2 4 6 7 7 3 9 4 5 0 7 8 19 4 1 3 6 8 10 4 6 6 1 6 6 7 4 10 3 10 1 3 1 10 6 9 9 5 2 9 2 9 8 10 2 10 3 3 2 3 8 6 2 7 10 7 2 7 2 8 9 6 2 5 4 4 5 3 3 9 10 9 4 9 3 9 5 3 11 6 2 3 6 10 3 10 2 6 13 10 10 4 8\n3 3 2 9 4 4 10 2 7 3 3 2 6 3 3 4 7 4 1 2 3 8 1 6 14 7 2 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIn this Kata, you will be given an array of unique elements, and your task is to rerrange the values so that the first max value is followed by the first minimum, followed by second max value then second min value, etc. \...
[{"input": "[78, 79, 52, 87, 16, 74, 31, 63, 80]", "output": "[[87, 16, 80, 31, 79, 52, 78, 63, 74]]", "fn_name": "solve"}, {"input": "[52, 77, 72, 44, 74, 76, 40]", "output": "[[77, 40, 76, 44, 74, 52, 72]]", "fn_name": "solve"}, {"input": "[1, 6, 9, 4, 3, 7, 8, 2]", "output": "[[9, 1, 8, 2, 7, 3, 6, 4]]", "fn_name": ...
code_functional
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are playing one RPG from the 2010s. You are planning to raise your smithing skill, so you need as many resources as possible. So how to get resources? By stealing, of course.\n\nYou decided to rob a town's blacksmith ...
[{"type": "stdin_stdout", "input": "9\n475033014 267058742\n26843 148652\n850113755 279316120\n871120869 885251487\n51363 15651\n220811492 256297120\n473761699 194406678\n38725 23371\n167395720 333327477\n107541472 19164492\n74340 1113\n654389849 224345301\n663158140 437349008\n332 5052\n971865476 538450184\n959712803 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAs you know, every birthday party has a cake! This time, Babaei is going to prepare the very special birthday party's cake.\n\nSimple cake is a cylinder of some radius and height. The volume of the simple cake is equal to...
[{"type": "stdin_stdout", "input": "24\n14 3600\n105 64\n40 441\n15 3136\n24 1225\n42 400\n84 100\n12 4900\n120 49\n56 225\n140 36\n70 144\n168 25\n60 196\n30 784\n280 9\n10 7056\n21 1600\n28 579\n210 16\n420 4\n840 1\n35 576\n20 1764\n", "output": "3642789.7791728945\n"}, {"type": "stdin_stdout", "input": "24\n14 3600...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe football season has just ended in Berland. According to the rules of Berland football, each match is played between two teams. The result of each match is either a draw, or a victory of one of the playing teams. If a ...
[{"type": "stdin_stdout", "input": "1000000000000 68088352351238212 100000 99999\n", "output": "680883461725 61788 319116476487\n"}, {"type": "stdin_stdout", "input": "1108577267933 48182461851369906 125899 19927\n", "output": "382707249106 95156 725869923671\n"}, {"type": "stdin_stdout", "input": "1252579684821 112616...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIn an infinite array with two rows, the numbers in the top row are denoted\n\n`. . . , A[βˆ’2], A[βˆ’1], A[0], A[1], A[2], . . .`\n\nand the numbers in the bottom row are denoted\n\n`. . . , B[βˆ’2], B[βˆ’1], B[0], B[1], B[2], . ...
[{"input": "[0, 4, 6, 13]\n100", "output": "[335254562473098582210532865941148591672699700764231400858]", "fn_name": "find_a"}, {"input": "[1, 2, 3, 5]\n100", "output": "[60560100487003612846322657690093088848428068520476594299]", "fn_name": "find_a"}, {"input": "[-20, 1, -3, 14]\n-5", "output": "[-44402]", "fn_name": ...
code_functional
[ { "content": "Solve the following coding problem using the programming language python:\n\nVanya got n cubes. He decided to build a pyramid from them. Vanya wants to build the pyramid as follows: the top level of the pyramid must consist of 1 cube, the second level must consist of 1 + 2 = 3 cubes, the third lev...
[{"type": "stdin_stdout", "input": "10000\n", "output": "38\n"}, {"type": "stdin_stdout", "input": "10001\n", "output": "38\n"}, {"type": "stdin_stdout", "input": "4115\n", "output": "28\n"}, {"type": "stdin_stdout", "input": "9894\n", "output": "38\n"}, {"type": "stdin_stdout", "input": "7969\n", "output": "35\n"}, {"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are N bags of biscuits. The i-th bag contains A_i biscuits.\n\nTakaki will select some of these bags and eat all of the biscuits inside. Here, it is also possible to select all or none of the bags.\n\nHe would like ...
[{"type": "stdin_stdout", "input": "45 1\n17 55 85 55 74 20 90 67 40 121 39 178 91 50 16 38 14 43 24 68 25 9 89 71 41 16 53 11 61 15 85 72 62 67 42 26 36 66 4 87 59 91 4 24 26", "output": "17592186044416\n"}, {"type": "stdin_stdout", "input": "45 1\n17 55 85 55 74 20 90 67 40 121 39 178 91 50 16 38 14 43 24 68 25 9 89 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSome days ago, I learned the concept of LCM (least common multiple). I've played with it for several times and I want to make a big number with it.\n\nBut I also don't want to use many numbers, so I'll choose three positi...
[{"type": "stdin_stdout", "input": "1000000\n", "output": "999996000003000000\n"}, {"type": "stdin_stdout", "input": "862795\n", "output": "642275489615199390\n"}, {"type": "stdin_stdout", "input": "763116\n", "output": "444394078546562430\n"}, {"type": "stdin_stdout", "input": "756604\n", "output": "433115377058855412...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nGiven a string, return a new string that has transformed based on the input:\n\n* Change case of every character, ie. lower case to upper case, upper case to lower case.\n* Reverse the order of words from the input.\n\n**...
[{"input": "\"To be OR not to be That is the Question\"", "output": "[\"qUESTION THE IS tHAT BE TO NOT or BE tO\"]", "fn_name": "string_transformer"}, {"input": "\"You Know When THAT Hotline Bling\"", "output": "[\"bLING hOTLINE that wHEN kNOW yOU\"]", "fn_name": "string_transformer"}, {"input": "\" A b C d E f G \...
code_functional
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a string S consisting of lowercase English letters. Determine whether all the characters in S are different.\n\n-----Constraints-----\n - 2 ≀ |S| ≀ 26, where |S| denotes the length of S.\n - S consists of lo...
[{"type": "stdin_stdout", "input": "uncopyrightable\n", "output": "yes\n"}, {"type": "stdin_stdout", "input": "uncopyrightacle", "output": "no\n"}, {"type": "stdin_stdout", "input": "elcathgirypocnu", "output": "no\n"}, {"type": "stdin_stdout", "input": "elcathgirxpocnu", "output": "no\n"}, {"type": "stdin_stdout", "in...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe function is not returning the correct values. Can you figure out why?\n\n```python\nget_planet_name(3) # should return 'Earth'\n```\n\nWrite your solution by modifying this code:\n\n```python\ndef get_planet_name(id):...
[{"input": "5", "output": "[\"Jupiter\"]", "fn_name": "get_planet_name"}, {"input": "8", "output": "[\"Neptune\"]", "fn_name": "get_planet_name"}, {"input": "1", "output": "[\"Mercury\"]", "fn_name": "get_planet_name"}, {"input": "2", "output": "[\"Venus\"]", "fn_name": "get_planet_name"}, {"input": "3", "output": "[\"...
code_functional
[ { "content": "Solve the following coding problem using the programming language python:\n\n# Task\n A lock has `n` buttons in it, numbered from `1 to n`. To open the lock, you have to press all buttons in some order, i.e. a key to the lock is a permutation of the first `n` integers. If you push the right button...
[{"input": "2000", "output": "[1333335000]", "fn_name": "press_button"}, {"input": "10", "output": "[175]", "fn_name": "press_button"}, {"input": "4", "output": "[14]", "fn_name": "press_button"}, {"input": "1", "output": "[1]", "fn_name": "press_button"}, {"input": "3", "output": "[7]", "fn_name": "press_button"}]
code_functional
[ { "content": "Solve the following coding problem using the programming language python:\n\nLittle Artem got n stones on his birthday and now wants to give some of them to Masha. He knows that Masha cares more about the fact of receiving the present, rather than the value of that present, so he wants to give her...
[{"type": "stdin_stdout", "input": "1000000000\n", "output": "666666667\n"}, {"type": "stdin_stdout", "input": "1001000000\n", "output": "667333333\n"}, {"type": "stdin_stdout", "input": "1001100000\n", "output": "667400000\n"}, {"type": "stdin_stdout", "input": "1001001000\n", "output": "667334000\n"}, {"type": "stdin...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nTo help those contestants who struggle a lot in contests, the headquarters of Codeforces are planning to introduce Division 5. In this new division, the tags of all problems will be announced prior to the round to help th...
[{"type": "stdin_stdout", "input": "4\n6\n1 1 2 3 1 1\n5\n1 1 1 2 2\n8\n7 7 2 7 7 1 4 7\n10\n1 2 3 10 1 1 2 3 4 1\n", "output": "-1\n3\n-1\n2\n"}, {"type": "stdin_stdout", "input": "4\n6\n2 2 2 3 1 2\n5\n1 1 1 2 2\n8\n7 7 2 7 7 1 8 7\n10\n1 2 6 4 1 1 2 4 4 1\n", "output": "-1\n3\n-1\n2\n"}, {"type": "stdin_stdout", "in...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nMonocarp has been collecting rare magazines for quite a while, and now he has decided to sell them. He distributed the magazines between $n$ boxes, arranged in a row. The $i$-th box contains $a_i$ magazines. Some of the b...
[{"type": "stdin_stdout", "input": "9\n5\n01110\n10 5 8 9 6\n6\n011011\n20 10 9 30 20 19\n4\n0000\n100 100 100 100\n4\n0111\n5 4 5 1\n5\n01110\n10 5 8 9 6\n6\n011011\n20 10 9 30 20 19\n4\n0000\n100 100 100 100\n4\n0111\n5 4 5 1\n4\n0111\n5 4 5 1\n", "output": "27\n80\n0\n14\n27\n80\n0\n14\n14\n"}, {"type": "stdin_stdou...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAnalyzing the mistakes people make while typing search queries is a complex and an interesting work. As there is no guaranteed way to determine what the user originally meant by typing some query, we have to use different...
[{"type": "stdin_stdout", "input": "250\niiffiehchidfgigdbcciahdehjjfacbbaaadagaibjjcehjcbjdhaadebaejiicgidbhajfbfejcdicgfbcchgbahfccbefdcddbjjhejigiafhdjbiiehadfficicbebeeegcebideijidbgdecffeaegjfjbbcfiabfbaiddbjgidebdiccfcgfbcbbfhaejaibeicghecchjbiaceaibfgibhgcfgifiedcbhhfadhccfdhejeggcah\njbadcfjffcfabbecfabgcafgfcg...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere is a city that can be represented as a square grid with corner points in $(0, 0)$ and $(10^6, 10^6)$.\n\nThe city has $n$ vertical and $m$ horizontal streets that goes across the whole city, i. e. the $i$-th vertica...
[{"type": "stdin_stdout", "input": "2\n2 2 4\n0 1000000\n0 1000000\n1 0\n1000000 1\n717934 1000000\n0 999999\n5 4 9\n0 1 2 6 1000000\n0 4 8 1000000\n4 4\n1 3\n2 2\n6 3\n1000000 1\n3 8\n2 8\n10 8\n1 15\n", "output": "2\n7\n"}, {"type": "stdin_stdout", "input": "2\n2 2 4\n0 1000000\n0 1000000\n0 0\n1000000 0\n172846 1000...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIn this Kata, you will be given an array of integers and your task is to return the number of arithmetic progressions of size `3` that are possible from that list. In each progression, the differences between the elements...
[{"input": "[0, 1, 4, 5, 7, 9, 10, 13, 15, 16, 18, 19]", "output": "[15]", "fn_name": "solve"}, {"input": "[0, 1, 2, 3, 5, 8, 11, 13, 14, 16, 18, 19]", "output": "[13]", "fn_name": "solve"}, {"input": "[0, 1, 2, 3, 5, 6, 7, 11, 13, 15, 17, 19]", "output": "[17]", "fn_name": "solve"}, {"input": "[0, 5, 8, 9, 11, 13, 14,...
code_functional
[ { "content": "Solve the following coding problem using the programming language python:\n\nFind the minimum number with the given sum of digits $s$ such that all digits in it are distinct (i.e. all digits are unique).\n\nFor example, if $s=20$, then the answer is $389$. This is the minimum number in which all d...
[{"type": "stdin_stdout", "input": "45\n45\n45\n45\n45\n45\n45\n45\n45\n45\n45\n45\n45\n45\n45\n45\n45\n45\n45\n45\n45\n45\n45\n45\n45\n45\n45\n45\n45\n45\n45\n45\n45\n45\n45\n45\n45\n45\n45\n45\n45\n45\n45\n45\n45\n45\n", "output": "123456789\n123456789\n123456789\n123456789\n123456789\n123456789\n123456789\n123456789...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIn Summer Informatics School, if a student doesn't behave well, teachers make a hole in his badge. And today one of the teachers caught a group of $n$ students doing yet another trick. \n\nLet's assume that all these stud...
[{"type": "stdin_stdout", "input": "100\n73 81 39 85 48 49 37 20 66 41 79 32 54 71 31 50 48 29 10 85 81 20 20 20 48 54 70 40 71 31 49 77 50 33 12 87 19 12 54 39 87 10 20 39 81 18 70 53 86 7 33 37 62 9 77 54 50 30 70 81 66 12 41 12 20 23 87 73 91 75 94 49 18 71 81 32 79 85 30 94 48 10 41 62 73 90 40 70 90 91 33 100 79 9...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe only difference between easy and hard versions is constraints.\n\nA session has begun at Beland State University. Many students are taking exams.\n\nPolygraph Poligrafovich is going to examine a group of $n$ students....
[{"type": "stdin_stdout", "input": "100 100\n100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPolycarp is writing the prototype of a graphic editor. He has already made up his mind that the basic image transformations in his editor will be: rotate the image 90 degrees clockwise, flip the image horizontally (symmet...
[{"type": "stdin_stdout", "input": "9 20\n**.......\n****.....\n******...\n*******..\n..******.\n....****.\n......***\n*.....***\n*********\n*********\n*********\n*********\n....**...\n...****..\n..******.\n.********\n****..***\n***...***\n**.....**\n*.......*\n", "output": "********......**********........********\n**...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nBeing tired of participating in too many Codeforces rounds, Gildong decided to take some rest in a park. He sat down on a bench, and soon he found two rabbits hopping around. One of the rabbits was taller than the other.\...
[{"type": "stdin_stdout", "input": "5\n-1 10 0 3\n1 10 2 0\n900000000 1000000000 1 9999999\n0 2 1 2\n1 3 1 2\n", "output": "-1\n-1\n10\n-1\n-1\n"}, {"type": "stdin_stdout", "input": "5\n-1 1 0 3\n1 13 2 -1\n900000000 1000000000 1 2570333\n0 2 1 2\n1 3 1 2\n", "output": "-1\n12\n-1\n-1\n-1\n"}, {"type": "stdin_stdout", ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are some rabbits in Singapore Zoo. To feed them, Zookeeper bought $n$ carrots with lengths $a_1, a_2, a_3, \\ldots, a_n$. However, rabbits are very fertile and multiply very quickly. Zookeeper now has $k$ rabbits an...
[{"type": "stdin_stdout", "input": "54 42164\n810471 434523 262846 930807 148016 633714 247313 376546 142288 30094 599543 829013 182512 647950 512266 827248 452285 531124 257259 453752 114536 833190 737596 267349 598567 781294 390500 318098 354290 725051 978831 905185 849542 761886 55532 608148 631077 557070 355245 929...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nConsider all binary strings of length $m$ ($1 \\le m \\le 60$). A binary string is a string that consists of the characters 0 and 1 only. For example, 0110 is a binary string, and 012aba is not. Obviously, there are exact...
[{"type": "stdin_stdout", "input": "5\n3 3\n010\n001\n111\n4 3\n000\n111\n100\n011\n1 1\n1\n1 1\n0\n3 2\n00\n01\n10\n", "output": "100\n010\n0\n1\n11\n"}, {"type": "stdin_stdout", "input": "5\n3 3\n010\n001\n110\n4 3\n000\n111\n100\n011\n1 1\n1\n1 1\n0\n3 2\n00\n01\n10\n", "output": "100\n010\n0\n1\n11\n"}, {"type": "s...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIn some countries of former Soviet Union there was a belief about lucky tickets. A transport ticket of any sort was believed to posess luck if sum of digits on the left half of its number was equal to the sum of digits on...
[{"input": "\"943294329932\"", "output": "[false]", "fn_name": "luck_check"}, {"input": "\"1233499943\"", "output": "[false]", "fn_name": "luck_check"}, {"input": "\"543970707\"", "output": "[false]", "fn_name": "luck_check"}, {"input": "\"439924\"", "output": "[false]", "fn_name": "luck_check"}, {"input": "\"935336\""...
code_functional
[ { "content": "Solve the following coding problem using the programming language python:\n\nIn the official contest this problem has a different statement, for which jury's solution was working incorrectly, and for this reason it was excluded from the contest. This mistake have been fixed and the current given p...
[{"type": "stdin_stdout", "input": "20\n713900269 224495293 592111899 609607891 585084800 601258511 223103775 876894656 751583891 230837577 971499807 312977833 344314550 397998873 558637732 216574673 913028292 762852863 464376621 61315042\n", "output": "375537226\n"}, {"type": "stdin_stdout", "input": "20\n713900269 22...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA few years ago, Hitagi encountered a giant crab, who stole the whole of her body weight. Ever since, she tried to avoid contact with others, for fear that this secret might be noticed.\n\nTo get rid of the oddity and rec...
[{"type": "stdin_stdout", "input": "100 5\n175 30 124 0 12 111 6 0 119 108 0 38 127 3 151 114 95 54 4 128 91 11 168 120 80 107 18 21 149 169 0 141 195 20 78 157 33 118 17 69 105 130 197 57 74 110 138 84 71 172 132 93 191 44 152 156 24 101 146 26 2 36 143 122 104 42 103 97 39 116 115 0 155 87 53 85 7 43 65 196 136 154 1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nFor encrypting strings this region of chars is given (in this order!):\n\n* all letters (ascending, first all UpperCase, then all LowerCase)\n* all digits (ascending)\n* the following chars: `.,:;-?! '()$%&\"` \n\nThese a...
[{"input": "\"$-Wy,dM79H'i'o$n0C&I.ZTcMJw5vPlZc Hn!krhlaa:khV mkL;gvtP-S7Rt1Vp2RV:wV9VuhO Iz3dqb.U0w\"", "output": "[\"Do the kata \\\"Kobayashi-Maru-Test!\\\" Endless fun and excitement when finding a solution!\"]", "fn_name": "decrypt"}, {"input": "\"5MyQa79H'ijQaw!Ns6jVtpmnlZ.V6p\"", "output": "[\"This kata is very ...
code_functional
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a prime number $p$, $n$ integers $a_1, a_2, \\ldots, a_n$, and an integer $k$. \n\nFind the number of pairs of indexes $(i, j)$ ($1 \\le i < j \\le n$) for which $(a_i + a_j)(a_i^2 + a_j^2) \\equiv k \\bmod ...
[{"type": "stdin_stdout", "input": "7 7 3\n4 0 5 3 1 2 6\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "7 7 3\n4 0 5 3 1 2 6\n", "output": "0"}, {"type": "stdin_stdout", "input": "6 7 2\n1 2 3 4 5 6\n", "output": "3\n"}, {"type": "stdin_stdout", "input": "6 7 2\n1 2 3 4 5 6\n", "output": "3"}, {"type": "stdin...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWe have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it.\nIt takes us A_i minutes to read the i-th book from the top on Desk A (1 \\leq i \\leq N), and B_i minutes ...
[{"type": "stdin_stdout", "input": "5 4 1\n1000000000 1000000000 1000000000 1000000000 1000000000\n1000000000 1000000000 1000000000 1000000000\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "5 4 1\n1000000000 1000000000 1000000000 1000000000 1000000000\n1000000000 1000000000 1000000010 1000000000", "output": "...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA soldier wants to buy w bananas in the shop. He has to pay k dollars for the first banana, 2k dollars for the second one and so on (in other words, he has to pay iΒ·k dollars for the i-th banana). \n\nHe has n dollars. Ho...
[{"type": "stdin_stdout", "input": "1000 61465564 1000\n", "output": "439034436\n"}, {"type": "stdin_stdout", "input": "859 453892 543\n", "output": "126416972\n"}, {"type": "stdin_stdout", "input": "859 453892 889\n", "output": "339370803\n"}, {"type": "stdin_stdout", "input": "859 267939 889\n", "output": "339556756\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe Earth has been invaded by aliens. They demand our beer and threaten to destroy the Earth if we do not supply the exact number of beers demanded.\n\nUnfortunately, the aliens only speak Morse code. Write a program to c...
[{"input": "\".----..---...--....-.....-....--...---..----.-----\"", "output": "[1234567890]", "fn_name": "morse_converter"}, {"input": "\"..----------...-....----------\"", "output": "[207600]", "fn_name": "morse_converter"}, {"input": "\".----.----.----.----.----\"", "output": "[11111]", "fn_name": "morse_converter"}...
code_functional
[ { "content": "Solve the following coding problem using the programming language python:\n\nFox Ciel is playing a card game with her friend Jiro.\n\nJiro has n cards, each one has two attributes: position (Attack or Defense) and strength. Fox Ciel has m cards, each one has these two attributes too. It's known th...
[{"type": "stdin_stdout", "input": "36 30\nATK 116\nATK 120\nATK 122\nATK 120\nATK 116\nATK 118\nATK 123\nDEF 2564\nATK 123\nDEF 1810\nATK 124\nATK 120\nDEF 2598\nATK 119\nDEF 2103\nATK 123\nATK 118\nATK 118\nATK 123\nDEF 1988\nATK 122\nATK 120\nDEF 2494\nATK 122\nATK 124\nATK 117\nATK 121\nATK 118\nATK 117\nATK 122\nA...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIn Russia regular bus tickets usually consist of 6 digits. The ticket is called lucky when the sum of the first three digits equals to the sum of the last three digits. Write a function to find out whether the ticket is l...
[{"input": "\"12341234\"", "output": "[false]", "fn_name": "is_lucky"}, {"input": "\"100200\"", "output": "[false]", "fn_name": "is_lucky"}, {"input": "\"12a12a\"", "output": "[false]", "fn_name": "is_lucky"}, {"input": "\"123321\"", "output": "[true]", "fn_name": "is_lucky"}, {"input": "\"100001\"", "output": "[true]"...
code_functional
[ { "content": "Solve the following coding problem using the programming language python:\n\nWhile dad was at work, a little girl Tanya decided to play with dad's password to his secret database. Dad's password is a string consisting of n + 2 characters. She has written all the possible n three-letter continuous ...
[{"type": "stdin_stdout", "input": "100\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given an array $a$ consisting of $500000$ integers (numbered from $1$ to $500000$). Initially all elements of $a$ are zero.\n\nYou have to process two types of queries to this array: $1$ $x$ $y$Β β€” increase $a_x$ ...
[{"type": "stdin_stdout", "input": "5\n1 3 4\n2 3 0\n2 4 3\n1 500000 1\n2 800 0\n", "output": "4\n4\n1\n"}, {"type": "stdin_stdout", "input": "5\n1 3 4\n2 3 0\n2 4 3\n1 500000 1\n2 800 0\n", "output": "4\n4\n1\n"}, {"type": "stdin_stdout", "input": "5\n1 3 4\n2 3 0\n2 4 3\n1 4 -4\n2 1 0\n", "output": "4\n4\n0\n"}, {"ty...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere is a building consisting of $10~000$ apartments numbered from $1$ to $10~000$, inclusive.\n\nCall an apartment boring, if its number consists of the same digit. Examples of boring apartments are $11, 2, 777, 9999$ a...
[{"type": "stdin_stdout", "input": "36\n9999\n9999\n9999\n9999\n9999\n9999\n9999\n9999\n9999\n9999\n9999\n9999\n9999\n9999\n9999\n9999\n9999\n9999\n9999\n9999\n9999\n9999\n9999\n9999\n9999\n9999\n9999\n9999\n9999\n9999\n9999\n9999\n9999\n9999\n9999\n9999\n", "output": "90\n90\n90\n90\n90\n90\n90\n90\n90\n90\n90\n90\n90...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nEzzat has an array of $n$ integers (maybe negative). He wants to split it into two non-empty subsequences $a$ and $b$, such that every element from the array belongs to exactly one subsequence, and the value of $f(a) + f(...
[{"type": "stdin_stdout", "input": "4\n3\n3 1 2\n3\n-7 -6 -6\n3\n2 2 2\n4\n17 3 5 -3\n", "output": "4.500000000\n-12.500000000\n4.000000000\n18.666666667\n"}, {"type": "stdin_stdout", "input": "4\n3\n3 1 3\n3\n-10 -3 -5\n3\n2 3 0\n4\n14 3 2 -1\n", "output": "5.0\n-10.5\n4.0\n15.333333333333334\n"}, {"type": "stdin_stdo...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nMahmoud wrote a message s of length n. He wants to send it as a birthday present to his friend Moaz who likes strings. He wrote it on a magical paper but he was surprised because some characters disappeared while writing ...
[{"type": "stdin_stdout", "input": "55\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000\n", "output": "383381198\n55\n1\n"}, {"type": "stdin_stdout", "input": "55\naaaaaaaaaaaaaaaaa...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nCreate a function that interprets code in the esoteric language **Poohbear**\n\n## The Language\n\nPoohbear is a stack-based language largely inspired by Brainfuck. It has a maximum integer value of 255, and 30,000 cells....
[{"input": "\"+LTQII>+WN<P>+E\"", "output": "[\"1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 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...
code_functional
[ { "content": "Solve the following coding problem using the programming language python:\n\nProblem statement\n\nReal variables $ x_1, x_2, ..., x_N $ satisfy the following conditions.\n\n1. $ 0 \\ leq x_i \\ leq 1 $ ($ 1 \\ leq i \\ leq N $)\n2. $ w_1x_1 + w_2x_2 + ... + w_Nx_N \\ leq W $\n\n\n\nAt this time, f...
[{"type": "stdin_stdout", "input": "2 1\n-1 0\n3 10", "output": "6.66666666667\n"}, {"type": "stdin_stdout", "input": "1 1\n3 2", "output": "0.666666666667\n"}, {"type": "stdin_stdout", "input": "1 2\n6 1", "output": "0.333333333333\n"}, {"type": "stdin_stdout", "input": "2 1\n-1 -3\n3 10", "output": "3.666667"}, {"typ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are N towns in Takahashi Kingdom. They are conveniently numbered 1 through N.\n\nTakahashi the king is planning to go on a tour of inspection for M days. He will determine a sequence of towns c, and visit town c_i o...
[{"type": "stdin_stdout", "input": "107 137", "output": "944428092\n"}, {"type": "stdin_stdout", "input": "21 300", "output": "213825142\n"}, {"type": "stdin_stdout", "input": "13 300", "output": "572293777\n"}, {"type": "stdin_stdout", "input": "13 146", "output": "392822654\n"}, {"type": "stdin_stdout", "input": "62 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nATM machines allow 4 or 6 digit PIN codes and PIN codes cannot contain anything but **exactly** 4 digits or exactly 6 digits. \n\nIf the function is passed a valid PIN string, return `true`, else return `false`.\n\n## Exa...
[{"input": "\"00000000\"", "output": "[false]", "fn_name": "validate_pin"}, {"input": "\"1234567\"", "output": "[false]", "fn_name": "validate_pin"}, {"input": "\"-12345\"", "output": "[false]", "fn_name": "validate_pin"}, {"input": "\"12345\"", "output": "[false]", "fn_name": "validate_pin"}, {"input": "\"-1234\"", "o...
code_functional
[ { "content": "Solve the following coding problem using the programming language python:\n\nIn this Kata, you will be given an integer `n` and your task will be to return `the largest integer that is <= n and has the highest digit sum`.\n\nFor example:\n```\nsolve(100) = 99. Digit Sum for 99 = 9 + 9 = 18. No oth...
[{"input": "999999999992", "output": "[999999999989]", "fn_name": "solve"}, {"input": "79320", "output": "[78999]", "fn_name": "solve"}, {"input": "99004", "output": "[98999]", "fn_name": "solve"}, {"input": "99088", "output": "[98999]", "fn_name": "solve"}, {"input": "99737", "output": "[98999]", "fn_name": "solve"}, ...
code_functional
[ { "content": "Solve the following coding problem using the programming language python:\n\nBertown is a city with $n$ buildings in a straight line.\n\nThe city's security service discovered that some buildings were mined. A map was compiled, which is a string of length $n$, where the $i$-th character is \"1\" i...
[{"type": "stdin_stdout", "input": "2\n1 1\n01000010\n10 1\n01101110\n", "output": "2\n11\n"}, {"type": "stdin_stdout", "input": "2\n2 1\n11000110\n10 1\n01101111\n", "output": "4\n11\n"}, {"type": "stdin_stdout", "input": "2\n1 1\n01010010\n10 1\n01101100\n", "output": "3\n11\n"}, {"type": "stdin_stdout", "input": "2\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are n beacons located at distinct positions on a number line. The i-th beacon has position a_{i} and power level b_{i}. When the i-th beacon is activated, it destroys all beacons to its left (direction of decreasing...
[{"type": "stdin_stdout", "input": "11\n110 90\n100 70\n148 10\n80 10\n70 1\n60 1\n50 10\n40 1\n30 1\n10 1\n20 1\n", "output": "5\n"}, {"type": "stdin_stdout", "input": "11\n110 90\n100 70\n90 10\n80 10\n70 1\n60 1\n50 10\n40 1\n30 1\n10 1\n20 1\n", "output": "4\n"}, {"type": "stdin_stdout", "input": "11\n110 61\n100 7...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPolycarp is playing a new computer game. This game has $n$ stones in a row. The stone on the position $i$ has integer power $a_i$. The powers of all stones are distinct.\n\nEach turn Polycarp can destroy either stone on t...
[{"type": "stdin_stdout", "input": "1\n52\n1 3 3 4 5 10 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 48 29 30 31 32 49 34 35 36 37 38 39 40 41 42 43 21 45 46 47 48 49 50 51 52\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "1\n52\n1 3 3 4 5 10 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 2...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAnton likes to listen to fairy tales, especially when Danik, Anton's best friend, tells them. Right now Danik tells Anton a fairy tale:\n\n\"Once upon a time, there lived an emperor. He was very rich and had much grain. O...
[{"type": "stdin_stdout", "input": "1000000000000000000 1000000000000000000\n", "output": "1000000000000000000\n"}, {"type": "stdin_stdout", "input": "1000000000000000000 1000000000000000000\n", "output": "1000000000000000000\n"}, {"type": "stdin_stdout", "input": "1000000000000000000 1100000000000000000\n", "output": ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are N people living on a number line.\nThe i-th person lives at coordinate X_i.\nYou are going to hold a meeting that all N people have to attend.\nThe meeting can be held at any integer coordinate. If you choose to...
[{"type": "stdin_stdout", "input": "100\n1 1 1 100 100 1 100 1 100 100 100 1 100 1 1 1 100 1 100 100 100 1 1 100 100 100 100 100 100 1 1 100 100 100 100 100 1 100 1 1 1 100 100 100 1 100 1 100 100 1 1 1 1 1 1 100 1 1 100 1 1 1 100 100 1 1 100 100 100 100 100 1 100 1 1 100 1 1 1 100 1 100 100 100 1 1 1 100 1 1 100 100 1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given four integers $n$, $c_0$, $c_1$ and $h$ and a binary string $s$ of length $n$.\n\nA binary string is a string consisting of characters $0$ and $1$.\n\nYou can change any character of the string $s$ (the stri...
[{"type": "stdin_stdout", "input": "7\n10 3 1 1\n1000000110\n1 10 1 1000\n0\n1 1 10 2\n1\n4 4 4 1\n1001\n1 1 1 1\n1\n2 1000 500 1000\n11\n3 500 500 1\n101\n", "output": "17\n10\n3\n16\n1\n1000\n1500\n"}, {"type": "stdin_stdout", "input": "7\n10 3 1 1\n1000000110\n1 10 1 1000\n0\n1 1 10 2\n1\n4 4 4 1\n1001\n1 1 1 1\n1\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given an array a of length n.\n\nLet's define the eversion operation. Let x = a_n. Then array a is partitioned into two parts: left and right. The left part contains the elements of a that are not greater than x (...
[{"type": "stdin_stdout", "input": "3\n5\n0 4 1 5 3\n5\n10 3 0 4 1\n2\n1 1 1 1\n", "output": "1\n2\n0\n"}, {"type": "stdin_stdout", "input": "3\n5\n0 4 1 5 3\n5\n10 3 0 5 1\n2\n1 1 1 1\n", "output": "1\n2\n0\n"}, {"type": "stdin_stdout", "input": "3\n5\n2 4 1 5 3\n5\n5 3 2 0 1\n4\n1 1 1 1\n", "output": "1\n3\n0\n"}, {"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou've got an array, consisting of n integers a_1, a_2, ..., a_{n}. Also, you've got m queries, the i-th query is described by two integers l_{i}, r_{i}. Numbers l_{i}, r_{i} define a subsegment of the original array, tha...
[{"type": "stdin_stdout", "input": "100 10\n53 72 2 58 6 48 65 13 43 9 77 1 58 28 49 95 12 11 7 36 51 25 78 20 6 2 69 76 1 47 17 6 91 54 50 66 69 122 74 31 19 96 35 84 163 15 65 73 66 73 29 53 17 47 3 19 4 16 85 6 49 6 57 70 96 19 66 92 86 61 10 21 11 82 13 98 59 96 85 1 13 65 28 34 143 16 88 32 60 50 33 37 36 57 97 28...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nProblem\n\nGiven the string S, which consists of lowercase letters and numbers. Follow the steps below to compress the length of string S.\n\n1. Change the order of the characters in the character string to any order.\nEx...
[{"type": "stdin_stdout", "input": "0ig3hd12fz99", "output": "10\n"}, {"type": "stdin_stdout", "input": "0hg3hd12fz99", "output": "11\n"}, {"type": "stdin_stdout", "input": "0hg3hd13fz99", "output": "12\n"}, {"type": "stdin_stdout", "input": "0hf3hd12fz99", "output": "11\n"}, {"type": "stdin_stdout", "input": "99zf21dh...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nBased on [this kata, Connect Four.](https://www.codewars.com/kata/connect-four-1)\n\nIn this kata we play a modified game of connect four. It's connect X, and there can be multiple players.\n\nWrite the function ```whoIsW...
[{"input": "[\"C_R\", \"p_Y\", \"a_B\", \"Q_T\", \"s_S\", \"I_R\", \"Z_Y\", \"a_B\", \"c_T\", \"d_S\", \"O_R\", \"C_Y\", \"M_B\", \"Q_T\", \"O_S\", \"I_R\", \"U_Y\", \"J_B\", \"K_T\", \"V_S\", \"i_R\", \"o_Y\", \"r_B\", \"H_T\", \"I_S\", \"C_R\", \"n_Y\", \"W_B\", \"G_T\", \"j_S\", \"p_R\", \"m_Y\", \"Y_B\", \"b_T\", \...
code_functional
[ { "content": "Solve the following coding problem using the programming language python:\n\nWrite a function that takes a string which has integers inside it separated by spaces, and your task is to convert each integer in the string into an integer and return their sum.\n\n### Example\n```python\nsummy(\"1 2 3\...
[{"input": "\"1 2 3 4 5\"", "output": "[15]", "fn_name": "summy"}, {"input": "\"1 2 3 4\"", "output": "[10]", "fn_name": "summy"}, {"input": "\"10 10\"", "output": "[20]", "fn_name": "summy"}, {"input": "\"1 2 3\"", "output": "[6]", "fn_name": "summy"}, {"input": "\"0 0\"", "output": "[0]", "fn_name": "summy"}]
code_functional
[ { "content": "Solve the following coding problem using the programming language python:\n\nVasya owns three big integers β€” $a, l, r$. Let's define a partition of $x$ such a sequence of strings $s_1, s_2, \\dots, s_k$ that $s_1 + s_2 + \\dots + s_k = x$, where $+$ is a concatanation of strings. $s_i$ is the $i$-...
[{"type": "stdin_stdout", "input": "12212222221212222221221221222222121222222122\n22222111112222222222221221222222121222222122\n22222111112222222222221221222222121222222122\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "12212222221212222221221221222222121222222122\n28110439567417001223290131317494419039608149...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nMemory and his friend Lexa are competing to get higher score in one popular computer game. Memory starts with score a and Lexa starts with score b. In a single turn, both Memory and Lexa get some integer in the range [ - ...
[{"type": "stdin_stdout", "input": "87 100 200 80\n", "output": " 913761305\n"}, {"type": "stdin_stdout", "input": "38 38 701 74\n", "output": " 496603581\n"}, {"type": "stdin_stdout", "input": "40 94 510 53\n", ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\n# Task\nJohn was in math class and got bored, so he decided to fold some origami from a rectangular `a Γ— b` sheet of paper (`a > b`). His first step is to make a square piece of paper from the initial rectangular piece of...
[{"input": "1000\n999", "output": "[1000]", "fn_name": "folding"}, {"input": "1000\n700", "output": "[6]", "fn_name": "folding"}, {"input": "10\n7", "output": "[6]", "fn_name": "folding"}, {"input": "2\n1", "output": "[2]", "fn_name": "folding"}, {"input": "3\n1", "output": "[3]", "fn_name": "folding"}, {"input": "4\n1...
code_functional
[ { "content": "Solve the following coding problem using the programming language python:\n\nproblem\n\nGiven the sequence $ A $ of length $ N $. The $ i $ item in $ A $ is $ A_i $. You can do the following for this sequence:\n\n* $ 1 \\ leq i \\ leq N --Choose the integer i that is 1 $. Swap the value of $ A_i $...
[{"type": "stdin_stdout", "input": "5\n2 10 5 22 4", "output": "0\n"}, {"type": "stdin_stdout", "input": "5\n1 6 7 31 10", "output": "1\n"}, {"type": "stdin_stdout", "input": "5\n1 8 7 31 12", "output": "0\n"}, {"type": "stdin_stdout", "input": "5\n2 10 5 22 8", "output": "0\n"}, {"type": "stdin_stdout", "input": "5\n2...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nGiven a string of integers, return the number of odd-numbered substrings that can be formed. \n\nFor example, in the case of `\"1341\"`, they are `1, 1, 3, 13, 41, 341, 1341`, a total of `7` numbers. \n\n`solve(\"1341\") ...
[{"input": "\"13472315\"", "output": "[28]", "fn_name": "solve"}, {"input": "\"1347231\"", "output": "[20]", "fn_name": "solve"}, {"input": "\"134721\"", "output": "[13]", "fn_name": "solve"}, {"input": "\"13471\"", "output": "[12]", "fn_name": "solve"}, {"input": "\"1357\"", "output": "[10]", "fn_name": "solve"}, {"in...
code_functional
[ { "content": "Solve the following coding problem using the programming language python:\n\nAmr doesn't like Maths as he finds it really boring, so he usually sleeps in Maths lectures. But one day the teacher suspected that Amr is sleeping and asked him a question to make sure he wasn't.\n\nFirst he gave Amr two...
[{"type": "stdin_stdout", "input": "1000 100 777767777\n", "output": "577920877\n"}, {"type": "stdin_stdout", "input": "1000 100 777767777\n", "output": "577920877"}, {"type": "stdin_stdout", "input": "886 10 902171654\n", "output": "134375492\n"}, {"type": "stdin_stdout", "input": "712 53 592302770\n", "output": "1476...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere is a circle with a circumference of L. Each point on the circumference has a coordinate value, which represents the arc length from a certain reference point clockwise to the point. On this circumference, there are ...
[{"type": "stdin_stdout", "input": "4 20 18\n7 2\n9 1\n12 1\n18 1", "output": "10\n16\n7\n9\n"}, {"type": "stdin_stdout", "input": "4 20 18\n3 2\n9 1\n12 1\n18 1", "output": "10\n16\n5\n7\n"}, {"type": "stdin_stdout", "input": "4 20 18\n3 2\n9 1\n12 1\n18 2", "output": "5\n7\n10\n0\n"}, {"type": "stdin_stdout", "input"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nNathan O. Davis has been running an electronic bulletin board system named JAG-channel. He is now having hard time to add a new feature there --- threaded view.\n\nLike many other bulletin board systems, JAG-channel is th...
[{"type": "stdin_stdout", "input": "1\n0\nccpi", "output": "ccpi\n"}, {"type": "stdin_stdout", "input": "1\n0\nipcc", "output": "ipcc\n"}, {"type": "stdin_stdout", "input": "1\n0\njpcc", "output": "jpcc\n"}, {"type": "stdin_stdout", "input": "1\n0\ncbpi", "output": "cbpi\n"}, {"type": "stdin_stdout", "input": "1\n0\nio...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\n# Task\n Given a string `s`, find out if its characters can be rearranged to form a palindrome.\n\n# Example\n\n For `s = \"aabb\"`, the output should be `true`.\n\n We can rearrange `\"aabb\"` to make `\"abba\"`, which i...
[{"input": "\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaabc\"", "output": "[false]", "fn_name": "palindrome_rearranging"}, {"input": "\"zyyzzzzz\"", "output": "[true]", "fn_name": "palindrome_rearranging"}, {"input": "\"abbcabb\"", "output": "[true]", "fn_name": "palindrome_rearranging"}, {"input": "\"aaabbb\"", "output": "[false]"...
code_functional
[ { "content": "Solve the following coding problem using the programming language python:\n\n# Task\n A ciphertext alphabet is obtained from the plaintext alphabet by means of rearranging some characters. For example \"bacdef...xyz\" will be a simple ciphertext alphabet where a and b are rearranged.\n\n A substit...
[{"input": "\"jpeuizmi\"\n\"mxxcwriq\"", "output": "[false]", "fn_name": "is_substitution_cipher"}, {"input": "\"aaxxaaz\"\n\"aazzaay\"", "output": "[true]", "fn_name": "is_substitution_cipher"}, {"input": "\"aaxyaa\"\n\"aazzaa\"", "output": "[false]", "fn_name": "is_substitution_cipher"}, {"input": "\"aazzaa\"\n\"aaxy...
code_functional
[ { "content": "Solve the following coding problem using the programming language python:\n\nAlice and Borys are playing tennis.\n\nA tennis match consists of games. In each game, one of the players is serving and the other one is receiving.\n\nPlayers serve in turns: after a game where Alice is serving follows a...
[{"type": "stdin_stdout", "input": "2\n99998 1\n1 99998\n", "output": "4\n49998 49999 50000 50001\n4\n49998 49999 50000 50001\n"}, {"type": "stdin_stdout", "input": "2\n99999 0\n0 99999\n", "output": "2\n49999 50000\n2\n49999 50000\n"}, {"type": "stdin_stdout", "input": "2\n99999 1\n1 99999\n", "output": "2\n49999 5000...
code_stdio