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.
Squirrel Liss lived in a forest peacefully, but unexpected trouble happens. Stones fall from a mountain. Initially Squirrel Liss occupies an interval [0, 1]. Next, n stones will fall and Liss will escape from the stones. The stones are numbered from 1 to... | {"inputs": ["l\n", "r\n", "l\n", "r\n", "llrlr\n", "rrlll\n", "lrlrr\n", "rlrll\n"], "outputs": ["1\n", "1\n", "1\n", "1\n", "3\n5\n4\n2\n1\n", "1\n2\n5\n4\n3\n", "2\n4\n5\n3\n1\n", "1\n3\n5\n4\n2\n"]} | 440 | 110 |
coding | Solve the programming task below in a Python markdown code block.
You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively.
An example of a trapezoid
Find the area of this trapezoid.
-----Constraints-----
- 1≦a≦100
- 1≦b≦100
- 1≦h≦100
- All input values are int... | {"inputs": ["4\n4\n7", "3\n6\n2", "4\n8\n7", "4\n8\n6", "4\n9\n6", "4\n5\n6", "3\n2\n2", "3\n1\n2"], "outputs": ["28\n", "9\n", "42\n", "36\n", "39\n", "27\n", "5\n", "4\n"]} | 217 | 99 |
coding | Solve the programming task below in a Python markdown code block.
Lia is fascinated by anything she considers to be a twin. She calls a pairs of positive integers, $\boldsymbol{i}$ and $j$, twins if:
They are both prime. A prime number is an integer greater than $\mbox{1}$ that has no positive divisors other than $\mb... | {"inputs": ["3 13\n"], "outputs": ["3\n"]} | 279 | 17 |
coding | Solve the programming task below in a Python markdown code block.
Bertown is a city with $n$ buildings in a straight line.
The city's security service discovered that some buildings were mined. A map was compiled, which is a string of length $n$, where the $i$-th character is "1" if there is a mine under the building ... | {"inputs": ["2\n1 1\n01000010\n5 1\n01101110\n", "2\n1 1\n01000110\n5 1\n01101110\n", "2\n2 1\n01000110\n5 1\n01101110\n", "2\n2 1\n01000110\n5 1\n01101101\n", "2\n2 1\n11000111\n5 1\n01101001\n", "2\n1 1\n01000110\n5 2\n01101110\n", "2\n1 1\n11000111\n5 1\n01101001\n", "2\n0 1\n11000111\n5 1\n00111001\n"], "outputs": ... | 563 | 294 |
coding | Solve the programming task below in a Python markdown code block.
There are N different types of colours numbered from 1 to N. Chef has A_{i} balls having colour i, (1≤ i ≤ N).
Chef will arrange some boxes and put each ball in exactly one of those boxes.
Find the minimum number of boxes Chef needs so that no box con... | {"inputs": ["3\n2\n8 5\n3\n5 10 15\n4\n4 4 4 4\n"], "outputs": ["8\n15\n4\n"]} | 537 | 45 |
coding | Solve the programming task below in a Python markdown code block.
The squarefree part of a positive integer is the largest divisor of that integer which itself has no square factors (other than 1). For example, the squareefree part of 12 is 6, since the only larger divisor is 12, and 12 has a square factor (namely, 4).... | {"functional": "_inputs = [[0], [-100], [2.5]]\n_outputs = [[None], [None], [None]]\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 Fa... | 271 | 171 |
coding | Solve the programming task below in a Python markdown code block.
Write a function that gets a sequence and value and returns `true/false` depending on whether the variable exists in a multidimentional sequence.
Example:
```
locate(['a','b',['c','d',['e']]],'e'); // should return true
locate(['a','b',['c','d',['e']]],... | {"functional": "_inputs = [[['a', 'b', ['c', 'd', ['e']]], 'a'], [['a', 'b', ['c', 'd', ['e']]], 'd'], [['a', 'b', ['c', 'd', ['e']]], 'e'], [['a', 'b', ['c', 'd', ['e']]], 'f'], [['a', 'b', ['c', 'd', ['e', ['a', 'b', ['c', 'd', ['e4']]]]]], 'e4'], [['a', 'b', ['c', 'd', ['e', ['a', 'b', ['c', 'd', ['e', ['a', 'b', ['... | 133 | 386 |
coding | Solve the programming task below in a Python markdown code block.
Your task is to perform a simple table calculation.
Write a program which reads the number of rows r, columns c and a table of r × c elements, and prints a new table, which includes the total sum for each row and column.
Constraints
* 1 ≤ r, c ≤ 100
*... | {"inputs": ["4 5\n1 1 3 4 8\n2 2 2 4 5\n3 3 0 1 1\n2 3 4 4 6", "4 5\n1 1 3 4 8\n2 2 2 4 5\n3 3 0 1 1\n2 3 4 8 6", "4 5\n1 1 3 4 8\n2 2 2 4 5\n3 3 0 1 1\n2 6 4 8 6", "4 5\n1 1 3 4 8\n2 2 2 4 5\n3 3 0 1 2\n2 6 4 8 6", "4 5\n2 1 3 4 8\n2 2 2 4 5\n3 3 0 1 2\n2 6 4 8 6", "4 5\n1 1 3 1 5\n2 2 2 4 5\n3 3 0 1 1\n2 3 4 4 6", "4... | 321 | 913 |
coding | Solve the programming task below in a Python markdown code block.
King Arthur has a large kingdom that can be represented as a tree, where nodes correspond to cities and edges correspond to the roads between cities. The kingdom has a total of $n$ cities numbered from $\mbox{1}$ to $n$.
The King wants to divide his ki... | {"inputs": ["5\n1 2\n1 3\n3 4\n3 5\n"], "outputs": ["4\n"]} | 531 | 30 |
coding | Solve the programming task below in a Python markdown code block.
Sergey Semyonovich is a mayor of a county city N and he used to spend his days and nights in thoughts of further improvements of Nkers' lives. Unfortunately for him, anything and everything has been done already, and there are no more possible improvemen... | {"inputs": ["2\n2 1\n", "2\n2 1\n", "2\n1 2\n", "3\n2 1\n3 2\n", "3\n2 1\n3 2\n", "4\n1 2\n1 3\n1 4\n", "4\n1 2\n2 3\n3 4\n", "4\n1 2\n1 3\n3 4\n"], "outputs": ["1\n", "1\n", "1\n", "3\n", "3\n", "6\n", "7\n", "7\n"]} | 622 | 134 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are assigned to put some amount of boxes onto one truck. You are given a 2D array boxTypes, where boxTypes[i] = [numberOfBoxesi, numberOfUnitsPerBoxi]:
numberOfBoxesi is the number of boxes of type i.
numberOfUni... | {"functional": "def check(candidate):\n assert candidate(boxTypes = [[1,3],[2,2],[3,1]], truckSize = 4) == 8\n assert candidate(boxTypes = [[5,10],[2,5],[4,7],[3,9]], truckSize = 10) == 91\n\n\ncheck(Solution().maximumUnits)"} | 189 | 84 |
coding | Solve the programming task below in a Python markdown code block.
In a coding contest, there are two types of problems:
Easy problems, which are worth 1 point each
Hard problems, which are worth 2 points each
To qualify for the next round, a contestant must score at least X points. Chef solved A Easy problems and B H... | {"inputs": ["3\n15 9 3\n5 3 0\n6 2 8\n"], "outputs": ["Qualify\nNotQualify\nQualify\n"]} | 489 | 41 |
coding | Solve the programming task below in a Python markdown code block.
The official capital and the cultural capital of Berland are connected by a single road running through n regions. Each region has a unique climate, so the i-th (1 ≤ i ≤ n) region has a stable temperature of ti degrees in summer.
This summer a group of ... | {"inputs": ["1 1000000\n4 4 6 2\n", "1 1000000\n4 4 4 2\n", "1 1000000\n4 3 6 2\n", "1 1000000\n1 3 6 2\n", "1 1000000\n1 3 6 4\n", "1 1000000\n1 1 6 4\n", "0 1000000\n1 1 6 2\n", "1 1000000\n4 3 4 2\n"], "outputs": ["6000002\n", "4000002\n", "6000002\n", "1000000\n", "2000000\n", "6000004\n", "0\n", "4000002\n"]} | 686 | 240 |
coding | Solve the programming task below in a Python markdown code block.
In this problem, a date is written as Y-M-D. For example, 2019-11-30 means November 30, 2019.
Integers M_1, D_1, M_2, and D_2 will be given as input.
It is known that the date 2019-M_2-D_2 follows 2019-M_1-D_1.
Determine whether the date 2019-M_1-D_1 is... | {"inputs": ["11 30\n6 1", "6 30\n12 1", "11 30\n2 1", "11 3\n11 8", "11 3\n11 7", "9 30\n12 1", "11 3\n11 9", "11 6\n11 7"], "outputs": ["1\n", "1\n", "1\n", "0\n", "0\n", "1\n", "0\n", "0\n"]} | 290 | 126 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given two strings s and t consisting of only lowercase English letters.
Return the minimum number of characters that need to be appended to the end of s so that t becomes a subsequence of s.
A subsequence is a... | {"functional": "def check(candidate):\n assert candidate(s = \"coaching\", t = \"coding\") == 4\n assert candidate(s = \"abcde\", t = \"a\") == 0\n assert candidate(s = \"z\", t = \"abcde\") == 5\n\n\ncheck(Solution().appendCharacters)"} | 120 | 73 |
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 mapping which represents the mapping rule of a shuffled decimal system. mapping[i] = j means digit i should be mapped to digit j in this system.
The mapped value of an integer i... | {"functional": "def check(candidate):\n assert candidate(mapping = [8,9,4,0,2,1,3,5,7,6], nums = [991,338,38]) == [338,38,991]\n assert candidate(mapping = [0,1,2,3,4,5,6,7,8,9], nums = [789,456,123]) == [123,456,789]\n\n\ncheck(Solution().sortJumbled)"} | 198 | 130 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given a valid parentheses string s, return the nesting depth of s. The nesting depth is the maximum number of nested parentheses.
Please complete the following python code precisely:
```python
class Solution:
de... | {"functional": "def check(candidate):\n assert candidate(s = \"(1+(2*3)+((8)/4))+1\") == 3\n assert candidate(s = \"(1)+((2))+(((3)))\") == 3\n assert candidate(s = \"()(())((()()))\") == 3\n\n\ncheck(Solution().maxDepth)"} | 72 | 79 |
coding | Solve the programming task below in a Python markdown code block.
You love coffee and want to know what beans you can afford to buy it.
The first argument to your search function will be a number which represents your budget.
The second argument will be an array of coffee bean prices.
Your 'search' function should r... | {"functional": "_inputs = [[3, [6, 1, 2, 9, 2]], [14, [7, 3, 23, 9, 14, 20, 7]], [0, [6, 1, 2, 9, 2]], [10, []], [24, [24, 0, 100, 2, 5]], [24, [2.7, 0, 100.9, 1, 5.5]], [-1, [1, 2, 3, 4]], [-1, [-1, 0, 1, 2, 3, 4]], [14, [17, 33, 23, 19, 19, 20, 17]], [14, [13, 15, 14, 14, 15, 13]]]\n_outputs = [['1,2,2'], ['3,7,7,9,1... | 128 | 428 |
coding | Solve the programming task below in a Python markdown code block.
Bitwise exclusive OR (or bitwise addition modulo two) is a binary operation which is equivalent to applying logical exclusive OR to every pair of bits located on the same positions in binary notation of operands. In other words, a binary digit of the res... | {"inputs": ["142\n0\n", "142\n5\n", "638\n33\n", "142\n41\n", "638\n29\n", "142\n69\n", "638\n93\n", "142\n49\n"], "outputs": ["71 71\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n"]} | 303 | 112 |
coding | Solve the programming task below in a Python markdown code block.
There's an array A consisting of N non-zero integers A1..N. A subarray of A is called alternating if any two adjacent elements in it have different signs (i.e. one of them should be negative and the other should be positive).
For each x from 1 to N, com... | {"inputs": ["3\n4\n1 2 3 4\n4\n1 -5 1 -5\n6\n-5 -1 -1 2 -2 -3"], "outputs": ["1 1 1 1\n4 3 2 1\n1 1 3 2 1 1"]} | 369 | 73 |
coding | Solve the programming task below in a Python markdown code block.
Everyone knows that hobbits love to organize all sorts of parties and celebrations. There are n hobbits living in the Shire. They decided to organize the Greatest Party (GP) that would last for several days. Next day the hobbits wrote a guest list, some ... | {"inputs": ["3\n", "7\n", "6\n", "9\n", "8\n", "4\n", "5\n", "16\n"], "outputs": ["3\n1 2 \n1 3 \n2 3 \n", "4\n1 2 3 \n1 4 5 \n2 4 6 \n3 5 6 \n", "4\n1 2 3 \n1 4 5 \n2 4 6 \n3 5 6 \n", "4\n1 2 3 \n1 4 5 \n2 4 6 \n3 5 6 \n", "4\n1 2 3 \n1 4 5 \n2 4 6 \n3 5 6 \n", "3\n1 2 \n1 3 \n2 3 \n", "3\n1 2 \n1 3 \n2 3 \n", "6\n1 2... | 340 | 306 |
coding | Solve the programming task below in a Python markdown code block.
You are given an array $a$ of $n$ integers. You are asked to find out if the inequality $$\max(a_i, a_{i + 1}, \ldots, a_{j - 1}, a_{j}) \geq a_i + a_{i + 1} + \dots + a_{j - 1} + a_{j}$$ holds for all pairs of indices $(i, j)$, where $1 \leq i \leq j \l... | {"inputs": ["1\n6\n10 -8 2 4 -8 10\n", "1\n6\n10 -6 1 1 -6 10\n", "1\n7\n5 -4 2 -1 2 -4 6\n", "1\n7\n9 -10 5 -1 1 -1 5\n", "1\n7\n10 -2 1 -2 1 -2 10\n", "1\n10\n0 0 0 0 0 0 0 0 0 0\n", "1\n9\n5 -1 1 -2 2 -3 3 -4 5\n", "1\n9\n9 -8 3 -2 2 -2 3 -8 9\n"], "outputs": ["NO\n", "NO\n", "NO\n", "NO\n", "NO\n", "YES\n", "NO\n",... | 438 | 216 |
coding | Solve the programming task below in a Python markdown code block.
Simply find the closest value to zero from the list. Notice that there are negatives in the list.
List is always not empty and contains only integers. Return ```None``` if it is not possible to define only one of such values. And of course, we are expec... | {"functional": "_inputs = [[[10, 3, 9, 1]], [[2, 4, -1, -3]], [[5, 2, -2]], [[5, 2, 2]], [[13, 0, -6]], [[1]], [[5, 1, -1, 2, -10]], [[5, -5, -2, 5, -3]], [[27, 37, 48, -18, 42, 16, 5, 34, 35, 26, -34, 3, -43, 35, 0, -45, -7, 45, 34, -18, 44, 12, 6, -45, 33, 27, -2, 28, 12, 9]], [[11, -30, -18, 4, -13, 43, 12, -5, -6, ... | 161 | 972 |
coding | Solve the programming task below in a Python markdown code block.
Vanya smashes potato in a vertical food processor. At each moment of time the height of the potato in the processor doesn't exceed h and the processor smashes k centimeters of potato each second. If there are less than k centimeters remaining, than durin... | {"inputs": ["1 1 1\n1\n", "1 1 1\n1\n", "1 1 2\n1\n", "5 6 3\n5 4 3 2 1\n", "5 6 3\n5 5 5 5 5\n", "5 6 3\n1 2 1 1 1\n", "5 6 3\n1 2 2 1 1\n", "5 6 3\n5 4 6 2 1\n"], "outputs": ["1\n", "1\n", "1\n", "5\n", "10\n", "2\n", "3\n", "6\n"]} | 641 | 159 |
coding | Solve the programming task below in a Python markdown code block.
Write a function taking in a string like `WOW this is REALLY amazing` and returning `Wow this is really amazing`. String should be capitalized and properly spaced. Using `re` and `string` is not allowed.
Examples:
```python
filter_words('HELLO... | {"functional": "_inputs = [['HELLO world!'], ['This will not pass '], ['NOW THIS is a VERY EXCITING test!']]\n_outputs = [['Hello world!'], ['This will not pass'], ['Now this is a very exciting test!']]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n r... | 137 | 198 |
coding | Solve the programming task below in a Python markdown code block.
Bob watches TV every day. He always sets the volume of his TV to $b$. However, today he is angry to find out someone has changed the volume to $a$. Of course, Bob has a remote control that can change the volume.
There are six buttons ($-5, -2, -1, +1, +... | {"inputs": ["3\n4 0\n5 1\n3 9\n", "3\n4 0\n5 14\n3 9\n", "3\n4 0\n5 14\n3 2\n", "3\n4 0\n4 14\n0 2\n", "3\n6 0\n2 8\n2 13\n", "3\n2 0\n6 14\n0 1\n", "3\n2 0\n6 25\n0 1\n", "3\n4 0\n5 14\n0 2\n"], "outputs": ["2\n2\n2\n", "2\n3\n2\n", "2\n3\n1\n", "2\n2\n1\n", "2\n2\n3\n", "1\n3\n1\n", "1\n5\n1\n", "2\n3\n1\n"]} | 501 | 205 |
coding | Solve the programming task below in a Python markdown code block.
shape
The shape tool gives a tuple of array dimensions and can be used to change the dimensions of an array.
(a). Using shape to get array dimensions
import numpy
my__1D_array = numpy.array([1, 2, 3, 4, 5])
print my_1D_array.shape #(5,) -> 1 row ... | {"inputs": ["1 2 3 4 5 6 7 8 9\n"], "outputs": ["[[1 2 3]\n [4 5 6]\n [7 8 9]]\n"]} | 393 | 53 |
coding | Solve the programming task below in a Python markdown code block.
Polycarp was gifted an array $a$ of length $n$. Polycarp considers an array beautiful if there exists a number $C$, such that each number in the array occurs either zero or $C$ times. Polycarp wants to remove some elements from the array $a$ to make it b... | {"inputs": ["3\n6\n1 3 2 1 4 2\n4\n100 100 4 100\n8\n1 2 3 3 3 2 6 6\n", "3\n6\n1 3 2 1 4 2\n4\n100 101 4 100\n8\n1 2 3 3 3 2 6 6\n", "3\n6\n1 3 3 1 4 2\n4\n100 100 7 100\n8\n1 0 3 3 3 2 6 6\n", "3\n6\n1 3 3 1 2 2\n4\n100 100 7 100\n8\n1 0 3 3 3 2 6 6\n", "3\n6\n1 3 0 1 4 2\n4\n100 100 7 100\n8\n2 2 3 3 3 2 6 6\n", "3\... | 516 | 486 |
coding | Solve the programming task below in a Python markdown code block.
Polycarp has $n$ friends, the $i$-th of his friends has $a_i$ candies. Polycarp's friends do not like when they have different numbers of candies. In other words they want all $a_i$ to be the same. To solve this, Polycarp performs the following set of ac... | {"inputs": ["1\n2\n1 691\n", "1\n2\n1 691\n", "1\n3\n1 1 67\n", "1\n3\n1 1 67\n", "1\n3\n1 1 65\n", "1\n3\n0 1 65\n", "1\n3\n0 1 91\n", "1\n3\n0 0 91\n"], "outputs": ["1\n", "1\n", "1\n", "1\n", "-1\n", "1\n", "-1\n", "-1\n"]} | 712 | 140 |
coding | Solve the programming task below in a Python markdown code block.
A string t is called an anagram of the string s, if it is possible to rearrange letters in t so that it is identical to the string s. For example, the string "aab" is an anagram of the string "aba" and the string "aaa" is not.
The string t is called a s... | {"inputs": ["?\na\n", "a\na\n", "b\na\n", "a\naa\n", "?\ncb\n", "b\naa\n", "?\nca\n", "?\ncc\n"], "outputs": ["1\n", "1\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n"]} | 505 | 85 |
coding | Solve the programming task below in a Python markdown code block.
# Task
Given a string `str`, reverse it omitting all non-alphabetic characters.
# Example
For `str = "krishan"`, the output should be `"nahsirk"`.
For `str = "ultr53o?n"`, the output should be `"nortlu"`.
# Input/Output
- `[input]` string `st... | {"functional": "_inputs = [['krishan'], ['ultr53o?n'], ['ab23c'], ['krish21an']]\n_outputs = [['nahsirk'], ['nortlu'], ['cba'], ['nahsirk']]\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... | 139 | 193 |
coding | Solve the programming task below in a Python markdown code block.
Devendra just had a million-dollar idea and he needs funds to startup. He was recently invited to Sasta Shark Tank (A TV show where entrepreneurs pitch their ideas to investors hoping to get investment in return).
He was offered deals from two investors... | {"inputs": ["3\n100 200\n200 100\n200 500\n"], "outputs": ["ANY\nFIRST\nSECOND"]} | 738 | 41 |
coding | Solve the programming task below in a Python markdown code block.
The Cybermen and the Daleks have long been the Doctor's main enemies. Everyone knows that both these species enjoy destroying everything they encounter. However, a little-known fact about them is that they both also love taking Turing tests!
Heidi desig... | {"inputs": ["2\n0 0\n0 1\n0 2\n1 0\n1 1\n1 2\n2 0\n2 1\n2 2\n", "2\n0 0\n0 1\n0 2\n0 3\n1 0\n1 2\n2 0\n2 1\n2 2\n", "2\n0 0\n0 1\n0 2\n0 3\n1 0\n1 2\n2 0\n2 1\n2 2\n", "2\n0 0\n0 1\n0 2\n1 0\n1 1\n1 2\n2 0\n2 1\n2 2\n", "2\n1 2\n1 27\n1 45\n10 45\n28 48\n38 1\n44 1\n45 7\n45 26\n", "2\n1 2\n1 27\n1 45\n10 45\n28 48\n38... | 400 | 426 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
The power of the string is the maximum length of a non-empty substring that contains only one unique character.
Given a string s, return the power of s.
Please complete the following python code precisely:
```python... | {"functional": "def check(candidate):\n assert candidate(s = \"leetcode\") == 2\n assert candidate(s = \"abbcccddddeeeeedcba\") == 5\n\n\ncheck(Solution().maxPower)"} | 79 | 49 |
coding | Solve the programming task below in a Python markdown code block.
Consider a string, $S$, of $n$ lowercase English letters where each character, $s_i$ ($0\leq i<n)$, denotes the letter at index $\boldsymbol{i}$ in $S$. We define an $(a,b,c,d)$ palindromic tuple of $S$ to be a sequence of indices in $S$ satisfying the f... | {"inputs": ["ghhggh\n", "abbaab\n", "akakak\n", "kkkkkkz\n", "kkkkkkz\n"], "outputs": ["4\n", "4\n", "2\n", "15\n", "15\n"]} | 608 | 60 |
coding | Solve the programming task below in a Python markdown code block.
You are given two positive integers `a` and `b` (`a < b <= 20000`). Complete the function which returns a list of all those numbers in the interval `[a, b)` whose digits are made up of prime numbers (`2, 3, 5, 7`) but which are not primes themselves.
B... | {"functional": "_inputs = [[2, 222], [2, 77], [2700, 3000], [500, 999], [999, 2500]]\n_outputs = [[[22, 25, 27, 32, 33, 35, 52, 55, 57, 72, 75, 77]], [[22, 25, 27, 32, 33, 35, 52, 55, 57, 72, 75]], [[2722, 2723, 2725, 2727, 2732, 2733, 2735, 2737, 2752, 2755, 2757, 2772, 2773, 2775]], [[522, 525, 527, 532, 533, 535, 53... | 117 | 660 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given a binary array nums, return the maximum number of consecutive 1's in the array if you can flip at most one 0.
Please complete the following python code precisely:
```python
class Solution:
def findMaxConse... | {"functional": "def check(candidate):\n assert candidate(nums = [1,0,1,1,0]) == 4\n assert candidate(nums = [1,0,1,1,0,1]) == 4\n\n\ncheck(Solution().findMaxConsecutiveOnes)"} | 80 | 65 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given a very large integer n, represented as a string, and an integer digit x. The digits in n and the digit x are in the inclusive range [1, 9], and n may represent a negative number.
You want to maximi... | {"functional": "def check(candidate):\n assert candidate(n = \"99\", x = 9) == \"999\"\n assert candidate(n = \"-13\", x = 2) == \"-123\"\n\n\ncheck(Solution().maxValue)"} | 220 | 63 |
coding | Solve the programming task below in a Python markdown code block.
Richik$Richik$ has just completed his engineering and has got a job in one of the firms at Sabrina$Sabrina$ which is ranked among the top seven islands in the world in terms of the pay scale.
Since Richik$Richik$ has to travel a lot to reach the firm, t... | {"inputs": ["1\n3 10"], "outputs": ["18"]} | 441 | 18 |
coding | Solve the programming task below in a Python markdown code block.
Given an array (ints) of n integers, find three integers in arr such that the sum is closest to a given number (num), target.
Return the sum of the three integers.
You may assume that each input would have exactly one solution.
Example:
Note: your so... | {"functional": "_inputs = [[[-1, 2, 1, -4], 1], [[5, 4, 0, 3], 3], [[1, 2, 3, 4], 4], [[-2, 2, -3, 1], 3]]\n_outputs = [[2], [7], [6], [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,... | 101 | 223 |
coding | Solve the programming task below in a Python markdown code block.
Problem
Taro decided to watch one movie every day at a nearby movie theater during the summer vacation. (Taro has 31 days of summer vacation from August 1st to August 31st.)
The theater is set to show n movies during the summer vacation. Each movie is ... | {"inputs": ["4\n1 31\n2 4\n2 3\n3 3", "4\n1 31\n2 2\n2 1\n3 3", "4\n1 31\n2 2\n2 3\n3 5", "4\n1 31\n2 4\n2 3\n1 3", "4\n1 31\n2 2\n2 3\n4 5", "4\n1 31\n2 2\n2 0\n3 3", "4\n1 31\n2 8\n2 3\n1 3", "4\n1 31\n2 8\n2 3\n1 1"], "outputs": ["1750\n", "1700\n", "1750\n", "1750\n", "1750\n", "1700\n", "1750\n", "1750\n"]} | 377 | 222 |
coding | Solve the programming task below in a Python markdown code block.
Dr .: Peter, do you know "Yes, I have a number"?
Peter: I used to do it on TV the other day. You remember something by the number of characters in each word contained in a sentence. "Yes, I have a number", so it means "the number 3.14" and is a keyword ... | {"inputs": ["Yes I have a number\nHow I wish I could calculate an unused bolor for space\nThank you\nEND OF INPUT", "Yes I have a rebmun\nHow I wish I could calculate an unused bolor for space\nThank you\nEND OF INPUT", "Yes I have a rebmun\nHow J wish I could calculate an unused bolor for space\nThank you\nEND OF INPU... | 543 | 420 |
coding | Solve the programming task below in a Python markdown code block.
Given is a string S consisting of lowercase English letters. Find the maximum positive integer K that satisfies the following condition:
* There exists a partition of S into K non-empty strings S=S_1S_2...S_K such that S_i \neq S_{i+1} (1 \leq i \leq K-... | {"inputs": ["a`bbaa", "b`aba`", "b``aaa", "a`bcaa", "a`acaa", "c`aaaa", "b`aaaa", "b`abaa"], "outputs": ["5\n", "6\n", "4\n", "5\n", "5\n", "5\n", "5\n", "5\n"]} | 198 | 84 |
coding | Solve the programming task below in a Python markdown code block.
Animesh has $n$ empty candy jars, numbered from ${1}$ to $n$, with infinite capacity. He performs $m$ operations. Each operation is described by $3$ integers, ${a}$, ${b}$, and ${k}$. Here, ${a}$ and ${b}$ are indices of the jars, and ${k}$ is the number... | {"inputs": ["5 3\n1 2 100\n2 5 100\n3 4 100\n"], "outputs": ["160\n"]} | 660 | 42 |
coding | Solve the programming task below in a Python markdown code block.
Chef is very organised in whatever he does and likes to maintain statistics of his work. Chef has expertise in web development and hence is a regular contributor on a forum. Chef sometimes makes multiple contributions in a single day.. Each day chef make... | {"inputs": ["1\n7\n20 6 5 3 3 1 1"], "outputs": ["1: 2\n3: 2\n5: 1\n6: 1\n20: 1"]} | 310 | 53 |
coding | Solve the programming task below in a Python markdown code block.
You can't possibly imagine how cold our friends are this winter in Nvodsk! Two of them play the following game to warm up: initially a piece of paper has an integer q. During a move a player should write any integer number that is a non-trivial divisor o... | {"inputs": ["9\n", "5\n", "2\n", "8\n", "3\n", "4\n", "7\n", "1\n"], "outputs": ["2\n", "1\n0\n", "1\n0\n", "1\n4\n", "1\n0\n", "2\n", "1\n0\n", "1\n0\n"]} | 418 | 82 |
coding | Solve the programming task below in a Python markdown code block.
In some other world, today is the day before Christmas Eve.
Mr. Takaha is buying N items at a department store. The regular price of the i-th item (1 \leq i \leq N) is p_i yen (the currency of Japan).
He has a discount coupon, and can buy one item with t... | {"inputs": ["2\n100\n100\n", "3\n7\n4428\n55", "3\n3\n4428\n55", "3\n2\n4428\n55", "3\n2\n4428\n76", "3\n1\n4428\n76", "3\n1\n4428\n99", "3\n0\n4428\n99"], "outputs": ["150\n", "2276\n", "2272\n", "2271\n", "2292\n", "2291\n", "2314\n", "2313\n"]} | 292 | 164 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given a 0-indexed integer array nums, return the smallest index i of nums such that i mod 10 == nums[i], or -1 if such index does not exist.
x mod y denotes the remainder when x is divided by y.
Please complete the ... | {"functional": "def check(candidate):\n assert candidate(nums = [0,1,2]) == 0\n assert candidate(nums = [4,3,2,1]) == 2\n assert candidate(nums = [1,2,3,4,5,6,7,8,9,0]) == -1\n assert candidate(nums = [2,1,3,5,2]) == 1\n\n\ncheck(Solution().smallestEqual)"} | 99 | 104 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given an integer num. You know that Bob will sneakily remap one of the 10 possible digits (0 to 9) to another digit.
Return the difference between the maximum and minimum values Bob can make by remapping exact... | {"functional": "def check(candidate):\n assert candidate(num = 11891) == 99009\n assert candidate(num = 90) == 99\n\n\ncheck(Solution().minMaxDifference)"} | 181 | 54 |
coding | Solve the programming task below in a Python markdown code block.
We will buy a product for N yen (the currency of Japan) at a shop.
If we use only 1000-yen bills to pay the price, how much change will we receive?
Assume we use the minimum number of bills required.
-----Constraints-----
- 1 \leq N \leq 10000
- N is ... | {"inputs": ["8", "0", "1", "2", "3", "4", "6", "9"], "outputs": ["992\n", "0\n", "999\n", "998\n", "997\n", "996\n", "994\n", "991\n"]} | 163 | 76 |
coding | Solve the programming task below in a Python markdown code block.
Alice and Bob have participated to a Rock Off with their bands. A jury of true metalheads rates the two challenges, awarding points to the bands on a scale from 1 to 50 for three categories: Song Heaviness, Originality, and Members' outfits.
For each on... | {"functional": "_inputs = [[[47, 7, 2], [47, 7, 2]], [[47, 50, 22], [26, 47, 12]], [[25, 50, 22], [34, 49, 50]], [[8, 8, 11], [3, 8, 10]], [[20, 32, 18], [48, 25, 40]], [[5, 6, 7], [3, 6, 10]], [[21, 39, 15], [50, 1, 12]], [[0, 1, 2], [1, 2, 0]]]\n_outputs = [['0, 0: that looks like a \"draw\"! Rock on!'], ['3, 0: Alic... | 357 | 443 |
coding | Solve the programming task below in a Python markdown code block.
Read problems statements in Mandarin Chinese and Russian.
Tanu has got interested in signs and gestures that we use for communication. One such gesture is the head-bob.
When we want to signal "Yes" to someone, we move the head up-and-down. For "No", t... | {"inputs": ["3\n5\nNNNYY\n6\nNNINNI\n4\nNNNN"], "outputs": ["NOT INDIAN\nINDIAN\nNOT SURE"]} | 407 | 39 |
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.
The *beauty* of a sequence of non-negative integers is computed in the following way: for each of its non-empty (not necessarily contiguous) subseque... | {"inputs": ["3\n2 2 7\n4 3 17\n3 5 13"], "outputs": ["6\n-1\n28"]} | 461 | 38 |
coding | Solve the programming task below in a Python markdown code block.
Create a function that takes a number and finds the factors of it, listing them in **descending** order in an **array**.
If the parameter is not an integer or less than 1, return `-1`. In C# return an empty array.
For Example:
`factors(54)` should retu... | {"functional": "_inputs = [[-4], [0], [-12], ['a'], [4.5], ['hello world'], [54], [49], [1]]\n_outputs = [[-1], [-1], [-1], [-1], [-1], [-1], [[54, 27, 18, 9, 6, 3, 2, 1]], [[49, 7, 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... | 125 | 241 |
coding | Solve the programming task below in a Python markdown code block.
Champernown constant is an irrational number represented in decimal by "0." followed by concatenation of all positive integers in the increasing order. The first few digits of this constant are: 0.123456789101112...
Your task is to write a program that ... | {"inputs": ["3 5\n6 7\n0 0", "4 5\n1 7\n0 0", "8 5\n6 7\n0 0", "3 5\n6 5\n0 0", "2 5\n1 0\n0 0", "2 5\n0 0\n0 0", "4 5\n0 0\n0 0", "4 1\n0 0\n0 0"], "outputs": ["34567\n6789101\n", "45678\n1234567\n", "89101\n6789101\n", "34567\n67891\n", "23456\n\n", "23456\n", "45678\n", "4\n"]} | 206 | 201 |
coding | Solve the programming task below in a Python markdown code block.
There are n banks in the city where Vasya lives, they are located in a circle, such that any two banks are neighbouring if their indices differ by no more than 1. Also, bank 1 and bank n are neighbours if n > 1. No bank is a neighbour of itself.
Vasya h... | {"inputs": ["1\n0\n", "1\n0\n", "3\n5 0 -5\n", "3\n5 0 -5\n", "4\n0 0 0 0\n", "3\n6 -1 -5\n", "4\n-1 0 1 0\n", "4\n1 2 3 -6\n"], "outputs": ["0\n", "0", "1\n", "1", "0\n", "2\n", "2\n", "3\n"]} | 486 | 115 |
coding | Solve the programming task below in a Python markdown code block.
You are given a long decimal number $a$ consisting of $n$ digits from $1$ to $9$. You also have a function $f$ that maps every digit from $1$ to $9$ to some (possibly the same) digit from $1$ to $9$.
You can perform the following operation no more than ... | {"inputs": ["1\n5\n1 2 3 4 5 6 7 8 9\n", "1\n9\n2 3 4 5 6 7 8 9 1\n", "1\n2\n9 7 6 2 2 6 2 4 4\n", "1\n3\n2 8 4 5 4 1 7 2 3\n", "1\n2\n1 4 4 8 8 8 7 3 2\n", "1\n3\n4 9 9 6 8 4 5 5 5\n", "1\n6\n4 8 2 6 8 8 8 8 3\n", "1\n3\n8 7 8 7 8 5 8 2 2\n"], "outputs": ["5\n", "9\n", "7\n", "4\n", "4\n", "9\n", "8\n", "8\n"]} | 434 | 230 |
coding | Solve the programming task below in a Python markdown code block.
Step through my `green glass door`.
You can take the `moon`, but not the `sun`.
You can take your `slippers`, but not your `sandals`.
You can go through `yelling`, but not `shouting`.
You can't run through `fast`, but you can run with `speed`.
You c... | {"functional": "_inputs = [['moon'], ['test'], ['glasses'], ['airplane'], ['free'], ['branch'], ['aardvark']]\n_outputs = [[True], [False], [True], [False], [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.isclose(a, b, rel_t... | 149 | 196 |
coding | Solve the programming task below in a Python markdown code block.
Write a program that extracts n different numbers from the numbers 0 to 100 and outputs the number of combinations that add up to s. Each n number is from 0 to 100, and the same number cannot be used in one combination. For example, if n is 3 and s is 6,... | {"inputs": ["6 6\n3 1\n0 0", "2 8\n4 3\n0 0", "3 4\n1 3\n0 0", "3 4\n2 3\n0 0", "3 0\n2 3\n0 0", "3 1\n2 9\n0 0", "3 6\n3 1\n0 0", "3 12\n3 1\n0 0"], "outputs": ["0\n0\n", "4\n0\n", "1\n1\n", "1\n2\n", "0\n2\n", "0\n5\n", "3\n0", "12\n0\n"]} | 260 | 159 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given a string s, return true if a permutation of the string could form a palindrome and false otherwise.
Please complete the following python code precisely:
```python
class Solution:
def canPermutePalindrome(s... | {"functional": "def check(candidate):\n assert candidate(s = \"code\") == False\n assert candidate(s = \"aab\") == True\n assert candidate(s = \"carerac\") == True\n\n\ncheck(Solution().canPermutePalindrome)"} | 70 | 56 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given two integers representing the numerator and denominator of a fraction, return the fraction in string format.
If the fractional part is repeating, enclose the repeating part in parentheses.
If multiple answers ar... | {"functional": "def check(candidate):\n assert candidate(numerator = 1, denominator = 2) == \"0.5\"\n assert candidate(numerator = 2, denominator = 1) == \"2\"\n assert candidate(numerator = 4, denominator = 333) == \"0.(012)\"\n\n\ncheck(Solution().fractionToDecimal)"} | 120 | 86 |
coding | Solve the programming task below in a Python markdown code block.
# Task
You are given three integers `l, d and x`. Your task is:
```
• determine the minimal integer n
such that l ≤ n ≤ d, and the sum of its digits equals x.
• determine the maximal integer m
such that l ≤ m ≤ d, and the sum of its digits equ... | {"functional": "_inputs = [[100, 200, 10], [123, 456, 5], [99, 501, 5], [99, 234, 1], [99, 234, 19], [99, 5001, 27], [99, 5001, 28], [2000, 7000, 3]]\n_outputs = [[[109, 190]], [[131, 410]], [[104, 500]], [[100, 100]], [[199, 199]], [[999, 4995]], [[1999, 4996]], [[2001, 3000]]]\nimport math\ndef _deep_eq(a, b, tol=1e-... | 290 | 341 |
coding | Solve the programming task below in a Python markdown code block.
In this problem you are to calculate the sum of all integers from 1 to n, but you should take all powers of two with minus in the sum.
For example, for n = 4 the sum is equal to - 1 - 2 + 3 - 4 = - 4, because 1, 2 and 4 are 2^0, 2^1 and 2^2 respective... | {"inputs": ["1\n4\n", "1\n8\n", "1\n2\n", "1\n3\n", "1\n6\n", "1\n5\n", "1\n7\n", "1\n16\n"], "outputs": ["-4\n", "6\n", "-3\n", "0\n", "7\n", "1\n", "14\n", "74\n"]} | 245 | 90 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given an m x n picture consisting of black 'B' and white 'W' pixels, return the number of black lonely pixels.
A black lonely pixel is a character 'B' that located at a specific position where the same row and same co... | {"functional": "def check(candidate):\n assert candidate(picture = [[\"W\",\"W\",\"B\"],[\"W\",\"B\",\"W\"],[\"B\",\"W\",\"W\"]]) == 3\n assert candidate(picture = [[\"B\",\"B\",\"B\"],[\"B\",\"B\",\"W\"],[\"B\",\"B\",\"B\"]]) == 0\n\n\ncheck(Solution().findLonelyPixel)"} | 109 | 91 |
coding | Solve the programming task below in a Python markdown code block.
Simon and Antisimon play a game. Initially each player receives one fixed positive integer that doesn't change throughout the game. Simon receives number a and Antisimon receives number b. They also have a heap of n stones. The players take turns to make... | {"inputs": ["1 1 2\n", "2 2 1\n", "2 1 1\n", "2 1 2\n", "4 2 5\n", "1 2 1\n", "9 5 1\n", "1 1 1\n"], "outputs": ["1\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n"]} | 586 | 102 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given the root of a perfect binary tree, reverse the node values at each odd level of the tree.
For example, suppose the node values at level 3 are [2,1,3,4,7,11,29,18], then it should become [18,29,11,7,4,3,1,2].
R... | {"functional": "def check(candidate):\n assert is_same_tree(candidate(root = tree_node([2,3,5,8,13,21,34])), tree_node([2,5,3,8,13,21,34]))\n assert is_same_tree(candidate(root = tree_node([7,13,11])), tree_node([7,11,13]))\n assert is_same_tree(candidate(root = tree_node([0,1,2,0,0,0,0,1,1,1,1,2,2,2,2])), tre... | 229 | 178 |
coding | Solve the programming task below in a Python markdown code block.
In the wake of the npm's `left-pad` debacle, you decide to write a new super padding method that superceds the functionality of `left-pad`. Your version will provide the same functionality, but will additionally add right, and justified padding of string... | {"functional": "_inputs = [['test', 10], ['test', 10, 'x'], ['test', 10, 'xO'], ['test', 10, 'xO-'], ['some other test', 10, 'nope'], ['some other test', 10, '> '], ['test', 7, '>nope'], ['test', 7, '^more complex'], ['test', 7, ''], ['test', 10, '< '], ['test', 3], ['test', 3, '> '], ['test', 10, ''], ['test', 10, '>'... | 482 | 390 |
coding | Solve the programming task below in a Python markdown code block.
Given a string ``string`` that contains only letters, you have to find out the number of **unique** strings (including ``string`` itself) that can be produced by re-arranging the letters of the ``string``. Strings are case **insensitive**.
HINT: Genera... | {"functional": "_inputs = [['AB'], ['ABC'], ['AbA'], ['ABBb'], ['AbcD'], ['AAA'], [''], ['ASTON'], ['BEST'], ['ABcDEFgHIJ'], ['ABcDEFgHIJbaslidbailsbdilasbdkanmsdklhkbHSJKHVDASH'], ['ABcDEFgHIJbaslidbailsbdilasbdkanmsdklhkbHSJKHVDASHVVYQVWKDVDWQUV']]\n_outputs = [[2], [6], [3], [4], [24], [1], [1], [120], [24], [362880... | 244 | 408 |
coding | Solve the programming task below in a Python markdown code block.
Prize
Segtree entered a programming contest with a team of $ N $ and won a $ K $ yen prize! I'm trying to distribute this prize now.
Each $ N $ team member, including Segtree, is numbered from $ 1 $ to $ N $ in order of ability. Segtree is $ 1 $.
If t... | {"inputs": ["1 2", "2 1", "1 3", "1 4", "1 6", "2 8", "1 9", "2 2"], "outputs": ["2\n", "1\n", "3\n", "4\n", "6\n", "5\n", "9\n", "1\n"]} | 319 | 78 |
coding | Solve the programming task below in a Python markdown code block.
Manasa is a student in the department of Mathematics. She is pretty good at doing calculations involving small numbers, but large numbers scare her. So she wants you to help her in the following calculations.
Given two numbers in the following manner:
... | {"inputs": ["2\n2 1 2 \n3 1 2\n"], "outputs": ["72\n"]} | 618 | 28 |
coding | Solve the programming task below in a Python markdown code block.
Given an Array of length $N$ containing elements $Ai$ ( i = 1 to n ) . You have to handle $Q$ queries on this array . Each Query is of two types k=(1 or 2).
Type 1:- $k$ $l$ $r$ in which you have to tell whether the product of numbers in range l to r ... | {"inputs": ["4\n2 2 3 4\n4\n1 1 2\n1 3 4\n2 3 3\n1 1 4"], "outputs": ["YES\nNO\nYES"]} | 665 | 50 |
coding | Solve the programming task below in a Python markdown code block.
The programming competition season has already started and it's time to train for ICPC. Sereja coaches his teams for a number of year and he knows that to get ready for the training session it's not enough to prepare only problems and editorial. As the t... | {"inputs": ["1\n0\n", "1\n1\n", "1\n2\n", "1\n3\n", "1\n2\n", "1\n1\n", "1\n0\n", "1\n3\n"], "outputs": ["YES\n", "NO\n", "YES\n", "NO\n", "YES\n", "NO\n", "YES\n", "NO\n"]} | 601 | 86 |
coding | Solve the programming task below in a Python markdown code block.
Two players play a game. The game is played on a rectangular board with n × m squares. At the beginning of the game two different squares of the board have two chips. The first player's goal is to shift the chips to the same square. The second player aim... | {"inputs": ["5 5 1 1 5 4\n", "6 2 6 1 1 2\n", "6 6 1 1 1 6\n", "5 5 1 1 5 3\n", "6 6 1 1 6 1\n", "5 4 1 4 5 1\n", "4 5 1 1 4 5\n", "5 5 1 5 4 1\n"], "outputs": ["Second\n", "Second\n", "Second\n", "First\n", "Second\n", "Second\n", "Second\n", "Second\n"]} | 606 | 150 |
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, find all pairs of elements with the minimum absolute difference of any two elements.
Return a list of pairs in ascending order(with respect to pairs), each pair [a, b] follows
... | {"functional": "def check(candidate):\n assert candidate(arr = [4,2,1,3]) == [[1,2],[2,3],[3,4]]\n assert candidate(arr = [1,3,6,10,15]) == [[1,3]]\n assert candidate(arr = [3,8,-10,23,19,-4,-14,27]) == [[-14,-10],[19,23],[23,27]]\n\n\ncheck(Solution().minimumAbsDifference)"} | 123 | 126 |
coding | Solve the programming task below in a Python markdown code block.
In order to win over and get noticed by his favorite streamer Daenerys, Jon decides to donate a significant amount of money . Every donation made to Daenerys is of $at$ $least$ $1$ $beastcoin$ and is displayed on Daenerys's stream alongside any message w... | {"inputs": ["2\n3\n7"], "outputs": ["4\n8"]} | 436 | 18 |
coding | Solve the programming task below in a Python markdown code block.
You are given $n$ packages of $w_i$ kg from a belt conveyor in order ($i = 0, 1, ... n-1$). You should load all packages onto $k$ trucks which have the common maximum load $P$. Each truck can load consecutive packages (more than or equals to zero) from t... | {"inputs": ["4 2\n1\n1\n2\n6", "4 2\n1\n1\n3\n1", "4 2\n1\n1\n3\n0", "4 2\n1\n4\n3\n0", "3 4\n1\n0\n2\n6", "4 2\n1\n1\n3\n6", "4 2\n1\n2\n3\n0", "4 2\n1\n0\n2\n6"], "outputs": ["6\n", "4\n", "3\n", "5\n", "2\n", "6\n", "3\n", "6\n"]} | 294 | 142 |
coding | Solve the programming task below in a Python markdown code block.
Being a nonconformist, Volodya is displeased with the current state of things, particularly with the order of natural numbers (natural number is positive integer number). He is determined to rearrange them. But there are too many natural numbers, so Volo... | {"inputs": ["7 7\n", "7 1\n", "7 2\n", "8 5\n", "8 3\n", "8 4\n", "1 1\n", "7 2\n"], "outputs": ["6", "1", "3", "2", "5", "7", "1", "3\n"]} | 306 | 79 |
coding | Solve the programming task below in a Python markdown code block.
An expression is formed by taking the digits 1 to 9 in numerical order and then inserting into each gap between the numbers either a plus sign or a minus sign or neither.
Your task is to write a method which takes one parameter and returns the **smalles... | {"functional": "_inputs = [[11], [100], [766], [160], [70], [389]]\n_outputs = [[5], [3], [4], [None], [6], [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_tol=tol, abs_tol=tol)\n if isinstance(a, (list, tuple)):\n i... | 411 | 195 |
coding | Solve the programming task below in a Python markdown code block.
It's IPL time and as usual RCB are finding it tough to qualify for playoffs. RCB needs a minimum of $X$ more points to qualify for playoffs in their remaining $Y$ matches. A win, tie and loss in a match will yield $2,1,0$ points respectively to a team.
... | {"inputs": ["2\n10 5\n1 5"], "outputs": ["5\n0"]} | 397 | 23 |
coding | Solve the programming task below in a Python markdown code block.
This is yet another problem dealing with regular bracket sequences.
We should remind you that a bracket sequence is called regular, if by inserting «+» and «1» into it we can get a correct mathematical expression. For example, sequences «(())()», «()» a... | {"inputs": [")((\n", "()(\n", "())\n", "(((\n", "(()\n", "))(\n", "()(())()\n", "(()())()\n"], "outputs": ["0 1\n", "2 1\n", "2 1\n", "0 1\n", "2 1\n", "0 1\n", "8 1\n", "8 1\n"]} | 237 | 95 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given an array of strings words, find the longest string in words such that every prefix of it is also in words.
For example, let words = ["a", "app", "ap"]. The string "app" has prefixes "ap" and "a", all of which a... | {"functional": "def check(candidate):\n assert candidate(words = [\"k\",\"ki\",\"kir\",\"kira\", \"kiran\"]) == \"kiran\"\n assert candidate(words = [\"a\", \"banana\", \"app\", \"appl\", \"ap\", \"apply\", \"apple\"]) == \"apple\"\n assert candidate(words = [\"abc\", \"bc\", \"ab\", \"qwe\"]) == \"\"\n\n\nche... | 143 | 104 |
coding | Solve the programming task below in a Python markdown code block.
We will play a one-player game using a number line and N pieces.
First, we place each of these pieces at some integer coordinate.
Here, multiple pieces can be placed at the same coordinate.
Our objective is to visit all of the M coordinates X_1, X_2, ...... | {"inputs": ["111 0\n-608", "111 0\n-624", "110 0\n-4833", "010 1\n-4464", "100 1\n-4199", "111 0\n-3124", "110 0\n-3872", "111 0\n-4743"], "outputs": ["0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n"]} | 390 | 140 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given a 0-indexed 1-dimensional (1D) integer array original, and two integers, m and n. You are tasked with creating a 2-dimensional (2D) array with m rows and n columns using all the elements from original.
... | {"functional": "def check(candidate):\n assert candidate(original = [1,2,3,4], m = 2, n = 2) == [[1,2],[3,4]]\n assert candidate(original = [1,2,3], m = 1, n = 3) == [[1,2,3]]\n assert candidate(original = [1,2], m = 1, n = 1) == []\n assert candidate(original = [3], m = 1, n = 2) == []\n\n\ncheck(Solution(... | 205 | 135 |
coding | Solve the programming task below in a Python markdown code block.
Each pizza consists of 4 slices. There are N friends and each friend needs exactly X slices.
Find the minimum number of pizzas they should order to satisfy their appetite.
------ Input Format ------
- The first line of input will contain a single in... | {"inputs": ["4\n1 5\n2 6\n4 3\n3 5\n"], "outputs": ["2\n3\n3\n4\n"]} | 383 | 36 |
coding | Solve the programming task below in a Python markdown code block.
Given an array A consisting of N integers A_{1},A_{2},…,A_{N}, determine if you can sort this array by applying the following operation several times (possibly, zero):
Pick a pair of indices (i,j) with i \neq j and A_{i} \mathbin{\&} A_{j} \neq 0,... | {"inputs": ["4\n3\n6 4 2\n6\n9 34 4 24 1 6\n6\n9 34 24 4 1 6\n2\n1 0"], "outputs": ["Yes\nYes\nNo\nNo"]} | 602 | 64 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Write a method that finds the maximum of two numbers. You should not use if-else or any other comparison operator.
Please complete the following python code precisely:
```python
class Solution:
def maximum(self, a... | {"functional": "def check(candidate):\n assert candidate(a = 1, b = 2) == 2\n\n\ncheck(Solution().maximum)"} | 73 | 35 |
coding | Solve the programming task below in a Python markdown code block.
Chef has X 5 rupee coins and Y 10 rupee coins. Chef goes to a shop to buy chocolates for Chefina where each chocolate costs Z rupees. Find the maximum number of chocolates that Chef can buy for Chefina.
------ Input Format ------
- The first line cont... | {"inputs": ["4\n10 10 10\n3 1 8\n8 1 3\n4 4 1000"], "outputs": ["15\n3\n16\n0\n"]} | 507 | 51 |
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 of non-negative integers nums. For each integer in nums, you must find its respective second greater integer.
The second greater integer of nums[i] is nums[j] such that:
j > i
nums[j] ... | {"functional": "def check(candidate):\n assert candidate(nums = [2,4,0,9,6]) == [9,6,6,-1,-1]\n assert candidate(nums = [3,3]) == [-1,-1]\n\n\ncheck(Solution().secondGreaterElement)"} | 214 | 66 |
coding | Solve the programming task below in a Python markdown code block.
Thor is getting used to the Earth. As a gift Loki gave him a smartphone. There are n applications on this phone. Thor is fascinated by this phone. He has only one minor issue: he can't count the number of unread notifications generated by those applicati... | {"inputs": ["300000 1\n2 44767\n", "300000 1\n1 300000\n", "300000 1\n2 300000\n", "3 4\n1 3\n1 1\n1 3\n2 3\n", "3 4\n2 3\n1 1\n1 3\n2 3\n", "3 4\n2 3\n2 1\n1 3\n2 3\n", "3 4\n2 3\n2 1\n2 3\n2 3\n", "3 4\n1 3\n1 2\n1 2\n2 3\n"], "outputs": ["0\n", "1\n", "0\n", "1\n2\n3\n1\n", "0\n1\n2\n1\n", "0\n0\n1\n0\n", "0\n0\n0\n... | 672 | 237 |
coding | Solve the programming task below in a Python markdown code block.
Problem description.
Dominic Toretto has taken his crew to compete in this years' Race Wars, a crew-on-crew tournament in which each member of one crew competes with a member of the other crew in a quarter mile drag race. Each win counts as one point for... | {"inputs": ["1\n3\n5 4 1\n5 4 1"], "outputs": ["2"]} | 594 | 26 |
coding | Solve the programming task below in a Python markdown code block.
Alex doesn't like boredom. That's why whenever he gets bored, he comes up with games. One long winter evening he came up with a game and decided to play it.
Given a sequence a consisting of n integers. The player can make several steps. In a single step... | {"inputs": ["2\n1 2\n", "3\n1 2 3\n", "1\n100000\n", "5\n3 3 4 5 4\n", "5\n5 3 5 3 4\n", "5\n4 2 3 2 5\n", "5\n3 3 8 5 4\n", "5\n5 3 5 5 4\n"], "outputs": ["2\n", "4\n", "100000\n", "11\n", "16\n", "9\n", "19\n", "18\n"]} | 337 | 146 |
coding | Solve the programming task below in a Python markdown code block.
We all know that Share market is place where drastic change occurs within moments. So we have one Stockholder, Isabella, who wants to maximize her profit by selling her shares. She has $N$ shares of a Doofenshmirtz Corporation which is represented by $N$... | {"inputs": ["1\n4\n1 2\n4 3\n3 5\n2 4"], "outputs": ["3"]} | 454 | 34 |
coding | Solve the programming task below in a Python markdown code block.
A big company decided to launch a new series of rectangular displays, and decided that the display must have exactly n pixels.
Your task is to determine the size of the rectangular display — the number of lines (rows) of pixels a and the number of colu... | {"inputs": ["8\n", "5\n", "1\n", "2\n", "3\n", "4\n", "6\n", "7\n"], "outputs": ["2 4\n", "1 5\n", "1 1\n", "1 2\n", "1 3\n", "2 2\n", "2 3\n", "1 7\n"]} | 300 | 86 |
coding | Solve the programming task below in a Python markdown code block.
Create a function `longer` that accepts a string and sorts the words in it based on their respective lengths in an ascending order. If there are two words of the same lengths, sort them alphabetically. Look at the examples below for more details.
```pyt... | {"functional": "_inputs = [['Another Green World'], ['Darkness on the edge of Town'], ['Have you ever Seen the Rain'], ['Like a Rolling Stone'], ['This will be our Year'], ['hello Hello']]\n_outputs = [['Green World Another'], ['of on the Town edge Darkness'], ['the you Have Rain Seen ever'], ['a Like Stone Rolling'], ... | 198 | 225 |
coding | Solve the programming task below in a Python markdown code block.
Define a method that accepts 2 strings as parameters. The method returns the first string sorted by the second.
```python
sort_string("foos", "of") == "oofs"
sort_string("string", "gnirts") == "gnirts"
sort_string("banana", "abn") == "aaabnn"
`... | {"functional": "_inputs = [['banana', 'abn'], ['banana', 'xyz'], ['banana', 'an'], ['foos', 'of'], ['string', 'gnirts'], ['banana', 'a'], ['bungholio', 'aacbuoldiiaoh'], ['fumyarhncujlj', 'nsejcwn']]\n_outputs = [['aaabnn'], ['banana'], ['aaannb'], ['oofs'], ['gnirts'], ['aaabnn'], ['buoolihng'], ['njjcfumyarhul']]\nim... | 169 | 257 |
coding | Solve the programming task below in a Python markdown code block.
Given is an integer sequence A_1, ..., A_N of length N.
We will choose exactly \left\lfloor \frac{N}{2} \right\rfloor elements from this sequence so that no two adjacent elements are chosen.
Find the maximum possible sum of the chosen elements.
Here \lfl... | {"inputs": ["6\n1 2 6 4 5 6", "6\n1 2 4 4 5 6", "6\n1 2 4 3 4 6", "6\n1 2 6 2 2 2", "6\n1 2 3 4 5 6", "6\n1 2 3 4 5 6\n", "6\n1 2 11 4 5 6", "6\n1 2 6 2 3 -1"], "outputs": ["13\n", "12\n", "11\n", "9\n", "12", "12\n", "18\n", "10\n"]} | 219 | 166 |
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 of even length consisting of an equal number of positive and negative integers.
You should return the array of nums such that the the array follows the given conditions:
E... | {"functional": "def check(candidate):\n assert candidate(nums = [3,1,-2,-5,2,-4]) == [3,-2,1,-5,2,-4]\n assert candidate(nums = [-1,1]) == [1,-1]\n\n\ncheck(Solution().rearrangeArray)"} | 146 | 71 |
coding | Solve the programming task below in a Python markdown code block.
Here you have to do some mathematical operations on a "dirty string". This kata checks some basics, it's not too difficult.
__So what to do?__
Input: String which consists of two positive numbers (doubles) and exactly one operator like `+, -, * or /` ... | {"functional": "_inputs = [[';$%\u00a7fsdfsd235??df/sdfgf5gh.000kk0000'], ['sdfsd23454sdf*2342'], ['fsdfsd235???34.4554s4234df-sdfgf2g3h4j442'], ['fsdfsd234.4554s4234df+sf234442'], ['a1a2b3c.c0c/a1a0b.cc00c']]\n_outputs = [['47'], ['54929268'], ['-210908'], ['234676'], ['12']]\nimport math\ndef _deep_eq(a, b, tol=1e-5)... | 245 | 313 |
coding | Solve the programming task below in a Python markdown code block.
Arseniy is already grown-up and independent. His mother decided to leave him alone for m days and left on a vacation. She have prepared a lot of food, left some money and washed all Arseniy's clothes.
Ten minutes before her leave she realized that it w... | {"inputs": ["3 2 3\n1 2 3\n1 2\n2 3\n", "3 2 2\n1 1 2\n1 2\n2 1\n", "3 2 3\n1 2 3\n1 2\n2 3\n", "3 2 2\n1 1 2\n1 2\n2 1\n", "4 2 4\n1 2 3 4\n1 2\n3 4\n", "4 2 4\n1 2 3 4\n1 2\n3 4\n", "4 2 4\n1 2 3 4\n1 3\n3 4\n", "4 2 4\n1 2 1 4\n1 3\n3 4\n"], "outputs": ["2\n", "0\n", "2", "0", "2\n", "2", "2\n", "1\n"]} | 711 | 219 |
coding | Solve the programming task below in a Python markdown code block.
Petya and Vasya are tossing a coin. Their friend Valera is appointed as a judge. The game is very simple. First Vasya tosses a coin x times, then Petya tosses a coin y times. If the tossing player gets head, he scores one point. If he gets tail, nobody g... | {"inputs": ["3 2 1 1\n", "2 4 2 2\n", "1 1 1 1\n", "4 5 2 3\n", "9 7 4 7\n", "5 5 3 2\n", "4 5 2 3\n", "9 7 4 7\n"], "outputs": ["3\n2 1\n3 1\n3 2\n", "0\n", "0\n", "1\n4 3\n", "2\n8 7\n9 7\n", "6\n3 2\n4 2\n4 3\n5 2\n5 3\n5 4\n", "1\n4 3\n", "2\n8 7\n9 7\n"]} | 464 | 178 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.