task_type stringclasses 1
value | problem stringlengths 209 3.39k | answer stringlengths 35 6.15k | problem_tokens int64 60 774 | answer_tokens int64 12 2.04k |
|---|---|---|---|---|
coding | Solve the programming task below in a Python markdown code block.
You would like to get the 'weight' of a name by getting the sum of the ascii values. However you believe that capital letters should be worth more than mere lowercase letters. Spaces, numbers, or any other character are worth 0.
Normally in ascii
a... | {"functional": "_inputs = [['Joe'], ['CJ'], ['cj'], ['George Washington'], ['Billy Bob Joe'], ['King George II'], ['r2d2'], ['R2D2'], ['C3PO']]\n_outputs = [[254], [205], [141], [1275], [909], [1012], [150], [214], [322]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\... | 206 | 236 |
coding | Solve the programming task below in a Python markdown code block.
Monocarp is playing a MMORPG. There are two commonly used types of currency in this MMORPG — gold coins and silver coins. Monocarp wants to buy a new weapon for his character, and that weapon costs $n$ silver coins. Unfortunately, right now, Monocarp has... | {"inputs": ["4\n100 25 30\n9999997 25 50\n52 50 48\n49 50 1\n"], "outputs": ["4\n400000\n1\n1\n"]} | 612 | 66 |
coding | Solve the programming task below in a Python markdown code block.
You are given integers N and K. Find the number of triples (a,b,c) of positive integers not greater than N such that a+b,b+c and c+a are all multiples of K. The order of a,b,c does matter, and some of them can be the same.
Constraints
* 1 \leq N,K \leq... | {"inputs": ["4 3", "3 2", "5 3", "56 6", "20 6", "25 4", "25 7", "74 1"], "outputs": ["1\n", "9", "1", "1458\n", "54\n", "432\n", "27\n", "405224\n"]} | 211 | 93 |
coding | Solve the programming task below in a Python markdown code block.
Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Chef has $N$ items in his shop (numbered $1$ through $N$); for each valid $i$, the price of the $i$-th item is $P_{i}$. Since Chef has very loyal cus... | {"inputs": ["3\n5 4\n10 2 3 4 5\n7 15\n1 2 3 4 5 6 7\n5 5\n10 9 8 7 6"], "outputs": ["7\n0\n15"]} | 720 | 66 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given an array of strings queries and a string pattern, return a boolean array answer where answer[i] is true if queries[i] matches pattern, and false otherwise.
A query word queries[i] matches pattern if you can inse... | {"functional": "def check(candidate):\n assert candidate(queries = [\"FooBar\",\"FooBarTest\",\"FootBall\",\"FrameBuffer\",\"ForceFeedBack\"], pattern = \"FB\") == [True,False,True,True,False]\n assert candidate(queries = [\"FooBar\",\"FooBarTest\",\"FootBall\",\"FrameBuffer\",\"ForceFeedBack\"], pattern = \"FoBa... | 126 | 142 |
coding | Solve the programming task below in a Python markdown code block.
Story:
In the realm of numbers, the apocalypse has arrived. Hordes of zombie numbers have infiltrated and are ready to turn everything into undead. The properties of zombies are truly apocalyptic: they reproduce themselves unlimitedly and freely interact... | {"functional": "_inputs = [[[7, 11]], [[1, 7, 15]], [[2, 10]], [[687, 829, 998]], [[]], [[1]]]\n_outputs = [[59], [0], [-1], [45664], [-1], [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 isinstan... | 420 | 216 |
coding | Solve the programming task below in a Python markdown code block.
Given an array, return the difference between the count of even numbers and the count of odd numbers. `0` will be considered an even number.
```
For example:
solve([0,1,2,3]) = 0 because there are two even numbers and two odd numbers. Even - Odd = 2 - ... | {"functional": "_inputs = [[[0, 1, 2, 3]], [[0, 1, 2, 3, 'a', 'b']], [[0, 15, 'z', 16, 'm', 13, 14, 'c', 9, 10, 13, 'u', 4, 3]], [[13, 6, 8, 15, 4, 8, 13]], [[1, 'a', 17, 8, 'e', 3, 'i', 12, 1]], [[5, 15, 16, 10, 6, 4, 16, 't', 13, 'n', 14, 'k', 'n', 0, 'q', 'd', 7, 9]]]\n_outputs = [[0], [0], [0], [1], [-2], [2]]\nimp... | 307 | 357 |
coding | Solve the programming task below in a Python markdown code block.
You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format hours change from 1 to 12, while in 24-hours it changes from 0 to 23. In both formats minutes change from 0 to 59.
You are given... | {"inputs": ["24\n17:30\n", "12\n17:30\n", "24\n99:99\n", "12\n05:54\n", "12\n00:05\n", "24\n23:80\n", "24\n73:16\n", "12\n03:77\n"], "outputs": ["17:30\n", "07:30\n", "09:09\n", "05:54\n", "01:05\n", "23:00\n", "03:16\n", "03:07\n"]} | 412 | 158 |
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. A subarray of nums is called continuous if:
Let i, i + 1, ..., j be the indices in the subarray. Then, for each pair of indices i <= i1, i2 <= j, 0 <= |nums[i1] - nums[i2... | {"functional": "def check(candidate):\n assert candidate(nums = [5,4,2,4]) == 8\n assert candidate(nums = [1,2,3]) == 6\n\n\ncheck(Solution().continuousSubarrays)"} | 147 | 54 |
coding | Solve the programming task below in a Python markdown code block.
You are given two arrays `arr1` and `arr2`, where `arr2` always contains integers.
Write the function `find_array(arr1, arr2)` such that:
For `arr1 = ['a', 'a', 'a', 'a', 'a']`, `arr2 = [2, 4]`
`find_array returns ['a', 'a']`
For `arr1 = [0, 1, 5, 2, ... | {"functional": "_inputs = [[['a', 'a', 'a', 'a', 'a'], [2, 4]], [[0, 1, 5, 2, 1, 8, 9, 1, 5], [1, 4, 7]], [[1, 2, 3, 4, 5], [0]], [['this', 'is', 'test'], [0, 1, 2]], [[0, 3, 4], [2, 6]], [[1], []], [[], [2]], [[], []]]\n_outputs = [[['a', 'a']], [[1, 1, 1]], [[1]], [['this', 'is', 'test']], [[4]], [[]], [[]], [[]]]\ni... | 335 | 308 |
coding | Solve the programming task below in a Python markdown code block.
Valera's lifelong ambition was to be a photographer, so he bought a new camera. Every day he got more and more clients asking for photos, and one day Valera needed a program that would determine the maximum number of people he can serve.
The camera's me... | {"inputs": ["1 22\n3 5\n1 3\n", "1 22\n0 5\n1 3\n", "1 22\n0 5\n0 3\n", "1 22\n0 2\n0 3\n", "1 100\n6 10\n14 8\n", "1 110\n6 10\n14 8\n", "1 100\n6 10\n14 19\n", "2 160\n6 9\n11 9\n6 6\n"], "outputs": ["1\n1\n", "1\n1 \n", "1\n1 \n", "1\n1 \n", "0\n\n", "0\n\n", "0\n\n", "1\n2\n"]} | 577 | 190 |
coding | Solve the programming task below in a Python markdown code block.
Manasa loves the nim game, in which there are $n$ buckets, each having $A_i$ balls. Two players play alternately. Each turn consists of removing some non-zero number of balls from one of the bucket. A player with lack of moves looses. But, Manasa having ... | {"inputs": ["2\n2\n10 10\n3\n2 2 3\n"], "outputs": ["Sandy\nManasa\n"]} | 641 | 34 |
coding | Solve the programming task below in a Python markdown code block.
In distant future on Earth day lasts for n hours and that's why there are n timezones. Local times in adjacent timezones differ by one hour. For describing local time, hours numbers from 1 to n are used, i.e. there is no time "0 hours", instead of it "n ... | {"inputs": ["2\n5 1\n1 2\n", "2\n5 1\n1 2\n", "3\n1 2 3\n1 3\n", "3\n1 4 3\n1 3\n", "3\n1 2 3\n1 3\n", "2\n909 8422\n1 2\n", "5\n1 2 3 4 1\n1 3\n", "2\n5072 8422\n1 2\n"], "outputs": ["1\n", "1", "3\n", "3\n", "3", "2\n", "4\n", "2\n"]} | 533 | 155 |
coding | Solve the programming task below in a Python markdown code block.
Vasya has a grid with $2$ rows and $n$ columns. He colours each cell red, green, or blue.
Vasya is colourblind and can't distinguish green from blue. Determine if Vasya will consider the two rows of the grid to be coloured the same.
-----Input-----
T... | {"inputs": ["1\n5\nRRRRR\nRRRRR\n", "1\n7\nGGGRRBR\nGGGRRBB\n", "1\n7\nGRBBBBR\nGGGRRGG\n", "1\n30\nRBBBBBRRBRBBBBBRBBBBBRBBBBRBBB\nBBBRRBRRBBRBBBBRBBBBBRBBBBRBBB\n", "6\n2\nRG\nRB\n4\nGRBG\nGBGB\n5\nGGGGG\nBBBBB\n7\nBBBBBBB\nRRRRRRR\n8\nRGBRRGBR\nRGGRRBGR\n1\nG\nG\n", "1\n55\nBBBBBBBBBBBBBBBBBBBGGGGGGGGGGGGGGGGGGGGGGG... | 474 | 238 |
coding | Solve the programming task below in a Python markdown code block.
# Task
There are `n` bears in the orchard and they picked a lot of apples.
They distribute apples like this:
```
The first bear divided the apple into n piles, each with the same number. leaving an apple at last, and the apple was thrown away. Then h... | {"functional": "_inputs = [[2], [5]]\n_outputs = [[7], [3121]]\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 a... | 677 | 166 |
coding | Solve the programming task below in a Python markdown code block.
You are given an integer sequence $1, 2, \dots, n$. You have to divide it into two sets $A$ and $B$ in such a way that each element belongs to exactly one set and $|sum(A) - sum(B)|$ is minimum possible.
The value $|x|$ is the absolute value of $x$ and ... | {"inputs": ["3\n", "5\n", "6\n", "1\n", "2\n", "4\n", "4\n", "2\n"], "outputs": ["0\n", "1\n", "1\n", "1\n", "1\n", "0\n", "0\n", "1\n"]} | 360 | 70 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
There is a 1-based binary matrix where 0 represents land and 1 represents water. You are given integers row and col representing the number of rows and columns in the matrix, respectively.
Initially on day 0, the enti... | {"functional": "def check(candidate):\n assert candidate(row = 2, col = 2, cells = [[1,1],[2,1],[1,2],[2,2]]) == 2\n assert candidate(row = 2, col = 2, cells = [[1,1],[1,2],[2,1],[2,2]]) == 1\n assert candidate(row = 3, col = 3, cells = [[1,2],[2,1],[3,3],[2,2],[1,1],[1,3],[2,3],[3,2],[3,1]]) == 3\n\n\ncheck(S... | 270 | 149 |
coding | Solve the programming task below in a Python markdown code block.
Write a program to determine if a string contains only unique characters.
Return true if it does and false otherwise.
The string may contain any of the 128 ASCII characters.
Characters are case-sensitive, e.g. 'a' and 'A' are considered different charac... | {"functional": "_inputs = [[' nAa'], ['abcdef'], ['++-']]\n_outputs = [[False], [True], [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... | 91 | 171 |
coding | Solve the programming task below in a Python markdown code block.
In programming languages like C/C++, a goto statement provides an unconditional jump from the "goto" to a labeled statement. For example, a statement "goto CHECK_NUM;" is executed, control of the program jumps to CHECK_NUM. Using these constructs, you ca... | {"inputs": ["9", "7", "4", "53", "17", "28", "13", "25"], "outputs": [" 3 6 9\n", " 3 6\n", " 3\n", " 3 6 9 12 13 15 18 21 23 24 27 30 31 32 33 34 35 36 37 38 39 42 43 45 48 51 53\n", " 3 6 9 12 13 15\n", " 3 6 9 12 13 15 18 21 23 24 27\n", " 3 6 9 12 13\n", " 3 6 9 12 13 15 18 21 23 24\n"]} | 318 | 233 |
coding | Solve the programming task below in a Python markdown code block.
Athenaeus has just finished creating his latest musical composition and will present it tomorrow to the people of Athens. Unfortunately, the melody is rather dull and highly likely won't be met with a warm reception.
His song consists of $n$ notes, whic... | {"inputs": ["5\n6\n1 2 2 2 5 6\n2\n4 4\n6\n1 1 3 4 4 5\n1\n1\n6\n1 1 1 2 2 2\n", "5\n6\n1 2 2 2 5 6\n2\n2 4\n6\n1 1 3 4 4 5\n1\n1\n6\n1 1 1 2 2 2\n", "5\n6\n1 2 2 2 5 6\n2\n4 4\n6\n1 1 3 4 4 5\n1\n1\n6\n1 1 1 2 2 3\n", "5\n6\n1 2 2 4 5 6\n2\n2 4\n6\n1 1 3 4 4 5\n1\n1\n6\n1 1 2 2 2 2\n", "5\n6\n1 2 2 4 5 6\n2\n2 4\n6\n1... | 640 | 550 |
coding | Solve the programming task below in a Python markdown code block.
Luba is surfing the Internet. She currently has n opened tabs in her browser, indexed from 1 to n from left to right. The mouse cursor is currently located at the pos-th tab. Luba needs to use the tabs with indices from l to r (inclusive) for her studies... | {"inputs": ["6 3 2 4\n", "6 3 1 3\n", "5 2 1 5\n", "6 4 2 5\n", "7 4 2 5\n", "6 5 2 4\n", "5 4 2 4\n", "6 6 3 5\n"], "outputs": ["5\n", "1\n", "0\n", "6\n", "6\n", "5\n", "4\n", "5\n"]} | 528 | 118 |
coding | Solve the programming task below in a Python markdown code block.
Red John has committed another murder. This time, he doesn't leave a red smiley behind. Instead he leaves a puzzle for Patrick Jane to solve. He also texts Teresa Lisbon that if Patrick is successful, he will turn himself in. The puzzle begins as follows... | {"inputs": ["2\n1\n7\n"], "outputs": ["0\n3\n"]} | 585 | 20 |
coding | Solve the programming task below in a Python markdown code block.
How Many Divisors?
Write a program which reads three integers a, b and c, and prints the number of divisors of c between a and b.
Constraints
* 1 ≤ a, b, c ≤ 10000
* a ≤ b
Input
Three integers a, b and c are given in a line separated by a single spa... | {"inputs": ["6 2 4", "6 2 1", "6 1 1", "6 0 1", "4 0 0", "1 0 0", "2 0 0", "1 1 0"], "outputs": ["0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "1\n"]} | 116 | 94 |
coding | Solve the programming task below in a Python markdown code block.
You will be given the prime factors of a number as an array.
E.g: ```[2,2,2,3,3,5,5,13]```
You need to find the number, n, to which that prime factorization belongs.
It will be:
```
n = 2³.3².5².13 = 23400
```
Then, generate the divisors of this number.... | {"functional": "_inputs = [[[2, 3, 5, 5]], [[2, 3, 3, 3, 7]], [[3, 3, 3, 11]], [[2, 13, 2, 5, 2, 5, 3, 3]]]\n_outputs = [[[150, 11, 2, 75]], [[378, 15, 2, 189]], [[297, 7, 3, 99]], [[23400, 71, 2, 11700]]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return ... | 668 | 282 |
coding | Solve the programming task below in a Python markdown code block.
Today at the lesson Vitya learned a very interesting function — mex. Mex of a sequence of numbers is the minimum non-negative number that is not present in the sequence as element. For example, mex([4, 33, 0, 1, 1, 5]) = 2 and mex([1, 2, 3]) = 0.
Vitya ... | {"inputs": ["2 2\n1 6\n1\n3\n", "2 2\n2 5\n1\n1\n", "2 2\n1 3\n2\n3\n", "2 2\n1 6\n1\n0\n", "2 2\n1 6\n1\n1\n", "2 2\n1 3\n1\n1\n", "2 2\n1 5\n1\n1\n", "2 2\n2 5\n2\n1\n"], "outputs": ["1\n0\n", "0\n0\n", "0\n1\n", "1\n1\n", "1\n0\n", "1\n0\n", "1\n0\n", "1\n0\n"]} | 364 | 166 |
coding | Solve the programming task below in a Python markdown code block.
Vasily has a deck of cards consisting of n cards. There is an integer on each of the cards, this integer is between 1 and 100 000, inclusive. It is possible that some cards have the same integers on them.
Vasily decided to sort the cards. To do this, he... | {"inputs": ["1\n1000\n", "1\n1001\n", "1\n1011\n", "1\n1111\n", "1\n0111\n", "1\n1010\n", "1\n1110\n", "1\n1100\n"], "outputs": ["1\n", "1\n", "1\n", "1\n", "1\n", "1\n", "1\n", "1\n"]} | 553 | 110 |
coding | Solve the programming task below in a Python markdown code block.
Given is a permutation P of \{1, 2, \ldots, N\}.
For a pair (L, R) (1 \le L \lt R \le N), let X_{L, R} be the second largest value among P_L, P_{L+1}, \ldots, P_R.
Find \displaystyle \sum_{L=1}^{N-1} \sum_{R=L+1}^{N} X_{L,R}.
-----Constraints-----
- 2... | {"inputs": ["2\n1 2\n", "3\n1 3 2", "3\n3 1 2", "3\n3 2 1", "3\n2 1 3", "3\n1 2 3", "3\n1 3 2", "3\n1 2 3"], "outputs": ["1\n", "5\n", "4\n", "5\n", "4\n", "5\n", "5\n", "5\n"]} | 302 | 109 |
coding | Solve the programming task below in a Python markdown code block.
Your task is to make function, which returns the sum of a sequence of integers.
The sequence is defined by 3 non-negative values: **begin**, **end**, **step**.
If **begin** value is greater than the **end**, function should returns **0**
*Examples*
~... | {"functional": "_inputs = [[2, 6, 2], [1, 5, 1], [1, 5, 3], [0, 15, 3], [16, 15, 3], [2, 24, 22], [2, 2, 2], [2, 2, 1], [1, 15, 3], [15, 1, 3]]\n_outputs = [[12], [15], [5], [45], [0], [26], [2], [2], [35], [0]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n r... | 161 | 280 |
coding | Solve the programming task below in a Python markdown code block.
Cheffina challanges chef to rearrange the given array as arr[i] > arr[i+1] < arr[i+2] > arr[i+3].. and so on…, i.e. also arr[i] < arr[i+2] and arr[i+1] < arr[i+3] and arr[i] < arr[i+3] so on.. Chef accepts the challenge, chef starts coding but his code i... | {"inputs": ["2\n4\n4 1 6 3\n5\n4 5 1 6 3"], "outputs": ["3 1 6 4\n3 1 5 4 6"]} | 290 | 50 |
coding | Solve the programming task below in a Python markdown code block.
The Romans have attacked again. This time they are much more than the Persians but Shapur is ready to defeat them. He says: "A lion is never afraid of a hundred sheep".
Nevertheless Shapur has to find weaknesses in the Roman army to defeat them. So he ... | {"inputs": ["3\n5 2 1\n", "3\n4 3 1\n", "3\n4 2 1\n", "3\n3 2 1\n", "3\n2 3 1\n", "3\n2 7 11\n", "4\n7 8 3 1\n", "4\n1 5 0 4\n"], "outputs": ["1\n", "1\n", "1\n", "1", "0", "0", "2\n", "0\n"]} | 337 | 120 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given a digit string s that consists of digits from 0 to 9.
A string is called semi-repetitive if there is at most one adjacent pair of the same digit. For example, "0010", "002020", "0123", "2002", and "54944... | {"functional": "def check(candidate):\n assert candidate(s = \"52233\") == 4\n assert candidate(s = \"5494\") == 4\n assert candidate(s = \"1111111\") == 2\n\n\ncheck(Solution().longestSemiRepetitiveSubstring)"} | 206 | 74 |
coding | Solve the programming task below in a Python markdown code block.
You have an array $a_1, a_2, \dots, a_n$.
Let's call some subarray $a_l, a_{l + 1}, \dots , a_r$ of this array a subpermutation if it contains all integers from $1$ to $r-l+1$ exactly once. For example, array $a = [2, 2, 1, 3, 2, 3, 1]$ contains $6$ su... | {"inputs": ["5\n1 1 2 1 2\n", "5\n1 1 2 1 2\n", "8\n2 4 1 3 4 2 1 2\n", "8\n2 4 1 3 4 3 1 2\n", "8\n2 7 1 3 4 3 1 2\n", "8\n2 8 2 3 4 3 1 2\n", "8\n2 8 1 3 4 6 1 2\n", "8\n2 4 1 3 4 6 2 2\n"], "outputs": ["6\n", "6\n", "7\n", "6\n", "5\n", "4\n", "3\n", "2\n"]} | 480 | 186 |
coding | Solve the programming task below in a Python markdown code block.
Given integers ${b}$ and $a$, find the smallest integer ${h}$, such that there exists a triangle of height ${h}$, base ${b}$, having an area of at least $a$.
Example
$b=4$
${a=6}$
The minimum height ${h}$ is $3$. One example is a triangle formed... | {"inputs": ["2 2\n", "17 100\n"], "outputs": ["2\n", "12\n"]} | 485 | 30 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
There are n children standing in a line. Each child is assigned a rating value given in the integer array ratings.
You are giving candies to these children subjected to the following requirements:
Each child must hav... | {"functional": "def check(candidate):\n assert candidate(ratings = [1,0,2]) == 5\n assert candidate(ratings = [1,2,2]) == 4\n\n\ncheck(Solution().candy)"} | 122 | 53 |
coding | Solve the programming task below in a Python markdown code block.
Complete the function that calculates the derivative of a polynomial. A polynomial is an expression like: 3x^(4) - 2x^(2) + x - 10
### How to calculate the derivative:
* Take the exponent and multiply it with the coefficient
* Reduce the exponent by 1
... | {"functional": "_inputs = [['4x+1'], ['-4x-1'], ['x^2+2x+1'], ['0'], ['-100'], ['-x^2+3x+4'], ['-x^5-x^4-x^3'], ['10x^9+10x^3+10x'], ['100x^5+12x^3-3x-3'], ['-1000x^7+200x^4+6x^2+x+1000']]\n_outputs = [['4'], ['-4'], ['2x+2'], ['0'], ['0'], ['-2x+3'], ['-5x^4-4x^3-3x^2'], ['90x^8+30x^2+10'], ['500x^4+36x^2-3'], ['-7000... | 327 | 357 |
coding | Solve the programming task below in a Python markdown code block.
Given an integer N, Chef wants to find the smallest positive integer M such that the bitwise XOR of M and M+1 is N. If no such M exists output -1.
-----Input-----
The first line of input contain an integer T denoting the number of test cases. Each of th... | {"inputs": ["1\n3", "1\n1", "1\n2", "1\n7", "1\n6", "1\n4", "1\n8", "1\n5"], "outputs": ["1", "2\n", "-1\n", "3\n", "-1\n", "-1\n", "-1\n", "-1\n"]} | 179 | 77 |
coding | Solve the programming task below in a Python markdown code block.
Computation of the date either previous or forthcoming dates is quiet easy. But it is quiet difficult to calculate the day from a particular given date.
You are required to find a day from a particular date given to you.
-----Input-----
It consists of ... | {"inputs": ["14 3 2012"], "outputs": ["Wednesday"]} | 162 | 20 |
coding | Solve the programming task below in a Python markdown code block.
There are n squirrel(s) waiting below the feet of m chestnut tree(s). The first chestnut of the i-th tree will fall right after T_{i} second(s), and one more every P_{i} second(s) after that. The “big mama” of squirrels wants them to bring their nest no ... | {"inputs": ["2\n3 2 5\n5 1 2\n1 2 1\n3 2 5\n5 1 2\n1 1 1"], "outputs": ["4\n3"]} | 642 | 50 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
In an alien language, surprisingly, they also use English lowercase letters, but possibly in a different order. The order of the alphabet is some permutation of lowercase letters.
Given a sequence of words written in ... | {"functional": "def check(candidate):\n assert candidate(words = [\"hello\",\"leetcode\"], order = \"hlabcdefgijkmnopqrstuvwxyz\") == True\n assert candidate(words = [\"word\",\"world\",\"row\"], order = \"worldabcefghijkmnpqstuvxyz\") == False\n assert candidate(words = [\"apple\",\"app\"], order = \"abcdefgh... | 124 | 99 |
coding | Solve the programming task below in a Python markdown code block.
# Task:
Based on the received dimensions, `a` and `b`, of an ellipse, calculare its area and perimeter.
## Example:
```python
Input: ellipse(5,2)
Output: "Area: 31.4, perimeter: 23.1"
```
**Note:** The perimeter approximation formula you should use: ... | {"functional": "_inputs = [[5, 2], [6, 8], [13, 1]]\n_outputs = [['Area: 31.4, perimeter: 23.1'], ['Area: 150.8, perimeter: 44.2'], ['Area: 40.8, perimeter: 54.6']]\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=t... | 128 | 219 |
coding | Solve the programming task below in a Python markdown code block.
A has a string consisting of some number of lowercase English letters 'a'. He gives it to his friend B who appends some number of letters 'b' to the end of this string. Since both A and B like the characters 'a' and 'b', they have made sure that at this ... | {"inputs": ["c\n", "a\n", "b\n", "c\n", "b\n", "a\n", "cc\n", "bc\n"], "outputs": ["NO\n", "NO\n", "NO\n", "NO\n", "NO\n", "NO\n", "NO\n", "NO\n"]} | 421 | 70 |
coding | Solve the programming task below in a Python markdown code block.
Pavel cooks barbecue. There are n skewers, they lay on a brazier in a row, each on one of n positions. Pavel wants each skewer to be cooked some time in every of n positions in two directions: in the one it was directed originally and in the reversed dir... | {"inputs": ["1\n1\n0\n", "1\n1\n1\n", "1\n1\n0\n", "1\n1\n1\n", "2\n1 2\n0 0\n", "2\n2 1\n0 0\n", "2\n1 2\n0 1\n", "2\n2 1\n1 0\n"], "outputs": ["1\n", "0\n", "1\n", "0\n", "3\n", "1\n", "2\n", "0\n"]} | 541 | 118 |
coding | Solve the programming task below in a Python markdown code block.
You have N coins each of which has a value ai. Find the number of combinations that result when you choose K different coins in such a way that the total value of the coins is greater than or equal to L and less than or equal to R.
Constraints
* 1 ≤ K ... | {"inputs": ["2 2 2 9\n5 1", "2 2 2 9\n9 1", "2 1 1 9\n6 1", "2 2 2 9\n9 2", "2 2 2 9\n1 2", "2 3 2 9\n1 2", "2 3 2 9\n1 0", "2 3 1 9\n1 0"], "outputs": ["1\n", "0\n", "2\n", "0\n", "1\n", "0\n", "0\n", "0\n"]} | 192 | 142 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given two strings first and second, consider occurrences in some text of the form "first second third", where second comes immediately after first, and third comes immediately after second.
Return an array of all the ... | {"functional": "def check(candidate):\n assert candidate(text = \"alice is a good girl she is a good student\", first = \"a\", second = \"good\") == [\"girl\",\"student\"]\n assert candidate(text = \"we will we will rock you\", first = \"we\", second = \"will\") == [\"we\",\"rock\"]\n\n\ncheck(Solution().findOcur... | 109 | 89 |
coding | Solve the programming task below in a Python markdown code block.
Given are an integer N and four characters c_{\mathrm{AA}}, c_{\mathrm{AB}}, c_{\mathrm{BA}}, and c_{\mathrm{BB}}.
Here, it is guaranteed that each of those four characters is A or B.
Snuke has a string s, which is initially AB.
Let |s| denote the length... | {"inputs": ["4\nA\nB\nB\nA\n", "2\nB\nA\nA\nA\n", "2\nA\nB\nA\nA\n", "2\nB\nB\nA\nA\n", "2\nA\nA\nB\nA\n", "2\nB\nA\nB\nA\n", "2\nA\nB\nB\nA\n", "2\nB\nB\nB\nA\n"], "outputs": ["2\n", "1\n", "1\n", "1\n", "1\n", "1\n", "1\n", "1\n"]} | 547 | 134 |
coding | Solve the programming task below in a Python markdown code block.
Chef has a string S with him. Chef is happy if the string contains a contiguous substring of length strictly greater than 2 in which all its characters are vowels.
Determine whether Chef is happy or not.
Note that, in english alphabet, vowels are a, e... | {"inputs": ["4\naeiou\nabxy\naebcdefghij\nabcdeeafg\n"], "outputs": ["Happy\nSad\nSad\nHappy\n"]} | 405 | 38 |
coding | Solve the programming task below in a Python markdown code block.
Let's write all the positive integer numbers one after another from $1$ without any delimiters (i.e. as a single string). It will be the infinite sequence starting with 123456789101112131415161718192021222324252627282930313233343536...
Your task is to p... | {"inputs": ["7\n", "1\n", "2\n", "3\n", "4\n", "5\n", "6\n", "8\n"], "outputs": ["7\n", "1\n", "2\n", "3\n", "4\n", "5\n", "6\n", "8\n"]} | 206 | 70 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given a string s, return the length of the longest substring between two equal characters, excluding the two characters. If there is no such substring return -1.
A substring is a contiguous sequence of characters with... | {"functional": "def check(candidate):\n assert candidate(s = \"aa\") == 0\n assert candidate(s = \"abca\") == 2\n assert candidate(s = \"cbzxy\") == -1\n assert candidate(s = \"cabbac\") == 4\n\n\ncheck(Solution().maxLengthBetweenEqualCharacters)"} | 93 | 74 |
coding | Solve the programming task below in a Python markdown code block.
The ship crashed into a reef and is sinking. Now the entire crew must be evacuated. All n crew members have already lined up in a row (for convenience let's label them all from left to right with positive integers from 1 to n) and await further instructi... | {"inputs": ["1\nA captain\n", "2\nA captain\nB man\n", "2\nX captain\nY rat\n", "2\nX captain\nZ rat\n", "2\nX child\nY captain\n", "2\nB woman\nA captain\n", "2\nX child\nW captain\n", "2\nB woman\n@ captain\n"], "outputs": ["A\n", "B\nA\n", "Y\nX\n", "Z\nX\n", "X\nY\n", "B\nA\n", "X\nW\n", "B\n@\n"]} | 448 | 129 |
coding | Solve the programming task below in a Python markdown code block.
You are given an array A of length N.
The *interesting value* of a subarray is defined as the product of the maximum and minimum elements of the subarray.
Find the minimum and maximum *interesting value* over all subarrays for the given array.
Note: ... | {"inputs": ["2\n2\n2 2\n3\n5 0 9\n"], "outputs": ["4 4\n0 81"]} | 620 | 34 |
coding | Solve the programming task below in a Python markdown code block.
M-kun is a competitor in AtCoder, whose highest rating is X.
In this site, a competitor is given a kyu (class) according to his/her highest rating. For ratings from 400 through 1999, the following kyus are given:
* From 400 through 599: 8-kyu
* From 600... | {"inputs": ["543", "609", "982", "554", "417", "979", "424", "470"], "outputs": ["8\n", "7\n", "6\n", "8\n", "8\n", "6\n", "8\n", "8\n"]} | 328 | 78 |
coding | Solve the programming task below in a Python markdown code block.
Read problems statements in [Mandarin Chinese], [Russian], [Vietnamese] and [Bengali] as well.
Chef is participating in an ICPC regional contest, in which there is a total of $N$ problems (numbered $1$ through $N$) with varying difficulties. For each va... | {"inputs": ["3\n7\n1 2 3 4 5 7 6\n8\n8 7 6 5 4 3 2 1\n9\n7 4 3 5 6 1 8 2 9"], "outputs": ["7\n8\n8"]} | 548 | 70 |
coding | Solve the programming task below in a Python markdown code block.
Monocarp wants to watch $n$ videos. Each video is only one minute long, but its size may be arbitrary. The $i$-th video has the size $a_i$ megabytes. All videos are published on the Internet. A video should be downloaded before it can be watched. Monocar... | {"inputs": ["1 1\n1\n", "1 294\n132\n", "2 15\n14 1\n", "2 15\n14 2\n", "4 3\n1 3 2 3\n", "5 6\n1 2 3 4 5\n", "5 5\n1 2 3 4 5\n", "4 100\n11 3 3 6\n"], "outputs": ["2\n", "133\n", "16\n", "18\n", "12\n", "16\n", "17\n", "24\n"]} | 584 | 153 |
coding | Solve the programming task below in a Python markdown code block.
You are given three sticks with positive integer lengths of a, b, and c centimeters. You can increase length of some of them by some positive integer number of centimeters (different sticks can be increased by a different length), but in total by at most... | {"inputs": ["1 1 1 2\n", "1 2 3 1\n", "1 2 1 5\n", "2 7 8 4\n", "1 2 1 5\n", "2 7 8 4\n", "1 2 2 5\n", "2 7 8 0\n"], "outputs": ["4\n", "2\n", "20\n", "25\n", "20\n", "25\n", "23\n", "1\n"]} | 344 | 123 |
coding | Solve the programming task below in a Python markdown code block.
There's a chip in the point $(0, 0)$ of the coordinate plane. In one operation, you can move the chip from some point $(x_1, y_1)$ to some point $(x_2, y_2)$ if the Euclidean distance between these two points is an integer (i.e. $\sqrt{(x_1-x_2)^2+(y_1-y... | {"inputs": ["3\n8 6\n0 0\n9 15\n"], "outputs": ["1\n0\n2\n"]} | 467 | 31 |
coding | Solve the programming task below in a Python markdown code block.
We have a sandglass consisting of two bulbs, bulb A and bulb B. These bulbs contain some amount of sand.
When we put the sandglass, either bulb A or B lies on top of the other and becomes the upper bulb. The other bulb becomes the lower bulb.
The sand dr... | {"inputs": ["180\n3\n60 120 180\n3\n30 16\n61 1\n7 282", "180\n3\n85 120 180\n3\n2 9\n74 1\n238 180", "180\n3\n60 74 180\n3\n30 16\n61 1\n180 180", "180\n3\n60 74 173\n3\n30 16\n61 1\n180 316", "180\n3\n60 140 180\n3\n30 16\n61 1\n74 316", "180\n3\n30 32 180\n3\n30 16\n34 1\n180 316", "180\n3\n85 45 180\n3\n30 90\n45 1... | 545 | 378 |
coding | Solve the programming task below in a Python markdown code block.
A car number in Berland consists of exactly n digits. A number is called beautiful if it has at least k equal digits. Vasya wants to change the digits in his car's number so that the number became beautiful. To replace one of n digits Vasya has to pay th... | {"inputs": ["2 2\n11\n", "2 2\n80\n", "2 2\n09\n", "2 2\n10\n", "2 2\n85\n", "2 2\n15\n", "2 2\n24\n", "2 1\n24\n"], "outputs": ["0\n11\n", "8\n00\n", "9\n00\n", "1\n00\n", "3\n55\n", "4\n11\n", "2\n22\n", "0\n24\n"]} | 510 | 134 |
coding | Solve the programming task below in a Python markdown code block.
Shaun is very much interested in Subarrays. Shaun wants to count the number of subarrays in his chosen array with sum being a multiple of $10^9$. Since, Shaun is interested in huge numbers.He chose his array such that it contains only $10^8$ and $9*10^8$... | {"inputs": ["2\n3\n100000000 900000000 100000000\n1\n900000000"], "outputs": ["2\n0"]} | 295 | 58 |
coding | Solve the programming task below in a Python markdown code block.
Snuke found a record of a tree with N vertices in ancient ruins. The findings are as follows:
* The vertices of the tree were numbered 1,2,...,N, and the edges were numbered 1,2,...,N-1.
* Edge i connected Vertex a_i and b_i.
* The length of each edge w... | {"inputs": ["4\n1 2\n2 3\n3 4\n8 6 6 8", "5\n1 2\n1 3\n1 2\n1 5\n9 21 16 4 22", "5\n1 2\n1 2\n1 2\n1 5\n2 13 16 7 28", "5\n1 2\n1 2\n1 2\n1 4\n2 13 16 7 28", "5\n1 2\n1 3\n1 3\n1 5\n9 21 16 5 22", "5\n1 2\n1 3\n1 2\n1 4\n8 21 29 19 6", "5\n1 2\n1 2\n1 4\n1 5\n2 13 16 19 5", "5\n1 2\n1 3\n1 4\n1 5\n5 13 16 19 22"], "out... | 606 | 331 |
coding | Solve the programming task below in a Python markdown code block.
There were n groups of students which came to write a training contest. A group is either one person who can write the contest with anyone else, or two people who want to write the contest in the same team.
The coach decided to form teams of exactly thr... | {"inputs": ["2\n2 2\n", "2\n1 1\n", "2\n2 1\n", "2\n1 2\n", "2\n2 1\n", "2\n1 1\n", "2\n1 2\n", "2\n2 2\n"], "outputs": ["0\n", "0\n", "1\n", "1\n", "1", "0", "1", "0"]} | 414 | 98 |
coding | Solve the programming task below in a Python markdown code block.
You are given several queries. In the i-th query you are given a single positive integer ni. You are to represent ni as a sum of maximum possible number of composite summands and print this maximum number, or print -1, if there are no such splittings.
A... | {"inputs": ["1\n8\n", "1\n15\n", "1\n19\n", "1\n12\n", "2\n3\n7\n", "2\n3\n4\n", "2\n3\n1\n", "2\n6\n8\n"], "outputs": ["2\n", "2\n", "3\n", "3\n", "-1\n-1\n", "-1\n1\n", "-1\n-1\n", "1\n2\n"]} | 333 | 107 |
coding | Solve the programming task below in a Python markdown code block.
Limak is a grizzly bear who desires power and adoration. He wants to win in upcoming elections and rule over the Bearland.
There are n candidates, including Limak. We know how many citizens are going to vote for each candidate. Now i-th candidate would ... | {"inputs": ["2\n7 6\n", "2\n1 1\n", "2\n1 1\n", "2\n1 2\n", "2\n3 6\n", "2\n7 6\n", "2\n3 11\n", "2\n96 97\n"], "outputs": ["0\n", "1\n", "1", "1\n", "2\n", "0", "5\n", "1\n"]} | 497 | 103 |
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.
One day, Saeed was teaching a string compression algorithm. This algorithm finds all maximal substrings which contains only one character repeated one... | {"inputs": ["3\nbbbbbbbbbbaa\nc\naaaaaaaaaabcdefgh"], "outputs": ["YES\nNO\nNO"]} | 498 | 28 |
coding | Solve the programming task below in a Python markdown code block.
Chef has an array A of length N.
In one operation, Chef can choose any two distinct indices i, j (1 ≤ i, j ≤ N, i \neq j) and either change A_{i} to A_{j} or change A_{j} to A_{i}.
Find the minimum number of operations required to make all the elements... | {"inputs": ["4\n3\n1 2 3\n4\n5 5 5 5\n4\n2 2 1 1\n3\n1 1 2\n"], "outputs": ["2\n0\n2\n1\n"]} | 590 | 56 |
coding | Solve the programming task below in a Python markdown code block.
There are N piles of stones. The i-th pile has A_i stones.
Aoki and Takahashi are about to use them to play the following game:
- Starting with Aoki, the two players alternately do the following operation:
- Operation: Choose one pile of stones, and re... | {"inputs": ["2\n3 6", "2\n5 5", "2\n7 5", "2\n5 1", "2\n7 7", "2\n3 1", "2\n7 1", "2\n3 2"], "outputs": ["-1\n", "0\n", "1\n", "2\n", "0\n", "1\n", "3\n", "-1\n"]} | 402 | 95 |
coding | Solve the programming task below in a Python markdown code block.
You probably know the "like" system from Facebook and other pages. People can "like" blog posts, pictures or other items. We want to create the text that should be displayed next to such an item.
Implement a function `likes :: [String] -> String`, which... | {"functional": "_inputs = [[[]], [['Peter']], [['Jacob', 'Alex']], [['Max', 'John', 'Mark']], [['Alex', 'Jacob', 'Mark', 'Max']]]\n_outputs = [['no one likes this'], ['Peter likes this'], ['Jacob and Alex like this'], ['Max, John and Mark like this'], ['Alex, Jacob and 2 others like this']]\nimport math\ndef _deep_eq(a... | 231 | 220 |
coding | Solve the programming task below in a Python markdown code block.
Vasya got really tired of these credits (from problem F) and now wants to earn the money himself! He decided to make a contest to gain a profit.
Vasya has $n$ problems to choose from. They are numbered from $1$ to $n$. The difficulty of the $i$-th probl... | {"inputs": ["1 10\n1 13\n", "1 10\n1 13\n", "1 16\n1 13\n", "1 235\n15 210\n", "1 235\n15 210\n", "1 235\n23 210\n", "1 235\n23 340\n", "3 5\n1 8\n2 19\n3 11\n"], "outputs": ["0\n", " 0\n", "3\n", "25\n", " ... | 519 | 161 |
coding | Solve the programming task below in a Python markdown code block.
You are given a string q. A sequence of k strings s_1, s_2, ..., s_{k} is called beautiful, if the concatenation of these strings is string q (formally, s_1 + s_2 + ... + s_{k} = q) and the first characters of these strings are distinct.
Find any beauti... | {"inputs": ["1\nk\n", "1\nk\n", "1\nl\n", "1\nm\n", "1\nj\n", "1\nzz\n", "26\na\n", "2\nab\n"], "outputs": ["YES\nk\n", "YES\nk\n", "YES\nl\n", "YES\nm\n", "YES\nj\n", "YES\nzz\n", "NO\n", "YES\na\nb\n"]} | 312 | 103 |
coding | Solve the programming task below in a Python markdown code block.
Cat Snuke is learning to write characters.
Today, he practiced writing digits 1 and 9, but he did it the other way around.
You are given a three-digit integer n written by Snuke.
Print the integer obtained by replacing each digit 1 with 9 and each digit ... | {"inputs": ["191", "111", "199", "111", "199", "191", "119", "999"], "outputs": ["919\n", "999\n", "911\n", "999\n", "911\n", "919\n", "991", "111"]} | 219 | 92 |
coding | Solve the programming task below in a Python markdown code block.
Jabber ID on the national Berland service «Babber» has a form <username>@<hostname>[/resource], where
* <username> — is a sequence of Latin letters (lowercase or uppercase), digits or underscores characters «_», the length of <username> is between 1 ... | {"inputs": ["@\n", "/\n", ".\n", "@ops\n", "$@ru\n", "o@ps\n", "%@ru\n", "@mike\n"], "outputs": ["NO\n", "NO\n", "NO\n", "NO\n", "NO\n", "YES\n", "NO\n", "NO\n"]} | 343 | 75 |
coding | Solve the programming task below in a Python markdown code block.
Zonal Computing Olympiad 2015, 29 Nov 2014
An interval is a pair of positive integers [a, b] with a ≤ b. It is meant to denote the set of integers that lie between the values a and b. For example [3,5] denotes the set {3,4,5} while the interval [3, 3] d... | {"inputs": ["2\n3 5\n3 3", "3\n6 9\n3 5\n4 8"], "outputs": ["1", "2"]} | 571 | 38 |
coding | Solve the programming task below in a Python markdown code block.
Your friend gave you a dequeue D as a birthday present.
D is a horizontal cylinder that contains a row of N jewels.
The values of the jewels are V_1, V_2, ..., V_N from left to right. There may be jewels with negative values.
In the beginning, you have n... | {"inputs": ["1 1\n1\n", "2 40\n770493 0\n", "1 100\n4847850\n", "6 2\n0 9 0 -1 3 2", "6 4\n-10 8 2 0 2 6", "6 4\n-10 3 2 0 2 6", "6 4\n-10 3 4 0 2 6", "6 2\n-10 3 6 0 2 6"], "outputs": ["1\n", "770493\n", "4847850\n", "9\n", "14\n", "10\n", "12\n", "8\n"]} | 504 | 185 |
coding | Solve the programming task below in a Python markdown code block.
One day n friends met at a party, they hadn't seen each other for a long time and so they decided to make a group photo together.
Simply speaking, the process of taking photos can be described as follows. On the photo, each photographed friend occupies... | {"inputs": ["2\n1 5\n2 3\n", "2\n2 3\n1 1\n", "2\n1 1\n1 2\n", "2\n1 1\n1 2\n", "2\n2 3\n1 1\n", "2\n1 5\n2 3\n", "2\n2 6\n1 1\n", "2\n2 5\n2 3\n"], "outputs": ["6 5 ", "1 6 ", "2 1 ", "2 1 ", "1 6 ", "6 5 ", "1 12\n", "6 10\n"]} | 395 | 146 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
In an infinite chess board with coordinates from -infinity to +infinity, you have a knight at square [0, 0].
A knight has 8 possible moves it can make, as illustrated below. Each move is two squares in a cardinal dire... | {"functional": "def check(candidate):\n assert candidate(x = 2, y = 1) == 1\n assert candidate(x = 5, y = 5) == 4\n\n\ncheck(Solution().minKnightMoves)"} | 137 | 54 |
coding | Solve the programming task below in a Python markdown code block.
Read problems statements in [Hindi], [Mandarin Chinese], [Russian], [Vietnamese], and [Bengali] as well.
[Flappy Bird] is on a screen with height $H$ pixels (a 2D plane where the $y$-axis corresponds to the vertical direction). There are $N$ vertical ob... | {"inputs": ["1\n10 4\n0 2 5\n1 5 6\n1 8 8\n0 11 2"], "outputs": ["2 3 2 3"]} | 635 | 48 |
coding | Solve the programming task below in a Python markdown code block.
There is a square field of size $n \times n$ in which two cells are marked. These cells can be in the same row or column.
You are to mark two more cells so that they are the corners of a rectangle with sides parallel to the coordinate axes.
For example... | {"inputs": ["6\n4\n..*.\n....\n*...\n....\n2\n*.\n.*\n2\n.*\n.*\n3\n*.*\n...\n...\n5\n.....\n..*..\n.....\n.*...\n.....\n4\n....\n....\n*...\n*...\n", "6\n4\n..*.\n....\n*...\n....\n2\n*.\n.*\n2\n*.\n.*\n3\n*.*\n...\n...\n5\n.....\n..*..\n.....\n.*...\n.....\n4\n....\n....\n*...\n*...\n", "6\n4\n..*.\n....\n...*\n....\... | 493 | 1,159 |
coding | Solve the programming task below in a Python markdown code block.
### Tongues
Gandalf's writings have long been available for study, but no one has yet figured out what language they are written in. Recently, due to programming work by a hacker known only by the code name ROT13, it has been discovered that Gandalf use... | {"functional": "_inputs = [['Ita dotf ni dyca nsaw ecc.'], ['Tim oh nsa nowa gid ecc fiir wat ni liwa ni nsa eor ig nsaod liytndu.'], ['Giydhlida etr hakat uaedh efi iyd gidagensadh pdiyfsn ytni nsoh'], ['litnotatn e tam tenoit.'], ['Nsa zyolv pdimt gij xywbar ikad nsa cequ rifh.'], ['Tywpadh (1234567890) etr bytlnyeno... | 402 | 1,010 |
coding | Solve the programming task below in a Python markdown code block.
These days, many boys use beautiful girls' photos as dps in Social Networking Profiles. So it is pretty hard to guess whether it is a fake profile or not.Last year, Yogesh went to a forum and had a nice chat with a beauty (he thought so). After that they... | {"inputs": ["rahul", "palak", "payal", "anisha"], "outputs": ["IGNORE HIM!", "CHAT WITH HER!", "CHAT WITH HER!", "IGNORE HIM!"]} | 281 | 41 |
coding | Solve the programming task below in a Python markdown code block.
Today's Random Number
E869120 You ran a campaign called "Today's Random Numbers" for N days. This is a project to generate a random number once a day and post the value on Twitter.
The "random numbers of the day" on day $ 1, 2, 3, \ dots, N $ were $ A_... | {"inputs": ["5\n1 1 0 0 0", "5\n0 0 0 2 1", "5\n0 0 1 2 1", "5\n0 0 1 2 2", "5\n0 0 1 4 2", "5\n0 0 2 4 2", "5\n0 0 2 4 1", "5\n0 0 0 4 1"], "outputs": ["0\n", "1\n", "2\n", "2\n", "2\n", "2\n", "2\n", "1\n"]} | 478 | 142 |
coding | Solve the programming task below in a Python markdown code block.
The prime number sequence starts with: `2,3,5,7,11,13,17,19...`. Notice that `2` is in position `one`.
`3` occupies position `two`, which is a prime-numbered position. Similarly, `5`, `11` and `17` also occupy prime-numbered positions. We shall call pr... | {"functional": "_inputs = [[0, 10], [2, 200], [200, 2000], [500, 10000], [1000, 100000], [2000, 200000], [3000, 400000], [4000, 500000]]\n_outputs = [[8], [1080], [48132], [847039], [52114889], [183035206], [650120994], [972664400]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(... | 425 | 309 |
coding | Solve the programming task below in a Python markdown code block.
You are in a grid of dimensions N \times M.
You are allowed to perform two types of operations:
Go down, left, up, or right each for a cost of X. Formally, if you are at the cell (i,j) of the grid, you can go to either of the cells (i + 1, j), (i, j - 1... | {"inputs": ["3\n5 6 2 5\n4 7 5 6\n7 8 6 5"], "outputs": ["18\n33\n36"]} | 625 | 43 |
coding | Solve the programming task below in a Python markdown code block.
Jaggu is a little kid and he likes playing with water balloons. He took 1 million ( $10^{6} $) empty buckets and he filled the bucket with water balloons under the instruction of his sister Ishika.
His sister gives him two types of commands:
R pos1 po... | {"inputs": ["2\nU 692778 7 291188\nR 636916 747794\n"], "outputs": ["378 \n"]} | 594 | 51 |
coding | Solve the programming task below in a Python markdown code block.
Madoka is going to enroll in "TSUNS PTU". But she stumbled upon a difficult task during the entrance computer science exam:
A number is called good if it is a multiple of $d$.
A number is called beatiful if it is good and it cannot be represented as a ... | {"inputs": ["8\n6 2\n12 2\n36 2\n8 2\n1000 10\n2376 6\n128 4\n16384 4\n"], "outputs": ["NO\nNO\nYES\nNO\nYES\nYES\nNO\nYES\n"]} | 578 | 75 |
coding | Solve the programming task below in a Python markdown code block.
Chef has a permutation P of length 2 \cdot N. He can perform the following operation on P:
Select an index i (1 ≤ i < 2 \cdot N) and swap P_{i} and P_{i + 1}.
Chef would call the permutation P *good*, if the maximum element of the first half of P is les... | {"inputs": ["3\n2\n3 2 1 4\n3\n1 2 3 4 5 6\n3\n6 5 4 3 2 1\n"], "outputs": ["2\n0\n9\n"]} | 522 | 56 |
coding | Solve the programming task below in a Python markdown code block.
Rational numbers are numbers represented by ratios of two integers. For a prime number p, one of the elementary theorems in the number theory is that there is no rational number equal to √p. Such numbers are called irrational numbers. It is also known th... | {"inputs": ["3 4\n3 8\n5 100\n0 0", "3 5\n3 7\n7 101\n0 0", "3 8\n3 8\n5 100\n0 0", "6 8\n3 8\n5 100\n0 0", "3 2\n3 7\n7 101\n0 0", "3 3\n3 7\n7 100\n0 0", "2 6\n3 5\n5 100\n0 0", "3 2\n3 8\n5 100\n0 0"], "outputs": ["2/1 3/2\n7/4 5/3\n85/38 38/17\n", "2/1 5/3\n7/4 5/3\n45/17 82/31\n", "7/4 5/3\n7/4 5/3\n85/38 38/17\n"... | 543 | 398 |
coding | Solve the programming task below in a Python markdown code block.
A positive number $x$ of length $n$ in base $p$ ($2 \le p \le 10^9$) is written on the blackboard. The number $x$ is given as a sequence $a_1, a_2, \dots, a_n$ ($0 \le a_i < p$) — the digits of $x$ in order from left to right (most significant to least s... | {"inputs": ["1\n7 8\n7 7 7 7 7 7 7\n", "11\n2 3\n1 2\n4 2\n1 1 1 1\n6 6\n1 2 3 4 5 0\n5 2\n1 0 1 0 1\n3 10\n1 2 3\n5 1000\n4 1 3 2 5\n3 5\n2 3 4\n4 4\n3 2 3 0\n1 3\n2\n5 5\n1 2 2 2 4\n3 4\n1 0 1\n"], "outputs": ["7\n", "1\n1\n0\n0\n7\n995\n2\n1\n1\n1\n2\n"]} | 746 | 193 |
coding | Solve the programming task below in a Python markdown code block.
An area named Renus, is divided into $(N \times M)$ cells. According to archaeological survey the area contains huge amount of treasure. Some cells out of $(N \times M)$ cells contain treasure. But problem is, you can't go to every cell as some of the ce... | {"inputs": ["1\n3 3\n2\n1 1\n1 3\n2\n2 1\n2 2"], "outputs": ["0 1 0\nX X 1\n4 3 2"]} | 666 | 51 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given the string s, return the size of the longest substring containing each vowel an even number of times. That is, 'a', 'e', 'i', 'o', and 'u' must appear an even number of times.
Please complete the following pyt... | {"functional": "def check(candidate):\n assert candidate(s = \"eleetminicoworoep\") == 13\n assert candidate(s = \"leetcodeisgreat\") == 5\n assert candidate(s = \"bcbcbc\") == 6\n\n\ncheck(Solution().findTheLongestSubstring)"} | 98 | 69 |
coding | Solve the programming task below in a Python markdown code block.
A spy needs your help to encrypt a 5 letter message.
To encrypt the message the following steps are need to be done:
1)Each letter of the message will be converted to it's equivalent number (i.e A=0, B=1,..Z=25)
2)98, 57, 31, 45, 46 are the 5 numbers i... | {"inputs": ["2\nHELLO\nHELL"], "outputs": ["BJQEI\nBJQE"]} | 568 | 22 |
coding | Solve the programming task below in a Python markdown code block.
Everything is great about Ilya's city, except the roads. The thing is, the only ZooVille road is represented as n holes in a row. We will consider the holes numbered from 1 to n, from left to right.
Ilya is really keep on helping his city. So, he wants ... | {"inputs": ["1 1 1\n1 1 1\n", "10 1 3\n5 10 8\n", "10 1 3\n5 10 1\n", "10 1 3\n5 10 14\n", "10 1 3\n5 10 21\n", "10 1 9\n5 10 24\n", "14 1 9\n5 10 24\n", "10 1 9\n5 10 14\n"], "outputs": ["1\n", "8\n", "1\n", "14\n", "21\n", "-1\n", "-1\n", "-1\n"]} | 464 | 171 |
coding | Solve the programming task below in a Python markdown code block.
Chef and his friend is standing on the X-axis at the points X_{1} and X_{2} respectively.
Chef moves one step forward each second (that is he moves to X_{1} + 1 after the 1^{st} second, X_{1} + 2 after the 2^{nd} second, and so on), whereas his friend ... | {"inputs": ["3\n1 1\n1 7\n7 1\n"], "outputs": ["YES\nNO\nYES"]} | 454 | 29 |
coding | Solve the programming task below in a Python markdown code block.
A + B is often used as an example of the easiest problem possible to show some contest platform. However, some scientists have observed that sometimes this problem is not so easy to get accepted. Want to try?
-----Input-----
The input contains two int... | {"inputs": ["5 14\n", "1 14\n", "0 14\n", "0 52\n", "0 87\n", "5 14\n", "-1 14\n", "72 49\n"], "outputs": ["19\n", "15\n", "14\n", "52\n", "87\n", "19\n", "13\n", "121\n"]} | 126 | 104 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
A cinema has n rows of seats, numbered from 1 to n and there are ten seats in each row, labelled from 1 to 10 as shown in the figure above.
Given the array reservedSeats containing the numbers of seats already reserve... | {"functional": "def check(candidate):\n assert candidate(n = 3, reservedSeats = [[1,2],[1,3],[1,8],[2,6],[3,1],[3,10]]) == 4\n assert candidate(n = 2, reservedSeats = [[2,1],[1,8],[2,6]]) == 2\n assert candidate(n = 4, reservedSeats = [[4,3],[1,4],[4,6],[1,7]]) == 4\n\n\ncheck(Solution().maxNumberOfFamilies)"} | 253 | 122 |
coding | Solve the programming task below in a Python markdown code block.
In this simple exercise, you will build a program that takes a value, `integer `, and returns a list of its multiples up to another value, `limit `. If `limit` is a multiple of ```integer```, it should be included as well. There will only ever be positiv... | {"functional": "_inputs = [[5, 25], [1, 2], [5, 7], [4, 27], [11, 54]]\n_outputs = [[[5, 10, 15, 20, 25]], [[1, 2]], [[5]], [[4, 8, 12, 16, 20, 24]], [[11, 22, 33, 44]]]\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_... | 181 | 249 |
coding | Solve the programming task below in a Python markdown code block.
In Berland the opposition is going to arrange mass walking on the boulevard. The boulevard consists of n tiles that are lain in a row and are numbered from 1 to n from right to left. The opposition should start walking on the tile number 1 and the finish... | {"inputs": ["1\n1\n", "1\n17\n", "2\n1 2\n", "1\n500\n", "1\n987\n", "1\n585\n", "1\n435\n", "1\n474\n"], "outputs": ["1\n", "17\n", "1\n", "500\n", "987\n", "585\n", "435\n", "474\n"]} | 577 | 110 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given an array of integers arr and an integer k. Find the least number of unique integers after removing exactly k elements.
Please complete the following python code precisely:
```python
class Solution:
def f... | {"functional": "def check(candidate):\n assert candidate(arr = [5,5,4], k = 1) == 1\n assert candidate(arr = [4,3,1,1,3,3,2], k = 3) == 2\n\n\ncheck(Solution().findLeastNumOfUniqueInts)"} | 85 | 74 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
In combinatorial mathematics, a derangement is a permutation of the elements of a set, such that no element appears in its original position.
You are given an integer n. There is originally an array consisting of n in... | {"functional": "def check(candidate):\n assert candidate(n = 3) == 2\n assert candidate(n = 2) == 1\n\n\ncheck(Solution().findDerangement)"} | 131 | 44 |
coding | Solve the programming task below in a Python markdown code block.
Polycarp starts his own business. Tomorrow will be the first working day of his car repair shop. For now the car repair shop is very small and only one car can be repaired at a given time.
Polycarp is good at marketing, so he has already collected n req... | {"inputs": ["1\n1 1\n", "1\n1 1\n", "2\n6 3\n9 3\n", "2\n6 3\n9 1\n", "2\n6 1\n9 1\n", "2\n6 1\n9 2\n", "2\n6 1\n5 2\n", "2\n6 1\n2 2\n"], "outputs": ["1 1\n", "1 1\n", "6 8\n9 11\n", "6 8\n9 9\n", "6 6\n9 9\n", "6 6\n9 10\n", "6 6\n1 2\n", "6 6\n2 3\n"]} | 749 | 168 |
coding | Solve the programming task below in a Python markdown code block.
Amit is going on a date and he wants to gift his date an array of positive numbers. But he is running short on money. He already has an array of numbers in design. Cost of an array of numbers is the sum of elements in it. But he wants to minimize the cos... | {"inputs": ["3\n5\n8 4 1 5 0\n5\n1 2 4 0 8\n2\n10 10"], "outputs": ["8\n15\n0"]} | 402 | 49 |
coding | Solve the programming task below in a Python markdown code block.
Write a function that flattens an `Array` of `Array` objects into a flat `Array`. Your function must only do one level of flattening.
```python
flatten [1,2,3] # => [1,2,3]
flatten [[1,2,3],["a","b","c"],[1,2,3]] # => [1,2,3,"a","b","c",1,2,3]
flatten... | {"functional": "_inputs = [[[[[3], [4], [5]], [9], [9, 9], [8], [[1, 2, 3]]]], [[[[3], [4], [5]], [9], [9, 9], [8], [[1, 2, 3], [77777]]]], [[[[3], [4], [5]], [9], [9, 9], [8], [[1, 2, 3], [77777]], 'a']], [[[[3], [4], [5]], [9], [9, 9], [8], [[1, 2, 3], [77777]], [['a']]]]]\n_outputs = [[[[3], [4], [5], 9, 9, 9, 8, [1... | 150 | 455 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.