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. Paul hates palindromes. He assumes that string s is tolerable if each its character is one of the first p letters of the English alphabet and s doesn't contain any palindrome contiguous substring of length 2 or more. Paul has found a tolerable string s ...
{"inputs": ["1 2\na\n", "1 2\nb\n", "1 1\na\n", "1 3\na\n", "1 4\nb\n", "1 4\na\n", "2 2\nab\n", "2 4\ncd\n"], "outputs": ["b\n", "NO\n", "NO\n", "b\n", "c\n", "b\n", "ba\n", "da\n"]}
319
103
coding
Solve the programming task below in a Python markdown code block. As a token of his gratitude, Takahashi has decided to give his mother an integer sequence. The sequence A needs to satisfy the conditions below: - A consists of integers between X and Y (inclusive). - For each 1\leq i \leq |A|-1, A_{i+1} is a multiple ...
{"inputs": ["2 7\n", "2 8\n", "1 1\n", "3 20\n", "8 17\n", "25 100\n", "52627 828929983\n", "1 576460752303423488\n"], "outputs": ["2\n", "3\n", "1\n", "3\n", "2\n", "3\n", "14\n", "60\n"]}
188
122
coding
Solve the programming task below in a Python markdown code block. There are $n$ trees in a park, numbered from $1$ to $n$. The initial height of the $i$-th tree is $h_i$. You want to water these trees, so they all grow to the same height. The watering process goes as follows. You start watering trees at day $1$. Duri...
{"inputs": ["1\n3\n14159 26535 89793\n", "3\n3\n1 2 4\n5\n4 4 3 5 5\n7\n2 5 4 8 3 7 4\n"], "outputs": ["92595\n", "4\n3\n16\n"]}
625
87
coding
Solve the programming task below in a Python markdown code block. You are given an array $a_1, a_2, \dots, a_n$ and an integer $k$. You are asked to divide this array into $k$ non-empty consecutive subarrays. Every element in the array should be included in exactly one subarray. Let $f(i)$ be the index of subarray the...
{"inputs": ["4 1\n3 0 0 1\n", "4 1\n3 -1 6 0\n", "4 1\n3 -2 6 0\n", "4 1\n3 -2 1 0\n", "4 1\n2 -2 1 0\n", "4 1\n3 -2 2 0\n", "4 1\n0 -2 1 0\n", "4 1\n6 -2 1 0\n"], "outputs": ["4\n", "8\n", "7\n", "2\n", "1\n", "3\n", "-1\n", "5\n"]}
464
150
coding
Solve the programming task below in a Python markdown code block. You drop a ball from a given height. After each bounce, the ball returns to some fixed proportion of its previous height. If the ball bounces to height 1 or less, we consider it to have stopped bouncing. Return the number of bounces it takes for the ball...
{"functional": "_inputs = [[2, 0.5], [4, 0.5], [10, 0.1], [100, 0.1], [9, 0.3], [30, 0.3]]\n_outputs = [[1], [2], [1], [2], [2], [3]]\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...
246
219
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. The complement of an integer is the integer you get when you flip all the 0's to 1's and all the 1's to 0's in its binary representation. For example, The integer 5 is "101" in binary and its complement is "010" whic...
{"functional": "def check(candidate):\n assert candidate(5) == 2\n assert candidate(7) == 0\n assert candidate(10) == 5\n\n\ncheck(Solution().bitwiseComplement)"}
125
52
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. Given two strings a and b, return the minimum number of times you should repeat string a so that string b is a substring of it. If it is impossible for b​​​​​​ to be a substring of a after repeating it, return -1. Not...
{"functional": "def check(candidate):\n assert candidate(a = \"abcd\", b = \"cdabcdab\") == 3\n assert candidate(a = \"a\", b = \"aa\") == 2\n assert candidate(a = \"a\", b = \"a\") == 1\n assert candidate(a = \"abc\", b = \"wxyz\") == -1\n\n\ncheck(Solution().repeatedStringMatch)"}
133
92
coding
Solve the programming task below in a Python markdown code block. Convert integers to binary as simple as that. You would be given an integer as a argument and you have to return its binary form. To get an idea about how to convert a decimal number into a binary number, visit here. **Notes**: negative numbers should b...
{"functional": "_inputs = [[2], [3], [4], [5], [7], [10], [-3], [0], [1000], [-15], [-1000], [-999999], [999999]]\n_outputs = [['10'], ['11'], ['100'], ['101'], ['111'], ['1010'], ['11111111111111111111111111111101'], ['0'], ['1111101000'], ['11111111111111111111111111110001'], ['11111111111111111111110000011000'], ['1...
193
407
coding
Solve the programming task below in a Python markdown code block. Vasya has recently finished writing a book. Now he faces the problem of giving it the title. Vasya wants the title to be vague and mysterious for his book to be noticeable among others. That's why the title should be represented by a single word containi...
{"inputs": ["2\n?\n", "1\na\n", "1\n?\n", "1\n?a\n", "3\nb?c\n", "3\na?c\n", "2\n????\n", "3\n????\n"], "outputs": ["IMPOSSIBLE\n", "a\n", "a\n", "aa\n", "IMPOSSIBLE\n", "IMPOSSIBLE\n", "abba\n", "IMPOSSIBLE\n"]}
499
105
coding
Solve the programming task below in a Python markdown code block. N people are arranged in a row from left to right. You are given a string S of length N consisting of 0 and 1, and a positive integer K. The i-th person from the left is standing on feet if the i-th character of S is 0, and standing on hands if that char...
{"inputs": ["1 1\n0", "1 2\n0", "1 2\n1", "1 3\n1", "1 4\n1", "1 1\n1", "1 1\n1\n", "5 1\n00000"], "outputs": ["1\n", "1\n", "1\n", "1\n", "1\n", "1", "1\n", "5\n"]}
379
98
coding
Solve the programming task below in a Python markdown code block. Chefina has two sequences $A_1, A_2, \ldots, A_N$ and $B_1, B_2, \ldots, B_N$. She views two sequences with length $N$ as identical if, after they are sorted in non-decreasing order, the $i$-th element of one sequence is equal to the $i$-th element of th...
{"inputs": ["3\n1\n1\n2\n2\n1 2\n2 1\n2\n1 1\n2 2"], "outputs": ["-1\n0\n1"]}
594
43
coding
Solve the programming task below in a Python markdown code block. Write a function named `repeater()` that takes two arguments (a string and a number), and returns a new string where the input string is repeated that many times. ## Example: should return Also feel free to reuse/extend the following starter code: ```p...
{"functional": "_inputs = [['a', 5], ['Na', 16], ['Wub ', 6]]\n_outputs = [['aaaaa'], ['NaNaNaNaNaNaNaNaNaNaNaNaNaNaNaNa'], ['Wub Wub Wub Wub Wub Wub ']]\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...
76
205
coding
Solve the programming task below in a Python markdown code block. Chef decided to redecorate his house, and now needs to decide between two different styles of interior design. For the first style, tiling the floor will cost X_{1} rupees and painting the walls will cost Y_{1} rupees. For the second style, tiling the ...
{"inputs": ["4\n10 20 9 25\n10 20 9 20\n10 20 20 10\n100 43 85 61\n"], "outputs": ["30\n29\n30\n143"]}
569
71
coding
Solve the programming task below in a Python markdown code block. There is a pond with a rectangular shape. The pond is divided into a grid with H rows and W columns of squares. We will denote the square at the i-th row from the top and j-th column from the left by (i,\ j). Some of the squares in the pond contains a lo...
{"inputs": ["2 2\nST\n..\n", "2 2\nS.\nT.\n", "2 2\nS.\n.T\n", "2 2\nSo\noT\n", "2 3\nS.o\n.o.\no.T", "3 3\nS.o\n.o.\noT.", "2 3\nS.o\n.o.\no.S", "2 3\nS.p\n.o.\no.S"], "outputs": ["-1\n", "-1\n", "0\n", "2\n", "0\n", "1\n", "0\n", "0\n"]}
407
135
coding
Solve the programming task below in a Python markdown code block. Snuke has a calculator. It has a display and two buttons. Initially, the display shows an integer x. Snuke wants to change this value into another integer y, by pressing the following two buttons some number of times in arbitrary order: * Button A: Whe...
{"inputs": ["9 2", "28 0", "28 2", "28 3", "53 3", "53 6", "53 0", "84 0"], "outputs": ["9\n", "29\n", "28\n", "27\n", "52\n", "49\n", "54\n", "85\n"]}
249
92
coding
Solve the programming task below in a Python markdown code block. You are given two arrays A and B of length N. Let S be the set of integers from 1 to N. Can you find the maximum possible value of (A_{i1}+A_{i2}+...+A_{ik})^{2}+(B_{i1}+B_{i2}+...+B_{ik})^{2} where {i1,i2...ik} is a non-empty subset of S? Input Format ...
{"inputs": ["1 \n2 \n-1 5 \n4 -5 \n"], "outputs": ["50\n"]}
366
34
coding
Solve the programming task below in a Python markdown code block. You are given a matrix $a$ of size $n \times m$ consisting of integers. You can choose no more than $\left\lfloor\frac{m}{2}\right\rfloor$ elements in each row. Your task is to choose these elements in such a way that their sum is divisible by $k$ and t...
{"inputs": ["1 1 2\n1\n", "1 1 2\n1\n", "1 1 2\n70\n", "1 1 2\n70\n", "1 2 3\n3 2\n", "1 2 3\n3 3\n", "2 1 2\n1\n1\n", "1 2 2\n3 3\n"], "outputs": ["0\n", "0\n", "0\n", "0\n", "3\n", "3\n", "0\n", "0\n"]}
456
128
coding
Solve the programming task below in a Python markdown code block. Our friendly friend Pete is really a nice person, but he tends to be rather... Inappropriate. And possibly loud, if given enough ethanol and free rein, so we ask you to write a function that should take its not always "clean" speech and cover as much as...
{"functional": "_inputs = [['I want to punch someone in the face'], ['uh!'], ['What the hell am I doing here? And where is my wallet? PETE SMASH!'], ['I want to punch someone in the face', ['someone', 'face']], ['I want to punch someone in the face', ['drink', 'job', 'girls']]]\n_outputs = [['I w**t to p***h s*****e in...
413
315
coding
Solve the programming task below in a Python markdown code block. Some new cashiers started to work at your restaurant. They are good at taking orders, but they don't know how to capitalize words, or use a space bar! All the orders they create look something like this: `"milkshakepizzachickenfriescokeburgerpizzasa...
{"functional": "_inputs = [['burgerfriesfriesfriesfriesfriespizzasandwichcokefriesburger']]\n_outputs = [['Burger Burger Fries Fries Fries Fries Fries Fries Pizza Sandwich Coke']]\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...
237
190
coding
Solve the programming task below in a Python markdown code block. You are given a binary string of length $n$ (i. e. a string consisting of $n$ characters '0' and '1'). In one move you can swap two adjacent characters of the string. What is the lexicographically minimum possible string you can obtain from the given on...
{"inputs": ["1\n2 1\n00\n", "1\n2 1\n00\n", "2\n8 5\n11011010\n7 9\n1111100\n", "2\n8 5\n11011010\n7 9\n1111100\n", "2\n8 5\n11011010\n7 9\n1011100\n", "2\n8 5\n01011010\n7 9\n1011100\n", "2\n8 1\n01011010\n7 9\n1011100\n", "2\n8 5\n11011010\n7 9\n1111101\n"], "outputs": ["00\n", "00\n", "01011110\n0101111\n", "0101111...
540
326
coding
Solve the programming task below in a Python markdown code block. There are n student groups at the university. During the study day, each group can take no more than 7 classes. Seven time slots numbered from 1 to 7 are allocated for the classes. The schedule on Monday is known for each group, i. e. time slots when gr...
{"inputs": ["1\n0111000\n", "1\n0000000\n", "1\n1111111\n", "1\n0111000\n", "1\n1111111\n", "1\n0000000\n", "1\n0111100\n", "1\n1110111\n"], "outputs": ["1\n", "0\n", "1\n", "1\n", "1\n", "0\n", "1\n", "1\n"]}
338
134
coding
Solve the programming task below in a Python markdown code block. MoEngage goes shopping with Chef. There are N ingredients placed on a line, numbered 1 to N from left to right. At any point in time, MoEngage can choose the ingredient numbered x and do one of the following operations: If the chosen ingredient is not t...
{"inputs": ["3\n1\n3\n4\n4\n2 1 3 2\n4 2 4 3\n7\n3 10 5 2 8 3 9\n8 6 11 5 9 13 7\n"], "outputs": ["0\n5\n32\n"]}
759
76
coding
Solve the programming task below in a Python markdown code block. On a certain meeting of a ruling party "A" minister Pavel suggested to improve the sewer system and to create a new pipe in the city. The city is an n Γ— m rectangular squared field. Each square of the field is either empty (then the pipe can go in it), ...
{"inputs": ["2 2\n..\n..\n", "2 2\n..\n..\n", "3 3\n...\n..#\n...\n", "4 2\n..\n..\n..\n..\n", "4 2\n..\n..\n..\n..\n", "3 3\n...\n..#\n...\n", "4 5\n#...#\n#...#\n###.#\n###.#\n", "4 5\n#...#\n#...#\n#.###\n###.#\n"], "outputs": ["0\n", " 0\n", "3\n", "2\n"...
697
162
coding
Solve the programming task below in a Python markdown code block. A palindrome is a string $t$ which reads the same backward as forward (formally, $t[i] = t[|t| + 1 - i]$ for all $i \in [1, |t|]$). Here $|t|$ denotes the length of a string $t$. For example, the strings 010, 1001 and 0 are palindromes. You have $n$ bin...
{"inputs": ["1\n4\n0\n1\n1\n0\n", "1\n4\n0\n1\n1\n0\n", "1\n4\n0\n1\n1\n1\n", "1\n1\n0\n1\n1\n1\n", "1\n3\n0\n0110\n1\n", "1\n3\n0\n0110\n1\n", "1\n3\n0\n1110\n1\n", "1\n1\n0\n1110\n1\n"], "outputs": ["4\n", "4\n", "4\n", "1\n", "3\n", "3\n", "3\n", "1\n"]}
750
154
coding
Solve the programming task below in a Python markdown code block. Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Petya recently learned to determin...
{"inputs": ["1\n", "2\n", "7\n", "8\n", "6\n", "9\n", "4\n", "3\n"], "outputs": ["a", "ab", "abcdabc", "abcdabcd", "abcdab", "abcdabcda", "abcd", "abc"]}
492
67
coding
Solve the programming task below in a Python markdown code block. Read problems statements in Mandarin Chinese, Russian and Vietnamese as well. Not everyone probably knows that Chef has younger brother Jeff. Currently Jeff learns to read. He knows some subset of the letter of Latin alphabet. In order to help Jeff to...
{"inputs": ["act\n2\ncat\ndog"], "outputs": ["Yes\nNo"]}
410
22
coding
Solve the programming task below in a Python markdown code block. # Task After a long night (work, play, study) you find yourself sleeping on a bench in a park. As you wake up and try to figure out what happened you start counting trees. You notice there are different tree sizes but there's always one size which is un...
{"functional": "_inputs = [[[1, 2, 2, 3, 3]], [[11, 2, 3, 3, 3, 11, 2, 2]], [[234, 76, 45, 99, 99, 99, 99, 45, 234, 234, 45, 45, 76, 234, 76]], [[1, 1, 1, 1, 1, 1, 1, 22, 22, 22, 22, 22, 22, 22, 3, 3, 3, 3, 3, 3]], [[10, 205, 3000, 3000, 10]], [[50, 408, 50, 50, 50, 50, 408, 408, 408, 680, 408, 680, 50, 408, 680, 50, 5...
322
786
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. Hasan has recently heard about Chef's restaurant, which serves the tastiest dishes. The restaurant has published a list of $N$ dishes (numbered $1$ ...
{"inputs": ["2\n3 6\n5 7\n1 9\n2 5\n3 7\n5 8\n2 5\n5 10"], "outputs": ["16\n15"]}
563
49
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. You are given two binary trees root1 and root2. Imagine that when you put one of them to cover the other, some nodes of the two trees are overlapped while the others are not. You need to merge the two trees into a new...
{"functional": "def check(candidate):\n assert is_same_tree(candidate(root1 = tree_node([1,3,2,5]), root2 = tree_node([2,1,3,None,4,None,7])), tree_node([3,4,5,5,4,None,7]))\n assert is_same_tree(candidate(root1 = tree_node([1]), root2 = tree_node([1,2])), tree_node([2,2]))\n\n\ncheck(Solution().mergeTrees)"}
224
108
coding
Solve the programming task below in a Python markdown code block. It's the year 4527 and the tanks game that we all know and love still exists. There also exists Great Gena's code, written in 2016. The problem this code solves is: given the number of tanks that go into the battle from each country, find their product. ...
{"inputs": ["1\n0\n", "1\n1\n", "1\n9\n", "1\n0\n", "1\n1\n", "1\n9\n", "1\n2\n", "1\n4\n"], "outputs": ["0", "1", "9", "0\n", "1", "9", "2\n", "4\n"]}
488
81
coding
Solve the programming task below in a Python markdown code block. ## Task You are given an array of integers. On each move you are allowed to increase exactly one of its element by one. Find the minimal number of moves required to obtain a strictly increasing sequence from the input. ## Example For `arr = [1, 1, 1]...
{"functional": "_inputs = [[[1, 1, 1]], [[-1000, 0, -2, 0]], [[2, 1, 10, 1]], [[2, 3, 3, 5, 5, 5, 4, 12, 12, 10, 15]]]\n_outputs = [[3], [5], [12], [13]]\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...
203
237
coding
Solve the programming task below in a Python markdown code block. Sherlock Holmes has decided to start a new academy to some of the young lads. He has conducted several tests and finally selected N equally brilliant students.Now he don't know whether to train all the N students or not. Now since Holmes was in a confus...
{"inputs": ["2\n5\n2 3 5 1 2\n3\n1 2 3"], "outputs": ["3\n3"]}
613
34
coding
Solve the programming task below in a Python markdown code block. Chef has a binary string S. He can replace any occurrence of - - 01 with a - 10 with b - 010 with ab - 101 with ba While doing these operations, Chef noticed that he can end up with different strings depending upon the order of application of the opera...
{"inputs": ["3\nab\naa\nabb\n"], "outputs": ["2\n1\n2\n"]}
589
24
coding
Solve the programming task below in a Python markdown code block. You are given $n$ positive integers $a_1, \ldots, a_n$, and an integer $k \geq 2$. Count the number of pairs $i, j$ such that $1 \leq i < j \leq n$, and there exists an integer $x$ such that $a_i \cdot a_j = x^k$. -----Input----- The first line contai...
{"inputs": ["2 2\n1 90\n", "2 2\n40 90\n", "2 2\n40 90\n", "2 2\n70 90\n", "2 2\n70 126\n", "2 2\n130 126\n", "2 2\n61441 92480\n", "2 5\n49248 87211\n"], "outputs": ["0\n", "1\n", "1\n", "0\n", "0\n", "0\n", "0\n", "0\n"]}
326
148
coding
Solve the programming task below in a Python markdown code block. You are given two integers $n$ and $k$. You should create an array of $n$ positive integers $a_1, a_2, \dots, a_n$ such that the sum $(a_1 + a_2 + \dots + a_n)$ is divisible by $k$ and maximum element in $a$ is minimum possible. What is the minimum pos...
{"inputs": ["1\n7 99999999\n", "1\n2 33554431\n", "1\n2 69696969\n", "1\n7 99999999\n", "1\n2 69696969\n", "1\n2 33554431\n", "1\n2 54472221\n", "1\n7 49552848\n"], "outputs": ["14285715\n", "16777216\n", "34848485\n", "14285715\n", "34848485\n", "16777216\n", "27236111\n", "7078979\n"]}
418
213
coding
Solve the programming task below in a Python markdown code block. DO YOU EXPECT ME TO FIND THIS OUT? WHAT BASE AND/XOR LANGUAGE INCLUDES string? DON'T BYTE OF MORE THAN YOU CAN CHEW YOU CAN ONLY DISTORT THE LARGEST OF MATHEMATICS SO FAR SAYING "ABRACADABRA" WITHOUT A MAGIC AND WON'T DO YOU ANY GOOD THE LAST STACK ...
{"inputs": ["1\n8\n", "1\n8\n", "1\n11\n", "1\n22\n", "1\n26\n", "2\n1 5\n", "2\n4 8\n", "2\n5 9\n"], "outputs": ["0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n"]}
201
95
coding
Solve the programming task below in a Python markdown code block. You are given an integer N. You have to count the number of distinct tuples (A, B, C, D) with 1 ≀ A, B, C, D ≀ N such that A \cdot B = C \cdot D. Two tuples, say (A, B, C, D) and (E, F, G, H) are considered to be different if at least one of the follow...
{"inputs": ["3\n3\n50\n35"], "outputs": ["15\n10950\n4831"]}
495
32
coding
Solve the programming task below in a Python markdown code block. One day, $n$ people ($n$ is an even number) met on a plaza and made two round dances, each round dance consists of exactly $\frac{n}{2}$ people. Your task is to find the number of ways $n$ people can make two round dances if each round dance consists of ...
{"inputs": ["2\n", "4\n", "8\n", "6\n", "6\n", "2\n", "4\n", "8\n"], "outputs": ["1\n", "3\n", "1260\n", "40\n", "40\n", "1\n", "3\n", "1260\n"]}
461
78
coding
Solve the programming task below in a Python markdown code block. Most of the time when rounding a given number, it is customary to round to some multiple of a power of 10. However, there is no reason why we cannot use another multiple to do our rounding to. For example, you could round to the nearest multiple of 7, or...
{"inputs": ["26\n5 10\n4 10\n100 3\n123456 7\n49 7\n158854 50\n822992 101\n691238 345\n682373 49\n643378 53\n328697 62\n446656 228\n368684 130\n530193 371\n864163 325\n708578 207\n915093 485\n711860 28\n234554 366\n309089 25\n595700 393\n10 6\n9 19\n4 10\n11 2\n11 3"], "outputs": ["10\n0\n99\n123459\n49\n158850\n822948...
201
379
coding
Solve the programming task below in a Python markdown code block. Roy lives in a city that is circular in shape on a $2{D}$ plane that has radius ${r}$. The city center is located at origin $(0,0)$ and it has suburbs lying on the lattice points (points with integer coordinates). The city Police Department Headquarters ...
{"inputs": ["5\n1 3\n1 4\n4 4\n25 11\n25 12\n"], "outputs": ["impossible\npossible\npossible\nimpossible\npossible\n"]}
666
48
coding
Solve the programming task below in a Python markdown code block. You are given three positive integers $n$, $a$ and $b$. You have to construct a string $s$ of length $n$ consisting of lowercase Latin letters such that each substring of length $a$ has exactly $b$ distinct letters. It is guaranteed that the answer exist...
{"inputs": ["1\n2 1 1\n", "1\n1 1 1\n", "1\n3 1 1\n", "1\n3 1 2\n", "1\n2 2 1\n", "1\n1 0 1\n", "1\n27 1 1\n", "1\n30 1 1\n"], "outputs": ["aa\n", "a\n", "aaa\n", "aba\n", "aa\n", "a\n", "aaaaaaaaaaaaaaaaaaaaaaaaaaa\n", "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n"]}
500
127
coding
Solve the programming task below in a Python markdown code block. Mr. Bill is shopping at the store. There are some coins in his wallet (10-yen coins, 50-yen coins, 100-yen coins, 500-yen coins), but he is now trying to consume as much of this coin as possible. In other words, by paying for the goods with an appropriat...
{"inputs": ["160\n1 0 1 2\n4\n1 0 9 0\n0", "160\n2 0 4 1\n83\n1 0 4 5\n0", "160\n1 1 4 0\n46\n2 0 7 9\n0", "160\n2 2 6 1\n86\n1 0 4 5\n0", "160\n0 1 2 0\n5\n0 1 1 18\n0", "160\n0 0 0 2\n4\n1 0 14 0\n0", "160\n0 0 0 1\n8\n0 0 14 0\n0", "160\n0 0 0 1\n8\n0 0 17 0\n0"], "outputs": ["10 1\n500 1\n\n10 1\n100 5\n", "10 1\n1...
620
375
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. You are given a string of digits num, such as "123456579". We can split it into a Fibonacci-like sequence [123, 456, 579]. Formally, a Fibonacci-like sequence is a list f of non-negative integers such that: 0 <= f[i]...
{"functional": "def check(candidate):\n assert candidate(num = \"1101111\") == [11,0,11,11]\n assert candidate(\"0123\") == []\n\n\ncheck(Solution().splitIntoFibonacci)"}
228
63
coding
Solve the programming task below in a Python markdown code block. Iahub is so happy about inventing bubble sort graphs that he's staying all day long at the office and writing permutations. Iahubina is angry that she is no more important for Iahub. When Iahub goes away, Iahubina comes to his office and sabotage his res...
{"inputs": ["2\n-1 -1\n", "2\n-1 -1\n", "5\n-1 -1 4 5 1\n", "5\n-1 -1 4 2 1\n", "5\n-1 -1 4 3 -1\n", "5\n-1 -1 4 1 -1\n", "5\n-1 -1 4 5 -1\n", "5\n-1 -1 4 2 -1\n"], "outputs": ["1\n", "1\n", "1\n", "2\n", "2\n", "3\n", "3\n", "3\n"]}
472
146
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. You are given a string sentence that consist of words separated by spaces. Each word consists of lowercase and uppercase letters only. We would like to convert the sentence to "Goat Latin" (a made-up language similar ...
{"functional": "def check(candidate):\n assert candidate(sentence = \"I speak Goat Latin\") == \"Imaa peaksmaaa oatGmaaaa atinLmaaaaa\"\n assert candidate(sentence = \"The quick brown fox jumped over the lazy dog\") == \"heTmaa uickqmaaa rownbmaaaa oxfmaaaaa umpedjmaaaaaa overmaaaaaaa hetmaaaaaaaa azylmaaaaaaaaa ...
274
109
coding
Solve the programming task below in a Python markdown code block. Given are an N \times N matrix and an integer K. The entry in the i-th row and j-th column of this matrix is denoted as a_{i, j}. This matrix contains each of 1, 2, \dots, N^2 exactly once. Sigma can repeat the following two kinds of operation arbitraril...
{"inputs": ["1 1\n1\n", "1 2\n1\n", "2 5\n1 2\n4 3\n", "3 13\n3 2 7\n4 8 9\n1 6 5\n", "5 26\n14 9 6 21 19\n16 4 8 12 1\n25 5 15 7 18\n20 17 24 10 23\n3 13 11 22 2\n", "6 61\n36 22 23 5 33 27\n12 25 1 3 24 7\n30 8 34 28 26 31\n10 32 14 13 6 9\n17 29 16 20 35 11\n21 18 4 2 15 19\n", "6 61\n36 22 23 5 33 27\n12 25 1 3 24 ...
537
536
coding
Solve the programming task below in a Python markdown code block. For a positive integer n let's define a function f: f(n) = - 1 + 2 - 3 + .. + ( - 1)^{n}n Your task is to calculate f(n) for a given integer n. -----Input----- The single line contains the positive integer n (1 ≀ n ≀ 10^15). -----Output----- Pr...
{"inputs": ["4\n", "5\n", "1\n", "2\n", "2\n", "1\n", "3\n", "6\n"], "outputs": ["2\n", "-3\n", "-1\n", "1\n", "1\n", "-1\n", "-2\n", "3\n"]}
172
70
coding
Solve the programming task below in a Python markdown code block. You are going to the beach with the idea to build the greatest sand castle ever in your head! The beach is not as three-dimensional as you could have imagined, it can be decribed as a line of spots to pile up sand pillars. Spots are numbered 1 through in...
{"inputs": ["5 2\n", "6 8\n", "1 1\n", "1 1\n", "3 4\n", "6 9\n", "1 2\n", "3 2\n"], "outputs": ["3\n", "3\n", "1\n", "1\n", "2\n", "3\n", "1\n", "2\n"]}
737
86
coding
Solve the programming task below in a Python markdown code block. Kontti language is a finnish word play game. You add `-kontti` to the end of each word and then swap their characters until and including the first vowel ("aeiouy"); For example the word `tame` becomes `kome-tantti`; `fruity` becomes `koity-fruntti` a...
{"functional": "_inputs = [['lamppu'], ['lamppu sofia'], ['silly game'], ['aeiou'], ['xyz lamppu'], [''], ['lAmppU'], ['silly grrr']]\n_outputs = [['komppu-lantti'], ['komppu-lantti kofia-sontti'], ['kolly-sintti kome-gantti'], ['koeiou-antti'], ['koz-xyntti komppu-lantti'], [''], ['komppU-lAntti'], ['kolly-sintti grrr...
132
267
coding
Solve the programming task below in a Python markdown code block. A correct expression of the form a+b=c was written; a, b and c are non-negative integers without leading zeros. In this expression, the plus and equally signs were lost. The task is to restore the expression. In other words, one character '+' and one cha...
{"inputs": ["099\n", "112\n", "101\n", "011\n", "178\n", "000\n", "178\n", "101\n"], "outputs": ["0+9=9\n", "1+1=2\n", "1+0=1\n", "0+1=1\n", "1+7=8\n", "0+0=0\n", "1+7=8", "1+0=1"]}
421
116
coding
Solve the programming task below in a Python markdown code block. This kata is blatantly copied from inspired by This Kata Welcome this is the second in the series of the string iterations kata! Here we go! --------------------------------------------------------------------------------- We have a string s Let's...
{"functional": "_inputs = [['This is a string exemplification!', 0], ['String for test: incommensurability', 1], ['Ohh Man God Damn', 7], ['Ohh Man God Damnn', 19], ['I like it!', 1234], ['codingisfornerdsyounerd', 10101010], ['this_test_will_hurt_you', 12345678987654321]]\n_outputs = [['This is a string exemplificatio...
377
341
coding
Solve the programming task below in a Python markdown code block. You are given two positive integers A and B. Compare the magnitudes of these numbers. -----Constraints----- - 1 ≀ A, B ≀ 10^{100} - Neither A nor B begins with a 0. -----Input----- Input is given from Standard Input in the following format: A B ----...
{"inputs": ["36\n2", "36\n3", "36\n6", "36\n5", "36\n7", "36\n0", "36\n16", "36\n36"], "outputs": ["GREATER\n", "GREATER\n", "GREATER\n", "GREATER\n", "GREATER\n", "GREATER\n", "GREATER\n", "EQUAL\n"]}
128
95
coding
Solve the programming task below in a Python markdown code block. Problem There are $ N $ streetlights on a two-dimensional square of $ W \ times H $. Gaccho wants to start with $ (1,1) $ and go to $ (W, H) $. Gaccho is afraid of dark places, so he only wants to walk in the squares that are brightened by the streetlig...
{"inputs": ["8 6 1\n6 5", "8 6 1\n6 8", "1 1 1\n1 1", "8 10 1\n6 6", "24 4 1\n6 2", "8 10 1\n6 8", "10 3 1\n6 2", "8 10 1\n6 5"], "outputs": ["9\n", "12\n", "0", "10\n", "20\n", "12\n", "6\n", "9\n"]}
571
134
coding
Solve the programming task below in a Python markdown code block. Guys don’t misinterpret this it is three only. -----Input:----- - First line will contain an integer $X$. -----Output:----- A single line containing the answer to the problem modulo 1000000007. -----Constraints----- - $1 \leq X < 10^5$ -----Sample In...
{"inputs": ["1", "2"], "outputs": ["3", "14"]}
119
19
coding
Solve the programming task below in a Python markdown code block. In a regular table tennis match, the player who serves changes every time after 2 points are scored, regardless of which players scored them. Chef and Cook are playing a different match β€” they decided that the player who serves would change every time af...
{"inputs": ["3\n1 3 2\n0 3 2\n34 55 2"], "outputs": ["CHEF\nCOOK\nCHEF"]}
370
39
coding
Solve the programming task below in a Python markdown code block. Given a number $n$, give the last digit of sum of all the prime numbers from 1 to $n$ inclusive. -----Input:----- - First line contains number of testcase $t$. - Each testcase contains of a single line of input, number $n$. -----Output:----- Last digi...
{"inputs": ["1\n10"], "outputs": ["7"]}
134
15
coding
Solve the programming task below in a Python markdown code block. You received a notebook which is called Death Note. This notebook has infinite number of pages. A rule is written on the last page (huh) of this notebook. It says: "You have to write names in this notebook during $n$ consecutive days. During the $i$-th d...
{"inputs": ["1 1\n2\n", "1 1\n1\n", "1 1\n2\n", "1 1\n1\n", "1 1\n4\n", "1 100\n99\n", "1 100\n51\n", "1 001\n51\n"], "outputs": ["2 \n", "1 \n", "2\n", "1\n", "4\n", "0 \n", "0\n", "51\n"]}
687
115
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. Let's play the minesweeper game (Wikipedia, online game)! You are given an m x n char matrix board representing the game board where: 'M' represents an unrevealed mine, 'E' represents an unrevealed empty square, 'B' ...
{"functional": "def check(candidate):\n assert candidate(board = [[\"E\",\"E\",\"E\",\"E\",\"E\"],[\"E\",\"E\",\"M\",\"E\",\"E\"],[\"E\",\"E\",\"E\",\"E\",\"E\"],[\"E\",\"E\",\"E\",\"E\",\"E\"]], click = [3,0]) == [[\"B\",\"1\",\"E\",\"1\",\"B\"],[\"B\",\"1\",\"M\",\"1\",\"B\"],[\"B\",\"1\",\"1\",\"1\",\"B\"],[\"B\"...
324
243
coding
Solve the programming task below in a Python markdown code block. You have written N problems to hold programming contests. The i-th problem will have a score of P_i points if used in a contest. With these problems, you would like to hold as many contests as possible under the following condition: * A contest has thr...
{"inputs": ["3\n6 9\n5 6 3", "3\n6 0\n5 6 3", "3\n6 0\n5 9 3", "3\n6 0\n5 3 3", "3\n6 0\n5 3 2", "3\n6 0\n5 1 2", "3\n8 0\n5 1 2", "3\n8 0\n1 1 2"], "outputs": ["0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n"]}
312
142
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. There are n rooms labeled from 0 to n - 1Β and all the rooms are locked except for room 0. Your goal is to visit all the rooms. However, you cannot enter a locked room without having its key. When you visit a room, you...
{"functional": "def check(candidate):\n assert candidate(rooms = [[1],[2],[3],[]]) == True\n assert candidate(rooms = [[1,3],[3,0,1],[2],[0]]) == False\n\n\ncheck(Solution().canVisitAllRooms)"}
183
63
coding
Solve the programming task below in a Python markdown code block. There is a right triangle with legs of length a and b. Your task is to determine whether it is possible to locate the triangle on the plane in such a way that none of its sides is parallel to the coordinate axes. All the vertices must have integer coordi...
{"inputs": ["5 6\n", "2 2\n", "1 6\n", "2 3\n", "1 0\n", "9 5\n", "8 3\n", "2 6\n"], "outputs": ["NO", "NO", "NO\n", "NO\n", "NO\n", "NO\n", "NO\n", "NO\n"]}
245
84
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. Given the roots of two binary trees p and q, write a function to check if they are the same or not. Two binary trees are considered the same if they are structurally identical, and the nodes have the same value. Β  Ple...
{"functional": "def check(candidate):\n assert candidate(p = tree_node([1,2,3]), q = tree_node([1,2,3])) == True\n assert candidate(p = tree_node([1,2]), q = tree_node([1,None,2])) == False\n assert candidate(p = tree_node([1,2,1]), q = tree_node([1,1,2])) == False\n\n\ncheck(Solution().isSameTree)"}
153
101
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. Given two non-negative integers low and high. Return the count of odd numbers between low and highΒ (inclusive). Β  Please complete the following python code precisely: ```python class Solution: def countOdds(self, ...
{"functional": "def check(candidate):\n assert candidate(low = 3, high = 7) == 3\n assert candidate(low = 8, high = 10) == 1\n\n\ncheck(Solution().countOdds)"}
75
55
coding
Solve the programming task below in a Python markdown code block. Given an array of 4 integers ```[a,b,c,d]``` representing two points ```(a, b)``` and ```(c, d)```, return a string representation of the slope of the line joining these two points. For an undefined slope (division by 0), return ```undefined``` . N...
{"functional": "_inputs = [[[12, -18, -15, -18]], [[3, -20, 5, 8]], [[17, -3, 17, 8]], [[1, -19, -2, -7]], [[19, 3, 20, 3]], [[6, -12, 15, -3]], [[15, -3, 15, -3]], [[9, 3, 19, -17]], [[3, 6, 4, 10]], [[2, 7, 4, -7]], [[1, 24, 2, 88]], [[4, 384, 8, 768]], [[4, 16, 4, 18]], [[7, 28, 9, 64]], [[18, -36, 12, 36]], [[36, 5...
163
547
coding
Solve the programming task below in a Python markdown code block. Given a non-negative integer, return an array / a list of the individual digits in order. Examples: ``` 123 => [1,2,3] 1 => [1] 8675309 => [8,6,7,5,3,0,9] ``` Also feel free to reuse/extend the following starter code: ```python def digitize(n): ```
{"functional": "_inputs = [[123], [1], [0], [1230], [8675309]]\n_outputs = [[[1, 2, 3]], [[1]], [[0]], [[1, 2, 3, 0]], [[8, 6, 7, 5, 3, 0, 9]]]\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 isinstanc...
98
223
coding
Solve the programming task below in a Python markdown code block. You are given an integer x of n digits a_1, a_2, …, a_n, which make up its decimal notation in order from left to right. Also, you are given a positive integer k < n. Let's call integer b_1, b_2, …, b_m beautiful if b_i = b_{i+k} for each i, such that ...
{"inputs": ["2 1\n12\n", "2 1\n31\n", "2 1\n33\n", "2 1\n99\n", "3 1\n123\n", "3 1\n898\n", "3 2\n798\n", "3 2\n192\n"], "outputs": ["2\n22\n", "2\n33\n", "2\n33\n", "2\n99\n", "3\n222\n", "3\n999\n", "3\n808\n", "3\n202\n"]}
299
142
coding
Solve the programming task below in a Python markdown code block. You are given a tree T with N vertices. Recall that a tree is a connected graph with N-1 edges. Determine the minimum number of edges you must add to T to get a new graph G such that G has a Hamiltonian path. Note: A graph G is said to have a hamiltoni...
{"inputs": ["2\n5\n1 2\n1 3\n3 4\n5 3\n3\n1 2\n2 3\n", "1\n10\n8 2\n2 5\n5 6\n2 3\n3 7\n7 1\n1 9\n3 4\n7 10\n"], "outputs": ["1\n0", "2"]}
545
90
coding
Solve the programming task below in a Python markdown code block. You are given an array a_0, a_1, ..., a_{N-1} of length N. Process Q queries of the following types. * `0 p x`: a_p \gets a_p + x * `1 l r`: Print \sum_{i = l}^{r - 1}{a_i}. Constraints * 1 \leq N, Q \leq 500,000 * 0 \leq a_i, x \leq 10^9 * 0 \leq p <...
{"inputs": ["5 5\n0 1 8 4 7\n0 0 5\n1 2 4\n0 3 4\n1 0 5\n1 0 3", "5 5\n0 1 8 4 7\n0 0 5\n1 2 4\n0 3 4\n1 0 5\n1 1 3", "5 5\n1 2 3 4 5\n4 1 5\n1 2 4\n0 3 6\n1 0 5\n1 0 3", "5 5\n1 2 3 4 5\n1 1 5\n1 2 4\n0 3 10\n1 0 5\n1 0 3", "5 5\n1 2 5 4 5\n1 1 5\n1 2 4\n0 3 10\n1 0 5\n1 0 3", "5 5\n1 2 5 4 5\n1 1 2\n1 2 4\n0 3 10\n1 ...
292
463
coding
Solve the programming task below in a Python markdown code block. In a test, there are N problems, each carrying X marks. In each problem, Chef either received X marks or 0 marks. Determine whether is it possible for Chef to achieve exactly Y marks. ------ Input Format ------ - The first line of input will contai...
{"inputs": ["5\n1 8 4\n3 6 12\n4 5 0\n10 10 100\n8 5 36\n"], "outputs": ["NO\nYES\nYES\nYES\nNO\n"]}
413
58
coding
Solve the programming task below in a Python markdown code block. Problem C Medical Checkup Students of the university have to go for a medical checkup, consisting of lots of checkup items, numbered 1, 2, 3, and so on. Students are now forming a long queue, waiting for the checkup to start. Students are also numbered...
{"inputs": ["3 0\n1\n3\n3", "1 0\n1\n2\n3", "3 1\n1\n3\n3", "1 5\n5\n7\n3", "3 9\n1\n2\n0", "2 5\n6\n1\n3", "3 9\n1\n0\n0", "3 20\n1\n3\n6"], "outputs": ["1\n1\n1\n", "1\n", "2\n1\n1\n", "2\n", "10\n5\n5\n", "1\n1\n", "10\n10\n10\n", "21\n7\n3\n"]}
603
154
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. Given a positive integer n, write a function that returns the number of set bits in its binary representation (also known as the Hamming weight). Β  Please complete the following python code precisely: ```python class ...
{"functional": "def check(candidate):\n assert candidate(n = 11) == 3\n assert candidate(n = 128) == 1\n assert candidate(n = 2147483645) == 30\n\n\ncheck(Solution().hammingWeight)"}
78
69
coding
Solve the programming task below in a Python markdown code block. Write a simple regex to validate a username. Allowed characters are: - lowercase letters, - numbers, - underscore Length should be between 4 and 16 characters (both included). Also feel free to reuse/extend the following starter code: ```python def val...
{"functional": "_inputs = [['asddsa'], ['a'], ['Hass'], ['Hasd_12assssssasasasasasaasasasasas'], [''], ['____'], ['012'], ['p1pp1'], ['asd43 34'], ['asd43_34']]\n_outputs = [[True], [False], [False], [False], [False], [True], [False], [True], [False], [True]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstan...
72
242
coding
Solve the programming task below in a Python markdown code block. The Earth has been invaded by aliens. They demand our beer and threaten to destroy the Earth if we do not supply the exact number of beers demanded. Unfortunately, the aliens only speak Morse code. Write a program to convert morse code into numbers usin...
{"functional": "_inputs = [['.----.----.----.----.----'], ['..----------...-....----------'], ['---------------'], ['..---.--------....--'], ['.----..---...--....-.....-....--...---..----.-----']]\n_outputs = [[11111], [207600], [0], [2193], [1234567890]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a...
118
235
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. Given an integer array nums containing n integers, find the beauty of each subarray of size k. The beauty of a subarray is the xth smallest integer in the subarray if it is negative, or 0 if there are fewer than x neg...
{"functional": "def check(candidate):\n assert candidate(nums = [1,-1,-3,-2,3], k = 3, x = 2) == [-1,-2,-2]\n assert candidate(nums = [-1,-2,-3,-4,-5], k = 2, x = 2) == [-1,-2,-3,-4]\n assert candidate(nums = [-3,1,2,-3,0,-3], k = 2, x = 1) == [-3,0,-3,-3,-3]\n\n\ncheck(Solution().getSubarrayBeauty)"}
158
134
coding
Solve the programming task below in a Python markdown code block. Create a program that inputs the test result data of the visual acuity test and outputs the number of people who apply to each judgment based on the following visual acuity judgment table for each of the left and right eyesight. Judgment | Sight --- | -...
{"inputs": ["1.0 1.2\n0.8 1.5\n1.2 0.7\n2.0 2.0", "1.0 1.2\n0.8 1.5\n1.2 0.7\n2.0 2.1903643288076555", "1.0 1.2\n0.8 1.5\n1.2 0.7\n2.751284804693524 2.1903643288076555", "1.0 1.2\n0.8 1.5471720124202895\n1.2 0.7\n2.751284804693524 2.1903643288076555", "1.0 1.6960573379527397\n0.8 1.5471720124202895\n1.2 0.7\n2.75128480...
390
782
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. Given an m x n matrix grid where each cell is either a wall 'W', an enemy 'E' or empty '0', return the maximum enemies you can kill using one bomb. You can only place the bomb in an empty cell. The bomb kills all the ...
{"functional": "def check(candidate):\n assert candidate(grid = [[\"0\",\"E\",\"0\",\"0\"],[\"E\",\"0\",\"W\",\"E\"],[\"0\",\"E\",\"0\",\"0\"]]) == 3\n assert candidate(grid = [[\"W\",\"W\",\"W\"],[\"0\",\"0\",\"0\"],[\"E\",\"E\",\"E\"]]) == 1\n\n\ncheck(Solution().maxKilledEnemies)"}
130
95
coding
Solve the programming task below in a Python markdown code block. # Invalid Login - Bug Fixing #11 Oh NO! Timmy has moved divisions... but now he's in the field of security. Timmy, being the top coder he is, has allowed some bad code through. You must help Timmy and filter out any injected code! ## Task Your task is...
{"functional": "_inputs = [['Timmy', 'password'], ['Timmy', 'h4x0r'], ['Alice', 'alice'], ['Timmy', 'password\"||\"\"==\"'], ['Admin', 'gs5bw\"||1==1//']]\n_outputs = [['Successfully Logged in!'], ['Wrong username or password!'], ['Successfully Logged in!'], ['Wrong username or password!'], ['Wrong username or password...
269
231
coding
Solve the programming task below in a Python markdown code block. Takahashi and Aoki are training for long-distance races in an infinitely long straight course running from west to east. They start simultaneously at the same point and moves as follows towards the east: * Takahashi runs A_1 meters per minute for the f...
{"inputs": ["0 1\n0 1\n2 5", "0 0\n0 1\n2 5", "0 0\n0 1\n1 5", "0 0\n0 2\n1 5", "0 0\n0 2\n1 7", "0 0\n0 2\n1 3", "1 1\n0 4\n12 5", "1 2\n-1 2\n2 5"], "outputs": ["0\n", "infinity\n", "infinity\n", "infinity\n", "infinity\n", "infinity\n", "0\n", "0\n"]}
449
144
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. Given an integer array nums and an integer k, return the maximum sum of a non-empty subsequence of that array such that for every two consecutive integers in the subsequence, nums[i] and nums[j], where i < j, the cond...
{"functional": "def check(candidate):\n assert candidate(nums = [10,2,-10,5,20], k = 2) == 37\n assert candidate(nums = [-1,-2,-3], k = 1) == -1\n assert candidate(nums = [10,-2,-10,-5,20], k = 2) == 23\n\n\ncheck(Solution().constrainedSubsetSum)"}
142
100
coding
Solve the programming task below in a Python markdown code block. Ask a small girl - "How old are you?". She always says strange things... Lets help her! For correct answer program should return int from 0 to 9. Assume test input string always valid and may look like "1 year old" or "5 years old", etc.. The first c...
{"functional": "_inputs = [['1 year old'], ['2 years old'], ['3 years old'], ['4 years old'], ['5 years old'], ['6 years old'], ['7 years old'], ['8 years old'], ['9 years old']]\n_outputs = [[1], [2], [3], [4], [5], [6], [7], [8], [9]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinsta...
102
220
coding
Solve the programming task below in a Python markdown code block. Vova has taken his summer practice this year and now he should write a report on how it went. Vova has already drawn all the tables and wrote down all the formulas. Moreover, he has already decided that the report will consist of exactly $n$ pages and t...
{"inputs": ["1 1\n1\n1\n", "1 1\n2\n1\n", "1 1\n1\n2\n", "1 1\n3\n1\n", "1 1\n1\n3\n", "1 1\n2\n1\n", "1 1\n1\n2\n", "1 1\n3\n1\n"], "outputs": ["YES\n", "YES\n", "YES\n", "NO\n", "NO\n", "YES\n", "YES\n", "NO\n"]}
680
118
coding
Solve the programming task below in a Python markdown code block. There is a rectangle in the xy-plane, with its lower left corner at (0, 0) and its upper right corner at (W, H). Each of its sides is parallel to the x-axis or y-axis. Initially, the whole region within the rectangle is painted white. Snuke plotted N poi...
{"inputs": ["5 4 2\n2 1 1\n6 3 4", "5 4 2\n2 1 2\n6 3 4", "5 4 1\n2 1 2\n6 3 4", "8 4 2\n0 1 3\n6 3 4", "5 7 1\n2 2 2\n6 0 4", "6 5 2\n2 2 1\n3 0 1", "5 4 2\n2 1 2\n1 3 4", "5 4 2\n2 2 2\n1 3 4"], "outputs": ["9\n", "6\n", "8\n", "16\n", "14\n", "15\n", "6\n", "6\n"]}
558
193
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. You are given an array nums consisting of non-negative integers. You are also given a queries array, where queries[i] = [xi, mi]. The answer to the ith query is the maximum bitwise XOR value of xi and any element of n...
{"functional": "def check(candidate):\n assert candidate(nums = [0,1,2,3,4], queries = [[3,1],[1,3],[5,6]]) == [3,3,7]\n assert candidate(nums = [5,2,4,6,6,3], queries = [[12,4],[8,1],[6,3]]) == [15,-1,5]\n\n\ncheck(Solution().maximizeXor)"}
176
105
coding
Solve the programming task below in a Python markdown code block. Chef has two strings A and B consisting of lowercase alphabets, each of length N. Help Chef in finding the number of indices i (1 ≀ i ≀ N) such that A[i \dots N] < B[i \dots N]. S[i \dots N] denotes the suffix of string S starting at index i, i.e. S_{iS...
{"inputs": ["2\n2\nab\nbb\n3\naaa\naab"], "outputs": ["1\n3\n"]}
570
27
coding
Solve the programming task below in a Python markdown code block. Takahashi has decided to work on K days of his choice from the N days starting with tomorrow. You are given an integer C and a string S. Takahashi will choose his workdays as follows: - After working for a day, he will refrain from working on the subseq...
{"inputs": ["5 2 3\nonxoo", "5 2 1\nooxno", "5 2 2\nonoox", "5 2 1\nonxoo", "5 2 2\nonxoo", "5 2 3\nooxoo", "5 2 3\nooxoo\n", "5 1 0\nooooo\n"], "outputs": ["1\n5\n", "5\n", "1\n4\n", "1\n", "1\n", "1\n5", "1\n5\n", ""]}
372
132
coding
Solve the programming task below in a Python markdown code block. You are given an array $a$ consisting of $500000$ integers (numbered from $1$ to $500000$). Initially all elements of $a$ are zero. You have to process two types of queries to this array: $1$ $x$ $y$Β β€” increase $a_x$ by $y$; $2$ $x$ $y$Β β€” compute $\su...
{"inputs": ["2\n1 3213 321\n2 3213 0\n", "2\n1 3213 321\n2 3213 0\n", "2\n1 3213 321\n2 6100 0\n", "2\n1 3213 321\n2 2396 0\n", "2\n1 4824 321\n2 6100 0\n", "2\n1 4656 321\n2 2396 0\n", "2\n1 4824 528\n2 6100 0\n", "2\n1 4656 321\n2 2396 1\n"], "outputs": ["321\n", "321\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n"]}
427
234
coding
Solve the programming task below in a Python markdown code block. # Task Given an integer `product`, find the smallest positive integer the product of whose digits is equal to product. If there is no such integer, return -1 instead. # Example For `product = 1`, the output should be `11`; `1 x 1 = 1` (1 is not a ...
{"functional": "_inputs = [[12], [19], [450], [0], [13], [1], [5], [10]]\n_outputs = [[26], [-1], [2559], [10], [-1], [11], [15], [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, (li...
304
210
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. Given the availability time slots arrays slots1 and slots2 of two people and a meeting duration duration, return the earliest time slot that works for both of them and is of duration duration. If there is no common ti...
{"functional": "def check(candidate):\n assert candidate(slots1 = [[10,50],[60,120],[140,210]], slots2 = [[0,15],[60,70]], duration = 8) == [60,68]\n assert candidate(slots1 = [[10,50],[60,120],[140,210]], slots2 = [[0,15],[60,70]], duration = 12) == []\n\n\ncheck(Solution().minAvailableDuration)"}
202
132
coding
Solve the programming task below in a Python markdown code block. In this Kata, you will be given a number and your task will be to rearrange the number so that it is divisible by `25`, but without leading zeros. Return the minimum number of digit moves that are needed to make this possible. If impossible, return `-1` ...
{"functional": "_inputs = [[50], [25], [52], [57], [75], [100], [521], [1], [5071], [705], [1241367], [50011117], [1002], [50011111112], [2057], [50001111312], [500111117], [64954713879], [71255535569], [72046951686], [68151901446], [3848363615], [75733989998], [87364011400], [2992127830], [98262144757], [81737102196],...
109
651
coding
Solve the programming task below in a Python markdown code block. When registering in a social network, users are allowed to create their own convenient login to make it easier to share contacts, print it on business cards, etc. Login is an arbitrary sequence of lower and uppercase latin letters, digits and underline ...
{"inputs": ["Z\n1\nz\n", "0\n1\no\n", "0\n1\nO\n", "o\n1\n0\n", "o\n1\nO\n", "o\n1\no\n", "O\n1\no\n", "O\n1\n0\n"], "outputs": ["No\n", "No\n", "No\n", "No\n", "No\n", "No\n", "No\n", "No\n"]}
650
102
coding
Solve the programming task below in a Python markdown code block. A number is algebraic if it is a root of some nonzero polynomial with integer coefficients. A number is transcendental if it is not algebraic. For example, ${11}$, ${i}$, $\sqrt[3]{2}$ and $\phi$ (golden ratio) are algebraic, because they are roots of $...
{"inputs": ["3\n1\n4\n3\n2 4 4\n4\n1 2 3 5\n"], "outputs": ["1\n2\n8\n"]}
657
40
coding
Solve the programming task below in a Python markdown code block. You're given Q queries of the form (L, R). For each query you have to find the number of such x that L ≀ x ≀ R and there exist integer numbers a > 0, p > 1 such that x = a^{p}. -----Input----- The first line contains the number of queries Q (1 ≀ Q ≀...
{"inputs": ["6\n1 4\n9 9\n5 7\n12 29\n83 591\n1 1000000\n", "6\n1 2\n9 9\n5 7\n12 29\n83 591\n1 1000000\n", "6\n2 2\n9 9\n5 7\n12 29\n83 591\n1 1000000\n", "6\n2 2\n9 9\n3 7\n12 29\n83 591\n1 1000000\n", "6\n2 2\n9 9\n1 7\n12 29\n83 591\n1 1000000\n", "6\n4 2\n9 9\n2 7\n12 29\n83 301\n1 1000000\n", "6\n1 4\n9 9\n5 7\n1...
206
462
coding
Solve the programming task below in a Python markdown code block. Consider the set of all nonnegative integers: ${0, 1, 2, \dots}$. Given two integers $a$ and $b$ ($1 \le a, b \le 10^4$). We paint all the numbers in increasing number first we paint $0$, then we paint $1$, then $2$ and so on. Each number is painted whi...
{"inputs": ["1\n9 1\n", "1\n9 2\n", "1\n17 1\n", "1\n29 1\n", "1\n29 2\n", "1\n29 3\n", "1\n48 3\n", "1\n48 6\n"], "outputs": ["Finite\n", "Finite\n", "Finite\n", "Finite\n", "Finite\n", "Finite\n", "Infinite\n", "Infinite\n"]}
644
110
coding
Solve the programming task below in a Python markdown code block. Vasiliy has an exam period which will continue for n days. He has to pass exams on m subjects. Subjects are numbered from 1 to m. About every day we know exam for which one of m subjects can be passed on that day. Perhaps, some day you can't pass any ex...
{"inputs": ["1 1\n1\n1\n", "1 1\n1\n1\n", "1 1\n0\n1\n", "1 1\n0\n2\n", "1 1\n0\n3\n", "1 1\n1\n2\n", "1 1\n1\n4\n", "1 1\n1\n3\n"], "outputs": ["-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n"]}
693
119
coding
Solve the programming task below in a Python markdown code block. There are two rectangles. The lengths of the vertical sides of the first rectangle are A, and the lengths of the horizontal sides of the first rectangle are B. The lengths of the vertical sides of the second rectangle are C, and the lengths of the horizo...
{"inputs": ["3 3 2 7", "0 3 0 7", "1 4 4 2", "1 4 4 4", "0 0 9 1", "3 5 2 7", "3 5 2 7\n", "2 1 1 11"], "outputs": ["14\n", "0\n", "8\n", "16\n", "9\n", "15", "15\n", "11\n"]}
259
116
coding
Solve the programming task below in a Python markdown code block. There are K pieces of cakes. Mr. Takahashi would like to eat one cake per day, taking K days to eat them all. There are T types of cake, and the number of the cakes of type i (1 ≀ i ≀ T) is a_i. Eating the same type of cake two days in a row would be n...
{"inputs": ["7 3\n4 2 2", "6 2\n1 4 1", "100 2\n100", "110 2\n110", "7 3\n2 2 2", "7 3\n2 1 2", "7 3\n0 1 2", "7 3\n0 1 1"], "outputs": ["0\n", "1\n", "99\n", "109\n", "0\n", "0\n", "0\n", "0\n"]}
299
129
coding
Solve the programming task below in a Python markdown code block. You are given a grid with dimension $n$ x $m$ and two points with coordinates $X(x1,y1)$ and $Y(x2,y2)$ . Your task is to find the number of ways in which one can go from point $A(0, 0)$ to point $B (n, m)$ using the $shortest$ possible path such that th...
{"inputs": ["1\n3 3 1 1 1 2"], "outputs": ["5"]}
383
24
coding
Solve the programming task below in a Python markdown code block. There are $n$ block towers in a row, where tower $i$ has a height of $a_i$. You're part of a building crew, and you want to make the buildings look as nice as possible. In a single day, you can perform the following operation: Choose two indices $i$ and...
{"inputs": ["3\n3\n9 7 4\n4\n3 3 1 3\n5\n0 3 6 1 5\n", "3\n3\n9 7 4\n4\n3 3 1 6\n5\n0 3 6 1 5\n", "3\n3\n3 7 4\n4\n6 3 1 6\n5\n0 3 2 1 5\n", "3\n3\n9 7 7\n4\n3 3 1 6\n5\n0 3 6 1 5\n", "3\n3\n4 7 4\n4\n6 3 1 6\n5\n0 3 2 1 5\n", "3\n3\n6 5 0\n4\n6 1 2 2\n5\n1 4 3 1 4\n", "3\n3\n16 5 5\n4\n3 3 0 3\n5\n0 3 6 1 5\n", "3\n3\...
612
344
coding
Solve the programming task below in a Python markdown code block. Vladik often travels by trains. He remembered some of his trips especially well and I would like to tell you about one of these trips: Vladik is at initial train station, and now n people (including Vladik) want to get on the train. They are already lin...
{"inputs": ["6\n4 4 2 5 2 3\n", "6\n4 4 2 5 2 6\n", "6\n4 4 2 5 2 3\n", "6\n4 4 2 5 2 11\n", "9\n5 1 3 1 5 2 4 2 5\n", "9\n5 1 3 2 5 2 4 2 5\n", "9\n5 1 3 2 5 2 4 3 5\n", "9\n5 1 3 1 5 2 4 2 5\n"], "outputs": ["14\n", "17\n", "14\n", "22\n", "9\n", "8\n", "5\n", "9\n"]}
558
195
coding
Solve the programming task below in a Python markdown code block. Takahashi likes the sound when he buys a drink from a vending machine. That sound can be heard by spending A yen (the currency of Japan) each time. Takahashi has B yen. He will hear the sound as many times as he can with that money, but at most C times, ...
{"inputs": ["3 1 5", "2 2 2", "1 3 3", "3 1 3", "6 1 3", "7 1 3", "7 1 2", "7 1 4"], "outputs": ["0\n", "1\n", "3\n", "0\n", "0\n", "0\n", "0\n", "0\n"]}
196
94