problem stringlengths 14 4.09k | solution stringlengths 1 802k | task_type stringclasses 3
values | problem_tokens int64 5 895 |
|---|---|---|---|
Solve the programming task below in a Python markdown code block.
A post on facebook is said to be more *popular* if the number of likes on the post is strictly greater than the number of likes on some other post. In case the number of likes is same, the post having more comments is more *popular*.
Given arrays A and ... | {"inputs": ["4\n3\n5 4 4\n1 2 3\n3\n10 10 9\n2 5 4\n3\n3 3 9\n9 1 3\n4\n2 8 1 5\n2 8 1 9\n"], "outputs": ["1\n2\n3\n2\n"]} | coding | 642 |
Solve the programming task below in a Python markdown code block.
The stardate is 1977 and the science and art of detecting Death Stars is in its infancy. Princess Heidi has received information about the stars in the nearby solar system from the Rebel spies and now, to help her identify the exact location of the Death... | {"inputs": ["1\nO\nO\n", "1\nX\nO\n", "1\nO\nO\n", "1\nX\nO\n", "2\nXX\nOO\nXO\nOX\n", "2\nOX\nXX\nOX\nXX\n", "2\nOX\nXO\nXO\nOX\n", "2\nOX\nOX\nXX\nOX\n"], "outputs": ["Yes\n", "No\n", "Yes\n", "No\n", "No\n", "Yes\n", "Yes\n", "No\n"]} | coding | 449 |
Solve the programming task below in a Python markdown code block.
Polycarp doesn't like integers that are divisible by $3$ or end with the digit $3$ in their decimal representation. Integers that meet both conditions are disliked by Polycarp, too.
Polycarp starts to write out the positive (greater than $0$) integers w... | {"inputs": ["1\n5\n", "1\n5\n", "1\n2\n", "1\n3\n", "1\n6\n", "1\n1\n", "1\n4\n", "1\n8\n"], "outputs": ["7\n", "7\n", "2\n", "4\n", "8\n", "1\n", "5\n", "11\n"]} | coding | 302 |
Solve the programming task below in a Python markdown code block.
You are given an integer sequence of length n+1, a_1,a_2,...,a_{n+1}, which consists of the n integers 1,...,n.
It is known that each of the n integers 1,...,n appears at least once in this sequence.
For each integer k=1,...,n+1, find the number of the d... | {"inputs": ["1\n1 1", "1\n1 1\n", "3\n1 3 1 3", "3\n1 0 0 2", "3\n1 3 2 1", "3\n1 3 1 2", "3\n1 0 1 2", "3\n1 0 1 0"], "outputs": ["1\n1", "1\n1\n", "3\n5\n4\n1\n", "3\n4\n3\n1\n", "3\n6\n4\n1\n", "3\n5\n4\n1\n", "3\n5\n4\n1\n", "3\n5\n4\n1\n"]} | coding | 492 |
Solve the programming task below in a Python markdown code block.
There is a kangaroo at coordinate 0 on an infinite number line that runs from left to right, at time 0.
During the period between time i-1 and time i, the kangaroo can either stay at his position, or perform a jump of length exactly i to the left or to t... | {"inputs": ["6\n", "2\n", "11\n"], "outputs": ["3\n", "2\n", "5\n"]} | coding | 232 |
Solve the programming task below in a Python markdown code block.
Read problems statements in Mandarin Chinese and Russian.
Sereja have an array that consist of n integers a[1], a[2], ..., a[n]. Now Sereja want to delete some(possible none, but not all) elements from the array, such that arithmetical mean of all rema... | {"inputs": ["2\n1\n1\n4\n1 2 1 2"], "outputs": ["1\n3"]} | coding | 291 |
Solve the programming task below in a Python markdown code block.
Zonal Computing Olympiad 2012, 26 Nov 2011
We consider sequences of opening and closing brackets with two types of brackets, () and []. A bracket sequence is well-bracketed if we can pair up each opening bracket with a matching closing bracket in the u... | {"inputs": ["14\n1 1 3 4 2 2 3 3 3 1 2 4 4 4"], "outputs": ["2 6 8"]} | coding | 649 |
Solve the programming task below in a Python markdown code block.
You are required to create a simple calculator that returns the result of addition, subtraction, multiplication or division of two numbers.
Your function will accept three arguments:
The first and second argument should be numbers.
The third argument sh... | {"functional": "_inputs = [[6, 2, '+'], [4, 3, '-'], [5, 5, '*'], [5, 4, '/'], [6, '$', '+'], [6, 2, '&'], [4, 3, '\\\\'], ['a', 3, '+'], [6, 2, '='], [6, 2, '\\t'], [':', ',', '+']]\n_outputs = [[8], [1], [25], [1.25], ['unknown value'], ['unknown value'], ['unknown value'], ['unknown value'], ['unknown value'], ['unk... | coding | 188 |
Solve the programming task below in a Python markdown code block.
A priority queue is a data structure which maintains a set $S$ of elements, each of with an associated value (key), and supports the following operations:
* $insert(S, k)$: insert an element $k$ into the set $S$
* $extractMax(S)$: remove and return the ... | {"inputs": ["insert 8\ninsert 0\nextract\ninsert 4\nextract\ninsert 9\nextract\nextract\nend", "insert 8\ninsert 0\nextract\ninsert 5\nextract\ninsert 2\nextract\nextract\nend", "insert 8\ninsert 0\nextract\ninsert 7\nextract\ninsert 9\nextract\nextract\nend", "insert 8\ninsert 1\nextract\ninsert 5\nextract\ninsert 2\n... | coding | 303 |
Solve the programming task below in a Python markdown code block.
The Hedgehog recently remembered one of his favorite childhood activities, — solving puzzles, and got into it with new vigor. He would sit day in, day out with his friend buried into thousands of tiny pieces of the picture, looking for the required items... | {"inputs": ["1 1\nC\n", "1 1\nZ\n", "2 2\nCC\nBB\n", "2 2\nAB\nCD\n", "2 2\nML\nWQ\n", "2 2\nAB\nDD\n", "2 4\nABAA\nABBB\n", "2 4\nAAAA\nABBB\n"], "outputs": ["1\n1 1\n", "1\n1 1\n", "2\n1 2\n", "4\n1 1\n", "4\n1 1\n", "3\n1 2\n", "2\n1 4\n", "3\n1 4\n"]} | coding | 554 |
Solve the programming task below in a Python markdown code block.
A gene is represented as a string of length $n$ (where $n$ is divisible by $4$), composed of the letters $\mbox{A}$, $\mbox{C}$, $\textbf{T}$, and $\mbox{G}$.
It is considered to be steady if each of the four letters occurs exactly $\frac{n}{4}$ times. ... | {"inputs": ["8 \nGAAATAAA\n"], "outputs": ["5\n"]} | coding | 615 |
Solve the programming task below in a Python markdown code block.
Heidi has finally found the mythical Tree of Life – a legendary combinatorial structure which is said to contain a prophecy crucially needed to defeat the undead armies.
On the surface, the Tree of Life is just a regular undirected tree well-known from ... | {"inputs": ["2\n1 2\n", "2\n1 2\n", "2\n2 1\n", "3\n2 1\n3 2\n", "3\n2 1\n3 2\n", "3\n2 1\n3 1\n", "4\n1 2\n1 3\n1 4\n", "4\n1 2\n2 3\n1 4\n"], "outputs": ["0", "0\n", "0\n", "1", "1\n", "1\n", "3", "2\n"]} | coding | 364 |
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"]} | coding | 382 |
Solve the programming task below in a Python markdown code block.
The season for Snuke Festival has come again this year. First of all, Ringo will perform a ritual to summon Snuke. For the ritual, he needs an altar, which consists of three parts, one in each of the three categories: upper, middle and lower.
He has N p... | {"inputs": ["2\n1 5\n2 4\n2 6", "2\n2 5\n2 4\n2 6", "2\n0 5\n2 4\n2 6", "2\n0 5\n2 4\n2 5", "2\n0 5\n2 4\n2 3", "2\n1 5\n2 4\n3 6", "2\n0 10\n2 4\n2 3", "2\n0 12\n2 4\n2 3"], "outputs": ["2\n", "1\n", "2\n", "2\n", "1\n", "3", "1\n", "1\n"]} | coding | 477 |
Solve the programming task below in a Python markdown code block.
How many different ways can you make change for an amount, given a list of coins? In this problem, your code will need to efficiently compute the answer.
Task
Write a program that, given
An amount N and types of infinite available coins M.
A list of ... | {"inputs": ["4 3\n1 2 3", "240 23\n23 20 35 42 19 3 34 9 28 38 13 41 26 14 27 39 24 37 46 29 43 1 21", "250 26\n8 47 13 24 25 31 32 35 3 19 40 48 1 4 17 38 22 30 33 15 44 46 36 9 20 49"], "outputs": ["4", "127101770", "3542323427"]} | coding | 319 |
Solve the programming task below in a Python markdown code block.
Ayrat has number n, represented as it's prime factorization p_{i} of size m, i.e. n = p_1·p_2·...·p_{m}. Ayrat got secret information that that the product of all divisors of n taken modulo 10^9 + 7 is the password to the secret data base. Now he wants t... | {"inputs": ["2\n2 3\n", "2\n2 5\n", "2\n2 2\n", "2\n3 2\n", "2\n3 3\n", "2\n3 5\n", "2\n5 5\n", "2\n5 3\n"], "outputs": ["36\n", "100\n", "8\n", "36\n", "27\n", "225\n", "125\n", "225\n"]} | coding | 341 |
Solve the programming task below in a Python markdown code block.
You work as a system administrator in a dormitory, which has $n$ rooms one after another along a straight hallway. Rooms are numbered from $1$ to $n$.
You have to connect all $n$ rooms to the Internet.
You can connect each room to the Internet directly... | {"inputs": ["1 1\n0\n", "1 1\n1\n", "1 1\n0\n", "1 1\n1\n", "1 0\n1\n", "1 0\n0\n", "4 1\n0011\n", "4 2\n0011\n"], "outputs": ["1\n", "1\n", "1\n", "1\n", "1\n", "1\n", "4\n", "3\n"]} | coding | 673 |
Solve the programming task below in a Python markdown code block.
Vasya is sitting on an extremely boring math class. To have fun, he took a piece of paper and wrote out n numbers on a single line. After that, Vasya began to write out different ways to put pluses ("+") in the line between certain digits in the line so ... | {"inputs": ["1 0\n5\n", "1 0\n5\n", "3 1\n108\n", "3 2\n108\n", "3 1\n159\n", "3 1\n177\n", "3 1\n297\n", "3 1\n196\n"], "outputs": ["5", "5\n", "27", "9", "84\n", "102\n", "135\n", "122\n"]} | coding | 452 |
Solve the programming task below in a Python markdown code block.
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without ... | {"inputs": ["3 0\n", "2 1\n", "1 9\n", "1 0\n", "1 1\n", "1 2\n", "1 8\n", "2 0\n"], "outputs": ["-1 -1\n", "10 10\n", "9 9\n", "0 0\n", "1 1\n", "2 2\n", "8 8\n", "-1 -1\n"]} | coding | 200 |
Solve the programming task below in a Python markdown code block.
There are N different types of colours numbered from 1 to N. Chef has A_{i} balls having colour i, (1≤ i ≤ N).
Chef will arrange some boxes and put each ball in exactly one of those boxes.
Find the minimum number of boxes Chef needs so that no box con... | {"inputs": ["3\n2\n8 5\n3\n5 10 15\n4\n4 4 4 4\n"], "outputs": ["8\n15\n4\n"]} | coding | 537 |
Solve the programming task below in a Python markdown code block.
You are living on an infinite plane with the Cartesian coordinate system on it. In one move you can go to any of the four adjacent points (left, right, up, down).
More formally, if you are standing at the point $(x, y)$, you can:
go left, and move to $... | {"inputs": ["1\n4\n0 -1\n0 -2\n0 -3\n0 -4\n", "2\n3\n-6 0\n6 0\n0 -7\n3\n0 -6\n1 0\n0 3\n", "2\n3\n-2 0\n0 -5\n0 -1\n3\n3 0\n-2 0\n0 1\n", "3\n4\n0 -2\n1 0\n-1 0\n0 2\n3\n0 2\n-3 0\n0 -1\n1\n0 0\n"], "outputs": ["8\n", "38\n20\n", "14\n12\n", "12\n12\n0\n"]} | coding | 737 |
Solve the programming task below in a Python markdown code block.
In Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures.
City i is established in year Y_i and belongs to Prefecture P_i.
You can assume that there are no multiple cities that are established in the same ... | {"inputs": ["1 1\n1 852958660\n", "2 3\n1 32\n2 63\n1 6", "4 3\n2 5\n2 49\n2 12", "4 3\n2 5\n4 49\n1 12", "2 3\n2 4\n1 7\n2 528", "5 2\n1 63\n4 63\n0 9", "2 3\n1 32\n2 63\n1 4", "2 3\n2 39\n2 0\n1 12"], "outputs": ["000001000001\n", "000001000002\n000002000001\n000001000001\n", "000002000001\n000002000003\n000002000002... | coding | 504 |
Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given a string columnTitle that represents the column title as appears in an Excel sheet, return its corresponding column number.
For example:
A -> 1
B -> 2
C -> 3
...
Z -> 26
AA -> 27
AB -> 28
...
Please complet... | {"functional": "def check(candidate):\n assert candidate(columnTitle = \"A\") == 1\n assert candidate(columnTitle = \"AB\") == 28\n assert candidate(columnTitle = \"ZY\") == 701\n\n\ncheck(Solution().titleToNumber)"} | coding | 110 |
Solve the programming task below in a Python markdown code block.
For an upcoming programming contest, Roy is forming some teams from the students of his university. A team can have any number of contestants.
Roy knows the skill level of each contestant. To make the teams work as a unit, he forms the teams based on s... | {"inputs": ["4 \n7 4 5 2 3 -4 -3 -5 \n1 -4 \n4 3 2 3 1 \n7 1 -2 -3 -4 2 0 -1 \n"], "outputs": ["3\n1\n1\n7\n"]} | coding | 707 |
Solve the programming task below in a Python markdown code block.
There is a rectangle in the xy-plane, with its lower left corner at (0, 0) and its upper right corner at (W, H). Each of its sides is parallel to the x-axis or y-axis. Initially, the whole region within the rectangle is painted white.
Snuke plotted N poi... | {"inputs": ["5 4 2\n2 1 1\n6 3 4", "5 4 2\n2 1 2\n6 3 4", "5 4 1\n2 1 2\n6 3 4", "8 4 2\n0 1 3\n6 3 4", "5 7 1\n2 2 2\n6 0 4", "6 5 2\n2 2 1\n3 0 1", "5 4 2\n2 1 2\n1 3 4", "5 4 2\n2 2 2\n1 3 4"], "outputs": ["9\n", "6\n", "8\n", "16\n", "14\n", "15\n", "6\n", "6\n"]} | coding | 558 |
Solve the programming task below in a Python markdown code block.
A [Narcissistic Number](https://en.wikipedia.org/wiki/Narcissistic_number) is a positive number which is the sum of its own digits, each raised to the power of the number of digits in a given base. In this Kata, we will restrict ourselves to decimal (bas... | {"functional": "_inputs = [[1], [5], [7], [153], [370], [371], [1634]]\n_outputs = [[True], [True], [True], [True], [True], [True], [True]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return math.isclose(a, b, rel_tol=tol, abs_tol=tol)\n if isinstance(a,... | coding | 263 |
Solve the programming task below in a Python markdown code block.
Leha decided to move to a quiet town Vičkopolis, because he was tired by living in Bankopolis. Upon arrival he immediately began to expand his network of hacked computers. During the week Leha managed to get access to n computers throughout the town. Inc... | {"inputs": ["1\n2\n", "1\n2\n", "1\n0\n", "1\n1\n", "1\n-1\n", "1\n-2\n", "1\n-3\n", "1\n-4\n"], "outputs": ["0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n"]} | coding | 702 |
Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given two integers num1 and num2, return the sum of the two integers.
Please complete the following python code precisely:
```python
class Solution:
def sum(self, num1: int, num2: int) -> int:
``` | {"functional": "def check(candidate):\n assert candidate(num1 = 12, num2 = 5) == 17\n assert candidate(num1 = -10, num2 = 4) == -6\n\n\ncheck(Solution().sum)"} | coding | 69 |
Please solve the programming task below using a self-contained code snippet in a markdown code block.
Find all valid combinations of k numbers that sum up to n such that the following conditions are true:
Only numbers 1 through 9 are used.
Each number is used at most once.
Return a list of all possible valid combina... | {"functional": "def check(candidate):\n assert candidate(k = 3, n = 7) == [[1,2,4]]\n assert candidate(k = 3, n = 9) == [[1,2,6],[1,3,5],[2,3,4]]\n assert candidate(k = 4, n = 1) == []\n\n\ncheck(Solution().combinationSum3)"} | coding | 121 |
Solve the programming task below in a Python markdown code block.
You've got a bunch of textual data with embedded phone numbers. Write a function `area_code()` that finds and returns just the area code portion of the phone number.
```python
>>> message = "The supplier's phone number is (555) 867-5309"
>>> area_code(me... | {"functional": "_inputs = [[\"The supplier's phone number is (555) 867-5309\"], [\"Grae's cell number used to be (123) 456-7890\"], [\"The 102nd district court's fax line is (124) 816-3264\"]]\n_outputs = [['555'], ['123'], ['124']]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(... | coding | 156 |
Solve the programming task below in a Python markdown code block.
A tutorial for this problem is now available on our blog. Click here to read it.
You are asked to calculate factorials of some small positive integers.
------ Input ------
An integer t, 1≤t≤100, denoting the number of testcases, followed by t lines... | {"inputs": ["4\n1\n2\n5\n3", "4\n2\n2\n5\n3", "4\n2\n2\n5\n6", "4\n2\n2\n8\n6", "4\n2\n2\n2\n6", "4\n1\n2\n2\n6", "4\n1\n2\n2\n9", "4\n2\n2\n2\n9"], "outputs": ["1\n2\n120\n6", "2\n2\n120\n6\n", "2\n2\n120\n720\n", "2\n2\n40320\n720\n", "2\n2\n2\n720\n", "1\n2\n2\n720\n", "1\n2\n2\n362880\n", "2\n2\n2\n362880\n"]} | coding | 145 |
Solve the programming task below in a Python markdown code block.
There are N cities on a 2D plane. The coordinate of the i-th city is (x_i, y_i). Here (x_1, x_2, \dots, x_N) and (y_1, y_2, \dots, y_N) are both permuations of (1, 2, \dots, N).
For each k = 1,2,\dots,N, find the answer to the following question:
Rng i... | {"inputs": ["4\n2 4\n1 3\n3 1\n4 2", "4\n2 4\n1 3\n3 2\n4 1", "4\n1 4\n2 3\n3 2\n4 1", "4\n1 4\n2 2\n3 1\n4 3", "4\n2 4\n1 2\n3 1\n4 3", "4\n2 4\n1 3\n3 1\n4 2", "4\n2 4\n1 3\n3 2\n4 1", "4\n1 4\n3 3\n2 1\n4 2"], "outputs": ["2\n2\n2\n2\n", "2\n2\n1\n1\n", "1\n1\n1\n1\n", "1\n3\n3\n3\n", "4\n4\n4\n4\n", "2\n2\n2\n2\n",... | coding | 401 |
Solve the programming task below in a Python markdown code block.
There are $n$ piles of sand where the $i$-th pile has $a_i$ blocks of sand. The $i$-th pile is called too tall if $1 < i < n$ and $a_i > a_{i-1} + a_{i+1}$. That is, a pile is too tall if it has more sand than its two neighbours combined. (Note that pile... | {"inputs": ["3\n5 2\n2 9 2 4 1\n4 4\n1 3 2 1\n3 1\n1 3 1\n"], "outputs": ["2\n0\n1\n"]} | coding | 711 |
Solve the programming task below in a Python markdown code block.
Devu is a renowned classical singer. He is invited to many big functions/festivals. Recently he was invited to "All World Classical Singing Festival". Other than Devu, comedian Churu was also invited.
Devu has provided organizers a list of the songs and... | {"inputs": ["1 1\n1\n", "1 6\n1\n", "1 5\n1\n", "1 3\n4\n", "1 6\n1\n", "1 3\n4\n", "1 1\n1\n", "1 5\n1\n"], "outputs": ["0\n", "1\n", "0\n", "-1\n", "1\n", "-1\n", "0\n", "0\n"]} | coding | 584 |
Solve the programming task below in a Python markdown code block.
## Task
In your favorite game, you must shoot a target with a water-gun to gain points. Each target can be worth a different amount of points.
You are guaranteed to hit every target that you try to hit. You cannot hit consecutive targets though beca... | {"functional": "_inputs = [[[1, 2, 3, 4]], [[1, 3, 1]], [[5, 5, 5, 5, 5]], [[36, 42, 93, 29, 0, 33, 15, 84, 14, 24, 81, 11]], [[73, 80, 40, 86, 14, 96, 10, 56, 61, 84, 82, 36, 85]], [[11, 82, 47, 48, 80, 35, 73, 99, 86, 32, 32]], [[26, 54, 36, 35, 63, 58, 31, 80, 59, 61, 34, 54, 62, 73, 89, 7, 98, 91, 78]], [[0, 0, -1,... | coding | 447 |
Solve the programming task below in a Python markdown code block.
Mike decided to teach programming to children in an elementary school. He knows that it is not an easy task to interest children in that age to code. That is why he decided to give each child two sweets.
Mike has $n$ sweets with sizes $a_1, a_2, \ldots,... | {"inputs": ["2\n2 1\n", "2\n2 1\n", "2\n3 1\n", "2\n3 2\n", "2\n5 2\n", "2\n7 2\n", "2\n4 1\n", "2\n1 2\n"], "outputs": ["1\n", "1\n", "1\n", "1\n", "1\n", "1\n", "1\n", "1\n"]} | coding | 616 |
Solve the programming task below in a Python markdown code block.
Problem
Taro decided to watch one movie every day at a nearby movie theater during the summer vacation. (Taro has 31 days of summer vacation from August 1st to August 31st.)
The theater is set to show n movies during the summer vacation. Each movie is ... | {"inputs": ["4\n1 31\n2 4\n2 3\n3 3", "4\n1 31\n2 2\n2 1\n3 3", "4\n1 31\n2 2\n2 3\n3 5", "4\n1 31\n2 4\n2 3\n1 3", "4\n1 31\n2 2\n2 3\n4 5", "4\n1 31\n2 2\n2 0\n3 3", "4\n1 31\n2 8\n2 3\n1 3", "4\n1 31\n2 8\n2 3\n1 1"], "outputs": ["1750\n", "1700\n", "1750\n", "1750\n", "1750\n", "1700\n", "1750\n", "1750\n"]} | coding | 377 |
Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given two 0-indexed integer arrays nums1 and nums2 of equal length. Every second, for all indices 0 <= i < nums1.length, value of nums1[i] is incremented by nums2[i]. After this is done, you can do the followi... | {"functional": "def check(candidate):\n assert candidate(nums1 = [1,2,3], nums2 = [1,2,3], x = 4) == 3\n assert candidate(nums1 = [1,2,3], nums2 = [3,3,3], x = 4) == -1\n\n\ncheck(Solution().minimumTime)"} | coding | 182 |
Solve the programming task below in a Python markdown code block.
You are given $a$ uppercase Latin letters 'A' and $b$ letters 'B'.
The period of the string is the smallest such positive integer $k$ that $s_i = s_{i~mod~k}$ ($0$-indexed) for each $i$. Note that this implies that $k$ won't always divide $a+b = |s|$.
... | {"inputs": ["2 4\n", "5 3\n", "1 1\n", "1 2\n", "2 1\n", "1 3\n", "3 1\n", "2 2\n"], "outputs": ["4\n", "5\n", "1\n", "2\n", "2\n", "2\n", "2\n", "3\n"]} | coding | 378 |
Solve the programming task below in a Python markdown code block.
##Overview
Write a helper function that takes in a Time object and converts it to a more human-readable format. You need only go up to '_ weeks ago'.
```python
to_pretty(0) => "just now"
to_pretty(40000) => "11 hours ago"
```
##Specifics
- The output ... | {"functional": "_inputs = [[0], [1], [30], [90], [180], [4000], [40000], [140000], [400000], [1000000], [10000000]]\n_outputs = [['just now'], ['a second ago'], ['30 seconds ago'], ['a minute ago'], ['3 minutes ago'], ['an hour ago'], ['11 hours ago'], ['a day ago'], ['4 days ago'], ['a week ago'], ['16 weeks ago']]\ni... | coding | 278 |
Solve the programming task below in a Python markdown code block.
Today, Mezo is playing a game. Zoma, a character in that game, is initially at position $x = 0$. Mezo starts sending $n$ commands to Zoma. There are two possible commands: 'L' (Left) sets the position $x: =x - 1$; 'R' (Right) sets the position $x: =x +... | {"inputs": ["1\nL\n", "1\nR\n", "1\nR\n", "1\nL\n", "2\nLR\n", "2\nLR\n", "2\nRL\n", "4\nLRLR\n"], "outputs": ["2\n", "2\n", "2\n", "2\n", "3\n", "3\n", "3\n", "5\n"]} | coding | 416 |
Solve the programming task below in a Python markdown code block.
Tracy gives Charlie a [Directed Acyclic Graph] with N vertices. Among these N vertices, K vertices are *sources*, and L vertices are *sinks*.
Find out the maximum number of edges this graph can have.
Note:
A *source* is a vertex with no incoming edge.... | {"inputs": ["2\n3 1 1\n5 3 3\n"], "outputs": ["3\n4\n"]} | coding | 479 |
Solve the programming task below in a Python markdown code block.
Create a method `sayHello`/`say_hello`/`SayHello` that takes as input a name, city, and state to welcome a person. Note that `name` will be an array consisting of one or more values that should be joined together with one space between each, and the leng... | {"functional": "_inputs = [[['John', 'Smith'], 'Phoenix', 'Arizona'], [['Franklin', 'Delano', 'Roosevelt'], 'Chicago', 'Illinois'], [['Wallace', 'Russel', 'Osbourne'], 'Albany', 'New York'], [['Lupin', 'the', 'Third'], 'Los Angeles', 'California'], [['Marlo', 'Stanfield'], 'Baltimore', 'Maryland']]\n_outputs = [['Hello... | coding | 152 |
Solve the programming task below in a Python markdown code block.
`This kata is the first of the ADFGX Ciphers, the harder version can be found `here.
The ADFGX Cipher is a pretty well-known Cryptographic tool, and is essentially a modified Polybius Square.
Rather than having numbers as coordinates on the table, it h... | {"functional": "_inputs = [['helloworld', 'bchigklnmoqprstuvwxyzadef']]\n_outputs = [['AFXGDDDDDXGFDXFFDDXF']]\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 ... | coding | 629 |
Solve the programming task below in a Python markdown code block.
KISS stands for Keep It Simple Stupid.
It is a design principle for keeping things simple rather than complex.
You are the boss of Joe.
Joe is submitting words to you to publish to a blog. He likes to complicate things.
Define a function that determin... | {"functional": "_inputs = [['Joe had a bad day'], ['Joe had some bad days'], ['Joe is having no fun'], ['Sometimes joe cries for hours'], ['Joe is having lots of fun'], ['Joe is working hard a lot'], ['Joe listened to the noise and it was an onamonapia'], ['Joe listened to the noises and there were some onamonapias']]\... | coding | 218 |
Solve the programming task below in a Python markdown code block.
Valera runs a 24/7 fast food cafe. He magically learned that next day n people will visit his cafe. For each person we know the arrival time: the i-th person comes exactly at h_{i} hours m_{i} minutes. The cafe spends less than a minute to serve each cli... | {"inputs": ["1\n0 0\n", "1\n1 5\n", "1\n1 1\n", "1\n5 0\n", "1\n8 0\n", "1\n8 0\n", "1\n1 5\n", "1\n0 0\n"], "outputs": ["1\n", "1\n", "1\n", "1\n", "1\n", "1\n", "1\n", "1\n"]} | coding | 460 |
Solve the programming task below in a Python markdown code block.
There are 3 problems in a contest namely A, B, C respectively. Alice bets Bob that problem C is the hardest while Bob says that problem B will be the hardest.
You are given three integers S_{A}, S_{B}, S_{C} which denotes the number of successful submi... | {"inputs": ["3\n1 4 2\n16 8 10\n14 15 9\n"], "outputs": ["Draw\nBob\nAlice\n"]} | coding | 463 |
Solve the programming task below in a Python markdown code block.
`Description:`
Given an input array (`arr`) of positive integers, the objective is to return an output array where each index represents the amount of times an element appeared (frequency) in the input array.
More specifically, the element at each ind... | {"functional": "_inputs = [[2, 2, 4, 4, 6, 6, 9, 9, 9, 9], [3, 3, 3, 3, 2], [5, 5, 5, 5, 5], [77, 3, 40, 40, 40], [16, 7, 5, 3, 6, 23]]\n_outputs = [[[None, None, [2, 4, 6], None, [9], None, None, None, None, None, None]], [[None, [2], None, None, [3], None]], [[None, None, None, None, None, [5]]], [[None, [3, 77], Non... | coding | 647 |
Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given a string s and an integer k, reverse the first k characters for every 2k characters counting from the start of the string.
If there are fewer than k characters left, reverse all of them. If there are less than 2... | {"functional": "def check(candidate):\n assert candidate(s = \"abcdefg\", k = 2) == \"bacdfeg\"\n assert candidate(s = \"abcd\", k = 2) == \"bacd\"\n\n\ncheck(Solution().reverseStr)"} | coding | 123 |
Solve the programming task below in a Python markdown code block.
You've made it through the moat and up the steps of knowledge. You've won the temples games and now you're hunting for treasure in the final temple run. There's good news and bad news. You've found the treasure but you've triggered a nasty trap. You'll s... | {"functional": "_inputs = [[5], [1], [[]], [11], ['treasure'], ['5'], [-1], [3], [2], [0.5]]\n_outputs = [['X X\\n X X\\n X\\n X X\\nX X\\n'], ['X\\n'], ['?'], ['X X\\n X X\\n X X\\n X X\\n X X\\n X\\n X X\\n X... | coding | 348 |
Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given an integer array nums sorted in non-decreasing order.
Build and return an integer array result with the same length as nums such that result[i] is equal to the summation of absolute differences between n... | {"functional": "def check(candidate):\n assert candidate(nums = [2,3,5]) == [4,3,5]\n assert candidate(nums = [1,4,6,8,10]) == [24,15,13,15,21]\n\n\ncheck(Solution().getSumAbsoluteDifferences)"} | coding | 142 |
Solve the programming task below in a Python markdown code block.
The new £5 notes have been recently released in the UK and they've certainly became a sensation! Even those of us who haven't been carrying any cash around for a while, having given in to the convenience of cards, suddenly like to have some of these in t... | {"functional": "_inputs = [[2000, [500, 160, 400]], [1260, [500, 50, 100]], [3600, [1800, 350, 460, 500, 15]], [1995, [1500, 19, 44]], [10000, [1800, 500, 1200, 655, 150]], [2300, [590, 1500, 45, 655, 150]], [5300, [1190, 1010, 1045, 55, 10, 19, 55]], [2000, [500, 495, 100, 900]], [2000, [500, 496, 100, 900]], [2000, [... | coding | 201 |
Solve the programming task below in a Python markdown code block.
You are given a hexagonal grid consisting of two rows, each row consisting of $n$ cells. The cells of the first row are labelled $a_1,a_2,\ldots a_n$ and the cells of the second row are labelled $b_1,b_2,\ldots,b_n$.
For example, for $n=6$:
(Note tha... | {"inputs": ["6\n6\n010000\n000010\n2\n00\n00\n2\n00\n10\n2\n00\n01\n2\n00\n11\n2\n10\n00\n"], "outputs": ["YES\nYES\nNO\nNO\nYES\nNO\n"]} | coding | 552 |
Solve the programming task below in a Python markdown code block.
Write function alternateCase which switch every letter in string from upper to lower and from lower to upper.
E.g: Hello World -> hELLO wORLD
Also feel free to reuse/extend the following starter code:
```python
def alternateCase(s):
``` | {"functional": "_inputs = [['ABC'], [''], [' '], ['Hello World'], ['cODEwARS'], ['i LIKE MAKING KATAS VERY MUCH'], ['HuMpTy DuMpTy SaT On A WaLl'], ['aBracaDabRa'], ['Hickory DICKORY dock'], ['Jack JUMPED over THE CaNdLeStIcK']]\n_outputs = [['abc'], [''], [' '], ['hELLO wORLD'], ['CodeWars'], ['I like making katas ver... | coding | 66 |
Solve the programming task below in a Python markdown code block.
You are given two integers K and S.
Three variable X, Y and Z takes integer values satisfying 0≤X,Y,Z≤K.
How many different assignments of values to X, Y and Z are there such that X + Y + Z = S?
Constraints
* 2≤K≤2500
* 0≤S≤3K
* K and S are integers.
... | {"inputs": ["3 2", "5 7", "3 3", "4 7", "3 4", "1 7", "2 5", "4 0"], "outputs": ["6\n", "27\n", "10\n", "18\n", "12\n", "0\n", "3\n", "1\n"]} | coding | 153 |
Solve the programming task below in a Python markdown code block.
CSS colors are defined using a hexadecimal (HEX) notation for the combination of Red, Green, and Blue color values (RGB).
Specifications of HEX Color Code
■ It must start with a '#' symbol.
■ It can have $3$ or $\boldsymbol{6}$ digits.
■ Each digit i... | {"inputs": ["11\n#BED\n{\n color: #FfFdF8; background-color:#aef;\n font-size: 123px;\n background: -webkit-linear-gradient(top, #f9f9f9, #fff);\n}\n#Cab\n{\n background-color: #ABC;\n border: 2px dashed #fff;\n} \n"], "outputs": ["#FfFdF8\n#aef\n#f9f9f9\n#fff\n#ABC\n#fff\n"]} | coding | 489 |
Solve the programming task below in a Python markdown code block.
Takahashi has K 500-yen coins. (Yen is the currency of Japan.)
If these coins add up to X yen or more, print Yes; otherwise, print No.
-----Constraints-----
- 1 \leq K \leq 100
- 1 \leq X \leq 10^5
-----Input-----
Input is given from Standard Input i... | {"inputs": ["1 5", "2 5", "2 7", "4 2", "4 1", "5 1", "9 1", "9 0"], "outputs": ["Yes\n", "Yes\n", "Yes\n", "Yes\n", "Yes\n", "Yes\n", "Yes\n", "Yes\n"]} | coding | 174 |
Solve the programming task below in a Python markdown code block.
Chef has started developing interest in playing chess, and was learning how the [Queen] moves.
Chef has an empty N \times N chessboard. He places a Queen at (X, Y) and wonders - What are the number of cells that are under attack by the Queen?
Notes:
... | {"inputs": ["5\n1 1 1\n3 2 2\n3 2 1\n2 2 2\n150 62 41\n"], "outputs": ["0\n8\n6\n3\n527\n"]} | coding | 529 |
Solve the programming task below in a Python markdown code block.
Alice and Bob begin their day with a quick game. They first choose a starting number X_0 ≥ 3 and try to reach one million by the process described below.
Alice goes first and then they take alternating turns. In the i-th turn, the player whose turn it ... | {"inputs": ["4\n", "6\n", "8\n", "9\n", "8\n", "4\n", "6\n", "9\n"], "outputs": ["3\n", "3\n", "7\n", "7\n", "7", "3", "3", "7"]} | coding | 422 |
Solve the programming task below in a Python markdown code block.
Vasya has an array a consisting of positive integer numbers. Vasya wants to divide this array into two non-empty consecutive parts (the prefix and the suffix) so that the sum of all elements in the first part equals to the sum of elements in the second p... | {"inputs": ["1\n1\n", "1\n2\n", "1\n1\n", "1\n2\n", "1\n8\n", "1\n4\n", "1\n10\n", "1\n10\n"], "outputs": ["NO\n", "NO\n", "NO", "NO", "NO\n", "NO\n", "NO\n", "NO"]} | coding | 336 |
Solve the programming task below in a Python markdown code block.
Given is an integer N. Find the number of digits that N has in base K.
-----Notes-----
For information on base-K representation, see Positional notation - Wikipedia.
-----Constraints-----
- All values in input are integers.
- 1 \leq N \leq 10^9
- 2 ... | {"inputs": ["1 2", "1 3", "1 2\n", "22 2", "15 2", "11 4", "25 2", "20 2"], "outputs": ["1\n", "1\n", "1\n", "5\n", "4\n", "2\n", "5\n", "5\n"]} | coding | 151 |
Please solve the programming task below using a self-contained code snippet in a markdown code block.
There are n people standing in a queue, and they numbered from 0 to n - 1 in left to right order. You are given an array heights of distinct integers where heights[i] represents the height of the ith person.
A person ... | {"functional": "def check(candidate):\n assert candidate(heights = [10,6,8,5,11,9]) == [3,1,2,1,1,0]\n assert candidate(heights = [5,1,2,3,10]) == [4,1,1,1,0]\n\n\ncheck(Solution().canSeePersonsCount)"} | coding | 193 |
Solve the programming task below in a Python markdown code block.
### The Story:
Bob is working as a bus driver. However, he has become extremely popular amongst the city's residents. With so many passengers wanting to get aboard his bus, he sometimes has to face the problem of not enough space left on the bus! He want... | {"functional": "_inputs = [[10, 5, 5], [100, 60, 50], [20, 5, 5]]\n_outputs = [[0], [10], [0]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return math.isclose(a, b, rel_tol=tol, abs_tol=tol)\n if isinstance(a, (list, tuple)):\n if len(a) != len(b)... | coding | 437 |
Solve the programming task below in a Python markdown code block.
Iahub helps his grandfather at the farm. Today he must milk the cows. There are n cows sitting in a row, numbered from 1 to n from left to right. Each cow is either facing to the left or facing to the right. When Iahub milks a cow, all the cows that see ... | {"inputs": ["1\n1\n", "1\n0\n", "1\n0\n", "1\n1\n", "2\n0 1\n", "2\n1 0\n", "2\n0 0\n", "2\n1 1\n"], "outputs": ["0", "0", "0\n", "0\n", "0", "1", "0", "0"]} | coding | 456 |
Solve the programming task below in a Python markdown code block.
Read problem statements in [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Chef has three socks in his drawer. Each sock has one of 10 possible colours, which are represented by integers between 1 and 10. Specifically, the colours of... | {"inputs": ["5 4 3", "5 5 5"], "outputs": ["NO", "YES"]} | coding | 348 |
Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given a string s and an integer k, rearrange s such that the same characters are at least distance k from each other. If it is not possible to rearrange the string, return an empty string "".
Please complete the fol... | {"functional": "def check(candidate):\n assert candidate(s = \"aabbcc\", k = 3) == \"abcabc\"\n assert candidate(s = \"aaabc\", k = 3) == \"\"\n assert candidate(s = \"aaadbbcc\", k = 2) == \"abacabcd\"\n\n\ncheck(Solution().rearrangeString)"} | coding | 95 |
Solve the programming task below in a Python markdown code block.
Let $s$ be a string of lowercase Latin letters. Its price is the sum of the indices of letters (an integer between 1 and 26) that are included in it. For example, the price of the string abca is $1+2+3+1=7$.
The string $w$ and the integer $p$ are given.... | {"inputs": ["1\nvdjisjifreo\n39\n", "5\nabca\n2\nabca\n6\ncodeforces\n1\ncodeforces\n10\ncodeforces\n100\n"], "outputs": ["diife\n", "aa\naba\n\ncdc\ncodeforces\n"]} | coding | 510 |
Solve the programming task below in a Python markdown code block.
# Task
John is playing a RPG game. The initial attack value of the player is `x`. The player will face a crowd of monsters. Each monster has different defense value.
If the monster's defense value is less than or equal to the player's attack value, the... | {"functional": "_inputs = [[50, [50, 105, 200]], [20, [30, 20, 15, 40, 100]]]\n_outputs = [[110], [205]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return math.isclose(a, b, rel_tol=tol, abs_tol=tol)\n if isinstance(a, (list, tuple)):\n if len(a)... | coding | 347 |
Solve the programming task below in a Python markdown code block.
Let $s$ be some string consisting of symbols "0" or "1". Let's call a string $t$ a substring of string $s$, if there exists such number $1 \leq l \leq |s| - |t| + 1$ that $t = s_l s_{l+1} \ldots s_{l + |t| - 1}$. Let's call a substring $t$ of string $s$ ... | {"inputs": ["4 4\n", "5 3\n", "7 3\n", "1 1\n", "2 2\n", "3 3\n", "3 1\n", "4 2\n"], "outputs": ["1111", "01010", "0010010", "1", "11", "111", "010", "0101"]} | coding | 673 |
Solve the programming task below in a Python markdown code block.
In Takahashi Kingdom, there is an archipelago of N islands, called Takahashi Islands. For convenience, we will call them Island 1, Island 2, ..., Island N.
There are M kinds of regular boat services between these islands. Each service connects two islan... | {"inputs": ["3 2\n1 2\n0 3", "3 2\n1 2\n2 3", "4 3\n1 3\n2 3\n3 4", "4 3\n1 3\n3 3\n3 4", "4 3\n1 1\n2 3\n3 4", "4 2\n1 3\n2 3\n3 4", "4 3\n1 1\n2 5\n3 4", "4 2\n1 3\n2 3\n0 4"], "outputs": ["IMPOSSIBLE\n", "POSSIBLE", "POSSIBLE\n", "POSSIBLE\n", "IMPOSSIBLE\n", "IMPOSSIBLE\n", "IMPOSSIBLE\n", "IMPOSSIBLE\n"]} | coding | 403 |
Solve the programming task below in a Python markdown code block.
The smallest unit of data handled by a computer is called a bit, and the amount of information that represents multiple bits together is called a word. Currently, many computers process one word as 32 bits.
For a computer that represents one word in 32 ... | {"inputs": ["0", "5", "1", "2", "8", "6", "7", "9"], "outputs": ["0\n", "160\n", "32\n", "64\n", "256\n", "192\n", "224\n", "288\n"]} | coding | 153 |
Solve the programming task below in a Python markdown code block.
There are $n$ persons who initially don't know each other. On each morning, two of them, who were not friends before, become friends.
We want to plan a trip for every evening of $m$ days. On each trip, you have to select a group of people that will go o... | {"inputs": ["2 1 1\n2 1\n", "2 1 1\n2 1\n", "2 1 2\n2 1\n", "2 1 3\n2 1\n", "4 4 2\n2 3\n1 2\n1 3\n1 4\n", "4 4 2\n2 3\n1 2\n1 3\n1 4\n", "5 7 2\n1 5\n3 2\n2 5\n3 4\n1 2\n5 3\n1 3\n", "9 7 2\n1 5\n3 2\n2 5\n3 4\n1 2\n5 3\n1 3\n"], "outputs": ["2\n", "2\n", "0\n", "0\n", "0\n0\n3\n3\n", "0\n0\n3\n3\n", "0\n0\n0\n0\n3\n4... | coding | 704 |
Solve the programming task below in a Python markdown code block.
Bran and his older sister Arya are from the same house. Bran like candies so much, so Arya is going to give him some Candies.
At first, Arya and Bran have 0 Candies. There are n days, at the i-th day, Arya finds a_{i} candies in a box, that is given by ... | {"inputs": ["1 9\n10\n", "1 7\n10\n", "1 9\n10\n", "2 3\n1 2\n", "2 8\n7 8\n", "2 9\n4 8\n", "2 3\n3 3\n", "2 2\n1 2\n"], "outputs": ["-1", "1\n", "-1\n", "2", "2", "2", "1", "2"]} | coding | 473 |
Solve the programming task below in a Python markdown code block.
Write a program of a Merge Sort algorithm implemented by the following pseudocode. You should also report the number of comparisons in the Merge function.
Merge(A, left, mid, right)
n1 = mid - left;
n2 = right - mid;
create array L[0...n1], R[0...n2]
f... | {"inputs": ["10\n8 5 9 2 6 3 7 0 10 4", "10\n8 5 9 2 6 3 7 0 10 3", "10\n8 5 9 2 6 3 7 1 10 4", "10\n8 5 9 2 6 4 11 0 10 3", "10\n8 5 9 2 6 4 11 0 10 5", "10\n8 5 9 2 6 4 11 1 10 5", "10\n10 5 9 2 6 4 11 1 10 5", "10\n10 5 9 2 6 4 19 1 10 5"], "outputs": ["0 2 3 4 5 6 7 8 9 10\n34\n", "0 2 3 3 5 6 7 8 9 10\n34\n", "1 2... | coding | 391 |
Solve the programming task below in a Python markdown code block.
Efim just received his grade for the last test. He studies in a special school and his grade can be equal to any positive decimal fraction. First he got disappointed, as he expected a way more pleasant result. Then, he developed a tricky plan. Each secon... | {"inputs": ["3 1\n0.1\n", "3 1\n9.9\n", "3 1\n0.9\n", "3 1\n9.5\n", "3 3\n9.9\n", "3 3\n9.9\n", "3 1\n0.1\n", "3 1\n9.9\n"], "outputs": ["0.1\n", "10\n", "1\n", "10\n", "10\n", "10\n", "0.1\n", "10\n"]} | coding | 628 |
Solve the programming task below in a Python markdown code block.
A triangle is called an equable triangle if its area equals its perimeter. Return `true`, if it is an equable triangle, else return `false`. You will be provided with the length of sides of the triangle. Happy Coding!
Also feel free to reuse/extend the f... | {"functional": "_inputs = [[5, 12, 13], [2, 3, 4], [6, 8, 10], [7, 15, 20], [17, 17, 30], [7, 10, 12], [6, 11, 12], [25, 25, 45], [13, 37, 30], [6, 25, 29], [10, 11, 18], [73, 9, 80], [12, 35, 37], [120, 109, 13], [9, 10, 17]]\n_outputs = [[True], [False], [True], [True], [False], [False], [False], [False], [False], [T... | coding | 85 |
Solve the programming task below in a Python markdown code block.
Read problems statements in Mandarin Chinese, Russian and Vietnamese as well.
Chef Watson uses a social network called ChefBook, which has a new feed consisting of posts by his friends. Each post can be characterized by f - the identifier of the friend... | {"inputs": ["2 4\n1 2\n1 1 WhoDoesntLoveChefBook\n2 2 WinterIsComing\n3 10 TheseViolentDelightsHaveViolentEnds\n4 3 ComeAtTheKingBestNotMiss"], "outputs": ["WinterIsComing\nWhoDoesntLoveChefBook\nTheseViolentDelightsHaveViolentEnds\nComeAtTheKingBestNotMiss"]} | coding | 619 |
Solve the programming task below in a Python markdown code block.
Alice and Bob are playing a game with $n$ piles of stones. It is guaranteed that $n$ is an even number. The $i$-th pile has $a_i$ stones.
Alice and Bob will play a game alternating turns with Alice going first.
On a player's turn, they must choose exac... | {"inputs": ["2\n8 8\n", "2\n1 1\n", "2\n1 1\n", "2\n2 1\n", "2\n2 0\n", "2\n8 8\n", "2\n15 8\n", "4\n3 1 4 1\n"], "outputs": ["Bob\n", "Bob\n", "Bob\n", "Alice\n", "Alice\n", "Bob\n", "Alice\n", "Alice\n"]} | coding | 391 |
Solve the programming task below in a Python markdown code block.
Lucy had recently learned the game, called Natural Numbers.
The rules of the game are really simple. There are N players. At the same time, every player says one natural number. Let's call the number said by the i-th player Ai. The person with the smalle... | {"inputs": ["2\n5\nKouta 1\nYuka 1\nMayu 3\nyucL 2\nNana 5\n2\nLucy 2\nNana 2", "2\n5\nKouta 1\nYuka 0\nMayu 3\nyucL 2\nNana 5\n2\nLucy 2\nNana 2", "2\n5\nKouta 2\nakuY 0\nMayu 3\nyucL 2\nNana 5\n2\nLucy 2\nNana 2", "2\n5\nKouta 1\nYuka 1\nMayu 3\nLucy 2\nNana 5\n2\nLucy 2\nOana 2", "2\n5\nKouta 0\nYuka 1\nMayu 3\nLucy... | coding | 540 |
Solve the programming task below in a Python markdown code block.
A non-empty string is called palindrome, if it reads the same from the left to the right and from the right to the left. For example, "abcba", "a", and "abba" are palindromes, while "abab" and "xy" are not.
A string is called a substring of another stri... | {"inputs": ["1\nz\n", "2\naa\n", "2\naz\n", "4\nmems\n", "5\noolol\n", "6\nmsucmc\n", "7\nlolikek\n", "9\nabcabcabc\n"], "outputs": ["z\n", "aa\n", "az\n", "emms\n", "llooo\n", "ccmmsu\n", "eikkllo\n", "aaabbbccc\n"]} | coding | 517 |
Solve the programming task below in a Python markdown code block.
Dima and Inna are doing so great! At the moment, Inna is sitting on the magic lawn playing with a pink pony. Dima wanted to play too. He brought an n × m chessboard, a very tasty candy and two numbers a and b.
Dima put the chessboard in front of Inna an... | {"inputs": ["5 7 1 3 2 2\n", "5 5 2 3 1 1\n", "1 1 1 1 1 1\n", "5 7 1 3 1 2\n", "5 4 2 3 2 2\n", "5 4 2 3 1 1\n", "5 5 1 3 1 2\n", "5 5 4 3 1 2\n"], "outputs": ["2\n", "Poor Inna and pony!\n", "0\n", "2\n", "Poor Inna and pony!\n", "1\n", "Poor Inna and pony!\n", "1\n"]} | coding | 670 |
Solve the programming task below in a Python markdown code block.
Today is the day of the CCDSAP exam. Chef is responsible for monitoring the exam. The hall in which the exam will be held contains $N$ seats (numbered $1$ through $N$) arranged in a row. Initially, each seat is either empty or occupied by a participant i... | {"inputs": ["4\n3\n011\n5\n10111\n1\n1\n6\n000111"], "outputs": ["1\nimpossible\n0\n3"]} | coding | 506 |
Solve the programming task below in a Python markdown code block.
Alice and Bob are playing a game on a matrix, consisting of $2$ rows and $m$ columns. The cell in the $i$-th row in the $j$-th column contains $a_{i, j}$ coins in it.
Initially, both Alice and Bob are standing in a cell $(1, 1)$. They are going to perfo... | {"inputs": ["3\n3\n1 3 7\n3 5 1\n3\n1 3 9\n3 5 1\n1\n4\n7\n", "3\n3\n1 3 7\n3 5 1\n3\n1 3 9\n3 5 1\n1\n4\n4\n", "3\n3\n1 3 7\n3 5 1\n3\n0 3 9\n3 1 1\n1\n3\n5\n", "3\n3\n1 3 7\n3 2 0\n3\n1 3 9\n3 2 0\n1\n3\n7\n", "3\n3\n1 3 7\n3 5 1\n3\n1 3 6\n3 5 1\n1\n4\n4\n", "3\n3\n0 3 6\n3 5 1\n3\n1 3 9\n3 5 1\n1\n4\n4\n", "3\n3\n0... | coding | 551 |
Solve the programming task below in a Python markdown code block.
Harry Potter is on a mission to destroy You-Know-Who's Horcruxes. The first Horcrux that he encountered in the Chamber of Secrets is Tom Riddle's diary. The diary was with Ginny and it forced her to open the Chamber of Secrets. Harry wants to know the di... | {"inputs": ["1\nz\n", "1\nz\n", "1\ny\n", "1\n{\n", "1\n|\n", "1\n}\n", "1\n~\n", "1\n\u007f\n"], "outputs": ["NO\n", "NO\n", "NO\n", "NO\n", "NO\n", "NO\n", "NO\n", "NO\n"]} | coding | 398 |
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"]} | coding | 465 |
Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given an array of integers nums and a positive integer k, check whether it is possible to divide this array into sets of k consecutive numbers.
Return true if it is possible. Otherwise, return false.
Please complete... | {"functional": "def check(candidate):\n assert candidate(nums = [1,2,3,3,4,4,5,6], k = 4) == True\n assert candidate(nums = [3,2,1,2,3,4,3,4,5,9,10,11], k = 3) == True\n assert candidate(nums = [3,3,2,2,1,1], k = 3) == True\n assert candidate(nums = [1,2,3,4], k = 3) == False\n\n\ncheck(Solution().isPossibl... | coding | 94 |
Solve the programming task below in a Python markdown code block.
Christmas is coming, and Santa has a long list to go through, to find who deserves presents for the big day. Go through a list of children, and return a list containing every child who appeared on Santa's list. Do not add any child more than once. Output... | {"functional": "_inputs = [[['Jason', 'Jackson', 'Jordan', 'Johnny'], ['Jason', 'Jordan', 'Jennifer']], [['Jason', 'Jackson', 'Johnson', 'JJ'], ['Jason', 'James', 'JJ']], [['jASon', 'JAsoN', 'JaSON', 'jasON'], ['JasoN', 'jASOn', 'JAsoN', 'jASon', 'JASON']]]\n_outputs = [[['Jason', 'Jordan']], [['JJ', 'Jason']], [['JAso... | coding | 152 |
Solve the programming task below in a Python markdown code block.
Read problems statements in Mandarin Chinese, Russian and Vietnamese as well.
You are given a polynomial of degree N with integer coefficients. Your task is to find the value of this polynomial at some K different integers, modulo 786433.
------ Input... | {"inputs": ["2\n1 2 3\n3\n7\n8\n9"], "outputs": ["162\n209\n262"]} | coding | 502 |
Solve the programming task below in a Python markdown code block.
Teacher brought a fruit basket for three students. The basket contains only Apples, Mangoes and Oranges. Student A knows a value $a$, the total number of Apples and Mangoes in the Basket, B knows a value $b$, the total number of Mangoes and Oranges in th... | {"inputs": ["2\n7 9 8 12\n3 8 7 9"], "outputs": ["3 4 5\n1 2 6"]} | coding | 342 |
Solve the programming task below in a Python markdown code block.
Takahashi recorded his daily life for the last few days as a integer sequence of length 2N, as follows:
* a_1, b_1, a_2, b_2, ... , a_N, b_N
This means that, starting from a certain time T, he was:
* sleeping for exactly a_1 seconds
* then awake for... | {"inputs": ["3\n11001 2265\n499 81568\n5242 218", "3\n10000 2054\n499 42643\n5242 146", "3\n10000 2054\n499 42643\n5242 218", "3\n10000 2054\n499 64506\n5242 218", "3\n11000 2054\n499 64506\n5242 218", "3\n11000 2265\n499 64506\n5242 218", "3\n11001 2265\n499 64506\n5242 218", "3\n11162 10322\n5814 7716\n84163 87"], "o... | coding | 531 |
Solve the programming task below in a Python markdown code block.
Arya is new to matrices. With lots of subtopics in the chapter, he finds it difficult in getting good in all of them. As of now, he is practising matrix multiplications. He takes two different matrices and checks in how many different ways could they be ... | {"inputs": ["11\n12 4 3 12\n12 4 4 12\n18 20 10 23\n10 13 11 8\n3 20 3 14\n13 23 12 20\n12 17 5 19\n15 22 22 9\n20 20 15 3\n7 19 18 8\n2 16 6 19", "36\n30 2 2 30\n14 1 2 14\n30 6 38 40\n9 24 25 11\n7 48 10 18\n18 22 21 19\n4 24 24 23\n31 38 6 22\n30 49 34 48\n46 1 6 6\n9 31 11 48\n9 17 10 36\n42 15 20 19\n24 10 42 46\n... | coding | 258 |
Solve the programming task below in a Python markdown code block.
There are two lists of different length. The first one consists of keys, the second one consists of values. Write a function ```createDict(keys, values)``` that returns a dictionary created from keys and values. If there are not enough values, the rest o... | {"functional": "_inputs = [[[], []], [[], [1]], [['a'], []], [['a', 'b', 'c'], [1, 2, 3]], [['a', 'b', 'c', 'd', 'e'], [1, 2]], [['a', 'b'], [1, 2, 3, 4]]]\n_outputs = [[{}], [{}], [{'a': None}], [{'a': 1, 'b': 2, 'c': 3}], [{'a': 1, 'b': 2, 'c': None, 'd': None, 'e': None}], [{'a': 1, 'b': 2}]]\nimport math\ndef _deep... | coding | 236 |
Solve the programming task below in a Python markdown code block.
There are n heroes fighting in the arena. Initially, the i-th hero has a_i health points.
The fight in the arena takes place in several rounds. At the beginning of each round, each alive hero deals 1 damage to all other heroes. Hits of all heroes occur ... | {"inputs": ["7 4\n", "6 4\n", "4 5\n", "3 1\n", "5 8\n", "4 4\n", "6 8\n", "4 8\n"], "outputs": ["16384", "4096", "301", "1", "12048", "148", "119644", "1144"]} | coding | 362 |
Solve the programming task below in a Python markdown code block.
There is a square matrix n × n, consisting of non-negative integer numbers. You should find such a way on it that
* starts in the upper left cell of the matrix;
* each following cell is to the right or down from the current cell;
* the way ends... | {"inputs": ["2\n7 6\n3 8\n", "2\n4 6\n3 8\n", "2\n4 4\n3 8\n", "2\n4 7\n3 8\n", "2\n4 7\n6 8\n", "2\n4 7\n9 8\n", "2\n4 7\n10 8\n", "2\n4 2\n10 8\n"], "outputs": ["0\nDR", "0\nDR\n", "0\nDR\n", "0\nDR\n", "0\nDR\n", "0\nDR\n", "0\nRD\n", "0\nRD\n"]} | coding | 221 |
Solve the programming task below in a Python markdown code block.
Chef has an array consisting of N + K - 1 integers. The array contains only the first N positive odd numbers. Each number appears exactly once, except for one number which appears exactly K times. The sum of integers in Chef's array is equal to S.
For e... | {"inputs": ["3\n3 2 14\n5 4 28\n2 3 10\n"], "outputs": ["5\n1\n3\n"]} | coding | 434 |
Solve the programming task below in a Python markdown code block.
Chef is not feeling well today. He measured his body temperature using a thermometer and it came out to be X °F.
A person is said to have fever if his body temperature is strictly greater than 98 °F.
Determine if Chef has fever or not.
------ Input F... | {"inputs": ["3\n98\n100\n96\n"], "outputs": ["NO\nYES\nNO\n"]} | coding | 309 |
Solve the programming task below in a Python markdown code block.
Consider a sequence, which is formed by the following rule: next term is taken as the smallest possible non-negative integer, which is not yet in the sequence, so that `no 3` terms of sequence form an arithmetic progression.
## Example
`f(0) = 0` -- sm... | {"functional": "_inputs = [[0], [1], [2], [3], [4], [5], [334], [123], [546], [1634], [14514]]\n_outputs = [[0], [1], [3], [4], [9], [10], [7329], [1084], [19929], [79707], [2305425]]\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... | coding | 338 |
Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given a circular integer array nums of length n, return the maximum possible sum of a non-empty subarray of nums.
A circular array means the end of the array connects to the beginning of the array. Formally, the next ... | {"functional": "def check(candidate):\n assert candidate(nums = [1,-2,3,-2]) == 3\n assert candidate(nums = [5,-3,5]) == 10\n assert candidate(nums = [3,-2,2,-3]) == 3\n\n\ncheck(Solution().maxSubarraySumCircular)"} | coding | 195 |
Solve the programming task below in a Python markdown code block.
An anagram is a word, a phrase, or a sentence formed from another by rearranging its letters. An example of this is "angel", which is an anagram of "glean".
Write a function that receives an array of words, and returns the total number of distinct pairs... | {"functional": "_inputs = [[[]], [['dell', 'ledl', 'abc', 'cba']], [['dell', 'ledl', 'lled', 'cba']], [['dell', 'ledl', 'abc', 'cba', 'bca', 'bac', 'cab']]]\n_outputs = [[0], [2], [3], [11]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return math.isclose(a,... | coding | 163 |
Solve the programming task below in a Python markdown code block.
You are given an array $a$ consisting of $n$ integers. Let's denote monotonic renumeration of array $a$ as an array $b$ consisting of $n$ integers such that all of the following conditions are met:
$b_1 = 0$; for every pair of indices $i$ and $j$ suc... | {"inputs": ["2\n100 1\n", "2\n000 1\n", "2\n000 2\n", "2\n010 2\n", "2\n011 2\n", "2\n100 1\n", "4\n1 3 3 7\n", "4\n1 3 1 7\n"], "outputs": ["2\n", "2\n", "2\n", "2\n", "2\n", "2\n", "4\n", "2\n"]} | coding | 461 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.