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. #It's show time! Archers have gathered from all around the world to participate in the Arrow Function Faire. But the faire will only start if there are archers signed and if they all have enough arrows in their quivers - at least 5 is the requirement! Ar...
{"functional": "_inputs = [[[]], [[1, 2, 3, 4]], [[5, 6, 7, 8]], [[5, 6, 7, 4]], [[1, 2, 3, 4, 5, 6, 7, 8]]]\n_outputs = [[False], [False], [True], [False], [False]]\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=...
238
228
coding
Solve the programming task below in a Python markdown code block. You are given four integers A, B, C, and D. Find the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D. -----Constraints----- - 1\leq A\leq B\leq 10^{18} - 1\leq C,D\leq 10^9 - All values in input are intege...
{"inputs": ["4 5 2 3", "1 5 2 3", "1 5 2 6", "1 4 8 8", "4 9 2 3", "4 9 2 3\n", "1 1 1 1\n", "2 40 8 8"], "outputs": ["1\n", "2\n", "3\n", "4\n", "2", "2\n", "0\n", "34\n"]}
170
113
coding
Solve the programming task below in a Python markdown code block. "We've tried solitary confinement, waterboarding and listening to Just In Beaver, to no avail. We need something extreme." "Little Alena got an array as a birthday present..." The array b of length n is obtained from the array a of length n and two int...
{"inputs": ["5\n1 2 3 4 5\n00001\n", "5\n1 2 3 4 5\n00001\n", "5\n0 2 3 4 5\n00001\n", "5\n2 0 4 0 2\n00001\n", "5\n1 2 3 0 5\n00001\n", "5\n2 2 3 0 5\n00001\n", "5\n2 0 3 0 5\n00001\n", "5\n2 0 4 0 5\n00001\n"], "outputs": ["6 1000000000\n", "6 1000000000\n", "6 1000000000\n", "5 1000000000\n", "6 1000000000\n", "6 10...
631
286
coding
Solve the programming task below in a Python markdown code block. You are in the future. It's the time of autonomous cars. Switching lanes is a pretty difficult task for autonomous cars, and you have the logs from an experiment you had run with two cars. You want to verify whether the logs are corrupted, or could be va...
{"inputs": ["2\n3\n1 1 1 2 2\n2 2 1 2 2\n4 2 2 2 3\n1\n1 1 3 2 2"], "outputs": ["yes\nno"]}
746
58
coding
Solve the programming task below in a Python markdown code block. In this Kata, you will be given a string that has lowercase letters and numbers. Your task is to compare the number groupings and return the largest number. Numbers will not have leading zeros. For example, `solve("gh12cdy695m1") = 695`, because this i...
{"functional": "_inputs = [['gh12cdy695m1'], ['2ti9iei7qhr5'], ['vih61w8oohj5'], ['f7g42g16hcu5'], ['lu1j8qbbb85']]\n_outputs = [[695], [9], [61], [42], [85]]\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 ...
152
225
coding
Solve the programming task below in a Python markdown code block. Count the number of distinct sequences a_1, a_2, ..., a_{n} (1 ≤ a_{i}) consisting of positive integers such that gcd(a_1, a_2, ..., a_{n}) = x and $\sum_{i = 1}^{n} a_{i} = y$. As this number could be large, print the answer modulo 10^9 + 7. gcd here m...
{"inputs": ["3 9\n", "5 8\n", "1 8\n", "1 9\n", "1 1\n", "1 1\n", "1 9\n", "1 8\n"], "outputs": ["3\n", "0\n", "120\n", "252\n", "1\n", "1\n", "252\n", "120\n"]}
220
94
coding
Solve the programming task below in a Python markdown code block. Given a matrix (H × W) which contains only 1 and 0, find the area of the largest rectangle which only contains 0s. Constraints * 1 ≤ H, W ≤ 1,400 Input H W c1,1 c1,2 ... c1,W c2,1 c2,2 ... c2,W : cH,1 cH,2 ... cH,W In the first line, two integers ...
{"inputs": ["4 5\n0 0 1 0 0\n1 0 0 0 0\n0 0 0 0 0\n0 0 0 1 0", "4 5\n0 0 1 0 0\n1 0 0 0 0\n0 0 0 0 1\n0 0 0 1 0", "1 5\n0 0 1 0 0\n1 0 0 0 1\n0 0 0 1 0\n0 0 0 1 0", "4 5\n1 0 1 1 0\n1 0 0 0 0\n0 0 1 0 0\n0 0 0 1 0", "4 5\n0 0 1 0 0\n0 0 0 0 0\n0 0 0 0 0\n0 0 0 1 0", "4 5\n0 0 0 0 0\n1 1 0 0 0\n0 0 0 0 0\n0 0 0 1 0", "4...
213
399
coding
Solve the programming task below in a Python markdown code block. Binary trees are defined recursively. A binary tree T is a structure defined on a finite set of nodes that either * contains no nodes, or * is composed of three disjoint sets of nodes: - a root node. - a binary tree called its left subtree. - a binary t...
{"inputs": ["9\n0 2 4\n1 0 3\n2 -1 -1\n3 0 0\n4 5 8\n5 6 7\n6 -1 -1\n7 -1 -1\n8 -1 -1", "9\n0 2 4\n1 0 3\n2 -1 -1\n3 -1 0\n4 5 8\n5 6 7\n6 -1 -1\n7 -1 -1\n8 -1 -1", "9\n0 1 4\n1 2 5\n2 -1 -1\n3 -1 -1\n4 3 8\n5 6 7\n6 -1 -1\n7 -1 -1\n8 -1 -1", "9\n0 2 4\n1 1 3\n2 -1 -1\n3 -1 -1\n4 5 8\n5 6 7\n6 -1 -1\n7 -1 -1\n8 -1 -1",...
512
869
coding
Solve the programming task below in a Python markdown code block. Read problems statements in Mandarin Chinese and Russian. Alexandra has some distinct integer numbers a_{1},a_{2}...a_{n}. Count number of pairs (i,j) such that: 1≤ i ≤ n 1≤ j ≤ n a_{i} < a_{j}   ------ Input ------ The first line of the input contai...
{"inputs": ["2\n2\n12 11\n3\n13 11 12"], "outputs": ["1\n3"]}
329
33
coding
Solve the programming task below in a Python markdown code block. ATMs of a well-known bank of a small country are arranged so that they can not give any amount of money requested by the user. Due to the limited size of the bill dispenser (the device that is directly giving money from an ATM) and some peculiarities of ...
{"inputs": ["1 1\n1\n1\n1\n", "1 20\n1\n1\n200000000\n", "2 2\n1 2\n1\n200000000\n", "2 5\n1 2\n1\n200000000\n", "1 1\n42\n5\n1\n41\n42\n43\n84\n", "1 1\n42\n5\n1\n39\n42\n43\n84\n", "1 1\n1000000\n1\n200000000\n", "1 1\n1000000\n1\n179035188\n"], "outputs": ["1\n", "-1\n", "-1\n", "-1\n", "-1\n-1\n1\n-1\n-1\n", "-1\n-...
632
239
coding
Solve the programming task below in a Python markdown code block. You will get an array of numbers. Every preceding number is smaller than the one following it. Some numbers will be missing, for instance: ``` [-3,-2,1,5] //missing numbers are: -1,0,2,3,4 ``` Your task is to return an array of those missing numbers: ...
{"functional": "_inputs = [[[-3, -2, 1, 4]], [[-1, 0, 1, 2, 3, 4]], [[]], [[0]], [[-4, 4]]]\n_outputs = [[[-1, 0, 2, 3]], [[]], [[]], [[]], [[-3, -2, -1, 0, 1, 2, 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_to...
120
234
coding
Solve the programming task below in a Python markdown code block. Monk was asked to answer some queries in an interview. He is given an empty array A. Queries are of 4 types:- 1. 1 X - Add number X to the array A. 2. 2 X - Remove a single instance of number X from the array A. If not possible, print "-1" without the qu...
{"inputs": ["10\n1 5\n3\n3\n3\n1 4\n1 1\n1 8\n3\n1 6\n4\n", "100\n1 5\n1 22393\n2 22393\n4\n1 28040\n1 9505\n1 22027\n3\n1 2173\n4\n1 16189\n1 15918\n1 2896\n4\n4\n3\n4\n1 6654\n1 8716\n3\n4\n2 1472\n3\n4\n4\n1 2463\n2 2463\n2 19805\n4\n4\n4\n1 30479\n1 12892\n3\n3\n2 1\n4\n1 17656\n2 26370\n3\n2 28040\n3\n4\n4\n2 6263...
319
795
coding
Solve the programming task below in a Python markdown code block. Darshit is planning to celebrate the birthday of his friend, Diksha. There are two types of gifts that Diksha wants from Darshit: one is black and the other is white. To make her happy, Darshit has to buy B number of black gifts and W number of white gif...
{"inputs": ["5\n10 10\n1 1 1\n5 9\n2 3 4\n3 6\n9 1 1\n7 7\n4 2 1\n3 3\n1 9 2", "10\n330 557\n867513 531885 919789\n911 967\n707275 206718 144846\n897 543\n515113 825642 564879\n485 557\n368448 250548 443004\n398 561\n222741 277616 976299\n263 914\n323768 832927 597107\n595 257\n104664 621107 969493\n804 369\n386811 764...
657
1,606
coding
Solve the programming task below in a Python markdown code block. Today is Chocolate day and Kabir and Tara are visiting a Valentine fair. Upon arriving, they find a stall with an interesting game. There are N$N$ jars having some chocolates in them. To win the game, one has to select the maximum number of consecutive j...
{"inputs": ["1\n6 5\n1 3 3 1 1 5"], "outputs": ["3"]}
412
28
coding
Solve the programming task below in a Python markdown code block. Read problem statements in [Mandarin], [Bengali], [Russian], and [Vietnamese] as well. You are given a sequence A_{1}, A_{2}, \ldots, A_{N} which contains pairwise distinct elements and a sequence B_{1}, B_{2}, \ldots, B_{N}, which also contains pairwis...
{"inputs": ["1\n3\n1 4 5\n1 3 4"], "outputs": ["1 2 0"]}
581
30
coding
Solve the programming task below in a Python markdown code block. Monocarp is the coach of the Berland State University programming teams. He decided to compose a problemset for a training session for his teams. Monocarp has $n$ problems that none of his students have seen yet. The $i$-th problem has a topic $a_i$ (an...
{"inputs": ["2\n4\n2 4\n3 4\n2 1\n1 3\n5\n1 5\n2 4\n3 3\n4 2\n5 1\n", "2\n4\n2 4\n3 4\n2 1\n2 3\n5\n1 5\n2 4\n3 3\n4 2\n5 1\n", "2\n4\n2 4\n3 3\n2 2\n1 3\n5\n1 5\n2 4\n3 3\n4 2\n5 1\n", "2\n4\n4 4\n3 3\n2 2\n2 3\n5\n1 5\n2 4\n3 3\n4 2\n5 1\n", "2\n4\n2 4\n3 4\n2 2\n2 3\n5\n1 5\n2 3\n3 3\n4 2\n2 1\n", "2\n4\n4 4\n3 4\n2...
522
410
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 only of lowercase English letters. In one move, you can select any two adjacent characters of s and swap them. Return the minimum number of moves needed to make s a palindrome. Note...
{"functional": "def check(candidate):\n assert candidate(s = \"aabb\") == 2\n assert candidate(s = \"letelt\") == 2\n\n\ncheck(Solution().minMovesToMakePalindrome)"}
111
48
coding
Solve the programming task below in a Python markdown code block. A class of students got bored wearing the same pair of shoes every day, so they decided to shuffle their shoes among themselves. In this problem, a pair of shoes is inseparable and is considered as a single object. There are $n$ students in the class, a...
{"inputs": ["2\n5\n1 1 1 1 1\n6\n3 6 8 13 15 21\n", "2\n7\n2 2 3 3 3 4 4\n6\n1 2 2 2 3 3\n", "6\n1\n95\n12\n1 1 1 1 1 1 1 39 39 39 39 39\n3\n5 5 5\n9\n46 46 46 46 46 46 46 46 46\n8\n18 18 18 18 35 35 35 35\n17\n23 23 25 25 25 25 25 25 25 36 36 66 66 95 95 96 96\n", "3\n11\n195927690 195927690 195927690 195927690 648407...
709
1,022
coding
Solve the programming task below in a Python markdown code block. On some square in the lowest row of a chessboard a stands a pawn. It has only two variants of moving: upwards and leftwards or upwards and rightwards. The pawn can choose from which square of the lowest row it can start its journey. On each square lay fr...
{"inputs": ["2 2 0\n02\n64\n", "2 2 3\n15\n52\n", "2 2 9\n82\n68\n", "2 2 2\n82\n68\n", "2 2 2\n44\n68\n", "2 2 3\n15\n67\n", "2 2 10\n98\n12\n", "2 2 10\n98\n75\n"], "outputs": ["8\n1\nR\n", "-1\n", "-1\n", "-1", "12\n2\nL\n", "8\n2\nL\n", "11\n2\nL\n", "-1\n"]}
545
169
coding
Solve the programming task below in a Python markdown code block. It's that time of the year when the Russians flood their countryside summer cottages (dachas) and the bus stop has a lot of people. People rarely go to the dacha on their own, it's usually a group, so the people stand in queue by groups. The bus stop qu...
{"inputs": ["1 5\n4\n", "1 5\n4\n", "1 73\n24\n", "2 6\n1 4\n", "2 5\n5 5\n", "2 6\n1 4\n", "2 5\n5 5\n", "1 73\n24\n"], "outputs": ["1\n", "1\n", "1\n", "1\n", "2\n", "1\n", "2\n", "1\n"]}
323
114
coding
Solve the programming task below in a Python markdown code block. Tom has finally taken over the business empire and now looking for a new Name of the business to make a new start. Joe (Tom's dear friend) suggested a string $S$ consisting of Uppercase and lowercase letters Tom wants to make some changes as pe...
{"inputs": ["CodeSprInT"], "outputs": [".c.d.s.p.r.n.t"]}
408
22
coding
Solve the programming task below in a Python markdown code block. You've got a 5 × 5 matrix, consisting of 24 zeroes and a single number one. Let's index the matrix rows by numbers from 1 to 5 from top to bottom, let's index the matrix columns by numbers from 1 to 5 from left to right. In one move, you are allowed to a...
{"inputs": ["0 0 0 0 0\n0 0 0 0 1\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 1 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 1 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 1\n", "0 1 0 0 0\n0 0 0 0 0\n0 0 0 0 0\n0 0 0 0 0\n0 0 0 0 0\n", "1 0 0 0 0\n0...
411
454
coding
Solve the programming task below in a Python markdown code block. Little chief has his own restaurant in the city. There are N workers there. Each worker has his own salary. The salary of the i-th worker equals to W_{i} (i = 1, 2, ..., N). Once, chief decided to equalize all workers, that is, he wants to make salaries ...
{"inputs": ["2\n3\n1 4 3\n2\n7 2", "2\n3\n1 0 3\n2\n8 2", "2\n3\n1 4 3\n2\n42 7", "2\n3\n1 4 3\n2\n47 7", "2\n3\n1 4 3\n2\n20 7", "2\n3\n1 4 3\n2\n20 8", "2\n3\n1 0 2\n2\n1 17", "2\n3\n1 4 3\n2\n20 2"], "outputs": ["5\n5\n", "4\n6\n", "5\n35\n", "5\n40\n", "5\n13\n", "5\n12\n", "3\n16\n", "5\n18\n"]}
485
202
coding
Solve the programming task below in a Python markdown code block. There is a 120 minute videotape with standard recording. When I set the VCR counter to 00:00:00 with the tape completely rewound and recorded in standard recording mode, I got a certain counter value. Enter this counter value (hours, minutes, seconds), f...
{"inputs": ["0 9 1\n-1 -1 -1", "1 8 0\n-1 -1 -1", "0 8 1\n-1 -1 -1", "1 9 0\n-1 -1 -1", "1 5 0\n-1 -1 -1", "0 9 0\n-1 -1 -1", "0 8 2\n-1 -1 -1", "1 7 0\n-1 -1 -1"], "outputs": ["01:50:59\n05:32:57\n", "00:52:00\n02:36:00\n", "01:51:59\n05:35:57\n", "00:51:00\n02:33:00\n", "00:55:00\n02:45:00\n", "01:51:00\n05:33:00\n",...
351
278
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. Given a positive integer n, return the smallest positive integer that is a multiple of both 2 and n.   Please complete the following python code precisely: ```python class Solution: def smallestEvenMultiple(self, ...
{"functional": "def check(candidate):\n assert candidate(n = 5) == 10\n assert candidate(n = 6) == 6\n\n\ncheck(Solution().smallestEvenMultiple)"}
70
46
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
Solve the programming task below in a Python markdown code block. Astronaut Natasha arrived on Mars. She knows that the Martians are very poor aliens. To ensure a better life for the Mars citizens, their emperor decided to take tax from every tourist who visited the planet. Natasha is the inhabitant of Earth, therefore...
{"inputs": ["1 2\n1\n", "1 5\n4\n", "1 5\n3\n", "1 8\n6\n", "1 7\n6\n", "1 9\n6\n", "1 8\n5\n", "1 6\n4\n"], "outputs": ["2\n0 1 ", "5\n0 1 2 3 4 ", "5\n0 1 2 3 4 ", "4\n0 2 4 6 ", "7\n0 1 2 3 4 5 6 ", "3\n0 3 6 ", "8\n0 1 2 3 4 5 6 7 ", "3\n0 2 4 "]}
703
169
coding
Solve the programming task below in a Python markdown code block. Bob needs a fast way to calculate the volume of a cuboid with three values: `length`, `width` and the `height` of the cuboid. Write a function to help Bob with this calculation. ```if:shell In bash the script is ran with the following 3 arguments: `leng...
{"functional": "_inputs = [[2, 5, 6], [6.3, 3, 5]]\n_outputs = [[60], [94.5]]\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 ...
114
182
coding
Solve the programming task below in a Python markdown code block. Once Vasya played bricks. All the bricks in the set had regular cubical shape. Vasya vas a talented architect, however the tower he built kept falling apart. Let us consider the building process. Vasya takes a brick and puts it on top of the already bui...
{"inputs": ["1\n0 0 1 1\n", "1\n0 0 2 1\n", "1\n0 0 4 1\n", "1\n-50 -50 50 50\n", "1\n-50 -93 50 50\n", "2\n0 0 4 3\n1 0 4 3\n", "2\n0 0 3 3\n1 0 4 3\n", "2\n0 0 3 3\n2 0 5 3\n"], "outputs": ["1", "1", "1", "1", "1", "2", "2", "1"]}
634
160
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. Given a string s, reverse only all the vowels in the string and return it. The vowels are 'a', 'e', 'i', 'o', and 'u', and they can appear in both lower and upper cases, more than once.   Please complete the following...
{"functional": "def check(candidate):\n assert candidate(s = \"hello\") == \"holle\"\n assert candidate(s = \"leetcode\") == \"leotcede\"\n\n\ncheck(Solution().reverseVowels)"}
100
50
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 candies, where candies[i] represents the flavor of the ith candy. Your mom wants you to share these candies with your little sister by giving her k consecutive candies, but you ...
{"functional": "def check(candidate):\n assert candidate(candies = [1,2,2,3,4,3], k = 3) == 3\n assert candidate(candies = [2,2,2,2,3,3], k = 2) == 2\n assert candidate(candies = [2,4,5], k = 0) == 3\n\n\ncheck(Solution().shareCandies)"}
129
102
coding
Solve the programming task below in a Python markdown code block. The chef is trying to solve some pattern problems, Chef wants your help to code it. Chef has one number K to form a new pattern. Help the chef to code this pattern problem. -----Input:----- - First-line will contain $T$, the number of test cases. Then t...
{"inputs": ["5\n1\n2\n3\n4\n5"], "outputs": ["1\n1\n32\n1\n32\n654\n1\n32\n654\n10987\n1\n32\n654\n10987\n1514131211"]}
235
77
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 of even length n and an integer limit. In one move, you can replace any integer from nums with another integer between 1 and limit, inclusive. The array nums is complementary if for...
{"functional": "def check(candidate):\n assert candidate(nums = [1,2,4,3], limit = 4) == 1\n assert candidate(nums = [1,2,2,1], limit = 2) == 2\n assert candidate(nums = [1,2,1,2], limit = 2) == 0\n\n\ncheck(Solution().minMoves)"}
172
88
coding
Solve the programming task below in a Python markdown code block. A subsequence of length |x| of string s = s1s2... s|s| (where |s| is the length of string s) is a string x = sk1sk2... sk|x| (1 ≤ k1 < k2 < ... < k|x| ≤ |s|). You've got two strings — s and t. Let's consider all subsequences of string s, coinciding with...
{"inputs": ["aa\naaa\n", "cba\nba\n", "cca\nba\n", "abc\nba\n", "abc\nbac\n", "ab\nabcd\n", "abc\nbab\n", "ab\ndbca\n"], "outputs": ["No\n", "No\n", "No\n", "No\n", "No\n", "No\n", "No\n", "No\n"]}
387
88
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. You are given two 0-indexed arrays nums and cost consisting each of n positive integers. You can do the following operation any number of times: Increase or decrease any element of the array nums by 1. The cost of d...
{"functional": "def check(candidate):\n assert candidate(nums = [1,3,5,2], cost = [2,3,1,14]) == 8\n assert candidate(nums = [2,2,2,2,2], cost = [4,2,8,1,3]) == 0\n\n\ncheck(Solution().minCost)"}
127
82
coding
Solve the programming task below in a Python markdown code block. Write a program which converts uppercase/lowercase letters to lowercase/uppercase for a given string. Constraints * The length of the input string < 1200 Input A string is given in a line. Output Print the converted string in a line. Note that you ...
{"inputs": ["f@IR, LATER, OCCASIONALLY CLOUDY.", "f@IR, LATER, YLLANOISACCO CLOUDY.", "f@IR, LATER, OLLANOISACCY CLOUDY.", "f@IR, LATER, OLKANOISACCY CLOUDY.", ",RI@f LATER, OLKANOISACCY CLOUDY.", ",RI@f KATER, OLKANOISACCY CLOUDY.", ",RI@g KATER, OLKANOISACCY CLOUDY.", ",RI@g KATER, OLKANOISACCY CLOUDX."], "outputs": ...
110
273
coding
Solve the programming task below in a Python markdown code block. You are given an integer $x$ of $n$ digits $a_1, a_2, \ldots, a_n$, which make up its decimal notation in order from left to right. Also, you are given a positive integer $k < n$. Let's call integer $b_1, b_2, \ldots, b_m$ beautiful if $b_i = b_{i+k}$ ...
{"inputs": ["2 1\n33\n", "2 1\n99\n", "2 1\n31\n", "2 1\n33\n", "2 1\n12\n", "2 1\n31\n", "2 1\n12\n", "2 1\n33\n"], "outputs": ["2\n33\n", "2\n99\n", "2\n33\n", "2\n33\n", "2\n22\n", "2\n33\n", "2\n22\n", "2\n33\n"]}
373
134
coding
Solve the programming task below in a Python markdown code block. Master Oogway has forseen that a panda named Po will be the dragon warrior, and the master of Chi. But he did not tell anyone about the spell that would make him the master of Chi, and has left Po confused. Now Po has to defeat Kai, who is the super vill...
{"inputs": ["4\n1\n2\n3\n4"], "outputs": ["1\n2\n6\n24"]}
320
27
coding
Solve the programming task below in a Python markdown code block. Ayu loves distinct letter sequences ,a distinct letter sequence is defined by a sequence of small case english alphabets such that no character appears more then once. But however there are two phrases that she doesn't like these phrases are "kar" and "s...
{"inputs": ["2\nkarp\nabcd"], "outputs": ["22\n24"]}
280
21
coding
Solve the programming task below in a Python markdown code block. A reversed arabic no is one whose digits have been written in the reversed order. However in this any trailing zeroes are omitted. The task at hand here is a simple one. You need to add two numbers which have been written in reversed arabic and return th...
{"inputs": ["1\n24 1"], "outputs": ["34"]}
185
18
coding
Solve the programming task below in a Python markdown code block. Chloe is fascinated by prime numbers. She came across the number $283002$ on a sign and, though the number is not prime, found some primes hiding in it by using the following rules: Every three consecutive digits sum to a prime: $\underbrace{283}002\q...
{"inputs": ["1\n6\n"], "outputs": ["95\n"]}
469
17
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. There are n different online courses numbered from 1 to n. You are given an array courses where courses[i] = [durationi, lastDayi] indicate that the ith course should be taken continuously for durationi days and must ...
{"functional": "def check(candidate):\n assert candidate(courses = [[100, 200], [200, 1300], [1000, 1250], [2000, 3200]]) == 3\n assert candidate(courses = [[1,2]]) == 1\n assert candidate(courses = [[3,2],[4,3]]) == 0\n\n\ncheck(Solution().scheduleCourse)"}
135
108
coding
Solve the programming task below in a Python markdown code block. # Background My pet bridge-maker ants are marching across a terrain from left to right. If they encounter a gap, the first one stops and then next one climbs over him, then the next, and the next, until a bridge is formed across the gap. What clever ...
{"functional": "_inputs = [['GFEDCBA', '-----------------------'], ['GFEDCBA', '------------...-----------'], ['GFEDCBA', '------------.....---------'], ['GFEDCBA', '------.....------.....---------'], ['GFEDCBA', '------------...-----..----'], ['CBA', '--.--.---'], ['GFEDCBA', '------....-.---'], ['EDCBA', '--..---...-...
480
409
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 and an integer k. You may partition nums into one or more subsequences such that each element in nums appears in exactly one of the subsequences. Return the minimum number of subseq...
{"functional": "def check(candidate):\n assert candidate(nums = [3,6,1,2,5], k = 2) == 2\n assert candidate(nums = [1,2,3], k = 1) == 2\n assert candidate(nums = [2,2,4,5], k = 0) == 3\n\n\ncheck(Solution().partitionArray)"}
144
88
coding
Solve the programming task below in a Python markdown code block. ![](http://www.grindtv.com/wp-content/uploads/2015/08/drone.jpg) The other day I saw an amazing video where a guy hacked some wifi controlled lightbulbs by flying a drone past them. Brilliant. In this kata we will recreate that stunt... sort of. You w...
{"functional": "_inputs = [['xxxxxx', '====T'], ['xxxxxxxxx', '==T'], ['xxxxxxxxxxxxxxx', '=========T']]\n_outputs = [['ooooox'], ['oooxxxxxx'], ['ooooooooooxxxxx']]\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=...
242
189
coding
Solve the programming task below in a Python markdown code block. Alice and Bob are playing a game of table tennis where irrespective of the point scored, every player makes 2 consecutive serves before the service changes. Alice makes the first serve of the match. Therefore the first 2 serves will be made by Alice, the...
{"inputs": ["4\n0 0\n0 2\n2 2\n4 7\n"], "outputs": ["Alice\nBob\nAlice\nBob\n"]}
589
36
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. You are given a string s and an array of strings words. All the strings of words are of the same length. A concatenated string is a string that exactly contains all the strings of any permutation of words concatenated...
{"functional": "def check(candidate):\n assert candidate(s = \"barfoothefoobarman\", words = [\"foo\",\"bar\"]) == [0,9]\n assert candidate(s = \"wordgoodgoodgoodbestword\", words = [\"word\",\"good\",\"best\",\"word\"]) == []\n assert candidate(s = \"barfoofoobarthefoobarman\", words = [\"bar\",\"foo\",\"the\...
191
115
coding
Solve the programming task below in a Python markdown code block. There is an array $a$ of length $n$. You may perform the following operation any number of times: Choose two indices $l$ and $r$ where $1 \le l < r \le n$ and $a_l = a_r$. Then, set $a[l \ldots r] = [a_{l+1}, a_{l+2}, \ldots, a_r, a_l]$. You are also g...
{"inputs": ["5\n5\n1 2 3 3 2\n1 3 3 2 2\n5\n1 2 4 2 1\n4 2 2 1 1\n5\n2 4 5 5 2\n2 2 4 5 5\n3\n1 2 3\n1 2 3\n3\n1 1 2\n2 1 1\n"], "outputs": ["YES\nYES\nNO\nYES\nNO\n"]}
725
116
coding
Solve the programming task below in a Python markdown code block. **Background** You most probably know, that the *kilo* used by IT-People differs from the *kilo* used by the rest of the world. Whereas *kilo* in kB is (mostly) intrepreted as 1024 Bytes (especially by operating systems) the non-IT *kilo* denotes the ...
{"functional": "_inputs = [['1 KiB']]\n_outputs = [['1.024 kB']]\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...
521
162
coding
Solve the programming task below in a Python markdown code block. Chef has an 8 \times 8 chessboard. He placed a knight on the square (X_{1}, Y_{1}). Note that, the square at the intersection of the i^{th} row and j^{th} column is denoted by (i, j). Chef wants to determine whether the knight can end up at the square ...
{"inputs": ["3\n1 1 1 1\n8 8 7 6\n8 8 8 6\n"], "outputs": ["YES\nNO\nYES"]}
580
41
coding
Solve the programming task below in a Python markdown code block. Alice has a string $s$. She really likes the letter "a". She calls a string good if strictly more than half of the characters in that string are "a"s. For example "aaabb", "axaa" are good strings, and "baca", "awwwa", "" (empty string) are not. Alice ca...
{"inputs": ["a\n", "a\n", "ap\n", "ap\n", "pa\n", "aq\n", "dya\n", "ass\n"], "outputs": ["1\n", "1\n", "1\n", "1\n", "1\n", "1\n", "1\n", "1\n"]}
297
71
coding
Solve the programming task below in a Python markdown code block. There was a test in your class and you passed it. Congratulations! But you're an ambitious person. You want to know if you're better than the average student in your class. You receive an array with your peers' test scores. Now calculate the average and...
{"functional": "_inputs = [[[2, 3], 5], [[100, 40, 34, 57, 29, 72, 57, 88], 75], [[12, 23, 34, 45, 56, 67, 78, 89, 90], 69]]\n_outputs = [[True], [True], [True]]\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)...
195
245
coding
Solve the programming task below in a Python markdown code block. Mr. Retardo has lost his marbles. He's a professor, and absolutely loathes his students. And since going full retard, he asks them all sorts of useless questions. His latest obsession is prime numbers, and he gives all his a students random number n and ...
{"inputs": ["10\n\n9223372036854775807\n104729\n103141\n99999989\n9563494117\n8670344929\n11812315811854\n828456218949862\n0\n12198789456"], "outputs": ["NO\nYES\nYES\nYES\nYES\nYES\nNO\nNO\nNO\nNO"]}
154
142
coding
Solve the programming task below in a Python markdown code block. The most dangerous cyborg Jenish is finally entrapped on a narrow bridge over a valley. The bridge is $N$ meters long. For convenience, position $i$ represents a portion of bridge between whose left border is at distance $i-1$ meters from left end and ri...
{"inputs": ["3\n4 8\n5 1 4 2\n3 4\n3 1 2\n2 7\n5 5"], "outputs": ["YES\nYES\nNO"]}
721
46
coding
Solve the programming task below in a Python markdown code block. Ashu and Arvind participated in a coding contest, as a result of which they received N chocolates. Now they want to divide the chocolates between them equally. Can you help them by deciding if it is possible for them to divide all the N chocolates in su...
{"inputs": ["4\n10\n4\n3\n2\n"], "outputs": ["Yes\nYes\nNo\nYes"]}
375
28
coding
Solve the programming task below in a Python markdown code block. Shil likes Round numbers very much . A number is called Round number if its non-negative and its first and last digits are same. For example 0 , 3 , 343 and 50005 are round numbers whereas 1000 is not a round number. Shil has an array A1 , A2 .. AN...
{"inputs": ["10 10\n999999999999980689 -999999999999985424 999999999999997259 -999999999999980547 999999999999980429 999999999999985309 999999999999988309 -999999999999978240 999999999999973229 -999999999999986703 \n2 9 999999999999974279\n2 3 999999999999975369\n2 3 999999999999991679\n2 5 999999999999968959\n1 1 7\n1...
521
393
coding
Solve the programming task below in a Python markdown code block. Manasa was sulking her way through a boring class when suddenly her teacher singled her out and asked her a question. He gave her a number n and Manasa has to come up with the smallest number m which contains atleast n number of zeros at the end of m!. H...
{"inputs": ["3\n1\n2\n3\n"], "outputs": ["5\n10\n15\n"]}
282
26
coding
Solve the programming task below in a Python markdown code block. `{a, e, i, o, u, A, E, I, O, U}` Natural Language Understanding is the subdomain of Natural Language Processing where people used to design AI based applications have ability to understand the human languages. HashInclude Speech Processing team has a pr...
{"functional": "_inputs = [['bbbb'], ['baceb'], ['aeiou'], ['aeiouAEIOU']]\n_outputs = [[0], [16], [35], [220]]\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...
310
185
coding
Solve the programming task below in a Python markdown code block. The only difference between the easy and the hard versions is constraints. A subsequence is a string that can be derived from another string by deleting some or no symbols without changing the order of the remaining symbols. Characters to be deleted are...
{"inputs": ["1 2\nu\n", "1 5\nw\n", "1 5\nw\n", "1 2\nu\n", "1 0\ns\n", "1 10\ns\n", "1 25\no\n", "1 50\ns\n"], "outputs": ["1\n", "-1\n", "-1\n", "1\n", "0\n", "-1\n", "-1\n", "-1\n"]}
496
105
coding
Solve the programming task below in a Python markdown code block. Little Vasya went to the supermarket to get some groceries. He walked about the supermarket for a long time and got a basket full of products. Now he needs to choose the cashier to pay for the products. There are n cashiers at the exit from the supermar...
{"inputs": ["1\n1\n1\n", "1\n1\n1\n", "1\n1\n100\n", "1\n1\n100\n", "4\n1 4 3 2\n100\n1 2 2 3\n1 9 1\n7 8\n", "4\n1 4 3 2\n100\n1 4 2 3\n1 0 1\n7 8\n", "4\n1 4 3 2\n100\n1 4 2 3\n2 0 1\n7 8\n", "4\n1 4 3 2\n100\n1 4 2 3\n1 9 1\n7 8\n"], "outputs": ["20\n", "20\n", "515\n", "515\n", "100\n", "55\n", "60\n", "100\n"]}
609
222
coding
Solve the programming task below in a Python markdown code block. There are N cards. The i-th card has an integer A_i written on it. For any two cards, the integers on those cards are different. Using these cards, Takahashi and Aoki will play the following game: * Aoki chooses an integer x. * Starting from Takahashi,...
{"inputs": ["2 2\n4 25 18 55\n4\n2\n8", "1 2\n4 25 18 55\n4\n4\n6", "2 1\n0 3 59 55\n4\n1\n13", "2 1\n0 1 59 55\n4\n1\n13", "2 1\n0 43 68 85\n4\n0\n3", "4 3\n0 16 30 40\n2\n33\n8", "4 3\n1 20 30 46\n2\n33\n8", "4 3\n1 20 37 40\n2\n34\n8"], "outputs": ["25\n25\n", "4\n4\n", "3\n", "1\n", "43\n", "70\n56\n70\n", "76\n66\...
478
245
coding
Solve the programming task below in a Python markdown code block. To quickly hire highly skilled specialists one of the new IT City companies made an unprecedented move. Every employee was granted a car, and an employee can choose one of four different car makes. The parking lot before the office consists of one line ...
{"inputs": ["3\n", "4\n", "5\n", "6\n", "7\n", "6\n", "5\n", "7\n"], "outputs": ["24", "132", "672", "3264", "15360", "3264\n", "672\n", "15360\n"]}
392
86
coding
Solve the programming task below in a Python markdown code block. Shivam is the youngest programmer in the world, he is just 12 years old. Shivam is learning programming and today he is writing his first program. Program is very simple, Given two integers A and B, write a program to add these two numbers. -----Input...
{"inputs": ["3\n1 2\n100 200\n10 40"], "outputs": ["3\n300\n50"]}
187
37
coding
Solve the programming task below in a Python markdown code block. Robot Doc is located in the hall, with n computers stand in a line, numbered from left to right from 1 to n. Each computer contains exactly one piece of information, each of which Doc wants to get eventually. The computers are equipped with a security sy...
{"inputs": ["1\n0\n", "1\n0\n", "2\n0 1\n", "2\n0 1\n", "3\n0 2 0\n", "3\n0 2 1\n", "3\n0 2 1\n", "3\n0 2 0\n"], "outputs": ["0\n", "0", "0\n", "0", "1\n", "1\n", "1", "1"]}
576
102
coding
Solve the programming task below in a Python markdown code block. Write a function that receives two strings and returns n, where n is equal to the number of characters we should shift the first string forward to match the second. For instance, take the strings "fatigue" and "tiguefa". In this case, the first string h...
{"functional": "_inputs = [['fatigue', 'tiguefa'], ['hoop', 'pooh'], ['eecoff', 'coffee'], ['Moose', 'moose'], [\"isn't\", \"'tisn\"], ['Esham', 'Esham'], [' ', ' '], ['dog', 'god'], [' ', ' '], ['doomhouse', 'hoodmouse'], ['123456789!@#$%^&*( )qwerty', '9!@#$%^&*( )qwerty12345678']]\n_outputs = [[5], [-1], [4], [-1],...
240
304
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. Given a list of strings dict where all the strings are of the same length. Return true if there are 2 strings that only differ by 1 character in the same index, otherwise return false.   Please complete the following ...
{"functional": "def check(candidate):\n assert candidate(dict = [\"abcd\",\"acbd\", \"aacd\"]) == True\n assert candidate(dict = [\"ab\",\"cd\",\"yz\"]) == False\n assert candidate(dict = [\"abcd\",\"cccc\",\"abyd\",\"abab\"]) == True\n\n\ncheck(Solution().differByOne)"}
89
79
coding
Solve the programming task below in a Python markdown code block. KISS stands for Keep It Simple Stupid. It is a design principle for keeping things simple rather than complex. You are the boss of Joe. Joe is submitting words to you to publish to a blog. He likes to complicate things. Define a function that determin...
{"functional": "_inputs = [['Joe had a bad day'], ['Joe had some bad days'], ['Joe is having no fun'], ['Sometimes joe cries for hours'], ['Joe is having lots of fun'], ['Joe is working hard a lot'], ['Joe listened to the noise and it was an onamonapia'], ['Joe listened to the noises and there were some onamonapias']]\...
218
274
coding
Solve the programming task below in a Python markdown code block. Eugeny loves listening to music. He has n songs in his play list. We know that song number i has the duration of t_{i} minutes. Eugeny listens to each song, perhaps more than once. He listens to song number i c_{i} times. Eugeny's play list is organized ...
{"inputs": ["1 2\n2 8\n1 16\n", "1 2\n2 8\n1 16\n", "3 1\n2 50\n1 50\n1 50\n160\n", "3 1\n2 50\n1 50\n1 50\n160\n", "3 1\n2 50\n1 50\n1 82\n160\n", "3 1\n2 74\n1 50\n1 82\n160\n", "3 1\n2 74\n1 32\n1 82\n160\n", "3 1\n2 50\n1 53\n1 82\n160\n"], "outputs": ["1\n1\n", "1\n1\n", "3\n", "3\n", "3\n", "2\n", "2\n", "3\n"]}
555
222
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. Given a string array words, return an array of all characters that show up in all strings within the words (including duplicates). You may return the answer in any order.   Please complete the following python code pr...
{"functional": "def check(candidate):\n assert candidate(words = [\"bella\",\"label\",\"roller\"]) == [\"e\",\"l\",\"l\"]\n assert candidate(words = [\"cool\",\"lock\",\"cook\"]) == [\"c\",\"o\"]\n\n\ncheck(Solution().commonChars)"}
83
68
coding
Solve the programming task below in a Python markdown code block. Chef has an array A of size N. He can perform the following operation on A: Select an i (1 ≤ i ≤ N) and for all 1 ≤ j ≤ i, set A_{j} := A_{j} + 1 (i.e. add 1 to every element in the prefix of length i). Chef wants to convert A to a *palindrome* by using...
{"inputs": ["3\n4\n4 2 2 4\n5\n5 4 3 2 1\n4\n1 2 3 4\n"], "outputs": ["0\n-1\n3\n"]}
595
51
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. $N$ integers $A_{1}, A_{2}, \ldots, A_{N}$ are placed in a circle in such a way that for each valid $i$, $A_{i}$ and $A_{i+1}$ are adjacent, and $A_{...
{"inputs": ["1\n3\n10 10 1"], "outputs": ["32"]}
563
23
coding
Solve the programming task below in a Python markdown code block. For a given sequence $A = \\{a_0, a_1, ..., a_{n-1}\\}$ which is sorted by ascending order, find a specific value $k$ given as a query. Constraints * $1 \leq n \leq 100,000$ * $1 \leq q \leq 200,000$ * $0 \leq a_0 \leq a_1 \leq ... \leq a_{n-1} \leq 1,...
{"inputs": ["4\n1 2 2 4\n3\n2\n3\n6", "4\n1 1 2 4\n3\n0\n3\n8", "4\n0 1 2 6\n3\n0\n3\n6", "4\n1 2 1 4\n2\n0\n3\n8", "4\n0 1 2 7\n1\n0\n5\n3", "4\n0 2 3 4\n3\n2\n3\n4", "4\n0 2 2 1\n3\n4\n3\n0", "4\n1 1 1 4\n2\n0\n1\n8"], "outputs": ["1\n0\n0\n", "0\n0\n0\n", "1\n0\n1\n", "0\n0\n", "1\n", "1\n1\n1\n", "0\n0\n1\n", "0\n1...
335
214
coding
Solve the programming task below in a Python markdown code block. Have you ever used the chat application QQ? Well, in a chat group of QQ, administrators can muzzle a user for days. In Boboniu's chat group, there's a person called Du Yi who likes to make fun of Boboniu every day. Du will chat in the group for $n$ day...
{"inputs": ["1 1 0\n0\n", "1 1 1\n2\n", "1 1 0\n0\n", "1 1 1\n2\n", "1 0 0\n0\n", "1 1 0\n2\n", "1 1 -1\n1\n", "1 1 -1\n2\n"], "outputs": ["0\n", "2\n", "0\n", "2\n", "0\n", "2\n", "1\n", "2\n"]}
576
118
coding
Solve the programming task below in a Python markdown code block. Given a string `S` and a character `C`, return an array of integers representing the shortest distance from the current character in `S` to `C`. ### Notes * All letters will be lowercase. * If the string is empty, return an empty array. * If the charac...
{"functional": "_inputs = [['lovecodewars', 'e'], ['aaaaa', 'a'], ['aabbaabb', 'a'], ['aaaabbbb', 'b'], ['aaaaa', 'b'], ['lovecoding', ''], ['', '']]\n_outputs = [[[3, 2, 1, 0, 1, 2, 1, 0, 1, 2, 3, 4]], [[0, 0, 0, 0, 0]], [[0, 0, 1, 1, 0, 0, 1, 2]], [[4, 3, 2, 1, 0, 0, 0, 0]], [[]], [[]], [[]]]\nimport math\ndef _deep_...
234
305
coding
Solve the programming task below in a Python markdown code block. Let $s$ be a string of lowercase Latin letters. Its price is the sum of the indices of letters (an integer between 1 and 26) that are included in it. For example, the price of the string abca is $1+2+3+1=7$. The string $w$ and the integer $p$ are given....
{"inputs": ["1\nvdjisjifreo\n39\n", "5\nabca\n2\nabca\n6\ncodeforces\n1\ncodeforces\n10\ncodeforces\n100\n"], "outputs": ["diife\n", "aa\naba\n\ncdc\ncodeforces\n"]}
510
73
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. You are given a 0-indexed string text and another 0-indexed string pattern of length 2, both of which consist of only lowercase English letters. You can add either pattern[0] or pattern[1] anywhere in text exactly onc...
{"functional": "def check(candidate):\n assert candidate(text = \"abdcdbc\", pattern = \"ac\") == 4\n assert candidate(text = \"aabb\", pattern = \"ab\") == 6\n\n\ncheck(Solution().maximumSubsequenceCount)"}
169
58
coding
Solve the programming task below in a Python markdown code block. In this problem the input will consist of a number of lines of English text consisting of the letters of the English alphabet, the punctuation marks ' (apostrophe), . (full stop), , (comma), ; (semicolon), :(colon) and white space characters (blank, newl...
{"inputs": ["2\nThis is a sample piece of text to illustrate this \nproblem. If you are smart you will solve this right.\n"], "outputs": ["right this solve will you smart are you If problem\nthis illustrate to text of piece sample a is This"]}
342
59
coding
Solve the programming task below in a Python markdown code block. An infinitely long railway has a train consisting of n cars, numbered from 1 to n (the numbers of all the cars are distinct) and positioned in arbitrary order. David Blaine wants to sort the railway cars in the order of increasing numbers. In one move he...
{"inputs": ["1\n1\n", "1\n1\n", "2\n1 2\n", "2\n2 1\n", "2\n1 2\n", "2\n2 1\n", "3\n1 2 3\n", "3\n1 3 2\n"], "outputs": ["0\n", "0\n", "0\n", "1\n", "0\n", "1\n", "0\n", "1\n"]}
295
102
coding
Solve the programming task below in a Python markdown code block. Vasya likes to solve equations. Today he wants to solve $(x~\mathrm{div}~k) \cdot (x \bmod k) = n$, where $\mathrm{div}$ and $\mathrm{mod}$ stand for integer division and modulo operations (refer to the Notes below for exact definition). In this equation...
{"inputs": ["6 3\n", "1 2\n", "4 6\n", "2 2\n", "5 5\n", "9 8\n", "2 2\n", "5 5\n"], "outputs": ["11\n", "3\n", "10\n", "5\n", "26\n", "27\n", "5", "26"]}
460
89
coding
Solve the programming task below in a Python markdown code block. Vasya has become interested in wrestling. In wrestling wrestlers use techniques for which they are awarded points by judges. The wrestler who gets the most points wins. When the numbers of points of both wrestlers are equal, the wrestler whose sequence ...
{"inputs": ["2\n4\n-4\n", "2\n1\n-1\n", "2\n-4\n4\n", "2\n-5\n6\n", "2\n-5\n6\n", "2\n-4\n4\n", "2\n1\n-1\n", "2\n-5\n9\n"], "outputs": ["second\n", "second\n", "first\n", "first\n", "first\n", "first\n", "second\n", "first\n"]}
492
110
coding
Solve the programming task below in a Python markdown code block. Alice and Bob are studying for their class test together. The topic of the test is Prime Numbers. The preparation is getting too boring for their liking. To make it interesting, they turn it into a game. The winner will get an ice-cream treat from the ot...
{"inputs": ["4\n2 2 2\n3 8 2\n1 6 2\n4 16 5", "4\n2 2 2\n2 8 2\n2 15 4\n4 6 4", "4\n2 2 2\n3 6 2\n1 6 2\n4 16 1", "4\n5 0 1\n4 7 1\n1 15 0\n3 3 3", "4\n5 0 1\n7 7 1\n1 15 0\n3 3 3", "4\n2 0 1\n3 0 2\n1 15 2\n2 20 5", "4\n2 0 1\n2 12 1\n1 22 2\n2 0 1", "4\n2 2 2\n3 8 2\n1 15 2\n4 16 5"], "outputs": ["0\n1\n1\n0\n", "0\n...
682
313
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 nums of size n consisting of non-negative integers. You need to apply n - 1 operations to this array where, in the ith operation (0-indexed), you will apply the following on the ith ele...
{"functional": "def check(candidate):\n assert candidate(nums = [1,2,2,1,1,0]) == [1,4,2,0,0,0]\n assert candidate(nums = [0,1]) == [1,0]\n\n\ncheck(Solution().applyOperations)"}
221
69
coding
Solve the programming task below in a Python markdown code block. You are given <var>Q</var> tuples of integers <var>(L_i, A_i, B_i, M_i)</var>. For each tuple, answer the following question. There is an arithmetic progression with L terms: s_0, s_1, s_2, ... , s_{L-1}. The initial term is A, and the common difference...
{"inputs": ["5 5 4 10007", "2 5 4 10007", "2 1 4 10007", "5 3 4 10007", "5 3 4 10007\n", "6 8 1 1000000", "4 8 1 1001000", "3 8 1 1001000"], "outputs": ["358\n", "59\n", "15\n", "5563", "5563\n", "111213\n", "891011\n", "8910\n"]}
354
171
coding
Solve the programming task below in a Python markdown code block. We have a directed weighted graph with N vertices. Each vertex has two integers written on it, and the integers written on Vertex i are A_i and B_i. In this graph, there is an edge from Vertex x to Vertex y for all pairs 1 \leq x,y \leq N, and its weigh...
{"inputs": ["3\n2 5\n4 2\n6 3", "3\n1 5\n4 4\n6 3", "3\n1 5\n4 2\n6 3", "4\n1 5\n2 6\n0 7\n4 8", "4\n1 5\n0 6\n0 7\n4 8", "4\n1 3\n0 6\n0 7\n4 8", "4\n1 5\n2 6\n3 7\n4 8", "4\n1 3\n0 6\n-1 7\n4 8"], "outputs": ["8\n", "9\n", "7", "7\n", "5\n", "4\n", "10", "3\n"]}
318
178
coding
Solve the programming task below in a Python markdown code block. Everybody is worried about Rakesh as the boy does not have much knowledge about the real world. He can not go from one place to another on his own. It's high time he learned to explore the city. He is going to a relative's house situated on the other sid...
{"inputs": ["2\n20 20\n4 5\n13\nLLUUUUURRRRRR\n10 10\n3 4\n7\nUDUDDRR"], "outputs": ["Case 1: REACHED\nCase 2: DANGER"]}
744
62
coding
Solve the programming task below in a Python markdown code block. Given a word consisting of lowercase English letters, write a program to remove duplicates from the word. The characters in the output must preserve the same order, as their first appearance in the original word. Input Format The input consists of seve...
{"inputs": ["5\nbananasqr\naaaaa\nabcde\nayacazkeafagahbcbdbebfbg\nqweer\n"], "outputs": ["bansqr\na\nabcde\nayczkefghbd\nqwer\n"]}
168
59
coding
Solve the programming task below in a Python markdown code block. Imagine you start on the 5th floor of a building, then travel down to the 2nd floor, then back up to the 8th floor. You have travelled a total of 3 + 6 = 9 floors of distance. Given an array representing a series of floors you must reach by elevator, re...
{"functional": "_inputs = [[[5, 2, 8]], [[1, 2, 3]], [[7, 1, 7, 1]]]\n_outputs = [[9], [2], [18]]\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...
235
189
coding
Solve the programming task below in a Python markdown code block. Of the real numbers, those with a circular decimal part and those with a finite number of digits can be expressed as fractions. Given a real number that can be represented by a fraction, write a program that outputs an irreducible fraction equal to t...
{"inputs": ["1.0", "0.(2)", "1.(3)", "1.(2)", "0.(3)", "0.0739", "3.2(145)", "3.3(145)"], "outputs": ["1/1", "2/9\n", "4/3\n", "11/9\n", "1/3", "739/10000", "32113/9990\n", "16556/4995\n"]}
352
124
coding
Solve the programming task below in a Python markdown code block. Your favorite shop sells n Kinder Surprise chocolate eggs. You know that exactly s stickers and exactly t toys are placed in n eggs in total. Each Kinder Surprise can be one of three types: * it can contain a single sticker and no toy; * it can co...
{"inputs": ["1\n5 3 2\n", "1\n5 4 2\n", "1\n5 4 4\n", "1\n5 1 4\n", "1\n3 1 4\n", "1\n7 4 4\n", "1\n6 5 2\n", "1\n1926 54 3018\n"], "outputs": ["4\n", "4\n", "2\n", "5\n", "3\n", "4\n", "5\n", "1873\n"]}
435
128
coding
Solve the programming task below in a Python markdown code block. There are N hills in a row numbered 1 through N from left to right. Each hill has a height; for each valid i, the height of the i-th hill is Hi. Chef is initially on the leftmost hill (hill number 1). He can make an arbitrary number of jumps (including z...
{"inputs": ["3\n5 3 2\n2 5 2 6 3\n5 2 3\n4 4 4 4 4\n5 2 7\n1 4 3 2 1"], "outputs": ["3\n5\n1"]}
616
64
coding
Solve the programming task below in a Python markdown code block. You have found $M$ different types of jewels in a mine and each type of jewel is present in an infinite number. There are $N$ different boxes located at position $(1 ,2 ,3 ,...N)$. Each box can collect jewels up to a certain number ( box at position $i$ ...
{"inputs": ["2\n1 10\n5 2"], "outputs": ["1\n64"]}
295
24
coding
Solve the programming task below in a Python markdown code block. Reading books is one of Sasha's passions. Once while he was reading one book, he became acquainted with an unusual character. The character told about himself like that: "Many are my names in many countries. Mithrandir among the Elves, Tharkûn to the Dwa...
{"inputs": ["a\n", "f\n", "a\n", "f\n", "`\n", "e\n", "b\n", "d\n"], "outputs": ["Impossible\n", "Impossible\n", "Impossible", "Impossible", "Impossible\n", "Impossible\n", "Impossible\n", "Impossible\n"]}
676
68
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. You are given an integer n, the number of teams in a tournament that has strange rules: If the current number of teams is even, each team gets paired with another team. A total of n / 2 matches are played, and n / 2 ...
{"functional": "def check(candidate):\n assert candidate(n = 7) == 6\n assert candidate(n = 14) == 13\n\n\ncheck(Solution().numberOfMatches)"}
180
45
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. A number is ternary if it contains only digits $0$, $1$ and $2$. For example, the following numbers are ternary: $1022$, $11$, $21$, $2002$. You are given a long ternary number $x$. The first (leftmost) digit of $x$ is guaranteed to be $2$, the other di...
{"inputs": ["4\n5\n22222\n5\n21211\n1\n2\n9\n220222021\n", "4\n5\n22222\n5\n21211\n1\n2\n9\n220222021\n"], "outputs": ["11111\n11111\n11000\n10211\n1\n1\n110111011\n110111010\n", "11111\n11111\n11000\n10211\n1\n1\n110111011\n110111010\n"]}
623
178
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. Given a wooden stick of length n units. The stick is labelled from 0 to n. For example, a stick of length 6 is labelled as follows: Given an integer array cuts where cuts[i] denotes a position you should perform a cu...
{"functional": "def check(candidate):\n assert candidate(n = 7, cuts = [1,3,4,5]) == 16\n assert candidate(n = 9, cuts = [5,6,1,4,2]) == 22\n\n\ncheck(Solution().minCost)"}
204
69
coding
Solve the programming task below in a Python markdown code block. Given an array of integers and a target sum, determine the sum nearest to but not exceeding the target that can be created. To create the sum, use any element of your array zero or more times. For example, if $arr=[2,3,4]$ and your target sum is $10$, ...
{"inputs": ["2\n3 12\n1 6 9\n5 9\n3 4 4 4 8\n"], "outputs": ["12\n9\n"]}
425
42
coding
Solve the programming task below in a Python markdown code block. There is an infinitely large pond, which we consider as a number line. In this pond, there are N lotuses floating at coordinates 0, 1, 2, ..., N-2 and N-1. On the lotus at coordinate i, an integer s_i is written. You are standing on the lotus at coordina...
{"inputs": ["5\n0 2 5 0 0", "5\n0 2 5 1 0", "5\n0 2 5 1 0\n", "6\n0 7 -7 -4 0 0", "6\n0 2 -7 -1 -5 0", "6\n0 4 -7 -1 -3 0", "6\n0 4 -7 -1 -1 0", "6\n0 5 -7 -2 -1 0"], "outputs": ["2\n", "3", "3\n", "7\n", "0\n", "1\n", "3\n", "4\n"]}
634
152
coding
Solve the programming task below in a Python markdown code block. Holidays have finished. Thanks to the help of the hacker Leha, Noora managed to enter the university of her dreams which is located in a town Pavlopolis. It's well known that universities provide students with dormitory for the period of university studi...
{"inputs": ["4 3\n", "1 1\n", "5 3\n", "1 4\n", "5 4\n", "9 7\n", "2 3\n", "6 7\n"], "outputs": ["6\n", "1\n", "6\n", "1\n", "24\n", "5040\n", "2\n", "720\n"]}
409
92
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. You are given a 0-indexed m x n binary matrix land where a 0 represents a hectare of forested land and a 1 represents a hectare of farmland. To keep the land organized, there are designated rectangular areas of hectar...
{"functional": "def check(candidate):\n assert candidate(land = [[1,0,0],[0,1,1],[0,1,1]]) == [[0,0,0,0],[1,1,2,2]]\n assert candidate(land = [[1,1],[1,1]]) == [[0,0,1,1]]\n assert candidate(land = [[0]]) == []\n\n\ncheck(Solution().findFarmland)"}
299
105