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.
Slime has a sequence of positive integers $a_1, a_2, \ldots, a_n$.
In one operation Orac can choose an arbitrary subsegment $[l \ldots r]$ of this sequence and replace all values $a_l, a_{l + 1}, \ldots, a_r$ to the value of median of $\{a_l, a_{l + 1},... | {"inputs": ["1\n5 2\n2 1 5 1 1\n", "1\n5 2\n2 1 5 1 1\n", "1\n5 2\n4 1 5 1 1\n", "1\n5 2\n4 1 5 2 1\n", "1\n6 3\n3 1 1 6 1 6\n", "1\n6 3\n4 1 4 1 1 3\n", "1\n6 2\n3 1 3 1 1 2\n", "1\n6 3\n5 1 5 2 2 3\n"], "outputs": ["yes\n", "yes\n", "no\n", "yes\n", "yes\n", "yes\n", "yes\n", "yes\n"]} | 643 | 190 |
coding | Solve the programming task below in a Python markdown code block.
In order to write a string, Atilla needs to first learn all letters that are contained in the string.
Atilla needs to write a message which can be represented as a string $s$. He asks you what is the minimum alphabet size required so that one can write ... | {"inputs": ["5\n1\na\n4\ndown\n10\ncodeforces\n3\nbcf\n5\nzzzzz\n"], "outputs": ["1\n23\n19\n6\n26\n"]} | 400 | 52 |
coding | Solve the programming task below in a Python markdown code block.
You are playing a game where your character should overcome different obstacles. The current problem is to come down from a cliff. The cliff has height $h$, and there is a moving platform on each height $x$ from $1$ to $h$.
Each platform is either hidde... | {"inputs": ["1\n3 2\n3 2\n", "1\n3 2\n3 2\n", "1\n3 2\n3 1\n", "1\n6 2\n6 2\n", "1\n6 2\n6 1\n", "1\n6 2\n6 3\n", "4\n3 2\n3 1\n8 6\n8 7 6 5 3 2\n9 6\n9 8 5 4 3 1\n1 1\n1\n", "4\n1 1\n1\n3 2\n3 1\n8 6\n8 7 6 5 3 2\n9 6\n9 8 5 4 3 1\n"], "outputs": ["1\n", "1\n", "0\n", "1\n", "0\n", "1\n", "0\n1\n2\n0\n", "0\n0\n1\n2\n... | 674 | 222 |
coding | Solve the programming task below in a Python markdown code block.
Given an array of integers, find the one that appears an odd number of times.
There will always be only one integer that appears an odd number of times.
Also feel free to reuse/extend the following starter code:
```python
def find_it(seq):
``` | {"functional": "_inputs = [[[20, 1, -1, 2, -2, 3, 3, 5, 5, 1, 2, 4, 20, 4, -1, -2, 5]], [[1, 1, 2, -2, 5, 2, 4, 4, -1, -2, 5]], [[20, 1, 1, 2, 2, 3, 3, 5, 5, 4, 20, 4, 5]], [[10]], [[1, 1, 1, 1, 1, 1, 10, 1, 1, 1, 1]]]\n_outputs = [[5], [-1], [5], [10], [10]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstan... | 66 | 330 |
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- 2\n", "1 1\n+ 1\n", "3 1\n- 2\n", "3 1\n- 3\n", "20 1\n- 16\n", "20 1\n- 16\n"], "outputs": ["1\n1 ", "2\n1 2 ", "2\n1 2 \n", "1\n1 \n", "3\n1 2 3\n", "3\n1 2 3\n", "20\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 ", "20\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 1... | 614 | 250 |
coding | Solve the programming task below in a Python markdown code block.
Ambar is a gardener and have many water jugs in his garden.
The shape of water jug is a cone placed on the top of a cylinder (the radius and height of cylinder and cone and is "r").
There is a jug for each value of "r'. "r" varies from 1 to "n" ("n" be... | {"inputs": ["100"], "outputs": ["106824622"]} | 181 | 22 |
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 with no duplicates. A maximum binary tree can be built recursively from nums using the following algorithm:
Create a root node whose value is the maximum value in nums.
Recursively... | {"functional": "def check(candidate):\n assert is_same_tree(candidate(nums = [3,2,1,6,0,5]), tree_node([6,3,5,None,2,0,None,None,1]))\n assert is_same_tree(candidate(nums = [3,2,1]), tree_node([3,None,2,None,1]))\n\n\ncheck(Solution().constructMaximumBinaryTree)"} | 189 | 90 |
coding | Solve the programming task below in a Python markdown code block.
For a binary string S, define its beauty to be the maximum number of [substrings] S can be partitioned into, such that each substring has strictly more ones than zeroes. For example, the beauty of 11011 is 3, as it can be partitioned as [110][1][1]. If s... | {"inputs": ["4 1\n1\n0\n2\n11\n3\n010\n4\n0110\n2 4"], "outputs": ["3"]} | 633 | 40 |
coding | Solve the programming task below in a Python markdown code block.
In a classic chase, Tom is running after Jerry as Jerry has eaten Tom's favourite food.
Jerry is running at a speed of X metres per second while Tom is chasing him at a speed of Y metres per second. Determine whether Tom will be able to catch Jerry.
No... | {"inputs": ["4\n2 3\n4 1\n1 1\n3 5\n"], "outputs": ["YES\nNO\nNO\nYES\n"]} | 475 | 36 |
coding | Solve the programming task below in a Python markdown code block.
Indraneel's student has given him data from two sets of experiments that the student has performed. Indraneel wants to establish a correlation between the two sets of data. Each data set is a sequence of $N$ numbers. The two data sets do not match number... | {"inputs": ["7\n3 8 4 23 9 11 28\n2 3 22 26 8 16 12"], "outputs": ["4\n3 4 23 9\n2 3 22 8"]} | 470 | 65 |
coding | Solve the programming task below in a Python markdown code block.
Ahmed Gafer failed to pass the test, but he got the job because of his friendship with Said and Shahhoud. After working in the kitchen for a while, he blew it. The customers didn't like the food anymore and one day he even burned the kitchen. Now the mas... | {"inputs": ["2\na\nabba"], "outputs": ["0\n2"]} | 461 | 19 |
coding | Solve the programming task below in a Python markdown code block.
The Binomial Form of a polynomial has many uses, just as the standard form does. For comparison, if p(x) is in Binomial Form and q(x) is in standard form, we might write
p(x) := a0 \* xC0 + a1 \* xC1 + a2 \* xC2 + ... + aN \* xCN
q(x) := b0 + b1 \* x ... | {"functional": "_inputs = [[[1, 2, 7], 3], [[1, 2, 7, 0, 5], 2], [[1, 1, 1, 1, 7, 0, 5], 2], [[1, 2, 7, 0, 5], 0.6], [[1, 2, 7, 0, 5], 0]]\n_outputs = [[16], [12], [12], [4.24], [5.0]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return math.isclose(a, b, re... | 529 | 263 |
coding | Solve the programming task below in a Python markdown code block.
Madoka is a very strange girl, and therefore she suddenly wondered how many pairs of integers $(a, b)$ exist, where $1 \leq a, b \leq n$, for which $\frac{\operatorname{lcm}(a, b)}{\operatorname{gcd}(a, b)} \leq 3$.
In this problem, $\operatorname{gcd}(... | {"inputs": ["6\n1\n2\n3\n4\n5\n100000000\n"], "outputs": ["1\n4\n7\n10\n11\n266666666\n"]} | 426 | 54 |
coding | Solve the programming task below in a Python markdown code block.
You have given an array $a$ of length $n$ and an integer $x$ to a brand new robot. What the robot does is the following: it iterates over the elements of the array, let the current element be $q$. If $q$ is divisible by $x$, the robot adds $x$ copies of ... | {"inputs": ["2\n1 2\n12\n4 2\n4 6 8 2\n", "2\n1 2\n12\n4 2\n4 6 4 2\n", "2\n1 2\n12\n4 2\n7 6 4 2\n", "2\n1 2\n12\n4 2\n7 6 5 2\n", "2\n1 2\n12\n4 2\n7 6 3 2\n", "2\n1 2\n12\n4 2\n7 6 6 2\n", "2\n1 2\n1\n4 2\n2 11 8 2\n", "2\n1 2\n12\n4 4\n7 6 3 1\n"], "outputs": ["36\n44\n", "36\n36\n", "36\n19\n", "36\n20\n", "36\n18... | 626 | 253 |
coding | Solve the programming task below in a Python markdown code block.
Chef has recently started playing chess, and wants to play as many games as possible.
He calculated that playing one game of chess takes at least 20 minutes of his time.
Chef has N hours of free time. What is the maximum number of complete chess games... | {"inputs": ["4\n1\n10\n7\n3\n"], "outputs": ["3\n30\n21\n9\n"]} | 329 | 31 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given an integer array nums, in which exactly two elements appear only once and all the other elements appear exactly twice. Find the two elements that appear only once. You can return the answer in any order.
You mus... | {"functional": "def check(candidate):\n assert candidate(nums = [1,2,1,3,2,5]) == [3,5]\n assert candidate(nums = [-1,0]) == [-1,0]\n assert candidate(nums = [0,1]) == [1,0]\n\n\ncheck(Solution().singleNumber)"} | 110 | 78 |
coding | Solve the programming task below in a Python markdown code block.
In Byteland there are N cities, numbered 1 through N. Some pairs of cities are connected by bi-directional roads in such a way that starting from any one city you can visit all other cities either directly or indirectly.
Chef is currently at city A and ... | {"inputs": ["2\n3\n1 2\n1 3\n1\n5\n1 2\n1 3\n2 4\n2 5\n1"], "outputs": ["2\n4"]} | 578 | 46 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given an m x n matrix, return a new matrix answer where answer[row][col] is the rank of matrix[row][col].
The rank is an integer that represents how large an element is compared to other elements. It is calculated usi... | {"functional": "def check(candidate):\n assert candidate(matrix = [[1,2],[3,4]]) == [[1,2],[2,3]]\n assert candidate(matrix = [[7,7],[7,7]]) == [[1,1],[1,1]]\n assert candidate(matrix = [[20,-21,14],[-19,4,19],[22,-47,24],[-19,4,19]]) == [[4,2,3],[1,3,4],[5,1,6],[1,3,4]]\n assert candidate(matrix = [[7,3,6]... | 191 | 186 |
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 and an integer value.
In one operation, you can add or subtract value from any element of nums.
For example, if nums = [1,2,3] and value = 2, you can choose to subtract va... | {"functional": "def check(candidate):\n assert candidate(nums = [1,-10,7,13,6,8], value = 5) == 4\n assert candidate(nums = [1,-10,7,13,6,8], value = 7) == 2\n\n\ncheck(Solution().findSmallestInteger)"} | 197 | 79 |
coding | Solve the programming task below in a Python markdown code block.
You are given a string $s$ of lowercase Latin letters.
The following operation can be used:
select one character (from 'a' to 'z') that occurs at least once in the string. And replace all such characters in the string with the previous one in alphabeti... | {"inputs": ["1\n15 1\nwaterwaterwater\n", "4\n3 2\ncba\n4 5\nfgde\n7 5\ngndcafb\n4 19\nekyv\n"], "outputs": ["vatervatervater\n", "aaa\nagaa\nbnbbabb\naapp\n"]} | 497 | 77 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given a positive integer num, split it into two non-negative integers num1 and num2 such that:
The concatenation of num1 and num2 is a permutation of num.
In other words, the sum of the number of occurrences of ea... | {"functional": "def check(candidate):\n assert candidate(num = 4325) == 59\n assert candidate(num = 687) == 75\n\n\ncheck(Solution().splitNum)"} | 176 | 50 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
There is a car with capacity empty seats. The vehicle only drives east (i.e., it cannot turn around and drive west).
You are given the integer capacity and an array trips where trips[i] = [numPassengersi, fromi, toi] ... | {"functional": "def check(candidate):\n assert candidate(trips = [[2,1,5],[3,3,7]], capacity = 4) == False\n assert candidate(trips = [[2,1,5],[3,3,7]], capacity = 5) == True\n\n\ncheck(Solution().carPooling)"} | 176 | 73 |
coding | Solve the programming task below in a Python markdown code block.
A and B are preparing themselves for programming contests.
An important part of preparing for a competition is sharing programming knowledge from the experienced members to those who are just beginning to deal with the contests. Therefore, during the ne... | {"inputs": ["2 6\n", "4 5\n", "1 1\n", "3 3\n", "0 0\n", "0 1\n", "1 0\n", "0 6\n"], "outputs": ["2\n", "3\n", "0\n", "2\n", "0\n", "0\n", "0\n", "0\n"]} | 365 | 86 |
coding | Solve the programming task below in a Python markdown code block.
You have decided to write a book introducing good restaurants.
There are N restaurants that you want to introduce: Restaurant 1, Restaurant 2, ..., Restaurant N. Restaurant i is in city S_i, and your assessment score of that restaurant on a 100-point sca... | {"inputs": ["1\nv 81\n", "6\nrgkkavbtoa 3\nqooqye -1\n`nz^k 4\njabyp 0\nowdnsk 0\njb`qnvtajl 1", "6\nrgkkavbtoa 3\nqooqye -1\n`mz]k 3\npybaj 0\nowdnsk 0\njb`qnvtajl 1", "6\nqgkkavbtoa 3\nqooqye -1\n`mz]k 3\npybaj 0\nowdnsk 0\njb`qnvtajl 1", "6\naotbvakkgq 3\nqooqye -1\n`mz]k 3\npybaj 0\nowdnsk 0\njb`qnvtajl 1", "6\nrgk... | 409 | 445 |
coding | Solve the programming task below in a Python markdown code block.
You are given a string S, each of whose characters is either '0', '1', or '?'.
The *badness* of a binary string is defined to be the (absolute) difference between the number of 1s and the number of 0s present in it. For example, 001 has badness |1-2| = ... | {"inputs": ["4\n4\n?101\n4\n??10\n6\n???111\n5\n1?0?1\n"], "outputs": ["0101\n1010\n000111\n11001\n"]} | 688 | 63 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given a 0-indexed array nums comprising of n non-negative integers.
In one operation, you must:
Choose an integer i such that 1 <= i < n and nums[i] > 0.
Decrease nums[i] by 1.
Increase nums[i - 1] by 1.
Ret... | {"functional": "def check(candidate):\n assert candidate(nums = [3,7,1,6]) == 5\n assert candidate(nums = [10,1]) == 10\n\n\ncheck(Solution().minimizeArrayValue)"} | 131 | 55 |
coding | Solve the programming task below in a Python markdown code block.
Read problems statements in Mandarin Chinese and Russian as well.
Chef wants to implement wildcard pattern matching supporting only the wildcard '?'. The wildcard character '?' can be substituted by any single lower case English letter for matching. He... | {"inputs": ["2\ns?or?\nsco??\nstor?\nsco??", "2\ns?o?r\nsco??\nstor?\nsco??", "2\nr?o?s\nsco??\nstor?\nsco??", "2\nr?o?s\nsco??\n?rots\nsco??", "2\nr?o?s\nsco??\n@rots\nsco??", "2\nr?o?s\nsco??\n@rots\n??ocs", "2\nr?o?s\nsco??\n@rots\ntco??", "2\nr?o?s\nsco??\n@rots\nuco??"], "outputs": ["Yes\nNo", "Yes\nNo\n", "No\nNo... | 398 | 209 |
coding | Solve the programming task below in a Python markdown code block.
Vasya wrote down two strings s of length n and t of length m consisting of small English letters 'a' and 'b'. What is more, he knows that string t has a form "abab...", namely there are letters 'a' on odd positions and letters 'b' on even positions.
Sud... | {"inputs": ["1\nb\n1\n", "1\nb\n1\n", "1\nb\n2\n", "3\nb?a\n1\n", "3\nb?a\n1\n", "3\nba?\n1\n", "3\n?ab\n1\n", "5\nbb?a?\n1\n"], "outputs": ["0\n", "0", "0\n", "1\n", "1\n", "1\n", "1\n", "2\n"]} | 498 | 107 |
coding | Solve the programming task below in a Python markdown code block.
Given is a string S, where each character is `0`, `1`, or `?`.
Consider making a string S' by replacing each occurrence of `?` with `0` or `1` (we can choose the character for each `?` independently). Let us define the unbalancedness of S' as follows:
... | {"inputs": ["?0?", "?/?", "??0", "??/", "?.?", "??1", "?-?", "?,?"], "outputs": ["1\n", "1\n", "1\n", "1\n", "1\n", "1\n", "1\n", "1\n"]} | 277 | 66 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given an array of strings patterns and a string word, return the number of strings in patterns that exist as a substring in word.
A substring is a contiguous sequence of characters within a string.
Please complete t... | {"functional": "def check(candidate):\n assert candidate(patterns = [\"a\",\"abc\",\"bc\",\"d\"], word = \"abc\") == 3\n assert candidate(patterns = [\"a\",\"b\",\"c\"], word = \"aaaaabbbbb\") == 2\n assert candidate(patterns = [\"a\",\"a\",\"a\"], word = \"ab\") == 3\n\n\ncheck(Solution().numOfStrings)"} | 90 | 96 |
coding | Solve the programming task below in a Python markdown code block.
In this Kata, you will be given directions and your task will be to find your way back.
```Perl
solve(["Begin on Road A","Right on Road B","Right on Road C","Left on Road D"]) = ['Begin on Road D', 'Right on Road C', 'Left on Road B', 'Left on Road A']
... | {"functional": "_inputs = [[['Begin on 3rd Blvd', 'Right on First Road', 'Left on 9th Dr']], [['Begin on Road A', 'Right on Road B', 'Right on Road C', 'Left on Road D']], [['Begin on Road A']]]\n_outputs = [[['Begin on 9th Dr', 'Right on First Road', 'Left on 3rd Blvd']], [['Begin on Road D', 'Right on Road C', 'Left ... | 204 | 256 |
coding | Solve the programming task below in a Python markdown code block.
Recently, Greg got a grid with n rows and m columns. Rows are indexed from 1 to n and columns are indexed from 1 to m. The cell $ ( i , j )$ is the cell of intersection of row i and column j. Each cell has a number written on it. The number written on ce... | {"inputs": ["3 4\n"], "outputs": ["4"]} | 212 | 15 |
coding | Solve the programming task below in a Python markdown code block.
Chef is now a corporate person. He has to attend office regularly. But chef does not want to go to office, rather he wants to stay home and discover different recipes and cook them.
In the office where chef works, has two guards who count how many times... | {"inputs": ["1\n19 17"], "outputs": ["19 36"]} | 336 | 22 |
coding | Solve the programming task below in a Python markdown code block.
Complete the function ```circleArea``` so that it will return the area of a circle with the given ```radius```. Round the returned number to two decimal places (except for Haskell). If the radius is not positive or not a number, return ```false```.
Exam... | {"functional": "_inputs = [[0], ['An integer']]\n_outputs = [[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)):\n if len(a) != len(b): return False\n... | 172 | 161 |
coding | 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... | 121 | 246 |
coding | Solve the programming task below in a Python markdown code block.
Given is an integer N. Find the number of positive integers less than or equal to N that have an odd number of digits (in base ten without leading zeros).
-----Constraints-----
- 1 \leq N \leq 10^5
-----Input-----
Input is given from Standard Input in... | {"inputs": ["2", "3", "4", "1", "0", "7", "6", "5"], "outputs": ["2\n", "3\n", "4\n", "1\n", "0\n", "7\n", "6\n", "5\n"]} | 152 | 62 |
coding | Solve the programming task below in a Python markdown code block.
Your task is to make a program takes in a sentence (without puncuation), adds all words to a list and returns the sentence as a string which is the positions of the word in the list. Casing should not matter too.
Example
-----
`"Ask not what your COUN... | {"functional": "_inputs = [['The bumble bee'], ['SILLY LITTLE BOYS silly little boys'], ['Ask not what your COUNTRY can do for you ASK WHAT YOU CAN DO FOR YOUR country'], ['The number 0 is such a strange number Strangely it has zero meaning']]\n_outputs = [['012'], ['012012'], ['01234567802856734'], ['012345617891011']... | 160 | 254 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You have n processes forming a rooted tree structure. You are given two integer arrays pid and ppid, where pid[i] is the ID of the ith process and ppid[i] is the ID of the ith process's parent process.
Each process ha... | {"functional": "def check(candidate):\n assert candidate(pid = [1,3,10,5], ppid = [3,0,5,3], kill = 5) == [5,10]\n assert candidate(pid = [1], ppid = [0], kill = 1) == [1]\n\n\ncheck(Solution().killProcess)"} | 202 | 83 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are playing the following Nim Game with your friend:
Initially, there is a heap of stones on the table.
You and your friend will alternate taking turns, and you go first.
On each turn, the person whose turn it is... | {"functional": "def check(candidate):\n assert candidate(n = 4) == False \n assert candidate(n = 1) == True\n assert candidate(n = 2) == True\n\n\ncheck(Solution().canWinNim)"} | 152 | 55 |
coding | Solve the programming task below in a Python markdown code block.
Polycarpus has postcards and photos hung in a row on the wall. He decided to put them away to the closet and hang on the wall a famous painter's picture. Polycarpus does it like that: he goes from the left to the right and removes the objects consecutive... | {"inputs": ["P\n", "C\n", "CP\n", "PC\n", "PPPP\n", "PPPPP\n", "CPCCPPC\n", "CPPCCPC\n"], "outputs": ["1\n", "1\n", "2\n", "2\n", "1\n", "1\n", "5\n", "5\n"]} | 503 | 77 |
coding | Solve the programming task below in a Python markdown code block.
Problem statement
A programming contest will be held in the Russian Federation. The contest has N questions and has M participants. Question i has a score a_i, and it is known that participant j's ability is b_j. For problem i and participant j, partici... | {"inputs": ["6\n1 2 1 3 4 5\n7\n1 3 4 5 3 1 0\n2 8 5 3 4 5 3", "6\n1 2 1 5 4 5\n7\n1 3 4 7 3 1 0\n2 8 5 3 7 5 3", "6\n1 2 2 5 4 5\n7\n1 3 4 7 3 1 0\n2 8 5 3 7 5 3", "6\n1 2 1 6 3 1\n7\n1 3 4 7 3 1 0\n2 8 5 3 3 0 3", "6\n1 2 2 8 6 1\n7\n2 3 4 2 3 1 0\n1 8 1 3 3 1 1", "6\n1 2 1 5 4 5\n7\n1 3 3 7 3 1 0\n2 8 5 3 7 5 3", "6... | 701 | 494 |
coding | Solve the programming task below in a Python markdown code block.
Today, Marin is at a cosplay exhibition and is preparing for a group photoshoot!
For the group picture, the cosplayers form a horizontal line. A group picture is considered beautiful if for every contiguous segment of at least $2$ cosplayers, the number... | {"inputs": ["9\n3\n000\n3\n001\n3\n010\n3\n011\n3\n100\n3\n101\n3\n110\n3\n111\n19\n1010110000100000101\n"], "outputs": ["4\n2\n1\n0\n2\n0\n0\n0\n17\n"]} | 568 | 102 |
coding | Solve the programming task below in a Python markdown code block.
There are N+1 towns. The i-th town is being attacked by A_i monsters.
We have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters.
What is the maximum total number of monsters the heroes ca... | {"inputs": ["1\n1 1\n1\n", "2\n3 5 2\n7 5", "2\n3 5 1\n7 5", "2\n3 5 1\n0 5", "2\n2 5 1\n0 5", "2\n2 9 1\n0 5", "2\n2 9 1\n0 2", "2\n2 1 1\n0 2"], "outputs": ["1\n", "10\n", "9\n", "5\n", "5\n", "5\n", "2\n", "2\n"]} | 282 | 140 |
coding | Solve the programming task below in a Python markdown code block.
Santosh has a farm at Byteland. He has a very big family to look after. His life takes a sudden turn and he runs into a financial crisis. After giving all the money he has in his hand, he decides to sell his plots. The speciality of his land is that it ... | {"inputs": ["2\n9 4\n2 2", "2\n9 4\n2 3", "2\n5 4\n2 3", "2\n8 4\n2 3", "2\n4 1\n2 3", "2\n8 5\n4 1", "2\n9 8\n2 1", "2\n9 3\n2 2"], "outputs": ["36\n1\n", "36\n6\n", "20\n6\n", "2\n6\n", "4\n6\n", "40\n4\n", "72\n2\n", "3\n1\n"]} | 348 | 147 |
coding | Solve the programming task below in a Python markdown code block.
You're a programmer in a SEO company. The SEO specialist of your company gets the list of all project keywords everyday, then he looks for the longest keys to analyze them.
You will get the list with keywords and must write a simple function that return... | {"functional": "_inputs = [['key1', 'key22', 'key333'], ['coding', 'sorting', 'tryruby'], ['small keyword', 'how to coding?', 'very nice kata', 'a lot of keys', 'I like Ruby!!!'], ['pippi']]\n_outputs = [[\"'key333'\"], [\"'sorting', 'tryruby'\"], [\"'I like Ruby!!!', 'how to coding?', 'very nice kata'\"], [\"'pippi'\"... | 169 | 254 |
coding | Solve the programming task below in a Python markdown code block.
Taru likes reading. Every month he gets a copy of the magazine "BIT". The magazine contains information about the latest advancements in technology. Taru
reads the book at night and writes the page number to which he has read on a piece of paper so th... | {"inputs": ["2\n10\n2 1 2\n2\n10\n1 8\n0"], "outputs": ["31.2000\n47.0000"]} | 537 | 46 |
coding | Solve the programming task below in a Python markdown code block.
Facetook is a well known social network website, and it will launch a new feature called Facetook Priority Wall. This feature will sort all posts from your friends according to the priority factor (it will be described).
This priority factor will be aff... | {"inputs": ["a\n1\nb likes c's post\n", "a\n1\nc likes b's post\n", "aba\n1\nkikes likes posted's post\n", "aba\n1\nlieks likes posted's post\n", "aba\n1\nlheks likes posted's post\n", "aba\n1\nlikes likes posted's post\n", "fgzrn\n3\nzhl likes fgzrn's post\nxryet likes fgzrn's post\nzhl commented on fgzrn's post\n", "... | 592 | 218 |
coding | Solve the programming task below in a Python markdown code block.
Takahashi has an empty string S and a variable x whose initial value is 0.
Also, we have a string T consisting of `0` and `1`.
Now, Takahashi will do the operation with the following two steps |T| times.
* Insert a `0` or a `1` at any position of S of... | {"inputs": ["1001", "1000", "1010", "0010", "0001", "0000", "1110", "1011"], "outputs": ["5\n", "4\n", "6\n", "3\n", "2\n", "0\n", "6\n", "6\n"]} | 281 | 86 |
coding | Solve the programming task below in a Python markdown code block.
The positive odd numbers are sorted in ascending order as $1,3,5,7,9,11,13,15,17,19\ldots$, and grouped as $(1),(3,5),(7,9,11),(13,15,17,19),...$ and so on.
Thus, the first group is $\left(1\right)$, the second group is $(3,5)$, the third group is $(7,9... | {"inputs": ["3\n"], "outputs": ["27\n"]} | 342 | 15 |
coding | Solve the programming task below in a Python markdown code block.
Demiurges Shambambukli and Mazukta love to watch the games of ordinary people. Today, they noticed two men who play the following game.
There is a rooted tree on n nodes, m of which are leaves (a leaf is a nodes that does not have any children), edges o... | {"inputs": ["1\n", "1\n", "2\n1 2\n", "2\n1 2\n", "3\n1 2\n1 3\n", "3\n1 2\n1 3\n", "3\n1 2\n2 3\n", "5\n1 2\n1 3\n2 4\n2 5\n"], "outputs": ["1 1\n", "1 1", "1 1\n", "1 1", "2 2\n", "2 2", "1 1\n", "3 2\n"]} | 649 | 131 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
On a single-threaded CPU, we execute a program containing n functions. Each function has a unique ID between 0 and n-1.
Function calls are stored in a call stack: when a function call starts, its ID is pushed onto the... | {"functional": "def check(candidate):\n assert candidate(n = 2, logs = [\"0:start:0\",\"1:start:2\",\"1:end:5\",\"0:end:6\"]) == [3,4]\n assert candidate(n = 1, logs = [\"0:start:0\",\"0:start:2\",\"0:end:5\",\"0:start:6\",\"0:end:6\",\"0:end:7\"]) == [8]\n assert candidate(n = 2, logs = [\"0:start:0\",\"0:sta... | 352 | 157 |
coding | Solve the programming task below in a Python markdown code block.
We have two distinct integers A and B.
Print the integer K such that |A - K| = |B - K|.
If such an integer does not exist, print IMPOSSIBLE instead.
-----Constraints-----
- All values in input are integers.
- 0 \leq A,\ B \leq 10^9
- A and B are dist... | {"inputs": ["0 4", "0 2", "1 7", "6 4", "0 3", "0 3\n", "0 1\n", "1 13"], "outputs": ["2\n", "1\n", "4\n", "5\n", "IMPOSSIBLE", "IMPOSSIBLE\n", "IMPOSSIBLE\n", "7\n"]} | 176 | 89 |
coding | Solve the programming task below in a Python markdown code block.
The Fibonacci sequence $F_0, F_1, \ldots$ is a special infinite sequence of non-negative integers, where $F_0 = 0$, $F_1 = 1$ and for each integer $n \ge 2$, $F_n = F_{n-1} + F_{n-2}$.
Consider the sequence $D$ of the last decimal digits of the first $N$... | {"inputs": ["1\n9"], "outputs": ["3"]} | 558 | 14 |
coding | Solve the programming task below in a Python markdown code block.
Vasya is a school PE teacher. Unlike other PE teachers, Vasya doesn't like it when the students stand in line according to their height. Instead, he demands that the children stand in the following order: a1, a2, ..., an, where ai is the height of the i-... | {"inputs": ["4\n2 1 3 2\n3 2 1 2\n", "4\n2 2 3 1\n3 2 1 2\n", "4\n1 2 3 4\n3 2 1 4\n", "4\n2 2 3 2\n3 2 2 2\n", "4\n1 2 3 2\n3 2 1 2\n", "2\n1 100500\n1 100500\n", "1\n800950546\n800950546\n", "1\n873725529\n873725529\n"], "outputs": ["2\n1 2\n2 3\n", "3\n1 2\n3 4\n2 3\n", "3\n2 3\n1 2\n2 3\n", "2\n1 2\n2 3\n", "3\n2 3... | 498 | 260 |
coding | Solve the programming task below in a Python markdown code block.
Petya was late for the lesson too. The teacher gave him an additional task. For some array a Petya should find the number of different ways to select non-empty subset of elements from it in such a way that their product is equal to a square of some integ... | {"inputs": ["1\n64\n", "1\n64\n", "1\n33\n", "1\n42\n", "1\n69\n", "2\n15 4\n", "2\n15 5\n", "2\n70 70\n"], "outputs": ["1\n", "1\n", "0\n", "0\n", "0\n", "1\n", "0\n", "1\n"]} | 348 | 101 |
coding | Solve the programming task below in a Python markdown code block.
Take a string and return a hash with all the ascii values of the characters in the string.
Returns nil if the string is empty.
The key is the character, and the value is the ascii value of the character.
Repeated characters are to be ignored and non-alph... | {"functional": "_inputs = [[''], ['a'], ['aaa'], ['hello world'], ['ABaa ^']]\n_outputs = [[None], [{'a': 97}], [{'a': 97}], [{'h': 104, 'e': 101, 'l': 108, 'o': 111, 'w': 119, 'r': 114, 'd': 100}], [{'A': 65, 'B': 66, 'a': 97}]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, ... | 95 | 261 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given an integer n representing the number of houses on a number line, numbered from 0 to n - 1.
Additionally, you are given a 2D integer array offers where offers[i] = [starti, endi, goldi], indicating that i... | {"functional": "def check(candidate):\n assert candidate(n = 5, offers = [[0,0,1],[0,2,2],[1,3,2]]) == 3\n assert candidate(n = 5, offers = [[0,0,1],[0,2,10],[1,3,2]]) == 10\n\n\ncheck(Solution().maximizeTheProfit)"} | 179 | 89 |
coding | Solve the programming task below in a Python markdown code block.
You are given an array a. Some element of this array a_{i} is a local minimum iff it is strictly less than both of its neighbours (that is, a_{i} < a_{i} - 1 and a_{i} < a_{i} + 1). Also the element can be called local maximum iff it is strictly greater ... | {"inputs": ["1\n1\n", "1\n1\n", "1\n2\n", "1\n0\n", "1\n4\n", "1\n3\n", "1\n8\n", "1\n5\n"], "outputs": ["0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n"]} | 296 | 86 |
coding | Solve the programming task below in a Python markdown code block.
Given an integer, $n$, print the following values for each integer $\boldsymbol{i}$ from $\mbox{1}$ to $n$:
Decimal
Octal
Hexadecimal (capitalized)
Binary
Function Description
Complete the print_formatted function in the editor below.
print_for... | {"inputs": ["17\n"], "outputs": [" 1 1 1 1\n 2 2 2 10\n 3 3 3 11\n 4 4 4 100\n 5 5 5 101\n 6 6 6 110\n 7 7 7 111\n 8 10 8 1000\n 9 11 9 1001\n 10 12 A 1010\n 11 13 B 1011\n 12 14... | 463 | 288 |
coding | Solve the programming task below in a Python markdown code block.
Alice recently converted all the positive integers from 1 to 2^{N} - 1 (both inclusive) into binary strings and stored them in an array S. Note that the binary strings do not have leading zeroes.
While she was out, Bob sorted all the elements of S in ... | {"inputs": ["3\n3 2\n3 4\n3 7"], "outputs": ["2\n5\n12\n"]} | 641 | 30 |
coding | Solve the programming task below in a Python markdown code block.
The task is simply stated. Given an integer n (3 < n < 10^(9)), find the length of the smallest list of [*perfect squares*](https://en.wikipedia.org/wiki/Square_number) which add up to n. Come up with the best algorithm you can; you'll need it!
Examples... | {"functional": "_inputs = [[15], [16], [17], [18], [19], [2017], [1008], [3456], [4000], [12321], [661915703], [999887641], [999950886], [999951173], [999998999]]\n_outputs = [[4], [1], [2], [2], [3], [2], [4], [3], [2], [1], [4], [1], [3], [2], [4]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, flo... | 457 | 301 |
coding | Solve the programming task below in a Python markdown code block.
Are you fond of collecting some kind of stuff? Mike is crazy about collecting stamps. He is an active member of Stamp Collecting Сommunity(SCC).
SCC consists of N members which are fond of philately. A few days ago Mike argued with the others from SCC.... | {"inputs": ["5\n1 1 1 1 0", "5\n1 2 1 1 0", "5\n0 2 1 1 0", "5\n0 3 1 1 0", "5\n0 3 1 0 0", "5\n0 3 1 0 1", "5\n0 3 0 0 1", "5\n0 3 0 0 0"], "outputs": ["NO\n", "NO\n", "NO\n", "NO\n", "NO\n", "NO\n", "NO\n", "NO\n"]} | 312 | 142 |
coding | Solve the programming task below in a Python markdown code block.
Take debugging to a whole new level:
Given a string, remove every *single* bug.
This means you must remove all instances of the word 'bug' from within a given string, *unless* the word is plural ('bugs').
For example, given 'obugobugobuoobugsoo', you ... | {"functional": "_inputs = [['obugobugobuoobugsoo'], ['obbugugo'], ['bugs bunny'], ['bugs buggy'], ['oaiwjefbugoijoijapsbugsdoibugbugjfoijasdfbugsbug'], ['bugbugbugiahweoifuhiaasnoidfhnbugbugs'], ['bugsbugswaoeifhiauwehfoiwubugshefjnviouah'], ['bugbugbugbug'], ['bugsbugsbugsbugs'], ['buggybugs'], ['oaisjdfowjefpoibugsjs... | 138 | 393 |
coding | Solve the programming task below in a Python markdown code block.
Chef will not be able to attend the birthday of his best friend Rock. He promised Rock that this will not be the case on his half birthday. To keep his promise Chef must know Rock’s next half birthday accurately. Being busy, he is assigning this work to ... | {"inputs": ["3\n15 january\n31 august\n10 october"], "outputs": ["16 july\n1 march\n10 april"]} | 334 | 36 |
coding | Solve the programming task below in a Python markdown code block.
Let's consider a random permutation p_{1}, p_{2}, ..., p_{N} of numbers 1, 2, ..., N and calculate the value F=(X_{2}+...+X_{N-1})^{K}, where X_{i} equals 1 if one of the following two conditions holds: p_{i-1} < p_{i} > p_{i+1} or p_{i-1} > p_{i} < p_{i... | {"inputs": ["1 1000\n"], "outputs": ["1996 / 3\n"]} | 220 | 25 |
coding | Solve the programming task below in a Python markdown code block.
It's another Start[c]up finals, and that means there is pizza to order for the onsite contestants. There are only 2 types of pizza (obviously not, but let's just pretend for the sake of the problem), and all pizzas contain exactly S slices.
It is known ... | {"inputs": ["2 9\n6 1 7\n6 7 1\n", "2 9\n6 1 7\n6 7 1\n", "2 9\n5 1 7\n6 7 1\n", "2 9\n5 1 7\n6 9 1\n", "2 10\n7 2 1\n7 1 2\n", "2 10\n9 1 2\n9 2 1\n", "2 10\n9 1 2\n9 2 1\n", "2 10\n7 2 1\n7 1 2\n"], "outputs": ["84\n", "84\n", "77\n", "89\n", "28\n", "36\n", "36\n", "28\n"]} | 517 | 194 |
coding | Solve the programming task below in a Python markdown code block.
------Read problems statements in Hindi,
Mandarin chinese
, Russian and Vietnamese as well. ------
Chef likes to play with cards a lot. Today, he's playing a game with three cards. Each card has a letter written on the top face and another (possibly id... | {"inputs": ["3\nbob\nrob\ndbc\nocb\nboc\nobc"], "outputs": ["yes\nyes\nno"]} | 463 | 32 |
coding | Solve the programming task below in a Python markdown code block.
There are N squares numbered 1 to N from left to right. Each square has a character written on it, and Square i has a letter s_i. Besides, there is initially one golem on each square.
Snuke cast Q spells to move the golems.
The i-th spell consisted of ... | {"inputs": ["3 4\nACB\nA L\nB L\nB R\nA R", "3 3\nACB\nB L\nB L\nA R\n@ S", "3 3\nBCA\nB L\nB L\nA R\n@ S", "3 4\nCBB\nA L\nC L\nB R\nB R", "3 4\nACB\nA L\nB L\nB R\n@ R", "3 3\nACB\nA L\nB L\nB R\n@ R", "3 3\nACB\nA L\nB L\nA R\n@ R", "3 3\nACB\nA L\nB L\nA R\n@ S"], "outputs": ["2\n", "3\n", "1\n", "0\n", "2\n", "2\n... | 396 | 198 |
coding | Solve the programming task below in a Python markdown code block.
You are given two strings s and t consisting of lowercase Latin letters. The length of t is 2 (i.e. this string consists only of two characters).
In one move, you can choose any character of s and replace it with any lowercase Latin letter. More formall... | {"inputs": ["2 1\naa\nsb\n", "2 2\nas\nsa\n", "2 1\nas\nsa\n", "2 0\nas\nas\n", "2 1\naa\nbs\n", "2 2\nas\nas\n", "2 1\nar\nsa\n", "2 0\nar\nas\n"], "outputs": ["0\n", "1\n", "0\n", "1\n", "0\n", "1\n", "0\n", "0\n"]} | 429 | 118 |
coding | Solve the programming task below in a Python markdown code block.
In a tournament, $n$ players play against each other exactly once. Each game results in exactly one player winning. There are no ties. You have been given a scorecard containing the scores of each player at the end of the tournament. The score of a playe... | {"inputs": ["5\n3\n-1 -1 2\n3\n-1 -1 -1\n4\n0 1 2 3\n2\n1 1\n4\n-1 -1 -1 2\n"], "outputs": ["2\n7\n1\n0\n12\n"]} | 550 | 68 |
coding | Solve the programming task below in a Python markdown code block.
The police department of your city has just started its journey. Initially, they don’t have any manpower. So, they started hiring new recruits in groups.
Meanwhile, crimes keeps occurring within the city. One member of the police force can investigate o... | {"inputs": ["1\n2\n", "1\n1\n", "1\n1\n", "1\n2\n", "1\n3\n", "1\n5\n", "1\n4\n", "1\n7\n"], "outputs": ["0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n"]} | 408 | 86 |
coding | Solve the programming task below in a Python markdown code block.
You are given an array of $n$ integers $a_1, a_2, \ldots, a_n$. After you watched the amazing film "Everything Everywhere All At Once", you came up with the following operation.
In one operation, you choose $n-1$ elements of the array and replace each o... | {"inputs": ["4\n3\n42 42 42\n5\n1 2 3 4 5\n4\n4 3 2 1\n3\n24 2 22\n"], "outputs": ["YES\nYES\nNO\nNO\n"]} | 551 | 63 |
coding | Solve the programming task below in a Python markdown code block.
Every natural number, ```n```, may have a prime factorization like:
We define the arithmetic derivative of ```n```, ```n'``` the value of the expression:
Let's do the calculation for ```n = 231525```.
```
231525 = 3³5²7³
n' = (3*3²)*5²7³ + 3³*(2*5... | {"functional": "_inputs = [[231525, 5], [997, 5]]\n_outputs = [[[231525, 423360, 1899072, 7879680, 51895296]], ['997 is a prime number']]\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, (... | 556 | 222 |
coding | Solve the programming task below in a Python markdown code block.
Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Daanish as always is busy creating and solving his favourite and interesting graph problems. Chef assigns each problem a difficulty — an integer betw... | {"inputs": ["5\n1 10 1 5 3 2 4 9 0 100\n100\n2 0 1 0 0 0 0 0 0 10\n12\n2 0 1 0 0 0 0 10 0 0\n0\n2 0 1 0 0 0 0 0 0 10\n10\n1 10 1 5 3 2 4 9 0 100\n125"], "outputs": ["8\n1\n8\n3\n2"]} | 673 | 145 |
coding | Solve the programming task below in a Python markdown code block.
There are $n$ distinct points on a coordinate line, the coordinate of $i$-th point equals to $x_i$. Choose a subset of the given set of points such that the distance between each pair of points in a subset is an integral power of two. It is necessary to ... | {"inputs": ["1\n1\n", "1\n1\n", "1\n2\n", "1\n4\n", "1\n8\n", "1\n7\n", "1\n0\n", "1\n5\n"], "outputs": ["1\n1 \n", "1\n1\n", "1\n2 \n", "1\n4 \n", "1\n8 \n", "1\n7 \n", "1\n0 \n", "1\n5 \n"]} | 478 | 109 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given a string s, return the number of different non-empty palindromic subsequences in s. Since the answer may be very large, return it modulo 109 + 7.
A subsequence of a string is obtained by deleting zero or more ch... | {"functional": "def check(candidate):\n assert candidate(s = 'bccb') == 6\n assert candidate(s = 'abcdabcdabcdabcdabcdabcdabcdabcddcbadcbadcbadcbadcbadcbadcbadcba') == 104860361\n\n\ncheck(Solution().countPalindromicSubsequences)"} | 156 | 80 |
coding | Solve the programming task below in a Python markdown code block.
An input string S of length N is transferred through the network using a special protocol. The protocol can send the string through a series of operations. In one operation, we can choose a lowercase english alphabet C and do one of the following:
Trans... | {"inputs": ["2\n5\ncbcdc\n6\naabeee\n"], "outputs": ["5\n4\n"]} | 462 | 27 |
coding | Solve the programming task below in a Python markdown code block.
You are given a tree rooted at node $1$ with $N$ vertices. The $i$$th$ vertex initially has value $A_i (1 \leq i \leq N)$. You are also given $Q$ queries.
In each query you are given a vertex $V$. Let $S = \{ S_1 , S_2 , ... S_x \} $ denote the set of ... | {"inputs": ["1\n4 3\n6 2 7 3\n1 2\n2 3\n3 4\n3\n2\n1"], "outputs": ["13 5 0 0"]} | 713 | 49 |
coding | Solve the programming task below in a Python markdown code block.
We have a string S consisting of lowercase English letters.
If the length of S is at most K, print S without change.
If the length of S exceeds K, extract the first K characters in S, append ... to the end of them, and print the result.
-----Constraints... | {"inputs": ["1\nz\n", "2\nz\n", "1\nfa\n", "7\necitslosdnaokin", "7\nnikoandrolstice", "7\noikoandrolstice", "7\noikoancrolstice", "7\noikobncsoletics"], "outputs": ["z\n", "z\n", "f...\n", "ecitslo...\n", "nikoand...\n", "oikoand...\n", "oikoanc...\n", "oikobnc...\n"]} | 212 | 119 |
coding | Solve the programming task below in a Python markdown code block.
Read problems statements [Mandarin] , [Bengali] , [Hindi] , [Russian] and [Vietnamese] as well.
You are given a grid with $N$ rows and $M$ columns; each cell of this grid is either empty or contains an obstacle. Initially, all cells are colorless.
You ... | {"inputs": ["2\n3 3\n..#\n...\n...\n3 3\n...\n.#.\n..."], "outputs": ["YES\nNO"]} | 429 | 36 |
coding | Solve the programming task below in a Python markdown code block.
Gray code is a form of binary encoding where transitions between consecutive numbers differ by only one bit. This is a useful encoding for reducing hardware data hazards with values that change rapidly and/or connect to slower hardware as inputs. It is a... | {"functional": "_inputs = [[[1, 0, 1]], [[1, 1]], [[1]], [[0]], [[1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0]], [[1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0]]]\n_outputs = [[[1, 1, 1]], [[1, 0]], [[... | 279 | 611 |
coding | Solve the programming task below in a Python markdown code block.
A tree is a graph with n vertices and exactly n - 1 edges; this graph should meet the following condition: there exists exactly one shortest (by number of edges) path between any pair of its vertices.
A subtree of a tree T is a tree with both vertices a... | {"inputs": ["3\n1 2\n1 3\n2 0 1\n", "3\n1 2\n1 3\n1 -1 1\n", "3\n1 2\n1 3\n1 -1 2\n", "3\n1 2\n1 3\n2 -1 1\n", "3\n1 2\n1 3\n1 -1 3\n", "3\n1 2\n1 3\n2 -1 3\n", "3\n1 2\n1 3\n1 -1 1\n", "5\n2 3\n4 5\n2 5\n1 3\n0 2 1 4 3\n"], "outputs": ["2\n", "3\n", "3\n", "4\n", "5\n", "4\n", "3\n", "8\n"]} | 417 | 194 |
coding | Solve the programming task below in a Python markdown code block.
Write a program to take a character (C) as input and check whether the given character is a vowel or a consonant.
NOTE:-
Vowels are 'A', 'E', 'I', 'O', 'U'. Rest all alphabets are called consonants.
------ Input Format ------
- First line will contai... | {"inputs": ["Z\n"], "outputs": ["Consonant"]} | 157 | 15 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given the head of a singly linked list, return true if it is a palindrome or false otherwise.
Please complete the following python code precisely:
```python
# Definition for singly-linked list.
# class ListNode:
# ... | {"functional": "def check(candidate):\n assert candidate(head = list_node([1,2,2,1])) == True\n assert candidate(head = list_node([1,2])) == False\n\n\ncheck(Solution().isPalindrome)"} | 109 | 53 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You have k servers numbered from 0 to k-1 that are being used to handle multiple requests simultaneously. Each server has infinite computational capacity but cannot handle more than one request at a time. The requests... | {"functional": "def check(candidate):\n assert candidate(k = 3, arrival = [1,2,3,4,5], load = [5,2,3,3,3] ) == [1] \n assert candidate(k = 3, arrival = [1,2,3,4], load = [1,2,1,2]) == [0]\n assert candidate(k = 3, arrival = [1,2,3], load = [10,12,11]) == [0,1,2]\n assert candidate(k = 3, arrival = [1,2,3,4,... | 323 | 206 |
coding | Solve the programming task below in a Python markdown code block.
Mike wants to prepare for IMO but he doesn't know geometry, so his teacher gave him an interesting geometry problem. Let's define f([l, r]) = r - l + 1 to be the number of integer points in the segment [l, r] with l ≤ r (say that $f(\varnothing) = 0$). Y... | {"inputs": ["1 1\n45 70\n", "1 1\n45 70\n", "1 1\n-35 -8\n", "1 1\n-35 -8\n", "1 1\n45 113\n", "1 1\n-40 -8\n", "1 1\n-79 -51\n", "1 1\n-79 -51\n"], "outputs": ["26\n", " 26\n", "28\n", " 28\n", "69... | 592 | 151 |
coding | Solve the programming task below in a Python markdown code block.
The MEX of a set of integers is defined as the smallest non-negative integer that does not belong to this set. For example, $\mathrm{MEX}(\{0,2,3\}) = 1$ and $\mathrm{MEX}(\{1,3\}) = 0$.
Chef has a tree with $N$ nodes (numbered $1$ through $N$). The tree... | {"inputs": ["2\n3\n1 1\n5\n1 1 2 2\n"], "outputs": ["4\n9"]} | 452 | 31 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given the root of a binary tree, return the sum of every tree node's tilt.
The tilt of a tree node is the absolute difference between the sum of all left subtree node values and all right subtree node values. If a nod... | {"functional": "def check(candidate):\n assert candidate(root = tree_node([1,2,3])) == 1\n assert candidate(root = tree_node([4,2,9,3,5,None,7])) == 15\n assert candidate(root = tree_node([21,7,14,1,1,2,2,3,3])) == 9\n\n\ncheck(Solution().findTilt)"} | 184 | 96 |
coding | Solve the programming task below in a Python markdown code block.
Check Tutorial tab to know how to to solve.
Here is a sample line of code that can be executed in Python:
print("Hello, World!")
You can just as easily store a string as a variable and then print it to stdout:
my_string = "Hello, World!"
print(... | {"inputs": [""], "outputs": ["Hello World!\n"]} | 132 | 15 |
coding | Solve the programming task below in a Python markdown code block.
You are given an array of integers [A1,A2,…,AN]$[A_1, A_2, \ldots, A_N]$. Let's call adding an element to this array at any position (including the beginning and the end) or removing an arbitrary element from it a modification. It is not allowed to remov... | {"inputs": ["2\n5\n1 4 1 2 2\n4\n2 3 2 3"], "outputs": ["1\n2"]} | 520 | 36 |
coding | Solve the programming task below in a Python markdown code block.
You're given an ancient book that unfortunately has a few pages in the wrong position, fortunately your computer has a list of every page number in order from ``1`` to ``n``.
You're supplied with an array of numbers, and should return an array with each... | {"functional": "_inputs = [[[1, 2, 10, 3, 4, 5, 8, 6, 7]], [[1, 2, 3, 4, 50, 5, 6, 7, 51, 8, 40, 9]], [[1, 2, 3000, 3, 4, 5, 8, 6, 7, 8, 100, 9, 40, 10, 11, 13]], [[1, 2, 3, 4, 50, 5, 6, 7, 51, 8, 9]], [[4, 1, 2, 3, 3, 4, 26, 5, 6, 2, 7]]]\n_outputs = [[[10, 8]], [[50, 51, 40]], [[3000, 8, 100, 40, 13]], [[50, 51]], [[... | 171 | 404 |
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 where the largest integer is unique.
Determine whether the largest element in the array is at least twice as much as every other number in the array. If it is, return the index of t... | {"functional": "def check(candidate):\n assert candidate(nums = [3,6,1,0]) == 1\n assert candidate(nums = [1,2,3,4]) == -1\n\n\ncheck(Solution().dominantIndex)"} | 103 | 56 |
coding | Solve the programming task below in a Python markdown code block.
There are some candies that need to be distributed to some children as fairly as possible (i.e. the variance of result needs to be as small as possible), but I don't know how to distribute them, so I need your help. Your assignment is to write a function... | {"functional": "_inputs = [[-5, 0], [10, 0], [15, 0], [-5, -5], [10, -5], [15, -5]]\n_outputs = [[[]], [[]], [[]], [[]], [[]], [[]]]\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,... | 636 | 202 |
coding | Solve the programming task below in a Python markdown code block.
There are $n$ people who want to participate in a boat competition. The weight of the $i$-th participant is $w_i$. Only teams consisting of two people can participate in this competition. As an organizer, you think that it's fair to allow only teams with... | {"inputs": ["5\n5\n1 2 3 4 5\n8\n6 6 6 6 6 6 8 8\n8\n1 2 2 1 2 1 1 2\n3\n1 3 3\n6\n1 1 3 4 2 2\n", "5\n5\n1 2 3 4 5\n8\n6 6 6 6 6 6 8 8\n8\n1 2 2 1 2 1 1 2\n3\n1 3 3\n6\n1 1 3 4 2 2\n", "4\n14\n2 6 5 9 5 8 13 14 8 5 6 14 5 2\n36\n15 22 27 7 23 36 1 17 33 21 18 7 3 4 32 24 8 19 36 22 17 2 24 10 26 4 30 6 2 6 11 19 18 1 ... | 727 | 1,281 |
coding | Solve the programming task below in a Python markdown code block.
-----Input-----
The only line of the input is a string of 7 characters. The first character is letter A, followed by 6 digits. The input is guaranteed to be valid (for certain definition of "valid").
-----Output-----
Output a single integer.
-----E... | {"inputs": ["A221033\n", "A223635\n", "A232726\n", "A102210\n", "A231010\n", "A222222\n", "A555555\n", "A102222\n"], "outputs": ["21\n", "22\n", "23\n", "25\n", "26\n", "13\n", "31\n", "19\n"]} | 114 | 126 |
coding | Solve the programming task below in a Python markdown code block.
# Task
We know that some numbers can be split into two primes. ie. `5 = 2 + 3, 10 = 3 + 7`. But some numbers are not. ie. `17, 27, 35`, etc..
Given a positive integer `n`. Determine whether it can be split into two primes. If yes, return the maximum pr... | {"functional": "_inputs = [[1], [3], [4], [5], [6], [7], [8], [9], [10], [11], [12], [20], [100]]\n_outputs = [[0], [0], [4], [6], [9], [10], [15], [14], [25], [0], [35], [91], [2491]]\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... | 311 | 242 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
For an integer array nums, an inverse pair is a pair of integers [i, j] where 0 <= i < j < nums.length and nums[i] > nums[j].
Given two integers n and k, return the number of different arrays consisting of numbers fro... | {"functional": "def check(candidate):\n assert candidate(n = 3, k = 0) == 1\n assert candidate(n = 3, k = 1) == 2\n\n\ncheck(Solution().kInversePairs)"} | 137 | 54 |
coding | Solve the programming task below in a Python markdown code block.
Notes
Template in C
Constraints
* 1 ≤ n ≤ 100000
* 1 ≤ q ≤ 1000
* 1 ≤ timei ≤ 50000
* 1 ≤ length of namei ≤ 10
* 1 ≤ Sum of timei ≤ 1000000
Input
n q
name1 time1
name2 time2
...
namen timen
In the first line the number of processes n and the quant... | {"inputs": ["5 100\np1 54\n2p 80\n3p 200\np4 350\np5 14", "5 100\np1 54\n2p 80\n3p 200\n4p 350\np5 14", "4 100\np1 150\np2 80\np3 240\n4p 350\np5 8", "2 100\np1 54\n2p 80\n3p 200\n4p 350\np5 14", "4 100\np1 150\no2 80\np3 240\n4p 350\np5 8", "4 101\np1 150\no2 80\np3 240\n4p 350\np4 8", "4 101\n1p 150\no2 80\np3 240\n4... | 259 | 555 |
coding | Solve the programming task below in a Python markdown code block.
Skyscraper "MinatoHarukas"
Mr. Port plans to start a new business renting one or more floors of the new skyscraper with one giga floors, MinatoHarukas. He wants to rent as many vertically adjacent floors as possible, because he wants to show advertiseme... | {"inputs": ["15\n6\n2\n3\n2360136\n434020716\n332845831\n6280939\n987698769\n999999999\n0", "15\n16\n2\n3\n8678728\n223092870\n332845831\n6280939\n987698769\n999999999\n0", "15\n16\n2\n3\n8678728\n434020716\n332845831\n6280939\n987698769\n999999999\n0", "15\n6\n2\n3\n9699690\n116276261\n840868300\n986291783\n565625340\... | 753 | 1,234 |
coding | Solve the programming task below in a Python markdown code block.
Today an outstanding event is going to happen in the forest — hedgehog Filya will come to his old fried Sonya!
Sonya is an owl and she sleeps during the day and stay awake from minute l_1 to minute r_1 inclusive. Also, during the minute k she prinks and... | {"inputs": ["6 6 5 8 9\n", "1 1 1 1 1\n", "1 2 3 4 5\n", "1 3 3 5 3\n", "1 2 2 3 5\n", "2 4 3 7 3\n", "2 4 1 2 5\n", "4 6 6 8 9\n"], "outputs": ["1\n", "0\n", "0\n", "0\n", "1\n", "1\n", "1\n", "1\n"]} | 338 | 134 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.