messages
listlengths
1
1
ground_truth
stringlengths
156
726k
dataset
stringclasses
2 values
[ { "content": "One particularly well-known fact about zombies is that they move and think terribly slowly. While we still don't know why their movements are so sluggish, the problem of laggy thinking has been recently resolved. It turns out that the reason is not (as previously suspected) any kind of brain defec...
[{"input": "10 9\n2 3\n6 8\n10 1\n1 8\n6 7\n8 7\n10 5\n7 10\n2 5\n", "output": "no\n"}, {"input": "10 9\n2 3\n6 8\n10 1\n1 8\n6 7\n8 7\n10 5\n7 10\n2 5\n", "output": "no\n"}, {"input": "10 9\n2 3\n6 8\n10 1\n1 8\n6 7\n8 7\n10 5\n7 10\n2 2\n", "output": "no\n"}, {"input": "10 9\n2 3\n6 8\n10 1\n1 8\n6 7\n8 7\n10 4\n7 10...
code_stdio
[ { "content": "You are standing near a very strange machine. If you put C cents in the machine, the remaining money in your purse will transform in an unusual way. If you have A dollars and B cents remaining in your purse after depositing the C cents, then after the transformation you will have B dollars and A c...
[{"input": "2\n9 72 53\n98 73 69", "output": "125\n27\n"}, {"input": "2\n9 82 69\n98 116 69", "output": "33\n11\n"}, {"input": "2\n9 82 100\n98 116 69", "output": "1\n11\n"}, {"input": "2\n9 90 80\n100 73 69", "output": "125\n0\n"}, {"input": "2\n11 72 32\n78 0 13", "output": "53\n121\n"}, {"input": "2\n2 77 69\n104 84...
code_stdio
[ { "content": "Hooray! Berl II, the king of Berland is making a knight tournament. The king has already sent the message to all knights in the kingdom and they in turn agreed to participate in this grand event.\n\nAs for you, you're just a simple peasant. There's no surprise that you slept in this morning and we...
[{"input": "11 8\n3 5 5\n8 9 9\n4 6 6\n8 10 10\n5 7 7\n2 7 2\n10 11 11\n1 11 1\n", "output": "0 1 5 5 6 7 2 9 10 11 1 \n"}, {"input": "11 7\n7 8 8\n5 6 5\n1 3 3\n7 9 9\n5 10 10\n10 11 11\n1 11 4\n", "output": "3 3 4 0 10 5 8 9 10 11 4 \n"}, {"input": "11 7\n7 8 8\n5 6 5\n1 3 3\n7 9 9\n5 10 10\n10 11 11\n1 11 3\n", "out...
code_stdio
[ { "content": "Toad Rash has a binary string $s$. A binary string consists only of zeros and ones.\n\nLet $n$ be the length of $s$.\n\nRash needs to find the number of such pairs of integers $l$, $r$ that $1 \\leq l \\leq r \\leq n$ and there is at least one pair of integers $x$, $k$ such that $1 \\leq x, k \\le...
[{"input": "1101111000011110111111110101100111111110111100001111011010111001101100010110000001010101101010111000\n", "output": "4672\n"}, {"input": "1101111000011110111111110101100111111110111100001111011010111001101100010110000001010101101010111000\n", "output": "4672\n"}, {"input": "1101111000011110111111110101100110...
code_stdio
[ { "content": "New Year is coming in Line World! In this world, there are n cells numbered by integers from 1 to n, as a 1 × n board. People live in cells. However, it was hard to move between distinct cells, because of the difficulty of escaping the cell. People wanted to meet people who live in other cells.\n\...
[{"input": "120 104\n41 15 95 85 34 11 25 42 65 39 77 80 74 17 66 73 21 14 36 63 63 79 45 24 65 7 63 80 51 21 2 19 78 28 71 2 15 23 17 68 62 18 54 39 43 70 3 46 34 23 41 65 32 10 13 18 10 3 16 48 54 18 57 28 3 24 44 50 15 2 20 22 45 44 3 29 2 27 11 2 12 25 25 31 1 2 32 4 11 30 13 16 26 21 1 13 21 8 15 5 18 13 5 15 3 8 ...
code_stdio
[ { "content": "Americans are odd people: in their buildings, the first floor is actually the ground floor and there is no 13th floor (due to superstition).\n\nWrite a function that given a floor in the american system returns the floor in the european system.\n\nWith the 1st floor being replaced by the ground fl...
[{"input": "200", "output": "[198]", "fn_name": "get_real_floor"}, {"input": "12", "output": "[11]", "fn_name": "get_real_floor"}, {"input": "14", "output": "[12]", "fn_name": "get_real_floor"}, {"input": "15", "output": "[13]", "fn_name": "get_real_floor"}, {"input": "37", "output": "[35]", "fn_name": "get_real_floor"...
code_functional
[ { "content": "Example\n\nInput\n\n5\n\n\nOutput\n\n5\n\nWrite Python code to solve this problem. Your program should read the input from stdin and write the output to stdout. Enclose your complete solution in a single ```python code block.", "role": "user" } ]
[{"input": "304", "output": "10816520\n"}, {"input": "309", "output": "17426472\n"}, {"input": "352", "output": "45765225\n"}, {"input": "227", "output": "1542687\n"}, {"input": "280", "output": "6677055\n"}, {"input": "161", "output": "142120\n"}, {"input": "187", "output": "372075\n"}, {"input": "157", "output": "121...
code_stdio
[ { "content": "Tavas is a strange creature. Usually \"zzz\" comes out of people's mouth while sleeping, but string s of length n comes out from Tavas' mouth instead. [Image] \n\nToday Tavas fell asleep in Malekas' place. While he was sleeping, Malekas did a little process on s. Malekas has a favorite string p. H...
[{"input": "173700 6\nbcabcbcbcbaaacaccaacaccaabacabaacbcacbbccaccbcacbabcaccccccaacacabbbbbacabbaaacbcbbaccaccabbbbaabbacacbabccaabcabbbcacaaccbabbcaaaaaabccbbcabcacbcbcabcbcbbaabacaaccccabacaaaccacaaabbacacabbcccacbaabcacacbbaaaccaccbaccccccbccaabcacaacabaccababacabcccbcbbacbabacbcbabacbbaccaabcabcbbbaaabbacbbbcacccb...
code_stdio
[ { "content": "You are given an integer sequence of length N, a = {a_1, a_2, …, a_N}, and an integer K.\n\na has N(N+1)/2 non-empty contiguous subsequences, {a_l, a_{l+1}, …, a_r} (1 ≤ l ≤ r ≤ N). Among them, how many have an arithmetic mean that is greater than or equal to K?\n\nConstraints\n\n* All input value...
[{"input": "7 26\n10\n20\n30\n43\n30\n20\n10", "output": "13\n"}, {"input": "1 26\n10\n20\n30\n43\n30\n20\n10", "output": "0\n"}, {"input": "1 26\n10\n20\n30\n12\n30\n20\n12", "output": "0\n"}, {"input": "1 26\n10\n20\n27\n12\n30\n20\n12", "output": "0\n"}, {"input": "1 26\n10\n20\n30\n12\n30\n20\n20", "output": "0\n"}...
code_stdio
[ { "content": "Polycarp loves ciphers. He has invented his own cipher called Right-Left.\n\nRight-Left cipher is used for strings. To encrypt the string $s=s_{1}s_{2} \\dots s_{n}$ Polycarp uses the following algorithm: he writes down $s_1$, he appends the current word with $s_2$ (i.e. writes down $s_2$ to the...
[{"input": "qwertyuioasdfghjklrtyuiodfghjklqwertyuioasdfssddxb\n", "output": "dfogihujyktlrqlwkejrhtgyfudisoaaosidufystsrdedwxqb\n"}, {"input": "qwertyuioasdfghjklrtyuiodfghjklqwertyuioasdfssddxb\n", "output": "dfogihujyktlrqlwkejrhtgyfudisoaaosidufystsrdedwxqb\n"}, {"input": "qwertyuioasdfghjklrtyuipdfghjklqwertyuioas...
code_stdio
[ { "content": "There exist two zeroes: +0 (or just 0) and -0.\n\nWrite a function that returns `true` if the input number is -0 and `false` otherwise (`True` and `False` for Python).\n\nIn JavaScript / TypeScript / Coffeescript the input will be a number.\n\nIn Python / Java / C / NASM / Haskell / the input will...
[{"input": "-Infinity", "output": "[false]", "fn_name": "is_negative_zero"}, {"input": "Infinity", "output": "[false]", "fn_name": "is_negative_zero"}, {"input": "-5.0", "output": "[false]", "fn_name": "is_negative_zero"}, {"input": "-4.0", "output": "[false]", "fn_name": "is_negative_zero"}, {"input": "-3.0", "output"...
code_functional
[ { "content": "Given is a sequence of N digits a_1a_2\\ldots a_N, where each element is 1, 2, or 3. Let x_{i,j} defined as follows:\n\n* x_{1,j} := a_j \\quad (1 \\leq j \\leq N)\n* x_{i,j} := | x_{i-1,j} - x_{i-1,j+1} | \\quad (2 \\leq i \\leq N and 1 \\leq j \\leq N+1-i)\n\n\n\nFind x_{N,1}.\n\nConstraints\n\n...
[{"input": "10\n1806305381", "output": "0\n"}, {"input": "10\n2192114600", "output": "1\n"}, {"input": "10\n3104206232", "output": "1\n"}, {"input": "10\n2763272837", "output": "1\n"}, {"input": "10\n1238013900", "output": "1\n"}, {"input": "10\n1665759416", "output": "0\n"}, {"input": "10\n2224468077", "output": "0\n"...
code_stdio
[ { "content": "In this Kata you need to write the method SharedBits that returns true if 2 integers share at least two '1' bits. For simplicity assume that all numbers are positive\n\nFor example\nint seven = 7; //0111\nint ten = 10; //1010\nint fifteen = 15; //1111\nSharedBits(seven, ten); //false\nS...
[{"input": "16\n8", "output": "[false]", "fn_name": "shared_bits"}, {"input": "7\n10", "output": "[false]", "fn_name": "shared_bits"}, {"input": "43\n77", "output": "[true]", "fn_name": "shared_bits"}, {"input": "1\n2", "output": "[false]", "fn_name": "shared_bits"}, {"input": "1\n1", "output": "[false]", "fn_name": "s...
code_functional
[ { "content": "Given is an integer N. Snuke will choose integers s_1, s_2, n_1, n_2, u_1, u_2, k_1, k_2, e_1, and e_2 so that all of the following six conditions will be satisfied:\n\n* 0 \\leq s_1 < s_2\n* 0 \\leq n_1 < n_2\n* 0 \\leq u_1 < u_2\n* 0 \\leq k_1 < k_2\n* 0 \\leq e_1 < e_2\n* s_1 + s_2 + n_1 + n_2 ...
[{"input": "4\n33\n1\n28\n0111010001", "output": "996765147\n0\n399637805\n501963061\n"}, {"input": "4\n33\n1\n28\n0111110001", "output": "996765147\n0\n399637805\n744953502\n"}, {"input": "4\n24\n2\n30\n0110110001", "output": "192839398\n0\n434820093\n589150439\n"}, {"input": "4\n2\n18\n124\n0010000000", "output": "0\...
code_stdio
[ { "content": "Polycarp has built his own web service. Being a modern web service it includes login feature. And that always implies password security problems.\n\nPolycarp decided to store the hash of the password, generated by the following algorithm: take the password $p$, consisting of lowercase Latin lette...
[{"input": "5\nabacaba\nzyxaabcaabkjh\nonetwothree\nthreetwoone\none\nzzonneyy\none\nnone\ntwenty\nten\n", "output": "YES\nYES\nNO\nYES\nNO\n"}, {"input": "5\nabacaba\nzyxaabcaabkjh\nonetwothree\nthreetwoone\none\nzzonneyy\neno\nnone\ntwenty\nten\n", "output": "YES\nYES\nNO\nYES\nNO\n"}, {"input": "5\nabacaba\nzyxaabca...
code_stdio
[ { "content": "Roma is playing a new expansion for his favorite game World of Darkraft. He made a new character and is going for his first grind.\n\nRoma has a choice to buy exactly one of n different weapons and exactly one of m different armor sets. Weapon i has attack modifier a_i and is worth ca_i coins, and...
[{"input": "10 10 10\n51 87\n68 600\n82 1284\n33 936\n55 242\n89 1990\n58 357\n66 666\n62 512\n51 87\n92 1670\n56 280\n56 280\n91 1631\n77 1091\n89 1554\n61 473\n98 1901\n77 1091\n77 1091\n86 15 759\n43 58 386\n68 33 386\n39 62 386\n95 6 386\n74 27 386\n94 7 386\n17 36 386\n105 4 386\n45 56 386\n", "output": "598\n"}, ...
code_stdio
[ { "content": "Your task is to perform a simple table calculation.\n\nWrite a program which reads the number of rows r, columns c and a table of r × c elements, and prints a new table, which includes the total sum for each row and column.\n\nConstraints\n\n* 1 ≤ r, c ≤ 100\n* 0 ≤ an element of the table ≤ 100\n\...
[{"input": "4 5\n2 1 3 12 13\n0 2 2 12 5\n3 6 1 1 1\n2 6 3 1 21", "output": "2 1 3 12 13 31\n0 2 2 12 5 21\n3 6 1 1 1 12\n2 6 3 1 21 33\n7 15 9 26 40 97\n"}, {"input": "4 5\n2 1 3 12 13\n0 2 2 12 5\n3 3 1 1 1\n2 6 3 1 21", "output": "2 1 3 12 13 31\n0 2 2 12 5 21\n3 3 1 1 1 9\n2 6 3 1 21 33\n7 12 9 26 40 94\n"}, {"inpu...
code_stdio
[ { "content": "Tanya wants to go on a journey across the cities of Berland. There are $n$ cities situated along the main railroad line of Berland, and these cities are numbered from $1$ to $n$.\n\nTanya plans her journey as follows. First of all, she will choose some city $c_1$ to start her journey. She will vis...
[{"input": "10\n10 60 12 13 14 15 16 66 18 130\n", "output": "130\n"}, {"input": "10\n10 60 12 13 14 15 16 66 18 130\n", "output": "130\n"}, {"input": "10\n8 60 12 13 14 15 16 66 18 130\n", "output": "130\n"}, {"input": "9\n18 11 24 7 18 10 1 20 17\n", "output": "24\n"}, {"input": "9\n18 11 24 7 18 10 1 20 17\n", "outp...
code_stdio
[ { "content": "The faculty of application management and consulting services (FAMCS) of the Berland State University (BSU) has always been popular among Berland's enrollees. This year, N students attended the entrance exams, but no more than K will enter the university. In order to decide who are these students,...
[{"input": "1\n4 2 3 14\n7 5 7\n10 6 10\n7 10 9\n9 0", "output": "Impossible\n"}, {"input": "1\n4 2 3 14\n7 5 7\n10 6 10\n7 10 9\n9 1", "output": "Impossible\n"}, {"input": "1\n4 2 3 2\n14 7 7\n10 6 7\n7 14 11\n9 9", "output": "Impossible\n"}, {"input": "1\n4 2 3 2\n14 14 7\n10 6 7\n7 14 6\n9 9", "output": "Impossible\...
code_stdio
[ { "content": "Fox Ciel saw a large field while she was on a bus. The field was a n × m rectangle divided into 1 × 1 cells. Some cells were wasteland, and other each cell contained crop plants: either carrots or kiwis or grapes. \n\nAfter seeing the field carefully, Ciel found that the crop plants of each cell w...
[{"input": "31 31 31 4\n15 26\n29 15\n17 31\n29 21\n21 3\n9 27\n19 20\n8 19\n5 4\n1 16\n6 17\n5 24\n1 4\n27 30\n16 24\n14 29\n24 31\n6 20\n2 20\n12 26\n26 15\n23 8\n29 10\n11 8\n3 7\n2 26\n15 10\n15 24\n6 10\n31 22\n12 2\n10 3\n6 24\n23 12\n19 1\n", "output": "Grapes\nCarrots\nCarrots\nCarrots\n"}, {"input": "31 31 31 ...
code_stdio
[ { "content": "There are $n$ people in this world, conveniently numbered $1$ through $n$. They are using burles to buy goods and services. Occasionally, a person might not have enough currency to buy what he wants or needs, so he borrows money from someone else, with the idea that he will repay the loan later wi...
[{"input": "12 20\n1 3 1000000000\n3 2 1000000000\n1 4 1000000000\n4 2 1000000000\n1 5 1000000000\n5 2 1000000000\n1 6 1000000010\n6 2 1000000000\n1 7 1000000000\n7 2 1000000000\n1 8 1000000000\n8 4 1000000000\n1 9 1000000000\n9 2 1000000000\n1 10 1000000000\n10 2 1000000000\n1 11 1000000000\n11 2 1000000000\n1 12 1000...
code_stdio
[ { "content": "Tic-tac-toe is a game in which you win when you put ○ and × alternately in the 3 × 3 squares and line up ○ or × in one of the vertical, horizontal, and diagonal lines (Fig.). 1 to Fig. 3)\n\n<image> | <image> | <image>\n--- | --- | ---\nFigure 1: ○ wins | Figure 2: × wins | Figure 3: Draw\n\n\n\nI...
[{"input": "ooosxssxs\nxooswsosx\nooxxxooxo", "output": "o\nd\nd\n"}, {"input": "oopsxssxs\nxooswsosx\noxooxxxoo", "output": "d\nd\nd\n"}, {"input": "oopsxrsxs\nxsoswsoox\nooooxxxox", "output": "d\nd\no\n"}, {"input": "xprmnwrtt\ntoyqulosl\nxxxmilpm{", "output": "d\nd\nx\n"}, {"input": "ooosxssxs\nxoosxsosx\noxooxxxoo"...
code_stdio
[ { "content": "For a given polygon g and target points t, print \"2\" if g contains t, \"1\" if t is on a segment of g, \"0\" otherwise.\n\ng is represented by a sequence of points p1, p2,..., pn where line segments connecting pi and pi+1 (1 ≤ i ≤ n-1) are sides of the polygon. The line segment connecting pn and...
[{"input": "4\n3 0\n15 -1\n0 1\n-1 0\n3\n-1 -2\n1 0\n-1 -1", "output": "0\n1\n0\n"}, {"input": "4\n3 0\n8 -1\n0 1\n-1 2\n3\n-1 -2\n0 -1\n0 -1", "output": "0\n0\n0\n"}, {"input": "4\n-1 -1\n4 -2\n3 -1\n1 4\n2\n0 1\n1 0\n-2 1", "output": "2\n2\n"}, {"input": "4\n0 -1\n6 -2\n3 -1\n1 4\n2\n0 1\n1 0\n-1 0", "output": "0\n2\...
code_stdio
[ { "content": "A new agent called Killjoy invented a virus COVID-2069 that infects accounts on Codeforces. Each account has a rating, described by an integer (it can possibly be negative or very large).\n\nKilljoy's account is already infected and has a rating equal to $x$. Its rating is constant. There are $n$ ...
[{"input": "7\n2 7\n7 1313\n2 14\n8 1211\n2 9\n12 121\n2 121\n121 312\n2 121\n136 121\n2 7\n1313 7\n2 8\n1211 8\n", "output": "1\n2\n2\n1\n1\n1\n1\n"}, {"input": "7\n2 7\n7 1313\n2 8\n8 1211\n2 9\n12 121\n2 121\n121 312\n2 121\n312 121\n2 7\n1313 7\n2 8\n1211 8\n", "output": "1\n1\n2\n1\n1\n1\n1\n"}, {"input": "7\n2 7\...
code_stdio
[ { "content": "Bizon the Champion isn't just charming, he also is very smart.\n\nWhile some of us were learning the multiplication table, Bizon the Champion had fun in his own manner. Bizon the Champion painted an n × m multiplication table, where the element on the intersection of the i-th row and j-th column e...
[{"input": "500000 500000 250000000000\n", "output": "250000000000\n"}, {"input": "499997 499989 248758432143\n", "output": "225563648440\n"}, {"input": "499997 499989 248758432143\n", "output": "225563648440"}, {"input": "500000 500000 250000000000\n", "output": "250000000000"}, {"input": "183656 409931 42943608085\n"...
code_stdio
[ { "content": "You are given a string $s$, consisting of lowercase Latin letters. While there is at least one character in the string $s$ that is repeated at least twice, you perform the following operation:\n\nyou choose the index $i$ ($1 \\le i \\le |s|$) such that the character at position $i$ occurs at least...
[{"input": "1\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n", "output": "ba\n"}, {"input": "1\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...
code_stdio
[ { "content": "As behooves any intelligent schoolboy, Kevin Sun is studying psycowlogy, cowculus, and cryptcowgraphy at the Bovinia State University (BGU) under Farmer Ivan. During his Mathematics of Olympiads (MoO) class, Kevin was confronted with a weird functional equation and needs your help. For two fixed i...
[{"input": "990037 453792\n", "output": "654009570\n"}, {"input": "586189 189159\n", "output": "168174057\n"}, {"input": "512287 359783\n", "output": "542484357\n"}, {"input": "999983 239239\n", "output": "965993296\n"}, {"input": "498653 116674\n", "output": "625264514\n"}, {"input": "805711 702149\n", "output": "7598...
code_stdio
[ { "content": "From tomorrow, the long-awaited summer vacation will begin. So I decided to invite my friends to go out to the sea.\n\nHowever, many of my friends are shy. They would hate it if they knew that too many people would come with them.\n\nBesides, many of my friends want to stand out. They will probabl...
[{"input": "5\n8 100001\n14 100001\n12 100000\n11 100001\n3 100001", "output": "0\n"}, {"input": "5\n8 100001\n14 100001\n13 100000\n11 100001\n3 100001", "output": "0\n"}, {"input": "5\n8 000001\n14 100001\n13 100000\n11 100001\n3 100001", "output": "0\n"}, {"input": "5\n8 100001\n14 100001\n12 100000\n13 100001\n3 10...
code_stdio
[ { "content": "Given two matrices A and B. Both have N rows and M columns. In the matrix A, numbers from 1 to MN have been written in row major order. Row major order numbers cells from left to right, and top to bottom. That is,\n\n1 2 3 ... M\nA = M+1 ...
[{"input": "1\n1 102", "output": "102\n"}, {"input": "1\n1 167", "output": "167\n"}, {"input": "1\n-23 -5", "output": "-5\n"}, {"input": "1\n135 1", "output": "135\n"}, {"input": "1\n215 1", "output": "215\n"}, {"input": "1\n396 1", "output": "396\n"}, {"input": "1\n1 143", "output": "143\n"}, {"input": "1\n1 113", "ou...
code_stdio
[ { "content": "Bob is a duck. He wants to get to Alice's nest, so that those two can duck! [Image] Duck is the ultimate animal! (Image courtesy of See Bang) \n\nThe journey can be represented as a straight line, consisting of $n$ segments. Bob is located to the left of the first segment, while Alice's nest is on...
[{"input": "10\n324839129156 133475576222 1946579156099 185514358673 88712073883 243757012712 950854402304 21947060440 598567289966 674328002732\nGLLLLLLLLW\n", "output": "26365097587258\n"}, {"input": "10\n324839129156 133475576222 987711341463 185514358673 88712073883 243757012712 950854402304 21947060440 59856728996...
code_stdio
[ { "content": "Recently Polycarp started to develop a text editor that works only with correct bracket sequences (abbreviated as CBS). \n\nNote that a bracket sequence is correct if it is possible to get a correct mathematical expression by adding \"+\"-s and \"1\"-s to it. For example, sequences \"(())()\", \"(...
[{"input": "92 51 18\n(()(((()())(()())())())(()())()()()())((()()())(())(())(()((())()())())(())())((())()())()()\nLRLRLLLLRRRLLRRLDLRLRRLRDLDLDLDDRRLRRRLLRDRLDDRLRRD\n", "output": "(()()()()())((()()())(())(())(()((())()())())(())())((())()())()()\n"}, {"input": "86 11 62\n(((())())(((()())())()()())(()())(()()())()(...
code_stdio
[ { "content": "You are given a system of pipes. It consists of two rows, each row consists of $n$ pipes. The top left pipe has the coordinates $(1, 1)$ and the bottom right — $(2, n)$.\n\nThere are six types of pipes: two types of straight pipes and four types of curved pipes. Here are the examples of all six ty...
[{"input": "6\n7\n2323216\n1615124\n1\n3\n4\n2\n13\n24\n2\n12\n34\n3\n536\n345\n2\n46\n101\n", "output": "YES\nYES\nYES\nNO\nYES\nNO\n"}, {"input": "6\n7\n2323216\n1615124\n1\n5\n4\n2\n13\n24\n2\n12\n34\n3\n536\n345\n2\n46\n101\n", "output": "YES\nYES\nYES\nNO\nYES\nNO\n"}, {"input": "6\n7\n2323216\n1615124\n1\n3\n4\n2...
code_stdio
[ { "content": "Takahashi is at an all-you-can-eat restaurant.\nThe restaurant offers N kinds of dishes. It takes A_i minutes to eat the i-th dish, whose deliciousness is B_i.\nThe restaurant has the following rules:\n - You can only order one dish at a time. The dish ordered will be immediately served and ready ...
[{"input": "3000 3000\n2996 2995\n2990 2993\n2994 2994\n2994 2997\n3000 2990\n2991 3000\n3000 2998\n2994 2997\n2996 2993\n2991 3000\n2992 2991\n2991 2994\n2996 3000\n2996 2997\n3000 2998\n2995 2995\n2994 2997\n2996 2999\n2990 2992\n2997 2994\n2995 3000\n2993 2998\n2994 2998\n2990 2997\n2995 2998\n3000 2997\n3000 2995\n...
code_stdio
[ { "content": "A lot of people associate Logo programming language with turtle graphics. In this case the turtle moves along the straight line and accepts commands \"T\" (\"turn around\") and \"F\" (\"move 1 unit forward\").\n\nYou are given a list of commands that will be given to the turtle. You have to change...
[{"input": "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF\n50\n", "output": "100\n"}, {"input": "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF\n40\n", "output": "100\n"}, {"input": "FFFFFFFFFFFFFFFFFFFFFFFFFFFF...
code_stdio
[ { "content": "You are given an integer sequence A of length N.\nFind the maximum absolute difference of two elements (with different indices) in A.\n\n-----Constraints-----\n - 2 \\leq N \\leq 100\n - 1 \\leq A_i \\leq 10^9\n - All values in input are integers.\n\n-----Input-----\nInput is given from Standard I...
[{"input": "100\n3142445 16266949 17493698 35569790 80507149 98771888 109205766 111818374 116565925 119183522 141425056 157086378 180302992 187469083 216070266 233105051 257048184 265553444 273526101 281450237 289171706 301768399 311455945 319497119 326729809 338683702 339701654 346802542 353453224 373203259 386147801 ...
code_stdio
[ { "content": "# MOD 256 without the MOD operator\n\nThe MOD-operator % (aka mod/modulus/remainder):\n```\nReturns the remainder of a division operation.\nThe sign of the result is the same as the sign of the first operand.\n(Different behavior in Python!)\n```\n\nThe short unbelievable mad story for this kata:\...
[{"input": "-258", "output": "[254]", "fn_name": "mod256_without_mod"}, {"input": "254", "output": "[254]", "fn_name": "mod256_without_mod"}, {"input": "-254", "output": "[2]", "fn_name": "mod256_without_mod"}, {"input": "-256", "output": "[0]", "fn_name": "mod256_without_mod"}, {"input": "256", "output": "[0]", "fn_na...
code_functional
[ { "content": "On the Internet, data is divided into packets, and each packet is transferred to a destination via a relay device called a router. Each router determines the next router to forward from the destination described in the packet. In addition, a value called TTL (Time To Live) is added to the packet t...
[{"input": "7\n1 4 2 5 5 3\n2 1 5\n3 1 6\n4 1 7\n5 2 7 6\n6 1 2\n7 0\n6\n1 2 0\n1 5 0\n1 2 0\n5 1 3\n6 3 0\n1 7 4", "output": "NA\nNA\nNA\nNA\nNA\n3\n"}, {"input": "7\n1 4 2 5 4 3\n2 1 5\n3 1 6\n4 1 7\n5 2 7 6\n6 1 1\n7 0\n6\n1 2 1\n1 3 6\n1 2 0\n5 2 3\n6 3 0\n3 7 4", "output": "NA\n2\nNA\nNA\nNA\nNA\n"}, {"input": "7\...
code_stdio
[ { "content": "When registering in a social network, users are allowed to create their own convenient login to make it easier to share contacts, print it on business cards, etc.\n\nLogin is an arbitrary sequence of lower and uppercase latin letters, digits and underline symbols («_»). However, in order to decrea...
[{"input": "ELioO1lOoOIOiLoooi1iolul1O\n7\nOoEIuOIl1ui1010uiooOoi0Oio001L0EoEolO0\nOLIoOEuoE11u1u1iLOI0oO\nuEOuO0uIOOlO01OlEI0E1Oo0IO1LI0uE0LILO0\nEOo0Il11iIOOOIiuOiIiiLOLEOOII001EE\niOoO0LOulioE0OLIIIulli01OoiuOOOoOlEiI0EiiElIIu0\nlE1LOE1Oil\n1u0EOliIiIOl1u110il0l1O0u\n", "output": "Yes\n"}, {"input": "ELioO1lOoOIOiLo...
code_stdio
[ { "content": "Create a function that will return ```true``` if the input is in the following date time format ```01-09-2016 01:20``` and ```false``` if it is not.\n\nThis Kata has been inspired by the Regular Expressions chapter from the book Eloquent JavaScript.\n\nWrite Python code to solve this problem. Defi...
[{"input": "\"Tue Sep 06 2016 01:46:38 GMT+0100\"", "output": "[false]", "fn_name": "date_checker"}, {"input": "\"01-09-2016 01;20\"", "output": "[false]", "fn_name": "date_checker"}, {"input": "\"01_09_2016 01:20\"", "output": "[false]", "fn_name": "date_checker"}, {"input": "\"Tenth of January\"", "output": "[false]"...
code_functional
[ { "content": "------ Problem Statement ------ \n\nPast\n\nIn the year of 2048, the Virtual Reality Massively Multiplayer Online Role-Playing Game (VRMMORPG), Code Art Online (CAO), is released. With the Chef Gear, a virtual reality helmet that stimulates the user's five senses via their brain, players can exper...
[{"input": "2\n5 -1\n^^^^^\n^^]^^\n^^^^#\n^^^^^\n^]^^^\n5 7\n^^#^^^_\n^^###^^\n#^^^^^^\n^^#^^#^\n^^^^^^^", "output": "0\n0\n"}, {"input": "2\n5 -1\n^^^^_\n^^]^^\n^^^^#\n^^^^^\n^]^^^\n5 7\n^^#^^^_\n^^###^^\n#^^^^^^\n^^#^^#^\n^^^^^^^", "output": "0\n0\n"}, {"input": "2\n5 -1\n^^^^^\n^^]^^\n^^^^#\n^^^^^\n^]^^^\n5 7\n^^#^^...
code_stdio
[ { "content": "There is a line with 1000 cells numbered from 1 to 1000 from left to right and N coins placed on it. Coin i is placed at cell X_{i}, and no two coins are placed at the same cell.\n\nBob would like to move the coins to the N leftmost cells of the line. To do this, he is allowed to take a coin from ...
[{"input": "2\n12 2\n2 4 18\n22 3\n1 2 4 8 12", "output": "16\n7\n"}, {"input": "2\n10 2\n1 5 13\n8 6\n1 4 5 6 21", "output": "10\n16\n"}, {"input": "2\n10 2\n1 5 21\n8 6\n1 4 5 6 21", "output": "18\n16\n"}, {"input": "2\n10 2\n1 5 34\n8 6\n1 4 5 6 21", "output": "31\n16\n"}, {"input": "2\n12 2\n2 4 18\n22 3\n1 3 4 8 1...
code_stdio
[ { "content": "If you have completed the Tribonacci sequence kata, you would know by now that mister Fibonacci has at least a bigger brother. If not, give it a quick look to get how things work.\n\nWell, time to expand the family a little more: think of a Quadribonacci starting with a signature of 4 elements and...
[{"input": "[0.5, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n20", "output": "[[0.5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.5, 0.5, 1, 2, 4, 8, 16, 32, 64, 128]]", "fn_name": "Xbonacci"}, {"input": "[1, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n20", "output": "[[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 2, 4, 8, 16, 32, 64, 128, 256]]", "fn_name": "Xbonacci"}, {"i...
code_functional
[ { "content": "You are given an integer $n$. Pair the integers $1$ to $2n$ (i.e. each integer should be in exactly one pair) so that each sum of matched pairs is consecutive and distinct.\n\nFormally, let $(a_i, b_i)$ be the pairs that you matched. $\\{a_1, b_1, a_2, b_2, \\ldots, a_n, b_n\\}$ should be a permut...
[{"input": "4\n1\n2\n3\n4\n", "output": "YES\n1 2\nNO\nYES\n1 6\n2 4\n3 5\nNO\n"}, {"input": "1\n100000\n", "output": "NO\n"}, {"input": "1\n99988\n", "output": "NO\n"}, {"input": "1\n99990\n", "output": "NO\n"}, {"input": "1\n99992\n", "output": "NO\n"}, {"input": "1\n99994\n", "output": "NO\n"}, {"input": "1\n99996\n...
code_stdio
[ { "content": "Vasya is pressing the keys on the keyboard reluctantly, squeezing out his ideas on the classical epos depicted in Homer's Odysseus... How can he explain to his literature teacher that he isn't going to become a writer? In fact, he is going to become a programmer. So, he would take great pleasure i...
[{"input": "100\n1622 320 1261 282 1604 57 1427 1382 904 911 1719 1682 984 1727 1301 1799 1110 1057 248 764 1642 1325 1172 1677 182 32 665 397 1146 73 412 554 973 874 774 1948 1676 1959 518 280 1467 568 613 760 594 252 224 1359 876 253 760 1566 929 1614 940 1079 288 245 1432 1647 1534 1768 1947 733 225 495 1239 644 124...
code_stdio
[ { "content": "A number `n` is called `prime happy` if there is at least one prime less than `n` and the `sum of all primes less than n` is evenly divisible by `n`. Write `isPrimeHappy(n)` which returns `true` if `n` is `prime happy` else `false`.\n\nWrite Python code to solve this problem. Define a top-level fu...
[{"input": "8", "output": "[false]", "fn_name": "is_prime_happy"}, {"input": "25", "output": "[true]", "fn_name": "is_prime_happy"}, {"input": "32", "output": "[true]", "fn_name": "is_prime_happy"}, {"input": "2", "output": "[false]", "fn_name": "is_prime_happy"}, {"input": "0", "output": "[false]", "fn_name": "is_prim...
code_functional
[ { "content": "I have n tickets for a train with a rabbit. Each ticket is numbered from 0 to n − 1, and you can use the k ticket to go to p⋅ak + q⋅bk station.\n\nRabbit wants to go to the all-you-can-eat carrot shop at the station m station ahead of the current station, but wants to walk as short as possible. Th...
[{"input": "6 279 2 5 26 14", "output": "117\n"}, {"input": "17 256 2 3 10 9", "output": "67\n"}, {"input": "6 323 2 12 8 9", "output": "182\n"}, {"input": "6 279 2 5 46 14", "output": "57\n"}, {"input": "22 144 2 3 3 5", "output": "15\n"}, {"input": "17 144 2 3 6 5", "output": "37\n"}, {"input": "6 200 2 3 26 8", "out...
code_stdio
[ { "content": "Noora is a student of one famous high school. It's her final year in school — she is going to study in university next year. However, she has to get an «A» graduation certificate in order to apply to a prestigious one.\n\nIn school, where Noora is studying, teachers are putting down marks to the o...
[{"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 100 100 100 100 100 100...
code_stdio
[ { "content": "There are N Reversi pieces arranged in a row. (A Reversi piece is a disc with a black side and a white side.) The state of each piece is represented by a string S of length N. If S_i=`B`, the i-th piece from the left is showing black; If S_i=`W`, the i-th piece from the left is showing white.\n\nC...
[{"input": "WBWBWB", "output": "3\n"}, {"input": "WBWBVB", "output": "1\n"}, {"input": "WBWBUB", "output": "1\n"}, {"input": "WBWBUC", "output": "1\n"}, {"input": "WBWBTC", "output": "1\n"}, {"input": "WBWBVC", "output": "1\n"}, {"input": "WBVBVC", "output": "0\n"}, {"input": "BWBWBW", "output": "6"}, {"input": "BBX", ...
code_stdio
[ { "content": "There is a connected undirected graph with N vertices and M edges. The vertices are numbered 1 to N, and the edges are numbered 1 to M. Also, each of these vertices and edges has a specified weight. Vertex i has a weight of X_i; Edge i has a weight of Y_i and connects Vertex A_i and B_i.\n\nWe wou...
[{"input": "10 9\n81 20 73 7 2 61 86 38 90 28\n6 8 725\n3 10 12\n1 4 558\n4 9 615\n5 6 942\n8 9 918\n2 7 720\n4 7 292\n7 10 414", "output": "8\n"}, {"input": "10 9\n81 20 73 7 2 61 86 44 90 28\n6 8 725\n3 10 12\n1 4 558\n4 9 615\n5 6 942\n8 9 918\n2 7 720\n4 7 292\n7 10 414", "output": "8\n"}, {"input": "10 9\n81 20 73...
code_stdio
[ { "content": "It's Friday night, and Chuck is bored. He's already run 1,000 miles, stopping only to eat a family sized bag of Heatwave Doritos and a large fistful of M&Ms. He just can't stop thinking about kicking something! \n\nThere is only one thing for it, Chuck heads down to his local MMA gym and immediate...
[{"input": "[\"*****************************************\", \"*********** _O_ * _O_ ***********\", \"** _O_ * C(.)J * /(.)J * _O_ **\", \"** /(.)J * _| |_ * _/ )_ * C(.)J **\", \"** _/ )_ ********************* _/ |_ **\", \"******************* X *******************\", \"********************** ...
code_functional
[ { "content": "There is a tree with N vertices, numbered 1 through N. The i-th of the N-1 edges connects vertices a_i and b_i.\n\nCurrently, there are A_i stones placed on vertex i. Determine whether it is possible to remove all the stones from the vertices by repeatedly performing the following operation:\n\n* ...
[{"input": "6\n3 2 2 2 2 2\n1 2\n2 3\n1 6\n1 5\n4 6", "output": "YES\n"}, {"input": "6\n5 2 2 2 2 2\n1 2\n2 3\n1 6\n1 5\n4 6", "output": "NO\n"}, {"input": "6\n5 2 4 2 2 2\n1 2\n2 3\n1 6\n1 5\n4 6", "output": "NO\n"}, {"input": "6\n5 2 4 2 2 2\n1 2\n2 3\n1 6\n1 5\n6 6", "output": "NO\n"}, {"input": "6\n5 2 4 2 2 2\n1 0...
code_stdio
[ { "content": "In Berland a money reform is being prepared. New coins are being introduced. After long economic calculations was decided that the most expensive coin should possess the denomination of exactly n Berland dollars. Also the following restriction has been introduced for comfort: the denomination of e...
[{"input": "1000000\n", "output": "1000000 500000 250000 125000 62500 31250 15625 3125 625 125 25 5 1\n"}, {"input": "685248\n", "output": "685248 342624 171312 85656 42828 21414 10707 3569 83 1 "}, {"input": "100000\n", "output": "100000 50000 25000 12500 6250 3125 625 125 25 5 1\n"}, {"input": "537000\n", "output": "...
code_stdio
[ { "content": "We have N strings of lowercase English letters: S_1, S_2, \\cdots, S_N.\nTakahashi wants to make a string that is a palindrome by choosing one or more of these strings - the same string can be chosen more than once - and concatenating them in some order of his choice.\nThe cost of using the string...
[{"input": "50\nxkxkbxdadmrlymnhzpdb 964776970\nfxocahjfrcucddkozsuy 964776970\nxdqaekpuagisbklbybec 964776970\nvyowutrbwyqqqyvlchvr 964776970\nwjtibdpzhnmylrmdadxb 964776970\nyfvmjwesjqnahyzn 964776970\nuvbgtgszdkzicesngmpn 964776970\nmltwiydbpshxhgtgewfu 964776970\nsqhxdcadyvkjsyfwnphs 964776970\nxwbkeyhvgqcfznwybsct...
code_stdio
[ { "content": "We need you to implement a method of receiving commands over a network, processing the information and responding.\n\nOur device will send a single packet to you containing data and an instruction which you must perform before returning your reply.\n\nTo keep things simple, we will be passing a si...
[{"input": "\"H1H10F1200120008F4F4\"", "output": "[\"H1H1FFFF00200000F4F4\"]", "fn_name": "communication_module"}, {"input": "\"D7D70F1200250015G8G8\"", "output": "[\"D7D7FFFF00400000G8G8\"]", "fn_name": "communication_module"}, {"input": "\"X7X7B7A201400058L0L0\"", "output": "[\"X7X7FFFF00820000L0L0\"]", "fn_name": "c...
code_functional
[ { "content": "Alice and Bob are playing a game on a matrix, consisting of $2$ rows and $m$ columns. The cell in the $i$-th row in the $j$-th column contains $a_{i, j}$ coins in it.\n\nInitially, both Alice and Bob are standing in a cell $(1, 1)$. They are going to perform a sequence of moves to reach a cell $(2...
[{"input": "3\n3\n2 3 12\n2 10 0\n3\n-1 4 17\n3 9 0\n1\n4\n3\n", "output": "12\n12\n0\n"}, {"input": "3\n3\n2 3 12\n2 10 1\n3\n-1 4 17\n2 9 0\n1\n4\n3\n", "output": "12\n11\n0\n"}, {"input": "3\n3\n2 3 12\n2 10 2\n3\n-1 4 17\n3 5 0\n1\n4\n3\n", "output": "12\n8\n0\n"}, {"input": "3\n3\n2 3 12\n2 10 0\n3\n-1 4 17\n3 5 0...
code_stdio
[ { "content": "Read problems statements in Mandarin Chinese, Russian and Vietnamese as well. \nNim is a well-known combinatorial game, based on removing stones from piles. In this problem, we'll deal with a similar game, which we'll call Dual Nim. The rules of this game are as follows:\n\nInitially, there are N ...
[{"input": "3\n4\n1 2 4 12\n3\n2 3 3\n5\n1 3 3 3 3", "output": "First\nSecond\nSecond\n"}, {"input": "3\n4\n1 2 4 12\n3\n1 3 3\n5\n1 3 3 3 3", "output": "First\nSecond\nSecond\n"}, {"input": "3\n4\n1 2 8 13\n3\n3 1 3\n5\n1 3 1 3 3", "output": "First\nSecond\nSecond\n"}, {"input": "3\n4\n1 2 4 16\n3\n3 3 3\n5\n1 3 3 3 3...
code_stdio
[ { "content": "Bob has a server farm crunching numbers. He has `nodes` servers in his farm. His company has a lot of work to do. \n\nThe work comes as a number `workload` which indicates how many jobs there are. Bob wants his servers to get an equal number of jobs each. If that is impossible, he wants the first ...
[{"input": "4\n10", "output": "[[[0, 1, 2], [3, 4, 5], [6, 7], [8, 9]]]", "fn_name": "distribute"}, {"input": "3\n9", "output": "[[[0, 1, 2], [3, 4, 5], [6, 7, 8]]]", "fn_name": "distribute"}, {"input": "5\n4", "output": "[[[0], [1], [2], [3], []]]", "fn_name": "distribute"}, {"input": "4\n5", "output": "[[[0, 1], [2],...
code_functional
[ { "content": "You are given a matrix consisting of digits zero and one, its size is n × m. You are allowed to rearrange its rows. What is the maximum area of the submatrix that only consists of ones and can be obtained in the given problem by the described operations?\n\nLet's assume that the rows of matrix a a...
[{"input": "15 18\n111111111111111111\n111111111111111111\n111111111111111111\n111111111111111111\n111111111111111111\n111111111111111111\n111111111111111111\n111111111111111111\n111111111111111111\n111111111111111111\n111111111111111111\n111111111111111111\n111111111111111111\n111111111111111111\n111111111111111111\n"...
code_stdio
[ { "content": "You are given several queries. In the i-th query you are given a single positive integer n_{i}. You are to represent n_{i} as a sum of maximum possible number of composite summands and print this maximum number, or print -1, if there are no such splittings.\n\nAn integer greater than 1 is composit...
[{"input": "100\n611\n513\n544\n463\n38\n778\n347\n317\n848\n1308\n382\n108\n718\n33\n544\n876\n234\n22\n944\n305\n159\n245\n513\n691\n639\n135\n435\n324\n813\n459\n304\n116\n331\n993\n184\n224\n853\n769\n121\n687\n93\n930\n751\n308\n485\n914\n400\n695\n95\n981\n175\n972\n121\n1007\n242\n610\n617\n999\n237\n548\n742\n7...
code_stdio
[ { "content": "Cosmic market, commonly known as Kozumike, is the largest coterie spot sale in the universe. Doujin lovers of all genres gather at Kozumike. In recent years, the number of visitors to Kozumike has been increasing. If everyone can enter from the beginning, it will be very crowded and dangerous, so ...
[{"input": "5 5 4\n0 0 1\n0 0 0\n0 2 0\n1 1 1\n1 0 0\n5 5 5\n1 4 0\n0 1 1\n0 4 1\n1 3 0\n0 3 1\n5 5 5\n1 0 0\n0 3 1\n1 2 1\n0 4 0\n1 1 1\n0 0 0", "output": "5\n0\n13\n12\n"}, {"input": "5 14 5\n2 0 2\n0 0 0\n0 0 1\n1 2 1\n1 0 0\n5 5 5\n1 4 1\n0 1 1\n1 1 1\n1 3 0\n1 3 0\n5 10 5\n1 0 0\n0 3 0\n1 2 1\n0 4 0\n0 1 0\n0 0 0"...
code_stdio
[ { "content": "Implement `String#digit?` (in Java `StringUtils.isDigit(String)`), which should return `true` if given object is a digit (0-9), `false` otherwise.\n\nWrite Python code to solve this problem. Define a top-level function named `is_digit` that takes the input arguments described above and returns the...
[{"input": "\"1\\n0\"", "output": "[false]", "fn_name": "is_digit"}, {"input": "\"1\\n\"", "output": "[false]", "fn_name": "is_digit"}, {"input": "\"a5\"", "output": "[false]", "fn_name": "is_digit"}, {"input": "\"14\"", "output": "[false]", "fn_name": "is_digit"}, {"input": "\"\\\"\"", "output": "[false]", "fn_name": ...
code_functional
[ { "content": "You are given two arrays of integers $a_1, a_2, \\ldots, a_n$ and $b_1, b_2, \\ldots, b_n$.\n\nLet's define a transformation of the array $a$:\n\nChoose any non-negative integer $k$ such that $0 \\le k \\le n$.\n\nChoose $k$ distinct array indices $1 \\le i_1 < i_2 < \\ldots < i_k \\le n$.\n\nAdd ...
[{"input": "2\n10\n3 3 2 2 3 2 1 1 2 3\n3 3 2 1 2 3 2 3 1 1\n10\n1 1 3 1 2 2 1 3 3 3\n3 1 3 1 1 2 3 2 2 1\n", "output": "NO\nNO\n"}, {"input": "1\n10\n14 -91 -52 -82 -4 69 33 3 -46 81\n-45 15 -4 82 33 3 -90 -81 -51 69\n", "output": "YES\n"}, {"input": "4\n2\n1 1\n0 0\n3\n1 2 3\n1 3 5\n4\n1 3 5 7\n0 2 4 8\n3\n0 0 0\n-1 ...
code_stdio
[ { "content": "In this kata, you need to make a (simplified) LZ78 encoder and decoder.\n[LZ78](https://en.wikipedia.org/wiki/LZ77_and_LZ78#LZ78) is a dictionary-based compression method created in 1978. You will find a detailed explanation about how it works below.\n\nThe input parameter will always be a non-em...
[{"input": "\"ABCDDEFGABCDEDBBDEAAEDAEDCDABC\"", "output": "[\"0A0B0C0D4E0F0G1B3D0E4B2D10A1E4A10D9A2C\"]", "fn_name": "encoder"}, {"input": "\"ABBCBCABABCAABCAABBCAA\"", "output": "[\"0A0B2C3A2A4A6B6\"]", "fn_name": "encoder"}, {"input": "\"ABCABCABCABCABCABC\"", "output": "[\"0A0B0C1B3A2C4C7A6\"]", "fn_name": "encoder...
code_functional
[ { "content": "Ujan has a lot of useless stuff in his drawers, a considerable part of which are his math notebooks: it is time to sort them out. This time he found an old dusty graph theory notebook with a description of a graph.\n\nIt is an undirected weighted graph on $n$ vertices. It is a complete graph: each...
[{"input": "15 10\n2 3\n5 4\n5 6\n5 7\n3 8\n3 10\n11 12\n12 13\n13 14\n14 15\n", "output": "0\n"}, {"input": "15 10\n2 3\n5 4\n5 6\n5 7\n3 8\n3 10\n11 12\n12 13\n13 14\n14 15\n", "output": "0\n"}, {"input": "15 10\n2 3\n5 4\n5 4\n5 7\n3 8\n3 10\n11 12\n12 13\n13 14\n14 15\n", "output": "0\n"}, {"input": "15 10\n2 3\n5 ...
code_stdio
[ { "content": "Let T be arbitrary binary tree — tree, every vertex of which has no more than two children. Given tree is rooted, so there exists only one vertex which doesn't have a parent — it's the root of a tree. Every vertex has an integer number written on it. Following algorithm is run on every value from ...
[{"input": "10\n911605217 -1 -1\n801852416 -1 -1\n140035920 -1 9\n981454947 10 2\n404988051 6 3\n307545107 8 7\n278188888 4 1\n523010786 -1 -1\n441817740 -1 -1\n789680429 -1 -1\n", "output": "7\n"}, {"input": "10\n911605217 -1 -1\n801852416 -1 -1\n140035920 -1 9\n981454947 10 2\n404988051 6 3\n307545107 8 7\n278188888 ...
code_stdio
[ { "content": "Gennady is one of the best child dentists in Berland. Today n children got an appointment with him, they lined up in front of his office.\n\nAll children love to cry loudly at the reception at the dentist. We enumerate the children with integers from 1 to n in the order they go in the line. Every ...
[{"input": "10\n9 8 8\n2 9 33\n10 7 42\n7 2 18\n3 5 82\n9 9 25\n3 2 86\n3 5 49\n5 3 72\n4 4 71\n", "output": "10\n1 2 3 4 5 6 7 8 9 10 "}, {"input": "10\n9 8 8\n2 9 33\n10 7 42\n7 2 18\n3 5 82\n9 9 25\n3 2 86\n3 5 49\n5 3 72\n4 4 71\n", "output": "10\n1 2 3 4 5 6 7 8 9 10 "}, {"input": "10\n9 8 8\n2 9 33\n10 7 42\n7 2 ...
code_stdio
[ { "content": "Imp likes his plush toy a lot.\n\n [Image] \n\nRecently, he found a machine that can clone plush toys. Imp knows that if he applies the machine to an original toy, he additionally gets one more original toy and one copy, and if he applies the machine to a copied toy, he gets two additional copies....
[{"input": "1000000000 999999999\n", "output": "Yes\n"}, {"input": "1000000000 1000000000\n", "output": "No\n"}, {"input": "1000000000 999999999\n", "output": "Yes\n"}, {"input": "1000000000 1000000000\n", "output": "No\n"}, {"input": "1079372212 582938127\n", "output": "Yes\n"}, {"input": "1000001000 1000000000\n", "o...
code_stdio
[ { "content": "Write a function that removes every lone 9 that is inbetween 7s.\n\n```python\nseven_ate9('79712312') => '7712312'\nseven_ate9('79797') => '777'\n```\n\nInput: String\nOutput: String\n\nWrite Python code to solve this problem. Define a top-level function named `seven_ate9` that takes the input arg...
[{"input": "\"165561786121789797\"", "output": "[\"16556178612178977\"]", "fn_name": "seven_ate9"}, {"input": "\"797 9 7\"", "output": "[\"77 9 7\"]", "fn_name": "seven_ate9"}, {"input": "\"7979797\"", "output": "[\"7777\"]", "fn_name": "seven_ate9"}, {"input": "\"17797a\"", "output": "[\"1777a\"]", "fn_name": "seven_a...
code_functional
[ { "content": "ZS the Coder is coding on a crazy computer. If you don't type in a word for a c consecutive seconds, everything you typed disappear! \n\nMore formally, if you typed a word at second a and then the next word at second b, then if b - a ≤ c, just the new word is appended to other words on the screen....
[{"input": "2 1000000000\n1 1000000000\n", "output": "2\n"}, {"input": "2 1000000000\n1 1000000000\n", "output": "2"}, {"input": "6 5\n1 5 8 14 19 20\n", "output": "3\n"}, {"input": "5 10\n-1 1 22 32 34\n", "output": "3\n"}, {"input": "5 12\n-1 1 22 32 34\n", "output": "3\n"}, {"input": "6 5\n1 3 8 14 19 20\n", "output...
code_stdio
[ { "content": "There is a long-established secondhand bookstore called JOI secondhand bookstore in your town, and you often use the JOI secondhand bookstore. Each book has a standard price, and you can buy it at that price if you go to the JOI secondhand bookstore.\n\nAt the JOI secondhand bookstore, books are c...
[{"input": "7 7\n4 1\n13 2\n18 3\n64 3\n13 2\n16 10\n11 2", "output": "147\n"}, {"input": "7 7\n4 1\n13 2\n12 3\n48 3\n8 2\n16 10\n11 2", "output": "120\n"}, {"input": "7 5\n4 1\n13 3\n12 3\n48 3\n8 3\n16 10\n11 2", "output": "109\n"}, {"input": "7 7\n4 1\n13 2\n18 3\n48 3\n8 2\n16 10\n11 2", "output": "126\n"}, {"inpu...
code_stdio
[ { "content": "After a hard-working week Polycarp prefers to have fun. Polycarp's favorite entertainment is drawing snakes. He takes a rectangular checkered sheet of paper of size $n \\times m$ (where $n$ is the number of rows, $m$ is the number of columns) and starts to draw snakes in cells.\n\nPolycarp draws s...
[{"input": "2\n1 1\nb\n1 1\nz\n", "output": "YES\n2\n1 1 1 1\n1 1 1 1\nYES\n26\n1 1 1 1\n1 1 1 1\n1 1 1 1\n1 1 1 1\n1 1 1 1\n1 1 1 1\n1 1 1 1\n1 1 1 1\n1 1 1 1\n1 1 1 1\n1 1 1 1\n1 1 1 1\n1 1 1 1\n1 1 1 1\n1 1 1 1\n1 1 1 1\n1 1 1 1\n1 1 1 1\n1 1 1 1\n1 1 1 1\n1 1 1 1\n1 1 1 1\n1 1 1 1\n1 1 1 1\n1 1 1 1\n1 1 1 1\n"}, {"...
code_stdio
[ { "content": "A 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 battle, every second the monster's HP decrease by max(0, ATKY - DEFM), while Yan...
[{"input": "100 100 100\n100 100 100\n100 100 100\n", "output": "100"}, {"input": "50 100 51\n100 100 100\n1 100 100\n", "output": "1384"}, {"input": "100 100 1\n100 100 100\n1 100 100\n", "output": "1891"}, {"input": "1 1 1\n100 100 100\n100 100 101\n", "output": "19999\n"}, {"input": "50 100 80\n100 100 100\n1 100 10...
code_stdio
[ { "content": "# History\n\nThis kata is a sequel of my [Mixbonacci](https://www.codewars.com/kata/mixbonacci/python) kata. Zozonacci is a special integer sequence named after [**ZozoFouchtra**](https://www.codewars.com/users/ZozoFouchtra), who came up with this kata idea in the [Mixbonacci discussion](https://w...
[{"input": "[\"fib\", \"pel\", \"tri\"]\n10", "output": "[[0, 0, 0, 1, 1, 3, 5, 8, 21, 34]]", "fn_name": "zozonacci"}, {"input": "[\"tet\", \"jac\"]\n10", "output": "[[0, 0, 0, 1, 1, 3, 5, 11, 20, 42]]", "fn_name": "zozonacci"}, {"input": "[\"tri\", \"fib\"]\n10", "output": "[[0, 0, 0, 1, 1, 2, 4, 6, 12, 18]]", "fn_nam...
code_functional
[ { "content": "Vladik is a competitive programmer. This year he is going to win the International Olympiad in Informatics. But it is not as easy as it sounds: the question Vladik face now is to find the cheapest way to get to the olympiad.\n\nVladik knows n airports. All the airports are located on a straight li...
[{"input": "16 4 12\n0000000011111111\n", "output": "1\n"}, {"input": "16 1 12\n0000000011111111\n", "output": "1\n"}, {"input": "16 1 12\n0100000011111111\n", "output": "1\n"}, {"input": "16 2 12\n0100000011111111\n", "output": "0\n"}, {"input": "16 3 12\n0100000011111111\n", "output": "1\n"}, {"input": "16 2 12\n0100...
code_stdio
[ { "content": "An old document says that a Ninja House in Kanazawa City was in fact a defensive fortress, which was designed like a maze. Its rooms were connected by hidden doors in a complicated manner, so that any invader would become lost. Each room has at least two doors.\n\nThe Ninja House can be modeled by...
[{"input": "2\n3 3 3 3 -3 3 2 -5 3 2 -5 -3 0\n3 5 3 -2 4 -3 -2 -2 -1 0", "output": "1 2 4 6\n2 1 3 8\n3 2 4 7\n4 1 3 5\n5 4 6 7\n6 1 5\n7 3 5 8\n8 2 7\n1 2 2 3 4\n2 1 1 3 4 4\n3 1 2 4\n4 1 2 2 3\n"}, {"input": "2\n3 3 3 3 -3 3 2 -5 3 2 -5 -3 0\n3 5 4 -2 4 -1 -2 -2 -1 0", "output": "1 2 4 6\n2 1 3 8\n3 2 4 7\n4 1 3 5\n5...
code_stdio
[ { "content": "Watto, the owner of a spare parts store, has recently got an order for the mechanism that can process strings in a certain way. Initially the memory of the mechanism is filled with n strings. Then the mechanism should be able to process queries of the following type: \"Given string s, determine if...
[{"input": "1 17\ncacdbcacabccba\naccbcbcabaabbcbcaa\nbabccaaacccacbb\nbbbabbabbbcaacbaaac\nabbaccacabacaaaa\nbccbccabaacaacb\nbbbabbbbabcaacbcaac\nbcacababbbdaaca\nccbbbbababbccaab\nbbcbcc`babcaacb\naacccbabbacbabacaca\nbcaacbabcccbcbb\nacbacacbcacc\ncaaabcaaabacabbabbb\nabcbabaaaba\naacccbcaabacbcbcba\nabbaccacabbcaa...
code_stdio
[ { "content": "Anton and Dasha like to play different games during breaks on checkered paper. By the 11th grade they managed to play all the games of this type and asked Vova the programmer to come up with a new game. Vova suggested to them to play a game under the code name \"dot\" with the following rules: \n\...
[{"input": "12 -11 20 200\n11 189\n12 108\n19 190\n21 27\n24 193\n26 86\n26 123\n31 180\n39 196\n107 193\n122 46\n129 103\n131 129\n132 135\n142 51\n157 22\n161 27\n195 163\n198 55\n199 64\n", "output": "Anton\n"}, {"input": "12 -11 20 200\n11 189\n12 108\n19 190\n42 27\n24 193\n26 86\n26 123\n31 180\n39 196\n107 193\n...
code_stdio
[ { "content": "Завтра у хоккейной команды, которой руководит Евгений, важный матч. Евгению нужно выбрать шесть игроков, которые выйдут на лед в стартовом составе: один вратарь, два защитника и три нападающих.\n\nТак как это стартовый состав, Евгения больше волнует, насколько красива будет команда на льду, чем сп...
[{"input": "29 42 50\n605 254 369 842 889 103 937 235 135 698 482 883 738 467 848 70 1000 129 970 58 94 873 140 363 133 913 834 727 185\n17 676 703 245 149 296 800 106 153 111 285 382 12 704 830 664 30 533 604 380 469 155 216 466 36 347 270 170 10 349 86 5 164 599 517 593 373 461 908 34 569 573\n614 439 78 172 109 217 ...
code_stdio
[ { "content": "# The President's phone is broken\n\nHe is not very happy.\n\nThe only letters still working are uppercase ```E```, ```F```, ```I```, ```R```, ```U```, ```Y```.\n\nAn angry tweet is sent to the department responsible for presidential phone maintenance.\n\n\n# Kata Task\n\nDecipher the tweet by loo...
[{"input": "\"FIREYYFURYYFURYYFURRYFIRE\"", "output": "[\"You are fired! I am really furious. You are fired!\"]", "fn_name": "fire_and_fury"}, {"input": "\"FIREFIREFIREFIREFIRE\"", "output": "[\"You and you and you and you and you are fired!\"]", "fn_name": "fire_and_fury"}, {"input": "\"FURYFURYFURYFURYFURY\"", "outpu...
code_functional
[ { "content": "Pirates have notorious difficulty with enunciating. They tend to blur all the letters together and scream at people.\n\nAt long last, we need a way to unscramble what these pirates are saying.\n\nWrite a function that will accept a jumble of letters as well as a dictionary, and output a list of wo...
[{"input": "\"ortsp\"\n[\"sport\", \"parrot\", \"ports\", \"matey\"]", "output": "[[\"sport\", \"ports\"]]", "fn_name": "grabscrab"}, {"input": "\"oolp\"\n[\"donkey\", \"pool\", \"horse\", \"loop\"]", "output": "[[\"pool\", \"loop\"]]", "fn_name": "grabscrab"}, {"input": "\"ainstuomn\"\n[\"mountains\", \"hills\", \"mes...
code_functional
[ { "content": "Any resemblance to any real championship and sport is accidental.\n\nThe Berland National team takes part in the local Football championship which now has a group stage. Let's describe the formal rules of the local championship: \n\n * the team that kicked most balls in the enemy's goal area wins...
[{"input": "MYCXFLPTHVGWDSRXCOI BERLAND 5:9\nSPSHVVQLXQNRUB BERLAND 0:5\nSPSHVVQLXQNRUB MYCXFLPTHVGWDSRXCOI 4:6\nZPIIZCGCLCHNLIXCPBRM MYCXFLPTHVGWDSRXCOI 7:5\nZPIIZCGCLCHNLIXCPBRM SPSHVVQLXQNRUB 3:9\n", "output": "1:0"}, {"input": "VJWNNQCMHKJVXAPRVAD BERLAND 9:3\nVJWNNQCMHKJVXAPRVAD BUDKMHAAE 7:8\nYUMJUSFUDMHTXZAQN BE...
code_stdio
[ { "content": "Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom.\n\nA bar of chocolate can be presented as an n × n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to...
[{"input": "20 10\n10 11 U\n12 9 U\n6 15 L\n17 4 U\n11 10 L\n7 14 L\n4 17 U\n2 19 L\n8 13 L\n14 7 U\n", "output": "11\n9\n6\n4\n1\n7\n2\n2\n8\n7\n"}, {"input": "10 10\n5 6 U\n4 7 U\n8 3 L\n8 3 L\n1 10 U\n9 2 U\n10 1 L\n10 1 L\n8 3 U\n8 3 U\n", "output": "6\n7\n3\n0\n10\n2\n1\n0\n0\n0\n"}, {"input": "15 7\n8 8 U\n6 10 L...
code_stdio
[ { "content": "A sweet little monster Om Nom loves candies very much. One day he found himself in a rather tricky situation that required him to think a bit in order to enjoy candies the most. Would you succeed with the same task if you were on his place? [Image] \n\nOne day, when he came to his friend Evan, Om ...
[{"input": "925819493 47350513 28377591 119226256 49881078\n", "output": "510796638\n"}, {"input": "930064129 32726326 25428197 158103592 64501049\n", "output": "355994758\n"}, {"input": "930064129 32726326 25428197 83013449 64501049\n", "output": "363523396\n"}, {"input": "951102310 39876134 24967176 70096104 43888451...
code_stdio
[ { "content": "The three friends, Kuro, Shiro, and Katie, met up again! It's time for a party...\n\nWhat the cats do when they unite? Right, they have a party. Since they wanted to have as much fun as possible, they invited all their friends. Now $n$ cats are at the party, sitting in a circle and eating soup. Th...
[{"input": "1000 843\n", "output": "157\n"}, {"input": "1000 488\n", "output": "488\n"}, {"input": "1000 843\n", "output": "157\n"}, {"input": "1000 488\n", "output": "488\n"}, {"input": "1000 733\n", "output": "267\n"}, {"input": "543 110\n", "output": "110\n"}, {"input": "924 576\n", "output": "348\n"}, {"input": "10...
code_stdio
[ { "content": "Welcome\n\nThis kata is inspired by This Kata\n\n\nWe have a string s\n\nWe have a number n\n\nHere is a function that takes your string, concatenates the even-indexed chars to the front, odd-indexed chars to the back.\n\nExamples\n\n s = \"Wow Example!\"\n result = \"WwEapeo xml!\"\n s =...
[{"input": "\"this_test_will_hurt_you\"\n12345678987654321", "output": "[\"ti_etwl_utyuhsts_ilhr_o\"]", "fn_name": "jumbled_string"}, {"input": "\"codingisfornerdsyounerd\"\n10101010", "output": "[\"criyinodedsgufrnodnoser\"]", "fn_name": "jumbled_string"}, {"input": "\"better example\"\n2", "output": "[\"bexltept mera...
code_functional
[ { "content": "You are given a mysterious language (codenamed \"Secret\") available in \"Custom Invocation\" tab. Figure out what this language is and write a program which prints its name. Note that the program must be written in this language.\n\nInput\n\nThis program has only one test (your program doesn't ha...
[{"input": "-111\n", "output": "INTERCAL\n"}, {"input": "-165\n", "output": "INTERCAL\n"}, {"input": "-137\n", "output": "INTERCAL\n"}, {"input": "-116\n", "output": "INTERCAL\n"}, {"input": "-14\n", "output": "INTERCAL\n"}, {"input": "-17\n", "output": "INTERCAL\n"}, {"input": "-30\n", "output": "INTERCAL\n"}, {"input...
code_stdio
[ { "content": "Once at a team training Vasya, Petya and Sasha got a problem on implementing linear search in an array.\n\nAccording to the boys, linear search works as follows. The array elements in a pre-selected order are in turn compared with the number that you need to find. Once you find the array element t...
[{"input": "10\n5 2 10 8 3 1 9 7 6 4\n9\n2 1 9 2 9 2 10 9 8\n", "output": "40 59\n"}, {"input": "10\n5 2 10 8 3 1 9 7 6 4\n9\n3 1 9 2 9 2 10 9 8\n", "output": "43 56\n"}, {"input": "10\n5 2 10 8 3 1 9 7 6 4\n9\n2 1 6 2 9 2 10 9 8\n", "output": "42 57\n"}, {"input": "10\n5 2 10 8 3 1 9 7 6 4\n9\n2 1 6 2 9 2 10 8 8\n", "...
code_stdio
[ { "content": "Recently, Masha was presented with a chessboard with a height of $n$ and a width of $m$.\n\nThe rows on the chessboard are numbered from $1$ to $n$ from bottom to top. The columns are numbered from $1$ to $m$ from left to right. Therefore, each cell can be specified with the coordinates $(x,y)$, w...
[{"input": "5\n2 2\n1 1 2 2\n1 1 2 2\n3 4\n2 2 3 3\n3 1 4 3\n1 5\n1 1 3 1\n3 1 5 1\n6 4\n1 1 4 2\n1 3 4 4\n3 4\n1 2 4 2\n2 1 3 3\n", "output": "0 4\n4 8\n2 3\n12 12\n4 8\n"}, {"input": "5\n2 2\n1 1 2 2\n1 1 2 2\n3 5\n2 2 3 2\n3 1 4 3\n1 5\n1 1 5 1\n3 1 5 1\n4 4\n1 1 4 2\n1 3 4 4\n3 4\n1 2 4 2\n2 1 3 3\n", "output": "0 ...
code_stdio
[ { "content": "Positive integers have so many gorgeous features. \nSome of them could be expressed as a sum of two or more consecutive positive numbers.\n___\n\n# Consider an Example :\n\n* `10` , could be expressed as a sum of `1 + 2 + 3 + 4 `.\n___\n# Task\n\n**_Given_** *Positive integer*, N , **_Return_** tr...
[{"input": "5263987", "output": "[true]", "fn_name": "consecutive_ducks"}, {"input": "382131", "output": "[true]", "fn_name": "consecutive_ducks"}, {"input": "118070", "output": "[true]", "fn_name": "consecutive_ducks"}, {"input": "32768", "output": "[false]", "fn_name": "consecutive_ducks"}, {"input": "161997", "outpu...
code_functional
[ { "content": "Goa'uld Apophis captured Jack O'Neill's team again! Jack himself was able to escape, but by that time Apophis's ship had already jumped to hyperspace. But Jack knows on what planet will Apophis land. In order to save his friends, Jack must repeatedly go through stargates to get to this planet.\n\n...
[{"input": "8 10\n1 2 3\n2 8 3\n1 4 1\n4 3 6\n3 7 7\n4 5 5\n7 7 2\n7 8 1\n1 6 8\n6 8 7\n0\n4 1 2 3 4\n0\n0\n0\n0\n0\n0\n", "output": "8\n"}, {"input": "8 10\n1 2 3\n2 8 3\n1 4 1\n4 3 6\n3 7 7\n4 5 5\n5 7 2\n7 8 1\n1 6 8\n6 8 7\n0\n4 1 2 3 4\n0\n0\n0\n0\n0\n0\n", "output": "8"}, {"input": "7 6\n1 2 1\n1 3 3\n2 4 3\n2 5 ...
code_stdio
[ { "content": "This year, as in previous years, MemSQL is inviting the top 25 competitors from the Start[c]up qualification round to compete onsite for the final round. Not everyone who is eligible to compete onsite can afford to travel to the office, though. Initially the top 25 contestants are invited to come ...
[{"input": "25\n1000000 999999 999998 999997 999996 999995 999994 999993 999992 999991 999990 999989 999988 999987 999986 999985 999984 999983 999982 999981 999980 999979 999978 999977 999976\n", "output": "999975\n"}, {"input": "25\n58115 794098 753382 484882 238434 674285 690118 858677 196185 173301 349729 918792 600...
code_stdio
[ { "content": "Kyoya Ootori is selling photobooks of the Ouran High School Host Club. He has 26 photos, labeled \"a\" to \"z\", and he has compiled them into a photo booklet with some photos in some order (possibly with some photos being duplicated). A photo booklet can be described as a string of lowercase lett...
[{"input": "xulsyfkuizjauadjjopu\n", "output": "526\n"}, {"input": "cskgsxywlvfeicoueglr\n", "output": "526\n"}, {"input": "gggggggggggggggggggg\n", "output": "526\n"}, {"input": "qdqdddqddqqddqddqdqd\n", "output": "526\n"}, {"input": "takttttaakaaktakttkt\n", "output": "526\n"}, {"input": "coccoooogogcgocccmcg\n", "ou...
code_stdio
[ { "content": "Karafs is some kind of vegetable in shape of an 1 × h rectangle. Tavaspolis people love Karafs and they use Karafs in almost any kind of food. Tavas, himself, is crazy about Karafs.\n\n<image>\n\nEach Karafs has a positive integer height. Tavas has an infinite 1-based sequence of Karafses. The hei...
[{"input": "469 128038 4\n143 914502 747\n74 1244223 74477\n835 246699 1021\n7 477777 444444\n", "output": "-1\n-1\n-1\n-1\n"}, {"input": "469 128038 4\n82 914502 747\n80 1244223 74477\n1360 246699 1021\n7 477777 444444\n", "output": "-1\n-1\n-1\n-1\n"}, {"input": "469 128038 4\n82 914502 747\n74 1244223 74477\n432 383...
code_stdio
[ { "content": "Hexadecimal likes drawing. She has drawn many graphs already, both directed and not. Recently she has started to work on a still-life «interesting graph and apples». An undirected graph is called interesting, if each of its vertices belongs to one cycle only — a funny ring — and does not belong to...
[{"input": "50 21\n27 16\n42 35\n15 28\n46 17\n30 39\n47 18\n35 25\n26 24\n24 30\n28 41\n40 38\n11 21\n33 20\n43 10\n37 14\n1 43\n32 49\n49 6\n10 45\n21 50\n39 3\n", "output": "YES\n29\n1 2\n2 3\n4 5\n4 6\n5 7\n7 8\n8 9\n9 11\n12 13\n12 14\n13 15\n16 17\n18 19\n19 20\n22 23\n22 25\n23 26\n27 29\n29 31\n31 32\n33 34\n34...
code_stdio
[ { "content": "This is the simple version of Shortest Code series. If you need some challenges, please try the [challenge version](http://www.codewars.com/kata/570f45fab29c705d330004e3)\n\n## Task:\n\nThere is a rectangular land and we need to plant trees on the edges of that land.\n\nI will give you three param...
[{"input": "200\n2\n1", "output": "[200]", "fn_name": "sc"}, {"input": "2\n200\n1", "output": "[200]", "fn_name": "sc"}, {"input": "3\n3\n10", "output": "[0]", "fn_name": "sc"}, {"input": "3\n3\n1", "output": "[4]", "fn_name": "sc"}, {"input": "3\n3\n3", "output": "[2]", "fn_name": "sc"}, {"input": "3\n3\n2", "output":...
code_functional
[ { "content": "A priority queue is a data structure which maintains a set $S$ of elements, each of with an associated value (key), and supports the following operations:\n\n* $insert(S, k)$: insert an element $k$ into the set $S$\n* $extractMax(S)$: remove and return the element of $S$ with the largest key\n\n\n...
[{"input": "insert 8\ninsert -1\nextract\ninsert 12\nextract\ninsert 11\nextract\nextract\nend", "output": "8\n12\n11\n-1\n"}, {"input": "insert 9\ninsert -1\nextract\ninsert 12\nextract\ninsert 11\nextract\nextract\nend", "output": "9\n12\n11\n-1\n"}, {"input": "insert 16\ninsert 1\nextract\ninsert 15\nextract\ninsert...
code_stdio
[ { "content": "A ticket is a string consisting of six digits. A ticket is considered lucky if the sum of the first three digits is equal to the sum of the last three digits. Given a ticket, output if it is lucky or not. Note that a ticket can have leading zeroes.\n\n\n-----Input-----\n\nThe first line of the inp...
[{"input": "5\n213132\n973894\n045207\n000000\n055776\n", "output": "YES\nNO\nYES\nYES\nNO\n"}, {"input": "2\n193758\n123456\n", "output": "NO\nNO\n"}, {"input": "2\n192758\n123456\n", "output": "NO\nNO\n"}, {"input": "1\n114514\n", "output": "NO\n"}, {"input": "1\n975310\n", "output": "NO\n"}, {"input": "1\n666999\n",...
code_stdio
[ { "content": "You are given an integer $n$ ($n \\ge 0$) represented with $k$ digits in base (radix) $b$. So,\n\n$$n = a_1 \\cdot b^{k-1} + a_2 \\cdot b^{k-2} + \\ldots a_{k-1} \\cdot b + a_k.$$\n\nFor example, if $b=17, k=3$ and $a=[11, 15, 7]$ then $n=11\\cdot17^2+15\\cdot17+7=3179+255+7=3441$.\n\nDetermine wh...
[{"input": "97 100\n93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93\...
code_stdio
[ { "content": "Given are integers L and R. Find the number, modulo 10^9 + 7, of pairs of integers (x, y) (L \\leq x \\leq y \\leq R) such that the remainder when y is divided by x is equal to y \\mbox{ XOR } x.What is \\mbox{ XOR }?\n\nThe XOR of integers A and B, A \\mbox{ XOR } B, is defined as follows:\n\n - ...
[{"input": "576460752303423487 1000000000000000000\n", "output": "576747015\n"}, {"input": "576460752303423488 1000000000000000000\n", "output": "576747014\n"}, {"input": "272710541579005162 367157307262253986\n", "output": "252027897\n"}, {"input": "1000000000000000000 1000000000000000000\n", "output": "1\n"}, {"input...
code_stdio
[ { "content": "You are given n strings s_1, s_2, ..., s_{n} consisting of characters 0 and 1. m operations are performed, on each of them you concatenate two existing strings into a new one. On the i-th operation the concatenation s_{a}_{i}s_{b}_{i} is saved into a new string s_{n} + i (the operations are number...
[{"input": "2\n011\n100\n63\n1 1\n3 3\n4 4\n5 5\n6 6\n7 7\n8 8\n9 9\n10 10\n11 11\n12 12\n13 13\n14 14\n15 15\n16 16\n17 17\n18 18\n19 19\n20 20\n21 21\n22 22\n23 23\n24 24\n25 25\n26 26\n27 27\n28 28\n29 29\n30 30\n31 31\n32 32\n2 2\n34 34\n35 35\n36 36\n37 37\n38 38\n39 39\n40 40\n41 41\n42 42\n43 43\n44 44\n45 45\n4...
code_stdio