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\nLet's call a sequence of integers $x_1, x_2, \\dots, x_k$ MEX-correct if for all $i$ ($1 \\le i \\le k$) $|x_i - \\operatorname{MEX}(x_1, x_2, \\dots, x_i)| \\le 1$ holds. Where $\\operatorname{MEX}(x_1, \\dots, x_k)$ is ...
[{"type": "stdin_stdout", "input": "1\n30\n0 0 0 2 0 0 0 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2\n", "output": "998244352\n"}, {"type": "stdin_stdout", "input": "1\n30\n0 0 0 2 0 0 0 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2\n", "output": "998244352\n"}, {"type": "stdin_stdout", "input": "1\n30\n0 0 0 1 0 0 0...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nGiven the string S and m queries. The i-th query is given by the two strings xi and yi.\n\nFor each query, answer the longest substring of the string S, starting with xi and ending with yi.\n\nFor the string S, | S | repr...
[{"type": "stdin_stdout", "input": "icpcsummertraining\n9\nmm n\nicpc summer\ntrain ing\nsummer mm\ni c\ni i\nh f\ntrain i\nsummer er", "output": "11\n10\n8\n0\n4\n16\n0\n6\n6\n"}, {"type": "stdin_stdout", "input": "icpcsummertraining\n9\nmm n\nicpc summer\nniart ing\nsummer mm\ni c\ni i\nh f\ntrain i\nsummer er", "out...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a chess board with $n$ rows and $n$ columns. Initially all cells of the board are empty, and you have to put a white or a black knight into each cell of the board.\n\nA knight is a chess piece that can attac...
[{"type": "stdin_stdout", "input": "104\n", "output": "WBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWB\nBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBW\nWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBW...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nRound any given number to the closest 0.5 step\n\nI.E.\n```\nsolution(4.2) = 4\nsolution(4.3) = 4.5\nsolution(4.6) = 4.5\nsolution(4.8) = 5\n```\n\nRound **up** if number is as close to previous and next 0.5 steps.\n\n```...
[{"input": "4.74999999999", "output": "[4.5]", "fn_name": "solution"}, {"input": "4.74999999991", "output": "[4.5]", "fn_name": "solution"}, {"input": "4.25", "output": "[4.5]", "fn_name": "solution"}, {"input": "4.55", "output": "[4.5]", "fn_name": "solution"}, {"input": "4.74", "output": "[4.5]", "fn_name": "solution...
code_functional
[ { "content": "Solve the following coding problem using the programming language python:\n\nThis is a simplified version of the problem B2. Perhaps you should read the problem B2 before you start solving B1.\n\nPaul and Mary have a favorite string $s$ which consists of lowercase letters of the Latin alphabet. Th...
[{"type": "stdin_stdout", "input": "61\nkzaaa\ncodeforces\narchive\ny\nxxxxxx\nkzaaa\ncodeforces\narchive\ny\nxxxxxx\nkzaaa\ncodeforces\narchive\ny\nxxxxxx\nkzaaa\ncodeforces\narchive\ny\nxxxxxx\nkzaaa\ncodeforces\narchive\ny\nxxxxxx\nkzaaa\ncodeforces\narchive\ny\nxxxxxx\nkzaaa\ncodeforces\narchive\ny\nxxxxxx\nkzaaa\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou will be given a string. \n\nYou need to return an array of three strings by gradually pulling apart the string.\n\nYou should repeat the following steps until the string length is 1:\n\na) remove the final character f...
[{"input": "\"reusetestcasesbitcointakeovertheworldmaybewhoknowsperhaps\"", "output": "[[\"spahrepswonkohwebyamdlroweht\", \"reusetestcasesbitcointakeove\", \"r\"]]", "fn_name": "pop_shift"}, {"input": "\"turnsoutrandomtestcasesareeasierthanwritingoutbasicones\"", "output": "[[\"senocisabtuognitirwnahtreis\", \"turnsou...
code_functional
[ { "content": "Solve the following coding problem using the programming language python:\n\nLet us consider sets of positive integers less than or equal to n. Note that all elements of a set are different. Also note that the order of elements doesn't matter, that is, both {3, 5, 9} and {5, 9, 3} mean the same se...
[{"type": "stdin_stdout", "input": "9 3 23\n10 3 22\n10 3 28\n16 10 107\n26 8 102\n20 10 105\n24 10 155\n3 4 3\n4 2 11\n0 0 0", "output": "1\n5\n0\n20\n32200\n5448\n10222\n0\n0\n"}, {"type": "stdin_stdout", "input": "9 3 23\n9 3 22\n10 3 28\n16 10 107\n26 8 102\n20 10 105\n24 10 155\n3 4 3\n4 2 11\n0 0 0", "output": "1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIs every value in the array an array?\n\nThis should only test the second array dimension of the array. The values of the nested arrays don't have to be arrays. \n\nExamples:\n\n```python\n[[1],[2]] => true\n['1','2'] => ...
[{"input": "[\"A\", \"R\", \"R\", \"A\", \"Y\"]", "output": "[false]", "fn_name": "arr_check"}, {"input": "[[1], [2], [3]]", "output": "[true]", "fn_name": "arr_check"}, {"input": "[[\"string\"]]", "output": "[true]", "fn_name": "arr_check"}, {"input": "[[], {}]", "output": "[false]", "fn_name": "arr_check"}, {"input":...
code_functional
[ { "content": "Solve the following coding problem using the programming language python:\n\nVasya will fancy any number as long as it is an integer power of two. Petya, on the other hand, is very conservative and only likes a single integer $p$ (which may be positive, negative, or zero). To combine their tastes,...
[{"type": "stdin_stdout", "input": "1000000000 -1000\n", "output": "14\n"}, {"type": "stdin_stdout", "input": "1000000000 -1000\n", "output": "14\n"}, {"type": "stdin_stdout", "input": "1000000010 -1000\n", "output": "15\n"}, {"type": "stdin_stdout", "input": "1010000000 -1000\n", "output": "15\n"}, {"type": "stdin_std...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are N towns located in a line, conveniently numbered 1 through N. Takahashi the merchant is going on a travel from town 1 to town N, buying and selling apples.\nTakahashi will begin the travel at town 1, with no app...
[{"type": "stdin_stdout", "input": "10 100\n7 10 4 5 9 3 6 8 2 1\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "10 100\n7 10 4 5 9 3 6 8 1 1", "output": "2\n"}, {"type": "stdin_stdout", "input": "10 100\n7 10 4 5 9 3 6 8 2 1", "output": "2"}, {"type": "stdin_stdout", "input": "5 8\n50 30 40 10 20\n", "output"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nHaruna is a high school student. She must remember the seating arrangements in her class because she is a class president. It is too difficult task to remember if there are so many students.\n\nThat is the reason why seat...
[{"type": "stdin_stdout", "input": "1 2\n11 0\n0 0", "output": "yes\nyes\n"}, {"type": "stdin_stdout", "input": "2 1\n10 0\n0 0", "output": "yes\nyes\n"}, {"type": "stdin_stdout", "input": "1 4\n11 0\n0 0", "output": "yes\nyes\n"}, {"type": "stdin_stdout", "input": "2 -1\n8 0\n0 0", "output": "yes\nyes\n"}, {"type": "s...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA bracket sequence is a string, containing only characters \"(\", \")\", \"[\" and \"]\".\n\nA correct bracket sequence is a bracket sequence that can be transformed into a correct arithmetic expression by inserting chara...
[{"type": "stdin_stdout", "input": "[()][([[]])][[[]()]][()[]]()()([[][]][[]][](()))[[[(())]]][]()(([([])(([[[]]()])(()))]((())))([()]([()[[[]([][[[[][(())([[]()])]]][[(())]([])]()][[](())]()[])]()[][]]([[]])[]])[(()[()((()[][()]))][])[]()()([]())](()[][][])()()[]()))[]()[]\n", "output": "61\n[()][([[]])][[[]()]][()[]]...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nNot long ago Billy came across such a problem, where there were given three natural numbers A, B and C from the range [1, N], and it was asked to check whether the equation AB = C is correct. Recently Billy studied the co...
[{"type": "stdin_stdout", "input": "1000000\n", "output": "111111074060178115\n"}, {"type": "stdin_stdout", "input": "987572\n", "output": "107019643962508968\n"}, {"type": "stdin_stdout", "input": "983242\n", "output": "105618162572849728\n"}, {"type": "stdin_stdout", "input": "600000\n", "output": "23999973325791164\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou can perfectly predict the price of a certain stock for the next N days. You would like to profit on this knowledge, but only want to transact one share of stock per day. That is, each day you will either buy one share...
[{"type": "stdin_stdout", "input": "100\n411 642 560 340 276 440 515 519 182 314 35 227 390 136 97 5 502 584 567 79 543 444 413 463 455 316 545 329 437 443 9 435 291 384 328 501 603 234 285 297 453 587 550 72 130 163 282 298 605 349 270 198 24 179 243 92 115 56 83 26 3 456 622 325 366 360 299 153 140 552 216 117 61 307...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA monster is attacking the Cyberland!\n\nMaster Yang, a braver, is going to beat the monster. Yang and the monster each have 3 attributes: hitpoints (HP), offensive power (ATK) and defensive power (DEF).\n\nDuring the bat...
[{"type": "stdin_stdout", "input": "100 100 100\n100 100 100\n100 100 100\n", "output": "100\n"}, {"type": "stdin_stdout", "input": "100 100 100\n100 100 100\n100 100 100\n", "output": "100\n"}, {"type": "stdin_stdout", "input": "50 100 51\n100 100 100\n1 100 100\n", "output": "1384\n"}, {"type": "stdin_stdout", "input...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\n# Base64 Numeric Translator\n\nOur standard numbering system is (Base 10). That includes 0 through 9. Binary is (Base 2), only 1’s and 0’s. And Hexadecimal is (Base 16) (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F). A...
[{"input": "\"HelloWorld\"", "output": "[134710352538679645]", "fn_name": "base64_to_base10"}, {"input": "\"b64\"", "output": "[114360]", "fn_name": "base64_to_base10"}, {"input": "\"/+/\"", "output": "[262079]", "fn_name": "base64_to_base10"}, {"input": "\"WIN\"", "output": "[90637]", "fn_name": "base64_to_base10"}, {...
code_functional
[ { "content": "Solve the following coding problem using the programming language python:\n\nPetya's friends made him a birthday present — a bracket sequence. Petya was quite disappointed with his gift, because he dreamed of correct bracket sequence, yet he told his friends nothing about his dreams and decided to...
[{"type": "stdin_stdout", "input": "500\n())()())((()(()((())())(())())()((()(()()))())())))()())())())()())))(()))))((((())(((()(())))()()(()))())(((((()()(((())()((()((())()))()())()))))()))()(((()(())((()()((()())()))((((())(())))()(()(())((((((()()()())))((()())(((((()()(((()))((()((()))())(((())((((()))))))))()()(...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAn array of integers $p_1, p_2, \\dots, p_n$ is called a permutation if it contains each number from $1$ to $n$ exactly once. For example, the following arrays are permutations: $[3, 1, 2]$, $[1]$, $[1, 2, 3, 4, 5]$ and $...
[{"type": "stdin_stdout", "input": "5\n-1 2 -3 -1\n", "output": "4 3 5 2 1 "}, {"type": "stdin_stdout", "input": "5\n-1 2 -3 -1\n", "output": "4 3 5 2 1 "}, {"type": "stdin_stdout", "input": "5\n3 -2 1 -3\n", "output": "2 5 3 4 1 "}, {"type": "stdin_stdout", "input": "5\n-4 1 2 -1\n", "output": "5 1 2 4 3 "}, {"type": ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nUser ainta has a permutation p_1, p_2, ..., p_{n}. As the New Year is coming, he wants to make his permutation as pretty as possible.\n\nPermutation a_1, a_2, ..., a_{n} is prettier than permutation b_1, b_2, ..., b_{n}, ...
[{"type": "stdin_stdout", "input": "15\n6 1 2 7 9 13 14 8 4 5 3 12 10 15 11\n000100100100100\n000010010010010\n000001001001001\n100000100100100\n010000010010010\n001000001001001\n100100000100100\n010010000010010\n001001000001001\n100100100000100\n010010010000010\n001001001000001\n100100100100000\n010010010010000\n00100...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a string $s$ consisting of $n$ lowercase Latin letters. $n$ is even.\n\nFor each position $i$ ($1 \\le i \\le n$) in string $s$ you are required to change the letter on this position either to the previous l...
[{"type": "stdin_stdout", "input": "50\n6\nbxyxcz\n4\nzzcy\n2\nzb\n2\nyb\n6\nzzbxyx\n4\nbxzb\n4\naaca\n4\nbzyx\n4\nxaac\n2\nbb\n2\nzb\n6\ncabcbb\n6\nyxzbbb\n2\nxz\n2\ncc\n6\nazcaza\n4\nyyaa\n2\nxb\n2\nyb\n6\nzaxxxz\n4\nbyab\n4\naxxz\n2\nay\n2\nyb\n2\ncx\n4\nzyab\n6\nybcyya\n6\nxayzaz\n4\nzacx\n6\nzzyxbz\n2\ncc\n4\nbycx...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nFor the multiset of positive integers s=\\\\{s_1,s_2,...,s_k\\}, define the Greatest Common Divisor (GCD) and Least Common Multiple (LCM) of s as follow:\n\n * \\gcd(s) is the maximum positive integer x, such that all in...
[{"type": "stdin_stdout", "input": "10\n972 972 324 972 324 648 1944 243 324 474\n", "output": "162\n"}, {"type": "stdin_stdout", "input": "10\n61 1677 535 769 324 1309 1589 243 324 184\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "10\n61 1677 535 769 627 1309 1589 243 324 184\n", "output": "1\n"}, {"type": ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nNatasha is going to fly to Mars. She needs to build a rocket, which consists of several stages in some order. Each of the stages is defined by a lowercase Latin letter. This way, the rocket can be described by the string ...
[{"type": "stdin_stdout", "input": "50 13\nqwertyuiopasdfghjklzxcvbnmaaaaaaaaaaaaaaaaaaaaaaaa\n", "output": "169\n"}, {"type": "stdin_stdout", "input": "50 13\nqwertyuiopasdfghjklzxcvbnmaaaaaaaaaaaaaaaaaaaaaaaa\n", "output": "169"}, {"type": "stdin_stdout", "input": "50 31\nahbyyoxltryqdmvenemaqnbakglgqolxnaifnqtoclnnq...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWe have a tree with N vertices and N-1 edges, respectively numbered 1, 2,\\cdots, N and 1, 2, \\cdots, N-1. Edge i connects Vertex u_i and v_i.\nFor integers L, R (1 \\leq L \\leq R \\leq N), let us define a function f(L,...
[{"type": "stdin_stdout", "input": "10\n5 4\n5 7\n-1 13\n0 9\n12 10\n4 11\n7 4\n11 10\n7 4", "output": "152\n"}, {"type": "stdin_stdout", "input": "10\n5 16\n5 6\n-1 24\n1 10\n13 10\n4 6\n13 4\n6 3\n7 3", "output": "187\n"}, {"type": "stdin_stdout", "input": "10\n5 16\n5 6\n-1 24\n1 10\n13 10\n4 6\n13 4\n6 5\n7 3", "ou...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nTakahashi has N sticks that are distinguishable from each other. The length of the i-th stick is L_i.\nHe is going to form a triangle using three of these sticks. Let a, b, and c be the lengths of the three sticks used. H...
[{"type": "stdin_stdout", "input": "2000\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 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 1000 1000 1000 1000 100...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou will be given an array that contains two strings. Your job is to create a function that will take those two strings and transpose them, so that the strings go from top to bottom instead of left to right.\nA few things...
[{"input": "[\"joey\", \"louise\"]", "output": "[\"j l\\no o\\ne u\\ny i\\n s\\n e\"]", "fn_name": "transpose_two_strings"}, {"input": "[\"Hello\", \"World\"]", "output": "[\"H W\\ne o\\nl r\\nl l\\no d\"]", "fn_name": "transpose_two_strings"}, {"input": "[\"!a!a!\", \"?b?b\"]", "output": "[\"! ?\\na b\\n! ?\\na b\\n...
code_functional
[ { "content": "Solve the following coding problem using the programming language python:\n\nA country decides to build a palace.\nIn this country, the average temperature of a point at an elevation of x meters is T-x \\times 0.006 degrees Celsius.\nThere are N places proposed for the place. The elevation of Plac...
[{"type": "stdin_stdout", "input": "1000\n20 -20\n51765 34765 54644 24887 70030 45034 46376 88410 33772 52941 79750 44783 70874 36236 36651 16147 23251 11281 36605 69084 74679 18310 88655 92253 0 76064 82769 20419 60361 61197 51619 35110 6063 82815 99426 22379 61759 34008 31814 22642 80907 10203 11864 18291 34343 35250...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nOne day n friends met at a party, they hadn't seen each other for a long time and so they decided to make a group photo together. \n\nSimply speaking, the process of taking photos can be described as follows. On the photo...
[{"type": "stdin_stdout", "input": "10\n10 1000\n10 1000\n10 1000\n10 1000\n10 1000\n10 1000\n10 1000\n10 1000\n10 1000\n10 1000\n", "output": "90000 90000 90000 90000 90000 90000 90000 90000 90000 90000 "}, {"type": "stdin_stdout", "input": "10\n10 1000\n10 1000\n10 1000\n10 1000\n10 1000\n10 1000\n10 1000\n10 1000\n1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nKattapa, as you all know was one of the greatest warriors of his time. The kingdom of Maahishmati had never lost a battle under him (as army-chief), and the reason for that was their really powerful army, also called as M...
[{"type": "stdin_stdout", "input": "5\n12 -1 -2 -2 -2", "output": "READY FOR BATTLE\n"}, {"type": "stdin_stdout", "input": "5\n2 -1 -2 -2 -2", "output": "READY FOR BATTLE\n"}, {"type": "stdin_stdout", "input": "5\n2 -1 -1 -2 -2", "output": "READY FOR BATTLE\n"}, {"type": "stdin_stdout", "input": "5\n4 -1 -1 -2 -2", "ou...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSame as [the original](https://www.codewars.com/kata/simple-fun-number-258-is-divisible-by-6) (same rules, really, go there for example and I strongly recommend completing it first), but with more than one asterisk (but a...
[{"input": "\"***\"", "output": "[[\"000\", \"006\", \"012\", \"018\", \"024\", \"030\", \"036\", \"042\", \"048\", \"054\", \"060\", \"066\", \"072\", \"078\", \"084\", \"090\", \"096\", \"102\", \"108\", \"114\", \"120\", \"126\", \"132\", \"138\", \"144\", \"150\", \"156\", \"162\", \"168\", \"174\", \"180\", \"186\...
code_functional
[ { "content": "Solve the following coding problem using the programming language python:\n\nNeko is playing with his toys on the backyard of Aki's house. Aki decided to play a prank on him, by secretly putting catnip into Neko's toys. Unfortunately, he went overboard and put an entire bag of catnip into the toys...
[{"type": "stdin_stdout", "input": "1000\n", "output": "143886430\n"}, {"type": "stdin_stdout", "input": "450\n", "output": "690479399\n"}, {"type": "stdin_stdout", "input": "999\n", "output": "742390865\n"}, {"type": "stdin_stdout", "input": "900\n", "output": "454329300\n"}, {"type": "stdin_stdout", "input": "500\n",...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIn this Kata, we will calculate the **minumum positive number that is not a possible sum** from a list of positive integers. \n\n```\nsolve([1,2,8,7]) = 4 => we can get 1, 2, 3 (from 1+2), but we cannot get 4. 4 is the mi...
[{"input": "[4, 2, 8, 3, 1]", "output": "[19]", "fn_name": "solve"}, {"input": "[4, 2, 7, 3, 1]", "output": "[18]", "fn_name": "solve"}, {"input": "[2, 12, 3, 1]", "output": "[7]", "fn_name": "solve"}, {"input": "[4, 2, 12, 3]", "output": "[1]", "fn_name": "solve"}, {"input": "[1, 2, 8, 7]", "output": "[4]", "fn_name":...
code_functional
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou need count how many valleys you will pass.\n\nStart is always from zero level.\n\nEvery time you go down below 0 level counts as an entry of a valley, and as you go up to 0 level from valley counts as an exit of a val...
[{"input": "\"UFFDDFDUDFUFUUFFDDFDUDFUFUUFFDDFDUDFUFUUFFDDFDUDFUFUUFFDDFDUDFUFUUFFDDFDUDFUFU\"", "output": "[6]", "fn_name": "counting_valleys"}, {"input": "\"UFFDDFDUDFUFUUFFDDFDUDFUFUUFFDDFDUDFUFUUFFDDFDUDFUFU\"", "output": "[4]", "fn_name": "counting_valleys"}, {"input": "\"UFFDDFDUDFUFUUFFDDUFFDDUFFDDUDUDUDUDUDUUUU...
code_functional
[ { "content": "Solve the following coding problem using the programming language python:\n\nSimon has a prime number x and an array of non-negative integers a_1, a_2, ..., a_{n}.\n\nSimon loves fractions very much. Today he wrote out number $\\frac{1}{x^{a} 1} + \\frac{1}{x^{a_{2}}} + \\ldots + \\frac{1}{x^{a_{n...
[{"type": "stdin_stdout", "input": "26 7\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 2\n", "output": "49\n"}, {"type": "stdin_stdout", "input": "26 7\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 2\n", "output": "49\n"}, {"type": "stdin_stdout", "input": "26 2\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLike any unknown mathematician, Yuri has favourite numbers: $A$, $B$, $C$, and $D$, where $A \\leq B \\leq C \\leq D$. Yuri also likes triangles and once he thought: how many non-degenerate triangles with integer sides $x...
[{"type": "stdin_stdout", "input": "86565 229134 356183 486713\n", "output": "1559833368660730\n"}, {"type": "stdin_stdout", "input": "90528 225462 336895 417903\n", "output": "1043176084391535\n"}, {"type": "stdin_stdout", "input": "178561 294901 405737 476436\n", "output": "911664147520700\n"}, {"type": "stdin_stdout...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are playing a variation of game 2048. Initially you have a multiset $s$ of $n$ integers. Every integer in this multiset is a power of two. \n\nYou may perform any number (possibly, zero) operations with this multiset....
[{"type": "stdin_stdout", "input": "6\n4\n1024 512 64 512\n1\n2048\n3\n128 512 2\n2\n4096 8\n1\n2048 2 2048 2048 2048 2048 2048\n2\n2048 4898\n", "output": "YES\nYES\nNO\nNO\nYES\nYES\n"}, {"type": "stdin_stdout", "input": "6\n4\n1024 512 64 512\n1\n2048\n3\n64 512 2\n2\n4096 4\n7\n2048 2 2048 2048 2048 2048 2048\n2\n2...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nCreate a function that checks if a number `n` is divisible by two numbers `x` **AND** `y`. All inputs are positive, non-zero digits.\n\n```JS\nExamples:\n1) n = 3, x = 1, y = 3 => true because 3 is divisible by 1 and...
[{"input": "100\n5\n10", "output": "[true]", "fn_name": "is_divisible"}, {"input": "100\n5\n3", "output": "[false]", "fn_name": "is_divisible"}, {"input": "17\n17\n17", "output": "[true]", "fn_name": "is_divisible"}, {"input": "17\n1\n17", "output": "[true]", "fn_name": "is_divisible"}, {"input": "3\n2\n2", "output": "...
code_functional
[ { "content": "Solve the following coding problem using the programming language python:\n\nWrite a program which calculates the area and perimeter of a given rectangle.\n\nConstraints\n\n* 1 ≤ a, b ≤ 100\n\nInput\n\nThe length a and breadth b of the rectangle are given in a line separated by a single space.\n\n...
[{"type": "stdin_stdout", "input": "-10 2", "output": "-20 -16\n"}, {"type": "stdin_stdout", "input": "-16 -2", "output": "32 -36\n"}, {"type": "stdin_stdout", "input": "-16 -1", "output": "16 -34\n"}, {"type": "stdin_stdout", "input": "-16 1", "output": "-16 -30\n"}, {"type": "stdin_stdout", "input": "4 122", "output"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nMy friend John and I are members of the \"Fat to Fit Club (FFC)\". John is worried because\neach month a list with the weights of members is published and each month he is the last on the list\nwhich means he is the heavi...
[{"input": "\"387087 176 351832 100 430372 8 58052 54 175432 120 269974 147 309754 91 404858 67 271476 164 295747 111 40\"", "output": "[\"100 111 120 40 8 54 91 164 147 67 176 430372 58052 175432 351832 271476 309754 404858 387087 295747 269974\"]", "fn_name": "order_weight"}, {"input": "\"71899703 200 6 91 425 4 6740...
code_functional
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given two positive integers $a$ and $b$.\n\nIn one move, you can change $a$ in the following way:\n\n Choose any positive odd integer $x$ ($x > 0$) and replace $a$ with $a+x$; choose any positive even integer $y...
[{"type": "stdin_stdout", "input": "5\n2 3\n10 10\n2 4\n7 4\n9 3\n", "output": "1\n0\n2\n2\n1\n"}, {"type": "stdin_stdout", "input": "5\n2 3\n10 10\n2 4\n4 4\n9 3\n", "output": "1\n0\n2\n0\n1\n"}, {"type": "stdin_stdout", "input": "5\n2 3\n10 10\n2 7\n4 4\n9 3\n", "output": "1\n0\n1\n0\n1\n"}, {"type": "stdin_stdout", ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nVlad went into his appartment house entrance, now he is on the $1$-th floor. He was going to call the elevator to go up to his apartment.\n\nThere are only two elevators in his house. Vlad knows for sure that:\n\nthe firs...
[{"type": "stdin_stdout", "input": "69\n1 2 3\n3 1 2\n3 2 1\n1 2 3\n3 1 2\n3 2 1\n1 2 3\n3 1 2\n3 2 1\n1 2 3\n3 1 2\n3 2 1\n1 2 3\n3 1 2\n3 2 1\n1 2 3\n3 1 2\n3 2 1\n1 2 3\n3 1 2\n3 2 1\n1 2 3\n3 1 2\n3 2 1\n1 2 3\n3 1 2\n3 2 1\n1 2 3\n3 1 2\n3 2 1\n1 2 3\n3 1 2\n3 2 1\n1 2 3\n3 1 2\n3 2 1\n1 2 3\n3 1 2\n3 2 1\n1 2 3\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWe have a grid with 3 rows and N columns. The cell at the i-th row and j-th column is denoted (i, j). Initially, each cell (i, j) contains the integer i+3j-3.\n\n<image>\n\nA grid with N=5 columns\n\nSnuke can perform the...
[{"type": "stdin_stdout", "input": "7\n21 12 1 16 14 6 10\n20 11 0 27 14 7 8\n19 10 3 18 7 4 12", "output": "No\n"}, {"type": "stdin_stdout", "input": "7\n21 12 1 16 14 6 10\n20 12 0 27 14 7 8\n19 10 3 18 7 4 12", "output": "No\n"}, {"type": "stdin_stdout", "input": "7\n21 12 1 16 12 6 10\n20 12 0 27 14 7 8\n19 10 3 18...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a rectangle grid. That grid's size is n × m. Let's denote the coordinate system on the grid. So, each point on the grid will have coordinates — a pair of integers (x, y) (0 ≤ x ≤ n, 0 ≤ y ≤ m).\n\nYour task ...
[{"type": "stdin_stdout", "input": "1000000000 1000000000 286536427 579261823 230782719 575570138\n", "output": "171145067 291476754 401927786 867046892\n"}, {"type": "stdin_stdout", "input": "1000000000 1000000000 623214043 753726318 970868535 929707704\n", "output": "29131465 70292296 1000000000 1000000000\n"}, {"typ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWrite a function that checks if all the letters in the second string are present in the first one at least once, regardless of how many times they appear:\n\n```\n[\"ab\", \"aaa\"] => true\n[\"trances\", \"nectar\"] ...
[{"input": "[\"mastering\", \"streaming\"]", "output": "[true]", "fn_name": "letter_check"}, {"input": "[\"THE EYES\", \"they see\"]", "output": "[true]", "fn_name": "letter_check"}, {"input": "[\"drapes\", \"compadres\"]", "output": "[false]", "fn_name": "letter_check"}, {"input": "[\"assert\", \"staring\"]", "output"...
code_functional
[ { "content": "Solve the following coding problem using the programming language python:\n\nLa Confiserie d'ABC sells cakes at 4 dollars each and doughnuts at 7 dollars each.\nDetermine if there is a way to buy some of them for exactly N dollars. You can buy two or more doughnuts and two or more cakes, and you c...
[{"type": "stdin_stdout", "input": "100\n", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "11\n", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "40\n", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "12\n", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "15\n", "output": "Yes\n"}, {"type":...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nInnovation technologies are on a victorious march around the planet. They integrate into all spheres of human activity!\n\nA restaurant called \"Dijkstra's Place\" has started thinking about optimizing the booking system....
[{"type": "stdin_stdout", "input": "10\n739 307\n523 658\n700 143\n373 577\n120 433\n353 833\n665 516\n988 101\n817 604\n800 551\n10\n431 425 227 147 153 170 954 757 222 759\n", "output": "6 3621\n6 2\n2 8\n9 7\n4 1\n7 10\n5 4\n"}, {"type": "stdin_stdout", "input": "10\n739 307\n523 658\n700 143\n373 577\n120 433\n353 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a tree with $n$ vertices. You are allowed to modify the structure of the tree through the following multi-step operation: Choose three vertices $a$, $b$, and $c$ such that $b$ is adjacent to both $a$ and $c...
[{"type": "stdin_stdout", "input": "15\n4 6\n8 4\n12 11\n7 6\n9 8\n5 1\n14 13\n6 13\n1 4\n1 2\n6 11\n10 8\n15 14\n3 1\n", "output": "4\n"}, {"type": "stdin_stdout", "input": "15\n4 6\n8 4\n12 11\n7 6\n9 8\n5 1\n14 13\n6 13\n1 4\n1 2\n6 11\n10 8\n15 14\n3 1\n", "output": "4\n"}, {"type": "stdin_stdout", "input": "15\n9 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nRead problems statements in Mandarin Chinese and Russian \n\nChef is going to participate in a new quiz show: \"Who dares to be a millionaire?\"\nAccording to the rules of the game, contestants must answer N questions. ...
[{"type": "stdin_stdout", "input": "3\n5\nABCDE\nEBCDA\n1 10 34 18 78 225\n4\nCHEE\nQUIZ\n15 3 3 1 0\n8\nABBABAAB\nABABABAB\n100 100 100 100 001 001 000 000 000", "output": "34\n15\n100\n"}, {"type": "stdin_stdout", "input": "3\n5\nABCDE\nEBCDA\n1 10 34 18 63 225\n4\nCHEE\nQUIZ\n15 3 3 1 0\n8\nABBABAAB\nABABABAB\n100 1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nUnary is a minimalistic Brainfuck dialect in which programs are written using only one token. \n\nBrainfuck programs use 8 commands: \"+\", \"-\", \"[\", \"]\", \"<\", \">\", \".\" and \",\" (their meaning is not importan...
[{"type": "stdin_stdout", "input": ",]+>.],,+->+>-[]][><,-]><]++<.,-[.>.<+.[.<,[-,,[<]+>]->>]>]-+-+<][].,.]+][[<,-.+][+<<-+.],,,<,.]-].-\n", "output": "859903\n"}, {"type": "stdin_stdout", "input": ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n", "output": "20887...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nZS the Coder and Chris the Baboon has explored Udayland for quite some time. They realize that it consists of n towns numbered from 1 to n. \n\nThere are n directed roads in the Udayland. i-th of them goes from town i to ...
[{"type": "stdin_stdout", "input": "84\n2 50 67 79 71 45 43 40 57 20 25 8 60 47 52 10 37 23 1 28 22 26 3 42 11 63 61 68 49 32 55 18 5 24 31 70 66 27 38 41 54 12 65 51 15 34 30 35 77 74 21 62 33 16 81 14 19 48 80 73 69 78 39 6 76 46 75 72 84 29 58 59 13 17 82 9 83 4 36 56 53 7 64 44\n", "output": "428380105\n"}, {"type"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAlice has a cute cat. To keep her cat fit, Alice wants to design an exercising walk for her cat! \n\nInitially, Alice's cat is located in a cell $(x,y)$ of an infinite grid. According to Alice's theory, cat needs to move:...
[{"type": "stdin_stdout", "input": "6\n3 2 2 2\n0 0 -2 -2 2 2\n3 1 4 1\n0 0 -1 -1 1 1\n1 1 1 1\n1 1 1 1 1 1\n0 0 0 1\n0 0 0 0 0 1\n5 1 1 1\n0 0 -100 -100 0 100\n1 1 5 1\n0 0 -100 -100 100 0\n", "output": "Yes\nNo\nNo\nYes\nYes\nYes\n"}, {"type": "stdin_stdout", "input": "6\n3 2 2 2\n0 1 -2 -2 2 2\n3 1 4 1\n0 0 -1 -1 1 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nBizon the Champion isn't just attentive, he also is very hardworking.\n\nBizon the Champion decided to paint his old fence his favorite color, orange. The fence is represented as n vertical planks, put in a row. Adjacent ...
[{"type": "stdin_stdout", "input": "30\n1 4 5 3 9 7 8 4 5 9 2 3 4 2 3 4 5 5 6 8 1 2 9 4 3 7 2 6 5 4\n", "output": "26\n"}, {"type": "stdin_stdout", "input": "30\n1 4 5 3 9 7 8 4 5 9 2 3 4 2 3 4 5 5 6 8 1 2 9 4 3 7 2 6 5 4\n", "output": "26\n"}, {"type": "stdin_stdout", "input": "30\n1 4 5 3 9 7 8 4 5 1 2 3 4 2 3 4 5 5 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe Chef likes to stay in touch with his staff. So, the Chef, the head server, and the sous-chef all carry two-way transceivers so they can stay in constant contact. Of course, these transceivers have a limited range so i...
[{"type": "stdin_stdout", "input": "3\n2\n0 -1\n-1 -1\n1 0\n2\n0 0\n0 -1\n1 -1\n2\n1 0\n1 2\n1 1", "output": "yes\nyes\nyes\n"}, {"type": "stdin_stdout", "input": "3\n2\n0 -1\n-1 -1\n1 0\n2\n1 0\n0 -1\n1 -1\n2\n1 0\n1 2\n1 1", "output": "yes\nyes\nyes\n"}, {"type": "stdin_stdout", "input": "3\n2\n0 -1\n-1 -1\n1 0\n2\n0...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA [Word Square](https://en.wikipedia.org/wiki/Word_square) is a set of words written out in a square grid, such that the same words can be read both horizontally and vertically. The number of words, equal to the number of...
[{"input": "\"DESCENDANTECHENEIDAESHORTCOATSCERBERULUSENTEROMERENECROLATERDIOUMABANAADALETABATNATURENAMETESSERATED\"", "output": "[true]", "fn_name": "word_square"}, {"input": "\"GLASSESRELAPSEIMITATESMEAREDTANNERY\"", "output": "[false]", "fn_name": "word_square"}, {"input": "\"FRACTUREOUTLINEDBLOOMINGSEPTETTE\"", "ou...
code_functional
[ { "content": "Solve the following coding problem using the programming language python:\n\nWrite a function that will check whether the permutation of an input string is a palindrome. Bonus points for a solution that is efficient and/or that uses _only_ built-in language functions. Deem yourself **brilliant** i...
[{"input": "\"abcdefghba\"", "output": "[false]", "fn_name": "permute_a_palindrome"}, {"input": "\"racecars\"", "output": "[false]", "fn_name": "permute_a_palindrome"}, {"input": "\"baabcd\"", "output": "[false]", "fn_name": "permute_a_palindrome"}, {"input": "\"baa\"", "output": "[true]", "fn_name": "permute_a_palindr...
code_functional
[ { "content": "Solve the following coding problem using the programming language python:\n\nExample\n\nInput\n\n3\n1 3 3\n2\n1 2\n1 3\n\n\nOutput\n\n5\n\nThe input will be stdin and you should print your solution to stdout\n\n\nNow solve the problem and return the code.\n\nWrite Python code to solve this problem...
[{"type": "stdin_stdout", "input": "3\n0 2 0\n-1\n1 2\n0 2", "output": "3\n"}, {"type": "stdin_stdout", "input": "3\n0 2 0\n-1\n1 2\n0 1", "output": "3\n"}, {"type": "stdin_stdout", "input": "3\n1 1 0\n0\n1 2\n-1 1", "output": "3\n"}, {"type": "stdin_stdout", "input": "3\n0 1 1\n0\n2 1\n-1 1", "output": "3\n"}, {"type"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nBarney lives in country USC (United States of Charzeh). USC has n cities numbered from 1 through n and n - 1 roads between them. Cities and roads of USC form a rooted tree (Barney's not sure why it is rooted). Root of the...
[{"type": "stdin_stdout", "input": "85\n1 1 2 2 4 6 1 3 6 3 3 11 9 14 12 5 8 11 16 19 12 17 2 19 1 24 6 2 6 6 24 3 20 1 1 1 17 8 4 25 31 32 39 12 35 23 31 26 46 9 37 7 5 23 41 41 39 9 11 54 36 54 28 15 25 58 56 18 23 70 68 18 3 48 57 70 15 65 22 35 25 13 49 34\n", "output": "1.00000000 28.50000000 27.00000000 38.000000...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\n**Debug** a function called calculate that takes 3 values. The first and third values are numbers. The second value is a character. If the character is \"+\" , \"-\", \"\\*\", or \"/\", the function will return the result...
[{"input": "-2\n\"codewars\"\n-2", "output": "[null]", "fn_name": "calculate"}, {"input": "3.2\n\"+\"\n8", "output": "[11.2]", "fn_name": "calculate"}, {"input": "3.2\n\"-\"\n8", "output": "[-4.8]", "fn_name": "calculate"}, {"input": "3.2\n\"*\"\n8", "output": "[25.6]", "fn_name": "calculate"}, {"input": "6\n\"-\"\n1.5...
code_functional
[ { "content": "Solve the following coding problem using the programming language python:\n\nLet's call beauty of an array b_1, b_2, …, b_n (n > 1) — min_{1 ≤ i < j ≤ n} |b_i - b_j|.\n\nYou're given an array a_1, a_2, … a_n and a number k. Calculate the sum of beauty over all subsequences of the array of length e...
[{"type": "stdin_stdout", "input": "52 52\n19752 66708 73109 84463 95683 96876 98503 98812 99766 99778 99913 99975 99977 99997 99997 99997 99998 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nTwo bears are playing tic-tac-toe via mail. It's boring for them to play usual tic-tac-toe game, so they are a playing modified version of this game. Here are its rules.\n\nThe game is played on the following field.\n\n<i...
[{"type": "stdin_stdout", "input": "xxo xoo xxo\nooo ooo xxx\noox oxo oxx\n\noxo oxo xxx\nxoo oxx oxo\nxxx oxx ooo\n\noxx xoo xxo\nxxx oox xox\nxxo o.o oxo\n9 6\n", "output": "xxo xoo xxo \nooo ooo xxx \noox oxo oxx \n\noxo oxo xxx \nxoo oxx oxo \nxxx oxx ooo \n\noxx xoo xxo \nxxx oox xox \nxxo o!o oxo \n\n"}, {"type":...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA sequence $a = [a_1, a_2, \\ldots, a_l]$ of length $l$ has an ascent if there exists a pair of indices $(i, j)$ such that $1 \\le i < j \\le l$ and $a_i < a_j$. For example, the sequence $[0, 2, 0, 2, 0]$ has an ascent b...
[{"type": "stdin_stdout", "input": "10\n3 62 24 39\n1 17\n1 99\n1 60\n1 64\n1 30\n2 79 29\n2 20 73\n2 85 37\n1 100\n", "output": "72\n"}, {"type": "stdin_stdout", "input": "10\n3 62 24 39\n1 17\n1 99\n1 60\n1 64\n1 30\n2 79 29\n2 20 73\n2 85 37\n1 100\n", "output": "72\n"}, {"type": "stdin_stdout", "input": "5\n5 1 2 2...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nDropCaps means that the first letter of the starting word of the paragraph should be in caps and the remaining lowercase, just like you see in the newspaper. \n\nBut for a change, let's do that for each and every word of ...
[{"input": "\"Revelation of the contents outraged American public opinion, and helped generate\"", "output": "[\"Revelation of The Contents Outraged American Public Opinion, And Helped Generate\"]", "fn_name": "drop_cap"}, {"input": "\"more than one space between words\"", "output": "[\"More Than One Space Betw...
code_functional
[ { "content": "Solve the following coding problem using the programming language python:\n\nStudent Valera is an undergraduate student at the University. His end of term exams are approaching and he is to pass exactly n exams. Valera is a smart guy, so he will be able to pass any exam he takes on his first try. ...
[{"type": "stdin_stdout", "input": "1\n1000000000 999999999\n", "output": "999999999\n"}, {"type": "stdin_stdout", "input": "1\n1000000000 999999999\n", "output": "999999999\n"}, {"type": "stdin_stdout", "input": "1\n1010000000 999999999\n", "output": "999999999\n"}, {"type": "stdin_stdout", "input": "1\n1010000000 498...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere is a frequency operation in the conversion operation of a finite number sequence. The conversion result of the sequence $ S = \\\\ {s_1, s_2, ... s_n \\\\} $ is a sequence of the same length. If the result is $ C = ...
[{"type": "stdin_stdout", "input": "10\n2 5 1 -1 3 4 27 0 -2 6\n0", "output": "2\n10 10 10 10 10 10 10 10 10 10\n"}, {"type": "stdin_stdout", "input": "10\n2 1 0 0 3 5 0 0 0 12\n0", "output": "3\n10 10 10 10 10 10 10 10 10 10\n"}, {"type": "stdin_stdout", "input": "10\n2 5 1 0 3 4 27 0 -2 10\n0", "output": "2\n8 8 8 2 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nArseniy is already grown-up and independent. His mother decided to leave him alone for m days and left on a vacation. She have prepared a lot of food, left some money and washed all Arseniy's clothes. \n\nTen minutes befo...
[{"type": "stdin_stdout", "input": "10 3 3\n2 2 1 3 1 2 1 2 2 2\n10 8\n9 6\n8 10\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "10 1 3\n2 2 1 3 1 2 1 2 2 2\n10 8\n9 6\n8 10\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "10 1 3\n2 2 1 3 1 2 1 2 2 2\n10 8\n9 6\n3 10\n", "output": "0\n"}, {"type": "std...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nRead problems statements in English, Mandarin Chinese and Russian as well. \n\nSherlock is stuck. There is a N X N grid in which some cells are empty (denoted by ‘.’), while some cells have rocks in them (denoted by ‘#’)....
[{"type": "stdin_stdout", "input": "2\n3\n#..\n..#\n#..\n3\n#.#\n#.#\n#.#", "output": "3\n0\n"}, {"type": "stdin_stdout", "input": "2\n3\n#..\n\"..\n#..\n3\n#.#\n#.#\n#.#", "output": "6\n0\n"}, {"type": "stdin_stdout", "input": "2\n3\n$..\n..#\n#..\n3\n\"-#\n#.#\n\"#.", "output": "3\n1\n"}, {"type": "stdin_stdout", "in...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given an integer n. You have to apply m operations to it.\n\nIn a single operation, you must replace every digit d of the number with the decimal representation of integer d + 1. For example, 1912 becomes 21023 af...
[{"type": "stdin_stdout", "input": "5\n178 170\n26 25\n64 84\n19 12\n20 136\n", "output": "764520\n12\n1015\n6\n32483\n"}, {"type": "stdin_stdout", "input": "5\n178 170\n26 25\n64 84\n19 12\n38 136\n", "output": "764520\n12\n1015\n6\n46148\n"}, {"type": "stdin_stdout", "input": "5\n178 170\n26 25\n64 84\n19 6\n20 136\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are three houses on a number line: House 1, 2 and 3, with coordinates A, B and C, respectively. Print `Yes` if we pass the coordinate of House 3 on the straight way from House 1 to House 2 without making a detour, a...
[{"type": "stdin_stdout", "input": "31 61 59", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "31 61 51", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "31 86 59", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "39 69 59", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "31 49 59", "output":...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA bracket sequence is a string containing only characters \"(\" and \")\".\n\nA regular bracket sequence is a bracket sequence that can be transformed into a correct arithmetic expression by inserting characters \"1\" and...
[{"type": "stdin_stdout", "input": "10\n()()(\n)((\n)()(((()(\n(((()(\n)(()((\n))\n()()()()\n))()))((\n)\n))())(\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "10\n()()(\n)((\n)()(((()(\n(((()(\n)(()((\n))\n()()()()\n))()))((\n)\n))())(\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "10\n()()(\n)((\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYour company was appointed to lay new asphalt on the highway of length $n$. You know that every day you can either repair one unit of the highway (lay new asphalt over one unit of the highway) or skip repairing.\n\nSkippi...
[{"type": "stdin_stdout", "input": "3\n10 1 1\n11 4 10\n1000000 1 1000100\n", "output": "10\n16\n500049499900\n"}, {"type": "stdin_stdout", "input": "3\n10 1 1\n16 4 10\n1000000 1 1000100\n", "output": "10\n18\n500049499900\n"}, {"type": "stdin_stdout", "input": "3\n10 1 1\n16 4 10\n1000001 1 1000100\n", "output": "10\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nMonocarp wants to draw four line segments on a sheet of paper. He wants the $i$-th segment to have its length equal to $a_i$ ($1 \\le i \\le 4$). These segments can intersect with each other, and each segment should be ei...
[{"type": "stdin_stdout", "input": "4\n1 1 5 4\n4 16 10 4\n2 1 4 1\n100 21 54 111\n", "output": "4\n40\n2\n2100\n"}, {"type": "stdin_stdout", "input": "4\n0 5 2 4\n6 14 10 3\n2 0 5 1\n101 40 47 111\n", "output": "0\n30\n0\n4040\n"}, {"type": "stdin_stdout", "input": "4\n1 1 5 8\n4 16 10 4\n2 1 4 1\n100 21 54 111\n", "o...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nTakahashi is meeting up with Aoki.\nThey have planned to meet at a place that is D meters away from Takahashi's house in T minutes from now.\nTakahashi will leave his house now and go straight to the place at a speed of S...
[{"type": "stdin_stdout", "input": "7202 7775 4325\n", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "3982 4784 8417\n", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "2156 1932 5902\n", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "1 10000 10000\n", "output": "Yes\n"}, {"type": "stdin_stdout",...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\n## Your Story\n\"A *piano* in the home meant something.\" - *Fried Green Tomatoes at the Whistle Stop Cafe*\n\nYou've just realized a childhood dream by getting a beautiful and beautiful-sounding upright piano from a frie...
[{"input": "2017", "output": "[\"white\"]", "fn_name": "black_or_white_key"}, {"input": "100", "output": "[\"black\"]", "fn_name": "black_or_white_key"}, {"input": "111", "output": "[\"white\"]", "fn_name": "black_or_white_key"}, {"input": "200", "output": "[\"black\"]", "fn_name": "black_or_white_key"}, {"input": "12"...
code_functional
[ { "content": "Solve the following coding problem using the programming language python:\n\nGiven a string and an array of integers representing indices, capitalize all letters at the given indices. \n\nFor example:\n\n* `capitalize(\"abcdef\",[1,2,5]) = \"aBCdeF\"`\n* `capitalize(\"abcdef\",[1,2,5,100]) = \"aBC...
[{"input": "\"abracadabra\"\n[2, 6, 9, 10]", "output": "[\"abRacaDabRA\"]", "fn_name": "capitalize"}, {"input": "\"indexinglessons\"\n[0]", "output": "[\"Indexinglessons\"]", "fn_name": "capitalize"}, {"input": "\"codewars\"\n[1, 3, 5, 50]", "output": "[\"cOdEwArs\"]", "fn_name": "capitalize"}, {"input": "\"codewarrior...
code_functional
[ { "content": "Solve the following coding problem using the programming language python:\n\nIlya is a very clever lion, he lives in an unusual city ZooVille. In this city all the animals have their rights and obligations. Moreover, they even have their own bank accounts. The state of a bank account is an integer...
[{"type": "stdin_stdout", "input": "-1000000000\n", "output": "-100000000\n"}, {"type": "stdin_stdout", "input": "-1000000000\n", "output": "-100000000\n"}, {"type": "stdin_stdout", "input": "-1015555150\n", "output": "-101555510\n"}, {"type": "stdin_stdout", "input": "-1620057635\n", "output": "-162005763\n"}, {"type"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAddition is easy to calculate by hand, but if some numbers are missing, is it easy to fill in the missing numbers? For example, in the following long division, if there is a condition that the numbers 1 to 9 appear only o...
[{"type": "stdin_stdout", "input": "-1 -1 -1 -1 -1 -1 -1 -1 -1", "output": "168"}, {"type": "stdin_stdout", "input": "-1 -1 -1 -1 -1 -1 3 4 6", "output": "0\n"}, {"type": "stdin_stdout", "input": "-1 -1 -1 -1 -1 -1 3 2 6", "output": "0\n"}, {"type": "stdin_stdout", "input": "-1 -1 -1 -1 -1 -2 3 2 6", "output": "0\n"}, ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nExample\n\nInput\n\n3 3 1 2 4\n1 2\n2 3\n3 1\n\n\nOutput\n\nIMPOSSIBLE\n\nThe input will be stdin and you should print your solution to stdout\n\n\nNow solve the problem and return the code.\n\nWrite Python code to solve ...
[{"type": "stdin_stdout", "input": "4 1 2 1 2\n1 2\n2 3\n11 0", "output": "IMPOSSIBLE\n"}, {"type": "stdin_stdout", "input": "8 1 2 1 2\n1 2\n2 3\n11 0", "output": "IMPOSSIBLE\n"}, {"type": "stdin_stdout", "input": "3 3 2 2 4\n1 2\n2 3\n3 1", "output": "IMPOSSIBLE\n"}, {"type": "stdin_stdout", "input": "3 3 2 1 4\n1 2\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are $n$ computers in a row, all originally off, and Phoenix wants to turn all of them on. He will manually turn on computers one at a time. At any point, if computer $i-1$ and computer $i+1$ are both on, computer $i...
[{"type": "stdin_stdout", "input": "100 999999733\n", "output": "499246611\n"}, {"type": "stdin_stdout", "input": "350 999999733\n", "output": "255248393\n"}, {"type": "stdin_stdout", "input": "397 999999733\n", "output": "239189389\n"}, {"type": "stdin_stdout", "input": "398 999999733\n", "output": "875462745\n"}, {"t...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a tree with N vertices.\n\nHere, a tree is a kind of graph, and more specifically, a connected undirected graph with N-1 edges, where N is the number of its vertices.\n\nThe i-th edge (1≤i≤N-1) connects Vert...
[{"type": "stdin_stdout", "input": "30\n20 2 885820291\n9 3 833676138\n21 8 969316096\n13 10 732239064\n14 12 568976928\n4 14 362005859\n4 17 46938898\n4 21 706609800\n13 4 114271135\n18 13 475446302\n20 22 582315387\n7 23 941896909\n18 7 546231774\n30 24 698675648\n30 25 13971027\n11 26 760254873\n30 27 731457744\n1 2...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nJapan achieved the second straight victory in the national baseball competition WBC !! A baseball tournament was held at Aizu Gakuen High School as baseball became more popular. In this tournament, a round-robin league ma...
[{"type": "stdin_stdout", "input": "6\nA 1 0 0 2 -1\nB 0 0 1 2 -1\nC 2 1 1 1 1\nD 2 0 -1 0 2\nE 2 0 0 0 0\nF 1 1 1 2 2\n4\nh 1 1 1\ng 0 2 2\nx -1 0 0\n` 0 2 2\n0", "output": "E\nD\nA\nB\nF\nC\nx\ng\n`\nh\n"}, {"type": "stdin_stdout", "input": "6\nA 1 0 0 2 -1\nB 0 0 1 1 0\nC 1 1 1 1 1\nD 1 1 0 0 2\nE 2 0 -1 0 0\nF 1 2 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nJohnny drives a truck and must deliver a package from his hometown to the district center. His hometown is located at point 0 on a number line, and the district center is located at the point d.\n\nJohnny's truck has a ga...
[{"type": "stdin_stdout", "input": "281 12 23\n178 650197\n129 288456\n34 1664910\n43 683515\n305 957083\n103 724815\n105 308008\n252 1280706\n74 87088\n229 146026\n85 241042\n35 39127\n62 47524\n217 760274\n156 562141\n10 209057\n50 714473\n201 164128\n97 624021\n120 102709\n147 388268\n317 1546753\n190 1448117\n", "o...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nFast Forwarding\n\nMr. Anderson frequently rents video tapes of his favorite classic films. Watching the films so many times, he has learned the precise start times of his favorite scenes in all such films. He now wants t...
[{"type": "stdin_stdout", "input": "2139", "output": "21\n"}, {"type": "stdin_stdout", "input": "1374", "output": "22\n"}, {"type": "stdin_stdout", "input": "3723", "output": "23\n"}, {"type": "stdin_stdout", "input": "138", "output": "12\n"}, {"type": "stdin_stdout", "input": "149", "output": "13\n"}, {"type": "stdin_...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWhen Serezha was three years old, he was given a set of cards with letters for his birthday. They were arranged into words in the way which formed the boy's mother favorite number in binary notation. Serezha started playi...
[{"type": "stdin_stdout", "input": "400\nzzzerrzrzzrozrezooreroeoeezerrzeerooereezeeererrezrororoorrzezoeerrorzrezzrzoerrzorrooerzrzeozrrorzzzzeoeereeroeozezeozoozooereoeorrzoroeoezooeerorreeorezeozeroerezoerooooeerozrrorzozeroereerozeozeoerroroereeeerzzrzeeozrezzozeoooeerzzzorozrzezrrorozezoorzzerzroeeeerorreeoezoeroe...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a sequence (P_1,P_2,...,P_N) which is a permutation of the integers from 1 through N. You would like to sort this sequence in ascending order by repeating the following operation:\n\n* Choose an element in t...
[{"type": "stdin_stdout", "input": "8\n6\n3\n2\n1\n7\n4\n8\n5", "output": "5\n"}, {"type": "stdin_stdout", "input": "8\n6\n3\n1\n2\n5\n4\n8\n7", "output": "6\n"}, {"type": "stdin_stdout", "input": "8\n6\n3\n2\n1\n4\n7\n8\n5", "output": "5\n"}, {"type": "stdin_stdout", "input": "8\n6\n3\n2\n1\n7\n4\n5\n8", "output": "5\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nOn a chessboard with a width of $n$ and a height of $n$, rows are numbered from bottom to top from $1$ to $n$, columns are numbered from left to right from $1$ to $n$. Therefore, for each cell of the chessboard, you can a...
[{"type": "stdin_stdout", "input": "1000000000000000000\n1000000000000000010 1000000000000000000\n", "output": "black\n"}, {"type": "stdin_stdout", "input": "1000000000000000000\n1100000000000000010 1000000000000000000\n", "output": "black\n"}, {"type": "stdin_stdout", "input": "1000000000000000000\n1100000000000001010...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nKnights' tournaments were quite popular in the Middle Ages. A lot of boys were dreaming of becoming a knight, while a lot of girls were dreaming of marrying a knight on a white horse.\n\nIn this problem we consider one of...
[{"type": "stdin_stdout", "input": "14", "output": "0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA motorcade of n trucks, driving from city «Z» to city «З», has approached a tunnel, known as Tunnel of Horror. Among truck drivers there were rumours about monster DravDe, who hunts for drivers in that tunnel. Some drive...
[{"type": "stdin_stdout", "input": "20\n7892 2 0 24\n4201 1 2 23\n3667 1 3 22\n6388 1 4 21\n2406 1 5 20\n1148 1 6 19\n3958 1 7 18\n7363 1 8 17\n9025 2 9 15\n1909 1 11 14\n73 1 12 13\n5477 2 13 11\n1869 1 15 10\n107 1 16 9\n523 1 17 8\n6589 2 18 6\n6277 2 20 4\n3881 1 22 3\n5771 1 23 2\n622 2 24 0\n", "output": "20\n1 2...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\n# Task\n Sorting is one of the most basic computational devices used in Computer Science. \n \n Given a sequence (length ≤ 1000) of 3 different key values (7, 8, 9), your task is to find the minimum number of exchange ope...
[{"input": "[9, 9, 9, 9, 9, 8, 8, 8, 8, 7, 7, 7, 7, 7, 7]", "output": "[6]", "fn_name": "exchange_sort"}, {"input": "[9, 9, 9, 7, 7, 8, 9, 7, 8, 9, 7, 9]", "output": "[4]", "fn_name": "exchange_sort"}, {"input": "[8, 8, 7, 9, 9, 9, 8, 9, 7]", "output": "[4]", "fn_name": "exchange_sort"}, {"input": "[7, 7, 8, 8, 9, 9]",...
code_functional
[ { "content": "Solve the following coding problem using the programming language python:\n\nWrite a program which reads a $ n \\times m$ matrix $A$ and a $m \\times 1$ vector $b$, and prints their product $Ab$.\n\nA column vector with m elements is represented by the following equation.\n\n\\\\[ b = \\left( \\be...
[{"type": "stdin_stdout", "input": "3 4\n1 4 -2 1\n0 3 0 -1\n4 1 0 0\n0\n-2\n3\n0", "output": "-14\n-6\n-2\n"}, {"type": "stdin_stdout", "input": "3 4\n0 7 -13 0\n0 0 0 1\n4 2 2 0\n1\n1\n3\n-1", "output": "-32\n-1\n12\n"}, {"type": "stdin_stdout", "input": "3 4\n0 7 -13 0\n0 0 0 1\n4 2 2 0\n1\n2\n3\n-1", "output": "-25...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nBitwise exclusive OR (or bitwise addition modulo two) is a binary operation which is equivalent to applying logical exclusive OR to every pair of bits located on the same positions in binary notation of operands. In other...
[{"type": "stdin_stdout", "input": "9992164445234764941\n8162963574901971597\n", "output": "914600435166396672 9077564010068368269"}, {"type": "stdin_stdout", "input": "1367480970723947\n584615739735395\n", "output": "391432615494276 976048355229671"}, {"type": "stdin_stdout", "input": "339671107814\n208405902980\n", "...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLet's suppose you have an array a, a stack s (initially empty) and an array b (also initially empty).\n\nYou may perform the following operations until both a and s are empty:\n\n Take the first element of a, push it int...
[{"type": "stdin_stdout", "input": "40 39\n25 4 26 34 35 11 22 23 21 2 1 28 20 8 36 5 27 15 39 7 24 14 17 19 33 6 38 16 18 3 32 10 30 13 37 31 29 9 12\n", "output": "-1\n"}, {"type": "stdin_stdout", "input": "40 39\n25 4 26 34 35 11 22 23 21 2 1 28 20 8 36 5 27 15 39 7 24 14 17 19 33 6 38 16 18 3 32 10 30 13 37 31 29 9...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nRecall that string $a$ is a subsequence of a string $b$ if $a$ can be obtained from $b$ by deletion of several (possibly zero or all) characters. For example, for the string $a$=\"wowwo\", the following strings are subseq...
[{"type": "stdin_stdout", "input": "ovvvvovovvvvovoovovovovvvvvvvoovoovvovvoooooovo\n", "output": "463\n"}, {"type": "stdin_stdout", "input": "ovvvvovovvvvovoovovovovvvvvvvoovoovvovvoooooovo\n", "output": "463\n"}, {"type": "stdin_stdout", "input": "vvovooovovvovoovoovvvvovovvvov\n", "output": "100\n"}, {"type": "stdin...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nStudents of group 199 have written their lectures dismally. Now an exam on Mathematical Analysis is approaching and something has to be done asap (that is, quickly). Let's number the students of the group from 1 to n. Eac...
[{"type": "stdin_stdout", "input": "10\n9 10 6 8 5 3 1 7 4 2\n7 6 2 9 5 10 8 4 1 3\n", "output": "8 3 10 1 5 2 4 9 7 6 "}, {"type": "stdin_stdout", "input": "10\n2 9 1 7 6 8 5 4 10 3\n6 8 5 1 9 10 2 3 4 7\n", "output": "5 6 7 3 2 9 1 10 8 4 "}, {"type": "stdin_stdout", "input": "10\n5 9 7 1 4 10 3 6 2 8\n8 3 9 10 6 5 2...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given n points on the plane. The polygon formed from all the n points is strictly convex, that is, the polygon is convex, and there are no three collinear points (i.e. lying in the same straight line). The points ...
[{"type": "stdin_stdout", "input": "20\n-2967010 48581504\n-2967318 48581765\n-2967443 48581988\n-2967541 48582265\n-2967443 48582542\n-2967318 48582765\n-2967010 48583026\n-2966691 48583154\n-2966252 48583234\n-2965813 48583154\n-2965494 48583026\n-2965186 48582765\n-2965061 48582542\n-2964963 48582265\n-2965061 48581...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\n# Esolang Interpreters #2 - Custom Smallfuck Interpreter\n\n## About this Kata Series\n\n\"Esolang Interpreters\" is a Kata Series that originally began as three separate, independent esolang interpreter Kata authored by ...
[{"input": "\"*>*>>>*>*>>>>>*>[>*]\"\n\"0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\"", "output": "[\"11001...
code_functional
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a string S of length N. Among its subsequences, count the ones such that all characters are different, modulo 10^9+7. Two subsequences are considered different if their characters come from different positio...
[{"type": "stdin_stdout", "input": "5\naabbc", "output": "17\n"}, {"type": "stdin_stdout", "input": "5\nabcda", "output": "23\n"}, {"type": "stdin_stdout", "input": "5\nbdacf", "output": "31\n"}, {"type": "stdin_stdout", "input": "5\nabcaa", "output": "15\n"}, {"type": "stdin_stdout", "input": "5\nabbaa", "output": "11...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are N mountains in a circle, called Mountain 1, Mountain 2, ..., Mountain N in clockwise order. N is an odd number.\nBetween these mountains, there are N dams, called Dam 1, Dam 2, ..., Dam N. Dam i (1 \\leq i \\leq...
[{"type": "stdin_stdout", "input": "4347\n260851 113568 146755 277208 291368 365593 306158 216020 344668 347475 275144 352224 284362 117882 195739 364750 445348 416819 269652 99635 82915 80392 51627 75388 237943 322687 343290 419290 298882 162789 250158 343046 283281 278723 215017 105840 263209 271290 119076 276553 322...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe only difference between easy and hard versions is the maximum value of $n$.\n\nYou are given a positive integer number $n$. You really love good numbers so you want to find the smallest good number greater than or equ...
[{"type": "stdin_stdout", "input": "100\n2\n8\n5\n6\n5\n4\n4\n6\n12\n2\n9\n5\n10\n8\n4\n10\n9\n6\n9\n4\n5\n6\n4\n4\n7\n1\n2\n2\n5\n6\n1\n5\n10\n9\n10\n16\n3\n2\n2\n3\n2\n7\n9\n2\n9\n5\n7\n8\n1\n5\n2\n5\n1\n3\n8\n4\n7\n9\n3\n1\n7\n1\n2\n4\n7\n2\n7\n1\n1\n10\n8\n5\n7\n12\n10\n8\n1\n7\n5\n10\n7\n6\n6\n6\n7\n4\n9\n3\n4\n9\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSeveral days ago you bought a new house and now you are planning to start a renovation. Since winters in your region can be very cold you need to decide how to heat rooms in your house.\n\nYour house has $n$ rooms. In the...
[{"type": "stdin_stdout", "input": "69\n2 6\n2 6\n2 6\n2 6\n2 6\n2 6\n2 6\n2 6\n2 6\n2 6\n2 6\n2 6\n2 6\n2 6\n2 6\n2 6\n2 6\n2 6\n2 6\n2 6\n2 15\n2 6\n2 6\n2 6\n2 6\n2 6\n2 11\n2 6\n2 6\n2 6\n2 6\n2 6\n2 6\n2 6\n2 7\n2 11\n2 6\n2 6\n2 6\n2 6\n4 6\n2 6\n2 6\n2 6\n2 6\n2 6\n2 6\n2 6\n2 6\n2 6\n2 6\n2 6\n2 6\n2 6\n2 6\n2 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nTaro and Hanako have numbers of cards in their hands. Each of the cards has a score on it. Taro and Hanako wish to make the total scores of their cards equal by exchanging one card in one's hand with one card in the other...
[{"type": "stdin_stdout", "input": "2 2\n1\n6\n3\n14\n6 5\n3\n4\n5\n2\n4\n7\n11\n2\n7\n4\n1\n4 5\n10\n-1\n3\n11\n1\n9\n6\n0\n1\n7 4\n1\n0\n4\n0\n2\n1\n4\n4\n2\n1\n-1\n2 3\n0\n1\n2\n4\n2\n0 0", "output": "-1\n2 2\n3 0\n2 -1\n-1\n"}, {"type": "stdin_stdout", "input": "2 2\n1\n6\n3\n14\n6 5\n3\n4\n5\n2\n4\n7\n11\n2\n7\n4\...
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 11\n7 8\n8 9\n9 10\n10 11\n", "output": "0\n\n"}, {"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": "11 1 5\n6\n1 2\n2 3\n3 4\n4 5\n5 6\n6 7\n...
code_stdio