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
Please solve the programming task below using a self-contained code snippet in a markdown code block. We are given a list nums of integers representing a list compressed with run-length encoding. Consider each adjacent pair of elements [freq, val] = [nums[2*i], nums[2*i+1]] (with i >= 0).  For each such pair, there ar...
{"functional": "def check(candidate):\n assert candidate(nums = [1,2,3,4]) == [2,4,4,4]\n assert candidate(nums = [1,1,2,3]) == [1,3,3]\n\n\ncheck(Solution().decompressRLElist)"}
143
70
coding
Solve the programming task below in a Python markdown code block. You are living on an infinite plane with the Cartesian coordinate system on it. In one move you can go to any of the four adjacent points (left, right, up, down). More formally, if you are standing at the point $(x, y)$, you can: go left, and move to $...
{"inputs": ["1\n4\n0 -1\n0 -2\n0 -3\n0 -4\n", "2\n3\n-6 0\n6 0\n0 -7\n3\n0 -6\n1 0\n0 3\n", "2\n3\n-2 0\n0 -5\n0 -1\n3\n3 0\n-2 0\n0 1\n", "3\n4\n0 -2\n1 0\n-1 0\n0 2\n3\n0 2\n-3 0\n0 -1\n1\n0 0\n"], "outputs": ["8\n", "38\n20\n", "14\n12\n", "12\n12\n0\n"]}
737
169
coding
Solve the programming task below in a Python markdown code block. Vasya is writing an operating system shell, and it should have commands for working with directories. To begin with, he decided to go with just two commands: cd (change the current directory) and pwd (display the current directory). Directories in Vasya...
{"inputs": ["1\npwd\n", "4\ncd /b/b\npwd\ncd ../a/b\npwd\n", "4\ncd /a/b\npwd\ncd ../a/b\npwd\n", "5\npwd\ncd ztb/kag\npwd\npwd\npwd\n", "5\npwd\ncd gak/btz\npwd\npwd\npwd\n", "6\ncd a/a/b/b\npwd\ncd ../..\npwd\ncd ..\npwd\n", "5\npwd\ncd /xgztbykka\npwd\ncd /gia/kxfls\npwd\n", "5\npwd\ncd /xgztbzkka\npwd\ncd /gia/kxfl...
631
304
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. Given two arrays of integers with equal lengths, return the maximum value of: |arr1[i] - arr1[j]| + |arr2[i] - arr2[j]| + |i - j| where the maximum is taken over all 0 <= i, j < arr1.length.   Please complete the foll...
{"functional": "def check(candidate):\n assert candidate(arr1 = [1,2,3,4], arr2 = [-1,4,5,6]) == 13\n assert candidate(arr1 = [1,-2,-5,0,10], arr2 = [0,-2,-1,-7,-4]) == 20\n\n\ncheck(Solution().maxAbsValExpr)"}
117
90
coding
Solve the programming task below in a Python markdown code block. Little Petya loves counting. He wants to count the number of ways to paint a rectangular checkered board of size n × m (n rows, m columns) in k colors. Besides, the coloring should have the following property: for any vertical line that passes along the ...
{"inputs": ["6 6 8\n", "5 3 1\n", "3 3 2\n", "4 6 8\n", "5 3 2\n", "3 2 1\n", "4 2 2\n", "3 6 8\n"], "outputs": [" 522449402\n", " 1\n", " 290\n...
237
140
coding
Solve the programming task below in a Python markdown code block. Read problems statements in Mandarin Chinese, Russian and Vietnamese as well. Alexey is trying to develop a program for a very simple microcontroller. It makes readings from various sensors over time, and these readings must happen at specific regular ...
{"inputs": ["3\n3\n2 3 5\n4\n1 8 7 11\n4\n4 4 5 6"], "outputs": ["6\n7\n4"]}
585
45
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 n integers arr. The interval between two elements in arr is defined as the absolute difference between their indices. More formally, the interval between arr[i] and arr[j] is |i - j|...
{"functional": "def check(candidate):\n assert candidate(arr = [2,1,3,1,2,3,3]) == [4,2,7,2,4,4,5]\n assert candidate(arr = [10,5,10,10]) == [5,0,3,4]\n\n\ncheck(Solution().getDistances)"}
145
85
coding
Solve the programming task below in a Python markdown code block. # Sentence Smash Write a function that takes an array of words and smashes them together into a sentence and returns the sentence. You can ignore any need to sanitize words or add punctuation, but you should add spaces between each word. **Be careful, t...
{"functional": "_inputs = [[[]], [['hello']], [['hello', 'world']], [['hello', 'amazing', 'world']], [['this', 'is', 'a', 'really', 'long', 'sentence']]]\n_outputs = [[''], ['hello'], ['hello world'], ['hello amazing world'], ['this is a really long sentence']]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinst...
133
211
coding
Solve the programming task below in a Python markdown code block. Problem : Chotu's father is the owner of a Vada Pav shop. One Sunday, his father takes him to the shop. Father tells him that at the end of the day, Chotu has to give him a list consisting of the names of all the customers on that day who bought Vada Pa...
{"inputs": ["74\ngvny\ndk\nvc\nb\nsuvo\nbljl\nh\nnomnb\nzfv\noy\ngqdld\nrgq\nfia\nyhxbj\nyk\ngunj\nnqe\nmopv\nocgq\njwx\no\no\nh\njbsx\nhby\nnq\ndkp\nf\nnu\nnhl\nb\nrki\nefmlq\nlut\nwcem\nzz\niwevs\nwtpr\nvwn\nwwjjw\na\nqjevs\nsumon\nee\nv\nc\nwip\nylr\ny\nfn\nxlgw\njwwcy\nvdh\nx\nh\nurtoq\nlxc\nxc\nltfhu\nslv\nw\nuims...
398
1,703
coding
Solve the programming task below in a Python markdown code block. Problem statement Cards with ranks of $ 2 $ and $ 8 $ are powerful in card game millionaires. Therefore, we call an integer consisting of only the numbers $ 2 $ and $ 8 $ in $ 10 $ decimal notation a good integer. The best integers are listed from the s...
{"inputs": ["2", "4", "8", "6", "3", "7", "9", "5"], "outputs": ["1\n", "2\n", "3\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n"]}
346
62
coding
Solve the programming task below in a Python markdown code block. Permutation p is an ordered set of integers p1, p2, ..., pn, consisting of n distinct positive integers not larger than n. We'll denote as n the length of permutation p1, p2, ..., pn. Your task is to find such permutation p of length n, that the group o...
{"inputs": ["2 1\n", "4 2\n", "5 4\n", "7 5\n", "4 1\n", "9 8\n", "8 2\n", "5 3\n"], "outputs": ["1 2 \n", "1 3 2 4 ", "1 5 2 4 3 \n", "1 6 2 5 3 4 7 ", "1 2 3 4 \n", "1 9 2 8 3 7 4 6 5 \n", "1 3 2 4 5 6 7 8 ", "1 4 2 3 5 "]}
220
159
coding
Solve the programming task below in a Python markdown code block. Dawid has four bags of candies. The $i$-th of them contains $a_i$ candies. Also, Dawid has two friends. He wants to give each bag to one of his two friends. Is it possible to distribute the bags in such a way that each friend receives the same amount of ...
{"inputs": ["7 3 2 5\n", "1 1 1 1\n", "1 1 2 1\n", "2 4 1 1\n", "4 4 4 5\n", "2 6 3 2\n", "7 3 6 3\n", "2 4 6 6\n"], "outputs": ["NO\n", "YES\n", "NO\n", "YES\n", "NO\n", "NO\n", "NO\n", "NO\n"]}
304
118
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 p where p is a subsequence of s. You are also given a distinct 0-indexed integer array removable containing a subset of indices of s (s is also 0-indexed). You want to choose an integer...
{"functional": "def check(candidate):\n assert candidate(s = \"abcacb\", p = \"ab\", removable = [3,1,0]) == 2\n assert candidate(s = \"abcbddddd\", p = \"abcd\", removable = [3,2,1,4,5,6]) == 1\n assert candidate(s = \"abcab\", p = \"abc\", removable = [0,1,2,3,4]) == 0\n\n\ncheck(Solution().maximumRemovals)"...
240
114
coding
Solve the programming task below in a Python markdown code block. ## Grade book Complete the function so that it finds the mean of the three scores passed to it and returns the letter value associated with that grade. Numerical Score | Letter Grade --- | --- 90 <= score <= 100 | 'A' 80 <= score < 90...
{"functional": "_inputs = [[95, 90, 93], [100, 85, 96], [92, 93, 94], [100, 100, 100], [70, 70, 100], [82, 85, 87], [84, 79, 85], [70, 70, 70], [75, 70, 79], [60, 82, 76], [65, 70, 59], [66, 62, 68], [58, 62, 70], [44, 55, 52], [48, 55, 52], [58, 59, 60], [0, 0, 0]]\n_outputs = [['A'], ['A'], ['A'], ['A'], ['B'], ['B']...
181
405
coding
Solve the programming task below in a Python markdown code block. Xorgon is an extremely delicious treat formed by the sequence $S$ of binary integers $s_1, s_2,..,s_N$. A really interesting property found in a Xorgon is that the xor of all elements in any contiguous subsequence of length $K$ in $S$ will result in $1$....
{"inputs": ["7 5\n1 0 0 1 1 1 1"], "outputs": ["1"]}
375
28
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. Given an integer array nums (0-indexed) and two integers target and start, find an index i such that nums[i] == target and abs(i - start) is minimized. Note that abs(x) is the absolute value of x. Return abs(i - start...
{"functional": "def check(candidate):\n assert candidate(nums = [1,2,3,4,5], target = 5, start = 3) == 1\n assert candidate(nums = [1], target = 1, start = 0) == 0\n assert candidate(nums = [1,1,1,1,1,1,1,1,1,1], target = 1, start = 0) == 0\n\n\ncheck(Solution().getMinDistance)"}
123
112
coding
Solve the programming task below in a Python markdown code block. # Task For the given set `S` its powerset is the set of all possible subsets of `S`. Given an array of integers nums, your task is to return the powerset of its elements. Implement an algorithm that does it in a depth-first search fashion. That is, for...
{"functional": "_inputs = [[[1, 2]], [[1, 2, 3]], [[1]], [[125, 15, 155, 15, 158]], [[1, 2, 3, 4]]]\n_outputs = [[[[], [2], [1], [1, 2]]], [[[], [3], [2], [2, 3], [1], [1, 3], [1, 2], [1, 2, 3]]], [[[], [1]]], [[[], [158], [15], [15, 158], [155], [155, 158], [155, 15], [155, 15, 158], [15], [15, 158], [15, 15], [15, 15...
348
732
coding
Solve the programming task below in a Python markdown code block. As bad weather continues and vegetable prices soar, Seven-Eleven is offering customers bulk purchase sales of vegetables. The store is very busy, as you can get vegetables that are hard to find in stores at reasonable prices. One day, a group of three g...
{"inputs": ["4 1\n50 77 110 80\n7 3\n3 300 110 194 77 600 75\n0 0", "4 1\n50 77 110 80\n7 6\n3 300 110 194 77 600 75\n0 0", "4 3\n50 59 100 80\n7 3\n400 290 000 700 4 600 57\n0 0", "4 4\n50 59 100 80\n7 3\n400 290 000 700 4 600 57\n0 0", "4 2\n50 40 101 80\n7 4\n400 45 000 700 87 650 57\n0 0", "4 1\n27 77 100 80\n7 3\n...
522
494
coding
Solve the programming task below in a Python markdown code block. Chef hates unoptimized codes and people who write such codes. One fine day he decided to look through the kitchen's codebase and found a function whose pseudo-code is given here: input: integer N, list X[1, 2, ..., N], list Y[1, 2, ..., N] output: inte...
{"inputs": ["2\n3\n1 3\n3 1\n1 2\n5\n1 3\n2 4\n1 2\n3 2\n3 4"], "outputs": ["0\n11"]}
474
51
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. You have information about n different recipes. You are given a string array recipes and a 2D string array ingredients. The ith recipe has the name recipes[i], and you can create it if you have all the needed ingredie...
{"functional": "def check(candidate):\n assert candidate(recipes = [\"bread\"], ingredients = [[\"yeast\",\"flour\"]], supplies = [\"yeast\",\"flour\",\"corn\"]) == [\"bread\"]\n assert candidate(recipes = [\"bread\",\"sandwich\"], ingredients = [[\"yeast\",\"flour\"],[\"bread\",\"meat\"]], supplies = [\"yeast\",...
198
221
coding
Solve the programming task below in a Python markdown code block. We have N voting papers. The i-th vote (1 \leq i \leq N) has the string S_i written on it. Print all strings that are written on the most number of votes, in lexicographical order. -----Constraints----- - 1 \leq N \leq 2 \times 10^5 - S_i (1 \leq i \l...
{"inputs": ["4\nushi\ntaou\nnichia\nkun", "4\nihsu\ntaou\nnichia\nkun", "4\nihsu\ntaou\nmichia\nkun", "4\nihsu\ntaou\nmichia\nnuk", "4\nihsu\ntaou\nmichia\nmuk", "4\nihsu\nuoat\nmichia\nmuk", "4\nihsu\nuoat\nmichia\nkum", "4\nihsu\nuoat\nmichia\nluk"], "outputs": ["kun\nnichia\ntaou\nushi\n", "ihsu\nkun\nnichia\ntaou\n...
240
276
coding
Solve the programming task below in a Python markdown code block. Appleman and Toastman play a game. Initially Appleman gives one group of n numbers to the Toastman, then they start to complete the following tasks: Each time Toastman gets a group of numbers, he sums up all the numbers and adds this sum to the score. T...
{"inputs": ["1\n3\n", "1\n5\n", "1\n2\n", "1\n1\n", "1\n10\n", "1\n10\n", "2\n1 2\n", "2\n2 3\n"], "outputs": ["3\n", "5\n", "2\n", "1\n", "10\n", "10\n", "6\n", "10\n"]}
534
95
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 consisting of positive integers. You can choose two indices i and j, such that i != j, and the sum of digits of the number nums[i] is equal to that of nums[j]. Return the maximum v...
{"functional": "def check(candidate):\n assert candidate(nums = [18,43,36,13,7]) == 54\n assert candidate(nums = [10,12,19,14]) == -1\n\n\ncheck(Solution().maximumSum)"}
125
66
coding
Solve the programming task below in a Python markdown code block. # Task Your task is to write a function for calculating the score of a 10 pin bowling game. The input for the function is a list of pins knocked down per roll for one player. Output is the player's total score. # Rules ## General rules Rules of bowlin...
{"functional": "_inputs = [[[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]], [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]], [[4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4]], [[9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9]], [[10, 10, 10, 10, 10, 10, 10, 10, ...
416
710
coding
Solve the programming task below in a Python markdown code block. When you look at photographs of watches and clocks, you'll find that they almost always show the time 10:10. There are lots of theories and even urban legends about this. For example, when showing 10:10, the hands look like a smile, and so you are more i...
{"inputs": ["2\n2 3\n3 3\n"], "outputs": ["3\n62\n"]}
445
25
coding
Solve the programming task below in a Python markdown code block. Chef has an array A having N elements. Chef wants to make all the elements of the array equal by repeating the following move. Choose any integer K between 1 and N (inclusive). Then choose K distinct indices i_{1} , i_{2}, \dots, i_{K}, and increase the...
{"inputs": ["2\n3\n1 3 1\n3\n2 2 2"], "outputs": ["2\n0"]}
494
30
coding
Solve the programming task below in a Python markdown code block. We have a sequence of N integers A~=~A_0,~A_1,~...,~A_{N - 1}. Let B be a sequence of K \times N integers obtained by concatenating K copies of A. For example, if A~=~1,~3,~2 and K~=~2, B~=~1,~3,~2,~1,~3,~2. Find the inversion number of B, modulo 10^9 ...
{"inputs": ["2 2\n2 2", "2 2\n0 2", "2 2\n2 0", "2 4\n2 0", "2 2\n2 1", "3 5\n1 1 0", "3 5\n1 2 0", "2 -4\n2 -1"], "outputs": ["0\n", "1\n", "3\n", "10\n", "3", "30\n", "40\n", "6\n"]}
357
116
coding
Solve the programming task below in a Python markdown code block. A girl named Sonya is studying in the scientific lyceum of the Kingdom of Kremland. The teacher of computer science (Sonya's favorite subject!) invented a task for her. Given an array $a$ of length $n$, consisting only of the numbers $0$ and $1$, and th...
{"inputs": ["2 1\n0 1\n", "2 1\n1 0\n", "2 1\n1 1\n", "2 1\n0 0\n", "2 1\n1 0\n", "2 1\n0 1\n", "2 1\n1 1\n", "2 1\n0 0\n"], "outputs": ["0", "1", "1", "1", "1\n", "0\n", "1\n", "1\n"]}
645
114
coding
Solve the programming task below in a Python markdown code block. Chef Ada is building a new restaurant in the following way: - First, $N$ points $X_1, X_2, \ldots, X_N$ are chosen on the $x$-axis. - Then, $N$ columns (numbered $1$ through $N$) are made. For simplicity, the columns are represented as vertical segments;...
{"inputs": ["1\n5\n1 1\n2 2\n3 3\n4 4\n5 5"], "outputs": ["27"]}
614
35
coding
Solve the programming task below in a Python markdown code block. You've got string s, consisting of small English letters. Some of the English letters are good, the rest are bad. A substring s[l...r] (1 ≤ l ≤ r ≤ |s|) of string s = s_1s_2...s_{|}s| (where |s| is the length of string s) is string s_{l}s_{l} + 1...s...
{"inputs": ["a\n00000000000000000000000000\n0\n", "a\n00000000000000000000000000\n0\n", "a\n00000000000000000100000000\n0\n", "aaaa\n00000000000000000000000000\n0\n", "aaaa\n00000000000000000000000000\n0\n", "aaaa\n10000000000000000000000000\n0\n", "ababab\n01000000000000000000000000\n1\n", "aaaaaa\n0000000000000000000...
529
303
coding
Solve the programming task below in a Python markdown code block. You are given a sequence $A_1, A_2, \ldots, A_N$. You have to split the array into maximum number of non-empty subarrays such that the gcd of elements of each subarray is equal to 1. -----Input:----- - The first line of the input contains a single integ...
{"inputs": ["2\n3\n2 2 3\n4\n2 3 3 2"], "outputs": ["1\n2"]}
272
32
coding
Solve the programming task below in a Python markdown code block. The football season has just ended in Berland. According to the rules of Berland football, each match is played between two teams. The result of each match is either a draw, or a victory of one of the playing teams. If a team wins the match, it gets w po...
{"inputs": ["10 2 5 3\n", "10 2 5 4\n", "100 1 5 4\n", "10 6 10 9\n", "27 60 3 1\n", "20 0 28 5\n", "101 1 5 4\n", "10 2 10 9\n"], "outputs": ["-1\n", "-1\n", "-1\n", "-1\n", "20 0 7\n", "0 0 20\n", "-1\n", "-1\n"]}
583
143
coding
Solve the programming task below in a Python markdown code block. Passer ratings are the generally accepted standard for evaluating NFL quarterbacks. I knew a rating of 100 is pretty good, but never knew what makes up the rating. So out of curiosity I took a look at the wikipedia page and had an idea or my first kata: ...
{"functional": "_inputs = [[432, 3554, 291, 28, 2], [5, 76, 4, 1, 0], [48, 192, 19, 2, 3], [1, 2, 1, 1, 0], [34, 172, 20, 1, 1], [10, 17, 2, 0, 1]]\n_outputs = [[112.2], [158.3], [39.6], [118.8], [69.7], [0.0]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n re...
325
296
coding
Solve the programming task below in a Python markdown code block. You are given an array of positive integers a_1, a_2, ..., a_{n} × T of length n × T. We know that for any i > n it is true that a_{i} = a_{i} - n. Find the length of the longest non-decreasing sequence of the given array. -----Input----- The first li...
{"inputs": ["1 1\n5\n", "1 1\n5\n", "1 1\n10\n", "1 1\n12\n", "2 1\n1 2\n", "2 2\n1 2\n", "2 2\n1 2\n", "2 1\n1 2\n"], "outputs": ["1\n", "1\n", "1\n", "1\n", "2\n", "3\n", "3\n", "2\n"]}
249
112
coding
Solve the programming task below in a Python markdown code block. Lucy likes letters. She studied the definition of the lexicographical order at school and plays with it. At first, she tried to construct the lexicographically smallest word out of given letters. It was so easy! Then she tried to build multiple words an...
{"inputs": ["1 1 1\nv\n", "1 1 1\nn\n", "1 1 1\nz\n", "1 1 1\nd\n", "1 1 1\nb\n", "1 1 1\ny\n", "1 1 1\nc\n", "1 1 1\nx\n"], "outputs": ["v\n", "n\n", "z\n", "d\n", "b\n", "y\n", "c\n", "x\n"]}
306
118
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. You are given an integer array ribbons, where ribbons[i] represents the length of the ith ribbon, and an integer k. You may cut any of the ribbons into any number of segments of positive integer lengths, or perform no...
{"functional": "def check(candidate):\n assert candidate(ribbons = [9,7,5], k = 3) == 5\n assert candidate(ribbons = [7,5,9], k = 4) == 4\n assert candidate(ribbons = [5,7,9], k = 22) == 0\n\n\ncheck(Solution().maxLength)"}
250
88
coding
Solve the programming task below in a Python markdown code block. Prefix function of string $t = t_1 t_2 \ldots t_n$ and position $i$ in it is defined as the length $k$ of the longest proper (not equal to the whole substring) prefix of substring $t_1 t_2 \ldots t_i$ which is also a suffix of the same substring. For ex...
{"inputs": ["3\nvkcup\nabababa\nzzzzzz\n"], "outputs": ["ckpuv\naababab\nzzzzzz\n"]}
708
36
coding
Solve the programming task below in a Python markdown code block. We want to know the index of the vowels in a given word, for example, there are two vowels in the word super (the second and fourth letters). So given a string "super", we should return a list of [2, 4]. Some examples: Mmmm => [] ...
{"functional": "_inputs = [['mmm'], ['apple'], ['super'], ['orange'], ['grapes'], ['supercalifragilisticexpialidocious'], ['123456'], ['crIssUm'], ['Implied'], ['rIc'], ['UNDISARMED'], ['bialy'], ['stumpknocker'], ['narboonnee'], ['carlstadt'], ['ephodee'], ['spicery'], ['oftenness'], ['bewept'], ['capsized']]\n_output...
168
458
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. Given three strings a, b, and c, your task is to find a string that has the minimum length and contains all three strings as substrings. If there are multiple such strings, return the lexicographically smallest one. R...
{"functional": "def check(candidate):\n assert candidate(a = \"abc\", b = \"bca\", c = \"aaa\") == \"aaabca\"\n assert candidate(a = \"ab\", b = \"ba\", c = \"aba\") == \"aba\"\n\n\ncheck(Solution().minimumString)"}
173
68
coding
Solve the programming task below in a Python markdown code block. The chef is trying to solve some pattern problems, Chef wants your help to code it. Chef has one number K to form a new pattern. Help the chef to code this pattern problem. -----Input:----- - First-line will contain $T$, the number of test cases. Then t...
{"inputs": ["4\n1\n2\n3\n4"], "outputs": ["1\n13\n57\n135\n7911\n131517\n1357\n9111315\n17192123\n25272931"]}
231
73
coding
Solve the programming task below in a Python markdown code block. Abhishek is fond of playing cricket very much. One morning, he is playing cricket with his friends. Abhishek is a right-hand batsman .He has to face all types of balls either good or bad. There are total 26 balls in the game and each ball is represen...
{"inputs": ["2\nababab\nbgbbbbbbbbbbbbbbbbbbbbbbbb\n1\nacbacbacaa\nbbbbbbbbbbbbbbbbbbbbbbbbbb\n2"], "outputs": ["5\n8"]}
673
43
coding
Solve the programming task below in a Python markdown code block. Gottfried learned about binary number representation. He then came up with this task and presented it to you. You are given a collection of $n$ non-negative integers $a_1, \ldots, a_n$. You are allowed to perform the following operation: choose two dist...
{"inputs": ["1\n0\n", "1\n0\n", "1\n1\n", "1\n42\n", "1\n17\n", "1\n123\n", "1\n167\n", "1\n123\n"], "outputs": ["0\n", "0\n", "1\n", "1764\n", "289\n", "15129\n", "27889\n", "15129\n"]}
649
111
coding
Solve the programming task below in a Python markdown code block. n people came to a party. Then those, who had no friends among people at the party, left. Then those, who had exactly 1 friend among those who stayed, left as well. Then those, who had exactly 2, 3, ..., n - 1 friends among those who stayed by the moment...
{"inputs": ["1\n4\n", "1\n2\n", "1\n7\n", "1\n5\n", "1\n6\n", "1\n9\n", "1\n8\n", "1\n1\n"], "outputs": ["2\n", "0\n", "5\n", "3\n", "4\n", "7\n", "6\n", "0\n"]}
185
86
coding
Solve the programming task below in a Python markdown code block. ### Description: Remove all exclamation marks from sentence except at the end. ### Examples ``` remove("Hi!") == "Hi!" remove("Hi!!!") == "Hi!!!" remove("!Hi") == "Hi" remove("!Hi!") == "Hi!" remove("Hi! Hi!") == "Hi Hi!" remove("Hi") == "Hi" ``` Als...
{"functional": "_inputs = [['Hi!'], ['Hi!!!'], ['!Hi'], ['!Hi!'], ['Hi! Hi!'], ['Hi']]\n_outputs = [['Hi!'], ['Hi!!!'], ['Hi'], ['Hi!'], ['Hi Hi!'], ['Hi']]\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 ...
108
196
coding
Solve the programming task below in a Python markdown code block. Complete the function, which calculates how much you need to tip based on the total amount of the bill and the service. You need to consider the following ratings: - Terrible: tip 0% - Poor: tip 5% - Good: tip 10% - Great: tip 15% - Excellent: tip 20%...
{"functional": "_inputs = [[30, 'poor'], [20, 'Excellent'], [20, 'hi'], [107.65, 'GReat'], [20, 'great!']]\n_outputs = [[2], [4], ['Rating not recognised'], [17], ['Rating not recognised']]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return math.isclose(a, ...
192
212
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. There are n friends that are playing a game. The friends are sitting in a circle and are numbered from 1 to n in clockwise order. More formally, moving clockwise from the ith friend brings you to the (i+1)th friend fo...
{"functional": "def check(candidate):\n assert candidate(n = 5, k = 2) == 3\n assert candidate(n = 6, k = 5) == 1\n\n\ncheck(Solution().findTheWinner)"}
251
54
coding
Solve the programming task below in a Python markdown code block. # Summation Write a program that finds the summation of every number from 1 to num. The number will always be a positive integer greater than 0. For example: ```if-not:racket ~~~ summation(2) -> 3 1 + 2 summation(8) -> 36 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8...
{"functional": "_inputs = [[1], [8], [22], [100], [213]]\n_outputs = [[1], [36], [253], [5050], [22791]]\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)...
189
194
coding
Solve the programming task below in a Python markdown code block. Champa loved traveling the world. He loved going from one city to the other. Being the miser that he is, he never wishes spend any money. Champa, instead, jumps from one city to the other. Also he likes trips of high quality. He can start at any city of...
{"inputs": ["1\n2 1000\n1 3000000\n"], "outputs": ["2999999000\n"]}
450
40
coding
Solve the programming task below in a Python markdown code block. The [Sharkovsky's Theorem](https://en.wikipedia.org/wiki/Sharkovskii%27s_theorem) involves the following ordering of the natural numbers: ```math 3≺5≺7≺9≺ ...\\ ≺2·3≺2·5≺2·7≺2·9≺...\\ ≺2^n·3≺2^n·5≺2^n·7≺2^n·9≺...\\ ≺2^{(n+1)}·3≺2^{(n+1)}·5≺2^{(n+1)}·7≺2^...
{"functional": "_inputs = [[18, 12], [3, 9], [10, 16], [1, 22], [32, 1024], [17, 17]]\n_outputs = [[True], [True], [True], [False], [False], [False]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return math.isclose(a, b, rel_tol=tol, abs_tol=tol)\n if isi...
250
214
coding
Solve the programming task below in a Python markdown code block. Jon Snow now has to fight with White Walkers. He has n rangers, each of which has his own strength. Also Jon Snow has his favourite number x. Each ranger can fight with a white walker only if the strength of the white walker equals his strength. He howev...
{"inputs": ["1 1 1\n1\n", "1 1 1\n1\n", "1 2 1\n1\n", "2 3 5\n1 2\n", "2 1 5\n1 2\n", "2 1 5\n1 2\n", "2 3 5\n1 2\n", "2 1 5\n1 1\n"], "outputs": ["0 0", "0 0\n", "1 1\n", "7 1", "4 2", "4 2\n", "7 1\n", "4 1\n"]}
608
141
coding
Solve the programming task below in a Python markdown code block. Little Petya very much likes playing with little Masha. Recently he has received a game called "Zero-One" as a gift from his mother. Petya immediately offered Masha to play the game with him. Before the very beginning of the game several cards are lain ...
{"inputs": ["11\n", "??\n", "00\n", "10?\n", "01?\n", "1?1\n", "0101\n", "000?\n"], "outputs": ["11\n", "00\n01\n10\n11\n", "00\n", "00\n01\n", "00\n01\n", "01\n11\n", "01\n", "00\n"]}
735
111
coding
Solve the programming task below in a Python markdown code block. Simple, remove the spaces from the string, then return the resultant string. ~~~if:c For C, you must return a new dynamically allocated string. ~~~ Also feel free to reuse/extend the following starter code: ```python def no_space(x): ```
{"functional": "_inputs = [['8 j 8 mBliB8g imjB8B8 jl B'], ['8 8 Bi fk8h B 8 BB8B B B B888 c hl8 BhB fd'], ['8aaaaa dddd r '], ['jfBm gk lf8hg 88lbe8 '], ['8j aam']]\n_outputs = [['8j8mBliB8gimjB8B8jlB'], ['88Bifk8hB8BB8BBBB888chl8BhBfd'], ['8aaaaaddddr'], ['jfBmgklf8hg88lbe8'], ['8jaam']]\nimport math\ndef...
68
303
coding
Solve the programming task below in a Python markdown code block. Fibonacci numbers have the following form: $\begin{aligned}F_1&-1\\ F_2&=1\\ F_3&=2\\ \vdots\\ F_n&=F_{n-2}+F_{n-1}\end{aligned}$ We have an array $a_1,a_2,\ldots,a_N$ which contains $N$ elements. We want to find $\text{gcd}(F_{a_1},F_{a_2},F_{a...
{"inputs": ["2\n3\n6\n", "3\n2\n3\n5\n"], "outputs": ["2\n", "1\n"]}
356
32
coding
Solve the programming task below in a Python markdown code block. Find the symmetric difference of two sets $A = \\{a_0, a_1, ..., a_{n-1}\\}$ and $B = \\{b_0, b_1, ..., b_{m-1}\\}$. Constraints * $1 \leq n, m \leq 200,000$ * $0 \leq a_0 < a_1 < ... < a_{n-1} \leq 10^9$ * $0 \leq b_0 < b_1 < ... < b_{m-1} \leq 10^9$ ...
{"inputs": ["7\n1 2 3 4 5 6 8\n4\n2 4 6 8", "7\n1 2 3 4 5 6 7\n4\n1 4 6 8", "7\n1 2 3 4 5 6 8\n0\n4 9 6 9", "7\n1 2 3 4 5 6 7\n4\n2 4 6 8", "7\n1 2 3 4 5 6 7\n4\n2 4 6 11", "7\n1 2 3 4 5 6 7\n1\n2 4 6 11", "7\n1 2 3 4 5 6 10\n4\n1 4 6 8", "7\n1 2 3 4 5 6 10\n3\n1 4 6 8"], "outputs": ["1\n3\n5\n", "2\n3\n5\n7\n8\n", "1\...
288
324
coding
Solve the programming task below in a Python markdown code block. Read problems statements [Bengali] , [Mandarin chinese] , [Russian] and [Vietnamese] as well. There are two sequences $A_{1}, A_{2}, \dots, A_{N}$ and $B_{1}, B_{2}, \dots, B_{N}$. Answer $Q$ queries on these sequences. In each query, you should calcul...
{"inputs": ["1\n5 2\n4 6 5 2 7\n3 2 4 6 3\n2 4 2\n1 1 1"], "outputs": ["51\n12"]}
498
52
coding
Solve the programming task below in a Python markdown code block. The Free Meteor Association (FMA) has got a problem: as meteors are moving, the Universal Cosmic Descriptive Humorous Program (UCDHP) needs to add a special module that would analyze this movement. UCDHP stores some secret information about meteors as ...
{"inputs": ["1 2 1\n0 0\nc 1 2\n", "1 2 3\n1 2\nc 1 2\ng 1 1\ng 1 2\n", "2 1 3\n1\n2\nr 1 2\ng 1 1\ng 2 1\n", "1 2 3\n1 2\nc 1 2\ng 1 1\ng 1 1\n", "1 2 3\n0 2\nc 1 2\ng 1 1\ng 1 2\n", "1 2 3\n1 2\nc 1 2\ng 1 2\ng 1 2\n", "2 3 3\n1 0 4\n3 1 5\nc 2 1\nr 1 2\ng 1 3\n", "2 3 3\n1 2 4\n3 1 5\nc 2 2\nr 1 1\ng 1 3\n"], "outpu...
695
292
coding
Solve the programming task below in a Python markdown code block. You are given four digits N_1, N_2, N_3 and N_4. Determine if these can be arranged into the sequence of digits "1974". Constraints * 0 \leq N_1, N_2, N_3, N_4 \leq 9 * N_1, N_2, N_3 and N_4 are integers. Input Input is given from Standard Input in t...
{"inputs": ["1 2 3 1", "0 7 9 4", "1 3 3 1", "1 2 3 2", "1 0 3 2", "1 0 4 2", "1 0 0 2", "1 0 0 1"], "outputs": ["NO\n", "NO\n", "NO\n", "NO\n", "NO\n", "NO\n", "NO\n", "NO\n"]}
226
110
coding
Solve the programming task below in a Python markdown code block. Read problems statements in Mandarin Chinese and Russian. Sereja have array A' that contain N integers. Now Sereja want to permute elements of the array, he want to use some permutation p, such that A[i] = A'[p[i]], where A - new array.   Lets functi...
{"inputs": ["2\n3 2 4\n3 4 1\n4 4 1\n1 1 1 1"], "outputs": ["2 1 3\n4 3 2 1"]}
510
50
coding
Solve the programming task below in a Python markdown code block. You are given a rooted tree on N vertices. The nodes are numbered from 1 to N, and Node 1 is the root. Each node u has an associated value attached to it: Au. For each vertex v, we consider the path going upwards from v to the root. Suppose that path is ...
{"inputs": ["8\n1 1 1 1 5 8 6\n1 2 3 4 5 15 70 10"], "outputs": ["1 3 4 5 6 21 96 26"]}
644
62
coding
Solve the programming task below in a Python markdown code block. Alice has a binary string. She thinks a binary string is beautiful if and only if it doesn't contain the substring $\text{"010"}$. In one step, Alice can change a $0$ to a $1$ or vice versa. Count and print the minimum number of steps needed to make Al...
{"inputs": ["5\n01100\n", "7\n0101010\n", "10\n0100101010\n"], "outputs": ["0\n", "2 \n", "3\n"]}
508
58
coding
Solve the programming task below in a Python markdown code block. >When no more interesting kata can be resolved, I just choose to create the new kata, to solve their own, to enjoy the process --myjinxin2015 said # Description: Give you two number `m` and `n`(two positive integer, m < n), make a triangle pattern wit...
{"functional": "_inputs = [[1, 12], [1, 100]]\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 ...
313
167
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. There is a malfunctioning keyboard where some letter keys do not work. All other keys on the keyboard work properly. Given a string text of words separated by a single space (no leading or trailing spaces) and a strin...
{"functional": "def check(candidate):\n assert candidate(text = \"hello world\", brokenLetters = \"ad\") == 1\n assert candidate(text = \"leet code\", brokenLetters = \"lt\") == 1\n assert candidate(text = \"leet code\", brokenLetters = \"e\") == 0\n\n\ncheck(Solution().canBeTypedWords)"}
124
78
coding
Solve the programming task below in a Python markdown code block. ```if-not:ruby Create a function, that accepts an arbitrary number of arrays and returns a single array generated by alternately appending elements from the passed in arguments. If one of them is shorter than the others, the result should be padded with ...
{"functional": "_inputs = [[[1, 2, 3], ['c', 'd', 'e']], [[1, 2, 3], [4, 5]], [[1, 2], [3, 4, 5]], [[None], [None, None], [None, None, None]], [[1, 2, 3], [4, 5, 6], [7, 8, 9]], [[]]]\n_outputs = [[[1, 'c', 2, 'd', 3, 'e']], [[1, 4, 2, 5, 3, None]], [[1, 3, 2, 4, None, 5]], [[None, None, None, None, None, None, None, N...
289
340
coding
Solve the programming task below in a Python markdown code block. # Task John is a programmer. He treasures his time very much. He lives on the `n` floor of a building. Every morning he will go downstairs as quickly as possible to begin his great work today. There are two ways he goes downstairs: walking or taking th...
{"functional": "_inputs = [[5, 6, [1, 2, 3, 10]], [1, 6, [1, 2, 3, 10]], [5, 5, [1, 2, 3, 10]], [2, 2, [1, 2, 3, 10]], [2, 2, [2, 3, 4, 10]], [5, 4, [1, 2, 3, 10]], [5, 4, [2, 3, 4, 5]], [1, 6, [0, 0, 0, 0]], [1, 6, [0, 2, 0, 0]], [1, 6, [20, 0, 10, 0]]]\n_outputs = [[12], [0], [11], [8], [10], [12], [20], [0], [0], [0...
464
372
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. A sequence of numbers is called an arithmetic progression if the difference between any two consecutive elements is the same. Given an array of numbers arr, return true if the array can be rearranged to form an arithm...
{"functional": "def check(candidate):\n assert candidate(arr = [3,5,1]) == True\n assert candidate(arr = [1,2,4]) == False\n\n\ncheck(Solution().canMakeArithmeticProgression)"}
100
53
coding
Solve the programming task below in a Python markdown code block. Petya and Vasya decided to play a little. They found n red cubes and m blue cubes. The game goes like that: the players take turns to choose a cube of some color (red or blue) and put it in a line from left to right (overall the line will have n + m cube...
{"inputs": ["3 1\n", "2 4\n", "1 1\n", "2 1\n", "4 4\n", "1 2\n", "4 4\n", "1 2\n"], "outputs": ["2 1\n", "3 2\n", "0 1\n", "1 1\n", "3 4\n", "1 1\n", "3 4\n", "1 1\n"]}
476
102
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. You are given a 2D integer array tiles where tiles[i] = [li, ri] represents that every tile j in the range li <= j <= ri is colored white. You are also given an integer carpetLen, the length of a single carpet that ca...
{"functional": "def check(candidate):\n assert candidate(tiles = [[1,5],[10,11],[12,18],[20,25],[30,32]], carpetLen = 10) == 9\n assert candidate(tiles = [[10,11],[1,1]], carpetLen = 2) == 2\n\n\ncheck(Solution().maximumWhiteTiles)"}
128
93
coding
Solve the programming task below in a Python markdown code block. Tim likes Math. He likes it so much that he always brings his tablets with him and reads math e-books everywhere, even during parties. Tim found an interesting exercise in one of the e-books he is reading. But you want him to join the party, so you deci...
{"inputs": ["3\n1 2\n0 4\n-1 1\n"], "outputs": ["4\n2\n0\n"]}
402
31
coding
Solve the programming task below in a Python markdown code block. # Problem In China,there is an ancient mathematical book, called "The Mathematical Classic of Sun Zi"(《孙子算经》). In the book, there is a classic math problem: “今有物不知其数,三三数之剩二,五五数之剩三,七七数之剩二,问物几何?” Ahh, Sorry. I forgot that you don't know Chinese. Let's t...
{"functional": "_inputs = [[2, 3, 2], [1, 2, 3], [1, 3, 5], [0, 0, 0], [1, 1, 1]]\n_outputs = [[23], [52], [103], [105], [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)...
530
215
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. The median is the middle value in an ordered integer list. If the size of the list is even, there is no middle value. So the median is the mean of the two middle values. For examples, if arr = [2,3,4], the median is ...
{"functional": "def check(candidate):\n assert candidate(nums = [1,3,-1,-3,5,3,6,7], k = 3) == [1.00000,-1.00000,-1.00000,3.00000,5.00000,6.00000]\n assert candidate(nums = [1,2,3,4,2,3,1,4,2], k = 3) == [2.00000,3.00000,3.00000,3.00000,2.00000,3.00000,2.00000]\n\n\ncheck(Solution().medianSlidingWindow)"}
230
187
coding
Solve the programming task below in a Python markdown code block. Read problems statements in Mandarin Chinese and Russian as well. Petr, Nikita G. and Nikita are the most influential music critics in Saint-Petersburg. They have recently downloaded their favorite band's new album and going to listen to it. Nikita cla...
{"inputs": ["3\n1\n2\n3", "3\n1\n2\n2", "3\n1\n2\n6", "3\n2\n2\n2", "3\n1\n3\n2", "3\n1\n3\n6", "3\n1\n1\n2", "3\n1\n1\n6"], "outputs": ["1.0\n3.0\n5.5", "1.0\n3.0\n3.0\n", "1.0\n3.0\n14.7\n", "3.0\n3.0\n3.0\n", "1.0\n5.5\n3.0\n", "1.0\n5.5\n14.7\n", "1.0\n1.0\n3.0\n", "1.0\n1.0\n14.7\n"]}
543
192
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. There are n projects numbered from 0 to n - 1. You are given an integer array milestones where each milestones[i] denotes the number of milestones the ith project has. You can work on the projects following these two ...
{"functional": "def check(candidate):\n assert candidate(milestones = [1,2,3]) == 6\n assert candidate(milestones = [5,2,1]) == 7\n\n\ncheck(Solution().numberOfWeeks)"}
207
56
coding
Solve the programming task below in a Python markdown code block. The goal is to write a pair of functions the first of which will take a string of binary along with a specification of bits, which will return a numeric, signed complement in two's complement format. The second will do the reverse. It will take in an int...
{"functional": "_inputs = [['00000001', 8], ['00000010', 8], ['01111110', 8], ['01111111', 8], ['11111111', 8], ['11111110', 8], ['10000010', 8], ['1000 0000', 8], ['1010 1010 0010 0010 1110 1010 0010 1110', 32], ['1000 0000 1110 1111 0011 0100 1100 1010', 32], ['10110001000100000101100011111000', 32]]\n_outputs = [[1]...
238
452
coding
Solve the programming task below in a Python markdown code block. Polycarp analyzes the prices of the new berPhone. At his disposal are the prices for $n$ last days: $a_1, a_2, \dots, a_n$, where $a_i$ is the price of berPhone on the day $i$. Polycarp considers the price on the day $i$ to be bad if later (that is, a d...
{"inputs": ["5\n6\n3 9 2 6 7 5\n1\n1000000\n2\n2 1\n10\n31 5 59 26 53 58 97 93 23 84\n7\n3 2 1 2 3 4 5\n", "5\n6\n3 5 4 6 7 4\n1\n1000000\n2\n2 0\n10\n2 41 59 26 53 58 97 93 23 84\n7\n3 2 1 2 3 4 5\n", "5\n6\n3 9 2 6 7 5\n1\n1000000\n2\n2 1\n10\n31 5 59 26 53 58 97 93 23 84\n7\n3 2 1 2 4 4 5\n", "5\n6\n3 9 4 6 7 5\n1\n...
523
763
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 strings words and a 2D array of integers queries. Each query queries[i] = [li, ri] asks us to find the number of strings present in the range li to ri (both inclusive) of words that ...
{"functional": "def check(candidate):\n assert candidate(words = [\"aba\",\"bcb\",\"ece\",\"aa\",\"e\"], queries = [[0,2],[1,4],[1,1]]) == [2,3,0]\n assert candidate(words = [\"a\",\"e\",\"i\"], queries = [[0,2],[0,1],[2,2]]) == [3,2,1]\n\n\ncheck(Solution().vowelStrings)"}
160
101
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. There are n dominoes in a line, and we place each domino vertically upright. In the beginning, we simultaneously push some of the dominoes either to the left or to the right. After each second, each domino that is fal...
{"functional": "def check(candidate):\n assert candidate(dominoes = \"RR.L\") == \"RR.L\"\n assert candidate(dominoes = \".L.R...LR..L..\") == \"LL.RR.LLRRLL..\"\n\n\ncheck(Solution().pushDominoes)"}
274
67
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. Given the root of a complete binary tree, return the number of the nodes in the tree. According to Wikipedia, every level, except possibly the last, is completely filled in a complete binary tree, and all nodes in the...
{"functional": "def check(candidate):\n assert candidate(root = tree_node([1,2,3,4,5,6])) == 6\n assert candidate(root = tree_node([])) == 0\n assert candidate(root = tree_node([1])) == 1\n\n\ncheck(Solution().countNodes)"}
188
70
coding
Solve the programming task below in a Python markdown code block. Given an integer `n`, find two integers `a` and `b` such that: ```Pearl A) a >= 0 and b >= 0 B) a + b = n C) DigitSum(a) + Digitsum(b) is maximum of all possibilities. ``` You will return the digitSum(a) + digitsum(b). ``` For example: solve(29) = 11...
{"functional": "_inputs = [[18], [29], [45], [1140], [7019], [50000000], [15569047737], [2452148459], [1], [0]]\n_outputs = [[18], [11], [18], [33], [35], [68], [144], [116], [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, re...
191
253
coding
Solve the programming task below in a Python markdown code block. It is September 9 in Japan now. You are given a two-digit integer N. Answer the question: Is 9 contained in the decimal notation of N? -----Constraints----- - 10≤N≤99 -----Input----- Input is given from Standard Input in the following format: N -----...
{"inputs": ["1", "0", "8", "3", "2", "4", "7", "6"], "outputs": ["No\n", "No\n", "No\n", "No\n", "No\n", "No\n", "No\n", "No\n"]}
124
62
coding
Solve the programming task below in a Python markdown code block. In this Kata, you will be given a multi-dimensional array containing `2 or more` sub-arrays of integers. Your task is to find the maximum product that can be formed by taking any one element from each sub-array. ``` Examples: solve( [[1, 2],[3, 4]] ) = ...
{"functional": "_inputs = [[[[1, 2], [3, 4]]], [[[10, -15], [-1, -3]]], [[[-1, 2, -3, 4], [1, -2, 3, -4]]], [[[-11, -6], [-20, -20], [18, -4], [-20, 1]]], [[[14, 2], [0, -16], [-12, -16]]], [[[-3, -4], [1, 2, -3]]], [[[-2, -15, -12, -8, -16], [-4, -15, -7], [-10, -5]]]]\n_outputs = [[8], [45], [12], [17600], [3584], [1...
192
343
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. Given a string s, remove duplicate letters so that every letter appears once and only once. You must make sure your result is the smallest in lexicographical order among all possible results.   Please complete the fol...
{"functional": "def check(candidate):\n assert candidate(s = \"bcabc\") == \"abc\"\n assert candidate(s = \"cbacdcbc\") == \"acdb\"\n\n\ncheck(Solution().removeDuplicateLetters)"}
85
50
coding
Solve the programming task below in a Python markdown code block. Modern text editors usually show some information regarding the document being edited. For example, the number of words, the number of pages, or the number of characters. In this problem you should implement the similar functionality. You are given a s...
{"inputs": ["1\n_\n", "1\na\n", "1\n_\n", "1\na\n", "1\nb\n", "1\nc\n", "1\nd\n", "1\ne\n"], "outputs": ["0 0\n", "1 0\n", "0 0\n", "1 0\n", "1 0\n", "1 0\n", "1 0\n", "1 0\n"]}
596
102
coding
Solve the programming task below in a Python markdown code block. Given two strings, $a$ and $\boldsymbol{b}$, find and print the total number of ways to insert a character at any position in string $\class{ML__boldsymbol}{\boldsymbol{a}}$ such that the length of the Longest Common Subsequence of characters in the two ...
{"inputs": ["aa\nbaaa\n"], "outputs": ["4\n"]}
568
17
coding
Solve the programming task below in a Python markdown code block. Write a program which reads $n$ items and sorts them. Each item has attributes $\\{value, weight, type, date, name\\}$ and they are represented by $\\{$ integer, integer, upper-case letter, integer, string $\\}$ respectively. Sort the items based on the ...
{"inputs": ["5\n27 21 D 745654582374 hwftj\n000 15 C 393121129811 clue\n51 133 A 44541605340 nijo\n101 11 A 63613510230 lcalb\n111 1 C 3157365261 eerg", "5\n26 21 D 745654582374 hwftj\n000 15 C 393121129811 clue\n51 133 A 44541605340 nijo\n101 11 A 63613510230 lcalb\n111 1 C 3157365261 eerg", "5\n26 21 D 745654582374 h...
731
1,790
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. You are given an array of strings words and a string chars. A string is good if it can be formed by characters from chars (each character can only be used once). Return the sum of lengths of all good strings in words....
{"functional": "def check(candidate):\n assert candidate(words = [\"cat\",\"bt\",\"hat\",\"tree\"], chars = \"atach\") == 6\n assert candidate(words = [\"hello\",\"world\",\"leetcode\"], chars = \"welldonehoneyr\") == 10\n\n\ncheck(Solution().countCharacters)"}
99
74
coding
Solve the programming task below in a Python markdown code block. # Valid HK Phone Number ## Overview In Hong Kong, a valid phone number has the format ```xxxx xxxx``` where ```x``` is a decimal digit (0-9). For example: ## Task Define two functions, ```isValidHKPhoneNumber``` and ```hasValidHKPhoneNumber```, that...
{"functional": "_inputs = [['1234 5678'], ['2359 1478'], ['85748475'], ['3857 4756'], ['sklfjsdklfjsf'], [' 1234 5678 '], ['abcd efgh'], ['9684 2396'], ['836g 2986'], ['0000 0000'], ['123456789'], [' 987 634 '], [' 6 '], ['8A65 2986'], ['8368 2aE6'], ['8c65 2i86']]\n_outputs = [[True], [True], [False], [Fa...
142
368
coding
Solve the programming task below in a Python markdown code block. Three candidates take part in a TV show. In order to decide who will take part in the final game and probably become rich, they have to roll the Wheel of Fortune! The Wheel of Fortune is divided into 20 sections, each with a number from 5 to 100 (only ...
{"functional": "_inputs = [[[]]]\n_outputs = [[False]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return math.isclose(a, b, rel_tol=tol, abs_tol=tol)\n if isinstance(a, (list, tuple)):\n if len(a) != len(b): return False\n return all(_deep...
377
154
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. You are given an integer array nums. The adjacent integers in nums will perform the float division. For example, for nums = [2,3,4], we will evaluate the expression "2/3/4". However, you can add any number of parent...
{"functional": "def check(candidate):\n assert candidate(nums = [1000,100,10,2]) == \"1000/(100/10/2)\"\n assert candidate(nums = [2,3,4]) == \"2/(3/4)\"\n\n\ncheck(Solution().optimalDivision)"}
152
80
coding
Solve the programming task below in a Python markdown code block. Given an integer x, find 2 integers a and b such that: * 1 ≤ a,b ≤ x * b divides a (a is divisible by b). * a ⋅ b>x. * a/b<x. Input The only line contains the integer x (1 ≤ x ≤ 100). Output You should output two integers a and b, satis...
{"inputs": ["8\n", "7\n", "9\n", "4\n", "2\n", "5\n", "6\n", "3\n"], "outputs": ["3 3\n", "3 3\n", "4 4\n", "4 2\n", "2 2\n", "3 3\n", "3 3\n", "2 2\n"]}
148
86
coding
Solve the programming task below in a Python markdown code block. You are given a string $s$, consisting of $n$ letters, each letter is either 'a' or 'b'. The letters in the string are numbered from $1$ to $n$. $s[l; r]$ is a continuous substring of letters from index $l$ to $r$ of the string inclusive. A string is c...
{"inputs": ["1\n6\nbaaaaaaaaabaaaa`aaaaababaabaa\n", "1\n8\naaaaaabaaaab`aaaaa`aaabaaaaaa\n", "1\n3\naabaababaaaaaaaaaabaaaaaaaaab\n", "1\n8\naabaaaaaaaaaaaaaaaaaaaaaaaaaa\n", "1\n5\naabaababaaaaaaaaaabaaaaaaaaaa\n", "1\n3\naabaababaaaaa`aaaabaaaaaaaaab\n", "1\n8\naabaaaaaaaaaaaaaaa`aaaaaaaaaa\n", "1\n6\naabaababaaaaa`...
450
183
coding
Solve the programming task below in a Python markdown code block. Pasha loves his phone and also putting his hair up... But the hair is now irrelevant. Pasha has installed a new game to his phone. The goal of the game is following. There is a rectangular field consisting of n row with m pixels in each row. Initially, ...
{"inputs": ["1 1 1\n1 1\n", "1 1 1\n1 1\n", "1 2 1\n1 1\n", "2 2 4\n1 1\n1 2\n2 1\n2 2\n", "2 2 4\n1 1\n1 2\n2 1\n2 2\n", "2 2 5\n1 1\n2 1\n2 1\n1 2\n2 2\n", "1 1 5\n1 1\n1 1\n1 1\n1 1\n1 1\n", "1 5 5\n1 1\n1 2\n1 3\n1 4\n1 5\n"], "outputs": ["0\n", "0", "0\n", "4\n", "4", "5\n", "0\n", "0\n"]}
523
204
coding
Solve the programming task below in a Python markdown code block. At the annual family gathering, the family likes to find the oldest living family member’s age and the youngest family member’s age and calculate the difference between them. You will be given an array of all the family members' ages, in any order. The...
{"functional": "_inputs = [[[16, 22, 31, 44, 3, 38, 27, 41, 88]], [[5, 8, 72, 98, 41, 16, 55]], [[57, 99, 14, 32]], [[62, 0, 3, 77, 88, 102, 26, 44, 55]], [[2, 44, 34, 67, 88, 76, 31, 67]], [[46, 86, 33, 29, 87, 47, 28, 12, 1, 4, 78, 92]], [[66, 73, 88, 24, 36, 65, 5]], [[12, 76, 49, 37, 29, 17, 3, 65, 84, 38]], [[0, 1...
145
541
coding
Solve the programming task below in a Python markdown code block. ```if-not:racket Write a function called `repeat_str` which repeats the given string `src` exactly `count` times. ``` ```if:racket Write a function called `repeat-string` which repeats the given string `str` exactly `count` times. ``` Also feel free to r...
{"functional": "_inputs = [[4, 'a'], [3, 'hello '], [2, 'abc']]\n_outputs = [['aaaa'], ['hello hello hello '], ['abcabc']]\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)):\...
96
181
coding
Solve the programming task below in a Python markdown code block. The "BerCorp" company has got n employees. These employees can use m approved official languages for the formal correspondence. The languages are numbered with integers from 1 to m. For each employee we have the list of languages, which he knows. This li...
{"inputs": ["2 2\n0\n0\n", "2 2\n0\n0\n", "2 2\n1 2\n0\n", "3 3\n0\n0\n0\n", "3 3\n0\n0\n0\n", "3 2\n0\n0\n0\n", "3 4\n0\n0\n0\n", "2 2\n1 2\n0\n"], "outputs": ["2\n", "2", "1\n", "3\n", "3", "3\n", "3\n", "1"]}
493
127
coding
Solve the programming task below in a Python markdown code block. Divya's watch of worth Rs10 cr is abducted by N thieves(1,2....i...N). The fight over the watch leads to a final decision that it should belong to the thief who wins a simple game. The rules of the game state that every thief registers a time in the for...
{"inputs": ["2\n3\n12:28:26\n07:26:04\n11:23:17\n2\n07:43:25\n06:23:34"], "outputs": ["3\n1"]}
329
63
coding
Solve the programming task below in a Python markdown code block. This function takes two numbers as parameters, the first number being the coefficient, and the second number being the exponent. Your function should multiply the two numbers, and then subtract 1 from the exponent. Then, it has to print out an expressio...
{"functional": "_inputs = [[7, 8], [5, 9]]\n_outputs = [['56x^7'], ['45x^8']]\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 ...
256
174
coding
Solve the programming task below in a Python markdown code block. Chef has a square-shaped chart paper with the side length equal to N. He wants to cut out K \times K squares from this chart paper. Find the maximum number of K \times K squares he can cut from the entire chart paper. Note that, some part of the chart...
{"inputs": ["3\n5 1\n2 2\n5 2\n"], "outputs": ["25\n1\n4\n"]}
359
31
coding
Solve the programming task below in a Python markdown code block. A binary string is called *alternating* if no two adjacent characters of the string are equal. Formally, a binary string T of length M is called alternating if T_{i} \neq T_{i +1} for each 1 ≤ i < M. For example, 0, 1, 01, 10, 101, 010, 1010 are altern...
{"inputs": ["4\n3\n110\n4\n1010\n4\n0000\n7\n1101101\n"], "outputs": ["3\n4\n1\n5\n"]}
590
50
coding
Solve the programming task below in a Python markdown code block. Complete the method/function so that it converts dash/underscore delimited words into camel casing. The first word within the output should be capitalized **only** if the original word was capitalized (known as Upper Camel Case, also often referred to as...
{"functional": "_inputs = [[''], ['the_stealth_warrior'], ['The-Stealth-Warrior'], ['A-B-C']]\n_outputs = [[''], ['theStealthWarrior'], ['TheStealthWarrior'], ['ABC']]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return math.isclose(a, b, rel_tol=tol, abs_to...
137
192
coding
Solve the programming task below in a Python markdown code block. Mrs Jefferson is a great teacher. One of her strategies that helped her to reach astonishing results in the learning process is to have some fun with her students. At school, she wants to make an arrangement of her class to play a certain game with her p...
{"functional": "_inputs = [[10], [14], [16], [22], [65]]\n_outputs = [[[4, 3, 2, 1]], [[5, 4, 3, 2]], [[-1]], [[7, 6, 5, 4]], [[33, 32]]]\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, (...
364
218