task_type stringclasses 1
value | problem stringlengths 261 3.34k | answer stringlengths 35 6.15k | problem_tokens int64 62 774 | answer_tokens int64 12 2.04k |
|---|---|---|---|---|
coding | Solve the programming task below in a Python markdown code block.
People in Silverland use square coins. Not only they have square shapes but also their values are square numbers. Coins with values of all square numbers up to 289 (= 172), i.e., 1-credit coins, 4-credit coins, 9-credit coins, ..., and 289-credit coins, ... | {"inputs": ["2\n4\n1\n0", "2\n2\n6\n0", "2\n0\n6\n0", "2\n7\n0\n0", "2\n2\n1\n0", "2\n1\n8\n0", "2\n4\n6\n0", "2\n0\n8\n0"], "outputs": ["1\n2\n1\n", "1\n1\n2\n", "1\n", "1\n2\n", "1\n1\n1\n", "1\n1\n3\n", "1\n2\n2\n", "1\n"]} | 277 | 132 |
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.
Dr.D is now fond of matrices. He is particularly interested in Doofish Matrices. A Doofish Matrix of order $N$ is a matrix with $N$ rows (numbered $1... | {"inputs": ["2\n1\n2"], "outputs": ["Hooray\n1\nHooray\n3 1\n2 3"]} | 510 | 32 |
coding | Solve the programming task below in a Python markdown code block.
You are playing one famous sandbox game with the three-dimensional world. The map of the world can be represented as a matrix of size n × m, where the height of the cell (i, j) is a_{i, j}.
You are in the cell (1, 1) right now and want to get in the cel... | {"inputs": ["1\n8 6\n2 -1 3 4 1 6\n7 2 16 14 7 12\n1 14 15 10 1 27\n19 20 35 5 6 39\n7 27 54 60 30 31\n33 4 35 36 34 35\n47 38 75 40 41 42\n44 45 49 47 48 49\n", "1\n8 6\n2 -1 3 4 1 6\n7 2 16 14 7 12\n1 14 15 14 1 27\n19 20 35 5 6 39\n7 27 54 60 30 31\n33 4 35 36 34 35\n47 38 75 40 41 42\n44 45 49 47 48 49\n", "1\n8 6\... | 717 | 1,153 |
coding | Solve the programming task below in a Python markdown code block.
You are given a sequence $A_1, A_2, \ldots, A_N$. You want all the elements of the sequence to be equal. In order to achieve that, you may perform zero or more moves. In each move, you must choose an index $i$ ($1 \le i \le N$), then choose $j = i-1$ or ... | {"inputs": ["3\n5\n1 1 1 1 1\n4\n9 8 1 8\n2\n1 9"], "outputs": ["0\n2\n1"]} | 419 | 44 |
coding | Solve the programming task below in a Python markdown code block.
Vasya has n days of vacations! So he decided to improve his IT skills and do sport. Vasya knows the following information about each of this n days: whether that gym opened and whether a contest was carried out in the Internet on that day. For the i-th d... | {"inputs": ["1\n0\n", "1\n1\n", "1\n2\n", "1\n3\n", "1\n2\n", "1\n1\n", "1\n3\n", "1\n0\n"], "outputs": ["1\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "1\n"]} | 685 | 86 |
coding | Solve the programming task below in a Python markdown code block.
Chef is fond of burgers and decided to make as many burgers as possible.
Chef has A patties and B buns. To make 1 burger, Chef needs 1 patty and 1 bun.
Find the maximum number of burgers that Chef can make.
------ Input Format ------
- The first li... | {"inputs": ["4\n2 2\n2 3\n3 2\n23 17"], "outputs": ["2\n2\n2\n17\n"]} | 387 | 38 |
coding | Solve the programming task below in a Python markdown code block.
Read problems statements in Mandarin chinese, Russian and Vietnamese as well.
You are given a score log of a football match between two teams. Every time when one of the teams scored a goal, the name of that team was written in the score log on a separ... | {"inputs": ["2\n4\nab\nbc\nbc\nab\n3\nxxx\nyyy\nyyy"], "outputs": ["Draw\nyyy"]} | 361 | 32 |
coding | Solve the programming task below in a Python markdown code block.
You have a new professor of graph theory and he speaks very quickly. You come up with the following plan to keep up with his lecture and make notes.
You know two languages, and the professor is giving the lecture in the first one. The words in both lang... | {"inputs": ["1 1\na c\na\n", "1 1\na c\na\n", "1 1\namit am\namit\n", "1 1\namit am\namit\n", "1 1\namit ma\namit\n", "1 1\namit la\namit\n", "5 3\njoll wuqrd\neuzf un\nhbnyiyc rsoqqveh\nhbnyiyc joll joll euzf joll\n", "5 3\njoll wuqrd\neuzf un\nhbnyiyc rsoqqveh\nhbnyiyc joll joll euzf joll\n"], "outputs": ["a\n", "a "... | 562 | 210 |
coding | Solve the programming task below in a Python markdown code block.
Write a program to check whether a triangle is valid or not, when the three angles of the triangle are the inputs. A triangle is valid if the sum of all the three angles is equal to 180 degrees.
-----Input-----
The first line contains an integer T, the... | {"inputs": ["3 \n10 2 001\n0 8 5\n180 1 0", "3 \n10 2 001\n0 8 2\n180 1 0", "3 \n41 2 001\n0 8 15\n180 1 0", "3 \n10 2 001\n0 8 15\n180 1 0", "3 \n10 2 000\n0 8 15\n180 1 0", "3 \n10 2 000\n0 7 15\n180 1 0", "3 \n3 2 101\n0 45 15\n180 0 0", "3 \n41 2 101\n0 8 15\n180 1 0"], "outputs": ["NO\nNO\nNO\n", "NO\nNO\nNO\n", "... | 202 | 292 |
coding | Solve the programming task below in a Python markdown code block.
There are n boys and m girls studying in the class. They should stand in a line so that boys and girls alternated there as much as possible. Let's assume that positions in the line are indexed from left to right by numbers from 1 to n + m. Then the numbe... | {"inputs": ["3 3\n", "4 2\n", "5 5\n", "6 4\n", "1 1\n", "1 2\n", "2 1\n", "1 4\n"], "outputs": ["GBGBGB\n", "BGBGBB\n", "GBGBGBGBGB\n", "BGBGBGBGBB\n", "GB\n", "GBG\n", "BGB\n", "GBGGG\n"]} | 313 | 104 |
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.
In a *red-blue tree*, each vertex is either red or blue and adjacent vertices always have different colours.
You are given a tree with $N$ vertices... | {"inputs": ["1 \n7 \n1 2 \n1 3 \n2 4 \n2 5 \n3 6 \n3 7 \n0010010"], "outputs": ["3"]} | 573 | 62 |
coding | Solve the programming task below in a Python markdown code block.
A robot is initially at $(0,0)$ on the cartesian plane. It can move in 4 directions - up, down, left, right denoted by letter u, d, l, r respectively. More formally:
- if the position of robot is $(x,y)$ then u makes it $(x,y+1)$
- if the position of rob... | {"inputs": ["5\n1\n2\n3\n50\n12233443"], "outputs": ["0 1\n-1 1\n-1 0\n2 4\n-1749 812"]} | 388 | 56 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given an m x n matrix matrix and an integer k, return the max sum of a rectangle in the matrix such that its sum is no larger than k.
It is guaranteed that there will be a rectangle with a sum no larger than k.
Plea... | {"functional": "def check(candidate):\n assert candidate(matrix = [[1,0,1],[0,-2,3]], k = 2) == 2\n assert candidate(matrix = [[2,2,-1]], k = 3) == 3\n\n\ncheck(Solution().maxSumSubmatrix)"} | 104 | 69 |
coding | Solve the programming task below in a Python markdown code block.
Gerald plays the following game. He has a checkered field of size n × n cells, where m various cells are banned. Before the game, he has to put a few chips on some border (but not corner) board cells. Then for n - 1 minutes, Gerald every minute moves eac... | {"inputs": ["3 0\n", "4 0\n", "3 0\n", "999 0\n", "999 0\n", "540 0\n", "428 0\n", "1000 0\n"], "outputs": ["1\n", "4\n", "1\n", "1993\n", "1993\n", "1076\n", "852\n", "1996\n"]} | 523 | 111 |
coding | Solve the programming task below in a Python markdown code block.
## If/else syntax debug
While making a game, your partner, Greg, decided to create a function to check if the user is still alive called `checkAlive`/`CheckAlive`/`check_alive`. Unfortunately, Greg made some errors while creating the function.
`checkAl... | {"functional": "_inputs = [[5], [0], [-5]]\n_outputs = [[True], [False], [False]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return math.isclose(a, b, rel_tol=tol, abs_tol=tol)\n if isinstance(a, (list, tuple)):\n if len(a) != len(b): return Fals... | 161 | 166 |
coding | Solve the programming task below in a Python markdown code block.
Rabbits and cats are competing. The rules are as follows.
First, each of the two animals wrote n2 integers on a piece of paper in a square with n rows and n columns, and drew one card at a time. Shuffle two cards and draw them one by one alternately. Ea... | {"inputs": ["3 2 2 0\n1 2 3\n4 5 6\n7 8 9\n1 2 3\n6 5 4\n7 8 9\n11\n4\n7\n5\n10\n9\n2\n1\n3\n8", "3 2 4 10\n1 2 3\n4 5 6\n7 8 9\n1 2 3\n6 5 4\n7 8 9\n11\n4\n7\n5\n10\n9\n2\n1\n3\n8", "3 3 4 11\n1 2 3\n8 5 6\n7 8 9\n1 2 3\n8 5 4\n7 8 9\n11\n4\n7\n5\n10\n9\n3\n1\n3\n8", "3 5 4 11\n1 2 3\n8 5 6\n7 8 9\n1 2 3\n8 5 4\n7 8 9... | 574 | 592 |
coding | Solve the programming task below in a Python markdown code block.
Create a function named `divisors`/`Divisors` that takes an integer `n > 1` and returns an array with all of the integer's divisors(except for 1 and the number itself), from smallest to largest. If the number is prime return the string '(integer) is prim... | {"functional": "_inputs = [[15], [253], [24], [13], [3], [29]]\n_outputs = [[[3, 5]], [[11, 23]], [[2, 3, 4, 6, 8, 12]], ['13 is prime'], ['3 is prime'], ['29 is prime']]\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... | 176 | 222 |
coding | Solve the programming task below in a Python markdown code block.
Chef has decided to start home delivery from his restaurant. He hopes that he will get a lot of orders for delivery, however there is a concern. He doesn't have enough work forces for all the deliveries. For this he has came up with an idea - he will gr... | {"inputs": ["1\n4 2\n0 1\n1 2\n3\n0 2\n0 3\n2 1\n\n"], "outputs": ["YO\nNO\nYO"]} | 504 | 44 |
coding | Solve the programming task below in a Python markdown code block.
You will be given an array of strings. The words in the array should mesh together where one or more letters at the end of one word will have the same letters (in the same order) as the next word in the array. But, there are times when all the words won'... | {"functional": "_inputs = [[['beacon', 'condominium', 'umbilical', 'california']], [['allow', 'lowering', 'ringmaster', 'terror']], [['abandon', 'donation', 'onion', 'ongoing']], [['jamestown', 'ownership', 'hippocampus', 'pushcart', 'cartographer', 'pheromone']], [['marker', 'kerchief', 'effortless', 'lesson', 'sonnet... | 424 | 1,323 |
coding | Solve the programming task below in a Python markdown code block.
Airport Codes
Airport code
In the Kingdom of JAG, airport codes are assigned to each domestic airport for identification.
Airport codes are assigned according to the following rules based on the name of the airport in lowercase English alphabet:
1. E... | {"inputs": ["3\nhaneda\noookayama\nssu\n2\nazusa\nazishirabe\n2\nsnuke\nsnake\n4\nhaneda\nhonda\nhanamaki\nhawaii\n0", "3\nhaneda\noookayama\ntsv\n2\nazusa\nazishirabe\n2\nrnuke\nsnake\n4\nhaneda\nhonda\nhanamaki\nhawbii\n0", "3\nhaneda\noookayama\ntsv\n2\nazvsa\nazishirabe\n2\nrnuke\nsnake\n4\nhaneda\nhonda\nhanamaki\... | 553 | 484 |
coding | Solve the programming task below in a Python markdown code block.
Polycarpus is an amateur businessman. Recently he was surprised to find out that the market for paper scissors is completely free! Without further ado, Polycarpus decided to start producing and selling such scissors.
Polycaprus calculated that the optim... | {"inputs": ["1 0\n", "8 7\n", "9 0\n", "20 1\n", "10 1\n", "59 3\n", "16 1\n", "10 0\n"], "outputs": ["1\n", "8\n", "9\n", "19\n", "9\n", "59\n", "16\n", "10\n"]} | 347 | 95 |
coding | Solve the programming task below in a Python markdown code block.
Given an array $\boldsymbol{A\left[\right]}$ of $N$ distinct elements. Let $M_1$ and $M_2$ be the smallest and the next smallest element in the interval $[L,R]$ where $1\leq L<R\leq N$.
$S_i=(((M_1\wedge M_2)\oplus(M_1\vee M_2))\wedge(M_1\oplus M_2))$... | {"inputs": ["5\n9 6 3 5 2\n"], "outputs": ["15\n"]} | 323 | 25 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given an array of words where each word consists of lowercase English letters.
wordA is a predecessor of wordB if and only if we can insert exactly one letter anywhere in wordA without changing the order of th... | {"functional": "def check(candidate):\n assert candidate(words = [\"a\",\"b\",\"ba\",\"bca\",\"bda\",\"bdca\"]) == 4\n assert candidate(words = [\"xbc\",\"pcxbcf\",\"xb\",\"cxbc\",\"pcxbc\"]) == 5\n assert candidate(words = [\"abcd\",\"dbqca\"]) == 1\n\n\ncheck(Solution().longestStrChain)"} | 212 | 92 |
coding | Solve the programming task below in a Python markdown code block.
Mislove had an array $a_1$, $a_2$, $\cdots$, $a_n$ of $n$ positive integers, but he has lost it. He only remembers the following facts about it:
The number of different numbers in the array is not less than $l$ and is not greater than $r$;
For each... | {"inputs": ["4 2 2\n", "5 1 5\n", "1 1 1\n", "1 1 1\n", "2 1 1\n", "2 1 2\n", "2 2 2\n", "3 1 2\n"], "outputs": ["5 7\n", "5 31\n", "1 1\n", "1 1\n", "2 2\n", "2 3\n", "3 3\n", "3 5\n"]} | 561 | 119 |
coding | Solve the programming task below in a Python markdown code block.
Sinchan and his friends loves to eat. They have a 2D rectangular cake which they want to share. Sinchan is very kind and offers his friends to eat the cake first, all friends goes one by one to eat the cake. Each friend will cut cake into two parts. Firs... | {"inputs": ["3\n2\n5 3\n4\n4 8\n1\n1 2"], "outputs": ["Yes 2\nNo\nYes 1"]} | 379 | 38 |
coding | Solve the programming task below in a Python markdown code block.
The [Ones' Complement](https://en.wikipedia.org/wiki/Ones%27_complement) of a binary number is the number obtained by swapping all the 0s for 1s and all the 1s for 0s. For example:
```
onesComplement(1001) = 0110
onesComplement(1001) = 0110
```
For any... | {"functional": "_inputs = [['0'], ['1'], ['01'], ['10'], ['1101']]\n_outputs = [['1'], ['0'], ['10'], ['01'], ['0010']]\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 ... | 149 | 190 |
coding | Solve the programming task below in a Python markdown code block.
You are given $n$ non-negative integers, $a_0,a_1,\ldots,a_{n-1}$. We define the score for some permutation ($\boldsymbol{p}$) of length $n$ to be the maximum of $a_{p_i}\oplus a_{p_{i+1}}$ for $0\leq i<n-1$.
Find the permutation with the minimum possi... | {"inputs": ["3\n1 2 3\n", "4\n1 2 3 4\n"], "outputs": ["2\n", "5\n"]} | 451 | 36 |
coding | Solve the programming task below in a Python markdown code block.
Problem statement
N first-year students of the Faculty of Information Science and Technology of R University take the final exam of the lecture called Programming Exercise 1. The test is a perfect score of m. In other words, the score that one student c... | {"inputs": ["5 100", "5 110", "5 111", "6 110", "9 110", "9 100", "5 101", "9 000"], "outputs": ["0 0 0 100 100\n", "0 0 0 110 110\n", "0 0 0 111 111\n", "0 0 0 0 110 110\n", "0 0 0 0 0 110 110 110 110\n", "0 0 0 0 0 100 100 100 100\n", "0 0 0 101 101\n", "0 0 0 0 0 0 0 0 0\n"]} | 352 | 220 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
A sentence is a list of words that are separated by a single space with no leading or trailing spaces. Each word consists of lowercase and uppercase English letters.
A sentence can be shuffled by appending the 1-index... | {"functional": "def check(candidate):\n assert candidate(s = \"is2 sentence4 This1 a3\") == \"This is a sentence\"\n assert candidate(s = \"Myself2 Me1 I4 and3\") == \"Me Myself and I\"\n\n\ncheck(Solution().sortSentence)"} | 160 | 67 |
coding | Solve the programming task below in a Python markdown code block.
There are N Snukes lining up in a row. You are given a string S of length N. The i-th Snuke from the front has two red balls if the i-th character in S is `0`; one red ball and one blue ball if the i-th character in S is `1`; two blue balls if the i-th c... | {"inputs": ["1", "0", "2", "0", "1", "2", "10", "11"], "outputs": ["2\n", "1\n", "1\n", "1\n", "2\n", "1\n", "4\n", "6\n"]} | 364 | 64 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given a 2D integer array nums, return all elements of nums in diagonal order as shown in the below images.
Please complete the following python code precisely:
```python
class Solution:
def findDiagonalOrder(sel... | {"functional": "def check(candidate):\n assert candidate(nums = [[1,2,3],[4,5,6],[7,8,9]]) == [1,4,2,7,5,3,8,6,9]\n assert candidate(nums = [[1,2,3,4,5],[6,7],[8],[9,10,11],[12,13,14,15,16]]) == [1,6,2,8,7,3,9,4,12,10,5,13,11,14,15,16]\n assert candidate(nums = [[1,2,3],[4],[5,6,7],[8],[9,10,11]]) == [1,4,2,5,... | 76 | 243 |
coding | Solve the programming task below in a Python markdown code block.
Consider the word `"abode"`. We can see that the letter `a` is in position `1` and `b` is in position `2`. In the alphabet, `a` and `b` are also in positions `1` and `2`. Notice also that `d` and `e` in `abode` occupy the positions they would occupy in t... | {"functional": "_inputs = [[['abode', 'ABc', 'xyzD']], [['abide', 'ABc', 'xyz']], [['IAMDEFANDJKL', 'thedefgh', 'xyzDEFghijabc']], [['encode', 'abc', 'xyzD', 'ABmD']]]\n_outputs = [[[4, 3, 1]], [[4, 3, 0]], [[6, 5, 7]], [[1, 3, 1, 3]]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstan... | 370 | 246 |
coding | Solve the programming task below in a Python markdown code block.
We define the *goodness* of any array B of length M as: \sum_{i = 1}^{M - 1} |B_{i + 1} - B_{i}| (Here |X| denotes the absolute value of X). In particular, *goodness* of any array of length 1 is 0.
Alice and Bob have an array A containing N distinct ele... | {"inputs": ["2\n3\n1 3 2\n4\n1 2 3 4\n"], "outputs": ["Bob\nAlice\n"]} | 759 | 34 |
coding | Solve the programming task below in a Python markdown code block.
Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given a and b.
Constraints
* 0 < a, b ≤ 2,000,000,000
* LCM(a, b) ≤ 2,000,000,000
* The number of data sets ≤ 50
Input
Input consists of several d... | {"inputs": ["13 1\n183 188468232", "13 1\n183 218395056", "13 1\n183 158763340", "13 2\n183 158763340", "11 2\n183 158763340", "8 1\n21473 188468232", "8 1\n32366 188468232", "0 8\n3041947 11770363"], "outputs": ["1 13\n3 11496562152\n", "1 13\n3 13322098416\n", "1 13\n1 29053691220\n", "1 26\n1 29053691220\n", "1 22\n... | 204 | 342 |
coding | Solve the programming task below in a Python markdown code block.
Dr .: Peter, I've finally done it.
Peter: See you again? What kind of silly invention is this time?
Dr .: I finally came up with a revolutionary way to process mathematical formulas on a computer. Look at this table.
Ordinary notation | Dr.'s "breakth... | {"inputs": ["2 0 82 - /\n4 4 - 7 0 3 * + *\n0 0 1 + +", "1 0 82 - /\n4 4 - 7 0 3 * + *\n0 0 1 + +", "1 0 82 - /\n1 4 - 7 0 3 + + *\n0 0 1 + +", "1 0 82 - /\n1 4 - 7 0 3 * + *\n0 0 1 + +", "1 0 82 - /\n2 4 - 7 0 3 * + *\n0 0 1 + +", "1 0 82 - /\n2 4 - 7 0 3 * + *\n1 0 1 + +", "1 0 82 - /\n2 6 - 7 0 3 * + *\n1 0 1 + +", ... | 676 | 507 |
coding | Solve the programming task below in a Python markdown code block.
Before the Battle of Kamino the Confederacy of Independent Systems developed the a way to communicate with the far systems. This way is very unique as every word consists of exactly L lowercase letters. Also, there are exactly D words in this.
Jedi orde... | {"inputs": ["10 25 10\nnwlrbbmqbh\ncdarzowkky\nhiddqscdxr\njmowfrxsjy\nbldbefsarc\nbynecdyggx\nxpklorelln\nmpapqfwkho\npkmcoqhnwn\nkuewhsqmgb\nbuqcljjivs\nwmdkqtbxix\nmvtrrbljpt\nnsnfwzqfjm\nafadrrwsof\nsbcnuvqhff\nbsaqxwpqca\ncehchzvfrk\nmlnozjkpqp\nxrjxkitzyx\nacbhhkicqc\noendtomfgd\nwdwfcgpxiq\nvkuytdlcgd\newhtacioh... | 432 | 722 |
coding | Solve the programming task below in a Python markdown code block.
David was given a red checkered rectangle of size $n \times m$. But he doesn't like it. So David cuts the original or any other rectangle piece obtained during the cutting into two new pieces along the grid lines. He can do this operation as many times a... | {"inputs": ["4\n1 3\n2 2\n2 5\n3 5\n"], "outputs": ["1\n2\n4\n5\n"]} | 344 | 36 |
coding | Solve the programming task below in a Python markdown code block.
Vasya tries to break in a safe. He knows that a code consists of n numbers, and every number is a 0 or a 1. Vasya has made m attempts to enter the code. After each attempt the system told him in how many position stand the right numbers. It is not said i... | {"inputs": ["6 1\n101011 2\n", "6 2\n000000 2\n010100 4\n", "7 2\n1011111 2\n1001111 1\n", "6 3\n000100 2\n010100 4\n111100 0\n", "6 3\n000000 2\n010100 4\n111100 2\n", "6 3\n000000 2\n010100 4\n111100 0\n", "8 3\n00111100 5\n10100111 2\n10110101 2\n", "6 4\n000110 2\n010001 2\n001111 2\n001100 2\n"], "outputs": ["15",... | 387 | 277 |
coding | Solve the programming task below in a Python markdown code block.
Chef wants to gift C chocolates to Botswal on his birthday. However, he has only X chocolates with him.
The cost of 1 chocolate is Y rupees.
Find the minimum money in rupees Chef needs to spend so that he can gift C chocolates to Botswal.
------ Inp... | {"inputs": ["2\n7 5 5\n10 1 1"], "outputs": ["10\n9"]} | 322 | 28 |
coding | Solve the programming task below in a Python markdown code block.
Emuskald is an avid horticulturist and owns the world's longest greenhouse — it is effectively infinite in length.
Over the years Emuskald has cultivated n plants in his greenhouse, of m different plant species numbered from 1 to m. His greenhouse is ve... | {"inputs": ["1 1\n1 0\n", "1 1\n1 0\n", "3 3\n2 0\n1 1\n3 2\n", "3 3\n3 0\n1 1\n2 2\n", "3 3\n3 0\n1 1\n2 2\n", "3 3\n2 0\n1 1\n3 2\n", "3 3\n2 0\n1 1\n2 2\n", "3 3\n2 -1\n1 1\n3 2\n"], "outputs": ["0\n", "0\n", "1\n", "1\n", "1\n", "1\n", "1\n", "1\n"]} | 670 | 166 |
coding | Solve the programming task below in a Python markdown code block.
You are given an undirected connected weighted graph with N vertices and M edges that contains neither self-loops nor double edges.
The i-th (1≤i≤M) edge connects vertex a_i and vertex b_i with a distance of c_i.
Here, a self-loop is an edge where a_i = ... | {"inputs": ["3 2\n1 2 2\n2 3 1", "3 2\n1 3 2\n2 3 1", "3 2\n1 3 2\n2 0 1", "3 2\n1 2 2\n2 0 1", "3 2\n2 2 2\n2 0 1", "3 2\n1 1 1\n2 3 1", "3 2\n1 3 2\n2 1 1", "3 2\n1 3 3\n2 1 1"], "outputs": ["0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n"]} | 366 | 174 |
coding | Solve the programming task below in a Python markdown code block.
A famous gang of pirates, Sea Dogs, has come back to their hideout from one of their extravagant plunders. They want to split their treasure fairly amongst themselves, that is why You, their trusted financial advisor, devised a game to help them:
All of... | {"inputs": ["1 1\n1 1\n", "1 1\n1 1\n", "2 1\n1 1\n", "2 1\n1 0\n", "2 1\n2 0\n", "2 1\n2 -1\n", "2 1\n1 -1\n", "4 2\n1 2\n2 2\n"], "outputs": ["1", "1", "1\n", "1\n", "1\n", "1\n", "1\n", "1"]} | 605 | 119 |
coding | Solve the programming task below in a Python markdown code block.
In Omkar's last class of math, he learned about the least common multiple, or $LCM$. $LCM(a, b)$ is the smallest positive integer $x$ which is divisible by both $a$ and $b$.
Omkar, having a laudably curious mind, immediately thought of a problem involvi... | {"inputs": ["1\n2\n", "1\n2\n", "2\n7\n8\n", "2\n7\n8\n", "2\n7\n16\n", "2\n8\n11\n", "3\n4\n6\n9\n", "3\n4\n5\n2\n"], "outputs": ["1 1\n", "1 1\n", "1 6\n4 4\n", "1 6\n4 4\n", "1 6\n8 8\n", "4 4\n1 10\n", "2 2\n3 3\n3 6\n", "2 2\n1 4\n1 1\n"]} | 469 | 153 |
coding | Solve the programming task below in a Python markdown code block.
Little girl Alyona is in a shop to buy some copybooks for school. She study four subjects so she wants to have equal number of copybooks for each of the subjects. There are three types of copybook's packs in the shop: it is possible to buy one copybook f... | {"inputs": ["1 1 3 4\n", "6 2 1 1\n", "4 4 4 4\n", "7 4 3 1\n", "7 4 1 1\n", "3 9 1 1\n", "3 4 3 1\n", "3 3 1 1\n"], "outputs": ["3\n", "1\n", "0\n", "3\n", "2\n", "2\n", "3\n", "2\n"]} | 456 | 118 |
coding | Solve the programming task below in a Python markdown code block.
Your task is to Combine two Strings. But consider the rule...
By the way you don't have to check errors or incorrect input values, everything is ok without bad tricks, only two input strings and as result one output string;-)...
And here's the rule:
... | {"functional": "_inputs = [['abc', 'cde'], ['abcdeFgtrzw', 'defgGgfhjkwqe'], ['abcdeFg', 'defgG'], ['abab', 'bababa']]\n_outputs = [['abCCde'], ['abcDeFGtrzWDEFGgGFhjkWqE'], ['abcDEfgDEFGg'], ['ABABbababa']]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n retur... | 553 | 229 |
coding | Solve the programming task below in a Python markdown code block.
You are trying to cross a river by jumping along stones. Every time you land on a stone, you hop forwards by the value of that stone. If you skip *over* a stone then its value doesn't affect you in any way. Eg:
```
x--x-----x-->
[1][2][5][1]
```
Of c... | {"functional": "_inputs = [[[1]], [[2]], [[1, 1]], [[2, 1]], [[2, 1, 1]], [[1, 2, 1, 2]], [[1, 2, 5, 1]], [[2, 2, 3, 1, 1, 2, 1]]]\n_outputs = [[2], [2], [4], [3], [5], [5], [5], [7]]\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... | 318 | 246 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given an integer array nums, you need to find one continuous subarray such that if you only sort this subarray in non-decreasing order, then the whole array will be sorted in non-decreasing order.
Return the shortest ... | {"functional": "def check(candidate):\n assert candidate(nums = [2,6,4,8,10,9,15]) == 5\n assert candidate(nums = [1,2,3,4]) == 0\n assert candidate(nums = [1]) == 0\n\n\ncheck(Solution().findUnsortedSubarray)"} | 104 | 78 |
coding | Solve the programming task below in a Python markdown code block.
Problem H: Squid Multiplication
Squid Eiko loves mathematics. Especially she loves to think about integer. One day, Eiko found a math problem from a website.
"A sequence b ={ai + aj | i < j } is generated from a sequence a ={a0 , ... , an | ai is even ... | {"inputs": ["3\n6 10 14 15 27 35\n0\n1 7 7\n1", "3\n6 10 14 15 27 35\n0\n1 0 7\n1", "3\n6 10 14 15 27 35\n0\n0 0 7\n1", "3\n6 10 14 15 27 35\n0\n2 7 7\n1", "3\n6 10 14 15 27 35\n0\n30 3 8\n0", "3\n6 10 14 15 27 35\n0\n1 7 35\n1", "3\n6 10 14 15 27 35\n0\n3 4 35\n0", "3\n6 10 14 15 27 35\n0\n4 42 8\n0"], "outputs": ["2\... | 409 | 330 |
coding | Solve the programming task below in a Python markdown code block.
Amr lives in Lala Land. Lala Land is a very beautiful country that is located on a coordinate line. Lala Land is famous with its apple trees growing everywhere.
Lala Land has exactly n apple trees. Tree number i is located in a position x_{i} and has a_... | {"inputs": ["1\n1 1\n", "1\n1 1\n", "1\n0 0\n", "1\n1 0\n", "1\n2 1\n", "1\n-1 1\n", "1\n-1 1\n", "1\n-1 4\n"], "outputs": ["1", "1\n", "0\n", "0\n", "1\n", "1", "1\n", "4\n"]} | 580 | 103 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
n passengers board an airplane with exactly n seats. The first passenger has lost the ticket and picks a seat randomly. But after that, the rest of the passengers will:
Take their own seat if it is still available, a... | {"functional": "def check(candidate):\n assert candidate(n = 1) == 1.00000\n\n\ncheck(Solution().nthPersonGetsNthSeat)"} | 120 | 41 |
coding | Solve the programming task below in a Python markdown code block.
Bob is an active user of the social network Faithbug. On this network, people are able to engage in a mutual friendship. That is, if $a$ is a friend of $b$, then $b$ is also a friend of $a$. Each user thus has a non-negative amount of friends.
This morn... | {"inputs": ["1\n0\n", "1\n1\n", "1\n0\n", "1\n1\n", "2\n0 2\n", "2\n2 2\n", "2\n2 2\n", "2\n1 2\n"], "outputs": ["0 \n", "1 \n", "0 \n", "1 \n", "-1\n", "2 \n", "2 \n", "1 \n"]} | 622 | 101 |
coding | Solve the programming task below in a Python markdown code block.
Given a side length `n`, traveling only right and down how many ways are there to get from the top left corner to the bottom right corner of an `n by n` grid?
Your mission is to write a program to do just that!
Add code to `route(n)` that returns the n... | {"functional": "_inputs = [[156], [106], [108], [126], [165], [125], [103]]\n_outputs = [[376594020312425061595746241557406711201605603899894320577733841460621358204120168599683135056], [360262512886894560870925723424985925545493469115736766525399280], [5710703280600670271749409312650477833283445281465962347881848400],... | 198 | 724 |
coding | Solve the programming task below in a Python markdown code block.
Niwango-kun is an employee of Dwango Co., Ltd.
One day, he is asked to generate a thumbnail from a video a user submitted.
To generate a thumbnail, he needs to select a frame of the video according to the following procedure:
* Get an integer N and N in... | {"inputs": ["3\n0 2 3", "3\n0 0 3", "3\n0 0 1", "3\n1 1 3", "3\n1 0 3", "3\n0 0 2", "3\n0 1 3", "3\n0 2 5"], "outputs": ["1\n", "0\n", "0\n", "0\n", "0\n", "0\n", "1\n", "1\n"]} | 277 | 110 |
coding | Solve the programming task below in a Python markdown code block.
In this Kata, you will be given a list of strings and your task will be to find the strings that have the same characters and return the sum of their positions as follows:
```Haskell
solve(["abc","abbc", "ab", "xyz", "xy", "zzyx"]) = [1,8]
-- we see th... | {"functional": "_inputs = [[['abc', 'abbc', 'ab', 'xyz', 'xy', 'zzyx']], [['wkskkkkkk', 'fokoo', 'wkskk', 'uizzzz', 'fokooff', 'wkskkkk', 'uizzzzzzz']], [['xhuhhh', 'dghgg', 'dghgghh', 'mrerrrrrr', 'xhuhhhhhh', 'mrerrr']], [['uczcccccc', 'idffffiii', 'pnjjjjjjj', 'pnjjjj', 'idffff', 'uczcccc', 'uczcc']], [['rvjvvvv', '... | 342 | 464 |
coding | Solve the programming task below in a Python markdown code block.
```if-not:swift
Create a method that takes an array/list as an input, and outputs the index at which the sole odd number is located.
This method should work with arrays with negative numbers. If there are no odd numbers in the array, then the method sho... | {"functional": "_inputs = [[[2, 4, 6, 7, 10]], [[2, 16, 98, 10, 13, 78]], [[4, -8, 98, -12, -7, 90, 100]], [[2, 4, 6, 8]]]\n_outputs = [[3], [4], [4], [-1]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return math.isclose(a, b, rel_tol=tol, abs_tol=tol)\n ... | 253 | 238 |
coding | Solve the programming task below in a Python markdown code block.
Takahashi has N balls. Initially, an integer A_i is written on the i-th ball.
He would like to rewrite the integer on some balls so that there are at most K different integers written on the N balls.
Find the minimum number of balls that Takahashi need... | {"inputs": ["4 4\n0 1 2 2", "4 4\n0 1 2 4", "4 4\n1 1 4 2", "4 4\n0 2 2 4", "4 4\n1 0 4 2", "4 7\n0 2 2 4", "4 4\n1 2 2 2", "4 4\n0 1 3 2"], "outputs": ["0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n"]} | 237 | 142 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
An alphabetical continuous string is a string consisting of consecutive letters in the alphabet. In other words, it is any substring of the string "abcdefghijklmnopqrstuvwxyz".
For example, "abc" is an alphabetical c... | {"functional": "def check(candidate):\n assert candidate(s = \"abacaba\") == 2\n assert candidate(s = \"abcde\") == 5\n\n\ncheck(Solution().longestContinuousSubstring)"} | 120 | 48 |
coding | Solve the programming task below in a Python markdown code block.
$n$ players are playing a game.
There are two different maps in the game. For each player, we know his strength on each map. When two players fight on a specific map, the player with higher strength on that map always wins. No two players have the same ... | {"inputs": ["3\n4\n1 3 5 6\n1 2 3 4\n4\n17 11 20 21\n9 3 11 29\n1\n1000000000\n1000000000\n", "3\n4\n0 3 5 1\n1 2 3 4\n4\n1 12 20 21\n70 0 16 30\n1\n1000000000\n1000000000\n", "3\n4\n1 3 5 6\n1 2 3 4\n4\n1 12 20 21\n70 2 11 30\n1\n1000000000\n1000000000\n", "3\n4\n1 3 5 6\n1 2 3 4\n4\n1 12 20 21\n70 2 16 30\n1\n1000000... | 628 | 678 |
coding | Solve the programming task below in a Python markdown code block.
Consider the following operations on a triple of integers. In one operation, you should:
- Choose an integer $d$ and an arithmetic operation ― either addition or multiplication.
- Choose a subset of elements of the triple.
- Apply the arithmetic operatio... | {"inputs": ["2\n3 5 7\n6 5 10\n8 6 3\n9 7 8\n"], "outputs": ["1\n2"]} | 515 | 40 |
coding | Solve the programming task below in a Python markdown code block.
The Chef is sleeping now. He tries to cook new kind of meals in his dream.
These meals are arranged in a row and numbered from 1 to N consecutively. For each meal i (1≤i≤N) there
is given one integer f(i) which denotes the time needed to cook it. Init... | {"inputs": ["5 3\n40 30 40 30 40", "5 3\n40 30 40 30 40"], "outputs": ["3", "3"]} | 477 | 52 |
coding | Solve the programming task below in a Python markdown code block.
AquaMoon has a string $a$ consisting of only $0$ and $1$. She wants to add $+$ and $-$ between all pairs of consecutive positions to make the absolute value of the resulting expression as small as possible. Can you help her?
-----Input-----
The first ... | {"inputs": ["3\n2\n11\n5\n01101\n5\n10001\n"], "outputs": ["-\n+-++\n+++-\n"]} | 367 | 43 |
coding | Solve the programming task below in a Python markdown code block.
D: Sontaku (Surmise)
Some twins like even numbers.
Count how many even numbers are in $ N $ integers $ A_1, A_2, A_3, \ dots, A_N $.
input
The integer $ N $ is given on the first line.
On the second line, $ N $ integers $ A_1, A_2, A_3, \ dots, A_N ... | {"inputs": ["5\n4 3 5 2 8", "5\n4 3 1 2 9", "5\n4 3 1 2 8", "5\n4 6 1 2 9", "5\n4 3 5 2 9", "5\n5 3 5 2 8", "5\n3 3 1 2 8", "5\n4 6 1 1 9"], "outputs": ["3\n", "2\n", "3\n", "3\n", "2\n", "2\n", "2\n", "2\n"]} | 335 | 142 |
coding | Solve the programming task below in a Python markdown code block.
Little Chief loves math. Most of all, he loves equations. He can solve any equation in the whole world. Recently he found one interesting and easy equation
x1^{d}+x2^{d}+x3^{d} ≡ m (mod N)
Where x1, x2 and x3 are non negative integer numbers.
But, as ... | {"inputs": ["2\n2 2 3 5\n1 2013 3 31", "2\n2 2 3 5\n1 2013 3 31"], "outputs": ["4\n1\n", "4\n1"]} | 451 | 63 |
coding | Solve the programming task below in a Python markdown code block.
Chef loves arrays. But he really loves a specific kind of them - Rainbow Arrays.
The array is a Rainbow Array if it has such a structure:
- The first a1 elements equal to 1.
- The next a2 elements equal to 2.
- The next a3 elements equal to 3.
- Th... | {"inputs": ["12", "25", "17", "32", "16", "42", "22", "20"], "outputs": ["0\n", "924\n", "28\n", "5005\n", "7\n", "38760\n", "210\n", "84\n"]} | 488 | 83 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given an array of non-overlapping intervals intervals where intervals[i] = [starti, endi] represent the start and the end of the ith interval and intervals is sorted in ascending order by starti. You are also ... | {"functional": "def check(candidate):\n assert candidate(intervals = [[1,3],[6,9]], newInterval = [2,5]) == [[1,5],[6,9]]\n assert candidate(intervals = [[1,2],[3,5],[6,7],[8,10],[12,16]], newInterval = [4,8]) == [[1,2],[3,10],[12,16]]\n\n\ncheck(Solution().insert)"} | 185 | 110 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given an array of integers arr, a lucky integer is an integer that has a frequency in the array equal to its value.
Return the largest lucky integer in the array. If there is no lucky integer return -1.
Please compl... | {"functional": "def check(candidate):\n assert candidate(arr = [2,2,3,4]) == 2\n assert candidate(arr = [1,2,2,3,3,3]) == 3\n assert candidate(arr = [2,2,2,3,3]) == -1\n assert candidate(arr = [5]) == -1\n assert candidate(arr = [7,7,7,7,7,7,7]) == 7\n\n\ncheck(Solution().findLucky)"} | 93 | 116 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given a 0-indexed string s that has lowercase English letters in its even indices and digits in its odd indices.
You must perform an operation shift(c, x), where c is a character and x is a digit, that returns... | {"functional": "def check(candidate):\n assert candidate(s = \"a1c1e1\") == \"abcdef\"\n assert candidate(s = \"a1b2c3d4e\") == \"abbdcfdhe\"\n\n\ncheck(Solution().replaceDigits)"} | 212 | 61 |
coding | Solve the programming task below in a Python markdown code block.
There are $n$ beautiful skyscrapers in New York, the height of the $i$-th one is $h_i$. Today some villains have set on fire first $n - 1$ of them, and now the only safety building is $n$-th skyscraper.
Let's call a jump from $i$-th skyscraper to $j$-th... | {"inputs": ["2\n1 1\n", "2\n1 2\n", "2\n1 4\n", "2\n1 0\n", "2\n0 0\n", "2\n2 2\n", "2\n1 1\n", "4\n4 2 2 4\n"], "outputs": ["1", "1\n", "1\n", "1\n", "1\n", "1\n", "1", "1"]} | 513 | 103 |
coding | Solve the programming task below in a Python markdown code block.
There is Kannon-do in the mountain behind Ichiro's house. There are 30 steps from the foot to this Kannon-do, and Ichiro goes to Kannon-do almost every day. Ichiro can go up the stairs up to 3 steps with one foot. While playing, I noticed that there are ... | {"inputs": ["1\n2\n4\n0\n0", "1\n0\n14\n6\n0", "1\n2\n21\n0\n0", "1\n1\n16\n5\n0", "1\n1\n16\n0\n1", "1\n20\n7\n5\n0", "1\n26\n0\n9\n0", "1\n9\n1\n20\n0"], "outputs": ["1\n1\n1\n", "1\n", "1\n1\n62\n", "1\n1\n3\n1\n", "1\n1\n3\n", "1\n34\n1\n1\n", "1\n1288\n", "1\n1\n1\n34\n"]} | 346 | 171 |
coding | Solve the programming task below in a Python markdown code block.
A happy number is a number defined by the following process: starting with any positive integer, replace the number by the sum of the squares of its digits, and repeat the process until the number equals 1 (where it will stay), or it loops endlessly in a... | {"functional": "_inputs = [[1], [7], [16]]\n_outputs = [[True], [True], [False]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return math.isclose(a, b, rel_tol=tol, abs_tol=tol)\n if isinstance(a, (list, tuple)):\n if len(a) != len(b): return False... | 322 | 168 |
coding | Solve the programming task below in a Python markdown code block.
Akash has his maths test tomorrow. He secretly found out one of the questions from the test.
As the test is online, he wants to write a code that solves the question. However, he is not good at coding and thus, wants Chef to help him with that.
Chef is ... | {"inputs": ["2\n2\n5"], "outputs": ["1\n3"]} | 527 | 18 |
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.
Uttu broke his phone. He can get it repaired by spending X rupees or he can buy a new phone by spending Y rupees. Uttu wants to spend as little money as possible. Find out if it is better to get the phone repaired or to buy a new phone.
------ Input For... | {"inputs": ["3\n100 1000\n10000 5000\n3000 3000\n"], "outputs": ["REPAIR\nNEW PHONE\nANY\n"]} | 386 | 50 |
coding | Solve the programming task below in a Python markdown code block.
In this Kata, you will be given an array of numbers and a number `n`, and your task will be to determine if `any` array elements, when summed (or taken individually), are divisible by `n`.
For example:
* `solve([1,3,4,7,6],9) == true`, because `3 + ... | {"functional": "_inputs = [[[1, 2, 3, 4, 5], 8], [[7, 2, 8, 5], 16], [[1, 2, 3, 4, 5], 10], [[3, 1, 5, 7], 14], [[1, 2, 3, 4, 5], 15], [[8, 5, 3, 9], 7], [[8, 5, 3], 7]]\n_outputs = [[True], [False], [True], [False], [True], [True], [False]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or is... | 296 | 284 |
coding | Solve the programming task below in a Python markdown code block.
In the speed skating badge test, grades are awarded when the time specified for two distances is exceeded. For example, to reach Class A, 500 M requires less than 40.0 seconds and 1000 M requires less than 1 minute and 23 seconds.
Create a program that ... | {"inputs": ["40.0 70.0\n72.5 140.51", "40.0 70.15273874709118\n72.5 140.51", "40.0 70.15273874709118\n73.39358812211353 140.51", "40.0 70.26540141125885\n73.39358812211353 140.51", "40.991466890252646 70.26540141125885\n73.39358812211353 140.51", "40.991466890252646 70.71729331330802\n73.39358812211353 140.51", "40.991... | 473 | 471 |
coding | Solve the programming task below in a Python markdown code block.
The four bases found in DNA are adenine (A), cytosine (C), guanine (G) and thymine (T).
In genetics, GC-content is the percentage of Guanine (G) and Cytosine (C) bases on a DNA molecule that are either guanine or cytosine.
Given a DNA sequence (a stri... | {"functional": "_inputs = [[''], ['A'], ['C'], ['CA']]\n_outputs = [[0.0], [0.0], [100.0], [50.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)):\n if len(a) != le... | 218 | 182 |
coding | Solve the programming task below in a Python markdown code block.
You're playing a video game, in which you will get an achievement if you complete all of the levels consecutively without dying. You can play the levels in any order, and each time you play a level you'll either complete it or die. Each level has some pr... | {"inputs": ["1\n4\n1 1 1 1\n50 0 20 20", "3\n4\n1 1 1 1\n50 0 20 20\n3\n100 10 1\n0 50 0\n3\n100 80 50\n40 20 80"], "outputs": ["Case #1: 0 2 3 1", "Case #1: 0 2 3 1\nCase #2: 1 0 2\nCase #3: 2 0 1"]} | 509 | 143 |
coding | Solve the programming task below in a Python markdown code block.
The chef was busy in solving algebra, he found some interesting results, that there are many numbers which can be formed by sum of some numbers which are prime. Chef wrote those numbers in dairy. Cheffina came and saw what the chef was doing. Cheffina im... | {"inputs": ["2\n12 2\n11 2"], "outputs": ["1\n0"]} | 258 | 24 |
coding | Solve the programming task below in a Python markdown code block.
In a far away country called AlgoLandia, there are `N` islands numbered `1` to `N`. Each island is denoted by `k[i]`. King Algolas, king of AlgoLandia, built `N - 1` bridges in the country. A bridge is built between islands `k[i]` and `k[i+1]`. Bridges a... | {"functional": "_inputs = [[[True, True, False, True, False]], [[False, False, True, False, False]], [[False, False, False, False, False]], [[False, False, False, False, False, False]], [[False, False]], [[True, False]], [[False, False, False, True, False, False, False, True]], [[False, False, True, False, True, True, ... | 364 | 1,178 |
coding | Solve the programming task below in a Python markdown code block.
You are given an integer number $n$. The following algorithm is applied to it:
if $n = 0$, then end algorithm; find the smallest prime divisor $d$ of $n$; subtract $d$ from $n$ and go to step $1$.
Determine the number of subtrations the algorithm ... | {"inputs": ["5\n", "4\n", "2\n", "2\n", "6\n", "7\n", "8\n", "4\n"], "outputs": ["1\n", "2\n", "1\n", "1\n", "3\n", "1\n", "4\n", "2\n"]} | 198 | 70 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
A magic index in an array A[0...n-1] is defined to be an index such that A[i] = i. Given a sorted array of integers, write a method to find a magic index, if one exists, in array A. If not, return -1. If there are mor... | {"functional": "def check(candidate):\n assert candidate(nums = [0, 2, 3, 4, 5]) == 0\n assert candidate(nums = [1, 1, 1]) == 1\n\n\ncheck(Solution().findMagicIndex)"} | 123 | 62 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given an array of integers citations where citations[i] is the number of citations a researcher received for their ith paper and citations is sorted in ascending order, return the researcher's h-index.
According to th... | {"functional": "def check(candidate):\n assert candidate(citations = [0,1,3,5,6]) == 3\n assert candidate(citations = [1,2,100]) == 2\n\n\ncheck(Solution().hIndex)"} | 139 | 59 |
coding | Solve the programming task below in a Python markdown code block.
> If you've finished this kata, you can try the [more difficult version](https://www.codewars.com/kata/5b256145a454c8a6990000b5).
## Taking a walk
A promenade is a way of uniquely representing a fraction by a succession of “left or right” choices.
Fo... | {"functional": "_inputs = [[''], ['L'], ['R'], ['LRLL'], ['LLRLR'], ['RRRLRRR'], ['LLLLRLLLL'], ['LLLLLLLLLL'], ['RLRLRLRRLRLL'], ['LLRRLRRLRLLL'], ['LRRLLRLLRLRR'], ['LRRLRLLLLRLL'], ['LLLRRRLLLRLL'], ['RRLRRRLLRLRR'], ['RRRRLLRLLRLR'], ['LLRLRLLRLLRL'], ['LRLLRRRRLLRR'], ['RLRRLRRRRRRR']]\n_outputs = [[[1, 1]], [[1, ... | 641 | 414 |
coding | Solve the programming task below in a Python markdown code block.
Burenka came to kindergarden. This kindergarten is quite strange, so each kid there receives two fractions ($\frac{a}{b}$ and $\frac{c}{d}$) with integer numerators and denominators. Then children are commanded to play with their fractions.
Burenka is a... | {"inputs": ["1\n1 2 3 4\n", "1\n2 1 4 3\n", "1\n1 2 3 1\n", "1\n5 8 1 2\n", "1\n3 1 5 1\n", "1\n2 3 3 5\n", "1\n5 3 4 3\n", "1\n3 5 1 7\n"], "outputs": ["2\n", "2\n", "1\n", "2\n", "2\n", "2\n", "2\n", "2\n"]} | 522 | 134 |
coding | Solve the programming task below in a Python markdown code block.
Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Chef is attending math classes. On each day, the teacher gives him homework. Yesterday, the teacher gave Chef a sequence of positive integers and ask... | {"inputs": ["3\n2\n2 8\n3 \n8 2 8\n3\n9 10 11"], "outputs": ["7\n10\n18"]} | 600 | 43 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given an integer array digits, where each element is a digit. The array may contain duplicates.
You need to find all the unique integers that follow the given requirements:
The integer consists of the concate... | {"functional": "def check(candidate):\n assert candidate(digits = [2,1,3,0]) == [102,120,130,132,210,230,302,310,312,320]\n assert candidate(digits = [2,2,8,8,2]) == [222,228,282,288,822,828,882]\n assert candidate(digits = [3,7,5]) == []\n\n\ncheck(Solution().findEvenNumbers)"} | 155 | 140 |
coding | Solve the programming task below in a Python markdown code block.
After Fox Ciel won an onsite round of a programming contest, she took a bus to return to her castle. The fee of the bus was 220 yen. She met Rabbit Hanako in the bus. They decided to play the following game because they got bored in the bus.
* Initial... | {"inputs": ["3 0\n", "7 2\n", "5 5\n", "3 5\n", "8 2\n", "4 1\n", "8 1\n", "0 0\n"], "outputs": ["Hanako", "Ciel", "Hanako", "Ciel", "Ciel", "Hanako", "Hanako", "Hanako"]} | 418 | 86 |
coding | Solve the programming task below in a Python markdown code block.
Roma is playing a new expansion for his favorite game World of Darkraft. He made a new character and is going for his first grind.
Roma has a choice to buy exactly one of n different weapons and exactly one of m different armor sets. Weapon i has attack... | {"inputs": ["1 2 1\n2 2\n2 1\n2 2\n1 1 1\n", "1 1 1\n1 100\n1 100\n2 2 1\n", "1 2 1\n2 2\n2 1\n2 3\n1 1 1\n", "1 1 1\n1 100\n1 100\n2 4 1\n", "1 2 1\n2 2\n1 1\n2 3\n1 1 1\n", "1 2 1\n2 2\n2 1\n1 3\n1 1 1\n", "1 1 1\n1 100\n1 100\n2 0 1\n", "1 2 1\n2 2\n2 1\n1 2\n1 1 1\n"], "outputs": ["-2\n", "-200\n", "-2", "-200", "-... | 631 | 247 |
coding | Solve the programming task below in a Python markdown code block.
There are 3 problems in a contest namely A, B, C respectively. Alice bets Bob that problem C is the hardest while Bob says that problem B will be the hardest.
You are given three integers S_{A}, S_{B}, S_{C} which denotes the number of successful submi... | {"inputs": ["3\n1 4 2\n16 8 10\n14 15 9\n"], "outputs": ["Draw\nBob\nAlice\n"]} | 463 | 40 |
coding | Solve the programming task below in a Python markdown code block.
Eugene must do his homework, but he is struggling.
He has three integer numbers: A, N, M. He writes number A on the board N times in a row. Let's call the resulting big number X.
Help Eugene find X modulo M.
Input Format
First line contains T, the n... | {"inputs": ["2 \n12 2 17 \n523 3 11 \n"], "outputs": ["5\n6\n"]} | 278 | 39 |
coding | Solve the programming task below in a Python markdown code block.
You are given two integers $x$ and $y$ (it is guaranteed that $x > y$). You may choose any prime integer $p$ and subtract it any number of times from $x$. Is it possible to make $x$ equal to $y$?
Recall that a prime number is a positive integer that has... | {"inputs": ["1\n51 50\n", "1\n52 51\n", "1\n54 53\n", "1\n90 80\n", "1\n90 80\n", "1\n51 50\n", "1\n54 53\n", "1\n52 51\n"], "outputs": ["NO\n", "NO\n", "NO\n", "YES\n", "YES\n", "NO\n", "NO\n", "NO\n"]} | 461 | 118 |
coding | Solve the programming task below in a Python markdown code block.
Evlampiy has found one more cool application to process photos. However the application has certain limitations.
Each photo i has a contrast v_{i}. In order for the processing to be truly of high quality, the application must receive at least k photos w... | {"inputs": ["1 1\n4\n", "1 1\n4\n", "2 2\n7 5\n", "2 2\n7 5\n", "2 2\n6 5\n", "2 2\n12 5\n", "4 1\n2 3 4 1\n", "3 2\n34 3 75\n"], "outputs": ["0\n", "0", "2\n", "2", "1\n", "7\n", "0\n", "72\n"]} | 500 | 122 |
coding | Solve the programming task below in a Python markdown code block.
There is a string, $unrecognized$, of lowercase English letters that is repeated infinitely many times. Given an integer, $unrecognized$, find and print the number of letter a's in the first $unrecognized$ letters of the infinite string.
Example
$unr... | {"inputs": ["aba\n10\n", "a\n1000000000000\n"], "outputs": ["7\n", "1000000000000\n"]} | 342 | 51 |
coding | Solve the programming task below in a Python markdown code block.
You are given an array of $n$ integers $a_1, a_2, \ldots, a_n$. The integers are either $1$ or $-1$. You have to perform the following operation exactly once on the array $a$:
Choose an index $i$ ($1 \leq i < n$) and flip the signs of $a_i$ and $a_{i+1}... | {"inputs": ["4\n5\n-1 1 1 -1 -1\n5\n1 1 -1 -1 -1\n2\n1 1\n4\n1 -1 -1 1\n"], "outputs": ["3\n3\n-2\n4\n"]} | 460 | 62 |
coding | Solve the programming task below in a Python markdown code block.
Petya has noticed that when he types using a keyboard, he often presses extra buttons and adds extra letters to the words. Of course, the spell-checking system underlines the words for him and he has to click every word and choose the right variant. Pety... | {"inputs": ["ki\nb\n", "ab\na\n", "bb\nb\n", "ab\nb\n", "ik\nb\n", "ac\nb\n", "il\nb\n", "ac\nc\n"], "outputs": ["0\n", "1\n2 ", "2\n1 2 ", "1\n1\n", "0\n", "0\n", "0\n", "1\n1\n"]} | 365 | 94 |
coding | Solve the programming task below in a Python markdown code block.
Chef, being a Chess fan, was thrilled after he read the following news:
[Michael Simkin, a postdoctoral fellow at Harvard University’s Center of Mathematical Sciences and Applications proved that for a large value of N, there are approximately (0.143 \c... | {"inputs": ["2\n4\n10"], "outputs": ["0\n36\n"]} | 469 | 21 |
coding | Solve the programming task below in a Python markdown code block.
Read problem statements in [Mandarin], [Bengali], and [Russian] as well.
You are given a positive integer N. Consider a square grid of size N \times N, with rows numbered 1 to N from top to bottom and columns numbered 1 to N from left to right. Initial... | {"inputs": ["2\n3\n1 2\n2 3\n3 1\n2\n1 2\n2 1"], "outputs": ["YES\nNO"]} | 634 | 38 |
coding | Solve the programming task below in a Python markdown code block.
An array is beautiful if both of the following two conditions meet:
there are at least $l_1$ and at most $r_1$ elements in the array equal to its minimum;
there are at least $l_2$ and at most $r_2$ elements in the array equal to its maximum.
For examp... | {"inputs": ["1\n40 40 40 40\n", "1\n14 17 15 50\n", "7\n3 5 4 6\n5 8 5 5\n3 3 10 12\n1 5 3 3\n1 1 2 2\n2 2 1 1\n6 6 6 6\n"], "outputs": ["40\n", "15\n", "4\n5\n13\n3\n3\n3\n6\n"]} | 649 | 127 |
coding | Solve the programming task below in a Python markdown code block.
It seems like the year of 2013 came only yesterday. Do you know a curious fact? The year of 2013 is the first year after the old 1987 with only distinct digits.
Now you are suggested to solve the following problem: given a year number, find the minimum ... | {"inputs": ["1987\n", "2013\n", "1000\n", "1001\n", "1234\n", "5555\n", "9000\n", "1111\n"], "outputs": ["2013\n", "2014\n", "1023\n", "1023\n", "1235\n", "5601\n", "9012\n", "1203\n"]} | 186 | 118 |
coding | Solve the programming task below in a Python markdown code block.
Who's interested in football?
Rayne Wooney has been one of the top players for his football club for the last few years. But unfortunately, he got injured during a game a few months back and has been out of play ever since.
He's got proper treatment and ... | {"inputs": ["3\n6\n3 7 1 4 2 4\n5\n5 4 3 2 1\n5\n4 3 2 2 3", "3\n6\n3 7 1 4 2 4\n5\n5 4 3 2 1\n5\n4 3 1 2 3", "3\n6\n3 1 1 4 2 4\n5\n5 4 3 2 1\n5\n4 3 1 2 3", "3\n6\n3 1 1 4 2 4\n5\n2 4 3 2 1\n5\n4 3 1 2 3", "3\n6\n1 1 0 4 2 4\n5\n4 4 3 2 1\n5\n4 0 1 2 3", "3\n6\n1 1 0 4 2 4\n5\n4 7 3 2 2\n5\n4 0 1 2 3", "3\n6\n1 1 1 4... | 653 | 402 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.