task_type stringclasses 1
value | problem stringlengths 261 3.34k | answer stringlengths 35 6.15k | problem_tokens int64 62 774 | answer_tokens int64 12 2.04k |
|---|---|---|---|---|
coding | Solve the programming task below in a Python markdown code block.
Vasya plays the Need For Brake. He plays because he was presented with a new computer wheel for birthday! Now he is sure that he will win the first place in the championship in his favourite racing computer game!
n racers take part in the championship,... | {"inputs": ["2\nteama 10\nteamb 10\n2\n10 10\nteamb\n", "3\nteama 10\nteamb 20\nteamc 40\n2\n10 20\nteama\n", "5\nteamc 8\nteamd 7\nteame 15\nteama 3\nteamb 21\n3\n1 2 3\nteamb\n", "5\nteamc 4\nteamd 7\nteame 15\nteama 3\nteamb 21\n3\n1 2 3\nteamb\n", "5\ntaemc 4\nteamd 7\nteame 15\nteama 3\nteamb 21\n3\n1 2 3\nteamb\n... | 464 | 377 |
coding | Solve the programming task below in a Python markdown code block.
Given an integer a as input, print the value a + a^2 + a^3.
-----Constraints-----
- 1 \leq a \leq 10
- a is an integer.
-----Input-----
Input is given from Standard Input in the following format:
a
-----Output-----
Print the value a + a^2 + a^3 as a... | {"inputs": ["1", "0", "3", "4", "6", "7", "5", "9"], "outputs": ["3\n", "0\n", "39\n", "84\n", "258\n", "399\n", "155\n", "819\n"]} | 169 | 72 |
coding | Solve the programming task below in a Python markdown code block.
```if-not:swift
Write simple .camelCase method (`camel_case` function in PHP, `CamelCase` in C# or `camelCase` in Java) for strings. All words must have their first letter capitalized without spaces.
```
```if:swift
Write a simple `camelCase` function fo... | {"functional": "_inputs = [['test case'], ['camel case method'], ['say hello '], [' camel case word'], ['']]\n_outputs = [['TestCase'], ['CamelCaseMethod'], ['SayHello'], ['CamelCaseWord'], ['']]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return math.isclo... | 196 | 191 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given an integer array nums. The unique elements of an array are the elements that appear exactly once in the array.
Return the sum of all the unique elements of nums.
Please complete the following python co... | {"functional": "def check(candidate):\n assert candidate(nums = [1,2,3,2]) == 4\n assert candidate(nums = [1,1,1,1,1]) == 0\n assert candidate(nums = [1,2,3,4,5]) == 15\n\n\ncheck(Solution().sumOfUnique)"} | 85 | 79 |
coding | Solve the programming task below in a Python markdown code block.
E869120 found a chest which is likely to contain treasure.
However, the chest is locked. In order to open it, he needs to enter a string S consisting of lowercase English letters.
He also found a string S', which turns out to be the string S with some ... | {"inputs": [">q???d?>\n_ba", "d>>>???q\na`a", "d>>>???q\naaa", "??p??d??\nabb", "??p??d??\n`bb", "??p??d??\n`ab", "??p??d??\nba`", "??p??d??\nb``"], "outputs": [">q_bada>\n", "d>>>a`aq\n", "d>>>aaaq\n", "UNRESTORABLE\n", "UNRESTORABLE\n", "UNRESTORABLE\n", "UNRESTORABLE\n", "UNRESTORABLE\n"]} | 313 | 146 |
coding | Solve the programming task below in a Python markdown code block.
Iahub and Iahubina went to a picnic in a forest full of trees. Less than 5 minutes passed before Iahub remembered of trees from programming. Moreover, he invented a new problem and Iahubina has to solve it, otherwise Iahub won't give her the food.
Iahu... | {"inputs": ["1\n1\n", "1\n1\n", "2\n1 2\n", "2\n1 2\n", "2\n2 2\n", "4\n1 1 1 4\n", "4\n1 1 1 3\n", "4\n1 1 1 3\n"], "outputs": ["YES", "YES\n", "NO", "NO\n", "NO\n", "YES", "NO", "NO\n"]} | 327 | 106 |
coding | Solve the programming task below in a Python markdown code block.
There are two small spaceship, surrounded by two groups of enemy larger spaceships. The space is a two-dimensional plane, and one group of the enemy spaceships is positioned in such a way that they all have integer y-coordinates, and their x-coordinate i... | {"inputs": ["1 1\n0\n0\n", "1 1\n1\n1\n", "1 1\n0\n1\n", "1 1\n5\n5\n", "1 1\n0\n-1\n", "2 2\n0 2\n0 1\n", "1 5\n1\n1 2 3 4 5\n", "3 3\n0 0 0\n0 0 0\n"], "outputs": ["2\n", "2\n", "2\n", "2\n", "2\n", "4\n", "3\n", "6\n"]} | 582 | 139 |
coding | Solve the programming task below in a Python markdown code block.
Given are an integer K and integers a_1,\dots, a_K. Determine whether a sequence P satisfying below exists. If it exists, find the lexicographically smallest such sequence.
* Every term in P is an integer between 1 and K (inclusive).
* For each i=1,\dot... | {"inputs": ["3\n1 1 1", "3\n1 1 2", "3\n1 2 2", "3\n2 1 2", "3\n2 1 1", "3\n2 2 4", "3\n2 4 4", "3\n2 2 1"], "outputs": ["1 2 3 \n", "3 1 2 3 \n", "2 3 1 2 3 \n", "1 3 2 1 3 \n", "1 2 3 1 \n", "3 1 2 3 3 1 2 3 \n", "2 3 1 2 3 2 3 1 2 3 \n", "1 2 3 1 2 \n"]} | 329 | 190 |
coding | Solve the programming task below in a Python markdown code block.
Bear Limak wants to become the largest of bears, or at least to become larger than his brother Bob.
Right now, Limak and Bob weigh a and b respectively. It's guaranteed that Limak's weight is smaller than or equal to his brother's weight.
Limak eats a ... | {"inputs": ["4 7\n", "4 9\n", "1 1\n", "4 6\n", "1 1\n", "1 2\n", "1 3\n", "1 4\n"], "outputs": ["2\n", "3\n", "1\n", "2\n", "1\n", "2\n", "3\n", "4\n"]} | 418 | 86 |
coding | Solve the programming task below in a Python markdown code block.
Write a function `count_vowels` to count the number of vowels in a given string.
### Notes:
- Return `nil` or `None` for non-string inputs.
- Return `0` if the parameter is omitted.
### Examples:
```python
count_vowels("abcdefg") => 2
count_vowels("a... | {"functional": "_inputs = [['abcdefg'], ['asdfdsafdsafds'], [''], ['asdfdsaf asdfsdaf 13243242 dsafdsafds'], ['aeiouAEIOU'], ['1213'], ['12 3'], ['ewqriwetruituofdsajflsd23423r5043'], ['asdfviosdfopsiewrwwer asdf asdfdsaf)(asdflkajdsf '], ['asdfdsaf asdfsasdfdsafgjlsdjf asdfdsf daf 13243242 dsafdsafds... | 133 | 375 |
coding | Solve the programming task below in a Python markdown code block.
The working hours of Chef’s kitchen are from X pm to Y pm (1 ≤ X < Y ≤ 12).
Find the number of hours Chef works.
------ Input Format ------
- The first line of input will contain a single integer T, denoting the number of test cases.
- Each test cas... | {"inputs": ["4\n1 2\n3 7\n9 11\n2 10\n"], "outputs": ["1\n4\n2\n8\n"]} | 319 | 38 |
coding | Solve the programming task below in a Python markdown code block.
Given the coordinates (x, y) of a point in 2-D plane. Find if it is possible to reach (x, y) from (0, 0). The only possible moves from any coordinate (i, j) are as follows:
Go to the point with coordinates (i + 1, j + 1).
Go to the point with coordina... | {"inputs": ["6\n0 2\n1 2\n-1 -3\n-1 0\n-3 1\n2 -1\n"], "outputs": ["YES\nNO\nYES\nNO\nYES\nNO\n"]} | 457 | 51 |
coding | Solve the programming task below in a Python markdown code block.
Read problems statements in Mandarin Chinese and Russian.
Mike likes to invent new functions. The latest one he has invented is called SuperFunction. Let's consider how it can be calculated:
You are given two integers N and K. SuperFunction of N and K... | {"inputs": ["5 2 100"], "outputs": ["30"]} | 509 | 19 |
coding | Solve the programming task below in a Python markdown code block.
bhargav has dream to study his MS is foreign country. So, He started his preparation for GRE. There are huge number of words that he has to prepare for. So, firs he wanted to group all synonyms and antonyms. As there are huge number of words that he has ... | {"inputs": ["ashtrick\n25\namberhed\ndouglasb\nashmartin\nroogle\neglownasht\ndutterwo\naverists\ndueglors\naeufahef\neutifhre\naedsrntf\naleifksc\nalejfisj\neshmarin\naksiefjs\ndharanis\nqueofjsl\ndileeeep\nprashant\naravinds\nakhilesh\ndheufncs\najeufjvjs\naeuigvsr\naskhtakuen"], "outputs": ["10 6"]} | 227 | 138 |
coding | Solve the programming task below in a Python markdown code block.
Little penguin Polo loves his home village. The village has n houses, indexed by integers from 1 to n. Each house has a plaque containing an integer, the i-th house has a plaque containing integer pi (1 ≤ pi ≤ n).
Little penguin Polo loves walking aroun... | {"inputs": ["8 5\n", "9 8\n", "2 2\n", "2 1\n", "8 8\n", "1 1\n", "3 3\n", "8 1\n"], "outputs": ["16875\n", "2097152\n", "2\n", "1\n", "2097152\n", "1\n", "9\n", "823543\n"]} | 418 | 107 |
coding | Solve the programming task below in a Python markdown code block.
Sonya decided to organize an exhibition of flowers. Since the girl likes only roses and lilies, she decided that only these two kinds of flowers should be in this exhibition.
There are $n$ flowers in a row in the exhibition. Sonya can put either a rose ... | {"inputs": ["1 1\n1 1\n", "2 1\n1 2\n", "1 1\n1 1\n", "2 1\n1 2\n", "2 1\n1 1\n", "1 1\n2 1\n", "6 2\n1 6\n1 4\n", "6 2\n1 6\n1 4\n"], "outputs": ["0\n", "01\n", "0", "01", "01\n", "0\n", "010101\n", "010101"]} | 754 | 136 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given two integer arrays nums1 and nums2. We write the integers of nums1 and nums2 (in the order they are given) on two separate horizontal lines.
We may draw connecting lines: a straight line connecting two n... | {"functional": "def check(candidate):\n assert candidate(nums1 = [1,4,2], nums2 = [1,2,4]) == 2\n assert candidate(nums1 = [2,5,1,2,5], nums2 = [10,5,2,1,5,2]) == 3\n assert candidate(nums1 = [1,3,7,1,7,5], nums2 = [1,9,2,5,1]) == 2\n\n\ncheck(Solution().maxUncrossedLines)"} | 184 | 124 |
coding | Solve the programming task below in a Python markdown code block.
Slava plays his favorite game "Peace Lightning". Now he is flying a bomber on a very specific map.
Formally, map is a checkered field of size 1 × n, the cells of which are numbered from 1 to n, in each cell there can be one or several tanks. Slava doesn... | {"inputs": ["2\n", "3\n", "4\n", "6\n", "5\n", "4\n", "6\n", "5\n"], "outputs": ["3\n2 1 2 ", "4\n2 1 3 2 ", "6\n2 4 1 3 2 4 ", "9\n2 4 6 1 3 5 2 4 6 ", "7\n2 4 1 3 5 2 4 ", "6\n2 4 1 3 2 4\n", "9\n2 4 6 1 3 5 2 4 6\n", "7\n2 4 1 3 5 2 4\n"]} | 362 | 167 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You have n computers. You are given the integer n and a 0-indexed integer array batteries where the ith battery can run a computer for batteries[i] minutes. You are interested in running all n computers simultaneously... | {"functional": "def check(candidate):\n assert candidate(n = 2, batteries = [3,3,3]) == 4\n assert candidate(n = 2, batteries = [1,1,1,1]) == 2\n\n\ncheck(Solution().maxRunTime)"} | 193 | 64 |
coding | Solve the programming task below in a Python markdown code block.
Chef has three baskets and two of them have multiple balls(Natural numbers written on them). The first basket has N balls, the second basket has M balls and the third basket is empty. Chef starts choosing all the unique balls(only occurring once in both ... | {"inputs": ["1\n4 5\n1 2 3 4\n2 3 4 5 6"], "outputs": ["1 5 6"]} | 259 | 38 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given a 0-indexed integer array nums of length n.
nums contains a valid split at index i if the following are true:
The sum of the first i + 1 elements is greater than or equal to the sum of the last n - i - ... | {"functional": "def check(candidate):\n assert candidate(nums = [10,4,-8,7]) == 2\n assert candidate(nums = [2,3,1,0]) == 2\n\n\ncheck(Solution().waysToSplitArray)"} | 142 | 58 |
coding | Solve the programming task below in a Python markdown code block.
Consider the infinite sequence s of positive integers, created by repeating the following steps:
1. Find the lexicographically smallest triple of positive integers (a, b, c) such that
* a ⊕ b ⊕ c = 0, where ⊕ denotes the [bitwise XOR operation](h... | {"inputs": ["9\n2\n2\n3\n4\n5\n6\n7\n8\n9\n", "9\n2\n2\n3\n4\n9\n6\n7\n8\n9\n", "9\n1\n2\n3\n4\n5\n6\n7\n8\n9\n", "9\n2\n2\n3\n4\n5\n6\n7\n8\n17\n", "9\n3\n2\n3\n4\n5\n9\n15\n8\n7\n", "9\n1\n2\n3\n4\n5\n12\n7\n8\n9\n", "9\n3\n2\n3\n4\n9\n9\n15\n8\n7\n", "9\n2\n2\n3\n4\n5\n12\n7\n8\n9\n"], "outputs": ["2\n2\n3\n4\n8\n12... | 435 | 373 |
coding | Solve the programming task below in a Python markdown code block.
Take 2 strings `s1` and `s2` including only letters from `a`to `z`.
Return a new **sorted** string, the longest possible, containing distinct letters,
- each taken only once - coming from s1 or s2.
# Examples:
```
a = "xyaabbbccccdefww"
b = "xxxxyyyyabk... | {"functional": "_inputs = [['aretheyhere', 'yestheyarehere'], ['loopingisfunbutdangerous', 'lessdangerousthancoding'], ['inmanylanguages', 'theresapairoffunctions'], ['lordsofthefallen', 'gamekult'], ['codewars', 'codewars'], ['agenerationmustconfrontthelooming', 'codewarrs']]\n_outputs = [['aehrsty'], ['abcdefghilnopr... | 150 | 278 |
coding | Solve the programming task below in a Python markdown code block.
Polycarp had an array $a$ of $3$ positive integers. He wrote out the sums of all non-empty subsequences of this array, sorted them in non-decreasing order, and got an array $b$ of $7$ integers.
For example, if $a = \{1, 4, 3\}$, then Polycarp wrote out ... | {"inputs": ["1\n1 2 3 69696875 69696876 69696877 69696878\n", "1\n1 1 2 69696880 69696881 69696881 69696882\n", "1\n1 2 3 69696887 69696888 69696889 69696890\n", "1\n1 1 2 69696883 69696884 69696884 69696885\n", "1\n1 1 2 69696884 69696885 69696885 69696886\n", "1\n1 1 2 69696880 69696881 69696881 69696882\n", "1\n1 2 ... | 681 | 494 |
coding | Solve the programming task below in a Python markdown code block.
Alas, finding one's true love is not easy. Masha has been unsuccessful in that yet. Her friend Dasha told Masha about a way to determine the phone number of one's Prince Charming through arithmancy.
The phone number is divined like that. First one need... | {"inputs": ["3\n", "2\n", "0\n", "1\n", "4\n", "55\n", "15\n", "09\n"], "outputs": ["9\n", "9\n", "9\n", "9\n", "9\n", "14\n", "15\n", "15\n"]} | 554 | 76 |
coding | Solve the programming task below in a Python markdown code block.
Chef is playing a game which contains a binary string.
He can perform one operation only:
- Toggle the i_th bit of the string (0 to 1 or 1 to 0)
By performing operations on the string (can be zero times), you have to convert the string with no adjacent ... | {"inputs": ["1\n4\n1011"], "outputs": ["1"]} | 217 | 19 |
coding | Solve the programming task below in a Python markdown code block.
Alice likes word "nineteen" very much. She has a string s and wants the string to contain as many such words as possible. For that reason she can rearrange the letters of the string.
For example, if she has string "xiineteenppnnnewtnee", she can get str... | {"inputs": ["n\n", "n\n", "m\n", "ni\n", "ni\n", "in\n", "nine\n", "nine\n"], "outputs": ["0", "0\n", "0\n", "0", "0\n", "0\n", "0", "0\n"]} | 271 | 67 |
coding | Solve the programming task below in a Python markdown code block.
HackerLand University has the following grading policy:
Every student receives a $\textit{grade}$ in the inclusive range from $0$ to $100$.
Any $\textit{grade}$ less than $\boldsymbol{40}$ is a failing grade.
Sam is a professor at the university and l... | {"inputs": ["4\n73\n67\n38\n33\n"], "outputs": ["75\n67\n40\n33\n"]} | 623 | 36 |
coding | Solve the programming task below in a Python markdown code block.
Congratulations! That Special Someone has given you their phone number.
But WAIT, is it a valid number?
Your task is to write a function that verifies whether a given string contains a valid British mobile (cell) phone number or not.
If valid, retur... | {"functional": "_inputs = [['07454876120'], ['0754876120'], ['0745--487-61-20'], ['+447535514555'], ['-07599-51-4555'], ['075335440555'], ['+337535512555'], ['00535514555'], ['+447+4435512555'], ['+44']]\n_outputs = [['In with a chance'], ['Plenty more fish in the sea'], ['In with a chance'], ['In with a chance'], ['In... | 279 | 361 |
coding | Solve the programming task below in a Python markdown code block.
Write a function that checks the braces status in a string, and return `True` if all braces are properly closed, or `False` otherwise. Available types of brackets: `()`, `[]`, `{}`.
**Please note, you need to write this function without using regex!**
... | {"functional": "_inputs = [['[()]'], ['{[]}'], ['{[()]}'], ['([)]'], ['([[some](){text}here]...)'], ['}'], ['[()]]'], ['[()]{('], ['()[]{}()'], ['[[[[']]\n_outputs = [[True], [True], [True], [False], [True], [False], [False], [False], [True], [False]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, fl... | 198 | 232 |
coding | Solve the programming task below in a Python markdown code block.
Michael is accused of violating the social distancing rules and creating a risk of spreading coronavirus. He is now sent to prison. Luckily, Michael knows exactly what the prison looks like from the inside, especially since it's very simple.
The prison ... | {"inputs": ["2\n2 2\n1 3\n"], "outputs": ["4\n3\n"]} | 358 | 24 |
coding | Solve the programming task below in a Python markdown code block.
This is an easy version of the problem. In this version, all cards have the same color.
Alice has $n$ cards, each card is white, and the cards are stacked in a deck. Alice deals the cards to herself and to Bob, dealing at once several cards from the top... | {"inputs": ["5\n10\n6\n17\n8\n1000000\n"], "outputs": ["5 5\n1 5\n10 7\n3 5\n500202 499798\n"]} | 396 | 61 |
coding | Solve the programming task below in a Python markdown code block.
Let's define the permutation of length n as an array p = [p1, p2, ..., pn] consisting of n distinct integers from range from 1 to n. We say that this permutation maps value 1 into the value p1, value 2 into the value p2 and so on.
Kyota Ootori has just ... | {"inputs": ["2 2\n", "9 1\n", "4 2\n", "1 1\n", "5 8\n", "3 3\n", "5 1\n", "7 2\n"], "outputs": ["2 1\n", "1 2 3 4 5 6 7 8 9\n", "1 2 4 3\n", "1\n", "2 1 4 3 5\n", "2 1 3\n", "1 2 3 4 5\n", "1 2 3 4 5 7 6\n"]} | 647 | 142 |
coding | 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)"} | 226 | 55 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given an integer array arr, remove a subarray (can be empty) from arr such that the remaining elements in arr are non-decreasing.
Return the length of the shortest subarray to remove.
A subarray is a contiguous subseq... | {"functional": "def check(candidate):\n assert candidate(arr = [1,2,3,10,4,2,3,5]) == 3\n assert candidate(arr = [5,4,3,2,1]) == 4\n assert candidate(arr = [1,2,3]) == 0\n assert candidate(arr = [1]) == 0\n\n\ncheck(Solution().findLengthOfShortestSubarray)"} | 105 | 99 |
coding | Solve the programming task below in a Python markdown code block.
Read problems statements in Mandarin Chinese, Russian and Vietnamese as well.
Chef is a private detective. He was asked to investigate a case of murder in the city of Frangton.
Chef arrived in Frangton to find out that the mafia was involved in the cas... | {"inputs": ["6\n0 1 1 2 2 3"], "outputs": ["4 5 6"]} | 455 | 28 |
coding | 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, as long as it has more than one element:
Choose any two adjacent elements, remove them from the array and insert their sum at that position.
Formally, if the cu... | {"inputs": ["4\n3\n5 2 3\n2\n6 9\n5\n3 6 5 4 9\n3\n3 3 3\n"], "outputs": ["1\n1\n2\n0\n"]} | 616 | 54 |
coding | Solve the programming task below in a Python markdown code block.
Problem Statement
2 players, Cyborg and Geno are playing a game on a matrix. In each turn, the player choses a number from the matrix which is not selected yet and adds the number to his sum. In the end, the player with the largest sum wins the game.
As... | {"inputs": ["3\n1 1\n3\n2 3\n4 4 4\n4 4 4\n2 3\n4 3 4\n4 4 4"], "outputs": ["Cyborg\nDraw\nCyborg"]} | 439 | 56 |
coding | Solve the programming task below in a Python markdown code block.
Your friend is developing a computer game. He has already decided how the game world should look like — it should consist of n locations connected by m two-way passages. The passages are designed in such a way that it should be possible to get from any l... | {"inputs": ["4 3\n1 2\n4 2\n3 2\n", "4 3\n1 2\n4 3\n3 2\n", "5 5\n1 2\n2 3\n3 1\n4 1\n5 4\n", "5 5\n1 2\n2 3\n3 1\n4 1\n5 3\n", "5 5\n1 2\n2 3\n3 1\n4 1\n5 2\n", "5 6\n1 5\n2 3\n3 5\n2 1\n2 5\n2 4\n", "5 6\n1 5\n2 3\n3 5\n2 1\n2 5\n1 4\n", "5 6\n1 5\n3 3\n3 5\n2 2\n2 5\n2 4\n"], "outputs": ["2\n", "3\n", "2\n", "2\n", ... | 444 | 242 |
coding | Solve the programming task below in a Python markdown code block.
Just like in the ["father" kata](http://www.codewars.com/kata/find-fibonacci-last-digit/), you will have to return the last digit of the nth element in the Fibonacci sequence (starting with 1,1, to be extra clear, not with 0,1 or other numbers).
You wil... | {"functional": "_inputs = [[1], [21], [302], [4003], [50004], [600005], [7000006], [80000007], [900000008], [1000000009]]\n_outputs = [[1], [6], [1], [7], [8], [5], [3], [8], [1], [9]]\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, re... | 261 | 255 |
coding | Solve the programming task below in a Python markdown code block.
The growth of Computer Science has forced the scientific community to award Nobel Prize in CS starting from this year.
Chef knows that the Nobel community is going to award the prize to that person whose research is different from others (ie. no other r... | {"inputs": ["3\n4 4\n1 2 3 4\n5 4\n4 2 1 1 1\n4 4\n4 4 4 4"], "outputs": ["No\nYes\nYes"]} | 630 | 54 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given a binary tree root, return the maximum sum of all keys of any sub-tree which is also a Binary Search Tree (BST).
Assume a BST is defined as follows:
The left subtree of a node contains only nodes with keys less... | {"functional": "def check(candidate):\n assert candidate(root = tree_node([1,4,3,2,4,2,5,None,None,None,None,None,None,4,6])) == 20\n assert candidate(root = tree_node([4,3,None,1,2])) == 2\n assert candidate(root = tree_node([-4,-2,-5])) == 0\n assert candidate(root = tree_node([2,1,3])) == 6\n assert c... | 187 | 139 |
coding | Solve the programming task below in a Python markdown code block.
Chef has his lunch only between 1 pm and 4 pm (both inclusive).
Given that the current time is X pm, find out whether it is *lunchtime* for Chef.
------ Input Format ------
- The first line of input will contain a single integer T, the number of tes... | {"inputs": ["3\n1\n7\n3"], "outputs": ["YES\nNO\nYES"]} | 373 | 22 |
coding | Solve the programming task below in a Python markdown code block.
You are given a pair of integers $(a, b)$ and an integer $x$.
You can change the pair in two different ways:
set (assign) $a := |a - b|$;
set (assign) $b := |a - b|$,
where $|a - b|$ is the absolute difference between $a$ and $b$.
The pair $(a, b)$ ... | {"inputs": ["1\n4398046511104 4398050705408 8388608\n", "8\n6 9 3\n15 38 7\n18 8 8\n30 30 30\n40 50 90\n24 28 20\n365 216 52\n537037812705867558 338887693834423551 3199921013340\n"], "outputs": ["YES\n", "YES\nYES\nYES\nYES\nNO\nYES\nYES\nYES\n"]} | 466 | 183 |
coding | Solve the programming task below in a Python markdown code block.
Chef has N laddus of K sweetness each. Chef wants to eat all laddus, but Chef is restricted with the given condition that he must not eat two adjacent laddus. Chef starts calculating the maximum sweetness that he will get from the laddus. Find the maximu... | {"inputs": ["2\n1 2\n4 3"], "outputs": ["2\n6"]} | 301 | 22 |
coding | Solve the programming task below in a Python markdown code block.
Long long ago, there was a thief. Looking for treasures, he was running about all over the world. One day, he heard a rumor that there were islands that had large amount of treasures, so he decided to head for there.
Finally he found n islands that had ... | {"inputs": ["3\n2 3\n3 6\n1 2\n3\n2 3\n3 5\n2 2\n0", "3\n2 3\n3 6\n2 2\n3\n3 3\n3 6\n2 2\n0", "3\n2 1\n3 6\n1 2\n3\n2 3\n3 5\n0 2\n0", "3\n4 5\n3 8\n1 2\n0\n7 3\n3 5\n2 1\n0", "3\n2 3\n3 6\n1 2\n3\n0 3\n3 5\n1 2\n0", "3\n2 3\n3 6\n1 2\n3\n3 3\n3 5\n2 2\n0", "3\n2 3\n3 6\n1 2\n3\n3 3\n3 6\n2 2\n0", "3\n2 3\n3 8\n2 2\n3\... | 377 | 300 |
coding | 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"]} | 673 | 99 |
coding | Solve the programming task below in a Python markdown code block.
You are given two strings a and b. You have to remove the minimum possible number of consecutive (standing one after another) characters from string b in such a way that it becomes a subsequence of string a. It can happen that you will not need to remove... | {"inputs": ["a\na\n", "a\nb\n", "a\nb\n", "a\na\n", "b\nb\n", "aa\na\n", "a\nab\n", "b\ncb\n"], "outputs": ["a\n", "-\n", "-", "a", "b\n", "a\n", "a\n", "b\n"]} | 312 | 83 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given an undirected graph defined by an integer n, the number of nodes, and a 2D integer array edges, the edges in the graph, where edges[i] = [ui, vi] indicates that there is an undirected edge between ui and... | {"functional": "def check(candidate):\n assert candidate(n = 4, edges = [[1,2],[2,4],[1,3],[2,3],[2,1]], queries = [2,3]) == [6,5]\n assert candidate(n = 5, edges = [[1,5],[1,5],[3,4],[2,5],[1,3],[5,1],[2,3],[2,5]], queries = [1,2,3,4,5]) == [10,10,9,8,6]\n\n\ncheck(Solution().countPairs)"} | 224 | 135 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given two strings s and goal, return true if you can swap two letters in s so the result is equal to goal, otherwise, return false.
Swapping letters is defined as taking two indices i and j (0-indexed) such that i != ... | {"functional": "def check(candidate):\n assert candidate(s = \"ab\", goal = \"ba\") == True\n assert candidate(s = \"ab\", goal = \"ab\") == False\n assert candidate(s = \"aa\", goal = \"aa\") == True\n\n\ncheck(Solution().buddyStrings)"} | 136 | 68 |
coding | Solve the programming task below in a Python markdown code block.
You are given an array A of N integers. You can do the following two types of operations any (possibly zero) number of times:
Pick two indices i and j (1 ≤ i,j ≤ |A|, i \neq j). Change A_{j} := A_{j} + A_{i} and remove the i^{th} element from the array.... | {"inputs": ["2\n3\n1 2 4\n4\n1 1 3 4"], "outputs": ["3\n3"]} | 762 | 32 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are playing a game that has n levels numbered from 0 to n - 1. You are given a 0-indexed integer array damage where damage[i] is the amount of health you will lose to complete the ith level.
You are also given an ... | {"functional": "def check(candidate):\n assert candidate(damage = [2,7,4,3], armor = 4) == 13\n assert candidate(damage = [2,5,3,4], armor = 7) == 10\n assert candidate(damage = [3,3,3], armor = 0) == 10\n\n\ncheck(Solution().minimumHealth)"} | 171 | 92 |
coding | Solve the programming task below in a Python markdown code block.
Mahmoud and Ehab play a game called the even-odd game. Ehab chooses his favorite integer n and then they take turns, starting from Mahmoud. In each player's turn, he has to choose an integer a and subtract it from n such that: 1 ≤ a ≤ n. If it's Mahmou... | {"inputs": ["1\n", "2\n", "5\n", "3\n", "4\n", "6\n", "7\n", "8\n"], "outputs": ["Ehab", "Mahmoud", "Ehab", "Ehab", "Mahmoud", "Mahmoud", "Ehab", "Mahmoud"]} | 295 | 74 |
coding | Solve the programming task below in a Python markdown code block.
You are given an integer $n$. In one move, you can either multiply $n$ by two or divide $n$ by $6$ (if it is divisible by $6$ without the remainder).
Your task is to find the minimum number of moves needed to obtain $1$ from $n$ or determine if it's imp... | {"inputs": ["1\n64693265\n", "1\n10872979\n", "1\n21674312\n", "1\n32114318\n", "1\n54097276\n", "1\n65971871\n", "1\n93108643\n", "1\n30365546\n"], "outputs": ["-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n"]} | 500 | 143 |
coding | Solve the programming task below in a Python markdown code block.
There are two types of burgers in your restaurant — hamburgers and chicken burgers! To assemble a hamburger you need two buns and a beef patty. To assemble a chicken burger you need two buns and a chicken cutlet.
You have $b$ buns, $p$ beef patties and... | {"inputs": ["1\n0 4 4\n3 0\n", "1\n0 0 4\n3 0\n", "1\n0 0 4\n2 0\n", "1\n0 0 3\n2 0\n", "1\n1 0 3\n2 0\n", "1\n1 0 1\n2 0\n", "1\n1 0 1\n3 0\n", "1\n1 0 1\n4 0\n"], "outputs": ["0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n"]} | 435 | 150 |
coding | Solve the programming task below in a Python markdown code block.
Nearly each project of the F company has a whole team of developers working on it. They often are in different rooms of the office in different cities and even countries. To keep in touch and track the results of the project, the F company conducts share... | {"inputs": ["1 1\n+ 1\n", "2 1\n- 2\n", "2 1\n+ 1\n", "2 1\n+ 2\n", "20 1\n- 16\n", "2 2\n- 1\n+ 1\n", "6 2\n+ 1\n- 2\n", "6 2\n+ 1\n- 4\n"], "outputs": ["1\n1 \n", "2\n1 2 \n", "2\n1 2 \n", "2\n1 2 \n", "20\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 \n", "2\n1 2 \n", "4\n3 4 5 6 \n", "4\n2 3 5 6 \n"]} | 613 | 226 |
coding | Solve the programming task below in a Python markdown code block.
The BFS algorithm is defined as follows. Consider an undirected graph with vertices numbered from $1$ to $n$. Initialize $q$ as a new queue containing only vertex $1$, mark the vertex $1$ as used. Extract a vertex $v$ from the head of the queue $q$. P... | {"inputs": ["1\n1\n", "1\n1\n", "2\n1 2\n2 1\n", "2\n2 1\n1 2\n", "2\n2 1\n2 1\n", "2\n1 2\n2 1\n", "2\n2 1\n1 2\n", "2\n2 1\n2 1\n"], "outputs": ["Yes", "Yes\n", "No", "Yes", "No", "No\n", "Yes\n", "No\n"]} | 562 | 118 |
coding | Solve the programming task below in a Python markdown code block.
Chef's company wants to make ATM PINs for its users, so that they could use the PINs for withdrawing their hard-earned money. One of these users is Reziba, who lives in an area where a lot of robberies take place when people try to withdraw their money. ... | {"inputs": ["1\n1"], "outputs": ["1 1"]} | 490 | 16 |
coding | Solve the programming task below in a Python markdown code block.
You are given a program that consists of $n$ instructions. Initially a single variable $x$ is assigned to $0$. Afterwards, the instructions are of two types:
increase $x$ by $1$;
decrease $x$ by $1$.
You are given $m$ queries of the following format:
... | {"inputs": ["2\n8 4\n-+--+--+\n1 8\n2 8\n2 5\n1 1\n4 10\n+-++\n1 1\n1 2\n2 2\n1 3\n2 3\n3 3\n1 4\n2 4\n3 4\n4 4\n", "2\n8 4\n-+--+--+\n2 8\n2 8\n2 5\n1 1\n4 10\n+-++\n1 1\n1 2\n2 2\n1 3\n2 3\n3 3\n1 4\n2 4\n3 4\n4 4\n", "2\n8 4\n-+--+--+\n1 8\n2 8\n2 5\n2 1\n4 10\n+-++\n1 1\n1 2\n2 2\n1 3\n2 3\n3 3\n1 4\n2 4\n3 4\n4 4\... | 628 | 878 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given an integer num, return three consecutive integers (as a sorted array) that sum to num. If num cannot be expressed as the sum of three consecutive integers, return an empty array.
Please complete the following ... | {"functional": "def check(candidate):\n assert candidate(num = 33) == [10,11,12]\n assert candidate(num = 4) == []\n\n\ncheck(Solution().sumOfThree)"} | 87 | 53 |
coding | Solve the programming task below in a Python markdown code block.
You are given $n$ words. Some words may repeat. For each word, output its number of occurrences. The output order should correspond with the input order of appearance of the word. See the sample input/output for clarification.
Note: Each input line end... | {"inputs": ["4\nbcdef\nabcdefg\nbcde\nbcdef\n"], "outputs": ["3\n2 1 1\n"]} | 284 | 32 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given an array of unique integers salary where salary[i] is the salary of the ith employee.
Return the average salary of employees excluding the minimum and maximum salary. Answers within 10-5 of the actual an... | {"functional": "def check(candidate):\n assert candidate(salary = [4000,3000,1000,2000]) == 2500.00000\n assert candidate(salary = [1000,2000,3000]) == 2000.00000\n assert candidate(salary = [6000,5000,4000,3000,2000,1000]) == 3500.00000\n assert candidate(salary = [8000,9000,2000,3000,6000,1000]) == 4750.0... | 96 | 193 |
coding | Solve the programming task below in a Python markdown code block.
You are given an array $a$ of $n$ integers. You are allowed to perform the following operation on it as many times as you want (0 or more times):
Choose $2$ indices $i$,$j$ where $1 \le i < j \le n$ and replace $a_k$ for all $i \leq k \leq j$ with $|a_i... | {"inputs": ["3\n3\n1 1 1\n2\n9 1\n3\n4 9 5\n"], "outputs": ["3\n16\n18\n"]} | 468 | 42 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given a 0-indexed 2D integer array grid of size m x n which represents a field. Each cell has one of three values:
0 represents grass,
1 represents fire,
2 represents a wall that you and fire cannot pass thro... | {"functional": "def check(candidate):\n assert candidate(grid = [[0,2,0,0,0,0,0],[0,0,0,2,2,1,0],[0,2,0,0,1,2,0],[0,0,2,2,2,0,2],[0,0,0,0,0,0,0]]) == 3\n assert candidate(grid = [[0,0,0,0],[0,1,2,0],[0,2,0,0]]) == -1\n assert candidate(grid = [[0,0,0],[2,2,0],[1,2,0]]) == 1000000000\n\n\ncheck(Solution().maxim... | 286 | 170 |
coding | Solve the programming task below in a Python markdown code block.
###Instructions
Write a function that takes a negative or positive integer, which represents the number of minutes before (-) or after (+) Sunday midnight, and returns the current day of the week and the current time in 24hr format ('hh:mm') as a string... | {"functional": "_inputs = [[0], [-3], [45], [759], [1236], [1447], [7832], [18876], [259180], [-349000]]\n_outputs = [['Sunday 00:00'], ['Saturday 23:57'], ['Sunday 00:45'], ['Sunday 12:39'], ['Sunday 20:36'], ['Monday 00:07'], ['Friday 10:32'], ['Saturday 02:36'], ['Thursday 23:40'], ['Tuesday 15:20']]\nimport math\nd... | 304 | 295 |
coding | Solve the programming task below in a Python markdown code block.
Niwango created a playlist of N songs. The title and the duration of the i-th song are s_i and t_i seconds, respectively. It is guaranteed that s_1,\ldots,s_N are all distinct.
Niwango was doing some work while playing this playlist. (That is, all the s... | {"inputs": ["1\nabcde 0000\nabcde", "1\nabcde 1000\nabcde", "3\ndwango 2\nsixth 5\nprelims 4\ndwango", "3\ndwango 2\nsixth 5\nprelims 7\ndwango", "3\ndwango 2\nsixth 0\nprelims 7\ndwango", "3\ndwango 2\nshxth 5\nsmilerp 1\ndwango", "3\ndwango 2\nshxth 10\nsmilerp 7\ndwango", "3\ndwango 2\nsixth 5\nprelims 25\ndwango"],... | 516 | 215 |
coding | Solve the programming task below in a Python markdown code block.
Suppose there is a X x Y x Z 3D matrix A of numbers having coordinates (i, j, k) where 0 ≤ i < X, 0 ≤ j < Y, 0 ≤ k < Z. Now another X x Y x Z matrix B is defined from A such that the (i, j, k) element of B is the sum of all the the numbers in A in the cu... | {"inputs": ["2\n3 1 1\n1 \n8 \n22 \n1 2 3\n0 9 13 \n18 45 51", "2\n3 1 1\n1 \n8 \n22 \n1 2 3\n0 9 13 \n18 45 51"], "outputs": ["1 \n7 \n14 \n0 9 4 \n18 18 2", "1 \n7 \n14 \n0 9 4 \n18 18 2"]} | 484 | 142 |
coding | Solve the programming task below in a Python markdown code block.
Vasya had a strictly increasing sequence of positive integers a_1, ..., a_{n}. Vasya used it to build a new sequence b_1, ..., b_{n}, where b_{i} is the sum of digits of a_{i}'s decimal representation. Then sequence a_{i} got lost and all that remained i... | {"inputs": ["1\n6\n", "1\n6\n", "1\n8\n", "1\n2\n", "1\n1\n", "1\n3\n", "1\n4\n", "1\n5\n"], "outputs": ["6\n", "6\n", "8\n", "2\n", "1\n", "3\n", "4\n", "5\n"]} | 332 | 86 |
coding | Solve the programming task below in a Python markdown code block.
You are given an array $a$ consisting of $n$ integers.
In one move, you can choose two indices $1 \le i, j \le n$ such that $i \ne j$ and set $a_i := a_j$. You can perform such moves any number of times (possibly, zero). You can choose different indices... | {"inputs": ["1\n1\n75\n", "1\n1\n96\n", "1\n1\n21\n", "1\n1\n27\n", "1\n1\n30\n", "1\n1\n22\n", "1\n1\n25\n", "1\n1\n83\n"], "outputs": ["YES\n", "NO\n", "YES\n", "YES\n", "NO\n", "NO\n", "YES\n", "YES\n"]} | 443 | 110 |
coding | Solve the programming task below in a Python markdown code block.
problem
Hanako is playing with n (4 ≤ n ≤ 10) cards side by side. Each card has one integer between 1 and 99. Hanako chose k cards (2 ≤ k ≤ 4) from these cards and arranged them in a horizontal row to make an integer. How many kinds of integers can Hana... | {"inputs": ["4\n1\n1\n3\n12\n1\n6\n3\n8\n2\n0\n7\n2\n1\n0\n0", "4\n1\n1\n3\n12\n1\n6\n1\n8\n2\n0\n7\n2\n1\n0\n0", "4\n1\n1\n3\n17\n2\n6\n3\n8\n2\n0\n7\n2\n1\n0\n0", "4\n1\n2\n3\n12\n1\n6\n1\n8\n2\n0\n7\n2\n1\n0\n0", "4\n1\n1\n3\n17\n2\n6\n4\n8\n0\n0\n7\n4\n1\n0\n0", "4\n1\n2\n3\n12\n1\n6\n1\n8\n2\n1\n7\n2\n1\n0\n0", "4... | 441 | 332 |
coding | Solve the programming task below in a Python markdown code block.
Takahashi throws N dice, each having K sides with all integers from 1 to K. The dice are NOT pairwise distinguishable.
For each i=2,3,...,2K, find the following value modulo 998244353:
- The number of combinations of N sides shown by the dice such that ... | {"inputs": ["3 6", "1 5", "2 3", "5 3", "5 5", "3 5", "4 8", "6 6"], "outputs": ["13\n13\n4\n13\n13\n", "0\n", "2\n2\n2\n", "30\n30\n25\n25\n20\n25\n25\n30\n30\n", "91\n91\n61\n61\n36\n61\n61\n91\n91\n", "11\n11\n4\n11\n11\n", "81\n81\n32\n32\n32\n81\n81\n", "336\n336\n231\n231\n146\n146\n146\n231\n231\n336\n336\n"]} | 420 | 217 |
coding | Solve the programming task below in a Python markdown code block.
The squirrel Chokudai has N acorns. One day, he decides to do some trades in multiple precious metal exchanges to make more acorns.
His plan is as follows:
1. Get out of the nest with N acorns in his hands.
2. Go to Exchange A and do some trades.
3. Go... | {"inputs": ["23\n1 1 1\n2 2 1", "23\n1 2 1\n2 1 1", "23\n1 2 1\n2 0 1", "23\n0 2 1\n2 0 1", "23\n1 1 2\n1 1 0", "23\n1 1 1\n2 0 1", "23\n1 4 1\n2 1 1", "23\n1 1 2\n2 3 0"], "outputs": ["46\n", "92\n", "48\n", "27\n", "25\n", "47\n", "184\n", "71\n"]} | 451 | 175 |
coding | Solve the programming task below in a Python markdown code block.
In this kata you need to build a function to return either `true/True` or `false/False` if a string can be seen as the repetition of a simpler/shorter subpattern or not.
For example:
```cpp,java
hasSubpattern("a") == false; //no repeated pattern
hasSub... | {"functional": "_inputs = [['a'], ['aaaa'], ['abcd'], ['abababab'], ['ababababa'], ['123a123a123a'], ['123A123a123a'], ['abbaabbaabba'], ['abbabbabba'], ['abcdabcabcd']]\n_outputs = [[False], [True], [False], [True], [False], [True], [False], [True], [False], [False]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if... | 321 | 247 |
coding | 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 N integers: A_{1}, A_{2}, ..., A_{N}. You need to count the number of pairs of indices (i, j) such that 1 ≤ i < j ≤ N and A_{i} | A_{j} ≤ max(A_{i}, A_{j}).
No... | {"inputs": ["1\n3\n1 2 3"], "outputs": ["2"]} | 629 | 20 |
coding | Solve the programming task below in a Python markdown code block.
A factory produces thimbles in bulk. Typically, it can produce up to a thimbles a day. However, some of the machinery is defective, so it can currently only produce b thimbles each day. The factory intends to choose a k-day period to do maintenance and c... | {"inputs": ["1 1 2 1 1\n2 1\n", "1 1 2 0 1\n2 1\n", "1 1 3 0 1\n2 1\n", "2 1 3 0 1\n2 1\n", "1 1 2 2 1\n2 1\n", "2 1 3 0 1\n2 2\n", "1 1 2 4 1\n2 1\n", "1 1 2 3 1\n2 1\n"], "outputs": ["0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n"]} | 737 | 166 |
coding | Solve the programming task below in a Python markdown code block.
The country of Byteland contains N cities and N - 1 bidirectional roads between them such that there is a path between any two cities. The cities are numbered (0,...,N - 1). The people were very unhappy about the time it took to commute, especially sales... | {"inputs": ["2\n3\n0 1\n1 2\n5\n0 1\n1 2\n2 3\n2 4\n"], "outputs": ["2\n4\n"]} | 408 | 44 |
coding | Solve the programming task below in a Python markdown code block.
You are given an array A of length N containing the elements -1 and 1 only. Determine if it is possible to rearrange the array A in such a way that A_{i} is not the geometric mean of A_{i-1} and A_{i+1}, for all i such that 2 ≤ i ≤ N-1.
Y is said to be ... | {"inputs": ["3\n5\n1 1 1 -1 -1\n3\n1 1 1\n6\n1 -1 -1 -1 -1 1\n"], "outputs": ["Yes\nNo\nYes\n"]} | 478 | 52 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
There is an undirected tree with n nodes labeled from 0 to n - 1.
You are given a 0-indexed integer array nums of length n where nums[i] represents the value of the ith node. You are also given a 2D integer array edge... | {"functional": "def check(candidate):\n assert candidate(nums = [6,2,2,2,6], edges = [[0,1],[1,2],[1,3],[3,4]] ) == 2 \n assert candidate(nums = [2], edges = []) == 0\n\n\ncheck(Solution().componentValue)"} | 203 | 75 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Fruits are available at some positions on an infinite x-axis. You are given a 2D integer array fruits where fruits[i] = [positioni, amounti] depicts amounti fruits at the position positioni. fruits is already sorted b... | {"functional": "def check(candidate):\n assert candidate(fruits = [[2,8],[6,3],[8,6]], startPos = 5, k = 4) == 9\n assert candidate(fruits = [[0,9],[4,1],[5,7],[6,2],[7,4],[10,9]], startPos = 5, k = 4) == 14\n assert candidate(fruits = [[0,3],[6,4],[8,5]], startPos = 3, k = 2) == 0\n\n\ncheck(Solution().maxTot... | 216 | 134 |
coding | Solve the programming task below in a Python markdown code block.
Chef's dog Snuffles has so many things to play with! This time around, Snuffles has an array A containing N integers: A1, A2, ..., AN.
Bad news: Snuffles only loves to play with an array in which all the elements are equal.
Good news: We have a mover of ... | {"inputs": ["3\n5 2\n1 4 5 2 3\n3 1\n1 4 1\n4 2\n3 4 3 5"], "outputs": ["3\n2\n-1"]} | 660 | 53 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given a string date representing a Gregorian calendar date formatted as YYYY-MM-DD, return the day number of the year.
Please complete the following python code precisely:
```python
class Solution:
def dayOfYear... | {"functional": "def check(candidate):\n assert candidate(date = \"2019-01-09\") == 9\n assert candidate(date = \"2019-02-10\") == 41\n\n\ncheck(Solution().dayOfYear)"} | 71 | 62 |
coding | Solve the programming task below in a Python markdown code block.
Polycarpus has a ribbon, its length is n. He wants to cut the ribbon in a way that fulfils the following two conditions:
* After the cutting each ribbon piece should have length a, b or c.
* After the cutting the number of ribbon pieces should be ... | {"inputs": ["4 4 4 4\n", "4 6 4 9\n", "8 3 8 4\n", "1 1 1 1\n", "2 2 9 6\n", "5 1 3 3\n", "6 2 4 1\n", "4 3 4 4\n"], "outputs": ["1\n", "1\n", "2\n", "1\n", "1\n", "5\n", "6\n", "1\n"]} | 284 | 118 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given the root of a binary tree containing digits from 0 to 9 only.
Each root-to-leaf path in the tree represents a number.
For example, the root-to-leaf path 1 -> 2 -> 3 represents the number 123.
Return th... | {"functional": "def check(candidate):\n assert candidate(root = tree_node([1,2,3])) == 25\n assert candidate(root = tree_node([4,9,0,5,1])) == 1026\n\n\ncheck(Solution().sumNumbers)"} | 197 | 63 |
coding | Solve the programming task below in a Python markdown code block.
If we write out the digits of "60" as English words we get "sixzero"; the number of letters in "sixzero" is seven. The number of letters in "seven" is five. The number of letters in "five" is four. The number of letters in "four" is four: we have reached... | {"functional": "_inputs = [[1], [2], [3], [4], [12], [37], [311], [999]]\n_outputs = [[['one', 'three', 'five', 'four']], [['two', 'three', 'five', 'four']], [['three', 'five', 'four']], [['four']], [['onetwo', 'six', 'three', 'five', 'four']], [['threeseven', 'onezero', 'seven', 'five', 'four']], [['threeoneone', 'one... | 203 | 295 |
coding | Solve the programming task below in a Python markdown code block.
There are $N$ cities on a circle, numbered $1$ through $N$. For each $i$ ($1 \le i \le N-1$), cities $i$ and $i+1$ are directly connected by a bidirectional road with length $A_i$, and cities $N$ and $1$ are also directly connected by a bidirectional roa... | {"inputs": ["4\n4\n1 1 1 1\n4\n1 1 1 2\n4\n1 -1 -1 4\n4\n1 -1 2 -1"], "outputs": ["YES\n1 1 1 1\nNO\nYES\n1 4 1 4\nNO"]} | 587 | 74 |
coding | Solve the programming task below in a Python markdown code block.
You are given an array A with size N (indexed from 0) and an integer K. Let's define another array B with size N · K as the array that's formed by concatenating K copies of array A.
For example, if A = {1, 2} and K = 3, then B = {1, 2, 1, 2, 1, 2}.
You h... | {"inputs": ["2\n2 3\n1 2\n3 2\n1 -2 1\n\n"], "outputs": ["9\n2"]} | 466 | 34 |
coding | 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"]} | 570 | 71 |
coding | Solve the programming task below in a Python markdown code block.
You are given a square grid of size N, with rows numbered from 0 to N - 1 starting from the top and columns numbered from 0 to N - 1 starting from the left.
A cell (u, v) refers to the cell that is on the u^{th} row and the v^{th} column. Each cell c... | {"inputs": ["3 1\n0 1 0\n1 1 1\n0 1 0\n", "3 2\n1 0 1 \n1 1 0 \n0 0 0 \n"], "outputs": ["Possible\n1\n1 1\n", "Impossible\n"]} | 563 | 71 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given an array of integers, return the maximum sum for a non-empty subarray (contiguous elements) with at most one element deletion. In other words, you want to choose a subarray and optionally delete one element from... | {"functional": "def check(candidate):\n assert candidate(arr = [1,-2,0,3]) == 4\n assert candidate(arr = [1,-2,-2,3]) == 3\n assert candidate(arr = [-1,-1,-1,-1]) == -1\n\n\ncheck(Solution().maximumSum)"} | 133 | 73 |
coding | Solve the programming task below in a Python markdown code block.
This function should take two string parameters: a person's name (`name`) and a quote of theirs (`quote`), and return a string attributing the quote to the person in the following format:
```python
'[name] said: "[quote]"'
```
For example, if `name` is... | {"functional": "_inputs = [['Grae', 'Practice makes perfect'], ['Dan', 'Get back to work, Grae'], ['Alex', 'Python is great fun'], ['Bethany', 'Yes, way more fun than R'], ['Darrell', 'What the heck is this thing?']]\n_outputs = [['Grae said: \"Practice makes perfect\"'], ['Dan said: \"Get back to work, Grae\"'], ['Ale... | 185 | 273 |
coding | Solve the programming task below in a Python markdown code block.
The chef is trying to solve some pattern problems, Chef wants your help to code it. Chef has one number K to form a new pattern. Help the chef to code this pattern problem.
-----Input:-----
- First-line will contain $T$, the number of test cases. Then t... | {"inputs": ["3\n2\n3\n4"], "outputs": ["12\n21\n123\n231\n312\n1234\n2341\n3412\n4123"]} | 212 | 54 |
coding | Solve the programming task below in a Python markdown code block.
Let's call a set of positive integers a_1, a_2, ..., a_k quadratic if the product of the factorials of its elements is a square of an integer, i. e. ∏_{i=1}^{k} a_i! = m^2, for some integer m.
You are given a positive integer n.
Your task is to find a ... | {"inputs": ["5\n", "2\n", "0\n", "9\n", "7\n", "1\n", "4\n", "27\n"], "outputs": ["3\n1 3 4\n", "1\n1\n", "0\n\n", "7\n1 2 4 5 6 7 8 ", "4\n1 4 5 6 ", "1\n1 ", "3\n1 3 4 ", "25\n1 2 3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 21 22 23 24 26 27 "]} | 236 | 173 |
coding | Solve the programming task below in a Python markdown code block.
Mr. Chanek is currently participating in a science fair that is popular in town. He finds an exciting puzzle in the fair and wants to solve it.
There are $N$ atoms numbered from $1$ to $N$. These atoms are especially quirky. Initially, each atom is in n... | {"inputs": ["4 2\n1 2 4 8\n1 5 3 5\n", "4 2\n1 2 4 8\n5 1 3 5\n", "4 2\n1 2 4 8\n5 3 1 5\n", "4 2\n1 2 4 8\n6 5 3 1\n", "4 3\n1 2 4 8\n1 5 3 5\n", "4 3\n1 2 4 8\n5 1 3 5\n", "4 3\n1 2 4 8\n5 3 1 5\n", "4 3\n1 2 4 8\n6 5 3 1\n"], "outputs": ["14\n", "14\n", "14\n", "12\n", "14\n", "14\n", "14\n", "12\n"]} | 680 | 222 |
coding | 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\n0.9\n", "3 3\n9.9\n", "3 1\n9.5\n", "3 1\n9.9\n", "3 2\n0.9\n", "3 0\n0.1\n", "3 2\n9.5\n"], "outputs": ["0.1", "1", "10", "10", "10", "1", "0.1\n", "10"]} | 622 | 119 |
coding | Solve the programming task below in a Python markdown code block.
Read problems statements in Mandarin Chinese and Russian as well.
Euler's phi function for a positive integer N is usually denoted as φ(N) and defined as the number of positive integers less than or equal to N that are coprime with N. Let's call a po... | {"inputs": ["3\n4 3\n1 57\n8 23", "3\n4 3\n90 95\n1 21", "3\n4 3\n90 95\n4 21", "3\n4 5\n90 89\n8 21", "3\n1 3\n86 95\n12 8", "3\n4 5\n90 89\n8 11", "3\n2 3\n90 95\n6 21", "3\n4 5\n90 95\n1 21"], "outputs": ["0\n13\n4\n", "0\n0\n8\n", "0\n0\n6\n", "1\n0\n4\n", "2\n0\n0\n", "1\n0\n1\n", "1\n0\n5\n", "1\n0\n8\n"]} | 351 | 214 |
coding | Solve the programming task below in a Python markdown code block.
In a New York City coffee house called Central Perk, we're introduced to six friends: chef Monica Geller, data controller Chandler Bing who lives across the hall from Monica, Chandler's roommate/actor Joey Tribbiani, Monica's brother Ross Geller, new age... | {"inputs": ["3\n42\n5\n909"], "outputs": ["YES\nNO\nYES"]} | 355 | 25 |
coding | Solve the programming task below in a Python markdown code block.
Alan decided to get in shape for the summer, so he created a precise workout plan to follow. His plan is to go to a different gym every day during the next N days and lift $X[i]$ grams on day $i$. In order to improve his workout performance at the gym, h... | {"inputs": ["5 46\n38 4 11 1 49\n100\n13 55 29 31 977\n", "5 46\n38 4 11 1 49\n100\n135 55 29 31 977\n", "5 49\n38 23 11 1 49\n50\n135 55 24 31 977\n", "5 49\n38 4 11 1 49\n100\n135 55 24 31 977\n", "5 49\n38 4 11 1 49\n100\n135 55 29 31 977\n", "5 1\n1 1 1 2 9\n1000000000\n10 20 30 7 50\n", "5 49\n38 8 11 17 49\n50\n1... | 592 | 367 |
coding | Solve the programming task below in a Python markdown code block.
Lots of geeky customers visit our chef's restaurant everyday. So, when asked to fill the feedback form, these customers represent the feedback using a binary string (i.e a string that contains only characters '0' and '1'.
Now since chef is not that gre... | {"inputs": ["2\n11111110\n10101010101010", "2\n11101110\n10101010101010", "2\n11111110\n10101010111010", "2\n01010010\n10000000111111", "2\n11111111\n11000001111100", "2\n11101110\n10101010111010", "2\n11111110\n10100010111010", "2\n01111110\n10100010111010"], "outputs": ["Bad\nGood", "Good\nGood\n", "Bad\nGood\n", "Go... | 363 | 269 |
coding | Solve the programming task below in a Python markdown code block.
Given are 1-digit positive integers a and b. Consider these two strings: the concatenation of b copies of the digit a, and the concatenation of a copies of the digit b. Which of these is lexicographically smaller?
-----Constraints-----
- 1 \leq a \leq ... | {"inputs": ["7 2", "4 6", "7 4", "7 8", "5 7", "1 3", "5 2", "6 6"], "outputs": ["2222222\n", "444444\n", "4444444\n", "77777777\n", "5555555\n", "111\n", "22222\n", "666666\n"]} | 188 | 119 |
coding | Solve the programming task below in a Python markdown code block.
The average miner Vaganych took refresher courses. As soon as a miner completes the courses, he should take exams. The hardest one is a computer test called "Testing Pants for Sadness".
The test consists of n questions; the questions are to be answered ... | {"inputs": ["1\n18\n", "1\n24\n", "1\n29\n", "1\n46\n", "1\n27\n", "1\n10\n", "2\n2 1\n", "2\n2 2\n"], "outputs": ["18\n", "24\n", "29\n", "46\n", "27\n", "10", "3\n", "5"]} | 545 | 100 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.