task_type
stringclasses
1 value
problem
stringlengths
209
3.39k
answer
stringlengths
35
6.15k
problem_tokens
int64
60
774
answer_tokens
int64
12
2.04k
coding
Solve the programming task below in a Python markdown code block. You have a two-dimensional list in the following format: ```python data = [[2, 5], [3, 4], [8, 7]] ``` Each sub-list contains two items, and each item in the sub-lists is an integer. Write a function `process_data()` that processes each sub-list like ...
{"functional": "_inputs = [[[[2, 5], [3, 4], [8, 7]]], [[[2, 9], [2, 4], [7, 5]]], [[[5, 4], [6, 4]]], [[[2, 1], [5, 3], [7, 4], [10, 6]]]]\n_outputs = [[3], [28], [2], [24]]\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,...
207
240
coding
Solve the programming task below in a Python markdown code block. # Task Determine the client's membership level based on the invested `amount` of money and the given thresholds for membership levels. There are four membership levels (from highest to lowest): `Platinum, Gold, Silver, Bronze` The minimum investment i...
{"functional": "_inputs = [[100000, 1000000, 100000, 10000, 1000], [1001, 1000000, 100000, 10000, 1000], [998, 1000000, 100000, 10000, 1000], [0, 1000000, 100000, 10000, 1000]]\n_outputs = [['Gold'], ['Bronze'], ['Not a member'], ['Not a member']]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float)...
501
308
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 sorted in non-decreasing order. Build and return an integer array result with the same length as nums such that result[i] is equal to the summation of absolute differences between n...
{"functional": "def check(candidate):\n assert candidate(nums = [2,3,5]) == [4,3,5]\n assert candidate(nums = [1,4,6,8,10]) == [24,15,13,15,21]\n\n\ncheck(Solution().getSumAbsoluteDifferences)"}
142
78
coding
Solve the programming task below in a Python markdown code block. As you know America’s Presidential Elections are about to take place and the most popular leader of the Republican party Donald Trump is famous for throwing allegations against anyone he meets. He goes to a rally and meets n people which he wants to off...
{"inputs": ["3\n1\n4\n2\n10 5\n4\n2 3 1 3"], "outputs": ["4\n45\n0"]}
434
38
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. You are standing at position 0 on an infinite number line. There is a destination at position target. You can make some number of moves numMoves so that: On each move, you can either go left or right. During the ith ...
{"functional": "def check(candidate):\n assert candidate(target = 2) == 3\n assert candidate(target = 3) == 2\n\n\ncheck(Solution().reachNumber)"}
144
43
coding
Solve the programming task below in a Python markdown code block. We will say that two integer sequences of length N, x_1, x_2, ..., x_N and y_1, y_2, ..., y_N, are similar when |x_i - y_i| \leq 1 holds for all i (1 \leq i \leq N). In particular, any integer sequence is similar to itself. You are given an integer N a...
{"inputs": ["2\n2 4", "1\n000", "2\n3 6", "1\n011", "2\n2 6", "1\n010", "2\n3 4", "1\n111"], "outputs": ["5\n", "1\n", "7\n", "2\n", "5\n", "1\n", "7\n", "2\n"]}
321
94
coding
Solve the programming task below in a Python markdown code block. Today is your birthday. You have decided to give away candies to your friends. You have N friends and M candies. Suppose the 1^{st} friend has L buckets, 2^{nd} has L+1 buckets, 3^{rd} has L+2 buckets, and so on — in general, the i^{th} friend has L + ...
{"inputs": ["4\n2 8 2\n3 9 2\n3 10 2\n4 100 10"], "outputs": ["0\n1\n0\n9"]}
702
46
coding
Solve the programming task below in a Python markdown code block. Real stupidity beats artificial intelligence every time. — Terry Pratchett, Hogfather, Discworld You are given a string $s$ of length $n$ and a number $k$. Let's denote by $rev(s)$ the reversed string $s$ (i.e. $rev(s) = s_n s_{n-1} ... s_1$). You can ...
{"inputs": ["1\n2 1\nab\n", "1\n3 1\naab\n", "1\n3 1\nabc\n", "1\n4 1\nabcd\n", "1\n4 2\nabca\n", "4\n3 2\naab\n3 3\naab\n7 1\nabacaba\n2 0\nab\n"], "outputs": ["2\n", "2\n", "2\n", "2\n", "2\n", "2\n2\n1\n1\n"]}
523
117
coding
Solve the programming task below in a Python markdown code block. BerPhone X is almost ready for release with n applications being preinstalled on the phone. A category of an application characterizes a genre or a theme of this application (like "game", "business", or "education"). The categories are given as integers ...
{"inputs": ["3\n11\n1 5 1 3 1 5 1 1 1 1 5\n6\n1 2 2 2 2 1\n5\n4 3 3 1 2\n", "3\n11\n1 5 1 3 1 2 1 1 1 1 5\n6\n1 2 2 2 4 1\n5\n4 3 3 1 2\n", "3\n11\n1 5 1 3 2 2 1 1 1 1 5\n6\n1 2 2 2 4 2\n5\n4 3 3 1 2\n", "3\n11\n1 5 1 2 2 2 1 1 1 1 5\n6\n1 2 2 2 4 2\n5\n4 3 3 1 2\n", "3\n11\n2 5 1 5 1 5 1 1 1 1 5\n6\n1 2 2 2 2 1\n5\n4 ...
522
510
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. Given an unsorted integer array nums. Return the smallest positive integer that is not present in nums. You must implement an algorithm that runs in O(n) time and uses O(1) auxiliary space.   Please complete the follo...
{"functional": "def check(candidate):\n assert candidate(nums = [1,2,0]) == 3\n assert candidate(nums = [3,4,-1,1]) == 2\n assert candidate(nums = [7,8,9,11,12]) == 1\n\n\ncheck(Solution().firstMissingPositive)"}
90
76
coding
Solve the programming task below in a Python markdown code block. Chef has a sequence of positive integers $A_1, A_2, \ldots, A_N$. He wants to choose some elements of this sequence (possibly none or all of them) and compute their MEX, i.e. the smallest positive integer which does not occur among the chosen elements. F...
{"inputs": ["1\n3 3\n1 2 4\n"], "outputs": ["3"]}
388
23
coding
Solve the programming task below in a Python markdown code block. In a small town the population is `p0 = 1000` at the beginning of a year. The population regularly increases by `2 percent` per year and moreover `50` new inhabitants per year come to live in the town. How many years does the town need to see its popula...
{"functional": "_inputs = [[1500, 5, 100, 5000], [1500000, 2.5, 10000, 2000000], [1500000, 0.25, 1000, 2000000], [1500000, 0.25, -1000, 2000000], [1500000, 0.25, 1, 2000000], [1500000, 0.0, 10000, 2000000]]\n_outputs = [[15], [10], [94], [151], [116], [50]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance...
454
341
coding
Solve the programming task below in a Python markdown code block. You work in the quality control department of technical support for a large company. Your job is to make sure all client issues have been resolved. Today you need to check a copy of a dialog between a client and a technical support manager. According to...
{"inputs": ["5\n4\nQQAA\n4\nQQAQ\n3\nQAA\n1\nQ\n14\nQAQQAQAAQQQAAA\n"], "outputs": ["Yes\nNo\nYes\nNo\nYes\n"]}
511
54
coding
Solve the programming task below in a Python markdown code block. You are given two integers N \ ( N ≥ 2) and S. You have to construct an array A containing N integers such that: 0 ≤ A_{i} ≤ S for each 1 ≤ i ≤ N A_{1} + A_{2} + \ldots + A_{N} = S A_{1} \mathbin{\&} A_{2} \mathbin{\&} \ldots \mathbin{\&} A_{N} = 0, wher...
{"inputs": ["4\n2 7\n3 6\n5 21\n100 256455\n"], "outputs": ["4\n3\n5\n2570\n"]}
497
47
coding
Solve the programming task below in a Python markdown code block. Given is a string S representing the day of the week today. S is SUN, MON, TUE, WED, THU, FRI, or SAT, for Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, and Saturday, respectively. After how many days is the next Sunday (tomorrow or later)? ----...
{"inputs": ["SUN", "SAT", "SAT\n", "SUN\n", "FRI\n", "MON\n", "THU\n", "TUE\n"], "outputs": ["7", "1", "1\n", "7\n", "2\n", "6\n", "3\n", "5\n"]}
156
71
coding
Solve the programming task below in a Python markdown code block. One day Vasya decided to have a look at the results of Berland 1910 Football Championship’s finals. Unfortunately he didn't find the overall score of the match; however, he got hold of a profound description of the match's process. On the whole there are...
{"inputs": ["1\nABB\n", "1\nAAB\n", "1\nBAB\n", "1\nBAC\n", "1\nACB\n", "1\nCAB\n", "1\nC@B\n", "1\nB@C\n"], "outputs": ["ABB\n", "AAB\n", "BAB\n", "BAC\n", "ACB\n", "CAB\n", "C@B\n", "B@C\n"]}
272
102
coding
Solve the programming task below in a Python markdown code block. You are given string $s$ of length $n$ consisting of 0-s and 1-s. You build an infinite string $t$ as a concatenation of an infinite number of strings $s$, or $t = ssss \dots$ For example, if $s =$ 10010, then $t =$ 100101001010010... Calculate the numb...
{"inputs": ["1\n1 1\n0\n", "1\n1 0\n1\n", "1\n1 0\n1\n", "1\n1 1\n0\n", "1\n1 -1\n1\n", "1\n2 2\n00\n", "1\n2 2\n00\n", "1\n1 -1\n1\n"], "outputs": ["1\n", "1\n", "1\n", "1\n", "1\n", "1\n", "1\n", "1\n"]}
551
120
coding
Solve the programming task below in a Python markdown code block. After bracket sequences Arthur took up number theory. He has got a new favorite sequence of length n (a1, a2, ..., an), consisting of integers and integer k, not exceeding n. This sequence had the following property: if you write out the sums of all its...
{"inputs": ["1 1\n0\n", "1 1\n?\n", "1 1\n-1\n", "3 1\n4 ? 5\n", "3 2\n4 ? 5\n", "3 2\n? 1 2\n", "3 1\n-5 ? 0\n", "3 1\n-1 ? 1\n"], "outputs": ["0\n", "0\n", "-1 ", "Incorrect sequence\n", "4 0 5 ", "0 1 2\n", "-5 -1 0\n", "-1 0 1\n"]}
580
136
coding
Solve the programming task below in a Python markdown code block. Read problem statements in [Mandarin Chinese] and [Russian]. Chef opted for Bio-Statistics as an Open-Elective course in his university, but soon got bored, and decided to text his friends during lectures. The instructor caught Chef, and decided to puni...
{"inputs": ["2\n8\n5 9 2 9 7 2 5 3\n9\n5 9 2 9 7 2 5 3 1"], "outputs": ["2\n1"]}
663
52
coding
Solve the programming task below in a Python markdown code block. Little girl Tanya climbs the stairs inside a multi-storey building. Every time Tanya climbs a stairway, she starts counting steps from $1$ to the number of steps in this stairway. She speaks every number aloud. For example, if she climbs two stairways, t...
{"inputs": ["1\n1\n", "1\n1\n", "2\n1 2\n", "2\n1 2\n", "2\n1 1\n", "3\n1 1 2\n", "3\n1 1 2\n", "3\n1 1 1\n"], "outputs": ["1\n1 ", "1\n1 ", "1\n2 ", "1\n2 ", "2\n1 1 ", "2\n1 2 ", "2\n1 2 ", "3\n1 1 1 "]}
469
123
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. You are given an integer n. We say that two integers x and y form a prime number pair if: 1 <= x <= y <= n x + y == n x and y are prime numbers Return the 2D sorted list of prime number pairs [xi, yi]. The list shou...
{"functional": "def check(candidate):\n assert candidate(n = 10) == [[3,7],[5,5]]\n assert candidate(n = 2) == []\n\n\ncheck(Solution().findPrimePairs)"}
158
53
coding
Solve the programming task below in a Python markdown code block. Given are two integer sequences of N elements each: A_1,...,A_N and B_1,...,B_N. Determine if it is possible to do the following operation at most N-2 times (possibly zero) so that, for every integer i from 1 to N, A_i \leq B_i holds: * Choose two disti...
{"inputs": ["3\n1 3 3\n2 2 2", "3\n1 3 2\n2 2 3", "3\n1 3 6\n2 2 2", "3\n1 3 2\n3 2 3", "3\n1 3 6\n2 2 4", "3\n2 3 2\n3 2 3", "3\n1 3 6\n3 2 4", "3\n2 3 2\n5 2 3"], "outputs": ["No\n", "Yes\n", "No\n", "Yes\n", "No\n", "Yes\n", "No\n", "Yes\n"]}
274
158
coding
Solve the programming task below in a Python markdown code block. Autocomplete is a program function that enables inputting the text (in editors, command line shells, browsers etc.) completing the text by its inputted part. Vasya is busy working on a new browser called 'BERowser'. He happens to be working on the autoco...
{"inputs": ["find\n4\nfind\nfindfirstof\nfindit\nf", "fjnd\n4\nfind\nfindfirstof\nfindit\nf", "njfd\n4\nfind\nfotsqifdmig\nfindit\nf", "dfjn\n4\nfind\nfotsqifdmig\nfindit\nf", "dfjm\n4\nfinc\ngimdfiqstpf\nfiidnt\nf", "fjnd\n4\nfind\nfindfiqstof\nfindit\nf", "fjnd\n4\nfind\nfotsqifdnif\nfindit\nf", "fjnd\n4\nfind\nfotsq...
356
207
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. You are given an array of events where events[i] = [startDayi, endDayi]. Every event i starts at startDayi and ends at endDayi. You can attend an event i at any day d where startTimei <= d <= endTimei. You can only at...
{"functional": "def check(candidate):\n assert candidate(events = [[1,2],[2,3],[3,4]]) == 3\n assert candidate(events= [[1,2],[2,3],[3,4],[1,2]]) == 4\n\n\ncheck(Solution().maxEvents)"}
125
67
coding
Solve the programming task below in a Python markdown code block. You are given a string S consisting of digits between 1 and 9, inclusive. You can insert the letter + into some of the positions (possibly none) between two letters in this string. Here, + must not occur consecutively after insertion. All strings that ca...
{"inputs": ["0", "1", "2", "4", "3", "5", "9", "8"], "outputs": ["0\n", "1\n", "2\n", "4\n", "3\n", "5\n", "9\n", "8\n"]}
274
62
coding
Solve the programming task below in a Python markdown code block. You are given two positive integers $\class{ML__boldsymbol}{\boldsymbol{a}}$ and $\boldsymbol{b}$ in binary representation. You should find the following sum modulo $10^9+7$: $\sum\limits_{i=0}^{314159}\left(a\:x or\left(b\:s h l\:i\right)\right)$ wher...
{"inputs": ["10\n1010\n"], "outputs": ["489429555\n"]}
295
28
coding
Solve the programming task below in a Python markdown code block. # Introduction Digital Cypher assigns to each letter of the alphabet unique number. For example: ``` a b c d e f g h i j k l m 1 2 3 4 5 6 7 8 9 10 11 12 13 n o p q r s t u v w x y z 14 15 16 17 18 19 20 21 22 23 24 ...
{"functional": "_inputs = [['scout', 1939], ['masterpiece', 1939]]\n_outputs = [[[20, 12, 18, 30, 21]], [[14, 10, 22, 29, 6, 27, 19, 18, 6, 12, 8]]]\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...
752
229
coding
Solve the programming task below in a Python markdown code block. We arrange the numbers between 1 and N (1 <= N <= 10000) in increasing order and decreasing order like this: 1 2 3 4 5 6 7 8 9 . . . N N . . . 9 8 7 6 5 4 3 2 1 Two numbers faced each other form a pair. Your task is to compute the number of pairs P s...
{"inputs": ["1\n0\n6\n1", "1\n0\n9\n1", "1\n1\n8\n3", "1\n8\n9\n1", "1\n1\n2\n3", "1\n5\n0\n3", "1\n8\n7\n51", "1\n3\n20\n1"], "outputs": ["0\n0\n2\n0\n", "0\n0\n3\n0\n", "0\n0\n2\n1\n", "0\n2\n3\n0\n", "0\n0\n0\n1\n", "0\n1\n0\n1\n", "0\n2\n2\n6\n", "0\n1\n2\n0\n"]}
170
160
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 consisting of n non-negative integers. You are also given an array queries, where queries[i] = [xi, yi]. The answer to the ith query is the sum of all nums[j] where xi <= j...
{"functional": "def check(candidate):\n assert candidate(nums = [0,1,2,3,4,5,6,7], queries = [[0,3],[5,1],[4,2]]) == [9,18,10]\n assert candidate(nums = [100,200,101,201,102,202,103,203], queries = [[0,7]]) == [303]\n\n\ncheck(Solution().solve)"}
151
118
coding
Solve the programming task below in a Python markdown code block. Create a function that accepts 3 inputs, a string, a starting location, and a length. The function needs to simulate the string endlessly repeating in both directions and return a substring beginning at the starting location and continues for length. E...
{"functional": "_inputs = [['xyz', -23, 6], ['xyz', 0, 4], ['xyz', 19, 2], ['xyz', -4, -4], ['abcdefghijklmnopqrstuvwxyz', 29, 1], ['Hello! How are you?', -14, 27], ['1x2x3x4x', 1532, 100], ['1x2x3x4x', -1532, -100], ['112233', 0, 0], ['112233', -1, 0], ['112233', 15824, 0]]\n_outputs = [['yzxyzx'], ['xyzx'], ['yz'], [...
329
540
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. You are given an n x n grid where we place some 1 x 1 x 1 cubes that are axis-aligned with the x, y, and z axes. Each value v = grid[i][j] represents a tower of v cubes placed on top of the cell (i, j). We view the pr...
{"functional": "def check(candidate):\n assert candidate([[1,2],[3,4]]) == 17\n assert candidate(grid = [[2]]) == 5\n assert candidate([[1,0],[0,2]]) == 8\n\n\ncheck(Solution().projectionArea)"}
181
64
coding
Solve the programming task below in a Python markdown code block. Alex just got a new hula hoop, he loves it but feels discouraged because his little brother is better than him Write a program where Alex can input (n) how many times the hoop goes round and it will return him an encouraging message :) -If Alex gets 1...
{"functional": "_inputs = [[6], [10], [22]]\n_outputs = [['Keep at it until you get it'], ['Great, now move on to tricks'], ['Great, now move on to tricks']]\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 ...
131
187
coding
Solve the programming task below in a Python markdown code block. Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well. During a boring night at the restaurant, Chef decided to play with spaghetti. He has $R-L+1$ spaghetti: exactly one spaghetti with each length betwee...
{"inputs": ["2\n1 2\n3 5"], "outputs": ["3\n7"]}
354
22
coding
Solve the programming task below in a Python markdown code block. There is a building with n rooms, numbered 1 to n. We can move from any room to any other room in the building. Let us call the following event a move: a person in some room i goes to another room j~ (i \neq j). Initially, there was one person in each ro...
{"inputs": ["1 2", "4 2", "4 4", "5 4", "6 2", "9 2", "3 4", "3 2"], "outputs": ["1\n", "31\n", "35\n", "126\n", "181\n", "1081\n", "10\n", "10"]}
458
88
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. You want to water n plants in your garden with a watering can. The plants are arranged in a row and are labeled from 0 to n - 1 from left to right where the ith plant is located at x = i. There is a river at x = -1 th...
{"functional": "def check(candidate):\n assert candidate(plants = [2,2,3,3], capacity = 5) == 14\n assert candidate(plants = [1,1,1,4,2,3], capacity = 4) == 30\n assert candidate(plants = [7,7,7,7,7,7,7], capacity = 8) == 49\n\n\ncheck(Solution().wateringPlants)"}
263
106
coding
Solve the programming task below in a Python markdown code block. You are given an integer sequence of length N, a_1,a_2,...,a_N. For each 1≤i≤N, you have three choices: add 1 to a_i, subtract 1 from a_i or do nothing. After these operations, you select an integer X and count the number of i such that a_i=X. Maximize t...
{"inputs": ["1\n99999\n", "7\n3 1 4 1 5 9 2\n", "10\n0 1 2 3 4 5 6 7 8 9\n"], "outputs": ["1\n", "4\n", "3\n"]}
239
71
coding
Solve the programming task below in a Python markdown code block. Have you heard about Megamind? Megamind and Metro Man are two aliens who came to earth. Megamind wanted to destroy the earth, while Metro Man wanted to stop him and protect mankind. After a lot of fighting, Megamind finally threw Metro Man up into the sk...
{"functional": "_inputs = [[12, 4, 3, 2], [9, 4, 2, 7], [13, 4, 3, 1], [13, 4, 3, 50], [36, 4, 3, 2], [15, 4, 3, 12], [100000, 99999, 100000, 100000], [100000, 100000, 100000, 100000], [100000, 1, 50000, 49999], [100000, 1, 1000, 999], [17, 4, 4, 16], [23, 4, 4, 13], [1, 4, 4, 15], [22, 4, 4, 13], [16, 4, 4, 16], [20, ...
684
490
coding
Solve the programming task below in a Python markdown code block. Let f(n) be the number of triples of integers (x,y,z) that satisfy both of the following conditions: * 1 \leq x,y,z * x^2 + y^2 + z^2 + xy + yz + zx = n Given an integer N, find each of f(1),f(2),f(3),\ldots,f(N). Constraints * All values in input ...
{"inputs": ["3", "2", "4", "8", "1", "5", "6", "9"], "outputs": ["0\n0\n0\n", "0\n0\n", "0\n0\n0\n0\n", "0\n0\n0\n0\n0\n1\n0\n0\n", "0\n", "0\n0\n0\n0\n0\n", "0\n0\n0\n0\n0\n1\n", "0\n0\n0\n0\n0\n1\n0\n0\n0\n"]}
201
122
coding
Solve the programming task below in a Python markdown code block. Ivan unexpectedly saw a present from one of his previous birthdays. It is array of $n$ numbers from $1$ to $200$. Array is old and some numbers are hard to read. Ivan remembers that for all elements at least one of its neighbours ls not less than it, mor...
{"inputs": ["2\n2 9\n", "2\n1 9\n", "2\n1 2\n", "2\n1 3\n", "2\n2 21\n", "2\n1 21\n", "2\n3 30\n", "2\n1 30\n"], "outputs": ["0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n"]}
422
106
coding
Solve the programming task below in a Python markdown code block. Fukushima Prefecture is also famous for producing fruits, and among them, peaches and apples boast one of the highest production volumes in Japan. By the way, when I made a print manuscript of an English pamphlet for sale, I mistakenly wrote the descript...
{"inputs": ["the cost of one peach is higher than th`t of one apple.", "the cost of ooe peach is higher than th`t of one apple.", "the cost of ooe peach is higher than th`t of eno apple.", "the cpst of ooe peach is higher than th`t of eno apple.", "the cpst of ooe peach is higher than t`ht of eno apple.", "eht cpst of ...
217
311
coding
Solve the programming task below in a Python markdown code block. There are n kangaroos with pockets. Each kangaroo has a size (integer number). A kangaroo can go into another kangaroo's pocket if and only if the size of kangaroo who hold the kangaroo is at least twice as large as the size of kangaroo who is held. Eac...
{"inputs": ["1\n1\n", "1\n1\n", "1\n2\n", "1\n3\n", "1\n6\n", "3\n1\n2\n4\n", "3\n1\n2\n4\n", "4\n1\n1\n1\n2\n"], "outputs": ["1\n", "1\n", "1\n", "1\n", "1\n", "2\n", "2\n", "3\n"]}
268
100
coding
Solve the programming task below in a Python markdown code block. You are given 2 numbers is `n` and `k`. You need to find the number of integers between 1 and n (inclusive) that contains exactly `k` non-zero digit. Example1 ` almost_everywhere_zero(100, 1) return 19` by following condition we have 19 numbers that ...
{"functional": "_inputs = [[100, 1], [11, 2], [20, 2], [101, 2], [10001, 2], [10001000, 2], [500309160, 2], [10000000000000000000000, 3], [10000000000000000000000, 21], [1203, 4]]\n_outputs = [[19], [1], [9], [82], [487], [1729], [2604], [1122660], [2407217760893271902598], [81]]\nimport math\ndef _deep_eq(a, b, tol=1e...
250
352
coding
Solve the programming task below in a Python markdown code block. Rng is preparing a problem set for a qualification round of CODEFESTIVAL. He has N candidates of problems. The difficulty of the i-th candidate is D_i. There must be M problems in the problem set, and the difficulty of the i-th problem must be T_i. Her...
{"inputs": ["5\n3 1 4 1 5\n3\n5 4 3", "1\n9\n7\n110 100 110 110 100", "1\n9\n7\n100 100 110 110 100", "1\n9\n7\n100 100 110 111 100", "1\n9\n2\n100 100 110 111 100", "1\n9\n2\n100 100 111 111 100", "1\n9\n2\n100 000 111 111 100", "1\n9\n2\n101 000 111 111 100"], "outputs": ["YES", "NO\n", "NO\n", "NO\n", "NO\n", "NO\n"...
438
247
coding
Solve the programming task below in a Python markdown code block. A [perfect power](https://en.wikipedia.org/wiki/Perfect_power) is a classification of positive integers: > In mathematics, a **perfect power** is a positive integer that can be expressed as an integer power of another positive integer. More formally, n ...
{"functional": "_inputs = [[4], [9], [5]]\n_outputs = [[[2, 2]], [[3, 2]], [None]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return math.isclose(a, b, rel_tol=tol, abs_tol=tol)\n if isinstance(a, (list, tuple)):\n if len(a) != len(b): return Fal...
289
172
coding
Solve the programming task below in a Python markdown code block. A new school year is approaching, which also means students will be taking tests. The tests in this kata are to be graded in different ways. A certain number of points will be given for each correct answer and a certain number of points will be deducte...
{"functional": "_inputs = [[[0, 0, 0, 0, 2, 1, 0], 2, 0, 1], [[0, 1, 0, 0, 2, 1, 0, 2, 2, 1], 3, -1, 2], [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 5, -1, 2], [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 2, 2, 0, 0, 0, 0, 1, 1, 2, 2, 2, 2, 0], 6, 0, 1.5], [[0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 0, 2, 1, 2, 0, 2, 1], 10, -5, 10], [[...
429
545
coding
Solve the programming task below in a Python markdown code block. You will be given a string. You need to return an array of three strings by gradually pulling apart the string. You should repeat the following steps until the string length is 1: a) remove the final character from the original string, add to solutio...
{"functional": "_inputs = [['reusetestcasesbitcointakeovertheworldmaybewhoknowsperhaps'], ['turnsoutrandomtestcasesareeasierthanwritingoutbasicones'], ['exampletesthere'], ['letstalkaboutjavascriptthebestlanguage'], ['iwanttotraveltheworldwritingcodeoneday'], ['letsallgoonholidaysomewhereverycold']]\n_outputs = [[['spa...
164
359
coding
Solve the programming task below in a Python markdown code block. # Task The string is called `prime` if it cannot be constructed by concatenating some (more than one) equal strings together. For example, "abac" is prime, but "xyxy" is not("xyxy"="xy"+"xy"). Given a string determine if it is prime or not. # Inpu...
{"functional": "_inputs = [['abac'], ['abab'], ['aaaa'], ['x'], ['abc'], ['fdsyffdsyffdsyffdsyffdsyf'], ['utdutdtdutd'], ['abba']]\n_outputs = [[True], [False], [False], [True], [True], [False], [True], [True]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n re...
146
220
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. The count-and-say sequence is a sequence of digit strings defined by the recursive formula: countAndSay(1) = "1" countAndSay(n) is the run-length encoding of countAndSay(n - 1). Run-length encoding (RLE) is a string...
{"functional": "def check(candidate):\n assert candidate(n = 4) == \"1211\"\n assert candidate(n = 1) == \"1\"\n\n\ncheck(Solution().countAndSay)"}
235
49
coding
Solve the programming task below in a Python markdown code block. You are given two integers a and b. Determine if a+b=15 or a\times b=15 or neither holds. Note that a+b=15 and a\times b=15 do not hold at the same time. Constraints * 1 \leq a,b \leq 15 * All values in input are integers. Input Input is given from ...
{"inputs": ["8 7", "3 7", "2 1", "3 8", "4 1", "8 5", "3 0", "4 0"], "outputs": ["+\n", "x\n", "x\n", "x\n", "x\n", "x\n", "x\n", "x\n"]}
171
78
coding
Solve the programming task below in a Python markdown code block. Unlucky year in Berland is such a year that its number n can be represented as n = x^{a} + y^{b}, where a and b are non-negative integer numbers. For example, if x = 2 and y = 3 then the years 4 and 17 are unlucky (4 = 2^0 + 3^1, 17 = 2^3 + 3^2 = 2^4 +...
{"inputs": ["2 3 3 5\n", "3 2 6 7\n", "3 3 1 1\n", "4 4 1 1\n", "2 2 1 1\n", "2 3 1 1\n", "3 2 6 7\n", "4 4 1 1\n"], "outputs": ["0\n", "1\n", "1\n", "1\n", "1\n", "1\n", "1", "1"]}
415
116
coding
Solve the programming task below in a Python markdown code block. Today s kilometer long auto race takes place in Berland. The track is represented by a straight line as long as s kilometers. There are n cars taking part in the race, all of them start simultaneously at the very beginning of the track. For every car is ...
{"inputs": ["2 33\n2 5 1 2 14\n1 3 11\n", "2 33\n2 1 3 10 3\n1 11 3\n", "2 6\n3 1 2 2 1 1 2\n3 2 1 1 2 2 1\n", "2 5\n3 2 1 1 1 2 1\n3 1 1 2 1 1 2\n", "2 5\n3 2 1 1 1 2 1\n3 1 2 2 1 1 1\n", "2 166755\n2 733 187 362 82\n3 813 147 565 57 557 27\n", "5 33\n2 1 3 3 10\n1 11 3\n2 5 3 3 6\n2 3 1 10 3\n2 6 3 3 5\n", "3 228385\...
575
382
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. Given the head of a sorted linked list, delete all duplicates such that each element appears only once. Return the linked list sorted as well.   Please complete the following python code precisely: ```python # Definit...
{"functional": "def check(candidate):\n assert is_same_list(candidate(head = list_node([1,1,2])), list_node([1,2]))\n assert is_same_list(candidate(head = list_node([1,1,2,3,3])), list_node([1,2,3]))\n\n\ncheck(Solution().deleteDuplicates)"}
119
77
coding
Solve the programming task below in a Python markdown code block. This challenge is based on [the kata](https://www.codewars.com/kata/n-smallest-elements-in-original-order) by GiacomoSorbi. Before doing this one it is advisable to complete the non-performance version first. ___ # Task You will be given an array of r...
{"functional": "_inputs = [[[1, 2, 3, 4, 5], 3], [[5, 4, 3, 2, 1], 3], [[1, 2, 3, 4, 1], 3], [[2, 1, 3, 2, 3], 3]]\n_outputs = [[[1, 2, 3]], [[3, 2, 1]], [[1, 2, 1]], [[2, 1, 2]]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return math.isclose(a, b, rel_tol...
376
259
coding
Solve the programming task below in a Python markdown code block. Chef has two integers A and B. In one operation he can choose any integer d, and make one of the following two moves : Add d to A and subtract d from B. Add d to B and subtract d from A. Chef is allowed to make as many operations as he wants. Can he mak...
{"inputs": ["2\n3 3\n1 2\n"], "outputs": ["Yes\nNo\n"]}
294
24
coding
Solve the programming task below in a Python markdown code block. Sitting in a station waiting room, Joisino is gazing at her train ticket. The ticket is numbered with four digits A, B, C and D in this order, each between 0 and 9 (inclusive). In the formula A op1 B op2 C op3 D = 7, replace each of the symbols op1, op2 ...
{"inputs": ["2364", "1114", "2005", "1455", "1152", "3246", "6120", "2768"], "outputs": ["2+3+6-4=7\n", "1+1+1+4=7\n", "2+0+0+5=7\n", "1-4+5+5=7\n", "1-1+5+2=7\n", "3+2-4+6=7\n", "6-1+2+0=7\n", "2+7+6-8=7\n"]}
235
150
coding
Solve the programming task below in a Python markdown code block. Little Dima has two sequences of points with integer coordinates: sequence (a1, 1), (a2, 2), ..., (an, n) and sequence (b1, 1), (b2, 2), ..., (bn, n). Now Dima wants to count the number of distinct sequences of points of length 2·n that can be assembled...
{"inputs": ["1\n1\n2\n3\n", "1\n1\n3\n3\n", "1\n1\n5\n3\n", "1\n1\n5\n2\n", "1\n1\n2\n7\n", "2\n1 2\n1 2\n4\n", "2\n1 2\n2 2\n4\n", "2\n2 2\n1 2\n4\n"], "outputs": ["1\n", "1\n", "1\n", "1\n", "1\n", "1\n", "3\n", "3\n"]}
484
130
coding
Solve the programming task below in a Python markdown code block. Rachel has some candies and she decided to distribute them among $N$ kids. The ith kid receives $A_i$ candies. The kids are happy iff the difference between the highest and lowest number of candies received is less than $X$. Find out if the children are ...
{"inputs": ["2\n5 6\n3 5 6 8 1\n3 10\n5 2 9"], "outputs": ["NO\nYES"]}
295
39
coding
Solve the programming task below in a Python markdown code block. Let S(n) denote the sum of the digits in the decimal notation of n. For example, S(101) = 1 + 0 + 1 = 2. Given an integer N, determine if S(N) divides N. -----Constraints----- - 1 \leq N \leq 10^9 -----Input----- Input is given from Standard Input in ...
{"inputs": ["12\n", "101\n", "999999999\n", "693828976\n", "873041724\n", "689670774\n", "972655544\n", "506479109\n"], "outputs": ["Yes\n", "No\n", "Yes\n", "No\n", "Yes\n", "Yes\n", "No\n", "Yes\n"]}
165
121
coding
Solve the programming task below in a Python markdown code block. There are $N$ buckets numbered $1$ through $N$. The buckets contain balls; each ball has a color between $1$ and $K$. Let's denote the number of balls with color $j$ that are initially in bucket $i$ by $a_{i, j}$. For each $i$ from $1$ to $N-1$ (in this ...
{"inputs": ["2 2\n0 1\n1 1"], "outputs": ["0.333333 0.666667"]}
469
38
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. Given an m x n binary matrix mat, return the length of the longest line of consecutive one in the matrix. The line could be horizontal, vertical, diagonal, or anti-diagonal.   Please complete the following python code...
{"functional": "def check(candidate):\n assert candidate(mat = [[0,1,1,0],[0,1,1,0],[0,0,0,1]]) == 3\n assert candidate(mat = [[1,1,1,1],[0,1,1,0],[0,0,0,1]]) == 4\n\n\ncheck(Solution().longestLine)"}
87
88
coding
Solve the programming task below in a Python markdown code block. Read problem statements in [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well. You are given a graph $G$ with $N$ vertices (numbered $1$ through $N$) and $M$ edges. You should partition the vertices of $G$ into two sets $A$ and $B$ such ...
{"inputs": ["1\n5 7\n1 3\n1 4\n1 5\n2 3\n2 4\n2 5\n3 4"], "outputs": ["1\n11000"]}
705
50
coding
Solve the programming task below in a Python markdown code block. In order to celebrate Twice's 5th anniversary, Tzuyu and Sana decided to play a game. Tzuyu gave Sana two integers $a$ and $b$ and a really important quest. In order to complete the quest, Sana has to output the smallest possible value of ($a \oplus x$...
{"inputs": ["6\n6 12\n4 4\n7 832\n55 8\n2891 508\n1 1\n", "6\n6 12\n4 4\n1 832\n55 8\n7888 2912\n1 2\n", "6\n6 1\n4 3\n53 832\n28 8\n4925 2912\n3 1\n", "6\n6 3\n4 3\n90 832\n28 8\n4402 2912\n3 2\n", "6\n6 12\n4 4\n90 832\n55 8\n3049 508\n1 1\n", "6\n6 1\n4 3\n53 832\n28 8\n4925 2912\n3 0\n", "6\n6 12\n4 4\n90 832\n55 8...
335
473
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. There are n persons numbered from 0 to n - 1 and a door. Each person can enter or exit through the door once, taking one second. You are given a non-decreasing integer array arrival of size n, where arrival[i] is the ...
{"functional": "def check(candidate):\n assert candidate(arrival = [0,1,1,2,4], state = [0,1,0,0,1]) == [0,3,1,2,4]\n assert candidate(arrival = [0,0,0], state = [1,0,1]) == [0,2,1]\n\n\ncheck(Solution().timeTaken)"}
315
93
coding
Solve the programming task below in a Python markdown code block. You wish to buy video games from the famous online video game store Mist. Usually, all games are sold at the same price, $\boldsymbol{p}$ dollars. However, they are planning to have the seasonal Halloween Sale next month in which you can buy games at a ...
{"inputs": ["20 3 6 80\n", "20 3 6 85\n"], "outputs": ["6\n", "7\n"]}
677
38
coding
Solve the programming task below in a Python markdown code block. Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos. In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three...
{"inputs": ["x\n", "x\n", "y\n", "z\n", "{\n", "|\n", "zz\n", "xy\n"], "outputs": ["x\n", "x\n", "y\n", "z\n", "{\n", "|\n", "zz\n", "xy\n"]}
283
70
coding
Solve the programming task below in a Python markdown code block. Chef came across a new online judge that has N problems, and decided that he wants to solve them. Chef takes A_{i} consecutive minutes to solve the i-th problem, and will take a break of B_{i} minutes immediately after solving it. That is, Chef will...
{"inputs": ["4\n3 10\n3 4 5\n2 4 2\n3 8\n3 4 5\n2 4 2\n5 20\n23 54 124 54 83\n2 9 5 2 10\n5 20\n4 7 12 34 13\n30 4 3 0 9\n"], "outputs": ["2\n1\n0\n2\n"]}
736
114
coding
Solve the programming task below in a Python markdown code block. Given is an integer x that is greater than or equal to 0, and less than or equal to 1. Output 1 if x is equal to 0, or 0 if x is equal to 1. -----Constraints----- - 0 \leq x \leq 1 - x is an integer -----Input----- Input is given from Standard Input ...
{"inputs": ["1", "0", "1\n", "0\n", "000", "000"], "outputs": ["0", "1", "0\n", "1\n", "1\n", "1\n"]}
133
52
coding
Solve the programming task below in a Python markdown code block. The Quark Codejam's number QC(n, m) represents the number of ways to partition a set of n things into m nonempty subsets. For example, there are seven ways to split a four-element set into two parts: {1, 2, 3} ∪ {4}, {1, 2, 4} ∪ {3}, {1, 3, 4} ∪ {2}, {2...
{"inputs": ["1\n4 2"], "outputs": ["1"]}
393
16
coding
Solve the programming task below in a Python markdown code block. Today a plane was hijacked by a maniac. All the passengers of the flight are taken as hostage. Chef is also one of them. He invited one of the passengers to play a game with him. If he loses the game, he will release all the passengers, otherwise he will...
{"inputs": ["2\n3 3 3\n1\n3 3 3\n2"], "outputs": ["1\n4"]}
495
30
coding
Solve the programming task below in a Python markdown code block. Squirrel Liss is interested in sequences. She also has preferences of integers. She thinks n integers a_1, a_2, ..., a_{n} are good. Now she is interested in good sequences. A sequence x_1, x_2, ..., x_{k} is called good if it satisfies the following th...
{"inputs": ["1\n1\n", "1\n4\n", "1\n1\n", "1\n4\n", "1\n2\n", "1\n3\n", "1\n5\n", "1\n6\n"], "outputs": ["1\n", "1\n", "1", "1", "1\n", "1\n", "1\n", "1\n"]}
414
84
coding
Solve the programming task below in a Python markdown code block. Write a program which computes the digit number of sum of two integers a and b. Constraints * 0 ≤ a, b ≤ 1,000,000 * The number of datasets ≤ 200 Input There are several test cases. Each test case consists of two non-negative integers a and b which a...
{"inputs": ["0 1\n2 3\n1001 6", "0 0\n3 0\n0101 6", "1 1\n5 0\n0001 6", "1 1\n5 0\n0001 9", "0 1\n2 3\n1011 6", "0 1\n2 3\n1101 6", "0 0\n2 3\n1101 6", "0 0\n3 3\n1101 6"], "outputs": ["1\n1\n4\n", "1\n1\n3\n", "1\n1\n1\n", "1\n1\n2\n", "1\n1\n4\n", "1\n1\n4\n", "1\n1\n4\n", "1\n1\n4\n"]}
145
198
coding
Solve the programming task below in a Python markdown code block. Cowboy Vlad has a birthday today! There are $n$ children who came to the celebration. In order to greet Vlad, the children decided to form a circle around him. Among the children who came, there are both tall and low, so if they stand in a circle arbitra...
{"inputs": ["2\n8 1\n", "2\n5 32\n", "2\n5 42\n", "2\n5 28\n", "2\n5 16\n", "2\n5 27\n", "2\n5 17\n", "2\n9 17\n"], "outputs": ["1 8\n", "5 32\n", "5 42\n", "5 28\n", "5 16\n", "5 27\n", "5 17\n", "9 17\n"]}
558
132
coding
Solve the programming task below in a Python markdown code block. Find \displaystyle{\sum_{a=1}^{K}\sum_{b=1}^{K}\sum_{c=1}^{K} \gcd(a,b,c)}. Here \gcd(a,b,c) denotes the greatest common divisor of a, b, and c. -----Constraints----- - 1 \leq K \leq 200 - K is an integer. -----Input----- Input is given from Standard...
{"inputs": ["4", "8", "3", "5", "7", "0", "1", "9"], "outputs": ["76\n", "624\n", "30\n", "141\n", "400\n", "0\n", "1\n", "885\n"]}
267
72
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. Given the root of a binary search tree, return a balanced binary search tree with the same node values. If there is more than one answer, return any of them. A binary search tree is balanced if the depth of the two su...
{"functional": "def check(candidate):\n assert is_same_tree(candidate(root = tree_node([1,None,2,None,3,None,4,None,None])), tree_node([2,1,3,None,None,None,4]))\n\n\ncheck(Solution().balanceBST)"}
158
59
coding
Solve the programming task below in a Python markdown code block. ~~~if-not:java You have to code a function **getAllPrimeFactors** wich take an integer as parameter and return an array containing its prime decomposition by ascending factors, if a factors appears multiple time in the decomposition it should appear as m...
{"functional": "_inputs = [[10], [100], [1000], [1000001], [0], [1], [2], ['a'], [1.1], [-1]]\n_outputs = [[[2, 5]], [[2, 2, 5, 5]], [[2, 2, 2, 5, 5, 5]], [[101, 9901]], [[]], [[1]], [[2]], [[]], [[]], [[]]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n retur...
671
255
coding
Solve the programming task below in a Python markdown code block. In this problem, a $n \times m$ rectangular matrix $a$ is called increasing if, for each row of $i$, when go from left to right, the values strictly increase (that is, $a_{i,1}<a_{i,2}<\dots<a_{i,m}$) and for each column $j$, when go from top to bottom, ...
{"inputs": ["3 3\n1 2 3\n2 0 4\n4 5 6\n", "3 3\n1 2 3\n3 0 4\n4 5 6\n", "3 3\n1 2 3\n2 3 4\n3 4 2\n", "3 3\n1 1 1\n1 1 1\n1 1 1\n", "3 3\n1 2 3\n2 3 4\n3 4 4\n", "3 3\n1 2 3\n2 3 4\n3 5 5\n", "3 3\n1 2 3\n2 3 5\n3 4 5\n", "3 3\n1 2 3\n2 3 4\n3 5 5\n"], "outputs": ["30\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n",...
619
231
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\n2\n", "2 1\n1 1\n1\n", "2 2\n1 2\n1 1\n", "2 2\n2 2\n1 1\n"], "outputs": ["0\n", "0", "0\n", "0\n", "0", "0", "0\n", "-1\n"]}
484
131
coding
Solve the programming task below in a Python markdown code block. # Base reduction ## Input A positive integer: ``` 0 < n < 1000000000 ``` ## Output The end result of the base reduction. If it cannot be fully reduced (reduced down to a single-digit number), return -1. Assume that if 150 conversions from base 11 t...
{"functional": "_inputs = [[10], [5], [7], [7], [15]]\n_outputs = [[2], [5], [7], [7], [3]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return math.isclose(a, b, rel_tol=tol, abs_tol=tol)\n if isinstance(a, (list, tuple)):\n if len(a) != len(b): r...
493
181
coding
Solve the programming task below in a Python markdown code block. The Chef has been kidnapped by aliens ( they want to utilize his excellent cooking skills :P ) and has been transported to the alien planet "ZX532". Interestingly, "ZX532" uses a different time scale which has Y AlienHours on the face of a clock (instead...
{"inputs": ["3\n5 12\n1 0 2 0 4 0 5 0\n5 12\n3 30 4 0 5 0 6 0\n5 12\n3 0 4 0 5 0 6 0\n\n"], "outputs": ["1:20.56\n-1\n3:26.43"]}
714
95
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. A car travels from a starting position to a destination which is target miles east of the starting position. There are gas stations along the way. The gas stations are represented as an array stations where stations[i...
{"functional": "def check(candidate):\n assert candidate(target = 1, startFuel = 1, stations = []) == 0\n assert candidate(target = 100, startFuel = 1, stations = [[10,100]]) == -1\n assert candidate(target = 100, startFuel = 10, stations = [[10,60],[20,30],[30,30],[60,40]]) == 2\n\n\ncheck(Solution().minRefue...
266
121
coding
Solve the programming task below in a Python markdown code block. The chef was not happy with the binary number system, so he designed a new machine which is having 6 different states, i.e. in binary there is a total of 2 states as 0 and 1. Now, the chef is confused about how to correlate this machine to get an interac...
{"inputs": ["2\n3\n5"], "outputs": ["7\n37"]}
304
19
coding
Solve the programming task below in a Python markdown code block. To access CRED programs, one needs to have a credit score of 750 or more. Given that the present credit score is X, determine if one can access CRED programs or not. If it is possible to access CRED programs, output \texttt{YES}, otherwise output \tex...
{"inputs": ["823", "251"], "outputs": ["YES", "NO"]}
313
22
coding
Solve the programming task below in a Python markdown code block. We have N clocks. The hand of the i-th clock (1≤i≤N) rotates through 360° in exactly T_i seconds. Initially, the hand of every clock stands still, pointing directly upward. Now, Dolphin starts all the clocks simultaneously. In how many seconds will th...
{"inputs": ["2\n2\n5", "2\n3\n5", "2\n3\n3", "2\n3\n7", "2\n3\n9", "2\n3\n4", "2\n3\n6", "2\n0\n6"], "outputs": ["10\n", "15\n", "3\n", "21\n", "9\n", "12\n", "6\n", "0\n"]}
272
98
coding
Solve the programming task below in a Python markdown code block. Vasya and Petya are playing a simple game. Vasya thought of number x between 1 and n, and Petya tries to guess the number. Petya can ask questions like: "Is the unknown number divisible by number y?". The game is played by the following rules: first Pe...
{"inputs": ["1\n", "3\n", "2\n", "8\n", "5\n", "7\n", "9\n", "4\n"], "outputs": ["0\n", "2\n2 3\n", "1\n2\n", "6\n2 4 8 3 5 7\n", "4\n2 4 3 5\n", "5\n2 4 3 5 7\n", "7\n2 4 8 3 9 5 7\n", "3\n2 4 3 "]}
400
126
coding
Solve the programming task below in a Python markdown code block. # Task Let's define a `parameter` of number `n` as the least common multiple (LCM) of the sum of its digits and their product. Calculate the parameter of the given number `n`. # Input/Output `[input]` integer `n` A positive integer. It is guaranteed...
{"functional": "_inputs = [[1234], [1], [2], [22], [11], [239], [999999999], [91], [344], [123456789]]\n_outputs = [[120], [1], [2], [4], [2], [378], [387420489], [90], [528], [362880]]\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, r...
221
253
coding
Solve the programming task below in a Python markdown code block. You are given an integer N. Build an undirected graph with N vertices with indices 1 to N that satisfies the following two conditions: * The graph is simple and connected. * There exists an integer S such that, for every vertex, the sum of the indices o...
{"inputs": ["0", "4", "1", "2", "2", "0", "1", "4"], "outputs": ["0\n", "4\n1 2\n1 3\n2 4\n3 4\n", "0\n", "0\n", "0\n", "0\n", "0\n", "4\n1 2\n1 3\n2 4\n3 4\n"]}
214
94
coding
Solve the programming task below in a Python markdown code block. Chef loves bitwise operations. So, he creates the following problem but needs your help to solve it. Chef calls a sequence of integers A_{1}, A_{2}, \ldots, A_{N} tasty if it satisfies the following condition: parity(A_{i} \& A_{i+1}) \neq parity(A_{i} ...
{"inputs": ["2\n2\n0 0\n3\n6 16 69"], "outputs": ["-1\n1\n1 3"]}
692
35
coding
Solve the programming task below in a Python markdown code block. A: A-Z Cat / A-Z Cat story Aizunyan is a second-year student who belongs to the programming contest club of Wakagamatsu High School, commonly known as the Prokon club. It's so cute. Aizu Nyan was asked by her friend Joy to take care of her cat. It is a...
{"inputs": ["AOZUNYANPERIPERO", "OREQIRMQEAYNUYOA", "OREPIREPNAYNUZOA", "OREPIRNPEAYNUZOA", "OREQIRNPEAYNUZOA", "OREQIRMPEAYNUZOA", "AOZUNYAEPMRIQERO", "OREQIRMQEAYNUZOA"], "outputs": ["AZ\n", "-1\n", "AZ\n", "AZ\n", "AZ\n", "AZ\n", "AZ\n", "AZ\n"]}
585
120
coding
Solve the programming task below in a Python markdown code block. We have A apples and P pieces of apple. We can cut an apple into three pieces of apple, and make one apple pie by simmering two pieces of apple in a pan. Find the maximum number of apple pies we can make with what we have now. -----Constraints----- - A...
{"inputs": ["2 3", "1 1", "2 6", "0 0", "0 6", "2 5", "5 0", "1 3"], "outputs": ["4\n", "2\n", "6\n", "0\n", "3\n", "5\n", "7\n", "3"]}
185
77
coding
Solve the programming task below in a Python markdown code block. # Scenario **_Several people_** are standing in *a row divided into two teams*. The **_first person_** goes into **_team 1_**, **_the second_** goes into **_team 2_**, **_the third_** goes into **_team 1_**, and so on. ___ # Task **_Given_** *an arra...
{"functional": "_inputs = [[[80]], [[100, 50]], [[50, 60, 70, 80]], [[13, 27, 49]], [[70, 58, 75, 34, 91]], [[29, 83, 67, 53, 19, 28, 96]], [[0]], [[100, 51, 50, 100]], [[39, 84, 74, 18, 59, 72, 35, 61]], [[0, 1, 0]]]\n_outputs = [[[80, 0]], [[100, 50]], [[120, 140]], [[62, 27]], [[236, 92]], [[211, 164]], [[0, 0]], [[...
573
384
coding
Solve the programming task below in a Python markdown code block. We define the function `f1(n,k)`, as the least multiple of `n` that has all its digits less than `k`. We define the function `f2(n,k)`, as the least multiple of `n` that has all the digits that are less than `k`. Each digit may occur more than once in...
{"functional": "_inputs = [[542, 5], [1750, 6], [14990, 7], [3456, 4], [30500, 3], [62550, 5], [568525, 7], [9567100, 8]]\n_outputs = [[547], [1799], [14996], [3462], [30501], [62557], [568531], [9567115]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return ...
657
286
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, we repeatedly delete consecutive sequences of nodes that sum to 0 until there are no such sequences. After doing so, return the head of the final linked list.  You may return any such ...
{"functional": "def check(candidate):\n assert is_same_list(candidate(head = list_node([1,2,-3,3,1])), list_node([3,1]))\n assert is_same_list(candidate(head = list_node([1,2,3,-3,4])), list_node([1,2,4]))\n assert is_same_list(candidate(head = list_node([1,2,3,-3,-2])), list_node([1]))\n\n\ncheck(Solution().r...
158
112
coding
Solve the programming task below in a Python markdown code block. Given an array of integers, determine the minimum number of elements to delete to leave only elements of equal value. Example $arr=[1,2,2,3]$ Delete the $2$ elements $1$ and $3$ leaving $arr=[2,2]$. If both twos plus either the $1$ or the $3$ are ...
{"inputs": ["STDIN Function\n----- --------\n5 arr[] size n = 5\n3 3 2 1 3 arr = [3, 3, 2, 1, 3]\n"], "outputs": ["2 \n"]}
368
62
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. You are given a rows x cols matrix grid representing a field of cherries where grid[i][j] represents the number of cherries that you can collect from the (i, j) cell. You have two robots that can collect cherries for ...
{"functional": "def check(candidate):\n assert candidate(grid = [[3,1,1],[2,5,1],[1,5,5],[2,1,1]]) == 24\n assert candidate(grid = [[1,0,0,0,0,0,1],[2,0,0,0,0,3,0],[2,0,9,0,0,0,0],[0,3,0,5,4,0,0],[1,0,2,3,0,0,6]]) == 28\n assert candidate(grid = [[1,0,0,3],[0,0,0,3],[0,0,3,3],[9,0,3,3]]) == 22\n assert cand...
260
198
coding
Solve the programming task below in a Python markdown code block. You and your friend decide to play a game using a stack consisting of N bricks. In this game, you can alternatively remove 1, 2 or 3 bricks from the top, and the numbers etched on the removed bricks are added to your score. You have to play so that you o...
{"inputs": ["2\n5\n999 1 1 1 0\n5\n0 1 1 1 999\n"], "outputs": ["1001\n999\n"]}
617
49
coding
Solve the programming task below in a Python markdown code block. You are given a sequence of length N: A_1, A_2, ..., A_N. For each integer i between 1 and N (inclusive), answer the following question: - Find the maximum value among the N-1 elements other than A_i in the sequence. -----Constraints----- - 2 \leq N \...
{"inputs": ["2\n5\n4", "2\n3\n4", "2\n4\n4", "2\n4\n0", "2\n5\n3", "2\n5\n8", "2\n3\n5", "2\n8\n4"], "outputs": ["4\n5\n", "4\n3\n", "4\n4\n", "0\n4\n", "3\n5\n", "8\n5\n", "5\n3\n", "4\n8\n"]}
310
110
coding
Solve the programming task below in a Python markdown code block. You are given an array A consisting of N integers. From array A, we create a new array B containing all pairwise bitwise ANDs of elements from A. That is, B consists of N\cdot(N-1)/2 elements, each of the form A_{i} \mathbin{\&} A_{j} for some 1 ≤ i < j...
{"inputs": ["3\n2\n1 3\n3\n2 7 1\n4\n4 6 7 2"], "outputs": ["1\n3\n6\n"]}
681
41
coding
Solve the programming task below in a Python markdown code block. Fox Ciel is playing a card game with her friend Fox Jiro. There are n piles of cards on the table. And there is a positive integer on each card. The players take turns and Ciel takes the first turn. In Ciel's turn she takes a card from the top of any no...
{"inputs": ["1\n1 1\n", "1\n1 1\n", "2\n1 000\n2 1 4\n", "2\n1 100\n2 1 4\n", "2\n1 100\n2 1 10\n", "2\n1 100\n2 1 20\n", "2\n1 000\n2 1 20\n", "2\n1 110\n2 1 10\n"], "outputs": ["1 0\n", "1 0\n", "1 4\n", "101 4\n", "101 10\n", "101 20\n", "1 20\n", "111 10\n"]}
568
182
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. A super ugly number is a positive integer whose prime factors are in the array primes. Given an integer n and an array of integers primes, return the nth super ugly number. The nth super ugly number is guaranteed to f...
{"functional": "def check(candidate):\n assert candidate(n = 12, primes = [2,7,13,19]) == 32 \n assert candidate(n = 1, primes = [2,3,5]) == 1\n\n\ncheck(Solution().nthSuperUglyNumber)"}
108
71
coding
Solve the programming task below in a Python markdown code block. We have two indistinguishable pieces placed on a number line. Both pieces are initially at coordinate 0. (They can occupy the same position.) We can do the following two kinds of operations: * Choose a piece and move it to the right (the positive direc...
{"inputs": ["5 1 1", "4 4 6", "5 2 2", "5 2 3", "7 1 2", "6 2 3", "3 1 2", "4 1 1"], "outputs": ["4\n", "0\n", "8\n", "7\n", "6\n", "12\n", "2\n", "3\n"]}
396
95