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 are given circle $A$ with radius $r_a$ and with central coordinate $(x_a, y_a)$ and circle $B$ with radius $r_b$ and with central coordinate $(x_b, y_b)$.
Write a program which prints:
* "2" if $B$ is in $A$,
* "-2" if $A$ is in $B$,
* "1" if circu... | {"inputs": ["2\n0.0 0.0 5.0 0.0 0.0 4.0\n0.0 0.0 2.0 4.1 0.0 2.0", "2\n0.0 0.0 5.0 0.0 0.0 4.0\n0.0 0.0 2.0 4.1 0.0 2.4515674947137622", "2\n0.0 0.0 5.0 0.0 1.5542884595470625 4.0\n0.0 0.0 2.0 4.1 0.0 2.4515674947137622", "2\n0.0 0.0 5.0 0.0 0.5752470256734817 4.0\n0.0 0.0 2.0 4.1 0.0 2.4515674947137622", "2\n0.0 0.0 5... | 304 | 748 |
coding | Solve the programming task below in a Python markdown code block.
Consider a set, $\mbox{S}$, consisting of $\boldsymbol{\mbox{k}}$ integers. The set is beautiful if at least one of the following conditions holds true for every $x\in S$:
$x-1\in S$
$x+1\in S$
For example, $S=\{1,2,50,51\}$ is beautiful but $S=\{1,5,9... | {"inputs": ["2\n6 4\n27 2\n"], "outputs": ["6\n26\n"]} | 626 | 26 |
coding | Solve the programming task below in a Python markdown code block.
A robot is standing at the origin of the infinite two-dimensional plane. Each second the robot moves exactly $1$ meter in one of the four cardinal directions: north, south, west, and east. For the first step the robot can choose any of the four direction... | {"inputs": ["1\n", "2\n", "3\n", "8\n", "4\n", "5\n", "6\n", "7\n"], "outputs": ["4\n", "4\n", "12\n", "25\n", "9\n", "24\n", "16\n", "40\n"]} | 317 | 75 |
coding | Solve the programming task below in a Python markdown code block.
Sometimes Mister B has free evenings when he doesn't know what to do. Fortunately, Mister B found a new game, where the player can play against aliens.
All characters in this game are lowercase English letters. There are two players: Mister B and his co... | {"inputs": ["1 1 1 1\n", "4 1 1 9\n", "4 5 1 1\n", "3 3 3 8\n", "4 1 1 4\n", "1 2 1 1\n", "5 3 3 8\n", "1 1 1 2\n"], "outputs": ["1", "7", "1", "3", "4\n", "1\n", "3\n", "1\n"]} | 539 | 114 |
coding | Solve the programming task below in a Python markdown code block.
Mishka started participating in a programming contest. There are $n$ problems in the contest. Mishka's problem-solving skill is equal to $k$.
Mishka arranges all problems from the contest into a list. Because of his weird principles, Mishka only solves ... | {"inputs": ["1 5\n4\n", "1 2\n1\n", "1 1\n2\n", "1 5\n1\n", "1 4\n2\n", "1 1\n1\n", "1 6\n3\n", "1 5\n5\n"], "outputs": ["1\n", "1\n", "0\n", "1\n", "1\n", "1\n", "1\n", "1\n"]} | 592 | 102 |
coding | Solve the programming task below in a Python markdown code block.
Kitahara Haruki has bought n apples for Touma Kazusa and Ogiso Setsuna. Now he wants to divide all the apples between the friends.
Each apple weights 100 grams or 200 grams. Of course Kitahara Haruki doesn't want to offend any of his friend. Therefore t... | {"inputs": ["1\n100\n", "1\n200\n", "1\n200\n", "1\n100\n", "1\n200\n", "2\n100 100\n", "2\n200 200\n", "2\n100 200\n"], "outputs": ["NO\n", "NO\n", "NO\n", "NO\n", "NO\n", "YES\n", "YES\n", "NO\n"]} | 355 | 114 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
A confusing number is a number that when rotated 180 degrees becomes a different number with each digit valid.
We can rotate digits of a number by 180 degrees to form new digits.
When 0, 1, 6, 8, and 9 are rotated 18... | {"functional": "def check(candidate):\n assert candidate(6) == True\n assert candidate(89) == True\n assert candidate(11) == False\n assert candidate(25) == False\n\n\ncheck(Solution().confusingNumber)"} | 216 | 59 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Implement a method to perform basic string compression using the counts of repeated characters. For example, the string aabcccccaaa would become a2blc5a3. If the "compressed" string would not become smaller than the o... | {"functional": "def check(candidate):\n assert candidate(\"aabcccccaaa\") == \"a2b1c5a3\"\n assert candidate(\"abbccd\") == \"abbccd\"\n\n\ncheck(Solution().compressString)"} | 120 | 53 |
coding | Solve the programming task below in a Python markdown code block.
You are given an array $a$ that contains $n$ integers. You can choose any proper subsegment $a_l, a_{l + 1}, \ldots, a_r$ of this array, meaning you can choose any two integers $1 \le l \le r \le n$, where $r - l + 1 < n$. We define the beauty of a given... | {"inputs": ["1\n4\n1000000000 1000000000 1000000000 1000000000\n", "4\n8\n1 2 2 3 1 5 6 1\n5\n1 2 3 100 200\n4\n3 3 3 3\n6\n7 8 3 1 1 8\n"], "outputs": ["0\n", "9\n297\n0\n14\n"]} | 587 | 135 |
coding | Solve the programming task below in a Python markdown code block.
Andrew was very excited to participate in Olympiad of Metropolises. Days flew by quickly, and Andrew is already at the airport, ready to go home. He has $n$ rubles left, and would like to exchange them to euro and dollar bills. Andrew can mix dollar bill... | {"inputs": ["1\n30\n30\n", "1\n30\n30\n", "1\n29\n30\n", "1\n29\n33\n", "1\n29\n25\n", "50\n60\n70\n", "90\n80\n89\n", "30\n31\n30\n"], "outputs": ["1\n", "1\n", "1\n", "1\n", "1\n", "50\n", "10\n", "30\n"]} | 531 | 124 |
coding | Solve the programming task below in a Python markdown code block.
Naturally, the magical girl is very good at performing magic. She recently met her master wizard Devu, who gifted her R potions of red liquid,
B potions of blue liquid, and G potions of green liquid.
-
The red liquid potions have liquid amounts given ... | {"inputs": ["3\n1 1 1 1\n1\n2\n3\n1 1 1 1\n2\n4\n6\n3 2 2 2\n1 2 3\n2 4\n6 8", "3\n1 1 1 1\n1\n2\n3\n1 1 1 1\n3\n4\n6\n3 2 2 2\n1 2 3\n2 4\n6 8", "3\n1 1 1 1\n1\n4\n5\n1 1 1 1\n3\n4\n6\n3 2 2 2\n2 2 3\n2 7\n6 8", "3\n1 1 1 1\n1\n4\n5\n1 1 1 2\n3\n4\n6\n3 2 2 2\n2 2 3\n2 7\n6 8", "3\n2 1 1 1\n1\n4\n5\n1 1 1 2\n3\n4\n6\n... | 591 | 493 |
coding | Solve the programming task below in a Python markdown code block.
Easy and hard versions are actually different problems, so read statements of both problems completely and carefully.
Summer vacation has started so Alice and Bob want to play and joy, but... Their mom doesn't think so. She says that they have to read s... | {"inputs": ["1 1 1\n3 0 1\n", "1 2 1\n3 0 1\n", "1 2 1\n2 0 1\n", "1 2 1\n2 0 0\n", "1 2 1\n4 0 0\n", "2 1\n7 1 1\n2 1 1\n", "2 1\n7 1 1\n2 1 1\n", "2 1\n7 1 1\n2 0 1\n"], "outputs": ["-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "2\n", "2\n", "7\n"]} | 688 | 163 |
coding | Solve the programming task below in a Python markdown code block.
You are given n segments on the Ox-axis. You can drive a nail in any integer point on the Ox-axis line nail so, that all segments containing this point, are considered nailed down. If the nail passes through endpoint of some segment, this segment is cons... | {"inputs": ["1\n0 0\n", "1\n1 0\n", "1\n2 0\n", "1\n1 1\n", "1\n1 2\n", "1\n-1 0\n", "1\n1 -1\n", "2\n0 2\n2 9\n"], "outputs": ["1\n0\n", "1\n1\n", "1\n2\n", "1\n1\n", "1\n2\n", "1\n0\n", "1\n1\n", "1\n2\n"]} | 267 | 123 |
coding | Solve the programming task below in a Python markdown code block.
There are N events (numbered from 1 to N) and M contestants (numbered from 1 to M). For each event i, contestant j receives a predetermined number of points A_{i, j}.
A [subset] of these events will be selected, and the final score of contestant j, deno... | {"inputs": ["3\n1 1\n1\n3 3\n1 0 1\n1 2 1\n1 2 1\n4 2\n1 3\n5 1\n6 8\n2 1\n"], "outputs": ["0\n4\n5"]} | 634 | 65 |
coding | Solve the programming task below in a Python markdown code block.
problem
For the integer n (1 ≤ n), let Pn be a string of n + 1 I's and n O's starting with I and alternating, where I and O are the uppercase Ai and O, respectively. is there.
P1 | IOI
--- | ---
P2 | IOIOI
P3 | IOIOIOI
|. |
|. |
|. |
Pn | IOIOIO ... O... | {"inputs": ["1\n13\nOIIOIOIOIIOIO\n2\n13\nOOIOIOIOIIOII\n0", "1\n13\nOOIOIOIOIIOII\n3\n13\nOOIOIOIOIIOII\n0", "1\n25\nOOIOIOIOIIOII\n3\n13\nOOJOIOIOIIOIJ\n0", "1\n25\nOIIOIOIOIIOIO\n0\n13\nOOJOIOIOIIOIJ\n0", "1\n25\nOOIOIOIOIIOII\n1\n13\nJIOIIOIOIOIOO\n0", "1\n25\nOIIOIOIOIIOIO\n1\n13\nOOJOIOIOIIOIJ\n0", "1\n25\nOOIOIO... | 394 | 282 |
coding | Solve the programming task below in a Python markdown code block.
In this Kata, we are going to see how a Hash (or Map or dict) can be used to keep track of characters in a string.
Consider two strings `"aabcdefg"` and `"fbd"`. How many characters do we have to remove from the first string to get the second string? ... | {"functional": "_inputs = [['xyz', 'yxz'], ['abcxyz', 'ayxz'], ['abcdexyz', 'yxz'], ['xyz', 'yxxz'], ['abdegfg', 'ffdb'], ['aabcdefg', 'fbd']]\n_outputs = [[0], [2], [5], [0], [0], [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, r... | 202 | 216 |
coding | Solve the programming task below in a Python markdown code block.
CQXYM is counting permutations length of $2n$.
A permutation is an array consisting of $n$ distinct integers from $1$ to $n$ in arbitrary order. For example, $[2,3,1,5,4]$ is a permutation, but $[1,2,2]$ is not a permutation ($2$ appears twice in the ar... | {"inputs": ["1\n100000\n", "1\n100000\n", "2\n99997\n3\n", "2\n99997\n3\n", "2\n99997\n4\n", "4\n1\n2\n9\n91234\n", "4\n2\n2\n9\n91234\n", "4\n1\n2\n3\n91234\n"], "outputs": ["553573229\n", "553573229\n", "979296788\n360\n", "979296788\n360\n", "979296788\n20160\n", "1\n12\n830455698\n890287984\n", "12\n12\n830455698\n... | 737 | 262 |
coding | Solve the programming task below in a Python markdown code block.
Two strings are said to be anagrams of each other if the letters of one string may be rearranged to make the other string. For example, the words 'elvis' and 'lives' are anagrams.
In this problem you’ll be given two strings. Your job is to find if the t... | {"inputs": ["2\nhello\nhelalo\na quick brown fox jumps over the lazy dog a quick brown fox jumps over the lazy dogaabbccddee\na", "18\nabcde\ncdeab\n121\n112\n1\nabcde\n1486\ncBaAC\na quick brown fox jumps over the lazy dog a quick brown fox jumps over the lazy dog87452117855477888\nabcdefghijklmnopqrstuvwxyzabcdefghij... | 640 | 343 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given an array of n integers, nums, where there are at most 50 unique values in the array. You are also given an array of m customer order quantities, quantity, where quantity[i] is the amount of integers the ... | {"functional": "def check(candidate):\n assert candidate(nums = [1,2,3,4], quantity = [2]) == False\n assert candidate(nums = [1,2,3,3], quantity = [2]) == True\n assert candidate(nums = [1,1,2,2], quantity = [2,2]) == True\n\n\ncheck(Solution().canDistribute)"} | 160 | 88 |
coding | Solve the programming task below in a Python markdown code block.
The Little Elephant has got a problem — somebody has been touching his sorted by non-decreasing array a of length n and possibly swapped some elements of the array.
The Little Elephant doesn't want to call the police until he understands if he could hav... | {"inputs": ["2\n1 1\n", "2\n2 1\n", "2\n2 2\n", "2\n1 2\n", "3\n2 1 1\n", "3\n1 3 2\n", "3\n3 1 2\n", "3\n2 3 1\n"], "outputs": ["YES", "YES", "YES\n", "YES", "YES", "YES", "NO", "NO"]} | 388 | 103 |
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 fronts and backs of length n, where the ith card has the positive integer fronts[i] printed on the front and backs[i] printed on the back. Initially, each card is placed on a... | {"functional": "def check(candidate):\n assert candidate(fronts = [1,2,4,4,7], backs = [1,3,4,1,3]) == 2\n assert candidate(fronts = [1], backs = [1]) == 0\n\n\ncheck(Solution().flipgame)"} | 178 | 71 |
coding | Solve the programming task below in a Python markdown code block.
You are given a string $S$ and an integer $L$. A operation is described as :- "You are allowed to pick any substring from first $L$ charcaters of $S$, and place it at the end of the string $S$.
A string $A$ is a substring of an string $B$ if $A$ can be ... | {"inputs": ["2\n1 rga\n2 cab"], "outputs": ["arg\nabc"]} | 358 | 21 |
coding | Solve the programming task below in a Python markdown code block.
You're looking through different hex codes, and having trouble telling the difference between #000001 and #100000
We need a way to tell which is red, and which is blue!
That's where you create ```hex_color()```!
It should read an RGB input, and re... | {"functional": "_inputs = [[''], ['000 000 000'], ['121 245 255'], ['027 100 100'], ['021 021 021'], ['255 000 000'], ['000 147 000'], ['212 103 212'], ['101 101 092']]\n_outputs = [['black'], ['black'], ['blue'], ['cyan'], ['white'], ['red'], ['green'], ['magenta'], ['yellow']]\nimport math\ndef _deep_eq(a, b, tol=1e-... | 271 | 282 |
coding | Solve the programming task below in a Python markdown code block.
Vasya is choosing a laptop. The shop has n laptops to all tastes.
Vasya is interested in the following properties: processor speed, ram and hdd. Vasya is a programmer and not a gamer which is why he is not interested in all other properties.
If all thr... | {"inputs": ["1\n1000 256 1 100\n", "1\n1000 477 1 100\n", "1\n1000 477 1 101\n", "1\n1000 784 1 101\n", "1\n1200 512 300 700\n", "1\n1619 512 300 700\n", "1\n1619 579 300 700\n", "1\n1619 375 300 700\n"], "outputs": ["1", "1\n", "1\n", "1\n", "1", "1\n", "1\n", "1\n"]} | 494 | 196 |
coding | Solve the programming task below in a Python markdown code block.
Vasiliy likes to rest after a hard work, so you may often meet him in some bar nearby. As all programmers do, he loves the famous drink "Beecola", which can be bought in n different shops in the city. It's known that the price of one bottle in the shop i... | {"inputs": ["1\n1\n1\n1\n", "1\n1\n1\n1\n", "1\n2\n1\n1\n", "1\n1\n1\n2\n", "1\n4\n1\n1\n", "3\n1 1 1\n1\n1\n", "3\n1 1 1\n1\n1\n", "1\n1\n1\n100005\n"], "outputs": ["1\n", "1\n", "0\n", "1\n", "0\n", "3\n", "3\n", "1\n"]} | 487 | 131 |
coding | Solve the programming task below in a Python markdown code block.
You are given an undirected unweighted graph with N vertices and M edges that contains neither self-loops nor double edges.
Here, a self-loop is an edge where a_i = b_i (1≤i≤M), and double edges are two edges where (a_i,b_i)=(a_j,b_j) or (a_i,b_i)=(b_j,... | {"inputs": ["2 1\n1 2\n", "3 3\n1 2\n1 3\n2 3", "3 3\n1 2\n1 3\n2 3\n", "4 4\n1 2\n2 3\n2 4\n3 4\n", "7 4\n1 3\n2 7\n3 4\n4 5\n4 6\n5 6\n6 7", "7 7\n1 3\n2 7\n3 4\n4 5\n4 1\n5 6\n6 7", "7 7\n1 3\n2 7\n3 4\n4 5\n4 6\n4 6\n6 7", "7 4\n1 4\n2 7\n3 4\n4 5\n4 6\n5 6\n6 7"], "outputs": ["1\n", "2", "2\n", "2\n", "0\n", "1\n"... | 416 | 236 |
coding | Solve the programming task below in a Python markdown code block.
Read problems statements in Mandarin Chinese and Russian.
Tuzik is a little dog. But despite the fact he is still a puppy he already knows about the pretty things that coins are. He knows that for every coin he can get very tasty bone from his master.... | {"inputs": ["2\n5 4\n8 6", "2\n5 2\n5 3", "2\n9 6\n5 7", "2\n9 7\n8 3", "2\n9 7\n1 9", "2\n6 7\n8 7", "2\n6 7\n5 9", "2\n3 7\n4 6"], "outputs": ["2\n3\n", "1\n2\n", "4\n5\n", "4\n2\n", "4\n1\n", "6\n3\n", "6\n5\n", "3\n4\n"]} | 471 | 142 |
coding | Solve the programming task below in a Python markdown code block.
The Little Elephant loves playing with arrays. He has array a, consisting of n positive integers, indexed from 1 to n. Let's denote the number with index i as ai.
Additionally the Little Elephant has m queries to the array, each query is characterised ... | {"inputs": ["1 2\n1\n1 1\n1 1\n", "1 1\n1000000000\n1 1\n", "1 1\n1100000000\n1 1\n", "7 2\n3 1 2 2 3 6 7\n1 7\n3 4\n", "7 2\n3 1 2 2 1 6 7\n1 7\n3 4\n", "7 2\n2 1 2 2 1 6 7\n1 7\n3 4\n", "7 2\n3 1 2 2 3 6 7\n1 6\n3 4\n", "7 2\n3 1 2 2 3 3 7\n1 7\n3 4\n"], "outputs": ["1\n1\n", "0\n", "0\n", "2\n1\n", "1\n1\n", "0\n1\n... | 316 | 248 |
coding | Solve the programming task below in a Python markdown code block.
# Task
A noob programmer was given two simple tasks: sum and sort the elements of the given array `arr` = [a1, a2, ..., an].
He started with summing and did it easily, but decided to store the sum he found in some random position of the original arr... | {"functional": "_inputs = [[[1, 12, 3, 6, 2]], [[1, -3, -5, 7, 2]], [[2, -1, 2, 2, -1]], [[-3, -3]]]\n_outputs = [[[1, 2, 3, 6]], [[-5, -3, 2, 7]], [[-1, -1, 2, 2]], [[-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, ... | 410 | 244 |
coding | Solve the programming task below in a Python markdown code block.
In this Kata, you will be given two positive integers `a` and `b` and your task will be to apply the following operations:
```
i) If a = 0 or b = 0, return [a,b]. Otherwise, go to step (ii);
ii) If a ≥ 2*b, set a = a - 2*b, and repeat step (i). Otherwis... | {"functional": "_inputs = [[6, 19], [2, 1], [22, 5], [2, 10], [8796203, 7556], [7, 11], [19394, 19394]]\n_outputs = [[[6, 7]], [[0, 1]], [[0, 1]], [[2, 2]], [[1019, 1442]], [[7, 11]], [[19394, 19394]]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return math... | 241 | 268 |
coding | Solve the programming task below in a Python markdown code block.
One day Prof. Slim decided to leave the kingdom of the GUC to join the kingdom of the GIU. He was given an easy online assessment to solve before joining the GIU. Citizens of the GUC were happy sad to see the prof leaving, so they decided to hack into th... | {"inputs": ["4\n7\n7 3 2 -11 -13 -17 -23\n6\n4 10 25 47 71 96\n6\n71 -35 7 -4 -11 -25\n6\n-45 9 -48 -67 -55 7\n", "8\n2\n-59 -9\n1\n11\n3\n-41 -26 -2\n3\n22 33 54\n3\n-56 -6 55\n5\n36 15 9 14 -71\n3\n-7 40 47\n5\n-19 54 -5 7 -29\n"], "outputs": ["NO\nYES\nYES\nNO\n", "YES\nYES\nYES\nYES\nYES\nNO\nYES\nNO\n"]} | 739 | 207 |
coding | Solve the programming task below in a Python markdown code block.
You have written on a piece of paper an array of n positive integers a[1], a[2], ..., a[n] and m good pairs of integers (i_1, j_1), (i_2, j_2), ..., (i_{m}, j_{m}). Each good pair (i_{k}, j_{k}) meets the following conditions: i_{k} + j_{k} is an odd num... | {"inputs": ["2 1\n10 1\n1 2\n", "2 1\n10 2\n1 2\n", "2 1\n10 10\n1 2\n", "2 1\n10 10\n1 2\n", "2 1\n10 19\n1 2\n", "3 2\n8 3 8\n1 2\n2 3\n", "3 2\n8 6 8\n1 2\n2 3\n", "3 2\n2 6 8\n1 2\n2 3\n"], "outputs": ["0\n", "1\n", "2\n", "2\n", "0\n", "0\n", "1\n", "1\n"]} | 467 | 176 |
coding | Solve the programming task below in a Python markdown code block.
You are given a list/array which contains only integers (positive and negative). Your job is to sum only the numbers that are the same and consecutive. The result should be one list.
Extra credit if you solve it in one line. You can assume there is neve... | {"functional": "_inputs = [[[1, 4, 4, 4, 0, 4, 3, 3, 1]], [[1, 1, 7, 7, 3]], [[-5, -5, 7, 7, 12, 0]], [[3, 3, 3, 3, 1]], [[2, 2, -4, 4, 5, 5, 6, 6, 6, 6, 6, 1]], [[1, 1, 1, 1, 1, 3]], [[1, -1, -2, 2, 3, -3, 4, -4]], [[0, 1, 1, 2, 2]]]\n_outputs = [[[1, 12, 0, 4, 6, 1]], [[2, 14, 3]], [[-10, 14, 12, 0]], [[12, 1]], [[4,... | 264 | 432 |
coding | Solve the programming task below in a Python markdown code block.
We have a long seat of width X centimeters.
There are many people who wants to sit here. A person sitting on the seat will always occupy an interval of length Y centimeters.
We would like to seat as many people as possible, but they are all very shy, and... | {"inputs": ["8 3 1", "8 3 3", "4 0 1", "12 3 2", "8 0 11", "17 4 0", "-1 0 1", "13 3 1"], "outputs": ["1\n", "0\n", "3\n", "2\n", "-1\n", "4\n", "-2\n", "3"]} | 203 | 97 |
coding | Solve the programming task below in a Python markdown code block.
A valid parentheses sequence is a non-empty string where each character is either '(' or ')', which satisfies the following constraint:
You can find a way to repeat erasing adjacent pairs of parentheses '()' until it becomes empty.
For example, '(())'... | {"inputs": ["1\n()(())()()", "1\n((((()()))", "1\n(()(()()))", "1\n()((()(())", "1\n()()()()()", "1\n((((((()))", "1\n((((()(())", "1\n(((((((())"], "outputs": ["(())\n", "((((()))))\n", "((()))\n", "(((())))\n", "()\n", "((((((()))))))\n", "(((((())))))\n", "(((((((())))))))\n"]} | 527 | 119 |
coding | Solve the programming task below in a Python markdown code block.
A **bouncy number** is a positive integer whose digits neither increase nor decrease. For example, `1235` is an increasing number, `5321` is a decreasing number, and `2351` is a bouncy number. By definition, all numbers under `100` are non-bouncy, and `1... | {"functional": "_inputs = [[0], [99], [101], [120], [122], [221], [2379], [29340], [234689], [98874], [92722983], [129347924210]]\n_outputs = [[False], [False], [True], [True], [False], [False], [False], [True], [False], [False], [True], [True]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) o... | 238 | 264 |
coding | Solve the programming task below in a Python markdown code block.
A non-decreasing sequence is a called a Fox sequence, iff the most frequent element in the sequence is unique.
e.g. The sequence 1, 1, 2, 3, 4 is a Fox sequence, because it follows the above definition. The most frequent element is 1. It occurs twice ... | {"inputs": ["5\n2 1 1\n2 1 3\n3 1 2\n4 4 5\n10 2 4\n"], "outputs": ["1\n3\n4\n4\n60\n"]} | 476 | 54 |
coding | Solve the programming task below in a Python markdown code block.
Today on Informatics class Nastya learned about GCD and LCM (see links below). Nastya is very intelligent, so she solved all the tasks momentarily and now suggests you to solve one of them as well.
We define a pair of integers (a, b) good, if GCD(a, b) ... | {"inputs": ["1 2 1 2\n", "3 3 1 1\n", "2 2 3 3\n", "3 3 3 9\n", "3 3 3 9\n", "3 3 1 1\n", "2 2 3 3\n", "3 3 3 5\n"], "outputs": ["2\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n"]} | 407 | 118 |
coding | Solve the programming task below in a Python markdown code block.
Manasa recently lost a bet to Amit. To settle the problem, they are playing a game:
They have N balls in front of them. Each ball, except the 1st ball, is numbered from 0 to 9. The 1st ball is numbered from 1 to 9.
Amit calculates all the subsequenc... | {"inputs": ["111\n", "123\n"], "outputs": ["147\n", "177\n"]} | 572 | 30 |
coding | Solve the programming task below in a Python markdown code block.
Ridhiman challenged Ashish to find the maximum valued subsequence of an array $a$ of size $n$ consisting of positive integers.
The value of a non-empty subsequence of $k$ elements of $a$ is defined as $\sum 2^i$ over all integers $i \ge 0$ such that at... | {"inputs": ["1\n1\n", "1\n1\n", "2\n3 4\n", "2\n3 4\n", "2\n4 4\n", "2\n4 7\n", "2\n0 7\n", "3\n2 1 3\n"], "outputs": ["1", "1\n", "7", "7\n", "4\n", "7\n", "7\n", "3"]} | 601 | 97 |
coding | Solve the programming task below in a Python markdown code block.
You had $n$ positive integers $a_1, a_2, \dots, a_n$ arranged in a circle. For each pair of neighboring numbers ($a_1$ and $a_2$, $a_2$ and $a_3$, ..., $a_{n - 1}$ and $a_n$, and $a_n$ and $a_1$), you wrote down: are the numbers in the pair equal or not.... | {"inputs": ["2\nEEEEEN\nEE\n", "2\nEEEEEN\nEE\n", "2\nEENEEE\nEE\n", "2\nEEEEEN\nEEEEEN\n", "2\nEEEEEN\nEEEEEN\n", "2\nNEEEEE\nEEEEEN\n", "2\nEEEEEEN\nEEEEEEEN\n", "2\nEEEEEEN\nEEEEEEEN\n"], "outputs": ["NO\nYES\n", "NO\nYES\n", "NO\nYES\n", "NO\nNO\n", "NO\nNO\n", "NO\nNO\n", "NO\nNO\n", "NO\nNO\n"]} | 624 | 136 |
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. In one operation, you may do the following:
Choose two integers in nums that are equal.
Remove both integers from nums, forming a pair.
The operation is done on nums as ... | {"functional": "def check(candidate):\n assert candidate(nums = [1,3,2,1,3,2,2]) == [3,1]\n assert candidate(nums = [1,1]) == [1,0]\n assert candidate(nums = [0]) == [0,1]\n\n\ncheck(Solution().numberOfPairs)"} | 151 | 78 |
coding | Solve the programming task below in a Python markdown code block.
Your start-up's BA has told marketing that your website has a large audience in Scandinavia and surrounding countries. Marketing thinks it would be great to welcome visitors to the site in their own language. Luckily you already use an API that detects t... | {"functional": "_inputs = [['english'], ['dutch'], ['IP_ADDRESS_INVALID'], [''], [2]]\n_outputs = [['Welcome'], ['Welkom'], ['Welcome'], ['Welcome'], ['Welcome']]\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... | 535 | 181 |
coding | Solve the programming task below in a Python markdown code block.
Mike and Joe are fratboys that love beer and games that involve drinking. They play the following game: Mike chugs one beer, then Joe chugs 2 beers, then Mike chugs 3 beers, then Joe chugs 4 beers, and so on. Once someone can't drink what he is supposed ... | {"functional": "_inputs = [[3, 2], [4, 2], [9, 1000], [0, 1]]\n_outputs = [['Joe'], ['Mike'], ['Joe'], [\"Non-drinkers can't play\"]]\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... | 209 | 193 |
coding | Solve the programming task below in a Python markdown code block.
A nested list (or *array* in JavaScript) is a list that apears as a value inside another list,
```python
[item, item, [item, item], item]
```
in the above list, [item, item] is a nested list.
Your goal is to write a function that determines the dep... | {"functional": "_inputs = [[[1, [2, [3, [4, [5, [6], 5], 4], 3], 2], 1]], [[True]], [[]], [[2, 'yes', [True, False]]], [[2.0, [2, 0], 3.7, [3, 7], 6.7, [6, 7]]], [[[[[]]], [[[]]]]], [[True, False, True, [False], True]], [[[], [], [[], []]]], [[77]], [[2, 'yes', [True, [False]]]], [[77, [77]]], [[[77], 77, [[77]]]]]\n_o... | 256 | 335 |
coding | Solve the programming task below in a Python markdown code block.
There are N towns on a line running east-west. The towns are numbered 1 through N, in order from west to east. Each point on the line has a one-dimensional coordinate, and a point that is farther east has a greater coordinate value. The coordinate of tow... | {"inputs": ["4 2 5\n1 2 8 7", "4 2 5\n1 1 5 7", "4 2 5\n1 2 5 7", "7 2 101\n18 8 32 1 146 3 37", "7 2 101\n13 8 32 1 146 3 37", "7 2 101\n13 8 32 1 182 3 37", "7 2 101\n20 14 32 1 72 3 37", "7 2 100\n13 8 32 1 182 3 37"], "outputs": ["5\n", "9\n", "11", "-151\n", "-141\n", "-213\n", "-7\n", "-214\n"]} | 387 | 231 |
coding | Solve the programming task below in a Python markdown code block.
We have an N \times N square grid.
We will paint each square in the grid either black or white.
If we paint exactly A squares white, how many squares will be painted black?
-----Constraints-----
- 1 \leq N \leq 100
- 0 \leq A \leq N^2
-----Inputs----... | {"inputs": ["3\n2", "3\n3", "3\n0", "3\n1", "3\n6", "3\n5", "3\n7", "3\n9"], "outputs": ["7\n", "6\n", "9\n", "8\n", "3\n", "4\n", "2\n", "0\n"]} | 163 | 78 |
coding | Solve the programming task below in a Python markdown code block.
After the lessons n groups of schoolchildren went outside and decided to visit Polycarpus to celebrate his birthday. We know that the i-th group consists of si friends (1 ≤ si ≤ 4), and they want to go to Polycarpus together. They decided to get there by... | {"inputs": ["1\n2\n", "1\n3\n", "1\n1\n", "1\n4\n", "2\n2 1\n", "2\n4 2\n", "2\n4 1\n", "2\n1 1\n"], "outputs": ["1\n", "1\n", "1\n", "1\n", "1\n", "2\n", "2\n", "1\n"]} | 343 | 94 |
coding | Solve the programming task below in a Python markdown code block.
Read problems statements in Mandarin Chinese and Russian.
Alok-nath is man of equality. He needs your help to divide his “sanskars” evenly amongst all his followers. By doing this, Alok-nath can create equality amongst his followers and he'll be calle... | {"inputs": ["2\n5 3\n1 2 4 5 6\n5 3\n1 2 4 5 7", "2\n5 3\n1 2 4 4 6\n5 3\n1 2 4 5 7", "2\n1 3\n0 2 6 4 6\n5 3\n1 2 0 1 2", "2\n5 3\n1 2 5 4 6\n5 3\n1 2 4 5 8", "2\n5 3\n1 2 4 4 6\n5 3\n1 2 0 5 7", "2\n5 3\n1 2 4 4 6\n5 3\n0 2 0 5 7", "2\n1 3\n1 2 4 4 6\n5 3\n0 2 0 5 7", "2\n1 3\n1 2 4 4 6\n5 3\n1 2 0 5 7"], "outputs": ... | 450 | 301 |
coding | Solve the programming task below in a Python markdown code block.
Mainak has an array $a_1, a_2, \ldots, a_n$ of $n$ positive integers. He will do the following operation to this array exactly once:
Pick a subsegment of this array and cyclically rotate it by any amount.
Formally, he can do the following exactly once:... | {"inputs": ["1\n2\n1 10\n", "1\n3\n3 2 1\n", "1\n3\n7 3 1\n", "1\n4\n8 2 2 1\n", "1\n3\n100 3 1\n", "1\n3\n999 2 1\n", "1\n3\n999 3 1\n", "1\n3\n999 100 1\n"], "outputs": ["9\n", "1\n", "4\n", "6\n", "97\n", "997\n", "996\n", "899\n"]} | 668 | 152 |
coding | Solve the programming task below in a Python markdown code block.
# Task
Lonerz got some crazy growing plants and he wants to grow them nice and well.
Initially, the garden is completely barren.
Each morning, Lonerz can put any number of plants into the garden to grow.
And at night, each plant mutates into ... | {"functional": "_inputs = [[5], [8], [536870911], [1]]\n_outputs = [[2], [1], [29], [1]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return math.isclose(a, b, rel_tol=tol, abs_tol=tol)\n if isinstance(a, (list, tuple)):\n if len(a) != len(b): retu... | 340 | 184 |
coding | Solve the programming task below in a Python markdown code block.
A restaurant received n orders for the rental. Each rental order reserve the restaurant for a continuous period of time, the i-th order is characterized by two time values — the start time l_{i} and the finish time r_{i} (l_{i} ≤ r_{i}).
Restaurant mana... | {"inputs": ["1\n1 1\n", "1\n1 1\n", "1\n1 2\n", "1\n2 2\n", "1\n1 3\n", "1\n9 74\n", "1\n4 74\n", "1\n4 30\n"], "outputs": ["1\n", "1\n", "1\n", "1\n", "1\n", "1\n", "1\n", "1\n"]} | 286 | 105 |
coding | Solve the programming task below in a Python markdown code block.
You are given a tree (a connected acyclic undirected graph) of n vertices. Vertices are numbered from 1 to n and each vertex is assigned a character from a to t.
A path in the tree is said to be palindromic if at least one permutation of the labels in t... | {"inputs": ["5\n3 1\n3 5\n5 4\n5 2\nticdm\n", "5\n3 1\n3 2\n5 4\n5 2\nticdm\n", "5\n1 2\n2 3\n2 4\n3 5\nabcbb\n", "5\n1 2\n4 3\n2 4\n3 5\nabcbb\n", "5\n3 1\n3 5\n1 4\n5 2\nticdm\n", "5\n3 1\n3 2\n5 4\n5 1\nticdm\n", "5\n1 2\n2 3\n3 4\n3 5\nabcbb\n", "7\n6 2\n4 3\n1 7\n5 2\n7 2\n1 4\nafefdfs\n"], "outputs": ["1 1 1 1 1\... | 476 | 298 |
coding | Solve the programming task below in a Python markdown code block.
Chef recently printed directions from his home to a hot new restaurant across the town, but forgot to print the directions to get back home. Help Chef to transform the directions to get home from the restaurant.
A set of directions consists of several in... | {"inputs": ["2\n4\nBegin on Road A\nRight on Road B\nRight on Road C\nLeft on Road D\n6\nBegin on Old Madras Road\nLeft on Domlur Flyover\nLeft on 100 Feet Road\nRight on Sarjapur Road\nRight on Hosur Road\nRight on Ganapathi Temple Road", "2\n4\nBegin on Road A\nRight on Road B\nRight on Road C\nLeft on Road D\n6\nBeg... | 514 | 1,143 |
coding | Solve the programming task below in a Python markdown code block.
Alice and Bob are very good friends and they always distribute all the eatables equally among themselves.
Alice has A chocolates and Bob has B chocolates. Determine whether Alice and Bob can distribute all the chocolates equally among themselves.
Note ... | {"inputs": ["4\n1 1\n1 3\n1 2\n1 4\n"], "outputs": ["YES\nYES\nNO\nNO\n"]} | 433 | 36 |
coding | Solve the programming task below in a Python markdown code block.
Vasya is very upset that many people on the Net mix uppercase and lowercase letters in one word. That's why he decided to invent an extension for his favorite browser that would change the letters' register in every word so that it either only consisted ... | {"inputs": ["t\n", "N\n", "s\n", "O\n", "r\n", "P\n", "q\n", "Q\n"], "outputs": ["t", "N", "s\n", "O\n", "r\n", "P\n", "q\n", "Q\n"]} | 255 | 68 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given an array of integers nums, half of the integers in nums are odd, and the other half are even.
Sort the array so that whenever nums[i] is odd, i is odd, and whenever nums[i] is even, i is even.
Return any answer ... | {"functional": "def check(candidate):\n assert candidate(nums = [4,2,5,7]) == [4,5,2,7]\n assert candidate(nums = [2,3]) == [2,3]\n\n\ncheck(Solution().sortArrayByParityII)"} | 113 | 65 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given an integer array arr, and an integer target, return the number of tuples i, j, k such that i < j < k and arr[i] + arr[j] + arr[k] == target.
As the answer can be very large, return it modulo 109 + 7.
Please co... | {"functional": "def check(candidate):\n assert candidate(arr = [1,1,2,2,3,3,4,4,5,5], target = 8) == 20\n assert candidate(arr = [1,1,2,2,2,2], target = 5) == 12\n\n\ncheck(Solution().threeSumMulti)"} | 115 | 84 |
coding | Solve the programming task below in a Python markdown code block.
In this Kata, you will be given two numbers, `a` and `b`, and your task is to determine if the first number `a` is divisible by `all` the prime factors of the second number `b`. For example: `solve(15,12) = False` because `15` is not divisible by all the... | {"functional": "_inputs = [[2, 256], [2, 253], [9, 243], [15, 12], [21, 2893401], [21, 2893406], [54, 2834352], [54, 2834359], [1000013, 7187761], [1000013, 7187762]]\n_outputs = [[True], [False], [True], [False], [True], [False], [True], [False], [True], [False]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isi... | 214 | 298 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given a string s, return the lexicographically smallest subsequence of s that contains all the distinct characters of s exactly once.
Please complete the following python code precisely:
```python
class Solution:
... | {"functional": "def check(candidate):\n assert candidate(s = \"bcabc\") == \"abc\"\n assert candidate(s = \"cbacdcbc\") == \"acdb\"\n\n\ncheck(Solution().smallestSubsequence)"} | 74 | 51 |
coding | Solve the programming task below in a Python markdown code block.
There is a complete graph of m vertices. Initially, the edges of the complete graph are uncolored. Sunuke did the following for each i (1 ≤ i ≤ n): Select ai vertices from the complete graph and color all edges connecting the selected vertices with color... | {"inputs": ["2\n6\n3", "2\n6\n2", "2\n5\n2", "2\n1\n2", "2\n1\n3", "2\n8\n3", "2\n5\n1", "2\n3\n2"], "outputs": ["8\n", "7\n", "6\n", "2\n", "3\n", "10\n", "5\n", "4\n"]} | 167 | 95 |
coding | Solve the programming task below in a Python markdown code block.
Takahashi wants to be a member of some web service.
He tried to register himself with the ID S, which turned out to be already used by another user.
Thus, he decides to register using a string obtained by appending one character at the end of S as his ID... | {"inputs": ["b\nba", "a\nba", "b\nab", "a\nab", "a\nbb", "`\nbb", "`\nba", "`\nca"], "outputs": ["Yes\n", "No\n", "No\n", "Yes\n", "No\n", "No\n", "No\n", "No\n"]} | 210 | 78 |
coding | Solve the programming task below in a Python markdown code block.
Looking at consecutive powers of `2`, starting with `2^1`:
`2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, ...`
Note that out of all the digits `0-9`, the last one ever to appear is `7`. It only shows up for the first time in... | {"functional": "_inputs = [[100], [2], [3], [8], [1111], [3000]]\n_outputs = [[None], [7], [0], [7], [9], [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, tuple)):\n if ... | 351 | 193 |
coding | Solve the programming task below in a Python markdown code block.
The Two-dimensional kingdom is going through hard times... This morning the Three-Dimensional kingdom declared war on the Two-dimensional one. This (possibly armed) conflict will determine the ultimate owner of the straight line.
The Two-dimensional kin... | {"inputs": ["1 1 0 2\n9\n7\n", "1 1 0 0\n1\n1\n", "1 1 0 0\n1\n2\n", "1 1 2 1\n7\n8\n", "1 1 1 0\n1\n1\n", "1 1 0 0\n9\n7\n", "1 1 0 0\n1\n4\n", "1 1 2 1\n7\n6\n"], "outputs": ["0\n", "1\n1 1\n", "0\n", "1\n1 1\n", "1\n1 1\n", "0\n", "0\n", "1\n1 1\n"]} | 657 | 166 |
coding | Solve the programming task below in a Python markdown code block.
Lolek and Bolek are about to travel abroad by plane. The local airport has a special "Choose Your Plane" offer. The offer's conditions are as follows:
* it is up to a passenger to choose a plane to fly on;
* if the chosen plane has x (x > 0) empty ... | {"inputs": ["1 1\n6\n", "2 1\n7\n", "7 1\n7\n", "4 1\n7\n", "2 1\n12\n", "7 1\n15\n", "4 1\n12\n", "1 1\n20\n"], "outputs": ["6 6\n", "13 13\n", "28 28\n", "22 22\n", "23 23\n", "84 84\n", "42 42\n", "20 20\n"]} | 562 | 136 |
coding | Solve the programming task below in a Python markdown code block.
Nicholas, a painter is going to paint several new canvases. Nicholas is sure that the canvases will turn out so great that each one will need framing and being hung on the wall. Frames are what Nicholas decided to begin with.
Nicholas has n sticks whos... | {"inputs": ["1\n1\n", "1\n10\n", "1\n20\n", "1\n37\n", "2\n1 1\n", "2\n3 5\n", "2\n5 5\n", "2\n5 6\n"], "outputs": ["0", "0", "0\n", "0\n", "0", "0", "0\n", "0\n"]} | 341 | 93 |
coding | Solve the programming task below in a Python markdown code block.
There is a given list of strings where each string contains only lowercase letters from $a-j$, inclusive. The set of strings is said to be a GOOD SET if no string is a prefix of another string. In this case, print GOOD SET. Otherwise, print BAD SET on ... | {"inputs": ["4\naab\naac\naacghgh\naabghgh\n", "7\naab\ndefgab\nabcde\naabcde\ncedaaa\nbbbbbbbbbb\njabjjjad"], "outputs": ["BAD SET\naacghgh", "BAD SET\naabcde"]} | 563 | 66 |
coding | Solve the programming task below in a Python markdown code block.
# Background:
You're working in a number zoo, and it seems that one of the numbers has gone missing!
Zoo workers have no idea what number is missing, and are too incompetent to figure it out, so they're hiring you to do it for them.
In case the zoo lo... | {"functional": "_inputs = [[[2, 3, 4]], [[1, 3, 4]], [[1, 2, 4]], [[1, 2, 3]], [[]], [[1]], [[2]]]\n_outputs = [[1], [2], [3], [4], [1], [2], [1]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return math.isclose(a, b, rel_tol=tol, abs_tol=tol)\n if isinst... | 216 | 214 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given an array nums. We define a running sum of an array as runningSum[i] = sum(nums[0]…nums[i]).
Return the running sum of nums.
Please complete the following python code precisely:
```python
class Solution:
de... | {"functional": "def check(candidate):\n assert candidate(nums = [1,2,3,4]) == [1,3,6,10]\n assert candidate(nums = [1,1,1,1,1]) == [1,2,3,4,5]\n assert candidate(nums = [3,1,2,10,1]) == [3,4,6,16,17]\n\n\ncheck(Solution().runningSum)"} | 85 | 106 |
coding | Solve the programming task below in a Python markdown code block.
Two's company, three's a crowd!
It's been one year since Chef met his brother. Last year, his younger brother came to visit him during this time of the year. This year, the Chef is planning to go visit his brother. Chef's brother has planned to throw a "... | {"inputs": ["2\n3\n4"], "outputs": ["1\n3"]} | 430 | 18 |
coding | Solve the programming task below in a Python markdown code block.
We have N integers A_1, A_2, ..., A_N.
There are \frac{N(N-1)}{2} ways to choose two of them and form a pair. If we compute the product of each of those pairs and sort the results in ascending order, what will be the K-th number in that list?
-----Const... | {"inputs": ["4 3\n6 3 -4 -2", "4 3\n6 1 -4 -2", "4 3\n3 1 -4 -5", "4 5\n6 3 -4 -2", "4 3\n6 1 -1 -2", "4 5\n6 3 -7 -2", "4 3\n3 3 -4 -2", "4 3\n3 3 -4 -2\n"], "outputs": ["-12\n", "-4\n", "-5\n", "8\n", "-2\n", "14\n", "-6", "-6\n"]} | 297 | 145 |
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 got another sequence as a birthday present. He does not like this sequence very much because it is not sorted. Since you are a good programmer, ... | {"inputs": ["2\n4 1\n1 4 2 3\n4 2\n1 4 2 3"], "outputs": ["yes\nno"]} | 505 | 38 |
coding | Solve the programming task below in a Python markdown code block.
There will be two arrays of integers. Determine all integers that satisfy the following two conditions:
The elements of the first array are all factors of the integer being considered
The integer being considered is a factor of all elements of the se... | {"inputs": ["2 3\n2 4\n16 32 96\n"], "outputs": ["3\n"]} | 523 | 29 |
coding | Solve the programming task below in a Python markdown code block.
Snuke has a string S consisting of three kinds of letters: `a`, `b` and `c`.
He has a phobia for palindromes, and wants to permute the characters in S so that S will not contain a palindrome of length 2 or more as a substring. Determine whether this is ... | {"inputs": ["baa", "bba", "bab", "bbb", "abb", "abc", "cba", "bca"], "outputs": ["NO\n", "NO\n", "NO\n", "NO\n", "NO\n", "YES\n", "YES\n", "YES\n"]} | 183 | 65 |
coding | Solve the programming task below in a Python markdown code block.
You are given two integers $n$ and $m$. You have to construct the array $a$ of length $n$ consisting of non-negative integers (i.e. integers greater than or equal to zero) such that the sum of elements of this array is exactly $m$ and the value $\sum\lim... | {"inputs": ["1\n5 1\n", "1\n53 5\n", "1\n60 2\n", "1\n60 2\n", "1\n53 5\n", "1\n2 33\n", "1\n60 1\n", "1\n1 33\n"], "outputs": ["2\n", "10\n", "4\n", "4\n", "10\n", "33\n", "2\n", "0\n"]} | 629 | 112 |
coding | Solve the programming task below in a Python markdown code block.
You are given an array A of length N. An element X is said to be *dominant* if the frequency of X in A is strictly greater than the frequency of any other element in the A.
For example, if A = [2, 1, 4, 4, 4] then 4 is a dominant element since its frequ... | {"inputs": ["4\n5\n2 2 2 2 2\n4\n1 2 3 4\n4\n3 3 2 1\n6\n1 1 2 2 3 4\n"], "outputs": ["YES\nNO\nYES\nNO\n"]} | 394 | 66 |
coding | Solve the programming task below in a Python markdown code block.
Chef has N bags and an integer X. The i^{th} bag contains A_{i} coins such that A_{i} ≤ X.
In one operation, Chef can:
Pick any bag and increase its coins to X. Formally, if he choses the i^{th} bag, he can set A_{i} = X.
Given that the cost of perfo... | {"inputs": ["3\n5 5 2\n1 2 3 4 5\n3 4 4\n1 1 1\n5 3 2\n3 2 3 1 1\n"], "outputs": ["18\n3\n10\n"]} | 743 | 64 |
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 number of unique k-diff pairs in the array.
A k-diff pair is an integer pair (nums[i], nums[j]), where the following are true:
0 <= i, j < nums.length
i !=... | {"functional": "def check(candidate):\n assert candidate(nums = [3, 1, 4, 1, 5], k = 2) == 2\n assert candidate(nums = [1, 2, 3, 4, 5], k = 1) == 4\n assert candidate(nums = [1, 3, 1, 5, 4], k = 0) == 1\n\n\ncheck(Solution().findPairs)"} | 134 | 106 |
coding | Solve the programming task below in a Python markdown code block.
You are given an infinite 2-d grid with the bottom left cell referenced as (1,1). All the cells contain a value of zero initially. Let's play a game?
The game consists of N steps wherein each step you are given two integers a and b. The value of each ... | {"inputs": ["3\n2 3\n3 7\n4 1\n"], "outputs": ["2\n"]} | 559 | 26 |
coding | Solve the programming task below in a Python markdown code block.
Sereja has an array a, consisting of n integers a_1, a_2, ..., a_{n}. The boy cannot sit and do nothing, he decided to study an array. Sereja took a piece of paper and wrote out m integers l_1, l_2, ..., l_{m} (1 ≤ l_{i} ≤ n). For each number l_{i} he wa... | {"inputs": ["1 1\n1\n1\n", "1 1\n1\n1\n", "1 1\n2\n1\n", "1 1\n0\n1\n", "2 2\n8 4\n1\n1\n", "2 2\n8 4\n1\n1\n", "2 2\n8 4\n2\n1\n", "2 2\n2 4\n1\n1\n"], "outputs": ["1\n", "1", "1\n", "1\n", "2\n2\n", "2\n2", "1\n2\n", "2\n2\n"]} | 406 | 140 |
coding | Solve the programming task below in a Python markdown code block.
The integers 14 and 15, are contiguous (1 the difference between them, obvious) and have the same number of divisors.
```python
14 ----> 1, 2, 7, 14 (4 divisors)
15 ----> 1, 3, 5, 15 (4 divisors)
```
The next pair of contiguous integers with this propert... | {"functional": "_inputs = [[1, 50], [3, 100], [3, 200], [6, 350], [6, 1000], [7, 1500], [7, 2500], [7, 3000], [9, 4000], [9, 5000], [11, 5000]]\n_outputs = [[8], [7], [18], [86], [214], [189], [309], [366], [487], [622], [567]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, fl... | 488 | 293 |
coding | Solve the programming task below in a Python markdown code block.
Chef has an array A of length N. In one operation, Chef can choose any element A_{i} and split it into two positive integers X and Y such that X+Y = A_{i}.
Note that the length of array increases by 1 after every operation.
Determine the minimum numbe... | {"inputs": ["2\n4\n1 3 5 7\n3\n1 2 3\n"], "outputs": ["0\n1\n"]} | 449 | 34 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given a list of 24-hour clock time points in "HH:MM" format, return the minimum minutes difference between any two time-points in the list.
Please complete the following python code precisely:
```python
class Soluti... | {"functional": "def check(candidate):\n assert candidate(timePoints = [\"23:59\",\"00:00\"]) == 1\n assert candidate(timePoints = [\"00:00\",\"23:59\",\"00:00\"]) == 0\n\n\ncheck(Solution().findMinDifference)"} | 83 | 76 |
coding | Solve the programming task below in a Python markdown code block.
You are given an array $a$ consisting of $n$ integers.
You can remove at most one element from this array. Thus, the final length of the array is $n-1$ or $n$.
Your task is to calculate the maximum possible length of the strictly increasing contiguous ... | {"inputs": ["2\n1 2\n", "2\n2 1\n", "2\n1 1\n", "2\n7 6\n", "2\n2 2\n", "2\n2 1\n", "2\n1 1\n", "2\n2 2\n"], "outputs": ["2\n", "1\n", "1\n", "1\n", "1\n", "1", "1", "1"]} | 400 | 99 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given an array nums of integers, a move consists of choosing any element and decreasing it by 1.
An array A is a zigzag array if either:
Every even-indexed element is greater than adjacent elements, ie. A[0] > A[1] <... | {"functional": "def check(candidate):\n assert candidate(nums = [1,2,3]) == 2\n assert candidate(nums = [9,6,1,6,2]) == 4\n\n\ncheck(Solution().movesToMakeZigzag)"} | 188 | 59 |
coding | Solve the programming task below in a Python markdown code block.
Problem Statement
You are given a connected undirected graph which has even numbers of nodes. A connected graph is a graph in which all nodes are connected directly or indirectly by edges.
Your task is to find a spanning tree whose median value of edge... | {"inputs": ["2 1\n1 2 5\n4 6\n2 2 1\n1 3 2\n1 4 3\n2 3 4\n2 4 5\n3 4 6\n8 17\n1 4 767\n3 1 609\n8 3 426\n6 5 972\n8 1 607\n6 4 51\n5 1 683\n3 6 451\n3 4 630\n8 7 912\n3 7 43\n4 7 421\n3 5 33\n8 4 538\n5 7 832\n1 6 345\n8 2 608\n0 0", "2 1\n1 2 5\n4 6\n2 2 1\n1 3 2\n1 4 6\n2 3 4\n2 4 5\n3 4 6\n8 17\n1 4 767\n3 1 609\n8 ... | 532 | 1,630 |
coding | Solve the programming task below in a Python markdown code block.
A new pack of n t-shirts came to a shop. Each of the t-shirts is characterized by three integers p_{i}, a_{i} and b_{i}, where p_{i} is the price of the i-th t-shirt, a_{i} is front color of the i-th t-shirt and b_{i} is back color of the i-th t-shirt. A... | {"inputs": ["1\n529469903\n1\n3\n1\n3\n", "1\n529469903\n1\n3\n1\n3\n", "1\n529469903\n1\n1\n1\n3\n", "1\n529469903\n1\n1\n1\n1\n", "2\n1000000000 1\n1 1\n1 2\n2\n2 1\n", "2\n1000000000 1\n1 1\n1 3\n2\n2 1\n", "2\n1000000000 1\n2 1\n1 3\n2\n2 1\n", "2\n1000000100 1\n1 1\n1 3\n2\n2 1\n"], "outputs": ["529469903 \n", "52... | 717 | 299 |
coding | Solve the programming task below in a Python markdown code block.
You are given an integer a that consists of n digits. You are also given a sequence of digits s of length m. The digit in position j (1 ≤ j ≤ m) of sequence s means that you can choose an arbitrary position i (1 ≤ i ≤ n) in a and replace the digit in the... | {"inputs": ["1\n2\n", "1\n0\n", "1\n3\n", "1\n1\n", "1\n5\n", "1\n4\n", "87\n9\n", "31\n4\n"], "outputs": ["2\n", "1\n", "3", "1", "5", "4", "97\n", "41\n"]} | 280 | 86 |
coding | Solve the programming task below in a Python markdown code block.
You're given a row with $n$ chairs. We call a seating of people "maximal" if the two following conditions hold: There are no neighbors adjacent to anyone seated. It's impossible to seat one more person without violating the first rule.
The seating is... | {"inputs": ["1\n0\n", "1\n1\n", "1\n0\n", "1\n1\n", "2\n00\n", "2\n01\n", "2\n10\n", "2\n11\n"], "outputs": ["No\n", "Yes\n", "No\n", "Yes\n", "No\n", "Yes\n", "Yes\n", "No\n"]} | 319 | 90 |
coding | Solve the programming task below in a Python markdown code block.
Monocarp has got an array $a$ consisting of $n$ integers. Let's denote $k$ as the mathematic mean of these elements (note that it's possible that $k$ is not an integer).
The mathematic mean of an array of $n$ elements is the sum of elements divided by t... | {"inputs": ["1\n1\n228 1337 3\n", "1\n1\n228 1512 3\n", "1\n1\n228 2063 3\n", "1\n1\n228 2063 2\n", "1\n1\n342 1512 3\n", "1\n1\n228 2063 0\n", "1\n1\n228 4021 2\n", "1\n3\n40 270 228\n"], "outputs": ["0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n"]} | 577 | 174 |
coding | Solve the programming task below in a Python markdown code block.
There are $n$ boxes with different quantities of candies in each of them. The $i$-th box has $a_i$ candies inside.
You also have $n$ friends that you want to give the candies to, so you decided to give each friend a box of candies. But, you don't want a... | {"inputs": ["1\n1\n114514\n", "1\n1\n999999\n", "1\n3\n1000 1000 4567\n", "5\n5\n1 2 3 4 5\n6\n1000 1000 5 1000 1000 1000\n10\n1 2 3 5 1 2 7 9 13 5\n3\n8 8 8\n1\n10000000\n"], "outputs": ["0\n", "0\n", "3567\n", "10\n4975\n38\n0\n0\n"]} | 578 | 173 |
coding | Solve the programming task below in a Python markdown code block.
You are given N non-negative integers A_1, A_2, ..., A_N and another non-negative integer K.
For a integer X between 0 and K (inclusive), let f(X) = (X XOR A_1) + (X XOR A_2) + ... + (X XOR A_N).
Here, for non-negative integers a and b, a XOR b denotes t... | {"inputs": ["3 7\n1 6 3\n", "4 9\n7 4 0 3\n", "1 0\n1000000000000\n"], "outputs": ["14\n", "46\n", "1000000000000\n"]} | 388 | 78 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given an integer n, add a dot (".") as the thousands separator and return it in string format.
Please complete the following python code precisely:
```python
class Solution:
def thousandSeparator(self, n: int) -... | {"functional": "def check(candidate):\n assert candidate(n = 987) == \"987\"\n assert candidate(n = 1234) == \"1.234\"\n assert candidate(n = 123456789) == \"123.456.789\"\n assert candidate(n = 0) == \"0\"\n\n\ncheck(Solution().thousandSeparator)"} | 69 | 101 |
coding | Solve the programming task below in a Python markdown code block.
Harrenhal is the largest castle in the Seven Kingdoms and is the seat of House Whent in the Riverlands, on the north shore of the Gods Eye lake. Since the War of Conquest, however, it has become a dark and ruinous place.
(c) A Wiki of Ice and Fire
Now H... | {"inputs": ["1\nabbabaab\n\n"], "outputs": ["2"]} | 670 | 18 |
coding | Solve the programming task below in a Python markdown code block.
# Task
John and Alice have an appointment today.
In the morning, John starts from (`0,0`) and goes to the place (`a,b`) where he is dating. Unfortunately, John had no sense of direction at all, so he moved 1 step in a random direction(up, down, left o... | {"functional": "_inputs = [[3, 3, 6], [4, 5, 10], [-5, -5, 10], [-5, -5, 8], [10, -10, 10]]\n_outputs = [[True], [False], [True], [False], [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 isins... | 582 | 216 |
coding | Solve the programming task below in a Python markdown code block.
We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it.
It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top o... | {"inputs": ["0 3 000\n15 16 87\n83 94 18 4", "3 3 000\n57 16 125\n46 6 20 1", "0 3 000\n15 16 87\n83 94 18 14", "3 3 000\n60 16 4\n30 94 80 150", "3 3 000\n57 16 125\n46 9 20 14", "3 3 000\n57 16 125\n5 94 18 14", "-1 3 000\n26 9 87\n83 94 18 14", "3 3 100\n60 16 4\n30 94 80 150"], "outputs": ["0\n", "0\n", "0\n", "0\n... | 531 | 275 |
coding | Solve the programming task below in a Python markdown code block.
You are given two strings $s$ and $t$ both of length $n$ and both consisting of lowercase Latin letters.
In one move, you can choose any length $len$ from $1$ to $n$ and perform the following operation: Choose any contiguous substring of the string $s... | {"inputs": ["4\n4\nabcd\nabdc\n5\nababa\nbaaba\n4\nasdf\nasdg\n4\nabcd\nbadc\n", "4\n4\nabcd\nabdc\n5\nababa\nbaaba\n4\nasdf\nasdg\n4\nabdd\nbadc\n", "4\n4\nabcd\nabdc\n5\nababa\nabaab\n4\nasdf\nasdg\n4\nabcd\nbadc\n", "4\n4\nabcd\nabdc\n5\naaabc\nbabaa\n4\nfdsa\nasdg\n4\nabdd\nbadc\n", "4\n4\ndabb\nabdb\n5\nababa\naba... | 569 | 361 |
coding | Solve the programming task below in a Python markdown code block.
n soldiers stand in a circle. For each soldier his height ai is known. A reconnaissance unit can be made of such two neighbouring soldiers, whose heights difference is minimal, i.e. |ai - aj| is minimal. So each of them will be less noticeable with the o... | {"inputs": ["2\n6 6\n", "2\n3 6\n", "2\n511 5\n", "2\n511 6\n", "2\n605 6\n", "2\n511 32\n", "3\n83 504 68\n", "3\n136 452 68\n"], "outputs": ["1 2\n", "1 2\n", "1 2\n", "1 2\n", "1 2\n", "1 2\n", "3 1\n", "3 1\n"]} | 244 | 140 |
coding | Solve the programming task below in a Python markdown code block.
There is a circle with a circumference of L. Each point on the circumference has a coordinate value, which represents the arc length from a certain reference point clockwise to the point. On this circumference, there are N ants. These ants are numbered 1... | {"inputs": ["3 8 3\n0 2\n3 2\n6 1", "2 8 3\n0 1\n3 2\n6 1", "3 8 3\n1 2\n3 2\n6 1", "1 8 3\n1 2\n3 2\n6 1", "1 8 0\n1 2\n3 4\n6 1", "1 8 1\n1 2\n3 4\n6 1", "2 8 3\n1 1\n3 2\n6 1", "1 5 3\n1 2\n6 2\n6 1"], "outputs": ["0\n1\n5\n", "0\n3\n", "0\n1\n6\n", "6\n", "1\n", "0\n", "0\n4\n", "3\n"]} | 416 | 202 |
coding | Solve the programming task below in a Python markdown code block.
Chef's dog *binary* hears frequencies starting from 67 Hertz to 45000 Hertz (both inclusive).
If Chef's commands have a frequency of X Hertz, find whether *binary* can hear them or not.
------ Input Format ------
- The first line of input will conta... | {"inputs": ["5\n42\n67\n402\n45000\n45005\n"], "outputs": ["NO\nYES\nYES\nYES\nNO\n"]} | 478 | 44 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.