problem stringlengths 14 4.09k | solution stringlengths 1 802k | task_type stringclasses 3
values | problem_tokens int64 5 895 |
|---|---|---|---|
Please solve the programming task below using a self-contained code snippet in a markdown code block.
There are k workers who want to move n boxes from the right (old) warehouse to the left (new) warehouse. You are given the two integers n and k, and a 2D integer array time of size k x 4 where time[i] = [righti, picki... | {"functional": "def check(candidate):\n assert candidate(n = 1, k = 3, time = [[1,1,2,1],[1,1,3,1],[1,1,4,1]]) == 6\n assert candidate(n = 3, k = 2, time = [[1,9,1,8],[10,10,10,10]]) == 50\n\n\ncheck(Solution().findCrossingTime)"} | coding | 370 |
Solve the programming task below in a Python markdown code block.
The Chef is given an array of numbers and asked to find the first balance point of an array. A balance point is an index in the array N where the sum of the integers to the left of N is equal to the sum of the integers to the right of N. If there is no s... | {"inputs": ["2\n7\n7 8 9 1 9 8 7\n6\n1 100 50 -51 1 1"], "outputs": ["3\n1"]} | coding | 426 |
Solve the programming task below in a Python markdown code block.
Vitya is studying in the third grade. During the last math lesson all the pupils wrote on arithmetic quiz. Vitya is a clever boy, so he managed to finish all the tasks pretty fast and Oksana Fillipovna gave him a new one, that is much harder.
Let's deno... | {"inputs": ["1\n", "5\n", "4\n", "99\n", "91\n", "67\n", "11\n", "33\n"], "outputs": ["0\n", "0\n", "2\n", "54", "0", "0", "10\n", "21"]} | coding | 535 |
Solve the programming task below in a Python markdown code block.
Read problems statements in Mandarin Chinese and Russian as well.
Vadim and Roman like discussing challenging problems with each other. One day Vadim told his friend following problem:
Given N points on a plane. Each point p is defined by it's two inte... | {"inputs": ["2\n2\n1 2\n0 0\n3\n3 3\n0 0\n0 3", "2\n2\n1 2\n1 0\n3\n3 3\n0 0\n0 3", "2\n2\n1 2\n1 0\n3\n3 3\n1 0\n0 3", "2\n2\n1 2\n1 0\n3\n3 3\n2 0\n0 3", "2\n2\n1 2\n1 0\n3\n3 3\n2 0\n0 0", "2\n2\n1 2\n0 0\n3\n3 6\n0 0\n0 3", "2\n2\n1 2\n0 0\n3\n3 5\n0 0\n0 3", "2\n2\n1 2\n1 0\n3\n3 0\n1 0\n0 3"], "outputs": ["3\n0",... | coding | 629 |
Solve the programming task below in a Python markdown code block.
An element in an array is dominant if it is greater than all elements to its right. You will be given an array and your task will be to return a list of all dominant elements. For example:
```Haskell
solve([1,21,4,7,5]) = [21,7,5] because 21, 7 and 5 are... | {"functional": "_inputs = [[[16, 17, 14, 3, 14, 5, 2]], [[92, 52, 93, 31, 89, 87, 77, 105]], [[75, 47, 42, 56, 13, 55]], [[67, 54, 27, 85, 66, 88, 31, 24, 49]], [[76, 17, 25, 36, 29]], [[104, 18, 37, 9, 36, 47, 28]]]\n_outputs = [[[17, 14, 5, 2]], [[105]], [[75, 56, 55]], [[88, 49]], [[76, 36, 29]], [[104, 47, 28]]]\ni... | coding | 165 |
Solve the programming task below in a Python markdown code block.
In this Kata you are a builder and you are assigned a job of building a wall with a specific size (God knows why...).
Create a function called `build_a_wall` (or `buildAWall` in JavaScript) that takes `x` and `y` as integer arguments (which represent th... | {"functional": "_inputs = [[4, 5], [10, 7], ['eight', [3]], [12, -4], [0, 9], [123, 987]]\n_outputs = [['\u25a0|\u25a0\u25a0|\u25a0\u25a0|\u25a0\u25a0|\u25a0\u25a0|\u25a0\\n\u25a0\u25a0|\u25a0\u25a0|\u25a0\u25a0|\u25a0\u25a0|\u25a0\u25a0\\n\u25a0|\u25a0\u25a0|\u25a0\u25a0|\u25a0\u25a0|\u25a0\u25a0|\u25a0\\n\u25a0\u25a0... | coding | 764 |
Solve the programming task below in a Python markdown code block.
There are N dots in a two-dimensional plane. The coordinates of the i-th dot are (x_i, y_i).
We will repeat the following operation as long as possible:
- Choose four integers a, b, c, d (a \neq c, b \neq d) such that there are dots at exactly three of ... | {"inputs": ["2\n1 4\n5 5", "2\n1 14\n5 5", "2\n3 2\n17 6", "2\n5 10\n17 4", "2\n9 10\n17 4", "2\n9 11\n17 4", "2\n7 11\n17 6", "2\n3 11\n17 6"], "outputs": ["0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n"]} | coding | 333 |
Solve the programming task below in a Python markdown code block.
You are given a positive integer $n$ greater or equal to $2$. For every pair of integers $a$ and $b$ ($2 \le |a|, |b| \le n$), you can transform $a$ into $b$ if and only if there exists an integer $x$ such that $1 < |x|$ and ($a \cdot x = b$ or $b \cdot ... | {"inputs": ["4\n", "6\n", "2\n", "3\n", "5\n", "7\n", "8\n", "9\n"], "outputs": ["8", "28", "0", "0", "8", "28", "52", "64"]} | coding | 349 |
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)"} | coding | 231 |
Solve the programming task below in a Python markdown code block.
You are given an undirected connected graph with N vertices and M edges that does not contain self-loops and double edges.
The i-th edge (1 \leq i \leq M) connects Vertex a_i and Vertex b_i.
An edge whose removal disconnects the graph is called a brid... | {"inputs": ["3 2\n1 2\n1 3\n2 3", "3 0\n2 2\n1 3\n3 3", "6 1\n2 1\n1 1\n1 3", "3 2\n2 2\n1 3\n2 3", "3 2\n2 1\n1 3\n2 3", "3 2\n2 2\n1 3\n3 3", "3 2\n1 2\n1 3\n2 1", "3 2\n2 2\n1 3\n1 3"], "outputs": ["2\n", "0\n", "1\n", "2\n", "2\n", "2\n", "2\n", "2\n"]} | coding | 369 |
Solve the programming task below in a Python markdown code block.
Complete the function which returns the weekday according to the input number:
* `1` returns `"Sunday"`
* `2` returns `"Monday"`
* `3` returns `"Tuesday"`
* `4` returns `"Wednesday"`
* `5` returns `"Thursday"`
* `6` returns `"Friday"`
* `7` returns `"Sa... | {"functional": "_inputs = [[1], [2], [3], [4], [5], [6], [7], [0], [8], [20]]\n_outputs = [['Sunday'], ['Monday'], ['Tuesday'], ['Wednesday'], ['Thursday'], ['Friday'], ['Saturday'], ['Wrong, please enter a number between 1 and 7'], ['Wrong, please enter a number between 1 and 7'], ['Wrong, please enter a number betwee... | coding | 120 |
Solve the programming task below in a Python markdown code block.
In this problem, a date is written as Y-M-D. For example, 2019-11-30 means November 30, 2019.
Integers M_1, D_1, M_2, and D_2 will be given as input.
It is known that the date 2019-M_2-D_2 follows 2019-M_1-D_1.
Determine whether the date 2019-M_1-D_1 is... | {"inputs": ["11 30\n6 1", "6 30\n12 1", "11 30\n2 1", "11 3\n11 8", "11 3\n11 7", "9 30\n12 1", "11 3\n11 9", "11 6\n11 7"], "outputs": ["1\n", "1\n", "1\n", "0\n", "0\n", "1\n", "0\n", "0\n"]} | coding | 290 |
Solve the programming task below in a Python markdown code block.
An array of integers $p_1, p_2, \dots, p_n$ is called a permutation if it contains each number from $1$ to $n$ exactly once. For example, the following arrays are permutations: $[3, 1, 2]$, $[1]$, $[1, 2, 3, 4, 5]$ and $[4, 3, 1, 2]$. The following array... | {"inputs": ["2\n0\n", "2\n1\n", "2\n0\n", "2\n1\n", "2\n2\n", "2\n4\n", "2\n3\n", "2\n7\n"], "outputs": ["-1\n", "1 2 ", "-1\n", "1 2 ", "-1\n", "-1\n", "-1\n", "-1\n"]} | coding | 452 |
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.
Let's define another 0-indexed integer array, nums3, of length n. For each index i in the range [0, n - 1], you can assign either nums1[i] or num... | {"functional": "def check(candidate):\n assert candidate(nums1 = [2,3,1], nums2 = [1,2,1]) == 2\n assert candidate(nums1 = [1,3,2,1], nums2 = [2,2,3,4]) == 4\n assert candidate(nums1 = [1,1], nums2 = [2,2]) == 2\n\n\ncheck(Solution().maxNonDecreasingLength)"} | coding | 188 |
Solve the programming task below in a Python markdown code block.
Chef is shopping for masks. In the shop, he encounters 2 types of masks:
Disposable Masks — cost X but last only 1 day.
Cloth Masks — cost Y but last 10 days.
Chef wants to buy masks to last him 100 days. He will buy the masks which cost him the least... | {"inputs": ["4\n10 100\n9 100\n88 99\n1 11\n"], "outputs": ["Cloth\nDisposable\nCloth\nDisposable\n"]} | coding | 590 |
Solve the programming task below in a Python markdown code block.
Casimir has a string $s$ which consists of capital Latin letters 'A', 'B', and 'C' only. Each turn he can choose to do one of the two following actions:
he can either erase exactly one letter 'A' and exactly one letter 'B' from arbitrary places of the s... | {"inputs": ["6\nABACAB\nABBA\nAC\nABC\nCABCBB\nBCBCBCBCBCBCBCBC\n", "6\nABACAB\nABBA\nAC\nABC\nCABCBB\nCBCBCBCBCBCBCBCB\n", "6\nABACAB\nABBA\nAC\nABC\nCABCBB\nBCBCBCBCBCACBCBC\n", "6\nABACAB\nABBA\nBC\nABB\nCABCBB\nCBCBCBCBCBCBCBCB\n", "6\nABBCAB\nABBA\nAC\nABC\nCABCBB\nBCBCBCBCBCACBCBC\n", "6\nABACAC\nABBA\nAC\nACB\nC... | coding | 489 |
Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given a string s consisting of digits and an integer k.
A round can be completed if the length of s is greater than k. In one round, do the following:
Divide s into consecutive groups of size k such that the ... | {"functional": "def check(candidate):\n assert candidate(s = \"11111222223\", k = 3) == \"135\"\n assert candidate(s = \"00000000\", k = 3) == \"000\"\n\n\ncheck(Solution().digitSum)"} | coding | 218 |
Solve the programming task below in a Python markdown code block.
Santa Claus likes palindromes very much. There was his birthday recently. k of his friends came to him to congratulate him, and each of them presented to him a string s_{i} having the same length n. We denote the beauty of the i-th string by a_{i}. It ca... | {"inputs": ["1 1\ne -1\n", "1 2\nyy 1\n", "1 2\nyy 1\n", "1 1\ne -1\n", "1 2\nzy 1\n", "1 1\nf -1\n", "0 1\nf -1\n", "0 1\ne -1\n"], "outputs": ["0\n", "1\n", "1\n", "0\n", "0\n", "0\n", "0\n", "0\n"]} | coding | 506 |
Solve the programming task below in a Python markdown code block.
Kefaa has developed a novel decomposition of a tree. He claims that this decomposition solves many difficult problems related to trees. However, he doesn't know how to find it quickly, so he asks you to help him.
You are given a tree with $N$ vertices nu... | {"inputs": ["2\n4\n1 2\n1 3\n1 4\n7\n1 2\n2 3\n1 4\n4 5\n1 6\n6 7"], "outputs": ["YES\n1 2 3 4\nNO"]} | coding | 593 |
Solve the programming task below in a Python markdown code block.
Given are integers A, B, and N.
Find the maximum possible value of floor(Ax/B) - A × floor(x/B) for a non-negative integer x not greater than N.
Here floor(t) denotes the greatest integer not greater than the real number t.
-----Constraints-----
- 1 ≤ ... | {"inputs": ["4 7 4", "1 7 4", "5 7 5", "2 7 4", "7 7 5", "9 6 5", "1 7 1", "1 7 0"], "outputs": ["2\n", "0\n", "3\n", "1\n", "5\n", "7\n", "0\n", "0\n"]} | coding | 232 |
Solve the programming task below in a Python markdown code block.
Coolguy gives you a simple problem. Given a $1$-indexed array, $\mbox{A}$, containing $N$ elements, what will $\textit{and}$ be after this pseudocode is implemented and executed? Print $and\%(10^9+7)$.
//f(a, b) is a function that returns the minimum el... | {"inputs": ["3\n3 2 1\n"], "outputs": ["6\n"]} | coding | 459 |
Solve the programming task below in a Python markdown code block.
Write a function that takes a list of at least four elements as an argument and returns a list of the middle two or three elements in reverse order.
Also feel free to reuse/extend the following starter code:
```python
def reverse_middle(lst):
``` | {"functional": "_inputs = [[[4, 3, 100, 1]], [[1, False, 'string', {}, 7.43]]]\n_outputs = [[[100, 3]], [[{}, 'string', 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, tup... | coding | 64 |
Solve the programming task below in a Python markdown code block.
There are three cities and thus three EVMs. An insider told Chef that his party got A, B, C votes respectively in these three cities according to the EVMs. Also, the total number of votes cast are P, Q, R respectively for the three cities.
Chef, being ... | {"inputs": ["3\n1 1 1 3 3 3\n49 1 49 50 100 50\n0 0 0 1 1 1\n"], "outputs": ["YES\nYES\nNO\n"]} | coding | 610 |
Solve the programming task below in a Python markdown code block.
Everybody seems to think that the Martians are green, but it turns out they are metallic pink and fat. Ajs has two bags of distinct nonnegative integers. The bags are disjoint, and the union of the sets of numbers in the bags is \{0,1,…,M-1\}, for some p... | {"inputs": ["1 2\n1\n", "1 2\n0\n", "2 5\n3 4\n", "2 4\n1 3\n", "4 20\n5 6 7 16\n", "4 20\n5 2 7 16\n", "9 10\n1 2 3 4 5 6 7 8 9\n", "4 1000000000\n5 25 125 625\n"], "outputs": ["1\n0\n", "1\n0\n", "1\n2\n", "2\n0 2\n", "1\n12 \n", "0\n", "1\n0\n", "0\n\n"]} | coding | 568 |
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 equal length n and a positive integer k. You must choose a subsequence of indices from nums1 of length k.
For chosen indices i0, i1, ..., ik - 1, your scor... | {"functional": "def check(candidate):\n assert candidate(nums1 = [1,3,3,2], nums2 = [2,1,3,4], k = 3) == 12\n assert candidate(nums1 = [4,2,3,1,1], nums2 = [7,5,10,9,6], k = 1) == 30\n\n\ncheck(Solution().maxScore)"} | coding | 236 |
Solve the programming task below in a Python markdown code block.
Takahashi and Aoki are training for long-distance races in an infinitely long straight course running from west to east.
They start simultaneously at the same point and moves as follows towards the east:
* Takahashi runs A_1 meters per minute for the f... | {"inputs": ["0 1\n0 1\n2 5", "0 0\n0 1\n2 5", "0 0\n0 1\n1 5", "0 0\n0 2\n1 5", "0 0\n0 2\n1 7", "0 0\n0 2\n1 3", "1 1\n0 4\n12 5", "1 2\n-1 2\n2 5"], "outputs": ["0\n", "infinity\n", "infinity\n", "infinity\n", "infinity\n", "infinity\n", "0\n", "0\n"]} | coding | 449 |
Solve the programming task below in a Python markdown code block.
Given are three positive integers A, B, and C. Compute the following value modulo 998244353:
\sum_{a=1}^{A} \sum_{b=1}^{B} \sum_{c=1}^{C} abc
-----Constraints-----
- 1 \leq A, B, C \leq 10^9
-----Input-----
Input is given from standard input in the fo... | {"inputs": ["1 2 3\n", "88 395 518\n", "693 299 737\n", "198 235 277\n", "682152024 451794315 2028038\n", "192279221 156648747 154396385\n", "264704198 120999147 136987925\n", "1000000000 987654321 123456789\n"], "outputs": ["18\n", "572699487\n", "373149185\n", "518269127\n", "579633067\n", "152138957\n", "24444247\n"... | coding | 246 |
Solve the programming task below in a Python markdown code block.
Pasha loves his phone and also putting his hair up... But the hair is now irrelevant.
Pasha has installed a new game to his phone. The goal of the game is following. There is a rectangular field consisting of n row with m pixels in each row. Initially, ... | {"inputs": ["1 1 1\n1 1\n", "1 1 1\n1 1\n", "1 2 1\n1 1\n", "2 2 4\n1 1\n1 2\n2 1\n2 2\n", "2 2 4\n1 1\n1 2\n2 1\n2 2\n", "2 2 5\n1 1\n2 1\n2 1\n1 2\n2 2\n", "1 1 5\n1 1\n1 1\n1 1\n1 1\n1 1\n", "1 5 5\n1 1\n1 2\n1 3\n1 4\n1 5\n"], "outputs": ["0\n", "0", "0\n", "4\n", "4", "5\n", "0\n", "0\n"]} | coding | 523 |
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"]} | coding | 689 |
Solve the programming task below in a Python markdown code block.
-----Input-----
The input consists of a single string of uppercase letters A-Z. The length of the string is between 1 and 10 characters, inclusive.
-----Output-----
Output "YES" or "NO".
-----Examples-----
Input
NEAT
Output
YES
Input
WORD
Output... | {"inputs": ["Q\n", "Q\n", "P\n", "O\n", "AI\n", "IS\n", "IS\n", "JS\n"], "outputs": ["YES\n", "YES", "YES\n", "YES\n", "YES\n", "NO\n", "NO", "YES\n"]} | coding | 124 |
Solve the programming task below in a Python markdown code block.
There are N piles where the i^{th} pile consists of A_{i} stones.
Chef and Chefina are playing a game taking alternate turns with Chef starting first.
In his/her turn, a player can choose any non-empty pile and remove exactly 1 stone from it.
The ga... | {"inputs": ["3\n2\n2 2\n1\n10\n3\n1 5 6\n"], "outputs": ["CHEFINA\nCHEFINA\nCHEF\n"]} | coding | 454 |
Solve the programming task below in a Python markdown code block.
##Task:
You have to write a function `add` which takes two binary numbers as strings and returns their sum as a string.
##Note:
* You are `not allowed to convert binary to decimal & vice versa`.
* The sum should contain `No leading zeroes`.
##Examples:... | {"functional": "_inputs = [['111', '10'], ['1101', '101'], ['1101', '10111'], ['10111', '001010101'], ['00', '0']]\n_outputs = [['1001'], ['10010'], ['100100'], ['1101100'], ['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_to... | coding | 153 |
Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given two integers tomatoSlices and cheeseSlices. The ingredients of different burgers are as follows:
Jumbo Burger: 4 tomato slices and 1 cheese slice.
Small Burger: 2 Tomato slices and 1 cheese slice.
Return [tota... | {"functional": "def check(candidate):\n assert candidate(tomatoSlices = 16, cheeseSlices = 7) == [1,6]\n assert candidate(tomatoSlices = 17, cheeseSlices = 4) == []\n assert candidate(tomatoSlices = 4, cheeseSlices = 17) == []\n assert candidate(tomatoSlices = 0, cheeseSlices = 0) == [0,0]\n assert candi... | coding | 163 |
Please solve the programming task below using a self-contained code snippet in a markdown code block.
You start with an initial power of power, an initial score of 0, and a bag of tokens given as an integer array tokens, where each tokens[i] denotes the value of tokeni.
Your goal is to maximize the total score by stra... | {"functional": "def check(candidate):\n assert candidate(tokens = [100], power = 50) == 0\n assert candidate(tokens = [200,100], power = 150) == 1\n assert candidate(tokens = [100,200,300,400], power = 200) == 2\n\n\ncheck(Solution().bagOfTokensScore)"} | coding | 210 |
Solve the programming task below in a Python markdown code block.
Your task is to ___find the next higher number (int) with same '1'- Bits___.
I.e. as much `1` bits as before and output next higher than input. Input is always an int in between 1 and 1<<30 (inclusive). No bad cases or special tricks...
### Some easy ... | {"functional": "_inputs = [[128], [1], [1022], [127], [1253343]]\n_outputs = [[256], [2], [1279], [191], [1253359]]\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 ... | coding | 276 |
Solve the programming task below in a Python markdown code block.
Polycarp is going to participate in the contest. It starts at $h_1:m_1$ and ends at $h_2:m_2$. It is guaranteed that the contest lasts an even number of minutes (i.e. $m_1 \% 2 = m_2 \% 2$, where $x \% y$ is $x$ modulo $y$). It is also guaranteed that th... | {"inputs": ["10:00\n11:00\n", "11:10\n11:12\n", "01:02\n03:02\n", "00:00\n23:58\n", "00:01\n23:59\n", "00:00\n00:02\n", "23:57\n23:59\n", "11:40\n12:22\n"], "outputs": ["10:30\n", "11:11\n", "02:02\n", "11:59\n", "12:00\n", "00:01\n", "23:58\n", "12:01\n"]} | coding | 521 |
Solve the programming task below in a Python markdown code block.
# Task
If string has more than one neighboring dashes(e.g. --) replace they with one dash(-).
Dashes are considered neighbors even if there is some whitespace **between** them.
# Example
For `str = "we-are- - - code----warriors.-"`
The result ... | {"functional": "_inputs = [['we-are- - - code----warriors.-'], ['a---b- - -c'], ['a------'], ['Lorem - ipsum- - - dolor sit amet, consectetur adipiscing elit. Praesent tristique lectus non erat dapibus tincidunt. Integer non nibh fermentum, cursus-diam -------pharetra, mattis--risus.-------']]\n_outputs = [['we-are- co... | coding | 136 |
Solve the programming task below in a Python markdown code block.
Chef is playing an easier variation of the board game ‘Risk’ with his friend Mike. There is an $N * M$ grid, depicting the world map. Each cell of the grid is either $1$ or $0$ where $1$ denotes that there is land on this cell, while $0$ denotes water.
... | {"inputs": ["3\n4 4\n1001\n0110\n0110\n1001\n2 2\n11\n11\n3 3\n100\n010\n001"], "outputs": ["2\n0\n1"]} | coding | 617 |
Solve the programming task below in a Python markdown code block.
Polycarp is crazy about round numbers. He especially likes the numbers divisible by 10^{k}.
In the given number of n Polycarp wants to remove the least number of digits to get a number that is divisible by 10^{k}. For example, if k = 3, in the number 30... | {"inputs": ["0 1\n", "0 9\n", "0 9\n", "0 1\n", "10 1\n", "10 2\n", "10 9\n", "10 1\n"], "outputs": ["0\n", "0\n", "0\n", "0\n", "0\n", "1\n", "1\n", "0\n"]} | coding | 422 |
Solve the programming task below in a Python markdown code block.
Write a program which calculates the area and perimeter of a given rectangle.
Constraints
* 1 ≤ a, b ≤ 100
Input
The length a and breadth b of the rectangle are given in a line separated by a single space.
Output
Print the area and perimeter of the... | {"inputs": ["0 5", "1 5", "1 3", "0 3", "0 1", "0 2", "0 4", "1 4"], "outputs": ["0 10\n", "5 12\n", "3 8\n", "0 6\n", "0 2\n", "0 4\n", "0 8\n", "4 10\n"]} | coding | 104 |
Solve the programming task below in a Python markdown code block.
Rikhail Mubinchik believes that the current definition of prime numbers is obsolete as they are too complex and unpredictable. A palindromic number is another matter. It is aesthetically pleasing, and it has a number of remarkable properties. Help Rikhai... | {"inputs": ["1 1\n", "6 4\n", "3 1\n", "5 8\n", "4 9\n", "5 8\n", "4 9\n", "3 1\n"], "outputs": ["40\n", "172\n", "2530\n", "16\n", "10\n", "16", "10", "2530"]} | coding | 402 |
Solve the programming task below in a Python markdown code block.
Little Petya likes numbers a lot. He found that number 123 in base 16 consists of two digits: the first is 7 and the second is 11. So the sum of digits of 123 in base 16 is equal to 18.
Now he wonders what is an average value of sum of digits of the num... | {"inputs": ["6\n", "4\n", "3\n", "5\n", "31\n", "28\n", "98\n", "88\n"], "outputs": ["9/4\n", "3/2\n", "2/1\n", "7/3\n", "222/29\n", "85/13\n", "317/16\n", "1529/86\n"]} | coding | 252 |
Solve the programming task below in a Python markdown code block.
Snuke, a water strider, lives in a rectangular pond that can be seen as a grid with H east-west rows and W north-south columns. Let (i,j) be the square at the i-th row from the north and j-th column from the west.
Some of the squares have a lotus leaf on... | {"inputs": ["1 6 4\n1 1 1 1\n......", "1 6 4\n1 2 1 6\n......", "1 6 1\n1 1 1 6\n......", "1 6 2\n1 1 1 1\n......", "1 8 1\n1 1 1 6\n......", "1 6 4\n1 1 1 4\n......", "1 6 4\n1 1 1 1\n...-..", "1 8 2\n1 1 1 1\n......"], "outputs": ["0\n", "1\n", "5\n", "0\n", "5\n", "1\n", "0\n", "0\n"]} | coding | 664 |
Solve the programming task below in a Python markdown code block.
We say that a positive integer $n$ is $k$-good for some positive integer $k$ if $n$ can be expressed as a sum of $k$ positive integers which give $k$ distinct remainders when divided by $k$.
Given a positive integer $n$, find some $k \geq 2$ so that $n$... | {"inputs": ["5\n2\n4\n6\n15\n20\n", "1\n546504780814441385\n", "1\n999999999339134976\n", "1\n536870915758096384\n"], "outputs": ["-1\n-1\n3\n2\n5\n", "2\n", "465661287\n", "1000000007\n"]} | coding | 442 |
Solve the programming task below in a Python markdown code block.
Snuke has two boards, each divided into a grid with N rows and N columns. For both of these boards, the square at the i-th row from the top and the j-th column from the left is called Square (i,j).
There is a lowercase English letter written in each squ... | {"inputs": ["2\nab\nda", "2\nab\nad", "2\nab\nac", "2\nba\nca", "2\nbb\nca", "2\nbb\nac", "2\ncb\nac", "2\ncb\nab"], "outputs": ["2\n", "0\n", "0\n", "0\n", "0\n", "0\n", "2\n", "0\n"]} | coding | 506 |
Solve the programming task below in a Python markdown code block.
The number ```89``` is the first integer with more than one digit that fulfills the property partially introduced in the title of this kata.
What's the use of saying "Eureka"? Because this sum gives the same number.
In effect: ```89 = 8^1 + 9^2```
Th... | {"functional": "_inputs = [[1, 100], [10, 89], [10, 100], [90, 100], [90, 150], [50, 150], [10, 150], [89, 135]]\n_outputs = [[[1, 2, 3, 4, 5, 6, 7, 8, 9, 89]], [[89]], [[89]], [[]], [[135]], [[89, 135]], [[89, 135]], [[89, 135]]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b,... | coding | 339 |
Solve the programming task below in a Python markdown code block.
# Description
Write a function that checks whether a credit card number is correct or not, using the Luhn algorithm.
The algorithm is as follows:
* From the rightmost digit, which is the check digit, moving left, double the value of every second digit;... | {"functional": "_inputs = [['5457 6238 9823 4311'], ['8895 6238 9323 4311'], ['5457 6238 5568 4311'], ['5457 6238 9323 4311'], ['2222 2222 2222 2224'], ['5457 1125 9323 4311'], ['1252 6238 9323 4311'], ['9999 9999 9999 9995'], ['0000 0300 0000 0000'], ['4444 4444 4444 4448'], ['5457 6238 9323 1252'], ['5457 6238 1251 4... | coding | 383 |
Solve the programming task below in a Python markdown code block.
Chef has to attend an exam that starts in X minutes, but of course, watching shows takes priority.
Every episode of the show that Chef is watching, is 24 minutes long.
If he starts watching a new episode now, will he finish watching it strictly before... | {"inputs": ["4\n30\n23\n60\n24\n"], "outputs": ["Yes\nNo\nYes\nNo\n"]} | coding | 420 |
Solve the programming task below in a Python markdown code block.
Chef's phone has a total storage of S MB. Also, Chef has 2 apps already installed on his phone which occupy X MB and Y MB respectively.
He wants to install another app on his phone whose memory requirement is Z MB. For this, he might have to delete the... | {"inputs": ["4\n10 1 2 3\n9 4 5 1\n15 5 10 15\n100 20 30 75\n"], "outputs": ["0\n1\n2\n1\n"]} | coding | 483 |
Solve the programming task below in a Python markdown code block.
This is the first step to understanding FizzBuzz.
Your inputs:
a positive integer, n, greater than or equal to one.
n is provided, you have NO CONTROL over its value.
Your expected output is an array of positive integers from 1 to n (inclusive).
You... | {"functional": "_inputs = [[1], [2], [3], [4], [5]]\n_outputs = [[[1]], [[1, 2]], [[1, 2, 3]], [[1, 2, 3, 4]], [[1, 2, 3, 4, 5]]]\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, tu... | coding | 109 |
Solve the programming task below in a Python markdown code block.
Chef has three baskets and two of them have multiple balls(Natural numbers written on them). The first basket has N balls, the second basket has M balls and the third basket is empty. Chef starts choosing all the unique balls(only occurring once in both ... | {"inputs": ["1\n4 5\n1 2 3 4\n2 3 4 5 6"], "outputs": ["1 5 6"]} | coding | 259 |
Solve the programming task below in a Python markdown code block.
After celebrating the midcourse the students of one of the faculties of the Berland State University decided to conduct a vote for the best photo. They published the photos in the social network and agreed on the rules to choose a winner: the photo which... | {"inputs": ["1\n5\n", "1\n1\n", "1\n5\n", "1\n1\n", "1\n3\n", "1\n2\n", "1\n4\n", "1\n7\n"], "outputs": ["5\n", "1\n", "5", "1", "3\n", "2\n", "4\n", "7\n"]} | coding | 373 |
Solve the programming task below in a Python markdown code block.
There are N cities in Republic of AtCoder. The size of the i-th city is A_{i}. Takahashi would like to build N-1 bidirectional roads connecting two cities so that any city can be reached from any other city by using these roads.
Assume that the cost of ... | {"inputs": ["3 1\n2 100 1", "3 1\n0 100 1", "3 2\n1 100 1", "3 1\n0 101 1", "3 4\n1 100 1", "3 1\n4 110 1", "3 1\n1 100 1", "3 1000\n1 101 1"], "outputs": ["107\n", "104\n", "109\n", "105\n", "115\n", "119\n", "106", "2204\n"]} | coding | 344 |
Solve the programming task below in a Python markdown code block.
Harry Water, Ronaldo, Her-my-oh-knee and their friends have started a new school year at their MDCS School of Speechcraft and Misery. At the time, they are very happy to have seen each other after a long time. The sun is shining, birds are singing, flowe... | {"inputs": ["2\n1\n3\n", "2\n1\n4\n", "2\n0\n4\n", "2\n1\n1\n", "2\n1\n8\n", "2\n1\n9\n", "2\n1\n2\n", "2\n1\n6\n"], "outputs": ["6\n", "8\n", "0\n", "2\n", "16\n", "18\n", "4\n", "12\n"]} | coding | 478 |
Solve the programming task below in a Python markdown code block.
Vasya adores sport programming. He can't write programs but he loves to watch the contests' progress. Vasya even has a favorite coder and Vasya pays special attention to him.
One day Vasya decided to collect the results of all contests where his favorit... | {"inputs": ["1\n6\n", "1\n0\n", "1\n1\n", "1\n2\n", "1\n3\n", "1\n-1\n", "1\n-2\n", "1\n-3\n"], "outputs": ["0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n"]} | coding | 499 |
Solve the programming task below in a Python markdown code block.
If you visit Aizu Akabeko shrine, you will find a unique paper fortune on which a number with more than one digit is written.
Each digit ranges from 1 to 9 (zero is avoided because it is considered a bad omen in this shrine). Using this string of numeri... | {"inputs": ["88", "73", "19", "31", "799", "836", "138", "774"], "outputs": ["0\n", "4\n", "8\n", "2\n", "2\n", "5\n", "5\n", "3\n"]} | coding | 385 |
Solve the programming task below in a Python markdown code block.
A (1-indexed) string S of length N is said to be anti-palindrome if, for each 1 ≤ i ≤ N, S_{i} \ne S_{(N + 1 - i)}.
You are given a string S of length N (consisting of lowercase Latin letters only). Rearrange the string to convert it into an anti-palind... | {"inputs": ["4\n3\nabc\n8\nabccccdd\n4\nxyyx\n6\nppppqr\n"], "outputs": ["NO\nYES\nabddcccc\nYES\nxxyy\nNO\n"]} | coding | 562 |
Please solve the programming task below using a self-contained code snippet in a markdown code block.
There are n gas stations along a circular route, where the amount of gas at the ith station is gas[i].
You have a car with an unlimited gas tank and it costs cost[i] of gas to travel from the ith station to its next (... | {"functional": "def check(candidate):\n assert candidate(gas = [1,2,3,4,5], cost = [3,4,5,1,2]) == 3\n assert candidate(gas = [2,3,4], cost = [3,4,3]) == -1\n\n\ncheck(Solution().canCompleteCircuit)"} | coding | 174 |
Solve the programming task below in a Python markdown code block.
Kuroni is very angry at the other setters for using him as a theme! As a punishment, he forced them to solve the following problem:
You have an array $a$ consisting of $n$ positive integers. An operation consists of choosing an element and either adding... | {"inputs": ["2\n1 1\n", "2\n1 1\n", "2\n2 1\n", "2\n3 1\n", "3\n6 2 4\n", "3\n6 3 4\n", "3\n6 2 4\n", "3\n12 4 4\n"], "outputs": ["2\n", "2\n", "1\n", "2\n", "0\n", "1\n", "0\n", "0\n"]} | coding | 444 |
Solve the programming task below in a Python markdown code block.
Teja likes cricket very much and likes to watch it all the time, but he is bored of watching the
matches alone and asks his friend to give him company. But his friend doesn’t know how to read
cricket scores so Teja decided to teach him. To make him under... | {"inputs": ["3\n1 1\n4 1\n7 6", "3\n1 1\n9 1\n7 6"], "outputs": ["YES", "NO"]} | coding | 421 |
Solve the programming task below in a Python markdown code block.
In Snakeland, there are some snakes and mongooses. They are lined up in a row. The information about how exactly they are lined up it is provided to you by a string of length n. If the i-th character of this string is 's', then it means that there is a s... | {"inputs": ["4\nsm\nssm\nsms\nssmmmssss"], "outputs": ["mongooses\ntie\ntie\nsnakes"]} | coding | 647 |
Solve the programming task below in a Python markdown code block.
Recently, Greg got a grid with n rows and m columns. Rows are indexed from 1 to n and columns are indexed from 1 to m. The cell $ ( i , j )$ is the cell of intersection of row i and column j. Each cell has a number written on it. The number written on ce... | {"inputs": ["3 4\n"], "outputs": ["4"]} | coding | 212 |
Solve the programming task below in a Python markdown code block.
Note : This question carries $150$ $points$
There is an outcry in Middle Earth, as the greatest war between Orgs of Dark Lord Sauron and Frodo Baggins is about to begin. To end the war, Frodo decides to destroy the ring in the volcano of Mordor. There ar... | {"inputs": ["1\n1 9"], "outputs": ["1 1"]} | coding | 383 |
Solve the programming task below in a Python markdown code block.
Given are an integer X and an integer sequence of length N: p_1, \ldots, p_N.
Among the integers not contained in the sequence p_1, \ldots, p_N (not necessarily positive), find the integer nearest to X, that is, find the integer whose absolute difference... | {"inputs": ["1 0\n\n", "101 0", "100 0", "1 1\n1\n", "100 0\n\n", "100 2\n100 99\n", "3 1\n4 5 1 1 0", "3 2\n4 2 1 8 3"], "outputs": ["1\n", "101\n", "100", "0\n", "100\n", "101\n", "3\n", "5\n"]} | coding | 257 |
Solve the programming task below in a Python markdown code block.
There were $N$ students (numbered $1$ through $N$) participating in the Indian Programming Camp (IPC) and they watched a total of $K$ lectures (numbered $1$ through $K$). For each student $i$ and each lecture $j$, the $i$-th student watched the $j$-th le... | {"inputs": ["4 8 4\n1 2 1 2 5\n3 5 1 3 4\n1 2 4 5 11\n1 1 1 3 12"], "outputs": ["1"]} | coding | 663 |
Solve the programming task below in a Python markdown code block.
Chef has gone shopping with his 5-year old son. They have bought N items so far. The items are numbered from 1 to N, and the item i weighs Wi grams.
Chef's son insists on helping his father in carrying the items. He wants his dad to give him a few items... | {"inputs": ["2\n5 2\n3 2 5 2 1\n8 3\n1 1 1 1 1 1 0 1", "2\n5 2\n3 2 5 0 6\n8 3\n1 0 1 1 1 1 1 1", "2\n5 1\n3 2 5 2 1\n8 3\n1 1 1 1 1 1 0 1", "2\n5 2\n3 4 5 1 6\n8 3\n0 1 1 0 1 1 0 1", "2\n5 2\n3 2 5 2 8\n8 4\n1 1 1 1 1 1 1 1", "2\n5 2\n3 2 5 0 6\n8 3\n0 0 1 1 1 1 1 1", "2\n5 1\n3 2 5 2 1\n8 3\n1 1 1 1 1 0 0 1", "2\n5 2... | coding | 485 |
Solve the programming task below in a Python markdown code block.
Did you ever hear about 'Dragon Food' ? Its used to refer to the chocolates bought for your loved ones :). Po offers dragon food to master Shifu, who is a famous cook in the valley of food. In return, Shifu hands over the dragon scroll to Po, which is sa... | {"inputs": ["3\n3 5 4\n5 0 1\n4 3 7", "3\n3 5 4\n2 0 1\n4 3 7", "3\n3 5 4\n2 0 1\n4 3 0", "3\n3 5 4\n1 0 1\n4 3 6", "3\n3 5 0\n2 0 1\n4 3 7", "3\n3 5 0\n3 0 1\n4 3 7", "3\n5 5 0\n3 0 1\n4 3 7", "3\n5 5 0\n3 1 1\n4 3 7"], "outputs": ["7\n16\n14", "7\n2\n14\n", "7\n2\n12\n", "7\n1\n15\n", "6\n2\n14\n", "6\n4\n14\n", "24\... | coding | 745 |
Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given a directed acyclic graph, with n vertices numbered from 0 to n-1, and an array edges where edges[i] = [fromi, toi] represents a directed edge from node fromi to node toi.
Find the smallest set of vertices from w... | {"functional": "def check(candidate):\n assert candidate(n = 6, edges = [[0,1],[0,2],[2,5],[3,4],[4,2]]) == [0,3]\n assert candidate(n = 5, edges = [[0,1],[2,1],[3,1],[1,4],[2,4]]) == [0,2,3]\n\n\ncheck(Solution().findSmallestSetOfVertices)"} | coding | 156 |
Solve the programming task below in a Python markdown code block.
Write a simple regex to validate a username. Allowed characters are:
- lowercase letters,
- numbers,
- underscore
Length should be between 4 and 16 characters (both included).
Also feel free to reuse/extend the following starter code:
```python
def val... | {"functional": "_inputs = [['asddsa'], ['a'], ['Hass'], ['Hasd_12assssssasasasasasaasasasasas'], [''], ['____'], ['012'], ['p1pp1'], ['asd43 34'], ['asd43_34']]\n_outputs = [[True], [False], [False], [False], [False], [True], [False], [True], [False], [True]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstan... | coding | 72 |
Solve the programming task below in a Python markdown code block.
Niwango has N cards, numbered 1,2,\ldots,N. He will now arrange these cards in a row.
Niwango wants to know if there is a way to arrange the cards while satisfying all the N conditions below. To help him, determine whether such a way exists. If the answ... | {"inputs": ["2\n2 1", "4\n2 3 4 0", "4\n4 3 4 1", "4\n2 3 2 1", "4\n3 5 2 1", "4\n2 3 5 0", "4\n2 3 4 1", "13\n1 3 3 0 9 4 9 2 4 6 12 8 8"], "outputs": ["-1", "1 3 2 4\n", "1 2 4 3\n", "1 3 4 2\n", "1 2 3 4\n", "1 3 2 4\n", "1 3 2 4", "1 2 4 3 5 6 7 8 9 10 11 13 12\n"]} | coding | 380 |
Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given an integer array nums and an integer x. In one operation, you can either remove the leftmost or the rightmost element from the array nums and subtract its value from x. Note that this modifies the array ... | {"functional": "def check(candidate):\n assert candidate(nums = [1,1,4,2,3], x = 5) == 2\n assert candidate(nums = [5,6,7,8,9], x = 4) == -1\n assert candidate(nums = [3,2,20,1,1,3], x = 10) == 5\n\n\ncheck(Solution().minOperations)"} | coding | 125 |
Solve the programming task below in a Python markdown code block.
Iahub is a big fan of tourists. He wants to become a tourist himself, so he planned a trip. There are n destinations on a straight road that Iahub wants to visit. Iahub starts the excursion from kilometer 0. The n destinations are described by a non-nega... | {"inputs": ["3\n2 3 5\n", "3\n2 3 8\n", "3\n4 3 8\n", "3\n3 3 8\n", "3\n5 3 8\n", "3\n6 3 8\n", "3\n2 3 5\n", "3\n6 3 11\n"], "outputs": ["22 3", "37 3\n", "35 3\n", "34 3\n", "12 1\n", "37 3\n", "22 3", "52 3\n"]} | coding | 700 |
Solve the programming task below in a Python markdown code block.
Ronny the robot is watching someone perform the Cups and Balls magic trick. The magician has one ball and three cups, he shows Ronny which cup he hides the ball under (b), he then mixes all the cups around by performing multiple two-cup switches (arr). R... | {"functional": "_inputs = [[2, [[1, 2]]], [1, [[2, 3], [1, 2], [1, 2]]], [2, [[1, 3], [1, 2], [2, 1], [2, 3]]]]\n_outputs = [[1], [1], [3]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return math.isclose(a, b, rel_tol=tol, abs_tol=tol)\n if isinstance(a,... | coding | 332 |
Solve the programming task below in a Python markdown code block.
The `depth` of an integer `n` is defined to be how many multiples of `n` it is necessary to compute before all `10` digits have appeared at least once in some multiple.
example:
```
let see n=42
Multiple value digits comment
42*1 ... | {"functional": "_inputs = [[8], [13], [7], [25], [42], [1]]\n_outputs = [[12], [8], [10], [36], [9], [10]]\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(... | coding | 337 |
Solve the programming task below in a Python markdown code block.
Once Bob got to a sale of old TV sets. There were n TV sets at that sale. TV set with index i costs ai bellars. Some TV sets have a negative price — their owners are ready to pay Bob if he buys their useless apparatus. Bob can «buy» any TV sets he wants.... | {"inputs": ["1 1\n0\n", "1 1\n1\n", "1 1\n-1\n", "1 1\n555\n", "1 1\n-24\n", "4 2\n7 1 0 -7\n", "4 2\n7 0 0 -7\n", "2 2\n-742 -187\n"], "outputs": ["0\n", "0\n", "1\n", "0\n", "24\n", "7\n", "7\n", "929\n"]} | coding | 268 |
Solve the programming task below in a Python markdown code block.
Each month Blake gets the report containing main economic indicators of the company "Blake Technologies". There are n commodities produced by the company. For each of them there is exactly one integer in the final report, that denotes corresponding reven... | {"inputs": ["1 1\n366\n1 1\n", "1 1\n1234\n1 1\n", "1 1\n1234\n1 1\n", "1 1\n1722\n1 1\n", "3 1\n1 2 3\n2 2\n", "3 1\n1 2 6\n2 2\n", "3 1\n1 0 6\n2 2\n", "3 1\n1 2 3\n2 2\n"], "outputs": ["366\n", "1234 ", "1234 ", "1722\n", "2 1 3 ", "2 1 6\n", "1 0 6\n", "2 1 3 "]} | coding | 583 |
Solve the programming task below in a Python markdown code block.
Polycarp has $n$ coins, the value of the $i$-th coin is $a_i$. It is guaranteed that all the values are integer powers of $2$ (i.e. $a_i = 2^d$ for some non-negative integer number $d$).
Polycarp wants to know answers on $q$ queries. The $j$-th query is... | {"inputs": ["3 3\n1 1 1\n1\n2\n3\n", "3 3\n1 1 1\n1\n2\n3\n", "3 3\n1 1 1\n1\n4\n3\n", "3 3\n1 2 1\n1\n4\n3\n", "3 3\n1 4 1\n1\n4\n3\n", "3 3\n1 4 1\n1\n6\n3\n", "3 3\n1 4 2\n1\n6\n3\n", "3 3\n1 4 2\n1\n6\n2\n"], "outputs": ["1\n2\n3\n", "1\n2\n3\n", "1\n-1\n3\n", "1\n3\n2\n", "1\n1\n-1\n", "1\n3\n-1\n", "1\n2\n2\n", "... | coding | 476 |
Solve the programming task below in a Python markdown code block.
Chef found N magical cards in his drawer. Each card has a number written on each of its faces. He places all the cards on the table in a front face-up manner.
Chef denotes the numbers on the front face by A_{1}, A_{2},..., A_{N} and on the back face by ... | {"inputs": ["3\n3\n4 6 8\n2 1 2\n3\n0 2 0\n2 0 8\n3\n1 2 1\n2 3 6"], "outputs": ["2 2\n0 0\n2 2"]} | coding | 568 |
Solve the programming task below in a Python markdown code block.
The Fair Nut found a string $s$. The string consists of lowercase Latin letters. The Nut is a curious guy, so he wants to find the number of strictly increasing sequences $p_1, p_2, \ldots, p_k$, such that: For each $i$ ($1 \leq i \leq k$), $s_{p_i} =$... | {"inputs": ["agaa\n", "bgaa\n", "aagb\n", "agab\n", "agbb\n", "bgbb\n", "bbbg\n", "gbbb\n"], "outputs": ["3", "2\n", "2\n", "2\n", "1\n", "0\n", "0\n", "0\n"]} | coding | 396 |
Solve the programming task below in a Python markdown code block.
Luntik came out for a morning stroll and found an array $a$ of length $n$. He calculated the sum $s$ of the elements of the array ($s= \sum_{i=1}^{n} a_i$). Luntik calls a subsequence of the array $a$ nearly full if the sum of the numbers in that subsequ... | {"inputs": ["5\n5\n1 2 3 4 5\n2\n1000 1000\n2\n1 0\n5\n3 0 2 1 1\n5\n2 1 0 3 0\n", "5\n5\n1 2 3 4 5\n2\n1000 1000\n2\n1 0\n5\n3 0 2 1 0\n5\n2 1 0 3 0\n", "5\n5\n1 4 3 4 5\n2\n1000 1000\n2\n1 0\n5\n3 0 4 1 0\n5\n0 1 0 3 0\n", "5\n5\n1 2 3 4 1\n2\n1000 1000\n2\n1 0\n5\n3 0 2 1 1\n5\n2 1 0 3 0\n", "5\n5\n1 2 3 4 5\n2\n100... | coding | 532 |
Solve the programming task below in a Python markdown code block.
A Discrete Mathematics professor has a class of students. Frustrated with their lack of discipline, the professor decides to cancel class if fewer than some number of students are present when class starts. Arrival times go from on time ($arrivalTime\le... | {"inputs": ["2\n4 3\n-1 -3 4 2\n4 2\n0 -1 2 1\n"], "outputs": ["YES\nNO\n"]} | coding | 598 |
Solve the programming task below in a Python markdown code block.
You are given two positive integers a and b.
Let x be the average of a and b.
Print x rounded up to the nearest integer.
-----Constraints-----
- a and b are integers.
- 1 \leq a, b \leq 100
-----Input-----
Input is given from Standard Input in the fo... | {"inputs": ["1 3\n", "7 4\n", "5 5\n"], "outputs": ["2\n", "6\n", "5\n"]} | coding | 140 |
Solve the programming task below in a Python markdown code block.
Chef has an array of N natural numbers. Cheffina challenges the chef to choose the two numbers from the array and following the condition as the area of the rectangle formed from the two numbers is maximum. Cheffina also asks the chef to choose two numbe... | {"inputs": ["1\n5\n4 2 1 5 3"], "outputs": ["20 2"]} | coding | 228 |
Solve the programming task below in a Python markdown code block.
In this problem, you should process T testcases.
For each testcase, you are given four integers N, M, A, B.
Calculate \sum_{i = 0}^{N - 1} floor((A \times i + B) / M).
Constraints
* 1 \leq T \leq 100,000
* 1 \leq N, M \leq 10^9
* 0 \leq A, B < M
Inp... | {"inputs": ["5\n3 16 6 3\n2 2 2 3\n2 3 0 0\n31415 92653 97266 32384\n1000000000 1000001000 11747768 999999999", "5\n4 16 6 6\n6 5 4 3\n1 2 0 0\n31415 92653 58979 3909\n1000000000 1000000000 999999999 999999999", "5\n4 10 6 6\n6 5 4 3\n1 1 0 0\n31415 92653 58979 32384\n1000000000 1000000000 999999999 999999999", "5\n4 1... | coding | 332 |
Solve the programming task below in a Python markdown code block.
We need you to implement a method of receiving commands over a network, processing the information and responding.
Our device will send a single packet to you containing data and an instruction which you must perform before returning your reply.
To kee... | {"functional": "_inputs = [['H1H10F1200120008F4F4'], ['D7D70F1200250015G8G8'], ['X7X7B7A201400058L0L0'], ['Y2Y2B7A210000902N5N5'], ['R5R5C3D900120008K4K4'], ['S2S2C3D900250005I9I9'], ['E4E40F1239128908Z3Z3'], ['A6A6C3D911150015M0M0'], ['T7T7B7A200258908P2P2'], ['S4S4B7A201153215U8U8']]\n_outputs = [['H1H1FFFF00200000F4... | coding | 481 |
Solve the programming task below in a Python markdown code block.
You are given a sequence of $n$ integers $a_1$, $a_2$, ..., $a_n$. Let us call an index $j$ ($2 \le j \le {{n-1}}$) a hill if $a_j > a_{{j+1}}$ and $a_j > a_{{j-1}}$; and let us call it a valley if $a_j < a_{{j+1}}$ and $a_j < a_{{j-1}}$.
Let us define ... | {"inputs": ["4\n3\n2 5 3\n5\n3 3 2 2 2\n6\n1 6 2 5 2 3\n5\n1 6 2 4 1\n", "4\n3\n2 5 3\n5\n3 3 2 2 2\n6\n1 6 0 5 2 3\n5\n1 6 2 4 1\n", "4\n3\n2 5 3\n5\n3 3 3 2 2\n6\n1 6 2 5 2 3\n5\n1 6 2 4 1\n", "4\n3\n2 5 3\n5\n3 3 2 0 2\n6\n1 6 0 5 2 3\n5\n1 6 2 4 1\n", "4\n3\n0 5 3\n5\n3 3 2 2 2\n6\n1 6 2 5 2 3\n5\n1 6 2 4 1\n", "4\... | coding | 516 |
Solve the programming task below in a Python markdown code block.
Raju has created a program to find the square root of a number. But his program can store only integers. Being a newbie, he didn't know about rounding the numbers. Hence his program returns the absolute value of the result if possible. For example, sqrt(... | {"inputs": ["2 20\n5\n3"], "outputs": ["yes\nno"]} | coding | 479 |
Solve the programming task below in a Python markdown code block.
Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
There are $N$ boxes on a table, numbered $1$ through $N$ from left to right. Each box has a number written on it; let's denote the number written on ... | {"inputs": ["2\n4 3 0\n4 1 9 5\n4 3 1\n4 1 9 5"], "outputs": ["9\n1"]} | coding | 578 |
Solve the programming task below in a Python markdown code block.
You are given an array $a$ of $n$ integers, where $n$ is odd. You can make the following operation with it: Choose one of the elements of the array (for example $a_i$) and increase it by $1$ (that is, replace it with $a_i + 1$).
You want to make the m... | {"inputs": ["1 1\n1\n", "1 1\n1\n", "1 1\n2\n", "3 2\n1 3 5\n", "3 1\n1 1 1\n", "3 1\n1 1 1\n", "3 2\n1 3 5\n", "3 100\n1 2 3\n"], "outputs": ["2", "2", "3\n", "5", "1", "1", "5", "52"]} | coding | 470 |
Solve the programming task below in a Python markdown code block.
You are given an integer $n$. Check if $n$ has an odd divisor, greater than one (does there exist such a number $x$ ($x > 1$) that $n$ is divisible by $x$ and $x$ is odd).
For example, if $n=6$, then there is $x=3$. If $n=4$, then such a number does not... | {"inputs": ["2\n4\n54\n", "2\n7\n30\n", "2\n5\n30\n", "2\n3\n30\n", "2\n3\n57\n", "2\n7\n46\n", "2\n5\n54\n", "2\n5\n48\n"], "outputs": ["NO\nYES\n", "YES\nYES\n", "YES\nYES\n", "YES\nYES\n", "YES\nYES\n", "YES\nYES\n", "YES\nYES\n", "YES\nYES\n"]} | coding | 331 |
Solve the programming task below in a Python markdown code block.
You have a string $s_1 s_2 \ldots s_n$ and you stand on the left of the string looking right. You want to choose an index $k$ ($1 \le k \le n$) and place a mirror after the $k$-th letter, so that what you see is $s_1 s_2 \ldots s_k s_k s_{k - 1} \ldots s... | {"inputs": ["4\n10\ncodeforces\n9\ncbacbacba\n3\naaa\n4\nbbaa\n"], "outputs": ["cc\ncbaabc\naa\nbb\n"]} | coding | 465 |
Solve the programming task below in a Python markdown code block.
The weather in Takahashi's town changes day by day, in the following cycle: Sunny, Cloudy, Rainy, Sunny, Cloudy, Rainy, ...
Given is a string S representing the weather in the town today. Predict the weather tomorrow.
-----Constraints-----
- S is Sunny... | {"inputs": ["Sunny\n", "Rainy\n", "Cloudy\n"], "outputs": ["Cloudy\n", "Sunny\n", "Rainy\n"]} | coding | 150 |
Solve the programming task below in a Python markdown code block.
In this kata the function returns an array/list of numbers without its last element. The function is already written for you and the basic tests pass, but random tests fail. Your task is to figure out why and fix it.
Good luck!
Hint: watch out for side... | {"functional": "_inputs = [[[1, 2, 3, 4, 5]], [[9, 7, 6, 9]]]\n_outputs = [[[1, 2, 3, 4]], [[9, 7, 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=tol)\n if isinstance(a, (list, tuple)):\n if len(a) ... | coding | 164 |
Solve the programming task below in a Python markdown code block.
Mario was going to gift Princess Peach a string S of even length N.
Mario was clumsy and thus, broke the string in the middle. He now has two strings A and B such that A = S[1, \frac{N}{2}] and B = S[\frac{N}{2} + 1, N].
Mario is not sure about the o... | {"inputs": ["4\n6\nabcabc\n6\nabcdef\n4\naaaa\n4\nbaab"], "outputs": ["YES\nNO\nYES\nNO\n"]} | coding | 601 |
Solve the programming task below in a Python markdown code block.
You are given $n$ strings $s_1, s_2, \dots, s_n$ of length at most $\mathbf{8}$.
For each string $s_i$, determine if there exist two strings $s_j$ and $s_k$ such that $s_i = s_j + s_k$. That is, $s_i$ is the concatenation of $s_j$ and $s_k$. Note that $... | {"inputs": ["1\n3\ncodcode\ncod\na\n", "5\n1\na\n1\na\n1\na\n1\na\n1\na\n", "3\n5\nabab\nab\nabc\nabacb\nc\n3\nx\nxx\nxxx\n8\ncodeforc\nes\ncodes\ncod\nforc\nforces\ne\ncode\n"], "outputs": ["000\n", "0\n0\n0\n0\n0\n", "10100\n011\n10100101\n"]} | coding | 660 |
Solve the programming task below in a Python markdown code block.
There is a puzzle to complete by combining 14 numbers from 1 to 9. Complete by adding another number to the given 13 numbers.
The conditions for completing the puzzle are
* You must have one combination of the same numbers.
* The remaining 12 numbers a... | {"inputs": ["3649596966777\n4281679207521\n3239171774529\n606159871584\n1057360767920\n71774966057", "3649596966777\n2237884645346\n155584781051\n7133209108608\n7755542764533\n704120058101", "3649596966777\n2237884645346\n155584781051\n7133209108608\n6142846373259\n704120058101", "3649596966777\n2313441461120\n15558478... | coding | 562 |
Solve the programming task below in a Python markdown code block.
The chef is trying to solve some pattern problems, Chef wants your help to code it. Chef has one number K to form a new pattern. Help the chef to code this pattern problem.
-----Input:-----
- First-line will contain $T$, the number of test cases. Then t... | {"inputs": ["3\n2\n3\n4"], "outputs": ["1121\n1222\n112131\n122232\n132333\n11213141\n12223242\n13233343\n14243444"]} | coding | 241 |
Solve the programming task below in a Python markdown code block.
Alice and Bob are playing a game with n piles of stones. It is guaranteed that n is an even number. The i-th pile has a_i stones.
Alice and Bob will play a game alternating turns with Alice going first.
On a player's turn, they must choose exactly n/2 ... | {"inputs": ["2\n1 1\n", "2\n8 8\n", "4\n2 3 3 3\n", "4\n1 2 2 2\n", "4\n2 1 1 1\n", "4\n1 1 1 4\n", "4\n1 3 3 3\n", "4\n1 2 2 3\n"], "outputs": ["Bob\n", "Bob\n", "Alice\n", "Alice\n", "Bob\n", "Bob\n", "Alice\n", "Alice\n"]} | coding | 344 |
Solve the programming task below in a Python markdown code block.
Chef visited a grocery store for fresh supplies. There are N items in the store where the i^{th} item has a freshness value A_{i} and cost B_{i}.
Chef has decided to purchase all the items having a freshness value greater than equal to X. Find the total... | {"inputs": ["4\n2 20\n15 67\n10 90\n3 1\n1 2 3\n1 2 3\n3 100\n10 90 50\n30 7 93\n4 50\n12 78 50 40\n40 30 20 10\n"], "outputs": ["90\n6\n0\n50\n"]} | coding | 554 |
Solve the programming task below in a Python markdown code block.
Ever since you started work at the grocer, you have been faithfully logging down each item and its category that passes through. One day, your boss walks in and asks, "Why are we just randomly placing the items everywhere? It's too difficult to find anyt... | {"functional": "_inputs = [['fruit_banana,vegetable_carrot,meat_chicken,drink_juice'], ['fruit_banana,vegetable_carrot,fruit_apple,canned_sardines,drink_juice,fruit_orange'], ['vegetable_celery,meat_chicken,meat_beef,fruit_banana,vegetable_carrot,canned_sardines,drink_juice,frozen_fries,fruit_lemon'], ['fruit_orange']]... | coding | 315 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.