task_type stringclasses 1
value | problem stringlengths 209 3.39k | answer stringlengths 35 6.15k | problem_tokens int64 60 774 | answer_tokens int64 12 2.04k |
|---|---|---|---|---|
coding | Solve the programming task below in a Python markdown code block.
Takahashi is doing a research on sets of points in a plane. Takahashi thinks a set S of points in a coordinate plane is a good set when S satisfies both of the following conditions:
* The distance between any two points in S is not \sqrt{D_1}.
* The dis... | {"inputs": ["2 2 2", "2 2 4", "2 2 1", "2 1 5", "5 1 5", "3 2 4", "1 2 1", "3 1 6"], "outputs": ["0 0\n0 1\n0 2\n0 3\n", "0 0\n0 1\n2 2\n2 3\n", "0 0\n0 2\n2 0\n2 2\n", "0 0\n0 2\n1 1\n1 3\n", "0 0\n0 2\n0 4\n0 6\n0 8\n1 1\n1 3\n1 5\n1 7\n1 9\n2 0\n2 2\n2 4\n2 6\n2 8\n3 1\n3 3\n3 5\n3 7\n3 9\n4 0\n4 2\n4 4\n4 6\n4 8\n"... | 470 | 318 |
coding | Solve the programming task below in a Python markdown code block.
Chef is eagerly waiting for a piece of information. His secret agent told him that this information would be revealed to him after K weeks.
X days have already passed and Chef is getting restless now. Find the number of remaining days Chef has to wait f... | {"inputs": ["4\n1 5\n1 6\n1 1\n1 2"], "outputs": ["2\n1\n6\n5\n"]} | 475 | 35 |
coding | Solve the programming task below in a Python markdown code block.
For a collection of integers $S$, define $\operatorname{mex}(S)$ as the smallest non-negative integer that does not appear in $S$.
NIT, the cleaver, decides to destroy the universe. He is not so powerful as Thanos, so he can only destroy the universe by... | {"inputs": ["4\n4\n0 0 0 0\n5\n0 1 2 3 4\n7\n0 2 3 0 1 2 0\n1\n1000000000\n"], "outputs": ["0\n1\n2\n1\n"]} | 613 | 71 |
coding | Solve the programming task below in a Python markdown code block.
You are given a string of words (x), for each word within the string you need to turn the word 'inside out'. By this I mean the internal letters will move out, and the external letters move toward the centre.
If the word is even length, all letters wil... | {"functional": "_inputs = [['man i need a taxi up to ubud'], ['what time are we climbing up the volcano'], ['take me to semynak'], ['massage yes massage yes massage'], ['take bintang and a dance please']]\n_outputs = [['man i ende a atix up to budu'], ['hwta item are we milcgnib up the lovcona'], ['atek me to mesykan']... | 142 | 260 |
coding | Solve the programming task below in a Python markdown code block.
Recently in JEC ants have become huge, the Principal is on a journey to snipe them !!
Principal has limited $N$ practice Bullets to practice so that he can be sure to kill ants.
- The Practice ground has max length $L$.
- There is a Limit X such that if ... | {"inputs": ["2\n1 10\n2 10"], "outputs": ["10\n4"]} | 489 | 25 |
coding | Solve the programming task below in a Python markdown code block.
You are given a string S as input. This represents a valid date in the year 2019 in the yyyy/mm/dd format. (For example, April 30, 2019 is represented as 2019/04/30.)
Write a program that prints Heisei if the date represented by S is not later than April... | {"inputs": ["2019/03/30", "2019/11/00", "2019/04/20", "2019/12/01", "2019/14/20", "2119/12/01", "2019/24/10", "1019/04/30"], "outputs": ["Heisei\n", "TBD \n", "Heisei\n", "TBD \n", "TBD \n", "TBD \n", "TBD \n", "Heisei\n"]} | 204 | 150 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given an integer array nums that does not contain any zeros, find the largest positive integer k such that -k also exists in the array.
Return the positive integer k. If there is no such integer, return -1.
Please c... | {"functional": "def check(candidate):\n assert candidate(nums = [-1,2,-3,3]) == 3\n assert candidate(nums = [-1,10,6,7,-7,1]) == 7\n assert candidate(nums = [-10,8,6,7,-2,-3]) == -1\n\n\ncheck(Solution().findMaxK)"} | 94 | 84 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given a string s and an integer k, return the length of the longest substring of s that contains at most k distinct characters.
Please complete the following python code precisely:
```python
class Solution:
def ... | {"functional": "def check(candidate):\n assert candidate(s = \"eceba\", k = 2) == 3\n assert candidate(s = \"aa\", k = 1) == 2\n\n\ncheck(Solution().lengthOfLongestSubstringKDistinct)"} | 82 | 59 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given the root of a binary tree, return all root-to-leaf paths in any order.
A leaf is a node with no children.
Please complete the following python code precisely:
```python
# Definition for a binary tree node.
# c... | {"functional": "def check(candidate):\n assert candidate(root = tree_node([1,2,3,None,5])) == [\"1->2->5\",\"1->3\"]\n assert candidate(root = tree_node([1])) == [\"1\"]\n\n\ncheck(Solution().binaryTreePaths)"} | 130 | 69 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given a string licensePlate and an array of strings words, find the shortest completing word in words.
A completing word is a word that contains all the letters in licensePlate. Ignore numbers and spaces in licensePla... | {"functional": "def check(candidate):\n assert candidate(licensePlate = \"1s3 PSt\", words = [\"step\", \"steps\", \"stripe\", \"stepple\"]) == \"steps\"\n assert candidate(licensePlate = \"1s3 456\", words = [\"looks\", \"pest\", \"stew\", \"show\"]) == \"pest\"\n\n\ncheck(Solution().shortestCompletingWord)"} | 219 | 97 |
coding | Solve the programming task below in a Python markdown code block.
Dothraki are planning an attack to usurp King Robert's throne. King Robert learns of this conspiracy from Raven and plans to lock the single door through which the enemy can enter his kingdom.
But, to lock the door he needs a key that is an anagram of a... | {"inputs": ["aaabbbb\n", "cdcdcdcdeeeef\n", "cdefghmnopqrstuvw\n"], "outputs": ["YES\n", "YES\n", "NO\n"]} | 388 | 42 |
coding | Solve the programming task below in a Python markdown code block.
You are given a matrix f with 4 rows and n columns. Each element of the matrix is either an asterisk (*) or a dot (.).
You may perform the following operation arbitrary number of times: choose a square submatrix of f with size k × k (where 1 ≤ k ≤ 4) an... | {"inputs": ["4\n1 1 1 1\n....\n....\n....\n....\n", "4\n1 1 1 1\n****\n****\n****\n****\n", "4\n1 1 2 1\n....\n....\n....\n....\n", "4\n1 1 0 1\n****\n****\n****\n****\n", "4\n1 1 3 1\n....\n....\n....\n....\n", "4\n0 1 1 1\n....\n....\n....\n....\n", "4\n2 1 1 1\n****\n****\n****\n****\n", "4\n1 0 0 1\n****\n****\n***... | 494 | 228 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given a binary string binary consisting of only 0's or 1's. You can apply each of the following operations any number of times:
Operation 1: If the number contains the substring "00", you can replace it with ... | {"functional": "def check(candidate):\n assert candidate(binary = \"000110\") == \"111011\"\n assert candidate(binary = \"01\") == \"01\"\n\n\ncheck(Solution().maximumBinaryString)"} | 199 | 58 |
coding | Solve the programming task below in a Python markdown code block.
The numbers 12, 63 and 119 have something in common related with their divisors and their prime factors, let's see it.
```
Numbers PrimeFactorsSum(pfs) DivisorsSum(ds) Is ds divisible by pfs
12 2 + 2 + 3 = 7 1 + 2 + 3 ... | {"functional": "_inputs = [[10, 100], [20, 120], [50, 140]]\n_outputs = [[[12, 15, 35, 42, 60, 63, 66, 68, 84, 90, 95]], [[35, 42, 60, 63, 66, 68, 84, 90, 95, 110, 114, 119]], [[60, 63, 66, 68, 84, 90, 95, 110, 114, 119, 140]]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, fl... | 534 | 321 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given a positive integer arrivalTime denoting the arrival time of a train in hours, and another positive integer delayedTime denoting the amount of delay in hours.
Return the time when the train will arrive at... | {"functional": "def check(candidate):\n assert candidate(arrivalTime = 15, delayedTime = 5 ) == 20 \n assert candidate(arrivalTime = 13, delayedTime = 11) == 0\n\n\ncheck(Solution().findDelayedArrivalTime)"} | 117 | 67 |
coding | Solve the programming task below in a Python markdown code block.
Maksim has $n$ objects and $m$ boxes, each box has size exactly $k$. Objects are numbered from $1$ to $n$ in order from left to right, the size of the $i$-th object is $a_i$.
Maksim wants to pack his objects into the boxes and he will pack objects by th... | {"inputs": ["1 1 1\n1\n", "1 1 1\n1\n", "1 1 1\n0\n", "1 1 2\n0\n", "1 1 2\n1\n", "1 1 2\n2\n", "1 2 2\n1\n", "1 2 2\n2\n"], "outputs": ["1\n", "1", "1\n", "1\n", "1\n", "1\n", "1\n", "1\n"]} | 722 | 117 |
coding | Solve the programming task below in a Python markdown code block.
Akash is feeling lonely.So he decided to visit his friend's house.
His friend's house is located at the distance of K metres from his
house.Now,he can take a step of one metre ,two metres or three
metres at a time.Can you tell me number of ways of rea... | {"inputs": ["15\n1\n1\n9\n4\n10\n7\n2\n6\n6\n2\n12\n9\n8\n6\n6"], "outputs": ["1\n1\n149\n7\n274\n44\n2\n24\n24\n2\n927\n149\n81\n24\n24"]} | 173 | 87 |
coding | Solve the programming task below in a Python markdown code block.
You are given a connected undirected weighted graph consisting of $n$ vertices and $m$ edges.
You need to print the $k$-th smallest shortest path in this graph (paths from the vertex to itself are not counted, paths from $i$ to $j$ and from $j$ to $i$ a... | {"inputs": ["2 1 1\n1 2 123456789\n", "2 1 1\n1 2 123456789\n", "6 10 5\n2 5 1\n5 3 9\n6 2 2\n1 3 1\n5 1 8\n6 5 10\n1 6 5\n6 4 6\n3 6 2\n3 4 5\n", "6 10 5\n2 5 1\n5 3 9\n6 2 2\n1 3 1\n5 1 8\n6 5 10\n1 6 5\n6 4 6\n3 6 2\n3 4 5\n", "7 15 18\n2 6 3\n5 7 4\n6 5 4\n3 6 9\n6 7 7\n1 6 4\n7 1 6\n7 2 1\n4 3 2\n3 2 8\n5 3 6\n2 5... | 678 | 638 |
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.
Recently, Chef hosted a strange competition at the Byteland annual fair. There were $N$ participants in the competition (numbered $1$ through $N$); a... | {"inputs": ["1\n5\n5 2 4 6 7"], "outputs": ["5 5"]} | 732 | 26 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
The Tribonacci sequence Tn is defined as follows:
T0 = 0, T1 = 1, T2 = 1, and Tn+3 = Tn + Tn+1 + Tn+2 for n >= 0.
Given n, return the value of Tn.
Please complete the following python code precisely:
```python
clas... | {"functional": "def check(candidate):\n assert candidate(n = 4) == 4\n assert candidate(n = 25) == 1389537\n\n\ncheck(Solution().tribonacci)"} | 111 | 50 |
coding | Solve the programming task below in a Python markdown code block.
Recently, the Fair Nut has written k strings of length n, consisting of letters "a" and "b". He calculated c — the number of strings that are prefixes of at least one of the written strings. Every string was counted only one time.
Then, he lost his shee... | {"inputs": ["1 1\na\na\n", "1 2\na\na\n", "1 2\na\nb\n", "2 4\naa\nab\n", "2 4\naa\nbb\n", "3 3\naba\nabb\n", "3 3\naba\nbba\n", "4 5\nabbb\nbbaa\n"], "outputs": ["1\n", "1\n", "2\n", "3\n", "6\n", "4\n", "8\n", "14\n"]} | 444 | 123 |
coding | Solve the programming task below in a Python markdown code block.
The correct way of evaluating an expression with *, +, and - is, first multiplication, then addition, and then subtraction. For example, the expression 2+3*7-5 = 2+21-5 = 23-5 = 18.
You are given integers N and X. Your task is to generate a string S of ... | {"inputs": ["3\n3 4\n2 -5\n3 1\n"], "outputs": ["+++\n-1\n*+-\n"]} | 561 | 34 |
coding | Solve the programming task below in a Python markdown code block.
For a set $S$ of integers, perform a sequence of the following operations. Note that each value in $S$ must be unique.
* insert($x$): Insert $x$ to $S$ and report the number of elements in $S$ after the operation.
* find($x$): Report the number of $x$ i... | {"inputs": ["8\n0 1\n0 2\n0 2\n2 2\n1 1\n1 2\n1 3\n0 2", "8\n0 1\n0 4\n0 2\n2 2\n1 1\n1 2\n1 3\n0 2", "8\n0 1\n0 4\n0 2\n2 2\n1 1\n1 4\n1 3\n0 2", "8\n0 1\n0 4\n0 1\n2 2\n1 1\n1 4\n1 3\n0 2", "8\n0 2\n0 3\n0 1\n2 2\n1 1\n1 4\n1 3\n0 2", "8\n0 2\n0 3\n0 2\n2 2\n1 1\n1 4\n1 3\n0 2", "8\n1 1\n0 2\n0 3\n2 2\n1 1\n1 2\n1 3\... | 316 | 414 |
coding | Solve the programming task below in a Python markdown code block.
A single car can accommodate at most 4 people.
N friends want to go to a restaurant for a party. Find the minimum number of cars required to accommodate all the friends.
------ Input Format ------
- The first line contains a single integer T - the nu... | {"inputs": ["4\n4\n2\n7\n98\n"], "outputs": ["1\n1\n2\n25\n"]} | 285 | 30 |
coding | Solve the programming task below in a Python markdown code block.
There is a set A = \\{ a_1, a_2, \ldots, a_N \\} consisting of N positive integers. Taro and Jiro will play the following game against each other.
Initially, we have a pile consisting of K stones. The two players perform the following operation alternat... | {"inputs": ["2 3\n2 3", "2 7\n1 3", "2 4\n2 5", "2 1\n1 3", "2 4\n3 5", "2 2\n1 3", "2 2\n2 3", "2 5\n2 5"], "outputs": ["First\n", "First\n", "Second\n", "First\n", "First\n", "Second\n", "First\n", "First\n"]} | 332 | 110 |
coding | Solve the programming task below in a Python markdown code block.
As you know, majority of students and teachers of Summer Informatics School live in Berland for the most part of the year. Since corruption there is quite widespread, the following story is not uncommon.
Elections are coming. You know the number of vote... | {"inputs": ["1 2\n1 100\n", "1 2\n1 100\n", "1 3000\n670 56891830\n", "1 3000\n918 548706881\n", "1 3000\n918 548706881\n", "1 3000\n670 548706881\n", "1 3000\n670 141077449\n", "1 3000\n2006 226621946\n"], "outputs": ["0\n", "0\n", "56891830\n", "548706881\n", "548706881\n", "548706881\n", "141077449\n", "226621946\n"... | 561 | 247 |
coding | Solve the programming task below in a Python markdown code block.
Byteland has $N$ cities (numbered from $\mbox{1}$ to $N$) and $N-1$ bidirectional roads. It is guaranteed that there is a route from any city to any other city.
Jeanie is a postal worker who must deliver $\mbox{K}$ letters to various cities in Byteland... | {"inputs": ["5 3\n1 3 4\n1 2 1\n2 3 2\n2 4 2\n3 5 3\n"], "outputs": ["6\n"]} | 527 | 46 |
coding | Solve the programming task below in a Python markdown code block.
You are given a positive integer N.
Find the minimum positive integer divisible by both 2 and N.
-----Constraints-----
- 1 \leq N \leq 10^9
- All values in input are integers.
-----Input-----
Input is given from Standard Input in the following format... | {"inputs": ["5", "8", "1", "0", "9", "4", "7", "6"], "outputs": ["10\n", "8\n", "2\n", "0\n", "18\n", "4\n", "14\n", "6\n"]} | 146 | 65 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given two arrays of positive integers, boxes and warehouse, representing the heights of some boxes of unit width and the heights of n rooms in a warehouse respectively. The warehouse's rooms are labeled from 0... | {"functional": "def check(candidate):\n assert candidate(boxes = [1,2,2,3,4], warehouse = [3,4,1,2]) == 4\n assert candidate(boxes = [3,5,5,2], warehouse = [2,1,3,4,5]) == 3\n assert candidate(boxes = [1,2,3], warehouse = [1,2,3,4]) == 3\n assert candidate(boxes = [4,5,6], warehouse = [3,3,3,3,3]) == 0\n\n\... | 212 | 143 |
coding | Solve the programming task below in a Python markdown code block.
Alice and Bob like games. And now they are ready to start a new game. They have placed n chocolate bars in a line. Alice starts to eat chocolate bars one by one from left to right, and Bob — from right to left. For each chocololate bar the time, needed f... | {"inputs": ["1\n6\n", "1\n1\n", "1\n5\n", "1\n9\n", "1\n2\n", "1\n7\n", "1\n8\n", "1\n15\n"], "outputs": ["1 0\n", "1 0\n", "1 0\n", "1 0\n", "1 0\n", "1 0\n", "1 0\n", "1 0\n"]} | 289 | 103 |
coding | Solve the programming task below in a Python markdown code block.
F: Miko Mi String-
story
Mikko Mikkomi ~! Everyone's idol, Miko Miko Tazawa! Today ~, with Mikoto ~, practice the string algorithm, let's do it ☆
Miko's special ~~ character making ~~ The slogan "MikoMikomi" becomes "MikoMikoMi" in Roman letters! In o... | {"inputs": ["iNociNociN", "iNobiNociN", "iNoaiNociN", "iNoaiNochN", "NhcoNiaoNi", "NhcoNiNoai", "NhcoNjNoai", "NhboNjNoai"], "outputs": ["Love iNoc!\n", "mitomerarenaiWA\n", "mitomerarenaiWA\n", "mitomerarenaiWA\n", "mitomerarenaiWA\n", "mitomerarenaiWA\n", "mitomerarenaiWA\n", "mitomerarenaiWA\n"]} | 607 | 132 |
coding | Solve the programming task below in a Python markdown code block.
Andrewid the Android is a galaxy-famous detective. He is now investigating the case of vandalism at the exhibition of contemporary art.
The main exhibit is a construction of n matryoshka dolls that can be nested one into another. The matryoshka dolls ar... | {"inputs": ["1 1\n1 1\n", "3 2\n1 2\n2 1 3\n", "3 2\n2 1 2\n1 3\n", "5 3\n1 4\n3 1 2 3\n1 5\n", "7 3\n3 1 3 7\n2 2 5\n2 4 6\n", "8 5\n2 1 2\n2 3 4\n1 5\n2 6 7\n1 8\n", "10 10\n1 5\n1 4\n1 10\n1 3\n1 7\n1 1\n1 8\n1 6\n1 9\n1 2\n", "13 8\n1 5\n2 8 10\n1 13\n4 1 2 3 11\n1 7\n2 6 12\n1 4\n1 9\n"], "outputs": ["0\n", "3\n",... | 702 | 264 |
coding | Solve the programming task below in a Python markdown code block.
You were given a string of integer temperature values. Create a function `lowest_temp(t)` and return the lowest value or `None/null/Nothing` if the string is empty.
Also feel free to reuse/extend the following starter code:
```python
def lowest_temp(t):
... | {"functional": "_inputs = [[''], ['-1 50 -4 20 22 -7 0 10 -8']]\n_outputs = [[None], [-8]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return math.isclose(a, b, rel_tol=tol, abs_tol=tol)\n if isinstance(a, (list, tuple)):\n if len(a) != len(b): re... | 70 | 180 |
coding | Solve the programming task below in a Python markdown code block.
Motu and Patlu are racing against each other on a circular track of radius $R$. Initially they are at the same point on the track and will run in same direction .The coach ordered them to run $X$ rounds of the circular field. Patlu wants to know how many... | {"inputs": ["2\n3 10 2 5\n2 20 5 10"], "outputs": ["1\n0"]} | 329 | 33 |
coding | Solve the programming task below in a Python markdown code block.
You want to build a temple for snakes. The temple will be built on a mountain range, which can be thought of as n blocks, where height of i-th block is given by hi. The temple will be made on a consecutive section of the blocks and its height should star... | {"inputs": ["3\n3\n1 2 1\n4\n1 1 2 1\n5\n1 2 6 2 1"], "outputs": ["0\n1\n3"]} | 506 | 46 |
coding | Solve the programming task below in a Python markdown code block.
There are $n$ cities numbered from $1$ to $n$, and city $i$ has beauty $a_i$.
A salesman wants to start at city $1$, visit every city exactly once, and return to city $1$.
For all $i\ne j$, a flight from city $i$ to city $j$ costs $\max(c_i,a_j-a_i)$ d... | {"inputs": ["2\n4 0\n5 0\n", "2\n4 0\n5 0\n", "2\n5 2\n4 0\n", "2\n0 2\n4 0\n", "2\n-1 2\n4 0\n", "3\n1 9\n2 1\n4 1\n", "3\n2 1\n0 4\n4 1\n", "3\n1 1\n0 3\n3 1\n"], "outputs": ["1\n", "1\n", "3\n", "4\n", "5\n", "11\n", "6\n", "5\n"]} | 438 | 148 |
coding | Solve the programming task below in a Python markdown code block.
Read problems statements in mandarin chinese, russian and vietnamese as well.
The Chef had a box with N numbers arranged inside it: A_{1}, A_{2}, ..., A_{N}. He also had the number N at the front, so that he knows how many numbers are in it. That is, t... | {"inputs": ["3\n1 2 1\n3 1 2 8\n1 5 1 4 3 2"], "outputs": ["1\n8\n4"]} | 461 | 42 |
coding | Solve the programming task below in a Python markdown code block.
Your task is to ___Reverse and Combine Words___. It's not too difficult, but there are some things you have to consider...
### So what to do?
Input: String containing different "words" separated by spaces
```
1. More than one word? Reverse each word ... | {"functional": "_inputs = [['abc def'], ['abc def ghi jkl'], ['dfghrtcbafed'], ['234hh54 53455 sdfqwzrt rtteetrt hjhjh lllll12 44'], ['sdfsdf wee sdffg 342234 ftt']]\n_outputs = [['cbafed'], ['defabcjklghi'], ['dfghrtcbafed'], ['trzwqfdstrteettr45hh4325543544hjhjh21lllll'], ['gffds432243fdsfdseewttf']]\nimport math\nd... | 272 | 290 |
coding | Solve the programming task below in a Python markdown code block.
Hector the hacker has stolen some information, but it is encrypted. In order to decrypt it, he needs to write a function that will generate a decryption key from the encryption key which he stole (it is in hexadecimal). To do this, he has to determine th... | {"functional": "_inputs = [['47b'], ['2533'], ['1ba9']]\n_outputs = [[1080], [9328], [6912]]\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): ... | 253 | 182 |
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 of size n containing all numbers from 1 to n, return the number of increasing quadruplets.
A quadruplet (i, j, k, l) is increasing if:
0 <= i < j < k < l < n, and
nums[i] < nums[k... | {"functional": "def check(candidate):\n assert candidate(nums = [1,3,2,4,5]) == 2\n assert candidate(nums = [1,2,3,4]) == 0\n\n\ncheck(Solution().countQuadruplets)"} | 127 | 60 |
coding | Solve the programming task below in a Python markdown code block.
In Programmers Army Land, people have started preparation as sports day is scheduled next week.
You are given a task to form 1 team of $k$ consecutive players, from a list of sports player whose powers are given to you.
You want your team to win this cha... | {"inputs": ["1\n5 3\n1 2 3 4 5"], "outputs": ["12"]} | 368 | 27 |
coding | Solve the programming task below in a Python markdown code block.
You have two strings $s_1$ and $s_2$ of length $n$, consisting of lowercase English letters. You can perform the following operation any (possibly zero) number of times:
Choose a positive integer $1 \leq k \leq n$.
Swap the prefix of the string $s_1$ a... | {"inputs": ["7\n3\ncbc\naba\n5\nabcaa\ncbabb\n5\nabcaa\ncbabz\n1\na\na\n1\na\nb\n6\nabadaa\nadaaba\n8\nabcabdaa\nadabcaba\n"], "outputs": ["YES\nYES\nNO\nYES\nNO\nNO\nYES\n"]} | 724 | 83 |
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.
You are given a string $S$ with length $N$. You may perform the following operation any number of times: choose a non-empty substring of $S$ (possib... | {"inputs": ["4\n6\ncabbac\n7\nacabbad\n18\nfbedfcbdaebaaceeba\n21\nyourcrushlovesyouback"], "outputs": ["YES\nNO\nYES\nNO"]} | 483 | 53 |
coding | Solve the programming task below in a Python markdown code block.
Given an amount and the denominations of coins available, determine how many ways change can be made for amount. There is a limitless supply of each coin type.
Example
$n=3$
$c=[8,3,1,2]$
There are $3$ ways to make change for $n=3$: $\{1,1,1\}... | {"inputs": ["4 3\n1 2 3\n", "10 4\n2 5 3 6\n"], "outputs": ["4\n", "5\n"]} | 628 | 41 |
coding | Solve the programming task below in a Python markdown code block.
Check Tutorial tab to know how to to solve.
Task
The provided code stub reads two integers from STDIN, $\boldsymbol{\alpha}$ and $\boldsymbol{b}$. Add code to print three lines where:
The first line contains the sum of the two numbers.
The s... | {"inputs": ["3\n2\n"], "outputs": ["5\n1\n6\n"]} | 261 | 20 |
coding | Solve the programming task below in a Python markdown code block.
Interns Mehta and Sharma are waiting for their "build" to complete. Mehta comes up with an interesting game with an array P of integers of size N. She defines the rules of the game as:
Pick a number i from the set {1,2,...N-2}.
Remove P[i] from the array... | {"inputs": ["8\n477 744 474 777 447 747 777 474"], "outputs": ["2937051"]} | 261 | 50 |
coding | Solve the programming task below in a Python markdown code block.
There are N cities in Republic of AtCoder. The size of the i-th city is A_{i}. Takahashi would like to build N-1 bidirectional roads connecting two cities so that any city can be reached from any other city by using these roads.
Assume that the cost of ... | {"inputs": ["3 1\n2 100 1", "3 1\n0 100 1", "3 2\n1 100 1", "3 1\n0 101 1", "3 4\n1 100 1", "3 1\n4 110 1", "3 1\n1 100 1", "3 1000\n1 101 1"], "outputs": ["107\n", "104\n", "109\n", "105\n", "115\n", "119\n", "106", "2204\n"]} | 344 | 161 |
coding | Solve the programming task below in a Python markdown code block.
## Task:
You have to write a function `pattern` which returns the following Pattern(See Pattern & Examples) upto `n` number of rows.
* Note:`Returning` the pattern is not the same as `Printing` the pattern.
#### Rules/Note:
* If `n < 1` then it should... | {"functional": "_inputs = [[1], [2], [5], [0], [-25]]\n_outputs = [['1'], ['1\\n22'], ['1\\n22\\n333\\n4444\\n55555'], [''], ['']]\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, t... | 388 | 202 |
coding | Solve the programming task below in a Python markdown code block.
The winner of the card game popular in Berland "Berlogging" is determined according to the following rules. If at the end of the game there is only one player with the maximum number of points, he is the winner. The situation becomes more difficult if th... | {"inputs": ["3\nmike 1\nandrew 5\nmike 2\n", "3\nmike 1\nandsew 5\nmike 2\n", "3\nmike 3\nandrew 5\nmike 2\n", "3\neikm 0\nwesdna 12\nejkm 0\n", "3\nemki 0\nwdsena 12\nejmk 0\n", "3\nelkh 0\nwdsema 12\nemjk 0\n", "3\nmike 1\nandsew 10\nmike 2\n", "3\nmike 1\nandsew 12\nmike 2\n"], "outputs": ["andrew\n", "andsew\n", "a... | 371 | 216 |
coding | Solve the programming task below in a Python markdown code block.
There are n schoolchildren, boys and girls, lined up in the school canteen in front of the bun stall. The buns aren't ready yet and the line is undergoing some changes.
Each second all boys that stand right in front of girls, simultaneously swap places ... | {"inputs": ["F\n", "M\n", "F\n", "M\n", "FF\n", "FM\n", "MF\n", "MM\n"], "outputs": ["0\n", "0\n", "0", "0", "0\n", "0\n", "1\n", "0\n"]} | 522 | 68 |
coding | Solve the programming task below in a Python markdown code block.
Write a program which finds the greatest common divisor of two natural numbers a and b
Hint
You can use the following observation:
For integers x and y, if x ≥ y, then gcd(x, y) = gcd(y, x%y)
Constrants
1 ≤ a, b ≤ 109
Input
a and b are given in a ... | {"inputs": ["9 9", "2 1", "3 1", "2 2", "2 4", "4 1", "1 4", "9 5"], "outputs": ["9\n", "1\n", "1\n", "2\n", "2\n", "1\n", "1\n", "1\n"]} | 136 | 78 |
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 matrix maze (0-indexed) with empty cells (represented as '.') and walls (represented as '+'). You are also given the entrance of the maze, where entrance = [entrancerow, entrancecol] denotes the... | {"functional": "def check(candidate):\n assert candidate(maze = [[\"+\",\"+\",\".\",\"+\"],[\".\",\".\",\".\",\"+\"],[\"+\",\"+\",\"+\",\".\"]], entrance = [1,2]) == 1\n assert candidate(maze = [[\"+\",\"+\",\"+\"],[\".\",\".\",\".\"],[\"+\",\"+\",\"+\"]], entrance = [1,0]) == 2\n assert candidate(maze = [[\".... | 217 | 139 |
coding | Solve the programming task below in a Python markdown code block.
You are given an array of positive integers $a = [a_0, a_1, \dots, a_{n - 1}]$ ($n \ge 2$).
In one step, the array $a$ is replaced with another array of length $n$, in which each element is the greatest common divisor (GCD) of two neighboring elements (... | {"inputs": ["5\n4\n6 2 17 3\n4\n9 55 74 42\n3\n4 6 4\n5\n1 1 3 4 2\n6\n9 7 27 9 9 101\n", "5\n4\n26 24 10 5\n4\n9 58 41 42\n3\n4 6 4\n5\n1 2 2 4 5\n6\n9 9 27 9 9 63\n", "5\n4\n16 40 9 5\n4\n64 58 41 42\n3\n4 6 4\n5\n1 2 3 4 5\n6\n9 9 27 9 9 63\n", "5\n4\n26 40 19 5\n4\n9 58 41 42\n3\n4 6 4\n5\n1 2 2 4 5\n6\n9 9 27 9 9 ... | 729 | 629 |
coding | Solve the programming task below in a Python markdown code block.
A bracket sequence is a string, containing only characters "(", ")", "[" and "]".
A correct bracket sequence is a bracket sequence that can be transformed into a correct arithmetic expression by inserting characters "1" and "+" between the original char... | {"inputs": ["[[]\n", "([]\n", "()(\n", "))(\n", "*)(\n", "(((\n", "[[])\n", "(][)\n"], "outputs": ["1\n[]", "1\n[]", "0\n\n", "0\n\n", "0\n\n", "0\n\n", "1\n[]", "0\n"]} | 330 | 84 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given a 0-indexed integer array nums, an integer modulo, and an integer k.
Your task is to find the count of subarrays that are interesting.
A subarray nums[l..r] is interesting if the following condition hold... | {"functional": "def check(candidate):\n assert candidate(nums = [3,2,4], modulo = 2, k = 1) == 3\n assert candidate(nums = [3,1,9,6], modulo = 3, k = 0) == 2\n\n\ncheck(Solution().countInterestingSubarrays)"} | 173 | 75 |
coding | Solve the programming task below in a Python markdown code block.
# Explanation
It's your first day in the robot factory and your supervisor thinks that you should start with an easy task. So you are responsible for purchasing raw materials needed to produce the robots.
A complete robot weights `50` kilogram. Iron is... | {"functional": "_inputs = [[[10], 90], [[20, 10], 55], [[0], 90], [[0, 0, 0], 90], [[10, 0], 90], [[0, 10], 90], [[10, 0, 0, 10], 81], [[0, 10, 0, 10], 81], [[0, 10, 10, 0], 81], [[10, 20, 30, 40, 50, 60, 70, 80, 90], 25], [[90, 80, 70, 60, 50, 40, 30, 20, 10], 20], [[10, 0, 30, 0, 50, 0, 70, 0, 90], 25], [[22, 33, 44,... | 339 | 958 |
coding | Solve the programming task below in a Python markdown code block.
YouKn0wWho has an integer sequence $a_1, a_2, \ldots, a_n$. He will perform the following operation until the sequence becomes empty: select an index $i$ such that $1 \le i \le |a|$ and $a_i$ is not divisible by $(i + 1)$, and erase this element from the... | {"inputs": ["5\n3\n1 2 3\n1\n2\n2\n7 7\n10\n384836991 191890310 576823355 782177068 404011431 818008580 954291757 160449218 155374934 840594328\n8\n6 69 696 69696 696969 6969696 69696969 696969696\n"], "outputs": ["YES\nNO\nYES\nYES\nNO\n"]} | 704 | 194 |
coding | Solve the programming task below in a Python markdown code block.
# Task
You are the manager of the famous rescue team: The Knights. Your task is to assign your knights to a rescue missions on an infinite 2D-plane.
Your knights can move only by `n-knight` jumps.
For example, if a knight has n = 2, they can only ... | {"functional": "_inputs = [[[2], 2, 1], [[1], 10, 10], [[1], 1, 0], [[1, 2], 1, 0], [[1, 2, 3], 456546, 23532], [[1, 5, 3, 7, 9], 7, 8], [[1, 1, 1, 1, 1, 1, 1, 1, 1], 0, 1]]\n_outputs = [[True], [True], [False], [True], [True], [False], [False]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) o... | 361 | 290 |
coding | Solve the programming task below in a Python markdown code block.
The integers $0$ to $M - 1$ have been arranged in a circular fashion. That is, $0, 1, 2, \ldots, M - 1$, are in that order and
also, $0$ and $M - 1$ are next to each other. The distance between any two adjacent numbers on this circle is 1. You are given ... | {"inputs": ["9 3\n0 2\n3 4\n5 7"], "outputs": ["3"]} | 630 | 26 |
coding | Solve the programming task below in a Python markdown code block.
------Read problems statements in Hindi,
Mandarin chinese
, Russian and Vietnamese as well. ------
During Eid, it's a tradition that each father gives his kids money which they can spend on entertainment.
Chef has $N$ coins; let's denote the value of ... | {"inputs": ["2\n3\n1 4 2\n3\n1 3 3"], "outputs": ["1\n0"]} | 499 | 30 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given an array of strings words and a string s, determine if s is an acronym of words.
The string s is considered an acronym of words if it can be formed by concatenating the first character of each string in words in... | {"functional": "def check(candidate):\n assert candidate(words = [\"alice\",\"bob\",\"charlie\"], s = \"abc\") == True\n assert candidate(words = [\"an\",\"apple\"], s = \"a\") == False\n assert candidate(words = [\"never\",\"gonna\",\"give\",\"up\",\"on\",\"you\"], s = \"ngguoy\") == True\n\n\ncheck(Solution(... | 149 | 94 |
coding | Solve the programming task below in a Python markdown code block.
Polycarp has a strict daily schedule. He has n alarms set for each day, and the i-th alarm rings each day at the same time during exactly one minute.
Determine the longest time segment when Polycarp can sleep, i. e. no alarm rings in that period. It is ... | {"inputs": ["1\n05:43\n", "1\n04:43\n", "1\n05:43\n", "2\n00:00\n23:59\n", "2\n01:00\n01:01\n", "2\n06:25\n22:43\n", "2\n05:53\n04:15\n", "2\n11:24\n13:53\n"], "outputs": ["23:59\n", "23:59\n", "23:59\n", "23:58\n", "23:58\n", "16:17\n", "22:21\n", "21:30\n"]} | 434 | 180 |
coding | Solve the programming task below in a Python markdown code block.
An array B of length M consisting of only distinct elements is said to be *good* if the following condition holds:
Let i be the index of the maximum element of B.
Then, B[1,i] must be in ascending order, i.e, B_{1} < B_{2} < B_{3} < \ldots < B_{i}.
For ... | {"inputs": ["2\n4\n2 1 4 3\n5\n1 2 3 4 5\n"], "outputs": ["6\n16\n"]} | 615 | 39 |
coding | Solve the programming task below in a Python markdown code block.
In this Kata, you will implement a function `count` that takes an integer and returns the number of digits in `factorial(n)`.
For example, `count(5) = 3`, because `5! = 120`, and `120` has `3` digits.
More examples in the test cases.
Brute force i... | {"functional": "_inputs = [[5], [50], [500], [5000], [50000], [500000], [5000000], [50000000]]\n_outputs = [[3], [65], [1135], [16326], [213237], [2632342], [31323382], [363233781]]\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_t... | 137 | 257 |
coding | Solve the programming task below in a Python markdown code block.
Codehorses has just hosted the second Codehorses Cup. This year, the same as the previous one, organizers are giving T-shirts for the winners.
The valid sizes of T-shirts are either "M" or from $0$ to $3$ "X" followed by "S" or "L". For example, sizes "... | {"inputs": ["1\nM\nM\n", "1\nS\nM\n", "1\nL\nM\n", "1\nL\nS\n", "1\nM\nM\n", "1\nL\nS\n", "1\nL\nM\n", "1\nS\nM\n"], "outputs": ["0\n", "1\n", "1\n", "1\n", "0\n", "1\n", "1\n", "1\n"]} | 598 | 102 |
coding | Solve the programming task below in a Python markdown code block.
Read problem statements in [Mandarin], [Bengali], [Russian], and [Vietnamese] as well.
Two drunken players Alice and Bob are playing a modified version of Tic-Tac-Toe.
Initially, there is a $N \times M$ empty grid.
Alice and Bob take alternate turns s... | {"inputs": ["1\n3 4 2\n1 1\n3 1\n1 2\n2 3\n2 1\n2 4\n3 2\n3 4\n1 3\n3 3\n2 2\n1 4\n"], "outputs": ["Bob\n"]} | 649 | 68 |
coding | Solve the programming task below in a Python markdown code block.
You are given a huge decimal number consisting of $n$ digits. It is guaranteed that this number has no leading zeros. Each digit of this number is either 0 or 1.
You may perform several (possibly zero) operations with this number. During each operation ... | {"inputs": ["2 1 0\n10\n", "2 1 0\n10\n", "3 1 0\n100\n", "3 1 0\n100\n", "3 2 0\n100\n", "4 2 1\n1011\n", "4 2 0\n1000\n", "4 1 0\n1000\n"], "outputs": ["1\n", "1\n", "1\n", "1\n", "1\n", "1\n", "1\n", "1\n"]} | 498 | 135 |
coding | Solve the programming task below in a Python markdown code block.
Vasilisa the Wise from a far away kingdom got a present from her friend Helga the Wise from a farther away kingdom. The present is a surprise box, yet Vasilisa the Wise doesn't know yet what the surprise actually is because she cannot open the box. She h... | {"inputs": ["RRYYOO\n", "YYBBOO\n", "RRBYRR\n", "YYYYRB\n", "BYOVRR\n", "GVGBVO\n", "OVBRYG\n", "BRRBRB\n"], "outputs": ["6\n", "6\n", "2\n", "2\n", "15\n", "8\n", "30\n", "2\n"]} | 368 | 90 |
coding | Solve the programming task below in a Python markdown code block.
The prime numbers are not regularly spaced. For example from `2` to `3` the gap is `1`.
From `3` to `5` the gap is `2`. From `7` to `11` it is `4`.
Between 2 and 50 we have the following pairs of 2-gaps primes:
`3-5, 5-7, 11-13, 17-19, 29-31, 41-43`
A p... | {"functional": "_inputs = [[2, 3, 10], [3, 3, 10], [2, 100, 110], [4, 100, 110], [6, 100, 110], [8, 300, 400], [10, 300, 400], [4, 30000, 100000], [6, 30000, 100000], [8, 30000, 100000], [11, 30000, 100000], [2, 10000000, 11000000]]\n_outputs = [[[3, 5]], [None], [[101, 103]], [[103, 107]], [None], [[359, 367]], [[337,... | 711 | 447 |
coding | Solve the programming task below in a Python markdown code block.
In this kata, you will be given a string of text and valid parentheses, such as `"h(el)lo"`. You must return the string, with only the text inside parentheses reversed, so `"h(el)lo"` becomes `"h(le)lo"`. However, if said parenthesized text contains pare... | {"functional": "_inputs = [['h(el)lo'], ['a ((d e) c b)'], ['one (two (three) four)'], ['one (ruof ((rht)ee) owt)'], [''], ['many (parens) on (top)'], ['( ( ) (()) )']]\n_outputs = [['h(le)lo'], ['a (b c (d e))'], ['one (ruof (three) owt)'], ['one (two ((thr)ee) four)'], [''], ['many (snerap) on (pot)'], ['( (()) ( ) )... | 327 | 275 |
coding | Solve the programming task below in a Python markdown code block.
Check Tutorial tab to know how to to solve.
You are given a string $N$.
Your task is to verify that $N$ is a floating point number.
In this task, a valid float number must satisfy all of the following requirements:
$>$ Number can start with +,... | {"inputs": ["4\n4.0O0\n-1.00\n+4.54\nSomeRandomStuff\n"], "outputs": ["False\nTrue\nTrue\nFalse\n"]} | 324 | 42 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given a binary string s, you can split s into 3 non-empty strings s1, s2, and s3 where s1 + s2 + s3 = s.
Return the number of ways s can be split such that the number of ones is the same in s1, s2, and s3. Since the a... | {"functional": "def check(candidate):\n assert candidate(s = \"10101\") == 4\n assert candidate(s = \"1001\") == 0\n assert candidate(s = \"0000\") == 3\n assert candidate(s = \"100100010100110\") == 12\n\n\ncheck(Solution().numWays)"} | 133 | 93 |
coding | Solve the programming task below in a Python markdown code block.
There are N + 1 squares arranged in a row, numbered 0, 1, ..., N from left to right.
Initially, you are in Square X.
You can freely travel between adjacent squares. Your goal is to reach Square 0 or Square N.
However, for each i = 1, 2, ..., M, there is ... | {"inputs": ["5 3 3\n1 2 4\n", "7 3 2\n4 5 6\n", "10 7 5\n1 2 3 4 6 8 9\n"], "outputs": ["1\n", "0\n", "3\n"]} | 376 | 69 |
coding | Solve the programming task below in a Python markdown code block.
Finding your seat on a plane is never fun, particularly for a long haul flight... You arrive, realise again just how little leg room you get, and sort of climb into the seat covered in a pile of your own stuff.
To help confuse matters (although they cla... | {"functional": "_inputs = [['2B'], ['20B'], ['58I'], ['60D'], ['17K']]\n_outputs = [['Front-Left'], ['Front-Left'], ['No Seat!!'], ['Back-Middle'], ['Front-Right']]\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=t... | 255 | 197 |
coding | Solve the programming task below in a Python markdown code block.
Maxim always goes to the supermarket on Sundays. Today the supermarket has a special offer of discount systems.
There are m types of discounts. We assume that the discounts are indexed from 1 to m. To use the discount number i, the customer takes a spec... | {"inputs": ["1\n1\n1\n1\n", "1\n2\n1\n1\n", "1\n4\n1\n1\n", "1\n3\n1\n0\n", "1\n4\n1\n2\n", "1\n3\n1\n1\n", "1\n1\n3\n3 1 1\n", "1\n1\n7\n1 1 1 1 1 1 0\n"], "outputs": ["1", "1", "1\n", "0\n", "2\n", "1\n", "3", "2\n"]} | 544 | 131 |
coding | Solve the programming task below in a Python markdown code block.
The numbers 1 to n x n are contained in the n x n square squares one by one, and the sum of the squares in any vertical column and the sum of the squares in any horizontal column are diagonal squares. Those with the same sum of eyes are called magic squa... | {"inputs": ["3\n0\n0", "3\n7\n0", "3\n3\n0", "3\n9\n0", "3\n0\n1", "3\n0\n2", "3\n0\n3", "3\n0\n4"], "outputs": [" 4 9 2\n 3 5 7\n 8 1 6\n", " 4 9 2\n 3 5 7\n 8 1 6\n 22 47 16 41 10 35 4\n 5 23 48 17 42 11 29\n 30 6 24 49 18 36 12\n 13 31 7 25 43 19 37... | 500 | 866 |
coding | Solve the programming task below in a Python markdown code block.
There are 3 hidden numbers A, B, C.
You somehow found out the values of \min(A, B), \min(B, C), and \min(C, A).
Determine whether there exists any tuple (A, B, C) that satisfies the given values of \min(A, B), \min(B, C), \min(C, A).
------ Input Form... | {"inputs": ["3\n5 5 5\n2 3 4\n2 2 4\n"], "outputs": ["YES\nNO\nYES\n"]} | 369 | 36 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given an integer array nums, and you can perform the following operation any number of times on nums:
Swap the positions of two elements nums[i] and nums[j] if gcd(nums[i], nums[j]) > 1 where gcd(nums[i], num... | {"functional": "def check(candidate):\n assert candidate(nums = [7,21,3]) == True\n assert candidate(nums = [5,2,6,2]) == False\n assert candidate(nums = [10,5,9,3,15]) == True\n\n\ncheck(Solution().gcdSort)"} | 139 | 73 |
coding | Solve the programming task below in a Python markdown code block.
Read problem statements in [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Chef is given an array A consisting of N positive integers. Chef shuffles the array A and creates a new array B of length N, where B_{i} = (A_{i} + i) \bmod 2... | {"inputs": ["3\n3\n1 2 3\n3\n2 4 5\n2\n2 4\n"], "outputs": ["2\n3\n1"]} | 591 | 39 |
coding | Solve the programming task below in a Python markdown code block.
Snuke has two boards, each divided into a grid with N rows and N columns. For both of these boards, the square at the i-th row from the top and the j-th column from the left is called Square (i,j).
There is a lowercase English letter written in each squ... | {"inputs": ["2\nab\nda", "2\nab\nad", "2\nab\nac", "2\nba\nca", "2\nbb\nca", "2\nbb\nac", "2\ncb\nac", "2\ncb\nab"], "outputs": ["2\n", "0\n", "0\n", "0\n", "0\n", "0\n", "2\n", "0\n"]} | 506 | 96 |
coding | Solve the programming task below in a Python markdown code block.
Everybody knows the classic ["half your age plus seven"](https://en.wikipedia.org/wiki/Age_disparity_in_sexual_relationships#The_.22half-your-age-plus-seven.22_rule) dating rule that a lot of people follow (including myself). It's the 'recommended' age r... | {"functional": "_inputs = [[17], [40], [15], [35], [10], [53], [19], [12], [7], [33]]\n_outputs = [['15-20'], ['27-66'], ['14-16'], ['24-56'], ['9-11'], ['33-92'], ['16-24'], ['10-13'], ['6-7'], ['23-52']]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return ... | 277 | 255 |
coding | Solve the programming task below in a Python markdown code block.
Mobile phones are equipped with a function that displays input candidates in order to efficiently input texts such as emails. This records frequently used words and presents words that have the entered letters as initial letters as input candidates. For ... | {"inputs": ["1\nben likes bananas the best among many fruits because bananas are sweet and cheap\nb\n1\nwinners get to visit aizu and the university of aizu and make many friends as well\na\n3\nask alex about\nthe answer for the\nassignment on android apps\na\n2\nprogramming is both\na spprt and an intellectual puzzle\... | 439 | 836 |
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.
A non-empty string is called palindrome, if it reads the same from the left to the right and from the right to the left. For example, "abcba", "a", and "abba" are palindromes, while "abab" and "xy" are not.
A string is called a substring of another stri... | {"inputs": ["1\nz\n", "2\naa\n", "2\naz\n", "4\nmems\n", "5\noolol\n", "6\nmsucmc\n", "7\nlolikek\n", "9\nabcabcabc\n"], "outputs": ["z\n", "aa\n", "az\n", "emms\n", "llooo\n", "ccmmsu\n", "eikkllo\n", "aaabbbccc\n"]} | 517 | 106 |
coding | Solve the programming task below in a Python markdown code block.
Iahub and his friend Floyd have started painting a wall. Iahub is painting the wall red and Floyd is painting it pink. You can consider the wall being made of a very large number of bricks, numbered 1, 2, 3 and so on.
Iahub has the following scheme of ... | {"inputs": ["3 2 5 5\n", "1 1 1 1\n", "2 3 7 7\n", "3 3 3 7\n", "3 2 5 5\n", "3 3 3 7\n", "2 3 7 7\n", "1 1 1 1\n"], "outputs": ["0", "1", "0", "2", "0\n", "2\n", "0\n", "1\n"]} | 444 | 114 |
coding | Solve the programming task below in a Python markdown code block.
You are given a binary string S. A binary string is a string consisting of only 0's and 1's.
A binary string is called *good* if it has an equal number of occurrences of \texttt{01} substrings and \texttt{10} substrings. Note that these substrings may o... | {"inputs": ["2\n10100\n11111"], "outputs": ["2\n3"]} | 712 | 26 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given n tasks labeled from 0 to n - 1 represented by a 2D integer array tasks, where tasks[i] = [enqueueTimei, processingTimei] means that the ith task will be available to process at enqueueTi... | {"functional": "def check(candidate):\n assert candidate(tasks = [[1,2],[2,4],[3,2],[4,1]]) == [0,2,3,1]\n assert candidate(tasks = [[7,10],[7,12],[7,5],[7,4],[7,2]]) == [4,3,2,0,1]\n\n\ncheck(Solution().getOrder)"} | 248 | 93 |
coding | Solve the programming task below in a Python markdown code block.
Aujasvit just came up with a new game to play with his friends. N people stand in a circle, each assigned an index from 1 to N in clockwise order. Then the following operation is done N-1 times.
The person with the lowest index holds a coin.
Then, the c... | {"inputs": ["1\n2 3\n"], "outputs": ["1 1 1"]} | 476 | 21 |
coding | Solve the programming task below in a Python markdown code block.
### Description
As hex values can include letters `A` through to `F`, certain English words can be spelled out, such as `CAFE`, `BEEF`, or `FACADE`.
This vocabulary can be extended by using numbers to represent other letters, such as `5EAF00D`, or `DEC0D... | {"functional": "_inputs = [['DEFACE'], ['SAFE'], ['CODE'], ['BUGS'], [''], ['DO YOU SEE THAT BEE DRINKING DECAF COFFEE'], ['ASSESS ANY BAD CODE AND TRY AGAIN']]\n_outputs = [[14613198], [23294], [49374], [0], [0], [13565769], [10889952]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinst... | 263 | 242 |
coding | Solve the programming task below in a Python markdown code block.
The only difference between the easy and hard versions is that tokens of type O do not appear in the input of the easy version.
Errichto gave Monogon the following challenge in order to intimidate him from taking his top contributor spot on Codeforces.
... | {"inputs": ["1\n6\nXXXXXX\nXXXXXX\nXX..XX\nXX..XX\nXXXXXX\nXXXXXX\n", "3\n3\n.O.\nOOO\n.O.\n6\nXXXOOO\nXXXOOO\nXX..OO\nOO..XX\nOOOXXX\nOOOXXX\n5\n.OOO.\nOXXXO\nOXXXO\nOXXXO\n.OOO.\n", "3\n3\n.X.\nXXX\n.X.\n6\nXX.XXX\nXXXXXX\nXXX.XX\nXXXXXX\nXX.X.X\nXXXXXX\n5\nXXX.X\n.X..X\nXXX.X\n..X..\n..X..\n"], "outputs": ["XXOXXO\n... | 682 | 304 |
coding | Solve the programming task below in a Python markdown code block.
Devu is a disastrous oracle: his predictions about various events of your life are horrifying. Instead of providing good luck, he "blesses" you with bad luck. The secret behind his wickedness is a hidden omen which is a string of length m. On your visit ... | {"inputs": ["3\n2\nab\nba\n2\naa\nbb\n3\naabb\nabab\nbaab"], "outputs": ["1\n0\n2"]} | 488 | 39 |
coding | Solve the programming task below in a Python markdown code block.
Little Vasya has received a young builder’s kit. The kit consists of several wooden bars, the lengths of all of them are known. The bars can be put one on the top of the other if their lengths are the same.
Vasya wants to construct the minimal number of... | {"inputs": ["1\n1\n", "1\n2\n", "1\n1000\n", "3\n1 2 2\n", "3\n1 2 1\n", "3\n1 2 3\n", "3\n2 1 16\n", "3\n3 1 16\n"], "outputs": ["1 1\n", "1 1\n", "1 1\n", "2 2\n", "2 2\n", "1 3\n", "1 3\n", "1 3\n"]} | 218 | 127 |
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 integer matrix grid, where m and n are both even integers, and an integer k.
The matrix is composed of several layers, which is shown in the below image, where each color is its own layer:
A... | {"functional": "def check(candidate):\n assert candidate(grid = [[40,10],[30,20]], k = 1) == [[10,20],[40,30]]\n assert candidate(grid = [[1,2,3,4],[5,6,7,8],[9,10,11,12],[13,14,15,16]], k = 2) == [[3,4,8,12],[2,11,10,16],[1,7,6,15],[5,9,13,14]]\n\n\ncheck(Solution().rotateGrid)"} | 170 | 151 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
A sentence is a string of single-space separated words where each word can contain digits, lowercase letters, and the dollar sign '$'. A word represents a price if it is a sequence of digits preceded by a dollar sign.... | {"functional": "def check(candidate):\n assert candidate(sentence = \"there are $1 $2 and 5$ candies in the shop\", discount = 50) == \"there are $0.50 $1.00 and 5$ candies in the shop\"\n assert candidate(sentence = \"1 2 $3 4 $5 $6 7 8$ $9 $10$\", discount = 100) == \"1 2 $0.00 4 $0.00 $0.00 7 8$ $0.00 $10$\"\n... | 201 | 144 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given a 0-indexed integer array nums.
Initially, all of the indices are unmarked. You are allowed to make this operation any number of times:
Pick two different unmarked indices i and j such that 2 * nums[i] ... | {"functional": "def check(candidate):\n assert candidate(nums = [3,5,2,4]) == 2\n assert candidate(nums = [9,2,5,4]) == 4\n assert candidate(nums = [7,6,8]) == 0\n\n\ncheck(Solution().maxNumOfMarkedIndices)"} | 132 | 75 |
coding | Solve the programming task below in a Python markdown code block.
A bitstring is a string consisting only of the characters 0 and 1. A bitstring is called k-balanced if every substring of size k of this bitstring has an equal amount of 0 and 1 characters (k/2 of each).
You are given an integer k and a string s which i... | {"inputs": ["9\n6 4\n100111\n3 2\n1?1\n3 2\n0?1\n4 4\n????\n7 4\n?1??0?1\n10 8\n11???11?11\n4 2\n1??1\n4 4\n0??0\n6 2\n00????\n", "9\n6 4\n100110\n3 2\n1?1\n3 2\n0?1\n4 4\n????\n7 4\n1?0??1?\n10 6\n11???11?11\n4 2\n1??1\n4 4\n?0?0\n6 2\n????10\n", "9\n6 4\n100111\n3 2\n1?1\n3 2\n0?1\n4 4\n????\n7 4\n?1??0?1\n10 5\n11??... | 536 | 870 |
coding | Solve the programming task below in a Python markdown code block.
For an array $[b_1, b_2, \ldots, b_m]$ define its number of inversions as the number of pairs $(i, j)$ of integers such that $1 \le i < j \le m$ and $b_i>b_j$. Let's call array $b$ odd if its number of inversions is odd.
For example, array $[4, 2, 7]$ i... | {"inputs": ["5\n3\n1 2 3\n4\n4 3 2 1\n2\n1 2\n2\n2 1\n6\n4 5 6 1 2 3\n"], "outputs": ["0\n2\n0\n1\n1\n"]} | 645 | 66 |
coding | Solve the programming task below in a Python markdown code block.
# Task
Given array of integers `sequence` and some integer `fixedElement`, output the number of `even` values in sequence before the first occurrence of `fixedElement` or `-1` if and only if `fixedElement` is not contained in sequence.
# Input/Output
... | {"functional": "_inputs = [[[1, 4, 2, 6, 3, 1], 6], [[2, 2, 2, 1], 3], [[2, 3, 4, 3], 3], [[1, 3, 4, 3], 3]]\n_outputs = [[2], [-1], [1], [0]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return math.isclose(a, b, rel_tol=tol, abs_tol=tol)\n if isinstance... | 318 | 229 |
coding | Solve the programming task below in a Python markdown code block.
Princess'Gamble
Princess gambling
English text is not available in this practice contest.
One day, a brave princess in a poor country's tomboy broke the walls of her room, escaped from the castle, and entered the gambling hall where horse racing and o... | {"inputs": ["3 3 0\n1\n4\n3\n4 4 65\n1\n2\n3\n0\n3 1 3\n8\n2\n1\n0 0 0", "3 2 6\n2\n2\n3\n4 4 65\n1\n2\n6\n0\n3 1 2\n8\n1\n1\n0 0 0", "3 2 6\n3\n2\n3\n4 4 65\n1\n2\n6\n0\n3 1 2\n8\n1\n1\n0 0 0", "3 2 1\n1\n2\n3\n4 4 4\n1\n2\n1\n1\n3 1 16\n6\n0\n3\n0 0 0", "3 2 1\n1\n2\n3\n4 4 4\n1\n2\n1\n1\n3 1 16\n6\n0\n4\n0 0 0", "3 ... | 614 | 477 |
coding | Solve the programming task below in a Python markdown code block.
There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other.
Input
The first line contains... | {"inputs": ["1\n1\n", "1\n3\n", "1\n2\n", "2\n3 2\n", "2\n2 1\n", "2\n3 1\n", "2\n1 2\n", "2\n2 3\n"], "outputs": ["0\n", "0\n", "0\n", "1\n", "1\n", "1\n", "1\n", "1\n"]} | 182 | 96 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.