task_type stringclasses 1
value | problem stringlengths 261 3.34k | answer stringlengths 35 6.15k | problem_tokens int64 62 774 | answer_tokens int64 12 2.04k |
|---|---|---|---|---|
coding | Solve the programming task below in a Python markdown code block.
You have a binary string S. You can perform the following operation on S:
Select any substring S_{L \dots R} (1 ≤ L ≤ R ≤ |S|) which is sorted in non-decreasing order and remove it from S.
(Both the left and right halves are concatenated after performing... | {"inputs": ["3\n3\n000\n5\n01110\n2\n10\n"], "outputs": ["0\n1\n1\n"]} | 499 | 37 |
coding | Solve the programming task below in a Python markdown code block.
You are given two integers A and B as the input. Output the value of A + B.
However, if A + B is 10 or greater, output error instead.
-----Constraints-----
- A and B are integers.
- 1 ≤ A, B ≤ 9
-----Input-----
Input is given from Standard Input in t... | {"inputs": ["6 7", "6 0", "7 0", "5 0", "1 1", "1 0", "2 1", "3 1"], "outputs": ["error\n", "6\n", "7\n", "5\n", "2\n", "1\n", "3\n", "4\n"]} | 133 | 78 |
coding | Solve the programming task below in a Python markdown code block.
Write a program which solve a simultaneous equation:
ax + by = c
dx + ey = f
The program should print x and y for given a, b, c, d, e and f (-1,000 ≤ a, b, c, d, e, f ≤ 1,000). You can suppose that given equation has a unique solution.
Input
The in... | {"inputs": ["1 2 3 4 5 6\n2 -1 -2 0 -1 -5", "1 2 3 4 5 6\n2 -1 -2 0 -1 -4", "1 2 3 4 6 4\n2 -1 -4 -1 0 -5", "1 2 3 3 5 6\n2 -1 -2 0 -1 -4", "1 2 3 4 0 4\n2 -1 -4 -1 0 -5", "2 1 3 5 5 4\n4 -1 -4 -1 0 -5", "1 2 3 3 5 6\n2 -1 -2 -1 0 -4", "2 1 1 5 5 4\n4 -1 -4 -1 0 -5"], "outputs": ["-1.000 2.000\n1.500 5.000\n", "-1.000 ... | 282 | 420 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given an integer n, return true if and only if it is an Armstrong number.
The k-digit number n is an Armstrong number if and only if the kth power of each digit sums to n.
Please complete the following python code p... | {"functional": "def check(candidate):\n assert candidate(n = 153) == True\n assert candidate(n = 123) == False\n\n\ncheck(Solution().isArmstrong)"} | 89 | 46 |
coding | Solve the programming task below in a Python markdown code block.
This is the performance edition of [this kata](https://www.codewars.com/kata/ulam-sequences). If you didn't do it yet, you should begin there.
---
The Ulam sequence U is defined by `u0=u`, `u1=v`, with the general term `u_n` for `n>2` given by the leas... | {"functional": "_inputs = [[1, 2, 5], [3, 4, 5], [5, 6, 8]]\n_outputs = [[[1, 2, 3, 4, 6]], [[3, 4, 7, 10, 11]], [[5, 6, 11, 16, 17, 21, 23, 26]]]\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 isinst... | 638 | 239 |
coding | Solve the programming task below in a Python markdown code block.
Recently a new building with a new layout was constructed in Monocarp's hometown. According to this new layout, the building consists of three types of apartments: three-room, five-room, and seven-room apartments. It's also known that each room of each a... | {"inputs": ["1\n1\n", "1\n1\n", "1\n2\n", "1\n3\n", "1\n5\n", "1\n6\n", "1\n4\n", "2\n448\n6\n"], "outputs": ["-1\n", "-1\n", "-1\n", "1 0 0\n", "0 1 0\n", "2 0 0\n", "-1\n", "147 0 1\n2 0 0\n"]} | 533 | 115 |
coding | Solve the programming task below in a Python markdown code block.
Takahashi is going to set a 3-character password.
How many possible passwords are there if each of its characters must be a digit between 1 and N (inclusive)?
-----Constraints-----
- 1 \leq N \leq 9
- N is an integer.
-----Input-----
Input is given f... | {"inputs": ["4", "0", "3", "5", "8", "6", "9", "7"], "outputs": ["64\n", "0\n", "27\n", "125\n", "512\n", "216\n", "729\n", "343\n"]} | 156 | 74 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given an alphanumeric string s, return the second largest numerical digit that appears in s, or -1 if it does not exist.
An alphanumeric string is a string consisting of lowercase English letters and digits.
Please ... | {"functional": "def check(candidate):\n assert candidate(s = \"dfa12321afd\") == 2\n assert candidate(s = \"abc1111\") == -1\n\n\ncheck(Solution().secondHighest)"} | 87 | 53 |
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 of the same length present and future where present[i] is the current price of the ith stock and future[i] is the price of the ith stock a year in the future. You may buy eac... | {"functional": "def check(candidate):\n assert candidate(present = [5,4,6,2,3], future = [8,5,4,3,5], budget = 10) == 6\n assert candidate(present = [2,2,5], future = [3,4,10], budget = 6) == 5\n assert candidate(present = [3,3,12], future = [0,3,15], budget = 10) == 0\n\n\ncheck(Solution().maximumProfit)"} | 138 | 125 |
coding | Solve the programming task below in a Python markdown code block.
Given a string, return a new string that has transformed based on the input:
* Change case of every character, ie. lower case to upper case, upper case to lower case.
* Reverse the order of words from the input.
**Note:** You will have to handle multip... | {"functional": "_inputs = [['Example string'], ['Example Input'], ['To be OR not to be That is the Question'], [''], ['You Know When THAT Hotline Bling'], [' A b C d E f G ']]\n_outputs = [['STRING eXAMPLE'], ['iNPUT eXAMPLE'], ['qUESTION THE IS tHAT BE TO NOT or BE tO'], [''], ['bLING hOTLINE that wHEN kNOW yOU'],... | 131 | 252 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given two 0-indexed strings str1 and str2.
In an operation, you select a set of indices in str1, and for each index i in the set, increment str1[i] to the next character cyclically. That is 'a' becomes 'b', 'b... | {"functional": "def check(candidate):\n assert candidate(str1 = \"abc\", str2 = \"ad\") == True\n assert candidate(str1 = \"zc\", str2 = \"ad\") == True\n assert candidate(str1 = \"ab\", str2 = \"d\") == False\n\n\ncheck(Solution().canMakeSubsequence)"} | 200 | 75 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Hercy wants to save money for his first car. He puts money in the Leetcode bank every day.
He starts by putting in $1 on Monday, the first day. Every day from Tuesday to Sunday, he will put in $1 more than the day bef... | {"functional": "def check(candidate):\n assert candidate(n = 4) == 10\n assert candidate(n = 10) == 37\n assert candidate(n = 20) == 96\n\n\ncheck(Solution().totalMoney)"} | 147 | 60 |
coding | Solve the programming task below in a Python markdown code block.
You are given two points $P$ and $Q$ and an opaque sphere in a three-dimensional space. The point $P$ is not moving, while $Q$ is moving in a straight line with constant velocity. You are also given a direction vector $d$ with the following meaning: the ... | {"inputs": ["1\n3 0 0 -10 -10 0 0 10 0 0 -3 0 3"], "outputs": ["1.0000000000"]} | 566 | 52 |
coding | Solve the programming task below in a Python markdown code block.
The followers of Psycho-Helmet religion follow a peculiar calendar – a normal year contains N days. Every K-th year is a “MOB” year. For example, if K = 4, then years 4, 8, 12, 16 \ldots are “MOB” years. A “MOB” year contains M additional days i.e. it co... | {"inputs": ["3\n2 1 4 17\n3 7 5 50\n3 7 5 61"], "outputs": ["YES\nNO\nYES"]} | 689 | 43 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given a binary tree root and an integer target, delete all the leaf nodes with value target.
Note that once you delete a leaf node with value target, if its parent node becomes a leaf node and has the value target, it... | {"functional": "def check(candidate):\n assert is_same_tree(candidate(root = tree_node([1,2,3,2,None,2,4]), target = 2), tree_node([1,None,3,None,4]))\n assert is_same_tree(candidate(root = tree_node([1,3,3,3,2]), target = 3), tree_node([1,3,None,None,2]))\n assert is_same_tree(candidate(root = tree_node([1,2,... | 168 | 195 |
coding | Solve the programming task below in a Python markdown code block.
A telephone number is a sequence of exactly 11 digits, where the first digit is 8. For example, the sequence 80011223388 is a telephone number, but the sequences 70011223388 and 80000011223388 are not.
You are given a string $s$ of length $n$, consistin... | {"inputs": ["1\n11\n80000000000\n", "1\n11\n83583640644\n", "1\n11\n83583640644\n", "1\n11\n80000000000\n", "1\n11\n81840233933\n", "1\n18\n80000000000\n", "1\n21\n80000000000\n", "1\n15\n80000000000\n"], "outputs": ["YES\n", "YES\n", "YES\n", "YES\n", "YES\n", "YES\n", "YES\n", "YES\n"]} | 402 | 190 |
coding | Solve the programming task below in a Python markdown code block.
You are given an integer m as a product of integers a_1, a_2, ... a_{n} $(m = \prod_{i = 1}^{n} a_{i})$. Your task is to find the number of distinct decompositions of number m into the product of n ordered positive integers.
Decomposition into n product... | {"inputs": ["1\n1\n", "1\n1\n", "1\n15\n", "1\n15\n", "2\n5 7\n", "2\n1 2\n", "2\n1 6\n", "2\n1 2\n"], "outputs": ["1\n", "1\n", "1\n", "1\n", "4\n", "2\n", "4\n", "2\n"]} | 430 | 96 |
coding | Solve the programming task below in a Python markdown code block.
There are five people playing a game called "Generosity". Each person gives some non-zero number of coins b as an initial bet. After all players make their bets of b coins, the following operation is repeated for several times: a coin is passed from one ... | {"inputs": ["2 5 4 0 4\n", "4 5 9 2 1\n", "0 0 0 0 0\n", "1 2 1 2 3\n", "2 3 4 5 6\n", "1 1 1 1 1\n", "0 1 2 3 4\n", "0 0 0 0 1\n"], "outputs": ["3\n", "-1\n", "-1\n", "-1\n", "4\n", "1\n", "2\n", "-1\n"]} | 368 | 134 |
coding | Solve the programming task below in a Python markdown code block.
Nowadays the one-way traffic is introduced all over the world in order to improve driving safety and reduce traffic jams. The government of Berland decided to keep up with new trends. Formerly all n cities of Berland were connected by n two-way roads in ... | {"inputs": ["3\n3 1 1\n2 1 1\n2 3 1\n", "3\n1 3 2\n1 2 1\n3 2 1\n", "3\n1 3 1\n1 2 7\n3 2 1\n", "3\n1 3 1\n1 2 7\n3 2 2\n", "3\n3 1 2\n2 1 1\n2 3 1\n", "3\n1 3 4\n1 2 1\n3 2 1\n", "3\n1 3 1\n1 2 1\n3 2 2\n", "3\n1 3 3\n1 2 1\n3 2 1\n"], "outputs": ["1\n", "1\n", "2\n", "3\n", "1\n", "1\n", "1\n", "1\n"]} | 442 | 214 |
coding | Solve the programming task below in a Python markdown code block.
Section numbers are strings of dot-separated integers. The highest level sections (chapters) are numbered 1, 2, 3, etc. Second level sections are numbered 1.1, 1.2, 1.3, 2.1, 2.2, 2.3, etc. Next level sections are numbered 1.1.1, 1.1.2, 1.1.2, 1.2.1, 1.2... | {"functional": "_inputs = [['1', '2'], ['1.1', '1.2'], ['1.1', '1'], ['1.2.3.4', '1.2.3.4'], ['3', '3.0'], ['3', '3.0.0.0'], ['1.2.1', '1.2.0'], ['3.0.0', '3.1.1'], ['3.0.1', '3.1'], ['1.2.3', '1.02.003'], ['1.20', '1.5']]\n_outputs = [[-1], [-1], [1], [0], [0], [0], [1], [-1], [-1], [0], [1]]\nimport math\ndef _deep_e... | 446 | 311 |
coding | Solve the programming task below in a Python markdown code block.
A bow adorned with nameless flowers that bears the earnest hopes of an equally nameless person.
You have obtained the elegant bow known as the Windblume Ode. Inscribed in the weapon is an array of n (n ≥ 3) positive distinct integers (i.e. different, no... | {"inputs": ["1\n3\n2 3 1\n", "1\n3\n4 3 1\n", "1\n3\n6 3 2\n", "1\n3\n2 4 1\n", "1\n3\n4 3 2\n", "1\n3\n5 3 1\n", "1\n3\n5 0 1\n", "1\n3\n3 3 0\n"], "outputs": ["3\n1 2 3\n", "3\n1 2 3\n", "2\n1 3\n", "2\n1 2\n", "3\n1 2 3\n", "3\n1 2 3\n", "3\n1 2 3\n", "3\n1 2 3\n"]} | 566 | 178 |
coding | Solve the programming task below in a Python markdown code block.
## Problem
There are `n` apples that need to be divided into four piles. We need two mysterious number `x` and `y`. Let The number of first pile equals to `x+y`, the number of second pile equals to `x-y`, the number of third pile equals to `x*y`, the nu... | {"functional": "_inputs = [[48, 3], [100, 4], [25, 4], [24, 4]]\n_outputs = [[[12, 6, 27, 3]], [[20, 12, 64, 4]], [[]], [[]]]\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)... | 539 | 212 |
coding | Solve the programming task below in a Python markdown code block.
To destroy humanity, The Monster Association sent $n$ monsters to Earth's surface. The $i$-th monster has health $h_i$ and power $p_i$.
With his last resort attack, True Spiral Incineration Cannon, Genos can deal $k$ damage to all monsters alive. In oth... | {"inputs": ["1\n2 1\n1000000000 1\n1 1000000000\n", "3\n6 7\n18 5 13 9 10 1\n2 7 2 1 2 6\n3 4\n5 5 5\n4 4 4\n3 2\n2 1 3\n1 1 1\n"], "outputs": ["NO\n", "YES\nNO\nYES\n"]} | 642 | 119 |
coding | Solve the programming task below in a Python markdown code block.
ZS the Coder and Chris the Baboon are travelling to Udayland! To get there, they have to get on the special IOI bus. The IOI bus has n rows of seats. There are 4 seats in each row, and the seats are separated into pairs by a walkway. When ZS and Chris ca... | {"inputs": ["1\nXO|OX\n", "1\nOO|OO\n", "1\nOO|XX\n", "1\nXO|OX\n", "1\nOO|OO\n", "1\nOO|XX\n", "1\nXX|OO\n", "1\nXO|NX\n"], "outputs": ["NO\n", "YES\n++|OO\n", "YES\n++|XX\n", "NO\n", "YES\n++|OO\n", "YES\n++|XX\n", "YES\nXX|++\n", "NO\n"]} | 613 | 126 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given a 0-indexed 2D matrix grid of size m x n, where (r, c) represents:
A land cell if grid[r][c] = 0, or
A water cell containing grid[r][c] fish, if grid[r][c] > 0.
A fisher can start at any water cell (r,... | {"functional": "def check(candidate):\n assert candidate(grid = [[0,2,1,0],[4,0,0,3],[1,0,0,4],[0,3,2,0]]) == 7\n assert candidate(grid = [[1,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,1]]) == 1\n\n\ncheck(Solution().findMaxFish)"} | 240 | 104 |
coding | Solve the programming task below in a Python markdown code block.
Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Chef and his friend Magda have $2N$ mutual friends: $N$ of these friends are chefs and the other $N$ are chefettes. The chefs are numbered $1$ throug... | {"inputs": ["2\n3\n4 5 6\n1 2 3\n5\n4 8 6 4 1\n2 5 7 4 7"], "outputs": ["10\n23"]} | 647 | 52 |
coding | Solve the programming task below in a Python markdown code block.
problem
At the JOI pasta shop, the recommended pasta for lunch and the set menu of freshly squeezed juice are popular. When ordering this set menu, choose one from each of the three pasta and two juices of the day. The price is the total price of pasta ... | {"inputs": ["800\n4\n10\n4\n0", "800\n7\n10\n4\n0", "800\n2\n5\n-4\n0", "800\n2\n3\n0\n-1", "800\n0\n0\n-6\n0", "800\n5\n0\n-7\n1", "800\n37\n63\n1\n1", "800\n37\n10\n1\n1"], "outputs": ["-46\n", "-43\n", "-52\n", "-49\n", "-56\n", "-57\n", "-12\n", "-39\n"]} | 148 | 161 |
coding | Solve the programming task below in a Python markdown code block.
For given two sequences $X$ and $Y$, a sequence $Z$ is a common subsequence of $X$ and $Y$ if $Z$ is a subsequence of both $X$ and $Y$. For example, if $X = \\{a,b,c,b,d,a,b\\}$ and $Y = \\{b,d,c,a,b,a\\}$, the sequence $\\{b,c,a\\}$ is a common subseque... | {"inputs": ["3\nabcbdab\nbdcaba\nabc\nabc\nacb\nbc", "3\nabcbdab\nbdcaba\nabc\nabc\nbcb\nbc", "3\nabcbdab\nbdcaba\n`bc\nabc\nbcb\nbc", "3\nbadbcba\nbdcaba\n`bc\nabc\nbcb\nbc", "3\nbadbdba\nbdcaba\n`bc\nabc\nbcb\ncc", "3\nbadbdba\nbdcaba\n`bc\nabd\nbcb\ncc", "3\nbadbdba\nabacdb\n_cb\ndba\nbbb\ncc", "3\n`bdbdab\nabacdb\n... | 428 | 235 |
coding | Solve the programming task below in a Python markdown code block.
We have N non-negative integers: A_1, A_2, ..., A_N.
Consider painting at least one and at most N-1 integers among them in red, and painting the rest in blue.
Let the beauty of the painting be the \mbox{XOR} of the integers painted in red, plus the \mbox... | {"inputs": ["3\n5 6 5", "3\n4 6 5", "3\n4 8 5", "3\n4 8 9", "3\n4 8 4", "3\n5 8 5", "3\n0 6 5", "3\n8 8 9"], "outputs": ["8\n", "7\n", "17\n", "21\n", "16\n", "18\n", "11\n", "9\n"]} | 452 | 115 |
coding | Solve the programming task below in a Python markdown code block.
To celebrate the opening of the Winter Computer School the organizers decided to buy in n liters of cola. However, an unexpected difficulty occurred in the shop: it turned out that cola is sold in bottles 0.5, 1 and 2 liters in volume. At that, there are... | {"inputs": ["7 2 2 2\n", "2 2 2 2\n", "1 0 2 0\n", "3 3 2 1\n", "1 1 0 0\n", "1 0 0 1\n", "1 0 1 0\n", "7 3 0 5\n"], "outputs": ["1\n", "3\n", "1\n", "3\n", "0\n", "0\n", "1\n", "1\n"]} | 354 | 118 |
coding | Solve the programming task below in a Python markdown code block.
Ivan has number $b$. He is sorting through the numbers $a$ from $1$ to $10^{18}$, and for every $a$ writes $\frac{[a, \,\, b]}{a}$ on blackboard. Here $[a, \,\, b]$ stands for least common multiple of $a$ and $b$. Ivan is very lazy, that's why this task ... | {"inputs": ["1\n", "2\n", "3\n", "6\n", "5\n", "8\n", "5\n", "8\n"], "outputs": ["1", "2", "2", "4", "2", "4", "2\n", "4\n"]} | 307 | 64 |
coding | Solve the programming task below in a Python markdown code block.
You are given a sequence of positive integers of length N, a = (a_1, a_2, ..., a_N). Your objective is to remove some of the elements in a so that a will be a good sequence.
Here, an sequence b is a good sequence when the following condition holds true:... | {"inputs": ["4\n0 3 3 3", "4\n3 3 3 3", "5\n2 4 1 4 1", "5\n1 4 2 4 2", "5\n1 4 1 4 1", "5\n1 4 1 4 2", "5\n1 3 2 4 2", "5\n1 3 3 4 2"], "outputs": ["1\n", "1", "4\n", "2\n", "4\n", "4\n", "2\n", "4\n"]} | 377 | 137 |
coding | Solve the programming task below in a Python markdown code block.
You are given an array A of length N.
Find the maximum length of any subarray of A, such that, the [bitwise OR] of all the elements of the subarray is equal to the [bitwise OR] of the remaining elements of the array.
Report -1 if no such subarray exis... | {"inputs": ["3\n3\n1 2 4\n3\n1 3 2\n4\n2 3 4 7\n"], "outputs": ["-1\n1\n3\n"]} | 597 | 45 |
coding | Solve the programming task below in a Python markdown code block.
A company needs random numbers for its operation. $N$ random numbers have been generated using $N$ numbers as seeds and the following recurrence formula:
$\begin{aligned}F(K)=&\left(C(1)\times F(K-1)+C(2)\times F(K-2)+\cdots+C(N-1)\times F(K-N+1)+C(N)\t... | {"inputs": ["2 6\n13 8\n1 1\n"], "outputs": ["1 1 \n"]} | 484 | 28 |
coding | Solve the programming task below in a Python markdown code block.
There are n boys and m girls attending a theatre club. To set a play "The Big Bang Theory", they need to choose a group containing exactly t actors containing no less than 4 boys and no less than one girl. How many ways are there to choose a group? Of co... | {"inputs": ["4 2 6\n", "4 1 5\n", "7 3 6\n", "5 1 6\n", "6 1 5\n", "5 1 5\n", "4 4 5\n", "6 1 6\n"], "outputs": ["1", "1", "168", "1\n", "15\n", "5\n", "4\n", "6\n"]} | 236 | 102 |
coding | Solve the programming task below in a Python markdown code block.
In number world, two different numbers are friends if they have a lot in common, but also each one has unique perks.
More precisely, two different numbers a and b are friends if gcd(a,b), (a)/(gcd(a,b)), (b)/(gcd(a,b)) can form sides of a triangle.
Thr... | {"inputs": ["3\n2 7 6\n", "3\n1 7 6\n", "3\n1 8 6\n", "3\n1 7 10\n", "3\n2 7 10\n", "3\n1 5 10\n", "6\n12 432 3 199 7 1\n", "6\n12 432 21 199 7 1\n"], "outputs": ["2\n4\n3\n", "1\n4\n3\n", "1\n4\n3\n", "1\n4\n3\n", "2\n4\n3\n", "1\n3\n3\n", "4\n76\n3\n41\n4\n1\n", "4\n76\n7\n41\n4\n1\n"]} | 345 | 192 |
coding | Solve the programming task below in a Python markdown code block.
There are $n$ candy boxes in front of Tania. The boxes are arranged in a row from left to right, numbered from $1$ to $n$. The $i$-th box contains $r_i$ candies, candies have the color $c_i$ (the color can take one of three values — red, green, or blue... | {"inputs": ["1 1 10\n10\nR\n", "1 1 10\n10\nR\n", "1 1 20\n10\nR\n", "2 1 15\n5 6\nRG\n", "2 1 10\n5 5\nRG\n", "2 1 10\n5 6\nRR\n", "2 1 10\n5 5\nRG\n", "2 1 10\n5 6\nRR\n"], "outputs": ["0\n", "0\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n"]} | 715 | 155 |
coding | Solve the programming task below in a Python markdown code block.
You are playing a very popular game called Cubecraft. Initially, you have one stick and want to craft $k$ torches. One torch can be crafted using one stick and one coal.
Hopefully, you've met a very handsome wandering trader who has two trade offers: e... | {"inputs": ["5\n2 2 5\n76 3 24\n7 15 9\n1000000000 1001000000 1000100001\n2 1000000001 1000000000\n", "5\n2 2 5\n76 19 24\n7 15 9\n1000000000 1001000000 1000000000\n2 1000000000 1000000000\n", "5\n2 2 5\n76 19 24\n7 15 9\n1000000000 1001000000 1000100000\n2 1000000000 1000000000\n", "5\n2 2 5\n76 19 24\n7 15 9\n1000000... | 492 | 1,003 |
coding | Solve the programming task below in a Python markdown code block.
Timur's grandfather gifted him a chessboard to practice his chess skills. This chessboard is a grid $a$ with $n$ rows and $m$ columns with each cell having a non-negative integer written on it.
Timur's challenge is to place a bishop on the board such th... | {"inputs": ["1\n1 1\n114514\n", "4\n4 4\n1 2 2 1\n2 4 2 4\n2 2 3 1\n2 4 2 4\n2 1\n1\n0\n3 3\n1 1 1\n1 1 1\n1 1 1\n3 3\n0 1 1\n1 0 1\n1 1 0\n"], "outputs": ["114514\n", "20\n1\n5\n3\n"]} | 474 | 133 |
coding | Solve the programming task below in a Python markdown code block.
Top-model Izabella participates in the competition. She wants to impress judges and show her mathematical skills.
Her problem is following: for given string, consisting of only 0 and 1, tell if it's possible to remove some digits in such a way, that rem... | {"inputs": ["0\n", "1\n", "0\n", "1\n", "100\n", "000\n", "000\n", "101\n"], "outputs": ["no", "no", "no\n", "no\n", "no", "no", "no\n", "no\n"]} | 228 | 74 |
coding | Solve the programming task below in a Python markdown code block.
Recently a dog was bought for Polycarp. The dog's name is Cormen. Now Polycarp has a lot of troubles. For example, Cormen likes going for a walk.
Empirically Polycarp learned that the dog needs at least k walks for any two consecutive days in order to ... | {"inputs": ["1 1\n1\n", "1 4\n2\n", "1 5\n1\n", "1 2\n1\n", "1 5\n2\n", "1 3\n0\n", "1 3\n1\n", "1 5\n0\n"], "outputs": ["0\n1\n", "0\n2\n", "0\n1\n", "0\n1\n", "0\n2\n", "0\n0\n", "0\n1\n", "0\n0\n"]} | 616 | 118 |
coding | Solve the programming task below in a Python markdown code block.
Read problems statements in [Hindi], [Mandarin Chinese], [Vietnamese], and [Bengali] as well.
You are given the height $H$ (in metres) and mass $M$ (in kilograms) of Chef. The Body Mass Index (BMI) of a person is computed as $\frac{M}{H^{2}}$.
Report t... | {"inputs": ["3\n72 2\n80 2\n120 2"], "outputs": ["1\n2\n4"]} | 506 | 32 |
coding | Solve the programming task below in a Python markdown code block.
Chef gives an array A with N elements to Babla. Babla's task is to find the maximum non-negative integer X such that:
No element in the array belongs to the range [-X, X]. In other words, for all (1≤ i ≤ N), either A_{i} < -X or A_{i} > X.
Help Babla t... | {"inputs": ["3\n5\n8 4 2 5 2\n6\n7 9 -10 8 12 17\n4\n0 -3 -1 -10\n"], "outputs": ["1\n6\n-1\n"]} | 509 | 59 |
coding | Solve the programming task below in a Python markdown code block.
You are given a chessboard of size 1 × n. It is guaranteed that n is even. The chessboard is painted like this: "BWBW...BW".
Some cells of the board are occupied by the chess pieces. Each cell contains no more than one chess piece. It is known that the ... | {"inputs": ["2\n2\n", "2\n2\n", "2\n1\n", "6\n1 2 6\n", "6\n1 5 6\n", "6\n1 4 5\n", "6\n3 5 6\n", "6\n3 4 5\n"], "outputs": ["0\n", "0\n", "0\n", "2\n", "2\n", "1\n", "2\n", "2\n"]} | 465 | 106 |
coding | Solve the programming task below in a Python markdown code block.
When you want to get the square of a binomial of two variables x and y, you will have:
`$(x+y)^2 = x^2 + 2xy + y ^2$`
And the cube:
`$(x+y)^3 = x^3 + 3x^2y + 3xy^2 +y^3$`
It is known from many centuries ago that for an exponent n, the result of a bin... | {"functional": "_inputs = [[0], [1], [2], [3], [6], [10]]\n_outputs = [[[1, 1]], [[1, 2, 3]], [[1, 2, 4, 7]], [[1, 2, 4, 8, 15]], [[1, 2, 4, 8, 16, 32, 64, 127]], [[1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2047]]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n ... | 441 | 289 |
coding | Solve the programming task below in a Python markdown code block.
You are to write a function to transpose a guitar tab up or down a number of semitones. The amount to transpose is a number, positive or negative. The tab is given as an array, with six elements for each guitar string (fittingly passed as strings). Outpu... | {"functional": "_inputs = [[2, ['e|-------5-7-----7-|-8-----8-2-----2-|-0---------0-----|-----------------|', 'B|-----5-----5-----|---5-------3-----|---1---1-----1---|-0-1-1-----------|', 'G|---5---------5---|-----5-------2---|-----2---------2-|-0-2-2-----------|', 'D|-7-------6-------|-5-------4-------|-3-------------... | 663 | 1,428 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given a 0-indexed integer array nums containing n distinct positive integers. A permutation of nums is called special if:
For all indexes 0 <= i < n - 1, either nums[i] % nums[i+1] == 0 or nums[i+1] % nums[i]... | {"functional": "def check(candidate):\n assert candidate(nums = [2,3,6]) == 2\n assert candidate(nums = [1,4,3]) == 2\n\n\ncheck(Solution().specialPerm)"} | 155 | 51 |
coding | Solve the programming task below in a Python markdown code block.
Tieu owns a pizza restaurant and he manages it in his own way. While in a normal restaurant, a customer is served by following the first-come, first-served rule, Tieu simply minimizes the average waiting time of his customers. So he gets to decide who i... | {"inputs": ["3\n0 3\n1 9\n2 6\n", "3\n0 3\n1 9\n2 5\n"], "outputs": ["9\n", "8\n"]} | 677 | 46 |
coding | Solve the programming task below in a Python markdown code block.
Your job is to write a function which increments a string, to create a new string.
- If the string already ends with a number, the number should be incremented by 1.
- If the string does not end with a number. the number 1 should be appended to the new ... | {"functional": "_inputs = [['foo'], ['foobar001'], ['foobar1'], ['foobar00'], ['foobar99'], [''], ['foobar000'], ['foobar999'], ['foobar00999'], ['1'], ['009']]\n_outputs = [['foo1'], ['foobar002'], ['foobar2'], ['foobar01'], ['foobar100'], ['1'], ['foobar001'], ['foobar1000'], ['foobar01000'], ['2'], ['010']]\nimport ... | 162 | 259 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
A perfect number is a positive integer that is equal to the sum of its positive divisors, excluding the number itself. A divisor of an integer x is an integer that can divide x evenly.
Given an integer n, return true ... | {"functional": "def check(candidate):\n assert candidate(num = 28) == True\n assert candidate(num = 7) == False\n\n\ncheck(Solution().checkPerfectNumber)"} | 105 | 43 |
coding | Solve the programming task below in a Python markdown code block.
One quite ordinary day Valera went to school (there's nowhere else he should go on a week day). In a maths lesson his favorite teacher Ms. Evans told students about divisors. Despite the fact that Valera loved math, he didn't find this particular topic i... | {"inputs": ["4 4 4\n", "4 4 8\n", "1 80 7\n", "1 10 2\n", "6 19 5\n", "12 23 3\n", "2 1000 4\n", "1 124 11\n"], "outputs": ["0\n", "0\n", "3\n", "5\n", "0\n", "2\n", "0\n", "2\n"]} | 453 | 113 |
coding | Solve the programming task below in a Python markdown code block.
You are given an array A, consisting of N distinct integers.
Calculate number of pairs (i,j) (1 ≤ i < j ≤ N), such that 2 \cdot (A_{i} \oplus A_{j}) = A_{i} + A_{j}, where \oplus denotes [bitwise XOR].
------ Input Format ------
- The first line con... | {"inputs": ["4\n1 2 3 6\n", "5\n4 3 9 7 1"], "outputs": ["2\n", "1"]} | 567 | 38 |
coding | Solve the programming task below in a Python markdown code block.
Check Tutorial tab to know how to to solve.
You are given a string $\boldsymbol{s}$ consisting only of digits 0-9, commas ,, and dots .
Your task is to complete the regex_pattern defined below, which will be used to re.split() all of the , and . symb... | {"inputs": ["100,000,000.000\n"], "outputs": ["100\n000\n000\n000\n"]} | 146 | 42 |
coding | Solve the programming task below in a Python markdown code block.
This is the hard version of the problem. The difference between the versions is that in the easy version all prices $a_i$ are different. You can make hacks if and only if you solved both versions of the problem.
Today is Sage's birthday, and she will go... | {"inputs": ["1\n1\n", "1\n1\n", "1\n2\n", "1\n0\n", "1\n3\n", "1\n5\n", "1\n4\n", "1\n8\n"], "outputs": ["0\n1 ", "0\n1 ", "0\n2\n", "0\n0\n", "0\n3\n", "0\n5\n", "0\n4\n", "0\n8\n"]} | 461 | 100 |
coding | Solve the programming task below in a Python markdown code block.
------ Problem Statement ------
Past
In the year of 2048, the Virtual Reality Massively Multiplayer Online Role-Playing Game (VRMMORPG), Code Art Online (CAO), is released. With the Chef Gear, a virtual reality helmet that stimulates the user's five s... | {"inputs": ["2\n5 5\n^^^^^\n^^^^^\n^^^^#\n^^^^^\n^^^^^\n5 7\n^^#^^^^\n^^#^#^#\n#^^^^^^\n^^#^^#^\n^^^^^^^", "2\n5 5\n^^^^^\n^^^^^\n^^^]#\n^^^^^\n^^^^^\n5 7\n^^#^^^^\n^^#^#^#\n#^^^^^^\n^^#^^#^\n^^^^^^^", "2\n5 1\n^^^^^\n^^^^^\n^^^^#\n^^^^^\n^]^^^\n5 7\n^^#^^^_\n^^###^^\n#^^^^^^\n^^#^^#^\n^^^^^^^", "2\n5 1\n^^^^^\n^^^^^\n... | 656 | 488 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given an array of integers nums and an integer target.
Return the number of non-empty subsequences of nums such that the sum of the minimum and maximum element on it is less or equal to target. Since the answe... | {"functional": "def check(candidate):\n assert candidate(nums = [3,5,6,7], target = 9) == 4\n assert candidate(nums = [3,3,6,8], target = 10) == 6\n assert candidate(nums = [2,3,3,4,6,7], target = 12) == 61\n\n\ncheck(Solution().numSubseq)"} | 114 | 96 |
coding | Solve the programming task below in a Python markdown code block.
You are given an array consisting of $n$ integers $a_1, a_2, \dots, a_n$, and a positive integer $m$. It is guaranteed that $m$ is a divisor of $n$.
In a single move, you can choose any position $i$ between $1$ and $n$ and increase $a_i$ by $1$.
Let's ... | {"inputs": ["4 2\n0 1 2 3\n", "4 2\n1 1 2 3\n", "4 2\n1 0 2 3\n", "4 2\n0 1 2 3\n", "1 1\n1000000000\n", "1 1\n1000000000\n", "1 1\n1010000000\n", "6 3\n3 2 0 6 10 12\n"], "outputs": ["0\n0 1 2 3 \n", "1\n1 1 2 4 \n", "0\n1 0 2 3 \n", "0\n0 1 2 3 \n", "0\n1000000000 \n", "0\n1000000000 \n", "0\n1010000000 \n", "3\n3 2 ... | 476 | 252 |
coding | Solve the programming task below in a Python markdown code block.
Chef hosts a party for his birthday. There are N people at the party. All these N people decide to play Jenga.
There are X Jenga tiles available. In one round, all the players pick 1 tile each and place it in the tower.
The game is *valid* if:
All the... | {"inputs": ["3\n3 3\n4 2\n2 4\n"], "outputs": ["YES\nNO\nYES\n"]} | 389 | 30 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
In a gold mine grid of size m x n, each cell in this mine has an integer representing the amount of gold in that cell, 0 if it is empty.
Return the maximum amount of gold you can collect under the conditions:
Every t... | {"functional": "def check(candidate):\n assert candidate(grid = [[0,6,0],[5,8,7],[0,9,0]]) == 24\n assert candidate(grid = [[1,0,7],[2,0,6],[3,4,5],[0,3,0],[9,0,20]]) == 28\n\n\ncheck(Solution().getMaximumGold)"} | 174 | 91 |
coding | Solve the programming task below in a Python markdown code block.
# Task
You have set an alarm for some of the week days.
Days of the week are encoded in binary representation like this:
```
0000001 - Sunday
0000010 - Monday
0000100 - Tuesday
0001000 - Wednesday
0010000 - Thursday
0100000 - Friday
1000000 - Saturd... | {"functional": "_inputs = [[4, 42], [6, 42], [7, 42]]\n_outputs = [[6], [2], [2]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return math.isclose(a, b, rel_tol=tol, abs_tol=tol)\n if isinstance(a, (list, tuple)):\n if len(a) != len(b): return Fals... | 342 | 180 |
coding | Solve the programming task below in a Python markdown code block.
A set of four prime numbers arranged like (a, a + 2, a + 6, a + 8) is called a quadruplet prime number. Of the four prime numbers that make up a quadruplet prime, the largest number is called the size of the quadruplet prime. For example, the smallest pr... | {"inputs": ["13\n23\n15\n0\n0\n76\n1\n0\n10000\n2", "13\n14\n19\n0\n6\n40\n1\n0\n10000\n1", "13\n0\n15\n16\n17\n27\n0\n3\n11000\n0", "13\n14\n15\n16\n0\n24\n0\n3\n11000\n0", "13\n14\n15\n0\n24\n27\n0\n0\n11100\n1", "13\n14\n0\n21\n17\n24\n0\n2\n11000\n0", "13\n19\n15\n16\n0\n18\n0\n20\n10001\n0", "13\n14\n15\n21\n17\n2... | 328 | 340 |
coding | Solve the programming task below in a Python markdown code block.
Chef made two laddus with sweetness X and Y respectively. Cheffina comes and sees the chef created two laddus with different sweetness (might be same). Cheffina has the magical power to make the sweetness of laddus equal. Cheffina requires 1 unit of powe... | {"inputs": ["2\n2 2\n4 6"], "outputs": ["0\n3"]} | 328 | 22 |
coding | Solve the programming task below in a Python markdown code block.
# Task
The `hamming distance` between a pair of numbers is the number of binary bits that differ in their binary notation.
# Example
For `a = 25, b= 87`, the result should be `4`
```
25: 00011001
87: 01010111
```
The `hamming distance` between thes... | {"functional": "_inputs = [[25, 87], [256, 302], [543, 634], [34013, 702]]\n_outputs = [[4], [4], [4], [7]]\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... | 221 | 202 |
coding | Solve the programming task below in a Python markdown code block.
Limak is a little polar bear. He plays by building towers from blocks. Every block is a cube with positive integer length of side. Limak has infinitely many blocks of each side length.
A block with side a has volume a3. A tower consisting of blocks with... | {"inputs": ["8\n", "2\n", "7\n", "9\n", "1\n", "4\n", "3\n", "6\n"], "outputs": ["7 7\n", "2 2\n", "7 7\n", "7 7\n", "1 1\n", "4 4\n", "3 3\n", "6 6\n"]} | 522 | 86 |
coding | Solve the programming task below in a Python markdown code block.
Our chef has recently opened a new restaurant with a unique style. The restaurant is divided into K compartments (numbered from 1 to K) and each compartment can be occupied by at most one customer.
Each customer that visits the restaurant has a strongly... | {"inputs": ["2\n3 3\n1 3 1\n4 6 2\n7 10 3\n4 2\n10 100 1\n100 200 2\n150 500 2\n200 300 2"], "outputs": ["3\n3"]} | 537 | 80 |
coding | Solve the programming task below in a Python markdown code block.
Chef considers a permutation P of \{1, 2, 3, \dots, N\} End Sorted if and only if P_{1} = 1 and P_{N} = N.
Chef is given a permutation P.
In one operation Chef can choose any index i \ (1 ≤ i ≤ N-1) and swap P_{i} and P_{i+1}. Determine the minimum num... | {"inputs": ["4\n4\n1 3 2 4\n3\n3 2 1\n2\n2 1\n3\n2 1 3\n"], "outputs": ["0\n3\n1\n1\n"]} | 587 | 52 |
coding | Solve the programming task below in a Python markdown code block.
Write a function called `sumIntervals`/`sum_intervals()` that accepts an array of intervals, and returns the sum of all the interval lengths. Overlapping intervals should only be counted once.
### Intervals
Intervals are represented by a pair of intege... | {"functional": "_inputs = [[[[1, 5]]]]\n_outputs = [[4]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return math.isclose(a, b, rel_tol=tol, abs_tol=tol)\n if isinstance(a, (list, tuple)):\n if len(a) != len(b): return False\n return all(_de... | 384 | 160 |
coding | Solve the programming task below in a Python markdown code block.
Chef is solving mathematics problems. He is preparing for Engineering Entrance exam. He's stuck in a problem.
$f(n)=1^n*2^{n-1}*3^{n-2} * \ldots * n^{1} $
Help Chef to find the value of $f(n)$.Since this number could be very large, compute it modulo $10... | {"inputs": ["1\n3"], "outputs": ["12"]} | 284 | 15 |
coding | Solve the programming task below in a Python markdown code block.
Rohit has n empty boxes lying on the ground in a line. The size of the boxes is given in the form of an array $a$. The size of the ith box is denoted by $a[i]$. Since Rohit has a tiny room, there is a shortage of space. Therefore, he has to reduce the nu... | {"inputs": ["5\n16\n1\n4\n8\n2"], "outputs": ["3"]} | 342 | 23 |
coding | Solve the programming task below in a Python markdown code block.
Read problems statements in Mandarin Chinese, Russian and Vietnamese as well.
Devu is a disastrous oracle: his predictions about various events of your life are horrifying. Instead of providing good luck, he "blesses" you with bad luck. The secret behi... | {"inputs": ["3\n2\nab\nba\n2\naa\nbb\n3\naabb\nabab\nbaab"], "outputs": ["1\n0\n2"]} | 525 | 39 |
coding | Solve the programming task below in a Python markdown code block.
Petya has an array $a$ consisting of $n$ integers. He wants to remove duplicate (equal) elements.
Petya wants to leave only the rightmost entry (occurrence) for each element of the array. The relative order of the remaining unique elements should not be... | {"inputs": ["1\n1\n", "1\n1\n", "1\n2\n", "1\n4\n", "1\n3\n", "1\n5\n", "1\n1000\n", "1\n1000\n"], "outputs": ["1\n1 \n", "1\n1\n", "1\n2\n", "1\n4\n", "1\n3\n", "1\n5\n", "1\n1000 \n", "1\n1000\n"]} | 412 | 116 |
coding | Solve the programming task below in a Python markdown code block.
You are given a table consisting of n rows and m columns.
Numbers in each row form a permutation of integers from 1 to m.
You are allowed to pick two elements in one row and swap them, but no more than once for each row. Also, no more than once you are... | {"inputs": ["1 1\n1\n", "1 1\n1\n", "1 1\n1\n", "1 4\n2 3 4 1\n", "1 4\n2 3 4 1\n", "2 3\n3 1 2\n1 2 3\n", "2 3\n3 1 2\n1 2 3\n", "2 4\n1 3 2 4\n1 3 4 2\n"], "outputs": ["YES\n", "YES\n", "YES", "NO\n", "NO", "YES\n", "YES", "YES\n"]} | 478 | 145 |
coding | Solve the programming task below in a Python markdown code block.
The Chef likes to stay in touch with his staff. So, the Chef, the head server, and the sous-chef all carry two-way transceivers so they can stay in constant contact. Of course, these transceivers have a limited range so if two are too far apart, they can... | {"inputs": ["3\n1\n0 1\n0 0\n1 0\n2\n0 1\n0 0\n1 0\n2\n0 0\n0 2\n2 1", "3\n1\n0 1\n0 0\n1 0\n2\n0 1\n0 0\n1 0\n2\n0 0\n0 3\n2 1", "3\n2\n0 0\n0 0\n1 0\n2\n0 1\n0 0\n1 0\n2\n0 0\n0 2\n2 1", "3\n1\n0 1\n0 0\n1 0\n4\n0 1\n0 0\n1 0\n2\n0 0\n0 3\n2 1", "3\n2\n0 1\n0 0\n1 0\n2\n0 1\n0 0\n1 0\n2\n0 0\n0 2\n2 1", "3\n1\n0 1\n0... | 485 | 429 |
coding | Solve the programming task below in a Python markdown code block.
Let us call a pair of integer numbers m-perfect, if at least one number in the pair is greater than or equal to m. Thus, the pairs (3, 3) and (0, 2) are 2-perfect while the pair (-1, 1) is not.
Two integers x, y are written on the blackboard. It is allo... | {"inputs": ["1 2 5\n", "0 1 8\n", "0 0 0\n", "0 0 1\n", "0 0 0\n", "0 0 1\n", "0 1 8\n", "0 0 0\n"], "outputs": ["2\n", "5\n", "0\n", "-1\n", "0\n", "-1\n", "5\n", "0\n"]} | 401 | 102 |
coding | 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"]} | 385 | 74 |
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 an integer k, return the total number of subarrays whose sum equals to k.
A subarray is a contiguous non-empty sequence of elements within an array.
Please complete the following ... | {"functional": "def check(candidate):\n assert candidate(nums = [1,1,1], k = 2) == 2\n assert candidate(nums = [1,2,3], k = 3) == 2\n\n\ncheck(Solution().subarraySum)"} | 92 | 62 |
coding | Solve the programming task below in a Python markdown code block.
Ivan decided to prepare for the test on solving integer equations. He noticed that all tasks in the test have the following form:
You are given two positive integers $u$ and $v$, find any pair of integers (not necessarily positive) $x$, $y$, such that: ... | {"inputs": ["4\n1 1\n2 3\n3 5\n6 9\n", "1\n144266828 777818251\n"], "outputs": ["-1 1\n-4 9\n-9 25\n-36 81\n", "-20812917661181584 605001231588699001\n"]} | 540 | 114 |
coding | Solve the programming task below in a Python markdown code block.
*This is my first Kata in the Ciphers series. This series is meant to test our coding knowledge.*
## Ciphers #1 - The 01 Cipher
This cipher doesn't exist, I just created it by myself. It can't actually be used, as there isn't a way to decode it. It's a ... | {"functional": "_inputs = [['Hello World!']]\n_outputs = [['10110 00111!']]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return math.isclose(a, b, rel_tol=tol, abs_tol=tol)\n if isinstance(a, (list, tuple)):\n if len(a) != len(b): return False\n ... | 232 | 167 |
coding | Solve the programming task below in a Python markdown code block.
You have a statistic of price changes for one product represented as an array of $n$ positive integers $p_0, p_1, \dots, p_{n - 1}$, where $p_0$ is the initial price of the product and $p_i$ is how the price was increased during the $i$-th month.
Using ... | {"inputs": ["1\n3 3\n7 2 3\n", "1\n3 3\n7 2 6\n", "1\n3 3\n97 2 2\n", "1\n3 3\n97 2 2\n", "1\n3 3\n17 2 2\n", "1\n3 2\n25 2 2\n", "1\n3 1\n94 2 2\n", "1\n3 2\n25 2 4\n"], "outputs": ["91\n", "191\n", "0\n", "0\n", "50\n", "75\n", "106\n", "173\n"]} | 690 | 165 |
coding | Solve the programming task below in a Python markdown code block.
You are playing the game "Arranging The Sheep". The goal of this game is to make the sheep line up. The level in the game is described by a string of length $n$, consisting of the characters '.' (empty space) and '*' (sheep). In one move, you can move an... | {"inputs": ["2\n6\n**..**\n4\n**..\n", "2\n6\n**..**\n4\n**..\n", "2\n6\n**..**\n4\n..**\n", "2\n6\n**.**.\n4\n..**\n", "2\n6\n**..**\n4\n.*.*\n", "2\n6\n**.**.\n4\n*.*.\n", "2\n6\n.**.**\n4\n*..*\n", "2\n6\n**..**\n4\n*..*\n"], "outputs": ["4\n0\n", "4\n0\n", "4\n0\n", "2\n0\n", "4\n1\n", "2\n1\n", "2\n2\n", "4\n2\n"]... | 486 | 189 |
coding | Solve the programming task below in a Python markdown code block.
Recently a Golden Circle of Beetlovers was found in Byteland. It is a circle route going through n ⋅ k cities. The cities are numerated from 1 to n ⋅ k, the distance between the neighboring cities is exactly 1 km.
Sergey does not like beetles, he loves ... | {"inputs": ["3 3\n1 0\n", "4 3\n1 1\n", "2 1\n0 0\n", "6 3\n1 1\n", "5 5\n2 2\n", "4 3\n1 0\n", "1 1\n0 0\n", "6 3\n0 1\n"], "outputs": ["9 9\n", "1 12\n", "1 2\n", "1 18\n", "1 25\n", "3 12\n", "1 1\n", "9 18\n"]} | 740 | 139 |
coding | Solve the programming task below in a Python markdown code block.
As most of you might know already, a prime number is an integer `n` with the following properties:
* it must be greater than 1
* it must be divisible only by itself and 1
And that's it: -15 or 8 are not primes, 5 or 97 are; pretty easy, isn't it?
Well... | {"functional": "_inputs = [[1], [2], [5], [143], [-1], [29], [53], [529]]\n_outputs = [[False], [True], [True], [False], [False], [True], [True], [False]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return math.isclose(a, b, rel_tol=tol, abs_tol=tol)\n i... | 631 | 202 |
coding | 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"]} | 150 | 36 |
coding | Solve the programming task below in a Python markdown code block.
A palindrome is a word that reads the same forward and backward. Given a string s, you need to make it a palindrome by adding 0 or more characters to the end of s, and remember, we want the palindrome to be as short as possible.
INPUT
First line is T, ... | {"inputs": ["6\nabdfhdyrbdbsdfghjkllkjhgfds\nzazazazazazazazazazazazazazazazazazazazazazazazaza\nbacba\na\nadwuaaxcnleegluqvsczaguujoppchwecusmevz\nkoikijiikmmkmonkiinnjlijmiimnniokikimikkkkjkmiinii"], "outputs": ["38\n51\n9\n1\n77\n95"]} | 184 | 120 |
coding | Solve the programming task below in a Python markdown code block.
Ilya is a very good-natured lion. He likes maths. Of all mathematical objects, his favourite one is matrices. Now he's faced a complicated matrix problem he needs to solve.
He's got a square 2^{n} × 2^{n}-sized matrix and 4^{n} integers. You need to arr... | {"inputs": ["1\n6\n", "1\n8\n", "1\n9\n", "1\n6\n", "1\n8\n", "1\n9\n", "1\n3\n", "1\n5\n"], "outputs": ["6\n", "8\n", "9\n", "6", "8", "9", "3\n", "5\n"]} | 489 | 83 |
coding | Solve the programming task below in a Python markdown code block.
Takahashi is at an all-you-can-eat restaurant.
The restaurant offers N kinds of dishes. It takes A_i minutes to eat the i-th dish, whose deliciousness is B_i.
The restaurant has the following rules:
- You can only order one dish at a time. The dish orde... | {"inputs": ["2 60\n10 10\n60 100\n", "2 60\n10 13\n100 100", "2 60\n10 13\n100 101", "2 60\n10 10\n000 100", "2 60\n10 20\n100 101", "2 60\n10 30\n100 101", "2 60\n10 10\n100 100", "2 60\n10 10\n100 100\n"], "outputs": ["110\n", "113\n", "114\n", "110\n", "121\n", "131\n", "110", "110\n"]} | 378 | 214 |
coding | Solve the programming task below in a Python markdown code block.
Initially, there is a magical stone of mass 2^{N} lying at the origin of the number line. For the next N seconds, the following event happens:
Let us define the *decomposition* of a magical stone as follows: If there is a magical stone of mass M > 1 ly... | {"inputs": ["3\n2 -2 2\n2 0 2\n150000 48 48\n"], "outputs": ["1 0 2 0 1\n2 0 1\n122830846\n"]} | 659 | 63 |
coding | Solve the programming task below in a Python markdown code block.
One day Vasya got hold of information on the Martian dollar course in bourles for the next n days. The buying prices and the selling prices for one dollar on day i are the same and are equal to ai. Vasya has b bourles. He can buy a certain number of doll... | {"inputs": ["2 4\n6 7\n", "2 2\n6 7\n", "2 4\n3 7\n", "1 1472\n77\n", "1 1653\n77\n", "1 3232\n22\n", "1 2592\n31\n", "1 1653\n11\n"], "outputs": ["4\n", "2\n", "8\n", "1472\n", "1653\n", "3232\n", "2592\n", "1653\n"]} | 267 | 143 |
coding | Solve the programming task below in a Python markdown code block.
It is the Indian version of the famous heist “The Italian Job”. N robbers have already broken into the National Museum and are just about to get inside the main vault which is full of jewels. They were lucky that just as they broke into the museum, the g... | {"inputs": ["2\n3 4\n2 4 2\n3 2\n2 4 2\n"], "outputs": ["YES\nNO\n"]} | 548 | 36 |
coding | Solve the programming task below in a Python markdown code block.
zeros
The zeros tool returns a new array with a given shape and type filled with $\mbox{o}$'s.
import numpy
print numpy.zeros((1,2)) #Default type is float
#Output : [[ 0. 0.]]
print numpy.zeros((1,2), dtype = numpy.int) #Type ch... | {"inputs": ["3 3 3\n"], "outputs": ["[[[0 0 0]\n [0 0 0]\n [0 0 0]]\n\n [[0 0 0]\n [0 0 0]\n [0 0 0]]\n\n [[0 0 0]\n [0 0 0]\n [0 0 0]]]\n[[[1 1 1]\n [1 1 1]\n [1 1 1]]\n\n [[1 1 1]\n [1 1 1]\n [1 1 1]]\n\n [[1 1 1]\n [1 1 1]\n [1 1 1]]]\n"]} | 466 | 184 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
There are n cities connected by some number of flights. You are given an array flights where flights[i] = [fromi, toi, pricei] indicates that there is a flight from city fromi to city toi with cost pricei.
You are als... | {"functional": "def check(candidate):\n assert candidate(n = 4, flights = [[0,1,100],[1,2,100],[2,0,100],[1,3,600],[2,3,200]], src = 0, dst = 3, k = 1) == 700\n assert candidate(n = 3, flights = [[0,1,100],[1,2,100],[0,2,500]], src = 0, dst = 2, k = 1) == 200\n assert candidate(n = 3, flights = [[0,1,100],[1,2... | 154 | 205 |
coding | Solve the programming task below in a Python markdown code block.
Reduce a string of lowercase characters in range ascii[‘a’..’z’]by doing a series of operations. In each operation, select a pair of adjacent letters that match, and delete them.
Delete as many characters as possible using this method and return the ... | {"inputs": ["aa\n", "baab\n", "aaabccddd\n"], "outputs": ["Empty String\n", "Empty String\n", "abd\n"]} | 333 | 36 |
coding | Solve the programming task below in a Python markdown code block.
N ants are in a circular race. The length of the race is 1000 meters and ant number i is initially Vi meters far from starting point (point 0) of the race in clockwise order. All the ants walk with a speed of 0.1 meters per second, some of them walk in c... | {"inputs": ["2\n0 500\n"], "outputs": ["400000 \n"]} | 478 | 26 |
coding | Solve the programming task below in a Python markdown code block.
This problem was part of the CodeChef April Challenge. All user submissions for this contest problem are publicly available here.
In the game of "BattleShip V", you control a cannon which is attacking a large enemy battleship, armed with many guns. You... | {"inputs": ["1\n2 -2 1"], "outputs": ["2"]} | 384 | 18 |
coding | Solve the programming task below in a Python markdown code block.
Let's play Fairy Chess!
You have an $n\times n$ chessboard. An $\boldsymbol{\mathrm{~S~}}$-leaper is a chess piece which can move from some square $(x_0,y_0)$ to some square $(x_{1},y_{1})$ if $abs(x_0-x_1)+abs(y_0-y_1)\leq s$; however, its movements ar... | {"inputs": ["3\n4 1 1\n....\n.L..\n.P..\n....\n3 2 1\n...\n...\n..L\n4 3 2\n....\n...L\n..P.\nP...\n"], "outputs": ["4\n11\n385\n"]} | 714 | 70 |
coding | Solve the programming task below in a Python markdown code block.
A binary string S of length N is called *K-balanced string* if it holds the following property: For each index i\;(1 ≤ i ≤ N) such that S_{i} = '1', there must exist an index j\;(1 ≤ j ≤ N) such that S_{j} = '1' and \mid i - j \mid = K, where \mid x \... | {"inputs": ["4\n2 1\n01\n3 1\n111\n4 2\n1101\n5 3\n11110\n\n"], "outputs": ["1\n0\n1\n2\n"]} | 653 | 55 |
coding | Solve the programming task below in a Python markdown code block.
Write a function that takes two arguments, and returns a new array populated with the elements **that only appear once, in either one array or the other, taken only once**; display order should follow what appears in arr1 first, then arr2:
```python
ho... | {"functional": "_inputs = [[['tartar', 'blanket', 'domino'], ['blanket']], [[77, 'basketweave'], [78, 42, 'basketweave']], [[100, 45, 'ciao'], [100, 2, 3, 45, 5]], [[10, 200, 30], [10, 20, 3, 4, 5, 5, 5, 200]], [[1, 2, 3, 3], [3, 2, 1, 4, 5, 4]]]\n_outputs = [[['tartar', 'domino']], [[77, 78, 42]], [['ciao', 2, 3, 5]],... | 258 | 350 |
coding | Solve the programming task below in a Python markdown code block.
YouKn0wWho has two even integers x and y. Help him to find an integer n such that 1 ≤ n ≤ 2 ⋅ 10^{18} and n mod x = y mod n. Here, a mod b denotes the remainder of a after division by b. If there are multiple such integers, output any. It can be shown th... | {"inputs": ["1\n1000000000 1000000000\n", "1\n1000010000 1000000000\n", "1\n1001010000 1000000000\n", "1\n1001010010 1000000000\n", "1\n1001010010 1000100000\n", "1\n1000010010 1000000000\n", "1\n1000010011 1000000000\n", "1\n1001000000 1000000000\n"], "outputs": ["1000000000 \n", "2000010000\n", "2001010000\n", "20010... | 352 | 319 |
coding | Solve the programming task below in a Python markdown code block.
Lukas is a Civil Engineer who loves designing road networks to connect $n$ cities numbered from $1$ to $n$. He can build any number of bidirectional roads as long as the resultant network satisfies these constraints:
It must be possible to reach any cit... | {"inputs": ["3\n1\n3\n10\n"], "outputs": ["1\n4\n201986643\n"]} | 488 | 33 |
coding | Solve the programming task below in a Python markdown code block.
## Task
Let's say we have a positive integer, `$n$`. You have to find the smallest possible positive integer that when multiplied by `$n$`, becomes a perfect power of integer `$k$`. A perfect power of `$k$` is any positive integer that can be represente... | {"functional": "_inputs = [[100, 3], [36, 2], [72, 4], [5, 2], [1152, 3]]\n_outputs = [[10], [1], [18], [5], [12]]\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 ... | 374 | 204 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.