problem
stringlengths
14
4.09k
solution
stringlengths
1
802k
task_type
stringclasses
3 values
problem_tokens
int64
5
895
Solve the programming task below in a Python markdown code block. We have N bulbs arranged on a number line, numbered 1 to N from left to right. Bulb i is at coordinate i. Each bulb has a non-negative integer parameter called intensity. When there is a bulb of intensity d at coordinate x, the bulb illuminates the segm...
{"inputs": ["5 1\n0 0 0 1 0", "5 2\n0 0 0 1 0", "5 2\n0 0 0 0 0", "5 2\n1 0 0 0 0", "5 2\n0 0 0 0 1", "5 0\n0 0 0 0 1", "5 2\n1 0 0 2 0", "5 2\n0 0 0 2 0"], "outputs": ["1 1 2 1 2\n", "3 3 4 3 3\n", "2 3 3 3 2\n", "2 3 3 4 2\n", "2 4 3 3 2\n", "0 0 0 0 1\n", "3 3 4 4 4\n", "3 3 4 4 3\n"]}
coding
391
Solve the programming task below in a Python markdown code block. # Task Pac-Man got lucky today! Due to minor performance issue all his enemies have frozen. Too bad Pac-Man is not brave enough to face them right now, so he doesn't want any enemy to see him. Given a gamefield of size `N` x `N`, Pac-Man's position(...
{"functional": "_inputs = [[1, [0, 0], []], [2, [0, 0], []], [3, [0, 0], []], [3, [1, 1], []], [2, [0, 0], [[1, 1]]], [3, [2, 0], [[1, 1]]], [3, [2, 0], [[0, 2]]], [10, [4, 6], [[0, 2], [5, 2], [5, 5]]], [8, [1, 1], [[5, 4]]], [8, [1, 5], [[5, 4]]], [8, [6, 1], [[5, 4]]]]\n_outputs = [[0], [3], [8], [8], [0], [0], [3],...
coding
494
Solve the programming task below in a Python markdown code block. Write a function that takes two arguments, and returns a new array populated with the elements **that only appear once, in either one array or the other, taken only once**; display order should follow what appears in arr1 first, then arr2: ```python ho...
{"functional": "_inputs = [[['tartar', 'blanket', 'domino'], ['blanket']], [[77, 'basketweave'], [78, 42, 'basketweave']], [[100, 45, 'ciao'], [100, 2, 3, 45, 5]], [[10, 200, 30], [10, 20, 3, 4, 5, 5, 5, 200]], [[1, 2, 3, 3], [3, 2, 1, 4, 5, 4]]]\n_outputs = [[['tartar', 'domino']], [[77, 78, 42]], [['ciao', 2, 3, 5]],...
coding
258
Solve the programming task below in a Python markdown code block. Write a function that gets a sequence and value and returns `true/false` depending on whether the variable exists in a multidimentional sequence. Example: ``` locate(['a','b',['c','d',['e']]],'e'); // should return true locate(['a','b',['c','d',['e']]],...
{"functional": "_inputs = [[['a', 'b', ['c', 'd', ['e']]], 'a'], [['a', 'b', ['c', 'd', ['e']]], 'd'], [['a', 'b', ['c', 'd', ['e']]], 'e'], [['a', 'b', ['c', 'd', ['e']]], 'f'], [['a', 'b', ['c', 'd', ['e', ['a', 'b', ['c', 'd', ['e4']]]]]], 'e4'], [['a', 'b', ['c', 'd', ['e', ['a', 'b', ['c', 'd', ['e', ['a', 'b', ['...
coding
133
Solve the programming task below in a Python markdown code block. The followers of Psycho-Helmet religion follow a peculiar calendar – a normal year contains N days. Every K-th year is a “MOB” year. For example, if K = 4, then years 4, 8, 12, 16 \ldots are “MOB” years. A “MOB” year contains M additional days i.e. it co...
{"inputs": ["3\n2 1 4 17\n3 7 5 50\n3 7 5 61"], "outputs": ["YES\nNO\nYES"]}
coding
689
Solve the programming task below in a Python markdown code block. An English text needs to be encrypted using the following encryption scheme. First, the spaces are removed from the text. Let $L$ be the length of this text. Then, characters are written into a grid, whose rows and columns have the following constrai...
{"inputs": ["chillout\n", "haveaniceday\n", "feedthedog \n"], "outputs": ["clu hlt io\n", "hae and via ecy\n", "fto ehg ee dd\n"]}
coding
662
Solve the programming task below in a Python markdown code block. For an array of non-negative integers $a$ of size $n$, we construct another array $d$ as follows: $d_1 = a_1$, $d_i = |a_i - a_{i - 1}|$ for $2 \le i \le n$. Your task is to restore the array $a$ from a given array $d$, or to report that there are multi...
{"inputs": ["1\n2\n5 5\n", "1\n2\n1 1\n", "1\n2\n3 3\n", "1\n2\n2 2\n", "1\n2\n4 4\n", "1\n2\n7 7\n", "1\n2\n2 3\n", "1\n2\n6 6\n"], "outputs": ["-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "2 5\n", "-1\n"]}
coding
373
Please solve the programming task below using a self-contained code snippet in a markdown code block. Given an m x n matrix mat where every row is sorted in strictly increasing order, return the smallest common element in all rows. If there is no common element, return -1.   Please complete the following python code p...
{"functional": "def check(candidate):\n assert candidate(mat = [[1,2,3,4,5],[2,4,5,8,10],[3,5,7,9,11],[1,3,5,7,9]]) == 5\n assert candidate(mat = [[1,2,3],[2,3,4],[2,3,5]]) == 2\n\n\ncheck(Solution().smallestCommonElement)"}
coding
87
Solve the programming task below in a Python markdown code block. # Task John and Alice have an appointment today. In the morning, John starts from (`0,0`) and goes to the place (`a,b`) where he is dating. Unfortunately, John had no sense of direction at all, so he moved 1 step in a random direction(up, down, left o...
{"functional": "_inputs = [[3, 3, 6], [4, 5, 10], [-5, -5, 10], [-5, -5, 8], [10, -10, 10]]\n_outputs = [[True], [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=tol)\n if isins...
coding
582
Solve the programming task below in a Python markdown code block. You are given two arrays $a$ and $b$, both of length $n$. Let's define a function $f(l, r) = \sum\limits_{l \le i \le r} a_i \cdot b_i$. Your task is to reorder the elements (choose an arbitrary order of elements) of the array $b$ to minimize the value...
{"inputs": ["2\n1 3\n4 2\n", "2\n1 3\n4 1\n", "2\n1 5\n4 1\n", "2\n1 9\n4 1\n", "2\n1 9\n4 2\n", "2\n1 9\n4 0\n", "2\n2 9\n4 0\n", "2\n1 3\n4 2\n"], "outputs": ["20\n", "14\n", "18\n", "26\n", "44\n", "8\n", "16\n", "20\n"]}
coding
462
Solve the programming task below in a Python markdown code block. One upon a time there were three best friends Abhinav, Harsh, and Akash decided to form a team and take part in ICPC from KIIT. Participants are usually offered several problems during the programming contest. Long before the start, the friends decided...
{"inputs": ["3\n1 1 0\n1 1 1\n1 0 0"], "outputs": ["2"]}
coding
403
Solve the programming task below in a Python markdown code block. People in Chefland have three different eye colors, namely brown, blue, and green. green is the rarest of the eye colors whereas brown is most common. The eye color of the child of two people is most likely to be the most common eye color between them. ...
{"inputs": ["R B\n", "B B\n", "G B\n"], "outputs": ["R", "B", "B"]}
coding
393
Solve the programming task below in a Python markdown code block. Convert integers to binary as simple as that. You would be given an integer as a argument and you have to return its binary form. To get an idea about how to convert a decimal number into a binary number, visit here. **Notes**: negative numbers should b...
{"functional": "_inputs = [[2], [3], [4], [5], [7], [10], [-3], [0], [1000], [-15], [-1000], [-999999], [999999]]\n_outputs = [['10'], ['11'], ['100'], ['101'], ['111'], ['1010'], ['11111111111111111111111111111101'], ['0'], ['1111101000'], ['11111111111111111111111111110001'], ['11111111111111111111110000011000'], ['1...
coding
193
Solve the programming task below in a Python markdown code block. A new entertainment has appeared in Buryatia — a mathematical circus! The magician shows two numbers to the audience — $n$ and $k$, where $n$ is even. Next, he takes all the integers from $1$ to $n$, and splits them all into pairs $(a, b)$ (each integer ...
{"inputs": ["1\n200000 618391804\n", "4\n4 1\n2 0\n12 10\n14 11\n"], "outputs": ["NO\n", "YES\n1 2\n3 4\nNO\nYES\n3 4\n7 8\n11 12\n2 1\n6 5\n10 9\nYES\n1 2\n3 4\n5 6\n7 8\n9 10\n11 12\n13 14\n"]}
coding
641
Solve the programming task below in a Python markdown code block. Vanya and his friend Vova play a computer game where they need to destroy n monsters to pass a level. Vanya's character performs attack with frequency x hits per second and Vova's character performs attack with frequency y hits per second. Each character...
{"inputs": ["1 1 1\n1\n", "1 1 1\n1\n", "1 1 2\n1\n", "2 1 1\n1\n2\n", "2 1 2\n1\n2\n", "2 1 2\n1\n4\n", "2 1 1\n1\n1\n", "2 1 1\n1\n2\n"], "outputs": ["Both\n", "Both\n", "Vova\n", "Both\nBoth\n", "Vova\nBoth\n", "Vova\nVova\n", "Both\nBoth\n", "Both\nBoth\n"]}
coding
449
Solve the programming task below in a Python markdown code block. Farmer Bob have a big farm, where he growths chickens, rabbits and cows. It is very difficult to count the number of animals for each type manually, so he diceded to buy a system to do it. But he bought a cheap system that can count only total number of ...
{"functional": "_inputs = [[34, 11, 6], [154, 42, 10], [74, 20, 34], [152, 38, 34], [56, 17, 0]]\n_outputs = [[{'rabbits': 3, 'chickens': 5, 'cows': 3}], [{'rabbits': 30, 'chickens': 7, 'cows': 5}], [{'rabbits': 0, 'chickens': 3, 'cows': 17}], [{'rabbits': 21, 'chickens': 0, 'cows': 17}], [{'rabbits': 11, 'chickens': 6...
coding
499
Solve the programming task below in a Python markdown code block. Let's call a set of positive integers a_1, a_2, ..., a_k quadratic if the product of the factorials of its elements is a square of an integer, i. e. ∏_{i=1}^{k} a_i! = m^2, for some integer m. You are given a positive integer n. Your task is to find a ...
{"inputs": ["5\n", "2\n", "0\n", "9\n", "7\n", "1\n", "4\n", "27\n"], "outputs": ["3\n1 3 4\n", "1\n1\n", "0\n\n", "7\n1 2 4 5 6 7 8 ", "4\n1 4 5 6 ", "1\n1 ", "3\n1 3 4 ", "25\n1 2 3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 21 22 23 24 26 27 "]}
coding
236
Solve the programming task below in a Python markdown code block. problem In the area where Kazakhstan is now located, there used to be a trade route called the "Silk Road". There are N + 1 cities on the Silk Road, numbered from west as city 0, city 1, ..., city N. The distance between city i -1 and city i (1 ≤ i ≤ N...
{"inputs": ["1 5\n0\n58\n7\n64\n30\n1\n67\n2", "3 5\n10\n38\n7\n0\n40\n6\n4\n28", "3 5\n16\n38\n7\n0\n40\n6\n1\n28", "2 5\n0\n58\n5\n64\n60\n1\n46\n2", "1 5\n1\n61\n7\n64\n25\n1\n33\n2", "1 5\n3\n38\n7\n32\n30\n1\n40\n30", "3 5\n10\n62\n7\n50\n30\n6\n2\n30", "3 5\n10\n38\n7\n50\n30\n6\n2\n30"], "outputs": ["0\n", "256\...
coding
619
Solve the programming task below in a Python markdown code block. problem AOR Ika is at the $ S $ th bus stop at time $ 0 $ and wants to go from there to the $ G $ th bus stop. The number of bus stops $ N $ and $ M $ routes (*) connecting different bus stops are given. The bus stops are numbered $ 1, \ dots, and N $, ...
{"inputs": ["2 1 1 2\n1 2 9 011\n2 2 5 500", "2 2 1 2\n1 2 6 001\n1 2 2 893", "2 2 1 2\n1 2 8 111\n1 1 4 526", "2 1 1 2\n1 2 10 001\n1 2 5 58", "2 2 1 2\n1 2 6 101\n1 2 5 893", "2 1 1 2\n1 2 5 101\n1 2 5 500", "2 1 1 2\n1 2 10 001\n1 2 5 28", "2 2 1 2\n1 2 0 001\n2 2 5 500"], "outputs": ["9\n", "2\n", "8\n", "10\n", "5...
coding
372
Solve the programming task below in a Python markdown code block. Why would we want to stop to only 50 shades of grey? Let's see to how many we can go. Write a function that takes a number n as a parameter and return an array containing n shades of grey in hexadecimal code (`#aaaaaa` for example). The array should be...
{"functional": "_inputs = [[-1], [0], [1], [254], [5000]]\n_outputs = [[[]], [[]], [['#010101']], [['#010101', '#020202', '#030303', '#040404', '#050505', '#060606', '#070707', '#080808', '#090909', '#0a0a0a', '#0b0b0b', '#0c0c0c', '#0d0d0d', '#0e0e0e', '#0f0f0f', '#101010', '#111111', '#121212', '#131313', '#141414', ...
coding
254
Solve the programming task below in a Python markdown code block. You are given the equation $\tan\alpha=\frac{p}{q}$ and a positive integer, $n$. Calculate $\tan n\alpha$. There are $\mathbf{T}$ test cases. Input Format The first line contains $\mathbf{T}$, the number of test cases. The next $\mathbf{T}$ lines con...
{"inputs": ["2\n2 1 2\n5 6 7\n"], "outputs": ["666666670\n237627959\n"]}
coding
425
Please solve the programming task below using a self-contained code snippet in a markdown code block. Given a string containing just the characters '(' and ')', return the length of the longest valid (well-formed) parentheses substring.   Please complete the following python code precisely: ```python class Solution: ...
{"functional": "def check(candidate):\n assert candidate(s = \"(()\") == 2\n assert candidate(s = \")()())\") == 4\n assert candidate(s = \"\") == 0\n\n\ncheck(Solution().longestValidParentheses)"}
coding
74
Please solve the programming task below using a self-contained code snippet in a markdown code block. You are given an m x n grid grid where: '.' is an empty cell. '#' is a wall. '@' is the starting point. Lowercase letters represent keys. Uppercase letters represent locks. You start at the starting point and one mo...
{"functional": "def check(candidate):\n assert candidate(grid = [\"@.a..\",\"###.#\",\"b.A.B\"]) == 8\n assert candidate(grid = [\"@..aA\",\"..B#.\",\"....b\"]) == 6\n\n\ncheck(Solution().shortestPathAllKeys)"}
coding
251
Solve the programming task below in a Python markdown code block. It's dinner time. Ashish is very hungry and wants to eat something. He has X rupees in his pocket. Since Ashish is very picky, he only likes to eat either PIZZA or BURGER. In addition, he prefers eating PIZZA over eating BURGER. The cost of a PIZZA is Y ...
{"inputs": ["3\n50 40 60\n40 55 39\n30 42 37\n"], "outputs": ["PIZZA\nBURGER\nNOTHING\n"]}
coding
475
Solve the programming task below in a Python markdown code block. You are given two arithmetic progressions: a_1k + b_1 and a_2l + b_2. Find the number of integers x such that L ≤ x ≤ R and x = a_1k' + b_1 = a_2l' + b_2, for some integers k', l' ≥ 0. -----Input----- The only line contains six integers a_1, b_1, a_2,...
{"inputs": ["2 0 3 3 5 21\n", "2 4 3 0 6 17\n", "2 0 3 3 5 21\n", "2 4 3 0 6 17\n", "4 0 4 1 5 100\n", "4 0 4 1 0 100\n", "4 0 4 1 0 100\n", "4 0 4 1 5 100\n"], "outputs": ["3\n", "2\n", "3\n", "2\n", "0\n", "0\n", "0\n", "0\n"]}
coding
218
Solve the programming task below in a Python markdown code block. In this Kata, you will be given an array of numbers in which two numbers occur once and the rest occur only twice. Your task will be to return the sum of the numbers that occur only once. For example, `repeats([4,5,7,5,4,8]) = 15` because only the numb...
{"functional": "_inputs = [[[4, 5, 7, 5, 4, 8]], [[9, 10, 19, 13, 19, 13]], [[16, 0, 11, 4, 8, 16, 0, 11]], [[5, 17, 18, 11, 13, 18, 11, 13]], [[5, 10, 19, 13, 10, 13]]]\n_outputs = [[15], [19], [12], [22], [24]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n ...
coding
341
Solve the programming task below in a Python markdown code block. Petr likes to come up with problems about randomly generated data. This time problem is about random permutation. He decided to generate a random permutation this way: he takes identity permutation of numbers from 1 to n and then 3n times takes a random ...
{"inputs": ["5\n2 4 5 1 3\n"], "outputs": ["Petr\n"]}
coding
376
Solve the programming task below in a Python markdown code block. Champernown constant is an irrational number represented in decimal by "0." followed by concatenation of all positive integers in the increasing order. The first few digits of this constant are: 0.123456789101112... Your task is to write a program that ...
{"inputs": ["3 5\n6 7\n0 0", "4 5\n1 7\n0 0", "8 5\n6 7\n0 0", "3 5\n6 5\n0 0", "2 5\n1 0\n0 0", "2 5\n0 0\n0 0", "4 5\n0 0\n0 0", "4 1\n0 0\n0 0"], "outputs": ["34567\n6789101\n", "45678\n1234567\n", "89101\n6789101\n", "34567\n67891\n", "23456\n\n", "23456\n", "45678\n", "4\n"]}
coding
206
Solve the programming task below in a Python markdown code block. Back in 2015, Usain Bolt announced that he'll be retiring after the 2017 World Championship. Though his final season did not end gloriously, we all know that he is a true legend and we witnessed his peak during 2008 - 2013. Post retirement, Usain Bolt i...
{"inputs": ["2\n10 100 10 10\n100 10 5 10"], "outputs": ["Bolt\nTiger"]}
coding
640
Solve the programming task below in a Python markdown code block. We will define Ginkgo numbers and multiplication on Ginkgo numbers. A Ginkgo number is a pair <m, n> where m and n are integers. For example, <1, 1>, <-2, 1> and <-3,-1> are Ginkgo numbers. The multiplication on Ginkgo numbers is defined by <m, n> * <x...
{"inputs": ["8\n2 0\n1 2\n-3 1\n4 2\n0 -13\n-4 1\n-2 0\n2 0", "8\n10 -1\n0 2\n0 3\n4 0\n2 -25\n-4 0\n-2 0\n2 0", "8\n10 -1\n0 2\n0 3\n8 0\n2 -23\n-4 0\n-2 1\n2 0", "8\n2 0\n1 2\n-3 1\n4 2\n0 -13\n-4 1\n-2 0\n2 -1", "8\n10 -1\n0 2\n0 3\n4 1\n2 -23\n-4 0\n-2 0\n2 0", "8\n4 0\n0 2\n-3 1\n4 2\n0 -32\n-4 0\n-3 0\n2 -1", "8\...
coding
635
Solve the programming task below in a Python markdown code block. ## Your Job Find the sum of all multiples of `n` below `m` ## Keep in Mind * `n` and `m` are natural numbers (positive integers) * `m` is **excluded** from the multiples ## Examples Also feel free to reuse/extend the following starte...
{"functional": "_inputs = [[4, 123], [123, 4567], [2, 10], [2, 2], [7, 7], [7, 2], [21, 3], [0, 2], [2, 0], [4, -7], [-7, 4]]\n_outputs = [[1860], [86469], [20], [0], [0], [0], [0], ['INVALID'], ['INVALID'], ['INVALID'], ['INVALID']]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance...
coding
96
Solve the programming task below in a Python markdown code block. ### Tongues Gandalf's writings have long been available for study, but no one has yet figured out what language they are written in. Recently, due to programming work by a hacker known only by the code name ROT13, it has been discovered that Gandalf use...
{"functional": "_inputs = [['Ita dotf ni dyca nsaw ecc.'], ['Tim oh nsa nowa gid ecc fiir wat ni liwa ni nsa eor ig nsaod liytndu.'], ['Giydhlida etr hakat uaedh efi iyd gidagensadh pdiyfsn ytni nsoh'], ['litnotatn e tam tenoit.'], ['Nsa zyolv pdimt gij xywbar ikad nsa cequ rifh.'], ['Tywpadh (1234567890) etr bytlnyeno...
coding
402
Solve the programming task below in a Python markdown code block. There are two popular keyboard layouts in Berland, they differ only in letters positions. All the other keys are the same. In Berland they use alphabet with 26 letters which coincides with English alphabet. You are given two strings consisting of 26 dis...
{"inputs": ["ayvguplhjsoiencbkxdrfwmqtz\nkhzvtbspcndierqumlojyagfwx\n3\n", "ayvguplhjsoiencbkxdrfwmqtz\nkhzvtbspcndierqumlojyagfwx\n3\n", "ayvguplhjsoiebcnkxdrfwmqtz\nkhzvtbspcndierqumlojyagfwx\n3\n", "ayvguplhjsoiebcnkxdrfwmqtz\nkhzvtbspcndierqumlojyagfwx\n1\n", "ayvguplhjsoiebcnkxdrfwmqtz\nkhzvtbspcndierqumlojyagfwx\...
coding
389
Solve the programming task below in a Python markdown code block. Snuke has an empty sequence a. He will perform N operations on this sequence. In the i-th operation, he chooses an integer j satisfying 1 \leq j \leq i, and insert j at position j in a (the beginning is position 1). You are given a sequence b of lengt...
{"inputs": ["2\n1 1", "2\n1 2", "2\n4 2", "2\n3 2", "2\n3 4", "2\n1 4", "2\n2 4", "2\n2 8"], "outputs": ["1\n1\n", "1\n2\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n"]}
coding
305
Solve the programming task below in a Python markdown code block. In Conway's Game of Life, cells in a grid are used to simulate biological cells. Each cell is considered to be either alive or dead. At each step of the simulation each cell's current status and number of living neighbors is used to determine the status ...
{"inputs": ["4\n00011101\n000\n000001\n11110", "4\n00011101\n100\n000001\n11110", "4\n00010101\n100\n000101\n11110", "4\n00010101\n100\n010101\n11110", "4\n00010101\n000\n011111\n11110", "4\n00010101\n000\n011111\n11100", "4\n00000101\n000\n011111\n11100", "4\n00000101\n000\n010101\n11100"], "outputs": ["01100101\nMult...
coding
505
Solve the programming task below in a Python markdown code block. Chef has recently moved into an apartment. It takes 30 minutes for Chef to reach office from the apartment. Chef left for the office X minutes before Chef was supposed to reach. Determine whether or not Chef will be able to reach on time. ------ Input...
{"inputs": ["6\n30\n60\n14\n29\n31\n42\n"], "outputs": ["YES\nYES\nNO\nNO\nYES\nYES\n"]}
coding
291
Please solve the programming task below using a self-contained code snippet in a markdown code block. You are given a 2D integer array ranges and two integers left and right. Each ranges[i] = [starti, endi] represents an inclusive interval between starti and endi. Return true if each integer in the inclusive range [le...
{"functional": "def check(candidate):\n assert candidate(ranges = [[1,2],[3,4],[5,6]], left = 2, right = 5) == True\n assert candidate(ranges = [[1,10],[10,20]], left = 21, right = 21) == False\n\n\ncheck(Solution().isCovered)"}
coding
154
Solve the programming task below in a Python markdown code block. Masha has three sticks of length $a$, $b$ and $c$ centimeters respectively. In one minute Masha can pick one arbitrary stick and increase its length by one centimeter. She is not allowed to break sticks. What is the minimum number of minutes she needs t...
{"inputs": ["3 4 5\n", "2 5 3\n", "1 1 1\n", "3 1 1\n", "2 3 6\n", "4 5 6\n", "4 2 7\n", "2 5 2\n"], "outputs": ["0\n", "1\n", "0\n", "2\n", "2\n", "0\n", "2\n", "2\n"]}
coding
441
Please solve the programming task below using a self-contained code snippet in a markdown code block. You are given an integer array target and an integer n. You have an empty stack with the two following operations: "Push": pushes an integer to the top of the stack. "Pop": removes the integer on the top of the stack...
{"functional": "def check(candidate):\n assert candidate(target = [1,3], n = 3) == [\"Push\",\"Push\",\"Pop\",\"Push\"]\n assert candidate(target = [1,2,3], n = 3) == [\"Push\",\"Push\",\"Push\"]\n assert candidate(target = [1,2], n = 4) == [\"Push\",\"Push\"]\n\n\ncheck(Solution().buildArray)"}
coding
260
Solve the programming task below in a Python markdown code block. For a binary string S, define its beauty to be the maximum number of [substrings] S can be partitioned into, such that each substring has strictly more ones than zeroes. For example, the beauty of 11011 is 3, as it can be partitioned as [110][1][1]. If s...
{"inputs": ["4 1\n1\n0\n2\n11\n3\n010\n4\n0110\n2 4"], "outputs": ["3"]}
coding
633
Solve the programming task below in a Python markdown code block. Kostya likes Codeforces contests very much. However, he is very disappointed that his solutions are frequently hacked. That's why he decided to obfuscate (intentionally make less readable) his code before upcoming contest. To obfuscate the code, Kostya ...
{"inputs": ["a\n", "z\n", "b\n", "x\n", "c\n", "z\n", "c\n", "b\n"], "outputs": ["YES\n", "NO\n", "NO\n", "NO\n", "NO\n", "NO\n", "NO\n", "NO\n"]}
coding
408
Solve the programming task below in a Python markdown code block. Alice gave Bob 3 integers N, K, and S. Help Bob find an S-good sequence. A sequence B of length N is called S-good if the following conditions are met: B_{i} \in \{-1, 0, 1\} for each 1 ≤ i ≤ N \sum_{i=1}^N B_{i}\cdot K^{i-1} = S If there are multiple ...
{"inputs": ["3\n4 2 15\n3 6 36\n5 5 7"], "outputs": ["1 1 1 1\n0 0 1\n-2"]}
coding
497
Solve the programming task below in a Python markdown code block. Read problems statements in Mandarin Chinese and Russian. Sereja have array A' that contain N integers. Now Sereja want to permute elements of the array, he want to use some permutation p, such that A[i] = A'[p[i]], where A - new array.   Lets functi...
{"inputs": ["2\n3 2 4\n3 4 1\n4 4 1\n1 1 1 1"], "outputs": ["2 1 3\n4 3 2 1"]}
coding
510
Solve the programming task below in a Python markdown code block. Chef is learning linear algebra. Recently, he learnt that for a square matrix $M$, $\mathop{\rm trace}(M)$ is defined as the sum of all elements on the main diagonal of $M$ (an element lies on the main diagonal if its row index and column index are equal...
{"inputs": ["1\n3\n1 2 5\n6 3 4\n2 7 1"], "outputs": ["13"]}
coding
553
Solve the programming task below in a Python markdown code block. Little Lesha loves listening to music via his smartphone. But the smartphone doesn't have much memory, so Lesha listens to his favorite songs in a well-known social network InTalk. Unfortunately, internet is not that fast in the city of Ekaterinozavodsk...
{"inputs": ["5 2 2\n", "5 4 7\n", "6 2 3\n", "2 1 2\n", "2 1 3\n", "2 1 3\n", "2 1 2\n", "5 1 2\n"], "outputs": ["2\n", "1\n", "1\n", "1\n", "1\n", "1\n", "1\n", "3\n"]}
coding
420
Solve the programming task below in a Python markdown code block. The Little Elephant from the Zoo of Lviv currently is on the military mission. There are N enemy buildings placed in a row and numbered from left to right strating from 0. Each building i (except the first and the last) has exactly two adjacent buildings...
{"inputs": ["3\n3\n010\n5\n10001\n7\n0000000"], "outputs": ["0\n1\n7"]}
coding
305
Please solve the programming task below using a self-contained code snippet in a markdown code block. You are given a 0-indexed two-dimensional integer array nums. Return the largest prime number that lies on at least one of the diagonals of nums. In case, no prime is present on any of the diagonals, return 0. Note th...
{"functional": "def check(candidate):\n assert candidate(nums = [[1,2,3],[5,6,7],[9,10,11]]) == 11\n assert candidate(nums = [[1,2,3],[5,17,7],[9,11,10]]) == 17\n\n\ncheck(Solution().diagonalPrime)"}
coding
199
Solve the programming task below in a Python markdown code block. The Fibonacci sequence is defined as F(n) = F(n-1) + F(n-2). You have developed two sequences of numbers. The first sequence that uses the bitwise XOR operation instead of the addition method is called the Xoronacci number. It is described as follows: X(...
{"inputs": ["1\n3 4 2"], "outputs": ["4"]}
coding
383
Solve the programming task below in a Python markdown code block. Vasya's birthday is approaching and Lena decided to sew a patterned handkerchief to him as a present. Lena chose digits from 0 to n as the pattern. The digits will form a rhombus. The largest digit n should be located in the centre. The digits should dec...
{"inputs": ["4\n", "5\n", "9\n", "7\n", "8\n", "6\n", "3\n", "2\n"], "outputs": [" 0\n 0 1 0\n 0 1 2 1 0\n 0 1 2 3 2 1 0\n0 1 2 3 4 3 2 1 0\n 0 1 2 3 2 1 0\n 0 1 2 1 0\n 0 1 0\n 0\n", " 0\n 0 1 0\n 0 1 2 1 0\n 0 1 2 3 2 1 0\n 0 1 2 3 4 3 2 1 0\n0 1 2 3 4 5 4 3 2 ...
coding
463
Solve the programming task below in a Python markdown code block. Vasya is an administrator of a public page of organization "Mouse and keyboard" and his everyday duty is to publish news from the world of competitive programming. For each news he also creates a list of hashtags to make searching for a particular topic ...
{"inputs": ["1\n#h\n", "1\n#h\n", "2\n#y\n#q\n", "2\n#y\n#q\n", "2\n#y\n#p\n", "2\n#y\n#o\n", "2\n#x\n#o\n", "2\n#x\n#p\n"], "outputs": ["#h\n", "#h\n", "#\n#q\n", "#\n#q\n", "#\n#p\n", "#\n#o\n", "#\n#o\n", "#\n#p\n"]}
coding
698
Solve the programming task below in a Python markdown code block. Sheldon, Leonard, Penny, Rajesh and Howard are in the queue for a "Double Cola" drink vending machine; there are no other people in the queue. The first one in the queue (Sheldon) buys a can, drinks it and doubles! The resulting two Sheldons go to the en...
{"inputs": ["4\n", "5\n", "3\n", "2\n", "8\n", "6\n", "1\n", "24\n"], "outputs": ["Rajesh", "Howard", "Penny", "Leonard", "Leonard\n", "Sheldon", "Sheldon", "Penny"]}
coding
362
Solve the programming task below in a Python markdown code block. There is an easy way to obtain a new task from an old one called "Inverse the problem": we give an output of the original task, and ask to generate an input, such that solution to the original problem will produce the output we provided. The hard task of...
{"inputs": ["1\n0\n", "1\n1\n", "1\n2\n", "1\n4\n", "1\n6\n", "1\n5\n", "1\n7\n", "1\n3\n"], "outputs": ["YES\n", "NO\n", "NO\n", "NO\n", "NO\n", "NO\n", "NO\n", "NO\n"]}
coding
458
Solve the programming task below in a Python markdown code block. You are given an integer sequence $A_1, A_2, \ldots, A_N$ and an integer $X$. Consider a $N \times N$ matrix $B$, where $B_{i,j} = A_i + A_j$ for each valid $i$ and $j$. You need to find the number of square submatrices of $B$ such that the sum of their ...
{"inputs": ["2\n5 36\n1 2 3 1 12\n4 54\n3 3 3 3"], "outputs": ["6\n4"]}
coding
499
Solve the programming task below in a Python markdown code block. Given a complete binary tree with the height of H, we index the nodes respectively top-down and left-right from 1. The i-th node stores a positive integer V_{i}. Define P_{i} as follows: P_{i}=V_{i} if the i-th node is a leaf, otherwise P_{i}=max(V_{i}*P...
{"inputs": ["2\n1 2 3\n3\n3 1 5 2 6 4 7\n0", "2\n1 2 3\n3\n3 1 1 2 6 4 7\n0", "2\n1 2 3\n3\n3 1 1 2 6 1 8\n0", "2\n1 2 1\n3\n3 1 1 2 3 1 8\n0", "2\n1 2 3\n3\n3 2 1 2 6 1 7\n0", "2\n1 2 1\n3\n4 1 1 2 3 1 8\n0", "2\n1 2 3\n3\n1 2 1 2 6 1 7\n0", "2\n2 2 3\n3\n3 1 1 2 6 4 7\n0"], "outputs": ["3\n105", "3\n21\n", "3\n24\n",...
coding
347
Solve the programming task below in a Python markdown code block. Edward Leven loves multiples of eleven very much. When he sees a number, he always tries to find consecutive subsequences (or substrings) forming multiples of eleven. He calls such subsequences as 11-sequences. For example, he can find an 11-sequence 781...
{"inputs": ["17819\n1010\n10011\n7865275925328748785018788\n0", "17819\n0110\n10011\n7865275925328748785018788\n0", "17819\n0110\n10011\n4852349612300523475741654\n0", "17819\n0110\n00011\n4852349612300523475741654\n0", "17819\n0110\n01011\n6299136610007038575852406\n0", "17819\n0110\n01011\n8858159281710306483280973\n...
coding
353
Solve the programming task below in a Python markdown code block. Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well. For an array $B$, while it has more than one element, you can apply an operation on it - you choose any two elements $x,y$ (they may be the same val...
{"inputs": ["10 \n0 1 2 3 4 5 6 7 8 9"], "outputs": ["160"]}
coding
580
Solve the programming task below in a Python markdown code block. ## Number pyramid Number pyramid is a recursive structure where each next row is constructed by adding adjacent values of the current row. For example: ``` Row 1 [1 2 3 4] Row 2 [3 5 7] Row 3 [8 12] Row 4 ...
{"functional": "_inputs = [[[1]], [[3, 5]], [[3, 9, 4]], [[5, 6, 7, 8]], [[13, 1, 21, 9]], [[13, 76, 21, 42, 63]]]\n_outputs = [[1], [8], [25], [52], [88], [674]]\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...
coding
221
Solve the programming task below in a Python markdown code block. Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well. There are $N$ students standing in a row and numbered $1$ through $N$ from left to right. You are given a string $S$ with length $N$, where for each ...
{"inputs": ["3\nxy\nxyxxy\nyy"], "outputs": ["1\n2\n0"]}
coding
473
Solve the programming task below in a Python markdown code block. Write a program to check whether a triangle is valid or not, when the three angles of the triangle are the inputs. A triangle is valid if the sum of all the three angles is equal to 180 degrees. -----Input----- The first line contains an integer T, the...
{"inputs": ["3 \n10 2 001\n0 8 5\n180 1 0", "3 \n10 2 001\n0 8 2\n180 1 0", "3 \n41 2 001\n0 8 15\n180 1 0", "3 \n10 2 001\n0 8 15\n180 1 0", "3 \n10 2 000\n0 8 15\n180 1 0", "3 \n10 2 000\n0 7 15\n180 1 0", "3 \n3 2 101\n0 45 15\n180 0 0", "3 \n41 2 101\n0 8 15\n180 1 0"], "outputs": ["NO\nNO\nNO\n", "NO\nNO\nNO\n", "...
coding
202
Solve the programming task below in a Python markdown code block. Inspired by the development team at Vooza, write the function `howManyLightsabersDoYouOwn`/`how_many_light_sabers_do_you_own` that * accepts the name of a programmer, and * returns the number of lightsabers owned by that person. The only person who ow...
{"functional": "_inputs = [['Zach'], ['zach']]\n_outputs = [[18], [0]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return math.isclose(a, b, rel_tol=tol, abs_tol=tol)\n if isinstance(a, (list, tuple)):\n if len(a) != len(b): return False\n ...
coding
266
Solve the programming task below in a Python markdown code block. Let f be a [permutation] of length N, where N is even. The *riffle* of f is defined to be the permutation g = (f(1), f(3), \ldots, f(N-1), f(2), f(4), \ldots, f(N)) You are given two integers N and K. Output the resultant permutation when you riffle the...
{"inputs": ["3\n6 1\n8 2\n14 452"], "outputs": ["1 3 5 2 4 6\n1 5 2 6 3 7 4 8\n1 10 6 2 11 7 3 12 8 4 13 9 5 14"]}
coding
598
Solve the programming task below in a Python markdown code block. Summer is coming! It's time for Iahub and Iahubina to work out, as they both want to look hot at the beach. The gym where they go is a matrix a with n lines and m columns. Let number a[i][j] represents the calories burned by performing workout at the cel...
{"inputs": ["3 3\n3 1 2\n3 2 0\n2 3 2\n", "3 3\n9 0 9\n0 9 9\n9 9 9\n", "3 3\n3 1 2\n3 2 0\n2 3 2\n", "3 3\n9 0 9\n0 9 9\n9 9 9\n", "3 3\n3 1 2\n3 2 0\n1 3 2\n", "3 3\n9 0 9\n0 9 9\n9 5 9\n", "3 3\n3 1 3\n3 2 0\n1 3 2\n", "3 3\n0 0 9\n0 9 9\n9 5 9\n"], "outputs": ["16", "54", "16\n", "54\n", "15\n", "50\n", "16\n", "41...
coding
558
Solve the programming task below in a Python markdown code block. A generalization of Bézier surfaces, called the S-patch, uses an interesting scheme for indexing its control points. In the case of an n-sided surface of degree d, each index has n non-negative integers that sum to d, and all possible configurations are...
{"functional": "_inputs = [[1, 0], [3, 0]]\n_outputs = [[[[0]]], [[[0, 0, 0]]]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return math.isclose(a, b, rel_tol=tol, abs_tol=tol)\n if isinstance(a, (list, tuple)):\n if len(a) != len(b): return False\...
coding
232
Solve the programming task below in a Python markdown code block. Jaggu is a little kid and he likes playing with water balloons. He took 1 million ( $10^{6} $) empty buckets and he filled the bucket with water balloons under the instruction of his sister Ishika. His sister gives him two types of commands: R pos1 po...
{"inputs": ["2\nU 692778 7 291188\nR 636916 747794\n"], "outputs": ["378 \n"]}
coding
594
Please solve the programming task below using a self-contained code snippet in a markdown code block. You may recall that an array arr is a mountain array if and only if: arr.length >= 3 There exists some index i (0-indexed) with 0 < i < arr.length - 1 such that: arr[0] < arr[1] < ... < arr[i - 1] < arr[i] arr[i] >...
{"functional": "def check(candidate):\n assert candidate(nums = [1,3,1]) == 0\n assert candidate(nums = [2,1,1,5,6,2,3,1]) == 3\n\n\ncheck(Solution().minimumMountainRemovals)"}
coding
165
Solve the programming task below in a Python markdown code block. # Introduction The first century spans from the **year 1** *up to* and **including the year 100**, **The second** - *from the year 101 up to and including the year 200*, etc. # Task : Given a year, return the century it is in. Also feel free to reuse/...
{"functional": "_inputs = [[1705], [1900], [1601], [2000], [356], [89]]\n_outputs = [[18], [19], [17], [20], [4], [1]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return math.isclose(a, b, rel_tol=tol, abs_tol=tol)\n if isinstance(a, (list, tuple)):\n ...
coding
102
Solve the programming task below in a Python markdown code block. problem Given the sequence $ A $ of length $ N $. Find the maximum value of $ \ sum B_i $, where $ B $ is one of the longest increasing subsequences of the sequence $ A $. The longest increasing subsequence of the sequence $ A $ is the longest subseque...
{"inputs": ["4\n7 4 7 8", "4\n7 4 1 8", "4\n7 4 2 9", "4\n7 4 2 6", "4\n6 4 3 8", "4\n7 5 7 8", "4\n6 4 3 3", "4\n6 1 3 3"], "outputs": ["19\n", "15\n", "16\n", "10\n", "14\n", "20\n", "6\n", "4\n"]}
coding
150
Solve the programming task below in a Python markdown code block. Given an array of bird sightings where every element represents a bird type id, determine the id of the most frequently sighted type. If more than 1 type has been spotted that maximum amount, return the smallest of their ids. Example $arr=[1,1,2,2,3]...
{"inputs": ["6\n1 4 4 4 5 3\n", "11\n1 2 3 4 5 4 3 2 1 3 4\n"], "outputs": ["4\n", "3\n"]}
coding
484
Solve the programming task below in a Python markdown code block. DNA is a biomolecule that carries genetic information. It is composed of four different building blocks, called nucleotides: adenine (A), thymine (T), cytosine (C) and guanine (G). Two DNA strands join to form a double helix, whereby the nucleotides of o...
{"functional": "_inputs = [['GTCTTAGTGTAGCTATGCATGC', 'GCATGCATAGCTACACTACGAC'], ['ATGCTACG', 'CGTAGCAT'], ['AGTCTGTATGCATCGTACCC', 'GGGTACGATGCATACAGACT'], ['TGCTACGTACGATCGACGATCCACGAC', 'GTCGTGGATCGTCGATCGTACGTAGCA'], ['ATGCCTACGGCCATATATATTTAG', 'CTAAATATGTATGGCCGTAGGCAT'], ['GTCACCGA', 'TCGGCTGAC'], ['TAATACCCGACT...
coding
437
Solve the programming task below in a Python markdown code block. Recently a Golden Circle of Beetlovers was found in Byteland. It is a circle route going through n ⋅ k cities. The cities are numerated from 1 to n ⋅ k, the distance between the neighboring cities is exactly 1 km. Sergey does not like beetles, he loves ...
{"inputs": ["3 3\n1 0\n", "4 3\n1 1\n", "2 1\n0 0\n", "6 3\n1 1\n", "5 5\n2 2\n", "4 3\n1 0\n", "1 1\n0 0\n", "6 3\n0 1\n"], "outputs": ["9 9\n", "1 12\n", "1 2\n", "1 18\n", "1 25\n", "3 12\n", "1 1\n", "9 18\n"]}
coding
740
Solve the programming task below in a Python markdown code block. Alice and Bob are playing a game of coins. N coins are placed on the table in a row. The game begins with Alice and afterwards they alternate the moves. A valid move is defined as follows: You pick one coin or two adjacent coins and remove them. The...
{"inputs": ["100\n1\n8\n8\n2\n8\n8\n3\n1\n9\n5\n1\n3\n9\n6\n1\n8\n9\n9\n5\n8\n3\n8\n7\n6\n8\n8\n10\n10\n3\n10\n2\n3\n2\n9\n7\n8\n5\n7\n4\n5\n10\n9\n10\n1\n5\n5\n3\n9\n7\n9\n1\n1\n3\n4\n4\n8\n1\n10\n3\n8\n5\n9\n8\n10\n9\n8\n6\n3\n2\n4\n1\n6\n1\n8\n8\n4\n7\n1\n1\n10\n8\n5\n7\n9\n6\n6\n9\n10\n7\n1\n1\n9\n10\n9\n5\n10\n5\n...
coding
228
Solve the programming task below in a Python markdown code block. Read problems statements in Mandarin chinese, Russian and Vietnamese as well. A sequence of integers is beautiful if each element of this sequence is divisible by 4. You are given a sequence a_{1}, a_{2}, ..., a_{n}. In one step, you may choose any tw...
{"inputs": ["1\n7\n1 2 3 1 2 3 8"], "outputs": ["3"]}
coding
309
Please solve the programming task below using a self-contained code snippet in a markdown code block. Given the head of a linked list, return the list after sorting it in ascending order.   Please complete the following python code precisely: ```python # Definition for singly-linked list. # class ListNode: # def _...
{"functional": "def check(candidate):\n assert is_same_list(candidate(head = list_node([4,2,1,3])), list_node([1,2,3,4]))\n assert is_same_list(candidate(head = list_node([-1,5,3,4,0])), list_node([-1,0,3,4,5]))\n assert is_same_list(candidate(head = list_node([])), list_node([]))\n\n\ncheck(Solution().sortLis...
coding
109
Solve the programming task below in a Python markdown code block. Will you make it? You were camping with your friends far away from home, but when it's time to go back, you realize that your fuel is running out and the nearest pump is ```50``` miles away! You know that on average, your car runs on about ```25``` mile...
{"functional": "_inputs = [[50, 25, 2], [60, 30, 3], [70, 25, 1], [100, 25, 3]]\n_outputs = [[True], [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=tol)\n if isinstance(a, (list, tuple...
coding
175
Solve the programming task below in a Python markdown code block. You are given a string S, consisting of lowercase English letters. You can do the following operation at most once : Choose a subsequence of the string S, then remove it from S and concatenate the subsequence at the end of the remaining string. Find t...
{"inputs": ["4\naba\nabcd\ncbcdbef\nfabcdac"], "outputs": ["aab\nabcd\nbbccdef\naacfbcd\n"]}
coding
520
Solve the programming task below in a Python markdown code block. Fox Ciel studies number theory. She thinks a non-empty set S contains non-negative integers is perfect if and only if for any $a, b \in S$ (a can be equal to b), $(a \text{xor} b) \in S$. Where operation xor means exclusive or operation (http://en.wikip...
{"inputs": ["1\n", "2\n", "3\n", "4\n", "8\n", "5\n", "6\n", "0\n"], "outputs": ["2\n", "3\n", "5\n", "6\n", "17\n", "8\n", "11\n", "1\n"]}
coding
327
Please solve the programming task below using a self-contained code snippet in a markdown code block. You are given two non-increasing 0-indexed integer arrays nums1​​​​​​ and nums2​​​​​​. A pair of indices (i, j), where 0 <= i < nums1.length and 0 <= j < nums2.length, is valid if both i <= j and nums1[i] <= nums2[j]....
{"functional": "def check(candidate):\n assert candidate(nums1 = [55,30,5,4,2], nums2 = [100,20,10,10,5]) == 2\n assert candidate(nums1 = [2,2,2], nums2 = [10,10,1]) == 1\n assert candidate(nums1 = [30,29,19,5], nums2 = [25,25,25,25,25]) == 2\n\n\ncheck(Solution().maxDistance)"}
coding
188
Solve the programming task below in a Python markdown code block. Read problems statements [Bengali] and [Vietnamese] as well. Ghayeeth is a math teacher. He likes playing games, so he invented a new game which he wants to play against his student Siroj. The rules of the game are as follows: Initially, Ghayeeth writes...
{"inputs": ["2\n3\n7 9 11\n2\n13 15"], "outputs": ["Ghayeeth\nSiroj"]}
coding
450
Solve the programming task below in a Python markdown code block. In genetics, a sequence’s motif is a nucleotides (or amino-acid) sequence pattern. Sequence motifs have a biological significance. For more information you can take a look [here](https://en.wikipedia.org/wiki/Sequence_motif). For this kata you need to ...
{"functional": "_inputs = [['TTCCGGAACC', 'CC'], ['ACGTTACAACGTTAG', 'ACGT'], ['ACGTACGTACGT', 'AAA'], ['ACGT', 'ACGTGAC']]\n_outputs = [[[3, 9]], [[1, 9]], [[]], [[]]]\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_t...
coding
297
Solve the programming task below in a Python markdown code block. Every day we can send from the server a certain limit of e-mails. Task: Write a function that will return the integer number of e-mails sent in the percentage of the limit. Example: ``` limit - 1000; emails sent - 101; return - 10%; // becou...
{"functional": "_inputs = [[101, 1000], [256, 500], [259], [0], [1000, 1000]]\n_outputs = [['10%'], ['51%'], ['25%'], ['No e-mails sent'], ['Daily limit is reached']]\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...
coding
209
Solve the programming task below in a Python markdown code block. Read problem statements in [Russian], [Bengali], and [Mandarin Chinese] as well. There are $N$ students standing in a canteen queue, numbered $1$ to $N$ from left to right. For each valid $i$, the $i$-th student has a height $h_{i}$. Two students $i$ a...
{"inputs": ["1\n5\n1 2 2 3 2"], "outputs": ["0 1 1 0 0"]}
coding
532
Solve the programming task below in a Python markdown code block. The defaultdict tool is a container in the collections class of Python. It's similar to the usual dictionary (dict) container, but the only difference is that a defaultdict will have a default value if that key has not been set yet. If you didn't use a d...
{"inputs": ["5 2\na\na\nb\na\nb\na\nb\n"], "outputs": ["1 2 4\n3 5\n"]}
coding
700
Please solve the programming task below using a self-contained code snippet in a markdown code block. Assume you are an awesome parent and want to give your children some cookies. But, you should give each child at most one cookie. Each child i has a greed factor g[i], which is the minimum size of a cookie that the ch...
{"functional": "def check(candidate):\n assert candidate(g = [1,2,3], s = [1,1]) == 1\n assert candidate(g = [1,2], s = [1,2,3]) == 2\n\n\ncheck(Solution().findContentChildren)"}
coding
162
Please solve the programming task below using a self-contained code snippet in a markdown code block. Given a string s, return the number of distinct substrings of s. A substring of a string is obtained by deleting any number of characters (possibly zero) from the front of the string and any number (possibly zero) fro...
{"functional": "def check(candidate):\n assert candidate(s = \"aabbaba\") == 21\n assert candidate(s = \"abcdefg\") == 28\n\n\ncheck(Solution().countDistinct)"}
coding
100
Solve the programming task below in a Python markdown code block. Luke Skywalker gave Chewbacca an integer number x. Chewbacca isn't good at numbers but he loves inverting digits in them. Inverting digit t means replacing it with digit 9 - t. Help Chewbacca to transform the initial number x to the minimum possible po...
{"inputs": ["1\n", "9\n", "9\n", "1\n", "5\n", "8\n", "27\n", "81\n"], "outputs": ["1\n", "9\n", "9\n", "1\n", "4\n", "1\n", "22\n", "11\n"]}
coding
187
Please solve the programming task below using a self-contained code snippet in a markdown code block. Given two strings s1 and s2, return the lowest ASCII sum of deleted characters to make two strings equal.   Please complete the following python code precisely: ```python class Solution: def minimumDeleteSum(self,...
{"functional": "def check(candidate):\n assert candidate(s1 = \"sea\", s2 = \"eat\") == 231\n assert candidate(s1 = \"delete\", s2 = \"leet\") == 403\n\n\ncheck(Solution().minimumDeleteSum)"}
coding
78
Solve the programming task below in a Python markdown code block. Utkarsh is forced to play yet another one of Ashish's games. The game progresses turn by turn and as usual, Ashish moves first. Consider the 2D plane. There is a token which is initially at $(0,0)$. In one move a player must increase either the $x$ coor...
{"inputs": ["5\n4 1\n4 1\n20 3\n55 4\n768 53\n", "5\n6 1\n2 2\n9 1\n58 4\n4776 53\n", "5\n2 1\n9 1\n10 3\n9 4\n33374 5\n", "5\n6 1\n3 2\n9 1\n58 4\n4776 53\n", "5\n2 1\n9 1\n13 3\n9 4\n33374 5\n", "5\n4 2\n2 1\n6 2\n58 4\n15769 7\n", "5\n4 1\n2 2\n9 1\n58 4\n12041 53\n", "5\n2 1\n9 1\n10 3\n9 4\n33374 57\n"], "outputs"...
coding
443
Solve the programming task below in a Python markdown code block. Given an integer N not less than 3, find the sum of the interior angles of a regular polygon with N sides. Print the answer in degrees, but do not print units. Constraints * 3 \leq N \leq 100 Input Input is given from Standard Input in the following...
{"inputs": ["5", "9", "7", "2", "4", "8", "6", "3"], "outputs": ["540\n", "1260\n", "900\n", "0\n", "360\n", "1080\n", "720\n", "180"]}
coding
127
Solve the programming task below in a Python markdown code block. The student council has a shared document file. Every day, some members of the student council write the sequence TMT (short for Towa Maji Tenshi) in it. However, one day, the members somehow entered the sequence into the document at the same time, crea...
{"inputs": ["5\n3\nTMT\n3\nMTT\n6\nTMTMTT\n6\nTMTTTT\n6\nTTMMTT\n", "5\n3\nTMT\n3\nMTT\n6\nTMTMTT\n6\nMTTTTT\n6\nTTMMTT\n", "5\n3\nTMT\n3\nMTT\n6\nTMTMTT\n6\nMTTTTT\n6\nTTMTTM\n", "5\n3\nTMT\n3\nMTT\n6\nTTTMMT\n6\nTMTTTT\n6\nTTMMTT\n", "5\n3\nTTM\n3\nTTM\n6\nTMTMTT\n6\nMTTTTT\n6\nTTMMTT\n", "5\n3\nTTM\n3\nTMT\n6\nTMTMT...
coding
471
Solve the programming task below in a Python markdown code block. Chef recently learned about ratios and proportions. He wrote some positive integers a, b, c, d on a paper. Chef wants to know whether he can shuffle these numbers so as to make some proportion? Formally, four numbers x, y, z, w are said to make a proport...
{"inputs": ["1 2 4 2"], "outputs": ["Possible"]}
coding
236
Solve the programming task below in a Python markdown code block. There is a programing contest named SnakeUp, 2n people want to compete for it. In order to attend this contest, people need to form teams of exactly two people. You are given the strength of each possible combination of two people. All the values of the ...
{"inputs": ["1\n1000000\n", "1\n1000000\n", "1\n1000001\n", "1\n1000100\n", "1\n0000001\n", "1\n1000110\n", "1\n0001001\n", "1\n1001110\n"], "outputs": ["2 1\n", "2 1\n", "2 1 ", "2 1 ", "2 1 ", "2 1 ", "2 1 ", "2 1 "]}
coding
531
Please solve the programming task below using a self-contained code snippet in a markdown code block. Given a string s, find the first non-repeating character in it and return its index. If it does not exist, return -1.   Please complete the following python code precisely: ```python class Solution: def firstUniqC...
{"functional": "def check(candidate):\n assert candidate(s = \"leetcode\") == 0\n assert candidate(s = \"loveleetcode\") == 2\n assert candidate(s = \"aabb\") == -1\n\n\ncheck(Solution().firstUniqChar)"}
coding
78
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"]}
coding
545
Solve the programming task below in a Python markdown code block. We have a permutation of the integers from 1 through N, p_1, p_2, .., p_N. We also have M pairs of two integers between 1 and N (inclusive), represented as (x_1,y_1), (x_2,y_2), .., (x_M,y_M). AtCoDeer the deer is going to perform the following operation...
{"inputs": ["3 2\n3 2 1\n1 2\n1 3", "3 2\n3 2 1\n1 2\n2 2", "3 2\n3 2 1\n1 1\n1 3", "5 1\n1 2 3 4 5\n1 5", "3 2\n3 2 1\n1 2\n2 3", "5 2\n5 3 1 4 3\n1 3\n5 4", "5 2\n5 3 1 4 2\n1 2\n5 4", "5 2\n5 3 1 4 2\n1 2\n5 3"], "outputs": ["3\n", "1\n", "3\n", "5", "3", "2\n", "1\n", "1\n"]}
coding
459
Solve the programming task below in a Python markdown code block. The height of the student was measured at the medical examination. Create a program that takes height data as input, creates a frequency distribution, and outputs it. The frequency distribution is divided into 6 classes in 5 cm increments, and the number...
{"inputs": ["4\n180.3\n168.2\n165.5\n175.3", "4\n180.3\n168.42932428490565\n165.5\n175.3", "4\n180.68754203533285\n168.42932428490565\n165.5\n175.3", "4\n180.95536695412983\n168.42932428490565\n165.5\n175.3", "4\n180.95536695412983\n168.42932428490565\n165.65038418972082\n175.3", "4\n186.487152384495\n176.2575594727457...
coding
564
Please solve the programming task below using a self-contained code snippet in a markdown code block. You are given an m x n integer matrix grid​​​, where m and n are both even integers, and an integer k. The matrix is composed of several layers, which is shown in the below image, where each color is its own layer: A...
{"functional": "def check(candidate):\n assert candidate(grid = [[40,10],[30,20]], k = 1) == [[10,20],[40,30]]\n assert candidate(grid = [[1,2,3,4],[5,6,7,8],[9,10,11,12],[13,14,15,16]], k = 2) == [[3,4,8,12],[2,11,10,16],[1,7,6,15],[5,9,13,14]]\n\n\ncheck(Solution().rotateGrid)"}
coding
170
Solve the programming task below in a Python markdown code block. A certain type of steel is graded according to the following conditions. 1. Hardness of the steel must be greater than 50 2. Carbon content of the steel must be less than 0.7 3. Tensile strength must be greater than 5600 The grades awarded are as follo...
{"inputs": ["3 \n67 0.6 5602\n45 0 4500\n0 0 0", "3 \n67 0.6 5602\n78 0 4500\n0 0 0", "3 \n53 0.6 5602\n45 0 4500\n0 0 0", "3 \n103 0.6 5602\n78 0 4500\n0 0 0", "3 \n103 0.6 5602\n78 0 4466\n0 0 0", "3 \n103 0.6 7770\n78 0 4466\n0 0 0", "3 \n53 0.6 5602\n45 0 4500\n0 0 0 \n", "3 \n103 0.6 7770\n78 -1 4466\n0 0 0"], "ou...
coding
349
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"]}
coding
435
Solve the programming task below in a Python markdown code block. HTML Element Generator In this kata, you will be creating a python function that will take arguments and turn them into an HTML element. An HTML tag has three parts: The opening tag, which consists of a tag name and potentially attributes, all in betwee...
{"functional": "_inputs = [['br'], ['title', 'Webpage Title']]\n_outputs = [['<br />'], ['<title>Webpage Title</title>']]\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...
coding
520
Solve the programming task below in a Python markdown code block. **This Kata is intended as a small challenge for my students** All Star Code Challenge #16 Create a function called noRepeat() that takes a string argument and returns a single letter string of the **first** not repeated character in the entire string....
{"functional": "_inputs = [['aabbccdde'], ['wxyz'], ['testing'], ['codewars'], ['Testing']]\n_outputs = [['e'], ['w'], ['e'], ['c'], ['T']]\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,...
coding
162