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.
Let us consider the following operations on a string consisting of A and B:
- Select a character in a string. If it is A, replace it with BB. If it is B, replace with AA.
- Select a substring that is equal to either AAA or BBB, and delete it from the s... | {"inputs": ["BBBAAAABA\nBBBBA\n4\n7 9 2 5\n7 9 1 4\n1 7 2 5\n1 6 2 4", "BBBAAAABA\nBBBBA\n4\n7 3 2 5\n7 9 1 4\n1 7 2 5\n1 6 2 4", "BBBAAAABA\nABBBB\n4\n7 9 2 5\n7 9 1 4\n1 7 2 5\n1 7 2 4", "BBBAAAABA\nABBBB\n4\n7 9 2 5\n7 9 1 4\n2 7 2 5\n1 7 2 4", "BBBAABABA\nBBBBA\n4\n7 3 2 5\n1 9 1 4\n1 7 2 5\n2 6 4 4", "BBBAABABA\nB... | 584 | 429 |
coding | Solve the programming task below in a Python markdown code block.
Little Petya likes points a lot. Recently his mom has presented him n points lying on the line OX. Now Petya is wondering in how many ways he can choose three distinct points so that the distance between the two farthest of them doesn't exceed d.
Note t... | {"inputs": ["4 3\n1 2 3 4\n", "4 2\n-3 -2 -1 0\n", "5 19\n1 10 20 30 50\n", "3 1000000000\n-5 -1 1\n", "1 14751211\n847188590\n", "2 1000000000\n-14348867 1760823\n", "10 5\n31 36 43 47 48 50 56 69 71 86\n", "10 50\n1 4 20 27 65 79 82 83 99 100\n"], "outputs": ["4\n", "2\n", "1\n", "1\n", "0\n", "0\n", "2\n", "25\n"]} | 375 | 241 |
coding | Solve the programming task below in a Python markdown code block.
Chef is given three numbers A, B, and C.
He wants to find whether he can select exactly two numbers out of these such that the product of the selected numbers is negative.
------ Input Format ------
- The first line of input will contain a single int... | {"inputs": ["5\n1 5 7\n-5 0 4\n6 -1 0\n-3 -5 -2\n0 0 -4\n"], "outputs": ["NO\nYES\nYES\nNO\nNO\n"]} | 380 | 54 |
coding | Solve the programming task below in a Python markdown code block.
Old timers of Summer Informatics School can remember previous camps in which each student was given a drink of his choice on the vechorka (late-evening meal). Or may be the story was more complicated?
There are $n$ students living in a building, and for... | {"inputs": ["1 1\n1\n", "1 1\n1\n", "1 2\n1\n", "1 1000\n19\n", "1 1000\n548\n", "1 1000\n548\n", "1 1000\n892\n", "1 1000\n406\n"], "outputs": ["1\n", "1\n", "1\n", "1\n", "1\n", "1\n", "1\n", "1\n"]} | 717 | 126 |
coding | Solve the programming task below in a Python markdown code block.
A string $s$ of length $n$ ($1 \le n \le 26$) is called alphabetical if it can be obtained using the following algorithm:
first, write an empty string to $s$ (i.e. perform the assignment $s$ := "");
then perform the next step $n$ times;
at the $i$-th ... | {"inputs": ["1\nbabe\n", "1\nbabe\n", "1\nbbae\n", "1\ndcab\n", "1\nbaae\n", "1\nabae\n", "1\nabbe\n", "1\nebba\n"], "outputs": ["NO\n", "NO\n", "NO\n", "YES\n", "NO\n", "NO\n", "NO\n", "NO\n"]} | 520 | 96 |
coding | Solve the programming task below in a Python markdown code block.
Two friends are on the coordinate axis Ox in points with integer coordinates. One of them is in the point x_1 = a, another one is in the point x_2 = b.
Each of the friends can move by one along the line in any direction unlimited number of times. When ... | {"inputs": ["3\n4\n", "1\n2\n", "2\n1\n", "2\n1\n", "1\n2\n", "1\n4\n", "3\n7\n", "3\n4\n"], "outputs": ["1\n", "1\n", "1\n", "1", "1", "4\n", "6\n", "1"]} | 505 | 83 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given a 2D integer array items where items[i] = [pricei, beautyi] denotes the price and beauty of an item respectively.
You are also given a 0-indexed integer array queries. For each queries[j], you want to de... | {"functional": "def check(candidate):\n assert candidate(items = [[1,2],[3,2],[2,4],[5,6],[3,5]], queries = [1,2,3,4,5,6]) == [2,4,5,5,6,6]\n assert candidate(items = [[1,2],[1,2],[1,3],[1,4]], queries = [1]) == [4]\n assert candidate(items = [[10,1000]], queries = [5]) == [0]\n\n\ncheck(Solution().maximumBeau... | 165 | 131 |
coding | Solve the programming task below in a Python markdown code block.
Chef is making Window frames for his new office, for this he has n wooden Logs whose lengths are l1, l2, … ln respectively. Chef Doesn’t want to break any logs or Stick 2 or more logs together.
To make a h × w Window Frame, he needs two Logs with lengt... | {"inputs": ["2\n4\n1 2 1 2\n8\n1 2 1 3 4 1 5 6"], "outputs": ["1\n0"]} | 361 | 42 |
coding | Solve the programming task below in a Python markdown code block.
Given a sequence of $n$ integers, $p(1),p(2),...,p(n)$ where each element is distinct and satisfies $1\leq p(x)\leq n$. For each $\boldsymbol{x}$ where $1\leq x\leq n$, that is $\boldsymbol{x}$ increments from $\mbox{1}$ to $n$, find any integer $y$ such... | {"inputs": ["3\n2 3 1\n", "5\n4 3 5 1 2\n"], "outputs": ["2\n3\n1\n", "1\n3\n5\n4\n2\n"]} | 693 | 50 |
coding | Solve the programming task below in a Python markdown code block.
Write a program that will take a string of digits and give you all the possible consecutive slices of length `n` in that string.
Raise an error if `n` is larger than the length of the string.
## Examples
For example, the string `"01234"` has the foll... | {"functional": "_inputs = [['01234', 1], ['01234', 2], ['01234', 3], ['01234', 4], ['01234', 5]]\n_outputs = [[[[0], [1], [2], [3], [4]]], [[[0, 1], [1, 2], [2, 3], [3, 4]]], [[[0, 1, 2], [1, 2, 3], [2, 3, 4]]], [[[0, 1, 2, 3], [1, 2, 3, 4]]], [[[0, 1, 2, 3, 4]]]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isi... | 169 | 309 |
coding | Solve the programming task below in a Python markdown code block.
Each evening Roma plays online poker on his favourite website. The rules of poker on this website are a bit strange: there are always two players in a hand, there are no bets, and the winner takes 1 virtual bourle from the loser.
Last evening Roma start... | {"inputs": ["1 1\n?\n", "1 2\n?\n", "1 4\n?\n", "3 1\n??W\n", "6 1\nW??\n", "5 1\n??W\n", "6 1\nW@?\n", "6 1\n??W\n"], "outputs": ["W\n", "NO\n", "NO\n", "DDW\n", "NO\n", "NO\n", "NO\n", "NO\n"]} | 472 | 110 |
coding | Solve the programming task below in a Python markdown code block.
problem
You decide to invite your friends of the school and your friends of a friend to the Christmas party. The number of students in your school is n, and each student is assigned a number from 1 to n. Your number is 1. You have a list of who and who ... | {"inputs": ["6\n5\n1 2\n1 3\n3 4\n2 3\n4 5\n6\n5\n2 3\n3 4\n4 5\n5 6\n2 6\n0\n0", "6\n5\n1 2\n1 3\n3 4\n2 3\n4 5\n6\n5\n2 3\n3 4\n1 5\n5 6\n2 6\n0\n0", "6\n5\n1 2\n1 3\n3 5\n2 3\n4 5\n6\n5\n2 3\n3 4\n1 5\n6 6\n2 6\n0\n0", "6\n5\n1 2\n1 3\n3 5\n2 3\n4 5\n6\n5\n2 3\n3 4\n1 5\n1 6\n2 6\n0\n0", "6\n5\n1 2\n1 3\n2 4\n2 3\n3... | 364 | 478 |
coding | Solve the programming task below in a Python markdown code block.
You are given integers A and B, each between 1 and 3 (inclusive).
Determine if there is an integer C between 1 and 3 (inclusive) such that A \times B \times C is an odd number.
-----Constraints-----
- All values in input are integers.
- 1 \leq A, B \l... | {"inputs": ["1 1", "2 4", "1 3", "2 0", "2 3", "2 6", "2 1", "3 3"], "outputs": ["Yes\n", "No\n", "Yes\n", "No\n", "No\n", "No\n", "No\n", "Yes\n"]} | 183 | 78 |
coding | Solve the programming task below in a Python markdown code block.
Given are integers N and K.
How many quadruples of integers (a,b,c,d) satisfy both of the following conditions?
- 1 \leq a,b,c,d \leq N
- a+b-c-d=K
-----Constraints-----
- 1 \leq N \leq 10^5
- -2(N-1) \leq K \leq 2(N-1)
- All numbers in input are i... | {"inputs": ["2 1\n", "1 0\n", "2525 -425\n", "23294 13184\n", "97692 12674\n", "24115 24178\n", "66977 75123\n", "13582 27162\n"], "outputs": ["4\n", "1\n", "10314607400\n", "5523272501050\n", "606889464360839\n", "2319008467426\n", "33936530568560\n", "1\n"]} | 215 | 192 |
coding | Solve the programming task below in a Python markdown code block.
In this kata, you will make a function that converts between `camelCase`, `snake_case`, and `kebab-case`.
You must write a function that changes to a given case. It must be able to handle all three case types:
```python
py> change_case("snakeCase", "sn... | {"functional": "_inputs = [['snakeCase', 'snake'], ['some-lisp-name', 'camel'], ['map_to_all', 'kebab'], ['doHTMLRequest', 'kebab'], ['invalid-inPut_bad', 'kebab'], ['valid-input', 'huh???'], ['', 'camel'], ['snake-kebab_case', 'kebab'], ['snakeCamel_case', 'snake'], ['kebabCamel-case', 'snake'], ['case-Camel', 'kebab'... | 256 | 287 |
coding | Solve the programming task below in a Python markdown code block.
It's the most hotly anticipated game of the school year - Gryffindor vs Slytherin! Write a function which returns the winning team.
You will be given two arrays with two values.
The first given value is the number of points scored by the team's Chase... | {"functional": "_inputs = [[[100, 'yes'], [100, 'no']], [[350, 'no'], [250, 'yes']], [[100, 'yes'], [250, 'no']], [[0, 'yes'], [150, 'no']], [[150, 'no'], [0, 'yes']]]\n_outputs = [['Gryffindor wins!'], ['Slytherin wins!'], [\"It's a draw!\"], [\"It's a draw!\"], [\"It's a draw!\"]]\nimport math\ndef _deep_eq(a, b, tol... | 205 | 269 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given an integer array nums and an integer k, return the number of good subarrays of nums.
A good array is an array where the number of different integers in that array is exactly k.
For example, [1,2,3,1,2] has 3 di... | {"functional": "def check(candidate):\n assert candidate(nums = [1,2,1,2,3], k = 2) == 7\n assert candidate(nums = [1,2,1,3,4], k = 3) == 3\n\n\ncheck(Solution().subarraysWithKDistinct)"} | 135 | 72 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given an array of integers nums and a positive integer k, check whether it is possible to divide this array into sets of k consecutive numbers.
Return true if it is possible. Otherwise, return false.
Please complete... | {"functional": "def check(candidate):\n assert candidate(nums = [1,2,3,3,4,4,5,6], k = 4) == True\n assert candidate(nums = [3,2,1,2,3,4,3,4,5,9,10,11], k = 3) == True\n assert candidate(nums = [3,3,2,2,1,1], k = 3) == True\n assert candidate(nums = [1,2,3,4], k = 3) == False\n\n\ncheck(Solution().isPossibl... | 94 | 139 |
coding | Solve the programming task below in a Python markdown code block.
A bracket is considered to be any one of the following characters: (, ), {, }, [, or ].
Two brackets are considered to be a matched pair if the an opening bracket (i.e., (, [, or {) occurs to the left of a closing bracket (i.e., ), ], or }) of the exac... | {"inputs": ["3\n{[()]}\n{[(])}\n{{[[(())]]}}\n"], "outputs": ["YES\nNO\nYES\n"]} | 540 | 36 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given an integer mountain array arr of length n where the values increase to a peak element and then decrease.
Return the index of the peak element.
Your task is to solve it in O(log(n)) time complexity.
Ple... | {"functional": "def check(candidate):\n assert candidate(arr = [0,1,0]) == 1\n assert candidate(arr = [0,2,1,0]) == 1\n assert candidate(arr = [0,10,5,2]) == 1\n\n\ncheck(Solution().peakIndexInMountainArray)"} | 96 | 75 |
coding | Solve the programming task below in a Python markdown code block.
There are N towns in Snuke Kingdom, conveniently numbered 1 through N. Town 1 is the capital.
Each town in the kingdom has a Teleporter, a facility that instantly transports a person to another place. The destination of the Teleporter of town i is town ... | {"inputs": ["3 1\n3 3 1", "3 1\n2 1 1", "3 2\n3 3 1", "3 4\n3 3 1", "3 4\n1 3 1", "3 7\n1 3 1", "3 2\n3 3 2", "3 2\n1 3 1"], "outputs": ["2\n", "1\n", "1\n", "1\n", "0\n", "0\n", "1\n", "0\n"]} | 349 | 126 |
coding | Solve the programming task below in a Python markdown code block.
*Recreation of [Project Euler problem #6](https://projecteuler.net/problem=6)*
Find the difference between the sum of the squares of the first `n` natural numbers `(1 <= n <= 100)` and the square of their sum.
## Example
For example, when `n = 10`:
* ... | {"functional": "_inputs = [[5], [10], [100]]\n_outputs = [[170], [2640], [25164150]]\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 F... | 288 | 184 |
coding | Solve the programming task below in a Python markdown code block.
# A History Lesson
Soundex is an interesting phonetic algorithm developed nearly 100 years ago for indexing names as they are pronounced in English. The goal is for homophones to be encoded to the same representation so that they can be matched despite ... | {"functional": "_inputs = [['Sarah Connor'], ['Sara Conar'], ['Serah Coner'], ['Sarh Connor'], ['Sayra Cunnarr'], ['Tim'], ['Joe'], ['Bob'], ['Robert'], ['Rupert'], ['Rubin'], ['Ashcraft'], ['Ashcroft'], ['Tymczak'], ['Pfister'], ['zxqurlwbx'], ['uryrtkzp']]\n_outputs = [['S600 C560'], ['S600 C560'], ['S600 C560'], ['S... | 549 | 351 |
coding | Solve the programming task below in a Python markdown code block.
Chef has $N$ markers. There is a cap on each marker. For each valid $i$, the $i$-th marker has colour $a_i$. Initially, for each valid $i$, the colour of the cap on the $i$-th marker is also $a_i$.
Chef wants to rearrange the caps in such a way that no m... | {"inputs": ["2\n9\n1 1 1 2 2 2 3 3 3\n2\n1 1"], "outputs": ["Yes\n2 2 2 3 3 3 1 1 1\nNo"]} | 430 | 58 |
coding | Solve the programming task below in a Python markdown code block.
We have three stones at points (0, 0), (1,0), and (0,1) on a two-dimensional plane.
These three stones are said to form an L when they satisfy the following conditions:
- Each of the stones is at integer coordinates.
- Each of the stones is adjacent to... | {"inputs": ["1\n3 2 2 2 2 1\n", "10\n0 0 1 0 0 1\n1 0 0 1 1 1\n2 -1 1 -1 1 0\n1 -2 2 -1 1 -1\n-1 2 0 2 -1 3\n-1 -2 -2 -2 -2 -3\n-2 4 -3 3 -2 3\n3 1 4 2 4 1\n-4 2 -4 3 -3 3\n5 4 5 3 4 4\n"], "outputs": ["4\n", "0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n"]} | 587 | 177 |
coding | Solve the programming task below in a Python markdown code block.
For her next karate demonstration, Ada will break some bricks.
Ada stacked three bricks on top of each other. Initially, their widths (from top to bottom) are W1,W2,W3.
Ada's strength is S. Whenever she hits a stack of bricks, consider the largest k≥0 su... | {"inputs": ["3\n3 1 2 2\n2 1 1 1\n3 2 2 1"], "outputs": ["2\n2\n2"]} | 443 | 40 |
coding | Solve the programming task below in a Python markdown code block.
You are given a set of N distinct points P_{1}, P_{2}, P_{3}, \ldots, P_{N} on a 2-D plane.
A triplet (i, j, k) is called a holy triplet if
1 ≤ i < j < k ≤ N
P_{i}, P_{j} and P_{k} are non-collinear and
Any two of the points P_{i}, P_{j} and P_{k} are [... | {"inputs": ["1\n4\n0 1\n0 -1\n1 0\n-1 0"], "outputs": ["4"]} | 620 | 31 |
coding | Solve the programming task below in a Python markdown code block.
Devu loves to play with his dear mouse Jerry. One day they play a game on 2 dimensional grid of dimensions n * n (n ≥ 2). Jerry is currently at coordinates (sx, sy) and wants to move to location (ex, ey) where cheese is placed by Devu. Also Devu is very... | {"inputs": ["2\n2 1 1 2 2 1 2\n3 1 1 1 3 1 2"], "outputs": ["2\n4"]} | 391 | 42 |
coding | Solve the programming task below in a Python markdown code block.
Three Best Friends $AMAN$ , $AKBAR$ , $ANTHONY$ are planning to go to “GOA” , but just like every other goa trip plan there is a problem to their plan too.
Their parents will only give permission if they can solve this problem for them
They are a given ... | {"inputs": ["3"], "outputs": ["3"]} | 286 | 12 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given an integer array nums and an integer k, return true if there are two distinct indices i and j in the array such that nums[i] == nums[j] and abs(i - j) <= k.
Please complete the following python code precisely:... | {"functional": "def check(candidate):\n assert candidate(nums = [1,2,3,1], k = 3) == True\n assert candidate(nums = [1,0,1,1], k = 1) == True\n assert candidate(nums = [1,2,3,1,2,3], k = 2) == False\n\n\ncheck(Solution().containsNearbyDuplicate)"} | 96 | 91 |
coding | Solve the programming task below in a Python markdown code block.
Vasya has a pile, that consists of some number of stones. $n$ times he either took one stone from the pile or added one stone to the pile. The pile was non-empty before each operation of taking one stone from the pile.
You are given $n$ operations which... | {"inputs": ["1\n+\n", "1\n-\n", "1\n-\n", "1\n+\n", "2\n-+\n", "2\n++\n", "2\n+-\n", "2\n--\n"], "outputs": ["1", "0", "0\n", "1\n", "1", "2", "0", "0"]} | 545 | 84 |
coding | Solve the programming task below in a Python markdown code block.
Authors have come up with the string $s$ consisting of $n$ lowercase Latin letters.
You are given two permutations of its indices (not necessary equal) $p$ and $q$ (both of length $n$). Recall that the permutation is the array of length $n$ which contai... | {"inputs": ["3 2\n1 2 3\n1 3 2\n", "3 2\n3 1 2\n3 2 1\n", "3 2\n3 1 2\n3 2 1\n", "3 3\n3 1 2\n3 2 1\n", "3 4\n1 2 3\n1 3 2\n", "3 6\n3 1 2\n3 2 1\n", "3 6\n3 1 2\n3 1 2\n", "3 7\n3 1 2\n3 2 1\n"], "outputs": ["YES\nabb\n", "YES\nbba\n", "YES\nbba\n", "NO\n", "NO\n", "NO\n", "NO\n", "NO\n"]} | 506 | 190 |
coding | Solve the programming task below in a Python markdown code block.
Read problems statements in Mandarin Chinese, Russian and Vietnamese as well.
You are given an array of N integers. You should support the following queries on this array.
0 L R : Find the minimum integer in the range A_{L}, A_{L+1}, ..., A_{R}.
1 L R... | {"inputs": ["5 5\n1 5 2 3 4\n0 2 5\n1 1 5 6\n0 2 2\n1 2 5 3\n0 1 3"], "outputs": ["2\n4\n0"]} | 285 | 62 |
coding | Solve the programming task below in a Python markdown code block.
In this Kata, you will be given an array of unique elements, and your task is to rerrange the values so that the first max value is followed by the first minimum, followed by second max value then second min value, etc.
For example:
The first max is `1... | {"functional": "_inputs = [[[15, 11, 10, 7, 12]], [[91, 75, 86, 14, 82]], [[84, 79, 76, 61, 78]], [[52, 77, 72, 44, 74, 76, 40]], [[1, 6, 9, 4, 3, 7, 8, 2]], [[78, 79, 52, 87, 16, 74, 31, 63, 80]]]\n_outputs = [[[15, 7, 12, 10, 11]], [[91, 14, 86, 75, 82]], [[84, 61, 79, 76, 78]], [[77, 40, 76, 44, 74, 52, 72]], [[9, 1... | 135 | 442 |
coding | Solve the programming task below in a Python markdown code block.
This is a harder version of the problem. In this version $n \le 500\,000$
The outskirts of the capital are being actively built up in Berland. The company "Kernel Panic" manages the construction of a residential complex of skyscrapers in New Berlskva. A... | {"inputs": ["1\n1\n", "1\n1\n", "1\n2\n", "3\n7 6 4\n", "3\n7 3 4\n", "3\n10 6 8\n", "3\n10 6 4\n", "3\n10 3 8\n"], "outputs": ["1 \n", "1 \n", "2\n", "7 6 4\n", "7 3 3\n", "10 6 6 \n", "10 6 4\n", "10 3 3\n"]} | 683 | 135 |
coding | Solve the programming task below in a Python markdown code block.
Chef is throwing a party for his N friends. There is a pizza store nearby and he wants to buy pizza for his friends. Each pizza has exactly K slices. Chef's friends get sad if one gets more slices than the other. Also, Chef gets sad if there are some piz... | {"inputs": ["3\n2 2\n2 3\n4 2\n"], "outputs": ["1\n2\n2\n"]} | 552 | 30 |
coding | Solve the programming task below in a Python markdown code block.
Read problems statements in Mandarin chinese, Russian and Vietnamese as well.
Chef is tired of solving boring math problems by hand. One of these problems is summing up the products of elements from each k-subset of the set [n]. Here, a k-subset is a s... | {"inputs": ["1\n4 2"], "outputs": ["2"]} | 616 | 16 |
coding | Solve the programming task below in a Python markdown code block.
Johnny has some difficulty memorizing the small prime numbers. So, his computer science teacher has asked him to play with the following puzzle game frequently.
The puzzle is a 3x3 board consisting of numbers from 1 to 9. The objective of the puzzle is t... | {"inputs": ["2\n\n7 3 2 \n4 1 5 \n6 8 9 \n\n9 8 5 \n2 4 1 \n3 7 6 \n\n"], "outputs": ["6\n-1"]} | 316 | 62 |
coding | Solve the programming task below in a Python markdown code block.
Read problems statements in mandarin chinese, russian and vietnamese as well.
Today is the final round of La Liga, the most popular professional football league in the world. Real Madrid is playing against Malaga and Barcelona is playing against Eibar.... | {"inputs": ["2\nBarcelona 2\nMalaga 1\nRealMadrid 1\nEibar 0\nMalaga 3\nRealMadrid 2\nBarcelona 8\nEibar 6"], "outputs": ["RealMadrid\nBarcelona"]} | 436 | 61 |
coding | Solve the programming task below in a Python markdown code block.
Emuskald is an avid horticulturist and owns the world's longest greenhouse — it is effectively infinite in length.
Over the years Emuskald has cultivated n plants in his greenhouse, of m different plant species numbered from 1 to m. His greenhouse is ve... | {"inputs": ["1 1\n1 0\n", "1 2\n1 0\n", "3 3\n3 0\n1 1\n2 2\n", "3 3\n2 0\n1 1\n3 2\n", "3 3\n3 0\n1 1\n2 4\n", "3 3\n2 0\n1 2\n3 2\n", "3 3\n2 0\n1 4\n3 2\n", "3 2\n2 1\n2 2.0\n1 3.100\n"], "outputs": ["0\n", "0\n", "1\n", "1\n", "1\n", "1\n", "1\n", "1\n"]} | 638 | 172 |
coding | Solve the programming task below in a Python markdown code block.
Takahashi wants to print a document with N pages double-sided, where two pages of data can be printed on one sheet of paper.
At least how many sheets of paper does he need?
-----Constraints-----
- N is an integer.
- 1 \leq N \leq 100
-----Input-----
... | {"inputs": ["9", "3", "6", "1", "8", "5", "2", "5\n"], "outputs": ["5\n", "2\n", "3\n", "1\n", "4\n", "3", "1", "3\n"]} | 173 | 61 |
coding | Solve the programming task below in a Python markdown code block.
Andrii is good in Math, but not in Programming. He is asking you to solve following problem: Given an integer number N and two sets of integer A and B. Let set A contain all numbers from 1 to N and set B contain all numbers from N + 1 to 2N. Multiset C c... | {"inputs": ["3 5\n6\n2\n9\n7\n0", "3 5\n6\n2\n8\n7\n0", "3 5\n5\n2\n9\n7\n0", "3 5\n6\n1\n9\n6\n5", "3 5\n6\n2\n8\n5\n0", "6 5\n5\n2\n9\n7\n0", "3 5\n6\n1\n9\n6\n3", "5 5\n6\n2\n8\n7\n0"], "outputs": ["2\n0\n1\n3\n0\n", "2\n0\n2\n3\n0\n", "1\n0\n1\n3\n0\n", "2\n0\n1\n2\n1\n", "2\n0\n2\n1\n0\n", "0\n0\n2\n0\n0\n", "2\n0... | 359 | 222 |
coding | Solve the programming task below in a Python markdown code block.
Shaka and his brother have created a boring game which is played like this:
They take a word composed of lowercase English letters and try to get the maximum possible score by building exactly 2 palindromic subsequences. The score obtained is the prod... | {"inputs": ["eeegeeksforskeeggeeks\n"], "outputs": ["50\n"]} | 425 | 23 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
There is a special kind of apple tree that grows apples every day for n days. On the ith day, the tree grows apples[i] apples that will rot after days[i] days, that is on day i + days[i] the apples will be rotten and ... | {"functional": "def check(candidate):\n assert candidate(apples = [1,2,3,5,2], days = [3,2,1,4,2]) == 7\n assert candidate(apples = [3,0,0,0,0,2], days = [3,0,0,0,0,2]) == 5\n\n\ncheck(Solution().eatenApples)"} | 193 | 93 |
coding | Solve the programming task below in a Python markdown code block.
Write a function
```javascript
tripledouble(num1,num2)
```
```python
triple_double(num1, num2)
```
which takes numbers `num1` and `num2` and returns `1` if there is a straight triple of a number at any place in `num1` and also a straight double of the ... | {"functional": "_inputs = [[451999277, 41177722899], [1222345, 12345], [12345, 12345], [666789, 12345667], [10560002, 100], [1112, 122]]\n_outputs = [[1], [0], [0], [1], [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... | 279 | 265 |
coding | Solve the programming task below in a Python markdown code block.
You are given an integer n. Find any string s of length n consisting only of English lowercase letters such that each non-empty substring of s occurs in s an odd number of times. If there are multiple such strings, output any. It can be shown that such s... | {"inputs": ["1\n5\n", "1\n8\n", "1\n6\n", "1\n3\n", "1\n7\n", "1\n9\n", "1\n4\n", "1\n94\n"], "outputs": ["aabca\n", "aaaabaaa\n", "aaabaa\n", "abc\n", "aaabcaa\n", "aaaabcaaa\n", "aaba\n", "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n"]} | 346 | 112 |
coding | Solve the programming task below in a Python markdown code block.
Create a function that takes a string as a parameter and does the following, in this order:
1. replaces every letter with the letter following it in the alphabet (see note below)
2. makes any vowels capital
3. makes any consonants lower case
**Note:** ... | {"functional": "_inputs = [['Cat30'], ['Alice'], ['sponge1'], ['Hello World'], ['dogs'], ['z']]\n_outputs = [['dbU30'], ['bmjdf'], ['tqpOhf1'], ['Ifmmp xpsmE'], ['Epht'], ['A']]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return math.isclose(a, b, rel_tol=t... | 137 | 205 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
There is a robot on an m x n grid. The robot is initially located at the top-left corner (i.e., grid[0][0]). The robot tries to move to the bottom-right corner (i.e., grid[m - 1][n - 1]). The robot can only move eithe... | {"functional": "def check(candidate):\n assert candidate(m = 3, n = 7) == 28\n assert candidate(m = 3, n = 2) == 3\n assert candidate(m = 7, n = 3) == 28\n assert candidate(m = 3, n = 3) == 6\n\n\ncheck(Solution().uniquePaths)"} | 173 | 89 |
coding | Solve the programming task below in a Python markdown code block.
The task is very simple.
You must to return pyramids. Given a number ```n``` you print a pyramid with ```n``` floors
For example , given a ```n=4``` you must to print this pyramid:
```
/\
/ \
/ \
/______\
```
Other example, given a ``... | {"functional": "_inputs = [[4], [6], [10]]\n_outputs = [[' /\\\\\\n / \\\\\\n / \\\\\\n/______\\\\\\n'], [' /\\\\\\n / \\\\\\n / \\\\\\n / \\\\\\n / \\\\\\n/__________\\\\\\n'], [' /\\\\\\n / \\\\\\n / \\\\\\n / \\\\\\n / \\\\\\n / ... | 236 | 292 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given an integer array deck. There is a deck of cards where every card has a unique integer. The integer on the ith card is deck[i].
You can order the deck in any order you want. Initially, all the cards start... | {"functional": "def check(candidate):\n assert candidate([17,13,11,2,3,5,7]) == [2,13,3,11,5,17,7]\n\n\ncheck(Solution().deckRevealedIncreasing)"} | 221 | 63 |
coding | Solve the programming task below in a Python markdown code block.
~~~if:csharp,javascript,cfml,php
Given a 2D array of size `m * n`. Your task is to find the sum of minimum value in each row.
~~~
~~~if:cpp
Given a 2D vector of size `m * n`. Your task is to find the sum of minimum value in each row.
~~~
~~~if:python,rub... | {"functional": "_inputs = [[[[7, 9, 8, 6, 2], [6, 3, 5, 4, 3], [5, 8, 7, 4, 5]]], [[[11, 12, 14, 54], [67, 89, 90, 56], [7, 9, 4, 3], [9, 8, 6, 7]]]]\n_outputs = [[9], [76]]\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, ... | 394 | 261 |
coding | Solve the programming task below in a Python markdown code block.
Summer holidays! Someone is going on trips, someone is visiting grandparents, but someone is trying to get a part-time job. This summer Noora decided that she wants to earn some money, and took a job in a shop as an assistant.
Shop, where Noora is worki... | {"inputs": ["1 1\n5 8\n", "1 1\n1 1\n", "1 1\n5 8\n", "1 1\n1 1\n", "1 1\n0 1\n", "1 1\n9 8\n", "1 0\n10 20\n", "1 0\n12 12\n"], "outputs": ["8", "1", "8", "1", "0\n", "8\n", "10", "12"]} | 673 | 118 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given two positive integers n and k, the binary string Sn is formed as follows:
S1 = "0"
Si = Si - 1 + "1" + reverse(invert(Si - 1)) for i > 1
Where + denotes the concatenation operation, reverse(x) returns the reve... | {"functional": "def check(candidate):\n assert candidate(n = 3, k = 1) == \"0\"\n assert candidate(n = 4, k = 11) == \"1\"\n assert candidate(n = 1, k = 1) == \"0\"\n assert candidate(n = 2, k = 3) == \"1\"\n\n\ncheck(Solution().findKthBit)"} | 223 | 94 |
coding | Solve the programming task below in a Python markdown code block.
Chef got in the trouble! He is the king of Chefland and Chessland. There is one queen in Chefland and one queen in Chessland and they both want a relationship with him. Chef is standing before a difficult choice…
Chessland may be considered a chessboard ... | {"inputs": ["2\n3 3 2 2\n4 4 2 3"], "outputs": ["24\n94"]} | 689 | 32 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given two strings firstString and secondString that are 0-indexed and consist only of lowercase English letters. Count the number of index quadruples (i,j,a,b) that satisfy the following conditions:
0 <= i <=... | {"functional": "def check(candidate):\n assert candidate(firstString = \"abcd\", secondString = \"bccda\") == 1\n assert candidate(firstString = \"ab\", secondString = \"cd\") == 0\n\n\ncheck(Solution().countQuadruples)"} | 189 | 60 |
coding | Solve the programming task below in a Python markdown code block.
Taro and Jiro will play the following game against each other.
Initially, they are given a sequence a = (a_1, a_2, \ldots, a_N). Until a becomes empty, the two players perform the following operation alternately, starting from Taro:
* Remove the elemen... | {"inputs": ["1\n8", "1\n1", "1\n0", "1\n2", "1\n6", "1\n18", "1\n31", "1\n10"], "outputs": ["8\n", "1\n", "0\n", "2\n", "6\n", "18\n", "31\n", "10"]} | 406 | 83 |
coding | Solve the programming task below in a Python markdown code block.
Given are three integers A_1, A_2, and A_3.
If A_1+A_2+A_3 is greater than or equal to 22, print bust; otherwise, print win.
-----Constraints-----
- 1 \leq A_i \leq 13 \ \ (i=1,2,3)
- All values in input are integers.
-----Input-----
Input is given f... | {"inputs": ["5 7 4", "5 1 4", "5 1 0", "0 9 4", "5 1 1", "0 1 4", "6 1 1", "0 2 4"], "outputs": ["win\n", "win\n", "win\n", "win\n", "win\n", "win\n", "win\n", "win\n"]} | 178 | 94 |
coding | Solve the programming task below in a Python markdown code block.
Thanks to the effects of El Nino this year my holiday snorkelling trip was akin to being in a washing machine... Not fun at all.
Given a string made up of '~' and '\_' representing waves and calm respectively, your job is to check whether a person would... | {"functional": "_inputs = [['~'], ['_~~~~~~~_~__~______~~__~~_~~'], ['______~___~_'], ['____'], ['_~~_~____~~~~~~~__~_~']]\n_outputs = [['No Problem'], ['Throw Up'], ['Throw Up'], ['No Problem'], ['Throw Up']]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n ret... | 165 | 215 |
coding | Solve the programming task below in a Python markdown code block.
Do you know "sed," a tool provided with Unix? Its most popular use is to substitute every occurrence of a string contained in the input string (actually each input line) with another string β. More precisely, it proceeds as follows.
1. Within the input... | {"inputs": ["2\na bb\nb aa\na\nbbbbbbbb\n1\na aa\na\naaaaa\n3\nab aab\nabc aadc\nad dee\nabc\ndeeeeeeeec\n10\na abc\nb bai\nc acf\nd bed\ne abh\nf fag\ng abe\nh bag\ni aaj\nj bbb\na\nabaceaabe\n0", "2\na bb\nb aa\nb\nbbbbbbbb\n1\nb aa\na\naaaaa\n3\nab aab\nabc aadc\nad dee\nabc\ndeeeeeeeec\n10\na abc\nb bai\nc acf\nd b... | 624 | 838 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given the logs for users' actions on LeetCode, and an integer k. The logs are represented by a 2D integer array logs where each logs[i] = [IDi, timei] indicates that the user with IDi performed an action at th... | {"functional": "def check(candidate):\n assert candidate(logs = [[0,5],[1,2],[0,2],[0,5],[1,3]], k = 5) == [0,2,0,0,0]\n assert candidate(logs = [[1,1],[2,2],[2,3]], k = 4) == [1,1,0,0]\n\n\ncheck(Solution().findingUsersActiveMinutes)"} | 231 | 101 |
coding | Solve the programming task below in a Python markdown code block.
## Task
Implement a function which finds the numbers less than `2`, and the indices of numbers greater than `1` in the given sequence, and returns them as a pair of sequences.
Return a nested array or a tuple depending on the language:
* The first se... | {"functional": "_inputs = [[[0, 1, 2, 1, 0, 2, 1, 1, 1, 0, 4, 5, 6, 2, 1, 1, 0]], [[0, 1, 1, 2, 0]], [[2, 2, 0]], [[0, 1, 2, 1, 0, 2, 1, 1]], [[1]], [[3, 0, 7, 0, 2, 0]]]\n_outputs = [[[[0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 0], [2, 5, 10, 11, 12, 13]]], [[[0, 1, 1, 0], [3]]], [[[0], [0, 1]]], [[[0, 1, 1, 0, 1, 1], [2, 5]]], [... | 208 | 401 |
coding | Solve the programming task below in a Python markdown code block.
Vlad, like everyone else, loves to sleep very much.
Every day Vlad has to do $n$ things, each at a certain time. For each of these things, he has an alarm clock set, the $i$-th of them is triggered on $h_i$ hours $m_i$ minutes every day ($0 \le h_i < 24... | {"inputs": ["1\n1 14 51\n1 2\n", "1\n1 14 52\n1 1\n", "1\n4 14 31\n0 0\n0 0\n0 0\n0 0\n", "3\n1 6 13\n8 0\n3 6 0\n12 30\n14 45\n6 0\n2 23 35\n20 15\n10 30\n"], "outputs": ["10 11\n", "10 9\n", "9 29\n", "1 47\n0 0\n10 55\n"]} | 570 | 162 |
coding | Solve the programming task below in a Python markdown code block.
The trafic on the Internet is increasing these days due to smartphones. The wireless carriers have to enhance their network infrastructure.
The network of a wireless carrier consists of a number of base stations and lines. Each line connects two base st... | {"inputs": ["3 3\n1 2 x+2\n2 2 2x+1\n3 1 x+1\n2 0\n3 2\n1 2 x\n2 3 2\n4 3\n1 2 x^3+2x^2+3x+4\n2 3 x^2+2x+3\n3 4 x+2\n0 0", "3 3\n1 2 x+2\n2 2 2x+1\n3 1 x+1\n2 0\n3 2\n1 2 x\n2 3 1\n4 3\n1 2 x^3+2x^2+3x+4\n2 3 x^2+2x+3\n3 4 x+2\n0 0", "3 3\n1 2 x+2\n2 2 2x+1\n3 1 x+1\n2 0\n3 2\n1 2 x\n2 3 4\n4 3\n1 2 x^3+2x^2+3x+4\n2 3 ... | 729 | 841 |
coding | Solve the programming task below in a Python markdown code block.
Chef is setting up a perfect bath for himself. He has X litres of hot water and Y litres of cold water.
The initial temperature of water in his bathtub is A degrees. On mixing water, the temperature of the bathtub changes as following:
The temperature... | {"inputs": ["4\n24 25 2 0\n37 37 2 9\n30 20 10 9\n30 31 0 20\n"], "outputs": ["YES\nYES\nNO\nNO\n"]} | 581 | 62 |
coding | Solve the programming task below in a Python markdown code block.
We like parsed SQL or PL/SQL blocks...
You need to write function that return list of literals indices from source block, excluding "in" comments, OR return empty list if no literals found.
input:
some fragment of sql or pl/sql code
output:
list of li... | {"functional": "_inputs = [[\"select 'text' into row from table where a = 'value'\"], [\"if a>'data'and b<'nnn' then c:='test'; end if;\"], [\"select aaa, bbb, ccc, /*'ddd'?*/ into row from table;\"], [\"a:='data''s';\"]]\n_outputs = [[[[7, 13], [44, 51]]], [[[5, 11], [17, 22], [31, 37]]], [[]], [[[3, 12]]]]\nimport ma... | 354 | 276 |
coding | Solve the programming task below in a Python markdown code block.
The number ```1331``` is the first positive perfect cube, higher than ```1```, having all its digits odd (its cubic root is ```11```).
The next one is ```3375```.
In the interval [-5000, 5000] there are six pure odd digit perfect cubic numbers and are... | {"functional": "_inputs = [[-5000, 5000], [0, 5000], [-1, 5000], [-5000, -2]]\n_outputs = [[[-3375, -1331, -1, 1, 1331, 3375]], [[1, 1331, 3375]], [[-1, 1, 1331, 3375]], [[-3375, -1331]]]\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,... | 403 | 270 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given two 0-indexed integer arrays nums1 and nums2 of length n.
A range [l, r] (inclusive) where 0 <= l <= r < n is balanced if:
For every i in the range [l, r], you pick either nums1[i] or nums2[i].
The sum ... | {"functional": "def check(candidate):\n assert candidate(nums1 = [1,2,5], nums2 = [2,6,3]) == 3\n assert candidate(nums1 = [0,1], nums2 = [1,0]) == 4\n\n\ncheck(Solution().countSubranges)"} | 267 | 70 |
coding | Solve the programming task below in a Python markdown code block.
Soma is a fashionable girl. She absolutely loves shiny stones that she can put on as jewellery accessories. She has been collecting stones since her childhood - now she has become really good with identifying which ones are fake and which ones are not. ... | {"inputs": ["4\nabc\nabcdef\naA\nabAZ\naaa\na\nwhat\nnone", "4\nacb\nabcdef\naA\nabAZ\naaa\na\nwhat\nnone", "4\nacb\nabcdef\nAa\nabZA\naaa\n`\nwhat\nnone", "4\naca\nebcdaf\naA\nAbZa\n`aa\n`\nswha\nnomf", "4\nac`\nebcdae\naA\nAbZa\n`aa\n_\nsvha\nnome", "4\nac`\nebcdae\naA\nAbZ`\n`aa\n_\nsvha\nemon", "4\n`ca\neacdae\naA\... | 318 | 279 |
coding | Solve the programming task below in a Python markdown code block.
Read problem statements in [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
For a given $N$, find the number of ways to choose an integer $x$ from the range $[0, 2^{N} - 1]$ such that $x \oplus (x+1) = (x+2) \oplus (x+3)$, where $\opl... | {"inputs": ["2\n1\n2"], "outputs": ["1\n2"]} | 326 | 18 |
coding | Solve the programming task below in a Python markdown code block.
There are n seats in the train's car and there is exactly one passenger occupying every seat. The seats are numbered from 1 to n from left to right. The trip is long, so each passenger will become hungry at some moment of time and will go to take boiled ... | {"inputs": ["1 1\n1\n", "1 2\n1\n", "1 2\n0\n", "1 3\n1\n", "1 3\n0\n", "5 314\n0 310 18 628 0\n", "5 314\n0 365 18 628 0\n", "5 314\n0 365 18 1117 0\n"], "outputs": ["2 \n", "3 ", "2 ", "4 ", "3 ", "314 628 942 1256 1570 ", "314 942 628 1256 1570 ", "314 942 628 1570 1256 "]} | 627 | 203 |
coding | Solve the programming task below in a Python markdown code block.
Chef has a recipe book. He wishes to read it completely as soon as possible so that he could try to cook the dishes mentioned in the book.
The pages of the book are numbered $1$ through $N$. Over a series of days, Chef wants to read each page. On each da... | {"inputs": ["1\n5\n"], "outputs": ["2\n3 1 2 5\n2 3 4"]} | 596 | 29 |
coding | Solve the programming task below in a Python markdown code block.
Polycarp loves geometric progressions very much. Since he was only three years old, he loves only the progressions of length three. He also has a favorite integer k and a sequence a, consisting of n integers.
He wants to know how many subsequences of le... | {"inputs": ["1 1\n1\n", "1 2\n0\n", "1 2\n0\n", "1 1\n1\n", "1 1\n2\n", "2 1\n1 1\n", "2 2\n1 2\n", "2 2\n0 0\n"], "outputs": ["0", "0", "0\n", "0\n", "0\n", "0", "0", "0"]} | 474 | 103 |
coding | Solve the programming task below in a Python markdown code block.
Your classmate, whom you do not like because he is boring, but whom you respect for his intellect, has two strings: $s$ of length $n$ and $t$ of length $m$.
A sequence $p_1, p_2, \ldots, p_m$, where $1 \leq p_1 < p_2 < \ldots < p_m \leq n$, is called be... | {"inputs": ["2 2\nab\nab\n", "2 2\nba\nba\n", "2 2\nab\nab\n", "3 3\ncad\ncad\n", "3 3\ncad\ncad\n", "5 2\naaaaa\naa\n", "4 3\ndbbd\ndbd\n", "5 2\nddaca\nda\n"], "outputs": ["1\n", "1\n", "\n1\n", "1\n", "1\n", "4\n", "2\n", "4\n"]} | 518 | 129 |
coding | Solve the programming task below in a Python markdown code block.
This winter is so cold in Nvodsk! A group of n friends decided to buy k bottles of a soft drink called "Take-It-Light" to warm up a bit. Each bottle has l milliliters of the drink. Also they bought c limes and cut each of them into d slices. After that t... | {"inputs": ["3 4 3 5 3 6 2 1\n", "1 6 5 5 5 8 3 1\n", "2 5 3 5 6 9 2 1\n", "1 7 3 5 3 6 2 1\n", "1 7 5 3 3 9 2 1\n", "2 4 5 4 5 7 3 2\n", "1 7 5 5 5 5 2 2\n", "1 4 6 7 3 5 1 3\n"], "outputs": ["2\n", "8\n", "3\n", "6\n", "9\n", "1\n", "2\n", "1\n"]} | 415 | 182 |
coding | Solve the programming task below in a Python markdown code block.
There are n railway stations in Berland. They are connected to each other by n-1 railway sections. The railway network is connected, i.e. can be represented as an undirected tree.
You have a map of that network, so for each railway section you know whic... | {"inputs": ["2\n2 1\n1\n1 2 3\n", "2\n2 1\n1\n1 2 4\n", "3\n2 1\n3 1\n1\n3 2 3\n", "3\n2 1\n3 1\n1\n2 3 1\n", "2\n2 1\n2\n1 2 3\n1 2 3\n", "2\n2 1\n2\n1 2 1\n2 1 1\n", "4\n4 1\n2 3\n2 1\n1\n1 3 1\n", "3\n1 2\n1 3\n2\n3 2 2\n1 3 4\n"], "outputs": ["3 \n", "4 \n", "3 3 \n", "1 1 \n", "3 \n", "1 \n", "1 1 1 \n", "2 4 \n"]... | 701 | 222 |
coding | Solve the programming task below in a Python markdown code block.
The king's birthday dinner was attended by $k$ guests. The dinner was quite a success: every person has eaten several dishes (though the number of dishes was the same for every person) and every dish was served alongside with a new set of kitchen utensil... | {"inputs": ["1 1\n9\n", "1 2\n7\n", "1 1\n7\n", "1 2\n1\n", "1 1\n14\n", "1 1\n14\n", "5 2\n1 2 2 1 3\n", "5 2\n1 2 2 1 3\n"], "outputs": ["0\n", "1\n", "0\n", "1\n", "0\n", "0\n", "1\n", "1\n"]} | 613 | 120 |
coding | Solve the programming task below in a Python markdown code block.
Find the number of integers between 1 and N (inclusive) that contains exactly K non-zero digits when written in base ten.
-----Constraints-----
- 1 \leq N < 10^{100}
- 1 \leq K \leq 3
-----Input-----
Input is given from Standard Input in the followin... | {"inputs": ["9\n1\n", "9\n2\n", "25\n1", "25\n4", "25\n5", "25\n3", "25\n9", "25\n7"], "outputs": ["9\n", "0\n", "11\n", "0\n", "0\n", "0\n", "0\n", "0\n"]} | 173 | 87 |
coding | Solve the programming task below in a Python markdown code block.
You are given an array $a_1, a_2, \dots, a_n$. You can perform the following operation any number of times: Choose a pair of two neighboring equal elements $a_i = a_{i + 1}$ (if there is at least one such pair). Replace them by one element with value $... | {"inputs": ["1\n1000\n", "1\n1000\n", "3\n1 3 5\n", "3\n2 3 5\n", "3\n2 3 1\n", "3\n1 3 5\n", "5\n4 3 2 2 3\n", "5\n4 3 2 3 3\n"], "outputs": ["1\n", "1\n", "3\n", "3\n", "3\n", "3\n", "2\n", "4\n"]} | 506 | 124 |
coding | Solve the programming task below in a Python markdown code block.
# Task
You have two sorted arrays `a` and `b`, merge them to form new array of unique items.
If an item is present in both arrays, it should be part of the resulting array if and only if it appears in both arrays the same number of times.
# Example
... | {"functional": "_inputs = [[[10, 10, 10, 15, 20, 20, 25, 25, 30, 7000], [10, 15, 20, 20, 27, 7200]], [[500, 550, 1000, 1000, 1400, 3500], [2, 2, 2, 2, 3, 1500]], [[5], [5, 5, 7]]]\n_outputs = [[[15, 20, 25, 27, 30, 7000, 7200]], [[2, 3, 500, 550, 1000, 1400, 1500, 3500]], [[7]]]\nimport math\ndef _deep_eq(a, b, tol=1e-... | 318 | 359 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given an integer rowIndex, return the rowIndexth (0-indexed) row of the Pascal's triangle.
In Pascal's triangle, each number is the sum of the two numbers directly above it as shown:
Please complete the following p... | {"functional": "def check(candidate):\n assert candidate(rowIndex = 3) == [1,3,3,1]\n assert candidate(rowIndex = 0) == [1]\n assert candidate(rowIndex = 1) == [1,1]\n\n\ncheck(Solution().getRow)"} | 89 | 65 |
coding | Solve the programming task below in a Python markdown code block.
A bracketed sequence is called correct (regular) if by inserting "+" and "1" you can get a well-formed mathematical expression from it. For example, sequences "(())()", "()" and "(()(()))" are correct, while ")(", "(()" and "(()))(" are not.
The teacher... | {"inputs": ["1\n(\n", "1\n)\n", "2\n((\n", "2\n)(\n", "2\n()\n", "2\n))\n", "3\n(()\n", "4\n))))\n"], "outputs": ["-1\n", "-1\n", "-1\n", "2\n", "0\n", "-1\n", "-1\n", "-1\n"]} | 521 | 92 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You have n bags numbered from 0 to n - 1. You are given two 0-indexed integer arrays capacity and rocks. The ith bag can hold a maximum of capacity[i] rocks and currently contains rocks[i] rocks. You are also given an... | {"functional": "def check(candidate):\n assert candidate(capacity = [2,3,4,5], rocks = [1,2,4,4], additionalRocks = 2) == 3\n assert candidate(capacity = [10,2,2], rocks = [2,2,0], additionalRocks = 100) == 3\n\n\ncheck(Solution().maximumBags)"} | 152 | 93 |
coding | Solve the programming task below in a Python markdown code block.
Implement function which will return sum of roots of a quadratic equation rounded to 2 decimal places, if there are any possible roots, else return **None/null/nil/nothing**. If you use discriminant,when discriminant = 0, x1 = x2 = root => return sum of ... | {"functional": "_inputs = [[1, -35, -23], [6, 0, -24], [-5, 21, 0], [6, 4, 8], [1, 5, -24], [3, 11, 6], [2, 2, 9], [1, -1.6666666666666667, -26], [1, 6, 10], [7, -2, -5], [1, 8, 20], [2, 3, -2], [1, 4, 12], [3, -2, -5], [3, 4, 9], [5, 4, 0], [4, -5, 0], [1, 4, 9], [1, 0, -49], [2, 8, 8], [1, 0, -0.16], [1, 6, 12], [1, ... | 123 | 786 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
A permutation perm of n integers of all the integers in the range [1, n] can be represented as a string s of length n - 1 where:
s[i] == 'I' if perm[i] < perm[i + 1], and
s[i] == 'D' if perm[i] > perm[i + 1].
Given ... | {"functional": "def check(candidate):\n assert candidate(s = \"I\") == [1,2]\n assert candidate(s = \"DI\") == [2,1,3]\n\n\ncheck(Solution().findPermutation)"} | 139 | 52 |
coding | Solve the programming task below in a Python markdown code block.
Given an array of one's and zero's that represents a positive binary number convert the number to two's complement value.
Two's complement is the way most computers represent positive or negative integers. The most significant bit is negative.
Example... | {"functional": "_inputs = [[[0, 0, 0, 0]], [[0, 0, 1, 0]], [[0, 0, 1, 1]], [[0, 1, 0, 0]]]\n_outputs = [[[0, 0, 0, 0]], [[1, 1, 1, 0]], [[1, 1, 0, 1]], [[1, 1, 0, 0]]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return math.isclose(a, b, rel_tol=tol, abs_to... | 234 | 246 |
coding | Solve the programming task below in a Python markdown code block.
You are given 3 numbers A, B, and C.
Determine whether the average of A and B is strictly greater than C or not?
NOTE: Average of A and B is defined as \frac{(A+B)}{2}. For example, average of 5 and 9 is 7, average of 5 and 8 is 6.5.
------ Input Form... | {"inputs": ["5\n5 9 6\n5 8 6\n5 7 6\n4 9 8\n3 7 2\n"], "outputs": ["YES\nYES\nNO\nNO\nYES\n"]} | 432 | 52 |
coding | Solve the programming task below in a Python markdown code block.
You are given ${D}$ datasets where each dataset is in the form of two integers, $m$ and ${a}$, such that:
$n=\prod\limits_{i=1}^m p_i^{a+i},\text{where}~p_i~\text{is the}~i^{th}~\text{prime}.$
For each dataset, find and print the following on a new line... | {"inputs": ["3\n2 0\n3 0\n2 4\n"], "outputs": ["18\n180\n588\n"]} | 511 | 35 |
coding | Solve the programming task below in a Python markdown code block.
Monk has magical powers, by which he can compare any part of the strings and figure out if they're equal. His magical powers are faster than a super computer even. So, to prove his worth, he's given a string and he has to answer multiple queries based on... | {"inputs": ["qrstqrstqrstqrstqrstqrstqrstqrstqrstqrstqrstqrstqrstqrstqrstqrstqrstqrstqrstqrstqrstqrstqrstqrstqrstqrstqrstqrstqrstqrstqrstqrstqrstqrstqrstqrstqrstqrstqrstqrstqrstqrstqrstqrstqrstqrstqrstqrstqrstqrstqrstqrstqrstqrstqrstqrstqrstqrstqrstqrstqrstqrstqrstqrstqrstqrstqrstqrstqrstqrstqrstqrstqrstqrstqrstqrstqrs... | 463 | 1,929 |
coding | Solve the programming task below in a Python markdown code block.
Vietnamese and Bengali as well.
An $N$-bonacci sequence is an infinite sequence $F_1, F_2, \ldots$ such that for each integer $i > N$, $F_i$ is calculated as $f(F_{i-1}, F_{i-2}, \ldots, F_{i-N})$, where $f$ is some function. A XOR $N$-bonacci sequence i... | {"inputs": ["3 4\n0 1 2\n7\n2\n5\n1000000000"], "outputs": ["3\n1\n0\n0"]} | 541 | 43 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
We had some 2-dimensional coordinates, like "(1, 3)" or "(2, 0.5)". Then, we removed all commas, decimal points, and spaces and ended up with the string s.
For example, "(1, 3)" becomes s = "(13)" and "(2, 0.5)" beco... | {"functional": "def check(candidate):\n assert candidate(s = \"(123)\") == [\"(1, 2.3)\",\"(1, 23)\",\"(1.2, 3)\",\"(12, 3)\"]\n assert candidate(s = \"(0123)\") == [\"(0, 1.23)\",\"(0, 12.3)\",\"(0, 123)\",\"(0.1, 2.3)\",\"(0.1, 23)\",\"(0.12, 3)\"]\n assert candidate(s = \"(00011)\") == [\"(0, 0.011)\",\"(0.... | 262 | 198 |
coding | Solve the programming task below in a Python markdown code block.
One day n cells of some array decided to play the following game. Initially each cell contains a number which is equal to it's ordinal number (starting from 1). Also each cell determined it's favourite number. On it's move i-th cell can exchange it's val... | {"inputs": ["1\n1\n1\n", "1\n1\n2\n", "2\n2 1\n2 2\n", "2\n2 1\n1 1\n", "2\n1 2\n1 1\n", "2\n1 2\n2 2\n", "2\n2 1\n1 2\n", "4\n1 2 3 4\n1 1 1 1\n"], "outputs": ["YES\n", "YES\n", "NO\n", "YES\n", "YES\n", "YES\n", "YES\n", "YES\n"]} | 333 | 134 |
coding | Solve the programming task below in a Python markdown code block.
Your friend Mishka and you attend a calculus lecture. Lecture lasts n minutes. Lecturer tells a_{i} theorems during the i-th minute.
Mishka is really interested in calculus, though it is so hard to stay awake for all the time of lecture. You are given a... | {"inputs": ["1 1\n10\n0\n", "1 1\n10\n0\n", "1 1\n64\n0\n", "1 1\n423\n0\n", "1 1\n423\n0\n", "1 1\n105\n0\n", "2 2\n3 2\n1 0\n", "2 1\n3 2\n0 0\n"], "outputs": ["10\n", "10\n", "64\n", "423\n", "423\n", "105\n", "5\n", "3\n"]} | 542 | 144 |
coding | Solve the programming task below in a Python markdown code block.
The Siruseri amusement park has a new attraction. It consists of a rectangular array of discs. Each disc is divided into four equal sectors and the four sectors are coloured with the colours Red, Blue, Green and Yellow (in some order). The ordering may b... | {"inputs": ["2 4\nG Y B R\nB G R Y\nG Y B R\nG R B Y\nB Y G R\nG B R Y\nB R G Y\nB R G Y"], "outputs": ["2"]} | 732 | 54 |
coding | Solve the programming task below in a Python markdown code block.
You are given an array $a$ of $n$ integers. Count the number of pairs of indices $(i, j)$ such that $i < j$ and $a_j - a_i = j - i$.
-----Input-----
The first line contains one integer $t$ ($1 \le t \le 10^4$). Then $t$ test cases follow.
The first l... | {"inputs": ["1\n3\n3 1 2\n", "1\n3\n1 1 2\n", "1\n3\n2 1 2\n", "1\n3\n3 1 2\n", "1\n3\n2 1 2\n", "1\n3\n1 1 2\n", "1\n3\n3 1 3\n", "1\n3\n2 2 2\n"], "outputs": ["1\n", "1\n", "1\n", "1\n", "1\n", "1\n", "0\n", "0\n"]} | 304 | 134 |
coding | Solve the programming task below in a Python markdown code block.
You are given an array A consisting of N integers.
In one operation, you can:
Choose any two indices i and j (i \neq j);
Subtract min(A_{i} , A_{j}) from both A_{i} and A_{j}. Note that min(A_{i} , A_{j}) denotes the minimum of A_{i} and A_{j}.
Determi... | {"inputs": ["3\n2\n1 1 \n3 \n1 3 1\n4\n1 3 1 3\n"], "outputs": ["1\n1 2\n-1\n2\n1 3\n2 4"]} | 680 | 56 |
coding | Solve the programming task below in a Python markdown code block.
Draw a chessboard which has a height of H cm and a width of W cm. For example, the following figure shows a chessboard which has a height of 6 cm and a width of 10 cm.
.#.#.#.#.
.#.#.#.#.#
.#.#.#.#.
.#.#.#.#.#
.#.#.#.#.
.#.#.#.#.#
Note that the top l... | {"inputs": ["3 4\n5 6\n3 3\n2 2\n1 0\n0 0", "3 7\n5 6\n3 3\n2 2\n1 0\n0 0", "3 7\n5 6\n3 0\n2 2\n1 0\n0 0", "6 7\n5 6\n3 0\n2 2\n1 0\n0 0", "3 4\n5 6\n2 3\n2 2\n1 1\n0 0", "3 4\n5 6\n3 3\n2 4\n1 0\n0 0", "3 7\n5 6\n4 3\n2 2\n1 0\n0 0", "3 7\n5 5\n3 0\n2 2\n1 0\n0 0"], "outputs": ["#.#.\n.#.#\n#.#.\n\n#.#.#.\n.#.#.#\n#.... | 261 | 712 |
coding | Solve the programming task below in a Python markdown code block.
Alice and Bob begin their day with a quick game. They first choose a starting number X0 ≥ 3 and try to reach one million by the process described below.
Alice goes first and then they take alternating turns. In the i-th turn, the player whose turn it i... | {"inputs": ["6\n", "9\n", "4\n", "8\n", "12\n", "15\n", "16\n", "81\n"], "outputs": ["3\n", "7\n", "3\n", "7\n", "6\n", "8\n", "11\n", "76\n"]} | 397 | 76 |
coding | Solve the programming task below in a Python markdown code block.
Read problems statements in Mandarin chinese, Russian and Vietnamese as well.
Chef has two integers $A$ and $B$. He can perform the following operation on $A$ an arbitrary number of times (including zero):
write $A$ as a binary number with an arbitrary... | {"inputs": ["2\n2 4\n1 5"], "outputs": ["2\n1"]} | 388 | 22 |
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 [subsequence] of the array and any integer X and then add X to all the elements of the chosen subsequence.
Determine the minimum number of operations required to make all the elemen... | {"inputs": ["4\n3\n3 3 3\n6\n1 3 2 1 2 2\n4\n1 2 1 2\n5\n1 3 2 4 6\n"], "outputs": ["2\n2\n1\n0\n"]} | 662 | 64 |
coding | Solve the programming task below in a Python markdown code block.
Given an array of arguments, representing system call arguments keys and values, join it into a single, space-delimited string. You don't need to care about the application name -- your task is only about parameters.
Each element of the given array can ... | {"functional": "_inputs = [[['foo']], [['f']], [[['f']]], [[['foo', 'bar']]], [[['f', 'bar']]], [[['foo', 'bar'], ['baz', 'qux']]], [[['foo'], 'bar', ['baz', 'qux'], ['xyzzy', 'a'], 'a', ['a'], ['a', 'plugh']]], [[]], [[['---'], '---', ['---', '---'], ['-----', '-'], '-', ['-'], ['-', '-----']]]]\n_outputs = [['foo'], ... | 284 | 315 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.