task_type
stringclasses
1 value
problem
stringlengths
333
3.04k
answer
stringlengths
38
3.95k
problem_tokens
int64
69
769
answer_tokens
int64
14
1.46k
coding
Solve the programming task below in a Python markdown code block. Consider the range `0` to `10`. The primes in this range are: `2, 3, 5, 7`, and thus the prime pairs are: `(2,2), (2,3), (2,5), (2,7), (3,3), (3,5), (3,7),(5,5), (5,7), (7,7)`. Let's take one pair `(2,7)` as an example and get the product, then sum the ...
{"functional": "_inputs = [[0, 20], [2, 200], [2, 2000], [1000, 3000], [2000, 5000]]\n_outputs = [[14], [457], [17705], [12801], [25005]]\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, (...
473
226
coding
Solve the programming task below in a Python markdown code block. Read problems statements in Mandarin Chinese here ------ Problem Statement ------ As we know, Fibonacci Number is defined as F_{n}=n if n ≀ 1 F_{n}=F_{n-1}+F_{n-2}, otherwise Now this problem is quite simple: you are given one prime number P a...
{"inputs": ["4\n0 11\n16 19\n18 19\n4 19"], "outputs": ["0\n14\n16\n-1"]}
436
43
coding
Solve the programming task below in a Python markdown code block. Bessie is out grazing on the farm, which consists of $n$ fields connected by $m$ bidirectional roads. She is currently at field $1$, and will return to her home at field $n$ at the end of the day. The Cowfederation of Barns has ordered Farmer John to in...
{"inputs": ["2 1 2\n1 2\n1 2\n", "2 1 2\n1 2\n1 2\n", "4 3 2\n3 4\n1 2\n2 3\n1 4\n", "4 3 2\n3 4\n1 2\n2 3\n1 4\n", "5 4 2\n2 4\n1 2\n2 3\n3 4\n4 5\n", "5 4 2\n3 4\n2 1\n2 3\n1 4\n4 5\n", "5 4 2\n4 5\n1 2\n2 3\n3 4\n1 5\n", "5 4 2\n3 4\n2 1\n2 3\n1 4\n4 5\n"], "outputs": ["1\n", "1\n", "1\n", "1\n", "3\n", "2\n", "1\n"...
612
230
coding
Solve the programming task below in a Python markdown code block. Write a program which calculates the area and perimeter of a given rectangle. Constraints * 1 ≀ a, b ≀ 100 Input The length a and breadth b of the rectangle are given in a line separated by a single space. Output Print the area and perimeter of the...
{"inputs": ["0 5", "1 5", "1 3", "0 3", "0 1", "0 2", "0 4", "1 4"], "outputs": ["0 10\n", "5 12\n", "3 8\n", "0 6\n", "0 2\n", "0 4\n", "0 8\n", "4 10\n"]}
104
97
coding
Solve the programming task below in a Python markdown code block. Takahashi has many red balls and blue balls. Now, he will place them in a row. Initially, there is no ball placed. Takahashi, who is very patient, will do the following operation 10^{100} times: - Place A blue balls at the end of the row of balls alread...
{"inputs": ["8 0 1", "8 3 7", "8 1 1", "8 1 7", "8 1 5", "6 1 0", "8 1 0", "6 2 3"], "outputs": ["0\n", "3\n", "4\n", "1\n", "2\n", "6\n", "8\n", "3\n"]}
266
94
coding
Solve the programming task below in a Python markdown code block. Lets define G(x, {A_{1}, A_{2}, A_{3}, ..., A_{x}}) as a game played by 2 players in which we have x piles of stones with ith pile having A_{i} stones. Player 1 moves first. The players move alternatively. In a move a player can select a single non empty...
{"inputs": ["6\n1 1 2 3 3 2"], "outputs": ["1"]}
642
24
coding
Solve the programming task below in a Python markdown code block. You are given a string s of length 8 consisting solely of '0's and '1's. Assume that the characters of the string are written in a circular fashion. You need to find the number of 0-1 or 1-0 transitions that one has to make while making a single traversa...
{"inputs": ["4\n00000000\n10101010\n10000001\n10010011"], "outputs": ["uniform\nnon-uniform\nuniform\nnon-uniform"]}
338
58
coding
Solve the programming task below in a Python markdown code block. DropCaps means that the first letter of the starting word of the paragraph should be in caps and the remaining lowercase, just like you see in the newspaper. But for a change, let's do that for each and every word of the given String. Your task is to c...
{"functional": "_inputs = [['Apple Banana'], ['Apple'], [''], ['of'], ['Revelation of the contents outraged American public opinion, and helped generate'], ['more than one space between words'], [' leading spaces'], ['trailing spaces '], ['ALL CAPS CRAZINESS'], ['rAnDoM CaPs CrAzInEsS']]\n_outputs = [['Apple Ban...
201
286
coding
Solve the programming task below in a Python markdown code block. An isogram is a word that has no repeating letters, consecutive or non-consecutive. Implement a function that determines whether a string that contains only letters is an isogram. Assume the empty string is an isogram. Ignore letter case. ```python is_i...
{"functional": "_inputs = [['Dermatoglyphics'], ['isogram'], ['moose'], ['isIsogram'], ['aba'], ['moOse'], ['thumbscrewjapingly'], ['abcdefghijklmnopqrstuvwxyz'], ['abcdefghijklmnopqrstuwwxyz'], ['']]\n_outputs = [[True], [True], [False], [False], [False], [False], [True], [True], [False], [True]]\nimport math\ndef _de...
178
227
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. Alice just invited Bob to come over for dinner at her place. Bob is not dressed properly and he does not wish to take any chances, so he wants to rus...
{"inputs": ["2\n3 1 5 2\n6 7 8\n1 1 2 1000000000\n1000000000"], "outputs": ["8\n2999999997"]}
560
65
coding
Solve the programming task below in a Python markdown code block. Two players play a game. The game is played on a rectangular board with n Γ— m squares. At the beginning of the game two different squares of the board have two chips. The first player's goal is to shift the chips to the same square. The second player aim...
{"inputs": ["5 4 1 1 5 4\n", "1 2 1 1 1 2\n", "5 5 1 1 5 5\n", "5 5 1 1 5 3\n", "3 5 1 1 3 5\n", "5 4 1 4 5 1\n", "5 5 1 1 4 5\n", "4 4 1 4 4 1\n"], "outputs": ["Second\n", "First\n", "Second\n", "First\n", "First\n", "Second\n", "Second\n", "First\n"]}
606
150
coding
Solve the programming task below in a Python markdown code block. Raju has created a program to find the square root of a number. But his program can store only integers. Being a newbie, he didn't know about rounding the numbers. Hence his program returns the absolute value of the result if possible. For example, sqrt(...
{"inputs": ["2 20\n5\n3"], "outputs": ["yes\nno"]}
479
21
coding
Solve the programming task below in a Python markdown code block. Ignoring the air resistance, velocity of a freely falling object $v$ after $t$ seconds and its drop $y$ in $t$ seconds are represented by the following formulas: $ v = 9.8 t $ $ y = 4.9 t^2 $ A person is trying to drop down a glass ball and check whet...
{"inputs": ["25.4\n25.4", "26.000450676027395\n25.4", "26.601491934975797\n25.4", "44.72115406668142\n44.101745823639", "38.4955310270825\n37.15642943049945", "60.63345250628777\n63.4141206664841", "73.9111092448129\n75.52007039121814", "35.31260445827307\n34.47301494550142"], "outputs": ["8\n8", "8\n8\n", "9\n8\n", "2...
262
304
coding
Solve the programming task below in a Python markdown code block. Qwerty the Ranger took up a government job and arrived on planet Mars. He should stay in the secret lab and conduct some experiments on bacteria that have funny and abnormal properties. The job isn't difficult, but the salary is high. At the beginning o...
{"inputs": ["2 2 5 4\n", "1 4 1 5\n", "1 1 1 1\n", "1 1 2 2\n", "2 3 4 5\n", "3 1 3 1\n", "5 4 1 4\n", "5 5 2 1\n"], "outputs": ["4\n", "0\n", "1\n", "1\n", "3\n", "3\n", "1\n", "2\n"]}
390
118
coding
Solve the programming task below in a Python markdown code block. Jem is famous for his laziness at school. He always leaves things to last minute. Now Jem has N problems in the assignment of "Advanced topics in algorithm" class to solved. The assignment is due tomorrow and as you may guess he hasn't touch any of the p...
{"inputs": ["2\n9 1 2\n123456 123456 123456"], "outputs": ["45\n131351258112"]}
610
53
coding
Solve the programming task below in a Python markdown code block. # Exclusive "or" (xor) Logical Operator ## Overview In some scripting languages like PHP, there exists a logical operator (e.g. ```&&```, ```||```, ```and```, ```or```, etc.) called the "Exclusive Or" (hence the name of this Kata). The exclusive or ev...
{"functional": "_inputs = [[False, False], [True, False], [False, True], [True, True]]\n_outputs = [[False], [True], [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(a, (list...
211
180
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. There is a directed graph of n colored nodes and m edges. The nodes are numbered from 0 to n - 1. You are given a string colors where colors[i] is a lowercase English letter representing the color of the ith node in t...
{"functional": "def check(candidate):\n assert candidate(colors = \"abaca\", edges = [[0,1],[0,2],[2,3],[3,4]]) == 3\n assert candidate(colors = \"a\", edges = [[0,0]]) == -1\n\n\ncheck(Solution().largestPathValue)"}
237
72
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. There is a long and thin painting that can be represented by a number line. The painting was painted with multiple overlapping segments where each segment was painted with a unique color. You are given a 2D integer ar...
{"functional": "def check(candidate):\n assert candidate(segments = [[1,4,5],[4,7,7],[1,7,9]]) == [[1,4,14],[4,7,16]]\n assert candidate(segments = [[1,7,9],[6,8,15],[8,10,7]]) == [[1,6,9],[6,7,24],[7,8,15],[8,10,7]]\n assert candidate(segments = [[1,4,5],[1,4,7],[4,7,1],[4,7,11]]) == [[1,4,12],[4,7,12]]\n\n\n...
448
171
coding
Solve the programming task below in a Python markdown code block. You are given positive integer number n. You should create such strictly increasing sequence of k positive numbers a_1, a_2, ..., a_{k}, that their sum is equal to n and greatest common divisor is maximal. Greatest common divisor of sequence is maximum ...
{"inputs": ["6 3\n", "8 2\n", "5 3\n", "1 1\n", "1 2\n", "2 1\n", "5 1\n", "6 2\n"], "outputs": ["1 2 3\n", "2 6\n", "-1\n", "1\n", "-1\n", "2\n", "5\n", "2 4\n"]}
188
94
coding
Solve the programming task below in a Python markdown code block. Given an array of integer $a_1, a_2, \ldots, a_n$. In one operation you can make $a_i := a_i + 1$ if $i < n$ and $a_i \leq a_{i + 1}$, or $i = n$ and $a_i \leq a_1$. You need to check whether the array $a_1, a_2, \ldots, a_n$ can become equal to the arr...
{"inputs": ["1\n5\n4 4 4 4 4\n3 3 3 3 3\n", "1\n2\n10 10\n1000000 1000000\n", "1\n2\n1 1\n1000000000 1000000000\n", "1\n4\n1 1 1 1\n40000000 40000000 40000000 40000000\n", "5\n3\n1 2 5\n1 2 5\n2\n2 2\n1 3\n4\n3 4 1 2\n6 4 2 5\n3\n2 4 1\n4 5 3\n5\n1 2 3 4 5\n6 5 6 7 6\n"], "outputs": ["NO\n", "YES\n", "YES\n", "YES\n", ...
711
252
coding
Solve the programming task below in a Python markdown code block. There's a **"3 for 2"** (or **"2+1"** if you like) offer on mangoes. For a given quantity and price (per mango), calculate the total cost of the mangoes. ### Examples ```python mango(3, 3) ==> 6 # 2 mangoes for 3 = 6; +1 mango for free mango(9, 5) ==...
{"functional": "_inputs = [[3, 3], [9, 5]]\n_outputs = [[6], [30]]\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 retu...
154
167
coding
Solve the programming task below in a Python markdown code block. Polycarpus is sure that his life fits the description: "first there is a white stripe, then a black one, then a white one again". So, Polycarpus is sure that this rule is going to fulfill during the next n days. Polycarpus knows that he is in for w good ...
{"inputs": ["3 3 1\n", "4 2 3\n", "4 3 2\n", "3 3 3\n", "4 4 2\n", "3 4 1\n", "4 4 4\n", "3 5 1\n"], "outputs": ["12\n", "24\n", "48\n", "72\n", " 432", " 72", " ...
628
118
coding
Solve the programming task below in a Python markdown code block. Marc loves cupcakes, but he also likes to stay fit. Each cupcake has a calorie count, and Marc can walk a distance to expend those calories. If Marc has eaten $j$ cupcakes so far, after eating a cupcake with $\textbf{C}$ calories he must walk at least $...
{"inputs": ["3\n1 3 2\n", "4\n7 4 9 6\n"], "outputs": ["11\n", "79\n"]}
632
38
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. You are given two strings of the same length s1 and s2 and a string baseStr. We say s1[i] and s2[i] are equivalent characters. For example, if s1 = "abc" and s2 = "cde", then we have 'a' == 'c', 'b' == 'd', and 'c' =...
{"functional": "def check(candidate):\n assert candidate(s1 = \"parker\", s2 = \"morris\", baseStr = \"parser\") == \"makkek\"\n assert candidate(s1 = \"hello\", s2 = \"world\", baseStr = \"hold\") == \"hdld\"\n assert candidate(s1 = \"leetcode\", s2 = \"programs\", baseStr = \"sourcecode\") == \"aauaaaaada\"\...
283
107
coding
Solve the programming task below in a Python markdown code block. # Task You are given a `moment` in time and space. What you must do is break it down into time and space, to determine if that moment is from the past, present or future. `Time` is the sum of characters that increase time (i.e. numbers in range ['1'.....
{"functional": "_inputs = [['12:30 am'], ['12:02 pm'], ['01:00 pm'], ['11:12 am'], ['05:20 pm'], ['04:20 am']]\n_outputs = [[[False, False, True]], [[False, True, False]], [[True, False, False]], [[False, False, True]], [[False, False, True]], [[False, True, False]]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if ...
451
241
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. You are given two strings s and t of equal length n. You can perform the following operation on the string s: Remove a suffix of s of length l where 0 < l < n and append it at the start of s. For example, let s = 'a...
{"functional": "def check(candidate):\n assert candidate(s = \"abcd\", t = \"cdab\", k = 2) == 2\n assert candidate(s = \"ababab\", t = \"ababab\", k = 1) == 2\n\n\ncheck(Solution().numberOfWays)"}
184
69
coding
Solve the programming task below in a Python markdown code block. MoEngage helps the Chef send email reminders about rated contests to the participants. There are a total of N participants on Chef’s platform, and U of them have told Chef not to send emails to them. If so, how many participants should MoEngage send th...
{"inputs": ["100 7", "4456 342"], "outputs": ["93", "4114"]}
298
33
coding
Solve the programming task below in a Python markdown code block. You are a rebel leader and you are planning to start a revolution in your country. But the evil Government found out about your plans and set your punishment in the form of correctional labor. You must paint a fence which consists of $10^{100}$ planks i...
{"inputs": ["1\n99999 100001 2\n", "1\n99999 100001 2\n", "1\n99999 100001 1\n", "1\n99999 100000 2\n", "1\n99999 100000 0\n", "1\n99999 100000 1\n", "1\n12 73 200000000\n", "1\n12 73 200000000\n"], "outputs": ["REBEL\n", "REBEL\n", "REBEL\n", "OBEY\n", "REBEL\n", "REBEL\n", "OBEY\n", "OBEY\n"]}
520
203
coding
Solve the programming task below in a Python markdown code block. You are given a positive integer $x$. Check whether the number $x$ is representable as the sum of the cubes of two positive integers. Formally, you need to check if there are two integers $a$ and $b$ ($1 \le a, b$) such that $a^3+b^3=x$. For example, i...
{"inputs": ["1\n999999999999\n", "1\n999999999999\n", "1\n1000000000000\n", "1\n1000000000000\n", "2\n405527623378\n5204291237\n", "2\n620475187705\n5204291237\n", "2\n620475187705\n5369629849\n", "2\n392481106372\n5369629849\n"], "outputs": ["NO\n", "NO\n", "NO\n", "NO\n", "NO\nNO\n", "NO\nNO\n", "NO\nNO\n", "NO\nNO\n...
521
228
coding
Solve the programming task below in a Python markdown code block. Given are a sequence of N positive integers A_1, A_2, \ldots, A_N, and a positive integer K. Find the number of non-empty contiguous subsequences in A such that the remainder when dividing the sum of its elements by K is equal to the number of its elemen...
{"inputs": ["5 1\n1 4 2 3 5", "5 8\n1 4 2 3 5", "5 1\n1 4 2 4 5", "0 1\n1 4 2 4 5", "0 1\n1 4 2 6 5", "0 1\n1 0 2 6 5", "0 1\n0 0 2 6 5", "0 1\n0 0 2 6 3"], "outputs": ["0\n", "1\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n"]}
252
158
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. Assume you are an awesome parent and want to give your children some cookies. But, you should give each child at most one cookie. Each child i has a greed factor g[i], which is the minimum size of a cookie that the ch...
{"functional": "def check(candidate):\n assert candidate(g = [1,2,3], s = [1,1]) == 1\n assert candidate(g = [1,2], s = [1,2,3]) == 2\n\n\ncheck(Solution().findContentChildren)"}
162
66
coding
Solve the programming task below in a Python markdown code block. You have a fraction $\frac{a}{b}$. You need to find the first occurrence of digit c into decimal notation of the fraction after decimal point. -----Input----- The first contains three single positive integers a, b, c (1 ≀ a < b ≀ 10^5, 0 ≀ c ≀ 9). -...
{"inputs": ["1 2 0\n", "2 3 7\n", "1 7 7\n", "1 9 0\n", "1 3 0\n", "2 3 0\n", "1 2 5\n", "1 7 0\n"], "outputs": ["2", "-1", "6", "-1", "-1", "-1", "1", "-1"]}
230
94
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. You are given an integer n. A perfectly straight street is represented by a number line ranging from 0 to n - 1. You are given a 2D integer array lights representing the street lamp(s) on the street. Each lights[i] = ...
{"functional": "def check(candidate):\n assert candidate(n = 5, lights = [[0,1],[2,1],[3,2]], requirement = [0,2,1,4,1]) == 4\n assert candidate(n = 1, lights = [[0,1]], requirement = [2]) == 0\n\n\ncheck(Solution().meetRequirement)"}
238
83
coding
Solve the programming task below in a Python markdown code block. Suppose I have two vectors: `(a1, a2, a3, ..., aN)` and `(b1, b2, b3, ..., bN)`. The dot product between these two vectors is defined as: ``` a1*b1 + a2*b2 + a3*b3 + ... + aN*bN ``` The vectors are classified as orthogonal if the dot product equals zer...
{"functional": "_inputs = [[[1, 2], [2, 1]], [[1, -2], [2, 1]], [[7, 8], [7, -6]], [[-13, -26], [-8, 4]], [[1, 2, 3], [0, -3, 2]], [[3, 4, 5], [6, 7, -8]], [[3, -4, -5], [-4, -3, 0]], [[1, -2, 3, -4], [-4, 3, 2, -1]], [[2, 4, 5, 6, 7], [-14, -12, 0, 8, 4]], [[5, 10, 1, 20, 2], [-2, -20, -1, 10, 5]]]\n_outputs = [[False...
234
375
coding
Solve the programming task below in a Python markdown code block. In a country called Chef Land, there was a lot of monetary fraud, so Chefu, the head of the country, decided to choose new denominations of the local currency ― all even-valued coins up to an integer $N$ should exist. After a few days, a citizen complain...
{"inputs": ["4\n2 2\n1 14\n30 10\n31 4"], "outputs": ["1\n1\n3\n9"]}
439
38
coding
Solve the programming task below in a Python markdown code block. You are given $n$ integers $w_i (i = 0, 1, ..., n-1)$ to be sorted in ascending order. You can swap two integers $w_i$ and $w_j$. Each swap operation has a cost, which is the sum of the two integers $w_i + w_j$. You can perform the operations any number ...
{"inputs": ["4\n8 3 2 1", "4\n3 5 2 1", "4\n4 0 2 1", "4\n0 3 2 1", "4\n4 5 2 1", "4\n6 5 2 1", "4\n4 3 1 2", "4\n6 7 2 1"], "outputs": ["14\n", "13\n", "5\n", "4\n", "14\n", "14\n", "12\n", "18\n"]}
247
132
coding
Solve the programming task below in a Python markdown code block. If the first day of the month is a Friday, it is likely that the month will have an `Extended Weekend`. That is, it could have five Fridays, five Saturdays and five Sundays. In this Kata, you will be given a start year and an end year. Your task will b...
{"functional": "_inputs = [[2016, 2020], [1900, 1950], [1800, 2500]]\n_outputs = [[['Jan', 'May', 5]], [['Mar', 'Dec', 51]], [['Aug', 'Oct', 702]]]\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...
280
215
coding
Solve the programming task below in a Python markdown code block. In this Kata, you will check if it is possible to convert a string to a palindrome by changing one character. For instance: ```Haskell solve ("abbx") = True, because we can convert 'x' to 'a' and get a palindrome. solve ("abba") = False, because we ca...
{"functional": "_inputs = [['abba'], ['abbaa'], ['abbx'], ['aa'], ['ab'], ['abcba']]\n_outputs = [[False], [True], [True], [False], [True], [True]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return math.isclose(a, b, rel_tol=tol, abs_tol=tol)\n if isins...
189
189
coding
Solve the programming task below in a Python markdown code block. Jack loved his house very much, because his lovely cats take a nap on the wall of his house almost every day. Jack loved cats very much. Jack decided to keep an observation diary of the cats as a free study during the summer vacation. After observing fo...
{"inputs": ["4 6\ns 0 2\ns 1 2\ns 2 1\nw 0\ns 3 3\ns 4 2\n3 3\ns 0 1\ns 1 1\ns 2 1\n0 0", "4 6\ns 0 2\ns 1 3\ns 2 1\nw 0\ns 3 3\ns 4 2\n3 3\ns 0 1\ns 0 1\ns 2 1\n0 0", "4 6\ns 0 2\ns 1 2\ns 2 1\nw 0\ns 3 3\ns 4 2\n4 3\ns 0 1\ns 1 2\ns 2 1\n0 0", "4 6\ns 0 3\ns 1 3\ns 2 1\nw 0\ns 3 3\ns 4 2\n3 3\ns 0 1\ns 1 1\ns 2 1\n0 ...
653
722
coding
Solve the programming task below in a Python markdown code block. The postal code in Atcoder Kingdom is A+B+1 characters long, its (A+1)-th character is a hyphen -, and the other characters are digits from 0 through 9. You are given a string S. Determine whether it follows the postal code format in Atcoder Kingdom. --...
{"inputs": ["0 0\n5", "0 2\n31", "0 0\n31", "0 0\n48", "0 0\n32", "1 0\n32", "1 0\n48", "0 2\n55"], "outputs": ["No\n", "No\n", "No\n", "No\n", "No\n", "No\n", "No\n", "No\n"]}
203
101
coding
Solve the programming task below in a Python markdown code block. Levian works as an accountant in a large company. Levian knows how much the company has earned in each of the n consecutive months β€” in the i-th month the company had income equal to a_i (positive income means profit, negative income means loss, zero inc...
{"inputs": ["2\n0\n0\n", "2\n2\n2\n", "2\n4\n2\n", "2\n2\n0\n", "2\n1\n2\n", "2\n1\n0\n", "2\n0\n1\n", "2\n2\n1\n"], "outputs": ["-1", "2", "2\n", "2\n", "2\n", "2\n", "2\n", "2\n"]}
602
101
coding
Solve the programming task below in a Python markdown code block. Given two arrays of strings, return the number of times each string of the second array appears in the first array. #### Example ```python array1 = ['abc', 'abc', 'xyz', 'cde', 'uvw'] array2 = ['abc', 'cde', 'uap'] ``` How many times do the elements i...
{"functional": "_inputs = [[['abc', 'abc', 'xyz', 'abcd', 'cde'], ['abc', 'cde', 'uap']], [['abc', 'xyz', 'abc', 'xyz', 'cde'], ['abc', 'cde', 'xyz']], [['quick', 'brown', 'fox', 'is', 'quick'], ['quick', 'abc', 'fox']]]\n_outputs = [[[2, 1, 0]], [[2, 1, 2]], [[2, 0, 1]]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n ...
267
254
coding
Solve the programming task below in a Python markdown code block. You've decided to carry out a survey in the theory of prime numbers. Let us remind you that a prime number is a positive integer that has exactly two distinct positive integer divisors. Consider positive integers a, a + 1, ..., b (a ≀ b). You want to fi...
{"inputs": ["2 4 2\n", "1 4 3\n", "5 8 2\n", "1 5 2\n", "6 8 3\n", "1 1 1\n", "1 2 1\n", "1 3 1\n"], "outputs": ["3\n", "-1\n", "4\n", "3\n", "-1\n", "-1\n", "2\n", "2\n"]}
255
102
coding
Solve the programming task below in a Python markdown code block. Chefina has an array A consisting of N positive integers. A permutation subsequence of length M is a subsequence that represents a permutation of length M. Now, Chefina asks Chef to find the count of permutation subsequences in array A. The count can ...
{"inputs": ["2\n5\n1 2 3 2 4\n6\n1 3 5 8 9 8\n"], "outputs": ["7\n1"]}
494
41
coding
Solve the programming task below in a Python markdown code block. Taro's summer vacation starts tomorrow, and he has decided to make plans for it now. The vacation consists of N days. For each i (1 \leq i \leq N), Taro will choose one of the following activities and do it on the i-th day: * A: Swim in the sea. Gain a...
{"inputs": ["1\n110 1 0", "1\n010 3 0", "1\n011 3 1", "1\n001 3 0", "1\n001 4 0", "1\n001 6 0", "1\n000 2 0", "1\n100 16 1"], "outputs": ["110\n", "10\n", "11\n", "3\n", "4\n", "6\n", "2\n", "100\n"]}
365
133
coding
Solve the programming task below in a Python markdown code block. A simple recommendation system would recommend a user things liked by a certain number of their friends. In this problem you will implement part of such a system. You are given user's friends' opinions about a list of items. You are also given a thresho...
{"inputs": ["1 3 1\nYYN\n", "1 3 1\nYYN\n", "3 1 1\nN\nY\nN\n", "3 1 1\nN\nY\nN\n", "2 4 2\nNYNY\nNYNY\n", "2 4 2\nNYNY\nNYNY\n", "2 4 2\nYNNY\nNYNY\n", "2 4 1\nYNNY\nNYNY\n"], "outputs": ["2\n", "2\n", "1\n", "1\n", "2\n", "2\n", "1\n", "3\n"]}
263
146
coding
Solve the programming task below in a Python markdown code block. Read problems statements [Hindi] ,[Bengali] , [Mandarin chinese] , [Russian] and [Vietnamese] as well. Appy loves balloons! She wants you to give her balloons on each of $N$ consecutive days (numbered $1$ through $N$); let's denote the number of balloon...
{"inputs": ["5 3 \n1 2 3 4 5\n1 2 3 4 5"], "outputs": ["15"]}
623
36
coding
Solve the programming task below in a Python markdown code block. Remainder of Big Integers Given two integers $A$ and $B$, compute the remainder of $\frac{A}{B}$. Input Two integers $A$ and $B$ separated by a space character are given in a line. Output Print the remainder in a line. Constraints * $0 \leq A, B \...
{"inputs": ["5 3", "9 3", "9 6", "4 3", "5 7", "6 7", "9 1", "5 1"], "outputs": ["2\n", "0\n", "3\n", "1\n", "5\n", "6\n", "0\n", "0\n"]}
153
78
coding
Solve the programming task below in a Python markdown code block. There are three friend living on the straight line Ox in Lineland. The first friend lives at the point x_1, the second friend lives at the point x_2, and the third friend lives at the point x_3. They plan to celebrate the New Year together, so they need ...
{"inputs": ["7 1 4\n", "1 2 3\n", "1 3 2\n", "4 2 6\n", "6 9 3\n", "8 1 9\n", "3 5 4\n", "2 1 3\n"], "outputs": ["6\n", "2\n", "2\n", "4\n", "6\n", "8\n", "2\n", "2\n"]}
314
102
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. There are n unique candies (labeled 1 through n) and k bags. You are asked to distribute all the candies into the bags such that every bag has at least one candy. There can be multiple ways to distribute the candies. ...
{"functional": "def check(candidate):\n assert candidate(n = 3, k = 2) == 3\n assert candidate(n = 4, k = 2) == 7\n assert candidate(n = 20, k = 5) == 206085257\n\n\ncheck(Solution().waysToDistribute)"}
291
81
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 of positive integers nums. A triplet of three distinct indices (i, j, k) is called a single divisor triplet of nums if nums[i] + nums[j] + nums[k] is divisible by exactly one of nums[i]...
{"functional": "def check(candidate):\n assert candidate(nums = [4,6,7,3,2]) == 12\n assert candidate(nums = [1,2,2]) == 6\n assert candidate(nums = [1,1,1]) == 0\n\n\ncheck(Solution().singleDivisorTriplet)"}
125
75
coding
Solve the programming task below in a Python markdown code block. A triangle is called an equable triangle if its area equals its perimeter. Return `true`, if it is an equable triangle, else return `false`. You will be provided with the length of sides of the triangle. Happy Coding! Also feel free to reuse/extend the f...
{"functional": "_inputs = [[5, 12, 13], [2, 3, 4], [6, 8, 10], [7, 15, 20], [17, 17, 30], [7, 10, 12], [6, 11, 12], [25, 25, 45], [13, 37, 30], [6, 25, 29], [10, 11, 18], [73, 9, 80], [12, 35, 37], [120, 109, 13], [9, 10, 17]]\n_outputs = [[True], [False], [True], [True], [False], [False], [False], [False], [False], [T...
85
365
coding
Solve the programming task below in a Python markdown code block. Toad Ivan has $m$ pairs of integers, each integer is between $1$ and $n$, inclusive. The pairs are $(a_1, b_1), (a_2, b_2), \ldots, (a_m, b_m)$. He asks you to check if there exist two integers $x$ and $y$ ($1 \leq x < y \leq n$) such that in each give...
{"inputs": ["2 1\n1 2\n", "4 1\n1 2\n", "4 1\n1 2\n", "2 1\n1 2\n", "8 1\n1 2\n", "4 2\n1 2\n3 4\n", "4 2\n1 2\n2 3\n", "4 2\n1 2\n2 3\n"], "outputs": ["YES\n", "YES\n", "YES", "YES", "YES\n", "YES\n", "YES\n", "YES"]}
519
127
coding
Solve the programming task below in a Python markdown code block. Given are N pairwise distinct non-negative integers A_1,A_2,\ldots,A_N. Find the number of ways to choose a set of between 1 and K numbers (inclusive) from the given numbers so that the following two conditions are satisfied: * The bitwise AND of the ch...
{"inputs": ["3 3 0 3\n0 2 3", "3 3 0 6\n0 2 3", "3 4 0 3\n1 2 3", "3 6 0 3\n0 2 3", "0 3 0 6\n0 2 3", "3 3 0 3\n1 2 3", "3 3 -1 6\n0 2 3", "3 3 -1 7\n0 2 3"], "outputs": ["2", "0", "2", "2", "0", "2", "0", "0"]}
283
150
coding
Solve the programming task below in a Python markdown code block. The hamming distance of two equal-length strings is the number of positions, in which the two string differ. In other words, the number of character substitutions required to transform one string into the other. For this first Kata, you will write a fu...
{"functional": "_inputs = [['100101', '101001'], ['1010', '0101'], ['100101011011010010010', '101100010110010110101']]\n_outputs = [[2], [4], [9]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return math.isclose(a, b, rel_tol=tol, abs_tol=tol)\n if isinst...
200
233
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. Given an integer num, repeatedly add all its digits until the result has only one digit, and return it. Β  Please complete the following python code precisely: ```python class Solution: def addDigits(self, num: int...
{"functional": "def check(candidate):\n assert candidate(num = 38) == 2\n assert candidate(num = 0) == 0\n\n\ncheck(Solution().addDigits)"}
69
44