task_type stringclasses 4
values | problem stringlengths 14 5.23k | solution stringlengths 1 8.29k | problem_tokens int64 9 1.02k | solution_tokens int64 1 1.98k |
|---|---|---|---|---|
coding | Solve the programming task below in a Python markdown code block.
Two beavers, Timur and Marsel, play the following game.
There are n logs, each of exactly m meters in length. The beavers move in turns. For each move a beaver chooses a log and gnaws it into some number (more than one) of equal parts, the length of eac... | {"inputs": ["1 9 3\n", "2 1 2\n", "1 2 1\n", "1 2 2\n", "2 2 1\n", "1 7 1\n", "2 2 2\n", "1 1 2\n"], "outputs": ["Timur\n", "Marsel\n", "Timur\n", "Marsel\n", "Marsel\n", "Timur\n", "Marsel\n", "Marsel\n"]} | 365 | 115 |
coding | Solve the programming task below in a Python markdown code block.
Riley is a very bad boy, but at the same time, he is a yo-yo master. So, he decided to use his yo-yo skills to annoy his friend Anton.
Anton's room can be represented as a grid with $n$ rows and $m$ columns. Let $(i, j)$ denote the cell in row $i$ and c... | {"inputs": ["7\n2 3 1 1\n4 4 1 2\n3 5 2 2\n5 1 2 1\n3 1 3 1\n1 1 1 1\n1000000000 1000000000 1000000000 50\n"], "outputs": ["1 1 2 3\n1 1 4 4\n1 1 3 5\n1 1 5 1\n1 1 3 1\n1 1 1 1\n1 1 1000000000 1000000000\n"]} | 709 | 170 |
coding | Solve the programming task below in a Python markdown code block.
Xavier is a computer science student.He is given a task by his teacher the task is to
generate a code which accepts an array of n integers.He now has to select an integer from this array but there is a trick in selection of integer from the array.
... | {"inputs": ["6\n3 5 7 1 2 8\n3", "10\n3 5 7 1 2 8 15 20 35 55\n6"], "outputs": ["1 3 5 7", "1 3 5 7 15 35 55"]} | 412 | 80 |
coding | Solve the programming task below in a Python markdown code block.
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1... | {"inputs": ["3\n2 2 3", "3\n2 4 3", "3\n2 4 5", "3\n2 4 8", "3\n2 6 8", "3\n4 6 8", "3\n4 2 8", "3\n6 2 8"], "outputs": ["2 2 3\n2 2 3\n2 2 3\n", "2 4 3\n2 4 3\n2 3 4\n", "2 4 5\n2 4 5\n2 4 5\n", "2 4 8\n2 4 8\n2 4 8\n", "2 6 8\n2 6 8\n2 6 8\n", "4 6 8\n4 6 8\n4 6 8\n", "4 2 8\n2 4 8\n2 4 8\n", "6 2 8\n2 6 8\n2 6 8\n"]... | 353 | 238 |
coding | Solve the programming task below in a Python markdown code block.
One of the built-in functions of Python is divmod, which takes two arguments $\boldsymbol{\alpha}$ and $\boldsymbol{b}$ and returns a tuple containing the quotient of $a/b$ first and then the remainder $\boldsymbol{a}$.
For example:
>>> print divmo... | {"inputs": ["177\n10\n"], "outputs": ["17\n7\n(17, 7)\n"]} | 291 | 30 |
coding | Solve the programming task below in a Python markdown code block.
There are N dots in a two-dimensional plane. The coordinates of the i-th dot are (x_i, y_i).
We will repeat the following operation as long as possible:
- Choose four integers a, b, c, d (a \neq c, b \neq d) such that there are dots at exactly three of ... | {"inputs": ["2\n1 4\n5 5", "2\n1 14\n5 5", "2\n3 2\n17 6", "2\n5 10\n17 4", "2\n9 10\n17 4", "2\n9 11\n17 4", "2\n7 11\n17 6", "2\n3 11\n17 6"], "outputs": ["0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n"]} | 333 | 138 |
coding | Solve the programming task below in a Python markdown code block.
In this Kata, you will be given an array of integers and your task is to return the number of arithmetic progressions of size `3` that are possible from that list. In each progression, the differences between the elements must be the same.
```
[1, 2, 3,... | {"functional": "_inputs = [[[1, 2, 3, 4, 5]], [[1, 2, 3, 5, 7, 9]], [[0, 5, 8, 9, 11, 13, 14, 16, 17, 19]], [[0, 1, 2, 3, 5, 6, 7, 11, 13, 15, 17, 19]], [[0, 1, 4, 5, 7, 9, 10, 13, 15, 16, 18, 19]], [[0, 1, 2, 3, 5, 8, 11, 13, 14, 16, 18, 19]]]\n_outputs = [[4], [5], [10], [17], [15], [13]]\nimport math\ndef _deep_eq(a... | 172 | 364 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
A self-dividing number is a number that is divisible by every digit it contains.
For example, 128 is a self-dividing number because 128 % 1 == 0, 128 % 2 == 0, and 128 % 8 == 0.
A self-dividing number is not allowed... | {"functional": "def check(candidate):\n assert candidate(left = 1, right = 22) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 15, 22]\n assert candidate(left = 47, right = 85) == [48,55,66,77]\n\n\ncheck(Solution().selfDividingNumbers)"} | 162 | 110 |
coding | Solve the programming task below in a Python markdown code block.
The numbers of all offices in the new building of the Tax Office of IT City will have lucky numbers.
Lucky number is a number that consists of digits 7 and 8 only. Find the maximum number of offices in the new building of the Tax Office given that a doo... | {"inputs": ["2\n", "1\n", "3\n", "5\n", "3\n", "5\n", "1\n", "6\n"], "outputs": ["6", "2", "14", "62", "14\n", "62\n", "2\n", "126\n"]} | 152 | 72 |
coding | Solve the programming task below in a Python markdown code block.
A palindrome is a word, phrase, number, or other sequence of characters which reads the same backward as forward. Examples of numerical palindromes are:
2332
110011
54322345
For a given number `num`, write a function to test if it's a numerical p... | {"functional": "_inputs = [[1221], [110011], [1456009006541], [123322], [1], [152], [9999], ['ACCDDCCA'], ['@14AbC'], ['1221'], [-450]]\n_outputs = [[True], [True], [True], [False], [True], [False], [True], ['Not valid'], ['Not valid'], ['Not valid'], ['Not valid']]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if i... | 237 | 260 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given an array of integers distance.
You start at the point (0, 0) on an X-Y plane, and you move distance[0] meters to the north, then distance[1] meters to the west, distance[2] meters to the south, distance[... | {"functional": "def check(candidate):\n assert candidate(distance = [2,1,1,2]) == True\n assert candidate(distance = [1,2,3,4]) == False\n assert candidate(distance = [1,1,1,1]) == True\n\n\ncheck(Solution().isSelfCrossing)"} | 149 | 72 |
coding | Solve the programming task below in a Python markdown code block.
Iahub is a big fan of tourists. He wants to become a tourist himself, so he planned a trip. There are n destinations on a straight road that Iahub wants to visit. Iahub starts the excursion from kilometer 0. The n destinations are described by a non-nega... | {"inputs": ["3\n2 3 5\n", "3\n2 3 8\n", "3\n4 3 8\n", "3\n3 3 8\n", "3\n5 3 8\n", "3\n6 3 8\n", "3\n2 3 5\n", "3\n6 3 11\n"], "outputs": ["22 3", "37 3\n", "35 3\n", "34 3\n", "12 1\n", "37 3\n", "22 3", "52 3\n"]} | 700 | 141 |
coding | Solve the programming task below in a Python markdown code block.
Polycarp doesn't like integers that are divisible by $3$ or end with the digit $3$ in their decimal representation. Integers that meet both conditions are disliked by Polycarp, too.
Polycarp starts to write out the positive (greater than $0$) integers w... | {"inputs": ["1\n5\n", "1\n5\n", "1\n2\n", "1\n3\n", "1\n6\n", "1\n1\n", "1\n4\n", "1\n8\n"], "outputs": ["7\n", "7\n", "2\n", "4\n", "8\n", "1\n", "5\n", "11\n"]} | 302 | 87 |
coding | Solve the programming task below in a Python markdown code block.
Chef's son wants to go on a roller coaster ride. The height of Chef's son is X inches while the minimum height required to go on the ride is H inches. Determine whether he can go on the ride or not.
------ Input Format ------
- The first line contains... | {"inputs": ["4\n15 20\n50 48\n32 32\n38 39\n"], "outputs": ["NO\nYES\nYES\nNO"]} | 357 | 43 |
coding | Solve the programming task below in a Python markdown code block.
Andy got a box of candies for Christmas. In fact, he discovered that the box contained several identical smaller boxes, and they could contain even smaller boxes, and so on. Formally, we say that candies are boxes of level 0, and for 1 ≤ i ≤ n, a level i... | {"inputs": ["5 1\n1 1 1 1 1\n1", "3 3\n3 3 3\n2 8 13"], "outputs": ["5", "3\n5\n8"]} | 554 | 51 |
coding | Solve the programming task below in a Python markdown code block.
Recently, Chef studied the binary numeral system and noticed that it is extremely simple to perform bitwise operations like AND, XOR or bit shift on non-negative integers, while it is much more complicated to perform arithmetic operations (e.g. addition,... | {"inputs": ["3\n100010\n0\n0\n100010\n11100\n1010"], "outputs": ["0\n1\n3"]} | 732 | 45 |
coding | Solve the programming task below in a Python markdown code block.
You are given an array $a$ consisting of $n$ integers.
Your task is to say the number of such positive integers $x$ such that $x$ divides each number from the array. In other words, you have to find the number of common divisors of all elements in the a... | {"inputs": ["1\n1\n", "1\n1\n", "1\n4\n", "1\n2\n", "1\n3\n", "1\n5\n", "1\n15\n", "1\n15\n"], "outputs": ["1\n", "1\n", "3\n", "2\n", "2\n", "2\n", "4\n", "4\n"]} | 327 | 88 |
coding | Solve the programming task below in a Python markdown code block.
Write a function `insertDash(num)`/`InsertDash(int num)` that will insert dashes ('-') between each two odd numbers in num. For example: if num is 454793 the output should be 4547-9-3. Don't count zero as an odd number.
Note that the number will always ... | {"functional": "_inputs = [[454793], [123456], [1003567], [24680], [13579]]\n_outputs = [['4547-9-3'], ['123456'], ['1003-567'], ['24680'], ['1-3-5-7-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 i... | 114 | 233 |
coding | Solve the programming task below in a Python markdown code block.
Imagine that there is a group of three friends: A, B and С. A owes B 20 rubles and B owes C 20 rubles. The total sum of the debts is 40 rubles. You can see that the debts are not organized in a very optimal manner. Let's rearrange them like that: assume ... | {"inputs": ["3 0\n", "1 0\n", "3 0\n", "4 3\n1 2 1\n2 3 1\n3 1 1\n", "4 3\n1 4 1\n2 3 1\n4 2 2\n", "4 3\n1 4 1\n2 3 1\n4 2 2\n", "4 2\n1 2 1\n2 3 1\n3 1 1\n", "4 2\n1 2 1\n2 3 1\n3 1 2\n"], "outputs": ["0\n", "0\n", "0\n", "0\n", "2\n", "2\n", "1\n", "1\n"]} | 573 | 176 |
coding | Solve the programming task below in a Python markdown code block.
You are given two arrays: an array $a$ consisting of $n$ zeros and an array $b$ consisting of $n$ integers.
You can apply the following operation to the array $a$ an arbitrary number of times: choose some subsegment of $a$ of length $k$ and add the arit... | {"inputs": ["1 1\n1\n", "3 3\n5 4 6\n", "6 3\n1 2 3 2 2 3\n", "6 3\n1 2 4 1 2 3\n", "1 1\n1000000000000\n", "3 3\n14159 26535 89793\n", "7 3\n50 17 81 25 42 39 96\n", "7 4\n1 10000 1 1 1 1 10000\n"], "outputs": ["1\n", "5\n", "3\n", "3\n", "1000000000000\n", "29931\n", "92\n", "7500\n"]} | 691 | 213 |
coding | Solve the programming task below in a Python markdown code block.
Read problems statements in [Hindi], [Mandarin Chinese], [Russian], [Vietnamese] and [Bengali] as well.
There is a garland — a cyclic rope with red and green flowers on it in some order. The sequence of flower colours is described by a string $s$; since... | {"inputs": ["3\nRG\nRRGG\nRR"], "outputs": ["yes\nyes\nno"]} | 464 | 23 |
coding | Solve the programming task below in a Python markdown code block.
For two positive integers a and b, let g(a, b) = [gcd]
(a, b) + [lcm](a, b).
For a positive integer N, let f(N) denote the minimum value of g(a, b) over all the pairs of positive integers (a, b) such that a+b = N.
Find out the number of ordered pairs ... | {"inputs": ["2\n4\n105"], "outputs": ["3\n14\n"]} | 422 | 22 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given an m x n matrix, return a new matrix answer where answer[row][col] is the rank of matrix[row][col].
The rank is an integer that represents how large an element is compared to other elements. It is calculated usi... | {"functional": "def check(candidate):\n assert candidate(matrix = [[1,2],[3,4]]) == [[1,2],[2,3]]\n assert candidate(matrix = [[7,7],[7,7]]) == [[1,1],[1,1]]\n assert candidate(matrix = [[20,-21,14],[-19,4,19],[22,-47,24],[-19,4,19]]) == [[4,2,3],[1,3,4],[5,1,6],[1,3,4]]\n assert candidate(matrix = [[7,3,6]... | 191 | 186 |
coding | Solve the programming task below in a Python markdown code block.
Paul hates palindromes. He assumes that string s is tolerable if each its character is one of the first p letters of the English alphabet and s doesn't contain any palindrome contiguous substring of length 2 or more.
Paul has found a tolerable string s ... | {"inputs": ["1 2\na\n", "1 2\nb\n", "1 1\na\n", "1 3\na\n", "1 4\nb\n", "1 4\na\n", "2 2\nab\n", "2 4\ncd\n"], "outputs": ["b\n", "NO\n", "NO\n", "b\n", "c\n", "b\n", "ba\n", "da\n"]} | 319 | 103 |
coding | Solve the programming task below in a Python markdown code block.
Janmansh has to submit 3 assignments for Chingari before 10 pm and he starts to do the assignments at X pm. Each assignment takes him 1 hour to complete. Can you tell whether he'll be able to complete all assignments on time or not?
------ Input Format ... | {"inputs": ["2\n7\n9\n"], "outputs": ["Yes\nNo\n"]} | 278 | 20 |
coding | Solve the programming task below in a Python markdown code block.
You have a long stick, consisting of $m$ segments enumerated from $1$ to $m$. Each segment is $1$ centimeter long. Sadly, some segments are broken and need to be repaired.
You have an infinitely long repair tape. You want to cut some pieces from the tap... | {"inputs": ["1 1 1\n1\n", "1 1 1\n1\n", "3 8 1\n2 6 7\n", "3 8 2\n4 6 8\n", "3 8 3\n1 2 6\n", "3 8 3\n1 2 6\n", "3 8 2\n4 6 8\n", "3 8 1\n2 6 7\n"], "outputs": ["1\n", "1", "6\n", "4\n", "3\n", "3", "4", "6"]} | 512 | 138 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given an array of positive integers nums, return an array answer that consists of the digits of each integer in nums after separating them in the same order they appear in nums.
To separate the digits of an integer is... | {"functional": "def check(candidate):\n assert candidate(nums = [13,25,83,77]) == [1,3,2,5,8,3,7,7]\n assert candidate(nums = [7,1,3,9]) == [7,1,3,9]\n\n\ncheck(Solution().separateDigits)"} | 133 | 82 |
coding | Solve the programming task below in a Python markdown code block.
Alice and Bob are playing a game of table tennis where irrespective of the point scored, every player makes 2 consecutive serves before the service changes. Alice makes the first serve of the match. Therefore the first 2 serves will be made by Alice, the... | {"inputs": ["4\n0 0\n0 2\n2 2\n4 7\n"], "outputs": ["Alice\nBob\nAlice\nBob\n"]} | 589 | 36 |
coding | Solve the programming task below in a Python markdown code block.
There are n kangaroos with pockets. Each kangaroo has a size (integer number). A kangaroo can go into another kangaroo's pocket if and only if the size of kangaroo who hold the kangaroo is at least twice as large as the size of kangaroo who is held.
Eac... | {"inputs": ["1\n1\n", "1\n2\n", "3\n1\n2\n4\n", "3\n1\n3\n4\n", "3\n1\n3\n5\n", "3\n1\n6\n5\n", "3\n1\n6\n9\n", "3\n1\n11\n9\n"], "outputs": ["1\n", "1\n", "2\n", "2\n", "2\n", "2\n", "2\n", "2\n"]} | 257 | 111 |
coding | Solve the programming task below in a Python markdown code block.
You are given a string S of length 2N consisting of lowercase English letters.
There are 2^{2N} ways to color each character in S red or blue. Among these ways, how many satisfy the following condition?
* The string obtained by reading the characters p... | {"inputs": ["4\ncacaabba", "4\nacbaacab", "4\nhgfedcba", "4\nabbaacac", "4\nhgfbdcea", "4\nacbaacac", "4\nhgfbccea", "4\ncacaabca"], "outputs": ["0\n", "4\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n"]} | 228 | 102 |
coding | Solve the programming task below in a Python markdown code block.
You're given an ancient book that unfortunately has a few pages in the wrong position, fortunately your computer has a list of every page number in order from ``1`` to ``n``.
You're supplied with an array of numbers, and should return an array with each... | {"functional": "_inputs = [[[1, 2, 10, 3, 4, 5, 8, 6, 7]], [[1, 2, 3, 4, 50, 5, 6, 7, 51, 8, 40, 9]], [[1, 2, 3000, 3, 4, 5, 8, 6, 7, 8, 100, 9, 40, 10, 11, 13]], [[1, 2, 3, 4, 50, 5, 6, 7, 51, 8, 9]], [[4, 1, 2, 3, 3, 4, 26, 5, 6, 2, 7]]]\n_outputs = [[[10, 8]], [[50, 51, 40]], [[3000, 8, 100, 40, 13]], [[50, 51]], [[... | 171 | 404 |
coding | Solve the programming task below in a Python markdown code block.
Given $n$ integers $a_1, a_2, \dots, a_n$. You can perform the following operation on them:
select any element $a_i$ ($1 \le i \le n$) and divide it by $2$ (round down). In other words, you can replace any selected element $a_i$ with the value $\left \l... | {"inputs": ["1\n2\n1000000000 2\n", "1\n2\n2000000000 1\n", "7\n3\n3 6 5\n4\n5 3 2 1\n5\n1 2 3 4 5\n1\n1000000000\n4\n2 8 7 5\n5\n8 26 5 21 10\n2\n5 14\n", "1\n30\n1073741824 1073741824 1610612736 1073741824 1342177280 1610612736 1879048192 1073741824 1207959552 1342177280 1476395008 1610612736 1744830464 1879048192 10... | 666 | 486 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given a string s and an integer k. You can choose one of the first k letters of s and append it at the end of the string.
Return the lexicographically smallest string you could have after applying the mentione... | {"functional": "def check(candidate):\n assert candidate(s = \"cba\", k = 1) == \"acb\"\n assert candidate(s = \"baaca\", k = 3) == \"aaabc\"\n\n\ncheck(Solution().orderlyQueue)"} | 103 | 58 |
coding | Solve the programming task below in a Python markdown code block.
B: 階層的計算機 (Hierarchical Calculator)
Problem
Ebi-chan has N formulae: y = a_i x for i =1, ..., N (inclusive). Now she considers a subsequence of indices with length k: s_1, s_2, ..., s_k. At first, let x_0 be 1 and evaluate s_1-th formulae with x = x_0.... | {"inputs": ["4\n0 0 0 2", "4\n2 0 0 0", "4\n0 0 0 1", "4\n0 0 0 0", "4\n1 0 0 0", "4\n1 0 0 1", "4\n2 0 -1 1", "4\n2 -1 1 2"], "outputs": ["1\n4\n", "1\n1\n", "0\n", "0\n", "0\n", "0\n", "1\n1\n", "2\n1\n4\n"]} | 620 | 136 |
coding | Solve the programming task below in a Python markdown code block.
Amr doesn't like Maths as he finds it really boring, so he usually sleeps in Maths lectures. But one day the teacher suspected that Amr is sleeping and asked him a question to make sure he wasn't.
First he gave Amr two positive integers n and k. Then he... | {"inputs": ["1 1 1\n", "1 2 2\n", "1 2 2\n", "1 1 1\n", "1 4 2\n", "1 2 1000\n", "2 2 1000\n", "5 3 1103\n"], "outputs": ["0", "0", "0\n", "0\n", "0\n", "4", "45", "590"]} | 319 | 109 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given the head of a linked list. Delete the middle node, and return the head of the modified linked list.
The middle node of a linked list of size n is the ⌊n / 2⌋th node from the start using 0-based indexing,... | {"functional": "def check(candidate):\n assert is_same_list(candidate(head = list_node([1,3,4,7,1,2,6])), list_node([1,3,4,1,2,6]))\n assert is_same_list(candidate(head = list_node([1,2,3,4])), list_node([1,2,4]))\n assert is_same_list(candidate(head = list_node([2,1])), list_node([2]))\n\n\ncheck(Solution().d... | 205 | 113 |
coding | Solve the programming task below in a Python markdown code block.
A social network for dogs called DH (DogHouse) has k special servers to recompress uploaded videos of cute cats. After each video is uploaded, it should be recompressed on one (any) of the servers, and only after that it can be saved in the social networ... | {"inputs": ["1 1\n1 1\n", "1 1\n1 1\n", "1 1\n2 1\n", "1 1\n2 2\n", "1 1\n2 4\n", "3 2\n1 5\n2 5\n3 5\n", "3 2\n1 1\n2 5\n3 5\n", "3 2\n2 1\n2 5\n3 5\n"], "outputs": ["2\n", "2\n", "3", "4", "6", "6\n7\n11\n", "2\n7\n8", "3\n7\n8"]} | 613 | 150 |
coding | Solve the programming task below in a Python markdown code block.
Read problem statements in [Mandarin], [Russian], and [Vietnamese] as well.
An index of an array is called a fixed point if the value on the index of the array is equal to the index itself. Formally, an index i of an array A of length N is a fixed point... | {"inputs": ["3\n2\n1 2\n3\n2 3 2\n4\n1 3 4 2\n"], "outputs": ["3\n1\n5\n"]} | 686 | 42 |
coding | Solve the programming task below in a Python markdown code block.
Takahashi is solving quizzes. He has easily solved all but the last one.
The last quiz has three choices: 1, 2, and 3.
With his supernatural power, Takahashi has found out that the choices A and B are both wrong.
Print the correct choice for this problem... | {"inputs": ["3\n2", "1\n3", "3\n2", "1\n3", "1\n2", "3\n1", "3\n1\n", "1\n2\n"], "outputs": ["1\n", "2\n", "1\n", "2\n", "3", "2", "2\n", "3\n"]} | 164 | 78 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
On day 1, one person discovers a secret.
You are given an integer delay, which means that each person will share the secret with a new person every day, starting from delay days after discovering the secret. You are a... | {"functional": "def check(candidate):\n assert candidate(n = 6, delay = 2, forget = 4) == 5\n assert candidate(n = 4, delay = 1, forget = 3) == 6\n\n\ncheck(Solution().peopleAwareOfSecret)"} | 183 | 65 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given a string s, remove the vowels 'a', 'e', 'i', 'o', and 'u' from it, and return the new string.
Please complete the following python code precisely:
```python
class Solution:
def removeVowels(self, s: str) -... | {"functional": "def check(candidate):\n assert candidate(s = \"leetcodeisacommunityforcoders\") == \"ltcdscmmntyfrcdrs\"\n assert candidate(s = \"aeiou\") == \"\"\n\n\ncheck(Solution().removeVowels)"} | 82 | 60 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given two strings needle and haystack, return the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.
Please complete the following python code precisely:
```python
class So... | {"functional": "def check(candidate):\n assert candidate(haystack = \"sadbutsad\", needle = \"sad\") == 0\n assert candidate(haystack = \"leetcode\", needle = \"leeto\") == -1\n\n\ncheck(Solution().strStr)"} | 81 | 61 |
coding | Solve the programming task below in a Python markdown code block.
You are given a string S of length N consisting of A, B and C, and an integer K which is between 1 and N (inclusive).
Print the string S after lowercasing the K-th character in it.
-----Constraints-----
- 1 ≤ N ≤ 50
- 1 ≤ K ≤ N
- S is a string of len... | {"inputs": ["1 1\nA\n", "3 2\nABC", "3 2\nACC", "3 2\nBCC", "3 2\nCBA", "3 2\nBDC", "6 2\nCCA", "3 2\nCDB"], "outputs": ["a\n", "AbC\n", "AcC\n", "BcC\n", "CbA\n", "BdC\n", "CcA\n", "CdB\n"]} | 149 | 108 |
coding | Solve the programming task below in a Python markdown code block.
AtCoDeer the deer found N rectangle lying on the table, each with height 1.
If we consider the surface of the desk as a two-dimensional plane, the i-th rectangle i(1≤i≤N) covers the vertical range of [i-1,i] and the horizontal range of [l_i,r_i], as show... | {"inputs": ["1\n1 400", "1\n1 400\n", "3\n2 5\n4 6\n2 4", "3\n1 3\n5 8\n1 3", "3\n1 3\n8 8\n1 3", "3\n2 3\n4 4\n2 4", "3\n2 1\n8 8\n1 3", "3\n2 1\n4 9\n1 8"], "outputs": ["0", "0\n", "0\n", "2\n", "5\n", "1\n", "7\n", "3\n"]} | 313 | 146 |
coding | Solve the programming task below in a Python markdown code block.
Guddu was participating in a programming contest. He only had one problem left when his mother called him for dinner. Guddu is well aware how angry his mother could get if he was late for dinner and he did not want to sleep on an empty stomach, so he had... | {"inputs": ["1\n3\n5 2 7"], "outputs": ["2"]} | 557 | 20 |
coding | Solve the programming task below in a Python markdown code block.
Jon Snow is on the lookout for some orbs required to defeat the white walkers. There are k different types of orbs and he needs at least one of each. One orb spawns daily at the base of a Weirwood tree north of the wall. The probability of this orb being... | {"inputs": ["1 1\n1\n", "1 1\n1\n", "2 2\n1\n2\n", "2 2\n1\n4\n", "1 2\n1\n4\n", "2 2\n1\n2\n", "1 1\n1000\n", "1 1\n1000\n"], "outputs": ["1\n", "1\n", "2\n2\n", "2\n2\n", "1\n1\n", "2\n2\n", "1\n", "1\n"]} | 315 | 124 |
coding | Solve the programming task below in a Python markdown code block.
You probably know the "like" system from Facebook and other pages. People can "like" blog posts, pictures or other items. We want to create the text that should be displayed next to such an item.
Implement a function `likes :: [String] -> String`, which... | {"functional": "_inputs = [[[]], [['Peter']], [['Jacob', 'Alex']], [['Max', 'John', 'Mark']], [['Alex', 'Jacob', 'Mark', 'Max']]]\n_outputs = [['no one likes this'], ['Peter likes this'], ['Jacob and Alex like this'], ['Max, John and Mark like this'], ['Alex, Jacob and 2 others like this']]\nimport math\ndef _deep_eq(a... | 231 | 220 |
coding | Solve the programming task below in a Python markdown code block.
After acquiring an extraordinary amount of knowledge through programming contests, Malvika decided to harness her expertise to train the next generation of Indian programmers. So, she decided to hold a programming camp. In the camp, she held a discussion... | {"inputs": ["2\n2 1\n3 2"], "outputs": ["1\n4"]} | 639 | 22 |
coding | Solve the programming task below in a Python markdown code block.
A subsequence of a string S is a string that can be obtained by deleting zero or more characters from S without changing the order of the remaining characters.
For example, arc, artistic and (an empty string) are all subsequences of artistic; abc and ci ... | {"inputs": ["atcoddrregularcontest", "ssetabcrdpuflrrdaemtn", "nstcebmrmrteqbfcaress", "rdscrblracsfldraqdqso", "jrpddbrrqrrm_qnfsecec", "cenesebp_mrrprraddprj", "qsadmbdbqok^r`qtmore_", "atooddrregularccntest"], "outputs": ["b\n", "g\n", "d\n", "e\n", "a\n", "f\n", "c\n", "b\n"]} | 228 | 128 |
coding | Solve the programming task below in a Python markdown code block.
N teams have come to participate in a competitive coding event called “Binary Battles”. It is a [single-elimination tournament] consisting of several rounds.
Note: It is known that N is a power of 2.
In one round, each team will be paired up with and c... | {"inputs": ["4\n4 10 5\n16 30 5\n32 45 15\n1024 23 9\n"], "outputs": ["25\n135\n285\n311"]} | 675 | 60 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given an array tasks where tasks[i] = [actuali, minimumi]:
actuali is the actual amount of energy you spend to finish the ith task.
minimumi is the minimum amount of energy you require to begin the ith task.
... | {"functional": "def check(candidate):\n assert candidate(tasks = [[1,2],[2,4],[4,8]]) == 8\n assert candidate(tasks = [[1,3],[2,4],[10,11],[10,12],[8,9]]) == 32\n assert candidate(tasks = [[1,7],[2,8],[3,9],[4,10],[5,11],[6,12]]) == 27\n\n\ncheck(Solution().minimumEffort)"} | 185 | 115 |
coding | Solve the programming task below in a Python markdown code block.
This is a spin off of my first [kata](http://www.codewars.com/kata/56bc28ad5bdaeb48760009b0). You are given a list of character sequences as a comma separated string. Write a function which returns another string containing all the character sequences ex... | {"functional": "_inputs = [[''], ['1'], ['1, 3'], ['1,2,3'], ['1,2,3,4']]\n_outputs = [[None], [None], [None], ['2'], ['2 3']]\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... | 143 | 191 |
coding | Solve the programming task below in a Python markdown code block.
Shapur was an extremely gifted student. He was great at everything including Combinatorics, Algebra, Number Theory, Geometry, Calculus, etc. He was not only smart but extraordinarily fast! He could manage to sum 1018 numbers in a single second.
One day ... | {"inputs": ["0\n0\n", "0\n1\n", "10\n01\n", "000\n111\n", "1110\n1010\n", "01110\n01100\n", "011101\n000001\n", "011101\n000000\n"], "outputs": ["0\n", "1\n", "11\n", "111\n", "0100\n", "00010\n", "011100\n", "011101\n"]} | 471 | 146 |
coding | Solve the programming task below in a Python markdown code block.
Bear Limak has n colored balls, arranged in one long row. Balls are numbered 1 through n, from left to right. There are n possible colors, also numbered 1 through n. The i-th ball has color t_{i}.
For a fixed interval (set of consecutive elements) of ba... | {"inputs": ["1\n1\n", "1\n1\n", "2\n2 1\n", "2\n2 1\n", "2\n2 2\n", "3\n1 1 1\n", "3\n2 1 1\n", "3\n1 1 1\n"], "outputs": ["1 \n", "1 ", "2 1 \n", "2 1 ", "0 3\n", "6 0 0 \n", "5 1 0\n", "6 0 0 "]} | 412 | 123 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given a digit string s, return the number of unique substrings of s where every digit appears the same number of times.
Please complete the following python code precisely:
```python
class Solution:
def equalDig... | {"functional": "def check(candidate):\n assert candidate(s = \"1212\") == 5\n assert candidate(s = \"12321\") == 9\n\n\ncheck(Solution().equalDigitFrequency)"} | 73 | 51 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given the root of a binary search tree, return a balanced binary search tree with the same node values. If there is more than one answer, return any of them.
A binary search tree is balanced if the depth of the two su... | {"functional": "def check(candidate):\n assert is_same_tree(candidate(root = tree_node([1,None,2,None,3,None,4,None,None])), tree_node([2,1,3,None,None,None,4]))\n\n\ncheck(Solution().balanceBST)"} | 158 | 59 |
coding | Solve the programming task below in a Python markdown code block.
You are given a sequence a1, a2, ..., aN. Find the smallest possible value of ai + aj, where 1 ≤ i < j ≤ N.
-----Input-----
The first line of the input contains an integer T denoting the number of test cases. The description of T test cases follows.
Th... | {"inputs": ["1\n4\n5 1 3 4", "1\n4\n5 1 3 8", "1\n4\n4 0 3 8", "1\n4\n7 1 3 0", "1\n4\n7 0 3 0", "1\n4\n5 1 6 8", "1\n4\n1 1 3 8", "1\n4\n5 2 9 8"], "outputs": ["4", "4\n", "3\n", "1\n", "0\n", "6\n", "2\n", "7\n"]} | 287 | 141 |
coding | Solve the programming task below in a Python markdown code block.
Given an array $a$ of $n$ elements, print any value that appears at least three times or print -1 if there is no such value.
-----Input-----
The first line contains an integer $t$ ($1 \leq t \leq 10^4$) — the number of test cases.
The first line of e... | {"inputs": ["7\n1\n1\n3\n2 2 2\n7\n2 2 3 3 4 2 2\n8\n1 4 3 4 3 2 4 1\n9\n1 1 1 2 2 2 3 3 3\n5\n1 5 2 4 3\n4\n4 4 4 4\n"], "outputs": ["-1\n2\n2\n4\n3\n-1\n4\n"]} | 499 | 116 |
coding | Solve the programming task below in a Python markdown code block.
There is a kangaroo at coordinate 0 on an infinite number line that runs from left to right, at time 0. During the period between time i-1 and time i, the kangaroo can either stay at his position, or perform a jump of length exactly i to the left or to t... | {"inputs": ["4", "1", "3", "6", "2", "12", "19", "24"], "outputs": ["3\n", "1\n", "2\n", "3", "2", "5\n", "6\n", "7\n"]} | 217 | 63 |
coding | Solve the programming task below in a Python markdown code block.
Santa has to send presents to the kids. He has a large stack of $n$ presents, numbered from $1$ to $n$; the topmost present has number $a_1$, the next present is $a_2$, and so on; the bottom present has number $a_n$. All numbers are distinct.
Santa has ... | {"inputs": ["2\n3 3\n3 1 2\n3 2 1\n7 2\n2 1 7 3 4 5 6\n3 1\n", "2\n3 3\n3 1 2\n3 2 1\n7 2\n4 1 7 3 4 5 6\n3 1\n", "2\n3 3\n3 1 2\n3 2 1\n7 2\n2 1 7 3 4 5 6\n6 1\n", "2\n3 3\n3 1 2\n3 2 1\n7 2\n2 1 7 3 4 5 6\n4 1\n", "2\n3 3\n3 1 2\n3 2 1\n7 2\n2 1 7 3 5 7 6\n2 1\n", "2\n3 3\n3 1 2\n3 2 1\n7 2\n2 1 7 3 5 5 6\n1 2\n", "2... | 611 | 393 |
coding | Solve the programming task below in a Python markdown code block.
# Two samurai generals are discussing dinner plans after a battle, but they can't seem to agree.
The discussion gets heated and you are cannot risk favoring either of them as this might damage your political standing with either of the two clans the sam... | {"functional": "_inputs = [['eat chicken', 'eat chicken and rice'], ['eat a burger and drink a coke', 'drink a coke'], ['i like turtles', 'what are you talking about'], ['aa bb', 'aa bb cc'], ['aa bb cc', 'bb cc'], ['aa bb cc', 'bb cc bb aa'], ['aa bb', 'cc dd'], ['aa bb', ''], ['', 'cc dd'], ['', '']]\n_outputs = [['e... | 236 | 272 |
coding | Solve the programming task below in a Python markdown code block.
Monocarp is the coach of the Berland State University programming teams. He decided to compose a problemset for a training session for his teams.
Monocarp has $n$ problems that none of his students have seen yet. The $i$-th problem has a topic $a_i$ (an... | {"inputs": ["2\n4\n2 4\n3 4\n2 1\n1 3\n5\n1 5\n2 4\n3 3\n4 2\n5 1\n", "2\n4\n2 4\n3 4\n2 1\n2 3\n5\n1 5\n2 4\n3 3\n4 2\n5 1\n", "2\n4\n2 4\n3 3\n2 2\n1 3\n5\n1 5\n2 4\n3 3\n4 2\n5 1\n", "2\n4\n4 4\n3 3\n2 2\n2 3\n5\n1 5\n2 4\n3 3\n4 2\n5 1\n", "2\n4\n2 4\n3 4\n2 2\n2 3\n5\n1 5\n2 3\n3 3\n4 2\n2 1\n", "2\n4\n4 4\n3 4\n2... | 522 | 410 |
coding | Solve the programming task below in a Python markdown code block.
Snuke has decided to use a robot to clean his room.
There are N pieces of trash on a number line. The i-th piece from the left is at position x_i. We would like to put all of them in a trash bin at position 0.
For the positions of the pieces of trash, ... | {"inputs": ["2 100\n1 13", "2 100\n1 25", "2 101\n1 25", "2 101\n1 42", "2 101\n1 10", "2 100\n0 13", "2 001\n1 25", "2 101\n0 10"], "outputs": ["370\n", "430\n", "433\n", "518\n", "358\n", "365\n", "133\n", "353\n"]} | 656 | 150 |
coding | Solve the programming task below in a Python markdown code block.
Chef is setting up a perfect bath for himself. He has X litres of hot water and Y litres of cold water.
The initial temperature of water in his bathtub is A degrees. On mixing water, the temperature of the bathtub changes as following:
The temperature... | {"inputs": ["4\n24 25 2 0\n37 37 2 9\n30 20 10 9\n30 31 0 20\n"], "outputs": ["YES\nYES\nNO\nNO\n"]} | 581 | 62 |
coding | Solve the programming task below in a Python markdown code block.
Suppose you are given a string s of length n consisting of lowercase English letters. You need to compress it using the smallest possible number of coins.
To compress the string, you have to represent s as a concatenation of several non-empty strings: s... | {"inputs": ["3 3 1\naba\n", "4 2 1\nabcd\n", "4 1 1\nabcd\n", "4 10 2\naaaa\n", "4 10 1\naaaa\n", "1 3102 3554\nb\n", "1 3102 6861\nb\n", "1 5003 6861\nb\n"], "outputs": ["7", "8\n", "4", "14\n", "12", "3102", "3102\n", "5003\n"]} | 535 | 145 |
coding | Solve the programming task below in a Python markdown code block.
In genetic the reverse complement of a sequence is formed by **reversing** the sequence and then taking the complement of each symbol.
The four nucleotides in DNA is Adenine (A), Cytosine (C), Guanine (G) and Thymine (Thymine).
- A is the complement o... | {"functional": "_inputs = [['TTCCGGAA'], ['GACTGACTGTA'], [''], ['XYZ']]\n_outputs = [['TTCCGGAA'], ['TACAGTCAGTC'], [''], ['Invalid sequence']]\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 isinstan... | 229 | 188 |
coding | Solve the programming task below in a Python markdown code block.
You are given a problemset consisting of $n$ problems. The difficulty of the $i$-th problem is $a_i$. It is guaranteed that all difficulties are distinct and are given in the increasing order.
You have to assemble the contest which consists of some prob... | {"inputs": ["1\n1\n", "1\n1\n", "2\n1 2\n", "2\n2 3\n", "2\n1 3\n", "2\n2 3\n", "2\n1 3\n", "2\n1 2\n"], "outputs": ["1\n", "1\n", "2\n", "2\n", "1\n", "2\n", "1\n", "2\n"]} | 747 | 98 |
coding | Solve the programming task below in a Python markdown code block.
There are two rival donut shops.
The first shop sells donuts at retail: each donut costs a dollars.
The second shop sells donuts only in bulk: box of b donuts costs c dollars. So if you want to buy x donuts from this shop, then you have to buy the smal... | {"inputs": ["1\n8042 1 2\n", "1\n9353 1 2\n", "1\n12313 2 2\n", "1\n12313 1 2\n", "1\n13806 1 2\n", "1\n165 82 165\n", "1\n165 82 173\n", "1\n165 165 165\n"], "outputs": ["-1 1\n", "-1 1\n", "-1 2\n", "-1 1\n", "-1 1\n", "-1 82\n", "1 82\n", "-1 165\n"]} | 762 | 173 |
coding | Solve the programming task below in a Python markdown code block.
You are given a sequence of non-negative integers $A_1, A_2, \ldots, A_N$. At most once, you may choose a non-negative integer $X$ and for each valid $i$, change $A_i$ to $A_i \oplus X$ ($\oplus$ denotes bitwise XOR).
Find the minimum possible value of t... | {"inputs": ["3\n5\n2 3 4 5 6\n4\n7 7 7 7\n3\n1 1 3"], "outputs": ["14\n0\n2"]} | 473 | 47 |
coding | Solve the programming task below in a Python markdown code block.
Read problems statements in Mandarin Chinese, Russian and Vietnamese as well.
You are given a tree consisting of n nodes numbered from 1 to n. The weights of edges of the tree can be any binary integer satisfying following Q conditions.
Each conditi... | {"inputs": ["3\n3 2\n1 2\n1 3\n1 2 0\n1 3 0\n3 0\n1 2\n2 3\n3 1\n1 2\n2 3\n1 2 1"], "outputs": ["1\n4\n2"]} | 670 | 70 |
coding | Solve the programming task below in a Python markdown code block.
There are N cards on a table, out of which X cards are face-up and the remaining are face-down.
In one operation, we can do the following:
Select any one card and flip it (i.e. if it was initially face-up, after the operation, it will be face-down and v... | {"inputs": ["4\n5 0\n4 2\n3 3\n10 2\n"], "outputs": ["0\n2\n0\n2\n"]} | 402 | 37 |
coding | Solve the programming task below in a Python markdown code block.
Two strings are said to be anagrams of each other if the letters of one string may be rearranged to make the other string. For example, the words 'elvis' and 'lives' are anagrams.
In this problem you’ll be given two strings. Your job is to find if the t... | {"inputs": ["2\nhello\nhelalo\na quick brown fox jumps over the lazy dog a quick brown fox jumps over the lazy dogaabbccddee\na", "18\nabcde\ncdeab\n121\n112\n1\nabcde\n1486\ncBaAC\na quick brown fox jumps over the lazy dog a quick brown fox jumps over the lazy dog87452117855477888\nabcdefghijklmnopqrstuvwxyzabcdefghij... | 640 | 343 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given three integers x, y, and bound, return a list of all the powerful integers that have a value less than or equal to bound.
An integer is powerful if it can be represented as xi + yj for some integers i >= 0 and j... | {"functional": "def check(candidate):\n assert candidate(x = 2, y = 3, bound = 10) == [2,3,4,5,7,9,10]\n assert candidate(x = 3, y = 5, bound = 15) == [2,4,6,8,10,14]\n\n\ncheck(Solution().powerfulIntegers)"} | 134 | 94 |
coding | Solve the programming task below in a Python markdown code block.
DNA is a biomolecule that carries genetic information. It is composed of four different building blocks, called nucleotides: adenine (A), thymine (T), cytosine (C) and guanine (G). Two DNA strands join to form a double helix, whereby the nucleotides of o... | {"functional": "_inputs = [['GTCTTAGTGTAGCTATGCATGC', 'GCATGCATAGCTACACTACGAC'], ['ATGCTACG', 'CGTAGCAT'], ['AGTCTGTATGCATCGTACCC', 'GGGTACGATGCATACAGACT'], ['TGCTACGTACGATCGACGATCCACGAC', 'GTCGTGGATCGTCGATCGTACGTAGCA'], ['ATGCCTACGGCCATATATATTTAG', 'CTAAATATGTATGGCCGTAGGCAT'], ['GTCACCGA', 'TCGGCTGAC'], ['TAATACCCGACT... | 437 | 604 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given an integer array arr, return the number of distinct bitwise ORs of all the non-empty subarrays of arr.
The bitwise OR of a subarray is the bitwise OR of each integer in the subarray. The bitwise OR of a subarray... | {"functional": "def check(candidate):\n assert candidate(arr = [0]) == 1\n assert candidate(arr = [1,1,2]) == 3\n assert candidate(arr = [1,2,4]) == 6\n\n\ncheck(Solution().subarrayBitwiseORs)"} | 124 | 67 |
coding | Solve the programming task below in a Python markdown code block.
Serval soon said goodbye to Japari kindergarten, and began his life in Japari Primary School.
In his favorite math class, the teacher taught him the following interesting definitions.
A parenthesis sequence is a string, containing only characters "(" a... | {"inputs": ["1\n?\n", "1\n(\n", "1\n)\n", "1\n)\n", "1\n?\n", "1\n(\n", "2\n??\n", "2\n((\n"], "outputs": [":(\n", ":(\n", ":(\n", ":(\n", ":(\n", ":(\n", "()\n", ":(\n"]} | 526 | 95 |
coding | Solve the programming task below in a Python markdown code block.
The only difference between easy and hard versions is the size of the input.
You are given a string $s$ consisting of $n$ characters, each character is 'R', 'G' or 'B'.
You are also given an integer $k$. Your task is to change the minimum number of cha... | {"inputs": ["3\n5 2\nBGGGG\n5 3\nRBRGR\n5 5\nBBBRR\n", "3\n5 2\nBGGGG\n5 3\nRBRGR\n5 5\nBBRBR\n", "3\n5 3\nBGGGG\n5 3\nRBRGR\n5 5\nBBBRR\n", "3\n5 2\nBGGGG\n5 4\nRBRGR\n5 5\nBBRBR\n", "3\n5 3\nBGGGG\n5 3\nRBRGR\n5 2\nBBBRR\n", "3\n5 2\nBGGGG\n5 4\nRBRGR\n5 5\nBRBRB\n", "3\n5 1\nBGGGG\n5 2\nRBRGR\n5 5\nBBRBR\n", "3\n5 1... | 591 | 294 |
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.
Chef has a sequence $A_{1}, A_{2}, \ldots, A_{N}$. He needs to find the number of pairs $(i, j)$ ($1 ≤ i < j ≤ N$) such that $A_{i} + A_{j} = A_{i} \... | {"inputs": ["2\n3\n2 4 2\n3\n0 2 3"], "outputs": ["1\n0"]} | 385 | 30 |
coding | Solve the programming task below in a Python markdown code block.
You have an integer variable x.
Initially, x=0.
Some person gave you a string S of length N, and using the string you performed the following operation N times.
In the i-th operation, you incremented the value of x by 1 if S_i=I, and decremented the valu... | {"inputs": ["5\nDIDII", "5\nDIIID", "5\nIDIID", "5\nIIDDI", "5\nDIIDI", "5\nIIIDD", "5\nDDIII", "5\nIDDII"], "outputs": ["1\n", "2\n", "2\n", "2\n", "1\n", "3\n", "1\n", "1\n"]} | 225 | 88 |
coding | Solve the programming task below in a Python markdown code block.
CSS colors are defined using a hexadecimal (HEX) notation for the combination of Red, Green, and Blue color values (RGB).
Specifications of HEX Color Code
■ It must start with a '#' symbol.
■ It can have $3$ or $\boldsymbol{6}$ digits.
■ Each digit i... | {"inputs": ["11\n#BED\n{\n color: #FfFdF8; background-color:#aef;\n font-size: 123px;\n background: -webkit-linear-gradient(top, #f9f9f9, #fff);\n}\n#Cab\n{\n background-color: #ABC;\n border: 2px dashed #fff;\n} \n"], "outputs": ["#FfFdF8\n#aef\n#f9f9f9\n#fff\n#ABC\n#fff\n"]} | 489 | 124 |
coding | Solve the programming task below in a Python markdown code block.
Alex doesn't like boredom. That's why whenever he gets bored, he comes up with games. One long winter evening he came up with a game and decided to play it.
Given a sequence a consisting of n integers. The player can make several steps. In a single step... | {"inputs": ["2\n1 2\n", "3\n1 2 3\n", "1\n100000\n", "5\n3 3 4 5 4\n", "5\n5 3 5 3 4\n", "5\n4 2 3 2 5\n", "5\n3 3 8 5 4\n", "5\n5 3 5 5 4\n"], "outputs": ["2\n", "4\n", "100000\n", "11\n", "16\n", "9\n", "19\n", "18\n"]} | 337 | 146 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given a string s which consists of lowercase or uppercase letters, return the length of the longest palindrome that can be built with those letters.
Letters are case sensitive, for example, "Aa" is not considered a pa... | {"functional": "def check(candidate):\n assert candidate(s = \"abccccdd\") == 7\n assert candidate(s = \"a\") == 1\n\n\ncheck(Solution().longestPalindrome)"} | 93 | 46 |
coding | Solve the programming task below in a Python markdown code block.
In Omkar's last class of math, he learned about the least common multiple, or $LCM$. $LCM(a, b)$ is the smallest positive integer $x$ which is divisible by both $a$ and $b$.
Omkar, having a laudably curious mind, immediately thought of a problem involvi... | {"inputs": ["1\n2\n", "1\n2\n", "2\n7\n8\n", "2\n7\n8\n", "2\n7\n16\n", "2\n8\n11\n", "3\n4\n6\n9\n", "3\n4\n5\n2\n"], "outputs": ["1 1\n", "1 1\n", "1 6\n4 4\n", "1 6\n4 4\n", "1 6\n8 8\n", "4 4\n1 10\n", "2 2\n3 3\n3 6\n", "2 2\n1 4\n1 1\n"]} | 469 | 153 |
coding | Solve the programming task below in a Python markdown code block.
Recently, Anton has found a set. The set consists of small English letters. Anton carefully wrote out all the letters from the set in one line, separated by a comma. He also added an opening curved bracket at the beginning of the line and a closing curve... | {"inputs": ["{}\n", "{}\n", "{a}\n", "{y}\n", "{x}\n", "{z}\n", "{a}\n", "{x}\n"], "outputs": ["0\n", "0\n", "1\n", "1\n", "1\n", "1\n", "1\n", "1\n"]} | 232 | 76 |
coding | Solve the programming task below in a Python markdown code block.
We will play a one-player game using a number line and N pieces.
First, we place each of these pieces at some integer coordinate.
Here, multiple pieces can be placed at the same coordinate.
Our objective is to visit all of the M coordinates X_1, X_2, ...... | {"inputs": ["111 0\n-608", "111 0\n-624", "110 0\n-4833", "010 1\n-4464", "100 1\n-4199", "111 0\n-3124", "110 0\n-3872", "111 0\n-4743"], "outputs": ["0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n"]} | 390 | 140 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given an array arr of integers, check if there exist two indices i and j such that :
i != j
0 <= i, j < arr.length
arr[i] == 2 * arr[j]
Please complete the following python code precisely:
```python
class Solution... | {"functional": "def check(candidate):\n assert candidate(arr = [10,2,5,3]) == True\n assert candidate(arr = [7,1,14,11]) == True\n assert candidate(arr = [3,1,7,11]) == False\n\n\ncheck(Solution().checkIfExist)"} | 91 | 75 |
coding | Solve the programming task below in a Python markdown code block.
# Task
Given an array of integers, sum consecutive even numbers and consecutive odd numbers. Repeat the process while it can be done and return the length of the final array.
# Example
For `arr = [2, 1, 2, 2, 6, 5, 0, 2, 0, 5, 5, 7, 7, 4, 3, 3, 9]`
... | {"functional": "_inputs = [[[2, 1, 2, 2, 6, 5, 0, 2, 0, 5, 5, 7, 7, 4, 3, 3, 9]], [[2, 1, 2, 2, 6, 5, 0, 2, 0, 3, 3, 3, 9, 2]], [[2]], [[1, 2]], [[1, 1, 2, 2]]]\n_outputs = [[6], [5], [1], [2], [1]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return math.is... | 369 | 277 |
coding | Solve the programming task below in a Python markdown code block.
# Task
Let's define a `parameter` of number `n` as the least common multiple (LCM) of the sum of its digits and their product.
Calculate the parameter of the given number `n`.
# Input/Output
`[input]` integer `n`
A positive integer. It is guaranteed... | {"functional": "_inputs = [[1234], [1], [2], [22], [11], [239], [999999999], [91], [344], [123456789]]\n_outputs = [[120], [1], [2], [4], [2], [378], [387420489], [90], [528], [362880]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return math.isclose(a, b, r... | 221 | 253 |
coding | Solve the programming task below in a Python markdown code block.
Let’s get to know our hero: Agent #134 - Mr. Slayer.
He was sent by his CSV agency to Ancient Rome in order to resolve some important national issues. However, something incredible has happened - the enemies have taken Julius Caesar as a prisoner!!!
Ca... | {"functional": "_inputs = [['123,.)(!?', 10], ['', 10], [None, 10], [' ', 10], ['Hello world!', 127], ['eBIIL TLOIA!', -127], ['ksdjai8983hdk?}{', 15], ['Hello world!', 0]]\n_outputs = [['123,.)(!?'], [''], [''], [''], ['eBIIL TLOIA!'], ['Hello world!'], ['zHsypx8983wsz?}{'], ['Hello world!']]\nimport math\ndef _deep... | 278 | 275 |
coding | Solve the programming task below in a Python markdown code block.
High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequence) consisting of equal letters.
Va... | {"inputs": ["1 0\na\n", "1 1\nb\n", "1 0\nb\n", "1 1\na\n", "1 1\na\n", "1 1\nb\n", "1 0\nb\n", "1 0\na\n"], "outputs": ["1\n", "1\n", "1\n", "1\n", "1\n", "1\n", "1\n", "1\n"]} | 276 | 102 |
coding | Solve the programming task below in a Python markdown code block.
# Task
You are given a binary string (a string consisting of only '1' and '0'). The only operation that can be performed on it is a Flip operation.
It flips any binary character ( '0' to '1' and vice versa) and all characters to the `right` of it.
... | {"functional": "_inputs = [['0101'], ['10000'], ['0000000000'], ['1111111111'], ['10101010101010'], ['11111000011111'], ['000001111100000'], ['111000000000'], ['00000000111111111'], ['1010101011111111111111000000000']]\n_outputs = [[3], [2], [0], [1], [14], [3], [2], [2], [1], [10]]\nimport math\ndef _deep_eq(a, b, tol... | 295 | 332 |
coding | Solve the programming task below in a Python markdown code block.
Vasya wrote down two strings s of length n and t of length m consisting of small English letters 'a' and 'b'. What is more, he knows that string t has a form "abab...", namely there are letters 'a' on odd positions and letters 'b' on even positions.
Sud... | {"inputs": ["1\nb\n1\n", "1\nb\n1\n", "1\nb\n2\n", "3\nb?a\n1\n", "3\nb?a\n1\n", "3\nba?\n1\n", "3\n?ab\n1\n", "5\nbb?a?\n1\n"], "outputs": ["0\n", "0", "0\n", "1\n", "1\n", "1\n", "1\n", "2\n"]} | 498 | 107 |
coding | Solve the programming task below in a Python markdown code block.
You are given $n$ one-dimensional segments (each segment is denoted by two integers — its endpoints).
Let's define the function $f(x)$ as the number of segments covering point $x$ (a segment covers the point $x$ if $l \le x \le r$, where $l$ is the left... | {"inputs": ["1\n2 9\n1 4\n3 7\n", "5\n1 4\n5 6\n1 4\n4 4\n1 2\n2 2\n1 1\n1 7\n1 4\n3 4\n", "5\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n", "5\n1 2\n1 1\n1 3\n2 4\n1 5\n2 6\n2 7\n3 5\n3 6\n1 1\n1 1\n", "4\n4 3\n1 3\n7 9\n2 5\n3 6\n2 9\n1 4\n3 7\n1 3\n2 4\n3 5\n1 4\n6 7\n5 5\n", "9\n4 3\n1 3\n7 9\n2 5\n3 6\n2 9\... | 502 | 412 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
There is an undirected graph with n nodes numbered from 0 to n - 1 (inclusive). You are given a 0-indexed integer array values where values[i] is the value of the ith node. You are also given a 0-indexed 2D integer ar... | {"functional": "def check(candidate):\n assert candidate(values = [0,32,10,43], edges = [[0,1,10],[1,2,15],[0,3,10]], maxTime = 49) == 75\n assert candidate(values = [5,10,15,20], edges = [[0,1,10],[1,2,10],[0,3,10]], maxTime = 30) == 25\n assert candidate(values = [1,2,3,4], edges = [[0,1,10],[1,2,11],[2,3,12... | 272 | 216 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
The variance of a string is defined as the largest difference between the number of occurrences of any 2 characters present in the string. Note the two characters may or may not be the same.
Given a string s consistin... | {"functional": "def check(candidate):\n assert candidate(s = \"aababbb\") == 3\n assert candidate(s = \"abcde\") == 0\n\n\ncheck(Solution().largestVariance)"} | 121 | 48 |
coding | Solve the programming task below in a Python markdown code block.
You have a set of four (4) balls labeled with different numbers: ball_1 (1), ball_2 (2), ball_3 (3) and ball(4) and we have 3 equal boxes for distribute them. The possible combinations of the balls, without having empty boxes, are:
```
(1) (... | {"functional": "_inputs = [[4, 3], [4, 2], [4, 4], [4, 1], [4, 0], [4, 5], [20, 8]]\n_outputs = [[6], [7], [1], [1], [0], ['It cannot be possible!'], [15170932662679]]\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... | 438 | 232 |
coding | Solve the programming task below in a Python markdown code block.
A Pythagorean triple is a triple of integer numbers $(a, b, c)$ such that it is possible to form a right triangle with the lengths of the first cathetus, the second cathetus and the hypotenuse equal to $a$, $b$ and $c$, respectively. An example of the Py... | {"inputs": ["1\n3\n", "1\n6\n", "1\n23\n", "1\n32\n", "1\n48\n", "1\n79\n", "1\n86\n", "1\n847\n"], "outputs": ["0\n", "1\n", "2\n", "3\n", "4\n", "5\n", "6\n", "20\n"]} | 542 | 94 |
coding | Solve the programming task below in a Python markdown code block.
Mr. Yamada Springfield Tanaka was appointed as Deputy Deputy Director of the National Land Readjustment Business Bureau. Currently, his country is in the midst of a major land readjustment, and if this land readjustment can be completed smoothly, his pro... | {"inputs": ["2\n-3 0 000 29\n-2 -100 18 100\n0\n-100 -20 -13 -280\n20 100 100 2\n0", "2\n-3 1 100 34\n-5 -100 18 100\n0\n-100 -20 -13 -284\n20 100 100 3\n0", "2\n-100 0 100 43\n-20 -100 18 100\n0\n-100 -4 -9 -284\n20 100 100 3\n0", "2\n-100 0 101 43\n-20 -100 18 100\n0\n-100 -4 -9 -284\n20 100 100 3\n0", "2\n-100 0 101... | 585 | 533 |
coding | Solve the programming task below in a Python markdown code block.
In mathematics, the [degree] of polynomials in one variable is the highest power of the variable in the algebraic expression with non-zero coefficient.
Chef has a polynomial in one variable x with N terms. The polynomial looks like A_{0}\cdot x^{0} + A_... | {"inputs": ["4\n1\n5\n2\n-3 3\n3\n0 0 5\n4\n1 2 4 0\n"], "outputs": ["0\n1\n2\n2"]} | 629 | 48 |
coding | Solve the programming task below in a Python markdown code block.
Write a program which manipulates a disjoint set S = {S1, S2, . . . , Sk}.
First of all, the program should read an integer n, then make a disjoint set where each element consists of 0, 1, ... n−1 respectively.
Next, the program should read an integer ... | {"inputs": ["5 5\n0 1 4\n0 2 3\n1 0 1\n1 3 4\n1 0 4\n1 2 2\n1 1 3\n1 1 4\n1 3 0\n0 0 4\n1 0 2\n1 3 0", "5 8\n0 1 4\n0 2 1\n1 1 2\n1 3 4\n1 1 4\n1 3 0\n0 1 3\n1 2 4\n1 3 0\n1 0 4\n1 0 2\n1 3 0", "5 12\n0 2 4\n0 2 3\n1 1 2\n1 3 4\n1 1 4\n1 3 2\n0 1 3\n1 2 4\n1 3 0\n0 0 4\n1 0 2\n1 3 0", "5 12\n0 1 4\n0 2 3\n1 1 2\n1 3 4\... | 367 | 760 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.