task_type stringclasses 1
value | problem stringlengths 261 3.34k | answer stringlengths 35 6.15k | problem_tokens int64 62 774 | answer_tokens int64 12 2.04k |
|---|---|---|---|---|
coding | Solve the programming task below in a Python markdown code block.
Little Dima has two sequences of points with integer coordinates: sequence (a_1, 1), (a_2, 2), ..., (a_{n}, n) and sequence (b_1, 1), (b_2, 2), ..., (b_{n}, n).
Now Dima wants to count the number of distinct sequences of points of length 2·n that can be... | {"inputs": ["1\n1\n2\n7\n", "1\n1\n2\n7\n", "2\n1 2\n1 2\n4\n", "2\n1 2\n2 2\n4\n", "2\n1 2\n2 2\n4\n", "2\n1 2\n1 2\n4\n", "2\n1 2\n2 3\n11\n", "2\n1 2\n2 6\n11\n"], "outputs": ["1\n", "1\n", "1\n", "3\n", "3\n", "1\n", "2\n", "2\n"]} | 541 | 144 |
coding | Solve the programming task below in a Python markdown code block.
Gerald has n younger brothers and their number happens to be even. One day he bought n^2 candy bags. One bag has one candy, one bag has two candies, one bag has three candies and so on. In fact, for each integer k from 1 to n^2 he has exactly one bag wit... | {"inputs": ["2\n", "4\n", "6\n", "8\n", "4\n", "6\n", "8\n", "2\n"], "outputs": ["1 4\n2 3\n", "1 16 2 15\n3 14 4 13\n5 12 6 11\n7 10 8 9\n", "1 36 2 35 3 34\n4 33 5 32 6 31\n7 30 8 29 9 28\n10 27 11 26 12 25\n13 24 14 23 15 22\n16 21 17 20 18 19\n", "1 64 2 63 3 62 4 61\n5 60 6 59 7 58 8 57\n9 56 10 55 11 54 12 53\n13... | 311 | 712 |
coding | Solve the programming task below in a Python markdown code block.
There are 2 trains A and B and N stations in a line from 1 to N in order. There is also an array P of length N-1 such that P_{i} (1≤ i < N) denotes the amount of time any train takes to go from the i-th station to the (i+1)-th station.
Initially, both ... | {"inputs": ["3\n2\n4\n3\n3 5\n4\n5 2 6\n"], "outputs": ["8\n13\n19\n"]} | 567 | 38 |
coding | Solve the programming task below in a Python markdown code block.
It is important to use strong passwords to make the Internet more secure. At the same time, it is very important not to reuse the same password. No matter how strong your password is, if the plaintext is leaked in one place, it will be very easy to break... | {"inputs": ["passxord", "parsxosd", "parsxpsd", "qarsxpsd", "qarxspsd", "dspsxraq", "qarxspsc", "cspsxraq"], "outputs": ["INVALID\n", "INVALID\n", "INVALID\n", "INVALID\n", "INVALID\n", "INVALID\n", "INVALID\n", "INVALID\n"]} | 385 | 87 |
coding | Solve the programming task below in a Python markdown code block.
Books are indexed. Write a program which reads a list of pairs of a word and a page number, and prints the word and a list of the corresponding page numbers.
You can assume that a word consists of at most 30 characters, and the page number is less than ... | {"inputs": ["mtzse 6\nveen 1\nnntroductioi 0\nsf_z 1\nstyle 32\ntndmucod 0\nstyld 5\nnuee 0", "mtzse 6\nveen 0\nnntroductioi 0\nsf_y 1\nstyle 17\ntndmucod 13\nstyld 7\nnuee 0", "mtzse 6\nveen 0\nnntroductioi 0\nsf_y 1\nstyle 32\ntndmucod 13\nstyld 7\nnuee 0", "mtzse 6\nveen 0\nnntroductioi 0\nsf_y 1\nstyle 32\ntndmucod... | 237 | 828 |
coding | Solve the programming task below in a Python markdown code block.
*Gormint aunty is very upset with the government and Imran wants to prove that his government is not sold out. Gormint aunty gives an ethical problem which only an honest person could solve. Help Imran solve this question.*
You are given two integers N ... | {"inputs": ["3\n5 4\n3 1\n6 3\n"], "outputs": ["5\n1 2 3 4 5\n1\n1 1 1\n3\n1 2 3 1 2 3"]} | 574 | 57 |
coding | Solve the programming task below in a Python markdown code block.
Your company was appointed to lay new asphalt on the highway of length $n$. You know that every day you can either repair one unit of the highway (lay new asphalt over one unit of the highway) or skip repairing.
Skipping the repair is necessary because ... | {"inputs": ["3\n6 1 1\n9 2 9\n1000000 1 1000000\n", "3\n6 1 2\n9 2 9\n1000000 1 1000000\n", "3\n5 1 2\n9 1 4\n1000001 1 1000100\n", "3\n5 1 2\n9 2 4\n1000001 1 1000100\n", "3\n5 1 1\n9 2 4\n1000000 1 1000000\n", "3\n4 1 1\n8 6 6\n1000001 2 1000000\n", "3\n3 1 2\n9 2 4\n1000001 1 1000100\n", "3\n5 1 1\n9 2 2\n1000000 1 ... | 530 | 436 |
coding | Solve the programming task below in a Python markdown code block.
Takahashi has come to an integer shop to buy an integer.
The shop sells the integers from 1 through 10^9. The integer N is sold for A \times N + B \times d(N) yen (the currency of Japan), where d(N) is the number of digits in the decimal notation of N.
F... | {"inputs": ["10 7 100\n", "2 1 100000000000\n", "1234 56789 314159265\n", "5 826766933 11100722310\n", "18 395432867 10840610026\n", "1000000000 1000000000 100\n", "384836991 191890310 91047313\n", "782177068 404011431 1793399970\n"], "outputs": ["9\n", "1000000000\n", "254309\n", "731963982\n", "404539679\n", "0\n", "... | 373 | 266 |
coding | Solve the programming task below in a Python markdown code block.
Vasya will fancy any number as long as it is an integer power of two. Petya, on the other hand, is very conservative and only likes a single integer $p$ (which may be positive, negative, or zero). To combine their tastes, they invented $p$-binary numbers... | {"inputs": ["1 1\n", "1 0\n", "5 2\n", "9 8\n", "3 2\n", "2 1\n", "9 4\n", "1 0\n"], "outputs": ["-1\n", "1\n", "-1\n", "1\n", "1\n", "1\n", "-1\n", "1\n"]} | 670 | 87 |
coding | Solve the programming task below in a Python markdown code block.
JATC loves Banh-mi (a Vietnamese food). His affection for Banh-mi is so much that he always has it for breakfast. This morning, as usual, he buys a Banh-mi and decides to enjoy it in a special way.
First, he splits the Banh-mi into $n$ parts, places the... | {"inputs": ["1 1\n0\n1 1\n", "1 1\n0\n1 1\n", "1 1\n1\n1 1\n", "3 2\n111\n1 2\n3 3\n", "3 2\n011\n1 2\n3 3\n", "3 2\n011\n1 2\n2 3\n", "3 2\n110\n1 2\n3 3\n", "3 2\n111\n1 2\n2 3\n"], "outputs": ["0\n", "0\n", "1\n", "3\n1\n", "2\n1\n", "2\n3\n", "3\n0\n", "3\n3\n"]} | 742 | 174 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
There is an n x n grid, with the top-left cell at (0, 0) and the bottom-right cell at (n - 1, n - 1). You are given the integer n and an integer array startPos where startPos = [startrow, startcol] indicates that a ro... | {"functional": "def check(candidate):\n assert candidate(n = 3, startPos = [0,1], s = \"RRDDLU\") == [1,5,4,3,1,0]\n assert candidate(n = 2, startPos = [1,1], s = \"LURD\") == [4,1,0,0]\n assert candidate(n = 1, startPos = [0,0], s = \"LRUD\") == [0,0,0,0]\n\n\ncheck(Solution().executeInstructions)"} | 272 | 121 |
coding | Solve the programming task below in a Python markdown code block.
Mysterious Chefland… Recently, Chef realised that Discuss, the educational system of Chefland, is out of date. Therefore, he is trying to find ways to update the infrastructure in the country. One possible way is to move all materials from Discuss to Dis... | {"inputs": ["5\n2 2 1 2\n11 10 5 9\n11 11 5 9\n12 11 5 9\n1 2 1 100"], "outputs": ["Chefirnemo\nChefirnemo\nPofik\nChefirnemo\nPofik"]} | 639 | 81 |
coding | Solve the programming task below in a Python markdown code block.
Read problems statements in Mandarin Chinese and Russian as well.
You are given a transparent three-dimensional table, the height equals to H and the base is a two-dimensional table N∙M.
The layers of the 3D table are numbered from 1 to H. Each layer i... | {"inputs": ["3 4 2\n6 1\n6 2", "2 2 3\n1 1\n1 2\n1 3", "1 2 3\n1 1\n1 2\n1 3", "1 2 3\n1 1\n1 1\n1 3", "1 2 3\n0 1\n1 1\n0 5", "1 2 3\n1 1\n1 3\n1 3", "1 2 3\n1 0\n1 1\n2 5", "1 2 3\n0 1\n2 3\n1 3"], "outputs": ["18", "Impossible", "3\n", "2\n", "Impossible\n", "4\n", "1\n", "6\n"]} | 528 | 185 |
coding | Solve the programming task below in a Python markdown code block.
Deepak like strings which are in flip flop in nature. For example, he likes XYXYX, while he doesn't like XXYX. Now he want to convert every string into a string which he likes. for this, he only delete the character in the string.
Now find the minimum n... | {"inputs": ["5\nXXXX\nYYYYY\nXYXYXYXY\nYXYXYX\nXXXYYY"], "outputs": ["3\n4\n0\n0\n4"]} | 252 | 38 |
coding | Solve the programming task below in a Python markdown code block.
in Chefland, there is a very famous street where $N$ types of street food (numbered $1$ through $N$) are offered. For each valid $i$, there are $S_i$ stores that offer food of the $i$-th type, the price of one piece of food of this type is $V_i$ (the sam... | {"inputs": ["2\n3\n4 6 8\n2 6 6\n1 4 3\n1\n7 7 4"], "outputs": ["12\n0"]} | 581 | 43 |
coding | Solve the programming task below in a Python markdown code block.
Eugeny has array a = a_1, a_2, ..., a_{n}, consisting of n integers. Each integer a_{i} equals to -1, or to 1. Also, he has m queries: Query number i is given as a pair of integers l_{i}, r_{i} (1 ≤ l_{i} ≤ r_{i} ≤ n). The response to the query will be... | {"inputs": ["1 1\n1\n1 1\n", "1 1\n1\n1 1\n", "1 1\n-1\n1 1\n", "1 1\n-1\n1 1\n", "1 1\n-1\n0 1\n", "1 1\n-1\n1 2\n", "1 1\n-1\n1 3\n", "1 1\n-1\n-1 1\n"], "outputs": ["0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n"]} | 369 | 141 |
coding | Solve the programming task below in a Python markdown code block.
This time no story, no theory. The examples below show you how to write function `accum`:
**Examples:**
```
accum("abcd") -> "A-Bb-Ccc-Dddd"
accum("RqaEzty") -> "R-Qq-Aaa-Eeee-Zzzzz-Tttttt-Yyyyyyy"
accum("cwAt") -> "C-Ww-Aaa-Tttt"
```
The parameter of ... | {"functional": "_inputs = [['ZpglnRxqenU'], ['NyffsGeyylB'], ['MjtkuBovqrU'], ['EvidjUnokmM'], ['HbideVbxncC'], ['VwhvtHtrxfE'], ['KurgiKmkphY'], ['NctlfBlnmfH'], ['WegunHvbdmV'], ['VoywwSpqidE'], ['VbaixFpxdcO'], ['OlyqvYwkuzF'], ['JrhfdMtchiH'], ['JiwpcSwslvW'], ['EagpiEvmabJ'], ['RznlcEmuxxP'], ['OrggaExarzP'], ['Dr... | 143 | 1,064 |
coding | Solve the programming task below in a Python markdown code block.
Luke is daydreaming in Math class. He has a sheet of graph paper with $n$ rows and $m$ columns, and he imagines that there is an army base in each cell for a total of $n\cdot m$ bases. He wants to drop supplies at strategic points on the sheet, marking e... | {"inputs": ["2 2\n"], "outputs": ["1\n"]} | 402 | 16 |
coding | Solve the programming task below in a Python markdown code block.
Indian summer is such a beautiful time of the year! A girl named Alyona is walking in the forest and picking a bouquet from fallen leaves. Alyona is very choosy — she doesn't take a leaf if it matches the color and the species of the tree of one of the l... | {"inputs": ["1\nqvwli hz\n", "1\nqvilw hz\n", "1\nqvilw gz\n", "1\nqvilw zg\n", "1\nqvhlw zg\n", "1\nqvhlw gz\n", "1\nqvhlv gz\n", "1\nrvhlv gz\n"], "outputs": ["1", "1\n", "1\n", "1\n", "1\n", "1\n", "1\n", "1\n"]} | 259 | 111 |
coding | Solve the programming task below in a Python markdown code block.
# Task
Get the digits sum of `n`th number from the [Look-and-Say sequence](http://en.wikipedia.org/wiki/Look-and-say_sequence)(1-based).
`1, 11, 21, 1211, 111221, 312211, 13112221, 1113213211, ...`
# Input/Output
`[input]` integer `n`
`n`th number in... | {"functional": "_inputs = [[1], [2], [3], [4], [5]]\n_outputs = [[1], [2], [3], [5], [8]]\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... | 308 | 183 |
coding | Solve the programming task below in a Python markdown code block.
You are given an array $a$ of $n$ elements. You can apply the following operation to it any number of times:
Select some subarray from $a$ of even size $2k$ that begins at position $l$ ($1\le l \le l+2\cdot{k}-1\le n$, $k \ge 1$) and for each $i$ betwee... | {"inputs": ["5\n3\n1 1 1\n2\n2 1\n5\n4 4 4 2 4\n4\n4 2 1 3\n1\n1\n"], "outputs": ["0\n1\n1\n2\n0\n"]} | 733 | 62 |
coding | Solve the programming task below in a Python markdown code block.
Alyona's mother wants to present an array of n non-negative integers to Alyona. The array should be special.
Alyona is a capricious girl so after she gets the array, she inspects m of its subarrays. Subarray is a set of some subsequent elements of the ... | {"inputs": ["1 1\n1 1\n", "9 1\n1 1\n", "2 1\n2 2\n", "6 2\n4 6\n2 5\n", "4 2\n1 4\n2 4\n", "4 2\n1 4\n2 3\n", "4 2\n2 4\n2 4\n", "4 2\n1 2\n2 3\n"], "outputs": ["1\n0\n", "1\n0 0 0 0 0 0 0 0 0\n", "1\n0 0\n", "3\n0 1 2 0 1 2\n", "3\n0 1 2 0\n", "2\n0 1 0 1 \n", "3\n0 1 2 0 \n", "2\n0 1 0 1 \n"]} | 505 | 209 |
coding | Solve the programming task below in a Python markdown code block.
Chef loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Let F(X) equals to the number of lu... | {"inputs": ["4\n1 100\n1 10000\n1 100000\n4444 4447\n\n"], "outputs": ["0\n16\n640\n2"]} | 493 | 56 |
coding | Solve the programming task below in a Python markdown code block.
It is the easy version of the problem. The difference is that in this version, there are no nodes with already chosen colors.
Theofanis is starving, and he wants to eat his favorite food, sheftalia. However, he should first finish his homework. Can you ... | {"inputs": ["3\n", "1\n", "2\n", "4\n", "2\n", "1\n", "4\n", "5\n"], "outputs": ["24576\n", "6\n", "96\n", "610612729\n", "96\n", "6\n", "610612729\n", "218379003\n"]} | 482 | 100 |
coding | Solve the programming task below in a Python markdown code block.
You are given an n × m rectangular table consisting of lower case English letters. In one operation you can completely remove one column from the table. The remaining parts are combined forming a new table. For example, after removing the second column f... | {"inputs": ["2 1\nb\na\n", "2 1\nb\na\n", "2 1\nc\na\n", "2 1\nc\nb\n", "2 2\nfb\nye\n", "2 2\nfb\nye\n", "2 2\nbf\nye\n", "2 3\naxc\nbxa\n"], "outputs": ["1\n", "1", "1\n", "1\n", "0\n", "0", "0\n", "0\n"]} | 378 | 118 |
coding | Solve the programming task below in a Python markdown code block.
# Task
Given an array `arr`, find the rank of the element at the ith position.
The `rank` of the arr[i] is a value equal to the number of elements `less than or equal to` arr[i] standing before arr[i], plus the number of elements `less than` arr[i] st... | {"functional": "_inputs = [[[2, 1, 2, 1, 2], 2], [[2, 1, 2, 2, 2], 2], [[3, 2, 3, 4, 1], 0], [[3, 2, 3, 4, 1], 1], [[3, 2, 3, 4, 1], 2]]\n_outputs = [[3], [2], [2], [1], [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,... | 304 | 254 |
coding | Solve the programming task below in a Python markdown code block.
There is enough money available on ATM in nominal value 10, 20, 50, 100, 200 and 500 dollars.
You are given money in nominal value of `n` with `1<=n<=1500`.
Try to find minimal number of notes that must be used to repay in dollars, or output -1 if it i... | {"functional": "_inputs = [[770], [550], [10], [1250], [125], [666], [42]]\n_outputs = [[4], [2], [1], [4], [-1], [-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)... | 121 | 203 |
coding | Solve the programming task below in a Python markdown code block.
Read problems statements in Mandarin chinese, Russian and Vietnamese as well.
Consider a very long K-digit number N with digits d_{0}, d_{1}, ..., d_{K-1} (in decimal notation; d_{0} is the most significant and d_{K-1} the least significant digit). Thi... | {"inputs": ["3\n5 3 4\n13 8 1\n760399384224 5 1"], "outputs": ["NO\nYES\nYES"]} | 455 | 46 |
coding | Solve the programming task below in a Python markdown code block.
Chef has two integers X and S. He is interested in sequences of non-negative integers such that the sum of their elements is S and the [bitwise OR] of their elements is X. Chef would like to know the shortest possible length such a sequence can have.
Fo... | {"inputs": ["3\n13 23\n6 13\n1 25\n"], "outputs": ["3\n-1\n25\n"]} | 483 | 36 |
coding | Solve the programming task below in a Python markdown code block.
You are given a positive integer N and an array A of size N. There are N lists L_{1}, L_{2} \ldots L_{N}. Initially, L_{i} = [A_{i}].
You can perform the following operation any number of times as long as there are at least 2 lists:
Select 2 (non-empty... | {"inputs": ["3\n1\n1\n2\n1 2\n3\n1 1 2\n"], "outputs": ["0\n-1\n2\n"]} | 678 | 37 |
coding | Solve the programming task below in a Python markdown code block.
There are N people. The name of the i-th person is S_i.
We would like to choose three people so that the following conditions are met:
- The name of every chosen person begins with M, A, R, C or H.
- There are no multiple people whose names begin with ... | {"inputs": ["1\nAAA\n", "5\nM\nA\nR\nC\nH\n", "4\nZY\nZZZ\nZ\nZZZZZZZZZZ", "4\nZY\nZZY\nZ\nZZZZZZZZZZ", "4\nZY\nYZZ\nZ\nZZZZZZZZZZ", "4\nZY\nYZZ\nY\nZZZZZZZZZZ", "4\nZY\nZYZ\nY\nZZZZZZZZZZ", "4\nZY\nZYZ\nY\nZYZZZZZZZZ"], "outputs": ["0\n", "10\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n"]} | 294 | 155 |
coding | Solve the programming task below in a Python markdown code block.
Having learned the multiplication table, Takahashi can multiply two integers between 1 and 9 (inclusive) together.
Given an integer N, determine whether N can be represented as the product of two integers between 1 and 9. If it can, print Yes; if it cann... | {"inputs": ["2", "1", "0", "3", "6", "4", "7", "8"], "outputs": ["Yes\n", "Yes\n", "No\n", "Yes\n", "Yes\n", "Yes\n", "Yes\n", "Yes\n"]} | 178 | 62 |
coding | Solve the programming task below in a Python markdown code block.
For given integers m and n, compute mn (mod 1,000,000,007). Here, A (mod M) is the remainder when A is divided by M.
Constraints
* 1 ≤ m ≤ 100
* 1 ≤ n ≤ 109
Input
m n
Two integers m and n are given in a line.
Output
Print mn (mod 1,000,000,007) ... | {"inputs": ["2 1", "5 9", "2 2", "7 9", "3 3", "1 3", "3 1", "0 1"], "outputs": ["2\n", "1953125\n", "4\n", "40353607\n", "27\n", "1\n", "3\n", "0\n"]} | 147 | 92 |
coding | Solve the programming task below in a Python markdown code block.
Complete the function/method so that it returns the url with anything after the anchor (`#`) removed.
## Examples
```python
# returns 'www.codewars.com'
remove_url_anchor('www.codewars.com#about')
# returns 'www.codewars.com?page=1'
remove_url_ancho... | {"functional": "_inputs = [['www.codewars.com#about'], ['www.codewars.com/katas/?page=1#about'], ['www.codewars.com/katas/']]\n_outputs = [['www.codewars.com'], ['www.codewars.com/katas/?page=1'], ['www.codewars.com/katas/']]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, floa... | 112 | 213 |
coding | Solve the programming task below in a Python markdown code block.
The Head Chef is receiving a lot of orders for cooking the best of the problems lately. For this, he organized an hiring event to hire some talented Chefs. He gave the following problem to test the skills of the participating Chefs. Can you solve this pr... | {"inputs": ["2\n2\n5\n\n"], "outputs": ["2\n8"]} | 756 | 20 |
coding | Solve the programming task below in a Python markdown code block.
Introduction
Mr. Safety loves numeric locks and his Nokia 3310. He locked almost everything in his house. He is so smart and he doesn't need to remember the combinations. He has an algorithm to generate new passcodes on his Nokia cell phone.
Task
... | {"functional": "_inputs = [['Nokia'], ['Valut'], ['toilet'], ['waterheater'], ['birdhouse']]\n_outputs = [['66542'], ['82588'], ['864538'], ['92837432837'], ['247346873']]\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, ab... | 226 | 215 |
coding | Solve the programming task below in a Python markdown code block.
Chef has fallen in love with Cheffina, and wants to buy N gifts for her. On reaching the gift shop, Chef got to know the following two things:
The cost of each gift is 1 coin.
On the purchase of every 4^{th} gift, Chef gets the 5^{th} gift free of cost. ... | {"inputs": ["2\n5\n4"], "outputs": ["4\n4"]} | 314 | 18 |
coding | Solve the programming task below in a Python markdown code block.
Given a word w, rearrange the letters of w to construct another word s in such a way that s is lexicographic-ally greater than w. In case of multiple possible answers, find the lexicographic-ally smallest one.
Input Format
The first line of input conta... | {"inputs": ["5\nab\nbb\nhefg\ndhck\ndkhc"], "outputs": ["ba\nno answer\nhegf\ndhkc\nhcdk"]} | 339 | 41 |
coding | Solve the programming task below in a Python markdown code block.
Sunake is in the form of a polygonal line consisting of n vertices (without self-intersection). First, Sunake-kun's i-th vertex is at (xi, yi). You can move continuously by translating or rotating, but you cannot deform (change the length of the polygona... | {"inputs": ["4\n0 1\n1 1\n1 2\n3 2", "4\n0 2\n1 1\n1 2\n3 2", "4\n0 2\n1 1\n2 2\n3 2", "4\n0 1\n1 1\n1 2\n2 2", "11\n124 186\n8 143\n6 675\n0 186\n248 50\n-3 561\n154 66\n13 19\n37 0\n1 294\n1 30", "11\n124 186\n8 143\n6 675\n0 186\n248 50\n-3 561\n154 66\n13 19\n51 0\n1 294\n1 30", "11\n124 186\n0 143\n6 675\n0 186\n2... | 352 | 405 |
coding | Solve the programming task below in a Python markdown code block.
There are some animals in a garden. Each of them is a crane with two legs or a turtle with four legs.
Takahashi says: "there are X animals in total in the garden, and they have Y legs in total." Determine whether there is a combination of numbers of cran... | {"inputs": ["2 2", "6 8", "3 2", "3 1", "6 3", "5 1", "3 3", "5 2"], "outputs": ["No\n", "No\n", "No\n", "No\n", "No\n", "No\n", "No\n", "No\n"]} | 238 | 78 |
coding | Solve the programming task below in a Python markdown code block.
Binod and his family live in Codingland. They have a festival called N-Halloween.
The festival is celebrated for N consecutive days. On each day Binod gets some candies from his mother. He may or may not take them. On a given day , Binod will be sad if... | {"inputs": ["5 2\n4 6 5 8 7\n1\n2", "6 3\n20 10 12 3 30 5\n2\n6\n13"], "outputs": ["30\n30", "77\n62\n30"]} | 533 | 70 |
coding | Solve the programming task below in a Python markdown code block.
You're given a string containing a sequence of words separated with whitespaces. Let's say it is a sequence of patterns: a name and a corresponding number - like this:
```"red 1 yellow 2 black 3 white 4"```
You want to turn it into a different **string... | {"functional": "_inputs = [['red 1 yellow 2 black 3 white 4'], ['1 red 2 white 3 violet 4 green'], ['1 1 2 2 3 3 4 4'], ['#@&fhds 123F3f 2vn2# 2%y6D @%fd3 @!#4fs W@R^g WE56h%'], ['']]\n_outputs = [[\"[{name : 'red', id : '1'}, {name : 'yellow', id : '2'}, {name : 'black', id : '3'}, {name : 'white', id : '4'}]\"], [\"[... | 291 | 466 |
coding | Solve the programming task below in a Python markdown code block.
Recently, the Fair Nut has written $k$ strings of length $n$, consisting of letters "a" and "b". He calculated $c$ — the number of strings that are prefixes of at least one of the written strings. Every string was counted only one time.
Then, he lost hi... | {"inputs": ["1 1\na\na\n", "1 1\na\na\n", "2 4\naa\nbb\n", "2 4\nab\nbb\n", "2 4\nba\nbb\n", "2 5\nab\nbb\n", "2 4\naa\nbb\n", "3 3\naba\nbba\n"], "outputs": ["1", "1\n", "6\n", "5\n", "3\n", "5\n", "6\n", "8\n"]} | 503 | 118 |
coding | Solve the programming task below in a Python markdown code block.
Teacher brought a fruit basket for three students. The basket contains only Apples, Mangoes and Oranges. Student A knows a value $a$, the total number of Apples and Mangoes in the Basket, B knows a value $b$, the total number of Mangoes and Oranges in th... | {"inputs": ["2\n7 9 8 12\n3 8 7 9"], "outputs": ["3 4 5\n1 2 6"]} | 342 | 39 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
A transaction is possibly invalid if:
the amount exceeds $1000, or;
if it occurs within (and including) 60 minutes of another transaction with the same name in a different city.
You are given an array of strings tra... | {"functional": "def check(candidate):\n assert candidate(transactions = [\"alice,20,800,mtv\",\"alice,50,100,beijing\"]) == [\"alice,20,800,mtv\",\"alice,50,100,beijing\"]\n assert candidate(transactions = [\"alice,20,800,mtv\",\"alice,50,1200,mtv\"]) == [\"alice,50,1200,mtv\"]\n assert candidate(transactions ... | 144 | 185 |
coding | Solve the programming task below in a Python markdown code block.
# Task
An IP address contains four numbers(0-255) and separated by dots. It can be converted to a number by this way:
Given a string `s` represents a number or an IP address. Your task is to convert it to another representation(`number to IP address` ... | {"functional": "_inputs = [['10.0.3.193'], ['167969729']]\n_outputs = [['167773121'], ['10.3.3.193']]\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) !=... | 391 | 196 |
coding | Solve the programming task below in a Python markdown code block.
$n$ people gathered to hold a jury meeting of the upcoming competition, the $i$-th member of the jury came up with $a_i$ tasks, which they want to share with each other.
First, the jury decides on the order which they will follow while describing the ta... | {"inputs": ["1\n3\n11 11 154\n", "1\n3\n11 11 154\n", "1\n3\n13 11 154\n", "1\n3\n11 20 154\n", "1\n3\n13 11 297\n", "1\n3\n19 11 297\n", "1\n3\n38 11 297\n", "4\n2\n1 2\n3\n5 5 5\n4\n1 3 3 7\n6\n3 4 2 1 3 3\n"], "outputs": ["0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "1\n6\n0\n540\n"]} | 709 | 200 |
coding | Solve the programming task below in a Python markdown code block.
Nezzar's favorite digit among $1,\ldots,9$ is $d$. He calls a positive integer lucky if $d$ occurs at least once in its decimal representation.
Given $q$ integers $a_1,a_2,\ldots,a_q$, for each $1 \le i \le q$ Nezzar would like to know if $a_i$ can be e... | {"inputs": ["2\n3 2\n6 47 1\n10 3\n50 52 2 43 113 92 9 73 42 60\n", "2\n3 7\n24 44 40\n10 7\n4 52 4 54 64 54 66 2 25 60\n", "2\n3 2\n5 47 1\n10 3\n50 52 2 43 113 92 9 73 42 60\n", "2\n3 7\n10 25 27\n10 5\n13 52 53 2 55 56 57 58 9 8\n", "2\n3 2\n5 47 1\n10 3\n50 52 1 43 113 92 8 73 42 60\n", "2\n3 2\n24 44 10\n10 7\n4 5... | 399 | 622 |
coding | Solve the programming task below in a Python markdown code block.
Jack and Jill got into a serious fight. Jack didn't not belive Jill when she said that her memory was far better than the others. He asked her to prove it as follows :-
- Jack would dictate a long list of numbers to her. At any point after he has dict... | {"inputs": ["6\n2\n3\n2\n-1\n-1\n1\n-1", "10\n5\n3\n6\n1\n4\n2\n9\n3\n1\n0\n-1"], "outputs": ["3\n3\n2", "3"]} | 460 | 63 |
coding | Solve the programming task below in a Python markdown code block.
Chef is playing badminton today. The service rules of this singles game of badminton are as follows:
1. The player who starts the game serves from the right side of their court.
2. Whenever a player wins a point, they serve next.
3. If the server has won... | {"inputs": ["4\n2\n9\n53\n746"], "outputs": ["2\n5\n27\n374"]} | 411 | 32 |
coding | Solve the programming task below in a Python markdown code block.
Read problem statement in Mandarin chinese and Vietnamese.
Suzumo is the coach of the ChefLand OI team. Physical condition is very important in any olympiad, so he wants to make the children run a bit as a warmup.
The team consists of $N$ children num... | {"inputs": ["1\n3\n10 10\n20 30\n30 10"], "outputs": ["0.5"]} | 624 | 34 |
coding | Solve the programming task below in a Python markdown code block.
The Little Elephant loves Ukraine very much. Most of all he loves town Rozdol (ukr. "Rozdil").
However, Rozdil is dangerous to settle, so the Little Elephant wants to go to some other town. The Little Elephant doesn't like to spend much time on travelli... | {"inputs": ["1\n47\n", "1\n76\n", "1\n71\n", "1\n22\n", "1\n31\n", "1\n16\n", "1\n15\n", "1\n127\n"], "outputs": ["1", "1\n", "1\n", "1\n", "1\n", "1\n", "1\n", "1\n"]} | 433 | 94 |
coding | Solve the programming task below in a Python markdown code block.
There were $N$ students (numbered $1$ through $N$) participating in the Indian Programming Camp (IPC) and they watched a total of $K$ lectures (numbered $1$ through $K$). For each student $i$ and each lecture $j$, the $i$-th student watched the $j$-th le... | {"inputs": ["4 8 4\n1 2 1 2 5\n3 5 1 3 4\n1 2 4 5 11\n1 1 1 3 12"], "outputs": ["1"]} | 663 | 58 |
coding | Solve the programming task below in a Python markdown code block.
The chef is trying to decode some pattern problems, Chef wants your help to code it. Chef has one number K to form a new pattern. Help the chef to code this pattern problem.
-----Input:-----
- First-line will contain $T$, the number of test cases. Then ... | {"inputs": ["4\n1\n2\n3\n4"], "outputs": ["0\n01\n10\n012\n101\n210\n0123\n1012\n2101\n3210"]} | 216 | 58 |
coding | Solve the programming task below in a Python markdown code block.
For a permutation P of integers from 1 to N, let's define its value as (1 \oplus P_{1}) + (2 \oplus P_{2}) + \ldots + (N \oplus P_{N}).
Given N, find the maximum possible value of the permutation of integers from 1 to N.
As a reminder, \oplus denotes ... | {"inputs": ["5\n1\n2\n3\n4\n29012022"], "outputs": ["0\n6\n6\n20\n841697449540506"]} | 510 | 52 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given two integer arrays preorder and inorder where preorder is the preorder traversal of a binary tree and inorder is the inorder traversal of the same tree, construct and return the binary tree.
Please complete th... | {"functional": "def check(candidate):\n assert is_same_tree(candidate(preorder = [3,9,20,15,7], inorder = [9,3,15,20,7]), tree_node([3,9,20,None,None,15,7]))\n assert is_same_tree(candidate(preorder = [-1], inorder = [-1]), tree_node([-1]))\n\n\ncheck(Solution().buildTree)"} | 141 | 99 |
coding | Solve the programming task below in a Python markdown code block.
-----Input-----
The input contains a single integer $a$ ($1 \le a \le 99$).
-----Output-----
Output "YES" or "NO".
-----Examples-----
Input
5
Output
YES
Input
13
Output
NO
Input
24
Output
NO
Input
46
Output
YES | {"inputs": ["5\n", "1\n", "2\n", "3\n", "4\n", "4\n", "2\n", "3\n"], "outputs": ["YES\n", "NO\n", "YES\n", "YES\n", "YES\n", "YES", "YES", "YES"]} | 86 | 67 |
coding | Solve the programming task below in a Python markdown code block.
Chef has just found a recipe book, where every dish consists of exactly four ingredients.
He is going to choose some two dishes and prepare them for dinner.
Of course, he likes diversity and wants to know whether the two dishes are similar.
Two dishes ar... | {"inputs": ["5\neggs sugar flour salt\nsugar eggs milk flour\naa ab ac ad\nac ad ae af\ncookies sugar grass lemon\nlemon meat chili wood\none two three four\none two three four\ngibberish jibberish lalalalala popopopopo\njibberisz gibberisz popopopopu lalalalalu"], "outputs": ["similar\nsimilar\ndissimilar\nsimilar\ndi... | 544 | 103 |
coding | Solve the programming task below in a Python markdown code block.
Tokitsukaze has a sequence $a$ of length $n$. For each operation, she selects two numbers $a_i$ and $a_j$ ($i \ne j$; $1 \leq i,j \leq n$).
If $a_i = a_j$, change one of them to $0$.
Otherwise change both of them to $\min(a_i, a_j)$.
Tokitsukaze wants... | {"inputs": ["3\n3\n1 2 3\n3\n1 2 2\n3\n1 2 0\n"], "outputs": ["4\n3\n2\n"]} | 550 | 42 |
coding | Solve the programming task below in a Python markdown code block.
You are given a string A. Find a string B, where B is a palindrome and A is a subsequence of B.
A subsequence of a string is a string that can be derived from it by deleting some (not necessarily consecutive) characters without changing the order of the... | {"inputs": ["ab\n", "ab\n", "ba\n", "ac\n", "ab\n", "aba\n", "aba\n", "abb\n"], "outputs": ["abba", "abba\n", "baab\n", "acca\n", "abba\n", "abaaba", "abaaba\n", "abbbba\n"]} | 314 | 77 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given a 0-indexed integer array stones sorted in strictly increasing order representing the positions of stones in a river.
A frog, initially on the first stone, wants to travel to the last stone and then retu... | {"functional": "def check(candidate):\n assert candidate(stones = [0,2,5,6,7]) == 5\n assert candidate(stones = [0,3,9]) == 9\n\n\ncheck(Solution().maxJump)"} | 204 | 57 |
coding | Solve the programming task below in a Python markdown code block.
The Resistance is trying to take control over as many planets of a particular solar system as possible. Princess Heidi is in charge of the fleet, and she must send ships to some planets in order to maximize the number of controlled planets.
The Galaxy c... | {"inputs": ["3\n1 2\n2 3\n", "3\n1 2\n2 3\n", "4\n1 2\n3 2\n4 2\n", "4\n1 2\n3 2\n4 1\n", "4\n1 3\n3 2\n4 2\n", "4\n1 3\n3 2\n4 1\n", "4\n1 2\n3 2\n4 2\n", "19\n2 19\n7 15\n8 10\n16 1\n12 5\n11 5\n6 18\n12 14\n14 15\n2 6\n9 14\n4 17\n16 10\n4 2\n7 18\n3 2\n9 13\n11 10\n"], "outputs": ["1 3 3 ", "1 3 3 ", "1 3 4 4 ", "1... | 446 | 326 |
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 subarrays of nums where the greatest common divisor of the subarray's elements is k.
A subarray is a contiguous non-empty sequence of elements within ... | {"functional": "def check(candidate):\n assert candidate(nums = [9,3,1,2,6,3], k = 3) == 4\n assert candidate(nums = [4], k = 7) == 0\n\n\ncheck(Solution().subarrayGCD)"} | 120 | 65 |
coding | Solve the programming task below in a Python markdown code block.
Read problem statements in [Mandarin], [Bengali], [Russian], and [Vietnamese] as well.
Chef and Divyam are playing a game. They start with a rational number $X$, such that $0 < X < 1$.
In each turn, Chef chooses a positive real number $Y$. Then Divyam ... | {"inputs": ["2\n1 2\n2 3"], "outputs": ["Yes\nNo"]} | 514 | 22 |
coding | Solve the programming task below in a Python markdown code block.
Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
There are $N$ students standing in a row and numbered $1$ through $N$ from left to right. You are given a string $S$ with length $N$, where for each ... | {"inputs": ["3\nxy\nxyxxy\nyy"], "outputs": ["1\n2\n0"]} | 473 | 24 |
coding | Solve the programming task below in a Python markdown code block.
Valera wanted to prepare a Codesecrof round. He's already got one problem and he wants to set a time limit (TL) on it.
Valera has written n correct solutions. For each correct solution, he knows its running time (in seconds). Valera has also wrote m wro... | {"inputs": ["1 1\n4\n9\n", "1 1\n2\n4\n", "1 1\n4\n9\n", "1 1\n2\n4\n", "1 1\n8\n9\n", "1 1\n1\n9\n", "1 1\n1\n0\n", "1 1\n0\n0\n"], "outputs": ["8", "-1\n", "8\n", "-1\n", "-1\n", "2\n", "-1\n", "-1\n"]} | 463 | 117 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given two 0-indexed integer arrays nums1 and nums2 of the same length. A pair of indices (i,j) is called beautiful if|nums1[i] - nums1[j]| + |nums2[i] - nums2[j]| is the smallest amongst all possible indices p... | {"functional": "def check(candidate):\n assert candidate(nums1 = [1,2,3,2,4], nums2 = [2,3,1,2,3]) == [0,3]\n assert candidate(nums1 = [1,2,4,3,2,5], nums2 = [1,4,2,3,5,1]) == [1,4]\n\n\ncheck(Solution().beautifulPair)"} | 200 | 99 |
coding | Solve the programming task below in a Python markdown code block.
There are $n$ points $1,2,\ldots,n$, each point $i$ has a number $a_i$ on it. You're playing a game on them. Initially, you are at point $1$. When you are at point $i$, take following steps:
If $1\le i\le n$, go to $i+a_i$,
Otherwise, the game ends.
B... | {"inputs": ["9\n1\n0\n2\n-1 0\n2\n1 -1\n2\n1 1\n3\n-1 -2 -1\n3\n1 -2 -1\n4\n-1 4 -2 1\n5\n1 1 1 1 -4\n5\n1 1 1 1 1\n"], "outputs": ["2\n8\n6\n7\n20\n17\n34\n30\n40\n"]} | 663 | 110 |
coding | Solve the programming task below in a Python markdown code block.
Bessie and the cows are playing with sequences and need your help. They start with a sequence, initially containing just the number 0, and perform n operations. Each operation is one of the following: Add the integer x_{i} to the first a_{i} elements of... | {"inputs": ["1\n2 1\n", "1\n2 0\n", "1\n2 1\n", "1\n2 0\n", "1\n2 -1\n", "1\n1 1 1\n", "1\n1 1 0\n", "1\n1 1 0\n"], "outputs": ["0.500000\n", "0.000000\n", "0.500000\n", "0.000000\n", "-0.500000\n", "1.000000\n", "0.000000\n", "0.000000\n"]} | 649 | 164 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given the root of a binary tree, calculate the vertical order traversal of the binary tree.
For each node at position (row, col), its left and right children will be at positions (row + 1, col - 1) and (row + 1, col +... | {"functional": "def check(candidate):\n assert candidate(root = tree_node([3,9,20,None,None,15,7])) == [[9],[3,15],[20],[7]]\n assert candidate(root = tree_node([1,2,3,4,5,6,7])) == [[4],[2],[1,5,6],[3],[7]]\n assert candidate(root = tree_node([1,2,3,4,6,5,7])) == [[4],[2],[1,5,6],[3],[7]]\n\n\ncheck(Solution(... | 247 | 137 |
coding | Solve the programming task below in a Python markdown code block.
You are given a string s consisting of lowercase English letters and a number k. Let's call a string consisting of lowercase English letters beautiful if the number of occurrences of each letter in that string is divisible by k. You are asked to find the... | {"inputs": ["4\n4 2\ndcba\n3 1\nabc\n4 3\naaaa\n9 3\nabaabaaaa\n", "4\n4 4\nabcd\n3 1\nabc\n4 3\naaaa\n9 3\nabaabaaaa\n", "4\n4 2\nabcd\n3 1\nabc\n4 1\naaaa\n9 3\nabaabaaaa\n", "4\n4 2\ndcba\n3 1\nabc\n4 3\naaaa\n9 3\nabbabaaaa\n", "4\n4 4\nabcd\n3 1\nabc\n4 1\naaaa\n9 3\nabaabaaaa\n", "4\n4 2\ndcba\n3 1\nabc\n4 3\naaa... | 490 | 362 |
coding | Solve the programming task below in a Python markdown code block.
The MarkiT online virtual market startup wants to organize its grand opening in NIT Patna.
but they want maximum crowd for their inauguration. So the manager told this to Praveen a student in NITP who suggested them:
The first-year students come to cam... | {"inputs": ["1\n10\n8 10 6"], "outputs": ["2"]} | 351 | 22 |
coding | Solve the programming task below in a Python markdown code block.
Madeline has an array $a$ of $n$ integers. A pair $(u, v)$ of integers forms an inversion in $a$ if:
$1 \le u < v \le n$. $a_u > a_v$.
Madeline recently found a magical paper, which allows her to write two indices $u$ and $v$ and swap the values $a... | {"inputs": ["1\n1\n", "1\n1\n", "1\n0\n", "1\n2\n", "1\n-1\n", "1\n-2\n", "1\n-3\n", "1\n-4\n"], "outputs": ["0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n"]} | 598 | 90 |
coding | Solve the programming task below in a Python markdown code block.
Madoka's father just reached $1$ million subscribers on Mathub! So the website decided to send him a personalized award — The Mathhub's Bit Button!
The Bit Button is a rectangular table with $n$ rows and $m$ columns with $0$ or $1$ in each cell. After e... | {"inputs": ["5\n3 3\n100\n011\n011\n3 3\n110\n111\n110\n1 5\n01111\n4 5\n11111\n01010\n01000\n01000\n3 2\n11\n00\n11\n"], "outputs": ["YES\nNO\nYES\nNO\nYES\n"]} | 585 | 105 |
coding | Solve the programming task below in a Python markdown code block.
You are given two very long integers a, b (leading zeroes are allowed). You should check what number a or b is greater or determine that they are equal.
The input size is very large so don't use the reading of symbols one by one. Instead of that use the... | {"inputs": ["9\n9\n", "1\n2\n", "9\n0\n", "0\n1\n", "0\n0\n", "1\n0\n", "0\n0\n", "9\n9\n"], "outputs": ["=\n", "<\n", ">\n", "<\n", "=\n", ">\n", "=\n", "=\n"]} | 295 | 86 |
coding | Solve the programming task below in a Python markdown code block.
A permutation of size n is an array of size n such that each integer from 1 to n occurs exactly once in this array. An inversion in a permutation p is a pair of indices (i, j) such that i > j and a_{i} < a_{j}. For example, a permutation [4, 1, 3, 2] con... | {"inputs": ["3\n1 2 3\n2\n1 2\n2 3\n", "3\n1 2 3\n2\n1 2\n2 6\n", "3\n1 2 3\n2\n1 2\n1 3\n", "3\n1 2 3\n2\n1 2\n2 5\n", "3\n1 2 3\n2\n1 3\n2 6\n", "3\n1 2 3\n2\n1 2\n2 3\n", "3\n2 1 3\n3\n2 3\n1 1\n1 3\n", "3\n2 1 3\n3\n2 3\n1 1\n1 3\n"], "outputs": ["odd\neven\n", "odd\nodd\n", "odd\neven\n", "odd\nodd\n", "odd\nodd\n... | 690 | 231 |
coding | Solve the programming task below in a Python markdown code block.
You are given a string of characters, or numbers. Find the minimum number of characters to be inserted into the string in order to obtain a palindrome.
A palindrome is a word, phrase, number, or other sequence of symbols or elements that reads the same ... | {"inputs": ["1\n20\neeeeeeeeeeeeeeeeeeee", "1\n20\n0ziG30WBD79ow1E0fu1X", "1\n20\nWbHRKhSxoS18CnGxola3"], "outputs": ["0", "17", "17"]} | 222 | 75 |
coding | Solve the programming task below in a Python markdown code block.
Modify the spacify function so that it returns the given string with spaces inserted between each character.
```python
spacify("hello world") # returns "h e l l o w o r l d"
```
Also feel free to reuse/extend the following starter code:
```python
def ... | {"functional": "_inputs = [[''], ['a'], ['Pippi']]\n_outputs = [[''], ['a'], ['P i p p i']]\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): r... | 80 | 170 |
coding | Solve the programming task below in a Python markdown code block.
For a given array $a$ consisting of $n$ integers and a given integer $m$ find if it is possible to reorder elements of the array $a$ in such a way that $\sum_{i=1}^{n}{\sum_{j=i}^{n}{\frac{a_j}{j}}}$ equals $m$? It is forbidden to delete elements as well... | {"inputs": ["1\n1 1\n2\n", "1\n1 0\n1\n", "1\n1 1\n0\n", "1\n1 2\n4\n", "1\n1 0\n2\n", "1\n1 0\n5\n", "1\n1 2\n4\n", "1\n1 0\n5\n"], "outputs": ["NO\n", "NO\n", "NO\n", "NO\n", "NO\n", "NO\n", "NO\n", "NO\n"]} | 449 | 118 |
coding | Solve the programming task below in a Python markdown code block.
Ram has invented a magic sequence. Each element of the sequence is defined by the same recursive definition - take some linear combination of previous elements (whose coefficients are fixed) and add to them the n-th powers of some integers. Formally: Xn ... | {"inputs": ["2 0\n1 1\n1 1 2 3 5 8 13 21 34 55", "1 1\n1\n1\n1\n11 12 13 14 15 16 17 18 19 20", "1 1\n1\n1\n2\n1 3 7 15 31 63 127 255 511 1023"], "outputs": ["89 144 233 377 610 987 1597 2584 4181 6765", "21 22 23 24 25 26 27 28 29 30", "2047 4095 8191 16383 32767 65535 131071 262143 524287 48575"]} | 590 | 259 |
coding | Solve the programming task below in a Python markdown code block.
Two friends Chef and Chefina are currently on floors A and B respectively. They hear an announcement that prizes are being distributed on the ground floor and so decide to reach the ground floor as soon as possible.
Chef can climb down X floors per min... | {"inputs": ["4\n2 2 2 2\n4 2 1 5\n3 2 4 1\n3 2 2 1\n"], "outputs": ["Both\nChefina\nChef\nChef"]} | 694 | 52 |
coding | Solve the programming task below in a Python markdown code block.
Polycarp likes squares and cubes of positive integers. Here is the beginning of the sequence of numbers he likes: $1$, $4$, $8$, $9$, ....
For a given number $n$, count the number of integers from $1$ to $n$ that Polycarp likes. In other words, find the... | {"inputs": ["1\n8\n", "1\n64\n", "1\n26\n", "1\n65\n", "1\n49\n", "1\n26\n", "1\n49\n", "1\n64\n"], "outputs": ["3\n", "10\n", "6\n", "10\n", "9\n", "6\n", "9\n", "10\n"]} | 296 | 96 |
coding | Solve the programming task below in a Python markdown code block.
In Chefland, precipitation is measured using a rain gauge in millimetre per hour.
Chef categorises rainfall as:
LIGHT, if rainfall is less than 3 millimetre per hour.
MODERATE, if rainfall is greater than equal to 3 millimetre per hour and less than 7 ... | {"inputs": ["4\n1\n20\n3\n7\n"], "outputs": ["LIGHT\nHEAVY\nMODERATE\nHEAVY"]} | 413 | 34 |
coding | Solve the programming task below in a Python markdown code block.
-----
ARRAY AND DISTINCT ELEMENTS
-----
Chef is multitalented but he mistakenly took part in 2 contest which will take place
at the same time. So while chef is busy at one cooking contest, he wants you to
take part in coding contest. Chef wants u to sol... | {"inputs": ["1\n10 6\n8 8 3 5 3 8 5 7 7 7"], "outputs": ["37"]} | 192 | 38 |
coding | Solve the programming task below in a Python markdown code block.
```if:python
Note: Python may currently have some performance issues. If you find them, please let me know and provide suggestions to improve the Python version! It's my weakest language... any help is much appreciated :)
```
Artlessly stolen and adapt... | {"functional": "_inputs = [[[100, 90, 90, 80], [70, 80, 105]], [[982, 490, 339, 180], [180, 250, 721, 2500]], [[1982, 490, 339, 180], [180, 250, 721, 880]], [[1079, 490, 339, 180], [180, 250, 1200, 1980]]]\n_outputs = [[[4, 3, 1]], [[4, 4, 2, 1]], [[4, 4, 2, 2]], [[4, 4, 1, 1]]]\nimport math\ndef _deep_eq(a, b, tol=1e-... | 505 | 351 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given the root of a binary tree, return the same tree where every subtree (of the given tree) not containing a 1 has been removed.
A subtree of a node node is node plus every node that is a descendant of node.
Pleas... | {"functional": "def check(candidate):\n assert is_same_tree(candidate(root = tree_node([1,None,0,0,1])), tree_node([1,None,0,None,1]))\n assert is_same_tree(candidate(root = tree_node([1,0,1,0,0,0,1])), tree_node([1,None,1,None,1]))\n assert is_same_tree(candidate(root = tree_node([1,1,0,1,1,0,1,0])), tree_nod... | 150 | 136 |
coding | Solve the programming task below in a Python markdown code block.
Byteland is a beautiful land known because of its beautiful trees.
Misha has found a binary tree with $n$ vertices, numbered from $1$ to $n$. A binary tree is an acyclic connected bidirectional graph containing $n$ vertices and $n - 1$ edges. Each verte... | {"inputs": ["4\n2\n1 2\n4\n1 2\n2 3\n2 4\n7\n1 2\n1 5\n2 3\n2 4\n5 6\n5 7\n15\n1 2\n2 3\n3 4\n4 5\n4 6\n3 7\n2 8\n1 9\n9 10\n9 11\n10 12\n10 13\n11 14\n11 15\n"], "outputs": ["0\n2\n2\n10\n"]} | 628 | 136 |
coding | Solve the programming task below in a Python markdown code block.
Given are positive integers N and K.
Determine if the 3N integers K, K+1, ..., K+3N-1 can be partitioned into N triples (a_1,b_1,c_1), ..., (a_N,b_N,c_N) so that the condition below is satisfied. Any of the integers K, K+1, ..., K+3N-1 must appear in ex... | {"inputs": ["3 6", "1 0", "1 2", "6 6", "0 2", "5 6", "7 6", "0 1"], "outputs": ["-1\n", "0 1 2\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n"]} | 311 | 83 |
coding | Solve the programming task below in a Python markdown code block.
There are n beacons located at distinct positions on a number line. The i-th beacon has position a_{i} and power level b_{i}. When the i-th beacon is activated, it destroys all beacons to its left (direction of decreasing coordinates) within distance b_{... | {"inputs": ["1\n0 1\n", "1\n0 1\n", "1\n1 1\n", "1\n0 2\n", "1\n1 2\n", "1\n0 4\n", "1\n1 3\n", "1\n0 3\n"], "outputs": ["0\n", "0", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n"]} | 486 | 101 |
coding | Solve the programming task below in a Python markdown code block.
Rachel has a date and tells everyone she is not mad at Ross but doesn't have any feelings for him anymore either. Seeing her date for the first time, everyone notices that he looks exactly like Ross. However, Rachel refuses to believe so.
Rachel makes a... | {"inputs": ["3\n4 2 2\n1 7 7 5\n1 8 1 2\n5 1 3\n9 8 7 2 5\n5 4 1 8 9\n3 3 0\n2 3 4\n2 3 4\n"], "outputs": ["YES\nNO\nYES\n"]} | 564 | 84 |
coding | Solve the programming task below in a Python markdown code block.
Truncate the given string (first argument) if it is longer than the given maximum length (second argument). Return the truncated string with a `"..."` ending.
Note that inserting the three dots to the end will add to the string length.
However, if the ... | {"functional": "_inputs = [['pippi', 3], ['Peter Piper picked a peck of pickled peppers', 14], ['A-tisket a-tasket A green and yellow basket', 43], ['A-tisket a-tasket A green and yellow basket', 45], ['A-', 1], ['Chingel loves his Angel so much!!!', 27], ['I like ice-cream.Do you?', 19], ['Seems like you have passed t... | 193 | 332 |
coding | Solve the programming task below in a Python markdown code block.
You are given N integers \{A_{1}, A_{2}, \ldots, A_{N}\}. Determine whether they can be reordered such that each pair of consecutive differences differ by a factor of 2.
Formally, determine whether there exists a rearrangement of the given integers into... | {"inputs": ["4\n3\n5 2 4\n5\n2 1 16 8 4\n5\n97 98 100 96 88\n6\n16 19 18 21 24 22"], "outputs": ["Yes\nYes\nNo\nYes\n"]} | 729 | 78 |
coding | Solve the programming task below in a Python markdown code block.
Polycarp has interviewed Oleg and has written the interview down without punctuation marks and spaces to save time. Thus, the interview is now a string s consisting of n lowercase English letters.
There is a filler word ogo in Oleg's speech. All words t... | {"inputs": ["1\no\n", "1\na\n", "1\ng\n", "1\nz\n", "1\no\n", "1\ng\n", "1\nz\n", "1\na\n"], "outputs": ["o\n", "a\n", "g\n", "z\n", "o\n", "g\n", "z\n", "a\n"]} | 411 | 86 |
coding | Solve the programming task below in a Python markdown code block.
An array A is called *weird* if it can be sorted in non-decreasing order by applying the given operation any number of times:
Select any index i (1 ≤ i ≤ |A|) and set A_{i} := -A_{i}.
For example: A = [2, 1, 3] is *weird* since after applying the operat... | {"inputs": ["3\n3\n2 3 1\n3\n2 1 3\n4\n1 2 3 4\n"], "outputs": ["5\n6\n10\n"]} | 449 | 45 |
coding | Solve the programming task below in a Python markdown code block.
Polycarp was presented with some sequence of integers $a$ of length $n$ ($1 \le a_i \le n$). A sequence can make Polycarp happy only if it consists of different numbers (i.e. distinct numbers).
In order to make his sequence like this, Polycarp is going ... | {"inputs": ["1\n6\n1 1 4 5 1 4\n", "1\n7\n1 6 5 4 3 2 1\n", "5\n4\n3 1 4 3\n5\n1 1 1 1 1\n1\n1\n6\n6 5 4 3 2 1\n7\n1 2 1 7 1 2 1\n"], "outputs": ["3\n", "1\n", "1\n4\n0\n0\n5\n"]} | 565 | 124 |
coding | Solve the programming task below in a Python markdown code block.
There are N robots numbered 1 to N placed on a number line. Robot i is placed at coordinate X_i. When activated, it will travel the distance of D_i in the positive direction, and then it will be removed from the number line. All the robots move at the sa... | {"inputs": ["2\n1 5\n4 3", "2\n1 5\n3 3", "2\n1 5\n3 3\n", "3\n6 5\n-1 7\n3 3", "3\n0 5\n-1 7\n3 3", "3\n6 8\n-1 10\n3 3", "3\n6 5\n-1 10\n3 3", "3\n6 5\n-1 10\n3 3\n"], "outputs": ["3\n", "3", "3\n", "6\n", "4\n", "5\n", "5", "5\n"]} | 524 | 154 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given the root of a binary tree, return the average value of the nodes on each level in the form of an array. Answers within 10-5 of the actual answer will be accepted.
Please complete the following python code prec... | {"functional": "def check(candidate):\n assert candidate(root = tree_node([3,9,20,None,None,15,7])) == [3.00000,14.50000,11.00000]\n assert candidate(root = tree_node([3,9,20,15,7])) == [3.00000,14.50000,11.00000]\n\n\ncheck(Solution().averageOfLevels)"} | 142 | 120 |
coding | Solve the programming task below in a Python markdown code block.
Naruto has recently joined the Ninja Academy for higher education, while filling the admission form he is required to choose minimum $X$ subjects out of a list of $N$ subjects. He is not very interested in studies but wants to get a good overall CPI. How... | {"inputs": ["1 \n5 2 \n50 40 30 20 10 "], "outputs": ["43.3333333333\n\n"]} | 486 | 51 |
coding | Solve the programming task below in a Python markdown code block.
You are given a rebus of form ? + ? - ? + ? = n, consisting of only question marks, separated by arithmetic operation '+' and '-', equality and positive integer n. The goal is to replace each question mark with some positive integer from 1 to n, such tha... | {"inputs": ["? - ? = 2\n", "? - ? = 1\n", "? = 1000010\n", "? = 1010010\n", "? = 1100000\n", "? = 1000011\n", "? = 1010011\n", "? = 1010001\n"], "outputs": ["Impossible", "Impossible\n", "Possible\n1000010 = 1000010", "Possible\n1010010 = 1010010", "Possible\n1100000 = 1100000", "Possible\n1000011 = 1000011", "Possible... | 296 | 222 |
coding | Solve the programming task below in a Python markdown code block.
You are given a string S of length N consisting of lowercase English letters.
We will cut this string at one position into two strings X and Y.
Here, we would like to maximize the number of different letters contained in both X and Y.
Find the largest po... | {"inputs": ["6\n`abbca", "6\nb`^dca", "6\nacbba`", "6\n`abbda", "6\nadbba`", "6\nadbbb`", "6\nadbcb`", "6\n`bbbda"], "outputs": ["2\n", "0\n", "2\n", "2\n", "2\n", "1\n", "1\n", "1\n"]} | 229 | 96 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.