messages
listlengths
1
1
ground_truth
stringlengths
156
726k
dataset
stringclasses
2 values
[ { "content": "Write an algorithm that takes an array and moves all of the zeros to the end, preserving the order of the other elements.\n\n```python\nmove_zeros([False,1,0,1,2,0,1,3,\"a\"]) # returns[False,1,1,2,1,3,\"a\",0,0]\n```\n\nWrite Python code to solve this problem. Define a top-level function named `m...
[{"input": "[\"a\", 0, 0, \"b\", null, \"c\", \"d\", 0, 1, false, 0, 1, 0, 3, [], 0, 1, 9, 0, 0, {}, 0, 0, 9]", "output": "[[\"a\", \"b\", null, \"c\", \"d\", 1, false, 1, 3, [], 1, 9, {}, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]", "fn_name": "move_zeros"}, {"input": "[\"a\", 0, 0, \"b\", \"c\", \"d\", 0, 1, 0, 1, 0, 3, 0, 1,...
code_functional
[ { "content": "Snuke has a string S consisting of three kinds of letters: `a`, `b` and `c`.\n\nHe has a phobia for palindromes, and wants to permute the characters in S so that S will not contain a palindrome of length 2 or more as a substring. Determine whether this is possible.\n\nConstraints\n\n* 1 \\leq |S| ...
[{"input": "bacaccbabab", "output": "YES\n"}, {"input": "bacaacbcbab", "output": "YES\n"}, {"input": "babcbcaacab", "output": "YES\n"}, {"input": "bababccacab", "output": "YES\n"}, {"input": "bacaccbabac", "output": "YES\n"}, {"input": "babacccbaab", "output": "YES\n"}, {"input": "bacaacccbab", "output": "YES\n"}, {"in...
code_stdio
[ { "content": "Codefortia is a small island country located somewhere in the West Pacific. It consists of $n$ settlements connected by $m$ bidirectional gravel roads. Curiously enough, the beliefs of the inhabitants require the time needed to pass each road to be equal either to $a$ or $b$ seconds. It's guarante...
[{"input": "6 7 13 22\n1 2 13\n2 3 13\n1 4 22\n3 4 13\n4 5 13\n5 6 13\n6 1 13\n", "output": "0 13 26 39 26 13\n"}, {"input": "6 7 13 22\n1 2 13\n2 3 13\n1 4 22\n3 4 13\n4 1 13\n5 6 13\n6 1 13\n", "output": "0 13 26 13 26 13 "}, {"input": "6 7 13 22\n2 2 13\n2 3 13\n1 4 22\n3 4 13\n4 1 13\n5 6 13\n6 1 13\n", "output": "...
code_stdio
[ { "content": "You are given a string $s$ consisting of lowercase Latin letters \"a\", \"b\" and \"c\" and question marks \"?\".\n\nLet the number of question marks in the string $s$ be $k$. Let's replace each question mark with one of the letters \"a\", \"b\" and \"c\". Here we can obtain all $3^{k}$ possible s...
[{"input": "300\ncc?aabbb?ba?cbcb??b??ababcabcb???b?bcb?ac??a?acc?cba?aa?a???bc?????ca??ac???cb??caaca???aabbc?cb?bb?a?bbb?a?cbbaccbcaab?a???baab?ac?ab??a?b?ac?acbcbb?cc??bbbcc?c??cab?cac?c???accb???c?cc?bb???b?bca?bbaccca??b?c?bb?b?a??ccb?c?abbc?aaa???bca?ccb?bb?c?b???c???bcac??ca?ba?a?cbabbb??b?aaaba??b??a?bbcbbcb\n"...
code_stdio
[ { "content": "Given is a number sequence A of length N.\nFind the number of integers i \\left(1 \\leq i \\leq N\\right) with the following property:\n - For every integer j \\left(1 \\leq j \\leq N\\right) such that i \\neq j , A_j does not divide A_i.\n\n-----Constraints-----\n - All values in input are intege...
[{"input": "10\n33 18 45 28 8 19 89 86 2 4\n", "output": "5\n"}, {"input": "10\n33 4 45 28 15 19 123 86 2 4", "output": "5\n"}, {"input": "10\n33 18 45 28 8 19 89 86 2 7", "output": "6\n"}, {"input": "10\n33 4 45 28 15 19 89 86 2 4", "output": "5\n"}, {"input": "10\n33 2 26 28 13 19 89 86 2 4", "output": "4\n"}, {"inpu...
code_stdio
[ { "content": "Create a program that will take in a string as input and, if there are duplicates of more than two alphabetical characters in the string, returns the string with all the extra characters in a bracket.\n\nFor example, the input \"aaaabbcdefffffffg\" should return \"aa[aa]bbcdeff[fffff]g\" \n\nPlea...
[{"input": "\"aaaabbcdefffffffg\"", "output": "[\"aa[aa]bbcdeff[fffff]g\"]", "fn_name": "string_parse"}, {"input": "\"aAAabbcdeFFFffffg\"", "output": "[\"aAAabbcdeFF[F]ff[ff]g\"]", "fn_name": "string_parse"}, {"input": "\"aAAabbcdeffFfFffg\"", "output": "[\"aAAabbcdeffFfFffg\"]", "fn_name": "string_parse"}, {"input": "...
code_functional
[ { "content": "We have a grid with H rows and W columns. The square at the i-th row and the j-th column will be called Square (i,j).\nThe integers from 1 through H×W are written throughout the grid, and the integer written in Square (i,j) is A_{i,j}.\nYou, a magical girl, can teleport a piece placed on Square (i...
[{"input": "5 5 4\n13 25 7 15 17\n16 22 20 2 9\n14 11 12 1 19\n10 6 23 8 18\n3 21 5 24 4\n3\n13 13\n2 10\n13 13\n", "output": "0\n5\n0\n"}, {"input": "5 5 4\n13 25 7 15 17\n16 22 20 2 9\n14 11 12 1 19\n10 6 23 8 18\n3 21 5 24 4\n3\n13 13\n0 10\n13 13", "output": "0\n5\n0\n"}, {"input": "5 5 7\n13 25 7 15 17\n16 22 20 2...
code_stdio
[ { "content": "Berland shop sells $n$ kinds of juices. Each juice has its price $c_i$. Each juice includes some set of vitamins in it. There are three types of vitamins: vitamin \"A\", vitamin \"B\" and vitamin \"C\". Each juice can contain one, two or all three types of vitamins in it.\n\nPetya knows that he ne...
[{"input": "25\n8 CA\n4 AB\n8 CA\n4 CA\n7 CB\n4 CB\n4 CB\n2 AC\n2 CA\n3 BC\n4 AC\n7 AB\n3 CA\n5 BC\n7 CB\n9 CA\n7 AB\n7 CA\n9 BA\n8 AC\n6 BA\n2 AC\n1 CB\n5 AB\n3 AB\n", "output": "3\n"}, {"input": "25\n8 CA\n4 AB\n8 CA\n4 CA\n2 CB\n4 CB\n4 CB\n2 AC\n2 CA\n3 BC\n4 AC\n7 AB\n3 CA\n5 BC\n7 CB\n9 CA\n7 AB\n7 CA\n9 BA\n8 AC...
code_stdio
[ { "content": "Bran and his older sister Arya are from the same house. Bran like candies so much, so Arya is going to give him some Candies.\n\nAt first, Arya and Bran have 0 Candies. There are n days, at the i-th day, Arya finds a_{i} candies in a box, that is given by the Many-Faced God. Every day she can give...
[{"input": "100 456\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": "Eighth-grader Vova is on duty today in the class. After classes, he went into the office to wash the board, and found on it the number n. He asked what is this number and the teacher of mathematics Inna Petrovna answered Vova that n is the answer to the arithmetic task for first-graders. In the te...
[{"input": "1000010010\n", "output": "2\n1000009977 1000010004\n"}, {"input": "1010011010\n", "output": "2\n1010010985 1010011003\n"}, {"input": "1100011010\n", "output": "2\n1100010985 1100011003\n"}, {"input": "999999979\n", "output": "2\n999999899 999999908 "}, {"input": "101011111\n", "output": "2\n101011094 101011...
code_stdio
[ { "content": "You are given a number $k$ and a string $s$ of length $n$, consisting of the characters '.' and '*'. You want to replace some of the '*' characters with 'x' characters so that the following conditions are met:\n\nThe first character '*' in the original string should be replaced with 'x';\n\nThe la...
[{"input": "5\n7 3\n***.**.\n5 12\n.*...\n5 2\n*.*.*\n3 2\n*.*\n1 1\n*\n", "output": "3\n1\n3\n2\n1\n"}, {"input": "5\n7 5\n***.**.\n5 12\n.*...\n5 2\n*.*.*\n3 2\n*.*\n1 1\n*\n", "output": "2\n1\n3\n2\n1\n"}, {"input": "5\n7 3\n***.**.\n5 12\n.*...\n5 2\n*.**.\n3 2\n*.*\n1 1\n*\n", "output": "3\n1\n3\n2\n1\n"}, {"input...
code_stdio
[ { "content": "Two T-shirt sizes are given: $a$ and $b$. The T-shirt size is either a string M or a string consisting of several (possibly zero) characters X and one of the characters S or L.\n\nFor example, strings M, XXL, S, XXXXXXXS could be the size of some T-shirts. And the strings XM, LL, SX are not sizes....
[{"input": "15\nM M\nM L\nL M\nS M\nM S\nL L\nXL L\nL XXXXXXL\nS S\nXXXXS XXXS\nXS XXXXXXS\nM XXXS\nM XXXL\nXXXXXS XL\nXL XXXXS\n", "output": "=\n<\n>\n<\n>\n=\n>\n<\n=\n<\n>\n>\n<\n<\n>\n"}, {"input": "1\nXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXS XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXL\n", "output"...
code_stdio
[ { "content": "Ternary numeric notation is quite popular in Berland. To telegraph the ternary number the Borze alphabet is used. Digit 0 is transmitted as «.», 1 as «-.» and 2 as «--». You are to decode the Borze code, i.e. to find out the ternary number given its representation in Borze alphabet.\n\nInput\n\nTh...
[{"input": "..---.-.--.-..-.-.---...--.-------..-.---.-...-.-----...-.-.....-..--.---.-.-.-----.-.-.-..----.-.----.-.---.--.-..-.----..---.-..--..------.-.-.---.-.-...--....-.--.--.-.-.-..-..-...--..---.-.------.\n", "output": "00211201011210020222101211001221001100001020211122111102201220121201012200211020022201121110...
code_stdio
[ { "content": "Adapted from here, with less terrible instructions and a couple tweaks.\n\nTwo kangaroos are jumping on a line. They start out at different points on the line, and jump in the same direction at different speeds. Your task is to determine whether or not they'll ever land in the same spot at the sam...
[{"input": "72893\n11125\n24432\n4202", "output": "[false]", "fn_name": "kangaroo"}, {"input": "-1571\n4240\n9023\n4234", "output": "[false]", "fn_name": "kangaroo"}, {"input": "-7855\n4240\n9023\n4234", "output": "[true]", "fn_name": "kangaroo"}, {"input": "9023\n4240\n1571\n4234", "output": "[false]", "fn_name": "kan...
code_functional
[ { "content": "You are given an array $a$ of length $n$ and array $b$ of length $m$ both consisting of only integers $0$ and $1$. Consider a matrix $c$ of size $n \\times m$ formed by following rule: $c_{i, j} = a_i \\cdot b_j$ (i.e. $a_i$ multiplied by $b_j$). It's easy to see that $c$ consists of only zeroes a...
[{"input": "50 50 6\n1 0 0 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 0 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 0 1 1 1 0 1\n1 1 0 1 0 1 1 0 1 1 1 1 1 1 0 1 1 0 1 0 0 1 1 1 1 0 0 1 0 1 1 1 0 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 0\n", "output": "2153\n"}, {"input": "50 50 6\n1 0 0 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 0 1 0 1...
code_stdio
[ { "content": "Santa Claus has received letters from $n$ different kids throughout this year. Of course, each kid wants to get some presents from Santa: in particular, the $i$-th kid asked Santa to give them one of $k_i$ different items as a present. Some items could have been asked by multiple kids.\n\nSanta is...
[{"input": "10\n5 48258 84644 992412 548310 132019\n5 132019 556600 548310 94345 992412\n6 132019 771663 523582 548310 463969 556600\n7 556600 132019 992412 523582 548310 70239 84644\n4 504172 548310 523582 286042\n7 548310 84644 771663 556600 132019 463969 48258\n5 556600 771663 463969 523582 84644\n6 131105 548310 84...
code_stdio
[ { "content": "You have a given integer $n$. Find the number of ways to fill all $3 \\times n$ tiles with the shape described in the picture below. Upon filling, no empty spaces are allowed. Shapes cannot overlap. $\\square$ This picture describes when $n = 4$. The left one is the shape and the right one is $3 \...
[{"input": "60\n", "output": "1073741824"}, {"input": "60\n", "output": "1073741824"}, {"input": "54\n", "output": "134217728\n"}, {"input": "58\n", "output": "536870912\n"}, {"input": "56\n", "output": "268435456"}, {"input": "56\n", "output": "268435456"}, {"input": "50\n", "output": "33554432\n"}, {"input": "52\n", ...
code_stdio
[ { "content": "Young boy Artem tries to paint a picture, and he asks his mother Medina to help him. Medina is very busy, that's why she asked for your help.\n\nArtem wants to paint an $n \\times m$ board. Each cell of the board should be colored in white or black. \n\nLets $B$ be the number of black cells that h...
[{"input": "19\n15 73\n16 92\n22 97\n13 64\n49 127\n79 79\n66 13\n49 48\n173 75\n64 77\n27 95\n27 156\n29 53\n48 10\n265 151\n26 37\n13 2\n44 13\n85 70\n", "output": "WBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB\nBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB\nBBB...
code_stdio
[ { "content": "In 2020, AtCoder Inc. with an annual sales of more than one billion yen (the currency of Japan) has started a business in programming education.\n\nOne day, there was an exam where a one-year-old child must write a program that prints Hello World, and a two-year-old child must write a program that...
[{"input": "1\n", "output": "Hello World\n"}, {"input": "2\n-2\n116", "output": "114\n"}, {"input": "2\n-2\n178", "output": "176\n"}, {"input": "2\n-2\n184", "output": "182\n"}, {"input": "2\n-2\n143", "output": "141\n"}, {"input": "2\n-3\n143", "output": "140\n"}, {"input": "2\n-3\n130", "output": "127\n"}, {"input": ...
code_stdio
[ { "content": "Recently Irina arrived to one of the most famous cities of Berland — the Berlatov city. There are n showplaces in the city, numbered from 1 to n, and some of them are connected by one-directional roads. The roads in Berlatov are designed in a way such that there are no cyclic routes between showpl...
[{"input": "10 45 8\n1 2 1\n1 3 1\n1 4 1\n1 5 1\n1 6 1\n1 7 1\n1 8 1\n1 9 1\n1 10 1\n2 3 1\n2 4 1\n2 5 1\n2 6 1\n2 7 1\n2 8 1\n2 9 1\n2 10 1\n3 4 1\n3 5 1\n3 6 1\n3 7 1\n3 8 1\n3 9 1\n3 10 1\n4 5 1\n4 6 1\n4 7 1\n4 8 1\n4 9 1\n4 10 1\n5 6 1\n5 7 1\n5 8 1\n5 9 1\n5 10 1\n6 7 1\n6 8 1\n6 9 1\n6 10 1\n7 8 1\n7 9 1\n7 10 1...
code_stdio
[ { "content": "You are given a positive integer $D$. Let's build the following graph from it: each vertex is a divisor of $D$ (not necessarily prime, $1$ and $D$ itself are also included); two vertices $x$ and $y$ ($x > y$) have an undirected edge between them if $x$ is divisible by $y$ and $\\frac x y$ is a ...
[{"input": "18\n36\n1 1\n1 2\n1 3\n1 6\n1 9\n1 18\n2 1\n2 2\n2 3\n2 6\n2 9\n2 18\n3 1\n3 2\n3 3\n3 6\n3 9\n3 18\n6 1\n6 2\n6 3\n6 6\n6 9\n6 18\n9 1\n9 2\n9 3\n9 6\n9 9\n9 18\n18 1\n18 2\n18 3\n18 6\n18 9\n18 18\n", "output": "1\n1\n1\n2\n1\n3\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n2\n2\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n3\n1...
code_stdio
[ { "content": "The Little Elephant has an integer a, written in the binary notation. He wants to write this number on a piece of paper.\n\nTo make sure that the number a fits on the piece of paper, the Little Elephant ought to delete exactly one any digit from number a in the binary record. At that a new number ...
[{"input": "11100010010010000110101101101100111111001010001101101001001111010110010111001011010000001100110101000101111000001111101111110010000010101110011110101101010110001100011101111011100010011101100111110010111111100110101000000111101000000000110100100101111101000110101010101101001110001110000101011010101100011100...
code_stdio
[ { "content": "ZS the Coder and Chris the Baboon arrived at the entrance of Udayland. There is a n × n magic grid on the entrance which is filled with integers. Chris noticed that exactly one of the cells in the grid is empty, and to enter Udayland, they need to fill a positive integer into the empty cell.\n\nCh...
[{"input": "9\n1 1000000000 1 1000000000 1 1000000000 1 1000000000 1\n1000000000 1 1000000000 1 1 1 1000000000 1 1000000000\n1 1000000000 1 1000000000 1 1000000000 1 1000000000 1\n1000000000 1 1000000000 1 1 1 1000000000 1 1000000000\n1 1 1 1 0 1 1 1 1\n1000000000 1 1000000000 1 1 1 1000000000 1 1000000000\n1 100000000...
code_stdio
[ { "content": "The sum of divisors of `6` is `12` and the sum of divisors of `28` is `56`. You will notice that `12/6 = 2` and `56/28 = 2`. We shall say that `(6,28)` is a pair with a ratio of `2`. Similarly, `(30,140)` is also a pair but with a ratio of `2.4`. These ratios are simply decimal representations of...
[{"input": "200\n1000", "output": "[1104]", "fn_name": "solve"}, {"input": "100\n1000", "output": "[2223]", "fn_name": "solve"}, {"input": "800\n2000", "output": "[2352]", "fn_name": "solve"}, {"input": "1\n1000", "output": "[2619]", "fn_name": "solve"}, {"input": "1\n300", "output": "[252]", "fn_name": "solve"}, {"inp...
code_functional
[ { "content": "A direced graph is strongly connected if every two nodes are reachable from each other. In a strongly connected component of a directed graph, every two nodes of the component are mutually reachable.\n\nConstraints\n\n* 1 ≤ |V| ≤ 10,000\n* 0 ≤ |E| ≤ 30,000\n* 1 ≤ Q ≤ 100,000\n\nInput\n\nA directed...
[{"input": "9 6\n1 1\n1 0\n1 4\n2 4\n4 3\n4 2\n4\n1 1\n-1 3\n2 -1\n3 4", "output": "1\n0\n0\n0\n"}, {"input": "5 6\n0 1\n1 0\n1 0\n2 4\n4 1\n3 2\n4\n0 1\n-1 0\n2 0\n3 4", "output": "1\n0\n0\n0\n"}, {"input": "9 6\n0 1\n1 0\n1 2\n2 4\n4 3\n4 2\n4\n1 1\n-1 3\n2 0\n3 4", "output": "1\n0\n0\n0\n"}, {"input": "5 6\n0 1\n1 0...
code_stdio
[ { "content": "INTERCAL is the oldest of esoteric programming languages. One of its many weird features is the method of character-based output, known as Turing Tape method. It converts an array of unsigned 8-bit integers into a sequence of characters to print, using the following method.\n\nThe integers of the ...
[{"input": "aMCT]:0hDJ*Up5g_l:O&>>%gjQkZkb(mi&;\\7dL\"nWOGz/;,6h*@Q0R53MS2<}F~+Ms\\\"cF-lgF0>C&y7)72\\.T\"8*#VO=|^OtYs\n", "output": "122\n212\n240\n152\n112\n94\n80\n246\n244\n208\n254\n170\n156\n98\n198\n236\n196\n218\n106\n142\n232\n0\n216\n190\n144\n204\n180\n124\n132\n144\n50\n94\n32\n50\n136\n162\n78\n198\n244\n2...
code_stdio
[ { "content": "In AtCoder, a person who has participated in a contest receives a color, which corresponds to the person's rating as follows: \n - Rating 1-399 : gray\n - Rating 400-799 : brown\n - Rating 800-1199 : green\n - Rating 1200-1599 : cyan\n - Rating 1600-1999 : blue\n - Rating 2000-2399 : yellow\n - R...
[{"input": "20\n800 2054 820 830 840 850 384 433 1213 259 900 1139 920 1007 92 2243 960 970 1357 990", "output": "5 5\n"}, {"input": "20\n800 2108 443 830 840 2012 116 614 620 92 399 1139 1229 646 92 2243 174 1254 1914 990", "output": "6 6\n"}, {"input": "20\n800 2108 443 830 840 2012 116 614 620 92 399 1139 1229 646 9...
code_stdio
[ { "content": "You are given $n$ integers $w_i (i = 0, 1, ..., n-1)$ to be sorted in ascending order. You can swap two integers $w_i$ and $w_j$. Each swap operation has a cost, which is the sum of the two integers $w_i + w_j$. You can perform the operations any number of times.\n\nWrite a program which reports t...
[{"input": "5\n0 91 14 2 11", "output": "120\n"}, {"input": "5\n0 91 14 3 11", "output": "122\n"}, {"input": "5\n1 25 13 2 11", "output": "55\n"}, {"input": "5\n0 91 9 2 11", "output": "106\n"}, {"input": "5\n0 26 3 1 10", "output": "38\n"}, {"input": "5\n0 26 3 1 19", "output": "47\n"}, {"input": "5\n0 17 3 1 13", "ou...
code_stdio
[ { "content": "A [Narcissistic Number](https://en.wikipedia.org/wiki/Narcissistic_number) is a positive number which is the sum of its own digits, each raised to the power of the number of digits in a given base. In this Kata, we will restrict ourselves to decimal (base 10).\n\nFor example, take 153 (3 digits):\...
[{"input": "1634", "output": "[true]", "fn_name": "narcissistic"}, {"input": "153", "output": "[true]", "fn_name": "narcissistic"}, {"input": "370", "output": "[true]", "fn_name": "narcissistic"}, {"input": "371", "output": "[true]", "fn_name": "narcissistic"}, {"input": "1", "output": "[true]", "fn_name": "narcissisti...
code_functional
[ { "content": "You are given a string $s$, consisting of brackets of two types: '(', ')', '[' and ']'.\n\nA string is called a regular bracket sequence (RBS) if it's of one of the following types:\n\nempty string;\n\n'(' + RBS + ')';\n\n'[' + RBS + ']';\n\nRBS + RBS.\n\nwhere plus is a concatenation of two strin...
[{"input": "7\n()\n()\n()\n()\n()\n()\n()\n", "output": "1\n1\n1\n1\n1\n1\n1\n"}, {"input": "7\n()\n()\n()\n()\n()\n()\n()\n", "output": "1\n1\n1\n1\n1\n1\n1\n"}, {"input": "7\n((\n()\n()\n()\n()\n()\n()\n", "output": "0\n1\n1\n1\n1\n1\n1\n"}, {"input": "7\n((\n()\n()\n)(\n()\n()\n()\n", "output": "0\n1\n1\n0\n1\n1\n1\...
code_stdio
[ { "content": "Polycarp is preparing the first programming contest for robots. There are $n$ problems in it, and a lot of robots are going to participate in it. Each robot solving the problem $i$ gets $p_i$ points, and the score of each robot in the competition is calculated as the sum of $p_i$ over all problems...
[{"input": "100\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 ...
code_stdio
[ { "content": "Mobile phones are equipped with a function that displays input candidates in order to efficiently input texts such as emails. This records frequently used words and presents words that have the entered letters as initial letters as input candidates. For example, if you usually enter the word \"com...
[{"input": "1\nben mikes bananas eht best among many fruits bec`use bananas are sweet and cheao\nb\n1\nwinners get to visit aizu and eht uvinersity of ahuz amd maje amnx friends as wlel\na\n3\nask alex about\nthe answer for the\nassignmdnt pn diordn` `pps\na\n2\ngnimmargorp si both\na sport aod an laitcelletnu puzzle\n...
code_stdio
[ { "content": "Vova's house is an array consisting of $n$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $i$-th element of the array is $1$ if there is a heater in the position $i$, otherwise the $i$-th element of the a...
[{"input": "187 64\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...
code_stdio
[ { "content": "It is known that there are k fish species in the polar ocean, numbered from 1 to k. They are sorted by non-decreasing order of their weight, which is a positive number. Let the weight of the i-th type of fish be wi, then 0 < w1 ≤ w2 ≤ ... ≤ wk holds.\n\nPolar bears Alice and Bob each have caught s...
[{"input": "100 50 11\n7 15 0 1 6 7 9 2 4 6 7 7 3 9 4 5 0 7 8 19 4 1 3 6 8 10 4 6 6 1 6 6 7 4 10 3 10 1 3 1 10 6 9 9 5 2 9 2 9 8 10 2 10 3 3 2 3 8 6 2 7 10 7 2 7 2 8 9 6 2 5 4 4 5 3 3 9 10 9 4 9 3 9 5 3 11 6 2 3 6 10 3 10 2 6 13 10 10 4 8\n3 3 2 9 4 4 10 2 7 3 3 2 6 3 3 4 7 4 1 2 3 8 1 6 14 7 2 10 1 0 1 5 7 7 5 1 6 8 7...
code_stdio
[ { "content": "In this Kata, you will be given an array of unique elements, and your task is to rerrange the values so that the first max value is followed by the first minimum, followed by second max value then second min value, etc. \n\nFor example:\nThe first max is `15` and the first min is `7`. The second m...
[{"input": "[78, 79, 52, 87, 16, 74, 31, 63, 80]", "output": "[[87, 16, 80, 31, 79, 52, 78, 63, 74]]", "fn_name": "solve"}, {"input": "[52, 77, 72, 44, 74, 76, 40]", "output": "[[77, 40, 76, 44, 74, 52, 72]]", "fn_name": "solve"}, {"input": "[1, 6, 9, 4, 3, 7, 8, 2]", "output": "[[9, 1, 8, 2, 7, 3, 6, 4]]", "fn_name": ...
code_functional
[ { "content": "You are playing one RPG from the 2010s. You are planning to raise your smithing skill, so you need as many resources as possible. So how to get resources? By stealing, of course.\n\nYou decided to rob a town's blacksmith and you take a follower with you. You can carry at most $p$ units and your fo...
[{"input": "9\n475033014 267058742\n26843 148652\n850113755 279316120\n871120869 885251487\n51363 15651\n220811492 256297120\n473761699 194406678\n38725 23371\n167395720 333327477\n107541472 19164492\n74340 1113\n654389849 224345301\n663158140 437349008\n332 5052\n971865476 538450184\n959712803 461224210\n3821 6144\n11...
code_stdio
[ { "content": "The football season has just ended in Berland. According to the rules of Berland football, each match is played between two teams. The result of each match is either a draw, or a victory of one of the playing teams. If a team wins the match, it gets w points, and the opposing team gets 0 points. I...
[{"input": "1000000000000 68088352351238212 100000 99999\n", "output": "680883461725 61788 319116476487\n"}, {"input": "1108577267933 48182461851369906 125899 19927\n", "output": "382707249106 95156 725869923671\n"}, {"input": "1252579684821 11261673116424810 25436 16077\n", "output": "442745437221 10902 809834236698\n...
code_stdio
[ { "content": "In an infinite array with two rows, the numbers in the top row are denoted\n\n`. . . , A[−2], A[−1], A[0], A[1], A[2], . . .`\n\nand the numbers in the bottom row are denoted\n\n`. . . , B[−2], B[−1], B[0], B[1], B[2], . . .`\n\nFor each integer `k`, the entry `A[k]` is directly above\nthe entry `...
[{"input": "[0, 4, 6, 13]\n100", "output": "[335254562473098582210532865941148591672699700764231400858]", "fn_name": "find_a"}, {"input": "[1, 2, 3, 5]\n100", "output": "[60560100487003612846322657690093088848428068520476594299]", "fn_name": "find_a"}, {"input": "[-20, 1, -3, 14]\n-5", "output": "[-44402]", "fn_name": ...
code_functional
[ { "content": "Vanya got n cubes. He decided to build a pyramid from them. Vanya wants to build the pyramid as follows: the top level of the pyramid must consist of 1 cube, the second level must consist of 1 + 2 = 3 cubes, the third level must have 1 + 2 + 3 = 6 cubes, and so on. Thus, the i-th level of the pyra...
[{"input": "10000\n", "output": "38\n"}, {"input": "10001\n", "output": "38\n"}, {"input": "4115\n", "output": "28\n"}, {"input": "9894\n", "output": "38\n"}, {"input": "7969\n", "output": "35\n"}, {"input": "6560\n", "output": "33\n"}, {"input": "9880\n", "output": "38\n"}, {"input": "9879\n", "output": "37\n"}, {"inp...
code_stdio
[ { "content": "There are N bags of biscuits. The i-th bag contains A_i biscuits.\n\nTakaki will select some of these bags and eat all of the biscuits inside. Here, it is also possible to select all or none of the bags.\n\nHe would like to select bags so that the total number of biscuits inside is congruent to P ...
[{"input": "45 1\n17 55 85 55 74 20 90 67 40 121 39 178 91 50 16 38 14 43 24 68 25 9 89 71 41 16 53 11 61 15 85 72 62 67 42 26 36 66 4 87 59 91 4 24 26", "output": "17592186044416\n"}, {"input": "45 1\n17 55 85 55 74 20 90 67 40 121 39 178 91 50 16 38 14 43 24 68 25 9 89 71 41 16 53 11 94 15 85 72 62 67 42 26 36 66 4 8...
code_stdio
[ { "content": "Some days ago, I learned the concept of LCM (least common multiple). I've played with it for several times and I want to make a big number with it.\n\nBut I also don't want to use many numbers, so I'll choose three positive integers (they don't have to be distinct) which are not greater than n. Ca...
[{"input": "1000000\n", "output": "999996000003000000\n"}, {"input": "862795\n", "output": "642275489615199390\n"}, {"input": "763116\n", "output": "444394078546562430\n"}, {"input": "756604\n", "output": "433115377058855412\n"}, {"input": "978187\n", "output": "935975171582120670\n"}, {"input": "642635\n", "output": "...
code_stdio
[ { "content": "Given a string, return a new string that has transformed based on the input:\n\n* Change case of every character, ie. lower case to upper case, upper case to lower case.\n* Reverse the order of words from the input.\n\n**Note:** You will have to handle multiple spaces, and leading/trailing spaces....
[{"input": "\"To be OR not to be That is the Question\"", "output": "[\"qUESTION THE IS tHAT BE TO NOT or BE tO\"]", "fn_name": "string_transformer"}, {"input": "\"You Know When THAT Hotline Bling\"", "output": "[\"bLING hOTLINE that wHEN kNOW yOU\"]", "fn_name": "string_transformer"}, {"input": "\" A b C d E f G \...
code_functional
[ { "content": "You are given a string S consisting of lowercase English letters. Determine whether all the characters in S are different.\n\n-----Constraints-----\n - 2 ≤ |S| ≤ 26, where |S| denotes the length of S.\n - S consists of lowercase English letters.\n\n-----Input-----\nInput is given from Standard Inp...
[{"input": "uncopyrightable\n", "output": "yes\n"}, {"input": "uncopyrightacle", "output": "no\n"}, {"input": "elcathgirypocnu", "output": "no\n"}, {"input": "elcathgirxpocnu", "output": "no\n"}, {"input": "elcathgiqxpocnu", "output": "no\n"}, {"input": "elcathgiqxcopnu", "output": "no\n"}, {"input": "elcathfiqxcopnu",...
code_stdio
[ { "content": "You are given a matrix of size n × n filled with lowercase English letters. You can change no more than k letters in this matrix.\n\nConsider all paths from the upper left corner to the lower right corner that move from a cell to its neighboring cell to the right or down. Each path is associated w...
[{"input": "7 6\nypnxnnp\npnxonpm\nnxanpou\nxnnpmud\nnhtdudu\nnpmuduh\npmutsnz\n", "output": "aaaaaaadudsnz\n"}, {"input": "7 6\nypnxnnp\npnxonpm\nnxanpou\nxnnpmud\nnhtdudu\nnpmuduh\npmutzns\n", "output": "aaaaaaaduduhs"}, {"input": "7 6\nypnxnnp\nmpnoxnp\nnxanpou\nxnnpmud\nnhtdudu\nnpmuduh\npmutsnz\n", "output": "aaaa...
code_stdio
[ { "content": "The function is not returning the correct values. Can you figure out why?\n\n```python\nget_planet_name(3) # should return 'Earth'\n```\n\nWrite Python code to solve this problem. Define a top-level function named `get_planet_name` that takes the input arguments described above and returns the ans...
[{"input": "5", "output": "[\"Jupiter\"]", "fn_name": "get_planet_name"}, {"input": "8", "output": "[\"Neptune\"]", "fn_name": "get_planet_name"}, {"input": "1", "output": "[\"Mercury\"]", "fn_name": "get_planet_name"}, {"input": "2", "output": "[\"Venus\"]", "fn_name": "get_planet_name"}, {"input": "3", "output": "[\"...
code_functional
[ { "content": "You are given an array $a$ of $n$ integers. Count the number of pairs of indices $(i, j)$ such that $i < j$ and $a_j - a_i = j - i$.\n\n\n-----Input-----\n\nThe first line contains one integer $t$ ($1 \\le t \\le 10^4$). Then $t$ test cases follow.\n\nThe first line of each test case contains one ...
[{"input": "1\n190\n2 1 1 1 0 1 1 1 1 1 1 0 0 0 0 0 1 1 1 1 1 1 0 2 1 0 1 2 1 2 1 1 2 1 1 1 1 1 1 1 0 2 1 1 1 -1 1 1 1 1 2 0 0 1 1 0 1 1 1 3 1 1 1 1 1 1 1 2 1 1 1 1 1 2 1 2 1 1 1 1 2 1 1 1 1 1 1 4 1 0 1 1 1 2 1 0 3 4 5 3 0 8 9 16 11 14 10 14 16 16 17 5 19 20 21 18 4 17 42 5 88 41 29 30 31 32 33 34 35 46 10 68 6 25 15 4...
code_stdio
[ { "content": "Little Artem got n stones on his birthday and now wants to give some of them to Masha. He knows that Masha cares more about the fact of receiving the present, rather than the value of that present, so he wants to give her stones as many times as possible. However, Masha remembers the last present ...
[{"input": "1000000000\n", "output": "666666667\n"}, {"input": "1001000000\n", "output": "667333333\n"}, {"input": "1001100000\n", "output": "667400000\n"}, {"input": "1001001000\n", "output": "667334000\n"}, {"input": "1001001100\n", "output": "667334067\n"}, {"input": "1000001100\n", "output": "666667400\n"}, {"input...
code_stdio
[ { "content": "The palindrome is a string that can be read the same way from left to right and from right to left. For example, strings \"aaaaa\", \"1221\", \"bbaabb\" are palindromes, however the string \"chef\" is not a palindrome because if we read it from right to left, we will obtain \"fehc\" that is not th...
[{"input": "2\n12\n12", "output": "12\n12\n"}, {"input": "2\n14\n11", "output": "14\n10\n"}, {"input": "2\n14\n22", "output": "14\n22\n"}, {"input": "2\n119\n1", "output": "118\n0\n"}, {"input": "2\n65\n12", "output": "64\n12\n"}, {"input": "2\n14\n13", "output": "14\n12\n"}, {"input": "2\n65\n11", "output": "64\n10\n"...
code_stdio
[ { "content": "To help those contestants who struggle a lot in contests, the headquarters of Codeforces are planning to introduce Division 5. In this new division, the tags of all problems will be announced prior to the round to help the contestants.\n\nThe contest consists of $n$ problems, where the tag of the ...
[{"input": "4\n6\n1 1 2 3 1 1\n5\n1 1 1 2 2\n8\n7 7 2 7 7 1 4 7\n10\n1 2 3 10 1 1 2 3 4 1\n", "output": "-1\n3\n-1\n2\n"}, {"input": "4\n6\n2 2 2 3 1 2\n5\n1 1 1 2 2\n8\n7 7 2 7 7 1 8 7\n10\n1 2 6 4 1 1 2 4 4 1\n", "output": "-1\n3\n-1\n2\n"}, {"input": "4\n6\n1 1 2 3 1 1\n5\n1 1 1 2 2\n8\n7 7 1 7 7 1 8 7\n10\n1 2 3 5 ...
code_stdio
[ { "content": "Monocarp has been collecting rare magazines for quite a while, and now he has decided to sell them. He distributed the magazines between $n$ boxes, arranged in a row. The $i$-th box contains $a_i$ magazines. Some of the boxes are covered with lids, others are not.\n\nSuddenly it started to rain, a...
[{"input": "9\n5\n01110\n10 5 8 9 6\n6\n011011\n20 10 9 30 20 19\n4\n0000\n100 100 100 100\n4\n0111\n5 4 5 1\n5\n01110\n10 5 8 9 6\n6\n011011\n20 10 9 30 20 19\n4\n0000\n100 100 100 100\n4\n0111\n5 4 5 1\n4\n0111\n5 4 5 1\n", "output": "27\n80\n0\n14\n27\n80\n0\n14\n14\n"}, {"input": "7\n6\n011011\n20 10 9 30 20 19\n6\...
code_stdio
[ { "content": "Analyzing the mistakes people make while typing search queries is a complex and an interesting work. As there is no guaranteed way to determine what the user originally meant by typing some query, we have to use different sorts of heuristics.\n\nPolycarp needed to write a code that could, given tw...
[{"input": "250\niiffiehchidfgigdbcciahdehjjfacbbaaadagaibjjcehjcbjdhaadebaejiicgidbhajfbfejcdicgfbcchgbahfccbefdcddbjjhejigiafhdjbiiehadfficicbebeeegcebideijidbgdecffeaegjfjbbcfiabfbaiddbjgidebdiccfcgfbcbbfhaejaibeicghecchjbiaceaibfgibhgcfgifiedcbhhfadhccfdhejeggcah\njbadcfjffcfabbecfabgcafgfcgfeffjjhhdaajjgcbgbechhia...
code_stdio
[ { "content": "You are given integer n. You have to arrange numbers from 1 to 2n, using each of them exactly once, on the circle, so that the following condition would be satisfied:\n\nFor every n consecutive numbers on the circle write their sum on the blackboard. Then any two of written on the blackboard 2n nu...
[{"input": "7015\n", "output": "YES\n1 4 5 8 9 12 13 16 17 20 21 24 25 28 29 32 33 36 37 40 41 44 45 48 49 52 53 56 57 60 61 64 65 68 69 72 73 76 77 80 81 84 85 88 89 92 93 96 97 100 101 104 105 108 109 112 113 116 117 120 121 124 125 128 129 132 133 136 137 140 141 144 145 148 149 152 153 156 157 160 161 164 165 168 1...
code_stdio
[ { "content": "There is a city that can be represented as a square grid with corner points in $(0, 0)$ and $(10^6, 10^6)$.\n\nThe city has $n$ vertical and $m$ horizontal streets that goes across the whole city, i. e. the $i$-th vertical streets goes from $(x_i, 0)$ to $(x_i, 10^6)$ and the $j$-th horizontal str...
[{"input": "2\n2 2 4\n0 1000000\n0 1000000\n1 0\n1000000 1\n717934 1000000\n0 999999\n5 4 9\n0 1 2 6 1000000\n0 4 8 1000000\n4 4\n1 3\n2 2\n6 3\n1000000 1\n3 8\n2 8\n10 8\n1 15\n", "output": "2\n7\n"}, {"input": "2\n2 2 4\n0 1000000\n0 1000000\n0 0\n1000000 0\n172846 1000000\n0 999999\n5 4 9\n0 1 2 6 1000000\n0 4 8 100...
code_stdio
[ { "content": "Everybody knows that opposites attract. That is the key principle of the \"Perfect Matching\" dating agency. The \"Perfect Matching\" matchmakers have classified each registered customer by his interests and assigned to the i-th client number ti ( - 10 ≤ ti ≤ 10). Of course, one number can be assi...
[{"input": "10\n1 -1 2 -2 3 -3 4 -4 0 0\n", "output": "5\n"}, {"input": "10\n1 -1 2 -2 3 -3 4 -5 0 0\n", "output": "4\n"}, {"input": "10\n1 -1 2 -1 1 -3 4 -5 0 0\n", "output": "5\n"}, {"input": "10\n1 -1 2 -1 3 -3 4 -5 0 0\n", "output": "4\n"}, {"input": "10\n1 0 3 -1 0 -3 4 -5 0 0\n", "output": "8\n"}, {"input": "10\n...
code_stdio
[ { "content": "There is a blackboard on which all integers from -10^{18} through 10^{18} are written, each of them appearing once. Takahashi will repeat the following sequence of operations any number of times he likes, possibly zero:\n\n* Choose an integer between 1 and N (inclusive) that is written on the blac...
[{"input": "123 35 678901234", "output": "410672012\n"}, {"input": "123 45 551859605", "output": "541684692\n"}, {"input": "123 37 551859605", "output": "197524002\n"}, {"input": "123 20 678901234", "output": "401663460\n"}, {"input": "34 13 360190222", "output": "235347591\n"}, {"input": "89 37 551859605", "output": "...
code_stdio
[ { "content": "Given are integers N and K.\nHow many quadruples of integers (a,b,c,d) satisfy both of the following conditions?\n - 1 \\leq a,b,c,d \\leq N\n - a+b-c-d=K\n\n-----Constraints-----\n - 1 \\leq N \\leq 10^5\n - -2(N-1) \\leq K \\leq 2(N-1)\n - All numbers in input are integers.\n\n-----Input-----\nI...
[{"input": "100000 -87789\n", "output": "234266710631140\n"}, {"input": "100000 -38560\n", "output": "546646229688720\n"}, {"input": "100000 51090\n", "output": "472325111688955\n"}, {"input": "100000 -8286\n", "output": "660085336344685\n"}, {"input": "97692 12674\n", "output": "606889464360839\n"}, {"input": "66977 7...
code_stdio
[ { "content": "In this Kata, you will be given an array of integers and your task is to return the number of arithmetic progressions of size `3` that are possible from that list. In each progression, the differences between the elements must be the same.\n\n```\n[1, 2, 3, 5, 7, 9] ==> 5\n// [1, 2, 3], [1, 3, 5],...
[{"input": "[0, 1, 4, 5, 7, 9, 10, 13, 15, 16, 18, 19]", "output": "[15]", "fn_name": "solve"}, {"input": "[0, 1, 2, 3, 5, 8, 11, 13, 14, 16, 18, 19]", "output": "[13]", "fn_name": "solve"}, {"input": "[0, 1, 2, 3, 5, 6, 7, 11, 13, 15, 17, 19]", "output": "[17]", "fn_name": "solve"}, {"input": "[0, 5, 8, 9, 11, 13, 14,...
code_functional
[ { "content": "Find the minimum number with the given sum of digits $s$ such that all digits in it are distinct (i.e. all digits are unique).\n\nFor example, if $s=20$, then the answer is $389$. This is the minimum number in which all digits are different and the sum of the digits is $20$ ($3+8+9=20$).\n\nFor th...
[{"input": "45\n45\n45\n45\n45\n45\n45\n45\n45\n45\n45\n45\n45\n45\n45\n45\n45\n45\n45\n45\n45\n45\n45\n45\n45\n45\n45\n45\n45\n45\n45\n45\n45\n45\n45\n45\n45\n45\n45\n45\n45\n45\n45\n45\n45\n45\n", "output": "123456789\n123456789\n123456789\n123456789\n123456789\n123456789\n123456789\n123456789\n123456789\n123456789\n...
code_stdio
[ { "content": "In Summer Informatics School, if a student doesn't behave well, teachers make a hole in his badge. And today one of the teachers caught a group of $n$ students doing yet another trick. \n\nLet's assume that all these students are numbered from $1$ to $n$. The teacher came to student $a$ and put a ...
[{"input": "100\n73 81 39 85 48 49 37 20 66 41 79 32 54 71 31 50 48 29 10 85 81 20 20 20 48 54 70 40 71 31 49 77 50 33 12 87 19 12 54 39 87 10 20 39 81 18 70 53 86 7 33 37 62 9 77 54 50 30 70 81 66 12 41 12 20 23 87 73 91 75 94 49 18 71 81 32 79 85 30 94 48 10 41 62 73 90 40 70 90 91 33 100 79 99 62 71 53 66 92 70\n", ...
code_stdio
[ { "content": "# Task\nAfter a long night (work, play, study) you find yourself sleeping on a bench in a park. As you wake up and try to figure out what happened you start counting trees.\n\nYou notice there are different tree sizes but there's always one size which is unbalanced. For example there are 2 size 2,...
[{"input": "[50, 408, 50, 50, 50, 50, 408, 408, 408, 680, 408, 680, 50, 408, 680, 50, 50, 680, 408, 680, 50, 680, 680, 408, 408, 50, 50, 408, 50, 50, 50, 50, 680, 408, 680, 50, 680, 408, 680, 408, 680, 50, 50, 50, 680, 50, 680, 408, 680, 680, 680, 408, 408, 408, 408, 680, 680, 50, 408, 408, 408, 50, 408, 408, 50, 680, ...
code_functional
[ { "content": "The only difference between easy and hard versions is constraints.\n\nA session has begun at Beland State University. Many students are taking exams.\n\nPolygraph Poligrafovich is going to examine a group of $n$ students. Students will take the exam one-by-one in order from $1$-th to $n$-th. Rules...
[{"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": "Polycarp is writing the prototype of a graphic editor. He has already made up his mind that the basic image transformations in his editor will be: rotate the image 90 degrees clockwise, flip the image horizontally (symmetry relative to the vertical line, that is, the right part of the image moves ...
[{"input": "9 20\n**.......\n****.....\n******...\n*******..\n..******.\n....****.\n......***\n*.....***\n*********\n*********\n*********\n*********\n....**...\n...****..\n..******.\n.********\n****..***\n***...***\n**.....**\n*.......*\n", "output": "********......**********........********\n********......**********.....
code_stdio
[ { "content": "Being tired of participating in too many Codeforces rounds, Gildong decided to take some rest in a park. He sat down on a bench, and soon he found two rabbits hopping around. One of the rabbits was taller than the other.\n\nHe noticed that the two rabbits were hopping towards each other. The posit...
[{"input": "5\n-1 10 0 3\n1 10 2 0\n900000000 1000000000 1 9999999\n0 2 1 2\n1 3 1 2\n", "output": "-1\n-1\n10\n-1\n-1\n"}, {"input": "5\n-1 1 0 3\n1 13 2 -1\n900000000 1000000000 1 2570333\n0 2 1 2\n1 3 1 2\n", "output": "-1\n12\n-1\n-1\n-1\n"}, {"input": "5\n0 10 -2 3\n1 10 3 2\n463681791 1000000000 1 9999999\n1 2 1 ...
code_stdio
[ { "content": "There are some rabbits in Singapore Zoo. To feed them, Zookeeper bought $n$ carrots with lengths $a_1, a_2, a_3, \\ldots, a_n$. However, rabbits are very fertile and multiply very quickly. Zookeeper now has $k$ rabbits and does not have enough carrots to feed all of them. To solve this problem, Zo...
[{"input": "54 42164\n810471 434523 262846 930807 148016 633714 247313 376546 142288 30094 599543 829013 182512 647950 512266 827248 452285 531124 257259 453752 114536 833190 737596 267349 598567 781294 390500 318098 354290 725051 978831 905185 849542 761886 55532 608148 631077 557070 355245 929381 280340 620004 285066...
code_stdio
[ { "content": "Consider all binary strings of length $m$ ($1 \\le m \\le 60$). A binary string is a string that consists of the characters 0 and 1 only. For example, 0110 is a binary string, and 012aba is not. Obviously, there are exactly $2^m$ such strings in total.\n\nThe string $s$ is lexicographically smalle...
[{"input": "5\n3 3\n010\n001\n111\n4 3\n000\n111\n100\n011\n1 1\n1\n1 1\n0\n3 2\n00\n01\n10\n", "output": "100\n010\n0\n1\n11\n"}, {"input": "5\n3 3\n010\n001\n110\n4 3\n000\n111\n100\n011\n1 1\n1\n1 1\n0\n3 2\n00\n01\n10\n", "output": "100\n010\n0\n1\n11\n"}, {"input": "5\n3 3\n010\n001\n101\n4 3\n000\n111\n100\n011\n...
code_stdio
[ { "content": "In some countries of former Soviet Union there was a belief about lucky tickets. A transport ticket of any sort was believed to posess luck if sum of digits on the left half of its number was equal to the sum of digits on the right half. Here are examples of such numbers:\n```\n003111 # ...
[{"input": "\"943294329932\"", "output": "[false]", "fn_name": "luck_check"}, {"input": "\"1233499943\"", "output": "[false]", "fn_name": "luck_check"}, {"input": "\"543970707\"", "output": "[false]", "fn_name": "luck_check"}, {"input": "\"439924\"", "output": "[false]", "fn_name": "luck_check"}, {"input": "\"935336\""...
code_functional
[ { "content": "In the official contest this problem has a different statement, for which jury's solution was working incorrectly, and for this reason it was excluded from the contest. This mistake have been fixed and the current given problem statement and model solution corresponds to what jury wanted it to be ...
[{"input": "20\n713900269 224495293 592111899 609607891 585084800 601258511 223103775 876894656 751583891 230837577 971499807 312977833 344314550 397998873 558637732 216574673 913028292 762852863 464376621 61315042\n", "output": "375537226\n"}, {"input": "20\n713900269 224495293 592111899 609607891 585084800 601258511 ...
code_stdio
[ { "content": "For given $n$ segments which are parallel to X-axis or Y-axis, find the number of intersections of them.\n\nConstraints\n\n* $1 \\leq n \\leq 100,000$\n* $ -1,000,000,000 \\leq x_1, y_1, x_2, y_2 \\leq 1,000,000,000$\n* Two parallel segments never overlap or touch.\n* The number of intersections $...
[{"input": "6\n2 2 2 5\n1 3 24 3\n4 2 4 4\n1 2 7 2\n1 1 11 1\n11 5 6 7", "output": "4\n"}, {"input": "6\n2 2 2 5\n1 3 24 3\n4 2 4 4\n1 2 7 2\n1 1 11 1\n11 5 5 7", "output": "4\n"}, {"input": "6\n2 2 2 5\n1 3 24 3\n4 2 4 4\n1 2 7 2\n1 1 11 1\n11 5 6 4", "output": "4\n"}, {"input": "6\n2 2 2 10\n1 3 5 3\n4 1 4 4\n2 2 12 ...
code_stdio
[ { "content": "You are given a prime number $p$, $n$ integers $a_1, a_2, \\ldots, a_n$, and an integer $k$. \n\nFind the number of pairs of indexes $(i, j)$ ($1 \\le i < j \\le n$) for which $(a_i + a_j)(a_i^2 + a_j^2) \\equiv k \\bmod p$.\n\n\n-----Input-----\n\nThe first line contains integers $n, p, k$ ($2 \\...
[{"input": "7 7 3\n4 0 5 3 1 2 6\n", "output": "0\n"}, {"input": "7 7 3\n4 0 5 3 1 2 6\n", "output": "0"}, {"input": "6 7 2\n1 2 3 4 5 6\n", "output": "3\n"}, {"input": "6 7 2\n1 2 3 4 5 6\n", "output": "3"}, {"input": "5 5 3\n3 0 4 1 2\n", "output": "1\n"}, {"input": "5 5 3\n3 0 4 1 2\n", "output": "1"}, {"input": "2 ...
code_stdio
[ { "content": "We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it.\nIt takes us A_i minutes to read the i-th book from the top on Desk A (1 \\leq i \\leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \\leq i \\leq M).\nConsider t...
[{"input": "5 4 1\n1000000000 1000000000 1000000000 1000000000 1000000000\n1000000000 1000000000 1000000000 1000000000\n", "output": "0\n"}, {"input": "5 4 1\n1000000000 1000000000 1000000000 1000000000 1000000000\n1000000000 1000000000 1000000010 1000000000", "output": "0\n"}, {"input": "5 4 1\n1000000000 1000000001 1...
code_stdio
[ { "content": "A soldier wants to buy w bananas in the shop. He has to pay k dollars for the first banana, 2k dollars for the second one and so on (in other words, he has to pay i·k dollars for the i-th banana). \n\nHe has n dollars. How many dollars does he have to borrow from his friend soldier to buy w banana...
[{"input": "1000 61465564 1000\n", "output": "439034436\n"}, {"input": "859 453892 543\n", "output": "126416972\n"}, {"input": "859 453892 889\n", "output": "339370803\n"}, {"input": "859 267939 889\n", "output": "339556756\n"}, {"input": "859 453892 543\n", "output": "126416972"}, {"input": "859 267939 418\n", "output...
code_stdio
[ { "content": "Vasya is a CEO of a big construction company. And as any other big boss he has a spacious, richly furnished office with two crystal chandeliers. To stay motivated Vasya needs the color of light at his office to change every day. That's why he ordered both chandeliers that can change its color cycl...
[{"input": "20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 100 13 43 90 86 7 20 87 88 59 49 80 82 40 18 9 1 2 67 12 15 83 79 16 22 56 35 60 102 85 28 65 8 6 46 39 25 48 65 47 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 34 97 11 34 73 51 89 68 32 74 42 30 4 131 76 ...
code_stdio
[ { "content": "Fox Ciel is playing a card game with her friend Jiro.\n\nJiro has n cards, each one has two attributes: position (Attack or Defense) and strength. Fox Ciel has m cards, each one has these two attributes too. It's known that position of all Ciel's cards is Attack.\n\nNow is Ciel's battle phase, Cie...
[{"input": "36 30\nATK 116\nATK 120\nATK 122\nATK 120\nATK 116\nATK 118\nATK 123\nDEF 2564\nATK 123\nDEF 1810\nATK 124\nATK 120\nDEF 2598\nATK 119\nDEF 2103\nATK 123\nATK 118\nATK 118\nATK 123\nDEF 1988\nATK 122\nATK 120\nDEF 2494\nATK 122\nATK 124\nATK 117\nATK 121\nATK 118\nATK 117\nATK 122\nATK 119\nATK 122\nDEF 248...
code_stdio
[ { "content": "# Task\nSome children are playing rope skipping game. Children skip the rope at roughly the same speed: `once per second`. If the child fails during the jump, he needs to tidy up the rope and continue. This will take `3 seconds`.\n\nYou are given an array `failedCount`, where each element is the j...
[{"input": "[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]", "output": "[30]", "fn_name": "tiaosheng"}, {"input": "[10, 20, 30, 40, 47, 60]", "output": "[47]", "fn_name": "tiaosheng"}, {"input": "[10, 20, 30, 40, 58]", "output": "[48]", "fn_name": "tiaosheng"}, {"input": "[10, 20, 30, 40]", "output": "[48]", "fn_name": "tiaosheng"}, ...
code_functional
[ { "content": "In Russia regular bus tickets usually consist of 6 digits. The ticket is called lucky when the sum of the first three digits equals to the sum of the last three digits. Write a function to find out whether the ticket is lucky or not. Return true if so, otherwise return false. Consider that input i...
[{"input": "\"12341234\"", "output": "[false]", "fn_name": "is_lucky"}, {"input": "\"100200\"", "output": "[false]", "fn_name": "is_lucky"}, {"input": "\"12a12a\"", "output": "[false]", "fn_name": "is_lucky"}, {"input": "\"123321\"", "output": "[true]", "fn_name": "is_lucky"}, {"input": "\"100001\"", "output": "[true]"...
code_functional
[ { "content": "While dad was at work, a little girl Tanya decided to play with dad's password to his secret database. Dad's password is a string consisting of n + 2 characters. She has written all the possible n three-letter continuous substrings of the password on pieces of paper, one for each piece of paper, a...
[{"input": "100\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa...
code_stdio
[ { "content": "You are given two strings $s$ and $t$. In a single move, you can choose any of two strings and delete the first (that is, the leftmost) character. After a move, the length of the string decreases by $1$. You can't choose a string if it is empty.\n\nFor example: by applying a move to the string \"...
[{"input": "lxuyspmieeuyxluv\ndfwxqvavzxctblaa\n", "output": "32\n"}, {"input": "lxuyspmieeuyxluv\naalbtcxzvavqxwfd\n", "output": "32\n"}, {"input": "kxuyspmieeuyxluv\naalbtcxzvavqxwfd\n", "output": "32\n"}, {"input": "vulxyueeimpsyuxk\naalbtcxzvavqxwfd\n", "output": "32\n"}, {"input": "vulxyueeimpsyuxk\naalbtcxyvavqxw...
code_stdio
[ { "content": "The only difference between easy and hard versions is the size of the input.\n\nYou are given a string $s$ consisting of $n$ characters, each character is 'R', 'G' or 'B'.\n\nYou are also given an integer $k$. Your task is to change the minimum number of characters in the initial string $s$ so tha...
[{"input": "3\n5 2\nBGGGG\n5 3\nRBRGR\n5 5\nBBBRR\n", "output": "1\n0\n3\n"}, {"input": "3\n5 2\nBGGGG\n5 3\nRBRGR\n5 5\nBBRBR\n", "output": "1\n0\n2\n"}, {"input": "3\n5 3\nBGGGG\n5 3\nRBRGR\n5 5\nBBBRR\n", "output": "1\n0\n3\n"}, {"input": "3\n5 2\nBGGGG\n5 4\nRBRGR\n5 5\nBBRBR\n", "output": "1\n1\n2\n"}, {"input": "...
code_stdio
[ { "content": "You are given an array $a$ consisting of $500000$ integers (numbered from $1$ to $500000$). Initially all elements of $a$ are zero.\n\nYou have to process two types of queries to this array: $1$ $x$ $y$ — increase $a_x$ by $y$; $2$ $x$ $y$ — compute $\\sum\\limits_{i \\in R(x, y)} a_i$, where $R...
[{"input": "5\n1 3 4\n2 3 0\n2 4 3\n1 500000 1\n2 800 0\n", "output": "4\n4\n1\n"}, {"input": "5\n1 3 4\n2 3 0\n2 4 3\n1 500000 1\n2 800 0\n", "output": "4\n4\n1\n"}, {"input": "5\n1 3 4\n2 3 0\n2 4 3\n1 4 -4\n2 1 0\n", "output": "4\n4\n0\n"}, {"input": "5\n1 3 4\n2 3 0\n2 4 3\n1 4 -4\n2 1 0\n", "output": "4\n4\n0\n"},...
code_stdio
[ { "content": "A ball will bounce along a number line, making N + 1 bounces. It will make the first bounce at coordinate D_1 = 0, and the i-th bounce (2 \\leq i \\leq N+1) at coordinate D_i = D_{i-1} + L_{i-1}.\nHow many times will the ball make a bounce where the coordinate is at most X?\n\n-----Constraints----...
[{"input": "100 10000\n100 29 69 46 30 75 24 30 98 20 27 23 76 2 3 5 62 52 79 84 28 62 29 23 36 53 66 3 78 63 85 74 37 8 88 34 79 62 54 5 73 56 94 89 36 85 93 81 34 86 39 28 77 99 13 78 59 56 63 9 13 88 38 38 55 76 93 35 48 45 88 59 69 30 66 53 17 84 30 34 78 92 77 38 86 74 7 38 6 93 66 66 14 59 73 14 41 10 27 53\n", "...
code_stdio
[ { "content": "There is a building consisting of $10~000$ apartments numbered from $1$ to $10~000$, inclusive.\n\nCall an apartment boring, if its number consists of the same digit. Examples of boring apartments are $11, 2, 777, 9999$ and so on.\n\nOur character is a troublemaker, and he calls the intercoms of a...
[{"input": "36\n9999\n9999\n9999\n9999\n9999\n9999\n9999\n9999\n9999\n9999\n9999\n9999\n9999\n9999\n9999\n9999\n9999\n9999\n9999\n9999\n9999\n9999\n9999\n9999\n9999\n9999\n9999\n9999\n9999\n9999\n9999\n9999\n9999\n9999\n9999\n9999\n", "output": "90\n90\n90\n90\n90\n90\n90\n90\n90\n90\n90\n90\n90\n90\n90\n90\n90\n90\n90...
code_stdio
[ { "content": "Mahmoud wrote a message s of length n. He wants to send it as a birthday present to his friend Moaz who likes strings. He wrote it on a magical paper but he was surprised because some characters disappeared while writing the string. That's because this magical paper doesn't allow character number ...
[{"input": "55\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000\n", "output": "383381198\n55\n1\n"}, {"input": "55\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n1000 100...
code_stdio
[ { "content": "Create a function that interprets code in the esoteric language **Poohbear**\n\n## The Language\n\nPoohbear is a stack-based language largely inspired by Brainfuck. It has a maximum integer value of 255, and 30,000 cells. The original intention of Poohbear was to be able to send messages that woul...
[{"input": "\"+LTQII>+WN<P>+E\"", "output": "[\"1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94...
code_functional
[ { "content": "If this challenge is too easy for you, check out: \nhttps://www.codewars.com/kata/5cc89c182777b00001b3e6a2\n\n___\n\nUpside-Down Pyramid Addition is the process of taking a list of numbers and consecutively adding them together until you reach one number.\n\nWhen given the numbers `2, 1, 1` the fo...
[{"input": "[101, 57, 29, 13, 6]", "output": "[[1, 3, 9, 7, 6]]", "fn_name": "reverse"}, {"input": "[84, 42, 21, 10, 2]", "output": "[[4, 7, 3, 8, 2]]", "fn_name": "reverse"}, {"input": "[83, 47, 28, 16, 7]", "output": "[[6, 4, 3, 9, 7]]", "fn_name": "reverse"}, {"input": "[66, 39, 25, 15, 7]", "output": "[[7, 2, 2, 8,...
code_functional
[ { "content": "ATM machines allow 4 or 6 digit PIN codes and PIN codes cannot contain anything but **exactly** 4 digits or exactly 6 digits. \n\nIf the function is passed a valid PIN string, return `true`, else return `false`.\n\n## Examples \n```\n\"1234\" --> true\n\"12345\" --> false\n\"a234\" --> fal...
[{"input": "\"00000000\"", "output": "[false]", "fn_name": "validate_pin"}, {"input": "\"1234567\"", "output": "[false]", "fn_name": "validate_pin"}, {"input": "\"-12345\"", "output": "[false]", "fn_name": "validate_pin"}, {"input": "\"12345\"", "output": "[false]", "fn_name": "validate_pin"}, {"input": "\"-1234\"", "o...
code_functional
[ { "content": "In this Kata, you will be given an integer `n` and your task will be to return `the largest integer that is <= n and has the highest digit sum`.\n\nFor example:\n```\nsolve(100) = 99. Digit Sum for 99 = 9 + 9 = 18. No other number <= 100 has a higher digit sum.\nsolve(10) = 9\nsolve(48) = 48. Note...
[{"input": "999999999992", "output": "[999999999989]", "fn_name": "solve"}, {"input": "79320", "output": "[78999]", "fn_name": "solve"}, {"input": "99004", "output": "[98999]", "fn_name": "solve"}, {"input": "99088", "output": "[98999]", "fn_name": "solve"}, {"input": "99737", "output": "[98999]", "fn_name": "solve"}, ...
code_functional
[ { "content": "Bertown is a city with $n$ buildings in a straight line.\n\nThe city's security service discovered that some buildings were mined. A map was compiled, which is a string of length $n$, where the $i$-th character is \"1\" if there is a mine under the building number $i$ and \"0\" otherwise.\n\nBerto...
[{"input": "2\n1 1\n01000010\n10 1\n01101110\n", "output": "2\n11\n"}, {"input": "2\n2 1\n11000110\n10 1\n01101111\n", "output": "4\n11\n"}, {"input": "2\n1 1\n01010010\n10 1\n01101100\n", "output": "3\n11\n"}, {"input": "2\n2 1\n10000110\n12 1\n01101111\n", "output": "4\n13\n"}, {"input": "2\n4 1\n10000110\n12 1\n0110...
code_stdio
[ { "content": "There are n beacons located at distinct positions on a number line. The i-th beacon has position a_{i} and power level b_{i}. When the i-th beacon is activated, it destroys all beacons to its left (direction of decreasing coordinates) within distance b_{i} inclusive. The beacon itself is not destr...
[{"input": "11\n110 90\n100 70\n148 10\n80 10\n70 1\n60 1\n50 10\n40 1\n30 1\n10 1\n20 1\n", "output": "5\n"}, {"input": "11\n110 90\n100 70\n90 10\n80 10\n70 1\n60 1\n50 10\n40 1\n30 1\n10 1\n20 1\n", "output": "4\n"}, {"input": "11\n110 61\n100 70\n90 10\n80 10\n70 1\n60 1\n50 10\n40 1\n30 1\n10 1\n20 1\n", "output":...
code_stdio
[ { "content": "Polycarp is playing a new computer game. This game has $n$ stones in a row. The stone on the position $i$ has integer power $a_i$. The powers of all stones are distinct.\n\nEach turn Polycarp can destroy either stone on the first position or stone on the last position (in other words, either the l...
[{"input": "1\n52\n1 3 3 4 5 10 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 48 29 30 31 32 49 34 35 36 37 38 39 40 41 42 43 21 45 46 47 48 49 50 51 52\n", "output": "2\n"}, {"input": "1\n52\n1 3 3 4 5 10 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 48 29 30 31 32 49 34 35 36 37 38 39 40 4...
code_stdio
[ { "content": "Anton likes to listen to fairy tales, especially when Danik, Anton's best friend, tells them. Right now Danik tells Anton a fairy tale:\n\n\"Once upon a time, there lived an emperor. He was very rich and had much grain. One day he ordered to build a huge barn to put there all his grain. Best build...
[{"input": "1000000000000000000 1000000000000000000\n", "output": "1000000000000000000\n"}, {"input": "1000000000000000000 1000000000000000000\n", "output": "1000000000000000000\n"}, {"input": "1000000000000000000 1100000000000000000\n", "output": "1000000000000000000\n"}, {"input": "1000000000000000000 999999999999999...
code_stdio
[ { "content": "There are N people living on a number line.\nThe i-th person lives at coordinate X_i.\nYou are going to hold a meeting that all N people have to attend.\nThe meeting can be held at any integer coordinate. If you choose to hold the meeting at coordinate P, the i-th person will spend (X_i - P)^2 poi...
[{"input": "100\n1 1 1 100 100 1 100 1 100 100 100 1 100 1 1 1 100 1 100 100 100 1 1 100 100 100 100 100 100 1 1 100 100 100 100 100 1 100 1 1 1 100 100 100 1 100 1 100 100 1 1 1 1 1 1 100 1 1 100 1 1 1 100 100 1 1 100 100 100 100 100 1 100 1 1 100 1 1 1 100 1 100 100 100 1 1 1 100 1 1 100 100 100 1 1 100 1 1 1 100\n",...
code_stdio
[ { "content": "We have sticks numbered 1, \\cdots, N. The length of Stick i (1 \\leq i \\leq N) is L_i.\nIn how many ways can we choose three of the sticks with different lengths that can form a triangle?\nThat is, find the number of triples of integers (i, j, k) (1 \\leq i < j < k \\leq N) that satisfy both of ...
[{"input": "100\n881431527 881431559 881431575 881431571 881431526 881431580 881431549 881431529 881431564 881431494 881431507 881431558 881431512 881431531 881431553 881431578 881431557 881431581 881431548 881431565 881431587 881431534 881431533 881431542 881431505 881431500 881431525 881431545 881431570 881431519 881...
code_stdio
[ { "content": "You are given four integers $n$, $c_0$, $c_1$ and $h$ and a binary string $s$ of length $n$.\n\nA binary string is a string consisting of characters $0$ and $1$.\n\nYou can change any character of the string $s$ (the string should be still binary after the change). You should pay $h$ coins for eac...
[{"input": "7\n10 3 1 1\n1000000110\n1 10 1 1000\n0\n1 1 10 2\n1\n4 4 4 1\n1001\n1 1 1 1\n1\n2 1000 500 1000\n11\n3 500 500 1\n101\n", "output": "17\n10\n3\n16\n1\n1000\n1500\n"}, {"input": "7\n10 3 1 1\n1000000110\n1 10 1 1000\n0\n1 1 10 2\n1\n4 4 4 1\n1001\n1 1 1 1\n1\n2 1000 500 1000\n11\n3 500 500 1\n101\n", "outpu...
code_stdio
[ { "content": "You are given an array a of length n.\n\nLet's define the eversion operation. Let x = a_n. Then array a is partitioned into two parts: left and right. The left part contains the elements of a that are not greater than x (≤ x). The right part contains the elements of a that are strictly greater tha...
[{"input": "3\n5\n0 4 1 5 3\n5\n10 3 0 4 1\n2\n1 1 1 1\n", "output": "1\n2\n0\n"}, {"input": "3\n5\n0 4 1 5 3\n5\n10 3 0 5 1\n2\n1 1 1 1\n", "output": "1\n2\n0\n"}, {"input": "3\n5\n2 4 1 5 3\n5\n5 3 2 0 1\n4\n1 1 1 1\n", "output": "1\n3\n0\n"}, {"input": "3\n5\n2 4 1 5 3\n5\n5 3 2 4 1\n2\n1 1 1 1\n", "output": "1\n2\n...
code_stdio
[ { "content": "You've got an array, consisting of n integers a_1, a_2, ..., a_{n}. Also, you've got m queries, the i-th query is described by two integers l_{i}, r_{i}. Numbers l_{i}, r_{i} define a subsegment of the original array, that is, the sequence of numbers a_{l}_{i}, a_{l}_{i} + 1, a_{l}_{i} + 2, ..., a...
[{"input": "100 10\n53 72 2 58 6 48 65 13 43 9 77 1 58 28 49 95 12 11 7 36 51 25 78 20 6 2 69 76 1 47 17 6 91 54 50 66 69 122 74 31 19 96 35 84 163 15 65 73 66 73 29 53 17 47 3 19 4 16 85 6 49 6 57 70 96 19 66 92 86 61 10 21 11 82 13 98 59 96 85 1 13 65 28 34 143 16 88 32 60 50 33 37 36 57 97 28 18 23 30 70\n25 43\n20 ...
code_stdio
[ { "content": "Problem\n\nGiven the string S, which consists of lowercase letters and numbers. Follow the steps below to compress the length of string S.\n\n1. Change the order of the characters in the character string to any order.\nExample: \"0ig3he12fz99\"-> \"efghiz012399\"\n2. Perform the following operatio...
[{"input": "0ig3hd12fz99", "output": "10\n"}, {"input": "0hg3hd12fz99", "output": "11\n"}, {"input": "0hg3hd13fz99", "output": "12\n"}, {"input": "0hf3hd12fz99", "output": "11\n"}, {"input": "99zf21dh3fh0", "output": "11\n"}, {"input": "0hfdh312fz99", "output": "11\n"}, {"input": "0gfdh312fz99", "output": "11\n"}, {"in...
code_stdio
[ { "content": "Based on [this kata, Connect Four.](https://www.codewars.com/kata/connect-four-1)\n\nIn this kata we play a modified game of connect four. It's connect X, and there can be multiple players.\n\nWrite the function ```whoIsWinner(moves,connect,size)```.\n\n```2 <= connect <= 10```\n\n```2 <= size <= ...
[{"input": "[\"C_R\", \"p_Y\", \"a_B\", \"Q_T\", \"s_S\", \"I_R\", \"Z_Y\", \"a_B\", \"c_T\", \"d_S\", \"O_R\", \"C_Y\", \"M_B\", \"Q_T\", \"O_S\", \"I_R\", \"U_Y\", \"J_B\", \"K_T\", \"V_S\", \"i_R\", \"o_Y\", \"r_B\", \"H_T\", \"I_S\", \"C_R\", \"n_Y\", \"W_B\", \"G_T\", \"j_S\", \"p_R\", \"m_Y\", \"Y_B\", \"b_T\", \...
code_functional
[ { "content": "Vasya owns three big integers — $a, l, r$. Let's define a partition of $x$ such a sequence of strings $s_1, s_2, \\dots, s_k$ that $s_1 + s_2 + \\dots + s_k = x$, where $+$ is a concatanation of strings. $s_i$ is the $i$-th element of the partition. For example, number $12345$ has the following pa...
[{"input": "12212222221212222221221221222222121222222122\n22222111112222222222221221222222121222222122\n22222111112222222222221221222222121222222122\n", "output": "0\n"}, {"input": "12212222221212222221221221222222121222222122\n28110439567417001223290131317494419039608149\n22222111112222222222221221222222121222222122\n...
code_stdio
[ { "content": "Memory and his friend Lexa are competing to get higher score in one popular computer game. Memory starts with score a and Lexa starts with score b. In a single turn, both Memory and Lexa get some integer in the range [ - k;k] (i.e. one integer among - k, - k + 1, - k + 2, ..., - 2, - 1, 0, 1,...
[{"input": "87 100 200 80\n", "output": " 913761305\n"}, {"input": "38 38 701 74\n", "output": " 496603581\n"}, {"input": "40 94 510 53\n", "output": " 233079...
code_stdio
[ { "content": "Chef likes strings a lot but he likes palindromic strings more. Today, Chef has two strings A and B, each consisting of lower case alphabets.\n\nChef is eager to know whether it is possible to choose some non empty strings s1 and s2 where s1 is a substring of A, s2 is a substring of B such that s1...
[{"input": "3\nabc\nabc\nb\nb\nabba\nbaab", "output": "Yes\nYes\nYes\n"}, {"input": "3\nabb\nabc\nb\nb\nabba\nbaab", "output": "Yes\nYes\nYes\n"}, {"input": "3\nabb\ncba\nb\nb\nabba\nbaab", "output": "Yes\nYes\nYes\n"}, {"input": "3\nbba\ncba\nb\nb\nabba\nbaab", "output": "Yes\nYes\nYes\n"}, {"input": "3\nbba\ncba\nb\n...
code_stdio