task_type
stringclasses
1 value
problem
stringlengths
261
3.34k
answer
stringlengths
35
6.15k
problem_tokens
int64
62
774
answer_tokens
int64
12
2.04k
coding
Solve the programming task below in a Python markdown code block. Blackjack is a type of card game played in casinos, where the game is played using cards with numbers from 1 to 13. The score of each card is decided as follows. * 1 is 1 point or 11 points * From 2 to 9, the score is as written. * 10 points from 10 to ...
{"inputs": ["1\n7 9 7\n1 7 8\n2 1\n2 2 1\n0", "1\n7 4 2\n1 9 8\n2 1\n9 2 1\n0", "1\n7 3 4\n1 7 8\n2 1\n3 3 1\n0", "1\n7 9 7\n1 7 2\n2 1\n2 2 1\n0", "1\n7 4 2\n1 9 8\n2 1\n1 2 1\n0", "1\n7 1 7\n7 7 8\n8 1\n3 1 2\n0", "1\n7 9 7\n2 7 2\n2 1\n2 2 1\n0", "1\n7 4 2\n1 9 8\n2 1\n2 2 1\n0"], "outputs": ["11\n0\n16\n13\n15\n", ...
380
354
coding
Solve the programming task below in a Python markdown code block. Piegirl got bored with binary, decimal and other integer based counting systems. Recently she discovered some interesting properties about number $q = \frac{\sqrt{5} + 1}{2}$, in particular that q^2 = q + 1, and she thinks it would make a good base for h...
{"inputs": ["0\n0\n", "0\n1\n", "1\n0\n", "1\n1\n", "1\n1\n", "0\n1\n", "0\n0\n", "1\n0\n"], "outputs": ["=\n", "<\n", ">\n", "=\n", "=", "<", "=", ">"]}
464
76
coding
Solve the programming task below in a Python markdown code block. The students of Codechef Middle School are visiting an amusement park. The children want to go on a ride, however, there is a minimum height requirement of $X$ cm. Determine if the children are eligible to go on the ride. Print "Yes" if they are eligibl...
{"inputs": ["2\n120 100\n90 100"], "outputs": ["Yes\nNo"]}
290
29
coding
Solve the programming task below in a Python markdown code block. Create a function finalGrade, which calculates the final grade of a student depending on two parameters: a grade for the exam and a number of completed projects. This function should take two arguments: exam - grade for exam (from 0 to 100); projects - ...
{"functional": "_inputs = [[100, 12], [99, 0], [10, 15], [85, 5], [55, 3], [55, 0], [20, 2]]\n_outputs = [[100], [100], [100], [90], [75], [0], [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 isin...
350
229
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. On a 2D plane, there are n points with integer coordinates points[i] = [xi, yi]. Return the minimum time in seconds to visit all the points in the order given by points. You can move according to these rules: In 1 se...
{"functional": "def check(candidate):\n assert candidate(points = [[1,1],[3,4],[-1,0]]) == 7\n assert candidate(points = [[3,2],[-2,2]]) == 5\n\n\ncheck(Solution().minTimeToVisitAllPoints)"}
192
63
coding
Solve the programming task below in a Python markdown code block. Let $n$ be a fixed integer. A permutation is a bijection from the set $\{1,2,\ldots,n\}$ to itself. A cycle of length ${k}$ ($k\geq2$) is a permutation $\mbox{f}$ where different integers exist $i_1,\ldots,i_k$ such that $f(i_1)=i_2,f(i_2)=i_3,...,f(...
{"inputs": ["1\n3 2\n2 2\n"], "outputs": ["6\n"]}
528
22
coding
Solve the programming task below in a Python markdown code block. You are given an array that of arbitrary depth that needs to be nearly flattened into a 2 dimensional array. The given array's depth is also non-uniform, so some parts may be deeper than others. All of lowest level arrays (most deeply nested) will conta...
{"functional": "_inputs = [[[[1]]], [[[1, 2, 3], [4, 5, 6]]], [[[1, 2, 3], [[4, 5], [[6], [7, 8]]]]], [[[[1, 2, 3], [9, 10]], [[4, 5], [6, 7, 8]]]]]\n_outputs = [[[[1]]], [[[1, 2, 3], [4, 5, 6]]], [[[1, 2, 3], [4, 5], [6], [7, 8]]], [[[1, 2, 3], [4, 5], [6, 7, 8], [9, 10]]]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\...
231
314
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. There are three stones in different positions on the X-axis. You are given three integers a, b, and c, the positions of the stones. In one move, you pick up a stone at an endpoint (i.e., either the lowest or highest p...
{"functional": "def check(candidate):\n assert candidate(a = 1, b = 2, c = 5) == [1, 2]\n assert candidate(a = 4, b = 3, c = 2) == [0, 0]\n\n\ncheck(Solution().numMovesStones)"}
246
73
coding
Solve the programming task below in a Python markdown code block. Problem statement There is a positive integer sequence $ a_1, a_2, \ ldots, a_N $ of length $ N $. Consider the following game, which uses this sequence and is played by $ 2 $ players on the play and the play. * Alternately select one of the following...
{"inputs": ["2\n0 2", "2\n0 4", "2\n0 1", "2\n1 0", "2\n0 7", "2\n2 0", "2\n4 0", "2\n5 0"], "outputs": ["Second\n", "Second\n", "First\n", "First\n", "First\n", "Second\n", "Second\n", "First\n"]}
517
94
coding
Solve the programming task below in a Python markdown code block. There's a chessboard of size $n \times n$. $m$ rooks are placed on it in such a way that: no two rooks occupy the same cell; no two rooks attack each other. A rook attacks all cells that are in its row or column. Is it possible to move exactly one ro...
{"inputs": ["2\n2 2\n1 2\n2 1\n3 1\n2 2\n", "3\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n", "17\n8 1\n1 1\n8 1\n1 1\n8 1\n1 1\n8 1\n1 1\n8 1\n1 1\n8 1\n1 1\n8 1\n1 1\n8 1\n1 1\n8 1\n1 1\n8 1\n1 1\n8 1\n1 1\n8 1\n1 1\n8 1\n1 1\n8 1\n1 1\n8 1\n1 1\n8 1\n1 1\n8 1\n1 1\n", "17\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1...
465
426
coding
Solve the programming task below in a Python markdown code block. The chef is trying to decode 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 ...
{"inputs": ["4\n1\n2\n3\n4"], "outputs": ["1\n10\n10\n101\n101\n101\n1010\n1010\n1010\n1010"]}
216
58
coding
Solve the programming task below in a Python markdown code block. There are N people standing in a queue from west to east. Given is a string S of length N representing the directions of the people. The i-th person from the west is facing west if the i-th character of S is L, and east if that character of S is R. A per...
{"inputs": ["1 99999\nL\n", "6 2\nLRLRRL", "6 0\nLRRLRL", "6 1\nRRLLRL", "6 0\nRRLLRL", "6 0\nLRLRLR", "6 4\nLRLRRL", "6 1\nLRRLRL"], "outputs": ["0\n", "5\n", "1\n", "4\n", "2\n", "0\n", "5\n", "3\n"]}
413
116
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. Given a string s, consider all duplicated substrings: (contiguous) substrings of s that occur 2 or more times. The occurrences may overlap. Return any duplicated substring that has the longest possible length. If s do...
{"functional": "def check(candidate):\n assert candidate(s = \"banana\") == \"ana\"\n assert candidate(s = \"abcd\") == \"\"\n\n\ncheck(Solution().longestDupSubstring)"}
109
46
coding
Solve the programming task below in a Python markdown code block. ## Task Create a function that given a sequence of strings, groups the elements that can be obtained by rotating others, ignoring upper or lower cases. In the event that an element appears more than once in the input sequence, only one of them will be...
{"functional": "_inputs = [[['Tokyo', 'London', 'Rome', 'Donlon', 'Kyoto', 'Paris', 'Okyot']], [['Tokyo', 'London', 'Rome', 'Donlon']], [['Rome', 'Rome', 'Rome', 'Donlon', 'London']], [['Ab', 'Aa']], [[]]]\n_outputs = [[[['Kyoto', 'Okyot', 'Tokyo'], ['Donlon', 'London'], ['Paris'], ['Rome']]], [[['Donlon', 'London'], [...
282
290
coding
Solve the programming task below in a Python markdown code block. Write a function that removes every lone 9 that is inbetween 7s. ```python seven_ate9('79712312') => '7712312' seven_ate9('79797') => '777' ``` Input: String Output: String Also feel free to reuse/extend the following starter code: ```python def seven_...
{"functional": "_inputs = [['165561786121789797'], ['797'], ['7979797'], ['16797'], ['77'], ['7927'], ['1779'], ['a779'], ['17797a'], ['797 9 7']]\n_outputs = [['16556178612178977'], ['77'], ['7777'], ['1677'], ['77'], ['7927'], ['1779'], ['a779'], ['1777a'], ['77 9 7']]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n ...
108
303
coding
Solve the programming task below in a Python markdown code block. # The Problem Dan, president of a Large company could use your help. He wants to implement a system that will switch all his devices into offline mode depending on his meeting schedule. When he's at a meeting and somebody texts him, he wants to send an ...
{"functional": "_inputs = [[[['09:30', '10:15'], ['12:20', '15:50']], '10:00'], [[['09:30', '10:15'], ['12:20', '15:50']], '11:00'], [[['09:30', '10:15'], ['12:20', '15:50']], '10:15'], [[], '10:15'], [[['12:13', '23:50']], '10:15'], [[['12:13', '23:50']], '23:55'], [[['12:13', '23:50']], '17:43']]\n_outputs = [['10:15...
450
361
coding
Solve the programming task below in a Python markdown code block. A palindrome is a word that reads the same forward and backward. Given a string s, you need to make it a palindrome by adding 0 or more characters to the end of s, and remember, we want the palindrome to be as short as possible. INPUT First line is T,...
{"inputs": ["6\nabdfhdyrbdbsdfghjkllkjhgfds\nzazazazazazazazazazazazazazazazazazazazazazazazaza\nbacba\na\nadwuaaxcnleegluqvsczaguujoppchwecusmevz\nkoikijiikmmkmonkiinnjlijmiimnniokikimikkkkjkmiinii"], "outputs": ["38\n51\n9\n1\n77\n95"]}
219
120
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. You have a cubic storeroom where the width, length, and height of the room are all equal to n units. You are asked to place n boxes in this room where each box is a cube of unit side length. There are however some rul...
{"functional": "def check(candidate):\n assert candidate(n = 3) == 3\n assert candidate(n = 4) == 3\n assert candidate(n = 10) == 6\n\n\ncheck(Solution().minimumBoxes)"}
165
56
coding
Solve the programming task below in a Python markdown code block. Chef found N magical cards in his drawer. Each card has a number written on each of its faces. He places all the cards on the table in a front face-up manner. Chef denotes the numbers on the front face by A_{1}, A_{2},..., A_{N} and on the back face by ...
{"inputs": ["3\n3\n4 6 8\n2 1 2\n3\n0 2 0\n2 0 8\n3\n1 2 1\n2 3 6"], "outputs": ["2 2\n0 0\n2 2"]}
568
64
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. Given a non-empty array of non-negative integers nums, the degree of this array is defined as the maximum frequency of any one of its elements. Your task is to find the smallest possible length of a (contiguous) subar...
{"functional": "def check(candidate):\n assert candidate(nums = [1,2,2,3,1]) == 2\n assert candidate(nums = [1,2,2,3,1,4,2]) == 6\n\n\ncheck(Solution().findShortestSubArray)"}
108
66
coding
Solve the programming task below in a Python markdown code block. It is only six months until Christmas, and AtCoDeer the reindeer is now planning his travel to deliver gifts. There are N houses along TopCoDeer street. The i-th house is located at coordinate a_i. He has decided to deliver gifts to all these houses. F...
{"inputs": ["4\n2 3 9 9", "4\n4 4 8 9", "4\n0 4 8 9", "4\n2 3 7 9", "4\n2 3 7 9\n", "4\n2 3 13 9", "4\n4 4 13 9", "4\n0 4 8 18"], "outputs": ["7\n", "5\n", "9\n", "7", "7\n", "11\n", "9\n", "18\n"]}
237
131
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. You are given an integer array nums (0-indexed). In one operation, you can choose an element of the array and increment it by 1. For example, if nums = [1,2,3], you can choose to increment nums[1] to make nums = [1,3...
{"functional": "def check(candidate):\n assert candidate(nums = [1,1,1]) == 3\n assert candidate(nums = [1,5,2,4,1]) == 14\n assert candidate(nums = [8]) == 0\n\n\ncheck(Solution().minOperations)"}
166
68
coding
Solve the programming task below in a Python markdown code block. Little Elephant is playing a game with arrays. He is given an array A0, A1, ..., AN−1 of N integers. And then Q queries are given, each containing an integer K. He has to tell how many subarrays satisfy the condition: the function foo returns K when it i...
{"inputs": ["5\n4 0 2 3 4\n4\n3\n4\n6\n1", "5\n4 0 2 3 4\n4\n5\n4\n6\n1", "5\n4 1 2 3 4\n4\n5\n4\n6\n1", "5\n4 1 2 6 4\n4\n5\n4\n6\n1", "5\n4 1 2 3 4\n4\n3\n7\n6\n1", "5\n4 0 2 3 4\n1\n3\n4\n6\n1", "5\n4 0 2 3 0\n4\n5\n4\n6\n1", "5\n4 1 2 3 4\n3\n5\n4\n6\n1"], "outputs": ["2\n2\n0\n0\n", "0\n2\n0\n0\n", "0\n2\n0\n8\n",...
545
262
coding
Solve the programming task below in a Python markdown code block. Kajaria has an empty bag and 2 types of tiles - tiles of type $1$ have the number $X$ written and those of type $2$ have the number $Y$ written on them. He has an infinite supply of both type of tiles. In one move, Kajaria adds exactly $1$ tile to the b...
{"inputs": ["1\n5 3 96\n1 3"], "outputs": ["48"]}
616
24
coding
Solve the programming task below in a Python markdown code block. You are given an unordered array of unique integers incrementing from $\mbox{1}$. You can swap any two elements a limited number of times. Determine the largest lexicographical value array that can be created by executing no more than the limited numbe...
{"inputs": ["2 1\n2 1\n", "3 1\n2 1 3\n"], "outputs": ["2 1\n", "3 1 2\n"]}
640
42
coding
Solve the programming task below in a Python markdown code block. There are n employees in Alternative Cake Manufacturing (ACM). They are now voting on some very important question and the leading world media are trying to predict the outcome of the vote. Each of the employees belongs to one of two fractions: depublic...
{"inputs": ["1\nD\n", "1\nR\n", "1\nR\n", "1\nD\n", "2\nDR\n", "2\nDR\n", "3\nRDD\n", "3\nDRD\n"], "outputs": ["D\n", "R\n", "R\n", "D\n", "D\n", "D\n", "D\n", "D\n"]}
588
87
coding
Solve the programming task below in a Python markdown code block. You have $n$ barrels lined up in a row, numbered from left to right from one. Initially, the $i$-th barrel contains $a_i$ liters of water. You can pour water from one barrel to another. In one act of pouring, you can choose two different barrels $x$ and...
{"inputs": ["2\n4 1\n5 5 5 5\n3 2\n0 0 0\n", "2\n4 2\n5 5 5 5\n3 2\n0 0 0\n", "2\n4 2\n5 5 5 5\n3 2\n0 0 1\n", "2\n4 3\n5 5 2 5\n3 2\n0 1 0\n", "2\n4 3\n5 5 2 1\n3 2\n0 1 0\n", "2\n4 3\n5 1 2 1\n3 2\n0 1 0\n", "2\n4 2\n2 5 5 0\n3 2\n0 0 0\n", "2\n4 3\n5 1 2 2\n3 2\n0 1 0\n"], "outputs": ["10\n0\n", "15\n0\n", "15\n1\n"...
525
269
coding
Solve the programming task below in a Python markdown code block. Given an integer N, find a permutation P = P_{1}, P_{2}, \ldots, P_{N} of length N that satisfies the following two conditions: P_{i} \neq i (1 ≤ i ≤ N); Consider the set which contains P_{i} \% i for all 1 ≤ i ≤ N. This set should have the minimum numbe...
{"inputs": ["2\n2\n3\n"], "outputs": ["2 1\n2 3 1"]}
562
25
coding
Solve the programming task below in a Python markdown code block. Marina loves Sasha. But she keeps wondering whether Sasha loves her. Of course, the best way to know it is fortune telling. There are many ways of telling fortune, but Marina has picked the easiest one. She takes in her hand one or several camomiles and ...
{"inputs": ["1\n0\n", "1\n2\n", "1\n1\n", "1\n31\n", "1\n44\n", "1\n33\n", "1\n64\n", "1\n11\n"], "outputs": ["0\n", "0\n", "1\n", "31\n", "0\n", "33\n", "0\n", "11\n"]}
321
94
coding
Solve the programming task below in a Python markdown code block. Lot of junior developer can be stuck when they need to change the access permission to a file or a directory in an Unix-like operating systems. To do that they can use the `chmod` command and with some magic trick they can change the permissionof a file...
{"functional": "_inputs = [[{'user': 'rwx', 'group': 'r-x', 'other': 'r-x'}], [{'user': 'rwx', 'group': 'r--', 'other': 'r--'}], [{'user': 'r-x', 'group': 'r-x', 'other': '---'}], [{'group': 'rwx'}], [{}]]\n_outputs = [['755'], ['744'], ['550'], ['070'], ['000']]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isin...
383
252
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. There is an integer array nums that consists of n unique elements, but you have forgotten it. However, you do remember every pair of adjacent elements in nums. You are given a 2D integer array adjacentPairs of size n ...
{"functional": "def check(candidate):\n assert candidate(adjacentPairs = [[2,1],[3,4],[3,2]]) == [1,2,3,4]\n assert candidate(adjacentPairs = [[4,-2],[1,4],[-3,1]]) == [-2,4,1,-3]\n assert candidate(adjacentPairs = [[100000,-100000]]) == [100000,-100000]\n\n\ncheck(Solution().restoreArray)"}
194
120
coding
Solve the programming task below in a Python markdown code block. You are given a fair coin and two integers X and N. You repeatedly flip the coin and perform the following operation based on the result: If it lands on heads, then X will increase by 1. However, if X = N then X will not change. If it lands on tails, X ...
{"inputs": ["4\n1 3\n2 2\n12 12\n568 57800"], "outputs": ["0\n2\n132\n65223144\n"]}
403
52
coding
Solve the programming task below in a Python markdown code block. There is data of up to 100 characters per line, consisting of half-width alphabetic character strings. Some lines are symmetric (same whether read from the left edge or the right edge). Create a program that reads this data and outputs the number of symm...
{"inputs": ["abcba\nsx\nabcddcba\nrstrd", "abcca\nsw\nabcddcba\nrstrd", "abcca\nxt\nadcbdcba\nrdsrt", "abcba\nsw\nabcddcba\nrstrd", "accba\nsw\nabcddcba\nrstrd", "accba\nsx\nabcddcba\nrstrd", "accba\ntx\nabcddcba\nrstrd", "accba\ntx\nabcddcba\nrsdrt"], "outputs": ["2\n", "1\n", "0\n", "2\n", "1\n", "1\n", "1\n", "1\n"]...
143
153
coding
Solve the programming task below in a Python markdown code block. Alice and Bob were having an argument about which of them is taller than the other. Charlie got irritated by the argument, and decided to settle the matter once and for all. Charlie measured the heights of Alice and Bob, and got to know that Alice's hei...
{"inputs": ["2\n150 160\n160 150"], "outputs": ["B\nA"]}
352
30
coding
Solve the programming task below in a Python markdown code block. =====Function Descriptions===== mean The mean tool computes the arithmetic mean along the specified axis. import numpy my_array = numpy.array([ [1, 2], [3, 4] ]) print numpy.mean(my_array, axis = 0) #Output : [ 2. 3.] print numpy.mean(my_arra...
{"inputs": ["2 2\n1 2\n3 4"], "outputs": ["[1.5 3.5]\n[1. 1.]\n1.118033988749895"]}
580
56
coding
Solve the programming task below in a Python markdown code block. Complete the solution so that it takes the object (JavaScript/CoffeeScript) or hash (ruby) passed in and generates a human readable string from its key/value pairs. The format should be "KEY = VALUE". Each key/value pair should be separated by a comma ...
{"functional": "_inputs = [[{'a': 1, 'b': 2}], [{'a': 'b', 'b': 'a'}], [{'0': 'a', 'b': 2}], [{'b': 1, 'c': 2, 'e': 3}], [{}]]\n_outputs = [['a = 1,b = 2'], ['a = b,b = a'], ['0 = a,b = 2'], ['b = 1,c = 2,e = 3'], ['']]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n ...
129
249
coding
Solve the programming task below in a Python markdown code block. You're given a sequence of N distinct integers. You need to find a subsequence of length K with the maximum possible median. The median of a sequence is the value of the element which is in the middle of the sequence after sorting it in non-decreasing o...
{"inputs": ["1\n5 3\n1 4 3 6 5"], "outputs": ["5\n1 6 5"]}
542
32
coding
Solve the programming task below in a Python markdown code block. Two integers are coprimes if the their only greatest common divisor is 1. ## Task In this kata you'll be given a number ```n >= 2``` and output a list with all positive integers less than ```gcd(n, k) == 1```, with ```k``` being any of the output number...
{"functional": "_inputs = [[2], [3], [6], [10], [20], [25], [30]]\n_outputs = [[[1]], [[1, 2]], [[1, 5]], [[1, 3, 7, 9]], [[1, 3, 7, 9, 11, 13, 17, 19]], [[1, 2, 3, 4, 6, 7, 8, 9, 11, 12, 13, 14, 16, 17, 18, 19, 21, 22, 23, 24]], [[1, 7, 11, 13, 17, 19, 23, 29]]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isin...
296
331
coding
Solve the programming task below in a Python markdown code block. Quite recently, a very smart student named Jury decided that lectures are boring, so he downloaded a game called "Black Square" on his super cool touchscreen phone. In this game, the phone's screen is divided into four vertical strips. Each second, a bl...
{"inputs": ["4 3 2 1\n2\n", "0 0 0 0\n1\n", "1 2 3 4\n4\n", "1 2 3 4\n4\n", "4 3 2 1\n2\n", "0 0 0 0\n1\n", "0 2 3 4\n4\n", "0 3 2 1\n2\n"], "outputs": ["3\n", "0\n", "4\n", "4\n", "3\n", "0\n", "4\n", "3\n"]}
361
134
coding
Solve the programming task below in a Python markdown code block. Read problems statements in Mandarin Chinese here ------ Problem Statement ------ Maxim likes dividers of the numbers. Also Maxim is fond of lucky numbers of small elephant from Lviv city.   If you remember, lucky numbers are positive integers whose ...
{"inputs": ["10\n2\n4\n2\n7\n5\n6\n7\n8\n9\n2", "10\n2\n2\n2\n4\n5\n8\n1\n2\n9\n5", "10\n2\n2\n1\n4\n5\n6\n3\n8\n9\n4", "10\n2\n3\n2\n5\n5\n4\n1\n2\n9\n5", "10\n2\n2\n1\n6\n5\n6\n3\n8\n9\n4", "10\n2\n4\n2\n7\n4\n6\n7\n8\n9\n2", "10\n2\n5\n4\n5\n5\n4\n1\n2\n9\n2", "10\n3\n4\n2\n9\n4\n6\n7\n8\n9\n2"], "outputs": ["0\n1\n...
370
374
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. You are given a 2D integer array grid of size m x n, where each cell contains a positive integer. A cornered path is defined as a set of adjacent cells with at most one turn. More specifically, the path should exclusi...
{"functional": "def check(candidate):\n assert candidate(grid = [[23,17,15,3,20],[8,1,20,27,11],[9,4,6,2,21],[40,9,1,10,6],[22,7,4,5,3]]) == 3\n assert candidate(grid = [[4,3,2],[7,6,1],[8,8,8]]) == 0\n\n\ncheck(Solution().maxTrailingZeros)"}
222
121
coding
Solve the programming task below in a Python markdown code block. A core idea of several left-wing ideologies is that the wealthiest should *support* the poorest, no matter what and that is exactly what you are called to do using this kata (which, on a side note, was born out of the necessity to redistribute the width ...
{"functional": "_inputs = [[[2, 3, 5, 15, 75], 5], [[2, 3, 5, 15, 75], 20], [[2, 3, 5, 45, 45], 5], [[2, 3, 5, 45, 45], 30], [[24, 48, 22, 19, 37], 30]]\n_outputs = [[[5, 5, 5, 15, 70]], [[20, 20, 20, 20, 20]], [[5, 5, 5, 42, 43]], [[]], [[30, 30, 30, 30, 30]]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinst...
669
332
coding
Solve the programming task below in a Python markdown code block. Given a string and an array of integers representing indices, capitalize all letters at the given indices. For example: * `capitalize("abcdef",[1,2,5]) = "aBCdeF"` * `capitalize("abcdef",[1,2,5,100]) = "aBCdeF"`. There is no index 100. The input will...
{"functional": "_inputs = [['abcdef', [1, 2, 5]], ['abcdef', [1, 2, 5, 100]], ['codewars', [1, 3, 5, 50]], ['abracadabra', [2, 6, 9, 10]], ['codewarriors', [5]], ['indexinglessons', [0]]]\n_outputs = [['aBCdeF'], ['aBCdeF'], ['cOdEwArs'], ['abRacaDabRA'], ['codewArriors'], ['Indexinglessons']]\nimport math\ndef _deep_e...
214
269
coding
Solve the programming task below in a Python markdown code block. ## Task: You have to write a function `pattern` which returns the following Pattern (See Pattern & Examples) upto `n` number of rows. * Note: `Returning` the pattern is not the same as `Printing` the pattern. ### Rules/Note: * If `n < 1` then it shoul...
{"functional": "_inputs = [[1], [2], [5], [0], [-25]]\n_outputs = [['1'], ['21\\n2'], ['54321\\n5432\\n543\\n54\\n5'], [''], ['']]\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, t...
448
202
coding
Solve the programming task below in a Python markdown code block. Your task is to calculate the distance between two $n$ dimensional vectors $x = \\{x_1, x_2, ..., x_n\\}$ and $y = \\{y_1, y_2, ..., y_n\\}$. The Minkowski's distance defined below is a metric which is a generalization of both the Manhattan distance and...
{"inputs": ["3\n2 2 3\n2 0 4", "3\n1 2 3\n2 0 4", "3\n2 2 3\n2 -1 4", "3\n2 4 5\n2 -1 4", "3\n3 4 5\n2 -1 4", "3\n6 4 5\n2 -1 4", "3\n6 5 5\n2 -1 4", "3\n6 5 5\n2 -1 3"], "outputs": ["3.000000\n2.236068\n2.080084\n2.000000\n", "4.000000\n2.449490\n2.154435\n2.000000", "4.000000\n3.162278\n3.036589\n3.000000\n", "6.0000...
554
432
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. Given a string s, return the number of substrings that have only one distinct letter.   Please complete the following python code precisely: ```python class Solution: def countLetters(self, s: str) -> int: ```
{"functional": "def check(candidate):\n assert candidate(s = \"aaaba\") == 8\n assert candidate(s = \"aaaaaaaaaa\") == 55\n\n\ncheck(Solution().countLetters)"}
65
46
coding
Solve the programming task below in a Python markdown code block. It’s the company's 3^rd anniversary, and everyone is super-excited about it. There is a tradition in the company, that the interns decide the seating arrangement of all the members. The requirements of this order are: The CEO of the company must sit in t...
{"inputs": ["80 82 81\n3\n50 90 65"], "outputs": ["79"]}
304
31
coding
Solve the programming task below in a Python markdown code block. # Your Task The city of Darkishland has a strange hotel with infinite rooms. The groups that come to this hotel follow the following rules: * At the same time only members of one group can rent the hotel. * Each group comes in the morning of the check-...
{"functional": "_inputs = [[1, 6], [3, 10], [3, 14], [10, 1000], [1, 1000], [5, 4], [5, 7], [10000, 1000000000000000], [2, 20000000000000], [10, 900000000000000000], [34545, 565], [234234, 6577], [10, 10]]\n_outputs = [[3], [5], [6], [46], [45], [5], [6], [44721361], [6324555], [1341640786], [34545], [234234], [10]]\ni...
341
374
coding
Solve the programming task below in a Python markdown code block. Most football fans love it for the goals and excitement. Well, this Kata doesn't. You are to handle the referee's little notebook and count the players who were sent off for fouls and misbehavior. The rules: Two teams, named "A" and "B" have 11 players ...
{"functional": "_inputs = [[[]], [['A4Y', 'A4Y']], [['A4Y', 'A4R']], [['A4Y', 'A5R', 'B5R', 'A4Y', 'B6Y']], [['A4R', 'A4R', 'A4R']], [['A4R', 'A2R', 'A3R', 'A6R', 'A8R', 'A10R', 'A11R']]]\n_outputs = [[[11, 11]], [[10, 11]], [[10, 11]], [[9, 10]], [[10, 11]], [[6, 11]]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n ...
358
299
coding
Solve the programming task below in a Python markdown code block. Polycarp has a poor memory. Each day he can remember no more than $3$ of different letters. Polycarp wants to write a non-empty string of $s$ consisting of lowercase Latin letters, taking minimum number of days. In how many days will he be able to do it...
{"inputs": ["1\nvdjisjifreo\n", "6\nlollipops\nstringology\nabracadabra\ncodeforces\ntest\nf\n"], "outputs": ["4\n", "2\n4\n3\n4\n1\n1\n"]}
459
60
coding
Solve the programming task below in a Python markdown code block. Chef gets confused between mean and median very often, and as a result, he has developed a dislike of arrays whose mean and median are not equal. Chef has an array A of N elements. He can perform the following operation on it: Pick an index 1 ≤ i ≤ N an...
{"inputs": ["3\n3\n1 2 3\n4\n1 1 3 3\n5\n1 1000000000 1 1000000000 1\n"], "outputs": ["0\n4\n500000002\n"]}
579
74
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. You are given an m x n integer matrix grid where each cell is either 0 (empty) or 1 (obstacle). You can move up, down, left, or right from and to an empty cell in one step. Return the minimum number of steps to walk f...
{"functional": "def check(candidate):\n assert candidate( grid = [[0,0,0],[1,1,0],[0,0,0],[0,1,1],[0,0,0]], k = 1) == 6\n assert candidate(grid = [[0,1,1],[1,1,1],[1,0,0]], k = 1) == -1\n\n\ncheck(Solution().shortestPath)"}
159
99
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 representing the strength of some heroes. The power of a group of heroes is defined as follows: Let i0, i1, ... ,ik be the indices of the heroes in a group. Then, the powe...
{"functional": "def check(candidate):\n assert candidate(nums = [2,1,4]) == 141\n assert candidate(nums = [1,1,1]) == 7\n\n\ncheck(Solution().sumOfPower)"}
174
54
coding
Solve the programming task below in a Python markdown code block. Every now and then people in the office moves teams or departments. Depending what people are doing with their time they can become more or less boring. Time to assess the current team. ```if-not:java You will be provided with an object(staff) containin...
{"functional": "_inputs = [[{'tim': 'change', 'jim': 'accounts', 'randy': 'canteen', 'sandy': 'change', 'andy': 'change', 'katie': 'IS', 'laura': 'change', 'saajid': 'IS', 'alex': 'trading', 'john': 'accounts', 'mr': 'finance'}], [{'tim': 'IS', 'jim': 'finance', 'randy': 'pissing about', 'sandy': 'cleaning', 'andy': 'c...
330
411
coding
Solve the programming task below in a Python markdown code block. The city of Hackerland has formed a new football club and wants to participate in the upcoming Football League of their country. The coach is worried that they will not be able to qualify because they don't have a famous footballer in their team. The ass...
{"inputs": ["5\n3 2\n4 5\n7 4\n34534985349875439875439875349875 93475349759384754395743975349573495\n34543987529435983745230948023948 3498573497543987543985743989120393097595572309482304\n"], "outputs": ["9\n1024\n2401\n735851262\n985546465\n"]}
665
211
coding
Solve the programming task below in a Python markdown code block. There is an array of $n$ integers. There are also $2$ disjoint sets, $\mbox{A}$ and $\mbox{B}$, each containing $m$ integers. You like all the integers in set $\mbox{A}$ and dislike all the integers in set $\mbox{B}$. Your initial happiness is $\mbox{o}$...
{"inputs": ["3 2\n1 5 3\n3 1\n5 7\n"], "outputs": ["1\n"]}
446
30
coding
Solve the programming task below in a Python markdown code block. We define a magic square to be an $n\times n$ matrix of distinct positive integers from $\mbox{1}$ to $n^2$ where the sum of any row, column, or diagonal of length $n$ is always equal to the same number: the magic constant. You will be given a $3\time...
{"inputs": ["4 9 2\n3 5 7\n8 1 5\n", "4 8 2\n4 5 7\n6 1 6\n"], "outputs": ["1\n", "4\n"]}
650
54
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. You are given an integer array nums. Each element in nums is 1, 2 or 3. In each operation, you can remove an element from nums. Return the minimum number of operations to make nums non-decreasing.   Please complete th...
{"functional": "def check(candidate):\n assert candidate(nums = [2,1,3,2,1]) == 3\n assert candidate(nums = [1,3,2,1,3,3]) == 2\n assert candidate(nums = [2,2,2,2,3,3]) == 0\n\n\ncheck(Solution().minimumOperations)"}
96
83
coding
Solve the programming task below in a Python markdown code block. You are given positive integers $L$ and $R$. You have to find the sum S=∑i=LR(L∧(L+1)∧…∧i),S=∑i=LR(L∧(L+1)∧…∧i),S = \sum_{i=L}^R \left(L \wedge (L+1) \wedge \ldots \wedge i\right) \,, where $\wedge$ denotes the bitwise AND operation. Since the sum could ...
{"inputs": ["2\n1 4\n4 10"], "outputs": ["1\n16"]}
407
24
coding
Solve the programming task below in a Python markdown code block. Our good friend Mole is trying to code a big message. He is typing on an unusual keyboard with characters arranged in following way: qwertyuiop asdfghjkl; zxcvbnm,./ Unfortunately Mole is blind, so sometimes it is problem for him to put his hands a...
{"inputs": ["L\nq\n", "L\no\n", "L\n,\n", "L\nz\n", "R\n.\n", "R\no\n", "R\nw\n", "R\nx\n"], "outputs": ["w\n", "p\n", ".\n", "x\n", ",\n", "i\n", "q\n", "z\n"]}
282
86
coding
Solve the programming task below in a Python markdown code block. Find the edit distance between given two words s1 and s2. The disntace is the minimum number of single-character edits required to change one word into the other. The edits including the following operations: * insertion: Insert a character at a partic...
{"inputs": ["`cac\nacm", "`cad\nacm", "`cac\nbcm", "`cac\nmcb", "`cab\nmcb", "`cab\nbcm", "_cac\nmcb", "_cca\nmcb"], "outputs": ["3\n", "3\n", "3\n", "3\n", "2\n", "3\n", "3\n", "3\n"]}
195
85
coding
Solve the programming task below in a Python markdown code block. The R2 company has n employees working for it. The work involves constant exchange of ideas, sharing the stories of success and upcoming challenging. For that, R2 uses a famous instant messaging program Spyke. R2 has m Spyke chats just to discuss all so...
{"inputs": ["2 1 1\n1\n1\n1 1\n", "2 1 1\n1\n1\n1 1\n", "2 1 1\n1\n1\n2 1\n", "2 1 1\n1\n1\n1 1\n", "2 1 1\n1\n1\n2 1\n", "2 1 1\n1\n0\n1 1\n", "3 1 2\n1\n1\n0\n1 1\n2 1\n", "3 1 2\n1\n0\n1\n1 1\n3 1\n"], "outputs": ["0 1 ", "0 1 ", "1 0 ", "0 1 \n", "1 0 \n", "0 0", "1 1 0 ", "1 0 1 "]}
624
195
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. There are several squares being dropped onto the X-axis of a 2D plane. You are given a 2D integer array positions where positions[i] = [lefti, sideLengthi] represents the ith square with a side length of sideLengthi t...
{"functional": "def check(candidate):\n assert candidate(positions = [[1,2],[2,3],[6,1]]) == [2,5,5]\n assert candidate(positions = [[100,100],[200,100]]) == [100,100]\n\n\ncheck(Solution().fallingSquares)"}
229
83
coding
Solve the programming task below in a Python markdown code block. The polar bears are going fishing. They plan to sail from (s_{x}, s_{y}) to (e_{x}, e_{y}). However, the boat can only sail by wind. At each second, the wind blows in one of these directions: east, south, west or north. Assume the boat is currently at (x...
{"inputs": ["1 5 5 5 6\nE\n", "1 5 5 5 6\nE\n", "1 5 3 5 6\nE\n", "1 5 8 5 6\nE\n", "1 0 0 0 -1\nS\n", "1 0 0 0 -1\nS\n", "1 5 3 5 12\nE\n", "1 -2 0 0 0\nS\n"], "outputs": ["-1\n", "-1\n", "-1\n", "-1\n", "1\n", "1\n", "-1\n", "-1\n"]}
489
152
coding
Solve the programming task below in a Python markdown code block. Chef loves cooking. Also, he is very hygienic. Hence, Chef grows his own vegetables in his mini kitchen garden. He has $M$ lanes in which he grows vegetables. The $ith$ lane has $Ai$ vegetables growing in it. Vegetables in $ith$ lane become edible on d...
{"inputs": ["2 4\n1 6\n2 5", "3 3\n1 4\n6 2\n5 3"], "outputs": ["11", "9"]}
662
43
coding
Solve the programming task below in a Python markdown code block. Given an array A having N elements, Chef wonders how many pairs (i, j) exists such that 1 ≤ i < j ≤ N, and A_{i} \cdot A_{j} is divisible by i \cdot j. Can you help Chef in finding the number of such pairs? ------ Input Format ------ - The first lin...
{"inputs": ["3\n3\n1 2 3\n4\n2 3 5 6\n5\n3 9 14 6 10\n"], "outputs": ["3\n2\n6\n"]}
390
50
coding
Solve the programming task below in a Python markdown code block. There are 2N balls, N white and N black, arranged in a row. The integers from 1 through N are written on the white balls, one on each ball, and they are also written on the black balls, one on each ball. The integer written on the i-th ball from the left...
{"inputs": ["1\nB 1\nW 1\n", "1\nB 1\nW 1\n", "1\nW 1\nB 1\n", "2\nW 2\nB 1\nW 1\nB 2\n", "3\nB 1\nW 1\nB 3\nW 2\nW 3\nB 2", "3\nB 1\nW 1\nB 2\nW 2\nW 3\nB 3", "3\nB 1\nW 1\nB 3\nW 3\nW 2\nB 2", "3\nB 1\nW 2\nB 2\nW 1\nW 3\nB 3"], "outputs": ["0\n", "0\n", "0\n", "2\n", "3", "0", "4", "2"]}
457
198
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. You are given a string word and an array of strings forbidden. A string is called valid if none of its substrings are present in forbidden. Return the length of the longest valid substring of the string word. A substr...
{"functional": "def check(candidate):\n assert candidate(word = \"cbaaaabc\", forbidden = [\"aaa\",\"cb\"]) == 4\n assert candidate(word = \"leetcode\", forbidden = [\"de\",\"le\",\"e\"]) == 4\n\n\ncheck(Solution().longestValidSubstring)"}
110
67
coding
Solve the programming task below in a Python markdown code block. It is the middle of 2018 and Maria Stepanovna, who lives outside Krasnokamensk (a town in Zabaikalsky region), wants to rent three displays to highlight an important problem. There are $n$ displays placed along a road, and the $i$-th of them can display...
{"inputs": ["3\n1 2 3\n1 1 1\n", "3\n1 2 3\n1 1 1\n", "3\n1 3 3\n1 1 1\n", "3\n1 3 3\n1 0 1\n", "3\n1 0 3\n1 0 1\n", "3\n1 -1 3\n1 0 1\n", "3\n1 -1 3\n1 0 2\n", "3\n0 -1 3\n1 0 2\n"], "outputs": ["3\n", "3\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n"]}
594
166
coding
Solve the programming task below in a Python markdown code block. Kiteretsu goes to his Chemistry Lab to perform the perfect reaction. In his lab, he found N reagents numbered 1 to N. The i^{th} reagent has two properties - A_{i} and B_{i}. A reaction can be performed between the reagents i and j only if A_{i} ≤ j. ...
{"inputs": ["2\n5 2\n2 4 5 5 6\n1 3 2 2 5\n2 3\n2 3\n1 2\n"], "outputs": ["6\n-7\n"]}
714
53
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 and an integer limit, delete all insufficient nodes in the tree simultaneously, and return the root of the resulting binary tree. A node is insufficient if every root to leaf path inter...
{"functional": "def check(candidate):\n assert is_same_tree(candidate(root = tree_node([1,2,3,4,-99,-99,7,8,9,-99,-99,12,13,-99,14]), limit = 1), tree_node([1,2,3,4,None,None,7,8,9,None,14]))\n assert is_same_tree(candidate(root = tree_node([5,4,8,11,None,17,4,7,1,None,None,5,3]), limit = 22), tree_node([5,4,8,11...
168
208
coding
Solve the programming task below in a Python markdown code block. Read problems statements in Mandarin Chinese , Russian and Vietnamese Chef likes to play table tennis. He found some statistics of matches which described who won the points in order. A game shall be won by the player first scoring 11 points except in...
{"inputs": ["2\n0101111111111\n11100000000000\n"], "outputs": ["WIN\nLOSE"]}
395
44
coding
Solve the programming task below in a Python markdown code block. Given a string S of length N containing only numeric characters, find the number of Nice Pairs. A Nice Pair is a pair of indices - (i, j) such that 1 ≤ i < j ≤ N and j - i = |S_{j} - S_{i}|. ------ Input Format ------ - First line will contain T, num...
{"inputs": ["3\n3\n123\n5\n13492\n8\n94241234\n"], "outputs": ["3\n2\n9\n"]}
343
43
coding
Solve the programming task below in a Python markdown code block. You should write a function that takes a string and a positive integer `n`, splits the string into parts of length `n` and returns them in an array. It is ok for the last element to have less than `n` characters. If `n` is not a valid size (`> 0`) (or i...
{"functional": "_inputs = [['codewars', 2]]\n_outputs = [[['co', 'de', 'wa', 'rs']]]\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 F...
226
170
coding
Solve the programming task below in a Python markdown code block. Chef calls a pair of integers (A, B) *equivalent* if there exist some positive integers X and Y such that A^{X} = B^{Y}. Given A and B, determine whether the pair is *equivalent* or not. ------ Input Format ------ - The first line of input will conta...
{"inputs": ["3\n2 3\n8 4\n12 24\n"], "outputs": ["NO\nYES\nNO\n"]}
367
32
coding
Solve the programming task below in a Python markdown code block. It's Friday night, and Chuck is bored. He's already run 1,000 miles, stopping only to eat a family sized bag of Heatwave Doritos and a large fistful of M&Ms. He just can't stop thinking about kicking something! There is only one thing for it, Chuck hea...
{"functional": "_inputs = [[['*****************************************', '** _O_ * _O_ * _O_ * _O_ **', '** /(.)J * C(.)J * /(.)J * C(.)J **', '** _| |_ * _| |_ * _( )_ * _( )_ *']], [['*** _O_ ** _O_ ** _O_ ** _O_ ***', '*** /(.)J ** /(.)J ** C(.)J ** C(.)J ***', '*** _| ...
303
1,042
coding
Solve the programming task below in a Python markdown code block. The idea for this Kata came from 9gag today.[here](http://9gag.com/gag/amrb4r9) [screen]:("http://img-9gag-fun.9cache.com/photo/amrb4r9_700b.jpg") You'll have to translate a string to Pilot's alphabet (NATO phonetic alphabet) [wiki](https://en.wikipedi...
{"functional": "_inputs = [['If you can read'], ['Did not see that coming']]\n_outputs = [['India Foxtrot Yankee Oscar Uniform Charlie Alfa November Romeo Echo Alfa Delta'], ['Delta India Delta November Oscar Tango Sierra Echo Echo Tango Hotel Alfa Tango Charlie Oscar Mike India November Golf']]\nimport math\ndef _deep...
263
202
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. You are given an m x n integer matrix grid containing distinct positive integers. You have to replace each integer in the matrix with a positive integer satisfying the following conditions: The relative order of ever...
{"functional": "def check(candidate):\n assert candidate(grid = [[3,1],[2,5]]) == [[2,1],[1,2]]\n assert candidate(grid = [[10]]) == [[1]]\n\n\ncheck(Solution().minScore)"}
284
60
coding
Solve the programming task below in a Python markdown code block. You are given an empty grid with $N$ rows (numbered $1$ through $N$) and $M$ columns (numbered $1$ through $M$). You should fill this grid with integers in a way that satisfies the following rules: - For any three cells $c_1$, $c_2$ and $c_3$ such that $...
{"inputs": ["2\n1 1\n2 3"], "outputs": ["1\n1\n3\n1 1 2\n2 3 3"]}
604
36
coding
Solve the programming task below in a Python markdown code block. Ivan had string s consisting of small English letters. However, his friend Julia decided to make fun of him and hid the string s. Ivan preferred making a new string to finding the old one. Ivan knows some information about the string s. Namely, he reme...
{"inputs": ["1\na 1 3\n", "1\na 1 4\n", "1\na 1 2\n", "1\nb 1 2\n", "1\nc 1 2\n", "1\nc 1 3\n", "1\nc 1 4\n", "1\na 1 3\n"], "outputs": ["aaa\n", "aaaa", "aa", "ab", "ac", "aac", "aaac", "aaa\n"]}
517
113
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. The hash of a 0-indexed string s of length k, given integers p and m, is computed using the following function: hash(s, p, m) = (val(s[0]) * p0 + val(s[1]) * p1 + ... + val(s[k-1]) * pk-1) mod m. Where val(s[i]) rep...
{"functional": "def check(candidate):\n assert candidate(s = \"leetcode\", power = 7, modulo = 20, k = 2, hashValue = 0) == \"ee\"\n assert candidate(s = \"fbxzaad\", power = 31, modulo = 100, k = 3, hashValue = 32) == \"fbx\"\n\n\ncheck(Solution().subStrHash)"}
238
97
coding
Solve the programming task below in a Python markdown code block. Eshag has an array $a$ consisting of $n$ integers. Eshag can perform the following operation any number of times: choose some subsequence of $a$ and delete every element from it which is strictly larger than $AVG$, where $AVG$ is the average of the numb...
{"inputs": ["1\n2\n1 2\n", "1\n2\n1 2\n", "1\n2\n0 2\n", "1\n2\n1 1\n", "1\n2\n1 4\n", "1\n2\n0 4\n", "1\n2\n1 6\n", "1\n2\n0 3\n"], "outputs": ["1\n", "1\n", "1\n", "0\n", "1\n", "1\n", "1\n", "1\n"]}
701
118
coding
Solve the programming task below in a Python markdown code block. Read problems statements in Mandarin Chinese and Russian. Sometimes mysteries happen. Chef found a directed graph with N vertices and M edges in his kitchen! The evening was boring and chef has nothing else to do, so to entertain himself, Chef though...
{"inputs": ["7 7\n1 2 \n3 2\n3 4\n7 4\n6 2\n5 6\n7 5", "7 7\n1 2 \n4 2\n3 4\n7 4\n6 2\n5 6\n7 5", "9 7\n1 2 \n4 2\n3 4\n7 4\n6 2\n5 6\n7 5", "7 7\n1 2 \n3 2\n2 4\n7 4\n6 2\n5 6\n7 5", "7 7\n1 2 \n3 2\n2 4\n4 4\n6 2\n5 6\n7 5", "8 7\n1 4 \n2 2\n3 4\n7 4\n6 2\n4 8\n7 6", "7 7\n1 2 \n3 2\n3 4\n7 4\n6 2\n5 6\n5 5", "7 7\n1...
451
309
coding
Solve the programming task below in a Python markdown code block. You have recently fallen through a hole and, after several hours of unconsciousness, have realized you are in an underground city. On one of your regular, daily walks through the unknown, you have encountered two unusually looking skeletons called Sanz a...
{"inputs": ["6\nabacba\n2\naba 6\nba 3\n1\n", "6\nabacba\n2\naba 6\nba 3\n2\n", "6\nabacba\n2\naba 6\nba 4\n2\n", "6\nabacba\n2\naba 5\nba 4\n2\n", "6\nabacba\n2\naba 5\nba 0\n2\n", "6\nabacba\n2\nbaa 5\nab 0\n2\n", "6\nabacba\n2\nbaa 5\nba 1\n2\n", "6\nabacba\n2\nbaa 5\nba 2\n2\n"], "outputs": ["9\n", "12\n", "14\n", ...
568
204
coding
Solve the programming task below in a Python markdown code block. Given is an integer N. Snuke will choose integers s_1, s_2, n_1, n_2, u_1, u_2, k_1, k_2, e_1, and e_2 so that all of the following six conditions will be satisfied: * 0 \leq s_1 < s_2 * 0 \leq n_1 < n_2 * 0 \leq u_1 < u_2 * 0 \leq k_1 < k_2 * 0 \leq e_...
{"inputs": ["4\n2\n6\n1\n1001000000", "4\n0\n6\n6\n1001000000", "4\n0\n0\n9\n1001000101", "4\n1\n0\n9\n1000000101", "4\n2\n1\n9\n1001000001", "4\n6\n2\n7\n0010010100", "4\n6\n2\n5\n0010010100", "4\n4\n6\n15\n1000000000"], "outputs": ["0\n11\n0\n475432620\n", "0\n11\n11\n475432620\n", "0\n0\n1346\n301343122\n", "0\n0\n1...
453
332
coding
Solve the programming task below in a Python markdown code block. Read problems statements [Hindi] , [Vietnamese] , [Mandarin Chinese] , [Russian] and [Bengali] as well. Oh, these difficult contests... In each contest, there are so many hard tasks Chef cannot solve. However, he knows that he can only become a successf...
{"inputs": ["1\n5 7"], "outputs": ["YES"]}
576
16
coding
Solve the programming task below in a Python markdown code block. There is a new mobile game that starts with consecutively numbered clouds. Some of the clouds are thunderheads and others are cumulus. The player can jump on any cumulus cloud having a number that is equal to the number of the current cloud plus $\mbox...
{"inputs": ["6\n0 0 0 0 1 0\n", "7\n0 0 1 0 0 1 0\n"], "outputs": ["3\n", "4\n"]}
572
48
coding
Solve the programming task below in a Python markdown code block. Sarthak and Anuradha are very good friends and are eager to participate in an event called *Equinox*. It is a game of words. In this game, $N$ strings $S_{1},\ldots, S_{N}$ are given. For each string $S_{i}$, if it starts with one of the letters of the w...
{"inputs": ["2\n4 1 3\nABBBCDDE\nEARTH\nINDIA\nUUUFFFDDD\n2 5 7\nSDHHD\nXOXOXOXO"], "outputs": ["DRAW\nANURADHA"]}
662
55
coding
Solve the programming task below in a Python markdown code block. Find the least common multiple (LCM) of given n integers. Constraints * 2 ≤ n ≤ 10 * 1 ≤ ai ≤ 1000 * Product of given integers ai(i = 1, 2, ... n) does not exceed 231-1 Input n a1 a2 ... an n is given in the first line. Then, n integers are given ...
{"inputs": ["3\n3 4 3", "3\n3 7 3", "3\n4 6 5", "3\n4 6 7", "3\n4 4 7", "3\n5 4 7", "3\n9 4 3", "3\n9 2 6"], "outputs": ["12\n", "21\n", "60\n", "84\n", "28\n", "140\n", "36\n", "18\n"]}
156
119
coding
Solve the programming task below in a Python markdown code block. Read problem statements in [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well. Chef's college is conducting an online exam, where his camera will be monitored by one or more invigilators (supervisors). Once again, Chef failed to prepare ...
{"inputs": ["3\n1 10 10\n0 10\n2 2 10\n0 5\n7 10\n2 2 100\n0 5\n5 10"], "outputs": ["NO\nYES\nYES"]}
736
62
coding
Solve the programming task below in a Python markdown code block. You are given $q$ queries in the following form: Given three integers $l_i$, $r_i$ and $d_i$, find minimum positive integer $x_i$ such that it is divisible by $d_i$ and it does not belong to the segment $[l_i, r_i]$. Can you answer all the queries? Re...
{"inputs": ["1\n1 1 1\n", "1\n2 5 6\n", "1\n5 5 5\n", "1\n6 6 6\n", "1\n1 3 2\n", "1\n6 6 6\n", "1\n1 1 1\n", "1\n1 3 2\n"], "outputs": ["2\n", "6\n", "10\n", "12\n", "4\n", "12\n", "2\n", "4\n"]}
285
121
coding
Solve the programming task below in a Python markdown code block. Little Petya wanted to give an April Fools Day present to some scientists. After some hesitation he decided to give them the array that he got as a present in Codeforces Round #153 (Div.2). The scientists rejoiced at the gift and decided to put some impo...
{"inputs": ["1\n", "7\n", "3\n", "8\n", "2\n", "5\n", "9\n", "4\n"], "outputs": ["1\n", "0\n", "0\n", "1\n", "0\n", "0\n", "1\n", "1\n"]}
545
70
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. Given a rows x cols binary matrix filled with 0's and 1's, find the largest rectangle containing only 1's and return its area.   Please complete the following python code precisely: ```python class Solution: def m...
{"functional": "def check(candidate):\n assert candidate(matrix = [[\"1\",\"0\",\"1\",\"0\",\"0\"],[\"1\",\"0\",\"1\",\"1\",\"1\"],[\"1\",\"1\",\"1\",\"1\",\"1\"],[\"1\",\"0\",\"0\",\"1\",\"0\"]]) == 6\n assert candidate(matrix = [[\"0\"]]) == 0\n assert candidate(matrix = [[\"1\"]]) == 1\n\n\ncheck(Solution()...
81
106
coding
Solve the programming task below in a Python markdown code block. You are given two strings $s$ and $t$. Both strings have length $n$ and consist of lowercase Latin letters. The characters in the strings are numbered from $1$ to $n$. You can successively perform the following move any number of times (possibly, zero):...
{"inputs": ["1\nk\nk\n", "1\no\nk\n", "1\no\nk\n", "1\nk\nk\n", "1\no\nj\n", "1\nj\nk\n", "1\np\nk\n", "1\ni\nk\n"], "outputs": ["0\n\n", "-1\n", "-1", "0\n", "-1\n", "-1\n", "-1\n", "-1\n"]}
587
102
coding
Solve the programming task below in a Python markdown code block. Takahashi will do a tap dance. The dance is described by a string S where each character is L, R, U, or D. These characters indicate the positions on which Takahashi should step. He will follow these instructions one by one in order, starting with the fi...
{"inputs": ["U\n", "L\n", "R\n", "D\n", "LLUD", "EULL", "EULM", "DULL"], "outputs": ["Yes\n", "No\n", "Yes\n", "Yes\n", "No\n", "No\n", "No\n", "No"]}
320
70
coding
Solve the programming task below in a Python markdown code block. Read problems statements [Hindi] , [Vietnamese] , [Mandarin Chinese] , [Russian] and [Bengali] as well. You are given a directed acyclic graph with $N$ vertices (numbered $1$ through $N$) and $M$ edges. You want to destroy it all! To destroy the graph, ...
{"inputs": ["6 6\n1 2\n2 3\n1 3\n3 4\n3 5\n1 6\n"], "outputs": ["4\n2 4 5\n2 6 3\n1 2\n1 1\n"]}
581
60
coding
Solve the programming task below in a Python markdown code block. Smart Beaver recently got interested in a new word game. The point is as follows: count the number of distinct good substrings of some string s. To determine if a string is good or not the game uses rules. Overall there are n rules. Each rule is describe...
{"inputs": ["a\n0\n", "b\n0\n", "a\n0\n", "aaab\n2\naa 0 0\naab 1 1\n", "aaab\n2\naa 0 0\nbaa 1 1\n", "aaab\n2\naa 0 0\naab 2 1\n", "aaab\n2\naa 1 0\naab 2 1\n", "aaab\n2\naa 1 1\naab 2 1\n"], "outputs": ["1\n", "1\n", "1\n", "3\n", "1\n", "0\n", "0\n", "0\n"]}
751
152
coding
Solve the programming task below in a Python markdown code block. “I am not in danger, Skyler. I am the danger. A guy opens his door and gets shot, and you think that of me? No! I am the one who knocks!” Skyler fears Walter and ponders escaping to Colorado. Walter wants to clean his lab as soon as possible and then go ...
{"inputs": ["3\n0 5\n4 -5\n0 10000001"], "outputs": ["1\n2\n1"]}
483
35
coding
Solve the programming task below in a Python markdown code block. Little Petya has recently started attending a programming club. Naturally he is facing the problem of choosing a programming language. After long considerations he realized that Java is the best choice. The main argument in favor of choosing Java was tha...
{"inputs": ["6\n", "9\n", "8\n", "71\n", "13\n", "16\n", "26\n", "19\n"], "outputs": ["byte\n", "byte\n", "byte\n", "byte\n", "byte\n", "byte\n", "byte\n", "byte\n"]}
561
75
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. The pair sum of a pair (a,b) is equal to a + b. The maximum pair sum is the largest pair sum in a list of pairs. For example, if we have pairs (1,5), (2,3), and (4,4), the maximum pair sum would be max(1+5, 2+3, 4+4)...
{"functional": "def check(candidate):\n assert candidate(nums = [3,5,2,3]) == 7\n assert candidate(nums = [3,5,4,2,4,6]) == 8\n\n\ncheck(Solution().minPairSum)"}
198
60