task_type
stringclasses
4 values
problem
stringlengths
14
5.23k
solution
stringlengths
1
8.29k
problem_tokens
int64
9
1.02k
solution_tokens
int64
1
1.98k
coding
Solve the programming task below in a Python markdown code block. n boys and m girls came to the party. Each boy presented each girl some integer number of sweets (possibly zero). All boys are numbered with integers from 1 to n and all girls are numbered with integers from 1 to m. For all 1 ≤ i ≤ n the minimal number o...
{"inputs": ["2 2\n0 0\n0 0\n", "2 2\n0 0\n0 1\n", "2 2\n1 1\n1 0\n", "2 2\n2 1\n1 0\n", "2 2\n2 0\n1 0\n", "2 2\n0 1\n1 0\n", "2 2\n0 0\n0 -1\n", "3 2\n1 2 2\n3 4\n"], "outputs": ["0\n", "1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "13\n"]}
731
153
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility) P A H N A P L S I I G Y I R And ...
{"functional": "def check(candidate):\n assert candidate(s = \"PAYPALISHIRING\", numRows = 3) == \"PAHNAPLSIIGYIR\"\n assert candidate(s = \"PAYPALISHIRING\", numRows = 4) == \"PINALSIGYAHRPI\"\n assert candidate(s = \"A\", numRows = 1) == \"A\"\n\n\ncheck(Solution().convert)"}
157
92
coding
Solve the programming task below in a Python markdown code block. Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided...
{"inputs": ["y\n0\n1 1 x", "x\n0\n1 1 x", "y\n1\n2 1 y", "x\n1\n2 1 x", "y\n1\n2 1 z", "|\n0\n1 1 u", "x\n1\n2 1 y", "w\n0\n1 1 w"], "outputs": ["y\n", "x\n", "yy\n", "xx\n", "zy\n", "|\n", "yx\n", "w\n"]}
447
118
coding
Solve the programming task below in a Python markdown code block. Hofstadter sequences are a family of related integer sequences, among which the first ones were described by an American professor Douglas Hofstadter in his book Gödel, Escher, Bach. ### Task Today we will be implementing the rather chaotic recursive s...
{"functional": "_inputs = [[1], [3], [7], [10], [100], [1000]]\n_outputs = [[1], [2], [5], [6], [56], [502]]\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 le...
231
196
coding
Solve the programming task below in a Python markdown code block. You are given a text that consists of lowercase Latin letters, spaces and punctuation marks (dot, comma, exclamation mark and question mark). A word is defined as a sequence of consecutive Latin letters. Your task is to add spaces to the text by the fol...
{"inputs": ["x\n", "w\n", "y\n", "xx\n", "yx\n", "xy\n", "wy\n", "x,x\n"], "outputs": ["x\n", "w\n", "y\n", "xx\n", "yx\n", "xy\n", "wy\n", "x, x\n"]}
291
73
coding
Solve the programming task below in a Python markdown code block. This is the easy version of the problem. The difference in the constraints between both versions is colored below in red. You can make hacks only if all versions of the problem are solved. Marin and Gojou are playing hide-and-seek with an array. Gojou ...
{"inputs": ["3\n0 3\n3 2 1 0\n0 3\n4 7 6 5\n0 2\n1 2 3\n"], "outputs": ["0\n4\n3\n"]}
578
52
coding
Solve the programming task below in a Python markdown code block. Coach Moony wants the best team to represent their college in ICPC. He has $N$ students standing in a circle with certain rating $X_i$ on a competitive coding platform. It is an established fact that any coder with more rating on the platform is a better...
{"inputs": ["1\n7\n10 40 30 30 20 0 0"], "outputs": ["100"]}
336
35
coding
Solve the programming task below in a Python markdown code block. This is a problem that involves adding numbers to items in a list. In a list you will have to add the item's remainder when divided by a given divisor to each item. For example if the item is 40 and the divisor is 3 you would have to add 1 since 40 minu...
{"functional": "_inputs = [[[2, 7, 5, 9, 100, 34, 32, 0], 3], [[], 2], [[1000, 999, 998, 997], 5], [[0, 0, 0, 0], 5], [[4, 3, 2, 1], 5], [[33, 23, 45, 78, 65], 10]]\n_outputs = [[[4, 8, 7, 9, 101, 35, 34, 0]], [[]], [[1000, 1003, 1001, 999]], [[0, 0, 0, 0]], [[8, 6, 4, 2]], [[36, 26, 50, 86, 70]]]\nimport math\ndef _de...
326
359
coding
Solve the programming task below in a Python markdown code block. Mr. Dango's family has extremely huge number of members. Once it had about 100 members, and now it has as many as population of a city. It is jokingly guessed that the member might fill this planet in near future. They all have warm and gracious personal...
{"inputs": ["3\n1 1 2 3\n0 1 2 2\n1 2 0 3\n7\n1 2 2 1\n0 2 3 2\n0 1 3 1\n2 1 1 2\n5 3 4 2\n4 3 6 1\n4 2 5 1\n0", "3\n1 2 2 3\n0 1 2 2\n1 2 0 3\n7\n1 2 0 1\n0 2 3 2\n0 0 3 2\n2 2 1 2\n5 3 4 2\n4 3 6 1\n4 0 5 1\n0", "3\n1 1 2 3\n0 0 2 2\n1 2 0 3\n0\n1 2 2 1\n0 2 3 2\n0 1 3 0\n2 1 1 2\n5 3 4 2\n4 3 6 1\n4 2 5 1\n0", "3\n1...
763
748
coding
Solve the programming task below in a Python markdown code block. Alice got many presents these days. So she decided to pack them into boxes and send them to her friends. There are $n$ kinds of presents. Presents of one kind are identical (i.e. there is no way to distinguish two gifts of the same kind). Presents of di...
{"inputs": ["1 3\n", "2 2\n", "1 1\n", "5 2\n", "2 5\n", "7 6\n", "5 8\n", "7 6\n"], "outputs": ["7", "9", "1", "243", "961", "980611601", "203901829", "980611601\n"]}
673
107
coding
Solve the programming task below in a Python markdown code block. You are participating in a contest which has $11$ problems (numbered $1$ through $11$). The first eight problems (i.e. problems $1, 2, \ldots, 8$) are scorable, while the last three problems ($9$, $10$ and $11$) are non-scorable ― this means that any sub...
{"inputs": ["2\n5\n2 45\n9 100\n8 0\n2 15\n8 90\n1\n11 1"], "outputs": ["135\n0"]}
672
50
coding
Solve the programming task below in a Python markdown code block. The R1 company has recently bought a high rise building in the centre of Moscow for its main office. It's time to decorate the new office, and the first thing to do is to write the company's slogan above the main entrance to the building. The slogan of ...
{"inputs": ["1 1\n!\n", "1 1\n!\n", "2 2\nR1\n", "2 1\nR1\n", "2 1\nOA\n", "2 2\nGW\n", "2 1\nOA\n", "2 2\nGW\n"], "outputs": ["PRINT !\n", "PRINT !\n", "PRINT 1\nLEFT\nPRINT R\n", "PRINT R\nRIGHT\nPRINT 1\n", "PRINT O\nRIGHT\nPRINT A\n", "PRINT W\nLEFT\nPRINT G\n", "PRINT O\nRIGHT\nPRINT A\n", "PRINT W\nLEFT\nPRINT G\...
691
146
coding
Solve the programming task below in a Python markdown code block. Vasya wants to climb up a stair of certain amount of steps (Input parameter 1). There are 2 simple rules that he has to stick to. 1. Vasya can climb 1 or 2 steps at each move. 2. Vasya wants the number of moves to be a multiple of a certain integer. (In...
{"functional": "_inputs = [[10, 2], [3, 5], [29, 7], [2, 2], [1, 2], [10000, 2], [10000, 3], [10000, 10], [9999, 3], [9999, 2], [9999, 10], [9999, 9], [18, 10], [19, 10], [20, 10], [7688, 5], [4608, 5], [3979, 2], [5, 2]]\n_outputs = [[6], [-1], [21], [2], [-1], [5000], [5001], [5000], [5001], [5000], [5000], [5004], [...
395
397
coding
Solve the programming task below in a Python markdown code block. A: Union Ball Problem Statement There are N balls in a box. The i-th ball is labeled with a positive integer A_i. You can interact with balls in the box by taking actions under the following rules: * If integers on balls in the box are all odd or all...
{"inputs": ["3\n6 5 6", "3\n3 5 6", "3\n6 6 6", "3\n3 6 6", "3\n6 6 2", "3\n6 9 2", "3\n6 0 2", "3\n6 1 2"], "outputs": ["2\n", "1\n", "0\n", "2\n", "0\n", "2\n", "0\n", "2\n"]}
439
110
coding
Solve the programming task below in a Python markdown code block. You are given a string $s$ of 0's and 1's. You are allowed to perform the following operation: choose a non-empty contiguous substring of $s$ that contains an equal number of 0's and 1's; flip all characters in the substring, that is, replace all 0's w...
{"inputs": ["2\n0\n1\n", "2\n0\n1\n", "4\n1\n10\n1\n11\n", "4\n1\n10\n01\n11\n", "4\n00\n10\n01\n11\n", "4\n00\n10\n01\n11\n", "3\n100101\n1100011\n10101010\n", "3\n100101\n1100011\n10001010\n"], "outputs": ["0\n1\n", "0\n1\n", "1\n10\n1\n11\n", "1\n10\n01\n11\n", "00\n10\n01\n11\n", "00\n10\n01\n11\n", "010110\n011011...
477
256
coding
Solve the programming task below in a Python markdown code block. You are given a string $s$, consisting of $n$ lowercase Latin letters. A substring of string $s$ is a continuous segment of letters from $s$. For example, "defor" is a substring of "codeforces" and "fors" is not. The length of the substring is the num...
{"inputs": ["1\ng\n", "1\ng\n", "1\nh\n", "1\ni\n", "1\nf\n", "2\nab\n", "2\naz\n", "2\nqa\n"], "outputs": ["NO\n", "NO\n", "NO\n", "NO\n", "NO\n", "YES\nab\n", "YES\naz\n", "YES\nqa\n"]}
349
92
coding
Solve the programming task below in a Python markdown code block. There is no single treatment that works for every phobia, but some people cure it by being gradually exposed to the phobic situation or object. In this kata we will try curing arachnophobia by drawing primitive spiders. Our spiders will have legs, body...
{"functional": "_inputs = [[1, 1, 'W', 'o'], [2, 2, 'w', 'O'], [3, 3, 'w', '0']]\n_outputs = [['^(oWo)^'], ['/\\\\((OOwOO))/\\\\'], ['/\u2572(((0000w0000)))\u2571\\\\']]\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_...
300
226
coding
Solve the programming task below in a Python markdown code block. Write a program to obtain length (L) and breadth (B) of a rectangle and check whether its area is greater or perimeter is greater or both are equal. ------ Input Format ------ - First line will contain the length (L) of the rectangle. - Second line wi...
{"inputs": ["1\n2\n"], "outputs": ["Peri\n6\n"]}
243
19
coding
Solve the programming task below in a Python markdown code block. Vasya goes to visit his classmate Petya. Vasya knows that Petya's apartment number is $n$. There is only one entrance in Petya's house and the distribution of apartments is the following: the first floor contains $2$ apartments, every other floor conta...
{"inputs": ["4\n8 3\n1 5\n22 5\n987 5\n", "4\n8 3\n1 5\n22 5\n859 5\n", "4\n8 3\n1 5\n29 5\n859 5\n", "4\n8 3\n1 5\n11 5\n859 5\n", "4\n8 3\n1 5\n29 5\n859 7\n", "4\n6 3\n1 5\n29 5\n859 6\n", "4\n8 3\n1 5\n37 5\n859 7\n", "4\n2 3\n1 5\n29 5\n859 6\n"], "outputs": ["3\n1\n5\n198\n", "3\n1\n5\n173\n", "3\n1\n7\n173\n", "...
471
286
coding
Solve the programming task below in a Python markdown code block. Bear Limak prepares problems for a programming competition. Of course, it would be unprofessional to mention the sponsor name in the statement. Limak takes it seriously and he is going to change some words. To make it still possible to read, he will try ...
{"inputs": ["1\nZ\n", "1\nK\n", "1\nV\n", "1\nY\n", "1\nL\n", "2\nKV\n", "2\nVK\n", "2\nVL\n"], "outputs": ["0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "1\n", "0\n"]}
499
86
coding
Solve the programming task below in a Python markdown code block. You are given two arrays $a_1, a_2, \dots , a_n$ and $b_1, b_2, \dots , b_m$. Array $b$ is sorted in ascending order ($b_i < b_{i + 1}$ for each $i$ from $1$ to $m - 1$). You have to divide the array $a$ into $m$ consecutive subarrays so that, for each ...
{"inputs": ["1 1\n1\n1\n", "1 1\n2\n1\n", "1 1\n3\n2\n", "1 1\n5\n3\n", "1 1\n1\n1\n", "1 1\n5\n3\n", "1 1\n2\n1\n", "1 1\n3\n2\n"], "outputs": ["1\n", "0\n", "0\n", "0\n", "1", "0", "0", "0"]}
613
114
coding
Solve the programming task below in a Python markdown code block. Chef published a blog post, and is now receiving many queries about it. On day $i$, he receives $Q_i$ queries. But Chef can answer at most $k$ queries in a single day. Chef always answers the maximum number of questions that he can on any given day (not...
{"inputs": ["2\n6 5\n10 5 5 3 2 1\n1 1\n100"], "outputs": ["6\n101"]}
709
41
coding
Solve the programming task below in a Python markdown code block. Oranges on Cans square1001 You put a $ N $ can of aluminum on the table. E869120 You put $ M $ of oranges on each aluminum can on the table. How many oranges are on the aluminum can? input Input is given from standard input in the following format. ...
{"inputs": ["3 0", "2 1", "2 2", "3 2", "6 2", "9 2", "2 5", "4 5"], "outputs": ["0\n", "2\n", "4\n", "6\n", "12\n", "18\n", "10\n", "20\n"]}
195
82
coding
Solve the programming task below in a Python markdown code block. The only difference between easy and hard versions is constraints. The BerTV channel every day broadcasts one episode of one of the $k$ TV shows. You know the schedule for the next $n$ days: a sequence of integers $a_1, a_2, \dots, a_n$ ($1 \le a_i \le ...
{"inputs": ["4\n5 2 2\n1 2 1 2 1\n9 3 3\n3 3 3 2 2 2 1 1 1\n4 10 4\n10 8 6 4\n16 9 8\n3 1 4 1 5 9 2 6 5 3 5 8 9 7 9 3\n", "4\n5 2 2\n1 2 1 2 1\n9 3 3\n3 3 3 2 2 4 1 1 1\n4 10 4\n10 8 6 4\n16 9 8\n3 1 4 1 5 4 2 6 5 6 5 8 9 8 9 3\n", "4\n5 2 2\n1 2 1 2 1\n9 3 3\n3 3 3 2 2 2 1 1 1\n4 10 4\n10 8 6 4\n16 9 8\n3 1 4 1 5 4 2 ...
755
878
coding
Solve the programming task below in a Python markdown code block. You are given two arithmetic progressions: a_1k + b_1 and a_2l + b_2. Find the number of integers x such that L ≤ x ≤ R and x = a_1k' + b_1 = a_2l' + b_2, for some integers k', l' ≥ 0. -----Input----- The only line contains six integers a_1, b_1, a_2,...
{"inputs": ["2 0 3 3 5 21\n", "2 4 3 0 6 17\n", "2 0 3 3 5 21\n", "2 4 3 0 6 17\n", "4 0 4 1 5 100\n", "4 0 4 1 0 100\n", "4 0 4 1 0 100\n", "4 0 4 1 5 100\n"], "outputs": ["3\n", "2\n", "3\n", "2\n", "0\n", "0\n", "0\n", "0\n"]}
218
162
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. Given an array nums sorted in non-decreasing order, return the maximum between the number of positive integers and the number of negative integers. In other words, if the number of positive integers in nums is pos an...
{"functional": "def check(candidate):\n assert candidate(nums = [-2,-1,-1,1,2,3]) == 3\n assert candidate(nums = [-3,-2,-1,0,0,1,2]) == 3\n assert candidate(nums = [5,20,66,1314]) == 4\n\n\ncheck(Solution().maximumCount)"}
117
88
coding
Solve the programming task below in a Python markdown code block. There are N people living on a number line. The i-th person lives at coordinate X_i. You are going to hold a meeting that all N people have to attend. The meeting can be held at any integer coordinate. If you choose to hold the meeting at coordinate P, t...
{"inputs": ["1\n1\n", "2\n0 4", "2\n0 1", "2\n2 4", "2\n0 3", "2\n1 4", "2\n1 4\n", "7\n4 1 0 12 23 0 0"], "outputs": ["0\n", "8\n", "1\n", "2\n", "5\n", "5", "5\n", "462\n"]}
292
107
coding
Solve the programming task below in a Python markdown code block. Let's introduce a number system which is based on a roman digits. There are digits I, V, X, L which correspond to the numbers $1$, $5$, $10$ and $50$ respectively. The use of other roman digits is not allowed. Numbers in this system are written as a seq...
{"inputs": ["1\n", "2\n", "3\n", "4\n", "5\n", "6\n", "7\n", "8\n"], "outputs": ["4\n", "10\n", "20\n", "35\n", "56\n", "83\n", "116\n", "155\n"]}
424
79
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. You are given a phone number as a string number. number consists of digits, spaces ' ', and/or dashes '-'. You would like to reformat the phone number in a certain manner. Firstly, remove all spaces and dashes. Then, ...
{"functional": "def check(candidate):\n assert candidate(number = \"1-23-45 6\") == \"123-456\"\n assert candidate(number = \"123 4-567\") == \"123-45-67\"\n assert candidate(number = \"123 4-5678\") == \"123-456-78\"\n assert candidate(number = \"12\") == \"12\"\n assert candidate(number = \"--17-5 229 ...
202
169
coding
Solve the programming task below in a Python markdown code block. We have two bottles for holding water. Bottle 1 can hold up to A milliliters of water, and now it contains B milliliters of water. Bottle 2 contains C milliliters of water. We will transfer water from Bottle 2 to Bottle 1 as much as possible. How much am...
{"inputs": ["0 2 0", "0 4 0", "0 6 4", "1 4 0", "1 7 0", "6 4 0", "6 2 0", "9 0 7"], "outputs": ["2\n", "4\n", "10\n", "3\n", "6\n", "0\n", "0\n", "0\n"]}
222
95
coding
Solve the programming task below in a Python markdown code block. Read problems statements [Bengali] and [Vietnamese] as well. Ghayeeth is a math teacher. He likes playing games, so he invented a new game which he wants to play against his student Siroj. The rules of the game are as follows: Initially, Ghayeeth writes...
{"inputs": ["2\n3\n7 9 11\n2\n13 15"], "outputs": ["Ghayeeth\nSiroj"]}
450
36
coding
Solve the programming task below in a Python markdown code block. After all the events in Orlando we all know, Sasha and Roma decided to find out who is still the team's biggest loser. Thankfully, Masha found somewhere a revolver with a rotating cylinder of n bullet slots able to contain exactly k bullets, now the boys...
{"inputs": ["3 0 3\n1\n2\n3\n", "3 1 3\n2\n2\n3\n", "3 1 3\n1\n2\n3\n", "4 0 4\n1\n2\n3\n4\n", "4 0 4\n1\n2\n3\n2\n", "4 0 4\n1\n2\n3\n3\n", "5 2 5\n2\n2\n3\n4\n5\n", "5 2 5\n1\n2\n3\n4\n5\n"], "outputs": ["...", "..X", "..X\n", "....\n", "....", "....", "...XX", "...XX\n"]}
725
159
coding
Solve the programming task below in a Python markdown code block. There is a 10 \times 10 grid with rows numbered 1 to 10 from top to bottom, and columns 1 to 10 from left to right. Each cell is identified by a pair (r, c) which means that the cell is located at row r and column c. If Chef's current location is (a,b),...
{"inputs": ["4\n1 2 9 8\n5 5 5 7\n8 6 6 8\n3 10 8 10\n"], "outputs": ["1\n2\n1\n2\n"]}
470
54
coding
Solve the programming task below in a Python markdown code block. In the year 4242, the language Haskell has evolved so much that it has become an AI. It can solve very challenging problems, in very little time. Humanity is worried that Haskell will take over the world. All hopes remain tied to the Competitive Programm...
{"inputs": ["1\n1 1"], "outputs": ["1"]}
303
16
coding
Solve the programming task below in a Python markdown code block. The sum of digits of a non-negative integer $a$ is the result of summing up its digits together when written in the decimal system. For example, the sum of digits of $123$ is $6$ and the sum of digits of $10$ is $1$. In a formal way, the sum of digits of...
{"inputs": ["5\n1\n161\n67\n1206\n19\n"], "outputs": ["0 1\n130 31\n33 34\n103 1103\n14 5\n"]}
429
60
coding
Solve the programming task below in a Python markdown code block. Polycarp has a cat and his cat is a real gourmet! Dependent on a day of the week he eats certain type of food: on Mondays, Thursdays and Sundays he eats fish food; on Tuesdays and Saturdays he eats rabbit stew; on other days of week he eats chicken st...
{"inputs": ["2 1 1\n", "3 2 2\n", "4 1 2\n", "2 8 9\n", "3 1 4\n", "3 2 1\n", "5 4 3\n", "1 1 2\n"], "outputs": ["4\n", "7\n", "6\n", "6\n", "6\n", "6\n", "12\n", "4\n"]}
525
103
coding
Solve the programming task below in a Python markdown code block. Ralph has a magic field which is divided into n × m blocks. That is to say, there are n rows and m columns on the field. Ralph can put an integer in each block. However, the magic field doesn't always work properly. It works only if the product of intege...
{"inputs": ["1 3 1\n", "2 7 1\n", "1 1 1\n", "2 2 1\n", "1 1 1\n", "2 2 1\n", "2 7 1\n", "1 7 1\n"], "outputs": ["1\n", "64\n", "1\n", "2\n", "1", "2\n", "64\n", "1\n"]}
342
103
coding
Solve the programming task below in a Python markdown code block. Kajaria has an empty bag and 2 types of tiles - tiles of type $1$ have the number $X$ written and those of type $2$ have the number $Y$ written on them. He has an infinite supply of both type of tiles. In one move, Kajaria adds exactly $1$ tile to the b...
{"inputs": ["1\n5 3 96\n1 3"], "outputs": ["48"]}
616
24
coding
Solve the programming task below in a Python markdown code block. Your dad doesn't really *get* punctuation, and he's always putting extra commas in when he posts. You can tolerate the run-on sentences, as he does actually talk like that, but those extra commas have to go! Write a function called ```dadFilter``` that ...
{"functional": "_inputs = [['all this,,,, used to be trees,,,,,,'], ['Listen,,,, kid,,,,,,'], ['Luke,,,,,,,,, I am your father,,,,,,,,, '], [\"i,, don't believe this round earth,,, show me evadence!!\"], [\"Dead or alive,,,, you're coming with me,,, \"]]\n_outputs = [['all this, used to be trees'], ['Listen, kid'], ...
119
267
coding
Solve the programming task below in a Python markdown code block. You are given string s. Let's call word any largest sequence of consecutive symbols without symbols ',' (comma) and ';' (semicolon). For example, there are four words in string "aba,123;1a;0": "aba", "123", "1a", "0". A word can be empty: for example, th...
{"inputs": ["1\n", "a\n", ".\n", ";\n", ";\n", ".\n", "0\n", "b\n"], "outputs": ["\"1\"\n-\n", "-\n\"a\"\n", "-\n\".\"\n", "-\n\",\"\n", "-\n\",\"\n", "-\n\".\"\n", "\"0\"\n-\n", "-\n\"b\"\n"]}
475
99
coding
Solve the programming task below in a Python markdown code block. # Making Change Complete the method that will determine the minimum number of coins needed to make change for a given amount in American currency. Coins used will be half-dollars, quarters, dimes, nickels, and pennies, worth 50¢, 25¢, 10¢, 5¢ and 1¢, r...
{"functional": "_inputs = [[0], [1], [5], [43], [91], [101], [239]]\n_outputs = [[{}], [{'P': 1}], [{'N': 1}], [{'Q': 1, 'D': 1, 'N': 1, 'P': 3}], [{'H': 1, 'Q': 1, 'D': 1, 'N': 1, 'P': 1}], [{'H': 2, 'P': 1}], [{'H': 4, 'Q': 1, 'D': 1, 'P': 4}]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) ...
342
281
coding
Solve the programming task below in a Python markdown code block. Vasya plays Robot Bicorn Attack. The game consists of three rounds. For each one a non-negative integer amount of points is given. The result of the game is the sum of obtained points. Vasya has already played three rounds and wrote obtained points one ...
{"inputs": ["1\n", "0\n", "2\n", "55\n", "99\n", "93\n", "13\n", "84\n"], "outputs": ["-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n"]}
373
76
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. Given a binary tree root, a node X in the tree is named good if in the path from root to X there are no nodes with a value greater than X. Return the number of good nodes in the binary tree.   Please complete the foll...
{"functional": "def check(candidate):\n assert candidate(root = tree_node([3,1,4,3,None,1,5])) == 4\n assert candidate(root = tree_node([3,3,None,4,2])) == 3\n assert candidate(root = tree_node([1])) == 1\n\n\ncheck(Solution().goodNodes)"}
145
79
coding
Solve the programming task below in a Python markdown code block. Vasya has a string $s$ of length $n$ consisting only of digits 0 and 1. Also he has an array $a$ of length $n$. Vasya performs the following operation until the string becomes empty: choose some consecutive substring of equal characters, erase it from ...
{"inputs": ["1\n1\n1337\n", "1\n1\n1337\n", "5\n10011\n8 7 55 0 4\n", "5\n10111\n8 7 60 0 5\n", "5\n01111\n5 1 37 3 5\n", "5\n10011\n8 7 71 0 4\n", "5\n10011\n8 7 55 0 5\n", "5\n10111\n8 7 55 0 5\n"], "outputs": ["1337\n", "1337\n", "71\n", "76\n", "47\n", "87\n", "71\n", "71\n"]}
450
198
coding
Solve the programming task below in a Python markdown code block. A number is simply made up of digits. The number 1256 is made up of the digits 1, 2, 5, and 6. For 1256 there are 24 distinct permutations of the digits: 1256, 1265, 1625, 1652, 1562, 1526, 2156, 2165, 2615, 2651, 2561, 2516, 5126, 5162, 5216, 5...
{"functional": "_inputs = [[2], [25], [737]]\n_outputs = [[2], [38], [629]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return math.isclose(a, b, rel_tol=tol, abs_tol=tol)\n if isinstance(a, (list, tuple)):\n if len(a) != len(b): return False\n ...
522
173
coding
Solve the programming task below in a Python markdown code block. Read problems statements [Hindi] ,[Bengali] , [Mandarin chinese] , [Russian] and [Vietnamese] as well. There are $N$ circles in a plane. Circle $i$ and circle $j$ form a *good pair* if it is possible to choose a point $P_{1}$ on the perimeter of circle ...
{"inputs": ["2 3\n0 0 5\n8 3 2\n0\n10\n20"], "outputs": ["0\n1\n0"]}
601
38
coding
Solve the programming task below in a Python markdown code block. You are given two integers, $N$ and $\mbox{M}$. Count the number of strings of length $N$ (under the alphabet set of size $\mbox{M}$) that doesn't contain any palindromic string of the length greater than $\mbox{1}$ as a consecutive substring. Input For...
{"inputs": ["2\n2 2\n2 3\n"], "outputs": ["2\n6\n"]}
463
24
coding
Solve the programming task below in a Python markdown code block. There is a circular track of length M consisting of M checkpoints and M bidirectional roads such that each road has a length of 1 unit. Chef is currently at checkpoint A and wants to reach checkpoint B. Find the minimum length of the road he needs to tr...
{"inputs": ["4\n1 3 100\n1 98 100\n40 30 50\n2 1 2\n"], "outputs": ["2\n3\n10\n1\n"]}
433
53
coding
Solve the programming task below in a Python markdown code block. Natasha is planning an expedition to Mars for $n$ people. One of the important tasks is to provide food for each participant. The warehouse has $m$ daily food packages. Each package has some food type $a_i$. Each participant must eat exactly one food p...
{"inputs": ["1 1\n2\n", "1 1\n3\n", "1 1\n59\n", "1 1\n59\n", "1 1\n18\n", "100 1\n1\n", "1 1\n100\n", "50 1\n75\n"], "outputs": ["1\n", "1\n", "1\n", "1\n", "1\n", "0\n", "1\n", "0\n"]}
565
111
coding
Solve the programming task below in a Python markdown code block. You are given a chessboard of size NxN. There is a white knight and several black pawns located on the board. The knight can move similarly to the normal knight in the game of chess; however it can only move towards the right of the board (see the below ...
{"inputs": ["1\n5\nK....\n..P..\n.P...\n...P.\n....."], "outputs": ["2"]}
284
31
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. The numeric value of a lowercase character is defined as its position (1-indexed) in the alphabet, so the numeric value of a is 1, the numeric value of b is 2, the numeric value of c is 3, and so on. The numeric value...
{"functional": "def check(candidate):\n assert candidate(n = 3, k = 27) == \"aay\"\n assert candidate(n = 5, k = 73) == \"aaszz\"\n\n\ncheck(Solution().getSmallestString)"}
246
62
coding
Solve the programming task below in a Python markdown code block. A soldier wants to buy w bananas in the shop. He has to pay k dollars for the first banana, 2k dollars for the second one and so on (in other words, he has to pay i·k dollars for the i-th banana). He has n dollars. How many dollars does he have to borr...
{"inputs": ["1 2 1\n", "1 1 1\n", "1 5 6\n", "1 5 6\n", "1 2 1\n", "1 1 1\n", "1 0 1\n", "3 0 4\n"], "outputs": ["0", "0", "16", "16\n", "0\n", "0\n", "1\n", "30\n"]}
202
102
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. You are given two positive integers n and k. A factor of an integer n is defined as an integer i where n % i == 0. Consider a list of all factors of n sorted in ascending order, return the kth factor in this list or r...
{"functional": "def check(candidate):\n assert candidate(n = 12, k = 3) == 3\n assert candidate(n = 7, k = 2) == 7\n assert candidate(n = 4, k = 4) == -1\n\n\ncheck(Solution().kthFactor)"}
115
72
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. Read problems statements in [Hindi], [Mandarin Chinese], [Russian], [Vietnamese], and [Bengali] as well. Chef has a memory machine. It has one layer for data storage and another layer for cache. Chef has stored an array with length $N$ in the first laye...
{"inputs": ["1\n5 3 3\n0 3 4"], "outputs": ["2"]}
731
24
coding
Solve the programming task below in a Python markdown code block. You have a fraction $\frac{a}{b}$. You need to find the first occurrence of digit c into decimal notation of the fraction after decimal point. -----Input----- The first contains three single positive integers a, b, c (1 ≤ a < b ≤ 10^5, 0 ≤ c ≤ 9). -...
{"inputs": ["1 2 0\n", "2 3 7\n", "1 7 7\n", "1 9 0\n", "1 3 0\n", "2 3 0\n", "1 2 5\n", "1 7 0\n"], "outputs": ["2", "-1", "6", "-1", "-1", "-1", "1", "-1"]}
230
94
coding
Solve the programming task below in a Python markdown code block. You have a card deck of $n$ cards, numbered from top to bottom, i. e. the top card has index $1$ and bottom card — index $n$. Each card has its color: the $i$-th card has color $a_i$. You should process $q$ queries. The $j$-th query is described by inte...
{"inputs": ["5 1\n1 2 3 4 5\n1\n", "5 1\n1 2 3 4 5\n1\n", "5 1\n1 4 3 4 5\n1\n", "5 1\n1 2 3 4 5\n2\n", "5 1\n2 5 1 8 5\n1\n", "5 1\n1 4 3 4 6\n1\n", "5 1\n1 2 3 4 6\n1\n", "5 1\n1 4 3 5 5\n1\n"], "outputs": ["1 ", "1 ", "1 ", "2 ", "3 ", "1 ", "1 ", "1 "]}
609
175
coding
Solve the programming task below in a Python markdown code block. Given an D-dimension array, where each axis is of length N, your goal is to find the sum of every index in the array starting from 0. For Example if D=1 and N=10 then the answer would be 45 ([0,1,2,3,4,5,6,7,8,9]) If D=2 and N = 3 the answer is 18 which...
{"functional": "_inputs = [[2, 2], [2, 3], [3, 2], [3, 3], [1, 101], [10, 10], [10, 11], [11, 10], [11, 11], [15, 8], [19, 84], [17, 76]]\n_outputs = [[4], [18], [12], [81], [5050], [450000000000], [1296871230050], [4950000000000], [15692141883605], [1847179534663680], [2871495452512585452340652014195036913664], [60022...
310
413
coding
Solve the programming task below in a Python markdown code block. ## Task In this kata you'll be given a string of English digits "collapsed" together, like this: `zeronineoneoneeighttwoseventhreesixfourtwofive` Your task is to split the string back to digits: `zero nine one one eight two seven three six four two fi...
{"functional": "_inputs = [['three'], ['eightsix'], ['fivefourseven'], ['ninethreesixthree'], ['foursixeighttwofive'], ['fivethreefivesixthreenineonesevenoneeight'], ['threesevensevensixninenineninefiveeighttwofiveeightsixthreeeight'], ['zeroonetwothreefourfivesixseveneightnine']]\n_outputs = [['three'], ['eight six'],...
164
298
coding
Solve the programming task below in a Python markdown code block. LiLand is a country, consisting of n cities. The cities are numbered from 1 to n. The country is well known because it has a very strange transportation system. There are many one-way flights that make it possible to travel between the cities, but the fl...
{"inputs": ["3 3\n1 2\n2 3\n1 3\n", "4 3\n1 2\n2 3\n3 4\n1 4\n", "4 4\n1 2\n2 3\n3 4\n1 3\n", "4 2\n1 2\n2 4\n3 4\n1 4\n", "4 3\n1 2\n2 3\n3 4\n1 3\n", "4 3\n1 2\n2 3\n3 4\n2 3\n", "4 3\n1 2\n2 3\n3 4\n1 5\n", "4 3\n1 2\n2 3\n3 4\n0 3\n"], "outputs": ["Yes\n1\n1\n2\n", "Yes\n2\n2\n2\n", "Yes\n1\n1\n2\n2\n", "Yes\n2\n2\...
514
258
coding
Solve the programming task below in a Python markdown code block. In a public bath, there is a shower which emits water for T seconds when the switch is pushed. If the switch is pushed when the shower is already emitting water, from that moment it will be emitting water for T seconds. Note that it does not mean that t...
{"inputs": ["1 0\n0", "1 2\n0", "1 1\n0", "2 4\n0 2", "2 4\n0 4", "2 6\n0 3", "2 8\n0 5", "2 9\n0 1"], "outputs": ["0\n", "2\n", "1", "6\n", "8\n", "9\n", "13\n", "10\n"]}
369
105
coding
Solve the programming task below in a Python markdown code block. Read problems statements in Mandarin Chinese and Russian. Today is Chef's birthday. His mom gifted him a truly lovable gift, a permutation of first N positive integers. She placed the permutation on a very long table in front of Chef and left it for ...
{"inputs": ["2\n5 2\n3 5\n5 1\n1", "2\n5 2\n3 5\n7 1\n1", "2\n5 2\n3 3\n7 1\n1", "2\n6 2\n1 3\n7 1\n2", "2\n6 0\n1 3\n7 0\n1", "2\n5 2\n3 3\n7 0\n1", "2\n5 2\n1 3\n7 0\n1", "2\n6 2\n1 3\n7 0\n1"], "outputs": ["Mom\nChef", "Mom\nChef\n", "Chef\nChef\n", "Chef\nMom\n", "Mom\nMom\n", "Chef\nChef\n", "Chef\nChef\n", "Chef\...
739
189
coding
Solve the programming task below in a Python markdown code block. Read problems statements in Mandarin chinese, Russian and Vietnamese as well. You are given a convex polygon with N vertices. You have to find any ⌊N/10⌋ distinct points with integer coordinates that lie strictly inside the polygon, or determine that ...
{"inputs": ["1\n11\n0 0\n1 1\n2 3\n2 5\n0 10\n-2 10\n-5 9\n-8 7\n-8 4\n-6 1\n-2 0"], "outputs": ["0 1"]}
635
69
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. You are given a 0-indexed array nums consisting of n positive integers. The array nums is called alternating if: nums[i - 2] == nums[i], where 2 <= i <= n - 1. nums[i - 1] != nums[i], where 1 <= i <= n - 1. In one o...
{"functional": "def check(candidate):\n assert candidate(nums = [3,1,3,2,4,3]) == 3\n assert candidate(nums = [1,2,2,2,2]) == 2\n\n\ncheck(Solution().minimumOperations)"}
147
61
coding
Solve the programming task below in a Python markdown code block. Given n number of people in a room, calculate the probability that any two people in that room have the same birthday (assume 365 days every year = ignore leap year). Answers should be two decimals unless whole (0 or 1) eg 0.05 Also feel free to reuse/ex...
{"functional": "_inputs = [[5], [15], [1], [365], [366]]\n_outputs = [[0.03], [0.25], [0], [1], [1]]\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) != ...
91
190
coding
Solve the programming task below in a Python markdown code block. Chef is given a sequence of prime numbers $A_1, A_2, \ldots, A_N$. This sequence has exactly $2^N$ subsequences. A subsequence of $A$ is good if it does not contain any two identical numbers; in particular, the empty sequence is good. Chef has to find th...
{"inputs": ["5 3\n2 2 3 3 5"], "outputs": ["18"]}
393
25
coding
Solve the programming task below in a Python markdown code block. There is a puzzle to complete by combining 14 numbers from 1 to 9. Complete by adding another number to the given 13 numbers. The conditions for completing the puzzle are * You must have one combination of the same numbers. * The remaining 12 numbers a...
{"inputs": ["3649596966777\n4281679207521\n3239171774529\n606159871584\n1057360767920\n71774966057", "3649596966777\n2237884645346\n155584781051\n7133209108608\n7755542764533\n704120058101", "3649596966777\n2237884645346\n155584781051\n7133209108608\n6142846373259\n704120058101", "3649596966777\n2313441461120\n15558478...
562
921
coding
Solve the programming task below in a Python markdown code block. The prime numbers are not regularly spaced. For example from `2` to `3` the step is `1`. From `3` to `5` the step is `2`. From `7` to `11` it is `4`. Between 2 and 50 we have the following pairs of 2-steps primes: `3, 5 - 5, 7, - 11, 13, - 17, 19, - 29,...
{"functional": "_inputs = [[2, 100, 110], [4, 100, 110], [6, 100, 110], [8, 300, 400], [10, 300, 400], [4, 30000, 100000], [6, 30000, 100000], [8, 30000, 100000], [11, 30000, 100000], [16, 5, 20], [2, 10000000, 11000000], [52, 1300, 15000], [10, 4900, 5000], [30, 4900, 5000], [2, 4900, 5000], [2, 104000, 105000], [2, 4...
720
716
coding
Solve the programming task below in a Python markdown code block. -----Input----- The input contains a single integer a (1 ≤ a ≤ 64). -----Output----- Output a single integer. -----Examples----- Input 2 Output 1 Input 4 Output 2 Input 27 Output 5 Input 42 Output 6
{"inputs": ["2\n", "4\n", "1\n", "3\n", "5\n", "6\n", "7\n", "8\n"], "outputs": ["1\n", "2\n", "1\n", "1\n", "1\n", "2\n", "1\n", "5\n"]}
76
70
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. Given an array of points on the X-Y plane points where points[i] = [xi, yi], return the area of the largest triangle that can be formed by any three different points. Answers within 10-5 of the actual answer will be a...
{"functional": "def check(candidate):\n assert candidate(points = [[0,0],[0,1],[1,0],[0,2],[2,0]]) == 2.00000\n assert candidate(points = [[1,0],[0,0],[0,1]]) == 0.50000\n\n\ncheck(Solution().largestTriangleArea)"}
103
85
coding
Solve the programming task below in a Python markdown code block. Have you ever used the chat application QQ? Well, in a chat group of QQ, administrators can muzzle a user for days. In Boboniu's chat group, there's a person called Du Yi who likes to make fun of Boboniu every day. Du will chat in the group for n days....
{"inputs": ["1 1 0\n0\n", "1 1 1\n2\n", "1 1 1\n0\n", "1 1 0\n2\n", "1 1 1\n1\n", "1 0 1\n0\n", "5 3 3\n8 5 5 1 14\n", "5 3 3\n8 5 5 2 14\n"], "outputs": ["0\n", "2\n", "0\n", "2\n", "1\n", "0\n", "22\n", "22\n"]}
558
138
coding
Solve the programming task below in a Python markdown code block. One day three best friends Petya, Vasya and Tonya decided to form a team and take part in programming contests. Participants are usually offered several problems during programming contests. Long before the start the friends decided that they will implem...
{"inputs": ["1\n1 0 0\n", "1\n1 1 1\n", "1\n0 0 0\n", "1\n1 1 0\n", "1\n0 1 0\n", "1\n1 0 1\n", "2\n1 0 0\n1 1 1\n", "2\n1 0 1\n1 1 1\n"], "outputs": ["0\n", "1\n", "0\n", "1\n", "0\n", "1\n", "1\n", "2\n"]}
406
130
coding
Solve the programming task below in a Python markdown code block. In BerSoft $n$ programmers work, the programmer $i$ is characterized by a skill $r_i$. A programmer $a$ can be a mentor of a programmer $b$ if and only if the skill of the programmer $a$ is strictly greater than the skill of the programmer $b$ $(r_a > r...
{"inputs": ["2 0\n3 1\n", "2 0\n1 1\n", "2 0\n3 1\n", "2 0\n1 1\n", "2 0\n1 2\n", "2 0\n3 2\n", "2 0\n3 3\n", "2 0\n1 3\n"], "outputs": ["1 0 \n", "0 0 \n", "1 0 ", "0 0 ", "0 1\n", "1 0\n", "0 0\n", "0 1\n"]}
673
134
coding
Solve the programming task below in a Python markdown code block. You are given an integer sequence $1, 2, \dots, n$. You have to divide it into two sets $A$ and $B$ in such a way that each element belongs to exactly one set and $|sum(A) - sum(B)|$ is minimum possible. The value $|x|$ is the absolute value of $x$ and ...
{"inputs": ["3\n", "5\n", "6\n", "1\n", "2\n", "4\n", "4\n", "2\n"], "outputs": ["0\n", "1\n", "1\n", "1\n", "1\n", "0\n", "0\n", "1\n"]}
360
70
coding
Solve the programming task below in a Python markdown code block. We will say that two integer sequences of length N, x_1, x_2, ..., x_N and y_1, y_2, ..., y_N, are similar when |x_i - y_i| \leq 1 holds for all i (1 \leq i \leq N). In particular, any integer sequence is similar to itself. You are given an integer N a...
{"inputs": ["2\n2 4", "1\n000", "2\n3 6", "1\n011", "2\n2 6", "1\n010", "2\n3 4", "1\n111"], "outputs": ["5\n", "1\n", "7\n", "2\n", "5\n", "1\n", "7\n", "2\n"]}
321
94
coding
Solve the programming task below in a Python markdown code block. Chef's phone has a total storage of S MB. Also, Chef has 2 apps already installed on his phone which occupy X MB and Y MB respectively. He wants to install another app on his phone whose memory requirement is Z MB. For this, he might have to delete the...
{"inputs": ["4\n10 1 2 3\n9 4 5 1\n15 5 10 15\n100 20 30 75\n"], "outputs": ["0\n1\n2\n1\n"]}
483
61
coding
Solve the programming task below in a Python markdown code block. DZY loves chessboard, and he enjoys playing with it. He has a chessboard of n rows and m columns. Some cells of the chessboard are bad, others are good. For every good cell, DZY wants to put a chessman on it. Each chessman is either white or black. Afte...
{"inputs": ["1 1\n.\n", "1 1\n-\n", "1 1\n-\n", "1 1\n.\n", "2 2\n..\n..\n", "3 1\n-\n.\n.\n", "3 1\n-\n.\n.\n", "2 2\n..\n-.\n"], "outputs": ["B\n", "-\n", "-\n", "B\n", "BW\nWB\n", "-\nW\nB\n", "-\nW\nB\n", "BW\n-B\n"]}
434
127
coding
Solve the programming task below in a Python markdown code block. Many years ago, Roman numbers were defined by only `4` digits: `I, V, X, L`, which represented `1, 5, 10, 50`. These were the only digits used. The value of a sequence was simply the sum of digits in it. For instance: ``` IV = VI = 6 IX = XI = 11 XXL = L...
{"functional": "_inputs = [[1], [2], [3], [4], [5], [6], [10], [10000000]]\n_outputs = [[4], [10], [20], [35], [56], [83], [244], [489999753]]\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...
322
219
coding
Solve the programming task below in a Python markdown code block. Johnny is a farmer and he annually holds a beet farmers convention "Drop the beet". Every year he takes photos of farmers handshaking. Johnny knows that no two farmers handshake more than once. He also knows that some of the possible handshake combinati...
{"functional": "_inputs = [[0], [1], [3], [6], [7]]\n_outputs = [[1], [2], [3], [4], [5]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return math.isclose(a, b, rel_tol=tol, abs_tol=tol)\n if isinstance(a, (list, tuple)):\n if len(a) != len(b): ret...
151
179
coding
Solve the programming task below in a Python markdown code block. A flea is sitting at one of the n hassocks, arranged in a circle, at the moment. After minute number k the flea jumps through k - 1 hassoсks (clockwise). For example, after the first minute the flea jumps to the neighboring hassock. You should answer: wi...
{"inputs": ["7\n", "5\n", "9\n", "8\n", "8\n", "2\n", "6\n", "4\n"], "outputs": ["NO\n", "NO\n", "NO\n", "YES\n", "YES\n", "YES\n", "NO\n", "YES\n"]}
159
70
coding
Solve the programming task below in a Python markdown code block. Write a function that checks if all the letters in the second string are present in the first one at least once, regardless of how many times they appear: ``` ["ab", "aaa"] => true ["trances", "nectar"] => true ["compadres", "DRAPES"] => true ...
{"functional": "_inputs = [[['abcd', 'aaa']], [['trances', 'nectar']], [['THE EYES', 'they see']], [['assert', 'staring']], [['arches', 'later']], [['dale', 'caller']], [['parses', 'parsecs']], [['replays', 'adam']], [['mastering', 'streaming']], [['drapes', 'compadres']], [['deltas', 'slated']], [['deltas', '']], [[''...
154
284
coding
Solve the programming task below in a Python markdown code block. You probably know the 42 number as "The answer to life, the universe and everything" according to Douglas Adams' "The Hitchhiker's Guide to the Galaxy". For Freud, the answer was quite different. In the society he lived in, people-women in particular- h...
{"functional": "_inputs = [['test'], ['sexy sex'], ['This is a test'], ['This is a longer test'], [\"You're becoming a true freudian expert\"]]\n_outputs = [['sex'], ['sex sex'], ['sex sex sex sex'], ['sex sex sex sex sex'], ['sex sex sex sex sex sex']]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, ...
254
209
coding
Solve the programming task below in a Python markdown code block. The XOR pair representation (XPR) of a positive integer $N$ is defined as a pair of integers $(A, B)$ such that: - $1 \le A \le B \le N$ - $A \oplus B = N$ - if there is no way to choose $A$ and $B$ satisfying the above conditions, $A = B = -1$ - otherwi...
{"inputs": ["5\n1 10\n3 6\n4 10\n10 17\n100 159"], "outputs": ["28\n9\n28\n79\n7485"]}
356
54
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 number of good subarrays of nums. A good array is an array where the number of different integers in that array is exactly k. For example, [1,2,3,1,2] has 3 di...
{"functional": "def check(candidate):\n assert candidate(nums = [1,2,1,2,3], k = 2) == 7\n assert candidate(nums = [1,2,1,3,4], k = 3) == 3\n\n\ncheck(Solution().subarraysWithKDistinct)"}
135
72
coding
Solve the programming task below in a Python markdown code block. You are given an array of non-negative integers, your task is to complete the series from 0 to the highest number in the array. If the numbers in the sequence provided are not in order you should order them, but if a value repeats, then you must return ...
{"functional": "_inputs = [[[0, 1]], [[1, 4, 6]], [[3, 4, 5]], [[2, 1]], [[1, 4, 4, 6]]]\n_outputs = [[[0, 1]], [[0, 1, 2, 3, 4, 5, 6]], [[0, 1, 2, 3, 4, 5]], [[0, 1, 2]], [[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=...
245
248
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. You are given an integer array rolls of length n and an integer k. You roll a k sided dice numbered from 1 to k, n times, where the result of the ith roll is rolls[i]. Return the length of the shortest sequence of rol...
{"functional": "def check(candidate):\n assert candidate(rolls = [4,2,1,2,3,3,2,4,1], k = 4) == 3\n assert candidate(rolls = [1,1,2,2], k = 2) == 2\n assert candidate(rolls = [1,1,3,2,2,2,3,3], k = 4) == 1\n\n\ncheck(Solution().shortestSequence)"}
133
110
coding
Solve the programming task below in a Python markdown code block. Sasha is a very happy guy, that's why he is always on the move. There are $n$ cities in the country where Sasha lives. They are all located on one straight line, and for convenience, they are numbered from $1$ to $n$ in increasing order. The distance bet...
{"inputs": ["4 2\n", "7 6\n", "9 5\n", "9 5\n", "5 5\n", "7 5\n", "4 1\n", "9 1\n"], "outputs": ["4\n", "6\n", "14\n", "14 \n", "4\n", "7\n", "6\n", "36\n"]}
557
90
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. Given an array of integers arr and an integer k. Find the least number of unique integers after removing exactly k elements.   Please complete the following python code precisely: ```python class Solution: def f...
{"functional": "def check(candidate):\n assert candidate(arr = [5,5,4], k = 1) == 1\n assert candidate(arr = [4,3,1,1,3,3,2], k = 3) == 2\n\n\ncheck(Solution().findLeastNumOfUniqueInts)"}
85
74
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. Given a pattern and a string s, return true if s matches the pattern. A string s matches a pattern if there is some bijective mapping of single characters to non-empty strings such that if each character in pattern is...
{"functional": "def check(candidate):\n assert candidate(pattern = \"abab\", s = \"redblueredblue\") == True\n assert candidate(pattern = \"aaaa\", s = \"asdasdasdasd\") == True\n assert candidate(pattern = \"aabb\", s = \"xyzabcxzyabc\") == False\n\n\ncheck(Solution().wordPatternMatch)"}
135
82
coding
Solve the programming task below in a Python markdown code block. A: Alphabet block Wakana Nakawa loves palindromes. Because my name is also a palindrome. Wakana got a set with some alphabet blocks. An alphabet block is a block in which one lowercase alphabet is written for each block, and you can create your favorit...
{"inputs": ["gcpc", "bgnc", "gcoc", "gcnc", "cgnc", "bcng", "bcnh", "hncb"], "outputs": ["1\n", "2\n", "1\n", "1\n", "1\n", "2\n", "2\n", "2\n"]}
436
71
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. Given an array of positive integers arr, find a pattern of length m that is repeated k or more times. A pattern is a subarray (consecutive sub-sequence) that consists of one or more values, repeated multiple times con...
{"functional": "def check(candidate):\n assert candidate(arr = [1,2,4,4,4,4], m = 1, k = 3) == True\n assert candidate(arr = [1,2,1,2,1,1,1,3], m = 2, k = 2) == True\n assert candidate(arr = [1,2,1,2,1,3], m = 2, k = 3) == False\n assert candidate(arr = [1,2,3,1,2], m = 2, k = 2) == False\n assert candid...
143
172
coding
Solve the programming task below in a Python markdown code block. Dr .: Peter, I've finally done it. Peter: See you again? What kind of silly invention is this time? Dr .: I finally came up with a revolutionary way to process mathematical formulas on a computer. Look at this table. Ordinary notation | Dr.'s "breakth...
{"inputs": ["2 0 82 - /\n4 4 - 7 0 3 * + *\n0 0 1 + +", "1 0 82 - /\n4 4 - 7 0 3 * + *\n0 0 1 + +", "1 0 82 - /\n1 4 - 7 0 3 + + *\n0 0 1 + +", "1 0 82 - /\n1 4 - 7 0 3 * + *\n0 0 1 + +", "1 0 82 - /\n2 4 - 7 0 3 * + *\n0 0 1 + +", "1 0 82 - /\n2 4 - 7 0 3 * + *\n1 0 1 + +", "1 0 82 - /\n2 6 - 7 0 3 * + *\n1 0 1 + +", ...
676
507
coding
Solve the programming task below in a Python markdown code block. In one little known, but very beautiful country called Waterland, lives a lovely shark Valerie. Like all the sharks, she has several rows of teeth, and feeds on crucians. One of Valerie's distinguishing features is that while eating one crucian she uses ...
{"inputs": ["1 1 0\n1 3\n", "2 2 13\n1 13\n2 12\n", "1 1 1000000\n1 1000000\n", "4 2 4\n1 9\n1 0\n1 4\n2 6\n", "4 2 4\n1 9\n1 1\n1 4\n2 6\n", "4 2 4\n1 4\n1 1\n1 4\n2 6\n", "4 2 8\n1 9\n1 10\n1 4\n2 6\n", "4 2 4\n1 9\n1 10\n1 4\n2 6\n"], "outputs": ["0\n", "13\n", "1000000\n", "4\n", "4\n", "4\n", "8\n", "4\n"]}
590
222
coding
Solve the programming task below in a Python markdown code block. Jack is working on his jumping skills recently. Currently he's located at point zero of the number line. He would like to get to the point x. In order to train, he has decided that he'll first jump by only one unit, and each subsequent jump will be exact...
{"inputs": ["3\n", "1\n", "2\n", "0\n", "6\n", "-2\n", "-5\n", "-8\n"], "outputs": ["2\n", "1\n", "3\n", "0\n", "3\n", "3\n", "5\n", "4\n"]}
163
70
coding
Solve the programming task below in a Python markdown code block. Timur has a stairway with $n$ steps. The $i$-th step is $a_i$ meters higher than its predecessor. The first step is $a_1$ meters higher than the ground, and the ground starts at $0$ meters. The stairs for the first test case. Timur has $q$ questions, e...
{"inputs": ["3\n4 5\n1 2 1 5\n1 2 4 9 10\n2 2\n1 1\n0 1\n3 1\n1000000000 1000000000 1000000000\n1000000000\n", "11\n1 1\n666\n666\n1 1\n666\n666\n1 1\n666\n666\n1 1\n666\n666\n1 1\n666\n666\n1 1\n666\n666\n1 1\n666\n666\n1 1\n666\n666\n1 1\n666\n666\n1 1\n666\n666\n1 1\n666\n666\n"], "outputs": ["1 4 4 9 9 \n0 2 \n3000...
734
317
coding
Solve the programming task below in a Python markdown code block. Dazzler has a task for you. Given two positive integers A and B, find two positive integers i and j such that: [gcd](i,j) > 1; A ≤ i < j ≤ B; The value (i + j) is minimum possible. If there are multiple solutions, you may print any of them. If no such...
{"inputs": ["2\n2 3\n2 10\n"], "outputs": ["-1\n2 4\n"]}
330
28
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. You are given a 0-indexed permutation of n integers nums. A permutation is called semi-ordered if the first number equals 1 and the last number equals n. You can perform the below operation as many times as you want u...
{"functional": "def check(candidate):\n assert candidate(nums = [2,1,4,3]) == 2\n assert candidate(nums = [2,4,1,3]) == 3\n assert candidate(nums = [1,3,4,2,5]) == 0\n\n\ncheck(Solution().semiOrderedPermutation)"}
154
77
coding
Solve the programming task below in a Python markdown code block. We’ve all seen katas that ask for conversion from snake-case to camel-case, from camel-case to snake-case, or from camel-case to kebab-case — the possibilities are endless. But if we don’t know the case our inputs are in, these are not very helpful. ##...
{"functional": "_inputs = [['hello-world'], ['hello-to-the-world'], ['hello_world'], ['hello_to_the_world'], ['helloWorld'], ['helloToTheWorld'], ['hello-World'], ['hello-To-The-World'], ['good-Night'], ['he--llo'], ['good-night'], ['good_night'], ['goodNight'], ['hello_World'], ['hello_To_The_World'], ['he_lloWorld'],...
557
320
coding
Solve the programming task below in a Python markdown code block. Chef Vivek is good in mathematics and likes solving problems on prime numbers. One day his friend Jatin told him about Victory numbers. Victory number can be defined as a number formed after summing up all the prime numbers till given number n. Now, chef...
{"inputs": ["3\n22\n13\n10"], "outputs": ["77\n41\n17"]}
225
28
coding
Solve the programming task below in a Python markdown code block. [0, 0] [0, 1] [1, 1] [0, 2] [1, 2] [2, 2] [0, 3] [1, 3] [2, 3] [3, 3] [0, 4] [1, 4] [2, 4] [3, 4] [4, 4] [0, 5] [1, 5] [2, 5] [3, 5] [4, 5] [5, 5] [0, 6] [1, 6] [2, 6] [3, 6] [4, 6] [5, 6] [6, 6] Consider the standard set of 28 wes...
{"inputs": ["6\n13 23 20 24 15 25\n10\n00 01 11 02 12 22 03 13 23 33", "6\n13 23 20 24 11 25\n10\n00 01 11 02 12 22 03 13 23 33", "6\n13 23 20 24 11 25\n10\n00 01 11 02 12 22 03 13 16 33", "6\n16 23 16 16 15 25\n10\n00 01 11 02 12 22 03 13 13 33", "6\n13 23 14 24 15 25\n10\n00 01 11 02 12 22 03 13 36 33", "6\n12 23 14 ...
580
486