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.
Read problems statements [Hindi] ,[Bengali] , [Mandarin chinese] , [Russian] and [Vietnamese] as well.
Chef is stuck at the following problem. Help him solve it!
Chef has a sequence of integers $A_{1}, A_{2}, \dots, A_{N}$. He should find the number of... | {"inputs": ["1\n5\n2 4 8 1 3"], "outputs": ["3"]} | 433 | 24 |
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.
As usual, I went to work in the morning. Unfortunately, I found out that my manager bought a new machine and I have to learn to operate it.
There are... | {"inputs": ["1\n3\n2 1 3"], "outputs": ["4"]} | 600 | 20 |
coding | Solve the programming task below in a Python markdown code block.
In this Kata, you will be given an array and your task will be to determine if an array is in ascending or descending order and if it is rotated or not.
Consider the array `[1,2,3,4,5,7,12]`. This array is sorted in `Ascending` order. If we rotate this... | {"functional": "_inputs = [[[1, 2, 3, 4, 5, 7]], [[7, 1, 2, 3, 4, 5]], [[2, 3, 4, 5, 7, 12]], [[7, 12, 1, 2, 3, 4, 5]], [[4, 5, 6, 1, 2, 3]], [[9, 8, 7, 6, 5]], [[5, 9, 8, 7, 6]], [[6, 5, 9, 8, 7]], [[9, 6, 7]], [[10, 12, 11]], [[13, 10, 11]]]\n_outputs = [['A'], ['RA'], ['A'], ['RA'], ['RA'], ['D'], ['RD'], ['RD'], ['... | 392 | 354 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You have a 1-indexed binary string of length n where all the bits are 0 initially. We will flip all the bits of this binary string (i.e., change them from 0 to 1) one by one. You are given a 1-indexed integer array fl... | {"functional": "def check(candidate):\n assert candidate(flips = [3,2,4,1,5]) == 2\n assert candidate(flips = [4,1,2,3]) == 1\n\n\ncheck(Solution().numTimesAllBlue)"} | 179 | 61 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given an array of integers heights representing the histogram's bar height where the width of each bar is 1, return the area of the largest rectangle in the histogram.
Please complete the following python code preci... | {"functional": "def check(candidate):\n assert candidate(heights = [2,1,5,6,2,3]) == 10\n assert candidate( heights = [2,4]) == 4\n\n\ncheck(Solution().largestRectangleArea)"} | 82 | 61 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
At a lemonade stand, each lemonade costs $5. Customers are standing in a queue to buy from you and order one at a time (in the order specified by bills). Each customer will only buy one lemonade and pay with either a ... | {"functional": "def check(candidate):\n assert candidate(bills = [5,5,5,10,20]) == True\n assert candidate(bills = [5,5,10,10,20]) == False\n\n\ncheck(Solution().lemonadeChange)"} | 181 | 66 |
coding | Solve the programming task below in a Python markdown code block.
Johnny has just found the new, great tutorial: "How to become a grandmaster?". The tutorial tells many strange and unexpected for Johnny things, such as you have to be patient or that very important is solving many harder and harder problems.
The boy h... | {"inputs": ["1\n1 2\n88\n", "1\n1 2\n88\n", "1\n1 3\n88\n", "1\n1 2\n70\n", "1\n1 5\n88\n", "1\n1 3\n103\n", "1\n1 3\n198\n", "1\n1 1\n103\n"], "outputs": ["140130951\n", "140130951\n", "772681989\n", "270016253\n", "467137716\n", "923126036\n", "792924246\n", "1\n"]} | 613 | 185 |
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.
Peter has a sequence of integers a_1, a_2, ..., a_{n}. Peter wants all numbers in the sequence to equal h. He can perform the operation of "adding one on the segment [l, r]": add one to all elements of the sequence with indices from l to r (inclusive). A... | {"inputs": ["3 2\n1 1 1\n", "3 2\n2 1 1\n", "3 4\n4 3 2\n", "3 6\n5 6 5\n", "3 2\n1 0 1\n", "1 349\n348\n", "3 2\n1 0 1\n", "3 2\n2 1 1\n"], "outputs": ["4\n", "2\n", "0\n", "1\n", "2\n", "1\n", "2\n", "2\n"]} | 374 | 134 |
coding | Solve the programming task below in a Python markdown code block.
Chef has two strings A and B of lengths N and M respectively.
Chef can rearrange both strings in any way he wants. Let the rearranged string of A be A' and the rearranged string of B be B'.
Determine whether we can construct rearrangements A' and B' s... | {"inputs": ["4\n5 2\nabcdd\nac\n3 3\nabc\nxyz\n2 4\naa\naaaa\n1 3\na\naax\n"], "outputs": ["YES\nNO\nYES\nNO\n"]} | 569 | 54 |
coding | Solve the programming task below in a Python markdown code block.
Polycarpus is an amateur programmer. Now he is analyzing a friend's program. He has already found there the function rangeIncrement(l, r), that adds 1 to each element of some array a for all indexes in the segment [l, r]. In other words, this function do... | {"inputs": ["1\n1\n", "1\n0\n", "2\n2 1\n", "2\n1 1\n", "2\n2 4\n", "2\n1 3\n", "2\n4 1\n", "2\n1 0\n"], "outputs": ["1\n1 1\n", "0\n", "2\n1 1\n1 2\n", "1\n1 2\n", "4\n2 2\n2 2\n1 2\n1 2\n", "3\n2 2\n2 2\n1 2\n", "4\n1 1\n1 1\n1 1\n1 2\n", "1\n1 1\n"]} | 565 | 162 |
coding | Solve the programming task below in a Python markdown code block.
In this Kata, you will be given an array of arrays and your task will be to return the number of unique arrays that can be formed by picking exactly one element from each subarray.
For example: `solve([[1,2],[4],[5,6]]) = 4`, because it results in only... | {"functional": "_inputs = [[[[1, 2], [4], [5, 6]]], [[[1, 2], [4, 4], [5, 6, 6]]], [[[1, 2], [3, 4], [5, 6]]], [[[1, 2, 3], [3, 4, 6, 6, 7], [8, 9, 10, 12, 5, 6]]]]\n_outputs = [[4], [4], [8], [72]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return math.is... | 334 | 264 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given a list of blocks, where blocks[i] = t means that the i-th block needs t units of time to be built. A block can only be built by exactly one worker.
A worker can either split into two workers (number of w... | {"functional": "def check(candidate):\n assert candidate(blocks = [1], split = 1) == 1\n assert candidate(blocks = [1,2], split = 5) == 7\n assert candidate(blocks = [1,2,3], split = 1) == 4\n\n\ncheck(Solution().minBuildTime)"} | 186 | 77 |
coding | Solve the programming task below in a Python markdown code block.
An array $b$ of length $k$ is called good if its arithmetic mean is equal to $1$. More formally, if $$\frac{b_1 + \cdots + b_k}{k}=1.$$
Note that the value $\frac{b_1+\cdots+b_k}{k}$ is not rounded up or down. For example, the array $[1,1,1,2]$ has an a... | {"inputs": ["1\n1\n1\n", "4\n3\n1 1 1\n2\n1 2\n4\n8 4 6 2\n1\n-2\n"], "outputs": ["0\n", "0\n1\n16\n1\n"]} | 557 | 62 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given an array nums of distinct positive integers, return the number of tuples (a, b, c, d) such that a * b = c * d where a, b, c, and d are elements of nums, and a != b != c != d.
Please complete the following pyth... | {"functional": "def check(candidate):\n assert candidate(nums = [2,3,4,6]) == 8\n assert candidate(nums = [1,2,4,5,10]) == 16\n\n\ncheck(Solution().tupleSameProduct)"} | 104 | 60 |
coding | Solve the programming task below in a Python markdown code block.
As a token of his gratitude, Takahashi has decided to give his mother an integer sequence. The sequence A needs to satisfy the conditions below:
* A consists of integers between X and Y (inclusive).
* For each 1\leq i \leq |A|-1, A_{i+1} is a multiple o... | {"inputs": ["4 7", "4 20", "4 37", "2 37", "6 20", "2 57", "1 67", "1 54"], "outputs": ["1\n", "3\n", "4\n", "5\n", "2\n", "5\n", "7\n", "6\n"]} | 218 | 85 |
coding | Solve the programming task below in a Python markdown code block.
Timur likes his name. As a spelling of his name, he allows any permutation of the letters of the name. For example, the following strings are valid spellings of his name: Timur, miurT, Trumi, mriTu. Note that the correct spelling must have uppercased T a... | {"inputs": ["1\n6\nTimura\n", "10\n5\nTimur\n5\nmiurT\n5\nTrumi\n5\nmriTu\n5\ntimur\n4\nTimr\n6\nTimuur\n10\ncodeforces\n10\nTimurTimur\n5\nTIMUR\n"], "outputs": ["NO\n", "YES\nYES\nYES\nYES\nNO\nNO\nNO\nNO\nNO\nNO\n"]} | 374 | 104 |
coding | Solve the programming task below in a Python markdown code block.
Consider the number `1176` and its square (`1176 * 1176) = 1382976`. Notice that:
* the first two digits of `1176` form a prime.
* the first two digits of the square `1382976` also form a prime.
* the last two digits of `1176` and `1382976` are the same... | {"functional": "_inputs = [[2, 1200], [1176, 1200], [2, 100000], [2, 1000000], [100000, 1000000]]\n_outputs = [[1], [1], [247], [2549], [2302]]\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 isinstanc... | 364 | 232 |
coding | Solve the programming task below in a Python markdown code block.
You are given an array (which will have a length of at least 3, but could be very large) containing integers. The array is either entirely comprised of odd integers or entirely comprised of even integers except for a single integer `N`. Write a method th... | {"functional": "_inputs = [[[0, 1, 2]], [[1, 2, 3]]]\n_outputs = [[1], [2]]\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 ... | 199 | 173 |
coding | Solve the programming task below in a Python markdown code block.
Nikolay has a lemons, b apples and c pears. He decided to cook a compote. According to the recipe the fruits should be in the ratio 1: 2: 4. It means that for each lemon in the compote should be exactly 2 apples and exactly 4 pears. You can't crumble up,... | {"inputs": ["2\n5\n7\n", "2\n3\n2\n", "1\n1\n1\n", "1\n2\n4\n", "1\n1\n4\n", "1\n2\n3\n", "2\n3\n8\n", "1\n2\n8\n"], "outputs": ["7\n", "0\n", "0\n", "7\n", "0\n", "0\n", "7\n", "7\n"]} | 434 | 102 |
coding | Solve the programming task below in a Python markdown code block.
Bill Gates is on one of his philanthropic journeys to a village in Utopia. He has brought a box of packets of candies and would like to distribute one packet to each of the children. Each of the packets contains a number of candies. He wants to minimiz... | {"inputs": ["7\n3\n10\n100\n300\n200\n1000\n20\n30\n", "10\n4\n1\n2\n3\n4\n10\n20\n30\n40\n100\n200\n"], "outputs": ["40\n", "10\n"]} | 681 | 83 |
coding | Solve the programming task below in a Python markdown code block.
If you have not ever heard the term **Arithmetic Progrossion**, refer to:
http://www.codewars.com/kata/find-the-missing-term-in-an-arithmetic-progression/python
And here is an unordered version. Try if you can survive lists of **MASSIVE** numbers (whic... | {"functional": "_inputs = [[[3, 9, 1, 11, 13, 5]], [[5, -1, 0, 3, 4, -3, 2, -2]], [[2, -2, 8, -8, 4, -4, 6, -6]]]\n_outputs = [[7], [1], [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, rel_tol=tol, abs_tol=tol)\n if isinstance(... | 193 | 224 |
coding | Solve the programming task below in a Python markdown code block.
Mohit's girlfriend is playing a game with Nicky. The description of the game is as follows:
- Initially on a table Player 1 will put N gem-stones.
- Players will play alternatively, turn by turn.
- At each move a player can take at most M gem-stones (at ... | {"inputs": ["4 2"], "outputs": ["2"]} | 411 | 14 |
coding | Solve the programming task below in a Python markdown code block.
Here, we want to solve path planning for a mobile robot cleaning a rectangular room floor with furniture.
Consider the room floor paved with square tiles whose size fits the cleaning robot (1 × 1). There are 'clean tiles' and 'dirty tiles', and the robo... | {"inputs": ["7 5\n.......\n.o...*.\n.......\n.*...*.\n.......\n15 13\n.......x.......\n...o...x....*..\n.......x.......\n.......x.......\n.......x.......\n.-.............\nxxxxx.....xxxxx\n...............\n.......x.......\n.......x.......\n.......x.......\n..*....x....*..\n.......x.......\n10 10\n..........\n..o.......... | 609 | 1,304 |
coding | Solve the programming task below in a Python markdown code block.
In an attempt to escape the Mischievous Mess Makers' antics, Farmer John has abandoned his farm and is traveling to the other side of Bovinia. During the journey, he and his k cows have decided to stay at the luxurious Grand Moo-dapest Hotel. The hotel c... | {"inputs": ["2 1\n00\n", "2 1\n00\n", "3 2\n000\n", "3 1\n010\n", "3 1\n010\n", "3 1\n000\n", "3 1\n001\n", "2 1\n001\n"], "outputs": ["1\n", "1\n", "1\n", "2\n", "2\n", "1\n", "1\n", "1\n"]} | 509 | 116 |
coding | Solve the programming task below in a Python markdown code block.
Chef has an array of N integers. He wants to play a special game. In this game he needs to make all the integers in the array greater than or equal to 0.
Chef can use two types of operations. The first type is to increase all the integers of the given ... | {"inputs": ["3\n2 3 0\n2", "3\n2 3 0\n3", "3\n2 3 0\n6", "3\n0 1 -2\n4", "3\n1 0 -1\n3", "3\n1 1 -7\n1", "3\n1 1 -9\n1", "3\n0 0 -2\n4"], "outputs": ["0\n", "0\n", "0\n", "2\n", "1\n", "7\n", "9\n", "2\n"]} | 309 | 126 |
coding | Solve the programming task below in a Python markdown code block.
Akari has n kinds of flowers, one of each kind.
She is going to choose one or more of these flowers to make a bouquet.
However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b.
How many different bouquets are there... | {"inputs": ["4 0 3", "7 1 3", "4 0 4", "7 2 3", "3 2 3", "4 1 3", "4 1 3\n", "2 1 2\n"], "outputs": ["10\n", "85\n", "13\n", "71\n", "3\n", "7", "7\n", "0\n"]} | 312 | 99 |
coding | Solve the programming task below in a Python markdown code block.
You are given a string $t$ and a set $S$ of $N$ different strings. You need to separate $t$ such that each part is included in $S$.
For example, the following 4 separation methods satisfy the condition when $t = abab$ and $S = \\{a, ab, b\\}$.
* $a,b,a... | {"inputs": ["3\na\nb\nc\nxy{", "3\nb\nb\nc\nxy{", "3\nb\nb\nc\nyx{", "3\nb\nb\nc\nxx{", "3\nb\nb\nd\nxx{", "3\nb\nb\nd\nx{x", "3\nb\na\nd\nx{x", "3\na\nb\nc\nzyx"], "outputs": ["0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n"]} | 517 | 134 |
coding | Solve the programming task below in a Python markdown code block.
Write a function that when given a URL as a string, parses out just the domain name and returns it as a string. For example:
```python
domain_name("http://github.com/carbonfive/raygun") == "github"
domain_name("http://www.zombie-bites.com") == "zombie-b... | {"functional": "_inputs = [['http://google.com'], ['http://google.co.jp'], ['https://123.net'], ['https://hyphen-site.org'], ['http://codewars.com'], ['www.xakep.ru'], ['https://youtube.com'], ['http://www.codewars.com/kata/'], ['icann.org']]\n_outputs = [['google'], ['google'], ['123'], ['hyphen-site'], ['codewars'], ... | 120 | 253 |
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 |
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 tree with $N$ nodes (numbered $1$ through $N$) and a non-negative integer $x$. The nodes of the tree have non-negative integer weights; le... | {"inputs": ["7 1\n1 0 1 0 1 0 1 \n1 2\n1 3\n2 4\n2 5\n3 6\n3 7"], "outputs": ["5"]} | 694 | 53 |
coding | Solve the programming task below in a Python markdown code block.
A key feature of the Siruseri railway network is that it has exactly one route between any pair of stations.
The government has chosen three contractors to run the canteens at the stations on the railway network. To ensure that there are no disputes betw... | {"inputs": ["6\n10\n20\n25\n40\n30\n30\n4 5\n1 3\n3 4\n2 3\n6 4"], "outputs": ["70"]} | 688 | 51 |
coding | Solve the programming task below in a Python markdown code block.
There are n cities in the country where the Old Peykan lives. These cities are located on a straight line, we'll denote them from left to right as c_1, c_2, ..., c_{n}. The Old Peykan wants to travel from city c_1 to c_{n} using roads. There are (n - 1) ... | {"inputs": ["2 3\n5 6\n5 5\n", "2 3\n5 6\n4 5\n", "2 3\n5 6\n4 1\n", "2 3\n5 1\n6 2\n", "2 3\n5 0\n9 2\n", "2 3\n2 1\n9 2\n", "2 3\n5 6\n4 2\n", "2 3\n5 6\n6 2\n"], "outputs": ["14\n", "14\n", "17\n", "6\n", "5\n", "3\n", "17\n", "14\n"]} | 532 | 155 |
coding | Solve the programming task below in a Python markdown code block.
Read problems statements in [Mandarin Chinese], [Russian], [Vietnamese] and [Bengali] as well.
Chefland is holding a virtual marathon for the categories 10 km, 21 km and 42 km having prizes A, B, C (A < B < C) respectively to promote physical fitness. I... | {"inputs": ["3\n1 1 1 2 3\n10 1 1 2 3\n10 3 1 2 3"], "outputs": ["0\n1\n2"]} | 494 | 48 |
coding | Solve the programming task below in a Python markdown code block.
This is a beginner friendly kata especially for UFC/MMA fans.
It's a fight between the two legends: Conor McGregor vs George Saint Pierre in Madison Square Garden. Only one fighter will remain standing, and after the fight in an interview with Joe Roga... | {"functional": "_inputs = [['George Saint Pierre'], ['Conor McGregor'], ['george saint pierre'], ['conor mcgregor']]\n_outputs = [['I am not impressed by your performance.'], [\"I'd like to take this chance to apologize.. To absolutely NOBODY!\"], ['I am not impressed by your performance.'], [\"I'd like to take this ch... | 162 | 229 |
coding | Solve the programming task below in a Python markdown code block.
Makes solves problems on Decoforces and lots of other different online judges. Each problem is denoted by its difficulty — a positive integer number. Difficulties are measured the same across all the judges (the problem with difficulty d on Decoforces is... | {"inputs": ["1 1\n3\n", "1 1\n2\n", "1 1\n4\n", "1 4\n9\n", "1 2\n9\n", "1 2\n9\n", "1 1\n4\n", "1 1\n3\n"], "outputs": ["1\n", "0\n", "1\n", "1\n", "2\n", "2", "1", "1"]} | 539 | 99 |
coding | Solve the programming task below in a Python markdown code block.
Once Volodya was at the museum and saw a regular chessboard as a museum piece. And there were only four chess pieces on it: two white rooks, a white king and a black king. "Aha, blacks certainly didn't win!", — Volodya said and was right for sure. And yo... | {"inputs": ["e8 e7 d8 g8\n", "b3 a8 d3 a3\n", "b2 c2 b3 b1\n", "c6 b2 g6 b4\n", "a5 c5 c3 a1\n", "d4 e5 b7 a5\n", "e8 e7 f8 h8\n", "h7 h8 c7 a8\n"], "outputs": ["CHECKMATE\n", "OTHER\n", "OTHER\n", "OTHER\n", "OTHER\n", "CHECKMATE\n", "OTHER\n", "OTHER\n"]} | 405 | 130 |
coding | Solve the programming task below in a Python markdown code block.
Everybody knows that the m-coder Tournament will happen soon. m schools participate in the tournament, and only one student from each school participates.
There are a total of n students in those schools. Before the tournament, all students put their na... | {"inputs": ["1 1 1\n1\n1\n1\n", "1 1 1\n2\n1\n1\n", "2 1 1\n1 2\n1 1\n1\n", "2 1 1\n1 2\n1 1\n2\n", "5 1 1\n4 3 2 1 5\n1 1 1 1 1\n5\n", "5 1 1\n4 3 2 1 5\n1 1 1 1 1\n1\n", "7 3 1\n1 5 3 4 6 7 2\n1 3 1 2 1 2 2\n3\n", "7 3 1\n1 5 3 4 6 7 2\n1 1 1 2 1 2 3\n3\n"], "outputs": ["0\n", "0\n", "1\n", "0\n", "0\n", "1\n", "1\n"... | 737 | 238 |
coding | Solve the programming task below in a Python markdown code block.
Devu and his brother love each other a lot. As they are super geeks, they only like to play with arrays. They are given two arrays a and b by their father. The array a is given to Devu and b to his brother.
As Devu is really a naughty kid, he wants the... | {"inputs": ["1 1\n1\n2\n", "1 1\n1\n1\n", "1 1\n2\n1\n", "1 1\n1\n2\n", "1 1\n1\n3\n", "1 1\n2\n1\n", "1 1\n1\n1\n", "1 1\n1\n2\n"], "outputs": ["1\n", "0\n", "0\n", "1\n", "2\n", "0\n", "0\n", "1\n"]} | 473 | 118 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given n points on a 2D plane where points[i] = [xi, yi], Return the widest vertical area between two points such that no points are inside the area.
A vertical area is an area of fixed-width extending infinitely along... | {"functional": "def check(candidate):\n assert candidate(points = [[8,7],[9,9],[7,4],[9,7]]) == 1\n assert candidate(points = [[3,1],[9,0],[1,0],[1,4],[5,3],[8,8]]) == 3\n\n\ncheck(Solution().maxWidthOfVerticalArea)"} | 140 | 82 |
coding | Solve the programming task below in a Python markdown code block.
Devu is a renowned classical singer. He is invited to many big functions/festivals. Recently he was invited to "All World Classical Singing Festival". Other than Devu, comedian Churu was also invited.
Devu has provided organizers a list of the songs and... | {"inputs": ["1 1\n1\n", "1 6\n1\n", "1 5\n1\n", "1 3\n4\n", "1 6\n1\n", "1 3\n4\n", "1 1\n1\n", "1 5\n1\n"], "outputs": ["0\n", "1\n", "0\n", "-1\n", "1\n", "-1\n", "0\n", "0\n"]} | 584 | 102 |
coding | Solve the programming task below in a Python markdown code block.
The only difference between easy and hard versions is the length of the string.
You are given a string $s$ and a string $t$, both consisting only of lowercase Latin letters. It is guaranteed that $t$ can be obtained from $s$ by removing some (possibly, ... | {"inputs": ["m\nm\n", "m\nm\n", "td\nt\n", "aa\na\n", "td\nt\n", "ba\na\n", "ba\nb\n", "bb\nb\n"], "outputs": ["0\n", "0", "1\n", "1", "1", "1\n", "1\n", "1\n"]} | 471 | 83 |
coding | Solve the programming task below in a Python markdown code block.
Given a mixed array of number and string representations of integers, add up the string integers and subtract this from the total of the non-string integers.
Return as a number.
Also feel free to reuse/extend the following starter code:
```python
def d... | {"functional": "_inputs = [[[9, 3, '7', '3']], [['5', '0', 9, 3, 2, 1, '9', 6, 7]], [['3', 6, 6, 0, '5', 8, 5, '6', 2, '0']], [['1', '5', '8', 8, 9, 9, 2, '3']], [[8, 0, 0, 8, 5, 7, 2, 3, 7, 8, 6, 7]]]\n_outputs = [[2], [14], [13], [11], [61]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or ... | 69 | 296 |
coding | Solve the programming task below in a Python markdown code block.
Read problems statements in Mandarin Chinese and Russian.
Chef loves brackets. So much so, that rather than just use plain brackets like (), {}, or [], he has invented his own notation that allows him to use many more types of brackets.
Each type of ... | {"inputs": ["11\n-1 -2 9 2 -3 -4 3 4 8 8 1 "], "outputs": ["12"]} | 524 | 38 |
coding | Solve the programming task below in a Python markdown code block.
Dhote and Shweta went on a tour by plane for the first time.Dhote was surprised by the conveyor belt at the airport.As Shweta was getting bored Dhote had an idea of playing a game with her.He asked Shweta to count the number of bags whose individual wei... | {"inputs": ["1\n4\n1 2 3 4"], "outputs": ["3"]} | 291 | 22 |
coding | Solve the programming task below in a Python markdown code block.
You are given an array A of length N.
You can perform the following operation on the array any number of times:
Choose any [subsequence] S of the array A and a positive integer X such that X is a power of 2 and subtract X from all the elements of the s... | {"inputs": ["4\n3\n2 2 2\n4\n2 2 2 4\n2\n0 0\n3\n1 2 3\n"], "outputs": ["1\n2\n0\n2\n"]} | 540 | 52 |
coding | Solve the programming task below in a Python markdown code block.
Help Johnny!
He can't make his code work!
Easy Code
Johnny is trying to make a function that adds the sum of two encoded strings, but he can't find the error in his code! Help him!
Also feel free to reuse/extend the following starter code:
```python
def ... | {"functional": "_inputs = [['a', 'b']]\n_outputs = [[195]]\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(_... | 81 | 158 |
coding | Solve the programming task below in a Python markdown code block.
We have an H-by-W matrix. Let a_{ij} be the element at the i-th row from the top and j-th column from the left. In this matrix, each a_{ij} is a lowercase English letter.
Snuke is creating another H-by-W matrix, A', by freely rearranging the elements in... | {"inputs": ["1 1\ny", "1 1\nz", "2 2\nba\nbb", "2 2\nab\nbb", "2 2\naa\nbc", "2 2\nbb\nbb", "2 0\nbb\nbb", "2 2\naa\nbb"], "outputs": ["Yes\n", "Yes", "No\n", "No\n", "No\n", "Yes\n", "Yes\n", "No"]} | 299 | 104 |
coding | Solve the programming task below in a Python markdown code block.
RSJ has a sequence $a$ of $n$ integers $a_1,a_2, \ldots, a_n$ and an integer $s$. For each of $a_2,a_3, \ldots, a_{n-1}$, he chose a pair of non-negative integers $x_i$ and $y_i$ such that $x_i+y_i=a_i$ and $(x_i-s) \cdot (y_i-s) \geq 0$.
Now he is inte... | {"inputs": ["10\n5 0\n2 0 1 3 4\n5 1\n5 3 4 3 5\n7 2\n7 6 5 4 3 2 1\n5 1\n1 2 3 4 5\n5 2\n1 2 3 4 5\n4 0\n0 1 1 1\n5 5\n4 3 5 6 4\n4 1\n0 2 1 0\n3 99999\n200000 200000 200000\n6 8139\n7976 129785 12984 78561 173685 15480\n"], "outputs": ["0\n18\n32\n11\n14\n0\n16\n0\n40000000000\n2700826806\n"]} | 714 | 242 |
coding | Solve the programming task below in a Python markdown code block.
There are n psychos standing in a line. Each psycho is assigned a unique integer from 1 to n. At each step every psycho who has an id greater than the psycho to his right (if exists) kills his right neighbor in the line. Note that a psycho might kill and... | {"inputs": ["1\n1\n", "1\n1\n", "2\n1 2\n", "2\n2 1\n", "2\n1 2\n", "2\n2 1\n", "6\n1 2 3 4 5 6\n", "6\n6 5 4 3 2 1\n"], "outputs": ["0\n", "0\n", "0\n", "1\n", "0\n", "1\n", "0\n", "1\n"]} | 326 | 114 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given a m x n binary matrix mat, find the 0-indexed position of the row that contains the maximum count of ones, and the number of ones in that row.
In case there are multiple rows that have the maximum count of ones,... | {"functional": "def check(candidate):\n assert candidate(mat = [[0,1],[1,0]]) == [0,1]\n assert candidate(mat = [[0,0,0],[0,1,1]]) == [1,2]\n assert candidate(mat = [[0,0],[1,1],[0,0]]) == [1,2]\n\n\ncheck(Solution().rowAndMaximumOnes)"} | 132 | 93 |
coding | Solve the programming task below in a Python markdown code block.
You are asked to watch your nephew who likes to play with toy blocks in a strange way.
He has $n$ boxes and the $i$-th box has $a_i$ blocks. His game consists of two steps:
he chooses an arbitrary box $i$;
he tries to move all blocks from the $i$-th b... | {"inputs": ["1\n3\n1000 1000 1001\n", "1\n3\n1000 1000 1001\n", "1\n3\n0000 1000 1001\n", "1\n3\n1000 1001 1001\n", "1\n3\n0000 1000 1000\n", "1\n3\n1000 1001 0001\n", "1\n3\n0001 1000 1000\n", "1\n2\n1000000000 1000000000\n"], "outputs": ["1\n", "1\n", "1\n", "0\n", "0\n", "0\n", "1\n", "0\n"]} | 610 | 213 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given an integer array nums of positive integers, return the average value of all even integers that are divisible by 3.
Note that the average of n elements is the sum of the n elements divided by n and rounded down t... | {"functional": "def check(candidate):\n assert candidate(nums = [1,3,6,10,12,15]) == 9\n assert candidate(nums = [1,2,4,7,10]) == 0\n\n\ncheck(Solution().averageValue)"} | 97 | 65 |
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 fewest number of coins that you need to make up that amount. If... | {"functional": "def check(candidate):\n assert candidate(coins = [1, 2, 5], amount = 11) == 3 \n assert candidate(coins = [2], amount = 3) == -1\n assert candidate(coins = [1], amount = 0) == 0\n\n\ncheck(Solution().coinChange)"} | 127 | 81 |
coding | Solve the programming task below in a Python markdown code block.
Vasya commutes by train every day. There are n train stations in the city, and at the i-th station it's possible to buy only tickets to stations from i + 1 to a_{i} inclusive. No tickets are sold at the last station.
Let ρ_{i}, j be the minimum number o... | {"inputs": ["2\n2\n", "2\n2\n", "3\n3 3\n", "3\n3 3\n", "3\n2 3\n", "4\n4 4 4\n", "4\n3 3 4\n", "4\n3 3 4\n"], "outputs": ["1\n", "1\n", "3\n", "3\n", "4\n", "6\n", "8\n", "8\n"]} | 495 | 104 |
coding | Solve the programming task below in a Python markdown code block.
MoEngage has 3 decks. Each deck consists of N cards, numbered from 1 to N. He draws out 1 card from each deck randomly with each card having an equal probability of being drawn.
MoEngage drew cards numbered A and B from the decks 1 and 2 respectively. N... | {"inputs": ["3\n4 2 3\n6 2 1\n5 2 5\n"], "outputs": ["2\n1\n0\n"]} | 508 | 36 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given an integer array nums, return an integer array counts where counts[i] is the number of smaller elements to the right of nums[i].
Please complete the following python code precisely:
```python
class Solution:
... | {"functional": "def check(candidate):\n assert candidate(nums = [5,2,6,1]) == [2,1,1,0] \n assert candidate(nums = [-1]) == [0]\n assert candidate(nums = [-1,-1]) == [0,0]\n\n\ncheck(Solution().countSmaller)"} | 78 | 76 |
coding | Solve the programming task below in a Python markdown code block.
A string S is called *Chef's favourite* if every substring chef in S must have a substring code before it.
You are given a string S of size N that contains both code and chef as a substring. Please determine if S is Chef's favourite.
Note: A substring ... | {"inputs": ["4\n8\ncodechef\n8\nchefcode\n14\nsxycodeghychef\n21\nsxychefvsvcodehghchef\n"], "outputs": ["AC\nWA\nAC\nWA\n"]} | 374 | 54 |
coding | Solve the programming task below in a Python markdown code block.
Takahashi is standing on a two-dimensional plane, facing north. Find the minimum positive integer K such that Takahashi will be at the starting position again after he does the following action K times:
* Go one meter in the direction he is facing. Then... | {"inputs": ["2", "4", "3", "5", "8", "6", "1", "33"], "outputs": ["180\n", "90\n", "120\n", "72\n", "45\n", "60\n", "360", "120\n"]} | 155 | 74 |
coding | Solve the programming task below in a Python markdown code block.
There are three airports A, B and C, and flights between each pair of airports in both directions.
A one-way flight between airports A and B takes P hours, a one-way flight between airports B and C takes Q hours, and a one-way flight between airports C a... | {"inputs": ["3 1 3", "2 3 4", "3 1 2", "3 1 0", "1 1 3", "3 0 0", "1 6 5", "1 6 6"], "outputs": ["4\n", "5\n", "3\n", "1\n", "2\n", "0\n", "6\n", "7\n"]} | 361 | 94 |
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.
Consider a sequence $A_{1}, A_{2}, \ldots, A_{N}$, where initially, $A_{i} = i$ for each valid $i$. You may perform any number of operations on this ... | {"inputs": ["2\n3\n1 2 2\n4\n1 2 3 2"], "outputs": ["NO\nYES"]} | 567 | 32 |
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, you are asked to construct the array ans of size n-k+1 where ans[i] is the number of distinct numbers in the subarray nums[i:i+k-1] = [nums[i], nums[i+1], ..., nums[i+k-1]... | {"functional": "def check(candidate):\n assert candidate(nums = [1,2,3,2,2,1,3], k = 3) == [3,2,2,2,3]\n assert candidate(nums = [1,1,1,1,2,3,4], k = 4) == [1,2,3,4]\n\n\ncheck(Solution().distinctNumbers)"} | 121 | 93 |
coding | Solve the programming task below in a Python markdown code block.
Since you are the best Wraith King, Nizhniy Magazin «Mir» at the centre of Vinnytsia is offering you a discount.
You are given an array a of length n and an integer c.
The value of some array b of length k is the sum of its elements except for the $\l... | {"inputs": ["1 1\n1\n", "1 1\n1\n", "1 1\n0\n", "3 5\n1 2 3\n", "3 5\n1 2 3\n", "7 2\n2 3 6 4 5 7 1\n", "7 2\n2 2 6 4 5 7 1\n", "7 2\n2 3 6 4 5 7 1\n"], "outputs": ["0\n", "0\n", "0\n", "6\n", "6\n", "17\n", "16\n", "17\n"]} | 535 | 149 |
coding | Solve the programming task below in a Python markdown code block.
You are given an integer N. Find the number of strings of length N that satisfy the following conditions, modulo 10^9+7:
- The string does not contain characters other than A, C, G and T.
- The string does not contain AGC as a substring.
- The conditi... | {"inputs": ["5", "6", "8", "9", "7", "6", "5", "4"], "outputs": ["865\n", "3247\n", "45719\n", "171531\n", "12185\n", "3247\n", "865\n", "230"]} | 281 | 86 |
coding | Solve the programming task below in a Python markdown code block.
In this task Anna and Maria play a game with a very unpleasant rival. Anna and Maria are in the opposite squares of a chessboard (8 × 8): Anna is in the upper right corner, and Maria is in the lower left one. Apart from them, the board has several statue... | {"inputs": ["S......A\n.SS..S..\nS....S..\nSSS...S.\n.SS.SSS.\n.S.SS...\n..S..S..\nM.SS....\n", "SSSSSSSA\n......S.\n......S.\n.....SS.\n....SS..\n...SS...\n..SS....\nMSS.....\n", "S..SSSSA\n.S..S...\nS.S....S\nSS..S.S.\nSSSS.S..\n.SS..SS.\n....SS..\nMS..S...\n", "...SSS.A\n.....S..\n..S.S.SS\n.S.S...S\nS.S...S.\n....S... | 570 | 350 |
coding | Solve the programming task below in a Python markdown code block.
Complete the function/method so that it takes CamelCase string and returns the string in snake_case notation. Lowercase characters can be numbers. If method gets number, it should return string.
Examples:
``` javascript
// returns test_controller
toUn... | {"functional": "_inputs = [['TestController'], ['ThisIsBeautifulDay'], ['Am7Days'], ['My3CodeIs4TimesBetter'], [5]]\n_outputs = [['test_controller'], ['this_is_beautiful_day'], ['am7_days'], ['my3_code_is4_times_better'], ['5']]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, f... | 198 | 205 |
coding | Solve the programming task below in a Python markdown code block.
Chef's college is conducting online exams. Chef has a test tomorrow and he being irresponsible failed to prepare for it on time (just as always). However, fortunately, he now realises the gravity of the situation and decides to prepare as much as possibl... | {"inputs": ["3\n2 2\n1 1\n2 1\n3 3\n1 1\n2 2\n3 3\n5 6\n5 1\n4 2\n3 3\n2 4\n1 5"], "outputs": ["2\n2\n9"]} | 609 | 68 |
coding | Solve the programming task below in a Python markdown code block.
It is known that each weight of 1 gram, 3 gram, 9 gram, and 27 gram can be weighed from 1 gram to 40 gram in 1 gram increments using a balance. For example, if you put a weight of 3 grams and a weight you want to weigh on one plate of the balance and a w... | {"inputs": ["9", "1", "2", "3", "5", "7", "4", "6"], "outputs": ["+00\n", "+\n", "+-\n", "+0\n", "+--\n", "+-+\n", "++\n", "+-0\n"]} | 630 | 68 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given an array points representing integer coordinates of some points on a 2D-plane, where points[i] = [xi, yi].
The cost of connecting two points [xi, yi] and [xj, yj] is the manhattan distance between them: ... | {"functional": "def check(candidate):\n assert candidate(points = [[0,0],[2,2],[3,10],[5,2],[7,0]]) == 20\n assert candidate(points = [[3,12],[-2,5],[-4,1]]) == 18\n assert candidate(points = [[0,0],[1,1],[1,0],[-1,1]]) == 4\n assert candidate(points = [[-1000000,-1000000],[1000000,1000000]]) == 4000000\n ... | 158 | 166 |
coding | Solve the programming task below in a Python markdown code block.
A product-sum number is a natural number N which can be expressed as both the product and the sum of the same set of numbers.
N = a1 × a2 × ... × ak = a1 + a2 + ... + ak
For example, 6 = 1 × 2 × 3 = 1 + 2 + 3.
For a given set of size, k, we shall call... | {"functional": "_inputs = [[3], [6], [12], [2]]\n_outputs = [[10], [30], [61], [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(a) != len(b): return Fa... | 401 | 176 |
coding | Solve the programming task below in a Python markdown code block.
Little C loves number «3» very much. He loves all things about it.
Now he is playing a game on a chessboard of size n × m. The cell in the x-th row and in the y-th column is called (x,y). Initially, The chessboard is empty. Each time, he places two ches... | {"inputs": ["3 7\n", "4 3\n", "1 4\n", "2 1\n", "1 8\n", "7 2\n", "7 1\n", "2 5\n"], "outputs": ["20\n", "12\n", "2\n", "0\n", "6\n", "12\n", "6\n", "10\n"]} | 311 | 90 |
coding | Solve the programming task below in a Python markdown code block.
Challenge:
Given two null-terminated strings in the arguments "string" and "prefix", determine if "string" starts with the "prefix" string. Return 1 (or any other "truthy" value) if true, 0 if false.
Example:
```
startsWith("hello world!", "hello"); // ... | {"functional": "_inputs = [['hello world!', 'hello'], ['hello world!', 'HELLO'], ['nowai', 'nowaisir'], ['', ''], ['abc', ''], ['', 'abc']]\n_outputs = [[True], [False], [False], [True], [True], [False]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return ma... | 278 | 203 |
coding | Solve the programming task below in a Python markdown code block.
Ksusha is a beginner coder. Today she starts studying arrays. She has array a_1, a_2, ..., a_{n}, consisting of n positive integers.
Her university teacher gave her a task. Find such number in the array, that all array elements are divisible by it. Help... | {"inputs": ["2\n4 6\n", "2\n6 8\n", "2\n6 4\n", "2\n6 4\n", "2\n4 6\n", "2\n6 8\n", "2\n6 3\n", "2\n6 6\n"], "outputs": ["-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "3\n", "6\n"]} | 245 | 103 |
coding | Solve the programming task below in a Python markdown code block.
ChefTown is the biggest city and the capital of ChefLand. There are N beautiful buildings: restaurants, museums, living houses with large kitchens and so on. Every building has its height. For every i (1≤i≤N) there is exactly one building with height i. ... | {"inputs": ["2 1\n2 1", "4 2\n1 2 3 4"], "outputs": ["2", "3"]} | 490 | 34 |
coding | Solve the programming task below in a Python markdown code block.
Johnny has a younger sister Anne, who is very clever and smart. As she came home from the kindergarten, she told his brother about the task that her kindergartener asked her to solve. The task was just to construct a triangle out of four sticks of differ... | {"inputs": ["4 4 4 5\n", "3 1 2 1\n", "1 5 1 3\n", "3 5 1 1\n", "1 5 5 5\n", "8 4 3 1\n", "3 3 3 1\n", "1 1 2 1\n"], "outputs": ["TRIANGLE\n", "SEGMENT\n", "IMPOSSIBLE\n", "IMPOSSIBLE\n", "TRIANGLE\n", "SEGMENT\n", "TRIANGLE\n", "TRIANGLE\n"]} | 359 | 134 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
There is a hidden integer array arr that consists of n non-negative integers.
It was encoded into another integer array encoded of length n - 1, such that encoded[i] = arr[i] XOR arr[i + 1]. For example, if arr = [1,0... | {"functional": "def check(candidate):\n assert candidate(encoded = [1,2,3], first = 1) == [1,0,2,1]\n assert candidate(encoded = [6,2,7,3], first = 4) == [4,2,0,7,4]\n\n\ncheck(Solution().decode)"} | 171 | 78 |
coding | Solve the programming task below in a Python markdown code block.
You are going to be given a word. Your job is to return the middle character of the word. If the word's length is odd, return the middle character. If the word's length is even, return the middle 2 characters.
#Examples:
~~~if-not:bf
```
Kata.getMiddle(... | {"functional": "_inputs = [['test'], ['testing'], ['middle'], ['A'], ['of']]\n_outputs = [['es'], ['t'], ['dd'], ['A'], ['of']]\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... | 300 | 178 |
coding | Solve the programming task below in a Python markdown code block.
A checksum is an algorithm that scans a packet of data and returns a single number. The idea is that if the packet is changed, the checksum will also change, so checksums are often used for detecting
transmission errors, validating document contents, and... | {"functional": "_inputs = [['ACM'], ['MID CENTRAL'], ['BBC'], ['???'], ['axg '], ['234 234 WEF ASDF AAA 554211 ???? '], ['A C M'], ['ABCDEFGHIJKLMNOPQRSTUVWXYZ'], ['A B C D E F G H I J K L M N O P Q R S T U V W X Y Z'], ['ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ... | 333 | 460 |
coding | Solve the programming task below in a Python markdown code block.
Bob recently read about bitwise operations used in computers: AND, OR and XOR. He have studied their properties and invented a new game.
Initially, Bob chooses integer m, bit depth of the game, which means that all numbers in the game will consist of m ... | {"inputs": ["1 6\na := ? OR ?\n", "1 6\na := ? OR ?\n", "1 6\nb := ? OR ?\n", "1 3\na := 0110110011\n", "1 3\nb := 0110110011\n", "1 10\na := 0110110011\n", "1 10\na := 0110110011\n", "1 10\na := 0110110111\n"], "outputs": ["000000\n111111\n", "000000\n111111\n", "000000\n111111\n", "000\n000\n", "000\n000\n", "0000000... | 660 | 288 |
coding | Solve the programming task below in a Python markdown code block.
During a break in the buffet of the scientific lyceum of the Kingdom of Kremland, there was formed a queue of $n$ high school students numbered from $1$ to $n$. Initially, each student $i$ is on position $i$. Each student $i$ is characterized by two numb... | {"inputs": ["1\n55 7\n", "1\n86 7\n", "1\n86 9\n", "1\n86 4\n", "1\n86 3\n", "1\n86 0\n", "1\n49 0\n", "1\n55 60\n"], "outputs": ["0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0"]} | 627 | 110 |
coding | Solve the programming task below in a Python markdown code block.
Alice and Bob are playing a game on a line with n cells. There are n cells labeled from 1 through n. For each i from 1 to n-1, cells i and i+1 are adjacent.
Alice initially has a token on some cell on the line, and Bob tries to guess where it is.
Bob ... | {"inputs": ["1 2\n1 1\n", "6 3\n5 1 4\n", "6 3\n4 2 3\n", "9 3\n5 1 4\n", "6 3\n5 2 4\n", "6 3\n5 2 3\n", "6 3\n5 2 1\n", "6 3\n5 4 3\n"], "outputs": ["0\n", "12\n", "11\n", "21\n", "12\n", "12\n", "12\n", "11\n"]} | 722 | 139 |
coding | Solve the programming task below in a Python markdown code block.
# Task
Given an array `arr`, find the maximal value of `k` such `a[i] mod k` = `a[j] mod k` for all valid values of i and j.
If it's impossible to find such number (there's an infinite number of `k`s), return `-1` instead.
# Input/Output
`[input]` in... | {"functional": "_inputs = [[[1, 2, 3]], [[1, 1, 1]], [[5, 2, 8]], [[4, 1, 7]], [[1, 7, 13]], [[4, 5, 4]], [[5, 6, 7, 8]], [[10, 100]], [[64, 8, 1]], [[2, 9, 30]]]\n_outputs = [[1], [-1], [3], [3], [6], [1], [1], [90], [7], [7]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, fl... | 295 | 276 |
coding | Solve the programming task below in a Python markdown code block.
Humpy, the little elephant, has his birthday coming up. He invited all his cousins but doesn’t know how many of them are really coming as some of them are having exams coming up. He will only get to know how many of them are coming on the day of his birt... | {"inputs": ["2\n4 10 2\n2 2 3 1\n4 12 3\n6 5 7 3"], "outputs": ["YES\nNO"]} | 383 | 44 |
coding | Solve the programming task below in a Python markdown code block.
Little Dima misbehaved during a math lesson a lot and the nasty teacher Mr. Pickles gave him the following problem as a punishment.
Find all integer solutions x (0 < x < 10^9) of the equation:x = b·s(x)^{a} + c,
where a, b, c are some predetermined ... | {"inputs": ["3 2 8\n", "1 1 0\n", "4 4 6\n", "5 1 0\n", "1 1 0\n", "5 1 0\n", "4 4 6\n", "4 4 7\n"], "outputs": ["3\n10 2008 13726 ", "9\n1 2 3 4 5 6 7 8 9 ", "13\n10 1030 40006 114250 202506 262150 521290 937030 1562506 2458630 3694090 4743690 7496650 ", "5\n1 17210368 52521875 60466176 205962976 ", "9\n1 2 3 4 5 6 7 ... | 326 | 414 |
coding | Solve the programming task below in a Python markdown code block.
There are $n$ consecutive seat places in a railway carriage. Each place is either empty or occupied by a passenger.
The university team for the Olympiad consists of $a$ student-programmers and $b$ student-athletes. Determine the largest number of studen... | {"inputs": ["1 0 1\n.\n", "1 1 1\n.\n", "1 1 1\n.\n", "1 0 1\n.\n", "1 0 2\n.\n", "1 1 2\n.\n", "1 2 1\n.\n", "2 2 0\n..\n"], "outputs": ["1\n", "1\n", "1\n", "1\n", "1\n", "1\n", "1\n", "1\n"]} | 501 | 118 |
coding | Solve the programming task below in a Python markdown code block.
Appleman and Toastman play a game. Initially Appleman gives one group of n numbers to the Toastman, then they start to complete the following tasks:
* Each time Toastman gets a group of numbers, he sums up all the numbers and adds this sum to the scor... | {"inputs": ["1\n6\n", "1\n2\n", "1\n4\n", "1\n3\n", "1\n5\n", "1\n8\n", "1\n20\n", "1\n19\n"], "outputs": ["6\n", "2\n", "4\n", "3\n", "5\n", "8\n", "20\n", "19\n"]} | 523 | 90 |
coding | Solve the programming task below in a Python markdown code block.
In this Kata, you will be given a series of times at which an alarm goes off. Your task will be to determine the maximum time interval between alarms. Each alarm starts ringing at the beginning of the corresponding minute and rings for exactly one minute... | {"functional": "_inputs = [[['14:51']], [['23:00', '04:22', '18:05', '06:24']], [['21:14', '15:34', '14:51', '06:25', '15:30']]]\n_outputs = [['23:59'], ['11:40'], ['09:10']]\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,... | 231 | 241 |
coding | Solve the programming task below in a Python markdown code block.
The string $t_1t_2 \dots t_k$ is good if each letter of this string belongs to at least one palindrome of length greater than 1.
A palindrome is a string that reads the same backward as forward. For example, the strings A, BAB, ABBA, BAABBBAAB are palin... | {"inputs": ["3\nAAA\n", "3\nABA\n", "3\nBBB\n", "3\nBAA\n", "3\nAAB\n", "3\nBBA\n", "3\nBAB\n", "3\nABB\n"], "outputs": ["3\n", "1\n", "3\n", "1\n", "1\n", "1\n", "1\n", "1\n"]} | 523 | 90 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
LeetCode wants to give one of its best employees the option to travel among n cities to collect algorithm problems. But all work and no play makes Jack a dull boy, you could take vacations in some particular cities an... | {"functional": "def check(candidate):\n assert candidate(flights = [[0,1,1],[1,0,1],[1,1,0]], days = [[1,3,1],[6,0,3],[3,3,3]]) == 12\n assert candidate(flights = [[0,0,0],[0,0,0],[0,0,0]], days = [[1,1,1],[7,7,7],[7,7,7]]) == 3\n assert candidate(flights = [[0,1,1],[1,0,1],[1,1,0]], days = [[7,0,0],[0,7,0],[0... | 466 | 173 |
coding | Solve the programming task below in a Python markdown code block.
A Discrete Mathematics professor has a class of students. Frustrated with their lack of discipline, the professor decides to cancel class if fewer than some number of students are present when class starts. Arrival times go from on time ($arrivalTime\le... | {"inputs": ["2\n4 3\n-1 -3 4 2\n4 2\n0 -1 2 1\n"], "outputs": ["YES\nNO\n"]} | 598 | 41 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given a string n representing an integer, return the closest integer (not including itself), which is a palindrome. If there is a tie, return the smaller one.
The closest is defined as the absolute difference minimize... | {"functional": "def check(candidate):\n assert candidate(n = \"123\") == \"121\"\n assert candidate(n = \"1\") == \"0\"\n\n\ncheck(Solution().nearestPalindromic)"} | 96 | 52 |
coding | Solve the programming task below in a Python markdown code block.
Chef has N dishes of different types arranged in a row: A_{1}, A_{2}, \ldots, A_{N}, where A_{i} denotes the type of the i^{th} dish. He wants to choose as many dishes as possible from the given list but while satisfying two conditions:
1. He can choo... | {"inputs": ["3\n5\n1 2 2 1 2\n6\n1 1 1 1 1 1\n8\n1 2 2 2 3 4 2 1"], "outputs": ["1\n1\n2"]} | 626 | 60 |
coding | Solve the programming task below in a Python markdown code block.
Read problems statements in Mandarin Chinese, Russian and Vietnamese as well.
Given an array of size n, you have to answer queries of the form : L R k . For each query, you have to find an element which occurs consecutively in the subarray [L,R] more t... | {"inputs": ["5 1\n1 2 2 2 2\n1 5 3"], "outputs": ["2"]} | 390 | 30 |
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 integer matrix grid consisting of distinct integers from 0 to m * n - 1. You can move in this matrix from a cell to any other cell in the next row. That is, if you are in cell (x, y) su... | {"functional": "def check(candidate):\n assert candidate(grid = [[5,3],[4,0],[2,1]], moveCost = [[9,8],[1,5],[10,12],[18,6],[2,4],[14,3]]) == 17\n assert candidate(grid = [[5,1,2],[4,0,3]], moveCost = [[12,10,15],[20,23,8],[21,7,1],[8,1,13],[9,10,25],[5,3,2]]) == 6\n\n\ncheck(Solution().minPathCost)"} | 306 | 146 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given two strings str1 and str2 of the same length, determine whether you can transform str1 into str2 by doing zero or more conversions.
In one conversion you can convert all occurrences of one character in str1 to a... | {"functional": "def check(candidate):\n assert candidate(str1 = \"aabcc\", str2 = \"ccdee\") == True\n assert candidate(str1 = \"leetcode\", str2 = \"codeleet\") == False\n\n\ncheck(Solution().canConvert)"} | 119 | 58 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
The array-form of an integer num is an array representing its digits in left to right order.
For example, for num = 1321, the array form is [1,3,2,1].
Given num, the array-form of an integer, and an integer k, retur... | {"functional": "def check(candidate):\n assert candidate(num = [1,2,0,0], k = 34) == [1,2,3,4]\n assert candidate(num = [2,7,4], k = 181) == [4,5,5]\n assert candidate(num = [2,1,5], k = 806) == [1,0,2,1]\n\n\ncheck(Solution().addToArrayForm)"} | 124 | 109 |
coding | Solve the programming task below in a Python markdown code block.
The chef is trying to solve some pattern problems, Chef wants your help to code it. Chef has one number K to form a new pattern. Help the chef to code this pattern problem.
-----Input:-----
- First-line will contain $T$, the number of test cases. Then t... | {"inputs": ["4\n1\n2\n3\n4"], "outputs": ["2\n24\n68\n246\n81012\n141618\n2468\n10121416\n18202224\n26283032"]} | 233 | 75 |
coding | Solve the programming task below in a Python markdown code block.
Chef is hosting a party at his house and N people are invited to it. Everyone has arrived and they are eager to make a group and chit-chat.
The i^{th} person prefers to be in a group of exactly P_{i} people (including himself). A person who is not in a ... | {"inputs": ["4\n5\n2 3 2 3 3\n5\n5 5 5 5 5\n5\n3 2 2 3 2\n4\n4 4 4 3\n"], "outputs": ["YES\nYES\nNO\nNO\n"]} | 563 | 66 |
coding | Solve the programming task below in a Python markdown code block.
Email address in Berland is a string of the form A@B, where A and B are arbitrary strings consisting of small Latin letters.
Bob is a system administrator in «Bersoft» company. He keeps a list of email addresses of the company's staff. This list is as ... | {"inputs": ["g\n", "@\n", "h\n", "?\n", "f\n", "w@\n", "jj\n", "@@\n"], "outputs": ["No solution\n", "No solution\n", "No solution\n", "No solution\n", "No solution\n", "No solution\n", "No solution\n", "No solution\n"]} | 334 | 79 |
coding | Solve the programming task below in a Python markdown code block.
Game "Minesweeper 1D" is played on a line of squares, the line's height is 1 square, the line's width is n squares. Some of the squares contain bombs. If a square doesn't contain a bomb, then it contains a number from 0 to 2 — the total number of bombs i... | {"inputs": ["?\n", "1\n", "0\n", "2\n", "*\n", "0\n", "*\n", "2\n"], "outputs": ["2\n", "0\n", "1\n", "0\n", "1\n", "1\n", "1\n", "0\n"]} | 489 | 70 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.