task_type
stringclasses
1 value
problem
stringlengths
209
3.39k
answer
stringlengths
35
6.15k
problem_tokens
int64
60
774
answer_tokens
int64
12
2.04k
coding
Solve the programming task below in a Python markdown code block. You are using at most A number of 1s and at most B number of 2s. How many different evaluation results are possible when they are formed in an expression containing only addition + sign and multiplication * sign are allowed? Note that, multiplication ta...
{"inputs": ["4\n0 0\n2 2\n0 2\n2 0\n"], "outputs": ["0\n6\n2\n2\n"]}
496
36
coding
Solve the programming task below in a Python markdown code block. Chef considers a string consisting of lowercase English alphabets *beautiful* if all the characters of the string are vowels. Chef has a string S consisting of lowercase English alphabets, of length N. He wants to convert S into a *beautiful* string T....
{"inputs": ["4\n5\naeiou\n5\nabcde\n8\nstarters\n8\ncodechef\n"], "outputs": ["1\n2\n4\n4"]}
574
40
coding
Solve the programming task below in a Python markdown code block. Gerald has been selling state secrets at leisure. All the secrets cost the same: n marks. The state which secrets Gerald is selling, has no paper money, only coins. But there are coins of all positive integer denominations that are powers of three: 1 mar...
{"inputs": ["1\n", "4\n", "3\n", "8\n", "2\n", "3\n", "8\n", "2\n"], "outputs": ["1\n", "2\n", "1\n", "3\n", "1\n", " 1", " 3", " 1"]}
492
73
coding
Solve the programming task below in a Python markdown code block. Write a program which reads an directed graph $G = (V, E)$, and finds the shortest distance from vertex $1$ to each vertex (the number of edges in the shortest path). Vertices are identified by IDs $1, 2, ... n$. Constraints * $1 \leq n \leq 100$ Inpu...
{"inputs": ["4\n1 2 1 4\n2 1 4\n3 0\n4 1 3", "4\n1 2 1 4\n2 1 4\n3 0\n4 1 4", "4\n1 2 2 4\n2 1 4\n3 0\n4 1 1", "4\n1 2 2 4\n2 1 1\n3 0\n4 1 3", "4\n1 2 1 1\n2 1 4\n3 0\n4 1 4", "4\n1 2 2 1\n2 1 1\n3 0\n4 1 3", "4\n1 2 1 4\n3 1 4\n3 0\n4 1 2", "4\n1 2 1 3\n0 1 1\n4 0\n4 1 1"], "outputs": ["1 0\n2 -1\n3 2\n4 1\n", "1 0\n...
303
366
coding
Solve the programming task below in a Python markdown code block. Tsetso likes to play with arrays. An Array A[1,2,\ldots,N] is said to be a Tsetso array if A[1] \cdot A[N] = max(A_{1},A_{2},\ldots,A_{N-1},A_{N}). Bedo, his teammate, likes to solve problems so much, so Tsetso gave him an array A of N \bf{distinct} i...
{"inputs": ["1\n7 3\n3 6 24 4 1 8 2\n1 7\n2 5\n4 7"], "outputs": ["7\n4\n4"]}
648
47
coding
Solve the programming task below in a Python markdown code block. "Duel!" Betting on the lovely princess Claris, the duel between Tokitsukaze and Quailty has started. There are $n$ cards in a row. Each card has two sides, one of which has color. At first, some of these cards are with color sides facing up and others ...
{"inputs": ["1 1\n1\n", "1 1\n0\n", "1 1\n1\n", "1 1\n0\n", "2 1\n11\n", "2 1\n00\n", "2 2\n01\n", "2 1\n10\n"], "outputs": ["tokitsukaze\n", "tokitsukaze\n", "tokitsukaze\n", "tokitsukaze\n", "tokitsukaze\n", "tokitsukaze\n", "tokitsukaze\n", "tokitsukaze\n"]}
603
130
coding
Solve the programming task below in a Python markdown code block. Chef is planning a huge party for all of you and has ordered M pizzas. He wants to invite as many people to the party. However, he knows that everyone will have exactly one slice of a pizza (regardless of the size) and he wants to make sure that he has e...
{"inputs": ["5 10\n1 2 3 4 5\n"], "outputs": ["31"]}
386
27
coding
Solve the programming task below in a Python markdown code block. Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$. Yui loves sweets, but she can eat at most $m$ sweets each day for health rea...
{"inputs": ["1 1\n7\n", "1 1\n7\n", "2 1\n6052 42201\n", "2 1\n6052 44516\n", "2 1\n6052 17658\n", "2 2\n51200 19970\n", "2 2\n51200 19970\n", "2 1\n70563 22973\n"], "outputs": ["7\n", "7\n", "6052 54305 \n", "6052 56620 \n", "6052 29762 \n", "19970 71170\n", "19970 71170\n", "22973 116509 \n"]}
611
221
coding
Solve the programming task below in a Python markdown code block. Little girl Tanya is learning how to decrease a number by one, but she does it wrong with a number consisting of two or more digits. Tanya subtracts one from a number by the following algorithm: if the last digit of the number is non-zero, she decreases...
{"inputs": ["5 2\n", "2 1\n", "2 1\n", "5 2\n", "2 0\n", "9 2\n", "3 2\n", "3 0\n"], "outputs": ["3\n", "1\n", "1\n", "3\n", "2\n", "7\n", "1\n", "3\n"]}
326
86
coding
Solve the programming task below in a Python markdown code block. # Let's play Psychic A box contains green, red, and blue balls. The total number of balls is given by `n` (`0 < n < 50`). Each ball has a mass that depends on the ball color. Green balls weigh `5kg`, red balls weigh `4kg`, and blue balls weigh `3kg`. ...
{"functional": "_inputs = [[3, 12], [40, 180], [30, 130], [32, 148], [18, 80], [18, 74], [50, 180], [50, 172]]\n_outputs = [[[[0, 3, 0], [1, 1, 1]]], [[[20, 20, 0], [21, 18, 1], [22, 16, 2], [23, 14, 3], [24, 12, 4], [25, 10, 5], [26, 8, 6], [27, 6, 7], [28, 4, 8], [29, 2, 9], [30, 0, 10]]], [[[10, 20, 0], [11, 18, 1],...
318
1,001
coding
Solve the programming task below in a Python markdown code block. Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well. Chef has a combination lock with $N$ wheels (numbered $1$ through $N$). For each valid $i$, on the $i$-th wheel, the integers from $0$ to $A_{i}$ (in...
{"inputs": ["3\n2\n2 2\n2\n5 5\n3\n3 4 5"], "outputs": ["443664157\n221832079\n598946612"]}
718
60
coding
Solve the programming task below in a Python markdown code block. Write a function that accepts two square matrices (`N x N` two dimensional arrays), and return the sum of the two. Both matrices being passed into the function will be of size `N x N` (square), containing only integers. How to sum two matrices: Take ea...
{"functional": "_inputs = [[[[1, 2, 3], [3, 2, 1], [1, 1, 1]], [[2, 2, 1], [3, 2, 3], [1, 1, 3]]], [[[1, 2], [1, 2]], [[2, 3], [2, 3]]], [[[1]], [[2]]]]\n_outputs = [[[[3, 4, 4], [6, 4, 4], [2, 2, 4]]], [[[3, 5], [3, 5]]], [[[3]]]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b...
265
283
coding
Solve the programming task below in a Python markdown code block. Kakarot and Vegeta are both training their sons Goten and Trunks as only they can defeat Beerus. To train them, Kakarot lays out an undirected graph where each node is connected to every other node (even to itself). Each node also has a weight, which is ...
{"inputs": ["1\n2\n4 5 \n5 6"], "outputs": ["5"]}
735
24
coding
Solve the programming task below in a Python markdown code block. A recent lab accident resulted in the creation of an extremely dangerous virus that replicates so rapidly it's hard to predict exactly how many cells it will contain after a given period of time. However, a lab technician made the following observations ...
{"inputs": ["2 4 1\n"], "outputs": ["3\n"]}
430
18
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. A stepping number is an integer such that all of its adjacent digits have an absolute difference of exactly 1. For example, 321 is a stepping number while 421 is not. Given two integers low and high, return a sorted...
{"functional": "def check(candidate):\n assert candidate(low = 0, high = 21) == [0,1,2,3,4,5,6,7,8,9,10,12,21]\n\n\ncheck(Solution().countSteppingNumbers)"}
120
67
coding
Solve the programming task below in a Python markdown code block. itertools.product() This tool computes the cartesian product of input iterables. It is equivalent to nested for-loops. For example, product(A, B) returns the same as ((x,y) for x in A for y in B). Sample Code >>> from itertools import product >>...
{"inputs": [" 1 2\n 3 4\n"], "outputs": [" (1, 3) (1, 4) (2, 3) (2, 4)\n"]}
707
45
coding
Solve the programming task below in a Python markdown code block. In Chef's house there are N apples lying in a row on the floor. These apples are numbered from 1 (left most one) to N (right most one). The types of apples are also numbered by positive integers, and the type of apple i is Ti. Chef has recently brought t...
{"inputs": ["5 5\n2 4 3 2 1", "5 5\n2 4 9 2 5", "5 8\n2 4 3 2 1", "5 5\n2 4 3 4 1", "5 8\n2 4 5 3 1", "4 5\n2 4 3 3 1", "3 5\n2 4 9 2 5", "5 8\n2 4 3 3 1"], "outputs": ["2", "-1", "-1\n", "2\n", "3\n", "1\n", "-1\n", "-1\n"]}
619
156
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. Given a string s, encode the string such that its encoded length is the shortest. The encoding rule is: k[encoded_string], where the encoded_string inside the square brackets is being repeated exactly k times. k shoul...
{"functional": "def check(candidate):\n assert candidate(s = \"aaa\") == \"aaa\"\n assert candidate(s = \"aaaaa\") == \"5[a]\"\n assert candidate(s = \"aaaaaaaaaa\") == \"10[a]\"\n assert candidate(s = \"aabcaabcd\") == \"2[aabc]d\"\n assert candidate(s = \"abbbabbbcabbbabbbc\") == \"2[2[abbb]c]\"\n\n\nc...
123
111
coding
Solve the programming task below in a Python markdown code block. You're laying out a rad pixel art mural to paint on your living room wall in homage to [Paul Robertson](http://68.media.tumblr.com/0f55f7f3789a354cfcda7c2a64f501d1/tumblr_o7eq3biK9s1qhccbco1_500.png), your favorite pixel artist. You want your work to be...
{"functional": "_inputs = [[4050, 27], [4066, 27], [10000, 20], [10005, 20]]\n_outputs = [[True], [False], [True], [False]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return math.isclose(a, b, rel_tol=tol, abs_tol=tol)\n if isinstance(a, (list, tuple)):...
524
203
coding
Solve the programming task below in a Python markdown code block. A tourist hiked along the mountain range. The hike lasted for n days, during each day the tourist noted height above the sea level. On the i-th day height was equal to some integer h_{i}. The tourist pick smooth enough route for his hike, meaning that th...
{"inputs": ["1 1\n1 2\n", "1 1\n1 5\n", "1 1\n1 2\n", "1 1\n1 5\n", "1 1\n1 7\n", "4 1\n1 0\n", "1 1\n1 0\n", "2 1\n1 0\n"], "outputs": ["2\n", "5\n", "2", "5", "7\n", "3\n", "0\n", "1\n"]}
560
116
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. A permutation perm of n + 1 integers of all the integers in the range [0, n] can be represented as a string s of length n where: s[i] == 'I' if perm[i] < perm[i + 1], and s[i] == 'D' if perm[i] > perm[i + 1]. Given ...
{"functional": "def check(candidate):\n assert candidate(s = \"IDID\") == [0,4,1,3,2]\n assert candidate(s = \"III\") == [0,1,2,3]\n assert candidate(s = \"DDI\") == [3,2,0,1]\n\n\ncheck(Solution().diStringMatch)"}
146
81
coding
Solve the programming task below in a Python markdown code block. You are given three strings A, B and C. Check whether they form a word chain. More formally, determine whether both of the following are true: - The last character in A and the initial character in B are the same. - The last character in B and the init...
{"inputs": ["a a `", "a b a", "a b `", "b a a", "b a b", "c a b", "c b b", "c b a"], "outputs": ["NO\n", "NO\n", "NO\n", "NO\n", "NO\n", "NO\n", "NO\n", "NO\n"]}
201
78
coding
Solve the programming task below in a Python markdown code block. Let's call a list of positive integers $a_0, a_1, ..., a_{n-1}$ a power sequence if there is a positive integer $c$, so that for every $0 \le i \le n-1$ then $a_i = c^i$. Given a list of $n$ positive integers $a_0, a_1, ..., a_{n-1}$, you are allowed to...
{"inputs": ["3\n1 3 2\n", "3\n2 3 1\n", "3\n1 3 2\n", "4\n5 5 5 5\n", "4\n5 5 5 5\n", "4\n3 1 5 5\n", "4\n5 1 5 8\n", "4\n1 3 8 64\n"], "outputs": ["1\n", "1\n", "1\n", "11\n", "11\n", "5\n", "4\n", "9\n"]}
468
131
coding
Solve the programming task below in a Python markdown code block. Each floating-point number should be formatted that only the first two decimal places are returned. You don't need to check whether the input is a valid number because only valid numbers are used in the tests. Don't round the numbers! Just cut them af...
{"functional": "_inputs = [[10.1289767789], [-7488.83485834983], [4.653725356]]\n_outputs = [[10.12], [-7488.83], [4.65]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return math.isclose(a, b, rel_tol=tol, abs_tol=tol)\n if isinstance(a, (list, tuple)):\n...
171
218
coding
Solve the programming task below in a Python markdown code block. Vasya has got an array consisting of $n$ integers, and two integers $k$ and $len$ in addition. All numbers in the array are either between $1$ and $k$ (inclusive), or equal to $-1$. The array is good if there is no segment of $len$ consecutive equal numb...
{"inputs": ["1 100 1\n-1\n", "1 100 1\n-1\n", "1 100 2\n-1\n", "1 010 4\n-1\n", "1 100 4\n-1\n", "1 000 2\n-1\n", "1 000 4\n-1\n", "1 010 2\n-1\n"], "outputs": ["0\n", "0\n", "100", "10", "100", "0", "0", "10"]}
474
142
coding
Solve the programming task below in a Python markdown code block. Monocarp has got two strings $s$ and $t$ having equal length. Both strings consist of lowercase Latin letters "a" and "b". Monocarp wants to make these two strings $s$ and $t$ equal to each other. He can do the following operation any number of times: ...
{"inputs": ["1\na\nb\n", "1\nb\nb\n", "1\nb\nb\n", "1\na\na\n", "1\nb\na\n", "1\na\nb\n", "2\nbb\nbb\n", "2\nab\nba\n"], "outputs": ["-1\n", "0\n", "0\n", "0\n", "-1\n", "-1\n", "0\n", "2\n1 1\n1 2\n"]}
504
111
coding
Solve the programming task below in a Python markdown code block. Reverse every other word in a given string, then return the string. Throw away any leading or trailing whitespace, while ensuring there is exactly one space between each word. Punctuation marks should be treated as if they are a part of the word in this ...
{"functional": "_inputs = [['Did it work?'], ['I really hope it works this time...'], ['Reverse this string, please!'], ['Have a beer'], [' '], ['This is not a test '], ['This is a test ']]\n_outputs = [['Did ti work?'], ['I yllaer hope ti works siht time...'], ['Reverse siht string, !esaelp'], ['Have a beer']...
87
249
coding
Solve the programming task below in a Python markdown code block. In this task you have to code process planner. You will be given initial thing, target thing and a set of processes to turn one thing into another (in the form of _[process\_name, start\_thing, end\_thing]_). You must return names of shortest sequence ...
{"functional": "_inputs = [['a', 'c', [['1', 'a', 'c'], ['2', 'a', 'b'], ['3', 'b', 'c']]], ['a', 'd', [['1', 'a', 'b'], ['2', 'b', 'c'], ['3', 'c', 'b']]], ['a', 'd', [['1', 'a', 'b'], ['2', 'b', 'c'], ['3', 'c', 'b'], ['4', 'c', 'd']]]]\n_outputs = [[['1']], [[]], [['1', '2', '4']]]\nimport math\ndef _deep_eq(a, b, t...
241
275
coding
Solve the programming task below in a Python markdown code block. Pupils decided to go to amusement park. Some of them were with parents. In total, n people came to the park and they all want to get to the most extreme attraction and roll on it exactly once. Tickets for group of x people are sold on the attraction, th...
{"inputs": ["1 2 2\n1\n", "1 2 2\n1\n", "1 4 2\n1\n", "1 6 2\n1\n", "1 2 4\n1\n", "1 4 0\n1\n", "1 6 1\n1\n", "1 2 5\n1\n"], "outputs": ["2\n", "2\n", "4\n", "6\n", "2\n", "4\n", "6\n", "2\n"]}
539
118
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. You are given an n x n binary matrix grid where 1 represents land and 0 represents water. An island is a 4-directionally connected group of 1's not connected to any other 1's. There are exactly two islands in grid. Yo...
{"functional": "def check(candidate):\n assert candidate(grid = [[0,1],[1,0]]) == 1\n assert candidate(grid = [[0,1,0],[0,0,0],[0,0,1]]) == 2\n assert candidate(grid = [[1,1,1,1,1],[1,0,0,0,1],[1,0,1,0,1],[1,0,0,0,1],[1,1,1,1,1]]) == 1\n\n\ncheck(Solution().shortestBridge)"}
138
126
coding
Solve the programming task below in a Python markdown code block. Correct this code so that it takes one argument, `x`, and returns "`x` is more than zero" if `x` is positive (and nonzero), and otherwise, returns "`x` is equal to or less than zero." In both cases, replace `x` with the actual value of `x`. Also feel fre...
{"functional": "_inputs = [[8], [1], [-2], [-1], [0]]\n_outputs = [['8 is more than zero.'], ['1 is more than zero.'], ['-2 is equal to or less than zero.'], ['-1 is equal to or less than zero.'], ['0 is equal to or less than zero.']]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstanc...
97
211
coding
Solve the programming task below in a Python markdown code block. Given an integer range [A,B], What’s the probability to get a 1-bit if we first randomly choose a number x in the range and then randomly choose a bit from x? What’s the expected number of bit 1s if we randomly choose a number x in the range? Inp...
{"inputs": ["1\n2 4\n"], "outputs": ["0.61111 1.33333\n"]}
370
32
coding
Solve the programming task below in a Python markdown code block. You are given a string $s$ consisting of lowercase Latin letters and $q$ queries for this string. Recall that the substring $s[l; r]$ of the string $s$ is the string $s_l s_{l + 1} \dots s_r$. For example, the substrings of "codeforces" are "code", "for...
{"inputs": ["aaab\n1\n2 4 4\n", "aaab\n1\n2 4 4\n", "abab\n1\n2 4 4\n", "bbaa\n1\n2 2 4\n", "abbb\n1\n2 4 4\n", "abaa\n1\n2 4 4\n", "baba\n1\n2 4 4\n", "bbba\n1\n2 4 4\n"], "outputs": ["1\n", "1\n", "1\n", "2\n", "1\n", "1\n", "1\n", "1\n"]}
486
143
coding
Solve the programming task below in a Python markdown code block. Vasya has recently learned at school what a number's divisor is and decided to determine a string's divisor. Here is what he came up with. String a is the divisor of string b if and only if there exists a positive integer x such that if we write out str...
{"inputs": ["a\na\n", "a\nb\n", "c\nc\n", "a\nc\n", "b\nc\n", "c\nb\n", "b\nd\n", "c\nd\n"], "outputs": ["1", "0", "1\n", "0\n", "0\n", "0\n", "0\n", "0\n"]}
280
84
coding
Solve the programming task below in a Python markdown code block. You talked to Polycarp and asked him a question. You know that when he wants to answer "yes", he repeats Yes many times in a row. Because of the noise, you only heard part of the answer — some substring of it. That is, if he answered YesYes, then you co...
{"inputs": ["1\nesY\n", "1\nali\n", "1\nccf\n", "1\nYesYesYesYesYesYesa\n", "1\nsYesYesYesYesYesYesYesYesYesYesYesYesYesYesYesYesY\n", "12\nYES\nesYes\ncodeforces\nes\nse\nYesY\nesYesYesYesYesYesYe\nseY\nYess\nsY\no\nYes\n"], "outputs": ["YES\n", "NO\n", "NO\n", "NO\n", "YES\n", "NO\nYES\nNO\nYES\nNO\nYES\nYES\nNO\nNO\...
397
149
coding
Solve the programming task below in a Python markdown code block. Implication is a function of two logical arguments, its value is false if and only if the value of the first argument is true and the value of the second argument is false. Implication is written by using character '$\rightarrow$', and the arguments an...
{"inputs": ["1\n0\n", "1\n1\n", "1\n1\n", "1\n0\n", "2\n1 1\n", "2\n0 0\n", "2\n0 1\n", "2\n1 0\n"], "outputs": ["YES\n0\n", "NO\n", "NO", "YES\n0", "NO\n", "NO\n", "NO\n", "YES\n1->0\n"]}
724
100
coding
Solve the programming task below in a Python markdown code block. Given the integer $n$ — the number of available blocks. You must use all blocks to build a pedestal. The pedestal consists of $3$ platforms for $2$-nd, $1$-st and $3$-rd places respectively. The platform for the $1$-st place must be strictly higher than...
{"inputs": ["1\n3777\n", "1\n3234\n", "1\n5234\n", "1\n14377\n", "6\n11\n6\n10\n100000\n7\n8\n", "17\n58512\n46568\n77983\n60262\n48767\n75002\n79520\n52911\n42089\n38692\n71175\n51960\n33754\n36367\n67108\n79100\n78009\n"], "outputs": ["1259 1260 1258\n", "1078 1079 1077\n", "1745 1746 1743\n", "4793 4794 4790\n", "4 ...
632
599
coding
Solve the programming task below in a Python markdown code block. Given an array $a$ of length $n$, tell us whether it has a non-empty subsequence such that the product of its elements is not a perfect square. A sequence $b$ is a subsequence of an array $a$ if $b$ can be obtained from $a$ by deleting some (possibly ze...
{"inputs": ["1\n1\n3\n", "1\n1\n5\n", "1\n1\n6\n", "1\n1\n7\n", "1\n1\n2\n", "1\n1\n8\n", "1\n1\n2\n", "1\n1\n8\n"], "outputs": ["YES\n", "YES\n", "YES\n", "YES\n", "YES\n", "YES\n", "YES\n", "YES\n"]}
318
102
coding
Solve the programming task below in a Python markdown code block. Let's call an array $a$ of $m$ integers $a_1, a_2, \ldots, a_m$ Decinc if $a$ can be made increasing by removing a decreasing subsequence (possibly empty) from it. For example, if $a = [3, 2, 4, 1, 5]$, we can remove the decreasing subsequence $[a_1, a_...
{"inputs": ["1\n1\n", "3\n2 3 1\n", "6\n4 5 2 6 1 3\n", "10\n7 10 1 8 3 9 2 4 6 5\n", "20\n2 1 13 10 12 18 15 19 5 14 16 9 3 8 17 11 7 20 6 4\n"], "outputs": ["1\n", "6\n", "19\n", "39\n", "90\n"]}
472
143
coding
Solve the programming task below in a Python markdown code block. The defaultdict tool is a container in the collections class of Python. It's similar to the usual dictionary (dict) container, but the only difference is that a defaultdict will have a default value if that key has not been set yet. If you didn't use a d...
{"inputs": ["5 2\na\na\nb\na\nb\na\nb\n"], "outputs": ["1 2 4\n3 5\n"]}
700
38
coding
Solve the programming task below in a Python markdown code block. Your goal is to create a function to format a number given a template; if the number is not present, use the digits `1234567890` to fill in the spaces. A few rules: * the template might consist of other numbers, special characters or the like: you need...
{"functional": "_inputs = [['xxx xxxxx xx', '5465253289'], ['xxx xxxxx xx'], ['+555 aaaa bbbb', '18031978'], ['+555 aaaa bbbb'], ['xxxx yyyy zzzz']]\n_outputs = [['546 52532 89'], ['123 45678 90'], ['+555 1803 1978'], ['+555 1234 5678'], ['1234 5678 9012']]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance...
304
286
coding
Solve the programming task below in a Python markdown code block. Read problems statements in [Hindi], [Mandarin Chinese], [Russian], [Vietnamese] and [Bengali] as well. Recently, Chef has moved to an evil land. In this land, there is only one bank, which offers $N$ savings plans (numbered $1$ through $N$). Initially...
{"inputs": ["4\n2 5 3\n2 4\n2 3 2\n1 2\n7 7 0\n4 1 3 2 0 6 5\n10 11 2\n9 1 10 4 5 8 2 3 6 0"], "outputs": ["1\n1\n1\n4"]}
739
87
coding
Solve the programming task below in a Python markdown code block. Phoenix is picking berries in his backyard. There are $n$ shrubs, and each shrub has $a_i$ red berries and $b_i$ blue berries. Each basket can contain $k$ berries. But, Phoenix has decided that each basket may only contain berries from the same shrub or...
{"inputs": ["1 5\n2 3\n", "1 5\n2 2\n", "1 5\n5 0\n", "1 5\n0 0\n", "1 5\n4 0\n", "1 5\n5 5\n", "1 5\n8 7\n", "1 5\n0 0\n"], "outputs": ["1\n", "0\n", "1\n", "0\n", "0\n", "2\n", "3\n", "0\n"]}
545
118
coding
Solve the programming task below in a Python markdown code block. # Definition **_Disarium number_** is the number that *The sum of its digits powered with their respective positions is equal to the number itself*. ____ # Task **_Given_** a number, **_Find if it is Disarium or not_** . ____ # Warm-up (Highly reco...
{"functional": "_inputs = [[1024], [1306], [1999], [2427], [1048576], [2646798]]\n_outputs = [['Not !!'], ['Disarium !!'], ['Not !!'], ['Disarium !!'], ['Not !!'], ['Disarium !!']]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return math.isclose(a, b, rel_to...
397
218
coding
Solve the programming task below in a Python markdown code block. # Task Vanya gets bored one day and decides to enumerate a large pile of rocks. He first counts the rocks and finds out that he has `n` rocks in the pile, then he goes to the store to buy labels for enumeration. Each of the labels is a digit from 0 ...
{"functional": "_inputs = [[1], [10], [13], [100], [36123011]]\n_outputs = [[1], [11], [17], [192], [277872985]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return math.isclose(a, b, rel_tol=tol, abs_tol=tol)\n if isinstance(a, (list, tuple)):\n i...
319
201
coding
Solve the programming task below in a Python markdown code block. Limak is going to participate in a contest on the last day of the 2016. The contest will start at 20:00 and will last four hours, exactly until midnight. There will be n problems, sorted by difficulty, i.e. problem 1 is the easiest and problem n is the h...
{"inputs": ["7 1\n", "1 1\n", "9 1\n", "1 1\n", "9 1\n", "7 8\n", "1 1\n", "7 8\n"], "outputs": ["7\n", "1\n", "9\n", "1\n", "9\n", "7\n", "1\n", "7\n"]}
508
86
coding
Solve the programming task below in a Python markdown code block. Little X and Little Z are good friends. They always chat online. But both of them have schedules. Little Z has fixed schedule. He always online at any moment of time between a_1 and b_1, between a_2 and b_2, ..., between a_{p} and b_{p} (all borders inc...
{"inputs": ["1 1 0 4\n2 3\n0 1\n", "1 1 0 0\n1 3\n2 5\n", "1 1 0 0\n1 3\n2 5\n", "1 1 0 0\n0 3\n2 5\n", "1 1 0 0\n0 1\n2 5\n", "1 1 1 0\n0 1\n2 5\n", "1 1 1 0\n0 2\n2 5\n", "1 1 1 0\n0 3\n2 5\n"], "outputs": ["3\n", "1\n", "1\n", "1", "0", "0", "0", "0"]}
548
177
coding
Solve the programming task below in a Python markdown code block. Musicians of a popular band "Flayer" have announced that they are going to "make their exit" with a world tour. Of course, they will visit Berland as well. There are n cities in Berland. People can travel between cities using two-directional train route...
{"inputs": ["4 2\n1 2 4\n2 3 7\n6 20 1 25\n", "4 2\n1 2 7\n2 3 7\n6 20 1 25\n", "4 2\n1 2 4\n2 3 7\n6 20 1 37\n", "4 2\n1 2 4\n2 3 7\n6 20 1 25\n", "3 1\n1 2 2\n8 3 1\n1 0 2\n9 10 20\n", "3 1\n1 2 2\n3 3 1\n1 3 0\n30 9 20\n", "3 1\n1 2 2\n3 3 1\n1 5 0\n30 9 20\n", "3 1\n1 2 2\n4 3 1\n1 3 2\n9 10 20\n"], "outputs": ["6 ...
669
326
coding
Solve the programming task below in a Python markdown code block. Chef has two binary strings A and B, each of length N. Chef can rearrange both the strings in any way. Find the maximum [bitwise XOR] he can achieve if he rearranges the strings optimally. ------ Input Format ------ - The first line of input will con...
{"inputs": ["4\n0011\n1011\n100\n100\n11111\n11101\n1\n0\n"], "outputs": ["1110\n110\n10000\n1\n"]}
583
63
coding
Solve the programming task below in a Python markdown code block. Along a road running in an east-west direction, there are A shrines and B temples. The i-th shrine from the west is located at a distance of s_i meters from the west end of the road, and the i-th temple from the west is located at a distance of t_i meter...
{"inputs": ["1 1 1\n1\n2\n3\n", "2 3 4\n110\n677\n400\n900\n1000\n1\n2000\n324\n756", "2 3 4\n110\n677\n769\n900\n1000\n1\n2000\n324\n756", "2 3 4\n110\n677\n769\n900\n1000\n2\n2000\n324\n756", "2 3 4\n000\n600\n400\n900\n1000\n150\n798\n899\n799", "2 3 3\n110\n608\n400\n900\n1000\n21\n1894\n899\n799", "2 3 3\n110\n608...
763
451
coding
Solve the programming task below in a Python markdown code block. Chef has a sequence of $N$ integers, $A_1, A_2, ... , A_N$. He likes this sequence if it contains a subsequence of $M$ integers, $B_1, B_2, ... , B_M$ within it. A subsequence is a sequence that can be derived from another sequence by deleting some or n...
{"inputs": ["2\n6\n0 2 2 4 7 6\n3\n2 3 4\n6\n5 5 3 19 1 4\n2\n5 9", "2\n6\n0 2 2 4 7 6\n3\n2 3 4\n6\n5 5 0 19 1 4\n2\n5 9", "2\n6\n0 2 2 4 7 6\n3\n2 5 4\n6\n5 5 0 19 1 4\n2\n5 9", "2\n6\n0 2 3 4 7 6\n3\n2 3 4\n6\n22 5 6 19 1 4\n2\n4 3", "2\n6\n0 2 2 4 7 6\n3\n2 3 4\n6\n41 5 3 19 1 4\n2\n5 9", "2\n6\n1 1 3 4 7 6\n3\n2 3...
758
427
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. You are given a string s. An awesome substring is a non-empty substring of s such that we can make any number of swaps in order to make it a palindrome. Return the length of the maximum length awesome substring of s. ...
{"functional": "def check(candidate):\n assert candidate(s = \"3242415\") == 5\n assert candidate(s = \"12345678\") == 1\n assert candidate(s = \"213123\") == 6\n assert candidate(s = \"00\") == 2\n\n\ncheck(Solution().longestAwesome)"}
93
87
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. Given two strings: s1 and s2 with the same size, check if some permutation of string s1 can break some permutation of string s2 or vice-versa. In other words s2 can break s1 or vice-versa. A string x can break string ...
{"functional": "def check(candidate):\n assert candidate(s1 = \"abc\", s2 = \"xya\") == True\n assert candidate(s1 = \"abe\", s2 = \"acd\") == False \n assert candidate(s1 = \"leetcodee\", s2 = \"interview\") == True\n\n\ncheck(Solution().checkIfCanBreak)"}
153
79
coding
Solve the programming task below in a Python markdown code block. Hands that shed innocent blood! There are n guilty people in a line, the i-th of them holds a claw with length L_{i}. The bell rings and every person kills some of people in front of him. All people kill others at the same time. Namely, the i-th person ...
{"inputs": ["1\n0\n", "1\n1\n", "1\n1\n", "1\n0\n", "1\n2\n", "1\n3\n", "1\n4\n", "2\n0 0\n"], "outputs": ["1\n", "1\n", "1\n", "1\n", "1\n", "1\n", "1\n", "2\n"]}
291
88
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. Given an array of points where points[i] = [xi, yi] represents a point on the X-Y plane, return the maximum number of points that lie on the same straight line.   Please complete the following python code precisely: `...
{"functional": "def check(candidate):\n assert candidate(points = [[1,1],[2,2],[3,3]]) == 3\n assert candidate(points = [[1,1],[3,2],[5,3],[4,1],[2,3],[1,4]]) == 4\n\n\ncheck(Solution().maxPoints)"}
87
75
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. You are given two 0-indexed strings word1 and word2. A move consists of choosing two indices i and j such that 0 <= i < word1.length and 0 <= j < word2.length and swapping word1[i] with word2[j]. Return true if it is ...
{"functional": "def check(candidate):\n assert candidate(word1 = \"ac\", word2 = \"b\") == False\n assert candidate(word1 = \"abcc\", word2 = \"aab\") == True\n assert candidate(word1 = \"abcde\", word2 = \"fghij\") == True\n\n\ncheck(Solution().isItPossible)"}
140
78
coding
Solve the programming task below in a Python markdown code block. You're given an array $a$ of length $n$. You can perform the following operation on it as many times as you want: Pick two integers $i$ and $j$ $(1 \le i,j \le n)$ such that $a_i+a_j$ is odd, then swap $a_i$ and $a_j$. What is lexicographically the sm...
{"inputs": ["2\n1 1\n", "2\n3 1\n", "2\n5 3\n", "2\n7 1\n", "2\n7 5\n", "2\n5 3\n", "2\n3 1\n", "2\n7 5\n"], "outputs": ["1 1 ", "3 1 ", "5 3 ", "7 1 ", "7 5 ", "5 3\n", "3 1\n", "7 5\n"]}
351
113
coding
Solve the programming task below in a Python markdown code block. Read problems statements in Mandarin Chinese and Russian. Chef wants to split a team of new chef into two teams to play a game. In order to make the split, he first designates two team captains who take alternate turns selecting players for their teams...
{"inputs": ["4\n1 1 1 1 1\n2 1 1 1 1\n3 1 2 3 4\n4 2 3 4 1"], "outputs": ["1\n2\n763\n74896"]}
582
64
coding
Solve the programming task below in a Python markdown code block. You are given a string $s$ consisting of $n$ lowercase Latin letters. Polycarp wants to remove exactly $k$ characters ($k \le n$) from the string $s$. Polycarp uses the following algorithm $k$ times: if there is at least one letter 'a', remove the lef...
{"inputs": ["1 1\nu\n", "1 1\nu\n", "2 1\nzz\n", "2 1\nzz\n", "4 3\nhack\n", "4 3\nzzzz\n", "4 3\nhack\n", "4 3\nzzzz\n"], "outputs": ["\n", "\n", "z\n", "z\n", "k\n", "z\n", "k\n", "z\n"]}
365
103
coding
Solve the programming task below in a Python markdown code block. The window of Takahashi's room has a width of A. There are two curtains hung over the window, each of which has a horizontal length of B. (Vertically, the curtains are long enough to cover the whole window.) We will close the window so as to minimize the...
{"inputs": ["3 0", "1 0", "2 0", "1 1\n", "16 4", "35 7", "20 7", "20 8"], "outputs": ["3\n", "1\n", "2\n", "0\n", "8\n", "21\n", "6\n", "4\n"]}
229
84
coding
Solve the programming task below in a Python markdown code block. Problem There is a grid of $ R \ times C $ squares with $ (0, 0) $ in the upper left and $ (R-1, C-1) $ in the lower right. When you are in a square ($ e $, $ f $), from there $ (e + 1, f) $, $ (e-1, f) $, $ (e, f + 1) $, $ (e) , f-1) $, $ (e, 0) $, $ (...
{"inputs": ["2 2 0 0 0 1", "1 2 0 0 0 0", "5 6 0 0 4 4", "8 6 0 0 4 4", "2 2 1 0 0 1", "2 4 0 0 1 1", "5 5 0 0 4 4", "1 1 0 0 0 0"], "outputs": ["1 2\n", "0 1\n", "3 3\n", "6 30\n", "2 8\n", "2 4\n", "2 2", "0 1"]}
624
157
coding
Solve the programming task below in a Python markdown code block. You will be given an array that contains two strings. Your job is to create a function that will take those two strings and transpose them, so that the strings go from top to bottom instead of left to right. A few things to note: 1. There should be one ...
{"functional": "_inputs = [[['Hello', 'World']], [['joey', 'louise']], [['a', 'cat']], [['cat', '']], [['!a!a!', '?b?b']]]\n_outputs = [['H W\\ne o\\nl r\\nl l\\no d'], ['j l\\no o\\ne u\\ny i\\n s\\n e'], ['a c\\n a\\n t'], ['c \\na \\nt '], ['! ?\\na b\\n! ?\\na b\\n! ']]\nimport math\ndef _deep_eq(a, b, tol=...
142
268
coding
Solve the programming task below in a Python markdown code block. Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well. You are given a string $S$ with length $N$ and you should change it to a palindrome using a sequence of zero or more operations. In one operation, yo...
{"inputs": ["3\n4\nabab\n5\nacbba\n5\naaaab"], "outputs": ["YES\n1\nYES\n1\nNO"]}
451
35
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. Given an integer array nums, return the most frequent even element. If there is a tie, return the smallest one. If there is no such element, return -1.   Please complete the following python code precisely: ```python ...
{"functional": "def check(candidate):\n assert candidate(nums = [0,1,2,2,4,4,1]) == 2\n assert candidate(nums = [4,4,4,9,2,4]) == 4\n assert candidate(nums = [29,47,21,41,13,37,25,7]) == -1\n\n\ncheck(Solution().mostFrequentEven)"}
85
100
coding
Solve the programming task below in a Python markdown code block. Chef has a stick of length N. He can break the stick into 2 or more parts such that the [parity] of length of each part is same. For example, a stick of length 11 can be broken into three sticks of lengths \{3, 3, 5\} since each part is odd, but it cann...
{"inputs": ["3\n6 1\n3 2\n4 3\n"], "outputs": ["YES\nNO\nYES\n"]}
442
30
coding
Solve the programming task below in a Python markdown code block. Complete the solution so that it reverses all of the words within the string passed in. Example: ```python reverseWords("The greatest victory is that which requires no battle") // should return "battle no requires which that is victory greatest The" `...
{"functional": "_inputs = [['hello world!']]\n_outputs = [['world! hello']]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return math.isclose(a, b, rel_tol=tol, abs_tol=tol)\n if isinstance(a, (list, tuple)):\n if len(a) != len(b): return False\n ...
87
158
coding
Solve the programming task below in a Python markdown code block. Given three positive integers N, A and B (A < B < N), find the sum of all positive integers less than N, which are divisible by either A or B. For example, when N = 20, A = 4 and B = 7, the possible values are 4, 7, 8, 12, 14, and 16. Their sum is 61. I...
{"inputs": ["1000 3 5"], "outputs": ["233168"]}
168
24
coding
Solve the programming task below in a Python markdown code block. Supermarket Dilemma Chef is going to local supermarket but there appears a problem with chef as he is confused about which Supermarket he can choose to go as he is not able to decide whether he can park his car in that particular supermarket’s parking lo...
{"inputs": ["2\n4\n5"], "outputs": ["YES\nNO"]}
300
18
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. Write a function to swap a number in place (that is, without temporary variables). Please complete the following python code precisely: ```python class Solution: def swapNumbers(self, numbers: List[int]) -> List[i...
{"functional": "def check(candidate):\n assert candidate(numbers = [1,2]) == [2,1]\n\n\ncheck(Solution().swapNumbers)"}
65
36
coding
Solve the programming task below in a Python markdown code block. There are three people sitting in a room - Alice, Bob, and Charlie. They need to decide on the temperature to set on the air conditioner. Everyone has a demand each: Alice wants the temperature to be at least A degrees. Bob wants the temperature to be a...
{"inputs": ["4\n30 35 25\n30 35 40\n30 35 35\n30 25 35\n"], "outputs": ["Yes\nNo\nYes\nNo\n"]}
685
56
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. You are playing a solitaire game with three piles of stones of sizes a​​​​​​, b,​​​​​​ and c​​​​​​ respectively. Each turn you choose two different non-empty piles, take one stone from each, and add 1 point to your sc...
{"functional": "def check(candidate):\n assert candidate(a = 2, b = 4, c = 6) == 6\n assert candidate(a = 4, b = 4, c = 6) == 7\n assert candidate(a = 1, b = 8, c = 8) == 8\n\n\ncheck(Solution().maximumScore)"}
159
85
coding
Solve the programming task below in a Python markdown code block. Read problems statements in [Hindi], [Mandarin Chinese], [Russian], [Vietnamese], and [Bengali] as well. It is well-known that if you become rich, you will have a lot of trouble. Coach Khaled is one of the richest men in the world. He has $N$ jewels (nu...
{"inputs": ["1\n4 4\n1 2 4 3\n1 3\n3 4\n1 2\n2 3"], "outputs": ["4"]}
725
40
coding
Solve the programming task below in a Python markdown code block. Given an D-dimension array, where each axis is of length N, your goal is to find the sum of every index in the array starting from 0. For Example if D=1 and N=10 then the answer would be 45 ([0,1,2,3,4,5,6,7,8,9]) If D=2 and N = 3 the answer is 18 which...
{"functional": "_inputs = [[2, 2], [2, 3], [3, 2], [3, 3], [1, 101], [10, 10], [10, 11], [11, 10], [11, 11], [15, 8], [19, 84], [17, 76]]\n_outputs = [[4], [18], [12], [81], [5050], [450000000000], [1296871230050], [4950000000000], [15692141883605], [1847179534663680], [2871495452512585452340652014195036913664], [60022...
310
413
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. You are given coordinates, a string that represents the coordinates of a square of the chessboard. Below is a chessboard for your reference. Return true if the square is white, and false if the square is black. The c...
{"functional": "def check(candidate):\n assert candidate(coordinates = \"a1\") == False\n assert candidate(coordinates = \"h3\") == True\n assert candidate(coordinates = \"c7\") == False\n\n\ncheck(Solution().squareIsWhite)"}
117
56
coding
Solve the programming task below in a Python markdown code block. # Task Given a sorted array of integers `A`, find such an integer x that the value of `abs(A[0] - x) + abs(A[1] - x) + ... + abs(A[A.length - 1] - x)` is the smallest possible (here abs denotes the `absolute value`). If there are several possible answ...
{"functional": "_inputs = [[[2, 4, 7]], [[1, 1, 3, 4]], [[23]], [[-10, -10, -10, -10, -10, -9, -9, -9, -8, -8, -7, -6, -5, -4, -3, -2, -1, 0, 0, 0, 0, 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...
216
563
coding
Solve the programming task below in a Python markdown code block. **This Kata is intended as a small challenge for my students** Create a function, called ``removeVowels`` (or ``remove_vowels``), that takes a string argument and returns that same string with all vowels removed (vowels are "a", "e", "i", "o", "u"). Als...
{"functional": "_inputs = [['drake'], ['scholarstem'], ['codewars'], ['high fives!'], [''], ['i'], ['b']]\n_outputs = [['drk'], ['schlrstm'], ['cdwrs'], ['hgh fvs!'], [''], [''], ['b']]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return math.isclose(a, b, r...
103
206
coding
Solve the programming task below in a Python markdown code block. Relative B man came to A child's house. He is 3 years old and loves singing. He is singing the song "Kobutanuki Tsuneko" (written and composed by Naozumi Yamamoto), which he learned from kindergarten. In this song, the four words "kobuta," "raccoon dog,"...
{"inputs": ["5\napple\nyellow\ngeorgia\ngnik\nemail\n7\napple\nyellow\ngeorgia\nking\nemail\nwink\nlucky\n0", "5\napple\nyellow\ngeorgia\ngnik\nemail\n7\napple\nzellow\ngeorgia\nking\nemail\nwink\nlucky\n0", "5\napple\noellyw\ngeorgia\ngink\nlibme\n0\napplf\nzelmow\ngeorgia\nkgnj\nembil\nxink\nlkcuy\n0", "5\napple\nyel...
399
361
coding
Solve the programming task below in a Python markdown code block. A Madhav array has the following property: ```a[0] = a[1] + a[2] = a[3] + a[4] + a[5] = a[6] + a[7] + a[8] + a[9] = ...``` Complete the function/method that returns `true` if the given array is a Madhav array, otherwise it returns `false`. *Edge cases...
{"functional": "_inputs = [[[6, 2, 4, 2, 2, 2, 1, 5, 0, 0]], [[6, 2, 4, 2, 2, 2, 1, 5, 0, -100]], [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, -2, -1]], [[-6, -3, -3, 8, -5, -4]], [[-6, -3, -3, 8, -10, -4]], [[3, 1, 2, 3, 0]], [[3, 3]], [[]], [[1]], [[5, 2, 4, 1, 0, 3]], [[6, 2, 4, 2, 2, 2, 1, 5, 0, 0, -12, 13, -5, 4, 6]],...
162
504
coding
Solve the programming task below in a Python markdown code block. Introduction The GADERYPOLUKI is a simple substitution cypher used in scouting to encrypt messages. The encryption is based on short, easy to remember key. The key is written as paired letters, which are in the cipher simple replacement. The most freq...
{"functional": "_inputs = [['Gug hgs g cgt', 'gaderypoluki'], ['Dkucr pu yhr ykbir', 'politykarenu'], ['ABCD', 'gaderypoluki'], ['Ala has a cat', 'gaderypoluki']]\n_outputs = [['Ala has a cat'], ['Dance on the table'], ['GBCE'], ['Gug hgs g cgt']]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float)...
380
235
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. You are given an integer array prices representing the daily price history of a stock, where prices[i] is the stock price on the ith day. A smooth descent period of a stock consists of one or more contiguous days such...
{"functional": "def check(candidate):\n assert candidate(prices = [3,2,1,4]) == 7\n assert candidate(prices = [8,6,7,7]) == 4\n assert candidate(prices = [1]) == 1\n\n\ncheck(Solution().getDescentPeriods)"}
136
73
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. You are given a 0-indexed array of strings garbage where garbage[i] represents the assortment of garbage at the ith house. garbage[i] consists only of the characters 'M', 'P' and 'G' representing one unit of metal, pa...
{"functional": "def check(candidate):\n assert candidate(garbage = [\"G\",\"P\",\"GP\",\"GG\"], travel = [2,4,3]) == 21\n assert candidate(garbage = [\"MMM\",\"PGM\",\"GP\"], travel = [3,10]) == 37\n\n\ncheck(Solution().garbageCollection)"}
248
82
coding
Solve the programming task below in a Python markdown code block. For an upcoming programming contest, Roy is forming some teams from the students of his university. A team can have any number of contestants. Roy knows the skill level of each contestant. To make the teams work as a unit, he forms the teams based on s...
{"inputs": ["4 \n7 4 5 2 3 -4 -3 -5 \n1 -4 \n4 3 2 3 1 \n7 1 -2 -3 -4 2 0 -1 \n"], "outputs": ["3\n1\n1\n7\n"]}
707
76
coding
Solve the programming task below in a Python markdown code block. Every character in the string “IITMANDI” is given a certain number of points. You are given a scrabble board with only one row. The input contains the positions of score modifiers such as: Double Letter, Triple Letter, Double Word and Triple Word. You ne...
{"inputs": ["2\n10\n..d.t.D..d\n10 11 12 9 8 10 11 15\n22\ndtDtTD..ddT.TtTdDT..TD\n12297 5077 28888 17998 12125 27400 31219 21536"], "outputs": ["270\n35629632"]}
636
119
coding
Solve the programming task below in a Python markdown code block. You are given n integers a_1, a_2, ..., a_{n}. Find the number of pairs of indexes i, j (i < j) that a_{i} + a_{j} is a power of 2 (i. e. some integer x exists so that a_{i} + a_{j} = 2^{x}). -----Input----- The first line contains the single positive...
{"inputs": ["1\n2\n", "1\n2\n", "1\n4\n", "2\n1 1\n", "2\n1 1\n", "3\n1 1 1\n", "3\n1 1 1\n", "4\n7 3 2 1\n"], "outputs": ["0\n", "0\n", "0\n", "1\n", "1\n", "3\n", "3\n", "2\n"]}
272
104
coding
Solve the programming task below in a Python markdown code block. There are N people living on a number line. The i-th person lives at coordinate X_i. You are going to hold a meeting that all N people have to attend. The meeting can be held at any integer coordinate. If you choose to hold the meeting at coordinate P, t...
{"inputs": ["1\n1\n", "2\n0 4", "2\n0 1", "2\n2 4", "2\n0 3", "2\n1 4", "2\n1 4\n", "7\n4 1 0 12 23 0 0"], "outputs": ["0\n", "8\n", "1\n", "2\n", "5\n", "5", "5\n", "462\n"]}
292
107
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. Given an array of strings wordsDict and two different strings that already exist in the array word1 and word2, return the shortest distance between these two words in the list.   Please complete the following python c...
{"functional": "def check(candidate):\n assert candidate(wordsDict = [\"practice\", \"makes\", \"perfect\", \"coding\", \"makes\"], word1 = \"coding\", word2 = \"practice\") == 3\n assert candidate(wordsDict = [\"practice\", \"makes\", \"perfect\", \"coding\", \"makes\"], word1 = \"makes\", word2 = \"coding\") ==...
94
98
coding
Solve the programming task below in a Python markdown code block. Sherlock has a new girlfriend (so unlike him!). Valentine's day is coming and he wants to gift her some jewelry. He bought n pieces of jewelry. The i-th piece has price equal to i + 1, that is, the prices of the jewelry are 2, 3, 4, ... n + 1. Watson g...
{"inputs": ["3\n", "4\n", "1\n", "2\n", "1\n", "2\n", "1\n", "4\n"], "outputs": ["2\n1 1 2 \n", "2\n1 1 2 1 \n", "1\n1 \n", "1\n1 1 \n", "1\n1 \n", "1\n1 1 \n", "1\n1 ", "2\n1 1 2 1 "]}
362
111
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. You are given the root of a binary tree with unique values, and an integer start. At minute 0, an infection starts from the node with value start. Each minute, a node becomes infected if: The node is currently uninfe...
{"functional": "def check(candidate):\n assert candidate(root = tree_node([1,5,3,None,4,10,6,9,2]), start = 3) == 4\n assert candidate(root = tree_node([1]), start = 1) == 0\n\n\ncheck(Solution().amountOfTime)"}
178
74
coding
Solve the programming task below in a Python markdown code block. Following on from [Part 1](http://www.codewars.com/kata/filling-an-array-part-1/), part 2 looks at some more complicated array contents. So let's try filling an array with... ## ...square numbers The numbers from `1` to `n*n` ## ...a range of numbers ...
{"functional": "_inputs = [[5]]\n_outputs = [[[1, 4, 9, 16, 25]]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return math.isclose(a, b, rel_tol=tol, abs_tol=tol)\n if isinstance(a, (list, tuple)):\n if len(a) != len(b): return False\n retur...
176
168
coding
Solve the programming task below in a Python markdown code block. Dhruvil has always been a studious person and will be completing his Engineering soon. He is always kneen about solving problems and is preparing hard for his next interview at Hackerrank. He has practiced lots of problems and now he came across this pro...
{"inputs": ["2\n12\n226"], "outputs": ["2\n3"]}
396
21
coding
Solve the programming task below in a Python markdown code block. Read problems statements in mandarin chinese, russian and vietnamese as well. Chef Ada loves trees, she thinks that the beauty of a tree is determined by the distance between its center and centroid. If the tree has multiple centers or centroids, then ...
{"inputs": ["1\n4 0"], "outputs": ["YES\n1 2\n1 3\n1 4"]}
415
28
coding
Solve the programming task below in a Python markdown code block. Alan's child can be annoying at times. When Alan comes home and tells his kid what he has accomplished today, his kid never believes him. Be that kid. Your function 'AlanAnnoyingKid' takes as input a sentence spoken by Alan (a string). The sentence c...
{"functional": "_inputs = [['Today I played football.'], [\"Today I didn't play football.\"], [\"Today I didn't attempt to hardcode this Kata.\"], ['Today I cleaned the kitchen.'], ['Today I learned to code like a pro.']]\n_outputs = [[\"I don't think you played football today, I think you didn't play at all!\"], [\"I ...
450
320
coding
Solve the programming task below in a Python markdown code block. The campus has $m$ rooms numbered from $0$ to $m - 1$. Also the $x$-mouse lives in the campus. The $x$-mouse is not just a mouse: each second $x$-mouse moves from room $i$ to the room $i \cdot x \mod{m}$ (in fact, it teleports from one room to another si...
{"inputs": ["4 3\n", "5 2\n", "7 2\n", "2 1\n", "2 1\n", "7 2\n", "3 2\n", "4 3\n"], "outputs": ["3\n", "2\n", "3\n", "2\n", "2\n", "3\n", "2\n", "3\n"]}
439
86
coding
Solve the programming task below in a Python markdown code block. Read problems statements in Mandarin Chinese and Russian Chef is sitting in a very boring lecture, waiting for it to end. He has recently asked his friend about the time, and instead of the straightforward answer, his friend, being an absolute jerk, ...
{"inputs": ["2\n0\n7", "2\n2\n6", "2\n1\n2", "2\n2\n5", "2\n0\n9", "2\n1\n3", "2\n2\n4", "2\n1\n9"], "outputs": ["00:00\n05:26\n06:34\n", "03:16\n08:44\n02:12\n09:48\n", "04:22\n07:38\n03:16\n08:44\n", "03:16\n08:44\n02:10\n09:50\n", "00:00\n03:18\n08:42\n", "04:22\n07:38\n01:06\n10:54\n", "03:16\n08:44\n05:28\n06:32\n...
471
258
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. You are given a string s formed by digits and '#'. We want to map s to English lowercase characters as follows: Characters ('a' to 'i') are represented by ('1' to '9') respectively. Characters ('j' to 'z') are repres...
{"functional": "def check(candidate):\n assert candidate(s = \"10#11#12\") == \"jkab\"\n assert candidate(s = \"1326#\") == \"acz\"\n\n\ncheck(Solution().freqAlphabets)"}
138
60
coding
Solve the programming task below in a Python markdown code block. Lavrenty, a baker, is going to make several buns with stuffings and sell them. Lavrenty has n grams of dough as well as m different stuffing types. The stuffing types are numerated from 1 to m. Lavrenty knows that he has ai grams left of the i-th stuffi...
{"inputs": ["2 1 2 1\n1 2 1 1\n", "1 1 1 1\n1 1 1 1\n", "2 1 2 1\n0 2 1 1\n", "2 1 1 1\n1 1 1 1\n", "2 1 2 1\n1 3 1 1\n", "2 1 1 1\n1 1 2 1\n", "4 1 2 4\n10 1 3 7\n", "4 1 2 4\n10 1 3 8\n"], "outputs": ["1", "1", "1\n", "2\n", "1\n", "2\n", "8", "8\n"]}
445
181
coding
Solve the programming task below in a Python markdown code block. Happy traveller [Part 1] There is a play grid NxN; Always square! 0 1 2 3 0 [o, o, o, X] 1 [o, o, o, o] 2 [o, o, o, o] 3 [o, o, o, o] You start from a random point. I mean, you are given the coordinates of your start position in format (row, c...
{"functional": "_inputs = [[1, [0, 0]], [2, [1, 0]], [2, [1, 1]], [3, [1, 0]], [5, [4, 0]], [6, [5, 0]], [7, [6, 0]]]\n_outputs = [[0], [2], [1], [3], [70], [252], [924]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return math.isclose(a, b, rel_tol=tol, abs...
521
237
coding
Solve the programming task below in a Python markdown code block. You are given a string S, consisting of lowercase English letters. You can do the following operation at most once : Choose a subsequence of the string S, then remove it from S and concatenate the subsequence at the end of the remaining string. Find t...
{"inputs": ["4\naba\nabcd\ncbcdbef\nfabcdac"], "outputs": ["aab\nabcd\nbbccdef\naacfbcd\n"]}
520
36
coding
Solve the programming task below in a Python markdown code block. Create a function that returns the average of an array of numbers ("scores"), rounded to the nearest whole number. You are not allowed to use any loops (including for, for/in, while, and do/while loops). Also feel free to reuse/extend the following start...
{"functional": "_inputs = [[[5, 78, 52, 900, 1]], [[5, 25, 50, 75]], [[2]], [[1, 1, 1, 1, 9999]], [[0]]]\n_outputs = [[207], [39], [2], [2001], [0]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return math.isclose(a, b, rel_tol=tol, abs_tol=tol)\n if isin...
78
227
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. Given an array arr of integers, check if there exist two indices i and j such that : i != j 0 <= i, j < arr.length arr[i] == 2 * arr[j]   Please complete the following python code precisely: ```python class Solution...
{"functional": "def check(candidate):\n assert candidate(arr = [10,2,5,3]) == True\n assert candidate(arr = [7,1,14,11]) == True\n assert candidate(arr = [3,1,7,11]) == False\n\n\ncheck(Solution().checkIfExist)"}
91
75