task_type
stringclasses
1 value
problem
stringlengths
261
3.34k
answer
stringlengths
35
6.15k
problem_tokens
int64
62
774
answer_tokens
int64
12
2.04k
coding
Solve the programming task below in a Python markdown code block. Similar to the [previous kata](https://www.codewars.com/kata/string-subpattern-recognition-ii/), but this time you need to operate with shuffled strings to identify if they are composed repeating a subpattern Since there is no deterministic way to tell ...
{"functional": "_inputs = [['a'], ['aaaa'], ['abcd'], ['babababababababa'], ['bbabbaaabbaaaabb'], ['123a123a123a'], ['123A123a123a'], ['12aa13a21233'], ['12aa13a21233A'], ['abcdabcaccd']]\n_outputs = [['a'], ['a'], ['abcd'], ['ab'], ['ab'], ['123a'], ['111222333Aaa'], ['123a'], ['111222333Aaaa'], ['aaabbccccdd']]\nimpo...
321
296
coding
Solve the programming task below in a Python markdown code block. Mash 2 arrays together so that the returning array has alternating elements of the 2 arrays . Both arrays will always be the same length. eg. [1,2,3] + ['a','b','c'] = [1, 'a', 2, 'b', 3, 'c'] Also feel free to reuse/extend the following starter code: ...
{"functional": "_inputs = [[[1, 2, 3], ['a', 'b', 'c']], [[1, 2, 3, 4, 5], ['a', 'b', 'c', 'd', 'e']], [[1, 1, 1, 1], [2, 2, 2, 2]], [[1, 8, 'hello', 'dog'], ['fish', '2', 9, 10]], [[None, 4], [None, 'hello']], [[1], [2]], [['h', 'l', 'o', 'o', 'l'], ['e', 'l', 'w', 'r', 'd']]]\n_outputs = [[[1, 'a', 2, 'b', 3, 'c']], ...
103
440
coding
Solve the programming task below in a Python markdown code block. Some time ago, Chef bought X stocks at the cost of Rs. Y each. Today, Chef is going to sell all these X stocks at Rs. Z each. What is Chef's total profit after he sells them? Chef's profit equals the total amount he received by selling the stocks, minus...
{"inputs": ["3\n2 5 20\n3 1 2\n4 5 6"], "outputs": ["30\n3\n4\n"]}
590
37
coding
Solve the programming task below in a Python markdown code block. My washing machine uses ```water``` amount of water to wash ```clothes``` amount of clothes. You are given a ```load``` amount of clothes to wash. For each single item of load above the standard amount of clothes, the washing machine will use 10% more w...
{"functional": "_inputs = [[10, 10, 21], [10, 10, 2], [10, 11, 20], [50, 15, 29], [50, 15, 15]]\n_outputs = [['Too much clothes'], ['Not enough clothes'], [23.58], [189.87], [50]]\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...
337
239
coding
Solve the programming task below in a Python markdown code block. You are playing a game called Guru Guru Gururin. In this game, you can move with the vehicle called Gururin. There are two commands you can give to Gururin: 'R' and 'L'. When 'R' is sent, Gururin rotates clockwise by 90 degrees. Otherwise, when 'L' is se...
{"inputs": ["RL", "QL", "LQ", "KR", "KQ", "QK", "RK", "SK"], "outputs": ["0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n"]}
513
65
coding
Solve the programming task below in a Python markdown code block. Let's define $S(x)$ to be the sum of digits of number $x$ written in decimal system. For example, $S(5) = 5$, $S(10) = 1$, $S(322) = 7$. We will call an integer $x$ interesting if $S(x + 1) < S(x)$. In each test you will be given one integer $n$. Your t...
{"inputs": ["5\n1\n4\n4\n3\n75116\n", "5\n1\n4\n4\n3\n52440\n", "5\n1\n4\n4\n0\n80298\n", "5\n1\n4\n3\n1\n86587\n", "5\n1\n5\n3\n0\n34153\n", "5\n1\n5\n3\n0\n13341\n", "5\n2\n4\n5\n1\n55511991\n", "5\n2\n4\n5\n0\n56517944\n"], "outputs": ["0\n0\n0\n0\n7511\n", "0\n0\n0\n0\n5244\n", "0\n0\n0\n0\n8029\n", "0\n0\n0\n0\n86...
299
282
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. Given a matrix and a target, return the number of non-empty submatrices that sum to target. A submatrix x1, y1, x2, y2 is the set of all cells matrix[x][y] with x1 <= x <= x2 and y1 <= y <= y2. Two submatrices (x1, y1...
{"functional": "def check(candidate):\n assert candidate(matrix = [[0,1,0],[1,1,1],[0,1,0]], target = 0) == 4\n assert candidate(matrix = [[1,-1],[-1,1]], target = 0) == 5\n assert candidate(matrix = [[904]], target = 0) == 0\n\n\ncheck(Solution().numSubmatrixSumTarget)"}
173
97
coding
Solve the programming task below in a Python markdown code block. You have a long stick, consisting of $m$ segments enumerated from $1$ to $m$. Each segment is $1$ centimeter long. Sadly, some segments are broken and need to be repaired. You have an infinitely long repair tape. You want to cut some pieces from the tap...
{"inputs": ["1 1 1\n1\n", "1 1 1\n1\n", "3 8 1\n2 6 7\n", "3 8 2\n4 6 8\n", "3 8 3\n1 2 6\n", "3 8 3\n1 2 6\n", "3 8 2\n4 6 8\n", "3 8 1\n2 6 7\n"], "outputs": ["1\n", "1", "6\n", "4\n", "3\n", "3", "4", "6"]}
512
138
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. You are given an integer array nums and an integer target. You want to build an expression out of nums by adding one of the symbols '+' and '-' before each integer in nums and then concatenate all the integers. For e...
{"functional": "def check(candidate):\n assert candidate(nums = [1,1,1,1,1], target = 3) == 5\n assert candidate(nums = [1], target = 1) == 1\n\n\ncheck(Solution().findTargetSumWays)"}
151
64
coding
Solve the programming task below in a Python markdown code block. There are N balls in the xy-plane. The coordinates of the i-th of them is (x_i, i). Thus, we have one ball on each of the N lines y = 1, y = 2, ..., y = N. In order to collect these balls, Snuke prepared 2N robots, N of type A and N of type B. Then, he p...
{"inputs": ["1\n18\n2", "1\n23\n1", "1\n23\n0", "1\n10\n3", "1\n15\n8", "1\n17\n9", "1\n0\n-8", "1\n0\n-7"], "outputs": ["4\n", "2\n", "0\n", "6\n", "14\n", "16\n", "-16\n", "-14\n"]}
546
106
coding
Solve the programming task below in a Python markdown code block. Write a function that takes a single array as an argument (containing multiple strings and/or positive numbers and/or arrays), and returns one of four possible string values, depending on the ordering of the lengths of the elements in the input array: Y...
{"functional": "_inputs = [[[1, 'b', ['p'], 2]], [[123, 1234, 12345, 123456]], [['a', 'abc', 'abcde', 'ab']], [[[1, 2, 3, 4], [5, 6, 7], [8, 9]]], [[1, 2, 3, 4, 56]], [[['ab', 'cdef', 'g'], ['hi', 'jk', 'lmnopq'], ['rst', 'uv', 'wx'], ['yz']]], [[[1, 23, 456, 78910], ['abcdef', 'ghijklmno', 'pqrstuvwxy'], [[1, 23, 456,...
238
412
coding
Solve the programming task below in a Python markdown code block. There is a street with $n$ houses in a line, numbered from $1$ to $n$. The house $i$ is initially painted in color $c_i$. The street is considered beautiful if all houses are painted in the same color. Tom, the painter, is in charge of making the street ...
{"inputs": ["3\n10 2\n1 1 2 2 1 1 2 2 2 1\n7 1\n1 2 3 4 5 6 7\n10 3\n1 3 3 3 3 1 2 1 3 3\n", "6\n6 4\n2 1 1 1 1 2\n10 5\n1 1 1 2 2 1 2 2 1 1\n9 6\n1 2 3 1 2 3 1 2 3\n1 1\n100\n10 10\n1 100 2 99 3 98 4 97 5 96\n8 1\n50 50 50 50 50 50 50 50\n"], "outputs": ["3\n6\n2\n", "1\n1\n2\n0\n1\n0\n"]}
624
235
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. There is a secret sequence $A_{1}, A_{2}, \ldots, A_{N}$. We do not know the elements of this sequence, but we know another sequence $B_{1}, B_{2}, \...
{"inputs": ["1\n5 3\n4 5 6 7\n1 2\n1 3\n4 1"], "outputs": ["4\nUNKNOWN\n5"]}
587
40
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. There is a new alien language that uses the English alphabet. However, the order of the letters is unknown to you. You are given a list of strings words from the alien language's dictionary. Now it is claimed that the...
{"functional": "def check(candidate):\n assert candidate(words = [\"wrt\",\"wrf\",\"er\",\"ett\",\"rftt\"]) == \"wertf\"\n assert candidate(words = [\"z\",\"x\"]) == \"zx\"\n assert candidate(words = [\"z\",\"x\",\"z\"]) == \"\"\n\n\ncheck(Solution().alienOrder)"}
177
82
coding
Solve the programming task below in a Python markdown code block. An army of n droids is lined up in one row. Each droid is described by m integers a_1, a_2, ..., a_{m}, where a_{i} is the number of details of the i-th type in this droid's mechanism. R2-D2 wants to destroy the sequence of consecutive droids of maximum ...
{"inputs": ["1 1 0\n0\n", "1 1 0\n1\n", "1 1 1\n0\n", "1 1 0\n0\n", "1 1 1\n0\n", "1 1 0\n1\n", "1 1 1\n1\n", "1 1 0\n2\n"], "outputs": ["0\n", "0\n", "0\n", "0 \n", "0 \n", "0 \n", "1 ", "0 "]}
486
120
coding
Solve the programming task below in a Python markdown code block. Hooray! Polycarp turned $n$ years old! The Technocup Team sincerely congratulates Polycarp! Polycarp celebrated all of his $n$ birthdays: from the $1$-th to the $n$-th. At the moment, he is wondering: how many times he turned beautiful number of years? ...
{"inputs": ["6\n18\n1\n9\n100500\n33\n1000000000\n"], "outputs": ["10\n1\n9\n45\n12\n81\n"]}
456
56
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. You are given a 0-indexed circular string array words and a string target. A circular array means that the array's end connects to the array's beginning. Formally, the next element of words[i] is words[(i + 1) % n] a...
{"functional": "def check(candidate):\n assert candidate(words = [\"hello\",\"i\",\"am\",\"leetcode\",\"hello\"], target = \"hello\", startIndex = 1) == 1\n assert candidate(words = [\"a\",\"b\",\"leetcode\"], target = \"leetcode\", startIndex = 0) == 1\n assert candidate(words = [\"i\",\"eat\",\"leetcode\"], ...
188
108
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. Given two strings s and t, find the number of ways you can choose a non-empty substring of s and replace a single character by a different character such that the resulting substring is a substring of t. In other word...
{"functional": "def check(candidate):\n assert candidate(s = \"aba\", t = \"baba\") == 6\n assert candidate(s = \"ab\", t = \"bb\") == 3\n assert candidate(s = \"a\", t = \"a\") == 0\n assert candidate(s = \"abe\", t = \"bbc\") == 10\n\n\ncheck(Solution().countSubstrings)"}
175
90
coding
Solve the programming task below in a Python markdown code block. Giant chess is quite common in Geraldion. We will not delve into the rules of the game, we'll just say that the game takes place on an h × w field, and it is painted in two colors, but not like in chess. Almost all cells of the field are white and only s...
{"inputs": ["3 4 2\n2 2\n2 3\n", "2 2 2\n2 1\n1 2\n", "2 2 2\n2 1\n1 2\n", "3 4 2\n2 2\n1 3\n", "3 4 2\n2 2\n2 3\n", "100000 100000 2\n1 2\n2 1\n", "100000 100000 2\n1 2\n2 1\n", "100000 100000 2\n2 2\n2 1\n"], "outputs": ["2\n", "0\n", "0\n", "1\n", "2\n", "0\n", "0\n", "307833736\n"]}
477
204
coding
Solve the programming task below in a Python markdown code block. The famous store "Second Food" sells groceries only two days a month. And the prices in each of days differ. You wanted to buy $n$ kilos of potatoes for a month. You know that on the first day of the month $1$ kilo of potatoes costs $a$ coins, and on the...
{"inputs": ["5\n5 4\n3 1\n5 4\n3 2\n3 4\n3 5\n20 15\n10 2\n1000000000 900000000\n1000000000 8\n"], "outputs": ["9\n10\n9\n135\n888888888900000000\n"]}
587
111
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. Given an array nums of integers and integer k, return the maximum sum such that there exists i < j with nums[i] + nums[j] = sum and sum < k. If no i, j exist satisfying this equation, return -1.   Please complete the ...
{"functional": "def check(candidate):\n assert candidate(nums = [34,23,1,24,75,33,54,8], k = 60) == 58\n assert candidate(nums = [10,20,30], k = 15) == -1\n\n\ncheck(Solution().twoSumLessThanK)"}
106
86
coding
Solve the programming task below in a Python markdown code block. Chef wants to become fit for which he decided to walk to the office and return home by walking. It is known that Chef's office is X km away from his home. If his office is open on 5 days in a week, find the number of kilometers Chef travels through off...
{"inputs": ["4\n1\n3\n7\n10\n"], "outputs": ["10\n30\n70\n100\n"]}
478
34
coding
Solve the programming task below in a Python markdown code block. Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. One day Petya dreamt of a lexicogr...
{"inputs": ["3 7\n", "2 3\n", "1 2\n", "1 1\n", "7 1\n", "2 4\n", "2 1\n", "2 2\n"], "outputs": ["-1\n", "-1\n", "-1\n", "0\n", "2\n", "-1\n", "0\n", "0\n"]}
425
87
coding
Solve the programming task below in a Python markdown code block. Sherlock considers a string to be valid if all characters of the string appear the same number of times. It is also valid if he can remove just $1$ character at $1$ index in the string, and the remaining characters will occur the same number of times. ...
{"inputs": ["aabbcd\n", "aabbccddeefghi\n", "abcdefghhgfedecba\n"], "outputs": ["NO\n", "NO\n", "YES\n"]}
556
42
coding
Solve the programming task below in a Python markdown code block. Write a program which reads a list of student test scores and evaluates the performance for each student. The test scores for a student include scores of the midterm examination m (out of 50), the final examination f (out of 50) and the makeup examinati...
{"inputs": ["34 10 1\n30 42 0\n1 1 1\n-1 -1 -1", "40 53 -1\n0 7 -1\n0 1 -1\n-1 -1 -1", "73 6 -1\n16 30 0\n1 2 -1\n-1 -1 -1", "92 64 0\n16 30 -1\n0 2 0\n-1 -1 -1", "40 53 -1\n0 7 -1\n0 1 -2\n-1 -1 -1", "92 64 0\n16 30 -1\n1 2 0\n-1 -1 -1", "40 53 -1\n0 58 -1\n0 1 0\n-1 -1 -1", "40 53 -2\n0 7 -1\n0 1 -1\n-1 -1 -1"], "out...
444
302
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 string $S$. He also has another string $P$, called *pattern*. He wants to find the pattern in $S$, but that might be impossible. Therefore...
{"inputs": ["3\nakramkeeanany\naka\nsupahotboy\nbohoty\ndaehabshatorawy\nbadawy"], "outputs": ["aaakaeekmnnry\nabohotypsu\naabadawyehhorst"]}
479
57
coding
Solve the programming task below in a Python markdown code block. Alice and Bob invented the following silly game: The game starts with an integer, $n$, that's used to build a $\boldsymbol{set}$ of $n$ distinct integers in the inclusive range from $1$ to $n$ (i.e., $set=\{1,2,3,\ldots,n-1,n\}$). Alice always plays fir...
{"inputs": ["3\n1\n2\n5\n"], "outputs": ["Bob\nAlice\nAlice\n"]}
679
24
coding
Solve the programming task below in a Python markdown code block. Vasily the bear has got a sequence of positive integers a_1, a_2, ..., a_{n}. Vasily the Bear wants to write out several numbers on a piece of paper so that the beauty of the numbers he wrote out was maximum. The beauty of the written out numbers b_1, ...
{"inputs": ["1\n1\n", "1\n1\n", "1\n315\n", "1\n284\n", "1\n535\n", "1\n785\n", "1\n805\n", "1\n6360\n"], "outputs": ["1\n1\n", "1\n1 ", "1\n315\n", "1\n284\n", "1\n535\n", "1\n785\n", "1\n805\n", "1\n6360\n"]}
497
127
coding
Solve the programming task below in a Python markdown code block. In Japan, people make offerings called hina arare, colorful crackers, on March 3. We have a bag that contains N hina arare. (From here, we call them arare.) It is known that the bag either contains arare in three colors: pink, white and green, or contain...
{"inputs": ["6\nG W Y Q Y W", "6\nG X X O X X", "6\nF W Y P Y W", "6\nF W Y O Y W", "6\nG W Y O Y W", "6\nE W Y O Y W", "6\nF W Y Q Y W", "6\nE W Y P Y W"], "outputs": ["Four\n", "Three\n", "Four\n", "Four\n", "Four\n", "Four\n", "Four\n", "Four\n"]}
315
118
coding
Solve the programming task below in a Python markdown code block. You can obtain profits from foreign exchange margin transactions. For example, if you buy 1000 dollar at a rate of 100 yen per dollar, and sell them at a rate of 108 yen per dollar, you can obtain (108 - 100) × 1000 = 8000 yen. Write a program which rea...
{"inputs": ["3\n4\n1\n2", "3\n4\n1\n3", "3\n5\n0\n6", "3\n3\n0\n9", "3\n2\n0\n0", "3\n4\n2\n3", "3\n5\n2\n3", "3\n5\n0\n3"], "outputs": ["1\n", "2\n", "6\n", "9\n", "0\n", "1\n", "1\n", "3\n"]}
277
110
coding
Solve the programming task below in a Python markdown code block. n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out a_{i} pe...
{"inputs": ["2 1\n1\n", "2 1\n2\n", "2 1\n3\n", "2 1\n1\n", "2 1\n3\n", "2 1\n2\n", "3 1\n2\n", "3 1\n1\n"], "outputs": ["2 \n", "1 \n", "2 \n", "2\n", "2\n", "1\n", "3\n", "2\n"]}
438
105
coding
Solve the programming task below in a Python markdown code block. Chef is deriving weird ways to sort his array. Currently he is trying to sort his arrays in increasing order by reversing some of his subarrays. To make it more challenging for himself, Chef decides that he can reverse only those subarrays that have sum...
{"inputs": ["3\n4 1\n1 2 3 4\n4 1\n2 1 3 4\n5 7\n3 2 2 3 3\n"], "outputs": ["YES\nNO\nYES\n"]}
624
56
coding
Solve the programming task below in a Python markdown code block. There is a sequence of colorful stones. The color of each stone is one of red, green, or blue. You are given a string s. The i-th (1-based) character of s represents the color of the i-th stone. If the character is "R", "G", or "B", the color of the corr...
{"inputs": ["R\nB\n", "R\nB\n", "S\nB\n", "S\nC\n", "S\nD\n", "T\nD\n", "U\nD\n", "R\nD\n"], "outputs": ["1\n", "1", "1\n", "1\n", "1\n", "1\n", "1\n", "1\n"]}
437
85
coding
Solve the programming task below in a Python markdown code block. Little Petya very much likes computers. Recently he has received a new "Ternatron IV" as a gift from his mother. Unlike other modern computers, "Ternatron IV" operates with ternary and not binary logic. Petya immediately wondered how the xor operation is...
{"inputs": ["1 0\n", "0 0\n", "0 1\n", "5 5\n", "14 34\n", "50 34\n", "524 8790\n", "5849 7211\n"], "outputs": ["2\n", "0\n", "1\n", "0\n", "50\n", "14\n", "8998\n", "10146\n"]}
437
110
coding
Solve the programming task below in a Python markdown code block. Chef has a pepperoni pizza in the shape of a $N \times N$ grid; both its rows and columns are numbered $1$ through $N$. Some cells of this grid have pepperoni on them, while some do not. Chef wants to cut the pizza vertically in half and give the two hal...
{"inputs": ["2\n6\n100000\n100000\n100000\n100000\n010010\n001100\n4\n0011\n1100\n1110\n0001"], "outputs": ["2\n0"]}
668
80
coding
Solve the programming task below in a Python markdown code block. Chef has N friends. Chef promised that he would gift a pair of shoes (consisting of one left shoe and one right shoe) to each of his N friends. Chef was about to go to the marketplace to buy shoes, but he suddenly remembers that he already had M left sho...
{"inputs": ["3\n2 4\n6 0\n4 3\n"], "outputs": ["2\n12\n5\n"]}
426
31
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. In English, we have a concept called root, which can be followed by some other word to form another longer word - let's call this word derivative. For example, when the root "help" is followed by the word "ful", we ca...
{"functional": "def check(candidate):\n assert candidate(dictionary = [\"cat\",\"bat\",\"rat\"], sentence = \"the cattle was rattled by the battery\") == \"the cat was rat by the bat\"\n assert candidate(dictionary = [\"a\",\"b\",\"c\"], sentence = \"aadsfasf absbs bbab cadsfafs\") == \"a a b c\"\n\n\ncheck(Solut...
169
94
coding
Solve the programming task below in a Python markdown code block. Consider an infinite sequence a_1, a_2, … Initially, the values of all the terms are 0, and from this state we will sequentially perform Q operations. The i-th operation (1 ≤ i ≤ Q) is as follows: * For every positive integer j, add x_i to the value of ...
{"inputs": ["3\n4 9\n3 -20\n2 18", "3\n7 9\n62 0\n111 1", "3\n2 10\n3 -4\n6 15", "3\n2 1\n4 -20\n6 15", "3\n2 18\n3 -20\n6 15", "3\n7 -3\n15 0\n110 0", "3\n2 18\n4 -20\n6 15", "3\n36 -3\n6 4\n111 2"], "outputs": ["27\n", "10\n", "21\n", "16\n", "18\n", "0\n", "33\n", "6\n"]}
310
185
coding
Solve the programming task below in a Python markdown code block. How many licks does it take to get to the tootsie roll center of a tootsie pop? A group of engineering students from Purdue University reported that its licking machine, modeled after a human tongue, took an average of 364 licks to get to the center of ...
{"functional": "_inputs = [[{'freezing temps': 10, 'clear skies': -2}], [{'happiness': -5, 'clear skies': -2}], [{}], [{'dragons': 100, 'evil wizards': 110, 'trolls': 50}], [{'white magic': -250}]]\n_outputs = [['It took 260 licks to get to the tootsie roll center of a tootsie pop. The toughest challenge was freezing t...
571
361
coding
Solve the programming task below in a Python markdown code block. Read problems statements in [Mandarin Chinese], [Russian], [Vietnamese] and [Bengali] as well. Chef is playing a game where he has an array $A$ of $N$ integers, and an integer $K$. He looks at every subarray of length $K$, and writes its sum on a piece ...
{"inputs": ["2\n3 3 \n1 2 3\n2 1\n4 6"], "outputs": ["0\n1"]}
477
33
coding
Solve the programming task below in a Python markdown code block. Takahashi has N days of summer vacation. His teacher gave him M summer assignments. It will take A_i days for him to do the i-th assignment. He cannot do multiple assignments on the same day, or hang out on a day he does an assignment. What is the maximu...
{"inputs": ["1 2\n0 1", "4 6\n2 0", "3 2\n7 4", "3 2\n7 8", "1 2\n7 8", "2 2\n7 8", "2 2\n6 8", "0 2\n6 8"], "outputs": ["0\n", "2\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n"]}
286
110
coding
Solve the programming task below in a Python markdown code block. Read problems statements in Russian also. Chef likes shopping, and especially he likes to buy oranges. But right now he is short of money. He has only k rubles. There are n oranges. The i-th one costs cost_{i} rubles and has weight equal to weight_{i}. ...
{"inputs": ["2\n1 3\n2 2\n3 4\n2 1\n2 2\n3 5", "2\n1 3\n2 2\n3 4\n2 2\n2 2\n3 5", "2\n1 3\n2 2\n1 4\n2 3\n2 2\n3 5", "2\n1 3\n2 3\n1 4\n2 3\n2 2\n3 5", "2\n1 3\n2 4\n1 4\n2 3\n2 2\n3 5", "2\n1 3\n2 2\n3 4\n0 1\n2 2\n3 5", "2\n2 3\n2 2\n3 4\n2 2\n2 2\n3 5", "2\n1 3\n2 2\n1 4\n2 1\n2 2\n3 5"], "outputs": ["2\n5", "2\n5\n...
357
269
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. You are given two arrays of positive integers, boxes and warehouse, representing the heights of some boxes of unit width and the heights of n rooms in a warehouse respectively. The warehouse's rooms are labelled from ...
{"functional": "def check(candidate):\n assert candidate(boxes = [4,3,4,1], warehouse = [5,3,3,4,1]) == 3\n assert candidate(boxes = [1,2,2,3,4], warehouse = [3,4,1,2]) == 3\n assert candidate(boxes = [1,2,3], warehouse = [1,2,3,4]) == 1\n\n\ncheck(Solution().maxBoxesInWarehouse)"}
211
113
coding
Solve the programming task below in a Python markdown code block. Complete the function solveMeFirst to compute the sum of two integers. Example $a=7$ $b=3$ Return $10$. Function Description Complete the solveMeFirst function in the editor below. solveMeFirst has the following parameters: int a: the fir...
{"inputs": ["2\n3\n"], "outputs": ["5\n"]}
140
16
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. You are given a string number representing a positive integer and a character digit. Return the resulting string after removing exactly one occurrence of digit from number such that the value of the resulting string i...
{"functional": "def check(candidate):\n assert candidate(number = \"123\", digit = \"3\") == \"12\"\n assert candidate(number = \"1231\", digit = \"1\") == \"231\"\n assert candidate(number = \"551\", digit = \"5\") == \"51\"\n\n\ncheck(Solution().removeDigit)"}
109
84
coding
Solve the programming task below in a Python markdown code block. You have an array $a$ of length $n$. For every positive integer $x$ you are going to perform the following operation during the $x$-th second: Select some distinct indices $i_{1}, i_{2}, \ldots, i_{k}$ which are between $1$ and $n$ inclusive, and add ...
{"inputs": ["3\n4\n1 7 6 5\n5\n1 2 3 4 5\n2\n0 -4\n", "3\n4\n1 7 7 5\n5\n1 2 3 4 5\n2\n0 -4\n", "3\n4\n1 7 6 5\n5\n1 4 3 4 5\n2\n0 -4\n", "3\n4\n1 7 6 5\n5\n1 6 3 4 5\n2\n0 -4\n", "3\n4\n1 7 7 5\n5\n1 0 3 4 5\n2\n0 -1\n", "3\n4\n1 7 7 7\n5\n1 0 3 4 5\n2\n0 -8\n", "3\n4\n1 7 7 4\n5\n1 2 9 0 1\n2\n-1 0\n", "3\n4\n1 7 7 8...
615
328
coding
Solve the programming task below in a Python markdown code block. Create a __moreZeros__ function which will __receive a string__ for input, and __return an array__ (or null terminated string in C) containing only the characters from that string whose __binary representation of its ASCII value__ consists of _more zeros...
{"functional": "_inputs = [['abcde'], ['thequickbrownfoxjumpsoverthelazydog'], ['THEQUICKBROWNFOXJUMPSOVERTHELAZYDOG'], ['abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890_'], ['DIGEST'], ['abcdabcd'], ['Forgiveness is the fragrance that the violet sheds on the heal that has crushed it']]\n_outputs = [[['a...
157
393
coding
Solve the programming task below in a Python markdown code block. CODE FESTIVAL 2016 is going to be held. For the occasion, Mr. Takahashi decided to make a signboard. He intended to write `CODEFESTIVAL2016` on it, but he mistakenly wrote a different string S. Fortunately, the string he wrote was the correct length. S...
{"inputs": ["C0DEFESTIVAL2O61", "EDOC6102LAVITSEF", "C0DEFERTIVAL2O61", "C0DEGERTIVAL2O61", "CTDEGER0IVAL2O61", "CT/EGERDIVAL2O61", "CT0EGERDIVAK2O61", "1DO2LAVI6REGE0TC"], "outputs": ["4\n", "16\n", "5\n", "6\n", "7\n", "8\n", "9\n", "15\n"]}
220
134
coding
Solve the programming task below in a Python markdown code block. Your classmates asked you to copy some paperwork for them. You know that there are 'n' classmates and the paperwork has 'm' pages. Your task is to calculate how many blank pages do you need. ### Example: ```python paperwork(5, 5) == 25 ``` **Note:** i...
{"functional": "_inputs = [[5, 5], [5, -5], [-5, -5], [-5, 5], [5, 0]]\n_outputs = [[25], [0], [0], [0], [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 isinstance(a, (list, tuple)):\n if l...
128
195
coding
Solve the programming task below in a Python markdown code block. Depth-first search (DFS) follows the strategy to search ”deeper” in the graph whenever possible. In DFS, edges are recursively explored out of the most recently discovered vertex $v$ that still has unexplored edges leaving it. When all of $v$'s edges hav...
{"inputs": ["4\n1 1 1\n2 1 4\n3 0\n4 1 3", "4\n1 1 1\n2 1 4\n3 0\n4 1 2", "4\n1 1 3\n2 1 4\n3 0\n4 1 3", "4\n1 1 3\n2 1 1\n3 0\n4 1 3", "4\n1 1 2\n2 1 4\n3 0\n4 1 2", "4\n1 1 2\n2 1 2\n3 0\n4 1 3", "4\n1 1 1\n2 1 1\n3 0\n4 1 2", "4\n1 1 1\n2 1 3\n3 0\n4 1 3"], "outputs": ["1 1 2\n2 3 8\n3 5 6\n4 4 7\n", "1 1 2\n2 3 6\n...
601
414
coding
Solve the programming task below in a Python markdown code block. # Task John is playing a RPG game. The initial attack value of the player is `x`. The player will face a crowd of monsters. Each monster has different defense value. If the monster's defense value is less than or equal to the player's attack value, the...
{"functional": "_inputs = [[50, [50, 105, 200]], [20, [30, 20, 15, 40, 100]]]\n_outputs = [[110], [205]]\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)...
347
202
coding
Solve the programming task below in a Python markdown code block. A film festival is coming up in the city N. The festival will last for exactly n days and each day will have a premiere of exactly one film. Each film has a genre — an integer from 1 to k. On the i-th day the festival will show a movie of genre a_{i}. W...
{"inputs": ["2 2\n1 2\n", "2 2\n1 2\n", "7 3\n3 1 3 2 3 1 2\n", "7 3\n3 1 2 2 3 1 2\n", "7 3\n3 1 2 3 3 1 2\n", "7 3\n3 1 3 2 3 1 2\n", "10 3\n1 1 2 3 2 3 3 1 1 3\n", "10 2\n1 2 2 1 1 2 1 1 2 2\n"], "outputs": ["1", "1\n", "1", "1\n", "1\n", "1\n", "3", "1"]}
676
188
coding
Solve the programming task below in a Python markdown code block. Congratulations !!! You have successfully completed the heist by looting all the gifts in Santa's locker. Now it's time to decide who gets to take all the gifts, you or the Grinch, there will be no splitting. So you and Grinch decide to play a game. To s...
{"inputs": ["7\n1\n2\n3\n4\n5\n6\n12"], "outputs": ["Grinch\nMe\nMe\nGrinch\nMe\nGrinch\nMe"]}
303
42
coding
Solve the programming task below in a Python markdown code block. You have to rebuild a string from an enumerated list. For this task, you have to check if input is correct beforehand. * Input must be a list of tuples * Each tuple has two elements. * Second element is an alphanumeric character. * First element is the ...
{"functional": "_inputs = [[1], ['a'], [[0]], [[['a', 0]]], [[[1, 'a']]], [[[0, '']]]]\n_outputs = [[False], [False], [False], [False], [False], [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...
187
196
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. There exists an undirected and unrooted tree with n nodes indexed from 0 to n - 1. You are given an integer n and a 2D integer array edges of length n - 1, where edges[i] = [ai, bi] indicates that there is an edge bet...
{"functional": "def check(candidate):\n assert candidate(coins = [1,0,0,0,0,1], edges = [[0,1],[1,2],[2,3],[3,4],[4,5]]) == 2\n assert candidate(coins = [0,0,0,1,1,0,0,1], edges = [[0,1],[0,2],[1,3],[1,4],[2,5],[5,6],[5,7]]) == 2\n\n\ncheck(Solution().collectTheCoins)"}
268
124
coding
Solve the programming task below in a Python markdown code block. # Remove Duplicates You are to write a function called `unique` that takes an array of integers and returns the array with duplicates removed. It must return the values in the same order as first seen in the given array. Thus no sorting should be done, ...
{"functional": "_inputs = [[[]], [[-1]], [[-1, 5, 10, -100, 3, 2]], [[1, 2, 3, 3, 2, 1, 2, 3, 1, 1, 3, 2]], [[1, 3, 2, 3, 2, 1, 2, 3, 1, 1, 3, 2]], [[3, 2, 3, 3, 2, 1, 2, 3, 1, 1, 3, 2]]]\n_outputs = [[[]], [[-1]], [[-1, 5, 10, -100, 3, 2]], [[1, 2, 3]], [[1, 3, 2]], [[3, 2, 1]]]\nimport math\ndef _deep_eq(a, b, tol=1e...
246
340
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. You are given a string array words and a string s, where words[i] and s comprise only of lowercase English letters. Return the number of strings in words that are a prefix of s. A prefix of a string is a substring tha...
{"functional": "def check(candidate):\n assert candidate(words = [\"a\",\"b\",\"c\",\"ab\",\"bc\",\"abc\"], s = \"abc\") == 3\n assert candidate(words = [\"a\",\"a\"], s = \"aa\") == 2\n\n\ncheck(Solution().countPrefixes)"}
121
70
coding
Solve the programming task below in a Python markdown code block. You are given three integers $n$, $a$, and $b$. Determine if there exist two permutations $p$ and $q$ of length $n$, for which the following conditions hold: The length of the longest common prefix of $p$ and $q$ is $a$. The length of the longest commo...
{"inputs": ["4\n1 1 1\n2 1 2\n3 1 1\n4 1 1\n"], "outputs": ["Yes\nNo\nNo\nYes\n"]}
435
44
coding
Solve the programming task below in a Python markdown code block. Bob is a dance teacher and he started dance classes recently. He observes a strange attendance pattern among his students. Initially, there are no students. On day i, a new student starts attending the class. The student stops attending the class, if and...
{"inputs": ["4\n1\n2\n3\n4\n"], "outputs": ["odd\nodd\nodd\neven\n"]}
572
29
coding
Solve the programming task below in a Python markdown code block. Write a regex to validate a 24 hours time string. See examples to figure out what you should check for: Accepted: 01:00 - 1:00 Not accepted: 24:00 You should check for correct length and no spaces. Also feel free to reuse/extend the following start...
{"functional": "_inputs = [['1:00'], ['13:1'], ['12:60'], ['12: 60'], ['24:00'], ['00:00'], ['24o:00'], ['24:000'], [''], ['09:00'], ['2400'], ['foo12:00bar'], ['010:00'], ['1;00']]\n_outputs = [[True], [False], [False], [False], [False], [True], [False], [False], [False], [True], [False], [False], [False], [False]]\ni...
91
285
coding
Solve the programming task below in a Python markdown code block. Mihai has an $8 \times 8$ chessboard whose rows are numbered from $1$ to $8$ from top to bottom and whose columns are numbered from $1$ to $8$ from left to right. Mihai has placed exactly one bishop on the chessboard. The bishop is not placed on the edg...
{"inputs": ["3\n\n.....#..\n#...#...\n.#.#....\n..#.....\n.#.#....\n#...#...\n.....#..\n......#.\n\n#.#.....\n.#......\n#.#.....\n...#....\n....#...\n.....#..\n......#.\n.......#\n\n.#.....#\n..#...#.\n...#.#..\n....#...\n...#.#..\n..#...#.\n.#.....#\n#.......\n"], "outputs": ["4 3\n2 2\n4 5\n"]}
502
136
coding
Solve the programming task below in a Python markdown code block. # Personalized greeting Create a function that gives a personalized greeting. This function takes two parameters: `name` and `owner`. Use conditionals to return the proper message: case | return --- | --- name equals owner | 'Hello boss' otherwise ...
{"functional": "_inputs = [['Daniel', 'Daniel'], ['Greg', 'Daniel']]\n_outputs = [['Hello boss'], ['Hello guest']]\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 ...
93
168
coding
Solve the programming task below in a Python markdown code block. There are just some things you can't do on television. In this case, you've just come back from having a "delicious" Barth burger and you're set to give an interview. The Barth burger has made you queezy, and you've forgotten some of the import rules of ...
{"functional": "_inputs = [['water'], ['wet'], ['wash'], [\"i don't know\"], ['slime'], ['wet water'], ['slime water'], [\"I don't know if this will work\"], [\"I don't know if this will work without watering it first.\"], [''], ['is there SLIME in that?!'], [\"i won't say anything\"], ['WaTeR?'], ['but i can say sludg...
414
381
coding
Solve the programming task below in a Python markdown code block. You are playing a variation of game 2048. Initially you have a multiset $s$ of $n$ integers. Every integer in this multiset is a power of two. You may perform any number (possibly, zero) operations with this multiset. During each operation you choose ...
{"inputs": ["6\n4\n1024 512 8 512\n1\n2048\n3\n32 512 2\n2\n4096 1\n1\n2048 2 2048 2048 2048 2048 2048\n2\n2048 4096\n", "6\n4\n1024 512 64 512\n1\n2048\n3\n64 512 2\n2\n4096 4\n7\n2048 2 2048 2048 2048 2048 2048\n2\n2048 4096\n", "6\n4\n1024 512 64 512\n1\n2048\n3\n64 512 2\n2\n4096 4\n1\n2048 2 2048 2048 2048 2048 20...
720
877
coding
Solve the programming task below in a Python markdown code block. Nickname Generator Write a function, `nicknameGenerator` that takes a string name as an argument and returns the first 3 or 4 letters as a nickname. If the 3rd letter is a consonant, return the first 3 letters. If the 3rd letter is a vowel, return the...
{"functional": "_inputs = [['Jimmy'], ['Samantha'], ['Sam'], ['Kayne'], ['Melissa'], ['James'], ['Gregory'], ['Jeannie'], ['Kimberly'], ['Timothy'], ['Dani'], ['Saamy'], ['Saemy'], ['Saimy'], ['Saomy'], ['Saumy'], ['Boyna'], ['Kiyna'], ['Sayma'], ['Ni'], ['Jam'], ['Suv']]\n_outputs = [['Jim'], ['Sam'], ['Error: Name to...
176
323
coding
Solve the programming task below in a Python markdown code block. AtCoDeer the deer recently bought three paint cans. The color of the one he bought two days ago is a, the color of the one he bought yesterday is b, and the color of the one he bought today is c. Here, the color of each paint can is represented by an int...
{"inputs": ["3 2 4", "2 2 2", "3 2 0", "3 4 0", "3 7 0", "8 0 1", "3 7 1", "6 4 0"], "outputs": ["3\n", "1\n", "3\n", "3\n", "3\n", "3\n", "3\n", "3\n"]}
201
94
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 integer matrix. You can do the following operation any number of times: Choose any two adjacent elements of matrix and multiply each of them by -1. Two elements are considered adjacent if and ...
{"functional": "def check(candidate):\n assert candidate(matrix = [[1,-1],[-1,1]]) == 4\n assert candidate(matrix = [[1,2,3],[-1,-2,-3],[1,2,3]]) == 16\n\n\ncheck(Solution().maxMatrixSum)"}
130
67
coding
Solve the programming task below in a Python markdown code block. How many non decreasing sequences are there of length ${K}$, with the condition that numbers in sequence can take values only from $1,2,3,\cdots N$ and gcd of all numbers in the sequence must be ${1}$. Input Format The first line contains an integer $...
{"inputs": ["4\n2 4 \n3 4\n5 2\n1 10\n"], "outputs": ["4\n13\n10\n1\n"]}
501
40
coding
Solve the programming task below in a Python markdown code block. A frog lives on the axis Ox and needs to reach home which is in the point n. She starts from the point 1. The frog can jump to the right at a distance not more than d. So, after she jumped from the point x she can reach the point x + a, where a is an int...
{"inputs": ["2 1\n11\n", "2 1\n11\n", "4 2\n1001\n", "4 2\n1001\n", "5 4\n11011\n", "5 4\n10001\n", "5 4\n11011\n", "5 4\n10001\n"], "outputs": ["1\n", "1\n", "-1\n", "-1\n", "1\n", "1\n", "1\n", "1\n"]}
528
126
coding
Solve the programming task below in a Python markdown code block. After the educational reform Polycarp studies only two subjects at school, Safety Studies and PE (Physical Education). During the long months of the fourth term, he received n marks in them. When teachers wrote a mark in the journal, they didn't write in...
{"inputs": ["2\n1 1\n1 2\n", "2\n1 1\n4 4\n", "2\n1 1\n5 1\n", "2\n1 1\n1 1\n", "2\n1 1\n1 0\n", "2\n1 1\n1 3\n", "2\n1 1\n0 4\n", "2\n1 1\n5 0\n"], "outputs": ["1 2\n", "1 2\n", "1 2\n", "1 2\n", "1 2\n", "1 2\n", "1 2\n", "1 2\n"]}
608
150
coding
Solve the programming task below in a Python markdown code block. There are $b$ boys and $g$ girls participating in Olympiad of Metropolises. There will be a board games tournament in the evening and $n$ participants have accepted the invitation. The organizers do not know how many boys and girls are among them. Organ...
{"inputs": ["5\n6\n3\n", "5\n3\n5\n", "1\n1\n1\n", "1\n1\n2\n", "3\n3\n4\n", "4\n4\n5\n", "4\n4\n7\n", "3\n3\n5\n"], "outputs": ["4\n", "4\n", "2\n", "1\n", "3\n", "4\n", "2\n", "2\n"]}
445
102
coding
Solve the programming task below in a Python markdown code block. Pak Chanek plans to build a garage. He wants the garage to consist of a square and a right triangle that are arranged like the following illustration. Define $a$ and $b$ as the lengths of two of the sides in the right triangle as shown in the illustrati...
{"inputs": ["3\n", "6\n", "5\n", "8\n", "4\n", "2\n", "1\n", "10\n"], "outputs": ["7\n", "11\n", "9\n", "13\n", "8\n", "5\n", "3\n", "16\n"]}
243
74
coding
Solve the programming task below in a Python markdown code block. Chef likes to play with big numbers. Today, he has a big positive integer N. He can select any two digits from this number (the digits can be same but their positions should be different) and orders them in any one of the two possible ways. For each of t...
{"inputs": ["4\n65\n566\n11\n1623455078"], "outputs": ["A\nAB\nACDFGHIJKLNPQRSTUVW"]}
467
45
coding
Solve the programming task below in a Python markdown code block. You are given a positive integer $x$. You can apply the following operation to the number: remove one occurrence of any digit in such a way that the resulting number does not contain any leading zeroes and is still a positive integer. For example, $1014...
{"inputs": ["5\n10000\n4\n1337\n0\n987654321\n6\n66837494128\n5\n7808652\n3\n"], "outputs": ["1\n1337\n321\n344128\n7052\n"]}
417
86
coding
Solve the programming task below in a Python markdown code block. A number, ${x}$, is called irresponsible when adding ${x}$ to $x+1$ requires a carry operation. For example, $5$, $17$, and ${91}$ are irresponsible numbers because adding them to ${6}$, ${18}$, and $92$ (respectively) requires a carry operation: In $5+...
{"inputs": ["1 2\n"], "outputs": ["4\n"]}
711
16
coding
Solve the programming task below in a Python markdown code block. A ticket is a string consisting of six digits. A ticket is considered lucky if the sum of the first three digits is equal to the sum of the last three digits. Given a ticket, output if it is lucky or not. Note that a ticket can have leading zeroes. ---...
{"inputs": ["1\n114514\n", "1\n975310\n", "1\n666999\n", "1\n975319\n", "2\n193758\n123456\n", "2\n192758\n123456\n", "5\n213132\n973894\n045207\n000000\n055776\n"], "outputs": ["NO\n", "NO\n", "NO\n", "NO\n", "NO\nNO\n", "NO\nNO\n", "YES\nNO\nYES\nYES\nNO\n"]}
428
165
coding
Solve the programming task below in a Python markdown code block. Chef just got a box of chocolates as his birthday gift. The box contains $N$ chocolates in a row (numbered $1$ through $N$), where $N$ is even. For each valid $i$, the $i$-th chocolate has a sweetness value $W_i$. Chef wants to eat all the chocolates in ...
{"inputs": ["2\n6\n1 1 2 1 1 1\n6\n1 1 2 1 1 2"], "outputs": ["3\n0"]}
588
42
coding
Solve the programming task below in a Python markdown code block. You are given three words s_1, s_2 and s_3, each composed of lowercase English letters, with spaces in between. Print the acronym formed from the uppercased initial letters of the words. -----Constraints----- - s_1, s_2 and s_3 are composed of lowercas...
{"inputs": ["k nearest robhgien", "k tseraen robhgien", "l tseraeo robhgien", "l oearest robghien", "l oearest neihgbor", "l pearest neihgbor", "m pearest neihgbor", "m tseraep neihgbor"], "outputs": ["KNR\n", "KTR\n", "LTR\n", "LOR\n", "LON\n", "LPN\n", "MPN\n", "MTN\n"]}
171
118
coding
Solve the programming task below in a Python markdown code block. There is a kangaroo at coordinate 0 on an infinite number line that runs from left to right, at time 0. During the period between time i-1 and time i, the kangaroo can either stay at his position, or perform a jump of length exactly i to the left or to t...
{"inputs": ["4", "1", "3", "6", "2", "12", "19", "24"], "outputs": ["3\n", "1\n", "2\n", "3", "2", "5\n", "6\n", "7\n"]}
217
63
coding
Solve the programming task below in a Python markdown code block. You are given a set of all integers from $l$ to $r$ inclusive, $l < r$, $(r - l + 1) \le 3 \cdot 10^5$ and $(r - l)$ is always odd. You want to split these numbers into exactly $\frac{r - l + 1}{2}$ pairs in such a way that for each pair $(i, j)$ the gr...
{"inputs": ["1 8\n", "1 2\n", "2 3\n", "4 9\n", "3 6\n", "2 7\n", "2 7\n", "1 2\n"], "outputs": ["YES\n1 2\n3 4\n5 6\n7 8\n", "YES\n1 2\n", "YES\n2 3\n", "YES\n4 5\n6 7\n8 9\n", "YES\n3 4\n5 6\n", "YES\n2 3\n4 5\n6 7\n", "YES\n2 3\n4 5\n6 7\n", "YES\n1 2\n"]}
344
158
coding
Solve the programming task below in a Python markdown code block. You are given $n$ dominoes. Each domino has a left and a right cell. Each cell can be colored either black or white. Some cells are already colored, while some aren't yet. The coloring is said to be valid if and only if it is possible to rearrange the d...
{"inputs": ["1\n?W\n", "1\nW?\n", "1\n?W\n", "2\n??\nW?\n", "2\n??\n?W\n", "2\n??\nW?\n", "4\nBB\n??\nW?\n??\n", "4\nBB\n??\n?W\n??\n"], "outputs": ["1\n", "1\n", "1", "2\n", "2\n", "2", "10\n", "10\n"]}
467
119
coding
Solve the programming task below in a Python markdown code block. Working from left-to-right if no digit is exceeded by the digit to its left it is called an increasing number; for example, 134468. Similarly if no digit is exceeded by the digit to its right it is called a decreasing number; for example, 66420. We sha...
{"functional": "_inputs = [[0.1], [0.15], [0.5], [0.75], [0.9]]\n_outputs = [[132], [160], [538], [3088], [21780]]\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 ...
323
204
coding
Solve the programming task below in a Python markdown code block. A: IP Address (Internet Protocol Address) problem Since one number string is given, find the number of valid delimiters for IPv4 IP addresses. However, the effective delimiters for IPv4 IP addresses are as follows. * The sequence of numbers is divided...
{"inputs": ["17", "15", "14", "25", "16", "59", "13", "30"], "outputs": ["0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n"]}
282
70
coding
Solve the programming task below in a Python markdown code block. A: Information Search problem The posting list is a list in which there is a correspondence between the search term and the appearing document ID. For example * Hokkaido: 1, 2, 4, 9 * Sightseeing: 1, 3, 4, 7 And so on. From the above posting list,...
{"inputs": ["4 4\n1 2 5 9\n1 3 4 7", "4 4\n1 2 5 9\n2 3 4 7", "4 4\n1 2 4 9\n0 3 4 7", "4 4\n1 2 5 9\n0 3 4 7", "4 4\n1 3 5 9\n0 3 4 7", "4 4\n1 2 5 9\n1 2 4 7", "4 4\n1 2 5 9\n1 3 4 8", "4 4\n1 2 7 9\n0 3 4 7"], "outputs": ["1 7\n1\n1\n2\n3\n4\n5\n7\n9\n", "1 7\n2\n1\n2\n3\n4\n5\n7\n9\n", "1 7\n4\n0\n1\n2\n3\n4\n7\n9\...
599
350
coding
Solve the programming task below in a Python markdown code block. Given the number pledged for a year, current value and name of the month, return string that gives information about the challenge status: - ahead of schedule - behind schedule - on track - challenge is completed Examples: `(12, 1, "February")` - shou...
{"functional": "_inputs = [[12, 5, 'January'], [12, 1, 'February'], [12, 1, 'March'], [12, 12, 'September'], [12, 5, 'March'], [100, 5, 'March'], [100, 52, 'July'], [100, 51, 'July'], [100, 53, 'July']]\n_outputs = [['You are on track.'], ['You are on track.'], ['You are 1 behind schedule.'], ['Challenge is completed.'...
276
321
coding
Solve the programming task below in a Python markdown code block. For any positive integer, we define a digit rotation as either moving the first digit to the end of the number (left digit rotation), or the last digit to the front of the number (right digit rotation). For example, the number 12345 could be left digit r...
{"inputs": ["6\n2528\n18211\n575\n268\n1\n257", "6\n4360\n18211\n575\n268\n1\n257", "6\n4360\n18211\n575\n268\n1\n443", "6\n4360\n18211\n575\n268\n1\n145", "6\n5788\n18211\n575\n268\n1\n145", "6\n5788\n32221\n575\n268\n1\n145", "6\n1689\n7692\n14761\n5838\n3\n68", "6\n1689\n7692\n14761\n8668\n3\n68"], "outputs": ["8252...
321
450
coding
Solve the programming task below in a Python markdown code block. I, Fischl, Prinzessin der Verurteilung, descend upon this land by the call of fate an — Oh, you are also a traveler from another world? Very well, I grant you permission to travel with me. It is no surprise Fischl speaks with a strange choice of words. ...
{"inputs": ["1\n25\nabcdefghijklmnopqrstuvwxy\n", "1\n25\nyxwvutsrqponmlkjihgfedcba\n", "1\n25\nabcdefghijklmnooqrstuvwxy\n", "1\n25\nyxwvutrrqponmlkjihgfedcba\n", "1\n25\nyxwvutsrlponmqkjihgfedcba\n", "1\n41\nsugimotomikasaackermannelectromasterjsoap\n", "1\n41\nsugimotomikasaacjermannelectromasterjsoap\n", "1\n21\nsu...
498
198
coding
Solve the programming task below in a Python markdown code block. -----Problem Statement----- A classroom has several students, half of whom are boys and half of whom are girls. You need to arrange all of them in a line for the morning assembly such that the following conditions are satisfied: - The students must be in...
{"inputs": ["1\n2\n1 3\n2 4"], "outputs": ["YES"]}
605
22
coding
Solve the programming task below in a Python markdown code block. Mark is asked to take a group photo of $2n$ people. The $i$-th person has height $h_i$ units. To do so, he ordered these people into two rows, the front row and the back row, each consisting of $n$ people. However, to ensure that everyone is seen proper...
{"inputs": ["3\n3 6\n1 3 9 10 12 16\n3 1\n2 5 2 2 2 5\n1 2\n8 6\n"], "outputs": ["YES\nNO\nYES\n"]}
625
61
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. You are given a range of integers $\{L, L+1, \ldots, R\}$. An integer $X$ is said to be *reachable* if it can be represented as a sum of two not nec...
{"inputs": ["2\n2 2\n2 3"], "outputs": ["1\n3"]}
312
22
coding
Solve the programming task below in a Python markdown code block. Pasha has two hamsters: Arthur and Alexander. Pasha put n apples in front of them. Pasha knows which apples Arthur likes. Similarly, Pasha knows which apples Alexander likes. Pasha doesn't want any conflict between the hamsters (as they may like the same...
{"inputs": ["1 1 1\n1\n1\n", "2 1 1\n2\n1\n", "2 1 1\n1\n2\n", "2 1 1\n2\n1\n", "1 1 1\n1\n1\n", "2 1 1\n1\n2\n", "1 1 0\n1\n1\n", "1 1 0\n1\n0\n"], "outputs": ["1\n", "2 1\n", "1 2\n", "2 1 ", "1 ", "1 2 ", "1\n", "1\n"]}
406
139
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. You are given a 0-indexed integer array tasks, where tasks[i] represents the difficulty level of a task. In each round, you can complete either 2 or 3 tasks of the same difficulty level. Return the minimum rounds requ...
{"functional": "def check(candidate):\n assert candidate(tasks = [2,2,3,3,2,4,4,4,4,4]) == 4\n assert candidate(tasks = [2,3,3]) == -1\n\n\ncheck(Solution().minimumRounds)"}
118
66
coding
Solve the programming task below in a Python markdown code block. *Chef has recently introduced a [feature] which allows you to open any user’s submitted code (not just your own), and ask an AI to explain that code in English. For example, you can go to https://www.codechef.com/viewsolution/70530506 and click on "Analy...
{"inputs": ["50\n", "1000\n", "1001\n"], "outputs": ["Yes", "Yes", "No"]}
435
34
coding
Solve the programming task below in a Python markdown code block. Petya loves hockey very much. One day, as he was watching a hockey match, he fell asleep. Petya dreamt of being appointed to change a hockey team's name. Thus, Petya was given the original team name w and the collection of forbidden substrings s1, s2, .....
{"inputs": ["3\na\nA\na\nA\nb\n", "3\na\nA\na\nA\na\n", "3\na\nA\nb\nA\nb\n", "3\na\nA\nb\nB\na\n", "3\na\nA\na\nB\na\n", "3\nb\nA\nb\nA\nb\n", "3\nab\nBa\naB\nABBA\nl\n", "3\nab\nBa\naB\nABBA\na\n"], "outputs": ["B\n", "B\n", "B\n", "A\n", "B\n", "B\n", "LLLL\n", "BAAB\n"]}
693
155
coding
Solve the programming task below in a Python markdown code block. Recently Vasya found a golden ticket — a sequence which consists of $n$ digits $a_1a_2\dots a_n$. Vasya considers a ticket to be lucky if it can be divided into two or more non-intersecting segments with equal sums. For example, ticket $350178$ is lucky ...
{"inputs": ["2\n00\n", "2\n44\n", "2\n55\n", "2\n02\n", "2\n36\n", "2\n11\n", "2\n00\n", "2\n55\n"], "outputs": ["YES\n", "YES\n", "YES\n", "NO\n", "NO\n", "YES\n", "YES\n", "YES\n"]}
334
94
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. You are given two string arrays words1 and words2. A string b is a subset of string a if every letter in b occurs in a including multiplicity. For example, "wrr" is a subset of "warrior" but is not a subset of "world...
{"functional": "def check(candidate):\n assert candidate(words1 = [\"amazon\",\"apple\",\"facebook\",\"google\",\"leetcode\"], words2 = [\"e\",\"o\"]) == [\"facebook\",\"google\",\"leetcode\"]\n assert candidate(words1 = [\"amazon\",\"apple\",\"facebook\",\"google\",\"leetcode\"], words2 = [\"l\",\"e\"]) == [\"ap...
159
217
coding
Solve the programming task below in a Python markdown code block. Jeff has become friends with Furik. Now these two are going to play one quite amusing game. At the beginning of the game Jeff takes a piece of paper and writes down a permutation consisting of n numbers: p1, p2, ..., pn. Then the guys take turns to make...
{"inputs": ["2\n2 1\n", "2\n1 2\n", "5\n2 3 4 5 1\n", "5\n2 3 5 4 1\n", "5\n3 5 1 4 2\n", "5\n3 5 2 4 1\n", "9\n4 1 8 6 7 5 2 9 3\n", "9\n1 7 8 5 3 4 6 9 2\n"], "outputs": ["1", "0", "8", "9\n", "12\n", "13", "33", "33"]}
481
152
coding
Solve the programming task below in a Python markdown code block. Your task is very simple. Just write a function `isAlphabetic(s)`, which takes an input string `s` in lowercase and returns `true`/`false` depending on whether the string is in alphabetical order or not. For example, `isAlphabetic('kata')` is False as '...
{"functional": "_inputs = [['asd'], ['codewars'], ['door'], ['cell'], ['z'], ['']]\n_outputs = [[False], [False], [True], [True], [True], [True]]\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 isinsta...
123
186
coding
Solve the programming task below in a Python markdown code block. There is a big staircase with $N$ steps (numbered $1$ through $N$) in ChefLand. Let's denote the height of the top of step $i$ by $h_i$. Chef Ada is currently under the staircase at height $0$ and she wants to reach the top of the staircase (the top of t...
{"inputs": ["1\n4 3\n2 4 8 16"], "outputs": ["3"]}
392
25
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. There is a street with n * 2 plots, where there are n plots on each side of the street. The plots on each side are numbered from 1 to n. On each plot, a house can be placed. Return the number of ways houses can be pla...
{"functional": "def check(candidate):\n assert candidate(n = 1) == 4\n assert candidate(n = 2) == 9\n\n\ncheck(Solution().countHousePlacements)"}
177
45