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.
Andrzej was given a task:
There are n jars with pills. In every jar there is a different type of pill and the amount of pills in each jar is infinite. One type of pill makes a person glow about 30 minutes after taking and none of the other types has any ... | {"functional": "_inputs = [[0], [1], [2], [4], [3], [16]]\n_outputs = [[0], [0], [0], [1], [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, abs_tol=tol)\n if isinstance(a, (list, tuple)):\n if len(a) != ... | 309 | 185 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given the array nums, obtain a subsequence of the array whose sum of elements is strictly greater than the sum of the non included elements in such subsequence.
If there are multiple solutions, return the subsequence... | {"functional": "def check(candidate):\n assert candidate(nums = [4,3,10,9,8]) == [10,9] \n assert candidate(nums = [4,4,7,6,7]) == [7,7,6] \n\n\ncheck(Solution().minSubsequence)"} | 168 | 72 |
coding | Solve the programming task below in a Python markdown code block.
Iahub helps his grandfather at the farm. Today he must milk the cows. There are n cows sitting in a row, numbered from 1 to n from left to right. Each cow is either facing to the left or facing to the right. When Iahub milks a cow, all the cows that see ... | {"inputs": ["1\n1\n", "1\n0\n", "1\n0\n", "1\n1\n", "2\n0 1\n", "2\n1 0\n", "2\n0 0\n", "2\n1 1\n"], "outputs": ["0", "0", "0\n", "0\n", "0", "1", "0", "0"]} | 456 | 88 |
coding | Solve the programming task below in a Python markdown code block.
Read problem statements in [Russian] and [Mandarin Chinese].
Value of an array A of length L is defined as the sum of (A_{i} \oplus i) for all 0 ≤ i < L, where \oplus denotes [bitwise xor operation]. Note that array indices start from zero.
You are gi... | {"inputs": ["3\n2 0\n2 1\n10 100"], "outputs": ["0\n6\n204600"]} | 658 | 36 |
coding | Solve the programming task below in a Python markdown code block.
# Task
You are given a string `s`. Every letter in `s` appears once.
Consider all strings formed by rearranging the letters in `s`. After ordering these strings in dictionary order, return the middle term. (If the sequence has a even length `n`, def... | {"functional": "_inputs = [['abc'], ['abcd'], ['abcdx'], ['abcdxg'], ['abcdxgz']]\n_outputs = [['bac'], ['bdca'], ['cbxda'], ['cxgdba'], ['dczxgba']]\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 isi... | 204 | 191 |
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 target.
An integer is considered beautiful if the sum of its digits is less than or equal to target.
Return the minimum non-negative integer x such that n + x is beautiful. Th... | {"functional": "def check(candidate):\n assert candidate(n = 16, target = 6) == 4\n assert candidate(n = 467, target = 6) == 33\n assert candidate(n = 1, target = 1) == 0\n\n\ncheck(Solution().makeIntegerBeautiful)"} | 112 | 75 |
coding | Solve the programming task below in a Python markdown code block.
Sereja has a string A consisting of n lower case English letters.
Sereja calls two strings X and Y each of length n similar if they can be made equal by applying the following operation at most once in each of them.
- Chose any two position i, j in th... | {"inputs": ["2\nz\nabcd\n\n"], "outputs": ["0\n144"]} | 504 | 22 |
coding | Solve the programming task below in a Python markdown code block.
Polycarp likes numbers that are divisible by 3.
He has a huge number $s$. Polycarp wants to cut from it the maximum number of numbers that are divisible by $3$. To do this, he makes an arbitrary number of vertical cuts between pairs of adjacent digits. ... | {"inputs": ["6\n", "4\n", "4\n", "5\n", "8\n", "1\n", "2\n", "7\n"], "outputs": ["1\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n"]} | 621 | 70 |
coding | Solve the programming task below in a Python markdown code block.
After learning about polynomial hashing, Heidi decided to learn about shift-xor hashing. In particular, she came across this interesting problem.
Given a bitstring $y \in \{0,1\}^n$ find out the number of different $k$ ($0 \leq k < n$) such that there e... | {"inputs": ["1\n0\n", "1\n1\n", "1\n0\n", "1\n1\n", "2\n00\n", "2\n10\n", "2\n01\n", "2\n11\n"], "outputs": ["1\n", "0\n", "1", "0", "2\n", "0\n", "0\n", "1\n"]} | 431 | 88 |
coding | Solve the programming task below in a Python markdown code block.
Andy got a box of candies for Christmas. In fact, he discovered that the box contained several identical smaller boxes, and they could contain even smaller boxes, and so on. Formally, we say that candies are boxes of level 0, and for 1 ≤ i ≤ n, a level i... | {"inputs": ["5 1\n1 1 1 1 1\n1", "3 3\n3 3 3\n2 8 13"], "outputs": ["5", "3\n5\n8"]} | 554 | 51 |
coding | Solve the programming task below in a Python markdown code block.
Write a program which performs the following operations to a binary search tree $T$ by adding the find operation to A: Binary Search Tree I.
* insert $k$: Insert a node containing $k$ as key into $T$.
* find $k$: Report whether $T$ has a node containin... | {"inputs": ["10\ninsert 30\ninsert 88\ninsert 3\ninsert 2\ninsert 20\nfind 12\ninsert 1\ninsert 24\nfind 2\nprint", "10\ninsert 30\ninsert 88\ninsert 3\ninsert 2\ninsert 20\nfind 12\ninsert 1\ninsert 24\nfind 16\nprint", "10\ninsert 30\ninsert 88\ninsert 12\ninsert 2\ninsert 20\nfind 8\ninsert 1\ninsert 24\nfind 16\npr... | 413 | 749 |
coding | Solve the programming task below in a Python markdown code block.
In your class, you have started lessons about "arithmetic progression". Because you are also a programmer, you have decided to write a function.
This function, arithmetic_sequence_sum(a, r, n), should return the sum of the first (n) elements of a sequen... | {"functional": "_inputs = [[3, 2, 20], [2, 2, 10], [1, -2, 10]]\n_outputs = [[440], [110], [-80]]\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... | 242 | 194 |
coding | Solve the programming task below in a Python markdown code block.
We call an quadruple of positive integers, $(W,X,Y,Z)$, beautiful if the following condition is true:
$W\oplus X\oplus Y\oplus Z\neq0$
Note: $\theta$ is the bitwise XOR operator.
Given $\mbox{A}$, $\mbox{B}$, $\mbox{C}$, and $\mbox{D}$, count the numb... | {"inputs": ["1 2 3 4\n"], "outputs": ["11\n"]} | 518 | 21 |
coding | Solve the programming task below in a Python markdown code block.
Alice has an array A of length N which is initially a *permutation*. She dislikes K numbers which are B_{1}, B_{2}, \ldots, B_{K} all of which are distinct. Therefore, she removes all the occurrences of these numbers from A. The order of the remaining el... | {"inputs": ["3\n4\n4 1 3 2\n2\n3 1\n9\n5 2 9 1 8 6 4 3 7\n3\n5 8 9\n5\n3 4 5 1 2\n2\n2 3\n"], "outputs": ["4 2\n2 1 6 4 3 7\n4 5 1\n"]} | 740 | 96 |
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 and an integer targetSum, return all root-to-leaf paths where the sum of the node values in the path equals targetSum. Each path should be returned as a list of the node values, not nod... | {"functional": "def check(candidate):\n assert candidate(root = tree_node([5,4,8,11,None,13,4,7,2,None,None,5,1]), targetSum = 22) == [[5,4,11,2],[5,8,4,5]]\n assert candidate(root = tree_node([1,2,3]), targetSum = 5) == []\n assert candidate(root = tree_node([1,2]), targetSum = 0) == []\n\n\ncheck(Solution().... | 187 | 126 |
coding | Solve the programming task below in a Python markdown code block.
There are N people numbered from 1 to N such that:
Exactly one of these people is a thief and always lies;
All the others are honest and always tell the truth.
If the i^{th} person claims that the thief is one person out of L_{i}, L_{i}+1, L_{i}+2, \cd... | {"inputs": ["1\n4\n2 2\n1 1\n1 3\n1 3"], "outputs": ["2\n1\n2"]} | 593 | 34 |
coding | Solve the programming task below in a Python markdown code block.
We have N sticks with negligible thickness.
The length of the i-th stick is A_i.
Snuke wants to select four different sticks from these sticks and form a rectangle (including a square), using the sticks as its sides.
Find the maximum possible area of the... | {"inputs": ["4\n1 2 0 4", "4\n1 2 0 5", "4\n1 1 0 5", "4\n0 1 0 5", "4\n0 1 0 3", "4\n1 2 3 4", "4\n1 2 3 4\n", "4\n-1 1 0 3"], "outputs": ["0\n", "0\n", "0\n", "0\n", "0\n", "0", "0\n", "0\n"]} | 195 | 127 |
coding | Solve the programming task below in a Python markdown code block.
Read problems statements in Mandarin Chinese, Russian and Vietnamese as well.
Phantasialand boasts of its famous theme park. The park is frequently visited. It is quite large park that some tourists visit it more than once to fully appreciate its offer... | {"inputs": ["2\n3 1", "2\n4 1", "2\n3 0", "2\n4 0", "2\n3 2", "2\n7 1", "2\n4 2", "2\n3 1"], "outputs": ["2", "3\n", "2\n", "2\n", "3\n", "4\n", "3\n", "2\n"]} | 725 | 93 |
coding | Solve the programming task below in a Python markdown code block.
Read problems statements in Mandarin Chinese and Russian.
In a far away dystopian world, the measure of the quality of a person’s life is the numbers of likes he gets for an article about their life. For a person to stay alive, he has to acquire at le... | {"inputs": ["2\n5 1 5 1\n9 4 3 2", "2\n5 2 5 1\n9 4 3 2", "2\n5 1 5 1\n4 2 2 2", "2\n5 1 5 1\n2 4 3 2", "2\n5 2 5 1\n9 3 3 2", "2\n5 3 5 1\n9 4 3 2", "2\n5 2 5 1\n1 4 5 2", "2\n5 4 5 1\n9 4 3 2"], "outputs": ["ALIVE AND KICKING\nALIVE AND KICKING\n", "ALIVE AND KICKING\nALIVE AND KICKING\n", "ALIVE AND KICKING\nALIVE A... | 495 | 286 |
coding | Solve the programming task below in a Python markdown code block.
Mike decided to teach programming to children in an elementary school. He knows that it is not an easy task to interest children in that age to code. That is why he decided to give each child two sweets.
Mike has $n$ sweets with sizes $a_1, a_2, \ldots,... | {"inputs": ["2\n2 1\n", "2\n2 1\n", "2\n3 1\n", "2\n3 2\n", "2\n5 2\n", "2\n7 2\n", "2\n4 1\n", "2\n1 2\n"], "outputs": ["1\n", "1\n", "1\n", "1\n", "1\n", "1\n", "1\n", "1\n"]} | 616 | 102 |
coding | Solve the programming task below in a Python markdown code block.
Today, hedgehog Filya went to school for the very first time! Teacher gave him a homework which Filya was unable to complete without your help.
Filya is given an array of non-negative integers a_1, a_2, ..., a_{n}. First, he pick an integer x and then h... | {"inputs": ["1\n0\n", "1\n0\n", "1\n1\n", "2\n1 2\n", "2\n4 2\n", "2\n2 3\n", "2\n4 2\n", "2\n2 3\n"], "outputs": ["YES\n", "YES\n", "YES\n", "YES\n", "YES\n", "YES\n", "YES\n", "YES\n"]} | 366 | 96 |
coding | Solve the programming task below in a Python markdown code block.
Construct a function 'coordinates', that will return the distance between two points on a cartesian plane, given the x and y coordinates of each point.
There are two parameters in the function, ```p1``` and ```p2```. ```p1``` is a list ```[x1,y1]``` whe... | {"functional": "_inputs = [[[3, 6], [14, 6]], [[-2, 5], [-2, -10], 2], [[1, 2], [4, 6]], [[5, 3], [10, 15], 2], [[-2, -10], [6, 5]], [[4, 7], [6, 2], 3], [[-4, -5], [-5, -4], 1], [[3, 8], [3, 8]], [[-3, 8], [3, 8]], [[3, 8], [3, -8]]]\n_outputs = [[11], [15], [5], [13], [17], [5.385], [1.4], [0], [6], [16]]\nimport mat... | 185 | 329 |
coding | Solve the programming task below in a Python markdown code block.
Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
You are given a rooted tree with $N$ nodes (numbered $1$ through $N$); the root is node $1$. For each valid $i$, node $i$ has weight $w_{i}$, which i... | {"inputs": ["1\n3\n1 0 1\n1 2\n1 3"], "outputs": ["1"]} | 585 | 28 |
coding | Solve the programming task below in a Python markdown code block.
Tokitsukaze and CSL are playing a little game of stones.
In the beginning, there are n piles of stones, the i-th pile of which has a_i stones. The two players take turns making moves. Tokitsukaze moves first. On each turn the player chooses a nonempty p... | {"inputs": ["1\n1\n", "1\n2\n", "1\n3\n", "1\n5\n", "1\n4\n", "1\n6\n", "1\n9\n", "1\n0\n"], "outputs": ["sjfnb\n", "cslnb\n", "sjfnb\n", "sjfnb\n", "cslnb\n", "cslnb\n", "sjfnb\n", "cslnb\n"]} | 702 | 102 |
coding | Solve the programming task below in a Python markdown code block.
Read problems statements [Mandarin] , [Bengali] , [Hindi] , [Russian] and [Vietnamese] as well.
Chef has bought a new robot, which will be used for delivering dishes to his customers. He started testing the robot by letting it move on a line.
Initially... | {"inputs": ["2\n6 10\nRRLLLL\n2 0\nLL"], "outputs": ["5\n3"]} | 497 | 28 |
coding | Solve the programming task below in a Python markdown code block.
Vasya has an array a_1, a_2, ..., a_n.
You don't know this array, but he told you m facts about this array. The i-th fact is a triple of numbers t_i, l_i and r_i (0 ≤ t_i ≤ 1, 1 ≤ l_i < r_i ≤ n) and it means:
* if t_i=1 then subbarray a_{l_i}, a_{l_i... | {"inputs": ["2 1\n1 1 2\n", "5 1\n0 1 3\n", "2 1\n0 1 2\n", "4 1\n0 1 2\n", "4 1\n0 1 1\n", "124 1\n1 1 2\n", "124 1\n0 1 2\n", "152 1\n0 1 2\n"], "outputs": ["YES\n2 2 \n", "YES\n5 4 3 2 1 \n", "YES\n2 1 \n", "YES\n4 3 2 1 ", "NO\n", "YES\n124 124 123 122 121 120 119 118 117 116 115 114 113 112 111 110 109 108 107 106... | 676 | 1,446 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given an m x n binary matrix grid.
A move consists of choosing any row or column and toggling each value in that row or column (i.e., changing all 0's to 1's, and all 1's to 0's).
Every row of the matrix is in... | {"functional": "def check(candidate):\n assert candidate(grid = [[0,0,1,1],[1,0,1,0],[1,1,0,0]]) == 39\n assert candidate(grid = [[0]]) == 1\n\n\ncheck(Solution().matrixScore)"} | 144 | 66 |
coding | Solve the programming task below in a Python markdown code block.
There is a house with $n$ flats situated on the main street of Berlatov. Vova is watching this house every night. The house can be represented as an array of $n$ integer numbers $a_1, a_2, \dots, a_n$, where $a_i = 1$ if in the $i$-th flat the light is o... | {"inputs": ["3\n0 0 0\n", "3\n1 0 1\n", "3\n1 1 1\n", "3\n0 1 1\n", "3\n1 1 0\n", "3\n1 0 0\n", "3\n0 1 0\n", "3\n0 0 1\n"], "outputs": ["0\n", "1\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n"]} | 471 | 118 |
coding | Solve the programming task below in a Python markdown code block.
In 2937, DISCO creates a new universe called DISCOSMOS to celebrate its 1000-th anniversary.
DISCOSMOS can be described as an H \times W grid. Let (i, j) (1 \leq i \leq H, 1 \leq j \leq W) denote the square at the i-th row from the top and the j-th colu... | {"inputs": ["2 2 1", "7 48 1110", "3 29 1101", "5 48 1110", "3 22 1101", "5 70 1110", "3 35 1101", "11 6 1111"], "outputs": ["9", "404785941\n", "582975580\n", "220543434\n", "899722747\n", "284885353\n", "133144039\n", "533072736\n"]} | 508 | 177 |
coding | Solve the programming task below in a Python markdown code block.
Dreamoon is a big fan of the Codeforces contests.
One day, he claimed that he will collect all the places from $1$ to $54$ after two more rated contests. It's amazing!
Based on this, you come up with the following problem:
There is a person who partic... | {"inputs": ["1\n1 5\n6\n", "1\n1 1\n2\n", "1\n1 1\n2\n", "1\n1 5\n6\n", "1\n1 9\n6\n", "1\n1 3\n6\n", "1\n1 3\n9\n", "1\n1 5\n4\n"], "outputs": ["6\n", "2\n", "2\n", "6\n", "10\n", "3\n", "3\n", "6\n"]} | 652 | 119 |
coding | Solve the programming task below in a Python markdown code block.
Division of Big Integers
Given two integers $A$ and $B$, compute the quotient, $\frac{A}{B}$. Round down to the nearest decimal.
Input
Two integers $A$ and $B$ separated by a space character are given in a line.
Output
Print the quotient in a line.
... | {"inputs": ["9 6", "2 1", "1 4", "2 4", "2 2", "5 3", "5 6", "9 8"], "outputs": ["1\n", "2\n", "0\n", "0\n", "1\n", "1\n", "0\n", "1\n"]} | 205 | 78 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given two positive integer arrays nums and target, of the same length.
In one operation, you can choose any two distinct indices i and j where 0 <= i, j < nums.length and:
set nums[i] = nums[i] + 2 and
set nu... | {"functional": "def check(candidate):\n assert candidate(nums = [8,12,6], target = [2,14,10]) == 2\n assert candidate(nums = [1,2,5], target = [4,1,3]) == 1\n assert candidate(nums = [1,1,1,1,1], target = [1,1,1,1,1]) == 0\n\n\ncheck(Solution().makeSimilar)"} | 166 | 105 |
coding | Solve the programming task below in a Python markdown code block.
Lucas numbers are numbers in a sequence defined like this:
```
L(0) = 2
L(1) = 1
L(n) = L(n-1) + L(n-2)
```
Your mission is to complete the function that returns the `n`th term of this sequence.
**Note:** It should work for negative numbers as well; ho... | {"functional": "_inputs = [[-10], [-1]]\n_outputs = [[123], [-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) != len(b): return False\n retur... | 227 | 165 |
coding | Solve the programming task below in a Python markdown code block.
Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Chef's apartment consists of $M$ floors (numbered $1$ through $M$), and there's an elevator that is used to move between different floors. The elevat... | {"inputs": ["5\n4 5\n2 3 4 3\n4 5\n2 -1 4 3\n4 5\n1 -1 -1 5\n5 4\n-1 -1 3 -1 -1\n5 5\n-1 -1 3 -1 -1\n"], "outputs": ["1\n1\n-1\n1\n0\n"]} | 569 | 89 |
coding | Solve the programming task below in a Python markdown code block.
A list of names is taken as input, in which a particular name can occur multiple times. You need to arrange these names as they will appear in the dictionary and also print the number of times the arranged names appear in the list taken as input.
Input:... | {"inputs": ["3\nritesh\nsahil\nritesh"], "outputs": ["ritesh 2\nsahil 1"]} | 252 | 31 |
coding | Solve the programming task below in a Python markdown code block.
# Task
Consider the following algorithm for constructing 26 strings S(1) .. S(26):
```
S(1) = "a";
For i in [2, 3, ..., 26]:
S(i) = S(i - 1) + character(i) + S(i - 1).```
For example:
```
S(1) = "a"
S(2) = S(1) + "b" + S(1) = "a" + "b" + "a" = "aba"
S... | {"functional": "_inputs = [[1], [2], [3], [4], [5], [6], [7], [8], [12], [16]]\n_outputs = [['a'], ['b'], ['a'], ['c'], ['a'], ['b'], ['a'], ['d'], ['c'], ['e']]\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)... | 308 | 211 |
coding | Solve the programming task below in a Python markdown code block.
*CodeChef recently revamped its [practice page] to make it easier for users to identify the next problems they should solve by introducing some new features:*
*Recent Contest Problems - Contains only problems from the last 2 contests*
*Separate Un-Attemp... | {"inputs": ["4\n3\nSTART38 LTIME108 START38\n4\nLTIME108 LTIME108 LTIME108 START38\n2\nLTIME108 LTIME108\n6\nSTART38 LTIME108 LTIME108 LTIME108 START38 LTIME108\n"], "outputs": ["2 1\n1 3\n0 2\n2 4\n"]} | 666 | 105 |
coding | Solve the programming task below in a Python markdown code block.
Chef was driving on a highway at a speed of X km/hour.
To avoid accidents, there are fine imposed on overspeeding as follows:
No fine if the speed of the car ≤ 70 km/hour.
Rs 500 fine if the speed of the car is strictly greater than 70 and ≤ 100.
Rs 200... | {"inputs": ["7\n40\n110\n70\n100\n69\n101\n85\n"], "outputs": ["0\n2000\n0\n500\n0\n2000\n500\n"]} | 481 | 60 |
coding | Solve the programming task below in a Python markdown code block.
In this kata, you will do addition and subtraction on a given string. The return value must be also a string.
**Note:** the input will not be empty.
## Examples
```
"1plus2plus3plus4" --> "10"
"1plus2plus3minus4" --> "2"
```
Also feel free to reuse/... | {"functional": "_inputs = [['1plus2plus3plus4'], ['1minus2minus3minus4'], ['1plus2plus3minus4'], ['1minus2plus3minus4'], ['1plus2minus3plus4minus5']]\n_outputs = [['10'], ['-8'], ['2'], ['-2'], ['-1']]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return math... | 103 | 211 |
coding | Solve the programming task below in a Python markdown code block.
Read problem statements in [Mandarin], [Vietnamese], and [Russian] as well.
Chef loves Chess and has thus invented a new piece named "Disabled King".
Let's denote the cell at the intersection of the i-th column from the left and j-th row from the top b... | {"inputs": ["2\n2\n3\n"], "outputs": ["2\n2\n"]} | 478 | 20 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given a 2D array of integers envelopes where envelopes[i] = [wi, hi] represents the width and the height of an envelope.
One envelope can fit into another if and only if both the width and height of one envelo... | {"functional": "def check(candidate):\n assert candidate(envelopes = [[5,4],[6,4],[6,7],[2,3]]) == 3\n assert candidate(envelopes = [[1,1],[1,1],[1,1]]) == 1\n\n\ncheck(Solution().maxEnvelopes)"} | 139 | 73 |
coding | Solve the programming task below in a Python markdown code block.
Problem statement
JOI decided to start a new social game from tomorrow.
In this social game, you can log in up to once a day, and you will get A coins each time you log in.
Also, if you log in for 7 consecutive days from Monday to Sunday, you will get... | {"inputs": ["4 0 2", "0 1 3", "3 0 19", "2 0 19", "4 0 19", "8 0 22", "6 0 43", "2 0 31"], "outputs": ["1\n", "21\n", "7\n", "10\n", "5\n", "3\n", "8\n", "16\n"]} | 536 | 103 |
coding | Solve the programming task below in a Python markdown code block.
Read problem statements in [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
You are given a strictly increasing sequence of integers $A_{1}, A_{2}, \ldots, A_{N}$. Your task is to compress this sequence.
The *compressed form* of this... | {"inputs": ["3\n12\n1 2 3 5 6 8 9 10 11 12 15 17\n4\n4 5 7 8\n1\n4"], "outputs": ["1...3,5,6,8...12,15,17\n4,5,7,8\n4"]} | 677 | 85 |
coding | Solve the programming task below in a Python markdown code block.
You are given strings S and T consisting of lowercase English letters.
You can perform the following operation on S any number of times:
Operation: Choose two distinct lowercase English letters c_1 and c_2, then replace every occurrence of c_1 with c_2, ... | {"inputs": ["x\nz\n", "h\nh\n", "aaa\nxxy\n", "uvan\naimq\n", "azzel\napqle", "azzle\napqle", "azzle\napqld", "azzle\ndlqpa"], "outputs": ["Yes\n", "Yes\n", "No\n", "Yes\n", "No\n", "No\n", "No\n", "No\n"]} | 246 | 97 |
coding | Solve the programming task below in a Python markdown code block.
Bob wants to put a new bargaining table in his office. To do so he measured the office room thoroughly and drew its plan: Bob's office room is a rectangular room n × m meters. Each square meter of the room is either occupied by some furniture, or free. A... | {"inputs": ["1 1\n0\n", "3 3\n000\n110\n000\n", "4 2\n00\n10\n11\n00\n", "3 3\n000\n010\n010\n", "3 3\n000\n010\n011\n", "3 3\n100\n010\n011\n", "3 3\n101\n010\n011\n", "3 3\n000\n010\n000\n"], "outputs": ["4", "8", "6", "8\n", "8\n", "6\n", "6\n", "8"]} | 317 | 168 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
For a string sequence, a string word is k-repeating if word concatenated k times is a substring of sequence. The word's maximum k-repeating value is the highest value k where word is k-repeating in sequence. If word i... | {"functional": "def check(candidate):\n assert candidate(sequence = \"ababc\", word = \"ab\") == 2\n assert candidate(sequence = \"ababc\", word = \"ba\") == 1\n assert candidate(sequence = \"ababc\", word = \"ac\") == 0\n\n\ncheck(Solution().maxRepeating)"} | 135 | 74 |
coding | Solve the programming task below in a Python markdown code block.
Let's consider a permutation P = {$p_{1}$,$ p_{2}$, ..., $p_{N}$} of the set of N = {1, 2, 3, ..., N} elements .
P is called a magic set if it satisfies both of the following constraints:
Given a set of K integers, the elements in positions $a_{1}$... | {"inputs": ["4 1 1\n2\n3\n", "10 2 2\n2 4\n3 9\n"], "outputs": ["5\n", "161280\n"]} | 520 | 48 |
coding | Solve the programming task below in a Python markdown code block.
We saw the little game Marmot made for Mole's lunch. Now it's Marmot's dinner time and, as we all know, Marmot eats flowers. At every dinner he eats some red and white flowers. Therefore a dinner can be represented as a sequence of several flowers, some ... | {"inputs": ["1 1\n1 3\n", "1 1\n1 3\n", "1 1\n2 3\n", "1 2\n2 3\n", "1 1\n3 3\n", "1 2\n2 4\n", "1 2\n3 6\n", "1 1\n1 1\n"], "outputs": ["14\n", "14\n", "12\n", "5\n", "8\n", "10\n", "29\n", "2\n"]} | 446 | 123 |
coding | Solve the programming task below in a Python markdown code block.
Tom is interested in power consumption of his favourite laptop. His laptop has three modes. In normal mode laptop consumes P1 watt per minute. T1 minutes after Tom moved the mouse or touched the keyboard for the last time, a screensaver starts and power ... | {"inputs": ["1 5 2 1 6 3\n2 4\n", "1 0 2 1 6 9\n1 4\n", "1 5 0 1 6 3\n3 4\n", "1 2 0 1 6 3\n3 4\n", "1 5 2 1 6 3\n1 4\n", "1 3 2 1 5 9\n1 4\n", "1 3 2 1 6 9\n1 4\n", "1 5 0 1 6 3\n2 4\n"], "outputs": ["10\n", "0\n", "5\n", "2\n", "15\n", "9\n", "9\n", "10\n"]} | 413 | 185 |
coding | Solve the programming task below in a Python markdown code block.
You are at a water bowling training. There are l people who play with their left hand, r people, who play with their right hand, and a ambidexters, who can play with left or right hand.
The coach decided to form a team of even number of players, exactly... | {"inputs": ["1 4 2\n", "5 5 5\n", "0 2 0\n", "0 0 0\n", "1 1 1\n", "1 2 1\n", "1 2 2\n", "2 2 2\n"], "outputs": ["6\n", "14\n", "0\n", "0\n", "2\n", "4\n", "4\n", "6\n"]} | 409 | 103 |
coding | Solve the programming task below in a Python markdown code block.
Transformation
Write a program which performs a sequence of commands to a given string $str$. The command is one of:
* print a b: print from the a-th character to the b-th character of $str$
* reverse a b: reverse from the a-th character to the b-th... | {"inputs": ["xyz\n3\nprint 0 2\nreplace 1 2 abc\nprint 0 2", "xyz\n1\nprint 0 2\nreplace 0 2 abc\nprint 0 2", "xyz\n3\nprint 0 1\nreplace 1 2 abc\nprint 0 2", "wyz\n1\nprint 0 2\nreplace 0 2 abc\nprint 0 2", "xyz\n3\nprint 0 2\nreplace 1 2 abb\nprint 0 4", "zyx\n3\nprint 0 2\nreplace 0 2 abc\nprint 0 2", "xyz\n3\nprint... | 317 | 245 |
coding | Solve the programming task below in a Python markdown code block.
Petya is the most responsible worker in the Research Institute. So he was asked to make a very important experiment: to melt the chocolate bar with a new laser device. The device consists of a rectangular field of n × m cells and a robotic arm. Each cell... | {"inputs": ["1\n3 3 3 2 1 1\n", "1\n4 5 2 2 4 2\n", "1\n2 5 1 5 2 2\n", "1\n5 6 3 4 4 2\n", "1\n3 5 2 4 3 5\n", "1\n2 6 2 6 2 3\n", "1\n2 2 1 2 2 1\n", "1\n7 3 6 2 5 2\n"], "outputs": ["5\n", "0\n", "6\n", "4\n", "2\n", "0\n", "2\n", "0\n"]} | 536 | 166 |
coding | Solve the programming task below in a Python markdown code block.
The tram in Berland goes along a straight line from the point 0 to the point s and back, passing 1 meter per t_1 seconds in both directions. It means that the tram is always in the state of uniform rectilinear motion, instantly turning around at points x... | {"inputs": ["4 2 4\n3 4\n1 1\n", "5 4 0\n1 2\n3 1\n", "2 0 2\n1 1\n1 1\n", "5 4 2\n1 2\n3 1\n", "4 2 4\n3 4\n2 1\n", "6 4 2\n1 2\n3 1\n", "3 1 3\n1 2\n1 1\n", "2 2 0\n7 3\n1 1\n"], "outputs": ["8\n", "7\n", "2\n", "4\n", "6\n", "4\n", "2\n", "6\n"]} | 699 | 166 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given two integer arrays of equal length target and arr. In one step, you can select any non-empty subarray of arr and reverse it. You are allowed to make any number of steps.
Return true if you can make arr e... | {"functional": "def check(candidate):\n assert candidate(target = [1,2,3,4], arr = [2,4,1,3]) == True\n assert candidate(target = [7], arr = [7]) == True\n assert candidate(target = [3,7,9], arr = [3,7,11]) == False\n\n\ncheck(Solution().canBeEqual)"} | 110 | 89 |
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 and two integers val and depth, add a row of nodes with value val at the given depth depth.
Note that the root node is at depth 1.
The adding rule is:
Given the integer depth, for each... | {"functional": "def check(candidate):\n assert is_same_tree(candidate(root = tree_node([4,2,6,3,1,5]), val = 1, depth = 2), tree_node([4,1,1,2,None,None,6,3,1,5]))\n assert is_same_tree(candidate(root = tree_node([4,2,None,3,1]), val = 1, depth = 3), tree_node([4,2,None,1,1,3,None,None,1]))\n\n\ncheck(Solution().... | 275 | 126 |
coding | Solve the programming task below in a Python markdown code block.
After many years of research, Ikta has acquired the ability to predict the future! The time and money he spent on this research was enormous, but it's finally time to be rewarded. To get the money back, Ikta decided to start investing in stocks.
Ikta do... | {"inputs": ["1 2 5\n4\n10000", "2 2 6\n3 2\n5 4", "1 2 7\n4\n10000", "1 1 5\n6\n10000", "2 1 8\n6\n10000", "1 2 5\n6\n10000", "2 2 5\n3 2\n5 4", "2 3 5\n4 5\n6 3\n8 6"], "outputs": ["10001\n", "12\n", "10003\n", "5\n", "8\n", "5", "9", "13\n"]} | 636 | 170 |
coding | Solve the programming task below in a Python markdown code block.
Polycarp watched TV-show where k jury members one by one rated a participant by adding him a certain number of points (may be negative, i. e. points were subtracted). Initially the participant had some score, and each the marks were one by one added to h... | {"inputs": ["1 1\n-27\n61769\n", "1 1\n1\n-164538\n", "1 1\n1\n-4000000\n", "1 1\n1\n-4000000\n", "1 1\n1\n-1911669\n", "1 1\n1\n-1398610\n", "1 1\n1\n-1396982\n", "1 1\n-659\n61769\n"], "outputs": ["1\n", "1\n", "1\n", "1\n", "1\n", "1\n", "1\n", "1\n"]} | 542 | 172 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given a 0-indexed n x n integer matrix grid, return the number of pairs (ri, cj) such that row ri and column cj are equal.
A row and column pair is considered equal if they contain the same elements in the same order ... | {"functional": "def check(candidate):\n assert candidate(grid = [[3,2,1],[1,7,6],[2,7,7]]) == 1\n assert candidate(grid = [[3,1,2,2],[1,4,4,5],[2,4,2,2],[2,4,2,2]]) == 3\n\n\ncheck(Solution().equalPairs)"} | 108 | 89 |
coding | Solve the programming task below in a Python markdown code block.
N teams have come to participate in a competitive coding event called “Binary Battles”. It is a [single-elimination tournament] consisting of several rounds.
Note: It is known that N is a power of 2.
In one round, each team will be paired up with and c... | {"inputs": ["4\n4 10 5\n16 30 5\n32 45 15\n1024 23 9\n"], "outputs": ["25\n135\n285\n311"]} | 675 | 60 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
There is an undirected graph with n nodes numbered from 0 to n - 1 (inclusive). You are given a 0-indexed integer array values where values[i] is the value of the ith node. You are also given a 0-indexed 2D integer ar... | {"functional": "def check(candidate):\n assert candidate(values = [0,32,10,43], edges = [[0,1,10],[1,2,15],[0,3,10]], maxTime = 49) == 75\n assert candidate(values = [5,10,15,20], edges = [[0,1,10],[1,2,10],[0,3,10]], maxTime = 30) == 25\n assert candidate(values = [1,2,3,4], edges = [[0,1,10],[1,2,11],[2,3,12... | 272 | 216 |
coding | Solve the programming task below in a Python markdown code block.
Vasya studies positional numeral systems. Unfortunately, he often forgets to write the base of notation in which the expression is written. Once he saw a note in his notebook saying a + b = ?, and that the base of the positional notation wasn’t written a... | {"inputs": ["9 7\n", "3 1\n", "1 2\n", "1 3\n", "2 3\n", "3 2\n", "2 2\n", "2 1\n"], "outputs": ["2\n", "2\n", "2\n", "2\n", "2\n", "2\n", "2\n", "2\n"]} | 402 | 86 |
coding | Solve the programming task below in a Python markdown code block.
>When no more interesting kata can be resolved, I just choose to create the new kata, to solve their own, to enjoy the process --myjinxin2015 said
# Description:
Given two array of integers(`arr1`,`arr2`). Your task is going to find a pair of numbers(... | {"functional": "_inputs = [[[3, 10, 5], [20, 7, 15, 8]], [[3], [20]], [[3, 10, 5], [3, 10, 5]], [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10]]]\n_outputs = [[[17, 2]], [[17, 17]], [[7, 0]], [[9, 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... | 436 | 258 |
coding | Solve the programming task below in a Python markdown code block.
Chef wants to impress Chefina by giving her the maximum number of gifts possible.
Chef is in a gift shop having N items where the cost of the i^{th} item is equal to A_{i}.
Chef has K amount of money and a 50 \% off discount coupon that he can use for a... | {"inputs": ["3\n1 4\n5\n3 15\n4 4 5\n3 10\n6 7 4"], "outputs": ["1\n3\n2"]} | 543 | 44 |
coding | Solve the programming task below in a Python markdown code block.
=====Problem Statement=====
For this challenge, you are given two complex numbers, and you have to print the result of their addition, subtraction, multiplication, division and modulus operations. The real and imaginary precision part should be correct u... | {"inputs": ["2 1\n5 6", "5.9 6\n9 10"], "outputs": ["7.00+7.00i\n-3.00-5.00i\n4.00+17.00i\n0.26-0.11i\n2.24+0.00i\n7.81+0.00i", "14.90+16.00i\n-3.10-4.00i\n-6.90+113.00i\n0.62-0.03i\n8.41+0.00i\n13.45+0.00i"]} | 528 | 170 |
coding | Solve the programming task below in a Python markdown code block.
You are given an array A of N positive integers.
In one operation, you can do the following:
Choose integers i and j (1 ≤ i < j ≤ N), such that A_{i} = A_{j};
For all k (i < k < j), change the value of A_{k} to A_{i}.
Find out whether A can have at mo... | {"inputs": ["4\n5\n5 9 5 5 5\n3\n1 2 3\n4\n1 2 1 3\n4\n1 2 3 1\n"], "outputs": ["YES\nNO\nYES\nYES\n"]} | 582 | 60 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given an array nums that consists of non-negative integers. Let us define rev(x) as the reverse of the non-negative integer x. For example, rev(123) = 321, and rev(120) = 21. A pair of indices (i, j) is nice i... | {"functional": "def check(candidate):\n assert candidate(nums = [42,11,1,97]) == 2\n assert candidate(nums = [13,10,35,24,76]) == 4\n\n\ncheck(Solution().countNicePairs)"} | 179 | 66 |
coding | Solve the programming task below in a Python markdown code block.
In a very ancient country the following game was popular. Two people play the game. Initially first player writes a string s1, consisting of exactly nine digits and representing a number that does not exceed a. After that second player looks at s1 and wr... | {"inputs": ["0 3 3\n", "0 0 1\n", "0 1 1\n", "3 0 3\n", "1 1 1\n", "1 0 3\n", "0 1 3\n", "1 0 7\n"], "outputs": ["2\n", "2\n", "2\n", "1 000000001\n", "2\n", "1 000000001\n", "2\n", "1 000000001\n"]} | 378 | 132 |
coding | Solve the programming task below in a Python markdown code block.
Triangular number is the amount of points that can fill equilateral triangle.
Example: the number 6 is a triangular number because all sides of a triangle has the same amount of points.
```
Hint!
T(n) = n * (n + 1) / 2,
n - is the size of one side.
T(... | {"functional": "_inputs = [[1], [3], [6], [10], [15], [21], [28], [2], [7], [14], [27]]\n_outputs = [[True], [True], [True], [True], [True], [True], [True], [False], [False], [False], [False]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return math.isclose(... | 146 | 221 |
coding | Solve the programming task below in a Python markdown code block.
You will receive an uncertain amount of integers in a certain order ```k1, k2, ..., kn```.
You form a new number of n digits in the following way:
you take one of the possible digits of the first given number, ```k1```, then the same with the given numb... | {"functional": "_inputs = [[23, 17, 89], [22, 22, 22, 22], [230, 15, 8]]\n_outputs = [[[8, 218, 379, 2388]], [[1, 2222]], [[4, 218, 358, 1152]]]\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 isinstan... | 535 | 235 |
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 words consisting of distinct strings.
The string words[i] can be paired with the string words[j] if:
The string words[i] is equal to the reversed string of words[j].
0 <= i < j < words... | {"functional": "def check(candidate):\n assert candidate(words = [\"cd\",\"ac\",\"dc\",\"ca\",\"zz\"]) == 2\n assert candidate(words = [\"ab\",\"ba\",\"cc\"]) == 1\n assert candidate(words = [\"aa\",\"ab\"]) == 0\n\n\ncheck(Solution().maximumNumberOfStringPairs)"} | 134 | 77 |
coding | Solve the programming task below in a Python markdown code block.
Leonardo Fibonacci in a rare portrait of his younger days
I assume you are all familiar with the famous Fibonacci sequence, having to get each number as the sum of the previous two (and typically starting with either `[0,1]` or `[1,1]` as the first numb... | {"functional": "_inputs = [[[1, 1], [0, 1], 2], [[1, 1], [0, 1], 3], [[1, 1], [0, 1], 4], [[3, 5, 2], [0, 1, 2], 4], [[7, 3, 4, 1], [1, 1], 6]]\n_outputs = [[2], [3], [5], [17], [2]]\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_... | 556 | 252 |
coding | Solve the programming task below in a Python markdown code block.
You are given two strings $s$ and $t$, each of length $n$ and consisting of lowercase Latin alphabets. You want to make $s$ equal to $t$.
You can perform the following operation on $s$ any number of times to achieve it — Choose any substring of $s$ a... | {"inputs": ["1\n1\na\na\n", "1\n1\na\na\n", "1\n1\na\nb\n", "1\n1\nb\na\n", "3\n2\naa\naa\n2\nab\nab\n2\nab\nba\n", "3\n2\naa\naa\n2\nab\nab\n2\nab\nba\n", "3\n2\naa\naa\n2\nab\nab\n2\naa\nba\n", "3\n2\naa\naa\n2\nba\nab\n2\naa\nba\n"], "outputs": ["0\n", "0\n", "-1\n", "-1\n", "0\n0\n1\n", "0\n0\n1\n", "0\n0\n-1\n", "... | 661 | 184 |
coding | Solve the programming task below in a Python markdown code block.
Aleksey has $n$ friends. He is also on a vacation right now, so he has $m$ days to play this new viral cooperative game! But since it's cooperative, Aleksey will need one teammate in each of these $m$ days.
On each of these days some friends will be ava... | {"inputs": ["2\n4 6\n1 1\n2 1 2\n3 1 2 3\n4 1 2 3 4\n2 2 3\n1 3\n2 2\n1 1\n1 1\n"], "outputs": ["YES\n1 2 1 1 2 3 \nNO\n"]} | 645 | 83 |
coding | Solve the programming task below in a Python markdown code block.
Dr. S. De teaches computer architecture in NIT Patna. Whenever he comes across any good question(with complexity $k$), he gives that question to students within roll number range $i$ and $j$
At the start of semester he assigns score of $10$ to every stud... | {"inputs": ["1\n5 3\n1 3 5\n2 5 2\n3 4 7"], "outputs": ["202"]} | 596 | 36 |
coding | Solve the programming task below in a Python markdown code block.
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Petya wonders eagerly what minimum... | {"inputs": ["7\n", "4\n", "5\n", "3\n", "1\n", "2\n", "6\n", "9\n"], "outputs": ["7\n", "4\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n"]} | 185 | 70 |
coding | Solve the programming task below in a Python markdown code block.
Read problems statements in Mandarin chinese, Russian and Vietnamese as well.
Today, Chef was trying to solve a problem he found pretty hard: Given an integer N and a triple of integers (a, b, c), compute the number of triples of positive integers (x, ... | {"inputs": ["3\n100 8 23 11\n497296800 1000000 1000000 1000000\n1 1 2 3"], "outputs": ["10\n97800\n1"]} | 499 | 75 |
coding | Solve the programming task below in a Python markdown code block.
A pair of positive integers $(a,b)$ is called special if $\lfloor \frac{a}{b} \rfloor = a mod b$. Here, $\lfloor \frac{a}{b} \rfloor$ is the result of the integer division between $a$ and $b$, while $a mod b$ is its remainder.
You are given two integers... | {"inputs": ["1\n3 1\n", "1\n3 1\n", "9\n8 11\n1 110\n6 3\n69 2\n1 2\n92 79\n8276 17989\n164 789\n6179509 2\n", "9\n8 6\n1 110\n5 3\n36 2\n1 2\n92 420\n8276 17989\n164 789\n16177647 9\n", "9\n8 11\n1 110\n6 3\n36 2\n1 2\n92 92\n8276 17989\n164 789\n20448260 4\n", "9\n8 11\n1 110\n6 3\n36 2\n1 2\n92 79\n8276 17989\n164 7... | 377 | 584 |
coding | Solve the programming task below in a Python markdown code block.
Read problems statements in Mandarin Chinese and Russian.
Aditi recently discovered a new magic trick. First, she gives you an integer N and asks you to think an integer between 1 and N. Then she gives you a bundle of cards each having a sorted list (... | {"inputs": ["2\n1\n4", "2\n1\n3", "2\n2\n4", "2\n2\n8", "2\n4\n4", "2\n2\n7", "2\n4\n8", "2\n8\n8"], "outputs": ["1\n3", "1\n3\n", "2\n3\n", "2\n5\n", "3\n3\n", "2\n4\n", "3\n5\n", "5\n5\n"]} | 676 | 109 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given a positive integer n, find the sum of all integers in the range [1, n] inclusive that are divisible by 3, 5, or 7.
Return an integer denoting the sum of all numbers in the given range satisfying the constraint.
... | {"functional": "def check(candidate):\n assert candidate(n = 7) == 21\n assert candidate(n = 10) == 40\n assert candidate(n = 9) == 30\n\n\ncheck(Solution().sumOfMultiples)"} | 103 | 61 |
coding | Solve the programming task below in a Python markdown code block.
A penguin Rocher has $n$ sticks. He has exactly one stick with length $i$ for all $1 \le i \le n$.
He can connect some sticks. If he connects two sticks that have lengths $a$ and $b$, he gets one stick with length $a + b$. Two sticks, that were used in ... | {"inputs": ["4\n1\n2\n3\n4\n", "4\n1\n2\n3\n8\n", "4\n1\n2\n1\n4\n", "4\n2\n2\n3\n5\n", "4\n1\n2\n4\n4\n", "4\n1\n3\n1\n4\n", "4\n1\n2\n5\n4\n", "4\n1\n3\n3\n5\n"], "outputs": ["1\n1\n2\n2\n", "1\n1\n2\n4\n", "1\n1\n1\n2\n", "1\n1\n2\n3\n", "1\n1\n2\n2\n", "1\n2\n1\n2\n", "1\n1\n3\n2\n", "1\n2\n2\n3\n"]} | 399 | 182 |
coding | Solve the programming task below in a Python markdown code block.
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played.
You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for th... | {"inputs": ["5\n3 0 0 0\n3 3 0 0\n6 4 1 0\n6 3 3 0\n3 3 3 2\n", "5\n3 0 0 0\n3 3 0 0\n6 4 1 0\n6 6 3 0\n3 3 3 2\n", "5\n3 0 0 0\n3 5 0 0\n6 3 1 0\n6 6 3 0\n1 3 3 4\n", "5\n3 0 0 0\n3 3 0 0\n6 4 1 0\n6 6 0 0\n3 3 3 2\n", "5\n5 0 0 0\n3 3 0 0\n6 4 1 0\n6 6 3 0\n3 3 3 4\n", "5\n3 0 0 0\n3 3 0 0\n6 4 1 0\n6 6 3 0\n3 3 3 4\... | 644 | 454 |
coding | Solve the programming task below in a Python markdown code block.
Chef got into a fight with the evil Dr Doof. Dr Doof has decided to destroy all even numbers from the universe using his Evil-Destroy-inator. Chef has $N$ integers with him. To stop Doof, Chef has to find an odd number which is an integer multiple of all... | {"inputs": ["2\n5\n1 2 5 4 3\n1\n7"], "outputs": ["NO\nYES"]} | 419 | 30 |
coding | Solve the programming task below in a Python markdown code block.
You are required to create a simple calculator that returns the result of addition, subtraction, multiplication or division of two numbers.
Your function will accept three arguments:
The first and second argument should be numbers.
The third argument sh... | {"functional": "_inputs = [[6, 2, '+'], [4, 3, '-'], [5, 5, '*'], [5, 4, '/'], [6, '$', '+'], [6, 2, '&'], [4, 3, '\\\\'], ['a', 3, '+'], [6, 2, '='], [6, 2, '\\t'], [':', ',', '+']]\n_outputs = [[8], [1], [25], [1.25], ['unknown value'], ['unknown value'], ['unknown value'], ['unknown value'], ['unknown value'], ['unk... | 188 | 279 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given a binary string s and a positive integer k.
Return the length of the longest subsequence of s that makes up a binary number less than or equal to k.
Note:
The subsequence can contain leading zeroes.
The... | {"functional": "def check(candidate):\n assert candidate(s = \"1001010\", k = 5) == 5\n assert candidate(s = \"00101001\", k = 1) == 6\n\n\ncheck(Solution().longestSubsequence)"} | 138 | 68 |
coding | Solve the programming task below in a Python markdown code block.
You have an array of numbers.
Your task is to sort ascending odd numbers but even numbers must be on their places.
Zero isn't an odd number and you don't need to move it. If you have an empty array, you need to return it.
*Example*
```python
sort_arr... | {"functional": "_inputs = [[[5, 3, 2, 8, 1, 4, 11]], [[2, 22, 37, 11, 4, 1, 5, 0]], [[1, 111, 11, 11, 2, 1, 5, 0]], [[1, 2, 3, 4, 5, 6, 7, 8, 9, 0]], [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]], [[0, 1, 2, 3, 4, 9, 8, 7, 6, 5]]]\n_outputs = [[[1, 3, 2, 8, 5, 4, 11]], [[2, 22, 1, 5, 4, 11, 37, 0]], [[1, 1, 5, 11, 2, 11, 111, 0]], ... | 135 | 482 |
coding | Solve the programming task below in a Python markdown code block.
There are N towers in the town where Ikta lives. Each tower is given a different number from 0 to N-1, and the tower with number i is called tower i. Curious Ikta was interested in the height of the N towers and decided to make a table T showing the magn... | {"inputs": ["1", "3\n0 2\n0 1", "3\n1 2\n0 1", "3\n1 0\n0 2", "3\n1 1\n0 2", "3\n1 1\n1 2", "3\n0 1\n2 2", "3\n1 0\n2 2"], "outputs": ["1", "3\n", "1\n", "1\n", "1\n", "1\n", "1\n", "1\n"]} | 622 | 117 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
There are a row of n houses, each house can be painted with one of the k colors. The cost of painting each house with a certain color is different. You have to paint all the houses such that no two adjacent houses hav... | {"functional": "def check(candidate):\n assert candidate(costs = [[1,5,3],[2,9,4]]) == 5\n assert candidate(costs = [[1,3],[2,4]]) == 5\n\n\ncheck(Solution().minCostII)"} | 176 | 62 |
coding | Solve the programming task below in a Python markdown code block.
Read problems statements in Mandarin chinese, Russian and Vietnamese as well.
Chef Tobby is trying to run a code given to him by Bhuvan for an experiment they want to include in the manuscript to be submitted to a conference. The deadline to submit the... | {"inputs": ["1\n2 2\n3 1", "1\n7 3\n3 7 5 4 6 2 1"], "outputs": ["1", "0"]} | 628 | 44 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given a 0-indexed string s consisting of only lowercase English letters. In one operation, you can change any character of s to any other character.
Return true if you can make s a palindrome after performing ... | {"functional": "def check(candidate):\n assert candidate(s = \"abcdba\") == True\n assert candidate(s = \"aa\") == True\n assert candidate(s = \"abcdef\") == False\n\n\ncheck(Solution().makePalindrome)"} | 102 | 53 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given two strings sentence1 and sentence2, each representing a sentence composed of words. A sentence is a list of words that are separated by a single space with no leading or trailing spaces. Each word consi... | {"functional": "def check(candidate):\n assert candidate(sentence1 = \"My name is Haley\", sentence2 = \"My Haley\") == True\n assert candidate(sentence1 = \"of\", sentence2 = \"A lot of words\") == False\n assert candidate(sentence1 = \"Eating right now\", sentence2 = \"Eating\") == True\n assert candidate... | 276 | 109 |
coding | Solve the programming task below in a Python markdown code block.
## Number of people in the bus
There is a bus moving in the city, and it takes and drop some people in each bus stop.
You are provided with a list (or array) of integer arrays (or tuples). Each integer array has two items which represent number of peopl... | {"functional": "_inputs = [[[[10, 0], [3, 5], [5, 8]]], [[[3, 0], [9, 1], [4, 10], [12, 2], [6, 1], [7, 10]]], [[[3, 0], [9, 1], [4, 8], [12, 2], [6, 1], [7, 8]]], [[[0, 0]]]]\n_outputs = [[5], [17], [21], [0]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n re... | 238 | 267 |
coding | Solve the programming task below in a Python markdown code block.
Caisa is going to have a party and he needs to buy the ingredients for a big chocolate cake. For that he is going to the biggest supermarket in town.
Unfortunately, he has just s dollars for sugar. But that's not a reason to be sad, because there are n ... | {"inputs": ["1 2\n1 0\n", "1 2\n5 0\n", "1 9\n9 0\n", "1 1\n1 0\n", "1 9\n9 1\n", "1 2\n2 1\n", "1 1\n1 0\n", "1 2\n5 0\n"], "outputs": ["0\n", "-1\n", "0\n", "0\n", "-1\n", "-1\n", "0\n", "-1\n"]} | 465 | 118 |
coding | Solve the programming task below in a Python markdown code block.
Consider a playoff tournament where $2^n$ athletes compete. The athletes are numbered from $1$ to $2^n$.
The tournament is held in $n$ stages. In each stage, the athletes are split into pairs in such a way that each athlete belongs exactly to one pair. ... | {"inputs": ["2\n3\n1\n", "9\n2\n2\n2\n2\n2\n2\n2\n2\n2\n", "30\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n25\n26\n27\n28\n29\n30\n", "30\n30\n30\n30\n30\n30\n30\n30\n30\n30\n30\n30\n30\n30\n30\n30\n30\n30\n30\n30\n30\n30\n30\n30\n30\n30\n30\n30\n30\n30\n30\n"], "outputs": ["... | 517 | 763 |
coding | Solve the programming task below in a Python markdown code block.
In the beginning of the new year Keivan decided to reverse his name. He doesn't like palindromes, so he changed Naviek to Navick.
He is too selfish, so for a given n he wants to obtain a string of n characters, each of which is either 'a', 'b' or 'c', w... | {"inputs": ["2\n", "3\n", "1\n", "6\n", "4\n", "6\n", "1\n", "3\n"], "outputs": ["aa\n", "aab\n", "a\n", "aabbaa\n", "aabb\n", "aabbaa\n", "a\n", "aab\n"]} | 236 | 75 |
coding | Solve the programming task below in a Python markdown code block.
There are N people standing in a row from west to east. Each person is facing east or west. The directions of the people is given as a string S of length N. The i-th person from the west is facing east if S_i = `E`, and west if S_i = `W`.
You will appoi... | {"inputs": ["5\nWWEEW", "5\nEWEWW", "5\nWWEWE", "5\nWEWEW", "5\nWEWWE", "5\nEWWWE", "5\nEWWEW", "5\nWWWEE"], "outputs": ["2\n", "1\n", "2\n", "2\n", "2\n", "1\n", "1\n", "2\n"]} | 275 | 93 |
coding | Solve the programming task below in a Python markdown code block.
Coding decimal numbers with factorials is a way of writing out numbers
in a base system that depends on factorials, rather than powers of numbers.
In this system, the last digit is always `0` and is in base 0!. The digit before that is either `0 or 1` ... | {"functional": "_inputs = [[463], [2982], [36288000]]\n_outputs = [['341010'], ['4041000'], ['A0000000000']]\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... | 392 | 201 |
coding | Solve the programming task below in a Python markdown code block.
A very passive-aggressive co-worker of yours was just fired. While he was gathering his things, he quickly inserted a bug into your system which renamed everything to what looks like jibberish. He left two notes on his desk, one reads: "ABCDEFGHIJKLMNOPQ... | {"functional": "_inputs = [['Ifmmp'], ['Uif usjdl up uijt lbub jt tjnqmf'], [45], ['XiBu BcPvU dSbAz UfYu'], [['Hello there', 'World']], ['BMM DBQT NBZCF'], ['qVAamFt BsF gVo'], ['CodeWars RockZ'], [''], ['J ipqf zpv bsf ibwjoh b ojdf ebz']]\n_outputs = [['Hello'], ['The trick to this kata is simple'], ['Input is not a... | 204 | 328 |
coding | Solve the programming task below in a Python markdown code block.
Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Chef wants to give a gift to Chefina to celebrate their anniversary. Of course, he has a sequence $a_{1}, a_{2}, \ldots, a_{N}$ ready for this occasi... | {"inputs": ["1\n4\n2 3 4 5"], "outputs": ["3"]} | 531 | 22 |
coding | Solve the programming task below in a Python markdown code block.
Chef is the event manager of his college. He has been assigned the task to manage the upcoming tech fest. There are $K$ rooms where the event can take place, and at a particular time only one event can be organized in a room for a particular time interva... | {"inputs": ["1\n4 2\n1 10 1\n10 20 2\n15 50 2\n20 30 2"], "outputs": ["3"]} | 468 | 47 |
coding | Solve the programming task below in a Python markdown code block.
HQ9+ is a joke programming language which has only four one-character instructions:
* "H" prints "Hello, World!",
* "Q" prints the source code of the program itself,
* "9" prints the lyrics of "99 Bottles of Beer" song,
* "+" increments the val... | {"inputs": ["Q\n", "~\n", "8\n", "H\n", "!\n", "9\n", "3\n", "+\n"], "outputs": ["YES\n", "NO\n", "NO\n", "YES\n", "NO\n", "YES\n", "NO\n", "NO\n"]} | 280 | 70 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.