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.
One day little Vasya found mom's pocket book. The book had n names of her friends and unusually enough, each name was exactly m letters long. Let's number the names from 1 to n in the order in which they are written.
As mom wasn't home, Vasya decided to... | {"inputs": ["1 1\nE\n", "1 1\nD\n", "1 1\nF\n", "2 2\nAA\nBB\n", "2 2\nNS\nPD\n", "2 2\nNS\nDP\n", "2 2\nSN\nDP\n", "2 2\nSN\nCP\n"], "outputs": ["1\n", "1\n", "1\n", "4\n", "4\n", "4\n", "4\n", "4\n"]} | 453 | 112 |
coding | Solve the programming task below in a Python markdown code block.
In Berland, $n$ different types of banknotes are used. Banknotes of the $i$-th type have denomination $10^{a_i}$ burles (burles are the currency used in Berland); the denomination of banknotes of the first type is exactly $1$.
Let's denote $f(s)$ as the... | {"inputs": ["4\n3 1\n0 1 2\n2 777\n0 2\n3 60\n0 1 3\n10 0000000010\n0 1 2 3 4 5 6 7 8 9\n", "4\n3 1\n0 1 2\n2 777\n0 2\n3 60\n0 1 3\n10 0000000011\n0 1 2 3 4 5 6 7 8 9\n", "4\n3 2\n0 1 2\n2 777\n0 2\n3 60\n0 1 3\n10 0000000010\n0 1 2 3 4 5 6 7 8 9\n", "4\n3 2\n0 1 2\n2 983\n0 2\n3 60\n0 1 3\n10 0000000010\n0 1 2 3 4 5 ... | 518 | 712 |
coding | Solve the programming task below in a Python markdown code block.
You are given a string $s$ consisting of lowercase Latin letters "a", "b" and "c" and question marks "?".
Let the number of question marks in the string $s$ be $k$. Let's replace each question mark with one of the letters "a", "b" and "c". Here we can o... | {"inputs": ["3\n???\n", "3\nabc\n", "3\nabc\n", "3\n???\n", "3\ncba\n", "3\nbac\n", "3\naac\n", "3\nabb\n"], "outputs": ["1\n", "1\n", "1\n", "1\n", "0\n", "0\n", "0\n", "0\n"]} | 703 | 89 |
coding | Solve the programming task below in a Python markdown code block.
Vasya plays the LionAge II. He was bored of playing with a stupid computer, so he installed this popular MMORPG, to fight with his friends. Vasya came up with the name of his character — non-empty string s, consisting of a lowercase Latin letters. Howeve... | {"inputs": ["xd 2\n0\n", "xd 3\n0\n", "dx 3\n0\n", "jmiqoyqf 4\n0\n", "jmiqoyqf 7\n0\n", "jmiqoyqf 2\n0\n", "jmiqoyqf 0\n0\n", "xmltrs 3\n2\ne a -27\nc v -932\n"], "outputs": ["0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n"]} | 447 | 136 |
coding | Solve the programming task below in a Python markdown code block.
Masha has three sticks of length $a$, $b$ and $c$ centimeters respectively. In one minute Masha can pick one arbitrary stick and increase its length by one centimeter. She is not allowed to break sticks.
What is the minimum number of minutes she needs t... | {"inputs": ["3 4 5\n", "2 5 3\n", "1 1 1\n", "3 1 1\n", "2 3 6\n", "4 5 6\n", "4 2 7\n", "2 5 2\n"], "outputs": ["0\n", "1\n", "0\n", "2\n", "2\n", "0\n", "2\n", "2\n"]} | 441 | 102 |
coding | Solve the programming task below in a Python markdown code block.
We have the number ```12385```. We want to know the value of the closest cube but higher than 12385. The answer will be ```13824```.
Now, another case. We have the number ```1245678```. We want to know the 5th power, closest and higher than that number.... | {"functional": "_inputs = [[12385, 3], [1245678, 5], [1245678, 6]]\n_outputs = [[13824], [1419857], [1771561]]\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 ... | 276 | 208 |
coding | Solve the programming task below in a Python markdown code block.
We have N squares assigned the numbers 1,2,3,\ldots,N. Each square has an integer written on it, and the integer written on Square i is a_i.
How many squares i satisfy both of the following conditions?
* The assigned number, i, is odd.
* The written in... | {"inputs": ["5\n1 5 4 5 7", "5\n0 4 4 5 7", "5\n0 4 4 5 0", "5\n1 4 4 5 7", "5\n0 5 4 5 7", "5\n1 3 4 6 7", "5\n2 5 4 5 7", "5\n1 4 4 7 7"], "outputs": ["2\n", "1\n", "0\n", "2\n", "1\n", "2\n", "1\n", "2\n"]} | 220 | 142 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given the array of integers nums, you will choose two different indices i and j of that array. Return the maximum value of (nums[i]-1)*(nums[j]-1).
Please complete the following python code precisely:
```python
clas... | {"functional": "def check(candidate):\n assert candidate(nums = [3,4,5,2]) == 12 \n assert candidate(nums = [1,5,4,5]) == 16\n assert candidate(nums = [3,7]) == 12\n\n\ncheck(Solution().maxProduct)"} | 84 | 73 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You have an inventory of different colored balls, and there is a customer that wants orders balls of any color.
The customer weirdly values the colored balls. Each colored ball's value is the number of balls of that c... | {"functional": "def check(candidate):\n assert candidate(inventory = [2,5], orders = 4) == 14\n assert candidate(inventory = [3,5], orders = 6) == 19\n assert candidate(inventory = [2,8,4,10,6], orders = 20) == 110\n assert candidate(inventory = [1000000000], orders = 1000000000) == 21\n\n\ncheck(Solution()... | 259 | 128 |
coding | Solve the programming task below in a Python markdown code block.
One day n friends gathered together to play "Mafia". During each round of the game some player must be the supervisor and other n - 1 people take part in the game. For each person we know in how many rounds he wants to be a player, not the supervisor: th... | {"inputs": ["3\n1 1 1\n", "3\n2 1 1\n", "3\n1 2 1\n", "3\n1 1 2\n", "3\n1 1 0\n", "3\n3 4 2\n", "3\n4 5 5\n", "3\n3 4 1\n"], "outputs": ["2\n", "2\n", "2\n", "2\n", "1\n", "5\n", "7\n", "4\n"]} | 329 | 118 |
coding | Solve the programming task below in a Python markdown code block.
ATM machines allow 4 or 6 digit PIN codes and PIN codes cannot contain anything but **exactly** 4 digits or exactly 6 digits.
If the function is passed a valid PIN string, return `true`, else return `false`.
## Examples
```
"1234" --> true
"12345"... | {"functional": "_inputs = [['1'], ['12'], ['123'], ['12345'], ['1234567'], ['-1234'], ['-12345'], ['1.234'], ['00000000'], ['a234'], ['.234'], ['1234'], ['0000'], ['1111'], ['123456'], ['098765'], ['000000'], ['090909']]\n_outputs = [[False], [False], [False], [False], [False], [False], [False], [False], [False], [Fals... | 126 | 321 |
coding | Solve the programming task below in a Python markdown code block.
It is known that there are k fish species in the polar ocean, numbered from 1 to k. They are sorted by non-decreasing order of their weight, which is a positive number. Let the weight of the i-th type of fish be wi, then 0 < w1 ≤ w2 ≤ ... ≤ wk holds.
Po... | {"inputs": ["1 1 1\n1\n1\n", "3 3 3\n2 2 4\n1 1 3\n", "3 3 3\n2 2 4\n1 1 1\n", "3 3 3\n2 2 4\n1 1 2\n", "3 3 3\n2 2 2\n1 1 3\n", "5 4 5\n1 2 2 3 4\n1 3 4 5\n", "5 5 10\n8 2 8 5 9\n9 1 7 5 1\n", "5 5 10\n8 2 8 5 1\n9 1 7 5 1\n"], "outputs": ["NO\n", "YES\n", "YES\n", "YES\n", "YES\n", "YES\n", "YES\n", "YES\n"]} | 478 | 214 |
coding | Solve the programming task below in a Python markdown code block.
An array is called `centered-N` if some `consecutive sequence` of elements of the array sum to `N` and this sequence is preceded and followed by the same number of elements.
Example:
```
[3,2,10,4,1,6,9] is centered-15
because the sequence 10,4,1 sums ... | {"functional": "_inputs = [[[0, 0, 0], 0], [[3, 2, 10, 4, 1, 6, 9], 15], [[2, 10, 4, 1, 6, 9], 15], [[3, 2, 10, 4, 1, 6], 15], [[1, 1, 8, 3, 1, 1], 15], [[1, 1, 8, 3, 1, 1], 11], [[1, 1, 8, 3, 1, 1], 13], [[9, 0, 6], 0], [[], 25], [[25], 25], [[25, 26, 23, 24], 0], [[2, 1, 2], 0], [[1, 1, 15, -1, -1], 15], [[1, 1, 15, ... | 189 | 509 |
coding | Solve the programming task below in a Python markdown code block.
There is a vampire family of N members. Vampires are also known as extreme gourmets. Of course vampires' foods are human blood. However, not all kinds of blood is acceptable for them. Vampires drink blood that K blood types of ones are mixed, and each va... | {"inputs": ["2 3\n9 3 6\n1 1 3\n3 2 0\n3 5\n0 2 2 6 5\n0 1 0 1 2\n1 0 1 2 4\n1 0 3 0 1\n0 0", "2 3\n9 2 6\n1 1 3\n3 2 0\n3 5\n0 2 2 6 5\n0 1 0 1 2\n1 0 1 2 4\n1 0 3 0 1\n0 0", "2 3\n9 2 6\n0 1 3\n3 2 0\n3 5\n0 2 2 6 5\n0 1 0 1 2\n1 0 1 2 4\n1 0 3 0 1\n0 0", "2 3\n9 2 6\n0 1 3\n3 2 0\n3 5\n0 2 2 6 5\n0 1 0 1 2\n1 0 2 2 ... | 448 | 622 |
coding | Solve the programming task below in a Python markdown code block.
Taro's Shopping
Mammy decided to give Taro his first shopping experience. Mammy tells him to choose any two items he wants from those listed in the shopping catalogue, but Taro cannot decide which two, as all the items look attractive. Thus he plans to ... | {"inputs": ["3 45\n20 20 30\n6 10\n1 2 5 8 4 11\n7 000\n11 34 8 47 59 29 70\n4 100\n80 70 62 50\n4 8\n0 5 10 16\n0 0", "3 45\n0 20 30\n6 10\n2 2 5 8 1 11\n7 100\n22 34 33 94 59 29 70\n4 100\n8 70 80 18\n4 20\n10 5 10 16\n0 0", "3 45\n2 20 30\n6 10\n1 2 5 8 4 11\n7 100\n11 34 83 47 59 29 70\n4 100\n80 70 62 50\n4 20\n1 ... | 649 | 903 |
coding | Solve the programming task below in a Python markdown code block.
Young Teodor enjoys drawing. His favourite hobby is drawing segments with integer borders inside his huge [1;m] segment. One day Teodor noticed that picture he just drawn has one interesting feature: there doesn't exist an integer point, that belongs eac... | {"inputs": ["2 7\n1 2\n3 4\n", "2 4\n1 2\n3 4\n", "4 6\n1 3\n2 5\n4 6\n5 6\n", "4 6\n1 3\n2 3\n4 6\n5 6\n", "11 3\n1 1\n1 1\n1 1\n1 1\n2 2\n2 2\n2 2\n3 3\n3 3\n3 3\n3 3\n", "31 1600\n51 1483\n8 475\n14 472\n49 81\n300 1485\n627 682\n44 443\n1191 1541\n478 732\n1112 1202\n741 1341\n475 1187\n1218 1463\n523 1513\n274 477... | 655 | 993 |
coding | Solve the programming task below in a Python markdown code block.
The Cartesian coordinate system is set in the sky. There you can see n stars, the i-th has coordinates (x_{i}, y_{i}), a maximum brightness c, equal for all stars, and an initial brightness s_{i} (0 ≤ s_{i} ≤ c).
Over time the stars twinkle. At moment 0... | {"inputs": ["2 3 3\n1 1 1\n3 2 0\n2 1 1 2 2\n0 2 1 4 5\n5 1 1 5 5\n", "2 3 3\n1 1 1\n3 2 0\n2 1 1 1 2\n0 2 1 4 5\n5 1 1 5 5\n", "2 3 3\n1 2 1\n3 2 0\n2 1 1 2 2\n0 2 1 7 5\n5 1 1 5 1\n", "2 3 3\n1 2 1\n3 2 0\n0 1 1 2 2\n0 2 1 7 5\n5 1 1 5 5\n", "2 3 3\n1 2 1\n3 2 0\n0 1 1 2 2\n1 2 1 7 5\n5 1 1 5 5\n", "2 3 3\n1 1 1\n3 2... | 755 | 471 |
coding | Solve the programming task below in a Python markdown code block.
Vova has won $n$ trophies in different competitions. Each trophy is either golden or silver. The trophies are arranged in a row.
The beauty of the arrangement is the length of the longest subsegment consisting of golden trophies. Vova wants to swap two ... | {"inputs": ["2\nSS\n", "2\nSG\n", "2\nGS\n", "2\nGG\n", "2\nSG\n", "2\nGG\n", "2\nGS\n", "2\nSS\n"], "outputs": ["0\n", "1\n", "1\n", "2\n", "1\n", "2", "1\n", "0"]} | 382 | 84 |
coding | Solve the programming task below in a Python markdown code block.
You are given an array a of length n. We define f_{a} the following way:
Initially f_{a} = 0, M = 1; for every 2 ≤ i ≤ n if a_{M} < a_{i} then we set f_{a} = f_{a} + a_{M} and then set M = i.
Calculate the sum of f_{a} over all n! permutations of t... | {"inputs": ["2\n1 3\n", "2\n1 6\n", "2\n1 9\n", "2\n1 3\n", "3\n1 1 2\n", "3\n1 2 2\n", "3\n1 2 4\n", "3\n1 1 4\n"], "outputs": ["1", "1\n", "1\n", "1\n", "4", "2\n", "8\n", "4\n"]} | 450 | 108 |
coding | Solve the programming task below in a Python markdown code block.
Ever since you started work at the grocer, you have been faithfully logging down each item and its category that passes through. One day, your boss walks in and asks, "Why are we just randomly placing the items everywhere? It's too difficult to find anyt... | {"functional": "_inputs = [['fruit_banana,vegetable_carrot,meat_chicken,drink_juice'], ['fruit_banana,vegetable_carrot,fruit_apple,canned_sardines,drink_juice,fruit_orange'], ['vegetable_celery,meat_chicken,meat_beef,fruit_banana,vegetable_carrot,canned_sardines,drink_juice,frozen_fries,fruit_lemon'], ['fruit_orange']]... | 315 | 359 |
coding | Solve the programming task below in a Python markdown code block.
Niwango-kun, an employee of Dwango Co., Ltd., likes Niconico TV-chan, so he collected a lot of soft toys of her and spread them on the floor.
Niwango-kun has N black rare soft toys of Niconico TV-chan and they are spread together with ordinary ones. He ... | {"inputs": ["3 2\n0 0\n1 0\n2 0", "1 4\n0 0\n2 1\n2 0", "3 8\n0 0\n0 0\n2 0", "3 4\n0 0\n1 0\n2 0", "3 4\n0 0\n1 1\n2 0", "3 4\n0 0\n2 1\n2 0", "1 4\n0 0\n2 1\n2 1", "3 4\n0 0\n0 0\n2 0"], "outputs": ["2\n", "0\n", "8\n", "2\n", "2\n", "2\n", "0\n", "4\n"]} | 583 | 174 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given the array orders, which represents the orders that customers have done in a restaurant. More specifically orders[i]=[customerNamei,tableNumberi,foodItemi] where customerNamei is the name of the customer, tableNu... | {"functional": "def check(candidate):\n assert candidate(orders = [[\"David\",\"3\",\"Ceviche\"],[\"Corina\",\"10\",\"Beef Burrito\"],[\"David\",\"3\",\"Fried Chicken\"],[\"Carla\",\"5\",\"Water\"],[\"Carla\",\"5\",\"Ceviche\"],[\"Rous\",\"3\",\"Ceviche\"]]) == [[\"Table\",\"Beef Burrito\",\"Ceviche\",\"Fried Chicke... | 218 | 316 |
coding | Solve the programming task below in a Python markdown code block.
Chef has a natural number N. Cheffina challenges chef to check whether the given number is divisible by the sum of its digits or not. If the given number is divisible then print "Yes" else "No".
-----Input:-----
- First-line will contain $T$, the number... | {"inputs": ["2\n16\n27"], "outputs": ["No\nYes"]} | 169 | 20 |
coding | Solve the programming task below in a Python markdown code block.
Read problems statements in Mandarin Chinese , Russian and Vietnamese as well.
You have been appointed as the designer for your school's computer network.
In total, there are N computers in the class, and M computer-to-computer connections need to be ... | {"inputs": ["2\n10 1\n5 5"], "outputs": ["-1 -1\n1 2\n2 3\n3 4\n4 5\n5 1"]} | 545 | 44 |
coding | Solve the programming task below in a Python markdown code block.
This time Baby Ehab will only cut and not stick. He starts with a piece of paper with an array a of length n written on it, and then he does the following:
* he picks a range (l, r) and cuts the subsegment a_l, a_{l + 1}, …, a_r out, removing the rest... | {"inputs": ["1 1\n100000\n1 1\n", "6 3\n1 4 5 5 4 3\n1 6\n4 4\n3 3\n", "6 3\n1 2 3 5 4 2\n1 2\n4 4\n3 6\n", "6 3\n1 6 3 4 4 1\n1 6\n2 6\n3 6\n", "6 3\n1 2 3 5 2 2\n1 6\n4 4\n3 6\n", "6 3\n1 2 3 5 4 2\n1 6\n4 4\n3 6\n", "6 3\n1 2 3 5 4 2\n1 6\n4 4\n3 5\n", "6 3\n1 4 3 5 4 2\n1 6\n4 4\n3 5\n"], "outputs": ["1\n", "2\n1\n... | 533 | 293 |
coding | Solve the programming task below in a Python markdown code block.
To become the king of Codeforces, Kuroni has to solve the following problem.
He is given $n$ numbers $a_1, a_2, \dots, a_n$. Help Kuroni to calculate $\prod_{1\le i<j\le n} |a_i - a_j|$. As result can be very big, output it modulo $m$.
If you are not f... | {"inputs": ["2 2\n1 2\n", "2 2\n9 6\n", "2 2\n0 1\n", "2 5\n3 0\n", "2 5\n3 0\n", "2 2\n9 6\n", "2 2\n1 2\n", "2 2\n0 1\n"], "outputs": ["1", "1", "1", "3", "3\n", "1\n", "1\n", "1\n"]} | 555 | 114 |
coding | Solve the programming task below in a Python markdown code block.
This time the Berland Team Olympiad in Informatics is held in a remote city that can only be reached by one small bus. Bus has n passenger seats, seat i can be occupied only by a participant from the city a_{i}.
Today the bus has completed m trips, each... | {"inputs": ["1 5 8\n1\n", "1 9 10\n1\n", "1 9 13\n1\n", "1 2 13\n1\n", "1 5 13\n1\n", "1 3 13\n1\n", "1 8 10\n1\n", "1 9 10\n2\n"], "outputs": ["3\n", "1\n", "4\n", "1\n", "3\n", "1\n", "2\n", "1\n"]} | 440 | 125 |
coding | Solve the programming task below in a Python markdown code block.
Write the following function:
```python
def area_of_polygon_inside_circle(circle_radius, number_of_sides):
```
It should calculate the area of a regular polygon of `numberOfSides`, `number-of-sides`, or `number_of_sides` sides inside a circle of radius... | {"functional": "_inputs = [[3, 3], [2, 4], [2.5, 5]]\n_outputs = [[11.691], [8], [14.86]]\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): ret... | 239 | 189 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given the roots of two binary trees root and subRoot, return true if there is a subtree of root with the same structure and node values of subRoot and false otherwise.
A subtree of a binary tree tree is a tree that co... | {"functional": "def check(candidate):\n assert candidate(root = tree_node([3,4,5,1,2]), subRoot = tree_node([4,1,2])) == True\n assert candidate(root = tree_node([3,4,5,1,2,None,None,None,None,0]), subRoot = tree_node([4,1,2])) == False\n\n\ncheck(Solution().isSubtree)"} | 181 | 92 |
coding | Solve the programming task below in a Python markdown code block.
A number K$K$ is said to be magical if it can be represented as a power of 2 only.That is K$K$=2x$2^{x}$ for some natural number x$x$.
Given a string of digits S$S$ of length N$N$, Let P be a valid arrangement of S.
By valid arrangement we mean that it ... | {"inputs": ["2\n35566\n31"], "outputs": ["65536\n-1"]} | 471 | 28 |
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.
Two strings $A$ and $B$ are *equivalent* (denoted by $A \sim B$) if they have the same lengths and $A$ can be transformed into $B$ by performing the ... | {"inputs": ["10\n00000\n10001\n10101\n01111\n11001\n01101\n10110\n10010\n10111\n11001"], "outputs": ["5\n11\n8\n9\n12\n10\n10\n11\n11\n12"]} | 480 | 98 |
coding | Solve the programming task below in a Python markdown code block.
Among Johnny's numerous hobbies, there are two seemingly harmless ones: applying bitwise operations and sneaking into his dad's office. As it is usually the case with small children, Johnny is unaware that combining these two activities can get him in a ... | {"inputs": ["6\n4\n1 0 2 6\n6\n10 7 14 8 0 6\n2\n0 2\n3\n1 2 3\n6\n1 0 3 10 5 12\n2\n0 1023\n", "6\n4\n1 0 2 3\n6\n10 7 14 8 0 12\n2\n0 2\n3\n1 2 3\n6\n1 4 6 10 11 12\n2\n0 302\n", "6\n4\n1 0 2 3\n6\n10 7 14 8 0 12\n2\n0 2\n3\n1 2 3\n6\n1 4 9 10 18 12\n2\n1 302\n", "6\n4\n1 0 2 3\n6\n10 7 14 8 0 12\n2\n0 2\n3\n1 2 3\n6... | 694 | 721 |
coding | Solve the programming task below in a Python markdown code block.
You are given an axis-aligned rectangle in a 2D Cartesian plane. The bottom left corner of this rectangle has coordinates (0,0)$(0, 0)$ and the top right corner has coordinates (N−1,N−1)$(N-1, N-1)$. You are also given K$K$ light sources; each light sour... | {"inputs": ["2\n2 10\n0 0\n1 0\n2 10\n1 2\n1 1"], "outputs": ["yes\nno"]} | 493 | 40 |
coding | Solve the programming task below in a Python markdown code block.
Complete the code which should return `true` if the given object is a single ASCII letter (lower or upper case), `false` otherwise.
Also feel free to reuse/extend the following starter code:
```python
def is_letter(s):
``` | {"functional": "_inputs = [[''], ['a'], ['X'], ['7'], ['_'], ['ab'], ['a\\n']]\n_outputs = [[False], [True], [True], [False], [False], [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 ... | 63 | 191 |
coding | Solve the programming task below in a Python markdown code block.
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
One day Petya encountered a tree w... | {"inputs": ["2\n1 2 7\n", "2\n1 2 3\n", "2\n1 2 10\n", "2\n2 1 1000000000\n", "2\n2 1 1010000000\n", "2\n2 1 1000000001\n", "4\n1 2 4\n3 1 2\n1 4 7\n", "4\n1 2 4\n1 3 47\n1 4 7447\n"], "outputs": ["0", "0", "0", "0", "0", "0", "16", "24"]} | 638 | 168 |
coding | Solve the programming task below in a Python markdown code block.
A group of people played a game. All players had distinct scores, which are positive integers.
Takahashi knows N facts on the players' scores. The i-th fact is as follows: the A_i-th highest score among the players is B_i.
Find the maximum possible num... | {"inputs": ["3\n4 5\n2 9\n6 2", "3\n4 5\n2 9\n6 3", "3\n4 7\n2 9\n6 2", "3\n8 3\n2 14\n3 3", "5\n1 10\n3 6\n5 2\n4 4\n2 8", "2\n1 1000100000\n1000000000 1", "2\n1 1000100000\n1000000010 1", "2\n0 1000110010\n1000001010 1"], "outputs": ["8\n", "9\n", "8", "11\n", "7", "1000000001\n", "1000000011\n", "1000001011\n"]} | 317 | 236 |
coding | Solve the programming task below in a Python markdown code block.
In this challenge, the task is to debug the existing code to successfully execute all provided test files.
A number is called a smart number if it has an odd number of factors. Given some numbers, find whether they are smart numbers or not.
Debug the g... | {"inputs": ["4\n1\n2\n7\n169\n"], "outputs": ["YES\nNO\nNO\nYES\n"]} | 395 | 30 |
coding | Solve the programming task below in a Python markdown code block.
## Task
Generate a sorted list of all possible IP addresses in a network.
For a subnet that is not a valid IPv4 network return `None`.
## Examples
```
ipsubnet2list("192.168.1.0/31") == ["192.168.1.0", "192.168.1.1"]
ipsubnet2list("213.256.46.160/28")... | {"functional": "_inputs = [['192.168.1.0/31'], ['195.20.15.0/28'], ['174.0.153.152/29'], ['213.192.46.160/28'], ['213.256.46.160/28']]\n_outputs = [[['192.168.1.0', '192.168.1.1']], [['195.20.15.1', '195.20.15.2', '195.20.15.3', '195.20.15.4', '195.20.15.5', '195.20.15.6', '195.20.15.7', '195.20.15.8', '195.20.15.9', '... | 148 | 769 |
coding | Solve the programming task below in a Python markdown code block.
Your website is divided vertically in sections, and each can be of different size (height).
You need to establish the section index (starting at `0`) you are at, given the `scrollY` and `sizes` of all sections.
Sections start with `0`, so if first se... | {"functional": "_inputs = [[1, [300, 200, 400, 600, 100]], [299, [300, 200, 400, 600, 100]], [300, [300, 200, 400, 600, 100]], [1599, [300, 200, 400, 600, 100]], [1600, [300, 200, 400, 600, 100]]]\n_outputs = [[0], [0], [1], [4], [-1]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstan... | 282 | 314 |
coding | Solve the programming task below in a Python markdown code block.
As you know, majority of students and teachers of Summer Informatics School live in Berland for the most part of the year. Since corruption there is quite widespread, the following story is not uncommon.
Elections are coming. You know the number of vote... | {"inputs": ["1 1\n1 100\n", "1 1\n1 110\n", "1 2\n1 100\n", "1 259\n55 226621946\n", "1 654\n408 226621946\n", "1 3000\n61 226621946\n", "1 3000\n55 226621946\n", "1 522\n408 226621946\n"], "outputs": ["0\n", "0\n", "0\n", "226621946\n", "226621946\n", "226621946\n", "226621946\n", "226621946\n"]} | 521 | 223 |
coding | Solve the programming task below in a Python markdown code block.
The wide mouth frog is particularly interested in the eating habits of other creatures.
He just can't stop asking the creatures he encounters what they like to eat. But then he meet the alligator who just LOVES to eat wide-mouthed frogs!
When he meets ... | {"functional": "_inputs = [['toucan'], ['ant bear'], ['alligator']]\n_outputs = [['wide'], ['wide'], ['small']]\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... | 152 | 171 |
coding | Solve the programming task below in a Python markdown code block.
You are given $\textit{q}$ queries where each query consists of a set of $n$ points on a two-dimensional plane (i.e., $(x,y)$). For each set of points, print YES on a new line if all the points fall on the edges (i.e., sides and/or corners) of a non-dege... | {"inputs": ["2\n3\n0 0\n0 1\n1 0\n4\n0 0\n0 2\n2 0\n1 1\n"], "outputs": ["YES\nNO\n"]} | 461 | 48 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given an array prices where prices[i] is the price of a given stock on the ith day.
You want to maximize your profit by choosing a single day to buy one stock and choosing a different day in the future to sell... | {"functional": "def check(candidate):\n assert candidate([7,1,5,3,6,4]) == 5\n assert candidate(prices = [7,6,4,3,1]) == 0\n\n\ncheck(Solution().maxProfit)"} | 120 | 60 |
coding | Solve the programming task below in a Python markdown code block.
The government has invited bids from contractors to run canteens at all railway stations. Contractors will be allowed to bid for the catering contract at more than one station. However, to avoid monopolistic price-fixing, the government has declared that... | {"inputs": ["6\n10\n20\n25\n40\n30\n30\n4 5\n1 3\n3 4\n2 3\n6 4"], "outputs": ["90"]} | 517 | 51 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given a valid (IPv4) IP address, return a defanged version of that IP address.
A defanged IP address replaces every period "." with "[.]".
Please complete the following python code precisely:
```python
class Solutio... | {"functional": "def check(candidate):\n assert candidate(address = \"1.1.1.1\") == \"1[.]1[.]1[.]1\"\n assert candidate(address = \"255.100.50.0\") == \"255[.]100[.]50[.]0\"\n\n\ncheck(Solution().defangIPaddr)"} | 86 | 87 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
In some array arr, the values were in arithmetic progression: the values arr[i + 1] - arr[i] are all equal for every 0 <= i < arr.length - 1.
A value from arr was removed that was not the first or last value in the ar... | {"functional": "def check(candidate):\n assert candidate(arr = [5,7,11,13]) == 9\n assert candidate(arr = [15,13,12]) == 14\n\n\ncheck(Solution().missingNumber)"} | 114 | 59 |
coding | Solve the programming task below in a Python markdown code block.
# Task
You are given a car odometer which displays the miles traveled as an integer.
The odometer has a defect, however: it proceeds from digit `3` to digit `5` always skipping the digit `4`. This defect shows up in all positions (ones, tens, hundre... | {"functional": "_inputs = [[13], [15], [55], [2005], [1500], [999999], [165826622]]\n_outputs = [[12], [13], [40], [1462], [1053], [531440], [69517865]]\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 ... | 285 | 236 |
coding | Solve the programming task below in a Python markdown code block.
Chef and his friends are playing the game AMONG US. They all have chosen their names as numbers. There are N people in Chef’s group including him, and each swears that he is not the imposter. However, it turns out there were N+1 people in the game. Now a... | {"inputs": ["3\n4 2 5\n4 2 3 5"], "outputs": ["3"]} | 224 | 26 |
coding | Solve the programming task below in a Python markdown code block.
Brief
=====
Sometimes we need information about the list/arrays we're dealing with. You'll have to write such a function in this kata. Your function must provide the following informations:
* Length of the array
* Number of integer items in the array
... | {"functional": "_inputs = [[[1, 2, 3.33, 4, 5.01, 'bass', 'kick', ' ']], [[0.001, 2, ' ']], [[]], [[' ']], [[' ', ' ']], [['jazz']], [[4]], [[3.1416]], [[11, 22, 33.33, 44.44, 'hasan', 'ahmad']], [['a', 'b', 'c', 'd', ' ']], [[1, 2, 3, 4, 5, 6, 7, 8, 9]], [[1, 2.23, 'string', ' ']]]\n_outputs = [[[[8], [3], [2], [2], [... | 398 | 488 |
coding | Solve the programming task below in a Python markdown code block.
# Task
You are given a string `s`. Let's call its substring a group, if all letters in it are adjacent and the same(such as `"aa","bbb","cccc"`..). Let's call the substiring with 2 or more adjacent group a big group(such as `"aabb","bbccc"`...).
Your... | {"functional": "_inputs = [['ccccoodeffffiiighhhhhhhhhhttttttts'], ['soooooldieeeeeer'], ['ccccoooooooooooooooooooooooddee'], ['wwwwaaaarrioooorrrrr'], ['gztxxxxxggggggggggggsssssssbbbbbeeeeeeehhhmmmmmmmitttttttlllllhkppppp']]\n_outputs = [[3], [0], [1], [2], [2]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isi... | 366 | 243 |
coding | Solve the programming task below in a Python markdown code block.
Little Elephant loves magic squares very much.
A magic square is a 3 × 3 table, each cell contains some positive integer. At that the sums of integers in all rows, columns and diagonals of the table are equal. The figure below shows the magic square, th... | {"inputs": ["0 1 1\n1 0 1\n1 1 0\n", "0 3 6\n5 0 5\n4 7 0\n", "0 4 4\n4 0 4\n4 4 0\n", "0 7 6\n9 0 1\n4 3 0\n", "0 9 2\n3 0 7\n8 1 0\n", "0 4 4\n4 0 4\n4 4 0\n", "0 9 2\n3 0 7\n8 1 0\n", "0 7 6\n9 0 1\n4 3 0\n"], "outputs": ["1 1 1\n1 1 1\n1 1 1\n", "6 3 6\n5 5 5\n4 7 4\n", "4 4 4\n4 4 4\n4 4 4\n", "2 7 6\n9 5 1\n4 3 8... | 494 | 326 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given an n x n grid where you have placed some 1 x 1 x 1 cubes. Each value v = grid[i][j] represents a tower of v cubes placed on top of cell (i, j).
After placing these cubes, you have decided to glue any dir... | {"functional": "def check(candidate):\n assert candidate(grid = [[1,2],[3,4]]) == 34\n assert candidate(grid = [[1,1,1],[1,0,1],[1,1,1]]) == 32\n assert candidate(grid = [[2,2,2],[2,1,2],[2,2,2]]) == 46\n\n\ncheck(Solution().surfaceArea)"} | 147 | 96 |
coding | Solve the programming task below in a Python markdown code block.
Write a program which reads $n$ dices constructed in the same way as Dice I, and determines whether they are all different. For the determination, use the same way as Dice III.
Constraints
* $2 \leq n \leq 100$
* $0 \leq $ the integer assigned to a fac... | {"inputs": ["3\n1 2 3 4 5 6\n6 5 4 3 2 1\n5 4 0 2 1 6", "3\n1 2 3 4 5 6\n6 2 5 3 5 1\n6 5 4 3 2 1", "3\n1 2 3 4 5 6\n5 5 4 3 2 1\n5 4 0 2 1 6", "3\n1 2 3 4 5 6\n6 2 5 3 0 1\n6 5 4 3 2 1", "3\n1 2 3 3 5 6\n5 5 4 3 2 1\n5 4 0 2 1 6", "3\n1 4 3 4 5 6\n6 2 5 3 0 1\n6 5 4 3 2 1", "3\n1 2 3 3 5 6\n5 2 4 3 2 1\n5 4 0 2 1 6", ... | 246 | 350 |
coding | Solve the programming task below in a Python markdown code block.
Arcady is a copywriter. His today's task is to type up an already well-designed story using his favorite text editor.
Arcady types words, punctuation signs and spaces one after another. Each letter and each sign (including line feed) requires one keyboa... | {"inputs": ["aaa aaaaaa\n", "aaa aaaaaa\n", "aaa aabaaa\n", "aaa aaabaa\n", "aaa aaabab\n", "aaa baaaab\n", "'co-co-co, codeforces?!'\n", "'co-co-co, '!?secrofedoc\n"], "outputs": ["10\n", "10\n", "11\n", "10\n", "10\n", "11\n", "25\n", "25\n"]} | 610 | 112 |
coding | Solve the programming task below in a Python markdown code block.
Generate and return **all** possible increasing arithmetic progressions of six primes `[a, b, c, d, e, f]` between the given limits. Note: the upper and lower limits are inclusive.
An arithmetic progression is a sequence where the difference between con... | {"functional": "_inputs = [[0, 200], [90, 600], [770, 1000], [30, 305], [1000, 4000]]\n_outputs = [[[[7, 37, 67, 97, 127, 157]]], [[[107, 137, 167, 197, 227, 257], [359, 389, 419, 449, 479, 509]]], [[]], [[[107, 137, 167, 197, 227, 257]]], [[[1013, 1193, 1373, 1553, 1733, 1913], [1039, 1249, 1459, 1669, 1879, 2089], [1... | 243 | 1,221 |
coding | Solve the programming task below in a Python markdown code block.
Snuke has N hats. The i-th hat has an integer a_i written on it.
There are N camels standing in a circle. Snuke will put one of his hats on each of these camels.
If there exists a way to distribute the hats to the camels such that the following conditi... | {"inputs": ["3\n1 2 0", "3\n3 2 1", "3\n0 2 0", "3\n0 1 0", "3\n1 2 1", "3\n2 2 1", "3\n3 4 1", "3\n3 7 1"], "outputs": ["No\n", "Yes\n", "No\n", "No\n", "No\n", "No\n", "No\n", "No\n"]} | 388 | 110 |
coding | Solve the programming task below in a Python markdown code block.
Given an array of integers.
Return an array, where the first element is the count of positives numbers and the second element is sum of negative numbers.
If the input array is empty or null, return an empty array.
# Example
For input `[1, 2, 3, 4, 5,... | {"functional": "_inputs = [[[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -11, -12, -13, -14, -15]], [[0, 2, 3, 0, 5, 6, 7, 8, 9, 10, -11, -12, -13, -14]], [[1]], [[-1]], [[0, 0, 0, 0, 0, 0, 0, 0, 0]], [[]]]\n_outputs = [[[10, -65]], [[8, -50]], [[1, 0]], [[0, -1]], [[0, 0]], [[]]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if... | 151 | 321 |
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 target, return indices of the two numbers such that they add up to target.
You may assume that each input would have exactly one solution, and you may not use the same el... | {"functional": "def check(candidate):\n assert candidate(nums = [2,7,11,15], target = 9) == [0,1]\n assert candidate(nums = [3,2,4], target = 6) == [1,2]\n assert candidate(nums = [3,3], target = 6) == [0,1]\n\n\ncheck(Solution().twoSum)"} | 110 | 93 |
coding | Solve the programming task below in a Python markdown code block.
Chef has two integers X and Y. Chef wants to perform some operations to make X and Y equal. In one operation, Chef can either:
set X := X + 1
or set Y := Y + 2
Find the minimum number of operations required to make X and Y equal.
------ Input Format -... | {"inputs": ["5\n3 4\n5 5\n7 3\n5 2\n7 12\n"], "outputs": ["1\n0\n2\n3\n5\n\n"]} | 432 | 44 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given an integer array nums containing distinct numbers, and you can perform the following operations until the array is empty:
If the first element has the smallest value, remove it
Otherwise, put the first ... | {"functional": "def check(candidate):\n assert candidate(nums = [3,4,-1]) == 5\n assert candidate(nums = [1,2,4,3]) == 5\n assert candidate(nums = [1,2,3]) == 3\n\n\ncheck(Solution().countOperationsToEmptyArray)"} | 116 | 72 |
coding | Solve the programming task below in a Python markdown code block.
There are N strings of lowercase alphabet only. The i-th string is S_i. Every string is unique.
Provide answers for the Q queries below. The i-th query has the following format:
Query: An integer k_i and a string p_{i,1}p_{i,2}...p_{i,26} that results ... | {"inputs": ["5\naa\nabbaa\nabbba\naaab\naaaaaba\n5\n1 abcdefghijklmnopqrstuvwxyz\n2 bacdefghijklmnopqrstuvwxyz\n3 abcdefghijklmnopqrstuvwxyz\n4 bacdefghijklmnopqrsttvwxyz\n5 abcdefghijklmnopqrstuvwxyz", "5\naa\nabbaa\nabbba\naaab\naaaaaba\n5\n1 abcdefghijklmnopqrstuvwxyz\n2 bacdefghijklmnopqrstuvwxyz\n3 abcdefghijklmno... | 607 | 639 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given the root of a binary tree, return the postorder traversal of its nodes' values.
Please complete the following python code precisely:
```python
# Definition for a binary tree node.
# class TreeNode:
# def _... | {"functional": "def check(candidate):\n assert candidate(root = tree_node([1,None,2,3])) == [3,2,1]\n assert candidate(root = tree_node([])) == []\n assert candidate(root = tree_node([1])) == [1]\n\n\ncheck(Solution().postorderTraversal)"} | 122 | 72 |
coding | Solve the programming task below in a Python markdown code block.
For all x in the range of integers [0, 2 ** n), let y[x] be the binary exclusive-or of x and x // 2. Find the sum of all numbers in y.
Write a function sum_them that, given n, will return the value of the above sum.
This can be implemented a simple loo... | {"functional": "_inputs = [[0], [1], [2], [3], [4]]\n_outputs = [[0], [1], [6], [28], [120]]\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): ... | 176 | 182 |
coding | Solve the programming task below in a Python markdown code block.
Vasya owns three big integers — $a, l, r$. Let's define a partition of $x$ such a sequence of strings $s_1, s_2, \dots, s_k$ that $s_1 + s_2 + \dots + s_k = x$, where $+$ is a concatanation of strings. $s_i$ is the $i$-th element of the partition. For ex... | {"inputs": ["123\n0\n0\n", "123\n0\n0\n", "123\n0\n1\n", "135\n2\n4\n", "135\n4\n4\n", "135\n6\n4\n", "135\n6\n2\n", "135\n6\n5\n"], "outputs": ["0\n", "0", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n"]} | 531 | 117 |
coding | Solve the programming task below in a Python markdown code block.
Given two positive numbers B and C, what is the minimum positive value of A, such that A \cdot B is divisible by C.
Here, A \cdot B denotes the value obtained when A is multiplied by B.
------ Input Format ------
- The first line will contain an int... | {"inputs": ["2\n2 4\n8 12"], "outputs": ["2\n3"]} | 341 | 23 |
coding | Solve the programming task below in a Python markdown code block.
The chef is trying to solve some pattern problems, Chef wants your help to code it. Chef has one number K to form a new pattern. Help the chef to code this pattern problem.
-----Input:-----
- First-line will contain $T$, the number of test cases. Then t... | {"inputs": ["4\n1\n2\n3\n4"], "outputs": ["1\n21\n*1\n321\n*21\n**1\n4321\n*321\n**21\n***1"]} | 212 | 54 |
coding | Solve the programming task below in a Python markdown code block.
HELP! Jason can't find his textbook! It is two days before the test date, and Jason's textbooks are all out of order! Help him sort a list (ArrayList in java) full of textbooks by subject, so he can study before the test.
The sorting should **NOT** be c... | {"functional": "_inputs = [[['Algebra', 'History', 'Geometry', 'English']], [['Algebra', 'history', 'Geometry', 'english']], [['Alg#bra', '$istory', 'Geom^try', '**english']]]\n_outputs = [[['Algebra', 'English', 'Geometry', 'History']], [['Algebra', 'english', 'Geometry', 'history']], [['$istory', '**english', 'Alg#br... | 96 | 237 |
coding | Solve the programming task below in a Python markdown code block.
Vasya became interested in bioinformatics. He's going to write an article about similar cyclic DNA sequences, so he invented a new method for determining the similarity of cyclic sequences.
Let's assume that strings s and t have the same length n, then ... | {"inputs": ["1\nC\n", "1\nT\n", "1\nT\n", "1\nA\n", "1\nG\n", "1\nC\n", "2\nAG\n", "2\nAG\n"], "outputs": ["1\n", "1\n", "1\n", "1\n", "1\n", "1\n", "4\n", "4\n"]} | 736 | 86 |
coding | Solve the programming task below in a Python markdown code block.
Zurikela is creating a graph with a special graph maker. At the begining, it is empty and has no nodes or edges. He can perform $3$ types of operations:
$\mbox{A}$ $\boldsymbol{x}$: Create a set of $\boldsymbol{x}$ new nodes and name it $\boldsymbol... | {"inputs": ["8\nA 1\nA 2\nB 1 2\nC 1\nA 2\nA 3\nB 3 4\nB 4 5\n"], "outputs": ["5\n"]} | 680 | 52 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are playing a simplified PAC-MAN game on an infinite 2-D grid. You start at the point [0, 0], and you are given a destination point target = [xtarget, ytarget] that you are trying to get to. There are several ghos... | {"functional": "def check(candidate):\n assert candidate(ghosts = [[1,0],[0,3]], target = [0,1]) == True\n assert candidate(ghosts = [[1,0]], target = [2,0]) == False\n assert candidate(ghosts = [[2,0]], target = [1,0]) == False\n\n\ncheck(Solution().escapeGhosts)"} | 257 | 90 |
coding | Solve the programming task below in a Python markdown code block.
The chef is trying to decode some pattern problems, Chef wants your help to code it. Chef has one number K(odd) to form a new pattern. Help the chef to code this pattern problem.
-----Input:-----
- First-line will contain $T$, the number of test cases. ... | {"inputs": ["4\n1\n3\n5\n7"], "outputs": ["1\n111\n111\n111\n11111\n11 11\n1 1 1\n11 11\n11111\n1111111\n11 11\n1 1 1 1\n1 1 1\n1 1 1 1\n11 11\n1111111"]} | 277 | 116 |
coding | Solve the programming task below in a Python markdown code block.
One day Misha and Andrew were playing a very simple game. First, each player chooses an integer in the range from 1 to n. Let's assume that Misha chose number m, and Andrew chose number a.
Then, by using a random generator they choose a random integer c... | {"inputs": ["3 1\n", "4 3\n", "5 5\n", "1 1\n", "1 1\n", "2 1\n", "2 2\n", "3 1\n"], "outputs": ["2", "2", "4", "1", "1", "2", "1", "2"]} | 446 | 78 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
The k-beauty of an integer num is defined as the number of substrings of num when it is read as a string that meet the following conditions:
It has a length of k.
It is a divisor of num.
Given integers num and k, re... | {"functional": "def check(candidate):\n assert candidate(num = 240, k = 2) == 2\n assert candidate(num = 430043, k = 2) == 2\n\n\ncheck(Solution().divisorSubstrings)"} | 139 | 62 |
coding | Solve the programming task below in a Python markdown code block.
You are given two positive integers $A$ and $B$. Find the number of pairs of positive integers $(X, Y)$ such that $1 \le X \le A$, $1 \le Y \le B$ and $X + Y$ is even.
-----Input-----
- The first line of the input contains a single integer $T$ denoting ... | {"inputs": ["4\n1 1\n2 3\n4 6\n8 9"], "outputs": ["1\n3\n12\n36"]} | 274 | 36 |
coding | Solve the programming task below in a Python markdown code block.
problem
I want to put as many rectangular tiles as possible on a rectangular wall with a size of $ h $ in height and $ w $ in width, and a size of $ a $ in height and $ b $ in width.
The following conditions must be met when attaching tiles.
* Do not... | {"inputs": ["5 8\n3 2", "5 8\n6 2", "6 8\n6 3", "5 8\n1 3", "1 7\n2 6", "5 8\n2 2", "12 8\n6 3", "12 8\n9 3"], "outputs": ["16\n", "40\n", "12\n", "10\n", "7\n", "8", "24\n", "42\n"]} | 189 | 117 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given an integer array nums. A subsequence of nums is called a square streak if:
The length of the subsequence is at least 2, and
after sorting the subsequence, each element (except the first element) is the ... | {"functional": "def check(candidate):\n assert candidate(nums = [4,3,6,16,8,2]) == 3\n assert candidate(nums = [2,3,5,6,7]) == -1\n\n\ncheck(Solution().longestSquareStreak)"} | 156 | 65 |
coding | Solve the programming task below in a Python markdown code block.
Alice and Bob were playing a game yet again but this time, Bob already lost the game. Now he wants to take revenge.
Bob saw a jigsaw puzzle which was solved by Alice and decided to jumble the puzzle pieces again. There are N puzzle pieces in a line numb... | {"inputs": ["4\n7 3\n1 4\n8 2\n5 3\n"], "outputs": ["21\n0\n22\n10\n"]} | 606 | 39 |
coding | Solve the programming task below in a Python markdown code block.
On Bertown's main street n trees are growing, the tree number i has the height of ai meters (1 ≤ i ≤ n). By the arrival of the President of Berland these trees were decided to be changed so that their heights formed a beautiful sequence. This means that ... | {"inputs": ["1\n511\n", "1\n909\n", "1\n587\n", "1\n645\n", "1\n637\n", "1\n731\n", "1\n211\n", "1\n2727\n"], "outputs": ["0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n"]} | 465 | 103 |
coding | Solve the programming task below in a Python markdown code block.
Complete the function that takes 3 numbers `x, y and k` (where `x ≤ y`), and returns the number of integers within the range `[x..y]` (both ends included) that are divisible by `k`.
More scientifically: `{ i : x ≤ i ≤ y, i mod k = 0 }`
## Example
Gi... | {"functional": "_inputs = [[6, 11, 2], [11, 345, 17], [0, 1, 7], [20, 20, 2], [20, 20, 8], [19, 20, 2], [0, 10, 1], [11, 14, 2], [101, 9999999999999999999999999999999999999999999, 11], [1005, 9999999999999999999999999999999999999999999, 109]]\n_outputs = [[3], [20], [1], [1], [0], [1], [11], [2], [909090909090909090909... | 198 | 458 |
coding | Solve the programming task below in a Python markdown code block.
An array of integers $p_1, p_2, \dots, p_n$ is called a permutation if it contains each number from $1$ to $n$ exactly once. For example, the following arrays are permutations: $[3, 1, 2]$, $[1]$, $[1, 2, 3, 4, 5]$ and $[4, 3, 1, 2]$. The following array... | {"inputs": ["2\n0\n", "2\n1\n", "2\n0\n", "2\n1\n", "2\n2\n", "2\n4\n", "2\n3\n", "2\n7\n"], "outputs": ["-1\n", "1 2 ", "-1\n", "1 2 ", "-1\n", "-1\n", "-1\n", "-1\n"]} | 452 | 89 |
coding | Solve the programming task below in a Python markdown code block.
You're hanging out with your friends in a bar, when suddenly one of them is so drunk, that he can't speak, and when he wants to say something, he writes it down on a paper. However, none of the words he writes make sense to you. He wants to help you, so ... | {"functional": "_inputs = [['yvvi'], ['Blf zoivzwb szw 10 yvvih'], [\"Ovg'h hdrn rm gsv ulfmgzrm!\"], [{'brand': 'Starobrno'}], [\"Tl slnv, blf'iv wifmp\"], [\"Hfiv r xzm wzmxv lm xlk'h xzi, slow nb yvvi\"], [True], [\"Hvv? R'n mlg gszg wifmp, r xzm hgroo gzpv nb xolgsvh luu\"], [123], [['Beer']]]\n_outputs = [['beer']... | 183 | 379 |
coding | Solve the programming task below in a Python markdown code block.
You are given a binary string $s$.
Find the number of distinct cyclical binary strings of length $n$ which contain $s$ as a substring.
The cyclical string $t$ contains $s$ as a substring if there is some cyclical shift of string $t$, such that $s$ is a... | {"inputs": ["2\n0\n", "1\n1\n", "5\n1\n", "1\n0\n", "5\n1\n", "1\n0\n", "1\n1\n", "2\n0\n"], "outputs": ["3", "1", "31", "1", "31\n", "1\n", "1\n", "3\n"]} | 415 | 84 |
coding | Solve the programming task below in a Python markdown code block.
You are given a positive integer $n$. Your task is to find any three integers $a$, $b$ and $c$ ($0 \le a, b, c \le 10^9$) for which $(a\oplus b)+(b\oplus c)+(a\oplus c)=n$, or determine that there are no such integers.
Here $a \oplus b$ denotes the bitw... | {"inputs": ["5\n4\n1\n12\n2046\n194723326\n"], "outputs": ["0 2 2\n-1\n0 6 6\n0 1023 1023\n0 97361663 97361663\n"]} | 484 | 81 |
coding | Solve the programming task below in a Python markdown code block.
A function receives a certain numbers of integers ```n1, n2, n3 ..., np```(all positive and different from 0) and a factor ```k, k > 0```
The function rearranges the numbers ```n1, n2, ..., np``` in such order that generates the minimum number concatena... | {"functional": "_inputs = [[4, 32, 3, 34, 7, 12], [10, 32, 3, 34, 7, 12]]\n_outputs = [['Rearrangement: 12, 3, 34, 7, 32 generates: 12334732 divisible by 4'], ['There is no possible rearrangement']]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return math.is... | 477 | 239 |
coding | Solve the programming task below in a Python markdown code block.
Read problems statements in Mandarin chinese, Russian and Vietnamese as well.
There are N minions who are competing in an election of the president of the ACM (Association of Cute Minions). They are standing in a line in the order from minion 1 to mini... | {"inputs": ["2\n4\n4 3 2 1\n5\n1 2 2 3 1"], "outputs": ["1 2 3 2\n2 3 2 3 1"]} | 526 | 50 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Seven different symbols represent Roman numerals with the following values:
Symbol
Value
I
1
V
5
X
10
L
50
C
100
D
500
M
1000
Roman numerals are formed by appending the conversions of decimal pla... | {"functional": "def check(candidate):\n assert candidate(num = 3) == \"III\"\n assert candidate(num = 4) == \"IV\"\n assert candidate(num = 9) == \"IX\"\n assert candidate(num = 58) == \"LVIII\"\n assert candidate(num = 1994) == \"MCMXCIV\"\n\n\ncheck(Solution().intToRoman)"} | 388 | 93 |
coding | Solve the programming task below in a Python markdown code block.
You are given two binary strings $a$ and $b$ of the same length. You can perform the following two operations on the string $a$:
Swap any two bits at indices $i$ and $j$ respectively ($1 \le i, j \le n$), the cost of this operation is $|i - j|$, that ... | {"inputs": ["1\n0\n1\n", "1\n1\n1\n", "1\n1\n1\n", "1\n0\n1\n", "2\n10\n01\n", "2\n10\n00\n", "2\n10\n01\n", "2\n10\n00\n"], "outputs": ["1\n", "0\n", "0\n", "1\n", "1\n", "1\n", "1\n", "1\n"]} | 500 | 110 |
coding | Solve the programming task below in a Python markdown code block.
In a bizarre game of chess ,knight was so drunk, that instead of his usual move he started walking straight. In every move Knight jumps on 2n steps forward (n is number of block that he had travelled so far from starting) but after that he has to take ei... | {"inputs": ["2\n17\n10"], "outputs": ["2111\n0"]} | 342 | 23 |
coding | Solve the programming task below in a Python markdown code block.
Chef likes prime numbers. However, there is one thing he loves even more. Of course, it's semi-primes! A semi-prime number is an integer which can be expressed as a product of two distinct primes. For example, $15 = 3 \cdot 5$ is a semi-prime number, but... | {"inputs": ["3\n30\n45\n62\n"], "outputs": ["YES\nYES\nNO"]} | 381 | 26 |
coding | Solve the programming task below in a Python markdown code block.
Little Artem has invented a time machine! He could go anywhere in time, but all his thoughts of course are with computer science. He wants to apply this time machine to a well-known data structure: multiset.
Artem wants to create a basic multiset of int... | {"inputs": ["3\n1 1 1\n2 2 1\n3 3 1\n", "3\n1 1 1\n2 2 1\n3 3 1\n", "6\n1 1 5\n3 5 5\n1 2 5\n3 6 5\n2 3 5\n3 7 5\n", "6\n1 1 5\n3 5 5\n1 2 0\n3 6 5\n2 3 5\n3 7 5\n", "6\n1 1 5\n3 5 5\n1 2 0\n3 6 2\n2 3 5\n3 7 5\n", "6\n1 1 5\n3 5 5\n1 2 0\n2 6 2\n2 3 5\n3 7 5\n", "6\n1 1 5\n3 4 5\n1 2 0\n2 6 2\n2 3 6\n3 7 5\n", "6\n1 1... | 706 | 342 |
coding | Solve the programming task below in a Python markdown code block.
You are given n positive integers a_1, a_2, ..., a_{n}.
For every a_{i} you need to find a positive integer k_{i} such that the decimal notation of 2^{k}_{i} contains the decimal notation of a_{i} as a substring among its last min(100, length(2^{k}_{i})... | {"inputs": ["2\n8\n2\n", "2\n1\n2\n", "2\n8\n2\n", "2\n14\n2\n", "2\n14\n3\n", "2\n3\n4857\n", "2\n1\n4857\n", "2\n3\n4857\n"], "outputs": ["3\n1\n", "9\n1\n", "3\n1\n", "18\n1\n", "18\n5\n", "5\n20\n", "9\n20\n", "5\n20\n"]} | 339 | 134 |
coding | Solve the programming task below in a Python markdown code block.
Read problem statements in [Mandarin Chinese] and [Vietnamese] as well.
Chef placed $N$ boxes (numbered $1$ through $N$) in a straight line. For each valid $i$, the $i$-th box contains $A_{i}$ balls.
Then, Chef painted the boxes using $M$ distinct col... | {"inputs": ["1 \n4 2 \n10 20 15 28"], "outputs": ["5"]} | 576 | 32 |
coding | Solve the programming task below in a Python markdown code block.
Mr. Pr and Ms. Ad are at $a$ and $b$ respectively on an infinite number line. Mr. Pr wants to meet Ms. Ad.
Mr. Pr can choose to move $c$ or $d$ units in 1 second. If Mr. Pr moves $c$ units then Ms. Ad will move $d$ units and vice versa. (Both of them al... | {"inputs": ["2\n3 4 1 2\n10 20 3 7"], "outputs": ["YES\nNO"]} | 350 | 32 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given two integer arrays inorder and postorder where inorder is the inorder traversal of a binary tree and postorder is the postorder traversal of the same tree, construct and return the binary tree.
Please complete... | {"functional": "def check(candidate):\n assert is_same_tree(candidate(inorder = [9,3,15,20,7], postorder = [9,15,7,20,3]), tree_node([3,9,20,None,None,15,7]))\n assert is_same_tree(candidate(inorder = [-1], postorder = [-1]), tree_node([-1]))\n\n\ncheck(Solution().buildTree)"} | 145 | 101 |
coding | Solve the programming task below in a Python markdown code block.
Team RCB has earned X points in the games it has played so far in this year's IPL. To qualify for the playoffs they must earn at least a total of Y points. They currently have Z games left, in each game they earn 2 points for a win, 1 point for a draw, a... | {"inputs": ["3\n4 10 8\n3 6 1 \n4 8 2 "], "outputs": ["YES\nNO\nYES\n"]} | 444 | 38 |
coding | Solve the programming task below in a Python markdown code block.
Hey CodeWarrior,
we've got a lot to code today!
I hope you know the basic string manipulation methods, because this kata will be all about them.
Here we go...
## Background
We've got a very long string, containing a bunch of User IDs. This string is... | {"functional": "_inputs = [['uid12345'], [' uidabc '], ['#uidswagger'], ['uidone, uidtwo'], ['uidCAPSLOCK'], ['uid##doublehashtag'], [' uidin name whitespace'], ['uidMultipleuid'], ['uid12 ab, uid#, uidMiXeDcHaRs'], [' uidT#e#S#t# ']]\n_outputs = [[['12345']], [['abc']], [['swagger']], [['one', 'two']], [['capslock... | 497 | 281 |
coding | Solve the programming task below in a Python markdown code block.
Hacker Zhorik wants to decipher two secret messages he intercepted yesterday. Yeah message is a sequence of encrypted blocks, each of them consists of several bytes of information.
Zhorik knows that each of the messages is an archive containing one or m... | {"inputs": ["1 1\n1\n1\n", "1 1\n1\n1\n", "1 1\n2\n2\n", "1 2\n2\n1 1\n", "1 2\n2\n1 1\n", "2 2\n1 1\n1 1\n", "2 2\n2 3\n4 1\n", "2 2\n2 3\n3 2\n"], "outputs": ["1\n", "1\n", "1\n", "1\n", "1\n", "2\n", "1\n", "1\n"]} | 742 | 134 |
coding | Solve the programming task below in a Python markdown code block.
Alice and Bob have invented a new game. They have a rooted tree having N nodes (rooted at node 1), and the i^{th} node has the value A_{i} associated with it (1-indexed). The value associated with the root node is 0.
They start with a marker at the root... | {"inputs": ["3\n3 1\n0 1 2\n1 2\n1 3\n4 0\n0 1 2 3\n1 2\n1 3\n2 4\n7 0\n0 2 1 4 2 7 3\n1 2\n1 3\n2 4\n2 5\n3 6\n3 7\n"], "outputs": ["1\n2\n6\n"]} | 693 | 102 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given a 0-indexed array of strings words. Each string consists of lowercase English letters only. No letter occurs more than once in any string of words.
Two strings s1 and s2 are said to be connected if the s... | {"functional": "def check(candidate):\n assert candidate(words = [\"a\",\"b\",\"ab\",\"cde\"]) == [2,3]\n assert candidate(words = [\"a\",\"ab\",\"abc\"]) == [1,3]\n\n\ncheck(Solution().groupStrings)"} | 308 | 64 |
coding | Solve the programming task below in a Python markdown code block.
You are given an integer $n$ and an integer $k$.
In one step you can do one of the following moves: decrease $n$ by $1$; divide $n$ by $k$ if $n$ is divisible by $k$.
For example, if $n = 27$ and $k = 3$ you can do the following steps: $27 \rightar... | {"inputs": ["1\n2 99\n", "1\n2 99\n", "1\n1 75\n", "1\n2 75\n", "1\n2 52\n", "1\n1 14\n", "1\n2 60\n", "1\n99 99\n"], "outputs": ["2\n", "2\n", "1\n", "2\n", "2\n", "1\n", "2\n", "2\n"]} | 387 | 111 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.