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.
In this Kata we are passing a number (n) into a function.
Your code will determine if the number passed is even (or not).
The function needs to return either a true or false.
Numbers may be positive or negative, integers or floats.
Floats are cons... | {"functional": "_inputs = [[0], [0.5], [1], [2], [-4], [15], [20], [220], [222222221], [500000000]]\n_outputs = [[True], [False], [False], [True], [True], [False], [True], [True], [False], [True]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return math.iscl... | 98 | 230 |
coding | Solve the programming task below in a Python markdown code block.
Each of you probably has your personal experience of riding public transportation and buying tickets. After a person buys a ticket (which traditionally has an even number of digits), he usually checks whether the ticket is lucky. Let us remind you that a... | {"inputs": ["1\n33\n", "1\n09\n", "1\n10\n", "1\n50\n", "1\n13\n", "1\n80\n", "1\n25\n", "1\n24\n"], "outputs": ["NO\n", "YES\n", "YES\n", "YES\n", "YES\n", "YES\n", "YES\n", "YES\n"]} | 492 | 94 |
coding | Solve the programming task below in a Python markdown code block.
For an array b of length m we define the function f as
f(b) = \begin{cases} b[1] & if m = 1 \\\ f(b[1] ⊕ b[2],b[2] ⊕ b[3],...,b[m-1] ⊕ b[m]) & otherwise, \end{cases}
where ⊕ is [bitwise exclusive OR](https://en.wikipedia.org/wiki/Bitwise_opera... | {"inputs": ["3\n5 4 1\n2\n2 3\n1 2\n", "3\n5 4 0\n2\n2 3\n1 2\n", "3\n2 4 0\n2\n2 3\n1 2\n", "3\n5 7 1\n2\n2 3\n1 2\n", "3\n2 4 1\n2\n2 3\n1 3\n", "3\n6 4 1\n2\n2 3\n1 3\n", "3\n8 8 1\n2\n2 3\n1 2\n", "3\n5 3 1\n2\n2 3\n1 2\n"], "outputs": ["5\n5\n", "4\n5\n", "4\n6\n", "7\n7\n", "5\n6\n", "5\n7\n", "9\n8\n", "3\n6\n"]... | 513 | 214 |
coding | Solve the programming task below in a Python markdown code block.
Johnny drives a truck and must deliver a package from his hometown to the district center. His hometown is located at point 0 on a number line, and the district center is located at the point d.
Johnny's truck has a gas tank that holds exactly n liters,... | {"inputs": ["16 5 2\n8 2\n5 1\n", "16 5 2\n8 2\n2 1\n", "16 5 2\n8 2\n5 1\n", "153 8 1\n96 83995\n", "200 8 1\n96 83995\n", "153 40 1\n96 83995\n", "153 11 1\n96 83995\n", "153 11 1\n96 74103\n"], "outputs": ["-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n"]} | 523 | 188 |
coding | Solve the programming task below in a Python markdown code block.
N problems are proposed for an upcoming contest. Problem i has an initial integer score of A_i points.
M judges are about to vote for problems they like. Each judge will choose exactly V problems, independently from the other judges, and increase the sc... | {"inputs": ["6 1 2 2\n2 1 1 5 0 2", "6 1 5 2\n2 1 1 3 1 2", "6 1 2 2\n2 1 1 5 0 0", "6 1 2 4\n2 1 1 5 0 0", "6 1 5 1\n3 1 1 3 0 2", "6 1 2 1\n1 1 1 5 0 2", "6 1 5 2\n2 0 1 3 1 2", "6 1 2 4\n2 1 1 2 0 0"], "outputs": ["5\n", "3\n", "4\n", "6\n", "2\n", "1\n", "3\n", "6\n"]} | 349 | 206 |
coding | Solve the programming task below in a Python markdown code block.
We have one slime.
You can set the health of this slime to any integer value of your choice.
A slime reproduces every second by spawning another slime that has strictly less health. You can freely choose the health of each new slime. The first reproducti... | {"inputs": ["1\n1 1\n", "2\n4 2 3 1\n", "2\n1 2 3 1\n", "5\n4 3 5 3 1 2 7 8 7 4 6 3 7 2 3 6 2 7 3 2 6 7 3 4 6 7 3 4 2 5 2 3\n"], "outputs": ["No\n", "Yes\n", "Yes\n", "No\n"]} | 449 | 122 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given an integer array nums and an integer k, return the maximum length of a subarray that sums to k. If there is not one, return 0 instead.
Please complete the following python code precisely:
```python
class Solut... | {"functional": "def check(candidate):\n assert candidate(nums = [1,-1,5,-2,3], k = 3) == 4\n assert candidate(nums = [-2,-1,2,1], k = 1) == 2\n\n\ncheck(Solution().maxSubArrayLen)"} | 88 | 69 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Alice and Bob take turns playing a game, with Alice starting first.
You are given a string num of even length consisting of digits and '?' characters. On each turn, a player will do the following if there is still at ... | {"functional": "def check(candidate):\n assert candidate(num = \"5023\") == False\n assert candidate(num = \"25??\") == True\n assert candidate(num = \"?3295???\") == False\n\n\ncheck(Solution().sumGame)"} | 275 | 63 |
coding | Solve the programming task below in a Python markdown code block.
You're re-designing a blog and the blog's posts have the following format for showing the date and time a post was made:
*Weekday* *Month* *Day*, *time*
e.g.,
Friday May 2, 7pm
You're running out of screen real estate, and on some pages you want to d... | {"functional": "_inputs = [['Monday February 2, 8pm'], ['Tuesday May 29, 8pm'], ['Wed September 1, 3am'], ['Friday May 2, 9am'], ['Tuesday January 29, 10pm']]\n_outputs = [['Monday February 2'], ['Tuesday May 29'], ['Wed September 1'], ['Friday May 2'], ['Tuesday January 29']]\nimport math\ndef _deep_eq(a, b, tol=1e-5)... | 197 | 235 |
coding | Solve the programming task below in a Python markdown code block.
ZCO is approaching, and you want to be well prepared!
There are $N$ topics to cover and the $i^{th}$ topic takes $H_i$ hours to prepare (where $1 \le i \le N$). You have only $M$ days left to prepare, and you want to utilise this time wisely. You know ... | {"inputs": ["2\n5 4 10\n10 24 30 19 40\n5 4 16\n7 16 35 10 15"], "outputs": ["2\n4"]} | 594 | 57 |
coding | Solve the programming task below in a Python markdown code block.
For this exercise you will create a global flatten method. The method takes in any number of arguments and flattens them into a single array. If any of the arguments passed in are an array then the individual objects within the array will be flattened so... | {"functional": "_inputs = [[1, 2, 3], [1, 2], [5, 'string'], [-4.5, -3, 1, 4], [[3, 4, 5], [1, 2, 3]], [[1], [], 2, [4, 5, 6]], [[4, 'string', 9, 3, 1], [], [], [], [], ['string']], [1, 2, ['9', [], []], None], [[1, 2], [3, 4, 5], [6, [7], [[8]]]], [['hello', 2, ['text', [4, 5]]], [[]], '[list]']]\n_outputs = [[[1, 2, ... | 226 | 442 |
coding | Solve the programming task below in a Python markdown code block.
MoEngage has given you an array A consisting of N positive integers.
You should perform Q queries of the following two types:
1 i X : Set A_{i} to X.
2 L R : Find the minimum non-negative integer K such that the sequence [|A_{L} - K|, |A_{L+1} - K|, \l... | {"inputs": ["5 7\n5 3 2 6 0\n2 1 5\n1 2 7\n2 1 5\n1 4 2\n2 1 5\n1 2 5\n2 1 2"], "outputs": ["4\n-1\n5\n0\n"]} | 561 | 74 |
coding | Solve the programming task below in a Python markdown code block.
Little Elephant likes lemonade.
When Little Elephant visits any room, he finds the bottle of the lemonade in that room that contains the greatest number of litres of lemonade and drinks it all.
There are n rooms (numbered from 0 to n-1), each contains ... | {"inputs": ["2\n3 3\n0 2 1\n3 1 2 3\n1 7\n2 4 7\n4 7\n0 1 3 0 1 0 0\n1 7\n3 9 4 5\n7 1 2 3 4 5 6 7\n1 1", "2\n3 3\n0 2 1\n3 1 2 3\n1 7\n2 4 7\n4 7\n0 1 2 0 1 0 0\n1 7\n3 9 4 5\n7 1 2 3 4 5 6 7\n1 1", "2\n3 3\n0 2 1\n3 1 2 3\n1 7\n2 4 7\n4 7\n0 1 2 0 2 0 0\n1 7\n3 9 4 5\n7 2 2 3 4 5 6 7\n1 1", "2\n3 3\n0 2 1\n3 1 2 3\n1... | 426 | 717 |
coding | Solve the programming task below in a Python markdown code block.
For a positive integer M, MoEngage defines \texttt{digitSum(M)} as the sum of digits of the number M (when written in decimal).
For example, \texttt{digitSum(1023)} = 1 + 0 + 2 + 3 = 6.
Given a positive integer N, find the smallest integer X strictly ... | {"inputs": ["3\n123\n19\n509"], "outputs": ["124\n21\n511"]} | 533 | 32 |
coding | Solve the programming task below in a Python markdown code block.
Your goal is to return multiplication table for ```number``` that is always an integer from 1 to 10.
For example, a multiplication table (string) for ```number == 5``` looks like below:
```
1 * 5 = 5
2 * 5 = 10
3 * 5 = 15
4 * 5 = 20
5 * 5 = 25
6 * 5 = ... | {"functional": "_inputs = [[5], [1]]\n_outputs = [['1 * 5 = 5\\n2 * 5 = 10\\n3 * 5 = 15\\n4 * 5 = 20\\n5 * 5 = 25\\n6 * 5 = 30\\n7 * 5 = 35\\n8 * 5 = 40\\n9 * 5 = 45\\n10 * 5 = 50'], ['1 * 1 = 1\\n2 * 1 = 2\\n3 * 1 = 3\\n4 * 1 = 4\\n5 * 1 = 5\\n6 * 1 = 6\\n7 * 1 = 7\\n8 * 1 = 8\\n9 * 1 = 9\\n10 * 1 = 10']]\nimport math... | 192 | 347 |
coding | Solve the programming task below in a Python markdown code block.
In this kata, your task is to identify the pattern underlying a sequence of numbers. For example, if the sequence is [1, 2, 3, 4, 5], then the pattern is [1], since each number in the sequence is equal to the number preceding it, plus 1. See the test cas... | {"functional": "_inputs = [[[1, 2, 3, 4, 5]], [[1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1]], [[1, 5, 2, 3, 1, 5, 2, 3, 1]], [[1, 5, 4, 8, 7, 11, 10, 14, 13]], [[0, 1]], [[4, 5, 6, 8, 3, 4, 5, 6, 8, 3, 4, 5, 6, 8, 3, 4]], [[4, 5, 3, -2, -1, 0, -2, -7, -6]], [[4, 5, 6, 5, 3, 2, 3, 4, 5, 6, 5, 3, 2, 3, 4, 5, 6, 5,... | 175 | 771 |
coding | Solve the programming task below in a Python markdown code block.
The aim of this Kata is to write a function which will reverse the case of all consecutive duplicate letters in a string. That is, any letters that occur one after the other and are identical.
If the duplicate letters are lowercase then they must be se... | {"functional": "_inputs = [['hello world'], ['HELLO WORLD'], ['HeLlo World'], ['WWW'], ['parallel universe'], ['shhh'], ['bookkeeper']]\n_outputs = [['heLLo world'], ['HEllO WORLD'], ['HeLlo World'], ['www'], ['paraLLel universe'], ['sHHH'], ['bOOKKEEper']]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance... | 188 | 216 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
This question is about implementing a basic elimination algorithm for Candy Crush.
Given an m x n integer array board representing the grid of candy where board[i][j] represents the type of candy. A value of board[i][... | {"functional": "def check(candidate):\n assert candidate(board = [[110,5,112,113,114],[210,211,5,213,214],[310,311,3,313,314],[410,411,412,5,414],[5,1,512,3,3],[610,4,1,613,614],[710,1,2,713,714],[810,1,2,1,1],[1,1,2,2,2],[4,1,4,4,1014]]) == [[0,0,0,0,0],[0,0,0,0,0],[0,0,0,0,0],[110,0,0,0,114],[210,0,0,0,214],[310,0... | 290 | 443 |
coding | Solve the programming task below in a Python markdown code block.
Vera adores poems. All the poems Vera knows are divided into quatrains (groups of four lines) and in each quatrain some lines contain rhymes.
Let's consider that all lines in the poems consist of lowercase Latin letters (without spaces). Letters "a", "e... | {"inputs": ["1 1\na\ne\ne\na\n", "1 1\ne\na\ne\na\n", "1 1\na\ne\ne\ne\n", "1 1\ne\ne\ne\ne\n", "1 1\na\na\na\na\n", "1 1\na\ne\na\ne\n", "1 1\na\na\na\ne\n", "1 1\ne\na\ne\ne\n"], "outputs": ["abba\n", "abab\n", "NO\n", "aaaa\n", "aaaa\n", "abab\n", "NO\n", "NO\n"]} | 688 | 153 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You have n coins and you want to build a staircase with these coins. The staircase consists of k rows where the ith row has exactly i coins. The last row of the staircase may be incomplete.
Given the integer n, return... | {"functional": "def check(candidate):\n assert candidate(n = 5) == 2\n assert candidate(n = 8) == 3\n\n\ncheck(Solution().arrangeCoins)"} | 105 | 44 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given an array of integers nums. Perform the following steps:
Find any two adjacent numbers in nums that are non-coprime.
If no such numbers are found, stop the process.
Otherwise, delete the two numbers and ... | {"functional": "def check(candidate):\n assert candidate(nums = [6,4,3,2,7,6,2]) == [12,7,6]\n assert candidate(nums = [2,2,1,1,3,3,3]) == [2,1,1,3]\n\n\ncheck(Solution().replaceNonCoprimes)"} | 217 | 83 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given a 0-indexed m x n integer matrix grid. The width of a column is the maximum length of its integers.
For example, if grid = [[-10], [3], [12]], the width of the only column is 3 since -10 is of length 3.... | {"functional": "def check(candidate):\n assert candidate(grid = [[1],[22],[333]]) == [3]\n assert candidate(grid = [[-15,1,3],[15,7,12],[5,6,-2]]) == [3,1,2]\n\n\ncheck(Solution().findColumnWidth)"} | 162 | 77 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given an integer hoursBefore, the number of hours you have to travel to your meeting. To arrive at your meeting, you have to travel through n roads. The road lengths are given as an integer array dist of lengt... | {"functional": "def check(candidate):\n assert candidate(dist = [1,3,2], speed = 4, hoursBefore = 2) == 1\n assert candidate(dist = [7,3,5,5], speed = 2, hoursBefore = 10) == 2\n assert candidate(dist = [7,3,5,5], speed = 1, hoursBefore = 10) == -1\n\n\ncheck(Solution().minSkips)"} | 364 | 107 |
coding | Solve the programming task below in a Python markdown code block.
Jack is working on his jumping skills recently. Currently he's located at point zero of the number line. He would like to get to the point x. In order to train, he has decided that he'll first jump by only one unit, and each subsequent jump will be exact... | {"inputs": ["3\n", "1\n", "2\n", "0\n", "6\n", "-2\n", "-5\n", "-8\n"], "outputs": ["2\n", "1\n", "3\n", "0\n", "3\n", "3\n", "5\n", "4\n"]} | 163 | 70 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given a string representing a code snippet, implement a tag validator to parse the code and return whether it is valid.
A code snippet is valid if all the following rules hold:
The code must be wrapped in a valid clo... | {"functional": "def check(candidate):\n assert candidate(code = \"<DIV>This is the first line <![CDATA[<div>]]></DIV>\") == True\n assert candidate(code = \"<DIV>>> ![cdata[]] <![CDATA[<div>]>]]>]]>>]</DIV>\") == True\n assert candidate(code = \"<A> <B> </A> </B>\") == False\n\n\ncheck(Solution().isValid)"... | 418 | 101 |
coding | Solve the programming task below in a Python markdown code block.
Find the closest prime number under a certain integer ```n``` that has the maximum possible amount of even digits.
For ```n = 1000```, the highest prime under ```1000``` is ```887```, having two even digits (8 twice)
Naming ```f()```, the function that... | {"functional": "_inputs = [[1000], [10000], [500], [487]]\n_outputs = [[887], [8887], [487], [467]]\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) != l... | 241 | 191 |
coding | Solve the programming task below in a Python markdown code block.
You are given two strings A and B of length N consisting of lowercase English letters. Your objective is to make both the strings equal.
You can apply one of the following 2 operations at each index i:
Convert char A_{i} to B_{i} by doing right cyclic s... | {"inputs": ["4\n3\nabb\nbaz\n3\nzzc\naaa\n4\nfxbs\ndkrc\n5\neaufq\ndrtkn\n"], "outputs": ["2\n0\n11\n9\n"]} | 723 | 53 |
coding | Solve the programming task below in a Python markdown code block.
You have N rods with you. The i-th rod has a length of A_{i} and a beauty of B_{i}.
You'd like to arrange these rods side-by-side in some order on the number line, starting from 0.
Let x_{i} be the starting position of the i-th rod in an arrangement.... | {"inputs": ["2\n2\n1 2\n4 6\n4\n2 8 9 11\n25 27 100 45"], "outputs": ["8\n2960"]} | 600 | 51 |
coding | Solve the programming task below in a Python markdown code block.
\textit {Life is change, change is stability.}
Chef calls a sequence of integers A_{1}, A_{2}, \ldots, A_{N} stable if all the elements in the sequence are equal.
Chef gives you a sequence A_{1}, A_{2}, \ldots, A_{N}. You may perform the following ope... | {"inputs": ["2\n3\n1 1 1\n2\n69 96"], "outputs": ["0\n1"]} | 568 | 30 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given a digit string s, return the number of unique substrings of s where every digit appears the same number of times.
Please complete the following python code precisely:
```python
class Solution:
def equalDig... | {"functional": "def check(candidate):\n assert candidate(s = \"1212\") == 5\n assert candidate(s = \"12321\") == 9\n\n\ncheck(Solution().equalDigitFrequency)"} | 73 | 51 |
coding | Solve the programming task below in a Python markdown code block.
You are given a sequence $a$ consisting of $n$ integers $a_1, a_2, \dots, a_n$, and an integer $x$. Your task is to make the sequence $a$ sorted (it is considered sorted if the condition $a_1 \le a_2 \le a_3 \le \dots \le a_n$ holds).
To make the sequen... | {"inputs": ["3\n5 1\n5 21 8 7 9\n6 3\n2 3 7 2 18 7\n8 7\n2 21 9 7 7 14 2 3\n", "3\n5 1\n5 21 8 7 9\n6 3\n2 3 7 2 18 7\n8 7\n2 11 9 7 7 14 2 3\n", "3\n5 1\n5 21 8 7 9\n6 3\n2 3 7 2 18 7\n8 7\n2 11 9 7 7 14 3 3\n", "3\n5 1\n5 21 8 7 9\n6 3\n2 3 7 2 18 7\n8 7\n2 11 9 7 6 14 3 3\n", "3\n5 12\n5 15 8 7 9\n6 3\n2 3 7 2 18 7\... | 653 | 555 |
coding | Solve the programming task below in a Python markdown code block.
There are N points on X-Y plane with integer coordinates (xi, yi). You are given a set of polygons with all of its edges parallel to the axes (in other words, all angles of the polygons are 90 degree angles and all lines are in the cardinal directions. T... | {"inputs": ["6 1\n1 1\n3 3\n3 5\n5 2\n6 3\n7 4\n10\n1 3\n1 6\n4 6\n4 3\n6 3\n6 1\n4 1\n4 2\n3 2\n3 3\n", "16 2\n0 0\n0 1\n0 2\n0 3\n1 0\n1 1\n1 2\n1 3\n2 0\n2 1\n2 2\n2 3\n3 0\n3 1\n3 2\n3 3\n8\n0 0\n0 1\n1 1\n1 2\n0 2\n0 3\n3 3\n3 0\n4\n0 0\n0 1\n1 1\n1 0\n"], "outputs": ["4\n", "16\n4\n"]} | 600 | 213 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given an array of n integers nums and an integer target, find the number of index triplets i, j, k with 0 <= i < j < k < n that satisfy the condition nums[i] + nums[j] + nums[k] < target.
Please complete the followi... | {"functional": "def check(candidate):\n assert candidate(nums = [-2,0,1,3], target = 2) == 2\n assert candidate(nums = [], target = 0) == 0\n assert candidate(nums = [0], target = 0) == 0\n\n\ncheck(Solution().threeSumSmaller)"} | 108 | 76 |
coding | Solve the programming task below in a Python markdown code block.
After celebrating the midcourse the students of one of the faculties of the Berland State University decided to conduct a vote for the best photo. They published the photos in the social network and agreed on the rules to choose a winner: the photo which... | {"inputs": ["1\n5\n", "1\n1\n", "1\n5\n", "1\n1\n", "1\n3\n", "1\n2\n", "1\n4\n", "1\n7\n"], "outputs": ["5\n", "1\n", "5", "1", "3\n", "2\n", "4\n", "7\n"]} | 373 | 84 |
coding | Solve the programming task below in a Python markdown code block.
In elementary arithmetic a "carry" is a digit that is transferred from one column of digits to another column of more significant digits during a calculation algorithm.
This Kata is about determining the number of carries performed during the addition o... | {"functional": "_inputs = [['123 456\\n555 555\\n123 594'], ['321 679\\n098 805\\n123 867'], ['123 457\\n631 372\\n999 111'], ['123 457\\n123 456\\n654 312\\n999 000\\n123 457'], ['1 9\\n123456789 111111101\\n01 09\\n11 09\\n123 457'], ['99 99']]\n_outputs = [['No carry operation\\n3 carry operations\\n1 carry operatio... | 225 | 430 |
coding | Solve the programming task below in a Python markdown code block.
Where do odds begin, and where do they end? Where does hope emerge, and will they ever break?
Given an integer sequence a_1, a_2, ..., a_{n} of length n. Decide whether it is possible to divide it into an odd number of non-empty subsegments, the each of... | {"inputs": ["1\n1\n", "1\n0\n", "1\n0\n", "1\n1\n", "1\n-2\n", "2\n1 1\n", "2\n1 1\n", "2\n0 1\n"], "outputs": ["Yes\n", "No\n", "No\n", "Yes\n", "No\n", "No\n", "No\n", "No\n"]} | 466 | 93 |
coding | Solve the programming task below in a Python markdown code block.
There are N items, numbered 1, 2, \ldots, N. For each i (1 \leq i \leq N), Item i has a weight of w_i and a value of v_i.
Taro has decided to choose some of the N items and carry them home in a knapsack. The capacity of the knapsack is W, which means th... | {"inputs": ["2 1\n3 6\n0 97\n8 96", "2 31\n2 4\n1 28\n1 5", "2 1\n1 6\n0 50\n4 96", "3 8\n3 30\n4 35\n5 60", "3 8\n3 30\n4 35\n5 78", "3 8\n3 30\n0 35\n5 78", "2 8\n3 30\n4 50\n5 60", "3 10\n3 30\n0 6\n5 78"], "outputs": ["97\n", "32\n", "56\n", "90\n", "108\n", "143\n", "80\n", "114\n"]} | 346 | 206 |
coding | Solve the programming task below in a Python markdown code block.
## Story
Your company migrated the last 20 years of it's *very important data* to a new platform, in multiple phases. However, something went wrong: some of the essential time-stamps were messed up! It looks like that some servers were set to use the `d... | {"functional": "_inputs = [[[]]]\n_outputs = [[[0, 0, 0]]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return math.isclose(a, b, rel_tol=tol, abs_tol=tol)\n if isinstance(a, (list, tuple)):\n if len(a) != len(b): return False\n return all(_... | 445 | 160 |
coding | Solve the programming task below in a Python markdown code block.
Create a function xMasTree(height) that returns a christmas tree of the correct height. The height is passed through to the function and the function should return a list containing each line of the tree.
```
xMasTree(5) should return : ['____#____', '_... | {"functional": "_inputs = [[3], [7], [2], [4], [6]]\n_outputs = [[['__#__', '_###_', '#####', '__#__', '__#__']], [['______#______', '_____###_____', '____#####____', '___#######___', '__#########__', '_###########_', '#############', '______#______', '______#______']], [['_#_', '###', '_#_', '_#_']], [['___#___', '__#... | 334 | 301 |
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 ai and power level bi. When the i-th beacon is activated, it destroys all beacons to its left (direction of decreasing coordinates) within distance bi inclus... | {"inputs": ["1\n0 1\n", "1\n0 2\n", "1\n1 2\n", "1\n0 4\n", "1\n1 1\n", "1\n2 1\n", "1\n2 2\n", "1\n4 2\n"], "outputs": ["0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n"]} | 454 | 102 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given an array of variable pairs equations and an array of real numbers values, where equations[i] = [Ai, Bi] and values[i] represent the equation Ai / Bi = values[i]. Each Ai or Bi is a string that represents... | {"functional": "def check(candidate):\n assert candidate(equations = [[\"a\",\"b\"],[\"b\",\"c\"]], values = [2.0,3.0], queries = [[\"a\",\"c\"],[\"b\",\"a\"],[\"a\",\"e\"],[\"a\",\"a\"],[\"x\",\"x\"]]) == [6.00000,0.50000,-1.00000,1.00000,-1.00000]\n assert candidate(equations = [[\"a\",\"b\"],[\"b\",\"c\"],[\"b... | 229 | 313 |
coding | Solve the programming task below in a Python markdown code block.
Vasya plays Robot Bicorn Attack.
The game consists of three rounds. For each one a non-negative integer amount of points is given. The result of the game is the sum of obtained points. Vasya has already played three rounds and wrote obtained points one ... | {"inputs": ["1\n", "0\n", "2\n", "55\n", "99\n", "93\n", "13\n", "84\n"], "outputs": ["-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n"]} | 373 | 76 |
coding | Solve the programming task below in a Python markdown code block.
Ronald's uncle left him 3 fertile chickens in his will. When life gives you chickens, you start a business selling chicken eggs which is exactly what Ronald decided to do.
A chicken lays 300 eggs in its first year. However, each chicken's egg productio... | {"functional": "_inputs = [[0, 5], [2, 1], [4, 8], [74, 10], [1, 15]]\n_outputs = [['No chickens yet!'], [900], [2655], [3984], [900]]\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, (lis... | 315 | 210 |
coding | Solve the programming task below in a Python markdown code block.
We have a grid with N rows and M columns of squares. Initially, all the squares are white.
There is a button attached to each row and each column. When a button attached to a row is pressed, the colors of all the squares in that row are inverted; that i... | {"inputs": ["4 2 2", "4 2 1", "7 9 8", "2 5 8", "6 2 2", "1 5 8", "2 3 2", "2 1 8"], "outputs": ["Yes\n", "No\n", "No\n", "Yes\n", "Yes\n", "No\n", "Yes\n", "No\n"]} | 251 | 94 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
A valid cut in a circle can be:
A cut that is represented by a straight line that touches two points on the edge of the circle and passes through its center, or
A cut that is represented by a straight line that touch... | {"functional": "def check(candidate):\n assert candidate(n = 4) == 2\n assert candidate(n = 3) == 3\n\n\ncheck(Solution().numberOfCuts)"} | 140 | 44 |
coding | Solve the programming task below in a Python markdown code block.
Vitaly is a diligent student who never missed a lesson in his five years of studying in the university. He always does his homework on time and passes his exams in time.
During the last lesson the teacher has provided two strings s and t to Vitaly. The... | {"inputs": ["y\nz\n", "a\nz\n", "q\nz\n", "x\nz\n", "a\nb\n", "w\nz\n", "p\nz\n", "b\nc\n"], "outputs": ["No such string", "b", "r", "y", "No such string", "x\n", "q\n", "No such string\n"]} | 392 | 87 |
coding | Solve the programming task below in a Python markdown code block.
Chef solved so many hard questions, now he wants to solve some easy problems for refreshment. Chef asks Cheffina for the new question. Cheffina challenges the chef to print the total number of 0's in the binary representation of N(natural number).
-----... | {"inputs": ["2\n2\n4"], "outputs": ["1\n2"]} | 235 | 18 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Alice and Bob have a different total number of candies. You are given two integer arrays aliceSizes and bobSizes where aliceSizes[i] is the number of candies of the ith box of candy that Alice has and bobSizes[j] is t... | {"functional": "def check(candidate):\n assert candidate(aliceSizes = [1,1], bobSizes = [2,2]) == [1,2]\n assert candidate(aliceSizes = [1,2], bobSizes = [2,3]) == [1,2]\n assert candidate(aliceSizes = [2], bobSizes = [1,3]) == [2,3]\n assert candidate(aliceSizes = [1,2,5], bobSizes = [2,4]) == [5,4]\n\n\nc... | 237 | 129 |
coding | Solve the programming task below in a Python markdown code block.
The educational program (AHK Education) of the Aiz Broadcasting Association broadcasts a handicraft program for children, "Play with Tsukuro". Today is the time to make a rectangle with sticks, but I would like to see if I can make a rectangle using the ... | {"inputs": ["0 1 2 2", "0 0 2 2", "2 0 1 2", "1 1 0 4", "2 0 2 2", "1 1 0 6", "2 0 2 4", "0 1 0 6"], "outputs": ["no\n", "yes\n", "no\n", "no\n", "no\n", "no\n", "no\n", "no\n"]} | 262 | 110 |
coding | Solve the programming task below in a Python markdown code block.
Nagase is a top student in high school. One day, she's analyzing some properties of special sets of positive integers.
She thinks that a set S = \\{a_{1}, a_{2}, ..., a_{N}\\} of distinct positive integers is called special if for all 1 \leq i \leq N, t... | {"inputs": ["3", "4"], "outputs": ["2 5 63", "2 5 20 63"]} | 362 | 31 |
coding | Solve the programming task below in a Python markdown code block.
You are participating in a contest which has $11$ problems (numbered $1$ through $11$). The first eight problems (i.e. problems $1, 2, \ldots, 8$) are scorable, while the last three problems ($9$, $10$ and $11$) are non-scorable ― this means that any sub... | {"inputs": ["2\n5\n2 45\n9 100\n8 0\n2 15\n8 90\n1\n11 1"], "outputs": ["135\n0"]} | 672 | 50 |
coding | Solve the programming task below in a Python markdown code block.
Mance Rayder, the King-Beyond-the-Wall, has always wanted to lead the largest army the North has ever seen against the NIght’s Watch. For this humungous feat he has banded the waring tribes, the Giants, Thenns and Wildings, together by going to great ext... | {"inputs": ["1\n1 2 1"], "outputs": ["Yes"]} | 384 | 18 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
There is an integer array nums sorted in non-decreasing order (not necessarily with distinct values).
Before being passed to your function, nums is rotated at an unknown pivot index k (0 <= k < nums.length) such that ... | {"functional": "def check(candidate):\n assert candidate(nums = [2,5,6,0,0,1,2], target = 0) == True\n assert candidate(nums = [2,5,6,0,0,1,2], target = 3) == False\n\n\ncheck(Solution().search)"} | 230 | 74 |
coding | Solve the programming task below in a Python markdown code block.
A new gangster is trying to take control of the city. He makes a list of his $N$ adversaries (e.g. gangster $\mbox{1}$, gangster $2$, ... gangster $N-1$, gangster $N$) and plans to get rid of them.
$\mbox{K}$ mercenaries are willing to do the job. The g... | {"inputs": ["3 2\n1 4 1\n2 2 2\n"], "outputs": [" 5\n"]} | 445 | 29 |
coding | Solve the programming task below in a Python markdown code block.
When Petya went to school, he got interested in large numbers and what they were called in ancient times. For instance, he learned that the Russian word "tma" (which now means "too much to be counted") used to stand for a thousand and "tma tmyschaya" (wh... | {"inputs": ["3\n9\n", "5\n5\n", "3\n7\n", "3\n8\n", "5\n30\n", "6\n18\n", "2\n64\n", "3\n27\n"], "outputs": ["YES\n1\n", "YES\n0\n", "NO\n", "NO\n", "NO\n", "NO\n", "YES\n5\n", "YES\n2\n"]} | 352 | 98 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
There are n tasks assigned to you. The task times are represented as an integer array tasks of length n, where the ith task takes tasks[i] hours to finish. A work session is when you work for at most sessionTime conse... | {"functional": "def check(candidate):\n assert candidate(tasks = [1,2,3], sessionTime = 3) == 2\n assert candidate(tasks = [3,1,3,1,1], sessionTime = 8) == 2\n assert candidate(tasks = [1,2,3,4,5], sessionTime = 15) == 1\n\n\ncheck(Solution().minSessions)"} | 209 | 94 |
coding | Solve the programming task below in a Python markdown code block.
You are given an undirected connected weighted graph consisting of $n$ vertices and $m$ edges. Let's denote the length of the shortest path from vertex $1$ to vertex $i$ as $d_i$.
You have to erase some edges of the graph so that at most $k$ edges rema... | {"inputs": ["3 3 2\n1 2 1\n3 2 1\n1 3 3\n", "3 3 2\n1 2 1\n3 2 1\n1 3 3\n", "4 4 0\n1 2 1\n2 3 1\n3 4 1\n1 4 2\n", "4 4 0\n1 2 1\n2 3 1\n3 4 1\n1 4 2\n", "4 4 0\n1 2 1\n2 3 1\n3 4 1\n1 4 0\n", "4 5 2\n4 1 8\n2 4 1\n2 1 3\n3 4 9\n3 1 5\n", "4 5 0\n4 1 8\n2 4 1\n2 1 3\n3 4 9\n3 1 5\n", "4 5 0\n4 1 8\n2 4 1\n2 1 3\n3 4 9\... | 518 | 310 |
coding | Solve the programming task below in a Python markdown code block.
Petya once wrote a sad love song and shared it to Vasya. The song is a string consisting of lowercase English letters. Vasya made up $q$ questions about this song. Each question is about a subsegment of the song starting from the $l$-th letter to the $r$... | {"inputs": ["7 3\nabacaba\n1 3\n2 5\n1 7\n", "7 3\nabacaba\n2 3\n2 5\n1 7\n", "7 3\nabacaba\n2 6\n2 5\n1 7\n", "7 3\nabacaba\n2 6\n2 6\n1 7\n", "7 3\nabacaba\n2 3\n4 5\n1 7\n", "7 1\nabacaba\n2 6\n2 5\n1 7\n", "7 2\nabacaba\n2 6\n2 6\n1 7\n", "7 3\nabacaba\n2 3\n4 5\n2 7\n"], "outputs": ["4\n7\n11\n", "3\n7\n11\n", "9\... | 613 | 246 |
coding | Solve the programming task below in a Python markdown code block.
You have k pieces of laundry, each of which you want to wash, dry and fold. You are at a laundromat that has n_1 washing machines, n_2 drying machines and n_3 folding machines. Each machine can process only one piece of laundry at a time. You can't dry a... | {"inputs": ["1 1 1 1 5 5 5\n", "5 2 4 5 9 9 6\n", "4 5 1 2 4 6 2\n", "1 3 2 2 5 2 8\n", "4 2 1 2 5 2 3\n", "4 2 1 2 5 2 3\n", "4 5 1 2 4 6 2\n", "5 2 4 5 9 9 6\n"], "outputs": ["15\n", "42\n", "30\n", "15\n", "17\n", "17", "30", "42"]} | 539 | 171 |
coding | Solve the programming task below in a Python markdown code block.
In Republic of AtCoder, Snuke Chameleons (Family: Chamaeleonidae, Genus: Bartaberia) are very popular pets. Ringo keeps N Snuke Chameleons in a cage.
A Snuke Chameleon that has not eaten anything is blue. It changes its color according to the following ... | {"inputs": ["8 5", "0 7", "0 5", "3 4", "4 7", "2 5", "4 8", "3 5"], "outputs": ["0\n", "64\n", "16\n", "4\n", "42\n", "15\n", "99\n", "11\n"]} | 452 | 84 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You have a lock in front of you with 4 circular wheels. Each wheel has 10 slots: '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'. The wheels can rotate freely and wrap around: for example we can turn '9' to be '0', o... | {"functional": "def check(candidate):\n assert candidate(deadends = [\"0201\",\"0101\",\"0102\",\"1212\",\"2002\"], target = \"0202\") == 6\n\n\ncheck(Solution().openLock)"} | 242 | 65 |
coding | Solve the programming task below in a Python markdown code block.
Mr. Matsudaira is always careful about eco-friendliness in his life. Last month's water charge was 4280 yen, which exceeded the usual target of 4000 yen, so we have been trying to save water this month. How much have you saved on your water bill compared... | {"inputs": ["29\n1\n0\n-1", "29\n16\n-1\n1", "29\n60\n0\n-1", "29\n9\n-1\n-1", "29\n28\n0\n-1", "29\n24\n-1\n1", "29\n97\n0\n-1", "29\n16\n0\n-1"], "outputs": ["620\n3130\n3130\n", "620\n2380\n", "620\n-4320\n3130\n", "620\n3130\n", "620\n760\n3130\n", "620\n1320\n", "620\n-10240\n3130\n", "620\n2380\n3130\n"]} | 512 | 216 |
coding | Solve the programming task below in a Python markdown code block.
You are given a positive integer N.
Find the number of the pairs of integers u and v (0≦u,v≦N) such that there exist two non-negative integers a and b satisfying a xor b=u and a+b=v.
Here, xor denotes the bitwise exclusive OR.
Since it can be extremely l... | {"inputs": ["3\n", "1422\n", "1000000000000000000\n"], "outputs": ["5\n", "52277\n", "787014179\n"]} | 332 | 63 |
coding | Solve the programming task below in a Python markdown code block.
A school has to decide on its team for an international quiz. There are $n$ students in the school. We can describe the students using an array $a$ where $a_i$ is the smartness of the $i$-th ($1 \le i \le n$) student.
There are $m$ topics $1, 2, 3, \ldo... | {"inputs": ["3\n2 4\n3 7\n4 2\n3 7 2 9\n5 7\n6 4 3 5 7\n"], "outputs": ["-1\n0\n3\n"]} | 606 | 53 |
coding | Solve the programming task below in a Python markdown code block.
Genos needs your help. He was asked to solve the following programming problem by Saitama:
The length of some string s is denoted |s|. The Hamming distance between two strings s and t of equal length is defined as $\sum_{i = 1}^{|s|}|s_{i} - t_{i}|$, wh... | {"inputs": ["0\n0\n", "1\n0\n", "0\n1\n", "1\n1\n", "1\n0\n", "0\n1\n", "0\n0\n", "1\n1\n"], "outputs": ["0\n", "1\n", "1\n", "0\n", "1\n", "1\n", "0\n", "0\n"]} | 523 | 86 |
coding | Solve the programming task below in a Python markdown code block.
The most basic encryption method is to map a char to another char by a certain math rule.
Because every char has an ASCII value, we can manipulate this value with a simple math expression.
For example 'a' + 1 would give us 'b', because 'a' value is 97 a... | {"functional": "_inputs = [['', 1], ['a', 1], ['please encrypt me', 2]]\n_outputs = [[''], ['b'], ['rngcug\"gpet{rv\"og']]\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)):\... | 185 | 184 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given a string s which consists of lowercase or uppercase letters, return the length of the longest palindrome that can be built with those letters.
Letters are case sensitive, for example, "Aa" is not considered a pa... | {"functional": "def check(candidate):\n assert candidate(s = \"abccccdd\") == 7\n assert candidate(s = \"a\") == 1\n\n\ncheck(Solution().longestPalindrome)"} | 93 | 46 |
coding | Solve the programming task below in a Python markdown code block.
# Task
* **_Given_** *three integers* `a` ,`b` ,`c`, **_return_** *the **_largest number_** obtained after inserting the following operators and brackets*: `+`, `*`, `()`
* In other words , **_try every combination of a,b,c with [*+()] , and return the ... | {"functional": "_inputs = [[2, 1, 2], [2, 1, 1], [1, 1, 1], [1, 2, 3], [1, 3, 1], [2, 2, 2], [5, 1, 3], [3, 5, 7], [5, 6, 1], [1, 6, 1], [2, 6, 1], [6, 7, 1], [2, 10, 3], [1, 8, 3], [9, 7, 2], [1, 1, 10], [9, 1, 1], [10, 5, 6], [1, 10, 1]]\n_outputs = [[6], [4], [3], [9], [5], [8], [20], [105], [35], [8], [14], [48], [... | 697 | 396 |
coding | Solve the programming task below in a Python markdown code block.
INTERCAL is the oldest of esoteric programming languages. One of its many weird features is the method of character-based output, known as Turing Tape method. It converts an array of unsigned 8-bit integers into a sequence of characters to print, using t... | {"inputs": ["N\n", "M\n", "o2^\"t\n", "p2^\"t\n", "\\Pk|a\\'\n", "aPk|\\\\'\n", "s3=MS8%X\n", "r3=MS8%X\n"], "outputs": ["142\n", "78\n", "10\n170\n210\n54\n22\n", "242\n194\n210\n54\n22\n", "198\n48\n52\n152\n184\n76\n86\n", "122\n124\n52\n152\n4\n0\n86\n", "50\n2\n16\n10\n232\n174\n120\n138\n", "178\n130\n16\n10\n232... | 475 | 225 |
coding | Solve the programming task below in a Python markdown code block.
Write a function which takes a number and returns the corresponding ASCII char for that value.
Example:
~~~if-not:java,racket
```
get_char(65) # => 'A'
```
~~~
~~~if:java
~~~
~~~if:racket
~~~
For ASCII table, you can refer to http://www.asciitable.co... | {"functional": "_inputs = [[65], [33], [34], [35], [36], [37], [38]]\n_outputs = [['A'], ['!'], ['\"'], ['#'], ['$'], ['%'], ['&']]\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, ... | 112 | 195 |
coding | Solve the programming task below in a Python markdown code block.
# Letterss of Natac
In a game I just made up that doesn’t have anything to do with any other game that you may or may not have played, you collect resources on each turn and then use those resources to build things like roads, settlements and cities. If ... | {"functional": "_inputs = [['', 'bw']]\n_outputs = [[[False, '']]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return math.isclose(a, b, rel_tol=tol, abs_tol=tol)\n if isinstance(a, (list, tuple)):\n if len(a) != len(b): return False\n retu... | 635 | 161 |
coding | Solve the programming task below in a Python markdown code block.
Chef has a bucket having a capacity of K liters. It is already filled with X liters of water.
Find the maximum amount of extra water in liters that Chef can fill in the bucket without overflowing.
------ Input Format ------
- The first line will c... | {"inputs": ["2\n5 4\n15 6\n"], "outputs": ["1\n9\n"]} | 333 | 25 |
coding | Solve the programming task below in a Python markdown code block.
B: Parentheses Number
problem
Define the correct parenthesis string as follows:
* The empty string is the correct parenthesis string
* For the correct parenthesis string S, `(` S `)` is the correct parenthesis string
* For correct parentheses S, T ST ... | {"inputs": ["2\n1 2", "2\n2 1", "2\n2 -2", "2\n2 -4", "2\n2 -3", "2\n2 -6", "2\n2 -5", "2\n2 -7"], "outputs": ["()()\n", "(())", ":(\n", ":(\n", ":(\n", ":(\n", ":(\n", ":(\n"]} | 416 | 100 |
coding | Solve the programming task below in a Python markdown code block.
Codex is about to start and Ram has not done dinner yet. So, he quickly goes to hostel mess and finds a long queue in front of food counter. But somehow he manages to take the food plate and reaches in front of the queue. The plates are divided into sec... | {"inputs": ["19\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19"], "outputs": ["4\n9\n25\n64\n169\n441\n1156\n3025\n7921\n20736\n54289\n142129\n372100\n974169\n2550409\n6677056\n17480761\n45765225\n119814916"]} | 367 | 169 |
coding | Solve the programming task below in a Python markdown code block.
Sometimes Sergey visits fast food restaurants. Today he is going to visit the one called PizzaKing.
Sergey wants to buy N meals, which he had enumerated by integers from 1 to N. He knows that the meal i costs Ci rubles. He also knows that there are M mea... | {"inputs": ["1\n3 3\n3 5 6\n11 3 1 2 3\n5 2 1 2\n5 2 1 3"], "outputs": ["10"]} | 679 | 50 |
coding | Solve the programming task below in a Python markdown code block.
# Definition
**_Strong number_** is the number that *the sum of the factorial of its digits is equal to number itself*.
## **_For example_**: **_145_**, since
```
1! + 4! + 5! = 1 + 24 + 120 = 145
```
So, **_145_** is a **_Strong number_**.
____
# ... | {"functional": "_inputs = [[40585], [2999999]]\n_outputs = [['STRONG!!!!'], ['Not Strong !!']]\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)... | 622 | 175 |
coding | Solve the programming task below in a Python markdown code block.
One day Vitaly was going home late at night and wondering: how many people aren't sleeping at that moment? To estimate, Vitaly decided to look which windows are lit in the house he was passing by at that moment.
Vitaly sees a building of n floors and 2·... | {"inputs": ["1 1\n0 0\n", "1 1\n0 1\n", "1 1\n1 0\n", "1 1\n1 1\n", "1 1\n0 0\n", "1 1\n0 1\n", "1 1\n1 0\n", "1 1\n1 1\n"], "outputs": ["0\n", "1\n", "1\n", "1\n", "0\n", "1\n", "1\n", "1\n"]} | 520 | 118 |
coding | Solve the programming task below in a Python markdown code block.
Andryusha is an orderly boy and likes to keep things in their place.
Today he faced a problem to put his socks in the wardrobe. He has n distinct pairs of socks which are initially in a bag. The pairs are numbered from 1 to n. Andryusha wants to put pai... | {"inputs": ["1\n1 1\n", "1\n1 1\n", "3\n2 1 1 3 2 3\n", "3\n2 1 1 3 2 3\n", "5\n5 1 3 2 4 3 1 2 4 5\n", "5\n5 1 3 2 4 3 1 2 4 5\n", "5\n5 2 3 1 4 3 1 2 4 5\n", "5\n5 2 3 1 4 3 2 2 4 5\n"], "outputs": ["1\n", "1\n", "2\n", "2\n", "5\n", "5\n", "5\n", "5\n"]} | 656 | 182 |
coding | Solve the programming task below in a Python markdown code block.
You are given an undirected graph consisting of $n$ vertices and $n$ edges, where $n$ is divisible by $6$. Each edge has a weight, which is a positive (greater than zero) integer.
The graph has the following structure: it is split into $\frac{n}{3}$ tri... | {"inputs": ["6\n4 2 6 6 6 4\n", "12\n1 3 3 7 8 5 2 2 2 2 4 2\n", "18\n5 8 3 8 9 10 7 10 2 7 3 2 1 10 7 7 8 9\n", "18\n58 40 14 8 86 29 5 50 24 42 96 53 72 54 95 62 30 77\n", "18\n626 619 11 809 967 233 474 747 648 256 397 174 705 695 520 682 402 925\n"], "outputs": ["2\n", "36\n", "20\n", "20\n", "20\n"]} | 543 | 252 |
coding | Solve the programming task below in a Python markdown code block.
Write a function that when given a number >= 0, returns an Array of ascending length subarrays.
```
pyramid(0) => [ ]
pyramid(1) => [ [1] ]
pyramid(2) => [ [1], [1, 1] ]
pyramid(3) => [ [1], [1, 1], [1, 1, 1] ]
```
**Note:** the subarrays should be fil... | {"functional": "_inputs = [[0], [1], [2], [3]]\n_outputs = [[[]], [[[1]]], [[[1], [1, 1]]], [[[1], [1, 1], [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)):\n ... | 134 | 196 |
coding | Solve the programming task below in a Python markdown code block.
Read problems statements in Mandarin Chinese and Russian.
This problem's statement is really a short one.
You are given an integer S. Consider an infinite sequence S, 2S, 3S, ... . Find the first number in this sequence that can be represented as Q^{... | {"inputs": ["2\n2\n2 2\n2\n2 3"], "outputs": ["8\n216"]} | 524 | 28 |
coding | Solve the programming task below in a Python markdown code block.
Sig has built his own keyboard. Designed for ultimate simplicity, this keyboard only has 3 keys on it: the 0 key, the 1 key and the backspace key.
To begin with, he is using a plain text editor with this keyboard. This editor always displays one string (... | {"inputs": ["3\n1", "3\n2", "3\n4", "3\n8", "3\n3", "3\n6", "3\n0", "3\n0\n"], "outputs": ["5\n", "5\n", "5\n", "5\n", "5\n", "5\n", "5", "5\n"]} | 433 | 78 |
coding | Solve the programming task below in a Python markdown code block.
Takahashi is participating in a programming contest, AXC001. He has just submitted his code to Problem A.
The problem has N test cases, all of which must be passed to get an AC verdict.
Takahashi's submission has passed M cases out of the N test cases.... | {"inputs": ["4 3", "0 0", "1 0", "3 4", "4 1", "2 0", "3 7", "4 0"], "outputs": ["No\n", "Yes\n", "No\n", "No\n", "No\n", "No\n", "No\n", "No\n"]} | 191 | 78 |
coding | Solve the programming task below in a Python markdown code block.
There are N towns numbered 1, 2, \cdots, N.
Some roads are planned to be built so that each of them connects two distinct towns bidirectionally. Currently, there are no roads connecting towns.
In the planning of construction, each town chooses one town... | {"inputs": ["2\n1 1", "2\n1 2", "2\n2 2", "2\n2 1", "2\n2 -1", "2\n-1 2", "2\n1 -1", "2\n-1 1"], "outputs": ["1\n", "0\n", "1\n", "1", "1\n", "1\n", "1\n", "1\n"]} | 428 | 95 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
A binary tree is named Even-Odd if it meets the following conditions:
The root of the binary tree is at level index 0, its children are at level index 1, their children are at level index 2, etc.
For every even-index... | {"functional": "def check(candidate):\n assert candidate(root = tree_node([1,10,4,3,None,7,9,12,8,6,None,None,2])) == True\n assert candidate(root = tree_node([5,4,2,3,3,7])) == False\n assert candidate(root = tree_node([5,9,1,3,5,7])) == False\n assert candidate(root = tree_node([1])) == True\n assert c... | 225 | 168 |
coding | Solve the programming task below in a Python markdown code block.
A Train started its journey at x=-infinity is travelling on the x-Coordinate Axis. Given n passengers and the coordinates $b_i$ and $d_i$ for each of the $ith$ passenger at which they board and leave from the train respectively. Due to current COVID-19 c... | {"inputs": ["3\n0 2\n1 3\n-1 4"], "outputs": ["12"]} | 446 | 26 |
coding | Solve the programming task below in a Python markdown code block.
problem
In the area where Kazakhstan is now located, there used to be a trade route called the "Silk Road".
There are N + 1 cities on the Silk Road, numbered from west as city 0, city 1, ..., city N. The distance between city i -1 and city i (1 ≤ i ≤ N... | {"inputs": ["1 5\n0\n58\n7\n64\n30\n1\n67\n2", "3 5\n10\n38\n7\n0\n40\n6\n4\n28", "3 5\n16\n38\n7\n0\n40\n6\n1\n28", "2 5\n0\n58\n5\n64\n60\n1\n46\n2", "1 5\n1\n61\n7\n64\n25\n1\n33\n2", "1 5\n3\n38\n7\n32\n30\n1\n40\n30", "3 5\n10\n62\n7\n50\n30\n6\n2\n30", "3 5\n10\n38\n7\n50\n30\n6\n2\n30"], "outputs": ["0\n", "256\... | 619 | 250 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given an integer array nums. We consider an array good if it is a permutation of an array base[n].
base[n] = [1, 2, ..., n - 1, n, n] (in other words, it is an array of length n + 1 which contains 1 to n - 1 e... | {"functional": "def check(candidate):\n assert candidate(nums = [2, 1, 3]) == False\n assert candidate(nums = [1, 3, 3, 2]) == True\n assert candidate(nums = [1, 1]) == True\n assert candidate(nums = [3, 4, 4, 1, 2, 1]) == False\n\n\ncheck(Solution().isGood)"} | 183 | 96 |
coding | Solve the programming task below in a Python markdown code block.
Takahashi and Aoki will have a battle using their monsters.
The health and strength of Takahashi's monster are A and B, respectively, and those of Aoki's monster are C and D, respectively.
The two monsters will take turns attacking, in the order Takahash... | {"inputs": ["46 4 4 5", "64 4 4 5", "64 8 4 5", "5 9 3 10", "54 8 4 5", "54 8 2 5", "54 6 2 5", "54 6 0 5"], "outputs": ["Yes\n", "Yes\n", "Yes\n", "Yes\n", "Yes\n", "Yes\n", "Yes\n", "Yes\n"]} | 324 | 118 |
coding | Solve the programming task below in a Python markdown code block.
You are locked in a room with a door that has a keypad with 10 keys corresponding to digits from 0 to 9. To escape from the room, you need to enter a correct code. You also have a sequence of digits.
Some keys on the keypad have fingerprints. You believ... | {"inputs": ["1 1\n4\n4\n", "1 1\n4\n4\n", "1 2\n1\n1 0\n", "1 2\n2\n1 2\n", "1 2\n2\n1 2\n", "1 2\n1\n1 0\n", "6 1\n4 2 7 3 1 8\n9\n", "1 6\n3\n6 8 2 4 5 3\n"], "outputs": ["4\n", "4\n", "1\n", "2\n", "2\n", "1\n", "\n", "3\n"]} | 484 | 145 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given an array of distinct integers arr, where arr is sorted in ascending order, return the smallest index i that satisfies arr[i] == i. If there is no such index, return -1.
Please complete the following python cod... | {"functional": "def check(candidate):\n assert candidate(arr = [-10,-5,0,3,7]) == 3\n assert candidate(arr = [0,2,5,8,17]) == 0\n assert candidate(arr = [-10,-5,3,4,7,9]) == -1\n\n\ncheck(Solution().fixedPoint)"} | 88 | 84 |
coding | Solve the programming task below in a Python markdown code block.
Tyndex is again well ahead of the rivals! The reaction to the release of Zoozle Chrome browser was the release of a new browser Tyndex.Brome!
The popularity of the new browser is growing daily. And the secret is not even the Tyndex.Bar installed (the Ty... | {"inputs": ["3 3\nbyg\ndwg\nl\nx\n", "3 3\nbzg\ndwg\nl\nx\n", "4 4\nlocw\na\nr\nba\nxuv\n", "4 4\nlocw\na\ns\nba\nxuv\n", "4 4\nlocw\na\ns\nba\nwuv\n", "4 4\nlocw\na\ns\nba\nwtv\n", "4 4\nlodw\na\nr\nba\nxuv\n", "5 5\nvpjjx\njj\ne\nnor\nuthm\nbf\n"], "outputs": ["6\n1\n1\n", "6\n1\n1\n", "1\n1\n4\n9\n", "1\n1\n4\n9\n",... | 682 | 228 |
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 nums. You can rearrange the elements of nums to any order (including the given order).
Let prefix be the array containing the prefix sums of nums after rearranging it. In other ... | {"functional": "def check(candidate):\n assert candidate(nums = [2,-1,0,1,-3,3,-3]) == 6\n assert candidate(nums = [-2,-3,0]) == 0\n\n\ncheck(Solution().maxScore)"} | 141 | 59 |
coding | Solve the programming task below in a Python markdown code block.
One day, at the "Russian Code Cup" event it was decided to play football as an out of competition event. All participants was divided into n teams and played several matches, two teams could not play against each other more than once.
The appointed Judg... | {"inputs": ["2 1\n", "4 1\n", "1 1\n", "1 2\n", "2 2\n", "7 3\n", "6 3\n", "4 2\n"], "outputs": ["-1\n", "4\n1 2\n2 3\n3 4\n4 1\n", "-1\n", "-1\n", "-1\n", "21\n1 2\n1 3\n1 4\n2 3\n2 4\n2 5\n3 4\n3 5\n3 6\n4 5\n4 6\n4 7\n5 6\n5 7\n5 1\n6 7\n6 1\n6 2\n7 1\n7 2\n7 3\n", "-1\n", "-1\n"]} | 376 | 188 |
coding | Solve the programming task below in a Python markdown code block.
Fox Ciel is playing a game with numbers now.
Ciel has n positive integers: x_1, x_2, ..., x_{n}. She can do the following operation as many times as needed: select two different indexes i and j such that x_{i} > x_{j} hold, and then apply assignment x_... | {"inputs": ["2\n1 2\n", "2\n1 1\n", "2\n3 5\n", "2\n8 5\n", "2\n1 1\n", "2\n3 5\n", "2\n8 5\n", "2\n3 9\n"], "outputs": ["2\n", "2\n", "2\n", "2\n", "2\n", "2\n", "2\n", "6\n"]} | 318 | 102 |
coding | Solve the programming task below in a Python markdown code block.
Read problem statements in [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Chef and his friend Bharat have decided to play the game "The Chefora Spell".
In the game, a positive integer N (in decimal system) is considered a "Chefora"... | {"inputs": ["2\n1 2\n9 11"], "outputs": ["1\n541416750"]} | 533 | 31 |
coding | Solve the programming task below in a Python markdown code block.
There are N slimes lining up in a row. Initially, the i-th slime from the left has a size of a_i.
Taro is trying to combine all the slimes into a larger slime. He will perform the following operation repeatedly until there is only one slime:
* Choose t... | {"inputs": ["4\n10 5 30 46", "4\n10 3 30 46", "4\n19 3 30 46", "4\n19 3 35 46", "4\n19 3 35 65", "4\n19 3 21 65", "4\n15 3 21 65", "4\n15 3 20 65"], "outputs": ["151\n", "145\n", "172\n", "182\n", "201\n", "173\n", "161\n", "159\n"]} | 342 | 166 |
coding | Solve the programming task below in a Python markdown code block.
Chef has just started Programming, he is in first year of Engineering. Chef is reading about Relational Operators.
Relational Operators are operators which check relatioship between two values. Given two numerical values A and B you need to help chef i... | {"inputs": ["3\n10 20\n20 10\n10 10"], "outputs": ["<\n>\n="]} | 250 | 35 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given two arrays of integers nums1 and nums2, return the number of triplets formed (type 1 and type 2) under the following rules:
Type 1: Triplet (i, j, k) if nums1[i]2 == nums2[j] * nums2[k] where 0 <= i < nums1.len... | {"functional": "def check(candidate):\n assert candidate(nums1 = [7,4], nums2 = [5,2,8,9]) == 1\n assert candidate(nums1 = [1,1], nums2 = [1,1,1]) == 9\n assert candidate(nums1 = [7,7,8,3], nums2 = [1,2,9,7]) == 2\n assert candidate(nums1 = [4,7,9,11,23], nums2 = [3,5,1024,12,18]) == 0\n\n\ncheck(Solution()... | 188 | 145 |
coding | Solve the programming task below in a Python markdown code block.
You are given a sequence $a_1, a_2, \ldots, a_n$. Each element of $a$ is $1$ or $2$.
Find out if an integer $k$ exists so that the following conditions are met.
$1 \leq k \leq n-1$, and
$a_1 \cdot a_2 \cdot \ldots \cdot a_k = a_{k+1} \cdot a_{k+2} \cd... | {"inputs": ["3\n6\n2 2 1 2 1 2\n3\n1 2 1\n4\n1 1 1 1\n"], "outputs": ["2\n-1\n1\n"]} | 489 | 51 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.