task_type
stringclasses
1 value
problem
stringlengths
261
3.34k
answer
stringlengths
35
6.15k
problem_tokens
int64
62
774
answer_tokens
int64
12
2.04k
coding
Solve the programming task below in a Python markdown code block. We have two integers: A and B. Print the largest number among A + B, A - B, and A \times B. -----Constraints----- - All values in input are integers. - -100 \leq A,\ B \leq 100 -----Input----- Input is given from Standard Input in the following forma...
{"inputs": ["0 0\n", "13 3\n", "91 0\n", "0 15\n", "10 1\n", "-13 3\n", "1 -33\n", "36 80\n"], "outputs": ["0\n", "39\n", "91\n", "15\n", "11\n", "-10\n", "34\n", "2880\n"]}
162
103
coding
Solve the programming task below in a Python markdown code block. Given a set of elements (integers or string characters) that may occur more than once, we need to know the amount of subsets that none of their values have repetitions. Let's see with an example: ``` set numbers = {1, 2, 3, 4} ``` The subsets are: ``` ...
{"functional": "_inputs = [[[1, 2, 3, 4]], [['a', 'b', 'c', 'd', 'd']]]\n_outputs = [[15], [15]]\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(...
488
185
coding
Solve the programming task below in a Python markdown code block. Your Goal is to create a function that takes two strings, a guess and a phone number. Based on the guess, the function should display a portion of the phone number: guess_my_number('052', '123-451-2345') would return the string: '#2#-#5#-2##5...
{"functional": "_inputs = [['0'], ['01'], ['012'], ['0123'], ['01234'], ['012345']]\n_outputs = [['###-###-####'], ['1##-##1-####'], ['12#-##1-2###'], ['123-##1-23##'], ['123-4#1-234#'], ['123-451-2345']]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return m...
275
249
coding
Solve the programming task below in a Python markdown code block. You have invented a time-machine which has taken you back to ancient Rome. Caeser is impressed with your programming skills and has appointed you to be the new information security officer. Caeser has ordered you to write a Caeser cipher to prevent Aste...
{"functional": "_inputs = [['This is a message', 0], ['who are you?', 18], ['..5tyu..', 25], ['..#$%^..', 0], ['..#$%^..', 26], ['final one', 9]]\n_outputs = [['THIS IS A MESSAGE'], ['OZG SJW QGM?'], ['..5SXT..'], ['..#$%^..'], ['..#$%^..'], ['ORWJU XWN']]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(...
185
247
coding
Solve the programming task below in a Python markdown code block. Zombies have placed themselves at every junction in Bucharest. Each junction 'i' initially has a presence of ai number of zombies. Every timestep, each zombie randomly chooses one of its neighboring junctions and walks towards it. Each neighboring juncti...
{"inputs": ["1\n10 18 100\n0 8\n0 5\n1 2\n1 5\n2 8\n2 4\n2 5\n2 6\n3 5\n4 8\n4 6\n4 7\n5 8\n5 9\n6 8\n6 9\n7 9\n8 9\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n"], "outputs": ["2 2 1 1 1\n"]}
451
124
coding
Solve the programming task below in a Python markdown code block. Watson gives a circle and a triangle in a 2-dimensional plane to Sherlock. Sherlock has to tell if they intersect/touch each other. The circle is centered at $(x_c,y_c)$ and has radius $\mbox{R}$. Input Format The first line contains $\mathbf{T}$...
{"inputs": ["2\n0 0 10\n10 0\n15 0\n15 5\n0 0 10\n0 0\n5 0\n5 5\n"], "outputs": ["YES\nNO\n"]}
337
57
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. Given a rectangle of size n x m, return the minimum number of integer-sided squares that tile the rectangle.   Please complete the following python code precisely: ```python class Solution: def tilingRectangle(sel...
{"functional": "def check(candidate):\n assert candidate(n = 2, m = 3) == 3\n assert candidate(n = 5, m = 8) == 5\n assert candidate(n = 11, m = 13) == 6\n\n\ncheck(Solution().tilingRectangle)"}
74
73
coding
Solve the programming task below in a Python markdown code block. We have an integer array with unique elements and we want to do the permutations that have an element fixed, in other words, these permutations should have a certain element at the same position than the original. These permutations will be called: **pe...
{"functional": "_inputs = [[4, 1], [4, 2], [4, 3], [10, 3], [10, 4], [20, 2], [4, 0], [4, 4], [4, 5]]\n_outputs = [[8], [6], [0], [222480], [55650], [447507315596451070], [9], [1], [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, r...
659
260
coding
Solve the programming task below in a Python markdown code block. Vasya has a beautiful garden where wonderful fruit trees grow and yield fantastic harvest every year. But lately thieves started to sneak into the garden at nights and steal the fruit too often. Vasya can’t spend the nights in the garden and guard the fr...
{"inputs": ["1 1\n1\n1 1\n", "1 1\n0\n1 1\n", "2 2\n1 1\n1 1\n1 1\n", "2 2\n1 0\n1 1\n1 1\n", "2 3\n1 0 1\n0 1 0\n3 2\n", "3 2\n1 1\n1 1\n1 0\n2 1\n", "2 3\n0 0 1\n0 1 0\n3 2\n", "2 3\n0 0 1\n1 1 0\n3 2\n"], "outputs": ["1", "0", "1\n", "0", "3", "1", "2\n", "3\n"]}
606
181
coding
Solve the programming task below in a Python markdown code block. Read problems statements in Mandarin chinese, Russian and Vietnamese as well. Danya gave integers $a$, $b$ and $n$ to Archi. Archi wants to compare $a^{n}$ and $b^{n}$. Help Archi with this task. ------ Input ------ The first line of the input conta...
{"inputs": ["2\n3 4 5\n-3 2 4"], "outputs": ["2\n1"]}
335
27
coding
Solve the programming task below in a Python markdown code block. You are given an equilateral triangle ΔABC with the side BC being the base. Each side of the triangle is of length L. There are L-1 additional points on each of the sides dividing the sides into equal parts of unit lengths. Points on the sides of the tri...
{"inputs": ["2\n4 3\n4 4"], "outputs": ["Case 1: 3\nCase 2: 1"]}
541
32
coding
Solve the programming task below in a Python markdown code block. High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequence) consisting of equal letters. Va...
{"inputs": ["1 0\na\n", "1 1\nb\n", "1 0\nb\n", "1 1\na\n", "1 1\na\n", "1 1\nb\n", "1 0\nb\n", "1 0\na\n"], "outputs": ["1\n", "1\n", "1\n", "1\n", "1\n", "1\n", "1\n", "1\n"]}
276
102
coding
Solve the programming task below in a Python markdown code block. Alex is attending a Halloween party with his girlfriend, Silvia. At the party, Silvia spots the corner of an infinite chocolate bar (two dimensional, infinitely long in width and length). If the chocolate can be served only as 1 x 1 sized pieces and A...
{"inputs": ["4\n5\n6\n7\n8\n"], "outputs": ["6\n9\n12\n16\n"]}
329
30
coding
Solve the programming task below in a Python markdown code block. Laura really hates people using acronyms in her office and wants to force her colleagues to remove all acronyms before emailing her. She wants you to build a system that will edit out all known acronyms or else will notify the sender if unknown acronyms ...
{"functional": "_inputs = [['BRB I need to go into a KPI meeting before EOD'], ['I am IAM so will be OOO until EOD'], ['Going to WAH today. NRN. OOO'], [\"We're looking at SMB on SM DMs today\"], ['OOO'], ['KPI'], ['EOD'], ['TBD'], ['TBD by EOD'], ['BRB I am OOO'], ['WAH'], ['IAM'], ['NRN'], ['CTA'], ['Hi PAB'], ['HATD...
434
684
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. You are given a circle represented as (radius, xCenter, yCenter) and an axis-aligned rectangle represented as (x1, y1, x2, y2), where (x1, y1) are the coordinates of the bottom-left corner, and (x2, y2) are the coordi...
{"functional": "def check(candidate):\n assert candidate(radius = 1, xCenter = 0, yCenter = 0, x1 = 1, y1 = -1, x2 = 3, y2 = 1) == True\n assert candidate(radius = 1, xCenter = 1, yCenter = 1, x1 = 1, y1 = -3, x2 = 2, y2 = -1) == False\n assert candidate(radius = 1, xCenter = 0, yCenter = 0, x1 = -1, y1 = 0, x...
192
160
coding
Solve the programming task below in a Python markdown code block. In 17th century our Chef was a Wizard. He asked his small son "Anshu" to bring him the secret of the Magical Mountain. The boy after travelling a lot reached the Mountain. The description of the Mountain was as follows: - Mountain contains N magical sto...
{"inputs": ["1\n5\n1 2\n1 3\n2 4\n2 5"], "outputs": ["1 2 3 4 5"]}
475
38
coding
Solve the programming task below in a Python markdown code block. You are given a positive integer $N$. Your task is to print a palindromic triangle of size $N$. For example, a palindromic triangle of size $5$ is: 1 121 12321 1234321 123454321 You can't take more than two lines. The first line (a for-statement...
{"inputs": ["5\n"], "outputs": ["1\n121\n12321\n1234321\n123454321\n"]}
245
42
coding
Solve the programming task below in a Python markdown code block. You are given $n$ one-dimensional segments (each segment is denoted by two integers — its endpoints). Let's define the function $f(x)$ as the number of segments covering point $x$ (a segment covers the point $x$ if $l \le x \le r$, where $l$ is the left...
{"inputs": ["1\n2 9\n1 4\n3 7\n", "5\n1 4\n5 6\n1 4\n4 4\n1 2\n2 2\n1 1\n1 7\n1 4\n3 4\n", "5\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n", "5\n1 2\n1 1\n1 3\n2 4\n1 5\n2 6\n2 7\n3 5\n3 6\n1 1\n1 1\n", "4\n4 3\n1 3\n7 9\n2 5\n3 6\n2 9\n1 4\n3 7\n1 3\n2 4\n3 5\n1 4\n6 7\n5 5\n", "9\n4 3\n1 3\n7 9\n2 5\n3 6\n2 9\...
502
412
coding
Solve the programming task below in a Python markdown code block. Find the greatest common divisor of two positive integers. The integers can be large, so you need to find a clever solution. The inputs `x` and `y` are always greater or equal to 1, so the greatest common divisor will always be an integer that is also ...
{"functional": "_inputs = [[1, 3], [60, 12], [2672, 5678], [10927782, 6902514], [1590771464, 1590771620]]\n_outputs = [[1], [12], [334], [846], [4]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return math.isclose(a, b, rel_tol=tol, abs_tol=tol)\n if isin...
99
237
coding
Solve the programming task below in a Python markdown code block. Chef is operating a slush machine. The machine produces slush drinks with $M$ flavors (numbered $1$ through $M$); for each valid $i$, the maximum number of drinks with flavour $i$ the machine can produce is $C_i$. Chef expects $N$ customers to come buy s...
{"inputs": ["1\n5 3\n1 2 3\n2 6 3\n2 10 7\n2 50 3\n1 10 5\n1 7 4"], "outputs": ["33\n2 2 3 1 3"]}
660
66
coding
Solve the programming task below in a Python markdown code block. Iahub is very proud of his recent discovery, propagating trees. Right now, he invented a new tree, called xor-tree. After this new revolutionary discovery, he invented a game for kids which uses xor-trees. The game is played on a tree having n nodes, nu...
{"inputs": ["1\n0\n0\n", "1\n1\n0\n", "1\n1\n1\n", "1\n0\n1\n", "1\n0\n2\n", "1\n0\n4\n", "1\n0\n3\n", "1\n0\n-1\n"], "outputs": ["0\n", "1\n1\n", "0\n", "1\n1\n", "1\n1\n", "1\n1\n", "1\n1\n", "1\n1\n"]}
477
115
coding
Solve the programming task below in a Python markdown code block. Pinkie Pie has bought a bag of patty-cakes with different fillings! But it appeared that not all patty-cakes differ from one another with filling. In other words, the bag contains some patty-cakes with the same filling. Pinkie Pie eats the patty-cakes o...
{"inputs": ["1\n15\n1 2 3 4 5 1 2 3 4 5 1 2 3 4 5\n", "1\n15\n1 2 3 4 5 1 2 3 4 5 1 2 3 4 5\n", "1\n15\n1 2 3 4 5 1 2 3 4 5 2 2 3 4 5\n", "1\n15\n1 2 3 4 5 1 2 3 4 5 2 1 3 4 5\n", "1\n15\n2 2 3 4 5 1 2 3 4 5 2 2 3 4 5\n", "1\n15\n1 2 3 7 5 1 2 3 4 5 1 2 3 4 9\n", "1\n15\n1 2 3 3 3 1 2 3 3 5 2 1 3 6 5\n", "1\n15\n1 2 3 ...
666
334
coding
Solve the programming task below in a Python markdown code block. Consider integer coordinates x, y in the Cartesian plan and three functions f, g, h defined by: ``` f: 1 <= x <= n, 1 <= y <= n --> f(x, y) = min(x, y) g: 1 <= x <= n, 1 <= y <= n --> g(x, y) = max(x, y) h: 1 <= x <= n, 1 <= y <= n --> h(x, y) = x + y ``...
{"functional": "_inputs = [[5], [6], [8], [15], [100], [365], [730], [4000]]\n_outputs = [[55], [91], [204], [1240], [338350], [16275715], [129938905], [21341334000]]\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...
713
243
coding
Solve the programming task below in a Python markdown code block. Say hello! Write a function to greet a person. Function will take name as input and greet the person by saying hello. Return null/nil/None if input is empty string or null/nil/None. Example: ```python greet("Niks") --> "hello Niks!" greet("") --> ...
{"functional": "_inputs = [['Niks'], ['Nick'], [''], [None]]\n_outputs = [['hello Niks!'], ['hello Nick!'], [None], [None]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return math.isclose(a, b, rel_tol=tol, abs_tol=tol)\n if isinstance(a, (list, tuple)):...
126
177
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. Given the root of a binary tree, return the lowest common ancestor of its deepest leaves. Recall that: The node of a binary tree is a leaf if and only if it has no children The depth of the root of the tree is 0. if ...
{"functional": "def check(candidate):\n assert is_same_tree(candidate(root = tree_node([3,5,1,6,2,0,8,None,None,7,4])), tree_node([2,7,4]))\n assert is_same_tree(candidate(root = tree_node([1])), tree_node([1]))\n assert is_same_tree(candidate(root = tree_node([0,1,3,None,2])), tree_node([2]))\n\n\ncheck(Solut...
214
113
coding
Solve the programming task below in a Python markdown code block. Aiz Onsen has a bathhouse and a pool. To use the bathhouse, you need to buy a bathing ticket, and to use the pool, you need to buy a pool ticket. Prices for these tickets may vary from day to day. In addition, Aiz Onsen has the following rules. * Ticket...
{"inputs": ["2\n100 000 1 1\n1000 500 5 2", "2\n100 000 1 1\n1010 500 5 2", "2\n110 000 1 1\n1010 500 5 2", "2\n100 100 1 1\n1000 500 5 2", "2\n110 000 1 2\n1010 500 10 2", "2\n110 000 1 2\n1010 500 17 2", "2\n110 000 2 4\n1010 500 17 2", "2\n110 000 2 4\n0010 500 17 2"], "outputs": ["100\n4800\n", "100\n4840\n", "110\...
475
322
coding
Solve the programming task below in a Python markdown code block. Yakko, Wakko and Dot, world-famous animaniacs, decided to rest from acting in cartoons, and take a leave to travel a bit. Yakko dreamt to go to Pennsylvania, his Motherland and the Motherland of his ancestors. Wakko thought about Tasmania, its beaches, s...
{"inputs": ["6 6\n", "1 4\n", "4 4\n", "3 3\n", "6 4\n", "6 3\n", "5 4\n", "5 6\n"], "outputs": ["1/6\n", "1/2\n", "1/2\n", "2/3\n", "1/6\n", "1/6\n", "1/3\n", "1/6\n"]}
386
102
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. You are given a binary string s and a positive integer k. You can apply the following operation on the string any number of times: Choose any substring of size k from s and flip all its characters, that is, turn all ...
{"functional": "def check(candidate):\n assert candidate(s = \"1001\", k = 3) == 4\n assert candidate(s = \"10110\", k = 5) == 2\n\n\ncheck(Solution().countDistinctStrings)"}
176
61
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. Two strings, X and Y, are considered similar if either they are identical or we can make them equivalent by swapping at most two letters (in distinct positions) within the string X. For example, "tars" and "rats" are ...
{"functional": "def check(candidate):\n assert candidate(strs = [\"tars\",\"rats\",\"arts\",\"star\"]) == 2\n assert candidate(strs = [\"omv\",\"ovm\"]) == 1\n\n\ncheck(Solution().numSimilarGroups)"}
252
61
coding
Solve the programming task below in a Python markdown code block. Do you know a story about the three musketeers? Anyway, you will learn about its origins now. Richelimakieu is a cardinal in the city of Bearis. He is tired of dealing with crime by himself. He needs three brave warriors to help him to fight against bad...
{"inputs": ["5 0\n", "3 0\n", "3 0\n", "5 0\n", "9 0\n", "10 0\n", "4000 0\n", "4000 0\n"], "outputs": ["-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n"]}
567
94
coding
Solve the programming task below in a Python markdown code block. Chef has $N$ dishes of different types arranged in a row: $A_1, A_2, \ldots, A_N$, where $A_i$ denotes the type of the $i^{th}$ dish. He wants to choose as many dishes as possible from the given list but while satisfying two conditions: - He can choose ...
{"inputs": ["3\n5\n1 2 2 1 2\n6\n1 1 1 1 1 1\n8\n1 2 2 2 3 4 2 1"], "outputs": ["1\n1\n2"]}
635
60
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. You are given a string s consisting of lowercase letters and an integer k. We call a string t ideal if the following conditions are satisfied: t is a subsequence of the string s. The absolute difference in the alphab...
{"functional": "def check(candidate):\n assert candidate(s = \"acfgbd\", k = 2) == 4\n assert candidate(s = \"abcd\", k = 3) == 4\n\n\ncheck(Solution().longestIdealString)"}
185
57
coding
Solve the programming task below in a Python markdown code block. Kabir likes Tara's smile and wants to look at her smile. They are sitting in the class and you are friends with Kabir. You have to place a mirror (point size) in the front wall of the class so that Kabir can have a glimpse of Tara's smile. Consider the ...
{"inputs": ["1\n1 1\n4 4"], "outputs": ["1.60"]}
321
23
coding
Solve the programming task below in a Python markdown code block. ### Task King Arthur and his knights are having a New Years party. Last year Lancelot was jealous of Arthur, because Arthur had a date and Lancelot did not, and they started a duel. To prevent this from happening again, Arthur wants to make sure that ...
{"functional": "_inputs = [[[1, -1, 1]], [[-1, -1, -1]], [[1, -1]], [[1, 1, 1]], [[]]]\n_outputs = [[True], [False], [False], [True], [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...
241
202
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. There are n persons on a social media website. You are given an integer array ages where ages[i] is the age of the ith person. A Person x will not send a friend request to a person y (x != y) if any of the following c...
{"functional": "def check(candidate):\n assert candidate(ages = [16,16]) == 2\n assert candidate(ages = [16,17,18]) == 2\n assert candidate(ages = [20,30,100,110,120]) == 3\n\n\ncheck(Solution().numFriendRequests)"}
200
86
coding
Solve the programming task below in a Python markdown code block. Given 2 strings, your job is to find out if there is a substring that appears in both strings. You will return true if you find a substring that appears in both strings, or false if you do not. We only care about substrings that are longer than one lette...
{"functional": "_inputs = [['Something', 'Home'], ['Something', 'Fun'], ['Something', ''], ['', 'Something'], ['BANANA', 'banana'], ['test', 'lllt'], ['', ''], ['1234567', '541265'], ['supercalifragilisticexpialidocious', 'SoundOfItIsAtrocious'], ['LoremipsumdolorsitametconsecteturadipiscingelitAeneannonaliquetligulaut...
277
467
coding
Solve the programming task below in a Python markdown code block. Thanos wants to destroy the avengers base, but he needs to destroy the avengers along with their base. Let we represent their base with an array, where each position can be occupied by many avengers, but one avenger can occupy only one position. Length ...
{"inputs": ["1 1 5 6\n1\n", "1 1 5 6\n1\n", "1 1 7 6\n1\n", "1 1 5 2\n1\n", "1 1 7 0\n1\n", "2 1 5 2\n1\n", "1 1 7 -1\n1\n", "1 1 7 -2\n2\n"], "outputs": ["11\n", "11", "12\n", "4\n", "0\n", "8\n", "-2\n", "-4\n"]}
650
136
coding
Solve the programming task below in a Python markdown code block. Byteburg Senate elections are coming. Usually "United Byteland", the ruling Byteland party, takes all the seats in the Senate to ensure stability and sustainable development. But this year there is one opposition candidate in one of the constituencies. E...
{"inputs": ["2 1\n0 0\n", "2 1\n1 0\n", "2 1\n2 1\n", "2 1\n1 1\n", "2 1\n1000 1000\n", "2 1\n1000 0000\n", "2 1\n0000 1000\n", "2 1\n0000 0000\n"], "outputs": ["0\n", "0\n\n", "0\n\n", "0\n", "0\n", "0\n\n", "1\n1\n", "0\n\n"]}
643
148
coding
Solve the programming task below in a Python markdown code block. Chef and Chefina are competing against each other in a programming contest. They were both able to solve all the problems in the contest, so the winner between them must be decided by time penalty. Chef solved all the problems in X minutes and made P wro...
{"inputs": ["3\n10 8 2 3\n10 10 10 10\n40 21 2 0\n"], "outputs": ["Chef\nDraw\nChefina"]}
721
49
coding
Solve the programming task below in a Python markdown code block. A robot is put at the origin in a two-dimensional plane. Initially, the robot is facing in the positive x-axis direction. This robot will be given an instruction sequence s. s consists of the following two kinds of letters, and will be executed in order ...
{"inputs": ["UF\n1 0", "FT\n1 0", "FF\n2 0", "UF\n0 0", "TF\n1 0", "FF\n1 0", "FF\n1 0\n", "TF\n1 0\n"], "outputs": ["No\n", "Yes\n", "Yes\n", "No\n", "No", "No", "No\n", "No\n"]}
265
94
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. On a campus represented as a 2D grid, there are n workers and m bikes, with n <= m. Each worker and bike is a 2D coordinate on this grid. We assign one unique bike to each worker so that the sum of the Manhattan dista...
{"functional": "def check(candidate):\n assert candidate(workers = [[0,0],[2,1]], bikes = [[1,2],[3,3]]) == 6\n assert candidate(workers = [[0,0],[1,1],[2,0]], bikes = [[1,0],[2,2],[2,1]]) == 4\n assert candidate(workers = [[0,0],[1,0],[2,0],[3,0],[4,0]], bikes = [[0,999],[1,999],[2,999],[3,999],[4,999]]) == 4...
175
155
coding
Solve the programming task below in a Python markdown code block. You are given a multiset of n integers. You should select exactly k of them in a such way that the difference between any two of them is divisible by m, or tell that it is impossible. Numbers can be repeated in the original multiset and in the multiset ...
{"inputs": ["3 2 3\n1 8 4\n", "3 3 3\n1 8 4\n", "3 2 3\n1 2 3\n", "3 2 2\n1 2 4\n", "3 2 4\n1 2 3\n", "3 3 3\n1 3 6\n", "3 2 3\n1 2 3\n", "3 2 4\n1 2 3\n"], "outputs": ["Yes\n1 4 ", "No", "No", "Yes\n2 4 ", "No", "No", "No\n", "No\n"]}
361
152
coding
Solve the programming task below in a Python markdown code block. George decided to prepare a Codesecrof round, so he has prepared m problems for the round. Let's number the problems with integers 1 through m. George estimates the i-th problem's complexity by integer b_{i}. To make the round good, he needs to put at l...
{"inputs": ["3 1\n2 3 4\n1\n", "3 1\n2 3 4\n0\n", "3 1\n2 6 4\n0\n", "3 1\n2 3 4\n1\n", "3 5\n1 2 3\n1 2 2 3 3\n", "3 5\n1 2 3\n1 1 1 1 1\n", "3 5\n1 0 3\n1 1 1 1 1\n", "3 5\n1 2 3\n1 2 1 3 3\n"], "outputs": ["3\n", "3\n", "3\n", "3\n", "0\n", "2\n", "1\n", "0\n"]}
600
182
coding
Solve the programming task below in a Python markdown code block. Program a function `sumAverage(arr)` where `arr` is an array containing arrays full of numbers, for example: ```python sum_average([[1, 2, 2, 1], [2, 2, 2, 1]]) ``` First, determine the average of each array. Then, return the sum of all the averages. ...
{"functional": "_inputs = [[[[1, 2, 2, 1], [2, 2, 2, 1]]], [[[52, 64, 84, 21, 54], [44, 87, 46, 90, 43]]], [[[44, 76, 12], [96, 12, 34, 53, 76, 34, 56, 86, 21], [34, 65, 34, 76, 34, 87, 34]]], [[[41, 16, 99, 93, 59, 18, 35, 23, 55, 45, 38, 39, 74, 60, 95, 44, 59, 70, 44, 89, 90, 19, 23, 67, 65, 66, 41, 89, 49, 22, 23, ...
416
795
coding
Solve the programming task below in a Python markdown code block. Iahub and Iahubina went to a picnic in a forest full of trees. Less than 5 minutes passed before Iahub remembered of trees from programming. Moreover, he invented a new problem and Iahubina has to solve it, otherwise Iahub won't give her the food. Iahu...
{"inputs": ["1\n1\n", "2\n1 2\n", "2\n2 2\n", "2\n2 3\n", "2\n2 1\n", "4\n1 1 1 3\n", "4\n1 2 1 4\n", "4\n1 1 1 2\n"], "outputs": ["YES", "NO", "NO\n", "NO\n", "NO\n", "NO\n", "NO\n", "NO\n"]}
318
110
coding
Solve the programming task below in a Python markdown code block. Vasya is preparing a contest, and now he has written a statement for an easy problem. The statement is a string of length $n$ consisting of lowercase Latin latters. Vasya thinks that the statement can be considered hard if it contains a subsequence hard;...
{"inputs": ["3\nxdd\n1 2 3\n", "3\nxdd\n1 2 3\n", "3\nxdd\n2 2 3\n", "3\nxdd\n2 3 3\n", "3\nxdd\n1 3 3\n", "3\nxdd\n1 4 3\n", "3\nxdd\n1 8 3\n", "3\nxdd\n1 8 4\n"], "outputs": ["0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n"]}
559
134
coding
Solve the programming task below in a Python markdown code block. A large banner with word CODEFORCES was ordered for the 1000-th onsite round of Codeforces^{ω} that takes place on the Miami beach. Unfortunately, the company that made the banner mixed up two orders and delivered somebody else's banner that contains som...
{"inputs": ["C\n", "C\n", "D\n", "B\n", "ABACABA\n", "ABACABA\n", "AABCABA\n", "CODEFORCE\n"], "outputs": ["NO\n", "NO\n", "NO\n", "NO\n", "NO\n", "NO\n", "NO\n", "NO\n"]}
427
77
coding
Solve the programming task below in a Python markdown code block. The main server of Gomble company received a log of one top-secret process, the name of which can't be revealed. The log was written in the following format: «[date:time]: message», where for each «[date:time]» value existed not more than 10 lines. All t...
{"inputs": ["1\n[12:00 a.m.]: asZv MF\n", "1\n[10:41 a.m.]: apppmama\n", "1\n[10:41 a.m.]9 apppmama\n", "2\n[06:00 p.m.]: uNzO VN Nz h\n[06:00 a.m.]: bTJv\n", "2\n[11:35 a.m.]: ampapaammaamamaam\n[11:35 a.m.]: ppammpmmppmam\n", "3\n[05:33 p.m.]: apm\n[05:24 p.m.]: mapammmapaaa\n[06:01 p.m.]: mpmmmpa\n", "3\n[05:33 p.m....
625
311
coding
Solve the programming task below in a Python markdown code block. Recently Luba bought a monitor. Monitor is a rectangular matrix of size n × m. But then she started to notice that some pixels cease to work properly. Luba thinks that the monitor will become broken the first moment when it contains a square k × k consis...
{"inputs": ["1 1 1 0\n", "1 1 1 0\n", "1 2 1 0\n", "1 2 2 0\n", "1 4 1 0\n", "1 4 2 0\n", "500 24 2 0\n", "500 24 4 0\n"], "outputs": ["-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n"]}
432
125
coding
Solve the programming task below in a Python markdown code block. Roy and Biv have a set of n points on the infinite number line. Each point has one of 3 colors: red, green, or blue. Roy and Biv would like to connect all the points with some edges. Edges can be drawn between any of the two of the given points. The co...
{"inputs": ["1\n3 R\n", "1\n3 R\n", "1\n2 R\n", "1\n4 R\n", "1\n5 R\n", "1\n1 R\n", "1\n6 R\n", "1\n0 R\n"], "outputs": ["0\n", "0", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n"]}
453
93
coding
Solve the programming task below in a Python markdown code block. T is playing a game with his friend, HL. There are n piles of stones, the i-th pile initially has a_i stones. T and HL will take alternating turns, with T going first. In each turn, a player chooses a non-empty pile and then removes a single stone fro...
{"inputs": ["1\n2\n1 7\n", "1\n2\n2 7\n", "1\n2\n3 7\n", "1\n2\n2 3\n", "1\n2\n4 7\n", "1\n2\n5 7\n", "1\n2\n3 3\n", "1\n2\n3 6\n"], "outputs": ["T\n", "T\n", "T\n", "T\n", "T\n", "T\n", "HL\n", "T\n"]}
362
118
coding
Solve the programming task below in a Python markdown code block. Story Jumbo Juice makes a fresh juice out of fruits of your choice.Jumbo Juice charges $5 for regular fruits and $7 for special ones. Regular fruits are Banana, Orange, Apple, Lemon and Grapes. Special ones are Avocado, Strawberry and Mango. Others fruit...
{"functional": "_inputs = [[['banana', 'mango', 'avocado']], [['melon', 'Mango', 'kiwi']], [['watermelon', 'cherry', 'avocado']], [['watermelon', 'lime', 'tomato']], [['blackBerry', 'coconut', 'avocado']], [['waterMelon', 'mango']], [['watermelon', 'pEach']], [['watermelon', 'Orange', 'grapes']], [['watermelon']], [['B...
260
292
coding
Solve the programming task below in a Python markdown code block. The Travelling Salesman spends a lot of time travelling so he tends to get bored. To pass time, he likes to perform operations on numbers. One such operation is to take a positive integer x and reduce it to the number of bits set to 1 in the binary repre...
{"inputs": ["1\n0\n", "1\n1\n", "1\n0\n", "1\n1\n", "1\n0\n", "1\n1\n", "10\n0\n", "11\n1\n"], "outputs": ["1\n", "0\n", "1\n", "0\n", "1\n", "0\n", "1\n", "1\n"]}
380
88
coding
Solve the programming task below in a Python markdown code block. Given an alphanumeric string made up of digits and lower case Latin characters only, find the sum of all the digit characters in the string. ------ Input ------ The first line of the input contains an integer T denoting the number of test cases. Then ...
{"inputs": ["1\nab1231da\n"], "outputs": ["7"]}
213
20
coding
Solve the programming task below in a Python markdown code block. We ask you to select some number of positive integers, and calculate the sum of them. It is allowed to select as many integers as you like, and as large integers as you wish. You have to follow these, however: each selected integer needs to be a multiple...
{"inputs": ["7 5 0", "2 2 0", "2 4 0", "4 5 1", "2 3 0", "4 4 0", "0 9 0", "4 5 0"], "outputs": ["YES\n", "YES\n", "YES\n", "YES\n", "YES\n", "YES\n", "YES\n", "YES\n"]}
218
94
coding
Solve the programming task below in a Python markdown code block. Given an array $A$ of size $N$ , count number of pairs of index $i,j$ such that $A_i$ is even, $A_j$ is odd and $i < j$ -----Input----- - The first line of the input contains a single integer $T$ denoting the number of test cases. - The first line of...
{"inputs": ["2\n4\n1 2 1 3\n5\n5 4 1 2 3"], "outputs": ["2\n3"]}
338
36
coding
Solve the programming task below in a Python markdown code block. The weight of a sequence is defined as the number of unordered pairs of indexes $(i,j)$ (here $i \lt j$) with same value ($a_{i} = a_{j}$). For example, the weight of sequence $a = [1, 1, 2, 2, 1]$ is $4$. The set of unordered pairs of indexes with same ...
{"inputs": ["2\n4\n1 2 1 1\n4\n1 2 3 4\n", "2\n4\n1 2 2 1\n4\n1 2 3 4\n", "2\n4\n2 2 2 1\n4\n1 2 3 4\n", "2\n4\n2 2 1 1\n4\n1 2 3 4\n", "2\n4\n2 2 2 1\n4\n1 3 3 4\n", "2\n4\n1 2 2 1\n4\n1 4 3 4\n", "2\n4\n2 2 4 1\n4\n1 2 3 4\n", "2\n4\n2 2 2 2\n4\n1 3 3 4\n"], "outputs": ["6\n0\n", "5\n0\n", "9\n0\n", "6\n0\n", "9\n4\n...
587
247
coding
Solve the programming task below in a Python markdown code block. Find the length between 2 co-ordinates. The co-ordinates are made of integers between -20 and 20 and will be given in the form of a 2D array: (0,0) and (5,-7) would be [ [ 0 , 0 ] , [ 5, -7 ] ] The function must return the answer rounded to 2 decimal ...
{"functional": "_inputs = [[[[0, 0], [1, 1]]], [[[0, 0], [-5, -6]]], [[[0, 0], [10, 15]]], [[[0, 0], [5, 1]]], [[[0, 0], [5, 4]]], [[[0, 0], [-7, 4]]], [[[0, 0], [0, 0]]], [[[-3, 4], [10, 5]]]]\n_outputs = [['1.41'], ['7.81'], ['18.03'], ['5.10'], ['6.40'], ['8.06'], ['0.00'], ['13.04']]\nimport math\ndef _deep_eq(a, b...
175
308
coding
Solve the programming task below in a Python markdown code block. Omy and Ish were learning the pattern printing. In order to learn they give themselves a task. In this task they are given a string and they have to form a pyramid with the pattern as follows: RowNumber are one based indexed. - If (RowNumber % 3 == 0) t...
{"inputs": ["5\nCODING\n2\n1 C\n2 D"], "outputs": ["1\n1"]}
410
25
coding
Solve the programming task below in a Python markdown code block. Read problems statements in Russian here Polo, the Penguin, likes the XOR operation. Please read NOTE if you are not familiar with XOR operation. XOR-sum of a list of numbers is the result of XOR-ing all of them. XOR-sum of (A[1] XOR A[2] XOR ... XOR A...
{"inputs": ["2\n3\n1 2 3\n3 1 2\n4\n1 2 2\n1 3 2\n4 3 1"], "outputs": ["3\n3"]}
716
48
coding
Solve the programming task below in a Python markdown code block. In this problem, we will deal with binary strings. Each character of a binary string is either a 0 or a 1. We will also deal with substrings; recall that a substring is a contiguous subsequence of a string. We denote the substring of string $s$ starting ...
{"inputs": ["1\n0\n1\n1 1 1\n", "1\n0\n1\n1 1 1\n", "3\n010\n3\n1 3 1\n1 3 1\n3 2 1\n", "3\n010\n3\n1 3 1\n1 3 1\n3 2 1\n", "5\n11011\n3\n1 3 3\n1 4 2\n1 2 3\n", "5\n11011\n3\n1 3 3\n1 4 2\n1 2 3\n", "5\n00010\n5\n5 3 1\n2 1 2\n4 1 1\n3 1 3\n2 1 3\n", "5\n11010\n5\n2 1 4\n3 5 1\n4 2 1\n4 5 1\n2 4 2\n"], "outputs": ["Ye...
714
298
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. There is a special square room with mirrors on each of the four walls. Except for the southwest corner, there are receptors on each of the remaining corners, numbered 0, 1, and 2. The square room has walls of length p...
{"functional": "def check(candidate):\n assert candidate(p = 2, q = 1) == 2\n\n\ncheck(Solution().mirrorReflection)"}
161
36
coding
Solve the programming task below in a Python markdown code block. Once upon a time in the Kingdom of Far Far Away lived Sam the Farmer. Sam had a cow named Dawn and he was deeply attached to her. Sam would spend the whole summer stocking hay to feed Dawn in winter. Sam scythed hay and put it into haystack. As Sam was a...
{"inputs": ["1\n", "6\n", "8\n", "9\n", "2\n", "4\n", "7\n", "96\n"], "outputs": ["17 17\n", "34 57\n", "40 73\n", "41 81\n", "22 25\n", "28 41\n", "47 65\n", "144 777\n"]}
728
105
coding
Solve the programming task below in a Python markdown code block. # Task Given the birthdates of two people, find the date when the younger one is exactly half the age of the other. # Notes * The dates are given in the format YYYY-MM-DD and are not sorted in any particular order * Round **down** to the nearest day *...
{"functional": "_inputs = [['1990-12-06', '2000-02-29'], ['2012-03-31', '1990-06-09'], ['1984-08-14', '1990-04-17'], ['2000-06-30', '1978-03-17'], ['1969-12-20', '2000-10-07']]\n_outputs = [['2009-05-24'], ['2034-01-21'], ['1995-12-19'], ['2022-10-14'], ['2031-07-26']]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n i...
111
329
coding
Solve the programming task below in a Python markdown code block. You've got a bunch of textual data with embedded phone numbers. Write a function `area_code()` that finds and returns just the area code portion of the phone number. ```python >>> message = "The supplier's phone number is (555) 867-5309" >>> area_code(me...
{"functional": "_inputs = [[\"The supplier's phone number is (555) 867-5309\"], [\"Grae's cell number used to be (123) 456-7890\"], [\"The 102nd district court's fax line is (124) 816-3264\"]]\n_outputs = [['555'], ['123'], ['124']]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(...
156
243
coding
Solve the programming task below in a Python markdown code block. Read problem statements in [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well. It’s Chef's birthday. He and his twin have received $N$ gifts in total. The $i$-th gift has a price of $A_{i}$. Each twin wants to keep the most expensive gif...
{"inputs": ["3\n3 1\n1 3 2\n3 1\n3 1 3\n5 2\n5 1 3 2 4"], "outputs": ["3\n4\n8"]}
592
50
coding
Solve the programming task below in a Python markdown code block. n children are standing in a circle and playing a game. Children's numbers in clockwise order form a permutation a_1, a_2, ..., a_{n} of length n. It is an integer sequence such that each integer from 1 to n appears exactly once in it. The game consists...
{"inputs": ["100 1\n6\n", "2 2\n2 2\n", "2 2\n2 2\n", "100 1\n6\n", "3 3\n3 1 2\n", "3 3\n2 2 3\n", "2 3\n1 1 2\n", "3 3\n1 1 3\n"], "outputs": ["1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 ...
506
710
coding
Solve the programming task below in a Python markdown code block. You have two arrays in this kata, every array contain only unique elements. Your task is to calculate number of elements in first array which also are in second array. Also feel free to reuse/extend the following starter code: ```python def match_arrays(...
{"functional": "_inputs = [[['Perl', 'Closure', 'JavaScript'], ['Go', 'C++', 'Erlang']], [['Erlang', 'JavaScript'], ['Go', 'C++', 'Python']], [[True, 3, 9, 11, 15], [True, 3, 11]]]\n_outputs = [[0], [0], [3]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n retu...
69
224
coding
Solve the programming task below in a Python markdown code block. Chef's pizza is the tastiest pizza to exist, and the reason for that is his special, juicy homegrown tomatoes. Tomatoes can be grown in rectangular patches of any side lengths. However, Chef only has a limited amount of land. Consider the entire town o...
{"inputs": ["2\n4\n10000000000"], "outputs": ["23\n227374950"]}
473
37
coding
Solve the programming task below in a Python markdown code block. Task ======= Make a custom esolang interpreter for the language Tick. Tick is a descendant of [Ticker](https://www.codewars.com/kata/esolang-ticker) but also very different data and command-wise. Syntax/Info ======== Commands are given in character fo...
{"functional": "_inputs = [['++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*>+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++**>+++...
280
209
coding
Solve the programming task below in a Python markdown code block. Vanya wants to pass n exams and get the academic scholarship. He will get the scholarship if the average grade mark for all the exams is at least avg. The exam grade cannot exceed r. Vanya has passed the exams and got grade a_{i} for the i-th exam. To in...
{"inputs": ["1 1 1\n1 1\n", "1 2 1\n2 2\n", "1 1 1\n1 1\n", "1 2 1\n2 2\n", "1 3 1\n2 2\n", "1 1 1\n0 1\n", "1 5 1\n2 2\n", "1 5 1\n2 4\n"], "outputs": ["0\n", "0\n", "0\n", "0\n", "0\n", "1\n", "0\n", "0\n"]}
373
134
coding
Solve the programming task below in a Python markdown code block. You are given $n$ integers $a_1, a_2, \ldots, a_n$. Is it possible to arrange them on a circle so that each number is strictly greater than both its neighbors or strictly smaller than both its neighbors? In other words, check if there exists a rearrange...
{"inputs": ["4\n3\n1 1 2\n4\n1 9 8 4\n4\n2 0 2 2\n6\n1 1 1 11 111 1111\n"], "outputs": ["NO\nYES\n1 8 4 9 \nNO\nYES\n1 11 1 111 1 1111 \n"]}
710
96
coding
Solve the programming task below in a Python markdown code block. Xander Cage has a list of cities he can visit on his new top-secret mission. He represents each city as a tuple of $(latitude,longitude,height,points)$. The values of $latitude$, $longitude$, and $height$ are distinct across all cities. We define a miss...
{"inputs": ["3 1 1\n1 1 1 3\n2 2 2 -1\n3 3 3 3\n"], "outputs": ["5\n"]}
673
42
coding
Solve the programming task below in a Python markdown code block. Given an Integer N, write a program to reverse it. -----Input----- The first line contains an integer T, total number of testcases. Then follow T lines, each line contains an integer N. -----Output----- For each test case, display the reverse of the ...
{"inputs": ["4\n12345\n31203\n2123\n2300"], "outputs": ["54321\n30213\n3212\n32"]}
157
52
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. Chefina is playing with ranges. There are $N$ ranges $[l_{1}, r_{1}], [l_{2}, r_{2}], \ldots, [l_{N}, r_{N}]$. Chefina wants to divide the ranges int...
{"inputs": ["3\n3\n1 4\n2 6\n5 7\n2\n1 4\n4 6\n2\n3 7\n8 9"], "outputs": ["1\n-1\n0"]}
623
51
coding
Solve the programming task below in a Python markdown code block. You are given a sequence of n integers S and a sequence of different q integers T. Write a program which outputs C, the number of integers in T which are also in the set S. Notes Constraints * Elements in S is sorted in ascending order * n ≤ 100000 * ...
{"inputs": ["3\n2 2 3\n1\n5", "3\n1 2 3\n1\n4", "3\n1 2 4\n1\n4", "3\n2 2 4\n1\n4", "3\n2 2 5\n1\n4", "3\n0 2 5\n1\n4", "3\n1 2 5\n1\n4", "3\n1 4 5\n1\n4"], "outputs": ["0\n", "0\n", "1\n", "1\n", "0\n", "0\n", "0\n", "1\n"]}
232
142
coding
Solve the programming task below in a Python markdown code block. We have held a popularity poll for N items on sale. Item i received A_i votes. From these N items, we will select M as popular items. However, we cannot select an item with less than \dfrac{1}{4M} of the total number of votes. If M popular items can be s...
{"inputs": ["3 3\n39 4 1", "4 1\n5 4 0 1", "3 1\n5 4 0 1", "3 2\n39 19 1", "3 2\n39 14 1", "3 2\n39 18 1", "3 1\n39 18 1", "3 1\n39 16 1"], "outputs": ["No\n", "Yes\n", "Yes\n", "Yes\n", "Yes\n", "Yes\n", "Yes\n", "Yes\n"]}
229
141
coding
Solve the programming task below in a Python markdown code block. Bizon the Champion isn't just charming, he also is very smart. While some of us were learning the multiplication table, Bizon the Champion had fun in his own manner. Bizon the Champion painted an n × m multiplication table, where the element on the inte...
{"inputs": ["2 2 2\n", "2 3 4\n", "1 1 1\n", "3 3 1\n", "3 3 2\n", "3 3 3\n", "3 3 5\n", "3 3 8\n"], "outputs": ["2\n", "3\n", "1\n", "1\n", "2\n", "2\n", "3\n", "6\n"]}
289
102
coding
Solve the programming task below in a Python markdown code block. # Task Mirko has been moving up in the world of basketball. He started as a mere spectator, but has already reached the coveted position of the national team coach! Mirco is now facing a difficult task: selecting five primary players for the upcoming ...
{"functional": "_inputs = [[['michael', 'jordan', 'lebron', 'james', 'kobe', 'bryant']], [['babic', 'keksic', 'boric', 'bukic', 'sarmic', 'balic', 'kruzic', 'hrenovkic', 'beslic', 'boksic', 'krafnic', 'pecivic', 'klavirkovic', 'kukumaric', 'sunkic', 'kolacic', 'kovacic', 'prijestolonasljednikovic']], [['jgztazpytubijfs...
408
499
coding
Solve the programming task below in a Python markdown code block. Batman is about to face Superman so he decides to prepare for the battle by upgrading his Batmobile. He manufactures multiple duplicates of his standard Batmobile each tweaked in a different way such that the maximum speed of each is never less than that...
{"inputs": ["2\n4\n1 2 3 4 5\n5\n1 10 100 1000 10000 100000"], "outputs": ["4\n5"]}
310
55
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 n integers, and an integer k. The k-radius average for a subarray of nums centered at some index i with the radius k is the average of all elements in nums between the indices i...
{"functional": "def check(candidate):\n assert candidate(nums = [7,4,3,9,1,8,5,2,6], k = 3) == [-1,-1,-1,5,4,4,-1,-1,-1]\n assert candidate(nums = [100000], k = 0) == [100000]\n assert candidate(nums = [8], k = 100000) == [-1]\n\n\ncheck(Solution().getAverages)"}
257
121
coding
Solve the programming task below in a Python markdown code block. Polycarp has prepared $n$ competitive programming problems. The topic of the $i$-th problem is $a_i$, and some problems' topics may coincide. Polycarp has to host several thematic contests. All problems in each contest should have the same topic, and al...
{"inputs": ["2\n1 1\n", "2\n1 1\n", "2\n2 1\n", "2\n4 1\n", "2\n5 1\n", "2\n5 0\n", "2\n1 0\n", "2\n5 -1\n"], "outputs": ["2\n", "2", "1\n", "1\n", "1\n", "1\n", "1\n", "1\n"]}
568
101
coding
Solve the programming task below in a Python markdown code block. Given the schedule of Chef for 30 days (A binary string of length 30 where '0' denotes that Chef was on leave and '1' denotes Chef was working on that day). Chef gets X- Rs for every day he worked. As working continuously for a long time is hectic so Com...
{"inputs": ["3\n6 3\n111100110101100000101100011111\n8 2\n111010111101001010100100111101\n5 6\n011101010100101000001101000010"], "outputs": ["117\n152\n78"]}
624
126
coding
Solve the programming task below in a Python markdown code block. Mutual Recursion allows us to take the fun of regular recursion (where a function calls itself until a terminating condition) and apply it to multiple functions calling each other! Let's use the Hofstadter Female and Male sequences to demonstrate this ...
{"functional": "_inputs = [[0], [5], [10], [15], [25]]\n_outputs = [[1], [3], [6], [9], [16]]\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):...
262
181
coding
Solve the programming task below in a Python markdown code block. Is it rated? Here it is. The Ultimate Question of Competitive Programming, Codeforces, and Everything. And you are here to answer it. Another Codeforces round has been conducted. No two participants have the same number of points. For each participant,...
{"inputs": ["2\n1 1\n1 1\n", "2\n1 1\n2 2\n", "2\n2 2\n1 1\n", "2\n2 1\n1 2\n", "2\n3 2\n3 2\n", "2\n1 2\n2 1\n", "2\n3 1\n9 8\n", "2\n2 1\n1 1\n"], "outputs": ["maybe\n", "unrated\n", "maybe\n", "rated\n", "rated\n", "rated\n", "rated\n", "rated\n"]}
630
135
coding
Solve the programming task below in a Python markdown code block. Вася купил стол, у которого n ножек. Каждая ножка состоит из двух частей, которые соединяются друг с другом. Каждая часть может быть произвольной положительной длины, но гарантируется, что из всех 2n частей возможно составить n ножек одинаковой длины. Пр...
{"inputs": ["1\n3 7\n", "1\n7 7\n", "3\n1 3 2 4 5 3\n", "3\n1 1 1 2 2 2\n", "10\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n", "10\n9 13 18 7 18 13 2 2 5 16 3 17 5 4 18 2 15 11 7 15\n", "10\n9 13 18 7 18 13 2 2 5 16 3 17 5 4 18 2 15 11 7 15\n", "10\n759 82 475 841 46 461 288 525 918 241 789 847 58 954 712 159 942 211 153...
493
556
coding
Solve the programming task below in a Python markdown code block. Write a program to obtain 2 numbers $($ $A$ $and$ $B$ $)$ and an arithmetic operator $(C)$ and then design a $calculator$ depending upon the operator entered by the user. So for example if C="+", you have to sum the two numbers. If C="-", you have to sub...
{"inputs": ["8\n2\n/", "5\n3\n+"], "outputs": ["4.0", "8"]}
337
27
coding
Solve the programming task below in a Python markdown code block. Let N be a positive integer. There is a numerical sequence of length 3N, a = (a_1, a_2, ..., a_{3N}). Snuke is constructing a new sequence of length 2N, a', by removing exactly N elements from a without changing the order of the remaining elements. Here,...
{"inputs": ["1\n1 0 5", "1\n0 0 5", "1\n1 3 5", "1\n1 2 5", "1\n0 0 8", "1\n0 0 0", "1\n0 1 0", "1\n1 2 3"], "outputs": ["1\n", "0\n", "-2\n", "-1\n", "0\n", "0\n", "1\n", "-1"]}
299
109
coding
Solve the programming task below in a Python markdown code block. Once, a genius guy Cristo visited NASA where he met many scientists. A young intern Mark at NASA asked Cristo to observe the strange behaviour of two independent particles (say Alpha and Beta) moving in the free space.Cristo was astonished to see the mo...
{"inputs": ["2\n1\n2"], "outputs": ["0 1\n2 1"]}
379
22
coding
Solve the programming task below in a Python markdown code block. Snuke got an integer sequence of length N from his mother, as a birthday present. The i-th (1 ≦ i ≦ N) element of the sequence is a_i. The elements are pairwise distinct. He is sorting this sequence in increasing order. With supernatural power, he can pe...
{"inputs": ["4\n2\n4\n2\n1", "4\n2\n4\n6\n1", "4\n2\n4\n2\n0", "4\n2\n4\n8\n1", "4\n2\n4\n5\n1", "4\n2\n4\n9\n1", "4\n2\n4\n3\n0", "4\n0\n4\n8\n1"], "outputs": ["1\n", "2\n", "1\n", "2\n", "2\n", "2\n", "1\n", "1\n"]}
290
126
coding
Solve the programming task below in a Python markdown code block. Tashizan Hikizan (Calculation Training) square1001 You gave E869120 two numbers, $ A $ and $ B $, as birthday presents. E869120 You decided to use these two numbers for calculation training. Specifically, E869120 does the following for these numbers e...
{"inputs": ["3\n4 4", "3\n4 3", "3\n5 3", "3\n9 3", "3\n7 3", "3\n0 3", "3\n0 5", "3\n0 6"], "outputs": ["-4 4\n", "-3 4\n", "-3 5\n", "-3 9\n", "-3 7\n", "-3 0\n", "-5 0\n", "-6 0\n"]}
439
111
coding
Solve the programming task below in a Python markdown code block. In a recent [breakthrough] in mathematics, the proof utilized a concept called Height. Consider a fraction \frac{a}{b}. Its Height is defined as the maximum of its numerator and denominator. So, for example, the Height of \frac{3}{19} would be 19, and t...
{"inputs": ["3 19\n", "27 4\n"], "outputs": ["19\n", "27\n"]}
306
30
coding
Solve the programming task below in a Python markdown code block. These days Arkady works as an air traffic controller at a large airport. He controls a runway which is usually used for landings only. Thus, he has a schedule of planes that are landing in the nearest future, each landing lasts $1$ minute. He was asked ...
{"inputs": ["1 1\n0 0\n", "1 5\n1 0\n", "1 2\n3 0\n", "1 5\n0 6\n", "1 2\n2 3\n", "1 2\n2 3\n", "1 1\n0 0\n", "1 2\n3 0\n"], "outputs": ["0 2\n", "0 0\n", "0 0\n", "0 0\n", "0 0\n", "0 0\n", "0 2\n", "0 0\n"]}
597
134
coding
Solve the programming task below in a Python markdown code block. # Two samurai generals are discussing dinner plans after a battle, but they can't seem to agree. The discussion gets heated and you are cannot risk favoring either of them as this might damage your political standing with either of the two clans the sam...
{"functional": "_inputs = [['eat chicken', 'eat chicken and rice'], ['eat a burger and drink a coke', 'drink a coke'], ['i like turtles', 'what are you talking about'], ['aa bb', 'aa bb cc'], ['aa bb cc', 'bb cc'], ['aa bb cc', 'bb cc bb aa'], ['aa bb', 'cc dd'], ['aa bb', ''], ['', 'cc dd'], ['', '']]\n_outputs = [['e...
236
272
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. You have a chat log of n messages. You are given two string arrays messages and senders where messages[i] is a message sent by senders[i]. A message is list of words that are separated by a single space with no leadin...
{"functional": "def check(candidate):\n assert candidate(messages = [\"Hello userTwooo\",\"Hi userThree\",\"Wonderful day Alice\",\"Nice day userThree\"], senders = [\"Alice\",\"userTwo\",\"userThree\",\"Alice\"]) == \"Alice\"\n assert candidate(messages = [\"How is leetcode for everyone\",\"Leetcode is useful fo...
195
106
coding
Solve the programming task below in a Python markdown code block. Takahashi has N blue cards and M red cards. A string is written on each card. The string written on the i-th blue card is s_i, and the string written on the i-th red card is t_i. Takahashi will now announce a string, and then check every card. Each time ...
{"inputs": ["3\nappme\norange\napple\n1\ngrape", "3\nappme\norange\napple\n0\ngrape", "3\nappme\nprange\napple\n0\ngrape", "3\nappme\nprange\napple\n0\ngrepa", "3\nappme\nprangd\napple\n0\ngrepa", "3\nappme\nprangd\napple\n0\ngreqa", "3\nappme\nprangd\napple\n0\naqerg", "3\nappme\ndgnarp\napple\n0\naqerg"], "outputs": ...
391
171
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. A teacher is writing a test with n true/false questions, with 'T' denoting true and 'F' denoting false. He wants to confuse the students by maximizing the number of consecutive questions with the same answer (multiple...
{"functional": "def check(candidate):\n assert candidate(answerKey = \"TTFF\", k = 2) == 4\n assert candidate(answerKey = \"TFFT\", k = 1) == 3\n assert candidate(answerKey = \"TTFTTFTT\", k = 1) == 5\n\n\ncheck(Solution().maxConsecutiveAnswers)"}
213
81
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. You are given a string s containing lowercase English letters, and a matrix shift, where shift[i] = [directioni, amounti]: directioni can be 0 (for left shift) or 1 (for right shift). amounti is the amount by which s...
{"functional": "def check(candidate):\n assert candidate(s = \"abc\", shift = [[0,1],[1,2]]) == \"cab\"\n assert candidate(s = \"abcdefg\", shift = [[1,1],[1,1],[0,2],[1,3]]) == \"efgabcd\"\n\n\ncheck(Solution().stringShift)"}
164
78
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. A company is planning to interview 2n people. Given the array costs where costs[i] = [aCosti, bCosti], the cost of flying the ith person to city a is aCosti, and the cost of flying the ith person to city b is bCosti. ...
{"functional": "def check(candidate):\n assert candidate(costs = [[10,20],[30,200],[400,50],[30,20]]) == 110\n assert candidate(costs = [[259,770],[448,54],[926,667],[184,139],[840,118],[577,469]]) == 1859\n assert candidate(costs = [[515,563],[451,713],[537,709],[343,819],[855,779],[457,60],[650,359],[631,42]...
134
198
coding
Solve the programming task below in a Python markdown code block. Toad Rash has a binary string s. A binary string consists only of zeros and ones. Let n be the length of s. Rash needs to find the number of such pairs of integers l, r that 1 ≤ l ≤ r ≤ n and there is at least one pair of integers x, k such that 1 ≤ x,...
{"inputs": ["0\n", "1\n", "01\n", "00\n", "100\n", "101\n", "001\n", "000\n"], "outputs": ["0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "1\n"]}
326
80