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 | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given an m x n grid grid of values 0, 1, or 2, where:
each 0 marks an empty land that you can pass by freely,
each 1 marks a building that you cannot pass through, and
each 2 marks an obstacle that you cannot... | {"functional": "def check(candidate):\n assert candidate(grid = [[1,0,2,0,1],[0,0,0,0,0],[0,0,1,0,0]]) == 7\n assert candidate(grid = [[1,0]]) == 1\n assert candidate(grid = [[1]]) == -1\n\n\ncheck(Solution().shortestDistance)"} | 233 | 86 |
coding | Solve the programming task below in a Python markdown code block.
On some day in January 2018, Takaki is writing a document. The document has a column where the current date is written in yyyy/mm/dd format. For example, January 23, 2018 should be written as 2018/01/23.
After finishing the document, she noticed that she... | {"inputs": ["2017/01/06", "2017/01/32", "2017/01//7", "2010/01/77", "2010/01/76", "2016/01/70", "2016/01/80", "2017/01/21"], "outputs": ["2018/01/06\n", "2018/01/32\n", "2018/01//7\n", "2018/01/77\n", "2018/01/76\n", "2018/01/70\n", "2018/01/80\n", "2018/01/21\n"]} | 262 | 204 |
coding | Solve the programming task below in a Python markdown code block.
Square Subsequences
A string is called a square string if it can be obtained by concatenating two copies of the same string. For example, "abab", "aa" are square strings, while "aaa", "abba" are not. Given a string, how many (non-empty) subsequences of ... | {"inputs": ["3\naaa\nabab\nbaaba"], "outputs": ["3\n3\n6"]} | 319 | 24 |
coding | Solve the programming task below in a Python markdown code block.
A series or sequence of numbers is usually the product of a function and can either be infinite or finite.
In this kata we will only consider finite series and you are required to return a code according to the type of sequence:
|Code|Type|Example|
|-|... | {"functional": "_inputs = [[[3, 5, 8, 1, 14, 3]], [[3, 5, 8, 9, 14, 23]], [[3, 5, 8, 8, 14, 14]], [[14, 9, 8, 5, 3, 1]], [[14, 14, 8, 8, 5, 3]], [[8, 8, 8, 8, 8, 8]], [[8, 9]], [[8, 8, 8, 8, 8, 9]], [[9, 8]], [[9, 9, 9, 8, 8, 8]], [[3, 5, 8, 1, 14, 2]]]\n_outputs = [[0], [1], [2], [3], [4], [5], [1], [2], [3], [4], [0]... | 335 | 364 |
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 | Solve the programming task below in a Python markdown code block.
Challenge:
Given a two-dimensional array, return a new array which carries over only those arrays from the original, which were not empty and whose items are all of the same type (i.e. homogenous). For simplicity, the arrays inside the array will only c... | {"functional": "_inputs = [[[[1, 5, 4], ['a', 3, 5], ['b'], [], ['1', 2, 3]]], [[[123, 234, 432], ['', 'abc'], [''], ['', 1], ['', '1'], []]], [[[1, 2, 3], ['1', '2', '3'], ['1', 2, 3]]]]\n_outputs = [[[[1, 5, 4], ['b']]], [[[123, 234, 432], ['', 'abc'], [''], ['', '1']]], [[[1, 2, 3], ['1', '2', '3']]]]\nimport math\n... | 212 | 300 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given an integer array nums, find a subarray that has the largest product, and return the product.
The test cases are generated so that the answer will fit in a 32-bit integer.
Please complete the following python c... | {"functional": "def check(candidate):\n assert candidate(nums = [2,3,-2,4]) == 6\n assert candidate(nums = [-2,0,-1]) == 0\n\n\ncheck(Solution().maxProduct)"} | 88 | 53 |
coding | Solve the programming task below in a Python markdown code block.
Chef's phone shows a Battery Low notification if the battery level is 15 \% or less.
Given that the battery level of Chef's phone is X \%, determine whether it would show a Battery low notification.
------ Input Format ------
- First line will conta... | {"inputs": ["3\n15\n3\n65"], "outputs": ["Yes\nYes\nNo"]} | 359 | 24 |
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:
John learns to play poker with his uncle. His uncle told him: Poker to be in accordance... | {"functional": "_inputs = [['D6H2S3D5SJCQSKC7D2C5H5H10SA', 'S2S3S5HJHQHKC8C9C10D4D5D6D7'], ['D6H2S3D5SJCQSKC7D2C5H5H10SA', 'C8C9C10D4D5D6D7S2S3S5HJHQHK']]\n_outputs = [['S3SJSKSAH2H5H10C5C7CQD2D5D6'], ['C5C7CQD2D5D6S3SJSKSAH2H5H10']]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance... | 382 | 309 |
coding | Solve the programming task below in a Python markdown code block.
`{a, e, i, o, u, A, E, I, O, U}`
Natural Language Understanding is the subdomain of Natural Language Processing where people used to design AI based applications have ability to understand the human languages. HashInclude Speech Processing team has a pr... | {"functional": "_inputs = [['bbbb'], ['baceb'], ['aeiou'], ['aeiouAEIOU']]\n_outputs = [[0], [16], [35], [220]]\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... | 310 | 185 |
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 | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given two string arrays word1 and word2, return true if the two arrays represent the same string, and false otherwise.
A string is represented by an array if the array elements concatenated in order forms the string.
... | {"functional": "def check(candidate):\n assert candidate(word1 = [\"ab\", \"c\"], word2 = [\"a\", \"bc\"]) == True\n assert candidate(word1 = [\"a\", \"cb\"], word2 = [\"ab\", \"c\"]) == False\n assert candidate(word1 = [\"abc\", \"d\", \"defg\"], word2 = [\"abcddefg\"]) == True\n\n\ncheck(Solution().arrayStr... | 100 | 109 |
coding | Solve the programming task below in a Python markdown code block.
# Task
John is playing a RPG game. The initial attack value of the player is `x`. The player will face a crowd of monsters. Each monster has different defense value.
If the monster's defense value is less than or equal to the player's attack value, the... | {"functional": "_inputs = [[50, [50, 105, 200]], [20, [30, 20, 15, 40, 100]]]\n_outputs = [[110], [205]]\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)... | 347 | 202 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given an integer n, return true if it is possible to represent n as the sum of distinct powers of three. Otherwise, return false.
An integer y is a power of three if there exists an integer x such that y == 3x.
Plea... | {"functional": "def check(candidate):\n assert candidate(n = 12) == True\n assert candidate(n = 91) == True\n assert candidate(n = 21) == False\n\n\ncheck(Solution().checkPowersOfThree)"} | 100 | 58 |
coding | Solve the programming task below in a Python markdown code block.
The store sells $n$ items, the price of the $i$-th item is $p_i$. The store's management is going to hold a promotion: if a customer purchases at least $x$ items, $y$ cheapest of them are free.
The management has not yet decided on the exact values of $... | {"inputs": ["2 1\n100 200\n1 1\n", "1 1\n1000000\n1 1\n", "3 1\n100 200 100\n2 1\n", "2 2\n100 200\n2 2\n2 1\n", "5 3\n5 3 1 5 2\n3 2\n1 1\n5 3\n", "5 2\n100 200 300 400 500\n1 1\n3 2\n", "5 3\n100 200 300 400 500\n2 1\n1 1\n3 2\n", "5 3\n100 200 300 400 500\n1 1\n3 2\n2 2\n"], "outputs": ["200\n", "1000000\n", "100\n"... | 477 | 302 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given an integer array nums where every element appears three times except for one, which appears exactly once. Find the single element and return it.
You must implement a solution with a linear runtime complexity and... | {"functional": "def check(candidate):\n assert candidate(nums = [2,2,3,2]) == 3\n assert candidate(nums = [0,1,0,1,0,1,99]) == 99\n\n\ncheck(Solution().singleNumber)"} | 97 | 63 |
coding | Solve the programming task below in a Python markdown code block.
Takahashi loves the number 7 and multiples of K.
Where is the first occurrence of a multiple of K in the sequence 7,77,777,\ldots? (Also see Output and Sample Input/Output below.)
If the sequence contains no multiples of K, print -1 instead.
-----Constr... | {"inputs": ["3", "1", "9", "2", "2\n", "1\n", "3\n", "7\n"], "outputs": ["3\n", "1\n", "9\n", "-1", "-1\n", "1\n", "3\n", "1\n"]} | 202 | 65 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You have a cubic storeroom where the width, length, and height of the room are all equal to n units. You are asked to place n boxes in this room where each box is a cube of unit side length. There are however some rul... | {"functional": "def check(candidate):\n assert candidate(n = 3) == 3\n assert candidate(n = 4) == 3\n assert candidate(n = 10) == 6\n\n\ncheck(Solution().minimumBoxes)"} | 165 | 56 |
coding | Solve the programming task below in a Python markdown code block.
Alice, Bob, and Charlie are contributing to buy a Netflix subscription. However, Netfix allows only two users to share a subscription.
Given that Alice, Bob, and Charlie have A, B, and C rupees respectively and a Netflix subscription costs X rupees, fin... | {"inputs": ["4\n1 1 1 3\n2 3 1 5\n4 2 3 4\n2 1 4 7\n"], "outputs": ["NO\nYES\nYES\nNO\n"]} | 487 | 52 |
coding | Solve the programming task below in a Python markdown code block.
Write a program that reads numbers until -1 is not given.
The program finds how many of the given numbers are more than 30, $N$.
It also finds the average weighted sum of even numbers, $A$.
The weight of the $i$th number is defined as the position of the... | {"inputs": ["1\n33 100 77 42 12 -1"], "outputs": ["4 38.91"]} | 384 | 36 |
coding | Solve the programming task below in a Python markdown code block.
-----Problem-----
Nikki's latest work is writing a story of letters. However, she finds writing story so boring that, after working for three hours, she realized that all she has written are M long words consisting entirely of letters A and B. Having... | {"inputs": ["3\nABAB\nAABB\nABBA"], "outputs": ["2"]} | 446 | 21 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
There are k workers who want to move n boxes from the right (old) warehouse to the left (new) warehouse. You are given the two integers n and k, and a 2D integer array time of size k x 4 where time[i] = [righti, picki... | {"functional": "def check(candidate):\n assert candidate(n = 1, k = 3, time = [[1,1,2,1],[1,1,3,1],[1,1,4,1]]) == 6\n assert candidate(n = 3, k = 2, time = [[1,9,1,8],[10,10,10,10]]) == 50\n\n\ncheck(Solution().findCrossingTime)"} | 370 | 106 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
There are n houses evenly lined up on the street, and each house is beautifully painted. You are given a 0-indexed integer array colors of length n, where colors[i] represents the color of the ith house.
Return the ma... | {"functional": "def check(candidate):\n assert candidate(colors = [1,1,1,6,1,1,1]) == 3\n assert candidate(colors = [1,8,3,8,3]) == 4\n assert candidate(colors = [0,1]) == 1\n\n\ncheck(Solution().maxDistance)"} | 130 | 77 |
coding | Solve the programming task below in a Python markdown code block.
Niwango-kun, an employee of Dwango Co., Ltd., likes Niconico TV-chan, so he collected a lot of soft toys of her and spread them on the floor.
Niwango-kun has N black rare soft toys of Niconico TV-chan and they are spread together with ordinary ones. He ... | {"inputs": ["3 2\n0 0\n1 0\n2 0", "1 4\n0 0\n2 1\n2 0", "3 8\n0 0\n0 0\n2 0", "3 4\n0 0\n1 0\n2 0", "3 4\n0 0\n1 1\n2 0", "3 4\n0 0\n2 1\n2 0", "1 4\n0 0\n2 1\n2 1", "3 4\n0 0\n0 0\n2 0"], "outputs": ["2\n", "0\n", "8\n", "2\n", "2\n", "2\n", "0\n", "4\n"]} | 583 | 174 |
coding | Solve the programming task below in a Python markdown code block.
Sereja has two sequences a and b and number p. Sequence a consists of n integers a_1, a_2, ..., a_{n}. Similarly, sequence b consists of m integers b_1, b_2, ..., b_{m}. As usual, Sereja studies the sequences he has. Today he wants to find the number of ... | {"inputs": ["1 1 1\n1\n1\n", "1 1 2\n1\n2\n", "1 1 2\n1\n2\n", "1 1 1\n1\n1\n", "1 1 2\n1\n3\n", "2 2 1\n1 2\n2 1\n", "2 2 1\n1 2\n1 2\n", "2 2 1\n1 2\n2 1\n"], "outputs": ["1\n1\n", "0\n", "0\n", "1\n1 ", "0\n\n", "1\n1\n", "1\n1\n", "1\n1 "]} | 380 | 156 |
coding | Solve the programming task below in a Python markdown code block.
Let's consider one interesting word game. In this game you should transform one word into another through special operations.
Let's say we have word w, let's split this word into two non-empty parts x and y so, that w = xy. A split operation is transfo... | {"inputs": ["aa\naa\n1\n", "ab\nba\n0\n", "hi\nhi\n1\n", "ab\nba\n9\n", "aa\naa\n0\n", "ab\nab\n9\n", "ab\nca\n2\n", "ab\nbb\n2\n"], "outputs": ["1\n", "0\n", "0\n", "1\n", "1\n", "0\n", "0\n", "0\n"]} | 453 | 102 |
coding | Solve the programming task below in a Python markdown code block.
Let S be the sum of divisors of an integer N excluding the number itself. When N = S, N is called a perfect number, when N> S, N is called a defendant number, and when N <S, N is called an abundant number. Create a program that determines whether a given... | {"inputs": ["1\n1\n5\n4\n6\n12\n18\n4\n820514\n99999998\n699564\n100001100\n0", "1\n1\n5\n6\n6\n12\n18\n4\n820514\n99999998\n699564\n100001100\n0", "1\n1\n5\n4\n6\n1\n5\n5\n1356316\n171009028\n699564\n100001100\n0", "1\n1\n5\n6\n6\n12\n20\n4\n820514\n99999998\n206539\n100101100\n0", "1\n1\n9\n4\n6\n0\n5\n5\n1356316\n17... | 330 | 802 |
coding | Solve the programming task below in a Python markdown code block.
Our good friend Mole is trying to code a big message. He is typing on an unusual keyboard with characters arranged in following way:
qwertyuiop
asdfghjkl;
zxcvbnm,./
Unfortunately Mole is blind, so sometimes it is problem for him to put his hands a... | {"inputs": ["L\nq\n", "L\no\n", "L\n,\n", "L\nz\n", "R\n.\n", "R\no\n", "R\nw\n", "R\nx\n"], "outputs": ["w\n", "p\n", ".\n", "x\n", ",\n", "i\n", "q\n", "z\n"]} | 282 | 86 |
coding | Solve the programming task below in a Python markdown code block.
"Ring Ring!!"
Sherlock's phone suddenly started ringing. And it was none other than Jim Moriarty..
"Long time no see ! You miss me right ? Anyway we'll talk about it later . Let me first tell you something. Dr.Watson is with me . And you've got only on... | {"inputs": ["2\n4 4\n6 5"], "outputs": ["EVEN\nODD"]} | 332 | 24 |
coding | Solve the programming task below in a Python markdown code block.
problem
Chairman K is a regular customer of the JOI pizza shop in the center of JOI city. For some reason, he decided to start a life-saving life this month. So he wanted to order the pizza with the highest calories per dollar among the pizzas he could ... | {"inputs": ["3\n2 3\n7\n0\n37\n110", "3\n2 1\n7\n0\n37\n110", "3\n2 1\n7\n0\n37\n010", "3\n2 1\n2\n0\n35\n010", "3\n2 2\n2\n0\n35\n000", "3\n5 2\n1\n0\n45\n101", "3\n1 2\n1\n0\n45\n101", "3\n2 1\n8\n0\n37\n010"], "outputs": ["23\n", "39\n", "14\n", "12\n", "9\n", "16\n", "34\n", "15\n"]} | 737 | 189 |
coding | Solve the programming task below in a Python markdown code block.
There is a farm whose length and width are A yard and B yard, respectively. A farmer, John, made a vertical road and a horizontal road inside the farm from one border to another, as shown below: (The gray part represents the roads.)
What is the area of ... | {"inputs": ["6 7", "2 1", "0 2", "0 4", "9 2", "2 4", "0 0", "7 2"], "outputs": ["30\n", "0\n", "-1\n", "-3\n", "8\n", "3\n", "1\n", "6\n"]} | 192 | 79 |
coding | Solve the programming task below in a Python markdown code block.
In CODE FESTIVAL XXXX, there are N+1 participants from all over the world, including Takahashi.
Takahashi checked and found that the time gap (defined below) between the local times in his city and the i-th person's city was D_i hours. The time gap betw... | {"inputs": ["1\n9", "1\n0", "1\n11", "1\n10", "2\n8 8", "2\n2 0", "2\n6 8", "2\n9 7"], "outputs": ["9\n", "0", "11\n", "10\n", "8\n", "0\n", "6\n", "7\n"]} | 353 | 89 |
coding | Solve the programming task below in a Python markdown code block.
The Chef's latest idea is that some cooks might work better in pairs. So, he is going to experiment by pairing up some of his employees to see if the quality of the food prepared in his kitchen increases. However, only some pairs of employees are compati... | {"inputs": ["2\n4 5\n0 1\n1 2\n2 3\n1 3\n3 0\n4 3\n0 1\n2 3\n2 1", "2\n4 5\n0 1\n1 2\n2 3\n1 3\n3 0\n4 3\n0 1\n2 3\n2 0", "2\n4 5\n0 1\n1 2\n0 3\n1 3\n1 0\n4 3\n0 1\n2 3\n2 0", "2\n4 5\n0 1\n1 2\n1 3\n1 3\n2 0\n4 3\n0 1\n2 3\n2 0", "2\n4 5\n0 1\n1 2\n1 3\n0 3\n3 0\n4 1\n0 1\n2 3\n2 1", "2\n8 5\n0 1\n1 2\n1 3\n0 3\n4 0\... | 533 | 415 |
coding | Solve the programming task below in a Python markdown code block.
Two participants are each given a pair of distinct numbers from 1 to 9 such that there's exactly one number that is present in both pairs. They want to figure out the number that matches by using a communication channel you have access to without reveali... | {"inputs": ["2 1\n1 2 1 3\n1 2\n", "2 1\n4 5 6 7\n4 7\n", "2 1\n1 2 1 3\n1 2\n", "2 1\n4 5 6 7\n4 7\n", "2 1\n1 4 1 3\n1 2\n", "2 1\n4 6 6 7\n4 7\n", "2 1\n3 6 6 7\n4 7\n", "2 2\n1 2 3 4\n1 5 3 4\n"], "outputs": ["1\n", "-1\n", "1", "-1", "1\n", "-1\n", "7\n", "1\n"]} | 754 | 184 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
There is a family tree rooted at 0 consisting of n nodes numbered 0 to n - 1. You are given a 0-indexed integer array parents, where parents[i] is the parent for node i. Since node 0 is the root, parents[0] == -1.
The... | {"functional": "def check(candidate):\n assert candidate(parents = [-1,0,0,2], nums = [1,2,3,4]) == [5,1,1,1]\n assert candidate(parents = [-1,0,1,0,3,3], nums = [5,4,6,2,1,3]) == [7,1,1,4,2,1]\n assert candidate(parents = [-1,2,3,0,2,4,1], nums = [2,3,4,5,6,7,8]) == [1,1,1,1,1,1,1]\n\n\ncheck(Solution().small... | 213 | 164 |
coding | Solve the programming task below in a Python markdown code block.
Read problems statements in Mandarin chinese, Russian and Vietnamese as well.
As New Year is approaching, Salik is studying functions in order to sharpen his math skills. Instead of regular functions, he is studying a strange function F which operates ... | {"inputs": ["3\n5 2\n7 2\n127 1"], "outputs": ["7\n4\n1"]} | 510 | 30 |
coding | Solve the programming task below in a Python markdown code block.
Let's call the following process a transformation of a sequence of length $n$.
If the sequence is empty, the process ends. Otherwise, append the greatest common divisor (GCD) of all the elements of the sequence to the result and remove one arbitrary ele... | {"inputs": ["3\n", "2\n", "1\n", "4\n", "5\n", "6\n", "7\n", "8\n"], "outputs": ["1 1 3 ", "1 2 ", "1 ", "1 1 2 4 ", "1 1 1 2 4 ", "1 1 1 2 2 6 ", "1 1 1 1 2 2 6 ", "1 1 1 1 2 2 4 8 "]} | 378 | 119 |
coding | Solve the programming task below in a Python markdown code block.
Read problems statements in Mandarin Chinese and Russian.
Little Elephant from Zoo of Lviv likes to paint.
He has n objects to paint, ordered in a row and numbered form left to right starting from 1. There are totally c colors, numbered from 0 to c-1... | {"inputs": ["2\n4 3 4\n1 2\n2 4\n3 3\n1 4\n7 10 7\n7 7\n3 4\n1 2\n5 5\n4 5\n2 7\n3 3"], "outputs": ["3.444444444\n22.943125000"]} | 442 | 92 |
coding | Solve the programming task below in a Python markdown code block.
You are given two strings $s$ and $t$. The string $s$ consists of lowercase Latin letters and at most one wildcard character '*', the string $t$ consists only of lowercase Latin letters. The length of the string $s$ equals $n$, the length of the string $... | {"inputs": ["1 1\nv\nk\n", "1 1\n*\na\n", "1 1\na\na\n", "1 1\nb\na\n", "1 1\n*\na\n", "1 1\nb\na\n", "1 1\na\na\n", "1 1\n+\na\n"], "outputs": ["NO\n", "YES\n", "YES\n", "NO\n", "YES\n", "NO\n", "YES\n", "NO\n"]} | 596 | 115 |
coding | Solve the programming task below in a Python markdown code block.
Rushitote went to a programming contest to distribute apples and oranges to the contestants.
He has N apples and M oranges, which need to be divided equally amongst the contestants. Find the maximum possible number of contestants such that:
Every cont... | {"inputs": ["3\n1 5\n2 4\n4 6"], "outputs": ["1\n2\n2"]} | 396 | 28 |
coding | Solve the programming task below in a Python markdown code block.
Polycarp invited all his friends to the tea party to celebrate the holiday. He has n cups, one for each of his n friends, with volumes a_1, a_2, ..., a_{n}. His teapot stores w milliliters of tea (w ≤ a_1 + a_2 + ... + a_{n}). Polycarp wants to pour tea ... | {"inputs": ["1 1\n1\n", "1 1\n2\n", "1 1\n1\n", "1 1\n2\n", "1 2\n2\n", "1 0\n2\n", "1 1\n20\n", "1 1\n38\n"], "outputs": ["1 \n", "1 \n", "1 ", "1 ", "2\n", "-1\n", "-1\n", "-1\n"]} | 464 | 104 |
coding | Solve the programming task below in a Python markdown code block.
# The President's phone is broken
He is not very happy.
The only letters still working are uppercase ```E```, ```F```, ```I```, ```R```, ```U```, ```Y```.
An angry tweet is sent to the department responsible for presidential phone maintenance.
# Kat... | {"functional": "_inputs = [['FURYYYFIREYYFIRE'], ['FIREYYFURYYFURYYFURRYFIRE'], ['FYRYFIRUFIRUFURE'], [''], ['FURYFURYFURY'], ['FURYFURYFURYFURY'], ['FURYFURYFURYFURYFURY'], ['FIRE'], ['FIREFIRE'], ['FIREFIREFIRE'], ['FIREFIREFIREFIRE'], ['FIREFIREFIREFIREFIRE']]\n_outputs = [['I am furious. You and you are fired!'], [... | 394 | 369 |
coding | Solve the programming task below in a Python markdown code block.
String can be called correct if it consists of characters "0" and "1" and there are no redundant leading zeroes. Here are some examples: "0", "10", "1001".
You are given a correct string s.
You can perform two different operations on this string: swa... | {"inputs": ["1\n1\n", "1\n0\n", "1\n0\n", "1\n1\n", "2\n10\n", "2\n11\n", "2\n11\n", "2\n10\n"], "outputs": ["1\n", "0\n", "0\n", "1\n", "10\n", "1\n", "1\n", "10\n"]} | 373 | 92 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given an array of positive integers beans, where each integer represents the number of magic beans found in a particular magic bag.
Remove any number of beans (possibly none) from each bag such that the number... | {"functional": "def check(candidate):\n assert candidate(beans = [4,1,6,5]) == 4\n assert candidate(beans = [2,10,3,2]) == 7\n\n\ncheck(Solution().minimumRemoval)"} | 146 | 59 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given an array points where points[i] = [xi, yi] represents a point on the X-Y plane, return true if these points are a boomerang.
A boomerang is a set of three points that are all distinct and not in a straight line.... | {"functional": "def check(candidate):\n assert candidate(points = [[1,1],[2,3],[3,2]]) == True\n assert candidate(points = [[1,1],[2,2],[3,3]]) == False\n\n\ncheck(Solution().isBoomerang)"} | 106 | 63 |
coding | Solve the programming task below in a Python markdown code block.
problem
You are in charge of quality control at a machine manufacturing plant. This machine requires a power supply, a motor, and a cable as parts. The manufacturing plant has a power supply, b motors, and c cables, numbered from 1 to a, a + 1 to a + b,... | {"inputs": ["2 2 2\n4\n2 4 5 0\n2 3 6 0\n1 4 5 0\n2 3 2 1\n0 0 0", "2 2 2\n4\n2 4 5 0\n2 3 6 0\n1 4 5 0\n2 3 2 0\n0 0 0", "3 2 2\n4\n2 4 5 0\n2 3 6 0\n1 4 5 0\n2 3 5 1\n0 0 0", "2 2 2\n4\n3 4 5 0\n2 3 6 0\n1 4 4 1\n2 3 2 0\n0 0 0", "2 2 2\n4\n2 4 5 0\n1 3 6 0\n1 4 5 0\n2 3 2 1\n0 0 0", "3 2 2\n4\n2 4 5 0\n2 4 6 0\n1 4 ... | 692 | 504 |
coding | Solve the programming task below in a Python markdown code block.
Two boys decided to compete in text typing on the site "Key races". During the competition, they have to type a text consisting of s characters. The first participant types one character in v_1 milliseconds and has ping t_1 milliseconds. The second parti... | {"inputs": ["5 1 2 1 2\n", "3 3 1 1 1\n", "4 5 3 1 5\n", "1 1 1 1 1\n", "8 8 1 1 1\n", "1 2 8 8 5\n", "1 2 8 9 8\n", "2 9 8 8 9\n"], "outputs": ["First\n", "Second\n", "Friendship\n", "Friendship\n", "Second\n", "Friendship\n", "First\n", "Friendship\n"]} | 506 | 138 |
coding | Solve the programming task below in a Python markdown code block.
Given integers ${b}$ and $a$, find the smallest integer ${h}$, such that there exists a triangle of height ${h}$, base ${b}$, having an area of at least $a$.
Example
$b=4$
${a=6}$
The minimum height ${h}$ is $3$. One example is a triangle formed... | {"inputs": ["2 2\n", "17 100\n"], "outputs": ["2\n", "12\n"]} | 485 | 30 |
coding | Solve the programming task below in a Python markdown code block.
In this kata, your task is to write a function `to_bytes(n)` (or `toBytes(n)` depending on language) that produces a list of bytes that represent a given non-negative integer `n`. Each byte in the list is represented by a string of `'0'` and `'1'` of len... | {"functional": "_inputs = [[0], [1]]\n_outputs = [[['00000000']], [['00000001']]]\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 Fals... | 136 | 176 |
coding | Solve the programming task below in a Python markdown code block.
A sequence $a_1, a_2, \dots, a_n$ is called good if, for each element $a_i$, there exists an element $a_j$ ($i \ne j$) such that $a_i+a_j$ is a power of two (that is, $2^d$ for some non-negative integer $d$).
For example, the following sequences are goo... | {"inputs": ["1\n1\n", "1\n1\n", "1\n2\n", "1\n5\n", "1\n4\n", "1\n6\n", "1\n16\n", "1\n31\n"], "outputs": ["1\n", "1", "1\n", "1\n", "1\n", "1\n", "1\n", "1\n"]} | 653 | 87 |
coding | Solve the programming task below in a Python markdown code block.
A particular month has 30 days, numbered from 1 to 30.
Day 1 is a Monday, and the usual 7-day week is followed (so day 2 is Tuesday, day 3 is Wednesday, and so on).
Every Saturday and Sunday is a holiday. There are N festival days, which are also holid... | {"inputs": ["3\n2\n5 7\n3\n23 1 6\n1\n13\n"], "outputs": ["9\n10\n8\n"]} | 668 | 39 |
coding | Solve the programming task below in a Python markdown code block.
Iahub got bored, so he invented a game to be played on paper.
He writes n integers a_1, a_2, ..., a_{n}. Each of those integers can be either 0 or 1. He's allowed to do exactly one move: he chooses two indices i and j (1 ≤ i ≤ j ≤ n) and flips all valu... | {"inputs": ["1\n1\n", "1\n0\n", "1\n0\n", "1\n1\n", "2\n1 1\n", "2\n1 1\n", "2\n0 0\n", "4\n1 0 0 1\n"], "outputs": ["0\n", "1\n", "1", "0\n", "1\n", "1\n", "2\n", "4\n"]} | 398 | 97 |
coding | Solve the programming task below in a Python markdown code block.
Simple, given a string of words, return the length of the shortest word(s).
String will never be empty and you do not need to account for different data types.
Also feel free to reuse/extend the following starter code:
```python
def find_short(s):
``` | {"functional": "_inputs = [['bitcoin take over the world maybe who knows perhaps'], ['turns out random test cases are easier than writing out basic ones'], ['lets talk about javascript the best language'], ['i want to travel the world writing code one day'], ['Lets all go on holiday somewhere very cold']]\n_outputs = [... | 68 | 220 |
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\n21\n*1\n321\n*21\n**1\n4321\n*321\n**21\n***1"]} | 212 | 54 |
coding | Solve the programming task below in a Python markdown code block.
Given is a string S consisting of lowercase English letters. Find the maximum positive integer K that satisfies the following condition:
* There exists a partition of S into K non-empty strings S=S_1S_2...S_K such that S_i \neq S_{i+1} (1 \leq i \leq K-... | {"inputs": ["a`bbaa", "b`aba`", "b``aaa", "a`bcaa", "a`acaa", "c`aaaa", "b`aaaa", "b`abaa"], "outputs": ["5\n", "6\n", "4\n", "5\n", "5\n", "5\n", "5\n", "5\n"]} | 198 | 84 |
coding | Solve the programming task below in a Python markdown code block.
Summer is coming! It's time for Iahub and Iahubina to work out, as they both want to look hot at the beach. The gym where they go is a matrix a with n lines and m columns. Let number a[i][j] represents the calories burned by performing workout at the cel... | {"inputs": ["3 3\n3 1 2\n3 2 0\n2 3 2\n", "3 3\n9 0 9\n0 9 9\n9 9 9\n", "3 3\n3 1 2\n3 2 0\n2 3 2\n", "3 3\n9 0 9\n0 9 9\n9 9 9\n", "3 3\n3 1 2\n3 2 0\n1 3 2\n", "3 3\n9 0 9\n0 9 9\n9 5 9\n", "3 3\n3 1 3\n3 2 0\n1 3 2\n", "3 3\n0 0 9\n0 9 9\n9 5 9\n"], "outputs": ["16", "54", "16\n", "54\n", "15\n", "50\n", "16\n", "41... | 558 | 236 |
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 | Solve the programming task below in a Python markdown code block.
British mathematician John Littlewood once said about Indian mathematician Srinivasa Ramanujan that "every positive integer was one of his personal friends."
It turns out that positive integers can also be friends with each other! You are given an array... | {"inputs": ["1\n3\n2 8943586220 45777194315\n", "1\n3\n2 7886764954 45777194315\n", "1\n3\n1 8943586220 276932169986\n", "1\n3\n1 8943586220 328707442366\n", "1\n3\n2 8943586220 328707442366\n", "1\n3\n2 8943586220 630301212521\n", "1\n3\n2 8943586220 844669376002\n", "1\n3\n2 8943586220 275585903615\n"], "outputs": ["... | 546 | 292 |
coding | Solve the programming task below in a Python markdown code block.
Prior to having fancy iPhones, teenagers would wear out their thumbs sending SMS
messages on candybar-shaped feature phones with 3x4 numeric keypads.
------- ------- -------
| | | ABC | | DEF |
| 1 | | 2 | | 3 |
------- -------... | {"functional": "_inputs = [['LOL'], ['HOW R U'], ['WHERE DO U WANT 2 MEET L8R'], ['lol'], ['0'], ['ZER0'], ['1'], ['IS NE1 OUT THERE'], ['#'], ['#codewars #rocks']]\n_outputs = [[9], [13], [47], [9], [2], [11], [1], [31], [1], [36]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(... | 536 | 236 |
coding | Solve the programming task below in a Python markdown code block.
There are N squares in a row. The leftmost square contains the integer A, and the rightmost contains the integer B. The other squares are empty.
Aohashi would like to fill the empty squares with integers so that the following condition is satisfied:
* ... | {"inputs": ["4 7 9 4 6", "4 4 9 4 6", "4 4 9 0 6", "3 4 9 0 5", "3 7 9 0 5", "3 7 9 0 3", "3 7 9 0 2", "5 1 5 2 4"], "outputs": ["YES\n", "YES\n", "YES\n", "YES\n", "YES\n", "YES\n", "YES\n", "YES"]} | 384 | 125 |
coding | Solve the programming task below in a Python markdown code block.
The Aizu Wakamatsu city office decided to lay a hot water pipeline covering the whole area of the city to heat houses. The pipeline starts from some hot springs and connects every district in the city. The pipeline can fork at a hot spring or a district,... | {"inputs": ["3 5\n0 8 25 56 0\n9 13 16 0 17\n20 9 16 10 22\n17 27 18 16\n2 4 0\n2 5\n21\n0 0", "3 5\n22 4 30 19 71\n5 12 11 0 8\n5 8 1 11 19\n17 21 19 16\n9 12 0\n19 3\n6\n0 0", "3 5\n0 8 30 19 44\n6 12 9 0 8\n30 8 16 4 22\n17 21 18 16\n7 12 0\n19 2\n21\n0 0", "3 5\n12 8 2 19 44\n5 12 16 0 8\n30 8 0 10 22\n17 21 18 16\... | 591 | 632 |
coding | Solve the programming task below in a Python markdown code block.
You take your son to the forest to see the monkeys. You know that there are a certain number there (n), but your son is too young to just appreciate the full number, he has to start counting them from 1.
As a good parent, you will sit and count with him... | {"functional": "_inputs = [[5], [3], [9], [10], [20]]\n_outputs = [[[1, 2, 3, 4, 5]], [[1, 2, 3]], [[1, 2, 3, 4, 5, 6, 7, 8, 9]], [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]], [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isin... | 174 | 319 |
coding | Solve the programming task below in a Python markdown code block.
In this Kata, you will count the number of times the first string occurs in the second.
```Haskell
solve("zaz","zazapulz") = 4 because they are ZAZapulz, ZAzapulZ, ZazApulZ, zaZApulZ
```
More examples in test cases.
Good luck!
Please also try [Simp... | {"functional": "_inputs = [['zaz', 'zazapulz'], ['rat', 'ratatoulie'], ['kata', 'katakatak'], ['code', 'codeodecode'], ['kata', 'kataxxxxkatak'], ['code', 'cozzdezodeczzode'], ['zaaz', 'zazaapulz'], ['defg', 'dsedsfsgsg'], ['defg', 'dvsxvevdvsvfvsvgvsvgg']]\n_outputs = [[4], [3], [7], [11], [7], [11], [4], [2], [3]]\ni... | 152 | 277 |
coding | Solve the programming task below in a Python markdown code block.
Create a function that takes a Roman numeral as its argument and returns its value as a numeric decimal integer. You don't need to validate the form of the Roman numeral.
Modern Roman numerals are written by expressing each decimal digit of the number t... | {"functional": "_inputs = [['XXI'], ['I'], ['IV'], ['MMVIII'], ['MDCLXVI']]\n_outputs = [[21], [1], [4], [2008], [1666]]\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 ... | 285 | 190 |
coding | Solve the programming task below in a Python markdown code block.
The kingdom of Lazyland is the home to $n$ idlers. These idlers are incredibly lazy and create many problems to their ruler, the mighty King of Lazyland.
Today $k$ important jobs for the kingdom ($k \le n$) should be performed. Every job should be done... | {"inputs": ["2 1\n1 1\n7 13\n", "2 2\n2 2\n7 13\n", "2 1\n1 1\n7 13\n", "2 2\n2 2\n7 13\n", "2 1\n1 1\n6 13\n", "2 2\n2 2\n7 12\n", "2 2\n1 2\n7 12\n", "2 1\n1 1\n6 11\n"], "outputs": ["0\n", "7\n", "0", "7", "0\n", "7\n", "0\n", "0\n"]} | 523 | 156 |
coding | Solve the programming task below in a Python markdown code block.
You just got done with your set at the gym, and you are wondering how much weight you could lift if you did a single repetition. Thankfully, a few scholars have devised formulas for this purpose (from [Wikipedia](https://en.wikipedia.org/wiki/One-repetit... | {"functional": "_inputs = [[135, 20], [200, 8], [270, 2], [360, 1], [400, 0]]\n_outputs = [[282], [253], [289], [360], [0]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return math.isclose(a, b, rel_tol=tol, abs_tol=tol)\n if isinstance(a, (list, tuple)):... | 233 | 215 |
coding | Solve the programming task below in a Python markdown code block.
The Quarkgo Empire Expeditionary Force is an evil organization that plans to invade the Earth. In keeping with the tradition of the invaders, they continued to send monsters at a pace of one every week, targeting the area around Tokyo in Japan. However, ... | {"inputs": ["3", "5", "4", "6", "2", "7", "9", "8"], "outputs": ["1\n", "2\n", "2\n", "2\n", "1\n", "2\n", "2\n", "2"]} | 701 | 61 |
coding | Solve the programming task below in a Python markdown code block.
Create a function that accepts dimensions, of Rows x Columns, as parameters in order to create a multiplication table sized according to the given dimensions. **The return value of the function must be an array, and the numbers must be Fixnums, NOT stri... | {"functional": "_inputs = [[2, 2], [3, 3], [3, 4], [4, 4], [2, 5]]\n_outputs = [[[[1, 2], [2, 4]]], [[[1, 2, 3], [2, 4, 6], [3, 6, 9]]], [[[1, 2, 3, 4], [2, 4, 6, 8], [3, 6, 9, 12]]], [[[1, 2, 3, 4], [2, 4, 6, 8], [3, 6, 9, 12], [4, 8, 12, 16]]], [[[1, 2, 3, 4, 5], [2, 4, 6, 8, 10]]]]\nimport math\ndef _deep_eq(a, b, t... | 168 | 344 |
coding | Solve the programming task below in a Python markdown code block.
Recently Irina arrived to one of the most famous cities of Berland — the Berlatov city. There are n showplaces in the city, numbered from 1 to n, and some of them are connected by one-directional roads. The roads in Berlatov are designed in a way such th... | {"inputs": ["2 1 1\n1 2 1\n", "2 1 1\n1 2 1\n", "2 1 2\n1 2 1\n", "4 3 13\n1 2 5\n2 3 7\n2 4 8\n", "4 3 13\n1 2 5\n2 3 7\n2 4 8\n", "4 4 3\n1 2 1\n2 3 1\n3 4 1\n1 3 1\n", "4 4 2\n1 2 1\n2 3 1\n3 4 1\n1 3 1\n", "4 4 2\n1 2 1\n2 3 1\n3 4 1\n1 3 1\n"], "outputs": ["2\n1 2 \n", "2\n1 2 ", "2\n1 2\n", "3\n1 2 4 \n", "3\n1 2... | 665 | 276 |
coding | Solve the programming task below in a Python markdown code block.
# Task
John was in math class and got bored, so he decided to fold some origami from a rectangular `a × b` sheet of paper (`a > b`). His first step is to make a square piece of paper from the initial rectangular piece of paper by folding the sheet along ... | {"functional": "_inputs = [[2, 1], [10, 7], [3, 1], [4, 1], [3, 2], [4, 2], [1000, 700], [1000, 999]]\n_outputs = [[2], [6], [3], [4], [3], [2], [6], [1000]]\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 ... | 397 | 234 |
coding | Solve the programming task below in a Python markdown code block.
Taro came to a square to look for treasure. There are many treasures buried in this square, but Taro has the latest machines, so he knows everything about where the treasures are buried. Since the square is very wide Taro decided to look for the treasure... | {"inputs": ["3 1\n1 1\n2 6\n5 3\n0 0 5 5", "3 1\n0 2\n2 4\n0 6\n0 0 0 5", "3 1\n0 2\n2 4\n0 6\n0 0 1 5", "3 1\n0 1\n2 4\n0 6\n0 0 1 5", "3 1\n0 1\n2 4\n0 6\n0 0 0 5", "3 1\n0 1\n2 8\n0 6\n0 0 0 5", "3 1\n1 1\n2 6\n5 3\n0 0 1 5", "3 1\n1 1\n2 4\n5 3\n0 0 5 5"], "outputs": ["2\n", "1\n", "1\n", "1\n", "1\n", "1\n", "1\n"... | 655 | 237 |
coding | Solve the programming task below in a Python markdown code block.
Given some positive integers, I wish to print the integers such that all take up the same width by adding a minimum number of leading zeroes. No leading zeroes shall be added to the largest integer.
For example, given `1, 23, 2, 17, 102`, I wish to prin... | {"functional": "_inputs = [[2], [1, 12, 34], [1009, 2], [1, 1, 13], [2, 5, 8], [1, 8, 27]]\n_outputs = [['2'], ['01\\n12\\n34'], ['1009\\n0002'], ['01\\n01\\n13'], ['2\\n5\\n8'], ['01\\n08\\n27']]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return math.iscl... | 165 | 260 |
coding | Solve the programming task below in a Python markdown code block.
Given a name, turn that name into a perfect square matrix (nested array with the amount of arrays equivalent to the length of each array).
You will need to add periods (`.`) to the end of the name if necessary, to turn it into a matrix.
If the name h... | {"functional": "_inputs = [[''], ['G'], ['Beyonce'], ['Franklin'], ['Bill'], ['Frank']]\n_outputs = [['name must be at least one letter'], [[['G']]], [[['B', 'e', 'y'], ['o', 'n', 'c'], ['e', '.', '.']]], [[['F', 'r', 'a'], ['n', 'k', 'l'], ['i', 'n', '.']]], [[['B', 'i'], ['l', 'l']]], [[['F', 'r', 'a'], ['n', 'k', '.... | 162 | 274 |
coding | Solve the programming task below in a Python markdown code block.
Things are heated up between the Finance team and the Marketing team, and they decide to have one-on-one fifa matches to settle it once and for all.
Jha, being an intern, won’t play (it’s a battle of legends, after all) and has been given one job: to fi... | {"inputs": ["4\n1 10 7 4\n15 3 8 7"], "outputs": ["250"]} | 373 | 32 |
coding | Solve the programming task below in a Python markdown code block.
Consider a string, $S$, of $n$ lowercase English letters where each character, $s_i$ ($0\leq i<n)$, denotes the letter at index $\boldsymbol{i}$ in $S$. We define an $(a,b,c,d)$ palindromic tuple of $S$ to be a sequence of indices in $S$ satisfying the f... | {"inputs": ["ghhggh\n", "abbaab\n", "akakak\n", "kkkkkkz\n", "kkkkkkz\n"], "outputs": ["4\n", "4\n", "2\n", "15\n", "15\n"]} | 608 | 60 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given an integer array nums and two integers k and p, return the number of distinct subarrays, which have at most k elements that are divisible by p.
Two arrays nums1 and nums2 are said to be distinct if:
They are of... | {"functional": "def check(candidate):\n assert candidate(nums = [2,3,3,2,2], k = 2, p = 2) == 11\n assert candidate(nums = [1,2,3,4], k = 4, p = 1) == 10\n\n\ncheck(Solution().countDistinct)"} | 144 | 79 |
coding | Solve the programming task below in a Python markdown code block.
We define f(x)=\begin{cases} f(x \oplus reverse(x))+1 & \text{if } x \neq 0 \\ 0 & \text{otherwise} \end{cases}
Here, \oplus denotes the [bitwise XOR operation] and reverse is a function that takes a postive integer, reverses its binary representation... | {"inputs": ["8\n1\n2\n3\n5\n8\n13\n21\n34\n"], "outputs": ["1\n4\n10\n58\n578\n20098\n5236738\n24641495\n"]} | 673 | 68 |
coding | Solve the programming task below in a Python markdown code block.
Your task is to create a new implementation of `modpow` so that it computes `(x^y)%n` for large `y`. The problem with the current implementation is that the output of `Math.pow` is so large on our inputs that it won't fit in a 64-bit float.
You're also ... | {"functional": "_inputs = [[11, 10, 300], [11, 100000, 49], [5, 100000000, 19], [2, 3, 5], [4, 12, 3], [200, 3000, 10], [8132, 21302, 5], [9, 193125, 37], [13, 81230123, 22], [29, 1013293125, 492], [31, 902938423012, 1023]]\n_outputs = [[1], [32], [5], [3], [1], [0], [4], [26], [19], [161], [961]]\nimport math\ndef _de... | 121 | 363 |
coding | Solve the programming task below in a Python markdown code block.
Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Chefina is playing with ranges. There are $N$ ranges $[l_{1}, r_{1}], [l_{2}, r_{2}], \ldots, [l_{N}, r_{N}]$. Chefina wants to divide the ranges int... | {"inputs": ["3\n3\n1 4\n2 6\n5 7\n2\n1 4\n4 6\n2\n3 7\n8 9"], "outputs": ["1\n-1\n0"]} | 623 | 51 |
coding | Solve the programming task below in a Python markdown code block.
Read problems statements in Mandarin Chinese and Russian.
Mike is fond of collecting stamps. He has a lot of rare and unusual ones in his collection. Unfortunately, a few days ago he was fired from his well-paid job.
But he doesn't complain about tha... | {"inputs": ["4 3\n2 1 2\n2 2 3\n2 3 4\n"], "outputs": ["2"]} | 434 | 33 |
coding | Solve the programming task below in a Python markdown code block.
There is a game that uses numbers called "Fizz Buzz". In this game, multiple players count the numbers one by one, starting with 1, and each player says only one number after the previous player. At that time, you must say "Fizz" if it is divisible by 3,... | {"inputs": ["5 7\n1\n0\nFizz\n4\nBuzz\n6\n7\n3 5\n1\n2\n3\n4\n5\n0 0", "5 7\n1\n0\nFizz\n4\nBuzz\n6\n2\n3 5\n1\n2\n3\n4\n5\n0 0", "5 7\n1\n0\nFizz\n2\nBuzz\n6\n2\n3 5\n1\n2\n4\n4\n8\n0 0", "5 7\n1\n0\nFizz\n2\nzuzB\n6\n2\n3 5\n1\n2\n4\n4\n8\n0 0", "5 7\n1\n2\nFizz\n4\nBuzz\n6\n7\n3 5\n1\n1\n3\n4\n5\n0 0", "5 7\n1\n0\nF... | 629 | 372 |
coding | Solve the programming task below in a Python markdown code block.
# Task
In the Land Of Chess, bishops don't really like each other. In fact, when two bishops happen to stand on the same diagonal, they immediately rush towards the opposite ends of that same diagonal.
Given the initial positions (in chess notation) o... | {"functional": "_inputs = [['d7', 'f5'], ['d8', 'b5'], ['a1', 'h8'], ['g3', 'e1'], ['b4', 'e7']]\n_outputs = [[['c8', 'h3']], [['b5', 'd8']], [['a1', 'h8']], [['e1', 'h4']], [['a3', 'f8']]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return math.isclose(a, ... | 368 | 232 |
coding | Solve the programming task below in a Python markdown code block.
Chef Ciel wants to put a fancy neon signboard over the entrance of her restaurant. She has not enough money to buy the new one so she bought some old neon signboard through the internet. Ciel was quite disappointed when she received her order - some of i... | {"inputs": ["5\n????CIELIS???E?\n????CIELISOUR???F\nT?KEITE?SY\n????????\n???C???", "5\n????CIELIS???E?\n????CIELISOUR???F\nT?KEITE?SY\n????????\n@??C???", "5\n????CIELIS???E?\n????CIELISOUR???F\nYS?ETIEK?T\n????????\n@??C???", "5\n????CIELIS???E?\n????CIELISOUR???F\nYS?ETIEK?T\n????>???\n@??C???", "5\n????CIELI?S??E?\... | 765 | 565 |
coding | Solve the programming task below in a Python markdown code block.
AtCoder Inc. has decided to lock the door of its office with a 3-digit PIN code.
The company has an N-digit lucky number, S. Takahashi, the president, will erase N-3 digits from S and concatenate the remaining 3 digits without changing the order to set ... | {"inputs": ["4\n0224", "6\n123123", "19\n5546189040285140044", "19\n4753841743850076999", "19\n9039528710159876563", "19\n3616863455241776042", "19\n2785343766571511696", "19\n2922045480066417189"], "outputs": ["3", "17", "273\n", "311\n", "412\n", "322\n", "239\n", "281\n"]} | 227 | 211 |
coding | Solve the programming task below in a Python markdown code block.
There are n points marked on the plane. The points are situated in such a way that they form a regular polygon (marked points are its vertices, and they are numbered in counter-clockwise order). You can draw n - 1 segments, each connecting any two marked... | {"inputs": ["3\n0 0 1\n0 0 1\n1 1 0\n", "3\n0 0 0\n0 0 1\n0 1 0\n", "3\n0 0 1\n0 0 1\n1 1 0\n", "3\n0 0 0\n0 0 1\n0 1 0\n", "4\n0 1 1 1\n1 0 1 1\n1 1 0 1\n1 1 1 0\n", "4\n0 0 0 1\n0 0 0 0\n0 0 0 1\n1 0 1 0\n", "4\n0 0 1 0\n0 0 0 1\n1 0 0 0\n0 1 0 0\n", "4\n0 0 1 0\n0 0 0 1\n1 0 0 0\n0 1 0 0\n"], "outputs": ["1\n", "0\n... | 458 | 271 |
coding | Solve the programming task below in a Python markdown code block.
Let be `n` an integer prime with `10` e.g. `7`.
`1/7 = 0.142857 142857 142857 ...`.
We see that the decimal part has a cycle: `142857`. The length of this cycle is `6`. In the same way:
`1/11 = 0.09 09 09 ...`. Cycle length is `2`.
# Task
Given an ... | {"functional": "_inputs = [[3], [33], [18118], [69], [197], [65], [97], [19], [111], [53], [59], [93], [51], [159], [183], [167], [94], [133], [218713], [38127], [431541], [221193], [1234567]]\n_outputs = [[1], [2], [-1], [22], [98], [-1], [96], [18], [3], [13], [58], [15], [16], [13], [60], [166], [-1], [18], [9744], ... | 402 | 365 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given a (0-indexed) integer array nums and two integers low and high, return the number of nice pairs.
A nice pair is a pair (i, j) where 0 <= i < j < nums.length and low <= (nums[i] XOR nums[j]) <= high.
Please com... | {"functional": "def check(candidate):\n assert candidate(nums = [1,4,2,7], low = 2, high = 6) == 6\n assert candidate(nums = [9,8,4,2,1], low = 5, high = 14) == 8\n\n\ncheck(Solution().countPairs)"} | 115 | 78 |
coding | Solve the programming task below in a Python markdown code block.
# Triple Trouble
Create a function that will return a string that combines all of the letters of the three inputed strings in groups. Taking the first letter of all of the inputs and grouping them next to each other. Do this for every letter, see exam... | {"functional": "_inputs = [['aaa', 'bbb', 'ccc'], ['aaaaaa', 'bbbbbb', 'cccccc'], ['burn', 'reds', 'roll'], ['Bm', 'aa', 'tn'], ['LLh', 'euo', 'xtr']]\n_outputs = [['abcabcabc'], ['abcabcabcabcabcabc'], ['brrueordlnsl'], ['Batman'], ['LexLuthor']]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float)... | 136 | 231 |
coding | Solve the programming task below in a Python markdown code block.
You are given a sequence of a journey in London, UK. The sequence will contain bus **numbers** and TFL tube names as **strings** e.g.
```python
['Northern', 'Central', 243, 1, 'Victoria']
```
Journeys will always only contain a combination of tube names... | {"functional": "_inputs = [[[12, 'Central', 'Circle', 21]], [['Piccidilly', 56]], [['Northern', 'Central', 'Circle']], [['Piccidilly', 56, 93, 243]], [[386, 56, 1, 876]], [[]]]\n_outputs = [['\u00a37.80'], ['\u00a33.90'], ['\u00a37.20'], ['\u00a35.40'], ['\u00a33.00'], ['\u00a30.00']]\nimport math\ndef _deep_eq(a, b, t... | 202 | 292 |
coding | Solve the programming task below in a Python markdown code block.
Kuro has just learned about permutations and he is really excited to create a new permutation type. He has chosen $n$ distinct positive integers and put all of them in a set $S$. Now he defines a magical permutation to be: A permutation of integers from ... | {"inputs": ["1\n1", "1\n20", "1\n7\n", "1\n2\n", "1\n4\n", "1\n5\n", "1\n8\n", "1\n3\n"], "outputs": ["1\n0 1", "0\n0", "0\n0\n", "0\n0\n", "0\n0\n", "0\n0\n", "0\n0\n", "0\n0\n"]} | 578 | 101 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given a string num, representing a large integer. Return the largest-valued odd integer (as a string) that is a non-empty substring of num, or an empty string "" if no odd integer exists.
A substring is a cont... | {"functional": "def check(candidate):\n assert candidate(num = \"52\") == \"5\"\n assert candidate(num = \"4206\") == \"\"\n assert candidate(num = \"35427\") == \"35427\"\n\n\ncheck(Solution().largestOddNumber)"} | 104 | 71 |
coding | Solve the programming task below in a Python markdown code block.
# Task
Given a binary number, we are about to do some operations on the number. Two types of operations can be here:
* ['I', i, j] : Which means invert the bit from i to j (inclusive).
* ['Q', i] : Answer whether the i'th bit is 0 or 1.
The MSB (most... | {"functional": "_inputs = [['0011001100', [['I', 1, 10], ['I', 2, 7], ['Q', 2], ['Q', 1], ['Q', 7], ['Q', 5]]], ['1011110111', [['I', 1, 10], ['I', 2, 7], ['Q', 2], ['Q', 1], ['Q', 7], ['Q', 5]]], ['1011110111', [['I', 1, 10], ['I', 2, 7]]], ['0000000000', [['I', 1, 10], ['Q', 2]]]]\n_outputs = [[['0', '1', '1', '0']],... | 375 | 352 |
coding | Solve the programming task below in a Python markdown code block.
Given are integers A, B, and N.
Find the maximum possible value of floor(Ax/B) - A × floor(x/B) for a non-negative integer x not greater than N.
Here floor(t) denotes the greatest integer not greater than the real number t.
-----Constraints-----
- 1 ≤ ... | {"inputs": ["4 7 4", "1 7 4", "5 7 5", "2 7 4", "7 7 5", "9 6 5", "1 7 1", "1 7 0"], "outputs": ["2\n", "0\n", "3\n", "1\n", "5\n", "7\n", "0\n", "0\n"]} | 232 | 94 |
coding | Solve the programming task below in a Python markdown code block.
Given a string of lowercase letters in the range ascii[a-z], determine the index of a character that can be removed to make the string a palindrome. There may be more than one solution, but any will do. If the word is already a palindrome or there is n... | {"inputs": ["3 \naaab \nbaa \naaa \n"], "outputs": ["3\n0\n-1\n"]} | 427 | 33 |
coding | Solve the programming task below in a Python markdown code block.
You are given a graph with $n$ nodes and $m$ directed edges. One lowercase letter is assigned to each node. We define a path's value as the number of the most frequently occurring letter. For example, if letters on a path are "abaca", then the value of t... | {"inputs": ["1 1\nf\n1 1\n", "1 1\nf\n1 1\n", "5 4\nabaca\n1 2\n1 3\n3 4\n4 5\n", "5 4\nabaca\n1 2\n1 3\n3 4\n4 5\n", "6 6\nxzyabc\n1 2\n3 1\n2 3\n5 4\n4 3\n6 4\n", "6 6\nxzyabc\n1 2\n3 1\n2 3\n5 4\n1 3\n6 4\n", "6 6\nxzyacc\n1 2\n3 1\n2 3\n5 4\n1 3\n6 4\n", "6 6\nxzyabc\n1 2\n3 1\n2 3\n5 4\n4 3\n6 4\n"], "outputs": ["... | 482 | 246 |
coding | Solve the programming task below in a Python markdown code block.
Xenia the programmer has a tree consisting of n nodes. We will consider the tree nodes indexed from 1 to n. We will also consider the first node to be initially painted red, and the other nodes — to be painted blue.
The distance between two tree nodes v... | {"inputs": ["5 4\n1 2\n2 3\n2 4\n4 5\n2 1\n2 5\n1 2\n2 1\n", "5 4\n1 2\n2 3\n2 4\n4 5\n2 1\n2 1\n1 2\n2 1\n", "5 4\n1 2\n2 3\n2 4\n1 5\n2 1\n2 5\n1 2\n2 5\n", "5 4\n1 2\n2 3\n2 4\n4 5\n2 1\n1 5\n1 2\n2 1\n", "5 4\n1 2\n2 3\n2 4\n1 5\n2 2\n2 5\n1 2\n2 5\n", "5 4\n1 2\n2 3\n1 4\n4 5\n2 1\n2 5\n1 2\n2 1\n", "5 4\n1 2\n2 3... | 402 | 370 |
coding | Solve the programming task below in a Python markdown code block.
Sarthak and Anuradha are very good friends and are eager to participate in an event called *Equinox*. It is a game of words. In this game, $N$ strings $S_{1},\ldots, S_{N}$ are given. For each string $S_{i}$, if it starts with one of the letters of the w... | {"inputs": ["2\n4 1 3\nABBBCDDE\nEARTH\nINDIA\nUUUFFFDDD\n2 5 7\nSDHHD\nXOXOXOXO"], "outputs": ["DRAW\nANURADHA"]} | 662 | 55 |
coding | Solve the programming task below in a Python markdown code block.
You have a string $s_1 s_2 \ldots s_n$ and you stand on the left of the string looking right. You want to choose an index $k$ ($1 \le k \le n$) and place a mirror after the $k$-th letter, so that what you see is $s_1 s_2 \ldots s_k s_k s_{k - 1} \ldots s... | {"inputs": ["4\n10\ncodeforces\n9\ncbacbacba\n3\naaa\n4\nbbaa\n"], "outputs": ["cc\ncbaabc\naa\nbb\n"]} | 465 | 46 |
coding | Solve the programming task below in a Python markdown code block.
There are N persons called Person 1 through Person N.
You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times.
If X and Y are friends, and Y and Z are friends, then X and Z are also friends. There is ... | {"inputs": ["5 2\n1 4\n3 4\n3 1", "5 3\n1 2\n3 4\n3 1", "5 3\n1 2\n3 5\n3 1", "5 2\n1 2\n3 4\n3 1", "5 3\n2 2\n3 4\n5 1", "5 2\n1 4\n3 4\n5 1", "5 2\n1 4\n3 4\n4 1", "5 3\n1 2\n3 4\n5 1"], "outputs": ["3\n", "4\n", "4\n", "2\n", "2\n", "3\n", "3\n", "3"]} | 291 | 173 |
coding | Solve the programming task below in a Python markdown code block.
During her tantrums the princess usually smashes some collectable porcelain. Every furious shriek is accompanied with one item smashed.
The collection of porcelain is arranged neatly on n shelves. Within each shelf the items are placed in one row, so th... | {"inputs": ["1 1\n1 100\n", "1 3\n4 4 5 1 2\n", "1 3\n4 4 5 0 2\n", "1 3\n4 4 3 1 2\n", "3 2\n1 10\n1 2\n1 5\n", "3 2\n1 13\n1 2\n1 5\n", "3 2\n1 14\n1 2\n1 5\n", "3 2\n1 13\n1 2\n1 10\n"], "outputs": ["100\n", "11\n", "11\n", "9\n", "15\n", "18\n", "19\n", "23\n"]} | 448 | 183 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.