task_type stringclasses 4
values | problem stringlengths 14 5.23k | solution stringlengths 1 8.29k | problem_tokens int64 9 1.02k | solution_tokens int64 1 1.98k |
|---|---|---|---|---|
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given a 0-indexed m x n binary matrix grid. You can move from a cell (row, col) to any of the cells (row + 1, col) or (row, col + 1) that has the value 1. The matrix is disconnected if there is no path from (0... | {"functional": "def check(candidate):\n assert candidate(grid = [[1,1,1],[1,0,0],[1,1,1]]) == True\n assert candidate(grid = [[1,1,1],[1,0,1],[1,1,1]]) == False\n\n\ncheck(Solution().isPossibleToCutPath)"} | 211 | 76 |
coding | Solve the programming task below in a Python markdown code block.
The longer the code, the stronger the code. The power number (P) of a code determines the strength of a code.
While computing the power number of a code we should ignore the keywords in the code. A few sample key words would be int, unsigned, string, et... | {"inputs": ["3\nababaac\nbabab\nabcbab\n1\nbab\n", "5\nlint maint lllint\nint maint lllintl\nlint maint lllint\nlint maint lllint\nlint maint lllint\n2\nint\nlint\n"], "outputs": ["5\n", "29\n"]} | 713 | 74 |
coding | Solve the programming task below in a Python markdown code block.
To address the situation of Water Scarcity in Chefland, Chef has started an awareness campaign to motivate people to use greywater for toilets, washing cars, gardening, and many other chores which don't require the use of freshwater. These activities pre... | {"inputs": ["3\n3 1 1 3\n1 1 1 2\n2 1 1 1"], "outputs": ["YES\nYES\nNO"]} | 586 | 40 |
coding | Solve the programming task below in a Python markdown code block.
It's autumn now, the time of the leaf fall.
Sergey likes to collect fallen leaves in autumn. In his city, he can find fallen leaves of maple, oak and poplar. These leaves can be of three different colors: green, yellow or red.
Sergey has collected some l... | {"inputs": ["1\n1 2 3\n3 2 1\n1 3 4"], "outputs": ["7"]} | 595 | 30 |
coding | Solve the programming task below in a Python markdown code block.
Laura really hates people using acronyms in her office and wants to force her colleagues to remove all acronyms before emailing her. She wants you to build a system that will edit out all known acronyms or else will notify the sender if unknown acronyms ... | {"functional": "_inputs = [['BRB I need to go into a KPI meeting before EOD'], ['I am IAM so will be OOO until EOD'], ['Going to WAH today. NRN. OOO'], [\"We're looking at SMB on SM DMs today\"], ['OOO'], ['KPI'], ['EOD'], ['TBD'], ['TBD by EOD'], ['BRB I am OOO'], ['WAH'], ['IAM'], ['NRN'], ['CTA'], ['Hi PAB'], ['HATD... | 434 | 684 |
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. In one operation, select any non-negative integer x and an index i, then update nums[i] to be equal to nums[i] AND (nums[i] XOR x).
Note that AND is the bitwise AND operat... | {"functional": "def check(candidate):\n assert candidate(nums = [3,2,4,6]) == 7\n assert candidate(nums = [1,2,3,9,2]) == 11\n\n\ncheck(Solution().maximumXOR)"} | 132 | 59 |
coding | Solve the programming task below in a Python markdown code block.
Vasya is an administrator of a public page of organization "Mouse and keyboard" and his everyday duty is to publish news from the world of competitive programming. For each news he also creates a list of hashtags to make searching for a particular topic ... | {"inputs": ["1\n#h\n", "1\n#h\n", "2\n#y\n#q\n", "2\n#y\n#q\n", "2\n#y\n#p\n", "2\n#y\n#o\n", "2\n#x\n#o\n", "2\n#x\n#p\n"], "outputs": ["#h\n", "#h\n", "#\n#q\n", "#\n#q\n", "#\n#p\n", "#\n#o\n", "#\n#o\n", "#\n#p\n"]} | 698 | 131 |
coding | Solve the programming task below in a Python markdown code block.
Read problem statements in [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Given a binary string $S$ consisting of $0's$ and $1's$, find whether there exists a rightwise [circular rotation] of the string such that every 2 adjacent $... | {"inputs": ["3\n4 1\n1100\n4 0\n0101\n6 1\n101001"], "outputs": ["YES\nNO\nYES"]} | 577 | 45 |
coding | Solve the programming task below in a Python markdown code block.
Given is an undirected connected graph with N vertices numbered 1 to N, and M edges numbered 1 to M.
The given graph may contain multi-edges but not self loops.
Each edge has an integer label between 1 and N (inclusive).
Edge i has a label c_i, and it co... | {"inputs": ["3 4\n1 2 1\n2 3 2\n3 1 3\n1 3 1\n"], "outputs": ["1\n2\n1\n"]} | 621 | 44 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given an integer array nums. You must perform exactly one operation where you can replace one element nums[i] with nums[i] * nums[i].
Return the maximum possible subarray sum after exactly one operation. The ... | {"functional": "def check(candidate):\n assert candidate(nums = [2,-1,-4,-3]) == 17\n assert candidate(nums = [1,-1,1,1,-1,-1,1]) == 4\n\n\ncheck(Solution().maxSumAfterOperation)"} | 105 | 64 |
coding | Solve the programming task below in a Python markdown code block.
The Cartesian coordinate system is set in the sky. There you can see n stars, the i-th has coordinates (x_{i}, y_{i}), a maximum brightness c, equal for all stars, and an initial brightness s_{i} (0 ≤ s_{i} ≤ c).
Over time the stars twinkle. At moment 0... | {"inputs": ["2 3 3\n1 1 1\n3 2 0\n2 1 1 2 2\n0 2 1 4 5\n5 1 1 5 5\n", "2 3 3\n1 1 1\n3 2 0\n2 1 1 1 2\n0 2 1 4 5\n5 1 1 5 5\n", "2 3 3\n1 2 1\n3 2 0\n2 1 1 2 2\n0 2 1 7 5\n5 1 1 5 1\n", "2 3 3\n1 2 1\n3 2 0\n0 1 1 2 2\n0 2 1 7 5\n5 1 1 5 5\n", "2 3 3\n1 2 1\n3 2 0\n0 1 1 2 2\n1 2 1 7 5\n5 1 1 5 5\n", "2 3 3\n1 1 1\n3 2... | 755 | 471 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given a string s and a character letter, return the percentage of characters in s that equal letter rounded down to the nearest whole percent.
Please complete the following python code precisely:
```python
class Sol... | {"functional": "def check(candidate):\n assert candidate(s = \"foobar\", letter = \"o\") == 33\n assert candidate(s = \"jjjj\", letter = \"k\") == 0\n\n\ncheck(Solution().percentageLetter)"} | 78 | 55 |
coding | Solve the programming task below in a Python markdown code block.
Ezio can manipulate at most X number of guards with the apple of eden.
Given that there are Y number of guards, predict if he can safely manipulate all of them.
------ Input Format ------
- First line will contain T, number of test cases. Then the te... | {"inputs": ["3\n5 7\n6 6\n9 1"], "outputs": ["NO\nYES\nYES"]} | 342 | 28 |
coding | Solve the programming task below in a Python markdown code block.
For a positive integer n, we denote the integer obtained by reversing the decimal notation of n (without leading zeroes) by rev(n). For example, rev(123) = 321 and rev(4000) = 4.
You are given a positive integer D. How many positive integers N satisfy r... | {"inputs": ["9", "8", "3", "6", "5", "7", "1", "2"], "outputs": ["8\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n"]} | 181 | 62 |
coding | Solve the programming task below in a Python markdown code block.
Chef has made a list for his monthly expenses. The list has N expenses with index 1 to N. The money spent on each expense depends upon the monthly income of Chef.
Chef spends 50\% of his total income on the expense with index 1.
The money spent on the i... | {"inputs": ["4\n1 2\n1 3\n2 3\n3 4\n"], "outputs": ["2\n4\n2\n2"]} | 676 | 35 |
coding | Solve the programming task below in a Python markdown code block.
Read problem statements in [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Chef's college is conducting an online exam, where his camera will be monitored by one or more invigilators (supervisors). Once again, Chef failed to prepare ... | {"inputs": ["3\n1 10 10\n0 10\n2 2 10\n0 5\n7 10\n2 2 100\n0 5\n5 10"], "outputs": ["NO\nYES\nYES"]} | 736 | 62 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given an array of integers nums and an integer threshold, we will choose a positive integer divisor, divide all the array by it, and sum the division's result. Find the smallest divisor such that the result mentioned ... | {"functional": "def check(candidate):\n assert candidate(nums = [1,2,5,9], threshold = 6) == 5\n assert candidate(nums = [2,3,5,7,11], threshold = 11) == 3\n assert candidate(nums = [19], threshold = 5) == 4\n\n\ncheck(Solution().smallestDivisor)"} | 158 | 89 |
coding | Solve the programming task below in a Python markdown code block.
AtCoDeer the deer has N square tiles. The tiles are numbered 1 through N, and the number given to each tile is written on one side of the tile. Also, each corner of each tile is painted in one of the 1000 colors, which are represented by the integers 0 b... | {"inputs": ["6\n0 1 2 3\n0 4 6 1\n1 6 9 2\n2 7 5 3\n6 4 5 7\n4 0 3 5", "6\n0 0 0 0\n0 0 1 0\n0 0 0 0\n0 0 0 0\n0 0 0 1\n0 1 0 0", "6\n0 0 0 0\n0 0 0 0\n0 0 0 0\n0 0 0 0\n0 0 0 0\n1 0 0 0", "6\n0 1 2 3\n0 4 6 1\n1 6 9 2\n3 7 5 3\n6 4 5 7\n4 0 3 5", "6\n0 1 2 3\n0 4 6 1\n1 6 9 2\n3 7 5 3\n6 4 6 7\n4 0 3 5", "6\n0 1 2 3\n... | 568 | 447 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Write a function to find the longest common prefix string amongst an array of strings.
If there is no common prefix, return an empty string "".
Please complete the following python code precisely:
```python
class So... | {"functional": "def check(candidate):\n assert candidate(strs = [\"flower\",\"flow\",\"flight\"]) == \"fl\"\n assert candidate(strs = [\"dog\",\"racecar\",\"car\"]) == \"\"\n\n\ncheck(Solution().longestCommonPrefix)"} | 78 | 61 |
coding | Solve the programming task below in a Python markdown code block.
Pooja would like to withdraw X $US from an ATM. The cash machine will only accept the transaction if X is a multiple of 5, and Pooja's account balance has enough cash to perform the withdrawal transaction (including bank charges). For each successful wi... | {"inputs": ["30 120.00\n\n", "42 120.00\n\n", "300 120.00\n\n"], "outputs": ["89.50", "120.00", "120.00"]} | 281 | 69 |
coding | Solve the programming task below in a Python markdown code block.
Shivam is the youngest programmer in the world, he is just 12 years old. Shivam is learning programming and today he is writing his first program.
Program is very simple, Given two integers A and B, write a program to add these two numbers.
-----Input... | {"inputs": ["3\n1 2\n100 200\n10 40"], "outputs": ["3\n300\n50"]} | 187 | 37 |
coding | Solve the programming task below in a Python markdown code block.
## Emotional Sort ( ︶︿︶)
You'll have a function called "**sortEmotions**" that will return an array of **emotions** sorted. It has two parameters, the first parameter called "**arr**" will expect an array of **emotions** where an **emotion** will be one... | {"functional": "_inputs = [[[':D', 'T_T', ':D', ':('], True], [['T_T', ':D', ':(', ':('], True], [[':)', 'T_T', ':)', ':D', ':D'], True], [[':D', 'T_T', ':D', ':('], False], [['T_T', ':D', ':(', ':('], False], [[':)', 'T_T', ':)', ':D', ':D'], False], [[], False], [[], True]]\n_outputs = [[[':D', ':D', ':(', 'T_T']], [... | 439 | 334 |
coding | Solve the programming task below in a Python markdown code block.
You are given an H \times W grid. The square at the top-left corner will be represented by (0, 0), and the square at the bottom-right corner will be represented by (H-1, W-1).
Of those squares, N squares (x_1, y_1), (x_2, y_2), ..., (x_N, y_N) are paint... | {"inputs": ["2 3\n1\n0 1", "2 3\n1\n0 2", "2 4\n1\n0 1", "2 4\n0\n0 1", "4 4\n0\n0 1", "6 4\n0\n0 1", "3 3\n1\n0 1", "4 3\n1\n0 1"], "outputs": ["20", "16", "48", "56", "320", "920", "59", "130"]} | 545 | 129 |
coding | Solve the programming task below in a Python markdown code block.
Read problem statements in [Russian], [Mandarin Chinese], [Bengali], and [Vietnamese] as well.
You are given an array A consisting of N integers and Q queries. Each query is described by two integers L and R. For each query, output the number of tuples ... | {"inputs": ["1\n6 3\n1 2 3 4 5 6\n1 3\n2 5\n1 6"], "outputs": ["1\n2\n10"]} | 491 | 45 |
coding | Solve the programming task below in a Python markdown code block.
A subsequence is a sequence that can be derived from another sequence by deleting some elements without changing the order of the remaining elements. Longest common subsequence (LCS) of 2 sequences is a subsequence, with maximal length, which is common ... | {"inputs": ["5 6\n1 2 3 4 1\n3 4 1 2 1 3\n"], "outputs": ["1 2 3\n"]} | 549 | 42 |
coding | Solve the programming task below in a Python markdown code block.
This is the easy version of this problem. In this version, we do not have queries. Note that we have multiple test cases in this version. You can make hacks only if both versions of the problem are solved.
An array $b$ of length $m$ is good if for all $... | {"inputs": ["3\n3\n1 2 3\n3\n1 1 1\n4\n2 1 4 3\n"], "outputs": ["6\n3\n7\n"]} | 515 | 44 |
coding | Solve the programming task below in a Python markdown code block.
Chef has a binary string S of length N.
In one operation, Chef can:
Select two indices i and j (1 ≤ i, j ≤ N, i \ne j) and flip S_{i} and S_{j}. (i.e. change 0 to 1 and 1 to 0)
For example, if S = 10010 and chef applys operation on i = 1 and j = 3 the... | {"inputs": ["3\n6\n101011\n2\n01\n7\n1110000\n"], "outputs": ["YES\nNO\nYES\n"]} | 637 | 42 |
coding | Solve the programming task below in a Python markdown code block.
A smelt fishing tournament was held at Lake Hibara. It seems that catch and release is recommended this time.
Create a program that reads the participant number and the number of fish caught or released in order as one event, and outputs the participant... | {"inputs": ["3 5\n1 4\n2 5\n1 3\n3 4\n2 7", "3 5\n1 4\n2 3\n1 3\n3 6\n2 7", "3 5\n1 4\n2 3\n1 3\n3 6\n2 1", "3 5\n1 4\n2 3\n2 3\n3 6\n2 1", "3 5\n1 4\n2 0\n2 3\n3 6\n2 1", "3 5\n1 4\n2 5\n2 3\n3 4\n2 7", "3 5\n1 2\n2 3\n1 3\n3 6\n2 7", "3 5\n1 4\n2 3\n1 3\n3 8\n2 1"], "outputs": ["1 4\n2 5\n1 7\n1 7\n2 12\n", "1 4\n1 4... | 321 | 386 |
coding | Solve the programming task below in a Python markdown code block.
The only difference between this problem and D2 is the bound on the size of the tree.
You are given an unrooted tree with $n$ vertices. There is some hidden vertex $x$ in that tree that you are trying to find.
To do this, you may ask $k$ queries $v_1, ... | {"inputs": ["3\n1\n2\n1 2\n10\n2 4\n2 1\n5 7\n3 10\n8 6\n6 1\n1 3\n4 7\n9 6\n"], "outputs": ["0\n1\n2\n"]} | 547 | 66 |
coding | Solve the programming task below in a Python markdown code block.
Reading books is one of Sasha's passions. Once while he was reading one book, he became acquainted with an unusual character. The character told about himself like that: "Many are my names in many countries. Mithrandir among the Elves, Tharkûn to the Dwa... | {"inputs": ["f\n", "a\n", "g\n", "b\n", "e\n", "c\n", "h\n", "d\n"], "outputs": ["Impossible\n", "Impossible\n", "Impossible\n", "Impossible\n", "Impossible\n", "Impossible\n", "Impossible\n", "Impossible\n"]} | 650 | 70 |
coding | Solve the programming task below in a Python markdown code block.
Mandarin chinese
, Russian and Vietnamese as well.
Chef is organising a contest with $P$ problems (numbered $1$ through $P$). Each problem has $S$ subtasks (numbered $1$ through $S$).
The difficulty of a problem can be calculated as follows:
- Let's deno... | {"inputs": ["3 3\n16 24 60\n498 861 589\n14 24 62\n72 557 819\n16 15 69\n435 779 232"], "outputs": ["2\n1\n3"]} | 624 | 80 |
coding | Solve the programming task below in a Python markdown code block.
# Situation
You have been hired by a company making electric garage doors. Accidents with the present product line have resulted in numerous damaged cars, broken limbs and several killed pets. Your mission is to write a safer version of their controller ... | {"functional": "_inputs = [[''], ['..........'], ['P..'], ['P....'], ['P......P......'], ['P.P..'], ['P.P.P....'], ['.....P.P........P....'], ['.....P......P.P..P....'], ['P.O....'], ['P......P.O....'], ['P..OP..P..'], ['P......P..OP..P...'], ['..P...O.....']]\n_outputs = [[''], ['0000000000'], ['123'], ['12345'], ['12... | 359 | 410 |
coding | Solve the programming task below in a Python markdown code block.
You and your friend decide to play a game using a stack consisting of N bricks. In this game, you can alternatively remove 1, 2 or 3 bricks from the top, and the numbers etched on the removed bricks are added to your score. You have to play so that you o... | {"inputs": ["2\n5\n999 1 1 1 0\n5\n0 1 1 1 999\n"], "outputs": ["1001\n999\n"]} | 617 | 49 |
coding | Solve the programming task below in a Python markdown code block.
Simon: On the fountain, there should be 2 jugs - a 5 gallon and a 3 gallon. Do you see them? Fill one of the jugs with exactly 4 gallons of water and place it on the scale and the timer will stop. You must be precise; one ounce more or less will result i... | {"inputs": ["2\n5 3 4\n3 6 4\n"], "outputs": ["YES\nNO\n"]} | 684 | 28 |
coding | Solve the programming task below in a Python markdown code block.
Given a number X between 0 to 1000000006 find smallest positive integer Y such that the products of digits of Y modulo 1000000007 is X.
Input Format
A single integer - X
Output Format
A single integer - Y
Input Constraint
0 ≤ X ≤ 1000000006
Proble... | {"inputs": ["0", "16", "220703118"], "outputs": ["10", "28", "5555555555555"]} | 151 | 47 |
coding | Solve the programming task below in a Python markdown code block.
You are given a string $s$ consisting of $n$ lowercase Latin letters.
You have to remove at most one (i.e. zero or one) character of this string in such a way that the string you obtain will be lexicographically smallest among all strings that can be ob... | {"inputs": ["2\nzz\n", "2\nok\n", "2\nas\n", "2\nab\n", "2\nae\n", "2\ncq\n", "2\naz\n", "2\ncb\n"], "outputs": ["z\n", "k\n", "a\n", "a\n", "a\n", "c\n", "a\n", "b\n"]} | 411 | 88 |
coding | Solve the programming task below in a Python markdown code block.
A telephone number is a sequence of exactly 11 digits, where the first digit is 8. For example, the sequence 80011223388 is a telephone number, but the sequences 70011223388 and 80000011223388 are not.
You are given a string $s$ of length $n$, consistin... | {"inputs": ["1\n11\n80000000000\n", "1\n11\n83583640644\n", "1\n11\n83583640644\n", "1\n11\n80000000000\n", "1\n11\n81840233933\n", "1\n18\n80000000000\n", "1\n21\n80000000000\n", "1\n15\n80000000000\n"], "outputs": ["YES\n", "YES\n", "YES\n", "YES\n", "YES\n", "YES\n", "YES\n", "YES\n"]} | 402 | 190 |
coding | Solve the programming task below in a Python markdown code block.
# Task
You're given a substring s of some cyclic string. What's the length of the smallest possible string that can be concatenated to itself many times to obtain this cyclic string?
# Example
For` s = "cabca"`, the output should be `3`
`"cabca"` i... | {"functional": "_inputs = [['cabca'], ['aba'], ['ccccccccccc'], ['abaca']]\n_outputs = [[3], [2], [1], [4]]\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... | 165 | 177 |
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 | Please solve the programming task below using a self-contained code snippet in a markdown code block.
In a row of dominoes, tops[i] and bottoms[i] represent the top and bottom halves of the ith domino. (A domino is a tile with two numbers from 1 to 6 - one on each half of the tile.)
We may rotate the ith domino, so th... | {"functional": "def check(candidate):\n assert candidate(tops = [2,1,2,4,2,2], bottoms = [5,2,6,2,3,2]) == 2\n assert candidate(tops = [3,5,1,2,3], bottoms = [3,6,3,3,4]) == -1\n\n\ncheck(Solution().minDominoRotations)"} | 165 | 94 |
coding | Solve the programming task below in a Python markdown code block.
collections.OrderedDict
An OrderedDict is a dictionary that remembers the order of the keys that were inserted first. If a new entry overwrites an existing entry, the original insertion position is left unchanged.
Example
Code
>>> from collections i... | {"inputs": ["9\nBANANA FRIES 12\nPOTATO CHIPS 30\nAPPLE JUICE 10\nCANDY 5\nAPPLE JUICE 10\nCANDY 5\nCANDY 5\nCANDY 5\nPOTATO CHIPS 30\n"], "outputs": ["BANANA FRIES 12\nPOTATO CHIPS 60\nAPPLE JUICE 20\nCANDY 20\n"]} | 632 | 112 |
coding | Solve the programming task below in a Python markdown code block.
A number is ternary if it contains only digits $0$, $1$ and $2$. For example, the following numbers are ternary: $1022$, $11$, $21$, $2002$.
You are given a long ternary number $x$. The first (leftmost) digit of $x$ is guaranteed to be $2$, the other di... | {"inputs": ["4\n5\n22222\n5\n21211\n1\n2\n9\n220222021\n", "4\n5\n22222\n5\n21211\n1\n2\n9\n220222021\n"], "outputs": ["11111\n11111\n11000\n10211\n1\n1\n110111011\n110111010\n", "11111\n11111\n11000\n10211\n1\n1\n110111011\n110111010\n"]} | 623 | 178 |
coding | Solve the programming task below in a Python markdown code block.
Currently, XXOC's rap is a string consisting of zeroes, ones, and question marks. Unfortunately, haters gonna hate. They will write $x$ angry comments for every occurrence of subsequence 01 and $y$ angry comments for every occurrence of subsequence 10. Y... | {"inputs": ["0?1\n2 3\n", "?10?\n239 7\n", "?01?\n7 239\n", "?????\n13 37\n", "01101001\n5 7\n", "?\n940946 502068\n", "1?\n930967 495068\n", "?0?\n333391 358196\n"], "outputs": ["4\n", "28\n", "28\n", "0\n", "96\n", "0\n", "0\n", "0\n"]} | 597 | 157 |
coding | Solve the programming task below in a Python markdown code block.
To get money for a new aeonic blaster, ranger Qwerty decided to engage in trade for a while. He wants to buy some number of items (or probably not to buy anything at all) on one of the planets, and then sell the bought items on another planet. Note that ... | {"inputs": ["2 1 5\nA\n6 5 5\nB\n10 9 0\n", "2 1 5\nA\n6 3 5\nB\n10 9 0\n", "2 1 5\nA\n6 3 2\nB\n10 9 0\n", "2 1 5\nA\n10 3 2\nB\n10 9 0\n", "2 1 5\nA\n10 3 2\nB\n10 9 1\n", "2 1 1\nG\n2 1 9\nRdepya\n2 1 8\n", "2 1 1\nG\n2 1 9\nRdepyb\n2 1 8\n", "2 1 1\nG\n1 1 9\nRdepyb\n2 1 4\n"], "outputs": ["15\n", "15\n", "6\n", "0... | 728 | 248 |
coding | Solve the programming task below in a Python markdown code block.
The number "zero" is called "love" (or "l'oeuf" to be precise, literally means "egg" in French), for example when denoting the zero score in a game of tennis.
Aki is fond of numbers, especially those with trailing zeros. For example, the number $9200$ ... | {"inputs": ["6 9\n", "5 2\n", "1 2\n", "2 2\n", "2 2\n", "1 2\n", "9 9\n", "9 2\n"], "outputs": ["1\n", "3\n", "0\n", "1\n", "1\n", "0\n", "2\n", "7\n"]} | 593 | 86 |
coding | Solve the programming task below in a Python markdown code block.
A hypergraph is a generalization of a graph, where an edge can connect any number of vertices. A k-uniform hypergraph is a hypergraph such that all its hyperedges have size k. For more information, see Wikipedia.
Let's call a particular hypergraph a hyp... | {"inputs": ["4\n3\n4\n5\n8\n\n"], "outputs": ["1\n6\n25\n93268"]} | 492 | 33 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given an m x n integer matrix grid containing distinct positive integers.
You have to replace each integer in the matrix with a positive integer satisfying the following conditions:
The relative order of ever... | {"functional": "def check(candidate):\n assert candidate(grid = [[3,1],[2,5]]) == [[2,1],[1,2]]\n assert candidate(grid = [[10]]) == [[1]]\n\n\ncheck(Solution().minScore)"} | 284 | 60 |
coding | Solve the programming task below in a Python markdown code block.
«One dragon. Two dragon. Three dragon», — the princess was counting. She had trouble falling asleep, and she got bored of counting lambs when she was nine.
However, just counting dragons was boring as well, so she entertained herself at best she could. ... | {"inputs": ["2\n2\n2\n2\n1\n", "1\n1\n1\n1\n1\n", "2\n3\n2\n2\n1\n", "1\n1\n1\n1\n0\n", "2\n3\n2\n2\n0\n", "2\n3\n4\n2\n0\n", "2\n3\n4\n4\n0\n", "10\n9\n8\n7\n6\n"], "outputs": ["0\n", "1\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n"]} | 332 | 135 |
coding | Solve the programming task below in a Python markdown code block.
We are given a sequence of coplanar points and see all the possible triangles that may be generated which all combinations of three points.
We have the following list of points with the cartesian coordinates of each one:
```
Points [x, y]
A [1, 2]
... | {"functional": "_inputs = [[[[1, 2], [3, 3], [4, 1], [1, 1], [4, -1]]], [[[1, 2], [4, -1], [3, 3], [4, -1], [4, 1], [1, 1], [4, -1], [4, -1], [3, 3], [1, 2]]]]\n_outputs = [[3], [3]]\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_... | 362 | 249 |
coding | Solve the programming task below in a Python markdown code block.
Your coworker was supposed to write a simple helper function to capitalize a string (that contains a single word) before they went on vacation.
Unfortunately, they have now left and the code they gave you doesn't work. Fix the helper function they wrote... | {"functional": "_inputs = [['word'], ['i'], ['glasswear']]\n_outputs = [['Word'], ['I'], ['Glasswear']]\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) ... | 148 | 169 |
coding | Solve the programming task below in a Python markdown code block.
You are given a board of size $2 \times n$ ($2$ rows, $n$ columns). Some cells of the board contain chips. The chip is represented as '*', and an empty space is represented as '.'. It is guaranteed that there is at least one chip on the board.
In one mo... | {"inputs": ["5\n1\n*\n.\n2\n.*\n**\n3\n*.*\n.*.\n4\n**.*\n**..\n5\n**...\n...**\n"], "outputs": ["0\n2\n3\n5\n5\n"]} | 502 | 63 |
coding | Solve the programming task below in a Python markdown code block.
Ridbit starts with an integer $n$.
In one move, he can perform one of the following operations:
divide $n$ by one of its proper divisors, or
subtract $1$ from $n$ if $n$ is greater than $1$.
A proper divisor is a divisor of a number, excluding itself... | {"inputs": ["6\n1\n2\n3\n4\n6\n9\n", "6\n1\n2\n3\n4\n1\n9\n", "6\n1\n2\n3\n7\n1\n1\n", "6\n1\n3\n3\n4\n1\n9\n", "6\n1\n3\n3\n3\n6\n7\n", "6\n1\n4\n3\n7\n1\n1\n", "6\n1\n3\n3\n4\n1\n3\n", "6\n1\n4\n3\n7\n1\n2\n"], "outputs": ["0\n1\n2\n2\n2\n3\n", "0\n1\n2\n2\n0\n3\n", "0\n1\n2\n3\n0\n0\n", "0\n2\n2\n2\n0\n3\n", "0\n2\n... | 373 | 246 |
coding | Solve the programming task below in a Python markdown code block.
Kabir Singh is playing a game on the non-negative side of x-axis. It takes him $1 second$ to reach from Pth position to (P−1)th position or (P+1)th position.
Kabir never goes to the negative side and also doesn't stop at any moment of time.
The movemen... | {"inputs": ["4\n0 1\n1 1\n1 3\n4 6"], "outputs": ["0\n1\n5\n46"]} | 619 | 35 |
coding | Solve the programming task below in a Python markdown code block.
Snuke has N dogs and M monkeys. He wants them to line up in a row.
As a Japanese saying goes, these dogs and monkeys are on bad terms. ("ken'en no naka", literally "the relationship of dogs and monkeys", means a relationship of mutual hatred.) Snuke is t... | {"inputs": ["2 2\n", "3 2\n", "1 8\n", "100000 100000\n"], "outputs": ["8\n", "12\n", "0\n", "530123477\n"]} | 265 | 65 |
coding | Solve the programming task below in a Python markdown code block.
The only difference between the easy and hard versions is that the given string $s$ in the easy version is initially a palindrome, this condition is not always true for the hard version.
A palindrome is a string that reads the same left to right and rig... | {"inputs": ["2\n4\n1001\n1\n0\n"], "outputs": ["BOB\nBOB\n"]} | 656 | 29 |
coding | Solve the programming task below in a Python markdown code block.
# Task
Let's consider a table consisting of `n` rows and `n` columns. The cell located at the intersection of the i-th row and the j-th column contains number i × j. The rows and columns are numbered starting from 1.
You are given a positive integer `... | {"functional": "_inputs = [[5, 5], [10, 5], [6, 12], [6, 169], [100000, 1000000000]]\n_outputs = [[2], [2], [4], [0], [16]]\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)):... | 489 | 212 |
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, replace the value of each node in the tree with the sum of all its cousins' values.
Two nodes of a binary tree are cousins if they have the same depth with different parents.
Return th... | {"functional": "def check(candidate):\n assert is_same_tree(candidate(root = tree_node([5,4,9,1,10,None,7])), tree_node([0,0,0,7,7,None,11]))\n assert is_same_tree(candidate(root = tree_node([3,1,2])), tree_node([0,0,0]))\n\n\ncheck(Solution().replaceValueInTree)"} | 179 | 93 |
coding | Solve the programming task below in a Python markdown code block.
Valera wanted to prepare a Codesecrof round. He's already got one problem and he wants to set a time limit (TL) on it.
Valera has written n correct solutions. For each correct solution, he knows its running time (in seconds). Valera has also wrote m wro... | {"inputs": ["1 1\n4\n9\n", "1 1\n2\n4\n", "1 1\n4\n9\n", "1 1\n2\n4\n", "1 1\n8\n9\n", "1 1\n1\n9\n", "1 1\n1\n0\n", "1 1\n0\n0\n"], "outputs": ["8", "-1\n", "8\n", "-1\n", "-1\n", "2\n", "-1\n", "-1\n"]} | 463 | 117 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
A chef has collected data on the satisfaction level of his n dishes. Chef can cook any dish in 1 unit of time.
Like-time coefficient of a dish is defined as the time taken to cook that dish including previous dishes m... | {"functional": "def check(candidate):\n assert candidate(satisfaction = [-1,-8,0,5,-9]) == 14\n assert candidate(satisfaction = [4,3,2]) == 20\n assert candidate(satisfaction = [-1,-4,-5]) == 0\n\n\ncheck(Solution().maxSatisfaction)"} | 150 | 77 |
coding | Solve the programming task below in a Python markdown code block.
I’m planning to have a party on my birthday. Many of my friends will come to the party. Some of them will come with one or more pieces of cakes, but it is not certain if the number of the cakes is a multiple of the number of people coming.
I wish to enj... | {"inputs": ["5 2\n5 5 6 5", "100 3\n1 3 3", "5 2\n3 5 6 5", "000 3\n1 3 3", "5 2\n3 7 6 5", "010 3\n1 3 3", "010 3\n1 3 5", "5 4\n5 5 6 5"], "outputs": ["2\n", "1\n", "2\n", "7\n", "2\n", "1\n", "1\n", "4"]} | 390 | 141 |
coding | Solve the programming task below in a Python markdown code block.
Read problems statements in Mandarin Chinese and Russian.
Roma gave Chef an array of intergers.
Chef wants to make all integers in the array equal to 1.
In a single operation, he can select a prime number p and a subset of the integers, and then div... | {"inputs": ["1\n3\n1 2 4"], "outputs": ["2"]} | 380 | 20 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given a zero-based permutation nums (0-indexed), build an array ans of the same length where ans[i] = nums[nums[i]] for each 0 <= i < nums.length and return it.
A zero-based permutation nums is an array of distinct in... | {"functional": "def check(candidate):\n assert candidate(nums = [0,2,1,5,3,4]) == [0,1,2,4,5,3]\n assert candidate(nums = [5,0,1,2,3,4]) == [4,5,0,1,2,3]\n\n\ncheck(Solution().buildArray)"} | 114 | 85 |
coding | Solve the programming task below in a Python markdown code block.
One day n friends gathered together to play "Mafia". During each round of the game some player must be the supervisor and other n - 1 people take part in the game. For each person we know in how many rounds he wants to be a player, not the supervisor: th... | {"inputs": ["3\n3 2 2\n", "3\n1 1 1\n", "3\n1 2 1\n", "3\n2 1 1\n", "3\n1 2 1\n", "3\n1 1 1\n", "3\n2 1 1\n", "3\n2 2 1\n"], "outputs": ["4\n", "2\n", "2\n", "2\n", "2\n", "2\n", "2\n", "3\n"]} | 349 | 118 |
coding | Solve the programming task below in a Python markdown code block.
We have a 3 \times 3 grid. A number c_{i, j} is written in the square (i, j), where (i, j) denotes the square at the i-th row from the top and the j-th column from the left.
According to Takahashi, there are six integers a_1, a_2, a_3, b_1, b_2, b_3 who... | {"inputs": ["1 0 1\n4 1 2\n1 0 1", "1 8 6\n2 9 7\n1 7 7", "0 8 8\n0 8 8\n0 0 8", "2 2 2\n2 1 0\n2 2 2", "1 0 1\n4 1 2\n0 0 1", "1 8 6\n4 9 7\n1 7 7", "0 8 2\n0 8 8\n0 0 8", "1 0 1\n4 1 4\n0 0 1"], "outputs": ["No\n", "No\n", "No\n", "No\n", "No\n", "No\n", "No\n", "No\n"]} | 347 | 190 |
coding | Solve the programming task below in a Python markdown code block.
Chef is given two integers A and C such that A ≤ C.
Chef wants to find whether there exists any integer B such that A, B, and C are in [arithmetic progression].
------ Input Format ------
- The first line of input will contain a single integer T, de... | {"inputs": ["4\n3 5\n6 6\n2 7\n1 9\n"], "outputs": ["4\n6\n-1\n5\n"]} | 331 | 37 |
coding | Solve the programming task below in a Python markdown code block.
An ordered sequence of numbers from 1 to N is given. One number might have deleted from it, then the remaining numbers were mixed. Find the number that was deleted.
Example:
- The starting array sequence is `[1,2,3,4,5,6,7,8,9]`
- The mixed array wit... | {"functional": "_inputs = [[[1, 2, 3, 4, 5, 6, 7, 8, 9], [5, 7, 9, 4, 8, 1, 2, 3]], [[1, 2, 3, 4, 5, 6, 7], [2, 3, 6, 1, 5, 4, 7]], [[1, 2, 3, 4, 5, 6, 7, 8, 9], [5, 7, 6, 9, 4, 8, 1, 2, 3]], [[1], []], [[], []]]\n_outputs = [[6], [0], [0], [1], [0]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, flo... | 186 | 320 |
coding | Solve the programming task below in a Python markdown code block.
A magic number is a number formed by concatenation of numbers 1, 14 and 144. We can use each of these numbers any number of times. Therefore 14144, 141414 and 1411 are magic numbers but 1444, 514 and 414 are not.
You're given a number. Determine if it i... | {"inputs": ["1\n", "9\n", "4\n", "1\n", "4\n", "9\n", "8\n", "2\n"], "outputs": ["YES\n", "NO\n", "NO\n", "YES\n", "NO\n", "NO\n", "NO\n", "NO\n"]} | 202 | 70 |
coding | Solve the programming task below in a Python markdown code block.
After a hard quarter in the office you decide to get some rest on a vacation. So you will book a flight for you and your girlfriend and try to leave all the mess behind you.
You will need a rental car in order for you to get around in your vacation. The... | {"functional": "_inputs = [[1], [2], [3], [4], [5], [6], [7], [8], [9], [10]]\n_outputs = [[40], [80], [100], [140], [180], [220], [230], [270], [310], [350]]\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 ... | 171 | 230 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given the root of a binary tree, return the postorder traversal of its nodes' values.
Please complete the following python code precisely:
```python
# Definition for a binary tree node.
# class TreeNode:
# def _... | {"functional": "def check(candidate):\n assert candidate(root = tree_node([1,None,2,3])) == [3,2,1]\n assert candidate(root = tree_node([])) == []\n assert candidate(root = tree_node([1])) == [1]\n\n\ncheck(Solution().postorderTraversal)"} | 122 | 72 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
A stepping number is an integer such that all of its adjacent digits have an absolute difference of exactly 1.
For example, 321 is a stepping number while 421 is not.
Given two integers low and high, return a sorted... | {"functional": "def check(candidate):\n assert candidate(low = 0, high = 21) == [0,1,2,3,4,5,6,7,8,9,10,12,21]\n\n\ncheck(Solution().countSteppingNumbers)"} | 120 | 67 |
coding | Solve the programming task below in a Python markdown code block.
Let's define a split of $n$ as a nonincreasing sequence of positive integers, the sum of which is $n$.
For example, the following sequences are splits of $8$: $[4, 4]$, $[3, 3, 2]$, $[2, 2, 1, 1, 1, 1]$, $[5, 2, 1]$.
The following sequences aren't spl... | {"inputs": ["7\n", "8\n", "9\n", "1\n", "2\n", "3\n", "1\n", "3\n"], "outputs": ["4\n", "5\n", "5\n", "1\n", "2\n", "2\n", "1\n", "2\n"]} | 459 | 70 |
coding | Solve the programming task below in a Python markdown code block.
A: Information Search
problem
The posting list is a list in which there is a correspondence between the search term and the appearing document ID. For example
* Hokkaido: 1, 2, 4, 9
* Sightseeing: 1, 3, 4, 7
And so on.
From the above posting list,... | {"inputs": ["4 4\n1 2 5 9\n1 3 4 7", "4 4\n1 2 5 9\n2 3 4 7", "4 4\n1 2 4 9\n0 3 4 7", "4 4\n1 2 5 9\n0 3 4 7", "4 4\n1 3 5 9\n0 3 4 7", "4 4\n1 2 5 9\n1 2 4 7", "4 4\n1 2 5 9\n1 3 4 8", "4 4\n1 2 7 9\n0 3 4 7"], "outputs": ["1 7\n1\n1\n2\n3\n4\n5\n7\n9\n", "1 7\n2\n1\n2\n3\n4\n5\n7\n9\n", "1 7\n4\n0\n1\n2\n3\n4\n7\n9\... | 599 | 350 |
coding | Solve the programming task below in a Python markdown code block.
A string t is called an anagram of the string s, if it is possible to rearrange letters in t so that it is identical to the string s. For example, the string "aab" is an anagram of the string "aba" and the string "aaa" is not.
The string t is called a s... | {"inputs": ["?\na\n", "a\na\n", "b\na\n", "a\naa\n", "?\ncb\n", "b\naa\n", "?\nca\n", "?\ncc\n"], "outputs": ["1\n", "1\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n"]} | 505 | 85 |
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 | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You have information about n different recipes. You are given a string array recipes and a 2D string array ingredients. The ith recipe has the name recipes[i], and you can create it if you have all the needed ingredie... | {"functional": "def check(candidate):\n assert candidate(recipes = [\"bread\"], ingredients = [[\"yeast\",\"flour\"]], supplies = [\"yeast\",\"flour\",\"corn\"]) == [\"bread\"]\n assert candidate(recipes = [\"bread\",\"sandwich\"], ingredients = [[\"yeast\",\"flour\"],[\"bread\",\"meat\"]], supplies = [\"yeast\",... | 198 | 221 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given an integer array nums, return the number of elements that have both a strictly smaller and a strictly greater element appear in nums.
Please complete the following python code precisely:
```python
class Soluti... | {"functional": "def check(candidate):\n assert candidate(nums = [11,7,2,15]) == 2\n assert candidate(nums = [-3,3,3,90]) == 2\n\n\ncheck(Solution().countElements)"} | 74 | 58 |
coding | Solve the programming task below in a Python markdown code block.
```
*************************
* Create a frame! *
* __ __ *
* / \~~~/ \ *
* ,----( .. ) *
* / \__ __/ *
* /| (\ |( *
* ^ \ /___\ /\ | *
* |__| |__|-.. *
****************... | {"functional": "_inputs = [[['Small', 'frame'], '~'], [['Create', 'this', 'kata'], '+'], [['This is a very long single frame'], '-']]\n_outputs = [['~~~~~~~~~\\n~ Small ~\\n~ frame ~\\n~~~~~~~~~'], ['++++++++++\\n+ Create +\\n+ this +\\n+ kata +\\n++++++++++'], ['------------------------------------\\n- This is a v... | 226 | 241 |
coding | Solve the programming task below in a Python markdown code block.
$n$ heroes fight against each other in the Arena. Initially, the $i$-th hero has level $a_i$.
Each minute, a fight between two different heroes occurs. These heroes can be chosen arbitrarily (it's even possible that it is the same two heroes that were f... | {"inputs": ["1\n3\n90 91 92\n", "1\n3\n90 91 92\n", "1\n3\n90 56 92\n", "1\n3\n90 75 92\n", "1\n3\n49 75 92\n", "1\n3\n90 43 92\n", "1\n3\n90 57 92\n", "1\n3\n49 75 180\n"], "outputs": ["2\n", "2\n", "2\n", "2\n", "2\n", "2\n", "2\n", "2\n"]} | 440 | 159 |
coding | Solve the programming task below in a Python markdown code block.
# Task
Imagine `n` horizontal lines and `m` vertical lines.
Some of these lines intersect, creating rectangles.
How many rectangles are there?
# Examples
For `n=2, m=2,` the result should be `1`.
there is only one 1x1 rectangle.
For `n=2, m=3`, the... | {"functional": "_inputs = [[2, 3], [2, 2], [1, 1], [0, 1], [3, 3], [100, 100]]\n_outputs = [[3], [1], [0], [0], [9], [24502500]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return math.isclose(a, b, rel_tol=tol, abs_tol=tol)\n if isinstance(a, (list, tup... | 274 | 213 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given a string s, check if it can be constructed by taking a substring of it and appending multiple copies of the substring together.
Please complete the following python code precisely:
```python
class Solution:
... | {"functional": "def check(candidate):\n assert candidate(s = \"abab\") == True\n assert candidate(s = \"aba\") == False\n assert candidate(s = \"abcabcabcabc\") == True\n\n\ncheck(Solution().repeatedSubstringPattern)"} | 74 | 58 |
coding | Solve the programming task below in a Python markdown code block.
Snuke found N strange creatures. Each creature has a fixed color and size. The color and size of the i-th creature are represented by i and A_i, respectively.
Every creature can absorb another creature whose size is at most twice the size of itself. Whe... | {"inputs": ["3\n3 1 3", "3\n1 1 3", "3\n5 1 3", "3\n1 1 2", "3\n5 2 3", "3\n1 1 1", "3\n3 1 4", "5\n1 1 1 1 2"], "outputs": ["2\n", "3\n", "2\n", "3\n", "3\n", "3\n", "2", "5\n"]} | 312 | 113 |
coding | Solve the programming task below in a Python markdown code block.
A prime number is number x which has only divisors as 1 and x itself.
Harsh is playing a game with his friends, where his friends give him a few numbers claiming that they are divisors of some number x but divisor 1 and the number x itself are not being ... | {"inputs": ["3\n2\n2 3\n2\n4 2\n3\n12 3 2"], "outputs": ["6\n8\n-1"]} | 440 | 38 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given a 1-indexed integer array nums of length n.
An element nums[i] of nums is called special if i divides n, i.e. n % i == 0.
Return the sum of the squares of all special elements of nums.
Please complete ... | {"functional": "def check(candidate):\n assert candidate(nums = [1,2,3,4]) == 21\n assert candidate(nums = [2,7,1,19,18,3]) == 63\n\n\ncheck(Solution().sumOfSquares)"} | 103 | 65 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are keeping the scores for a baseball game with strange rules. At the beginning of the game, you start with an empty record.
You are given a list of strings operations, where operations[i] is the ith operation you... | {"functional": "def check(candidate):\n assert candidate(ops = [\"5\",\"2\",\"C\",\"D\",\"+\"]) == 30\n assert candidate(ops = [\"5\",\"-2\",\"4\",\"C\",\"D\",\"9\",\"+\",\"+\"]) == 27\n assert candidate(ops = [\"1\"]) == 1\n\n\ncheck(Solution().calPoints)"} | 210 | 87 |
coding | Solve the programming task below in a Python markdown code block.
-----Input-----
The input contains a single integer $a$ ($1 \le a \le 99$).
-----Output-----
Output "YES" or "NO".
-----Examples-----
Input
5
Output
YES
Input
13
Output
NO
Input
24
Output
NO
Input
46
Output
YES | {"inputs": ["5\n", "1\n", "2\n", "3\n", "4\n", "4\n", "2\n", "3\n"], "outputs": ["YES\n", "NO\n", "YES\n", "YES\n", "YES\n", "YES", "YES", "YES"]} | 86 | 67 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
There are n projects numbered from 0 to n - 1. You are given an integer array milestones where each milestones[i] denotes the number of milestones the ith project has.
You can work on the projects following these two ... | {"functional": "def check(candidate):\n assert candidate(milestones = [1,2,3]) == 6\n assert candidate(milestones = [5,2,1]) == 7\n\n\ncheck(Solution().numberOfWeeks)"} | 207 | 56 |
coding | Solve the programming task below in a Python markdown code block.
Read problems statements in Mandarin Chinese, Russian and Vietnamese as well.
Bear Limak has a string S.
Each character of S is a digit '0' or '1'.
Help Limak and check if all the '1' digits form a single non-empty segment (consecutive subsequence) in... | {"inputs": ["6\n001111110\n00110011\n000\n1111\n101010101\n101111111111"], "outputs": ["YES\nNO\nNO\nYES\nNO\nNO"]} | 456 | 73 |
coding | Solve the programming task below in a Python markdown code block.
You've got a string s = s1s2... s|s| of length |s|, consisting of lowercase English letters. There also are q queries, each query is described by two integers li, ri (1 ≤ li ≤ ri ≤ |s|). The answer to the query is the number of substrings of string s[li.... | {"inputs": ["caaaba\n5\n1 1\n1 4\n2 3\n2 6\n4 5\n", "caaaba\n5\n1 1\n1 4\n1 3\n4 6\n4 5\n", "caaaba\n5\n1 1\n1 1\n2 3\n2 6\n4 5\n", "caaaba\n5\n1 1\n2 4\n1 3\n4 6\n4 5\n", "caaaba\n5\n1 1\n1 1\n3 3\n2 6\n4 5\n", "caaaba\n5\n1 1\n2 2\n1 3\n4 6\n4 5\n", "caaaba\n5\n1 1\n1 4\n2 5\n4 6\n4 5\n", "caaaba\n5\n1 1\n1 4\n2 3\n4... | 409 | 318 |
coding | Solve the programming task below in a Python markdown code block.
There are two exits in a bus with 100 seats:
First exit is located beside seat number 1.
Second exit is located beside seat number 100.
Seats are arranged in a straight line from 1 to 100 with equal spacing between any 2 adjacent seats.
A passenger pre... | {"inputs": ["6\n1\n50\n100\n30\n51\n73\n"], "outputs": ["LEFT\nLEFT\nRIGHT\nLEFT\nRIGHT\nRIGHT\n"]} | 458 | 42 |
coding | Solve the programming task below in a Python markdown code block.
Read problems statements in mandarin chinese, russian and vietnamese as well.
Alice and Bob are playing a game. Alice initially has the number A and Bob has the number B. There are a total of N turns in the game, and Alice and Bob alternatively take tu... | {"inputs": ["3\n1 2 1\n3 2 3\n3 7 2"], "outputs": ["1\n3\n2"]} | 726 | 34 |
coding | Solve the programming task below in a Python markdown code block.
You are given a certain integer, ```n, n > 0```. You have to search the partition or partitions, of n, with maximum product value.
Let'see the case for ```n = 8```.
```
Partition Product
[8] 8
[7, 1] ... | {"functional": "_inputs = [[8], [10]]\n_outputs = [[[[3, 3, 2], 18]], [[[4, 3, 3], [3, 3, 2, 2], 36]]]\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) !... | 630 | 196 |
coding | Solve the programming task below in a Python markdown code block.
A plot of land can be described by $M x N$ dots such that horizontal and vertical distance between any two dots is 10m.
Mr. Wolf would like to build a house in the land such that all four sides of the house are equal. Help Mr. Wolf to find the total numb... | {"inputs": ["4\n2 4\n3 4\n4 4\n1000 500"], "outputs": ["3\n10\n20\n624937395"]} | 298 | 49 |
coding | Solve the programming task below in a Python markdown code block.
Let's denote that some array $b$ is bad if it contains a subarray $b_l, b_{l+1}, \dots, b_{r}$ of odd length more than $1$ ($l < r$ and $r - l + 1$ is odd) such that $\forall i \in \{0, 1, \dots, r - l\}$ $b_{l + i} = b_{r - i}$.
If an array is not bad,... | {"inputs": ["2 3\n3 3\n", "2 3\n3 3\n", "2 6\n3 3\n", "2 6\n5 3\n", "2 6\n2 3\n", "2 6\n3 5\n", "2 7\n3 5\n", "2 9\n3 5\n"], "outputs": ["1\n", "1\n", "1\n", "1\n", "1\n", "1\n", "1\n", "1\n"]} | 442 | 118 |
coding | Solve the programming task below in a Python markdown code block.
Dreamoon is a big fan of the Codeforces contests.
One day, he claimed that he will collect all the places from $1$ to $54$ after two more rated contests. It's amazing!
Based on this, you come up with the following problem:
There is a person who partic... | {"inputs": ["1\n1 5\n6\n", "1\n1 1\n2\n", "1\n1 1\n2\n", "1\n1 5\n6\n", "1\n1 9\n6\n", "1\n1 3\n6\n", "1\n1 3\n9\n", "1\n1 5\n4\n"], "outputs": ["6\n", "2\n", "2\n", "6\n", "10\n", "3\n", "3\n", "6\n"]} | 652 | 119 |
coding | Solve the programming task below in a Python markdown code block.
There are $n$ rectangles in a row. You can either turn each rectangle by $90$ degrees or leave it as it is. If you turn a rectangle, its width will be height, and its height will be width. Notice that you can turn any number of rectangles, you also can t... | {"inputs": ["1\n1 1\n", "1\n1 1\n", "1\n1 2\n", "1\n2 2\n", "1\n3 2\n", "1\n4 2\n", "1\n0 2\n", "2\n3 4\n5 5\n"], "outputs": ["YES\n", "YES\n", "YES\n", "YES\n", "YES\n", "YES\n", "YES\n", "NO\n"]} | 375 | 106 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given a string representing a code snippet, implement a tag validator to parse the code and return whether it is valid.
A code snippet is valid if all the following rules hold:
The code must be wrapped in a valid clo... | {"functional": "def check(candidate):\n assert candidate(code = \"<DIV>This is the first line <![CDATA[<div>]]></DIV>\") == True\n assert candidate(code = \"<DIV>>> ![cdata[]] <![CDATA[<div>]>]]>]]>>]</DIV>\") == True\n assert candidate(code = \"<A> <B> </A> </B>\") == False\n\n\ncheck(Solution().isValid)"... | 418 | 101 |
coding | Solve the programming task below in a Python markdown code block.
Peter loves any kinds of cheating. A week before ICPC, he broke into Doctor's PC and sneaked a look at all the problems that would be given in ICPC. He solved the problems, printed programs out, and brought into ICPC. Since electronic preparation is stri... | {"inputs": ["3\n19 22 1\n7\n93 26 38 43 66 4 3", "3\n19 22 1\n7\n93 26 38 43 36 4 3", "3\n19 22 0\n7\n93 26 38 3 66 80 1", "3\n19 22 0\n7\n93 26 38 43 36 4 3", "3\n19 22 1\n7\n93 26 38 3 66 80 1", "3\n19 20 2\n7\n56 26 2 43 31 12 7", "3\n19 22 0\n7\n93 26 38 43 36 4 2", "3\n19 44 1\n7\n93 26 38 3 66 80 1"], "outputs": ... | 553 | 334 |
coding | Solve the programming task below in a Python markdown code block.
Tomya is a girl. She loves Chef Ciel very much.
Tomya like a positive integer p, and now she wants to get a receipt of Ciel's restaurant whose total price is exactly p.
The current menus of Ciel's restaurant are shown the following table.
Name of Menupr... | {"inputs": ["4\n5\n23\n1\n1090", "4\n7\n23\n1\n1090", "4\n8\n73\n94\n2919", "4\n8\n73\n12\n2919", "4\n6\n73\n12\n2919", "4\n3\n73\n94\n2919", "4\n15\n18\n12\n689", "4\n5\n23\n12\n1090"], "outputs": ["2\n4\n1\n3\n", "3\n4\n1\n3\n", "1\n3\n5\n8\n", "1\n3\n2\n8\n", "2\n3\n2\n8\n", "2\n3\n5\n8\n", "4\n2\n2\n5\n", "2\n4\n2\... | 556 | 212 |
coding | Solve the programming task below in a Python markdown code block.
# Summation Of Primes
The sum of the primes below or equal to 10 is **2 + 3 + 5 + 7 = 17**. Find the sum of all the primes **_below or equal to the number passed in_**.
From Project Euler's [Problem #10](https://projecteuler.net/problem=10 "Project Eul... | {"functional": "_inputs = [[5], [6], [7], [8], [9], [10], [20], [30], [40], [50], [100], [200], [300], [400], [500], [1000], [2000], [3000], [4000], [5000], [25000]]\n_outputs = [[10], [10], [17], [17], [17], [17], [77], [129], [197], [328], [1060], [4227], [8275], [13887], [21536], [76127], [277050], [593823], [101350... | 125 | 375 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given a string s of lowercase English letters and a 2D integer array shifts where shifts[i] = [starti, endi, directioni]. For every i, shift the characters in s from the index starti to the index endi (inclusi... | {"functional": "def check(candidate):\n assert candidate(s = \"abc\", shifts = [[0,1,0],[1,2,1],[0,2,1]]) == \"ace\"\n assert candidate(s = \"dztz\", shifts = [[0,0,0],[1,1,1]]) == \"catz\"\n\n\ncheck(Solution().shiftingLetters)"} | 198 | 85 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.