task_type
stringclasses
1 value
problem
stringlengths
209
3.39k
answer
stringlengths
35
6.15k
problem_tokens
int64
60
774
answer_tokens
int64
12
2.04k
coding
Solve the programming task below in a Python markdown code block. You have n distinct points on a plane, none of them lie on OY axis. Check that there is a point after removal of which the remaining points are located on one side of the OY axis. -----Input----- The first line contains a single positive integer n (2 ...
{"inputs": ["2\n8 0\n7 0\n", "2\n1 0\n2 0\n", "2\n8 0\n7 0\n", "2\n1 0\n2 0\n", "2\n1 0\n4 0\n", "2\n1 0\n-1 0\n", "2\n-1 0\n1 0\n", "2\n1 2\n-1 2\n"], "outputs": ["Yes", "Yes", "Yes\n", "Yes\n", "Yes\n", "Yes", "Yes", "Yes"]}
280
132
coding
Solve the programming task below in a Python markdown code block. There are n people taking dancing lessons. Every person is characterized by his/her dancing skill ai. At the beginning of the lesson they line up from left to right. While there is at least one couple of a boy and a girl in the line, the following proces...
{"inputs": ["1\nD\n85367\n", "1\nE\n85367\n", "1\nF\n85367\n", "1\nG\n85367\n", "1\nF\n59056\n", "1\nF\n80903\n", "1\nF\n42037\n", "1\nF\n18127\n"], "outputs": ["0\n\n", "0\n\n", "0\n\n", "0\n\n", "0\n\n", "0\n\n", "0\n\n", "0\n\n"]}
420
142
coding
Solve the programming task below in a Python markdown code block. In K-city, there are n streets running east-west, and m streets running north-south. Each street running east-west and each street running north-south cross each other. We will call the smallest area that is surrounded by four streets a block. How many b...
{"inputs": ["3 4\n", "2 2\n"], "outputs": ["6\n", "1\n"]}
141
26
coding
Solve the programming task below in a Python markdown code block. Rose loves to play games. This problem is about a game he recently played. In the game there are N locations, numbered 0 through N-1. Each location has one entrance and one exit. You are given an array aka A with N elements.For each i, A[i] describes the...
{"inputs": ["10\n2\n1 -1\n3\n1 0 -1\n3\n0 1 2\n37\n29 33 28 16 -1 11 10 14 6 31 7 35 34 8 15 17 26 12 13 22 1 20 2 21 -1 5 19 9 18 4 25 32 3 30 23 10 27\n48\n17 43 20 41 42 15 18 35 -1 31 7 33 23 33 -1 -1 0 33 19 12 42 -1 -1 9 9 -1 39 -1 31 46 -1 20 44 41 -1 -1 12 -1 36 -1 -1 6 47 10 2 4 1 29\n6\n3 1 1 2 -1 4\n47\n15 1...
372
1,895
coding
Solve the programming task below in a Python markdown code block. An X-layered kagami mochi (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of ...
{"inputs": ["3\n1\n1\n1", "3\n1\n5\n0", "3\n1\n0\n1", "3\n2\n0\n1", "3\n42\n5\n0", "3\n42\n5\n1", "3\n18\n5\n1", "3\n33\n5\n1"], "outputs": ["1\n", "3\n", "2\n", "3\n", "3\n", "3\n", "3\n", "3\n"]}
341
114
coding
Solve the programming task below in a Python markdown code block. You are given two positive integer numbers a and b. Permute (change order) of the digits of a to construct maximal number not exceeding b. No number in input and/or output can start with the digit 0. It is allowed to leave a as it is. -----Input----- ...
{"inputs": ["1\n2\n", "3\n3\n", "4\n9\n", "5\n6\n", "6\n9\n", "2\n6\n", "1\n2\n", "3\n3\n"], "outputs": ["1\n", "3\n", "4\n", "5\n", "6\n", "2\n", "1\n", "3\n"]}
243
86
coding
Solve the programming task below in a Python markdown code block. Arrow is getting paranoid about Malcom merlyn, his arch-enemy. All his efforts to subdue Merlyn have been in vain. These days Arrow is working on a problem with John Diggle. Diggle mentioned that the Felicity has been facing weird problem with their supe...
{"inputs": ["4\n1\n3\n5\n11"], "outputs": ["-1\n555\n33333\n55555533333"]}
455
44
coding
Solve the programming task below in a Python markdown code block. There is a building consisting of $10~000$ apartments numbered from $1$ to $10~000$, inclusive. Call an apartment boring, if its number consists of the same digit. Examples of boring apartments are $11, 2, 777, 9999$ and so on. Our character is a troub...
{"inputs": ["4\n6\n9999\n4\n777\n", "4\n9\n9999\n4\n777\n", "4\n4\n9999\n4\n777\n", "4\n9\n9999\n1\n777\n", "4\n3\n9999\n1\n777\n", "4\n9\n9999\n2\n777\n", "4\n4\n9999\n6\n777\n", "4\n3\n9999\n1\n555\n"], "outputs": ["51\n90\n31\n66\n", "81\n90\n31\n66\n", "31\n90\n31\n66\n", "81\n90\n1\n66\n", "21\n90\n1\n66\n", "81\n...
469
251
coding
Solve the programming task below in a Python markdown code block. # Introduction Hamsters are rodents belonging to the subfamily Cricetinae. The subfamily contains about 25 species, classified in six or seven genera. They have become established as popular small house pets, and, partly because they are easy to breed ...
{"functional": "_inputs = [['hamster', 'hamster'], ['hamster', 'helpme'], ['hmster', 'hamster'], ['hhhhammmstteree', 'hamster'], ['f', 'abcdefghijklmnopqrstuvwxyz']]\n_outputs = [['h1a1m1s1t1e1r1'], ['h1e1h5m4m1e1'], ['h1t8m1s1t1e1r1'], ['h1a1m1s1t1e1r1'], ['f22f23f24f25f26f1f2f3f4f5f6f7f8f9f10f11f12f13f14f15f16f17f18f...
655
320
coding
Solve the programming task below in a Python markdown code block. Takahashi is now competing in a programming contest, but he received TLE in a problem where the answer is YES or NO. When he checked the detailed status of the submission, there were N test cases in the problem, and the code received TLE in M of those ca...
{"inputs": ["1 0", "0 0", "8 5", "7 5", "7 2", "2 2", "2 4", "2 0"], "outputs": ["100\n", "0\n", "313600\n", "310400\n", "17200\n", "15200\n", "118400\n", "200\n"]}
460
105
coding
Solve the programming task below in a Python markdown code block. There is an apple tree that bears apples of N colors. The N colors of these apples are numbered 1 to N, and there are a_i apples of Color i. You and Lunlun the dachshund alternately perform the following operation (starting from you): * Choose one or m...
{"inputs": ["2\n0\n2", "2\n1\n0", "2\n1\n1", "2\n2\n1", "2\n2\n2", "2\n2\n3", "2\n1\n3", "2\n1\n6"], "outputs": ["second\n", "first\n", "first\n", "first\n", "second\n", "first\n", "first\n", "first\n"]}
259
94
coding
Solve the programming task below in a Python markdown code block. Read problems statements in [Hindi], [Mandarin Chinese], [Vietnamese], and [Bengali] as well. You are given two sets of segments on a line, $A$ and $B$. Set $A$ contains $N$ segments (numbered $1$ through $N$); for each valid $i$, the $i$-th of these se...
{"inputs": ["3\n2 2\n1 2\n3 4\n1 3\n2 4\n1 1\n1 2\n3 4\n2 1\n5 6\n6 8\n5 8\n"], "outputs": ["2\n0\n3\n"]}
769
66
coding
Solve the programming task below in a Python markdown code block. Training is indispensable for achieving good results at ICPC. Rabbit wants to win at ICPC, so he decided to practice today as well. Today's training is to gain dexterity that never mistypes by carefully stacking blocks. Since there are many building blo...
{"inputs": ["3\n5 49\n9 9\n28 0", "3\n0 2\n1 59\n1 -2", "3\n5 14\n9 9\n45 0", "3\n7 34\n1 41\n2 0", "3\n1 7\n79 0\n1 -1", "3\n6 42\n6 40\n28 0", "3\n6 49\n6 40\n28 0", "3\n6 49\n9 40\n28 0"], "outputs": ["86\n", "62\n", "68\n", "77\n", "87\n", "76\n", "83\n", "117\n"]}
317
184
coding
Solve the programming task below in a Python markdown code block. Read problem statements in [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well. Gintoki has been very lazy recently and he hasn't made enough money to pay the rent this month. So the old landlady has given him a problem to solve instead, ...
{"inputs": ["3\n3\n4\n5"], "outputs": ["3\n6\n9"]}
704
22
coding
Solve the programming task below in a Python markdown code block. Teacher thinks that we make a lot of progress. Now we are even allowed to use decimal notation instead of counting sticks. After the test the teacher promised to show us a "very beautiful number". But the problem is, he's left his paper with the number i...
{"inputs": ["6 5\n", "1 2\n", "6 4\n", "2 7\n", "1 1\n", "1 1\n", "2 7\n", "2 2\n"], "outputs": ["142857", "Impossible\n", "102564", "Impossible\n", "1", "1\n", "Impossible\n", "Impossible\n"]}
368
93
coding
Solve the programming task below in a Python markdown code block. Cherry has a string S$S$ consisting of lowercase English letters. Using this string, he formed a pyramid of infinite length with certain rules: - N$N$-th row of pyramid contains N$N$ characters. - Each row of pyramid begins with the first character of th...
{"inputs": ["codechef\nchefcode\n3\n4\n12\n1455"], "outputs": ["0\n1\n181"]}
619
34
coding
Solve the programming task below in a Python markdown code block. In a long narrow forest stretching east-west, there are N beasts. Below, we will call the point that is p meters from the west end Point p. The i-th beast from the west (1 ≤ i ≤ N) is at Point x_i, and can be sold for s_i yen (the currency of Japan) if c...
{"inputs": ["5\n10 2\n40 5\n60 3\n70 5\n90 1", "5\n10 2\n40 8\n60 3\n70 5\n90 1", "5\n10 2\n40 5\n60 3\n70 4\n90 1", "5\n28 17\n40 50\n60 35\n70 40\n90 3", "5\n2 20\n40 50\n60 13\n70 40\n89 10", "5\n2 20\n40 50\n60 13\n70 40\n71 10", "5\n18 17\n40 44\n60 35\n70 40\n90 3", "5\n10 20\n40 50\n60 35\n70 40\n90 10"], "outpu...
428
288
coding
Solve the programming task below in a Python markdown code block. Read problem statements in [Mandarin], [Russian], and [Vietnamese] as well. Chef is busy preparing for the next lunchtime, so he has given you the following task. You are given an array a consisting of n positive integers. The goodness of the array a...
{"inputs": ["2\n5\n18 6 4 3 12\n5\n12 4 6 16 28 "], "outputs": ["6\n4"]}
690
44
coding
Solve the programming task below in a Python markdown code block. You are given a tree that is built in a following way: initially there is single vertex 1. All the other vertices are added one by one, from vertex 2 to vertex N, by connecting it to one of those that have been added before. You are to find the diameter ...
{"inputs": ["2\n3\n1\n1\n5\n1\n2\n3\n3"], "outputs": ["1\n2\n1\n2\n3\n3"]}
323
38
coding
Solve the programming task below in a Python markdown code block. # Description: Replace the pair of exclamation marks and question marks to spaces(from the left to the right). A pair of exclamation marks and question marks must has the same number of "!" and "?". That is: "!" and "?" is a pair; "!!" and "??" is ...
{"functional": "_inputs = [['!!?!!?!!?!!?!!!??!!!??!!!??'], ['??!??!??!??!???!!???!!???!!'], ['?!!?!!?!!?!!!??!!!??!!!??!!!??!!!??']]\n_outputs = [[' ? ? ?!!?!!! !!! !!! '], [' ! ! !??!??? ??? ??? '], ['? ? ? ?!!! !!! !!! !!!??!!!??']]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, ...
197
252
coding
Solve the programming task below in a Python markdown code block. Every Codeforces user has rating, described with one integer, possibly negative or zero. Users are divided into two divisions. The first division is for users with rating 1900 or higher. Those with rating 1899 or lower belong to the second division. In e...
{"inputs": ["1\n0 2\n", "1\n3 2\n", "1\n3 2\n", "1\n0 2\n", "1\n0 1\n", "1\n-5 1\n", "1\n-1 2\n", "1\n-1 1\n"], "outputs": ["1899\n", "1902\n", "1902\n", "1899\n", "Infinity\n", "Infinity\n", "1898\n", "Infinity\n"]}
625
120
coding
Solve the programming task below in a Python markdown code block. ## Task: Your task is to write a function which returns the sum of following series upto nth term(parameter). Series: 1 + 1/4 + 1/7 + 1/10 + 1/13 + 1/16 +... ## Rules: * You need to round the answer to 2 decimal places and return it as String. ...
{"functional": "_inputs = [[1], [2], [3], [4], [5], [6], [7], [8], [9], [15], [39], [58], [0]]\n_outputs = [['1.00'], ['1.25'], ['1.39'], ['1.49'], ['1.57'], ['1.63'], ['1.68'], ['1.73'], ['1.77'], ['1.94'], ['2.26'], ['2.40'], ['0.00']]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinst...
236
268
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. You are given a 0-indexed integer array nums and an integer pivot. Rearrange nums such that the following conditions are satisfied: Every element less than pivot appears before every element greater than pivot. Every...
{"functional": "def check(candidate):\n assert candidate(nums = [9,12,5,10,14,3,10], pivot = 10) == [9,5,3,10,10,12,14]\n assert candidate(nums = [-3,4,3,2], pivot = 2) == [-3,2,4,3]\n\n\ncheck(Solution().pivotArray)"}
223
100
coding
Solve the programming task below in a Python markdown code block. Alice and Bob are controlling a robot. They each have one switch that controls the robot. Alice started holding down her button A second after the start-up of the robot, and released her button B second after the start-up. Bob started holding down his ...
{"inputs": ["0 6 1 5", "1 0 0 0", "2 0 0 0", "4 0 0 0", "1 6 -1 4", "1 11 1 6", "-1 0 0 4", "-1 0 0 1"], "outputs": ["4\n", "0\n", "0\n", "0\n", "3\n", "5\n", "0\n", "0\n"]}
294
111
coding
Solve the programming task below in a Python markdown code block. Nezzar has $n$ balls, numbered with integers $1, 2, \ldots, n$. Numbers $a_1, a_2, \ldots, a_n$ are written on them, respectively. Numbers on those balls form a non-decreasing sequence, which means that $a_i \leq a_{i+1}$ for all $1 \leq i < n$. Nezzar ...
{"inputs": ["5\n6\n1 1 1 2 3 4\n5\n1 1 2 2 3\n4\n2 2 2 2\n3\n1 2 3\n1\n1\n", "5\n6\n1 1 1 2 3 4\n5\n1 1 2 2 3\n4\n2 2 2 2\n3\n2 2 3\n1\n1\n", "5\n6\n1 1 1 2 3 3\n5\n1 1 2 2 3\n4\n1 2 2 2\n3\n2 2 3\n1\n1\n", "5\n6\n1 1 2 2 3 3\n5\n1 1 2 2 3\n4\n1 2 2 2\n3\n2 2 3\n1\n1\n", "5\n6\n1 1 1 2 3 6\n5\n1 1 2 2 3\n4\n2 2 2 2\n3\...
454
518
coding
Solve the programming task below in a Python markdown code block. Write a program that takes in a letterclass ID of a ship and display the equivalent string class description of the given ID. Use the table below. Class ID Ship ClassB or bBattleShipC or cCruiserD or dDestroyerF or fFrigate -----Input----- The first l...
{"inputs": ["3\nB\nc\nD", "3 \nC\nc\nD", "3 \nB\nc\nC", "3 \nB\nc\nB", "3 \nC\nc\nB", "3 \nC\nb\nB", "3 \nB\nd\nD", "3 \nC\nd\nD"], "outputs": ["BattleShip\nCruiser\nDestroyer", "Cruiser\nCruiser\nDestroyer\n", "BattleShip\nCruiser\nCruiser\n", "BattleShip\nCruiser\nBattleShip\n", "Cruiser\nCruiser\nBattleShip\n", "Cru...
160
182
coding
Solve the programming task below in a Python markdown code block. Our football team finished the championship. The result of each match look like "x:y". Results of all matches are recorded in the collection. For example: ```["3:1", "2:2", "0:1", ...]``` Write a function that takes such collection and counts the point...
{"functional": "_inputs = [[['1:0', '2:0', '3:0', '4:0', '2:1', '3:1', '4:1', '3:2', '4:2', '4:3']], [['1:1', '2:2', '3:3', '4:4', '2:2', '3:3', '4:4', '3:3', '4:4', '4:4']], [['0:1', '0:2', '0:3', '0:4', '1:2', '1:3', '1:4', '2:3', '2:4', '3:4']], [['1:0', '2:0', '3:0', '4:0', '2:1', '1:3', '1:4', '2:3', '2:4', '3:4']...
169
418
coding
Solve the programming task below in a Python markdown code block. Given is an integer r. How many times is the area of a circle of radius r larger than the area of a circle of radius 1? It can be proved that the answer is always an integer under the constraints given. -----Constraints----- - 1 \leq r \leq 100 - All ...
{"inputs": ["2\n", "8\n", "1\n", "30\n", "27\n", "87\n", "22\n", "76\n"], "outputs": ["4\n", "64\n", "1\n", "900\n", "729\n", "7569\n", "484\n", "5776\n"]}
187
88
coding
Solve the programming task below in a Python markdown code block. Charlie and Johnny play a game. For every integer $\mbox{X}$ Charlie gives, Johnny has to find the smallest positive integer $\mathbf{Y}$ such that $X\times Y$ ($\mbox{X}$ multiplied by $\mathbf{Y}$) contains only 4s and 0s and starts with one or more 4s...
{"inputs": ["3\n4\n5\n80\n"], "outputs": ["2\n3\n4\n"]}
463
25
coding
Solve the programming task below in a Python markdown code block. You are given an integer $n$. Check if $n$ has an odd divisor, greater than one (does there exist such a number $x$ ($x > 1$) that $n$ is divisible by $x$ and $x$ is odd). For example, if $n=6$, then there is $x=3$. If $n=4$, then such a number does not...
{"inputs": ["2\n4\n54\n", "2\n7\n30\n", "2\n5\n30\n", "2\n3\n30\n", "2\n3\n57\n", "2\n7\n46\n", "2\n5\n54\n", "2\n5\n48\n"], "outputs": ["NO\nYES\n", "YES\nYES\n", "YES\nYES\n", "YES\nYES\n", "YES\nYES\n", "YES\nYES\n", "YES\nYES\n", "YES\nYES\n"]}
331
126
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. You are given two strings s1 and s2, both of length 4, consisting of lowercase English letters. You can apply the following operation on any of the two strings any number of times: Choose any two indices i and j such...
{"functional": "def check(candidate):\n assert candidate(s1 = \"abcd\", s2 = \"cdab\") == True\n assert candidate(s1 = \"abcd\", s2 = \"dacb\") == False\n\n\ncheck(Solution().canBeEqual)"}
141
58
coding
Solve the programming task below in a Python markdown code block. Given a string of lowercase letters in the range ascii[a-z], determine the index of a character that can be removed to make the string a palindrome. There may be more than one solution, but any will do. If the word is already a palindrome or there is n...
{"inputs": ["3 \naaab \nbaa \naaa \n"], "outputs": ["3\n0\n-1\n"]}
427
33
coding
Solve the programming task below in a Python markdown code block. You are given positive integers $N$ and $D$. You may perform operations of the following two types: - add $D$ to $N$, i.e. change $N$ to $N+D$ - change $N$ to $\mathop{\mathrm{digitsum}}(N)$ Here, $\mathop{\mathrm{digitsum}}(x)$ is the sum of decimal dig...
{"inputs": ["3\n2 1\n9 3\n11 13\n"], "outputs": ["1 9\n3 2\n1 4"]}
580
37
coding
Solve the programming task below in a Python markdown code block. Make the 2D list by the sequential integers started by the ```head``` number. See the example test cases for the expected output. ``` Note: -10**20 < the head number <10**20 1 <= the number of rows <= 1000 0 <= the number of columms <= 1000 ``` Als...
{"functional": "_inputs = [[1, 2, 3], [2, 3, 4], [5, 6, 1], [7, 1, 1], [0, 1, 0], [-20, 2, 2], [10000000000, 2, 2]]\n_outputs = [[[[1, 2, 3], [4, 5, 6]]], [[[2, 3, 4, 5], [6, 7, 8, 9], [10, 11, 12, 13]]], [[[5], [6], [7], [8], [9], [10]]], [[[7]]], [[[]]], [[[-20, -19], [-18, -17]]], [[[10000000000, 10000000001], [1000...
119
384
coding
Solve the programming task below in a Python markdown code block. You are given an array of positive integers a1, a2, ..., an × T of length n × T. We know that for any i > n it is true that ai = ai - n. Find the length of the longest non-decreasing sequence of the given array. Input The first line contains two space-...
{"inputs": ["1 1\n5\n", "2 2\n1 2\n", "2 1\n1 2\n", "1 1000\n42\n", "1 1100\n42\n", "2 1000\n1 2\n", "2 1000\n1 1\n", "2 1000\n2 1\n"], "outputs": ["1", "3", "2", "1000", "1100\n", "1001", "2000\n", "1000\n"]}
225
139
coding
Solve the programming task below in a Python markdown code block. Victor has a 24-hour clock that shows the time in the format "HH:MM" (00 $\le$ HH $\le$ 23, 00 $\le$ MM $\le$ 59). He looks at the clock every $x$ minutes, and the clock is currently showing time $s$. How many different palindromes will Victor see in to...
{"inputs": ["1\n01:01 1439\n", "6\n03:12 360\n00:00 1\n13:22 2\n15:15 10\n11:11 1440\n22:30 27\n", "7\n09:09 855\n07:07 986\n01:01 251\n09:09 77\n02:02 28\n01:01 711\n06:06 1062\n", "10\n05:17 516\n03:42 1088\n10:47 1114\n21:01 954\n09:54 999\n00:47 846\n13:15 511\n15:51 712\n07:04 332\n04:42 17\n"], "outputs": ["16\n"...
581
322
coding
Solve the programming task below in a Python markdown code block. Sam lives in Awesomeburg, its downtown has a triangular shape. Also, the following is true about the triangle: its vertices have integer coordinates, the coordinates of vertices are non-negative, and its vertices are not on a single line. He calls a ...
{"inputs": ["1\n0 1\n0 3\n2 2\n", "1\n0 0\n0 1\n1 2\n", "1\n1 1\n0 5\n99999990 5\n", "5\n8 10\n10 4\n6 2\n4 6\n0 1\n4 2\n14 1\n11 2\n13 2\n0 0\n4 0\n2 4\n0 1\n1 1\n0 0\n"], "outputs": ["0\n", "0\n", "99999990\n", "0\n0\n2\n0\n1\n"]}
572
161
coding
Solve the programming task below in a Python markdown code block. Given a tree T with non-negative weight, find the height of each node of the tree. For each node, the height is the distance to the most distant leaf from the node. Constraints * 1 ≤ n ≤ 10,000 * 0 ≤ wi ≤ 1,000 Input n s1 t1 w1 s2 t2 w2 : sn-1 tn-1 ...
{"inputs": ["4\n0 2 2\n1 2 1\n1 3 3", "4\n0 1 2\n1 2 2\n1 3 3", "4\n0 1 2\n1 2 1\n2 3 3", "4\n0 1 2\n1 2 0\n1 3 3", "4\n0 2 2\n1 2 1\n2 3 3", "4\n0 1 2\n1 2 0\n0 3 3", "4\n0 1 0\n1 2 0\n1 3 3", "4\n0 1 2\n0 2 0\n0 3 3"], "outputs": ["6\n3\n4\n6\n", "5\n3\n5\n5\n", "6\n4\n3\n6\n", "5\n3\n3\n5\n", "5\n4\n3\n5\n", "3\n5\n...
249
254
coding
Solve the programming task below in a Python markdown code block. Given n number of people in a room, calculate the probability that any two people in that room have the same birthday (assume 365 days every year = ignore leap year). Answers should be two decimals unless whole (0 or 1) eg 0.05 Also feel free to reuse/ex...
{"functional": "_inputs = [[5], [15], [1], [365], [366]]\n_outputs = [[0.03], [0.25], [0], [1], [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 if len(a) != ...
91
190
coding
Solve the programming task below in a Python markdown code block. A binary matrix is called good if every even length square sub-matrix has an odd number of ones. Given a binary matrix $a$ consisting of $n$ rows and $m$ columns, determine the minimum number of cells you need to change to make it good, or report that ...
{"inputs": ["1 1\n0\n", "1 1\n1\n", "1 1\n0\n", "1 1\n1\n", "3 3\n101\n001\n110\n", "3 3\n101\n001\n100\n", "3 3\n101\n001\n111\n", "3 3\n111\n001\n100\n"], "outputs": ["0", "0", "0\n", "0\n", "2", "1\n", "2\n", "1\n"]}
697
139
coding
Solve the programming task below in a Python markdown code block. Pasha has a positive integer a without leading zeroes. Today he decided that the number is too small and he should make it larger. Unfortunately, the only operation Pasha can do is to swap two adjacent decimal digits of the integer. Help Pasha count the...
{"inputs": ["300 0\n", "5 100\n", "5 100\n", "4 100\n", "360 0\n", "7 100\n", "700 0\n", "6 100\n"], "outputs": ["300\n", "5\n", "5\n", "4\n", "360\n", "7\n", "700\n", "6\n"]}
224
108
coding
Solve the programming task below in a Python markdown code block. Some time ago Leonid have known about idempotent functions. Idempotent function defined on a set {1, 2, ..., n} is such function $g : \{1,2, \ldots, n \} \rightarrow \{1,2, \ldots, n \}$, that for any $x \in \{1,2, \ldots, n \}$ the formula g(g(x)) = g(x...
{"inputs": ["1\n1\n", "2\n1 2\n", "2\n1 1\n", "2\n2 2\n", "2\n2 1\n", "3\n2 3 3\n", "3\n2 3 1\n", "3\n2 1 2\n"], "outputs": ["1\n", "1\n", "1\n", "1\n", "2\n", "2\n", "3\n", "2\n"]}
745
106
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. Given an integer array nums, return all the triplets [nums[i], nums[j], nums[k]] such that i != j, i != k, and j != k, and nums[i] + nums[j] + nums[k] == 0. Notice that the solution set must not contain duplicate trip...
{"functional": "def check(candidate):\n assert candidate(nums = [-1,0,1,2,-1,-4]) == [[-1,-1,2],[-1,0,1]]\n assert candidate(nums = [0,1,1]) == []\n assert candidate(nums = [0,0,0]) == [[0,0,0]]\n\n\ncheck(Solution().threeSum)"}
114
92
coding
Solve the programming task below in a Python markdown code block. A sequence $a_1, a_2, \dots, a_n$ is called good if, for each element $a_i$, there exists an element $a_j$ ($i \ne j$) such that $a_i+a_j$ is a power of two (that is, $2^d$ for some non-negative integer $d$). For example, the following sequences are goo...
{"inputs": ["1\n1\n", "1\n1\n", "1\n2\n", "1\n5\n", "1\n4\n", "1\n6\n", "1\n16\n", "1\n31\n"], "outputs": ["1\n", "1", "1\n", "1\n", "1\n", "1\n", "1\n", "1\n"]}
653
87
coding
Solve the programming task below in a Python markdown code block. Read problems statements in Mandarin Chinese, Russian and Vietnamese as well. Today a plane was hijacked by a maniac. All the passengers of the flight are taken as hostage. Chef is also one of them. He invited one of the passengers to play a game with h...
{"inputs": ["2\n3 3 3\n1\n3 3 3\n2", "2\n6 3 3\n1\n3 3 3\n2", "2\n0 0 3\n2\n3 3 3\n2", "2\n6 0 3\n2\n3 3 3\n2", "2\n1 0 3\n1\n3 3 0\n2", "2\n0 0 3\n2\n3 3 4\n0", "2\n6 0 3\n3\n3 3 3\n2", "2\n0 0 3\n2\n3 4 0\n2"], "outputs": ["1\n4", "1\n4\n", "2\n4\n", "3\n4\n", "1\n3\n", "2\n-2\n", "5\n4\n", "2\n3\n"]}
523
206
coding
Solve the programming task below in a Python markdown code block. Polycarpus analyzes a string called abracadabra. This string is constructed using the following algorithm: * On the first step the string consists of a single character "a". * On the k-th step Polycarpus concatenates two copies of the string obtai...
{"inputs": ["1 4 4 7\n", "1 2 3 3\n", "3 3 1 2\n", "1 2 3 6\n", "2 2 6 6\n", "4 7 1 4\n", "1 3 5 7\n", "5 7 1 3\n"], "outputs": ["3\n", "1\n", "1\n", "2\n", "1\n", "3\n", "3\n", "3\n"]}
705
118
coding
Solve the programming task below in a Python markdown code block. You will be given two integers $a,b$. You are required to output the result of $2^{(2^a)}$ mod $\boldsymbol{b}$. Constraints $1\leq a,b\leq10^6$ Input Format First and only line of the input will contain two integers $a,b$ separated by a single blank...
{"inputs": ["2 7\n"], "outputs": ["2\n"]}
147
16
coding
Solve the programming task below in a Python markdown code block. # The President's phone is broken He is not very happy. The only letters still working are uppercase ```E```, ```F```, ```I```, ```R```, ```U```, ```Y```. An angry tweet is sent to the department responsible for presidential phone maintenance. # Kat...
{"functional": "_inputs = [['FURYYYFIREYYFIRE'], ['FIREYYFURYYFURYYFURRYFIRE'], ['FYRYFIRUFIRUFURE'], [''], ['FURYFURYFURY'], ['FURYFURYFURYFURY'], ['FURYFURYFURYFURYFURY'], ['FIRE'], ['FIREFIRE'], ['FIREFIREFIRE'], ['FIREFIREFIREFIRE'], ['FIREFIREFIREFIREFIRE']]\n_outputs = [['I am furious. You and you are fired!'], [...
394
369
coding
Solve the programming task below in a Python markdown code block. Sasha and Kolya decided to get drunk with Coke, again. This time they have k types of Coke. i-th type is characterised by its carbon dioxide concentration $\frac{a_{i}}{1000}$. Today, on the party in honour of Sergiy of Vancouver they decided to prepare ...
{"inputs": ["0 1\n0\n", "0 1\n0\n", "0 1\n1000\n", "0 1\n1000\n", "500 1\n1000\n", "500 1\n1000\n", "430 1\n1000\n", "50 2\n100 25\n"], "outputs": ["1\n", "1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "3\n"]}
606
129
coding
Solve the programming task below in a Python markdown code block. You are given a hexagonal grid consisting of two rows, each row consisting of $n$ cells. The cells of the first row are labelled $a_1,a_2,\ldots a_n$ and the cells of the second row are labelled $b_1,b_2,\ldots,b_n$. For example, for $n=6$: (Note tha...
{"inputs": ["6\n6\n010000\n000010\n2\n00\n00\n2\n00\n10\n2\n00\n01\n2\n00\n11\n2\n10\n00\n"], "outputs": ["YES\nYES\nNO\nNO\nYES\nNO\n"]}
552
80
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. Given an integer array nums, find three numbers whose product is maximum and return the maximum product.   Please complete the following python code precisely: ```python class Solution: def maximumProduct(self, nu...
{"functional": "def check(candidate):\n assert candidate(nums = [1,2,3]) == 6\n assert candidate(nums = [1,2,3,4]) == 24\n assert candidate(nums = [-1,-2,-3]) == -6\n\n\ncheck(Solution().maximumProduct)"}
67
70
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. Given an equation, represented by words on the left side and the result on the right side. You need to check if the equation is solvable under the following rules: Each character is decoded as one digit (0 - 9). No t...
{"functional": "def check(candidate):\n assert candidate(words = [\"SEND\",\"MORE\"], result = \"MONEY\") == True\n assert candidate(words = [\"SIX\",\"SEVEN\",\"SEVEN\"], result = \"TWENTY\") == True\n assert candidate(words = [\"THIS\",\"IS\",\"TOO\"], result = \"FUNNY\") == True\n assert candidate(words ...
160
113
coding
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 #19 You work for an ad agency and your boss, Bob, loves a catchy slogan. He's always jumbling together "buzz" words until he gets one he likes. You're looking to imp...
{"functional": "_inputs = [[['super']], [['super', 'hot']], [['super', 'hot', 'guacamole']], [['super', 'guacamole', 'super', 'super', 'hot', 'guacamole']], [['testing', 'testing', 'testing']]]\n_outputs = [[['super']], [['super hot', 'hot super']], [['super hot guacamole', 'super guacamole hot', 'hot super guacamole',...
397
302
coding
Solve the programming task below in a Python markdown code block. Write a program which prints $n$-th fibonacci number for a given integer $n$. The $n$-th fibonacci number is defined by the following recursive formula: \begin{equation*} fib(n)= \left \\{ \begin{array}{ll} 1 & (n = 0) \\\ 1 & (n = 1) \\\ fib(n - 1) + f...
{"inputs": ["1", "2", "4", "8", "6", "7", "5", "9"], "outputs": ["1\n", "2\n", "5\n", "34\n", "13\n", "21\n", "8\n", "55\n"]}
157
66
coding
Solve the programming task below in a Python markdown code block. # Task Four men, `a, b, c and d` are standing in a line, one behind another. There's a wall between the first three people (a, b and c) and the last one (d). a, b and c are lined up in order of height, so that person a can see the backs of b and ...
{"functional": "_inputs = [['white', 'black', 'white', 'black'], ['white', 'black', 'black', 'white']]\n_outputs = [[2], [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)...
403
179
coding
Solve the programming task below in a Python markdown code block. Water Country Water Deven has n cities. Each city is surrounded by water and looks like an island country. Water Deven has m bridges, and transportation between cities is carried out by these bridges, which allows you to travel to and from all cities. R...
{"inputs": ["5 6\n0 2 1\n2 1 3\n2 3 8\n1 3 1\n3 4 5\n1 4 4\n3 3\n1 2 3\n2 0 3\n0 1 3\n0 0", "5 6\n0 2 1\n2 1 3\n2 3 8\n1 3 3\n3 4 5\n1 4 4\n3 3\n1 2 3\n2 0 3\n0 1 3\n0 0", "5 6\n0 2 1\n2 1 3\n2 3 8\n1 3 0\n3 4 5\n1 4 4\n3 3\n1 2 3\n2 0 3\n0 1 3\n0 0", "5 6\n0 2 1\n2 1 3\n2 3 6\n0 3 1\n3 4 8\n1 3 4\n3 3\n1 2 3\n2 0 3\n0...
446
595
coding
Solve the programming task below in a Python markdown code block. Read problems statements in Mandarin Chinese and Russian. Roman has no idea, why this problem is called Stone. He also has no idea on how to solve the followong problem: given array of N integers A and a number K. During a turn the maximal value over a...
{"inputs": ["4 1\n5 0 7 0", "4 1\n5 0 7 1", "4 2\n5 0 7 1", "4 2\n5 0 7 0", "4 0\n2 0 5 0", "4 1\n4 0 0 1", "4 1\n4 0 1 1", "4 1\n4 1 1 1"], "outputs": ["2 7 0 7\n", "2 7 0 6\n", "5 0 7 1\n", "5 0 7 0\n", "2 0 5 0\n", "0 4 4 3\n", "0 4 3 3\n", "0 3 3 3\n"]}
263
190
coding
Solve the programming task below in a Python markdown code block. Petya is having a party soon, and he has decided to invite his $n$ friends. He wants to make invitations in the form of origami. For each invitation, he needs two red sheets, five green sheets, and eight blue sheets. The store sells an infinite number o...
{"inputs": ["3 5\n", "1 1\n", "1 4\n", "1 4\n", "1 1\n", "1 7\n", "2 1\n", "4 5\n"], "outputs": ["10\n", "15\n", "5\n", "5\n", "15\n", "4\n", "30\n", "13\n"]}
291
91
coding
Solve the programming task below in a Python markdown code block. Takahashi is a user of a site that hosts programming contests. When a user competes in a contest, the rating of the user (not necessarily an integer) changes according to the performance of the user, as follows: - Let the current rating of the user b...
{"inputs": ["4500\n1", "4500\n2", "2002\n2", "2002\n3", "2002\n0", "2002\n1", "2002\n4", "2002\n8"], "outputs": ["-4498\n", "-4496\n", "-1998\n", "-1996\n", "-2002\n", "-2000\n", "-1994\n", "-1986\n"]}
326
127
coding
Solve the programming task below in a Python markdown code block. # Task Miss X has only two combs in her possession, both of which are old and miss a tooth or two. She also has many purses of different length, in which she carries the combs. The only way they fit is horizontally and without overlapping. Given teeth' ...
{"functional": "_inputs = [['*..*', '*.*'], ['*...*', '*.*'], ['*..*.*', '*.***'], ['*.*', '*.*'], ['*.**', '*.*']]\n_outputs = [[5], [5], [9], [4], [5]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return math.isclose(a, b, rel_tol=tol, abs_tol=tol)\n if...
382
200
coding
Solve the programming task below in a Python markdown code block. You are given an array of non-negative integers, your task is to complete the series from 0 to the highest number in the array. If the numbers in the sequence provided are not in order you should order them, but if a value repeats, then you must return ...
{"functional": "_inputs = [[[0, 1]], [[1, 4, 6]], [[3, 4, 5]], [[2, 1]], [[1, 4, 4, 6]]]\n_outputs = [[[0, 1]], [[0, 1, 2, 3, 4, 5, 6]], [[0, 1, 2, 3, 4, 5]], [[0, 1, 2]], [[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=...
245
248
coding
Solve the programming task below in a Python markdown code block. # # Task: * #### Complete the pattern, using the special character ```■ □``` * #### In this kata, we draw some histogram of the sound performance of ups and downs. # # Rules: - parameter ```waves``` The value of sound waves, an array of number...
{"functional": "_inputs = [[[1, 2, 3, 4]], [[1, 2, 3, 3, 2, 1]], [[1, 2, 3, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7]], [[5, 3, 1, 2, 4, 6, 5, 4, 2, 3, 5, 2, 1]], [[1, 0, 1, 0, 1, 0, 1, 0]]]\n_outputs = [['\u25a1\u25a1\u25a1\u25a0\\n\u25a1\u25a1\u25a0\u25a0\\n\u25a1\u25a0\u25a0\u25a0\\n\u25a0\u25a0\u25a0\u25a0'], ['\u25a1\u25a1\u2...
476
1,381
coding
Solve the programming task below in a Python markdown code block. Did you hear about the Nibiru collision ? It is a supposed disastrous encounter between the earth and a large planetary object. Astronomers reject this idea. But why listen to other people's beliefs and opinions. We are coders above all, so what better w...
{"inputs": ["3\n0 0 R\n2\n2 0 U\n2 2 D\n1 2 U\n1\n2 0 U\n2 0 R\n1\n3 0 L", "3\n0 0 R\n2\n2 0 U\n2 2 D\n1 2 U\n1\n1 0 U\n1 0 R\n1\n3 0 L", "3\n0 0 R\n2\n1 -2 U\n2 2 D\n1 1 U\n1\n1 0 U\n0 0 R\n1\n3 0 L", "3\n0 0 R\n2\n2 -2 U\n2 2 D\n1 1 U\n1\n1 0 U\n0 0 R\n1\n3 0 L", "3\n0 0 R\n2\n1 -4 U\n1 2 D\n1 1 U\n1\n1 0 U\n0 0 R\n1...
733
443
coding
Solve the programming task below in a Python markdown code block. Imagine that you are given two sticks. You want to end up with three sticks of equal length. You are allowed to cut either or both of the sticks to accomplish this, and can throw away leftover pieces. Write a function, maxlen, that takes the lengths of ...
{"functional": "_inputs = [[5, 12], [12, 5], [5, 17], [17, 5], [7, 12], [12, 7]]\n_outputs = [[5], [5], [5.666666666666667], [5.666666666666667], [6.0], [6.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...
117
244
coding
Solve the programming task below in a Python markdown code block. Aureole the Techno-cultural fest of JEC thought of conducting a workshop on big data, as the topic is hot everyone wants to take part but due to limited seats in the Jashan Auditorium there is a selection criteria, a problem is given. the problem states ...
{"inputs": ["1\naaabb"], "outputs": ["-40"]}
336
17
coding
Solve the programming task below in a Python markdown code block. Read problems statements in Mandarin chinese, Russian and Vietnamese as well. Katya has a sequence of integers $a_{1}, a_{2}, \dots, a_{n}$ and an integer $m$. She defines a *good* sequence of integers as a non-empty sequence such that the sum of the ...
{"inputs": ["2\n2 3\n1 2\n2 3\n1 3"], "outputs": ["0\n1"]}
393
30
coding
Solve the programming task below in a Python markdown code block. Chef has $N$ doggo (dogs) , Lets number them $1$ to $N$. Chef decided to build houses for each, but he soon realizes that keeping so many dogs at one place may be messy. So he decided to divide them into several groups called doggo communities. Let the...
{"inputs": ["1\n4"], "outputs": ["2"]}
406
14
coding
Solve the programming task below in a Python markdown code block. ## Task You need to implement two functions, `xor` and `or`, that replicate the behaviour of their respective operators: - `xor` = Takes 2 values and returns `true` if, and only if, one of them is truthy. - `or` = Takes 2 values and returns `true` if ei...
{"functional": "_inputs = [[True, True], [True, False], [False, False], [0, 11], [None, []]]\n_outputs = [[True], [True], [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 isins...
221
190
coding
Solve the programming task below in a Python markdown code block. Once upon a time Mike and Mike decided to come up with an outstanding problem for some stage of ROI (rare olympiad in informatics). One of them came up with a problem prototype but another stole the idea and proposed that problem for another stage of the...
{"inputs": ["4 4\n1 7 4 7\n1 4 3\n2 10\n2 2\n1 3 3\n", "4 5\n5 2 6 1\n2 8\n2 7\n1 4 4\n2 9\n1 3 9\n", "4 5\n6 9 5 1\n1 4 9\n1 3 9\n1 4 7\n2 10\n2 7\n", "5 4\n4 8 3 4 10\n1 4 10\n1 4 6\n1 3 10\n2 1\n", "5 5\n1 2 3 4 5\n1 1 5\n2 10\n1 5 11\n1 4 1\n2 1\n", "5 5\n5 6 2 10 10\n1 2 7\n2 4\n1 1 10\n2 8\n1 3 4\n", "5 6\n1 2 3 ...
737
411
coding
Solve the programming task below in a Python markdown code block. Karan's mathematics professor has given him a lots of homework. Since he is busy preparing for September Easy Challenge, he needs your help. Given two numbers, find the sum of prime numbers between them, both inclusive. Input: The first line contains...
{"inputs": ["13\n1 99999\n10000 99999\n1 2\n1 1\n2 2\n1 6\n1579 2345\n2349 87324\n12345 23789\n12345 67890\n1 99999\n1 99999\n1 99999"], "outputs": ["454396537\n448660141\n2\n0\n2\n10\n193665\n349887984\n21106440\n208424627\n454396537\n454396537\n454396537\n"]}
129
212
coding
Solve the programming task below in a Python markdown code block. Rudolf is on his way to the castle. Before getting into the castle, the security staff asked him a question: Given two binary numbers $a$ and $b$ of length $n$. How many different ways of swapping two digits in $a$ (only in $a$, not $b$) so that bitwise...
{"inputs": ["2\n00\n00\n", "2\n00\n11\n", "2\n00\n11\n", "2\n00\n00\n", "5\n01011\n11001\n", "5\n01011\n11011\n", "5\n01011\n10011\n", "5\n11001\n10111\n"], "outputs": ["0\n", "0\n", "0\n", "0\n", "4\n", "3\n", "4\n", "2\n"]}
516
142
coding
Solve the programming task below in a Python markdown code block. You all know the Dirichlet principle, the point of which is that if n boxes have no less than n + 1 items, that leads to the existence of a box in which there are at least two items. Having heard of that principle, but having not mastered the technique ...
{"inputs": ["2 2 5\n", "5 1 7\n", "1 5 2\n", "1 1 2\n", "1 1 3\n", "1 5 4\n", "1 2 3\n", "3 1 5\n"], "outputs": ["Stas\n\n", "Masha\n\n", "Missing\n\n", "Missing\n\n", "Masha\n\n", "Missing\n", "Missing\n", "Masha\n"]}
435
111
coding
Solve the programming task below in a Python markdown code block. We all know the impressive story of Robin Hood. Robin Hood uses his archery skills and his wits to steal the money from rich, and return it to the poor. There are n citizens in Kekoland, each person has ci coins. Each day, Robin Hood will take exactly 1...
{"inputs": ["3 4\n1 2 7\n", "2 0\n182 2\n", "3 8\n1 2 7\n", "3 1\n2 2 2\n", "4 0\n1 4 4 4\n", "4 0\n1 4 4 7\n", "4 0\n1 4 5 7\n", "4 1\n1 1 4 2\n"], "outputs": ["1\n", "180\n", "1\n", "0\n", "3\n", "6\n", "6\n", "2\n"]}
465
144
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. You are given two 0-indexed integer arrays jobs and workers of equal length, where jobs[i] is the amount of time needed to complete the ith job, and workers[j] is the amount of time the jth worker can work each day. E...
{"functional": "def check(candidate):\n assert candidate(jobs = [5,2,4], workers = [1,7,5]) == 2\n assert candidate(jobs = [3,18,15,9], workers = [6,5,1,3]) == 3\n\n\ncheck(Solution().minimumTime)"}
138
77
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. You are given a string s. You can convert s to a palindrome by adding characters in front of it. Return the shortest palindrome you can find by performing this transformation.   Please complete the following python co...
{"functional": "def check(candidate):\n assert candidate(s = \"aacecaaa\") == \"aaacecaaa\"\n assert candidate(s = \"abcd\") == \"dcbabcd\"\n\n\ncheck(Solution().shortestPalindrome)"}
81
54
coding
Solve the programming task below in a Python markdown code block. Chef has a string S of length N, consisting of +, -, and 0, where + denotes a source of positive charge, - denotes a source of negative charge, and 0 denotes a neutral object. Each second, the charge sources emit their respective charge to their immedia...
{"inputs": ["4\n2\n00\n3\n-+0\n6\n00+-00\n8\n0-0+000-\n"], "outputs": ["2\n0\n0\n2\n"]}
734
50
coding
Solve the programming task below in a Python markdown code block. One day shooshuns found a sequence of n integers, written on a blackboard. The shooshuns can perform one operation with it, the operation consists of two steps: 1. Find the number that goes k-th in the current sequence and add the same number to the e...
{"inputs": ["1 1\n1\n", "2 1\n1 1\n", "2 1\n2 1\n", "2 1\n1 2\n", "3 2\n3 1 0\n", "3 2\n2 1 0\n", "3 2\n3 1 1\n", "3 1\n3 1 1\n"], "outputs": ["0\n", "0\n", "-1\n", "-1\n", "-1\n", "-1\n", "1\n", "-1\n"]}
333
124
coding
Solve the programming task below in a Python markdown code block. Dazzler has a task for you. Given two positive integers A and B, find two positive integers i and j such that: [gcd](i,j) > 1; A ≤ i < j ≤ B; The value (i + j) is minimum possible. If there are multiple solutions, you may print any of them. If no such...
{"inputs": ["2\n2 3\n2 10\n"], "outputs": ["-1\n2 4\n"]}
330
28
coding
Solve the programming task below in a Python markdown code block. Let $f(i)$ denote the minimum positive integer $x$ such that $x$ is not a divisor of $i$. Compute $\sum_{i=1}^n f(i)$ modulo $10^9+7$. In other words, compute $f(1)+f(2)+\dots+f(n)$ modulo $10^9+7$. -----Input----- The first line contains a single in...
{"inputs": ["1\n75137\n", "1\n46880\n", "1\n25013\n", "1\n30498\n", "1\n44931\n", "1\n25621\n", "1\n41771\n", "1\n60060\n"], "outputs": ["209458\n", "130685\n", "69722\n", "85019\n", "125250\n", "71422\n", "116442\n", "167431\n"]}
516
155
coding
Solve the programming task below in a Python markdown code block. Tonmoy has a special torch. The torch has 4 levels numbered 1 to 4 and 2 states (\texttt{On} and \texttt{Off}). Levels 1, 2, and 3 correspond to the \texttt{On} state while level 4 corresponds to the \texttt{Off} state. The levels of the torch can be c...
{"inputs": ["3\n4 0\n0 1\n3 1"], "outputs": ["Off\nOn\nAmbiguous"]}
633
29
coding
Solve the programming task below in a Python markdown code block. «Polygon» is a system which allows to create programming tasks in a simple and professional way. When you add a test to the problem, the corresponding form asks you for the test index. As in most cases it is clear which index the next test will have, the...
{"inputs": ["1\n3\n", "1\n1\n", "1\n2\n", "1\n4\n", "1\n5\n", "1\n9\n", "1\n6\n", "1\n7\n"], "outputs": ["1\n", "2\n", "1\n", "1\n", "1\n", "1\n", "1\n", "1\n"]}
214
86
coding
Solve the programming task below in a Python markdown code block. Given N points of the form (x_{i}, y_{i}) on a 2-D plane. From each point, you draw 2 lines one horizontal and one vertical. Now some of the lines may overlap each other, therefore you are required to print the number of distinct lines you can see on th...
{"inputs": ["3\n4\n1 1\n1 0\n0 1\n0 0\n5\n0 0\n0 1\n0 2\n0 3\n0 4\n1\n10 10"], "outputs": ["4\n6\n2"]}
493
64
coding
Solve the programming task below in a Python markdown code block. M-kun is a student in Aoki High School, where a year is divided into N terms. There is an exam at the end of each term. According to the scores in those exams, a student is given a grade for each term, as follows: * For the first through (K-1)-th terms:...
{"inputs": ["5 3\n96 98 95 000 20", "5 3\n96 98 95 100 20", "3 1\n1001 869120 1001", "3 2\n1011 869120 1001", "5 0\n96 98 162 100 39", "3 2\n0011 869120 1001", "3 0\n1101 681697 1001", "3 2\n1001 869120 1001"], "outputs": ["No\nNo\n", "Yes\nNo", "Yes\nNo\n", "No\n", "No\nNo\nNo\nNo\nNo\n", "Yes\n", "No\nNo\nNo\n", "No"...
426
228
coding
Solve the programming task below in a Python markdown code block. Shell Sort Shell Sort is a generalization of Insertion Sort to arrange a list of $n$ elements $A$. 1 insertionSort(A, n, g) 2 for i = g to n-1 3 v = A[i] 4 j = i - g 5 while j >= 0 && A[j] > v 6 A[j+g] = A...
{"inputs": ["3\n6\n2\n1", "3\n0\n2\n1", "3\n0\n2\n0", "3\n0\n1\n0", "3\n1\n1\n0", "3\n1\n8\n0", "3\n1\n8\n1", "3\n1\n1\n1"], "outputs": ["1\n1\n3\n1\n2\n6\n", "1\n1\n1\n0\n1\n2\n", "1\n1\n1\n0\n0\n2\n", "1\n1\n1\n0\n0\n1\n", "1\n1\n2\n0\n1\n1\n", "1\n1\n2\n0\n1\n8\n", "1\n1\n1\n1\n1\n8\n", "1\n1\n0\n1\n1\n1\n"]}
595
190
coding
Solve the programming task below in a Python markdown code block. There are N people (with different names) and K clubs. For each club you know the list of members (so you have K unordered lists). Each person can be a member of many clubs (and also 0 clubs) and two different clubs might have exactly the same members. T...
{"inputs": ["5", "9", "7", "8", "6", "2", "4", "3"], "outputs": ["4\n", "334\n", "336\n", "384\n", "1\n", "1", "7", "1"]}
628
65
coding
Solve the programming task below in a Python markdown code block. We all love the future president (or Führer or duce or sōtō as he could find them more fitting) donald trump, but we might fear that some of his many fans like John Miller or John Barron are not making him justice, sounding too much like their (and our a...
{"functional": "_inputs = [['I will build a huge wall'], ['HUUUUUGEEEE WAAAAAALL'], ['MEXICAAAAAAAANS GOOOO HOOOMEEEE'], ['America NUUUUUKEEEE Oooobaaaamaaaaa'], ['listen migrants: IIII KIIIDD YOOOUUU NOOOOOOTTT']]\n_outputs = [[0], [4], [2.5], [1.89], [1.56]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinsta...
438
239
coding
Solve the programming task below in a Python markdown code block. There are N cities and N directed roads in Steven's world. The cities are numbered from 0 to N - 1. Steven can travel from city i to city (i + 1) % N, ( 0-> 1 -> 2 -> .... -> N - 1 -> 0). Steven wants to travel around the world by car. The capacity of ...
{"inputs": ["3 3\n3 1 2\n2 2 2\n"], "outputs": ["2\n"]}
588
28
coding
Solve the programming task below in a Python markdown code block. You are given an integer N. Can you find the least positive integer X made up of only 9's and 0's, such that, X is a multiple of N? Update X is made up of one or more occurences of 9 and zero or more occurences of 0. Input Format The first line c...
{"inputs": ["3\n5\n7\n1\n"], "outputs": ["90\n9009\n9\n"]}
234
28
coding
Solve the programming task below in a Python markdown code block. In this Kata you are a builder and you are assigned a job of building a wall with a specific size (God knows why...). Create a function called `build_a_wall` (or `buildAWall` in JavaScript) that takes `x` and `y` as integer arguments (which represent th...
{"functional": "_inputs = [[4, 5], [10, 7], ['eight', [3]], [12, -4], [0, 9], [123, 987]]\n_outputs = [['\u25a0|\u25a0\u25a0|\u25a0\u25a0|\u25a0\u25a0|\u25a0\u25a0|\u25a0\\n\u25a0\u25a0|\u25a0\u25a0|\u25a0\u25a0|\u25a0\u25a0|\u25a0\u25a0\\n\u25a0|\u25a0\u25a0|\u25a0\u25a0|\u25a0\u25a0|\u25a0\u25a0|\u25a0\\n\u25a0\u25a0...
764
1,227
coding
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 #23 There is a certain multiplayer game where players are assessed at the end of the game for merit. Players are ranked according to an internal scoring system that ...
{"functional": "_inputs = [[[]]]\n_outputs = [[[]]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return math.isclose(a, b, rel_tol=tol, abs_tol=tol)\n if isinstance(a, (list, tuple)):\n if len(a) != len(b): return False\n return all(_deep_eq...
359
154
coding
Solve the programming task below in a Python markdown code block. It's finally summer in Chefland! So our chef is looking forward to prepare some of the best "beat-the-heat" dishes to attract more customers. He summons the Wizard of Dessert to help him with one such dish. The wizard provides the chef with a sequence of...
{"inputs": ["2\n5\n2 0 3 0 5\n4\n1 1 0 0", "2\n5\n2 0 3 0 5\n4\n0 1 0 0", "2\n5\n1 2 3 4 5\n4\n1 1 0 -1", "2\n5\n1 2 3 6 5\n4\n1 1 0 -1", "2\n5\n1 2 3 6 5\n4\n1 1 0 -2", "2\n5\n1 2 3 6 6\n4\n1 1 0 -1", "2\n5\n1 2 3 6 5\n4\n1 1 0 -3", "2\n5\n1 2 3 6 8\n4\n1 1 0 -1"], "outputs": ["8\n2\n", "8\n1\n", "13\n3\n", "15\n3\n",...
611
260
coding
Solve the programming task below in a Python markdown code block. There is a very long bench. The bench is divided into M sections, where M is a very large integer. Initially, the bench is vacant. Then, M people come to the bench one by one, and perform the following action: * We call a section comfortable if the sec...
{"inputs": ["1\nX", "3\n---", "5\n-X--X", "5\n-X-X-", "5\nX-X--", "5\n-XX--", "5\n---XX", "5\n--XX-"], "outputs": ["500000004 0 500000003", "0 0 0", "0 0 1\n", "500000004 0 500000002\n", "0 0 666666672\n", "0 0 0\n", "0 0 0\n", "0 0 0\n"]}
632
158
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. You are given a 2D array of strings equations and an array of real numbers values, where equations[i] = [Ai, Bi] and values[i] means that Ai / Bi = values[i]. Determine if there exists a contradiction in the equations...
{"functional": "def check(candidate):\n assert candidate(equations = [[\"a\",\"b\"],[\"b\",\"c\"],[\"a\",\"c\"]], values = [3,0.5,1.5]) == False\n assert candidate(equations = [[\"le\",\"et\"],[\"le\",\"code\"],[\"code\",\"et\"]], values = [2,5,0.5]) == True\n\n\ncheck(Solution().checkContradictions)"}
171
103
coding
Solve the programming task below in a Python markdown code block. Write a function that takes one or more arrays and returns a new array of unique values in the order of the original provided arrays. In other words, all values present from all arrays should be included in their original order, but with no duplicates i...
{"functional": "_inputs = [[[1, 2], [3, 4]], [[1, 3, 2], [5, 2, 1, 4], [2, 1]], [[4, 3, 2, 2]], [[4, 'a', 2], []], [[], [4, 'a', 2]], [[], [4, 'a', 2], []], [[]], [[], []], [[], [1, 2]], [[], [1, 2, 1, 2], [2, 1, 1, 2, 1]]]\n_outputs = [[[1, 2, 3, 4]], [[1, 3, 2, 5, 4]], [[4, 3, 2]], [[4, 'a', 2]], [[4, 'a', 2]], [[4, ...
173
357
coding
Solve the programming task below in a Python markdown code block. ChthollyNotaSeniorious received a special gift from AquaMoon: $n$ binary arrays of length $m$. AquaMoon tells him that in one operation, he can choose any two arrays and any position $pos$ from $1$ to $m$, and swap the elements at positions $pos$ in thes...
{"inputs": ["3\n3 4\n1 1 1 0\n0 0 1 0\n1 0 0 1\n4 3\n1 0 0\n0 1 1\n0 0 1\n0 0 0\n2 2\n0 0\n0 1\n"], "outputs": ["1\n2 1 1\n1\n4 2 2\n-1\n"]}
686
99
coding
Solve the programming task below in a Python markdown code block. re.findall() The expression re.findall() returns all the non-overlapping matches of patterns in a string as a list of strings. Code >>> import re >>> re.findall(r'\w','http://www.hackerrank.com/') ['h', 't', 't', 'p', 'w', 'w', 'w', 'h', 'a', 'c', 'k...
{"inputs": ["rabcdeefgyYhFjkIoomnpOeorteeeeet\n"], "outputs": ["ee\nIoo\nOeo\neeeee\n"]}
587
39
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. An additive number is a string whose digits can form an additive sequence. A valid additive sequence should contain at least three numbers. Except for the first two numbers, each subsequent number in the sequence must...
{"functional": "def check(candidate):\n assert candidate(\"112358\") == True \n assert candidate(\"199100199\") == True \n\n\ncheck(Solution().isAdditiveNumber)"}
151
54
coding
Solve the programming task below in a Python markdown code block. Task ====== Make a custom esolang interpreter for the language [InfiniTick](https://esolangs.org/wiki/InfiniTick). InfiniTick is a descendant of [Tick](https://esolangs.org/wiki/tick) but also very different. Unlike Tick, InfiniTick has 8 commands inste...
{"functional": "_inputs = [['\\\\h*&'], ['+-*&']]\n_outputs = [['\\x00'], ['\\x00']]\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 F...
466
169
coding
Solve the programming task below in a Python markdown code block. There are N squares lining up in a row, numbered 1 through N from left to right. Initially, all squares are white. We also have N-1 painting machines, numbered 1 through N-1. When operated, Machine i paints Square i and i+1 black. Snuke will operate the...
{"inputs": ["3", "6", "9", "8", "7", "2", "4", "5"], "outputs": ["4\n", "516\n", "275040\n", "30096\n", "3696\n", "1", "16", "84"]}
321
75
coding
Solve the programming task below in a Python markdown code block. There are N integers X_1, X_2, \cdots, X_N, and we know that A_i \leq X_i \leq B_i. Find the number of different values that the median of X_1, X_2, \cdots, X_N can take. -----Notes----- The median of X_1, X_2, \cdots, X_N is defined as follows. Let x_1...
{"inputs": ["2\n1 2\n2 4", "2\n1 1\n2 4", "2\n1 1\n1 7", "2\n0 1\n1 7", "2\n0 1\n0 7", "2\n0 1\n0 8", "2\n1 2\n0 0", "2\n0 2\n6 0"], "outputs": ["4\n", "3\n", "7\n", "8\n", "9\n", "10\n", "2\n", "-3\n"]}
425
127