task_type
stringclasses
4 values
problem
stringlengths
14
5.23k
solution
stringlengths
1
8.29k
problem_tokens
int64
9
1.02k
solution_tokens
int64
1
1.98k
coding
Solve the programming task below in a Python markdown code block. Chef has an array A of length N. Chef wants to select some disjoint, non-empty subarrays from A such that: The mex of each of the selected subarray is the same. Note that the selected subarrays need not cover all the elements of the array. For e.g. if...
{"inputs": ["2\n4\n0 1 1 0\n6\n0 0 3 1 2 0\n"], "outputs": ["2\n3\n"]}
595
40
coding
Solve the programming task below in a Python markdown code block. You are the "computer expert" of a local Athletic Association (C.A.A.). Many teams of runners come to compete. Each time you get a string of all race results of every team who has run. For example here is a string showing the individual results of a tea...
{"functional": "_inputs = [['01|15|59, 1|47|16, 01|17|20, 1|32|34, 2|17|17'], ['02|15|59, 2|47|16, 02|17|20, 2|32|34, 2|17|17, 2|22|00, 2|31|41'], ['02|15|59, 2|47|16, 02|17|20, 2|32|34, 2|32|34, 2|17|17'], ['0|15|59, 0|16|16, 0|17|20, 0|22|34, 0|19|34, 0|15|0'], ['11|15|59, 10|16|16, 12|17|20, 9|22|34, 13|19|34, 11|15...
621
804
coding
Solve the programming task below in a Python markdown code block. *Based on this Numberphile video: https://www.youtube.com/watch?v=Wim9WJeDTHQ* --- Multiply all the digits of a nonnegative integer `n` by each other, repeating with the product until a single digit is obtained. The number of steps required is known as...
{"functional": "_inputs = [[1234567890], [123456789], [12345678], [1234567], [123456], [12345], [2379], [777], [25], [277777788888899], [3778888999]]\n_outputs = [[[0]], [[362880, 0]], [[40320, 0]], [[5040, 0]], [[720, 0]], [[120, 0]], [[378, 168, 48, 32, 6]], [[343, 36, 18, 8]], [[10, 0]], [[4996238671872, 438939648, ...
404
480
coding
Solve the programming task below in a Python markdown code block. You will turn on the air conditioner if, and only if, the temperature of the room is 30 degrees Celsius or above. The current temperature of the room is X degrees Celsius. Will you turn on the air conditioner? -----Constraints----- - -40 \leq X \leq 40...
{"inputs": ["3", "1", "5", "0", "6", "2", "4", "8"], "outputs": ["No\n", "No\n", "No\n", "No\n", "No\n", "No\n", "No\n", "No\n"]}
129
62
coding
Solve the programming task below in a Python markdown code block. Now we will confect a reagent. There are eight materials to choose from, numbered 1,2,..., 8 respectively. We know the rules of confect: ``` material1 and material2 cannot be selected at the same time material3 and material4 cannot be selected at the sa...
{"functional": "_inputs = [[[1, 3, 7]], [[7, 1, 2, 3]], [[1, 3, 5, 7]], [[1, 5, 6, 7, 3]], [[5, 6, 7]], [[5, 6, 7, 8]], [[6, 7, 8]], [[7, 8]]]\n_outputs = [[True], [False], [False], [True], [True], [True], [False], [True]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):...
378
256
coding
Solve the programming task below in a Python markdown code block. Dima and Inna are doing so great! At the moment, Inna is sitting on the magic lawn playing with a pink pony. Dima wanted to play too. He brought an n × m chessboard, a very tasty candy and two numbers a and b. Dima put the chessboard in front of Inna an...
{"inputs": ["5 7 1 3 2 2\n", "5 5 2 3 1 1\n", "1 1 1 1 1 1\n", "5 7 1 3 1 2\n", "5 4 2 3 2 2\n", "5 4 2 3 1 1\n", "5 5 1 3 1 2\n", "5 5 4 3 1 2\n"], "outputs": ["2\n", "Poor Inna and pony!\n", "0\n", "2\n", "Poor Inna and pony!\n", "1\n", "Poor Inna and pony!\n", "1\n"]}
670
165
coding
Solve the programming task below in a Python markdown code block. There are four towns, numbered 1,2,3 and 4. Also, there are three roads. The i-th road connects different towns a_i and b_i bidirectionally. No two roads connect the same pair of towns. Other than these roads, there is no way to travel between these town...
{"inputs": ["4 3\n1 3\n2 3", "1 1\n3 2\n4 3", "1 2\n3 2\n4 3", "1 2\n2 2\n4 3", "3 2\n2 4\n1 4", "1 1\n3 2\n4 1", "1 4\n2 2\n4 3", "3 2\n3 4\n1 4"], "outputs": ["NO\n", "YES\n", "YES\n", "NO\n", "YES\n", "NO\n", "YES\n", "YES\n"]}
303
142
coding
Solve the programming task below in a Python markdown code block. There are N integers written on a blackboard. The i-th integer is A_i. Takahashi and Aoki will arrange these integers in a row, as follows: * First, Takahashi will arrange the integers as he wishes. * Then, Aoki will repeatedly swap two adjacent intege...
{"inputs": ["4\n2 0 4 6", "4\n1 0 4 6", "4\n1 0 2 6", "4\n1 0 2 2", "4\n2 0 2 2", "4\n2 0 3 2", "4\n2 0 6 2", "4\n2 3 4 1"], "outputs": ["0 2 4 6 ", "1 0 4 6 ", "1 0 2 6 ", "1 0 2 2 ", "0 2 2 2 ", "0 3 2 2 ", "0 2 2 6 ", "3 2 4 1 "]}
267
167
coding
Solve the programming task below in a Python markdown code block. Chef has an array A consisting of N integers (1-based indexing). He asks you to perform the following operation M times: for i = 2 to N: Ai = Ai + Ai-1 Your task is to find the xth element of the array (i.e., Ax) after performing the above operation...
{"inputs": ["2\n3 2 3\n1 2 3\n3 3 3\n1 2 3"], "outputs": ["5\n15"]}
478
39
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. The bitwise AND of an array nums is the bitwise AND of all integers in nums. For example, for nums = [1, 5, 3], the bitwise AND is equal to 1 & 5 & 3 = 1. Also, for nums = [7], the bitwise AND is 7. You are given an...
{"functional": "def check(candidate):\n assert candidate(candidates = [16,17,71,62,12,24,14]) == 4\n assert candidate(candidates = [8,8]) == 2\n\n\ncheck(Solution().largestCombination)"}
167
68
coding
Solve the programming task below in a Python markdown code block. Let's denote d(n) as the number of divisors of a positive integer n. You are given three integers a, b and c. Your task is to calculate the following sum: $\sum_{i = 1}^{a} \sum_{j = 1}^{b} \sum_{k = 1}^{c} d(i \cdot j \cdot k)$ Find the sum modulo 107...
{"inputs": ["2 2 2\n", "5 6 7\n", "1 5 1\n", "1 5 1\n", "2 1 2\n", "2 2 2\n", "5 6 7\n", "71 2 1\n"], "outputs": ["20\n", "1520\n", "10\n", "10\n", "8\n", "20\n", "1520\n", "811\n"]}
390
115
coding
Solve the programming task below in a Python markdown code block. You have three tasks, all of which need to be completed. First, you can complete any one task at cost 0. Then, just after completing the i-th task, you can complete the j-th task at cost |A_j - A_i|. Here, |x| denotes the absolute value of x. Find the mi...
{"inputs": ["3 5 2", "4 3 2", "4 3 0", "5 3 0", "0 1 6", "1 1 8", "0 1 8", "1 6 3"], "outputs": ["3\n", "2\n", "4\n", "5\n", "6\n", "7\n", "8\n", "5"]}
233
93
coding
Solve the programming task below in a Python markdown code block. January and February are usually very cold in ChefLand. The temperature may reach -20 and even -30 degrees Celsius. Because of that, many people seal up windows in their houses. Sergey also lives in ChefLand. He wants to seal the window in his house. The...
{"inputs": ["1\n4\n0 0\n1000 0\n1000 2000\n0 2000\n2\n1000 10\n2000 15"], "outputs": ["50"]}
767
61
coding
Solve the programming task below in a Python markdown code block. .symmetric_difference() The .symmetric_difference() operator returns a set with all the elements that are in the set and the iterable but not both. Sometimes, a ^ operator is used in place of the .symmetric_difference() tool, but it only operates on ...
{"inputs": ["9\n1 2 3 4 5 6 7 8 9\n9\n10 1 2 3 11 21 55 6 8\n"], "outputs": ["8\n"]}
637
56
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. You are given a string s consisting of lowercase English letters, and you are allowed to perform operations on it. In one operation, you can replace a character in s with another lowercase English letter. Your task is...
{"functional": "def check(candidate):\n assert candidate(s = \"egcfe\") == \"efcfe\"\n assert candidate(s = \"abcd\") == \"abba\"\n assert candidate(s = \"seven\") == \"neven\"\n\n\ncheck(Solution().makeSmallestPalindrome)"}
184
66
coding
Solve the programming task below in a Python markdown code block. International Abbreviation Olympiad takes place annually starting from 1989. Each year the competition receives an abbreviation of form IAO'y, where y stands for some number of consequent last digits of the current year. Organizers always pick an abbrevi...
{"inputs": ["1\nIAO'001\n", "1\nIAO'089\n", "1\nIAO'099\n", "1\nIAO'990\n", "1\nIAO'2015\n", "1\nIAO'2000\n", "1\nIAO'11378\n", "1\nIAO'11111\n"], "outputs": ["3001\n", "3089\n", "2099\n", "2990\n", "12015\n", "12000\n", "111378\n", "111111\n"]}
395
162
coding
Solve the programming task below in a Python markdown code block. Our chef has been assigned a task to make a necklace of length N, from gold, diamond and platinum.There is single kind of gold, two types of diamond and three types of platinum available. A necklace can be represented as strings of the form (G)∗(D1|D2)∗(...
{"inputs": ["2\n1\n2"], "outputs": ["6\n25"]}
415
19
coding
Solve the programming task below in a Python markdown code block. Snuke has an integer sequence A of length N. He will make three cuts in A and divide it into four (non-empty) contiguous subsequences B, C, D and E. The positions of the cuts can be freely chosen. Let P,Q,R,S be the sums of the elements in B,C,D,E, res...
{"inputs": ["5\n3 2 4 2 2", "5\n5 2 4 2 1", "5\n4 3 4 2 1", "5\n2 1 6 0 2", "5\n2 3 6 2 1", "5\n2 1 7 0 2", "5\n2 1 7 0 0", "5\n8 0 2 2 0"], "outputs": ["2\n", "3\n", "1\n", "5\n", "4\n", "6\n", "7\n", "8\n"]}
311
142
coding
Solve the programming task below in a Python markdown code block. Harsh was recently gifted a book consisting of N pages. Each page contains exactly M words printed on it. As he was bored, he decided to count the number of words in the book. Help Harsh find the total number of words in the book. ------ Input Format ...
{"inputs": ["4\n1 1\n4 2\n2 4\n95 42\n"], "outputs": ["1\n8\n8\n3990\n"]}
394
41
coding
Solve the programming task below in a Python markdown code block. Your goal is to implement the method **meanVsMedian** which accepts an *odd-length* array of integers and returns one of the following: * 'mean' - in case **mean** value is **larger than** median value * 'median' - in case **median** value is **larger t...
{"functional": "_inputs = [[[1, 1, 1]], [[1, 2, 37]], [[7, 14, -70]], [[-10, 20, 5]]]\n_outputs = [['same'], ['mean'], ['median'], ['same']]\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...
147
203
coding
Solve the programming task below in a Python markdown code block. Chef is a private detective. He was asked to investigate a case of murder in the city of Frangton. Chef arrived in Frangton to find out that the mafia was involved in the case. Chef spent some time watching for people that belong to the clan and was able...
{"inputs": ["6\n0 1 1 2 2 3"], "outputs": ["4 5 6"]}
405
28
coding
Solve the programming task below in a Python markdown code block. There are n cows playing poker at a table. For the current betting phase, each player's status is either "ALLIN", "IN", or "FOLDED", and does not change throughout the phase. To increase the suspense, a player whose current status is not "FOLDED" may sho...
{"inputs": ["2\nFA\n", "2\nFF\n", "2\nIF\n", "2\nFA\n", "2\nFF\n", "2\nFA\n", "2\nIF\n", "2\nAF\n"], "outputs": ["1\n", "0\n", "1\n", "1\n", "0", "1", "1", "1\n"]}
336
83
coding
Solve the programming task below in a Python markdown code block. Alice and Bob are playing a game. Initially, they are given a non-empty string $s$, consisting of lowercase Latin letters. The length of the string is even. Each player also has a string of their own, initially empty. Alice starts, then they alternate m...
{"inputs": ["2\nforces\nabba\n"], "outputs": ["Alice\nDraw\n"]}
597
21
coding
Solve the programming task below in a Python markdown code block. Chef solved so many hard questions, now he wants to solve some easy problems for refreshment. Chef asks Cheffina for the new question. Cheffina challanges the chef to print the total number of 1's in the binary representation of N(natural number). -----...
{"inputs": ["2\n2\n5"], "outputs": ["1\n2"]}
236
18
coding
Solve the programming task below in a Python markdown code block. Problem statement: Kiran P.S wrote some text on a piece of paper and now he wants to know how many star characters are in the text. If you think of the paper as the plane and a letter as a curve on the plane, then each letter divides the plane into re...
{"inputs": ["5\nBACKTOTHEFUTURE\nPIRAMIDOFEGYPT\nROMANCE\nINSTITUTEOFELECTRICALANDELECTRONICSENGINEERING\nTHISISTHETESTCASEEERING", "5\nOAXTJYRHRPXKBZCRTSQTUSTQPQZWOMXGPUPMYTOZEKFJPANKMK\nGATLIOYAJSKNAAQVRBDVCXJNLRKSGWANRIIVIEMCIIYZJJMXNSNZXWYSQLXFNHTLJKDR\nHWOKJWVEHBKRYRDIKVHLAVCCKV\nUPHWPQKUBCUDOQNVKBAPIGDCZFOZEGCDPO...
302
227
coding
Solve the programming task below in a Python markdown code block. Quickly after finishing the tutorial of the online game ATChat, you have decided to visit a particular place with N-1 players who happen to be there. These N players, including you, are numbered 1 through N, and the friendliness of Player i is A_i. The N...
{"inputs": ["4\n1 2 1 3", "4\n1 3 1 3", "4\n1 5 1 3", "4\n1 4 1 3", "4\n2 4 1 2", "4\n1 7 1 8", "4\n0 0 0 0", "4\n0 1 0 0"], "outputs": ["7\n", "9\n", "11\n", "10\n", "8\n", "22\n", "0\n", "1\n"]}
379
129
coding
Solve the programming task below in a Python markdown code block. You are given an array $d_1, d_2, \dots, d_n$ consisting of $n$ integer numbers. Your task is to split this array into three parts (some of which may be empty) in such a way that each element of the array belongs to exactly one of the three parts, and e...
{"inputs": ["2\n1 1\n", "2\n1 1\n", "2\n1 2\n", "2\n1 4\n", "2\n0 4\n", "3\n4 1 2\n", "3\n3 1 2\n", "3\n3 1 1\n"], "outputs": ["1\n", "1\n", "0\n", "0\n", "0\n", "0\n", "3\n", "0\n"]}
658
108
coding
Solve the programming task below in a Python markdown code block. Vova has won $n$ trophies in different competitions. Each trophy is either golden or silver. The trophies are arranged in a row. The beauty of the arrangement is the length of the longest subsegment consisting of golden trophies. Vova wants to swap two ...
{"inputs": ["2\nSS\n", "2\nSG\n", "2\nGS\n", "2\nGG\n", "2\nSG\n", "2\nGG\n", "2\nGS\n", "2\nSS\n"], "outputs": ["0\n", "1\n", "1\n", "2\n", "1\n", "2", "1\n", "0"]}
382
84
coding
Solve the programming task below in a Python markdown code block. Read problem statements in [Russian], [Mandarin Chinese], [Bengali], and [Vietnamese] as well. During a fight with the Joker, Batman's eyes lose the capability to distinguish between some pairs of colors. Each color has an integer ID from 1 to N. There...
{"inputs": ["3\n2 2 2\n1 2\n1 1\n2 1\n2 2 4\n1 1\n1 2\n1 2 2 1\n3 2 3\n2 1 3\n1 2\n1 3 1"], "outputs": ["2\n3\n1"]}
612
78
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. Given an array nums of positive integers. Your task is to select some subset of nums, multiply each element by an integer and add all these numbers. The array is said to be good if you can obtain a sum of 1 from the a...
{"functional": "def check(candidate):\n assert candidate(nums = [12,5,7,23]) == True\n assert candidate(nums = [29,6,10]) == True\n assert candidate(nums = [3,6]) == False\n\n\ncheck(Solution().isGoodArray)"}
127
69
coding
Solve the programming task below in a Python markdown code block. For any positive integer, we define a digit rotation as either moving the first digit to the end of the number (left digit rotation), or the last digit to the front of the number (right digit rotation). For example, the number 12345 could be left digit r...
{"inputs": ["6\n2528\n18211\n575\n268\n1\n257", "6\n4360\n18211\n575\n268\n1\n257", "6\n4360\n18211\n575\n268\n1\n443", "6\n4360\n18211\n575\n268\n1\n145", "6\n5788\n18211\n575\n268\n1\n145", "6\n5788\n32221\n575\n268\n1\n145", "6\n1689\n7692\n14761\n5838\n3\n68", "6\n1689\n7692\n14761\n8668\n3\n68"], "outputs": ["8252...
321
450
coding
Solve the programming task below in a Python markdown code block. One day Dima and Alex had an argument about the price and quality of laptops. Dima thinks that the more expensive a laptop is, the better it is. Alex disagrees. Alex thinks that there are two laptops, such that the price of the first laptop is less (stri...
{"inputs": ["1\n1 1\n", "1\n1 1\n", "2\n1 2\n2 1\n", "2\n1 1\n2 2\n", "2\n2 1\n1 2\n", "2\n2 1\n1 2\n", "2\n1 1\n2 2\n", "2\n1 3\n2 1\n"], "outputs": ["Poor Alex\n", "Poor Alex\n", "Happy Alex\n", "Poor Alex\n", "Happy Alex\n", "Happy Alex\n", "Poor Alex\n", "Happy Alex\n"]}
287
134
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. Given a list of strings words and a string pattern, return a list of words[i] that match pattern. You may return the answer in any order. A word matches the pattern if there exists a permutation of letters p so that a...
{"functional": "def check(candidate):\n assert candidate(words = [\"abc\",\"deq\",\"mee\",\"aqq\",\"dkd\",\"ccc\"], pattern = \"abb\") == [\"mee\",\"aqq\"]\n\n\ncheck(Solution().findAndReplacePattern)"}
152
61
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. You have k bags. You are given a 0-indexed integer array weights where weights[i] is the weight of the ith marble. You are also given the integer k. Divide the marbles into the k bags according to the following rules:...
{"functional": "def check(candidate):\n assert candidate(weights = [1,3,5,1], k = 2) == 4\n assert candidate(weights = [1, 3], k = 2) == 0\n\n\ncheck(Solution().putMarbles)"}
209
63
coding
Solve the programming task below in a Python markdown code block. Calculus class...is awesome! But you are a programmer with no time for mindless repetition. Your teacher spent a whole day covering differentiation of polynomials, and by the time the bell rang, you had already conjured up a program to automate the proce...
{"functional": "_inputs = [[[]]]\n_outputs = [[[]]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return math.isclose(a, b, rel_tol=tol, abs_tol=tol)\n if isinstance(a, (list, tuple)):\n if len(a) != len(b): return False\n return all(_deep_eq...
401
153
coding
Solve the programming task below in a Python markdown code block. There is unrest in the Galactic Senate. Several thousand solar systems have declared their intentions to leave the Republic. Master Heidi needs to select the Jedi Knights who will go on peacekeeping missions throughout the galaxy. It is well-known that t...
{"inputs": ["1 1\n1\n1\n", "1 1\n1\n1\n", "2 1\n1 1\n1\n", "2 1\n1 1\n2\n", "2 1\n1 1\n1\n", "2 1\n1 1\n2\n", "2 2\n1 2\n1 1\n", "2 2\n2 2\n0 2\n"], "outputs": ["YES\n", "YES\n", "YES\n", "YES\n", "YES\n", "YES\n", "YES\n", "YES\n"]}
360
134
coding
Solve the programming task below in a Python markdown code block. Complete the solution so that the function will break up camel casing, using a space between words. ### Example ``` solution("camelCasing") == "camel Casing" ``` Also feel free to reuse/extend the following starter code: ```python def solution(s): `...
{"functional": "_inputs = [['helloWorld'], ['camelCase'], ['breakCamelCase']]\n_outputs = [['hello World'], ['camel Case'], ['break Camel Case']]\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 isinsta...
73
174
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. You are given an integer array nums. You should move each element of nums into one of the two arrays A and B such that A and B are non-empty, and average(A) == average(B). Return true if it is possible to achieve that...
{"functional": "def check(candidate):\n assert candidate(nums = [1,2,3,4,5,6,7,8]) == True\n assert candidate(nums = [3,1]) == False\n\n\ncheck(Solution().splitArraySameAverage)"}
129
59
coding
Solve the programming task below in a Python markdown code block. You are teaching a class of $N$ students. Today, during the morning prayer, all the students are standing in a line. You are given a string $s$ with length $N$; for each valid $i$, the $i$-th character of this string is 'b' if the $i$-th student in the l...
{"inputs": ["3\ngb\nbgg\nbbgg"], "outputs": ["1\n2\n6"]}
576
25
coding
Solve the programming task below in a Python markdown code block. Read problems statements in [Hindi], [Mandarin Chinese], [Russian], [Vietnamese], and [Bengali] as well. It is well-known that if you become rich, you will have a lot of trouble. Coach Khaled is one of the richest men in the world. He has $N$ jewels (nu...
{"inputs": ["1\n4 4\n1 2 4 3\n1 3\n3 4\n1 2\n2 3"], "outputs": ["4"]}
725
40
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. The letter value of a letter is its position in the alphabet starting from 0 (i.e. 'a' -> 0, 'b' -> 1, 'c' -> 2, etc.). The numerical value of some string of lowercase English letters s is the concatenation of the let...
{"functional": "def check(candidate):\n assert candidate(firstWord = \"acb\", secondWord = \"cba\", targetWord = \"cdb\") == True\n assert candidate(firstWord = \"aaa\", secondWord = \"a\", targetWord = \"aab\") == False\n assert candidate(firstWord = \"aaa\", secondWord = \"a\", targetWord = \"aaaa\") == True...
228
92
coding
Solve the programming task below in a Python markdown code block. You have N apples, called Apple 1, Apple 2, Apple 3, ..., Apple N. The flavor of Apple i is L+i-1, which can be negative. You can make an apple pie using one or more of the apples. The flavor of the apple pie will be the sum of the flavors of the apples ...
{"inputs": ["5 4", "5 7", "5 9", "8 9", "8 7", "3 8", "4 0", "2 2"], "outputs": ["26\n", "38\n", "46\n", "91\n", "77\n", "19\n", "6\n", "3\n"]}
390
84
coding
Solve the programming task below in a Python markdown code block. We have N cards numbered 1, 2, ..., N. Card i (1 \leq i \leq N) has an integer A_i written in red ink on one side and an integer B_i written in blue ink on the other side. Initially, these cards are arranged from left to right in the order from Card 1 to...
{"inputs": ["2\n2 0\n1 2", "2\n2 1\n1 1", "2\n0 1\n1 1", "2\n0 1\n2 1", "2\n0 1\n0 1", "2\n1 1\n0 1", "2\n1 2\n0 1", "2\n1 2\n0 2"], "outputs": ["-1", "1", "0", "0", "0", "0", "0", "0"]}
489
119
coding
Solve the programming task below in a Python markdown code block. Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. One day Petya was delivered a stri...
{"inputs": ["7\n", "4\n", "5\n", "9\n", "8\n", "2\n", "3\n", "0\n"], "outputs": ["7\n", "4\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n"]}
417
70
coding
Solve the programming task below in a Python markdown code block. A **bouncy number** is a positive integer whose digits neither increase nor decrease. For example, `1235` is an increasing number, `5321` is a decreasing number, and `2351` is a bouncy number. By definition, all numbers under `100` are non-bouncy, and `1...
{"functional": "_inputs = [[0], [99], [101], [120], [122], [221], [2379], [29340], [234689], [98874], [92722983], [129347924210]]\n_outputs = [[False], [False], [True], [True], [False], [False], [False], [True], [False], [False], [True], [True]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) o...
238
264
coding
Solve the programming task below in a Python markdown code block. Assume that a, b, and n are all positive integers. Let f (i) be the i-th fraction of the fraction a / b (0 ≤ f (i) ≤ 9). At this time, let s be the sum of f (i) from i = 1 to n. s = f (1) + f (2) + ... + f (n) Create a program that reads a, b, n, outp...
{"inputs": ["1 2 1\n2 3 4\n5 4 3\n4 3 2", "1 2 1\n2 3 4\n5 4 3\n7 4 2", "1 2 1\n2 3 2\n5 4 3\n7 3 2", "1 2 1\n2 3 3\n5 4 3\n7 3 2", "1 2 1\n2 4 3\n5 4 3\n7 3 2", "1 2 1\n2 4 3\n5 4 3\n7 3 1", "1 2 1\n2 4 3\n5 1 3\n7 3 1", "2 2 1\n2 4 3\n5 1 3\n7 3 1"], "outputs": ["5\n24\n7\n6\n", "5\n24\n7\n12\n", "5\n12\n7\n6\n", "5\...
234
291
coding
Solve the programming task below in a Python markdown code block. Finally, a COVID vaccine is out on the market and the Chefland government has asked you to form a plan to distribute it to the public as soon as possible. There are a total of $N$ people with ages $a_1, a_2, \ldots, a_N$. There is only one hospital where...
{"inputs": ["2\n10 1\n10 20 30 40 50 60 90 80 100 1\n5 2\n9 80 27 72 79"], "outputs": ["10\n3"]}
508
68
coding
Solve the programming task below in a Python markdown code block. You work in the best consumer electronics corporation, and your boss wants to find out which three products generate the most revenue. Given 3 lists of the same length like these: * products: `["Computer", "Cell Phones", "Vacuum Cleaner"]` * amounts: `[...
{"functional": "_inputs = [[['Computer', 'Cell Phones', 'Vacuum Cleaner'], [3, 24, 8], [199, 299, 399]], [['Cell Phones', 'Vacuum Cleaner', 'Computer', 'Autos', 'Gold', 'Fishing Rods', 'Lego', ' Speakers'], [5, 25, 2, 7, 10, 3, 2, 24], [51, 225, 22, 47, 510, 83, 82, 124]], [['Cell Phones', 'Vacuum Cleaner', 'Computer',...
162
475
coding
Solve the programming task below in a Python markdown code block. B: Hokkaido University Hard Note Please note that the question settings are the same as question A, except for the constraints. story Homura-chan, who passed Hokkaido University and is excited about the beginning of a new life. But in front of her, a...
{"inputs": ["3 3\nB.B\nB..\n.BB", "2 3\nB.B\nB..\n.BB", "1 3\nB-B\n..B\n.BA", "1 1\nB-B\n..B\n.BA", "1 3\nBB.\nB..\n.AA", "3 3\nB.B\nB..\nBB.", "3 3\nB.B\nC..\nBB.", "3 3\nB/B\nC..\nBB."], "outputs": ["4\n", "3\n", "2\n", "0\n", "1\n", "4\n", "4\n", "4\n"]}
555
148
coding
Solve the programming task below in a Python markdown code block. Takahashi is about to assemble a character figure, consisting of N parts called Part 1, Part 2, ..., Part N and N-1 connecting components. Parts are distinguishable, but connecting components are not. Part i has d_i holes, called Hole 1, Hole 2, ..., Hol...
{"inputs": ["2\n1 1\n", "3\n1 1 3\n", "3\n1 1 1\n", "5\n2 1 1 1 3\n", "6\n7 3 5 10 6 4\n", "7\n1 3 3 2 3 1 1\n", "7\n1 5 1 2 5 1 2\n", "8\n6 2 9 9 7 6 2 2\n"], "outputs": ["1\n", "6\n", "0\n", "36\n", "389183858\n", "136080\n", "3024000\n", "621274425\n"]}
420
181
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. Alice and Bob take turns playing a game, with Alice starting first. You are given a string num of even length consisting of digits and '?' characters. On each turn, a player will do the following if there is still at ...
{"functional": "def check(candidate):\n assert candidate(num = \"5023\") == False\n assert candidate(num = \"25??\") == True\n assert candidate(num = \"?3295???\") == False\n\n\ncheck(Solution().sumGame)"}
275
63
coding
Solve the programming task below in a Python markdown code block. Kyoya Ootori is selling photobooks of the Ouran High School Host Club. He has 26 photos, labeled "a" to "z", and he has compiled them into a photo booklet with some photos in some order (possibly with some photos being duplicated). A photo booklet can be...
{"inputs": ["a\n", "y\n", "e\n", "e\n", "y\n", "d\n", "x\n", "c\n"], "outputs": ["51\n", "51\n", "51\n", "51\n", "51\n", "51\n", "51\n", "51\n"]}
299
78
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. A critical point in a linked list is defined as either a local maxima or a local minima. A node is a local maxima if the current node has a value strictly greater than the previous node and the next node. A node is a ...
{"functional": "def check(candidate):\n assert candidate(head = list_node([3,1])) == [-1,-1]\n assert candidate(head = list_node([5,3,1,2,5,1,2])) == [1,3]\n assert candidate(head = list_node([1,3,2,2,3,2,2,2,7])) == [3,3]\n assert candidate(head = list_node([2,3,3,2])) == [-1,-1]\n\n\ncheck(Solution().node...
254
125
coding
Solve the programming task below in a Python markdown code block. You are given an integer N. Is there a permutation of digits of integer that's divisible by 8? A permutation of digits of integer N is defined as an integer formed by rearranging the digits of N. For example, if the number N = 123, then {123, 132, 213, 2...
{"inputs": ["2\n61\n75\n"], "outputs": ["YES\nNO\n"]}
297
22
coding
Solve the programming task below in a Python markdown code block. Write a function that takes a single array as an argument (containing multiple strings and/or positive numbers and/or arrays), and returns one of four possible string values, depending on the ordering of the lengths of the elements in the input array: Y...
{"functional": "_inputs = [[[1, 'b', ['p'], 2]], [[123, 1234, 12345, 123456]], [['a', 'abc', 'abcde', 'ab']], [[[1, 2, 3, 4], [5, 6, 7], [8, 9]]], [[1, 2, 3, 4, 56]], [[['ab', 'cdef', 'g'], ['hi', 'jk', 'lmnopq'], ['rst', 'uv', 'wx'], ['yz']]], [[[1, 23, 456, 78910], ['abcdef', 'ghijklmno', 'pqrstuvwxy'], [[1, 23, 456,...
238
412
coding
Solve the programming task below in a Python markdown code block. Implement a method that accepts 3 integer values a, b, c. The method should return true if a triangle can be built with the sides of given length and false in any other case. (In this case, all triangles must have surface greater than 0 to be accepted)....
{"functional": "_inputs = [[1, 2, 2], [7, 2, 2], [1, 2, 3], [1, 3, 2], [3, 1, 2], [5, 1, 2], [1, 2, 5], [2, 5, 1], [4, 2, 3], [5, 1, 5], [2, 2, 2], [-1, 2, 3], [1, -2, 3], [1, 2, -3], [0, 2, 3]]\n_outputs = [[True], [False], [False], [False], [False], [False], [False], [False], [True], [True], [True], [False], [False],...
94
328
coding
Solve the programming task below in a Python markdown code block. The Academy is a school where each common area is laid out on an $m\times n$ grid and each cell in the grid is $\mbox{1}$ meter by $\mbox{1}$ meter. Danielle is their new head of security, and she wants to place a surveillance camera along every square m...
{"inputs": ["2\n3 3\n3 4\n"], "outputs": ["36\n78\n"]}
572
26
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. A perfectly straight street is represented by a number line. The street has building(s) on it and is represented by a 2D integer array buildings, where buildings[i] = [starti, endi, heighti]. This means that there is ...
{"functional": "def check(candidate):\n assert candidate(buildings = [[1,4,2],[3,9,4]]) == [[1,3,2],[3,4,3],[4,9,4]]\n assert candidate(buildings = [[1,3,2],[2,5,3],[2,8,3]]) == [[1,3,2],[3,8,3]]\n assert candidate(buildings = [[1,2,1],[5,6,1]]) == [[1,2,1],[5,6,1]]\n\n\ncheck(Solution().averageHeightOfBuildin...
430
139
coding
Solve the programming task below in a Python markdown code block. # Number encrypting: cypher ## Part I of Number encrypting Katas *** ## Introduction Back then when the internet was coming up, most search functionalities simply looked for keywords in text to show relevant documents. Hackers weren't very keen on havin...
{"functional": "_inputs = [['Hello World'], ['I am your father'], ['I do not know what else I can test. Be cool. Good luck'], ['IlRzEeAaSsGbTtBgOo'], ['']]\n_outputs = [['H3110 W0r1d'], ['1 4m y0ur f47h3r'], ['1 d0 n07 kn0w wh47 3153 1 c4n 7357. 83 c001. 600d 1uck'], ['112233445566778900'], ['']]\nimport math\ndef _dee...
678
290
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. You are given an array nums consisting of positive integers. You have to take each integer in the array, reverse its digits, and add it to the end of the array. You should apply this operation to the original integers...
{"functional": "def check(candidate):\n assert candidate(nums = [1,13,10,12,31]) == 6\n assert candidate(nums = [2,2,2]) == 1\n\n\ncheck(Solution().countDistinctIntegers)"}
108
61
coding
Solve the programming task below in a Python markdown code block. Vacations have arrived and Chef wants to go to his home in ChefLand. There are two types of routes he can take: Take a flight from his college to ChefArina which takes X minutes and then take a bus from ChefArina to ChefLand which takes Y minutes. Take...
{"inputs": ["3\n10 12 11\n3 5 15\n9 4 13\n"], "outputs": ["TRAIN\nPLANEBUS\nEQUAL\n"]}
474
43
coding
Solve the programming task below in a Python markdown code block. The hero of our story, Valera, and his best friend Arcady are still in school, and therefore they spend all the free time playing turn-based strategy "GAGA: Go And Go Again". The gameplay is as follows. There are two armies on the playing field each of...
{"inputs": ["6\n", "8\n", "2\n", "4\n", "10\n", "16\n", "98\n", "18\n"], "outputs": ["9", "12", "3", "6", "15", "24\n", "147\n", "27\n"]}
400
75
coding
Solve the programming task below in a Python markdown code block. A circular array of length N is defined as follows: N integers A_{1},A_{2},…,A_{N} are placed in a circle in such a way that for each 1 ≤ i < N, A_{i} and A_{i+1} are adjacent, and A_{1} and A_{N} are also adjacent. You are given a circular array A of l...
{"inputs": ["4\n6 1\n0 1 0 1 0 0\n3 0\n0 1 2\n8 2\n0 0 0 2 0 0 0 5\n3 10\n1 2 3"], "outputs": ["6\n3\n23\n66"]}
702
77
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. You are given an array nums of size n consisting of distinct integers from 1 to n and a positive integer k. Return the number of non-empty subarrays in nums that have a median equal to k. Note: The median of an array...
{"functional": "def check(candidate):\n assert candidate(nums = [3,2,1,4,5], k = 4) == 3\n assert candidate(nums = [2,3,1], k = 3) == 1\n\n\ncheck(Solution().countSubarrays)"}
180
66
coding
Solve the programming task below in a Python markdown code block. You are given four integers $n$, $c_0$, $c_1$ and $h$ and a binary string $s$ of length $n$. A binary string is a string consisting of characters $0$ and $1$. You can change any character of the string $s$ (the string should be still binary after the c...
{"inputs": ["6\n3 1 1 1\n100\n5 10 100 1\n01010\n5 2 1 1\n11101\n5 1 10 1\n11111\n12 2 1 9\n101110110101\n2 100 1 0\n00\n", "6\n3 1 1 0\n110\n5 5 100 1\n01000\n5 3 1 1\n11111\n5 1 10 2\n11111\n12 2 1 10\n101110110101\n2 100 0 10\n00\n", "6\n3 1 1 1\n100\n5 10 100 1\n01000\n5 3 0 1\n11111\n5 1 10 1\n10111\n12 4 1 10\n10...
574
929
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. Hercy wants to save money for his first car. He puts money in the Leetcode bank every day. He starts by putting in $1 on Monday, the first day. Every day from Tuesday to Sunday, he will put in $1 more than the day bef...
{"functional": "def check(candidate):\n assert candidate(n = 4) == 10\n assert candidate(n = 10) == 37\n assert candidate(n = 20) == 96\n\n\ncheck(Solution().totalMoney)"}
147
60
coding
Solve the programming task below in a Python markdown code block. The Little Elephant from the Zoo of Lviv currently is on the military mission. There are N enemy buildings placed in a row and numbered from left to right strating from 0. Each building i (except the first and the last) has exactly two adjacent buildings...
{"inputs": ["3\n3\n010\n5\n10001\n7\n0000000", "3\n3\n011\n5\n10001\n7\n0000000", "3\n3\n010\n5\n10001\n7\n0010000", "3\n3\n010\n5\n10001\n7\n1010000", "3\n3\n010\n5\n10000\n7\n1010000", "3\n3\n010\n5\n10011\n7\n0000000", "3\n3\n001\n5\n10101\n7\n0000000", "3\n3\n010\n5\n00011\n7\n1010000"], "outputs": ["0\n1\n7", "0\n...
318
285
coding
Solve the programming task below in a Python markdown code block. Read problem statements in [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well. Zanka finds fun in everyday simple things. One fine day he got interested in a very trivial sequence. Given a natural number $k$, he considers the sequence $A...
{"inputs": ["1\n1"], "outputs": ["6"]}
422
14
coding
Solve the programming task below in a Python markdown code block. Little Artem likes electronics. He can spend lots of time making different schemas and looking for novelties in the nearest electronics store. The new control element was delivered to the store recently and Artem immediately bought it. That element can ...
{"inputs": ["5 5 1\n1 5\n", "5 5 1\n1 4\n", "9 5 1\n1 4\n", "5 6 1\n1 4\n", "4 6 1\n1 4\n", "5 7 1\n1 5\n", "9 5 1\n1 7\n", "9 5 1\n1 5\n"], "outputs": ["0 0 0 0 0\n0 0 0 0 0\n0 0 0 0 0\n0 0 0 0 0\n0 0 0 0 0\n", "0 0 0 0 0\n0 0 0 0 0\n0 0 0 0 0\n0 0 0 0 0\n0 0 0 0 0\n", "0 0 0 0 0\n0 0 0 0 0\n0 0 0 0 0\n0 0 0 0 0\n0 0 ...
693
666
coding
Solve the programming task below in a Python markdown code block. When you want to get the square of a binomial of two variables x and y, you will have: `$(x+y)^2 = x^2 + 2xy + y ^2$` And the cube: `$(x+y)^3 = x^3 + 3x^2y + 3xy^2 +y^3$` It is known from many centuries ago that for an exponent n, the result of a bin...
{"functional": "_inputs = [[0], [1], [2], [3], [6], [10]]\n_outputs = [[[1, 1]], [[1, 2, 3]], [[1, 2, 4, 7]], [[1, 2, 4, 8, 15]], [[1, 2, 4, 8, 16, 32, 64, 127]], [[1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2047]]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n ...
441
289
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. A transaction is possibly invalid if: the amount exceeds $1000, or; if it occurs within (and including) 60 minutes of another transaction with the same name in a different city. You are given an array of strings tra...
{"functional": "def check(candidate):\n assert candidate(transactions = [\"alice,20,800,mtv\",\"alice,50,100,beijing\"]) == [\"alice,20,800,mtv\",\"alice,50,100,beijing\"]\n assert candidate(transactions = [\"alice,20,800,mtv\",\"alice,50,1200,mtv\"]) == [\"alice,50,1200,mtv\"]\n assert candidate(transactions ...
144
185
coding
Solve the programming task below in a Python markdown code block. Teddy and Freddy are two friends. Teddy has a pile of strings of size $N$. Each string $Si$ in the pile has length less or equal to $100$ ($len(Si) \leq 100$). Teddy and Freddy like playing with strings. Teddy gives Freddy a string $B$ of size $M$. Tedd...
{"inputs": ["4\na\naa\naaa\naaaa\n5\naaaaa", "4\na\nabc\nabcd\nabcde\n5\naaaaa"], "outputs": ["4", "1"]}
412
45
coding
Solve the programming task below in a Python markdown code block. Given a set of $n$ intervals, find the size of its largest possible subset of intervals such that no three intervals in the subset share a common point. Input Format The first line contains an integer, $\boldsymbol{\mathrm{~S~}}$, denoting the number o...
{"inputs": ["4\n3\n1 2\n2 3\n2 4\n3\n1 5\n1 5\n1 5\n4\n1 10\n1 3\n4 6\n7 10\n4\n1 10\n1 3\n3 6\n7 10\n"], "outputs": ["2\n2\n4\n3\n"]}
598
88
coding
Solve the programming task below in a Python markdown code block. A football league of N teams is taking place, where each team plays other teams once in [single round robin] fashion. A team gets 3 points for winning a game and 0 for losing (assume that no games end in a draw/tie). What is the maximum possible differen...
{"inputs": ["4\n2\n3\n4\n9"], "outputs": ["3\n3\n6\n12"]}
435
27
coding
Solve the programming task below in a Python markdown code block. We define subsequence as any subset of an array. We define a subarray as a contiguous subsequence in an array. Given an array, find the maximum possible sum among: all nonempty subarrays. all nonempty subsequences. Print the two values as space-s...
{"inputs": ["1\n5\n-2 -3 -1 -4 -6\n", "2\n4\n1 2 3 4\n6\n2 -1 2 3 4 -5\n"], "outputs": ["-1 -1\n", "10 10\n10 11\n"]}
568
72
coding
Solve the programming task below in a Python markdown code block. Given two integer arrays where the second array is a shuffled duplicate of the first array with one element missing, find the missing element. Please note, there may be duplicates in the arrays, so checking if a numerical value exists in one and not the...
{"functional": "_inputs = [[[1, 2, 3], [1, 3]], [[6, 1, 3, 6, 8, 2], [3, 6, 6, 1, 2]], [[7], []], [[4, 3, 3, 61, 8, 8], [8, 61, 8, 3, 4]], [[0, 0, 0, 0, 0], [0, 0, 0, 0]]]\n_outputs = [[2], [8], [7], [3], [0]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n ret...
179
278
coding
Solve the programming task below in a Python markdown code block. Chef Dengklek will open a new restaurant in the city. The restaurant will be open for N days. He can cook M different types of dish. He would like to cook a single dish every day, such that for the entire N days, he only cook at most K distinct types of ...
{"inputs": ["4\n1 1 1\n2 2 2\n4 3 2\n5 7 3"], "outputs": ["1\n4\n45\n5887"]}
267
46
coding
Solve the programming task below in a Python markdown code block. The characters of Chima need your help. Their weapons got mixed up! They need you to write a program that accepts the name of a character in Chima then tells which weapon he/she owns. For example: for the character `"Laval"` your program should return t...
{"functional": "_inputs = [['Laval'], ['Crominus'], ['Lagravis'], ['Cragger'], ['Tormak'], ['LiElla'], [\"G'loona\"], ['Stinkin gorillas'], ['qwertyuiopasdfghjklzxcvbnm']]\n_outputs = [['Laval-Shado Valious'], ['Crominus-Grandorius'], ['Lagravis-Blazeprowlor'], ['Cragger-Vengdualize'], ['Tormak-Tygafyre'], ['LiElla-Roa...
179
279
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. Given the head of a linked list, rotate the list to the right by k places.   Please complete the following python code precisely: ```python # Definition for singly-linked list. # class ListNode: # def __init__(sel...
{"functional": "def check(candidate):\n assert is_same_list(candidate(head = list_node([1,2,3,4,5]), k = 2), list_node([4,5,1,2,3]))\n assert is_same_list(candidate(head = list_node([0,1,2]), k = 4), list_node([2,0,1]))\n\n\ncheck(Solution().rotateRight)"}
114
93
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. You are given a 0-indexed array usageLimits of length n. Your task is to create groups using numbers from 0 to n - 1, ensuring that each number, i, is used no more than usageLimits[i] times in total across all groups....
{"functional": "def check(candidate):\n assert candidate(usageLimits = [1,2,5]) == 3\n assert candidate(usageLimits = [2,1,2]) == 2\n assert candidate(usageLimits = [1,1]) == 1\n\n\ncheck(Solution().maxIncreasingGroups)"}
170
72
coding
Solve the programming task below in a Python markdown code block. This is now a little serie :) Funny Dots You will get two Integer n (width) and m (height) and your task is to draw following pattern. Each line is seperated with '\n'. Both integers are equal or greater than 1. No need to check for invalid parameters...
{"functional": "_inputs = [[1, 1], [3, 2]]\n_outputs = [['+---+\\n| o |\\n+---+'], ['+---+---+---+\\n| o | o | o |\\n+---+---+---+\\n| o | o | o |\\n+---+---+---+']]\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=...
207
219
coding
Solve the programming task below in a Python markdown code block. The new operating system BerOS has a nice feature. It is possible to use any number of characters '/' as a delimiter in path instead of one traditional '/'. For example, strings //usr///local//nginx/sbin// and /usr/local/nginx///sbin are equivalent. The ...
{"inputs": ["/\n", "////\n", "/a/b/c\n", "/b/b/c\n", "/c/b/c\n", "/aa//b/aa\n", "/a//aa/a//\n", "////a//b/////g\n"], "outputs": ["/\n", "/\n", "/a/b/c\n", "/b/b/c\n", "/c/b/c\n", "/aa/b/aa\n", "/a/aa/a\n", "/a/b/g\n"]}
214
107
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. Given a positive integer n, there exists a 0-indexed array called powers, composed of the minimum number of powers of 2 that sum to n. The array is sorted in non-decreasing order, and there is only one way to form the...
{"functional": "def check(candidate):\n assert candidate(n = 15, queries = [[0,1],[2,2],[0,3]]) == [2,4,64]\n assert candidate(n = 2, queries = [[0,0]]) == [2]\n\n\ncheck(Solution().productQueries)"}
214
73
coding
Solve the programming task below in a Python markdown code block. You are given two arrays A and B, each of size n. The error, E, between these two arrays is defined $E = \sum_{i = 1}^{n}(a_{i} - b_{i})^{2}$. You have to perform exactly k_1 operations on array A and exactly k_2 operations on array B. In one operation, ...
{"inputs": ["1 5 7\n1\n2\n", "1 0 6\n0\n0\n", "1 1 2\n0\n8\n", "1 5 7\n1\n2\n", "1 1 2\n0\n8\n", "1 0 6\n0\n0\n", "1 5 7\n0\n2\n", "1 5 7\n0\n1\n"], "outputs": ["1", "0", "25", "1\n", "25\n", "0\n", "0\n", "1\n"]}
695
133
coding
Solve the programming task below in a Python markdown code block. Roma is programmer and he likes memes about IT, Maxim is chemist and he likes memes about chemistry, Danik is designer and he likes memes about design, and Vlad likes all other memes. ___ You will be given a meme (string), and your task is to ide...
{"functional": "_inputs = [['This is programmer meme ecause it has bug'], ['This is also programbur meme gecause it has needed key word'], ['This is edsigner meme cause it has key word'], ['This could be chemistry meme but our gey word boom is too late'], ['This is meme']]\n_outputs = [['Roma'], ['Roma'], ['Danik'], ['...
350
229
coding
Solve the programming task below in a Python markdown code block. Rachel has a date and tells everyone she is not mad at Ross but doesn't have any feelings for him anymore either. Seeing her date for the first time, everyone notices that he looks exactly like Ross. However, Rachel refuses to believe so. Rachel makes a...
{"inputs": ["3\n4 2 2\n1 7 7 5\n1 8 1 2\n5 1 3\n9 8 7 2 5\n5 4 1 8 9\n3 3 0\n2 3 4\n2 3 4\n"], "outputs": ["YES\nNO\nYES\n"]}
564
84
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. Alice manages a company and has rented some floors of a building as office space. Alice has decided some of these floors should be special floors, used for relaxation only. You are given two integers bottom and top, w...
{"functional": "def check(candidate):\n assert candidate(bottom = 2, top = 9, special = [4,6]) == 3\n assert candidate(bottom = 6, top = 8, special = [7,6,8]) == 0\n\n\ncheck(Solution().maxConsecutive)"}
151
70
coding
Solve the programming task below in a Python markdown code block. Given a square table sized NxN (3 ≤ N ≤ 5,000; rows and columns are indexed from 1) with a robot on it. The robot has a mission of moving from cell (1, 1) to cell (N, N) using only the directions "right" or "down". You are requested to find the number of...
{"inputs": ["4 2\n4 3\n5 3\n0 0", "2 2\n4 3\n5 3\n0 0", "2 2\n5 3\n5 3\n0 0", "2 1\n4 3\n5 3\n0 0", "2 1\n4 2\n5 3\n0 0", "2 2\n5 5\n5 2\n0 0", "2 1\n3 2\n5 3\n0 0", "2 2\n5 0\n5 3\n0 0"], "outputs": ["4\n8\n18", "774058230\n8\n18\n", "774058230\n18\n18\n", "2\n8\n18\n", "2\n4\n18\n", "774058230\n18\n6\n", "2\n2\n18\n"...
318
254
coding
Solve the programming task below in a Python markdown code block. There is a ladder which leads to the door of heaven. Each step of ladder has a card in it. The card is blue if the number printed on it is even otherwise red. Numbers on the ladder is in the following pattern : 1, 2, 3, 5, 8, 13, 21, 34, 55, 89 i.e., N...
{"inputs": ["9\n807\n763\n859\n676\n340\n599\n553\n136\n614"], "outputs": ["798\n798\n798\n798\n188\n188\n188\n44\n798"]}
338
81
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 mapping which represents the mapping rule of a shuffled decimal system. mapping[i] = j means digit i should be mapped to digit j in this system. The mapped value of an integer i...
{"functional": "def check(candidate):\n assert candidate(mapping = [8,9,4,0,2,1,3,5,7,6], nums = [991,338,38]) == [338,38,991]\n assert candidate(mapping = [0,1,2,3,4,5,6,7,8,9], nums = [789,456,123]) == [123,456,789]\n\n\ncheck(Solution().sortJumbled)"}
198
130
coding
Solve the programming task below in a Python markdown code block. # Task Let's call `product(x)` the product of x's digits. Given an array of integers a, calculate `product(x)` for each x in a, and return the number of distinct results you get. # Example For `a = [2, 8, 121, 42, 222, 23]`, the output should be `3`....
{"functional": "_inputs = [[[2, 8, 121, 42, 222, 23]], [[239]], [[100, 101, 111]], [[100, 23, 42, 239, 22339, 9999999, 456, 78, 228, 1488]], [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]]]\n_outputs = [[3], [1], [2], [10], [10]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a...
332
335
coding
Solve the programming task below in a Python markdown code block. The mayor of your city has decided to throw a party to gather the favour of his people in different regions of the city. There are 3 distinct regions in the city namely A, B, C comprising of P_{A}, P_{B} and P_{C} number of people respectively. Howev...
{"inputs": ["3\n2 3 4\n1 5 2\n8 8 8\n"], "outputs": ["6\n5\n16\n"]}
384
37
coding
Solve the programming task below in a Python markdown code block. ## Task Complete the function that receives an array of strings (`arr`) as an argument and returns all the valid Roman numerals. Basic Roman numerals are denoted as: ``` I: 1, V: 5, X: 10, L: 50, C: 100, D: 500, M: 1000 ``` For the purposes of this k...
{"functional": "_inputs = [[['MMMCDLXVL', 'MDLXXXVI', 'DCLXII', 'MMMMCLL', 'MMDCCCLXXXIVCD']], [['MMMMCCCXXXII', 'MMDCCCXXVCD', 'MMCCCXLV', 'DCCLXVIIICD', 'MMMMCXII']], [['DCCLIVI', 'MDCCXXXVVI', 'MDLXXVI', 'MDVIL', 'MCCLXIII']], [['DV', '', 'CLVIII', 'MDCCCXXCD', 'MDCLXVI', 'MMMDCCCLXXXVI']], [['MMCDXVIII', '', 'MMMCC...
630
401
coding
Solve the programming task below in a Python markdown code block. As a part of this Kata, you need to create a function that when provided with a triplet, returns the index of the numerical element that lies between the other two elements. The input to the function will be an array of three distinct numbers (Haskell: ...
{"functional": "_inputs = [[[2, 3, 1]], [[5, 10, 14]], [[1, 3, 4]], [[15, 10, 14]], [[-0.41, -23, 4]], [[-15, -10, 14]]]\n_outputs = [[0], [1], [1], [2], [0], [1]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return math.isclose(a, b, rel_tol=tol, abs_tol=to...
205
235
coding
Solve the programming task below in a Python markdown code block. Gohan has found his way into Dr. Gero's lab. There, he finds a circuit. He starts to toy with it. He finds the inverse transverse function $(V_{in}/V_{out})$ i.e (itf) of the circuit. Dr. Gero finds out about this. He gives Gohan an $s$-controller, thr...
{"inputs": ["2\n4 5 78 60\n4 5 6 3"], "outputs": ["-61.4\n-3.8"]}
478
39
coding
Solve the programming task below in a Python markdown code block. Recently a Golden Circle of Beetlovers was found in Byteland. It is a circle route going through n ⋅ k cities. The cities are numerated from 1 to n ⋅ k, the distance between the neighboring cities is exactly 1 km. Sergey does not like beetles, he loves ...
{"inputs": ["3 3\n1 0\n", "4 3\n1 1\n", "2 1\n0 0\n", "6 3\n1 1\n", "5 5\n2 2\n", "4 3\n1 0\n", "1 1\n0 0\n", "6 3\n0 1\n"], "outputs": ["9 9\n", "1 12\n", "1 2\n", "1 18\n", "1 25\n", "3 12\n", "1 1\n", "9 18\n"]}
740
139
coding
Solve the programming task below in a Python markdown code block. Most of this problem is by the original author of [the harder kata](https://www.codewars.com/kata/556206664efbe6376700005c), I just made it simpler. I read a book recently, titled "Things to Make and Do in the Fourth Dimension" by comedian and mathemati...
{"functional": "_inputs = [[1232], [123220], [0], [1], [141], [1234], [21234], [81352], [987654], [1020005], [9876545], [381654729], [1073741823]]\n_outputs = [[True], [False], [True], [True], [True], [False], [False], [False], [True], [True], [True], [True], [False]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if...
620
282
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. Given a 0-indexed integer array nums, return true if it can be made strictly increasing after removing exactly one element, or false otherwise. If the array is already strictly increasing, return true. The array nums ...
{"functional": "def check(candidate):\n assert candidate(nums = [1,2,10,5,7]) == True\n assert candidate(nums = [2,3,1,2]) == False\n assert candidate(nums = [1,1,1]) == False\n assert candidate(nums = [1,2,3]) == True\n\n\ncheck(Solution().canBeIncreasing)"}
117
87
coding
Solve the programming task below in a Python markdown code block. # Task Given a rectangular `matrix` and integers `a` and `b`, consider the union of the ath row and the bth (both 0-based) column of the `matrix`. Return sum of all elements of that union. # Example For ``` matrix = [[1, 1, 1, 1], [2, 2, 2...
{"functional": "_inputs = [[[[1, 1, 1, 1], [2, 2, 2, 2], [3, 3, 3, 3]], 1, 3], [[[1, 1], [3, 3], [1, 1], [2, 2]], 3, 0], [[[100]], 0, 0], [[[1, 2, 3, 4, 5]], 0, 0], [[[1], [2], [3], [4], [5]], 0, 0]]\n_outputs = [[12], [9], [100], [15], [15]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or i...
331
296
coding
Solve the programming task below in a Python markdown code block. Ilya is a very clever lion, he lives in an unusual city ZooVille. In this city all the animals have their rights and obligations. Moreover, they even have their own bank accounts. The state of a bank account is an integer. The state of a bank account can...
{"inputs": ["10\n", "46\n", "46\n", "10\n", "20\n", "17\n", "16\n", "18\n"], "outputs": ["10\n", "46\n", "46\n", "10\n", "20\n", "17\n", "16\n", "18\n"]}
408
86