problem stringlengths 14 4.09k | solution stringlengths 1 802k | task_type stringclasses 3
values | problem_tokens int64 5 895 |
|---|---|---|---|
Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given an array of strings ideas that represents a list of names to be used in the process of naming a company. The process of naming a company is as follows:
Choose 2 distinct names from ideas, call them idea... | {"functional": "def check(candidate):\n assert candidate(ideas = [\"coffee\",\"donuts\",\"time\",\"toffee\"]) == 6\n assert candidate(ideas = [\"lack\",\"back\"]) == 0\n\n\ncheck(Solution().distinctNames)"} | coding | 176 |
Solve the programming task below in a Python markdown code block.
Your task it to return ```true``` if the fractional part (rounded to 1 digit) of the result (```a``` / ```b```) exists, more than ```0``` and is multiple of ```n```.
Otherwise return ```false```. (For Python return True or False)
All arguments are posit... | {"functional": "_inputs = [[5, 2, 3], [5, 3, 4], [5, 4, 3], [666, 665, 2], [3691401, 1892272, 5]]\n_outputs = [[False], [False], [True], [False], [False]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return math.isclose(a, b, rel_tol=tol, abs_tol=tol)\n i... | coding | 244 |
Solve the programming task below in a Python markdown code block.
"What are your shoe sizes?"
Suddenly, the doctor asked me when I met him for the first time.
"It's 23.5"
"Oh, that's a really nice number. It's 2 to the 4th power plus 2 to the 2nd power, 2 to the 1st power, 2 to the 0th power, and 2 to the 1st power."... | {"inputs": ["23.5\n158.1\n-1.0", "23.72975180461117\n158.1\n-1.0", "24.206542817215936\n158.1\n-1.0", "24.615346202775605\n158.1\n-1.0", "25.190547978615548\n158.1\n-1.0", "23.529780841564097\n158.1\n-1.0", "24.722659099067236\n158.1\n-1.0", "23.5\n158.1\n-0.5246083014985048"], "outputs": ["00010111.1000\nNA", "NA\nNA\... | coding | 488 |
Solve the programming task below in a Python markdown code block.
Chef's coding class is very famous in Chefland.
This year X students joined his class and each student will require one chair to sit on. Chef already has Y chairs in his class. Determine the minimum number of new chairs Chef must buy so that every stud... | {"inputs": ["4\n20 14\n41 41\n35 0\n50 100\n"], "outputs": ["6\n0\n35\n0\n"]} | coding | 354 |
Solve the programming task below in a Python markdown code block.
When Chef was born, his parents took him to the famous monk Doctor Strange to know whether he will land himself in heaven after his life or not. According to Strange, Chef will live for $L$ years in total. If he wants to go to heaven, he must spend at le... | {"inputs": ["3\n2\n10\n3\n001\n4\n0100"], "outputs": ["YES\nNO\nYES"]} | coding | 622 |
Solve the programming task below in a Python markdown code block.
Little penguin Polo likes permutations. But most of all he likes permutations of integers from 0 to n, inclusive.
For permutation p = p_0, p_1, ..., p_{n}, Polo has defined its beauty — number $(0 \oplus p_{0}) +(1 \oplus p_{1}) + \cdots +(n \oplus p_{n... | {"inputs": ["4\n", "7\n", "1\n", "2\n", "3\n", "8\n", "2\n", "7\n"], "outputs": ["20\n0 2 1 4 3\n", "56\n7 6 5 4 3 2 1 0\n", "2\n1 0\n", "6\n0 2 1\n", "12\n3 2 1 0\n", "72\n0 6 5 4 3 2 1 8 7\n", "6\n0 2 1 ", "56\n7 6 5 4 3 2 1 0 "]} | coding | 265 |
Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given an equation, represented by words on the left side and the result on the right side.
You need to check if the equation is solvable under the following rules:
Each character is decoded as one digit (0 - 9).
No t... | {"functional": "def check(candidate):\n assert candidate(words = [\"SEND\",\"MORE\"], result = \"MONEY\") == True\n assert candidate(words = [\"SIX\",\"SEVEN\",\"SEVEN\"], result = \"TWENTY\") == True\n assert candidate(words = [\"THIS\",\"IS\",\"TOO\"], result = \"FUNNY\") == True\n assert candidate(words ... | coding | 160 |
Solve the programming task below in a Python markdown code block.
You are given an integer array $a_1, a_2, \ldots, a_n$.
The array $b$ is called to be a subsequence of $a$ if it is possible to remove some elements from $a$ to get $b$.
Array $b_1, b_2, \ldots, b_k$ is called to be good if it is not empty and for ever... | {"inputs": ["1\n7\n", "1\n32\n", "2\n1 2\n", "1\n688\n", "2\n1 2\n", "1\n1469\n", "1\n2185\n", "1\n89751\n"], "outputs": ["1\n", "1\n", "3", "1\n", "3\n", "1\n", "1\n", "1\n"]} | coding | 535 |
Solve the programming task below in a Python markdown code block.
For the first place at the competition, Alex won many arrays of integers and was assured that these arrays are very expensive. After the award ceremony Alex decided to sell them. There is a rule in arrays pawnshop: you can sell array only if it can be co... | {"inputs": ["1\n1\n1\n", "1\n5\n1 3 1 3 0\n", "1\n5\n0 1000000000 999999999 999999998 999999997\n", "6\n6\n1 9 17 6 14 3\n3\n4 2 2\n3\n7 3 4\n3\n2 2 4\n5\n0 1000000000 0 1000000000 0\n2\n1 1\n"], "outputs": ["0\n", "-1\n", "1000000001 1000000000\n", "19 8\n-1\n-1\n-1\n2000000000 1000000000\n0\n"]} | coding | 654 |
Solve the programming task below in a Python markdown code block.
Mr. Matsudaira is always careful about eco-friendliness in his life. Last month's water charge was 4280 yen, which exceeded the usual target of 4000 yen, so we have been trying to save water this month. How much have you saved on your water bill compared... | {"inputs": ["29\n1\n0\n-1", "29\n16\n-1\n1", "29\n60\n0\n-1", "29\n9\n-1\n-1", "29\n28\n0\n-1", "29\n24\n-1\n1", "29\n97\n0\n-1", "29\n16\n0\n-1"], "outputs": ["620\n3130\n3130\n", "620\n2380\n", "620\n-4320\n3130\n", "620\n3130\n", "620\n760\n3130\n", "620\n1320\n", "620\n-10240\n3130\n", "620\n2380\n3130\n"]} | coding | 512 |
Solve the programming task below in a Python markdown code block.
Consider the sequence `a(1) = 7, a(n) = a(n-1) + gcd(n, a(n-1)) for n >= 2`:
`7, 8, 9, 10, 15, 18, 19, 20, 21, 22, 33, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 69, 72, 73...`.
Let us take the differences between successive elements of the sequence ... | {"functional": "_inputs = [[1], [10], [100], [200], [1000], [10000], [100000]]\n_outputs = [[1], [8], [90], [184], [975], [9968], [99955]]\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 | 674 |
Solve the programming task below in a Python markdown code block.
There are several (or no) spiders, butterflies, and dragonflies.
In this kata, a spider has eight legs. A dragonfly or a butterfly has six legs. A __dragonfly__ has __two__ pairs of wings, while a __butterfly__ has __one__ pair of wings. __I am not sur... | {"functional": "_inputs = [[3, 20, 3]]\n_outputs = [[[1, 1, 1]]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return math.isclose(a, b, rel_tol=tol, abs_tol=tol)\n if isinstance(a, (list, tuple)):\n if len(a) != len(b): return False\n return... | coding | 314 |
Solve the programming task below in a Python markdown code block.
Consider X as the aleatory variable that count the number of letters in a word. Write a function that, give in input an array of words (strings), calculate the variance of X.
Max decimal of the variance : 4.
Some wiki: Variance ,
Aleatory variable ... | {"functional": "_inputs = [[['Hello', 'world']], [['Hi', 'world']], [['Variance', 'is', 'not', 'a', 'good', 'stimator']]]\n_outputs = [[0], [2.25], [7.5556]]\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 ... | coding | 383 |
Solve the programming task below in a Python markdown code block.
Given are an integer N and four characters c_{\mathrm{AA}}, c_{\mathrm{AB}}, c_{\mathrm{BA}}, and c_{\mathrm{BB}}.
Here, it is guaranteed that each of those four characters is A or B.
Snuke has a string s, which is initially AB.
Let |s| denote the length... | {"inputs": ["4\nA\nB\nB\nA\n", "2\nB\nA\nA\nA\n", "2\nA\nB\nA\nA\n", "2\nB\nB\nA\nA\n", "2\nA\nA\nB\nA\n", "2\nB\nA\nB\nA\n", "2\nA\nB\nB\nA\n", "2\nB\nB\nB\nA\n"], "outputs": ["2\n", "1\n", "1\n", "1\n", "1\n", "1\n", "1\n", "1\n"]} | coding | 547 |
Solve the programming task below in a Python markdown code block.
In mathematics, binomial coefficients are a family of positive integers that occur as coefficients in the binomial theorem.
$\left(\begin{matrix}n\\ k\end{matrix}\right)$
denotes the number of ways of choosing k objects from n different objects.
Howev... | {"inputs": ["3\n2 2\n3 2\n4 3\n"], "outputs": ["1\n0\n1\n"]} | coding | 266 |
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 its maximum depth.
A binary tree's maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.
Please complete the following... | {"functional": "def check(candidate):\n assert candidate(root = tree_node([3,9,20,None,None,15,7])) == 3\n assert candidate(root = tree_node([1,None,2])) == 2\n\n\ncheck(Solution().maxDepth)"} | coding | 141 |
Solve the programming task below in a Python markdown code block.
You are given a sequence of positive integers of length N, a = (a_1, a_2, ..., a_N). Your objective is to remove some of the elements in a so that a will be a good sequence.
Here, an sequence b is a good sequence when the following condition holds true:... | {"inputs": ["4\n0 3 3 3", "4\n3 3 3 3", "5\n2 4 1 4 1", "5\n1 4 2 4 2", "5\n1 4 1 4 1", "5\n1 4 1 4 2", "5\n1 3 2 4 2", "5\n1 3 3 4 2"], "outputs": ["1\n", "1", "4\n", "2\n", "4\n", "4\n", "2\n", "4\n"]} | coding | 377 |
Solve the programming task below in a Python markdown code block.
For the New Year, Polycarp decided to send postcards to all his $n$ friends. He wants to make postcards with his own hands. For this purpose, he has a sheet of paper of size $w \times h$, which can be cut into pieces.
Polycarp can cut any sheet of paper... | {"inputs": ["1\n1 001 1334\n", "1\n2 001 1334\n", "1\n2 011 1334\n", "1\n2 111 1334\n", "1\n98 101 9313\n", "1\n671 011 4442\n", "1\n671 011 7638\n", "1\n136 011 7638\n"], "outputs": ["NO\n", "NO\n", "NO\n", "NO\n", "NO\n", "NO\n", "NO\n", "NO\n"]} | coding | 703 |
Solve the programming task below in a Python markdown code block.
Consider the following $4 \times 4$ pattern:
1 2 4 7
3 5 8 11
6 9 12 14
10 13 15 16
You are given an integer $N$. Print the $N \times N$ pattern of the same kind (containing integers $1$ through $N^2$).
-----Input-----
- The first line of the inp... | {"inputs": ["1\n4"], "outputs": ["1 2 4 7\n3 5 8 11\n6 9 12 14\n10 13 15 16"]} | coding | 283 |
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 two integer arrays A and B each of size N. Let us define interaction of arrays A and B to be the sum of A[i] * B[i] for each i from 1 to N.
You want to maximiz... | {"inputs": ["2\n2 2\n2 1\n0 6\n3 9\n1 2 -3\n0 -1 -4", "2\n2 2\n1 2\n-4 6\n3 9\n1 2 -3\n-2 0 0", "2\n2 1\n0 2\n-3 3\n3 2\n1 2 -3\n0 3 -5", "2\n2 2\n1 2\n-2 3\n3 5\n1 2 -3\n-2 3 -5", "2\n2 2\n1 2\n-2 3\n3 2\n1 2 -3\n-2 3 -5", "2\n2 2\n0 2\n-2 3\n3 2\n1 2 -3\n-2 3 -5", "2\n2 1\n0 2\n-2 3\n3 2\n1 2 -3\n-2 3 -5", "2\n2 2\n1... | coding | 517 |
Solve the programming task below in a Python markdown code block.
A restaurant received n orders for the rental. Each rental order reserve the restaurant for a continuous period of time, the i-th order is characterized by two time values — the start time l_{i} and the finish time r_{i} (l_{i} ≤ r_{i}).
Restaurant mana... | {"inputs": ["1\n1 1\n", "1\n1 1\n", "1\n1 2\n", "1\n2 2\n", "1\n1 3\n", "1\n9 74\n", "1\n4 74\n", "1\n4 30\n"], "outputs": ["1\n", "1\n", "1\n", "1\n", "1\n", "1\n", "1\n", "1\n"]} | coding | 286 |
Solve the programming task below in a Python markdown code block.
Luntik has decided to try singing. He has $a$ one-minute songs, $b$ two-minute songs and $c$ three-minute songs. He wants to distribute all songs into two concerts such that every song should be included to exactly one concert.
He wants to make the abso... | {"inputs": ["4\n1 1 1\n2 1 3\n5 5 5\n1 1 2\n", "4\n1 1 1\n2 1 3\n5 2 5\n1 1 2\n", "4\n1 2 2\n2 1 1\n3 2 5\n1 1 2\n", "4\n1 2 2\n2 2 1\n3 2 2\n1 1 2\n", "4\n1 1 2\n2 2 1\n3 2 2\n2 1 2\n", "4\n2 2 0\n4 2 1\n6 4 5\n1 1 2\n", "4\n1 1 2\n2 2 1\n4 2 2\n2 1 2\n", "4\n2 2 0\n4 2 0\n6 4 5\n1 1 2\n"], "outputs": ["0\n1\n0\n1\n",... | coding | 398 |
Solve the programming task below in a Python markdown code block.
Read problems statements in Mandarin Chinese and Russian as well.
You are given a transparent three-dimensional table, the height equals to H and the base is a two-dimensional table N∙M.
The layers of the 3D table are numbered from 1 to H. Each layer i... | {"inputs": ["3 4 2\n6 1\n6 2", "2 2 3\n1 1\n1 2\n1 3", "1 2 3\n1 1\n1 2\n1 3", "1 2 3\n1 1\n1 1\n1 3", "1 2 3\n0 1\n1 1\n0 5", "1 2 3\n1 1\n1 3\n1 3", "1 2 3\n1 0\n1 1\n2 5", "1 2 3\n0 1\n2 3\n1 3"], "outputs": ["18", "Impossible", "3\n", "2\n", "Impossible\n", "4\n", "1\n", "6\n"]} | coding | 528 |
Solve the programming task below in a Python markdown code block.
# Definition
A **_Tidy number_** *is a number whose* **_digits are in non-decreasing order_**.
___
# Task
**_Given_** a number, **_Find if it is Tidy or not_** .
____
# Warm-up (Highly recommended)
# [Playing With Numbers Series](https://www.codew... | {"functional": "_inputs = [[12], [102], [9672], [2789], [2335]]\n_outputs = [[True], [False], [False], [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, (list, tuple)):\n ... | coding | 638 |
Solve the programming task below in a Python markdown code block.
You are given string s consists of opening and closing brackets of four kinds <>, {}, [], (). There are two types of brackets: opening and closing. You can replace any bracket by another of the same type. For example, you can replace < by the bracket {, ... | {"inputs": [">\n", ">\n", "]]\n", "{}\n", "{}\n", "{]\n", "{]\n", "{]\n"], "outputs": ["Impossible\n", "Impossible\n", "Impossible\n", "0\n", "0\n", "1\n", "1\n", "1\n"]} | coding | 307 |
Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given a 2D integer array grid of size m x n, where each cell contains a positive integer.
A cornered path is defined as a set of adjacent cells with at most one turn. More specifically, the path should exclusi... | {"functional": "def check(candidate):\n assert candidate(grid = [[23,17,15,3,20],[8,1,20,27,11],[9,4,6,2,21],[40,9,1,10,6],[22,7,4,5,3]]) == 3\n assert candidate(grid = [[4,3,2],[7,6,1],[8,8,8]]) == 0\n\n\ncheck(Solution().maxTrailingZeros)"} | coding | 222 |
Solve the programming task below in a Python markdown code block.
Theatre Square in the capital city of Berland has a rectangular shape with the size n × m meters. On the occasion of the city's anniversary, a decision was taken to pave the Square with square granite flagstones. Each flagstone is of the size a × a.
Wha... | {"inputs": ["1 1 3\n", "2 1 2\n", "2 2 1\n", "2 3 4\n", "2 1 1\n", "1 1 1\n", "1 2 1\n", "1 1 2\n"], "outputs": ["1\n", "1\n", "4\n", "1\n", "2\n", "1\n", "2\n", "1\n"]} | coding | 185 |
Solve the programming task below in a Python markdown code block.
Alice and Bob play the following game.They choose a number N to play with.The runs are as follows :
1.Bob plays first and the two players alternate.
2.In his/her turn ,a player can subtract from N any prime number(including 1) less than N.The numbe... | {"inputs": ["2\n1\n2"], "outputs": ["ALICE\nBOB"]} | coding | 273 |
Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given a 0-indexed array words consisting of distinct strings.
The string words[i] can be paired with the string words[j] if:
The string words[i] is equal to the reversed string of words[j].
0 <= i < j < words... | {"functional": "def check(candidate):\n assert candidate(words = [\"cd\",\"ac\",\"dc\",\"ca\",\"zz\"]) == 2\n assert candidate(words = [\"ab\",\"ba\",\"cc\"]) == 1\n assert candidate(words = [\"aa\",\"ab\"]) == 0\n\n\ncheck(Solution().maximumNumberOfStringPairs)"} | coding | 134 |
Solve the programming task below in a Python markdown code block.
You are given array a with n elements and the number m. Consider some subsequence of a and the value of least common multiple (LCM) of its elements. Denote LCM as l. Find any longest subsequence of a with the value l ≤ m.
A subsequence of a is an array ... | {"inputs": ["1 1\n2\n", "1 3\n5\n", "1 2\n3\n", "1 3\n2\n", "1 6\n5\n", "1 3\n5\n", "1 1\n2\n", "1 2\n3\n"], "outputs": ["1 0\n\n", "1 0\n\n", "1 0\n\n", "2 1\n1\n", "5 1\n1\n", "1 0\n", "1 0\n", "1 0\n"]} | coding | 336 |
Solve the programming task below in a Python markdown code block.
Aujasvit just came up with a new game to play with his friends. N people stand in a circle, each assigned an index from 1 to N in clockwise order. Then the following operation is done N-1 times.
The person with the lowest index holds a coin.
Then, the c... | {"inputs": ["1\n2 3\n"], "outputs": ["1 1 1"]} | coding | 476 |
Solve the programming task below in a Python markdown code block.
## Task:
You have to write a function `pattern` which returns the following Pattern(See Pattern & Examples) upto `n` number of rows.
* Note:`Returning` the pattern is not the same as `Printing` the pattern.
#### Rules/Note:
* If `n < 1` then it should... | {"functional": "_inputs = [[1], [2], [5], [0], [-25]]\n_outputs = [['1'], ['1\\n22'], ['1\\n22\\n333\\n4444\\n55555'], [''], ['']]\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, t... | coding | 388 |
Solve the programming task below in a Python markdown code block.
Everyone knows what a square looks like. Mathematically, a square is a regular quadrilateral. This means that it has four equal sides and four equal angles (90 degree angles).
One beautiful day, Johnny eagerly examined the interesting properties of squar... | {"inputs": ["1\n7\n0 0\n0 1\n1 0\n1 1\n1 2\n2 1\n2 2"], "outputs": ["3"]} | coding | 362 |
Solve the programming task below in a Python markdown code block.
Read problem statements in [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
You are given an integer N and a digit D. Find the minimum non-negetive integer you should add to N such that the final value of N does not contain the digit ... | {"inputs": ["5\n21 5\n8 8\n100 0\n5925 9\n434356 3\n"], "outputs": ["0\n1\n11\n75\n5644\n"]} | coding | 467 |
Solve the programming task below in a Python markdown code block.
You are given an array A of length N.
You can perform the following operation on the array any number of times:
Choose any [subsequence] S of the array A and a positive integer X such that X is a power of 2 and subtract X from all the elements of the s... | {"inputs": ["4\n3\n2 2 2\n4\n2 2 2 4\n2\n0 0\n3\n1 2 3\n"], "outputs": ["1\n2\n0\n2\n"]} | coding | 540 |
Solve the programming task below in a Python markdown code block.
Chef recently printed directions from his home to a hot new restaurant across the town, but forgot to print the directions to get back home. Help Chef to transform the directions to get home from the restaurant.
A set of directions consists of several in... | {"inputs": ["2\n4\nBegin on Road A\nRight on Road B\nRight on Road C\nLeft on Road D\n6\nBegin on Old Madras Road\nLeft on Domlur Flyover\nLeft on 100 Feet Road\nRight on Sarjapur Road\nRight on Hosur Road\nRight on Ganapathi Temple Road", "2\n4\nBegin on Road A\nRight on Road B\nRight on Road C\nLeft on Road D\n6\nBeg... | coding | 514 |
Solve the programming task below in a Python markdown code block.
Write a program to take two numbers as input and print their difference if the first number is greater than the second number otherwise$otherwise$ print their sum.
-----Input:-----
- First line will contain the first number (N1$N1$)
- Second line will c... | {"inputs": ["82\n28"], "outputs": ["54"]} | coding | 226 |
Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given an array of strings words and an integer k, return the k most frequent strings.
Return the answer sorted by the frequency from highest to lowest. Sort the words with the same frequency by their lexicographical o... | {"functional": "def check(candidate):\n assert candidate(words = [\"i\",\"love\",\"leetcode\",\"i\",\"love\",\"coding\"], k = 2) == [\"i\",\"love\"]\n assert candidate(words = [\"the\",\"day\",\"is\",\"sunny\",\"the\",\"the\",\"the\",\"sunny\",\"is\",\"is\"], k = 4) == [\"the\",\"is\",\"sunny\",\"day\"]\n\n\nchec... | coding | 98 |
Solve the programming task below in a Python markdown code block.
Your task is to calculate the sum (indicated by S) of all the k-balanced integers between [L, R]. An integer is called k-balanced when either of #1 or #2 below holds true.
The length of the integer <= k
Sum of the first k digits (with no leading ze... | {"inputs": ["9 23 1\n"], "outputs": ["42\n"]} | coding | 203 |
Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given four integers minLength, maxLength, oneGroup and zeroGroup.
A binary string is good if it satisfies the following conditions:
The length of the string is in the range [minLength, maxLength].
The size of... | {"functional": "def check(candidate):\n assert candidate(minLength = 2, maxLength = 3, oneGroup = 1, zeroGroup = 2) == 5\n assert candidate(minLength = 4, maxLength = 4, oneGroup = 4, zeroGroup = 3) == 1\n\n\ncheck(Solution().goodBinaryStrings)"} | coding | 247 |
Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given a 0-indexed 2D integer array flowers, where flowers[i] = [starti, endi] means the ith flower will be in full bloom from starti to endi (inclusive). You are also given a 0-indexed integer array people of ... | {"functional": "def check(candidate):\n assert candidate(flowers = [[1,6],[3,7],[9,12],[4,13]], people = [2,3,7,11]) == [1,2,2,2]\n assert candidate(flowers = [[1,10],[3,3]], people = [3,3,2]) == [2,2,1]\n\n\ncheck(Solution().fullBloomFlowers)"} | coding | 166 |
Solve the programming task below in a Python markdown code block.
Alice wants to send an email to Miku on her mobile phone.
The only buttons that can be used for input on mobile phones are number buttons. Therefore, in order to input characters, the number buttons are pressed several times to input characters. The fol... | {"inputs": ["5\n40\n0\n222220\n44033055505550666011011111090666077705550301110\n000555555550000330000444000080000200004440000", "5\n0\n20\n222220\n44033055505550666011011111090666077705550301110\n000555555550000330000444000080000200004440000", "5\n40\n30\n222220\n44033055505550666011011111090666077705550301110\n0005555... | coding | 539 |
Solve the programming task below in a Python markdown code block.
The Head Chef is receiving a lot of orders for cooking the best of the problems lately. For this, he organized an hiring event to hire some talented Chefs. He gave the following problem to test the skills of the participating Chefs. Can you solve this pr... | {"inputs": ["2\n2\n5\n\n"], "outputs": ["2\n8"]} | coding | 756 |
Solve the programming task below in a Python markdown code block.
You like the way the Python `+` operator easily handles adding different numeric types, but you need a tool to do that kind of addition without killing your program with a `TypeError` exception whenever you accidentally try adding incompatible types like... | {"functional": "_inputs = [[1, 3.414], [42, ' is the answer.'], [10, '2']]\n_outputs = [[4.414], [None], [None]]\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 i... | coding | 194 |
Solve the programming task below in a Python markdown code block.
Write a function which converts the input string to uppercase.
~~~if:bf
For BF all inputs end with \0, all inputs are lowercases and there is no space between.
~~~
Also feel free to reuse/extend the following starter code:
```python
def make_upper_case... | {"functional": "_inputs = [['hello'], ['hello world'], ['hello world !'], ['heLlO wORLd !'], ['1,2,3 hello world!']]\n_outputs = [['HELLO'], ['HELLO WORLD'], ['HELLO WORLD !'], ['HELLO WORLD !'], ['1,2,3 HELLO WORLD!']]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n ... | coding | 76 |
Solve the programming task below in a Python markdown code block.
Given an `array` of digital numbers, return a new array of length `number` containing the last even numbers from the original array (in the same order). The original array will be not empty and will contain at least "number" even numbers.
For example:
`... | {"functional": "_inputs = [[[1, 2, 3, 4, 5, 6, 7, 8, 9], 3], [[-22, 5, 3, 11, 26, -6, -7, -8, -9, -8, 26], 2], [[6, -25, 3, 7, 5, 5, 7, -3, 23], 1]]\n_outputs = [[[4, 6, 8]], [[-8, 26]], [[6]]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return math.isclose... | coding | 217 |
Solve the programming task below in a Python markdown code block.
Read problem statements in [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
You are an administrator of a popular quiz website. Every day, you hold a quiz on the website.
There are $N$ users (numbered $1$ through $N$) and $M$ admins ... | {"inputs": ["3\n1 1 1\n1\n1 1 2\n1 1\n5 5 10\n2 5 2 5 2 4 10 10 10 10"], "outputs": ["0\n1 1\n2 2 5"]} | coding | 570 |
Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given two positive integers n and target.
An integer is considered beautiful if the sum of its digits is less than or equal to target.
Return the minimum non-negative integer x such that n + x is beautiful. Th... | {"functional": "def check(candidate):\n assert candidate(n = 16, target = 6) == 4\n assert candidate(n = 467, target = 6) == 33\n assert candidate(n = 1, target = 1) == 0\n\n\ncheck(Solution().makeIntegerBeautiful)"} | coding | 112 |
Solve the programming task below in a Python markdown code block.
Let's call an array $a$ consisting of $n$ positive (greater than $0$) integers beautiful if the following condition is held for every $i$ from $1$ to $n$: either $a_i = 1$, or at least one of the numbers $a_i - 1$ and $a_i - 2$ exists in the array as wel... | {"inputs": ["4\n1\n3\n9\n9\n", "4\n1\n8\n7\n42\n", "4\n1\n1\n7\n42\n", "4\n1\n3\n7\n42\n", "4\n1\n1\n7\n27\n", "4\n1\n2\n7\n27\n", "4\n2\n3\n7\n27\n", "4\n2\n1\n9\n27\n"], "outputs": ["1\n2\n3\n3\n", "1\n3\n3\n7\n", "1\n1\n3\n7\n", "1\n2\n3\n7\n", "1\n1\n3\n6\n", "1\n2\n3\n6\n", "2\n2\n3\n6\n", "2\n1\n3\n6\n"]} | coding | 720 |
Solve the programming task below in a Python markdown code block.
Chef has two piles of stones with him, one has n1 stones and the other has n2 stones. Fired up by boredom, he invented a game with the two piles.
Before the start of the game Chef chooses an integer m.
In the j-th move:
- He chooses a number xj such... | {"inputs": ["3\n1 1 1\n1 2 1\n4 5 2"], "outputs": ["0\n1\n3"]} | coding | 622 |
Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given an integer array pref of size n. Find and return the array arr of size n that satisfies:
pref[i] = arr[0] ^ arr[1] ^ ... ^ arr[i].
Note that ^ denotes the bitwise-xor operation.
It can be proven that t... | {"functional": "def check(candidate):\n assert candidate(pref = [5,2,0,3,1]) == [5,7,2,3,2]\n assert candidate(pref = [13]) == [13]\n\n\ncheck(Solution().findArray)"} | coding | 111 |
Solve the programming task below in a Python markdown code block.
There is a house with $n$ flats situated on the main street of Berlatov. Vova is watching this house every night. The house can be represented as an array of $n$ integer numbers $a_1, a_2, \dots, a_n$, where $a_i = 1$ if in the $i$-th flat the light is o... | {"inputs": ["3\n0 0 0\n", "3\n1 0 1\n", "3\n1 1 1\n", "3\n0 1 1\n", "3\n1 1 0\n", "3\n1 0 0\n", "3\n0 1 0\n", "3\n0 0 1\n"], "outputs": ["0\n", "1\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n"]} | coding | 471 |
Solve the programming task below in a Python markdown code block.
The new "Die Hard" movie has just been released! There are n people at the cinema box office standing in a huge line. Each of them has a single 100, 50 or 25 ruble bill. A "Die Hard" ticket costs 25 rubles. Can the booking clerk sell a ticket to each per... | {"inputs": ["1\n50\n", "1\n50\n", "2\n25 25\n", "2\n50 25\n", "2\n50 25\n", "2\n25 25\n", "2\n25 100\n", "2\n25 100\n"], "outputs": ["NO\n", "NO\n", "YES\n", "NO\n", "NO\n", "YES\n", "NO\n", "NO\n"]} | coding | 288 |
Solve the programming task below in a Python markdown code block.
Read problems statements in Mandarin and Russian. Translations in Vietnamese to be uploaded soon.
You are given an integer N. Consider a vector a of length N^{2} accessible via 0-based indexing.
Let's call the following transformation a TVT-transformati... | {"inputs": ["2\n1\n2"], "outputs": ["YES\n1\nYES\n1 1 1 -1"]} | coding | 341 |
Solve the programming task below in a Python markdown code block.
This year, as in previous years, MemSQL is inviting the top 25 competitors from the Start[c]up qualification round to compete onsite for the final round. Not everyone who is eligible to compete onsite can afford to travel to the office, though. Initially... | {"inputs": ["1\n1\n", "1\n1\n", "1\n2\n", "1\n4\n", "1\n3\n", "1\n8\n", "1\n6\n", "1\n9\n"], "outputs": ["0\n", "0", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n"]} | coding | 432 |
Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given an integer array nums and an integer k, return true if there are two distinct indices i and j in the array such that nums[i] == nums[j] and abs(i - j) <= k.
Please complete the following python code precisely:... | {"functional": "def check(candidate):\n assert candidate(nums = [1,2,3,1], k = 3) == True\n assert candidate(nums = [1,0,1,1], k = 1) == True\n assert candidate(nums = [1,2,3,1,2,3], k = 2) == False\n\n\ncheck(Solution().containsNearbyDuplicate)"} | coding | 96 |
Solve the programming task below in a Python markdown code block.
Daniel is watching a football team playing a game during their training session. They want to improve their passing skills during that session.
The game involves $n$ players, making multiple passes towards each other. Unfortunately, since the balls were... | {"inputs": ["1\n2\n1000000000 0\n", "1\n5\n1000000000 1000000000 1000000000 1000000000 1000000000\n", "1\n6\n100000000 999999999 999999999 999999999 999999999 1000000000\n", "4\n4\n2 3 3 2\n3\n1 5 2\n2\n0 0\n4\n1000000000 1000000000 1000000000 1000000000\n", "1\n10\n1000000000 1000000000 1000000000 1000000000 100000000... | coding | 552 |
Solve the programming task below in a Python markdown code block.
Given an array A of size N.
You can do the following operation on the array:
Pick any 2 distinct indices i and j such that A_{i}=A_{j};
Change all the elements between the indices i and j to A_{i}, i.e, for all k (i ≤ k ≤ j), set A_{k}=A_{i}.
Find the... | {"inputs": ["2\n6\n1 2 1 3 4 3\n3\n3 1 2"], "outputs": ["2\n-1"]} | coding | 497 |
Solve the programming task below in a Python markdown code block.
In computer science, cycle detection is the algorithmic problem of finding a cycle in a sequence of iterated function values.
For any function ƒ, and any initial value x0 in S, the sequence of iterated function values
x0,x1=f(x0), x2=f(x1), ...,xi=... | {"functional": "_inputs = [[[2, 3, 4, 2, 3, 4]], [[1, 2, 3, 4, 2, 3, 4]], [[1, 1, 1, 1, 1, 1, 1, 1]], [[]], [[7]], [[1, 2, 3, 4]]]\n_outputs = [[[0, 3]], [[1, 3]], [[0, 1]], [[]], [[]], [[]]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return math.isclose(a... | coding | 508 |
Solve the programming task below in a Python markdown code block.
When multiple master devices are connected to a single bus (https://en.wikipedia.org/wiki/System_bus), there needs to be an arbitration in order to choose which of them can have access to the bus (and 'talk' with a slave).
We implement here a very simpl... | {"functional": "_inputs = [['001000101', 9], ['000000101', 9], ['0000', 4]]\n_outputs = [['001000000'], ['000000100'], ['0000']]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return math.isclose(a, b, rel_tol=tol, abs_tol=tol)\n if isinstance(a, (list, tup... | coding | 303 |
Solve the programming task below in a Python markdown code block.
You are given an array with several `"even"` words, one `"odd"` word, and some numbers mixed in.
Determine if any of the numbers in the array is the index of the `"odd"` word. If so, return `true`, otherwise `false`.
Also feel free to reuse/extend the f... | {"functional": "_inputs = [[['even', 4, 'even', 7, 'even', 55, 'even', 6, 'even', 10, 'odd', 3, 'even']], [['even', 4, 'even', 7, 'even', 55, 'even', 6, 'even', 9, 'odd', 3, 'even']], [['even', 10, 'odd', 2, 'even']]]\n_outputs = [[True], [False], [True]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a... | coding | 89 |
Solve the programming task below in a Python markdown code block.
The store sells $n$ items, the price of the $i$-th item is $p_i$. The store's management is going to hold a promotion: if a customer purchases at least $x$ items, $y$ cheapest of them are free.
The management has not yet decided on the exact values of $... | {"inputs": ["2 1\n100 200\n1 1\n", "1 1\n1000000\n1 1\n", "3 1\n100 200 100\n2 1\n", "2 2\n100 200\n2 2\n2 1\n", "5 3\n5 3 1 5 2\n3 2\n1 1\n5 3\n", "5 2\n100 200 300 400 500\n1 1\n3 2\n", "5 3\n100 200 300 400 500\n2 1\n1 1\n3 2\n", "5 3\n100 200 300 400 500\n1 1\n3 2\n2 2\n"], "outputs": ["200\n", "1000000\n", "100\n"... | coding | 477 |
Solve the programming task below in a Python markdown code block.
Given a string consisting of only lowercase English alphabets, your task is to find the smallest palindromic substring.
In case there are multiple palindromic substrings of the same length present, print the lexicographically smallest substring.
Formall... | {"inputs": ["2\n2\nzy\n1\ncd"], "outputs": ["y\nc"]} | coding | 325 |
Solve the programming task below in a Python markdown code block.
Little Joty has got a task to do. She has a line of n tiles indexed from 1 to n. She has to paint them in a strange pattern.
An unpainted tile should be painted Red if it's index is divisible by a and an unpainted tile should be painted Blue if it's ind... | {"inputs": ["1 1 1 1 1\n", "1 2 2 2 2\n", "2 1 3 3 3\n", "3 1 1 3 3\n", "4 1 5 4 3\n", "8 8 1 1 1\n", "6 6 2 8 2\n", "5 2 2 4 1\n"], "outputs": ["1\n", "0\n", "6\n", "9\n", "16\n", "8\n", "12\n", "8\n"]} | coding | 300 |
Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given a wooden stick of length n units. The stick is labelled from 0 to n. For example, a stick of length 6 is labelled as follows:
Given an integer array cuts where cuts[i] denotes a position you should perform a cu... | {"functional": "def check(candidate):\n assert candidate(n = 7, cuts = [1,3,4,5]) == 16\n assert candidate(n = 9, cuts = [5,6,1,4,2]) == 22\n\n\ncheck(Solution().minCost)"} | coding | 204 |
Solve the programming task below in a Python markdown code block.
You are given an $array$ of size $N$ and an integer $K$ ( $N > 1 , K > 0$ ).
Each element in the array can be incremented by $K$ or decremented by $K$ $at$ $most$ $once$.
So there will be $3^n$ possible combinations of final array. (As there are 3 optio... | {"inputs": ["2\n4 3\n4 2 5 1\n3 5\n2 5 3"], "outputs": ["10\n13"]} | coding | 335 |
Solve the programming task below in a Python markdown code block.
There are $n$ red balls kept on the positive $X$ axis, and $m$ blue balls kept on the positive $Y$ axis. You are given the positions of the balls. For each $i$ from $1$ to $n$, the $i$-th red ball has the coordinates $(x_i, 0)$, where $x_i$ is a positive... | {"inputs": ["1 1\n1 2\n2 1\n", "1 2\n1 2\n2 1\n1 2\n"], "outputs": ["1", "1"]} | coding | 754 |
Solve the programming task below in a Python markdown code block.
Shubham recently learned the lexicographical order in strings.
Now, he has two strings s1 and s2 of the equal size and Shubham wants to compare those two strings lexicographically.
Help Shubham with the strings comparison.
Note:
Letters are case i... | {"inputs": ["2\nabc\nacb\nAB\nba"], "outputs": ["first\nfirst"]} | coding | 200 |
Solve the programming task below in a Python markdown code block.
Passer ratings are the generally accepted standard for evaluating NFL quarterbacks.
I knew a rating of 100 is pretty good, but never knew what makes up the rating.
So out of curiosity I took a look at the wikipedia page and had an idea or my first kata: ... | {"functional": "_inputs = [[432, 3554, 291, 28, 2], [5, 76, 4, 1, 0], [48, 192, 19, 2, 3], [1, 2, 1, 1, 0], [34, 172, 20, 1, 1], [10, 17, 2, 0, 1]]\n_outputs = [[112.2], [158.3], [39.6], [118.8], [69.7], [0.0]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n re... | coding | 325 |
Solve the programming task below in a Python markdown code block.
Valerian was captured by Shapur. The victory was such a great one that Shapur decided to carve a scene of Valerian's defeat on a mountain. So he had to find the best place to make his victory eternal!
He decided to visit all n cities of Persia to find t... | {"inputs": ["1\n", "2\n2 1 5\n", "2\n2 1 89\n", "2\n2 1 17\n", "2\n2 1 140\n", "3\n1 2 0\n2 3 0\n", "3\n1 2 3\n2 3 5\n", "3\n1 2 3\n2 3 3\n"], "outputs": ["0", "5", "89", "17\n", "140\n", "0", "8\n", "6\n"]} | coding | 377 |
Solve the programming task below in a Python markdown code block.
You are asked to write a simple cypher that rotates every character (in range [a-zA-Z], special chars will be ignored by the cipher) by 13 chars. As an addition to the original ROT13 cipher, this cypher will also cypher numerical digits ([0-9]) with 5 ch... | {"functional": "_inputs = [['The quick brown fox jumps over the 2 lazy dogs'], ['Gur dhvpx oebja sbk whzcf bire gur 7 ynml qbtf'], ['1234567890'], ['12_-56789.']]\n_outputs = [['Gur dhvpx oebja sbk whzcf bire gur 7 ynml qbtf'], ['The quick brown fox jumps over the 2 lazy dogs'], ['6789012345'], ['67_-01234.']]\nimport ... | coding | 229 |
Solve the programming task below in a Python markdown code block.
The server in company A has a structure where N devices numbered 1, 2, ..., N are connected with N - 1 cables. The i-th cable connects Device U_i and Device V_i. Any two different devices are connected through some number of cables.
Each device v (1 \le... | {"inputs": ["4\n1 2 3 4\n1 2\n2 3\n1 4", "4\n1 2 3 4\n2 2\n2 3\n1 4", "4\n1 2 4 4\n1 2\n2 3\n1 4", "4\n1 2 3 6\n2 2\n2 3\n1 4", "4\n1 2 3 6\n2 2\n1 3\n1 4", "4\n1 2 3 4\n1 2\n2 3\n2 4", "4\n1 2 0 4\n2 2\n2 3\n1 4", "4\n1 2 6 4\n1 2\n2 3\n2 4"], "outputs": ["0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n"]} | coding | 695 |
Solve the programming task below in a Python markdown code block.
The king Copa often has been reported about the Codeforces site, which is rapidly getting more and more popular among the brightest minds of the humanity, who are using it for training and competing. Recently Copa understood that to conquer the world he ... | {"inputs": ["02.05.90\n08.03.50\n", "29.02.80\n29.02.60\n", "15.12.62\n17.12.21\n", "08.07.20\n27.01.01\n", "09.05.55\n25.09.42\n", "28.02.20\n11.01.29\n", "06.08.91\n05.12.73\n", "31.05.20\n02.12.04\n"], "outputs": ["YES\n", "YES\n", "YES\n", "YES\n", "NO\n", "YES\n", "YES\n", "YES\n"]} | coding | 623 |
Solve the programming task below in a Python markdown code block.
Gotham city is in danger. All the people from Gotham were airlifted and they are going to be dropped at different districts of a new safe city.
There are $N$ districts located at position $(1, 2, \ldots, N)$ in a straight line in this newly built safe c... | {"inputs": ["4\n5 5 6 1\n2\n2 11\n2 3\n"], "outputs": ["6\n2\n"]} | coding | 568 |
Solve the programming task below in a Python markdown code block.
There are N people standing in a row from west to east. Each person is facing east or west. The directions of the people is given as a string S of length N. The i-th person from the west is facing east if S_i = `E`, and west if S_i = `W`.
You will appoi... | {"inputs": ["5\nWWEEW", "5\nEWEWW", "5\nWWEWE", "5\nWEWEW", "5\nWEWWE", "5\nEWWWE", "5\nEWWEW", "5\nWWWEE"], "outputs": ["2\n", "1\n", "2\n", "2\n", "2\n", "1\n", "1\n", "2\n"]} | coding | 275 |
Solve the programming task below in a Python markdown code block.
The __Hamming weight__ of a string is the number of symbols that are different from the zero-symbol of the alphabet used. There are several algorithms for efficient computing of the Hamming weight for numbers. In this Kata, speaking technically, you have... | {"functional": "_inputs = [[0], [1], [2], [10], [21], [2048]]\n_outputs = [[0], [1], [1], [2], [3], [1]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return math.isclose(a, b, rel_tol=tol, abs_tol=tol)\n if isinstance(a, (list, tuple)):\n if len(a)... | coding | 135 |
Solve the programming task below in a Python markdown code block.
# Task
John has an important number, and he doesn't want others to see it.
He decided to encrypt the number, using the following steps:
```
His number is always a non strict increasing sequence
ie. "123"
He converted each digit into English words.
ie.... | {"functional": "_inputs = [['ONE'], ['OEN'], ['ONETWO'], ['OONETW'], ['TTONWOHREEE']]\n_outputs = [['1'], ['1'], ['12'], ['12'], ['123']]\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 | 337 |
Solve the programming task below in a Python markdown code block.
You have two arrays in this kata, every array contain only unique elements. Your task is to calculate number of elements in first array which also are in second array.
Also feel free to reuse/extend the following starter code:
```python
def match_arrays(... | {"functional": "_inputs = [[['Perl', 'Closure', 'JavaScript'], ['Go', 'C++', 'Erlang']], [['Erlang', 'JavaScript'], ['Go', 'C++', 'Python']], [[True, 3, 9, 11, 15], [True, 3, 11]]]\n_outputs = [[0], [0], [3]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n retu... | coding | 69 |
Solve the programming task below in a Python markdown code block.
Ivan recently bought a detective book. The book is so interesting that each page of this book introduces some sort of a mystery, which will be explained later. The $i$-th page contains some mystery that will be explained on page $a_i$ ($a_i \ge i$).
Iva... | {"inputs": ["1\n1\n", "1\n1\n", "4\n1 2 4 4\n", "4\n1 2 4 4\n", "4\n2 2 4 4\n", "4\n2 4 4 4\n", "9\n1 3 3 6 7 6 8 8 9\n", "9\n1 3 3 6 7 6 8 8 9\n"], "outputs": ["1\n", "1\n", "3\n", "3\n", "2\n", "1\n", "4\n", "4\n"]} | coding | 393 |
Solve the programming task below in a Python markdown code block.
Sherlock Holmes has decided to start a new academy to some of the young lads. He has conducted several tests and finally selected N equally brilliant
students.Now he don't know whether to train all the N students or not. Now since Holmes was in a confus... | {"inputs": ["2\n5\n2 3 5 1 2\n3\n1 2 3"], "outputs": ["3\n3"]} | coding | 613 |
Solve the programming task below in a Python markdown code block.
You are given an array of integers $a_1,a_2,\ldots,a_n$. Find the maximum possible value of $a_ia_ja_ka_la_t$ among all five indices $(i, j, k, l, t)$ ($i<j<k<l<t$).
-----Input-----
The input consists of multiple test cases. The first line contains an... | {"inputs": ["1\n5\n-3000 -777 -3000 810 831\n", "1\n5\n-3000 -777 -3123 810 831\n", "1\n5\n-3000 -777 -1726 810 831\n", "1\n5\n-3000 -777 -3123 810 176\n", "1\n5\n-3000 -777 -3000 810 3000\n", "1\n5\n-3000 -777 -3000 2024 3000\n", "1\n5\n-3000 -1535 -3000 3000 349\n", "1\n5\n-3000 -216 -3000 2024 3000\n"], "outputs": [... | coding | 563 |
Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given an alphanumeric string s, return the second largest numerical digit that appears in s, or -1 if it does not exist.
An alphanumeric string is a string consisting of lowercase English letters and digits.
Please ... | {"functional": "def check(candidate):\n assert candidate(s = \"dfa12321afd\") == 2\n assert candidate(s = \"abc1111\") == -1\n\n\ncheck(Solution().secondHighest)"} | coding | 87 |
Solve the programming task below in a Python markdown code block.
In the final of CODE FESTIVAL in some year, there are N participants. The height and power of Participant i is H_i and P_i, respectively.
Ringo is hosting a game of stacking zabuton (cushions).
The participants will line up in a row in some order, and ... | {"inputs": ["3\n2 4\n3 1\n4 2", "3\n0 2\n1 0\n3 4", "3\n2 7\n3 1\n4 1", "3\n0 0\n1 0\n3 4", "3\n3 7\n3 1\n4 1", "3\n0 0\n1 0\n6 4", "3\n3 7\n3 2\n4 1", "3\n0 0\n1 0\n6 3"], "outputs": ["2\n", "3\n", "3\n", "3\n", "3\n", "3\n", "3\n", "3\n"]} | coding | 378 |
Solve the programming task below in a Python markdown code block.
Giga Tower is the tallest and deepest building in Cyberland. There are 17 777 777 777 floors, numbered from - 8 888 888 888 to 8 888 888 888. In particular, there is floor 0 between floor - 1 and floor 1. Every day, thousands of tourists come to this p... | {"inputs": ["0\n", "2\n", "4\n", "6\n", "8\n", "6\n", "4\n", "2\n"], "outputs": ["8\n", "6\n", "4\n", "2\n", "10\n", "2\n", "4\n", "6\n"]} | coding | 436 |
Solve the programming task below in a Python markdown code block.
Mario's bullet moves at X pixels per frame. He wishes to shoot a goomba standing Y pixels away from him. The goomba does not move.
Find the minimum time (in seconds) after which Mario should shoot the bullet, such that it hits the goomba after at least... | {"inputs": ["3\n3 3 5\n2 4 1\n3 12 8"], "outputs": ["4\n0\n4"]} | coding | 505 |
Solve the programming task below in a Python markdown code block.
Aizu is famous for its buckwheat. There are many people who make buckwheat noodles by themselves.
One day, you went shopping to buy buckwheat flour. You can visit three shops, A, B and C. The amount in a bag and its unit price for each shop is determine... | {"inputs": ["500\n1000\n0", "500\n0000\n0", "500\n1100\n0", "500\n0000\n1", "500\n0000\n2", "500\n0000\n4", "500\n0000\n8", "500\n0000\n3"], "outputs": ["850\n1520\n", "850\n", "850\n1950\n", "850\n", "850\n", "850\n", "850\n", "850\n"]} | coding | 454 |
Solve the programming task below in a Python markdown code block.
Mishka started participating in a programming contest. There are $n$ problems in the contest. Mishka's problem-solving skill is equal to $k$.
Mishka arranges all problems from the contest into a list. Because of his weird principles, Mishka only solves ... | {"inputs": ["1 5\n4\n", "1 2\n1\n", "1 1\n2\n", "1 5\n1\n", "1 4\n2\n", "1 1\n1\n", "1 6\n3\n", "1 5\n5\n"], "outputs": ["1\n", "1\n", "0\n", "1\n", "1\n", "1\n", "1\n", "1\n"]} | coding | 592 |
Solve the programming task below in a Python markdown code block.
Given a string as input, move all of its vowels to the end of the string, in the same order as they were before.
Vowels are (in this kata): `a, e, i, o, u`
Note: all provided input strings are lowercase.
## Examples
```python
"day" ==> "dya"
"appl... | {"functional": "_inputs = [['day'], ['apple'], ['peace'], ['maker'], ['programming'], ['javascript'], ['python'], ['ruby'], ['haskell'], ['clojure'], ['csharp']]\n_outputs = [['dya'], ['pplae'], ['pceae'], ['mkrae'], ['prgrmmngoai'], ['jvscrptaai'], ['pythno'], ['rbyu'], ['hskllae'], ['cljroue'], ['cshrpa']]\nimport ma... | coding | 121 |
Solve the programming task below in a Python markdown code block.
Write a function named sumDigits which takes a number as input and returns the sum of the absolute value of each of the number's decimal digits. For example:
```python
sum_digits(10) # Returns 1
sum_digits(99) # Returns 18
sum_digits(-32) # Ret... | {"functional": "_inputs = [[10], [99], [-32], [1234567890], [0], [666], [100000002], [800000009]]\n_outputs = [[1], [18], [5], [45], [0], [18], [3], [17]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return math.isclose(a, b, rel_tol=tol, abs_tol=tol)\n i... | coding | 125 |
Solve the programming task below in a Python markdown code block.
Read problem statements in [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Given a binary string $S$ consisting of $0's$ and $1's$, find whether there exists a rightwise [circular rotation] of the string such that every 2 adjacent $... | {"inputs": ["3\n4 1\n1100\n4 0\n0101\n6 1\n101001"], "outputs": ["YES\nNO\nYES"]} | coding | 577 |
Solve the programming task below in a Python markdown code block.
Having written another programming contest, three Rabbits decided to grab some lunch. The coach gave the team exactly k time units for the lunch break.
The Rabbits have a list of n restaurants to lunch in: the i-th restaurant is characterized by two int... | {"inputs": ["1 5\n1 7\n", "1 2\n0 8\n", "1 7\n1 7\n", "1 5\n1 7\n", "1 5\n1 13\n", "1 4\n1 13\n", "1 4\n0 13\n", "1 2\n0 13\n"], "outputs": ["-1\n", "-6\n", "1\n", "-1\n", "-7\n", "-8\n", "-9\n", "-11\n"]} | coding | 413 |
Solve the programming task below in a Python markdown code block.
Chef solved so many hard questions, now he wants to solve some easy problems for refreshment. Chef asks Cheffina for the new question. Cheffina challanges the chef to print the total number of 1's in the binary representation of N(natural number).
-----... | {"inputs": ["2\n2\n5"], "outputs": ["1\n2"]} | coding | 236 |
Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given an n x n integer matrix grid, return the minimum sum of a falling path with non-zero shifts.
A falling path with non-zero shifts is a choice of exactly one element from each row of grid such that no two elements... | {"functional": "def check(candidate):\n assert candidate(grid = [[1,2,3],[4,5,6],[7,8,9]]) == 13\n assert candidate(grid = [[7]]) == 7\n\n\ncheck(Solution().minFallingPathSum)"} | coding | 108 |
Solve the programming task below in a Python markdown code block.
Alex decided to go on a touristic trip over the country.
For simplicity let's assume that the country has $n$ cities and $m$ bidirectional roads connecting them. Alex lives in city $s$ and initially located in it. To compare different cities Alex assign... | {"inputs": ["1 0\n1000000000\n1\n", "1 0\n1000000000\n1\n", "1 0\n1000000000\n1\n", "1 0\n1000010000\n1\n", "2 1\n999999999 2\n1 2\n2\n", "2 1\n999999999 2\n1 2\n2\n", "2 1\n999999999 2\n1 2\n2\n", "2 1\n999999999 4\n1 2\n2\n"], "outputs": ["1000000000\n", "1000000000\n", "1000000000\n", "1000010000\n", "1000000001\n",... | coding | 586 |
Please solve the programming task below using a self-contained code snippet in a markdown code block.
Suppose an array of length n sorted in ascending order is rotated between 1 and n times. For example, the array nums = [0,1,4,4,5,6,7] might become:
[4,5,6,7,0,1,4] if it was rotated 4 times.
[0,1,4,4,5,6,7] if it wa... | {"functional": "def check(candidate):\n assert candidate(nums = [1,3,5]) == 1\n assert candidate(nums = [2,2,2,0,1]) == 0\n\n\ncheck(Solution().findMin)"} | coding | 226 |
Solve the programming task below in a Python markdown code block.
# Task
You are the manager of the famous rescue team: The Knights. Your task is to assign your knights to a rescue missions on an infinite 2D-plane.
Your knights can move only by `n-knight` jumps.
For example, if a knight has n = 2, they can only ... | {"functional": "_inputs = [[[2], 2, 1], [[1], 10, 10], [[1], 1, 0], [[1, 2], 1, 0], [[1, 2, 3], 456546, 23532], [[1, 5, 3, 7, 9], 7, 8], [[1, 1, 1, 1, 1, 1, 1, 1, 1], 0, 1]]\n_outputs = [[True], [True], [False], [True], [True], [False], [False]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) o... | coding | 361 |
Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given an array of CPU tasks, each labeled with a letter from A to Z, and a number n. Each CPU interval can be idle or allow the completion of one task. Tasks can be completed in any order, but there's a constr... | {"functional": "def check(candidate):\n assert candidate(tasks = [\"A\",\"A\",\"A\",\"B\",\"B\",\"B\"], n = 2) == 8\n assert candidate(tasks = [\"A\",\"A\",\"A\",\"B\",\"B\",\"B\"], n = 0) == 6\n assert candidate(tasks = [\"A\",\"A\",\"A\",\"A\",\"A\",\"A\",\"B\",\"C\",\"D\",\"E\",\"F\",\"G\"], n = 2) == 16\n\... | coding | 136 |
Solve the programming task below in a Python markdown code block.
Alice and Bob are playing the game of Nim with $n$ piles of stones with sizes $p_0,p_1,\ldots,p_{n-1}$. If Alice plays first, she loses if and only if the 'xor sum' (or 'Nim sum') of the piles is zero, i.e., $p_0\oplus p_1\oplus...\oplus p_{n-1}=0$.
Sin... | {"inputs": ["3\n1 2 3\n", "10\n10 10 1 1 1 1 1 10 10 10\n"], "outputs": ["4\n", "321616\n"]} | coding | 467 |
Solve the programming task below in a Python markdown code block.
# Task
Given a sequence of 0s and 1s, determine if it is a prefix of Thue-Morse sequence.
The infinite Thue-Morse sequence is obtained by first taking a sequence containing a single 0 and then repeatedly concatenating the current sequence with its bin... | {"functional": "_inputs = [[[0, 1, 1, 0, 1]], [[0]], [[1]], [[0, 1, 0, 0]]]\n_outputs = [[True], [True], [False], [False]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return math.isclose(a, b, rel_tol=tol, abs_tol=tol)\n if isinstance(a, (list, tuple)):\... | coding | 322 |
Solve the programming task below in a Python markdown code block.
Andrewid the Android is a galaxy-famous detective. He is now chasing a criminal hiding on the planet Oxa-5, the planet almost fully covered with water.
The only dry land there is an archipelago of n narrow islands located in a row. For more comfort let'... | {"inputs": ["2 1\n1 2\n5 6\n1\n", "2 1\n1 2\n5 6\n1\n", "2 1\n1 2\n5 3\n2\n", "2 1\n0 2\n5 3\n2\n", "2 1\n1 2\n5 6\n0\n", "2 1\n1 2\n5 10\n1\n", "2 1\n1 2\n5 10\n2\n", "2 1\n1 1\n100 100\n5\n"], "outputs": ["No\n", "No\n", "No\n", "No\n", "No\n", "No\n", "No\n", "No\n"]} | coding | 741 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.