task_type stringclasses 1
value | problem stringlengths 209 3.39k | answer stringlengths 35 6.15k | problem_tokens int64 60 774 | answer_tokens int64 12 2.04k |
|---|---|---|---|---|
coding | Solve the programming task below in a Python markdown code block.
Today, Wet Shark is given n bishops on a 1000 by 1000 grid. Both rows and columns of the grid are numbered from 1 to 1000. Rows are numbered from top to bottom, while columns are numbered from left to right.
Wet Shark thinks that two bishops attack each... | {"inputs": ["1\n6 3\n", "1\n1 1\n", "1\n1 1\n", "1\n6 3\n", "1\n0 1\n", "1\n6 6\n", "1\n9 6\n", "1\n9 11\n"], "outputs": ["0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n"]} | 401 | 103 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
English description is not available for the problem. Please switch to Chinese.
Β
Please complete the following python code precisely:
```python
class Solution:
def game(self, guess: List[int], answer: List[int]... | {"functional": "def check(candidate):\n assert candidate(guess = [1,2,3], answer = [1,2,3]) == 3\n assert candidate(guess = [2,2,3], answer = [3,2,1]) == 1\n\n\ncheck(Solution().game)"} | 67 | 68 |
coding | Solve the programming task below in a Python markdown code block.
Compute A + B.
Constraints
* -1000 β€ A, B β€ 1000
Input
The input will consist of a series of pairs of integers A and B separated by a space, one pair of integers per line. The input will be terminated by EOF.
Output
For each pair of input integers ... | {"inputs": ["1 2\n0 6\n011 1", "2 2\n0 6\n011 1", "2 4\n0 6\n011 1", "2 4\n0 2\n011 1", "2 6\n0 2\n011 1", "3 6\n0 2\n011 1", "3 6\n0 2\n011 0", "3 6\n0 4\n011 0"], "outputs": ["3\n6\n12\n", "4\n6\n12\n", "6\n6\n12\n", "6\n2\n12\n", "8\n2\n12\n", "9\n2\n12\n", "9\n2\n11\n", "9\n4\n11\n"]} | 128 | 198 |
coding | Solve the programming task below in a Python markdown code block.
You are the principal of the Cake school in chefland and today is your birthday. You want to treat each of the children with a small cupcake which is made by you. But there is a problem, You don't know how many students are present today.
The students ha... | {"inputs": ["1\n5 10"], "outputs": ["50"]} | 227 | 18 |
coding | Solve the programming task below in a Python markdown code block.
Cooking Examinations Authority (C.E.A.) is conducting an Ordinary Cooking Level (O.C.L.) test, which tests the candidate skills on three different aspects - Appearance, Flavor and Texture. Chef is planning to appear in this coveted test.
O.C.L. is a 240... | {"inputs": ["3\n4 4 4\n5 5 5\n5 5 5\n10 8 6\n5 6 7\n5 6 7\n"], "outputs": ["300\n408\n240\n"]} | 491 | 61 |
coding | Solve the programming task below in a Python markdown code block.
In this Kata, you will be given a string that may have mixed uppercase and lowercase letters and your task is to convert that string to either lowercase only or uppercase only based on:
* make as few changes as possible.
* if the string contains equal... | {"functional": "_inputs = [['code'], ['CODe'], ['COde'], ['Code']]\n_outputs = [['code'], ['CODE'], ['code'], ['code']]\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 ... | 267 | 174 |
coding | Solve the programming task below in a Python markdown code block.
There are two buttons, one of size A and one of size B.
When you press a button of size X, you get X coins and the size of that button decreases by 1.
You will press a button twice. Here, you can press the same button twice, or press both buttons once.
A... | {"inputs": ["6 4", "4 3", "9 2", "2 3", "2 1", "2 2", "1 1", "1 0"], "outputs": ["11\n", "7\n", "17\n", "5\n", "3\n", "4\n", "2\n", "1\n"]} | 184 | 80 |
coding | Solve the programming task below in a Python markdown code block.
Write a function that checks if all the letters in the second string are present in the first one at least once, regardless of how many times they appear:
```
["ab", "aaa"] => true
["trances", "nectar"] => true
["compadres", "DRAPES"] => true
... | {"functional": "_inputs = [[['abcd', 'aaa']], [['trances', 'nectar']], [['THE EYES', 'they see']], [['assert', 'staring']], [['arches', 'later']], [['dale', 'caller']], [['parses', 'parsecs']], [['replays', 'adam']], [['mastering', 'streaming']], [['drapes', 'compadres']], [['deltas', 'slated']], [['deltas', '']], [[''... | 154 | 284 |
coding | Solve the programming task below in a Python markdown code block.
## Task
Given an array of strings, reverse them and their order in such way that their length stays the same as the length of the original inputs.
### Example:
```
Input: {"I", "like", "big", "butts", "and", "I", "cannot", "lie!"}
Output: {"!", "eilt"... | {"functional": "_inputs = [[['I', 'like', 'big', 'butts', 'and', 'I', 'cannot', 'lie!']], [['?kn', 'ipnr', 'utotst', 'ra', 'tsn', 'iksr', 'uo', 'yer', 'ofebta', 'eote', 'vahu', 'oyodpm', 'ir', 'hsyn', 'amwoH']]]\n_outputs = [[['!', 'eilt', 'onn', 'acIdn', 'ast', 't', 'ubgibe', 'kilI']], [['How', 'many', 'shrimp', 'do',... | 134 | 313 |
coding | Solve the programming task below in a Python markdown code block.
Let s be some string consisting of symbols "0" or "1". Let's call a string t a substring of string s, if there exists such number 1 β€ l β€ |s| - |t| + 1 that t = s_l s_{l+1} β¦ s_{l + |t| - 1}. Let's call a substring t of string s unique, if there exist on... | {"inputs": ["3 3\n", "6 4\n", "3 1\n", "7 3\n", "6 2\n", "1 1\n", "6 6\n", "5 1\n"], "outputs": ["111", "010101", "010", "0010010", "001001", "1", "111111", "00100"]} | 585 | 107 |
coding | Solve the programming task below in a Python markdown code block.
You have a list of numbers from $1$ to $n$ written from left to right on the blackboard.
You perform an algorithm consisting of several steps (steps are $1$-indexed). On the $i$-th step you wipe the $i$-th number (considering only remaining numbers). Yo... | {"inputs": ["1\n4271 0\n", "1\n3916 0\n", "1\n33777 1\n", "1\n33777 0\n", "1\n54843 1\n", "1\n21874 1\n", "1\n21874 2\n", "1\n42601 2\n"], "outputs": ["0\n", "0\n", "2\n", "0\n", "2\n", "2\n", "4\n", "4\n"]} | 355 | 132 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given a rectangular cake of size h x w and two arrays of integers horizontalCuts and verticalCuts where:
horizontalCuts[i] is the distance from the top of the rectangular cake to the ith horizontal cut and si... | {"functional": "def check(candidate):\n assert candidate(h = 5, w = 4, horizontalCuts = [1,2,4], verticalCuts = [1,3]) == 4 \n assert candidate(h = 5, w = 4, horizontalCuts = [3,1], verticalCuts = [1]) == 6\n assert candidate(h = 5, w = 4, horizontalCuts = [3], verticalCuts = [3]) == 9\n\n\ncheck(Solution().ma... | 187 | 121 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given an integer array nums and an integer k, return the kth largest element in the array.
Note that it is the kth largest element in the sorted order, not the kth distinct element.
Can you solve it without sorting?
Β ... | {"functional": "def check(candidate):\n assert candidate(nums = [3,2,1,5,6,4], k = 2) == 5\n assert candidate(nums = [3,2,3,1,2,4,5,5,6], k = 4) == 4\n\n\ncheck(Solution().findKthLargest)"} | 103 | 82 |
coding | Solve the programming task below in a Python markdown code block.
You are walking through a parkway near your house. The parkway has $n+1$ benches in a row numbered from $1$ to $n+1$ from left to right. The distance between the bench $i$ and $i+1$ is $a_i$ meters.
Initially, you have $m$ units of energy. To walk $1$ m... | {"inputs": ["1\n1 1\n3\n", "1\n1 1\n2\n", "1\n1 1\n69\n", "1\n2 1\n99 99\n", "1\n5 3\n1 91 99 80 5\n", "1\n5 100\n1 99 99 80 5\n", "1\n5 100\n1 91 99 80 5\n", "3\n3 1\n1 2 1\n4 5\n3 3 5 2\n5 16\n1 2 3 4 5\n"], "outputs": ["2\n", "1\n", "68\n", "197\n", "273\n", "184\n", "176\n", "3\n8\n0\n"]} | 583 | 204 |
coding | Solve the programming task below in a Python markdown code block.
You are given an array B of length 2N . You have an unknown array A which is sorted and contains *distinct* elements. You need to find out the array A. B contains all the medians of each prefix and suffix of the array A.
A median is the middle element i... | {"inputs": ["2\n3\n6 5 5 7 6 6\n3\n1 2 1 4 2 4"], "outputs": ["5 6 7\n-1"]} | 528 | 47 |
coding | Solve the programming task below in a Python markdown code block.
You are given a colored permutation $p_1, p_2, \dots, p_n$. The $i$-th element of the permutation has color $c_i$.
Let's define an infinite path as infinite sequence $i, p[i], p[p[i]], p[p[p[i]]] \dots$ where all elements have same color ($c[i] = c[p[i]... | {"inputs": ["3\n4\n1 3 4 2\n1 2 2 3\n5\n2 3 4 5 1\n1 2 3 4 5\n8\n7 4 5 6 1 8 3 2\n5 3 6 4 7 5 8 4\n", "3\n4\n1 3 4 2\n1 2 2 3\n5\n2 3 4 5 1\n1 2 3 4 5\n8\n7 4 5 6 1 8 3 2\n5 3 6 8 7 5 8 4\n", "3\n4\n1 3 4 2\n1 2 2 3\n5\n2 3 4 5 1\n1 2 5 4 5\n8\n7 4 5 6 1 8 3 2\n5 3 6 4 7 5 8 4\n", "3\n4\n1 3 4 2\n1 1 2 3\n5\n2 3 4 5 1\... | 757 | 694 |
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.
In your garden, there is a long and narrow flowerbed that stretches infinitely to the east. You have decided to plant N kinds of flowers in this empty flowerbed. For convenience, we will call these N kinds of flowers Flower 1, 2, β¦, N. Also, we will call... | {"inputs": ["2 5\n38 9\n25 15", "2 5\n38 9\n39 15", "2 5\n38 9\n17 15", "2 10\n26 9\n1 15", "2 5\n20 3\n25 10", "1 5\n38 9\n25 15", "2 5\n20 10\n25 15", "2 5\n20 16\n25 15"], "outputs": ["55\n", "56\n", "47\n", "62\n", "29\n", "74\n", "40\n", "52\n"]} | 450 | 176 |
coding | Solve the programming task below in a Python markdown code block.
There is a horizontal row of $n$ cubes. The length of each cube is given. You need to create a new vertical pile of cubes. The new pile should follow these directions: if $cube[i]$ is on top of $cube[j]$ then $side Length[j]\geq side Length[i]$.
When s... | {"inputs": ["2\n6\n4 3 2 1 3 4\n3\n1 3 2\n"], "outputs": ["Yes\nNo\n"]} | 562 | 38 |
coding | Solve the programming task below in a Python markdown code block.
Chef is a really nice and respectful person, in sharp contrast to his little brother, who is a very nasty and disrespectful person. Chef always sends messages to his friends in all small letters, whereas the little brother sends messages in all capital l... | {"inputs": ["4\n5 1\nfrauD\n5 1\nFRAUD\n4 4\nLife\n10 4\nsTRAWBerry"], "outputs": ["chef\nbrother\nboth\nnone"]} | 630 | 50 |
coding | Solve the programming task below in a Python markdown code block.
Today, Chef decided to cook some delicious meals from the ingredients in his kitchen. There are $N$ ingredients, represented by strings $S_1, S_2, \ldots, S_N$. Chef took all the ingredients, put them into a cauldron and mixed them up.
In the cauldron, t... | {"inputs": ["3\n6\ncplusplus\noscar\ndeck\nfee\nhat\nnear\n5\ncode\nhacker\nchef\nchaby\ndumbofe\n5\ncodechef\nchefcode\nfehcedoc\ncceeohfd\ncodechef"], "outputs": ["1\n2\n5"]} | 570 | 73 |
coding | Solve the programming task below in a Python markdown code block.
Two players are playing a game. First each of them writes an integer from 1 to 6, and then a dice is thrown. The player whose written number got closer to the number on the dice wins. If both payers have the same difference, it's a draw.
The first playe... | {"inputs": ["2 5\n", "2 4\n", "5 3\n", "1 6\n", "5 1\n", "6 3\n", "2 3\n", "5 6\n"], "outputs": ["3 0 3\n", "2 1 3\n", "2 1 3\n", "3 0 3\n", "3 1 2\n", "2 0 4\n", "2 0 4\n", "5 0 1\n"]} | 284 | 118 |
coding | Solve the programming task below in a Python markdown code block.
Consider the following $4 \times 4$ pattern:
1 2 4 7
3 5 8 11
6 9 12 14
10 13 15 16
You are given an integer $N$. Print the $N \times N$ pattern of the same kind (containing integers $1$ through $N^2$).
-----Input-----
- The first line of the inp... | {"inputs": ["1\n4"], "outputs": ["1 2 4 7\n3 5 8 11\n6 9 12 14\n10 13 15 16"]} | 283 | 51 |
coding | Solve the programming task below in a Python markdown code block.
You are the best freelancer in the city. Everybody knows you, but what they don't know, is that you are actually offloading your work to other freelancers and and you rarely need to do any work. You're living the life!
To make this process easier you ne... | {"functional": "_inputs = [[60, [[1, 0]]], [60, [[0, 0]]]]\n_outputs = [['Easy Money!'], ['I need to work 1 hour(s) and 0 minute(s)']]\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, (lis... | 244 | 192 |
coding | Solve the programming task below in a Python markdown code block.
This is the hard version of Problem F. The only difference between the easy version and the hard version is the constraints.
We will call a non-empty string balanced if it contains the same number of plus and minus signs. For example: strings "+--+" and... | {"inputs": ["5\n3\n+-+\n5\n-+---\n4\n----\n7\n--+---+\n6\n+++---\n"], "outputs": ["2\n4\n2\n7\n4\n"]} | 640 | 51 |
coding | Solve the programming task below in a Python markdown code block.
For two positive integers a and b, let g(a, b) = [gcd]
(a, b) + [lcm](a, b).
For a positive integer N, let f(N) denote the minimum value of g(a, b) over all the pairs of positive integers (a, b) such that a+b = N.
Find out the number of ordered pairs ... | {"inputs": ["2\n4\n105"], "outputs": ["3\n14\n"]} | 422 | 22 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You have n flower seeds. Every seed must be planted first before it can begin to grow, then bloom. Planting a seed takes time and so does the growth of a seed. You are given two 0-indexed integer arrays plantTime and ... | {"functional": "def check(candidate):\n assert candidate(plantTime = [1,4,3], growTime = [2,3,1]) == 9\n assert candidate(plantTime = [1,2,3,2], growTime = [2,1,2,1]) == 9\n assert candidate(plantTime = [1], growTime = [1]) == 2\n\n\ncheck(Solution().earliestFullBloom)"} | 253 | 102 |
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 length of the diameter of the tree.
The diameter of a binary tree is the length of the longest path between any two nodes in a tree. This path may or may not pass through th... | {"functional": "def check(candidate):\n assert candidate(root = tree_node([1,2,3,4,5])) == 3\n assert candidate(root = tree_node([1,2])) == 1\n\n\ncheck(Solution().diameterOfBinaryTree)"} | 170 | 60 |
coding | Solve the programming task below in a Python markdown code block.
For a rooted tree, find the lowest common ancestor of two nodes u and v.
The given tree consists of n nodes and every node has a unique ID from 0 to n-1 where 0 is the root.
Constraints
* 1 β€ n β€ 100000
* 1 β€ q β€ 100000
Input
n
k0 c1 c2 ... ck0
k1 ... | {"inputs": ["8\n3 1 2 3\n2 4 5\n0\n0\n0\n2 6 7\n0\n0\n4\n4 6\n4 0\n2 3\n7 3", "8\n3 1 2 3\n2 4 5\n0\n0\n0\n2 6 7\n0\n0\n4\n4 6\n4 7\n2 3\n3 3", "8\n3 1 2 3\n2 4 5\n0\n0\n0\n2 6 7\n0\n0\n4\n4 6\n4 7\n3 3\n5 2", "8\n3 1 2 3\n2 4 5\n0\n0\n0\n2 6 7\n0\n0\n4\n6 6\n4 7\n2 2\n7 3", "8\n3 1 2 3\n2 4 5\n0\n0\n0\n2 6 7\n0\n0\n4\... | 322 | 494 |
coding | Solve the programming task below in a Python markdown code block.
Today is August 24, one of the five Product Days in a year.
A date m-d (m is the month, d is the date) is called a Product Day when d is a two-digit number, and all of the following conditions are satisfied (here d_{10} is the tens digit of the day and ... | {"inputs": ["0 1", "0 0", "1 0", "2 0", "9 1", "9 0", "2 1", "4 0"], "outputs": ["0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n"]} | 301 | 78 |
coding | Solve the programming task below in a Python markdown code block.
You have a team of N people. For a particular task, you can pick any non-empty subset of people. The cost of having x people for the task is x^{k}.
Output the sum of costs over all non-empty subsets of people.
-----Input-----
Only line of input cont... | {"inputs": ["1 1\n", "3 2\n", "5 3\n", "5 3\n", "7 5\n", "3 3\n", "4 8\n", "1 1\n"], "outputs": ["1\n", "24\n", "800\n", "800\n", "181888", "54", "93320", "1\n"]} | 333 | 98 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given an integer array coins representing coins of different denominations and an integer amount representing a total amount of money.
Return the number of combinations that make up that amount. If that amount... | {"functional": "def check(candidate):\n assert candidate(amount = 5, coins = [1, 2, 5]) == 4\n assert candidate(amount = 3, coins = [2]) == 0\n assert candidate(amount = 10, coins = [10] ) == 1\n\n\ncheck(Solution().change)"} | 136 | 78 |
coding | Solve the programming task below in a Python markdown code block.
Moscow is hosting a major international conference, which is attended by n scientists from different countries. Each of the scientists knows exactly one language. For convenience, we enumerate all languages of the world with integers from 1 to 10^9.
In ... | {"inputs": ["1\n8\n1\n10\n3\n", "1\n8\n1\n17\n3\n", "1\n10\n1\n10\n3\n", "2\n1 6\n1\n6\n1\n", "1\n10\n1\n10\n3\n", "2\n1 6\n1\n6\n1\n", "1\n19\n1\n10\n3\n", "2\n1 6\n1\n3\n1\n"], "outputs": ["1\n", "1\n", "1\n", "1\n", "1\n", "1\n", "1\n", "1\n"]} | 730 | 148 |
coding | Solve the programming task below in a Python markdown code block.
Read problem statements in [Russian], [Mandarin Chinese], [Bengali], and [Vietnamese] as well.
It's the soccer match finals in Chefland and as always it has reached the penalty shotouts.
Each team is given 5 shots to make and the team scoring a goal on... | {"inputs": ["4\n0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 1\n1 0 1 0 0 0 0 0 0 0 \n1 1 1 1 1 1 1 1 1 0"], "outputs": ["0\n2\n1\n1"]} | 610 | 99 |
coding | Solve the programming task below in a Python markdown code block.
There is a string S consisting of digits 1, 2, ..., 9.
Lunlun, the Dachshund, will take out three consecutive digits from S, treat them as a single integer X and bring it to her master. (She cannot rearrange the digits.)
The master's favorite number is 7... | {"inputs": ["820", "708", "792", "571", "2761", "5306", "1537", "1801"], "outputs": ["67\n", "45\n", "39\n", "182\n", "8\n", "223\n", "216\n", "48\n"]} | 335 | 92 |
coding | Solve the programming task below in a Python markdown code block.
Learn, learn and learn again β Valera has to do this every day. He is studying at mathematical school, where math is the main discipline. The mathematics teacher loves her discipline very much and tries to cultivate this love in children. That's why she ... | {"inputs": ["1\n2\n", "1\n4\n", "1\n0\n", "1\n-3\n", "2\n0 3\n", "2\n0 0\n", "1\n7500\n", "1\n5507\n"], "outputs": ["2\n", "4\n", "0\n", "3\n", "3\n", "0\n", "7500\n", "5507\n"]} | 374 | 103 |
coding | Solve the programming task below in a Python markdown code block.
Patrick has just finished writing a message to his sweetheart Stacey when he noticed that the message didn't look fancy. Patrick was nervous while writing the message, so some of the letters there were lowercase and some of them were uppercase.
Patrick ... | {"inputs": ["P\n", "t\n", "O\n", "s\n", "N\n", "r\n", "M\n", "q\n"], "outputs": ["0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n"]} | 289 | 70 |
coding | Solve the programming task below in a Python markdown code block.
# Task
Your Informatics teacher at school likes coming up with new ways to help you understand the material. When you started studying numeral systems, he introduced his own numeral system, which he's convinced will help clarify things. His numeral syst... | {"functional": "_inputs = [['G'], ['A'], ['D'], ['E'], ['O']]\n_outputs = [[['A + G', 'B + F', 'C + E', 'D + D']], [['A + A']], [['A + D', 'B + C']], [['A + E', 'B + D', 'C + C']], [['A + O', 'B + N', 'C + M', 'D + L', 'E + K', 'F + J', 'G + I', 'H + H']]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(... | 367 | 257 |
coding | Solve the programming task below in a Python markdown code block.
There is a 10 \times 10 grid with rows numbered 1 to 10 from top to bottom, and columns 1 to 10 from left to right. Each cell is identified by a pair (r,βc) which means that the cell is located at row r and column c.
If Chef's current location is (a,b),... | {"inputs": ["4\n1 2 9 8\n5 5 5 7\n8 6 6 8\n3 10 8 10\n"], "outputs": ["1\n2\n1\n2\n"]} | 470 | 54 |
coding | Solve the programming task below in a Python markdown code block.
You're given an undirected graph with $n$ nodes and $m$ edges. Nodes are numbered from $1$ to $n$.
The graph is considered harmonious if and only if the following property holds: For every triple of integers $(l, m, r)$ such that $1 \le l < m < r \le n... | {"inputs": ["3 1\n1 3\n", "3 1\n1 3\n", "5 1\n1 3\n", "4 1\n1 3\n", "200000 1\n1 200000\n", "200000 1\n1 200000\n", "200000 3\n7 9\n9 8\n4 5\n", "200000 3\n4 9\n9 8\n4 5\n"], "outputs": ["1\n", "1\n", "1\n", "1\n", "199998\n", "199998\n", "0\n", "2\n"]} | 538 | 174 |
coding | Solve the programming task below in a Python markdown code block.
Create a function that takes a string and an integer (`n`).
The function should return a string that repeats the input string `n` number of times.
If anything other than a string is passed in you should return `"Not a string"`
## Example
```
"Hi", 2... | {"functional": "_inputs = [['*', 3], ['Hello', 11], ['243624', 22], [[], 3], [24, 3], [True, 3], ['Hello', 0]]\n_outputs = [['***'], ['HelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHello'], ['2436242436242436242436242436242436242436242436242436242436242436242436242436242436242436242436242436242436242436242436242436... | 115 | 364 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
The factorial of a positive integer n is the product of all positive integers less than or equal to n.
For example, factorial(10) = 10 * 9 * 8 * 7 * 6 * 5 * 4 * 3 * 2 * 1.
We make a clumsy factorial using the intege... | {"functional": "def check(candidate):\n assert candidate(4) == 7\n assert candidate(10) == 12\n\n\ncheck(Solution().clumsy)"} | 271 | 42 |
coding | Solve the programming task below in a Python markdown code block.
In 2020, AtCoder Inc. with an annual sales of more than one billion yen (the currency of Japan) has started a business in programming education.
One day, there was an exam where a one-year-old child must write a program that prints Hello World, and a tw... | {"inputs": ["1", "1\n", "2\n4\n5", "2\n4\n9", "2\n2\n9", "2\n4\n4", "2\n8\n4", "2\n6\n4"], "outputs": ["Hello World", "Hello World\n", "9\n", "13\n", "11\n", "8\n", "12\n", "10\n"]} | 281 | 92 |
coding | Solve the programming task below in a Python markdown code block.
There are $n$ persons who initially don't know each other. On each morning, two of them, who were not friends before, become friends.
We want to plan a trip for every evening of $m$ days. On each trip, you have to select a group of people that will go o... | {"inputs": ["2 1 1\n2 1\n", "2 1 1\n2 1\n", "2 1 2\n2 1\n", "2 1 3\n2 1\n", "4 4 2\n2 3\n1 2\n1 3\n1 4\n", "4 4 2\n2 3\n1 2\n1 3\n1 4\n", "5 7 2\n1 5\n3 2\n2 5\n3 4\n1 2\n5 3\n1 3\n", "9 7 2\n1 5\n3 2\n2 5\n3 4\n1 2\n5 3\n1 3\n"], "outputs": ["2\n", "2\n", "0\n", "0\n", "0\n0\n3\n3\n", "0\n0\n3\n3\n", "0\n0\n0\n0\n3\n4... | 704 | 242 |
coding | Solve the programming task below in a Python markdown code block.
We have the first value of a certain sequence, we will name it ```initVal```.
We define pattern list, ```patternL```, an array that has the differences between contiguous terms of the sequence.
``` E.g: patternL = [k1, k2, k3, k4]```
The terms of the ... | {"functional": "_inputs = [[10, [2, 1, 3], 6], [10, [2, 1, 3], 15], [10, [2, 1, 3], 50], [10, [2, 1, 3], 78], [10, [2, 1, 3], 157], [10, [2, 2, 5, 8], 6], [10, [2, 2, 5, 8], 15], [10, [2, 2, 5, 8], 50], [10, [2, 2, 5, 8], 78], [10, [2, 2, 5, 8], 157], [100, [2, 2, 5, 8], 6], [100, [2, 2, 5, 8], 15], [100, [2, 2, 5, 8],... | 585 | 553 |
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.
Find the smallest possible sum of the digits in the decimal notation of a positive multiple of K.
-----Constraints-----
- 2 \leq K \leq 10^5
- K is an integer.
-----Input-----
Input is given from Standard Input in the following format:
K
-----Output... | {"inputs": ["9", "8", "4", "3", "5", "2", "7", "6"], "outputs": ["9\n", "1\n", "1\n", "3\n", "1\n", "1\n", "2\n", "3"]} | 118 | 61 |
coding | Solve the programming task below in a Python markdown code block.
You can perform the following operations on the string, $a$:
Capitalize zero or more of $a$'s lowercase letters.
Delete all of the remaining lowercase letters in $a$.
Given two strings, $a$ and $\boldsymbol{b}$, determine if it's possible to make $a$... | {"inputs": ["1\ndaBcd\nABC\n"], "outputs": ["YES\n"]} | 551 | 20 |
coding | Solve the programming task below in a Python markdown code block.
Petya's friends made him a birthday present β a bracket sequence. Petya was quite disappointed with his gift, because he dreamed of correct bracket sequence, yet he told his friends nothing about his dreams and decided to fix present himself.
To make e... | {"inputs": ["1\n)\n", "1\n(\n", "1\n(\n", "1\n)\n", "2\n)(\n", "2\n()\n", "2\n((\n", "2\n((\n"], "outputs": ["No\n", "No\n", "No\n", "No\n", "Yes\n", "Yes\n", "No\n", "No\n"]} | 466 | 89 |
coding | Solve the programming task below in a Python markdown code block.
You are given an integer N.
For two positive integers A and B, we will define F(A,B) as the larger of the following: the number of digits in the decimal notation of A, and the number of digits in the decimal notation of B.
For example, F(3,11) = 2 sinc... | {"inputs": ["1\n", "56", "472", "010", "748", "395", "593", "101"], "outputs": ["1\n", "1\n", "2\n", "1\n", "2\n", "2\n", "3\n", "3\n"]} | 238 | 76 |
coding | Solve the programming task below in a Python markdown code block.
Tak performed the following action N times: rolling two dice.
The result of the i-th roll is D_{i,1} and D_{i,2}.
Check if doublets occurred at least three times in a row.
Specifically, check if there exists at lease one i such that D_{i,1}=D_{i,2}, D_{i... | {"inputs": ["3\n1 2\n3 4\n5 6\n", "3\n1 1\n2 2\n3 3\n", "3\n1 2\n1 2\n3 3\n", "3\n1 1\n1 1\n1 1\n", "5\n1 2\n6 6\n4 4\n3 3\n3 3", "5\n1 2\n2 2\n3 4\n5 5\n6 6", "5\n1 2\n6 6\n4 1\n3 3\n3 2", "5\n1 2\n2 2\n3 4\n9 5\n6 6"], "outputs": ["No\n", "Yes\n", "No\n", "Yes\n", "Yes\n", "No\n", "No\n", "No\n"]} | 277 | 194 |
coding | Solve the programming task below in a Python markdown code block.
The goal of this exercise is to convert a string to a new string where each character in the new string is `"("` if that character appears only once in the original string, or `")"` if that character appears more than once in the original string. Ignore ... | {"functional": "_inputs = [['din'], ['recede'], ['Success'], ['CodeWarrior'], ['Supralapsarian'], ['iiiiii'], ['(( @'], [' ( ( )']]\n_outputs = [['((('], ['()()()'], [')())())'], ['()(((())())'], [')()))()))))()('], ['))))))'], ['))(('], [')))))(']]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, floa... | 183 | 225 |
coding | Solve the programming task below in a Python markdown code block.
Return the century of the input year. The input will always be a 4 digit string, so there is no need for validation.
### Examples
```
"1999" --> "20th"
"2011" --> "21st"
"2154" --> "22nd"
"2259" --> "23rd"
"1124" --> "12th"
"2000" --> "20th"
```
Also f... | {"functional": "_inputs = [['1999']]\n_outputs = [['20th']]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return math.isclose(a, b, rel_tol=tol, abs_tol=tol)\n if isinstance(a, (list, tuple)):\n if len(a) != len(b): return False\n return all(... | 142 | 161 |
coding | Solve the programming task below in a Python markdown code block.
You are given an undirected graph with N vertices and 0 edges. Process Q queries of the following types.
* `0 u v`: Add an edge (u, v).
* `1 u v`: Print 1 if u and v are in the same connected component, 0 otherwise.
Constraints
* 1 \leq N \leq 200,000... | {"inputs": ["4 7\n1 0 1\n0 0 1\n0 2 3\n1 0 1\n1 1 2\n0 0 2\n1 0 3", "4 7\n1 0 1\n0 0 1\n0 2 3\n1 0 2\n1 1 2\n0 0 2\n1 1 3", "4 7\n1 0 1\n0 0 1\n0 2 3\n1 0 1\n1 1 2\n0 0 2\n0 0 3", "4 7\n1 0 1\n0 0 1\n0 2 3\n1 0 2\n1 1 2\n0 0 2\n0 1 3", "4 7\n1 1 1\n0 0 1\n0 2 3\n1 0 2\n1 0 2\n0 0 2\n0 1 3", "4 7\n1 0 1\n0 0 1\n0 2 3\n2... | 247 | 450 |
coding | Solve the programming task below in a Python markdown code block.
Codefortia is a small island country located somewhere in the West Pacific. It consists of $n$ settlements connected by $m$ bidirectional gravel roads. Curiously enough, the beliefs of the inhabitants require the time needed to pass each road to be equal... | {"inputs": ["2 1 1 2\n2 1 1\n", "2 1 1 2\n2 1 1\n", "2 1 1 4\n2 1 1\n", "2 1 185269 10000000\n1 2 10000000\n", "2 1 9999999 10000000\n1 2 10000000\n", "2 1 9999999 10000000\n1 2 10000000\n", "2 1 12099651 10000000\n1 2 10000000\n", "3 2 509529 96762\n1 2 509529\n3 2 509529\n"], "outputs": ["0 1\n", "0 1\n", "0 1 ", "0 ... | 751 | 325 |
coding | Solve the programming task below in a Python markdown code block.
Define a "prime prime" number to be a rational number written as one prime number over another prime number: `primeA / primeB` (e.g. `7/31`)
Given a whole number `N`, generate the number of "prime prime" rational numbers less than 1, using only prime nu... | {"functional": "_inputs = [[6], [4], [10], [65], [0], [1000], [666]]\n_outputs = [[[3, 1]], [[1, 0]], [[6, 3]], [[153, 63]], [[0, 0]], [[14028, 6266]], [[7260, 3213]]]\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_to... | 217 | 236 |
coding | Solve the programming task below in a Python markdown code block.
Chef has an array of N integers. Chef can rearrange this array in any manner.
Chef doesnβt like the array if any two adjacent elements are equal. Determine whether there exists a rearrangement of the array that Chef likes.
------ Input Format ------
... | {"inputs": ["2\n5\n1 1 1 1 1\n3\n3 3 4\n"], "outputs": ["No\nYes\n"]} | 363 | 36 |
coding | Solve the programming task below in a Python markdown code block.
We consider two strings to be anagrams of each other if the first string's letters can be rearranged to form the second string. In other words, both strings must contain the same exact letters in the same exact frequency. For example, bacdc and dcbac are... | {"inputs": ["cde\nabc\n"], "outputs": ["4\n"]} | 491 | 17 |
coding | Solve the programming task below in a Python markdown code block.
Kristen loves playing with and comparing numbers. She thinks that if she takes two different positive numbers, the one whose digits sum to a larger number is better than the other. If the sum of digits is equal for both numbers, then she thinks the small... | {"inputs": ["12\n"], "outputs": ["6\n"]} | 252 | 15 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given an integer array matches where matches[i] = [winneri, loseri] indicates that the player winneri defeated player loseri in a match.
Return a list answer of size 2 where:
answer[0] is a list of all player... | {"functional": "def check(candidate):\n assert candidate(matches = [[1,3],[2,3],[3,6],[5,6],[5,7],[4,5],[4,8],[4,9],[10,4],[10,9]]) == [[1,2,10],[4,5,7,8]]\n assert candidate(matches = [[2,3],[1,3],[5,4],[6,4]]) == [[1,2,5,6],[]]\n\n\ncheck(Solution().findWinners)"} | 175 | 122 |
coding | Solve the programming task below in a Python markdown code block.
DNA is a biomolecule that carries genetic information. It is composed of four different building blocks, called nucleotides: adenine (A), thymine (T), cytosine (C) and guanine (G). Two DNA strands join to form a double helix, whereby the nucleotides of o... | {"functional": "_inputs = [['GTCTTAGTGTAGCTATGCATGC', 'GCATGCATAGCTACACTACGAC'], ['ATGCTACG', 'CGTAGCAT'], ['AGTCTGTATGCATCGTACCC', 'GGGTACGATGCATACAGACT'], ['TGCTACGTACGATCGACGATCCACGAC', 'GTCGTGGATCGTCGATCGTACGTAGCA'], ['ATGCCTACGGCCATATATATTTAG', 'CTAAATATGTATGGCCGTAGGCAT'], ['GTCACCGA', 'TCGGCTGAC'], ['TAATACCCGACT... | 437 | 604 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given two positive integer arrays spells and potions, of length n and m respectively, where spells[i] represents the strength of the ith spell and potions[j] represents the strength of the jth potion.
You are ... | {"functional": "def check(candidate):\n assert candidate(spells = [5,1,3], potions = [1,2,3,4,5], success = 7) == [4,0,3]\n assert candidate(spells = [3,1,2], potions = [8,5,8], success = 16) == [2,0,2]\n\n\ncheck(Solution().successfulPairs)"} | 155 | 96 |
coding | Solve the programming task below in a Python markdown code block.
Given a binary number (of $N$ bits) $X$. Find the highest power of 2 that divides this number.
Note: If the binary number is "100" then the highest power of 2 that divides it is 2 (as $2^{2}$ = 4)
------ Input: ------
The first line contains N the num... | {"inputs": ["5\n10100"], "outputs": ["2"]} | 175 | 18 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
A complex number can be represented as a string on the form "real+imaginaryi" where:
real is the real part and is an integer in the range [-100, 100].
imaginary is the imaginary part and is an integer in the range [-... | {"functional": "def check(candidate):\n assert candidate(num1 = \"1+1i\", num2 = \"1+1i\") == \"0+2i\"\n assert candidate(num1 = \"1+-1i\", num2 = \"1+-1i\") == \"0+-2i\"\n\n\ncheck(Solution().complexNumberMultiply)"} | 151 | 78 |
coding | Solve the programming task below in a Python markdown code block.
Kevin Sun wants to move his precious collection of n cowbells from Naperthrill to Exeter, where there is actually grass instead of corn. Before moving, he must pack his cowbells into k boxes of a fixed size. In order to keep his collection safe during tr... | {"inputs": ["1 1\n1\n", "1 1\n1\n", "1 2\n10\n", "1 2\n10\n", "1 1\n10\n", "2 1\n2 5\n", "2 2\n2 3\n", "2 2\n2 3\n"], "outputs": ["1\n", "1\n", "10\n", "10\n", "10\n", "7\n", "3\n", "3\n"]} | 527 | 114 |
coding | Solve the programming task below in a Python markdown code block.
There are N apple trees in a row. People say that one of them will bear golden apples.
We want to deploy some number of inspectors so that each of these trees will be inspected.
Each inspector will be deployed under one of the trees. For convenience, we ... | {"inputs": ["0 3", "6 4", "4 0", "9 0", "2 7", "1 3", "1 4", "1 7"], "outputs": ["0\n", "1\n", "4\n", "9\n", "1\n", "1\n", "1\n", "1\n"]} | 240 | 78 |
coding | Solve the programming task below in a Python markdown code block.
We have a two-dimensional grid with H \times W squares. There are M targets to destroy in this grid - the position of the i-th target is \left(h_i, w_i \right).
Takahashi will choose one square in this grid, place a bomb there, and ignite it. The bomb wi... | {"inputs": ["2 3 3\n2 2\n1 1\n1 2", "2 3 3\n2 1\n1 1\n1 3", "2 3 3\n2 1\n1 1\n1 2", "2 4 3\n2 1\n1 1\n1 2", "2 3 3\n2 2\n2 1\n1 2", "4 3 3\n2 1\n1 1\n1 2", "4 3 3\n3 1\n1 1\n1 2", "8 3 3\n3 1\n1 1\n1 2"], "outputs": ["3\n", "3\n", "3\n", "3\n", "3\n", "3\n", "3\n", "3\n"]} | 347 | 190 |
coding | Solve the programming task below in a Python markdown code block.
The only difference between this problem and D1 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"]} | 554 | 66 |
coding | Solve the programming task below in a Python markdown code block.
You gave the twins Ai and Zu a program of games using strings. In this game, Ai and Zu each select a substring from the character string, compare them, and the person who chooses the smaller one will get points. The two competed and played the game many ... | {"inputs": ["13\naizualgorithm\n9\ncomp 1 1 4 5\ncomp 2 6 1 5\nset 9 12 b\ncomp 9 9 6 10\ncomp 5 8 1 3\nset 1 10 z\nset 11 6 x\ncomp 8 10 1 5\ncomp 1 5 2 5", "13\naozualgirithm\n9\ncomp 1 1 4 5\ncomp 2 6 1 5\nset 9 12 b\ncomp 9 9 6 10\ncomp 5 8 1 3\nset 1 10 z\nset 11 6 x\ncomp 8 10 1 5\ncomp 1 5 2 5", "13\naizualgorit... | 554 | 889 |
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.
Complete the solution. It should try to retrieve the value of the array at the index provided. If the index is out of the array's max bounds then it should return the default value instead.
Example:
```Haskell
solution [1..3] 1 1000 `shouldBe` 2
soluti... | {"functional": "_inputs = [[[None, None], 0, 'a']]\n_outputs = [[None]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return math.isclose(a, b, rel_tol=tol, abs_tol=tol)\n if isinstance(a, (list, tuple)):\n if len(a) != len(b): return False\n ... | 338 | 161 |
coding | Solve the programming task below in a Python markdown code block.
Leha is a bright mathematician. Today he is investigating whether an integer is divisible by some square number or not.
He has a positive integer X represented as a product of N integers a1, a2, .... aN. He has somehow figured out that there exists some ... | {"inputs": ["1\n3\n21 11 6"], "outputs": ["3"]} | 452 | 22 |
coding | Solve the programming task below in a Python markdown code block.
Gru wanted to upgrade the quality of his minions' despicableness through his new base, The Volcano. Dave, desperately wanting the Minion of the Year award, rushed to The Volcano only to find out that he needs to solve a series of questions before he can ... | {"inputs": ["2\n7 2\n1 1 1 5\n7 8 8 7\n11 5\n1 1 1 1\n0 1 2 3\n3 2 1 0\n9 8 7 6\n0 0 1 1\n"], "outputs": ["7\nwala\n2\n1\nwala\n33\n0\n"]} | 644 | 94 |
coding | Solve the programming task below in a Python markdown code block.
Mishka received a gift of multicolored pencils for his birthday! Unfortunately he lives in a monochrome world, where everything is of the same color and only saturation differs. This pack can be represented as a sequence a_1, a_2, ..., a_{n} of n integer... | {"inputs": ["1 1 1\n1\n", "1 1 1\n1\n", "1 1 0\n1\n", "3 2 2\n6 7 7\n", "3 2 2\n6 7 7\n", "3 2 3\n6 7 7\n", "4 2 3\n1 2 3 6\n", "4 2 1\n1 1 2 3\n"], "outputs": ["YES\n", "YES\n", "YES\n", "YES\n", "YES\n", "YES\n", "YES\n", "YES\n"]} | 562 | 142 |
coding | Solve the programming task below in a Python markdown code block.
In this kata you will have to change every letter in a given string to the next letter in the alphabet. You will write a function `nextLetter` to do this. The function will take a single parameter `s` (string).
Examples:
```
"Hello" --> "Ifmmp"
"What ... | {"functional": "_inputs = [['Hello'], ['What is your name?'], ['zOo']]\n_outputs = [['Ifmmp'], ['Xibu jt zpvs obnf?'], ['aPp']]\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, tupl... | 157 | 184 |
coding | Solve the programming task below in a Python markdown code block.
Mashmokh works in a factory. At the end of each day he must turn off all of the lights.
The lights on the factory are indexed from 1 to n. There are n buttons in Mashmokh's room indexed from 1 to n as well. If Mashmokh pushes button with index i, then ... | {"inputs": ["1 1\n1\n", "1 1\n1\n", "2 1\n1\n", "5 4\n4 3 1 2\n", "5 4\n2 3 4 1\n", "5 4\n2 3 4 1\n", "5 4\n3 3 4 1\n", "35 3\n6 1 11\n"], "outputs": ["1 \n", "1\n", "1 1 ", "1 1 3 4 4 \n", "1 2 2 2 2 \n", "1 2 2 2 2\n", "1 1 3 3 3 ", "1 1 1 1 1 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 "]} | 507 | 235 |
coding | Solve the programming task below in a Python markdown code block.
Consider the following series:
`1, 2, 4, 8, 16, 22, 26, 38, 62, 74, 102, 104, 108, 116, 122`
It is generated as follows:
* For single digit integers, add the number to itself to get the next element.
* For other integers, multiply all the non-zero dig... | {"functional": "_inputs = [[3], [5], [10], [15], [500], [5000]]\n_outputs = [[5], [6], [5], [2], [29], [283]]\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 l... | 515 | 194 |
coding | Solve the programming task below in a Python markdown code block.
How many multiples of d are there among the integers between L and R (inclusive)?
Constraints
* All values in input are integers.
* 1 \leq L \leq R \leq 100
* 1 \leq d \leq 100
Input
Input is given from Standard Input in the following format:
L R d... | {"inputs": ["5 4 1", "2 4 1", "2 3 1", "2 8 1", "2 5 1", "5 4 2", "2 2 1", "9 20 7"], "outputs": ["0\n", "3\n", "2\n", "7\n", "4\n", "0\n", "1\n", "1\n"]} | 153 | 95 |
coding | Solve the programming task below in a Python markdown code block.
Vasya has an array a consisting of positive integer numbers. Vasya wants to divide this array into two non-empty consecutive parts (the prefix and the suffix) so that the sum of all elements in the first part equals to the sum of elements in the second p... | {"inputs": ["1\n1\n", "1\n2\n", "1\n1\n", "1\n2\n", "1\n8\n", "1\n4\n", "1\n10\n", "1\n10\n"], "outputs": ["NO\n", "NO\n", "NO", "NO", "NO\n", "NO\n", "NO\n", "NO"]} | 336 | 85 |
coding | Solve the programming task below in a Python markdown code block.
#Unflatten a list (Easy)
There are several katas like "Flatten a list".
These katas are done by so many warriors, that the count of available list to flattin goes down!
So you have to build a method, that creates new arrays, that can be flattened!
#Sh... | {"functional": "_inputs = [[[3, 5, 2, 1]], [[1, 4, 5, 2, 1, 2, 4, 5, 2, 6, 2, 3, 3]], [[1, 1, 1, 1]], [[1]], [[99, 1, 1, 1]], [[3, 1, 1, 3, 1, 1]]]\n_outputs = [[[[3, 5, 2], 1]], [[1, [4, 5, 2, 1], 2, [4, 5, 2, 6], 2, [3, 3]]], [[1, 1, 1, 1]], [[1]], [[[99, 1, 1, 1]]], [[[3, 1, 1], [3, 1, 1]]]]\nimport math\ndef _deep_... | 512 | 346 |
coding | Solve the programming task below in a Python markdown code block.
We define the diameter of a strongly-connected oriented graph, $G=(V,E)$, as the minimum integer $\boldsymbol{d}$ such that for each $u,v\in G$ there is a path from $\mbox{u}$ to $v$ of length $\leq d$ (recall that a path's length is its number of edges)... | {"inputs": ["5 2\n"], "outputs": ["2\n1 4\n2 0\n3 1\n4 2\n0 3\n"]} | 606 | 36 |
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.
Chef has a simple undirected graph with $N$ vertices (numbered $1$ through $N$) and $M$ edges. He wants to divide it into $K$ parts (subgraphs) for s... | {"inputs": ["1\n5 5\n1 2\n1 3\n2 3\n2 4\n3 4"], "outputs": ["2\n1 2 1 1 2"]} | 735 | 46 |
coding | Solve the programming task below in a Python markdown code block.
One day Vasya the Hipster decided to count how many socks he had. It turned out that he had a red socks and b blue socks.
According to the latest fashion, hipsters should wear the socks of different colors: a red one on the left foot, a blue one on the ... | {"inputs": ["3 1\n", "2 3\n", "7 3\n", "1 1\n", "1 1\n", "2 1\n", "2 0\n", "7 5\n"], "outputs": ["1 1\n", "2 0\n", "3 2\n", "1 0\n", "1 0\n", "1 0\n", "0 1\n", "5 1\n"]} | 364 | 102 |
coding | Solve the programming task below in a Python markdown code block.
The most important part of a GSM network is so called Base Transceiver Station (BTS). These transceivers form the areas called cells (this term gave the name to the cellular phone) and every phone connects to the BTS with the strongest signal (in a littl... | {"inputs": ["6\n2\n188\n100\n415\n571\n92075", "6\n2\n188\n100\n415\n571\n216675", "6\n1\n37\n110\n671\n28\n11057064", "6\n1\n37\n110\n671\n36\n11057064", "6\n2\n37\n100\n671\n36\n11057064", "6\n3\n71\n100\n287\n4581\n8735373", "6\n8\n2\n100\n637\n31879\n8735373", "6\n3\n100\n100\n287\n351\n8735373"], "outputs": ["0\n4... | 619 | 425 |
coding | Solve the programming task below in a Python markdown code block.
Qwerty the Ranger took up a government job and arrived on planet Mars. He should stay in the secret lab and conduct some experiments on bacteria that have funny and abnormal properties. The job isn't difficult, but the salary is high.
At the beginning o... | {"inputs": ["5 5 2 1\n", "1 1 2 2\n", "1 1 1 1\n", "3 1 3 4\n", "1 4 1 5\n", "5 4 1 4\n", "2 3 4 5\n", "2 2 5 4\n"], "outputs": ["2\n", "1\n", "1\n", "2\n", "0\n", "1\n", "3\n", "4\n"]} | 390 | 118 |
coding | Solve the programming task below in a Python markdown code block.
There are $n$ participants in a competition, participant $i$ having a strength of $s_i$.
Every participant wonders how much of an advantage they have over the other best participant. In other words, each participant $i$ wants to know the difference betw... | {"inputs": ["5\n4\n4 7 3 5\n2\n1 2\n5\n1 2 3 4 5\n3\n4 9 4\n4\n4 4 4 4\n", "1\n23\n1 2 3 4 5 6 7 8 9 10 11 12 13 1 1 1 1 1 1 1 1 1 1\n"], "outputs": ["-3 2 -4 -2 \n-1 1 \n-4 -3 -2 -1 1 \n-5 5 -5 \n0 0 0 0 \n", "-12 -11 -10 -9 -8 -7 -6 -5 -4 -3 -2 -1 1 -12 -12 -12 -12 -12 -12 -12 -12 -12 -12 \n"]} | 644 | 222 |
coding | Solve the programming task below in a Python markdown code block.
In this challenge, the user enters a string and a substring. You have to print the number of times that the substring occurs in the given string. String traversal will take place from left to right, not from right to left.
NOTE: String letters are case... | {"inputs": ["ABCDCDC\nCDC\n"], "outputs": ["2\n"]} | 292 | 18 |
coding | Solve the programming task below in a Python markdown code block.
Given a number, write a function to output its reverse digits. (e.g. given 123 the answer is 321)
Numbers should preserve their sign; i.e. a negative number should still be negative when reversed.
### Examples
```
123 -> 321
-456 -> -654
1000 -> ... | {"functional": "_inputs = [[123], [-123], [1000], [4321234], [5], [0], [98989898]]\n_outputs = [[321], [-321], [1], [4321234], [5], [0], [89898989]]\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 isin... | 121 | 227 |
coding | Solve the programming task below in a Python markdown code block.
Johnny was asked by his math teacher to compute nn (n to the power of n, where n is an integer), and has to read his answer out loud. This is a bit of a tiring task, since the result is probably an extremely large number, and would certainly keep Johnny ... | {"inputs": ["2\n4 2\n9 3"], "outputs": ["25 56\n387 489"]} | 299 | 32 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given an array nums of n integers, return an array of all the unique quadruplets [nums[a], nums[b], nums[c], nums[d]] such that:
0 <= a, b, c, dΒ < n
a, b, c, and d are distinct.
nums[a] + nums[b] + nums[c] + nums[d] ... | {"functional": "def check(candidate):\n assert candidate(nums = [1,0,-1,0,-2,2], target = 0) == [[-2,-1,1,2],[-2,0,0,2],[-1,0,0,1]]\n assert candidate(nums = [2,2,2,2,2], target = 8) == [[2,2,2,2]]\n\n\ncheck(Solution().fourSum)"} | 139 | 104 |
coding | Solve the programming task below in a Python markdown code block.
Consider a list (list = []). You can perform the following commands:
insert i e: Insert integer $\boldsymbol{\mathrm{~e~}}$ at position $\boldsymbol{i}$.
print: Print the list.
remove e: Delete the first occurrence of integer $\boldsymbol{\mathrm{~e~... | {"inputs": ["12\ninsert 0 5\ninsert 1 10\ninsert 0 6\nprint\nremove 6\nappend 9\nappend 1\nsort\nprint\npop\nreverse\nprint\n"], "outputs": ["[6, 5, 10]\n[1, 5, 9, 10]\n[9, 5, 1]\n"]} | 462 | 91 |
coding | Solve the programming task below in a Python markdown code block.
AquaMoon has n friends. They stand in a row from left to right, and the i-th friend from the left wears a T-shirt with a number a_i written on it. Each friend has a direction (left or right). In the beginning, the direction of each friend is right.
Aqua... | {"inputs": ["1\n2\n4 3\n", "1\n2\n9 8\n", "1\n2\n6 5\n", "1\n2\n4 8\n", "1\n2\n7 8\n", "1\n2\n10 8\n", "1\n3\n6 5 4\n", "1\n3\n3 2 2\n"], "outputs": ["NO\n", "NO\n", "NO\n", "YES\n", "YES\n", "NO\n", "YES\n", "YES\n"]} | 537 | 123 |
coding | Solve the programming task below in a Python markdown code block.
Polycarp has created his own training plan to prepare for the programming contests. He will train for $n$ days, all days are numbered from $1$ to $n$, beginning from the first.
On the $i$-th day Polycarp will necessarily solve $a_i$ problems. One evenin... | {"inputs": ["1\n1\n", "1\n1\n", "1\n2\n", "2\n1 3\n", "2\n1 2\n", "2\n3 4\n", "2\n2 3\n", "2\n6 7\n"], "outputs": ["1\n", "1\n", "1\n", "2\n", "2\n", "2\n", "2\n", "2\n"]} | 405 | 96 |
coding | Solve the programming task below in a Python markdown code block.
Given an array of ints, return the index such that the sum of the elements to the right of that index equals the sum of the elements to the left of that index. If there is no such index, return `-1`. If there is more than one such index, return the left-... | {"functional": "_inputs = [[[1, 2, 3, 5, 3, 2, 1]], [[1, 12, 3, 3, 6, 3, 1]], [[10, 20, 30, 40]]]\n_outputs = [[3], [2], [-1]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return math.isclose(a, b, rel_tol=tol, abs_tol=tol)\n if isinstance(a, (list, tuple... | 274 | 216 |
coding | Solve the programming task below in a Python markdown code block.
ZS the Coder is coding on a crazy computer. If you don't type in a word for a c consecutive seconds, everything you typed disappear!
More formally, if you typed a word at second a and then the next word at second b, then if b - a β€ c, just the new word... | {"inputs": ["2 1\n1 2\n", "2 1\n1 2\n", "2 0\n1 2\n", "2 0\n1 3\n", "2 1\n1 100\n", "2 1\n1 100\n", "2 1\n2 100\n", "2 0\n1 100\n"], "outputs": ["2", "2\n", "1\n", "1\n", "1", "1\n", "1\n", "1\n"]} | 566 | 124 |
coding | Solve the programming task below in a Python markdown code block.
Chef is playing Ludo. According to the rules of Ludo, a player can enter a new token into the play only when he rolls a 6 on the die.
In the current turn, Chef rolled the number X on the die. Determine if Chef can enter a new token into the play in the ... | {"inputs": ["3\n1\n6\n3\n"], "outputs": ["NO\nYES\nNO\n"]} | 288 | 24 |
coding | Solve the programming task below in a Python markdown code block.
You are looking for a place to park your car on a wall street. You can park at any position that meets the following requirements:
1. It is not directly in front of a private driveway.
2. It is not directly in front of a bus stop.
3. It is not 5 meter... | {"inputs": ["46\n---B--S-D--S--\nDDBDDBDDBDD\n--S--S--S--S--\nSSD-B---BD-DDSB-----S-S--------S-B----BSB-S--B-S-D\n-SB---S----DD-D-DS---B--BD-S-SD---D----D-B---B-SDD\n------BB-----D--------S--D-BSSS-----B---S-S-SSS---\n----------S--S----D---------SD---DD--D---DSB-B----\n-S---------DDDB---BB----SSD---D-B---S-B-----DD---S... | 485 | 734 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given the root of a binary tree with n nodes where each node in the tree has node.val coins. There are n coins in total throughout the whole tree.
In one move, we may choose two adjacent nodes and move one coi... | {"functional": "def check(candidate):\n assert candidate(root = tree_node([3,0,0])) == 2\n assert candidate(root = tree_node([0,3,0])) == 3\n\n\ncheck(Solution().distributeCoins)"} | 185 | 56 |
coding | Solve the programming task below in a Python markdown code block.
You are given two non-empty strings $s$ and $t$, consisting of Latin letters.
In one move, you can choose an occurrence of the string $t$ in the string $s$ and replace it with dots.
Your task is to remove all occurrences of the string $t$ in the string... | {"inputs": ["8\nabababacababa\naba\nddddddd\ndddd\nxyzxyz\nxyz\nabc\nabcd\nabacaba\nabaca\nabc\ndef\naaaaaaaa\na\naaaaaaaa\naa\n", "3\nabacabadabacabaeabacabadabacabafabacabadabacabac\naba\nabacabadabacabaabacabadabaabaabacabaa\naba\nabacabadaababaaabacaaab\naba\n", "6\ncgleetgjqctvoln\ntttt\nqcmivmmvgifpnm\nmmmm\nxxxr... | 742 | 815 |
coding | Solve the programming task below in a Python markdown code block.
You have N items that you want to put them into a knapsack. Item i has value vi and weight wi.
You want to find a subset of items to put such that:
* The total value of the items is as large as possible.
* The items have combined weight at most W, that... | {"inputs": ["0 9\n4 5\n0 4", "2 2\n5 8\n2 7", "0 9\n4 5\n0 6", "2 20\n5 9\n1 8", "2 20\n4 5\n0 4", "0 20\n4 5\n1 2", "1 34\n3 9\n1 8", "1 5\n27 4\n0 1"], "outputs": ["0\n", "0\n", "0\n", "6\n", "4\n", "0\n", "3\n", "27\n"]} | 271 | 148 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.