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.
Petya loves lucky numbers. Everybody knows that positive integers are lucky if their decimal representation doesn't contain digits other than 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Lucky number is super lucky if it's ... | {"inputs": ["1\n", "4\n", "7\n", "9\n", "3\n", "6\n", "2\n", "5\n"], "outputs": ["47\n", "47\n", "47\n", "47\n", "47\n", "47\n", "47\n", "47\n"]} | 277 | 78 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given an infinite number of quarters (25 cents), dimes (10 cents), nickels (5 cents), and pennies (1 cent), write code to calculate the number of ways of representing n cents. (The result may be large, so you should r... | {"functional": "def check(candidate):\n assert candidate(n = 5) == 2\n assert candidate(n = 10) == 4\n\n\ncheck(Solution().waysToChange)"} | 116 | 45 |
coding | Solve the programming task below in a Python markdown code block.
On each of the following $N$ days (numbered $1$ through $N$), Chef is planning to cook either pizza or broccoli. He wrote down a string $A$ with length $N$, where for each valid $i$, if the character $A_i$ is '1', then he will cook pizza on the $i$-th da... | {"inputs": ["2\n13 2\n0101110000101\n6 3\n100001"], "outputs": ["5\n4"]} | 552 | 44 |
coding | Solve the programming task below in a Python markdown code block.
Doubleville, a small town in Texas, was attacked by the aliens. They have abducted some of the residents and taken them to the a spaceship orbiting around earth. After some (quite unpleasant) human experiments, the aliens cloned the victims, and released... | {"inputs": ["9 6\nAAAAAA\nACACAC\nGTTTTG\nACACAC\nGTTTTG\nACACAC\nACACAC\nTCCCCC\nTCCCCC\n0 0\n\n"], "outputs": ["1\n2\n0\n1\n0\n0\n0\n0\n0"]} | 515 | 73 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given an integer array nums and an integer k, modify the array in the following way:
choose an index i and replace nums[i] with -nums[i].
You should apply this process exactly k times. You may choose the same index ... | {"functional": "def check(candidate):\n assert candidate(nums = [4,2,3], k = 1) == 5\n assert candidate(nums = [3,-1,0,2], k = 3) == 6\n assert candidate(nums = [2,-3,-1,5,-4], k = 2) == 13\n\n\ncheck(Solution().largestSumAfterKNegations)"} | 122 | 94 |
coding | Solve the programming task below in a Python markdown code block.
Problem
Neat lives on the world line for a total of 360 days until the 30th of every month for 1 year and 12 months. In that world, N consecutive holidays with the same schedule were applied to people all over the world every year. Consecutive holidays ... | {"inputs": ["1\n1 1 1 1", "1\n1 2 1 1", "1\n1 1 359 1", "2\n4 3 5 0\n1 1 5 294", "2\n4 3 5 0\n1 1 5 262", "2\n3 4 5 7\n2 2 5 253", "2\n4 5 5 0\n4 7 1 457", "2\n4 3 5 0\n1 2 1 294"], "outputs": ["0\n", "0\n", "0", "116\n", "84\n", "75\n", "277\n", "114\n"]} | 596 | 185 |
coding | Solve the programming task below in a Python markdown code block.
Edogawa Conan got tired of solving cases, and invited his friend, Professor Agasa, over. They decided to play a game of cards. Conan has n cards, and the i-th card has a number a_{i} written on it.
They take turns playing, starting with Conan. In each t... | {"inputs": ["1\n1\n", "1\n2\n", "1\n2\n", "1\n1\n", "1\n4\n", "1\n16\n", "2\n1 1\n", "1\n485\n"], "outputs": ["Conan\n", "Conan\n", "Conan", "Conan", "Conan\n", "Conan\n", "Agasa\n", "Conan\n"]} | 399 | 97 |
coding | Solve the programming task below in a Python markdown code block.
Write a program which manipulates a disjoint set S = {S1, S2, . . . , Sk}.
First of all, the program should read an integer n, then make a disjoint set where each element consists of 0, 1, ... n−1 respectively.
Next, the program should read an integer ... | {"inputs": ["5 5\n0 1 4\n0 2 3\n1 0 1\n1 3 4\n1 0 4\n1 2 2\n1 1 3\n1 1 4\n1 3 0\n0 0 4\n1 0 2\n1 3 0", "5 8\n0 1 4\n0 2 1\n1 1 2\n1 3 4\n1 1 4\n1 3 0\n0 1 3\n1 2 4\n1 3 0\n1 0 4\n1 0 2\n1 3 0", "5 12\n0 2 4\n0 2 3\n1 1 2\n1 3 4\n1 1 4\n1 3 2\n0 1 3\n1 2 4\n1 3 0\n0 0 4\n1 0 2\n1 3 0", "5 12\n0 1 4\n0 2 3\n1 1 2\n1 3 4\... | 367 | 760 |
coding | Solve the programming task below in a Python markdown code block.
It is known that there are k fish species in the polar ocean, numbered from 1 to k. They are sorted by non-decreasing order of their weight, which is a positive number. Let the weight of the i-th type of fish be w_{i}, then 0 < w_1 ≤ w_2 ≤ ... ≤ w_{k} ho... | {"inputs": ["1 1 1\n1\n1\n", "1 1 1\n1\n1\n", "3 3 3\n2 2 2\n1 1 3\n", "3 3 3\n2 2 2\n0 1 3\n", "3 3 3\n0 2 2\n0 1 3\n", "3 3 3\n2 2 2\n1 1 3\n", "5 4 5\n1 2 2 3 4\n1 3 4 5\n", "5 4 5\n1 2 2 3 4\n1 3 4 5\n"], "outputs": ["NO\n", "NO\n", "YES\n", "YES\n", "YES\n", "YES\n", "YES\n", "YES\n"]} | 498 | 194 |
coding | Solve the programming task below in a Python markdown code block.
Read problem statements in [Mandarin], [Bengali], [Russian], and [Vietnamese] as well.
Ujan is a software developer. He is developing a software that takes two integers L and R and outputs the count of integers in the sequence L,L+1,\ldots,R-1,R whose s... | {"inputs": ["5\n139 141\n100 1235\n1000 2537\n998244353 1000000007\n27182818284 31415926535897"], "outputs": ["1\n378\n512\n585218\n10462914572538"]} | 485 | 117 |
coding | Solve the programming task below in a Python markdown code block.
Janmansh and Jay are playing a game. They start with a number X and they play a total of Y moves. Janmansh plays the first move of the game, after which both the players make moves alternatingly.
In one move, a player can increment or decrement X by 1.... | {"inputs": ["2\n2 2\n4 3\n"], "outputs": ["Janmansh\nJay\n"]} | 433 | 26 |
coding | Solve the programming task below in a Python markdown code block.
# Definition (Primorial Of a Number)
*Is similar to factorial of a number*, **_In primorial_**, not all the natural numbers get multiplied, **_only prime numbers are multiplied to calculate the primorial of a number_**. It's denoted with **_P_****_#_** ... | {"functional": "_inputs = [[3], [4], [5], [8], [9]]\n_outputs = [[30], [210], [2310], [9699690], [223092870]]\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 l... | 585 | 199 |
coding | Solve the programming task below in a Python markdown code block.
We have an integer sequence of length N: A_0,A_1,\cdots,A_{N-1}.
Find the following sum (\mathrm{lcm}(a, b) denotes the least common multiple of a and b):
* \sum_{i=0}^{N-2} \sum_{j=i+1}^{N-1} \mathrm{lcm}(A_i,A_j)
Since the answer may be enormous, ... | {"inputs": ["3\n1 4 6", "3\n2 3 6", "3\n2 1 6", "3\n2 4 6", "3\n0 1 10", "8\n1 4 3 4 6 8 12 12", "8\n1 8 3 4 6 8 12 12", "8\n1 8 3 4 6 7 12 12"], "outputs": ["22\n", "18\n", "14\n", "22", "10\n", "327\n", "383\n", "585\n"]} | 347 | 157 |
coding | Solve the programming task below in a Python markdown code block.
MoEngage has a bundle of N sticks. The i^{th} stick has a length L_{i} meters.
Find the minimum number of sticks (of any length) you need to add to the bundle such that you can construct some [rectangles] where each stick of the bundle belongs to exact... | {"inputs": ["4\n1\n1\n2\n2 5\n4\n2 2 3 3\n7\n1 3 5 7 1 7 5\n"], "outputs": ["3\n2\n0\n1\n"]} | 473 | 56 |
coding | Solve the programming task below in a Python markdown code block.
You are given a permutation $a$ consisting of $n$ numbers $1$, $2$, ..., $n$ (a permutation is an array in which each element from $1$ to $n$ occurs exactly once).
You can perform the following operation: choose some subarray (contiguous subsegment) of ... | {"inputs": ["1\n8\n6 2 3 1 8 4 5 7\n", "1\n8\n6 2 3 1 8 4 5 7\n", "1\n8\n6 0 3 1 8 4 5 7\n", "1\n8\n5 2 2 1 0 0 2 8\n", "1\n6\n6 0 3 1 8 4 5 7\n", "1\n8\n6 2 6 1 8 4 5 7\n", "1\n8\n6 0 3 1 8 6 5 7\n", "1\n6\n6 0 3 1 8 5 5 7\n"], "outputs": ["2\n", "2\n", "2\n", "1\n", "2\n", "2\n", "2\n", "2\n"]} | 606 | 214 |
coding | Solve the programming task below in a Python markdown code block.
Leha decided to move to a quiet town Vičkopolis, because he was tired by living in Bankopolis. Upon arrival he immediately began to expand his network of hacked computers. During the week Leha managed to get access to n computers throughout the town. Inc... | {"inputs": ["1\n2\n", "1\n2\n", "1\n0\n", "1\n1\n", "1\n-1\n", "1\n-2\n", "1\n-3\n", "1\n-4\n"], "outputs": ["0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n"]} | 702 | 90 |
coding | Solve the programming task below in a Python markdown code block.
B: Hokkaido University Hard
Note
Please note that the question settings are the same as question A, except for the constraints.
story
Homura-chan, who passed Hokkaido University and is excited about the beginning of a new life. But in front of her, a... | {"inputs": ["3 3\nB.B\nB..\n.BB", "2 3\nB.B\nB..\n.BB", "1 3\nB-B\n..B\n.BA", "1 1\nB-B\n..B\n.BA", "1 3\nBB.\nB..\n.AA", "3 3\nB.B\nB..\nBB.", "3 3\nB.B\nC..\nBB.", "3 3\nB/B\nC..\nBB."], "outputs": ["4\n", "3\n", "2\n", "0\n", "1\n", "4\n", "4\n", "4\n"]} | 555 | 148 |
coding | Solve the programming task below in a Python markdown code block.
Chef loves to play with iron (Fe) and magnets (Ma). He took a row of $N$ cells (numbered $1$ through $N$) and placed some objects in some of these cells. You are given a string $S$ with length $N$ describing them; for each valid $i$, the $i$-th character... | {"inputs": ["2\n4 5\nI::M\n9 10\nMIM_XII:M"], "outputs": ["1\n2"]} | 757 | 33 |
coding | Solve the programming task below in a Python markdown code block.
Its Christmas time and Santa has started his ride to deliver gifts to children waiting for him in a 1-dimentional city. All houses in this city are on a number line numbered as 1, 2, 3… and so on. Santa wants to deliver to houses from n to m, but he foun... | {"inputs": ["1\n2 20 2 1"], "outputs": ["5"]} | 428 | 21 |
coding | Solve the programming task below in a Python markdown code block.
As behooves any intelligent schoolboy, Kevin Sun is studying psycowlogy, cowculus, and cryptcowgraphy at the Bovinia State University (BGU) under Farmer Ivan. During his Mathematics of Olympiads (MoO) class, Kevin was confronted with a weird functional e... | {"inputs": ["3 2\n", "5 4\n", "7 2\n", "7 6\n", "5 0\n", "5 3\n", "7 1\n", "5 2\n"], "outputs": ["3\n", "25\n", "49\n", "343\n", "625\n", "5\n", "823543\n", "5\n"]} | 450 | 97 |
coding | Solve the programming task below in a Python markdown code block.
An array $b$ of $m$ positive integers is good if for all pairs $i$ and $j$ ($1 \leq i,j \leq m$), $\max(b_i,b_j)$ is divisible by $\min(b_i,b_j)$.
You are given an array $a$ of $n$ positive integers. You can perform the following operation:
Select an i... | {"inputs": ["4\n4\n2 3 5 5\n2\n4 8\n5\n3 4 343 5 6\n3\n31 5 17\n"], "outputs": ["4\n1 2\n2 1\n3 3\n4 3\n2\n1 4\n2 8\n5\n1 1\n2 4\n3 169\n4 3\n5 2\n3\n1 1\n2 3\n3 15\n"]} | 697 | 119 |
coding | Solve the programming task below in a Python markdown code block.
We have N cards numbered 1, 2, ..., N. Card i (1 \leq i \leq N) has an integer A_i written in red ink on one side and an integer B_i written in blue ink on the other side. Initially, these cards are arranged from left to right in the order from Card 1 to... | {"inputs": ["2\n2 0\n1 2", "2\n2 1\n1 1", "2\n0 1\n1 1", "2\n0 1\n2 1", "2\n0 1\n0 1", "2\n1 1\n0 1", "2\n1 2\n0 1", "2\n1 2\n0 2"], "outputs": ["-1", "1", "0", "0", "0", "0", "0", "0"]} | 489 | 119 |
coding | Solve the programming task below in a Python markdown code block.
We have a tree with N vertices, whose i-th edge connects Vertex u_i and Vertex v_i.
Vertex i has an integer a_i written on it.
For every integer k from 1 through N, solve the following problem:
- We will make a sequence by lining up the integers written... | {"inputs": ["10\n1 2 5 3 4 6 7 6 2 4\n1 2\n2 3\n3 4\n4 5\n3 6\n6 7\n1 8\n8 9\n9 10", "10\n1 2 5 2 7 6 7 3 0 4\n1 2\n2 3\n3 4\n4 5\n2 6\n6 7\n1 8\n8 9\n9 10", "10\n0 2 5 2 7 6 7 3 0 4\n1 3\n2 3\n3 4\n4 5\n2 6\n6 7\n1 8\n8 9\n9 10", "10\n0 2 5 2 7 1 7 3 0 4\n1 3\n2 3\n3 4\n4 5\n2 6\n6 7\n1 8\n8 9\n9 10", "10\n1 2 5 3 4 6... | 517 | 670 |
coding | Solve the programming task below in a Python markdown code block.
The chef is very expert in coding, so to keep his password safe from the hackers. He always enters a decoded code of his password. You are a hacker and your work is to find the maximum number of possible ways to unlock his password in encoded form.
The ... | {"inputs": ["2\n12\n223"], "outputs": ["YES\nNO"]} | 296 | 21 |
coding | Solve the programming task below in a Python markdown code block.
Chef and Chefina are playing a game. There are two piles numbered 1 and 2.
Pile 1 contains X stones while Pile 2 contains Y stones.
Chef starts the game.
In his turn, Chef can either remove 1 stone each from both the piles or remove 2 stones from pile... | {"inputs": ["3\n1 10\n2 2\n4 2\n"], "outputs": ["CHEFINA\nCHEFINA\nCHEF\n"]} | 529 | 36 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Alice and Bob take turns playing a game, with Alice starting first.
There are n stones in a pile. On each player's turn, they can remove a stone from the pile and receive points based on the stone's value. Alice and B... | {"functional": "def check(candidate):\n assert candidate(aliceValues = [1,3], bobValues = [2,1]) == 1\n assert candidate(aliceValues = [1,2], bobValues = [3,1]) == 0\n assert candidate(aliceValues = [2,4,3], bobValues = [1,6,7]) == -1\n\n\ncheck(Solution().stoneGameVI)"} | 237 | 96 |
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 the leftmost value in the last row of the tree.
Please complete the following python code precisely:
```python
# Definition for a binary tree node.
# class TreeNode:
# def... | {"functional": "def check(candidate):\n assert candidate(root = tree_node([2,1,3])) == 1\n assert candidate(root = tree_node([1,2,3,4,None,5,6,None,None,7])) == 7\n\n\ncheck(Solution().findBottomLeftValue)"} | 123 | 68 |
coding | Solve the programming task below in a Python markdown code block.
Ivan has got an array of n non-negative integers a_1, a_2, ..., a_{n}. Ivan knows that the array is sorted in the non-decreasing order.
Ivan wrote out integers 2^{a}_1, 2^{a}_2, ..., 2^{a}_{n} on a piece of paper. Now he wonders, what minimum number of... | {"inputs": ["1\n3\n", "1\n0\n", "1\n1\n", "1\n0\n", "1\n1\n", "1\n2\n", "1\n4\n", "1\n8\n"], "outputs": ["3\n", "0\n", "1\n", "0\n", "1\n", "2\n", "4\n", "8\n"]} | 334 | 86 |
coding | Solve the programming task below in a Python markdown code block.
For given three integers $a, b, c$, print the minimum value and the maximum value.
Constraints
* $-1,000,000,000 \leq a, b, c \leq 1,000,000,000$
Input
The input is given in the following format.
$a \; b \; c\;$
Three integers $a, b, c$ are given... | {"inputs": ["6 5 3", "6 5 1", "6 5 0", "6 8 0", "9 2 0", "2 1 0", "0 1 0", "0 7 0"], "outputs": ["3 6\n", "1 6\n", "0 6\n", "0 8\n", "0 9\n", "0 2\n", "0 1\n", "0 7\n"]} | 144 | 110 |
coding | Solve the programming task below in a Python markdown code block.
There are N stones, numbered 1, 2, \ldots, N. For each i (1 \leq i \leq N), the height of Stone i is h_i.
There is a frog who is initially on Stone 1. He will repeat the following action some number of times to reach Stone N:
* If the frog is currently... | {"inputs": ["3 1\n4 8 1", "2 100\n10 9", "2 100\n7 10", "2 100\n17 9", "2 101\n3 21", "3 1\n0 20 10", "3 1\n9 20 10", "3 1\n1 20 10"], "outputs": ["11\n", "1\n", "3\n", "8\n", "18\n", "30\n", "21\n", "29\n"]} | 358 | 141 |
coding | Solve the programming task below in a Python markdown code block.
You have a large rectangular board which is divided into $n \times m$ cells (the board has $n$ rows and $m$ columns). Each cell is either white or black.
You paint each white cell either red or blue. Obviously, the number of different ways to paint them... | {"inputs": ["1 4\noooo\n", "1 4\noooo\n", "2 2\noo\no*\n", "1 2\noo\no*\n", "2 2\noo\n*o\n", "1 2\noo\n*o\n", "1 2\noo\no)\n", "1 2\noo\n)o\n"], "outputs": ["9\n", "\n9\n", "4\n", "1\n", "4\n", "1\n", "1\n", "1\n"]} | 494 | 120 |
coding | Solve the programming task below in a Python markdown code block.
There are literally dozens of snooker competitions held each year, and team Jinotega tries to attend them all (for some reason they prefer name "snookah")! When a competition takes place somewhere far from their hometown, Ivan, Artsem and Konstantin take... | {"inputs": ["1\nESJ\nESJ->TSJ\n", "1\nAAK\nAAK->ABA\n", "1\nXYZ\nXYZ->XYR\n", "1\nESJ\nESJ->TSJ\n", "1\nAAK\nAAK->ABA\n", "1\nXYZ\nXYZ->XYR\n", "1\nAAK\nAAK.>ABA\n", "2\nXMR\nFAJ->XMR\nXMR->FAJ\n"], "outputs": ["contest\n", "contest\n", "contest\n", "contest\n", "contest\n", "contest\n", "contest", "home\n"]} | 521 | 141 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given the root of a binary tree that consists of exactly 3 nodes: the root, its left child, and its right child.
Return true if the value of the root is equal to the sum of the values of its two children, or f... | {"functional": "def check(candidate):\n assert candidate(root = tree_node([10,4,6])) == True\n assert candidate(root = tree_node([5,3,1])) == False\n\n\ncheck(Solution().checkTree)"} | 154 | 54 |
coding | Solve the programming task below in a Python markdown code block.
Colonel has n badges. He wants to give one badge to every of his n soldiers. Each badge has a coolness factor, which shows how much it's owner reached. Coolness factor can be increased by one for the cost of one coin.
For every pair of soldiers one of ... | {"inputs": ["1\n1\n", "1\n1\n", "3\n1 3 3\n", "3\n1 1 1\n", "3\n3 3 3\n", "3\n1 3 3\n", "3\n3 3 3\n", "3\n1 1 1\n"], "outputs": ["0", "0\n", "1", "3", "3", "1\n", "3\n", "3\n"]} | 303 | 106 |
coding | Solve the programming task below in a Python markdown code block.
Another programming contest is over. You got hold of the contest's final results table. The table has the following data. For each team we are shown two numbers: the number of problems and the total penalty time. However, for no team we are shown its fin... | {"inputs": ["1 1\n28 2\n", "1 1\n28 4\n", "1 1\n28 28\n", "2 2\n1 2\n1 2\n", "2 2\n1 2\n1 1\n", "2 1\n50 50\n50 49\n", "2 2\n50 50\n50 50\n", "2 1\n50 50\n50 50\n"], "outputs": ["1\n", "1\n", "1\n", "2\n", "1\n", "1\n", "2\n", "2\n"]} | 706 | 154 |
coding | Solve the programming task below in a Python markdown code block.
Famil Door wants to celebrate his birthday with his friends from Far Far Away. He has n friends and each of them can come to the party in a specific range of days of the year from a_{i} to b_{i}. Of course, Famil Door wants to have as many friends celebr... | {"inputs": ["1\nF 1 2\n", "1\nF 1 2\n", "1\nF 1 1\n", "1\nF 1 3\n", "1\nF 1 4\n", "1\nF 2 4\n", "1\nF 4 4\n", "1\nF 68 307\n"], "outputs": ["0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n"]} | 508 | 121 |
coding | Solve the programming task below in a Python markdown code block.
[Run-length encoding](http://en.wikipedia.org/wiki/Run-length_encoding) (RLE) is a very simple form of lossless data compression in which runs of data are stored as a single data value and count.
A simple form of RLE would encode the string `"AAABBBCCCD... | {"functional": "_inputs = [['A'], ['AAA'], ['AB'], ['AAABBBCCCA'], ['QQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQ... | 163 | 717 |
coding | Solve the programming task below in a Python markdown code block.
Given a list of unique words. Find all pairs of distinct indices (i, j) in the given list so that the concatenation of the two words, i.e. words[i] + words[j] is a palindrome.
Examples:
Non-string inputs should be converted to strings.
Return an array... | {"functional": "_inputs = [[['bat', 'tab', 'cat']], [['dog', 'cow', 'tap', 'god', 'pat']], [['abcd', 'dcba', 'lls', 's', 'sssll']], [[]], [['adgdfsh', 'wertewry', 'zxcbxcb', 'efveyn']], [[5, 2, 'abc', True, [False]]], [[5777, 'dog', 'god', True, 75]]]\n_outputs = [[[[0, 1], [1, 0]]], [[[0, 3], [2, 4], [3, 0], [4, 2]]],... | 123 | 338 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given n rectangles represented by a 0-indexed 2D integer array rectangles, where rectangles[i] = [widthi, heighti] denotes the width and height of the ith rectangle.
Two rectangles i and j (i < j) are consider... | {"functional": "def check(candidate):\n assert candidate(rectangles = [[4,8],[3,6],[10,20],[15,30]]) == 6\n assert candidate(rectangles = [[4,5],[7,8]]) == 0\n\n\ncheck(Solution().interchangeableRectangles)"} | 153 | 72 |
coding | Solve the programming task below in a Python markdown code block.
The last stage of Football World Cup is played using the play-off system.
There are n teams left in this stage, they are enumerated from 1 to n. Several rounds are held, in each round the remaining teams are sorted in the order of their ids, then the fi... | {"inputs": ["4 1 2\n", "8 2 6\n", "8 7 5\n", "2 1 2\n", "2 2 1\n", "4 1 3\n", "4 1 4\n", "4 2 1\n"], "outputs": ["1\n", "Final!\n", "2\n", "Final!\n", "Final!\n", "Final!\n", "Final!\n", "1\n"]} | 497 | 107 |
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.
There are $N$ boxes on a table, numbered $1$ through $N$ from left to right. Each box has a number written on it; let's denote the number written on ... | {"inputs": ["2\n4 3 0\n4 1 9 5\n4 3 1\n4 1 9 5"], "outputs": ["9\n1"]} | 578 | 42 |
coding | Solve the programming task below in a Python markdown code block.
$Gogi$, $Tapu$ and $Sonu$ are the elite members of $Tapu$ $Sena$. $Gogi$ is always stoned and asks absurd questions, But this time he asked a question which seems to be very serious and interesting. $Tapu$ wants to solve this question to impress $Sonu$. ... | {"inputs": ["1\n1\n2"], "outputs": ["2"]} | 355 | 16 |
coding | Solve the programming task below in a Python markdown code block.
On Children's Day, the child got a toy from Delayyy as a present. However, the child is so naughty that he can't wait to destroy the toy.
The toy consists of n parts and m ropes. Each rope links two parts, but every pair of parts is linked by at most on... | {"inputs": ["1 0\n643\n", "1 0\n674\n", "1 0\n376\n", "1 0\n416\n", "1 0\n3660\n", "1 0\n4387\n", "1 0\n6094\n", "1 0\n1852\n"], "outputs": ["0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n"]} | 659 | 122 |
coding | Solve the programming task below in a Python markdown code block.
"What are your shoe sizes?"
Suddenly, the doctor asked me when I met him for the first time.
"It's 23.5"
"Oh, that's a really nice number. It's 2 to the 4th power plus 2 to the 2nd power, 2 to the 1st power, 2 to the 0th power, and 2 to the 1st power."... | {"inputs": ["23.5\n158.1\n-1.0", "23.72975180461117\n158.1\n-1.0", "24.206542817215936\n158.1\n-1.0", "24.615346202775605\n158.1\n-1.0", "25.190547978615548\n158.1\n-1.0", "23.529780841564097\n158.1\n-1.0", "24.722659099067236\n158.1\n-1.0", "23.5\n158.1\n-0.5246083014985048"], "outputs": ["00010111.1000\nNA", "NA\nNA\... | 488 | 311 |
coding | Solve the programming task below in a Python markdown code block.
There are N squares arranged in a row from left to right.
The height of the i-th square from the left is H_i.
You will land on a square of your choice, then repeat moving to the adjacent square on the right as long as the height of the next square is not... | {"inputs": ["1\n1\n", "4\n1 2 3 6", "4\n1 2 6 6", "4\n1 4 3 6", "4\n0 4 3 6", "4\n0 4 3 7", "4\n0 4 4 7", "4\n0 4 0 7"], "outputs": ["0\n", "0\n", "1\n", "1\n", "1\n", "1\n", "1\n", "1\n"]} | 213 | 121 |
coding | Solve the programming task below in a Python markdown code block.
Read problems statements in Mandarin Chinese and Russian.
Chef is on a vacation these days, so his friend Chefza is trying to solve Chef's everyday tasks.
Today's task is to make a sweet roll. Rolls are made by a newly invented cooking machine. The ma... | {"inputs": ["6\n1 1\n2 1\n3 8\n4 1\n2 1\n2 4", "6\n1 2\n2 4\n6 8\n4 8\n1 1\n2 4", "6\n1 1\n2 4\n3 2\n4 4\n4 1\n1 4", "6\n2 2\n2 4\n6 8\n4 8\n1 1\n2 4", "6\n1 1\n2 1\n4 8\n5 1\n2 1\n2 4", "6\n1 1\n2 4\n3 8\n4 16\n4 1\n1 4", "6\n1 1\n2 4\n3 1\n4 16\n4 1\n1 4", "6\n1 1\n2 4\n3 8\n4 16\n1 1\n1 4"], "outputs": ["0\n1\n4\n2\... | 662 | 336 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given an array representing a row of seats where seats[i] = 1 represents a person sitting in the ith seat, and seats[i] = 0 represents that the ith seat is empty (0-indexed).
There is at least one empty seat, ... | {"functional": "def check(candidate):\n assert candidate(seats = [1,0,0,0,1,0,1]) == 2\n assert candidate(seats = [1,0,0,0]) == 3\n assert candidate(seats = [0,1]) == 1\n\n\ncheck(Solution().maxDistToClosest)"} | 144 | 81 |
coding | Solve the programming task below in a Python markdown code block.
In Finite Encyclopedia of Integer Sequences (FEIS), all integer sequences of lengths between 1 and N (inclusive) consisting of integers between 1 and K (inclusive) are listed.
Let the total number of sequences listed in FEIS be X. Among those sequences, ... | {"inputs": ["0 4", "2 1", "0 1", "2 5", "2 2", "0 5", "0 2", "3 1"], "outputs": ["0 0 0 0\n", "1\n", "0\n", "1 2 2 2 2\n", "1 2\n", "0 0 0 0 0\n", "0 0\n", "2\n"]} | 278 | 104 |
coding | Solve the programming task below in a Python markdown code block.
Problem Statement
Mr. Takatsuki, who is planning to participate in the Aizu training camp, is enthusiastic about studying and has been studying English recently. She tries to learn as many English words as possible by playing the following games on her ... | {"inputs": ["6\nUZI@ 4\nLINER 3\nKGNE 1\nBLL 2\nAS 1\nCHEL 10\nBSKA\nILIC\nNRZI\nUELE\n21", "6\nUZIA 2\nLINER 12\nLGNE 9\nALL 2\nSA 1\nCIEL 9\nBSLA\nCJLI\nIRZN\nUELE\n21", "6\nUZI@ 4\nLINER 12\nLGOE 9\nALL 2\nAS 0\nCIEL 5\nBSLA\nCILI\nINZR\nUELE\n21", "6\nAIZU 4\nLINER 6\nLGNE 3\nLLA 2\nAS 1\nCIEL 10\nBSLA\nCILI\nIRZN\... | 724 | 437 |
coding | Solve the programming task below in a Python markdown code block.
Madoka decided to participate in an underground sports programming competition. And there was exactly one task in it:
A square table of size $n \times n$, where $n$ is a multiple of $k$, is called good if only the characters '.' and 'X' are written in i... | {"inputs": ["3\n3 3 3 2\n2 1 1 2\n6 3 4 2\n"], "outputs": ["X..\n..X\n.X.\nXX\nXX\n.X..X.\nX..X..\n..X..X\n.X..X.\nX..X..\n..X..X\n"]} | 619 | 79 |
coding | Solve the programming task below in a Python markdown code block.
We've got no test cases. A big olympiad is coming up. But the problemsetters' number one priority should be adding another problem to the round.
The diameter of a multiset of points on the line is the largest distance between two points from this set. ... | {"inputs": ["1 5\n6\n", "1 5\n6\n", "1 3\n6\n", "1 0\n6\n", "1 0\n22\n", "1 0\n22\n", "1 1\n22\n", "1 1\n42\n"], "outputs": ["0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n"]} | 424 | 106 |
coding | Solve the programming task below in a Python markdown code block.
You are working at a lower league football stadium and you've been tasked with automating the scoreboard.
The referee will shout out the score, you have already set up the voice recognition module which turns the ref's voice into a string, but the spoke... | {"functional": "_inputs = [['The score is four nil'], ['new score: two three'], ['two two'], ['Arsenal just conceded another goal, two nil']]\n_outputs = [[[4, 0]], [[2, 3]], [[2, 2]], [[2, 0]]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return math.isclos... | 186 | 201 |
coding | Solve the programming task below in a Python markdown code block.
Internet search engines, such as Google, automatically sort and categorize web pages around the world to create a huge database. It also parses the search keywords entered by the user and creates an inquiry statement for database search.
In each case, c... | {"inputs": ["Rain, rain, go ot Spain.", "Rain, iarn, og ot Spain.", "Rain, arin, go to Spain.", "Rain, raio, go ot Spain.", "Rain, rain, og ot .niapS", "Rajn, rain, og ot .niapS", "Rain, rain, go to Spain.", "Win today's preliminary contest and be qualified to visit University fo Aizu."], "outputs": ["Rain rain Spain\n... | 266 | 155 |
coding | Solve the programming task below in a Python markdown code block.
You are given two positive integers a and b. You also have a number x, which is initially set to 0. At first, you can add a to x any number of times. After that, you can divide x by b any number of times as long as x is divisible by b.
Print YES if you ... | {"inputs": ["4\n3 10\n9 6\n7 30\n8 12"], "outputs": ["NO\nYES\nNO\nYES"]} | 426 | 37 |
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, where nums[i] is a digit between 0 and 9 (inclusive).
The triangular sum of nums is the value of the only element present in nums after the following process terminates:
... | {"functional": "def check(candidate):\n assert candidate(nums = [1,2,3,4,5]) == 8\n assert candidate(nums = [5]) == 5\n\n\ncheck(Solution().triangularSum)"} | 209 | 52 |
coding | Solve the programming task below in a Python markdown code block.
Read problems statements in Mandarin Chinese, Russian and Vietnamese as well.
Chef has recently got a broadband internet connection. His history of internet data usage is provided as below.
During the first T_{1} minutes, the internet data used was D_... | {"inputs": ["3\n2 2\n2 1\n2 3\n2 2\n1 2\n2 3\n3 0\n1 2\n2 4\n10 10"], "outputs": ["6\n3\n110"]} | 580 | 60 |
coding | Solve the programming task below in a Python markdown code block.
Snuke and Raccoon have a heap of N cards. The i-th card from the top has the integer a_i written on it.
They will share these cards.
First, Snuke will take some number of cards from the top of the heap, then Raccoon will take all the remaining cards.
Her... | {"inputs": ["2\n-6 0", "2\n-1 8", "2\n0 13", "2\n15 1", "2\n23 0", "2\n51 0", "2\n0 -10", "2\n0 -19"], "outputs": ["6\n", "9\n", "13\n", "14\n", "23\n", "51\n", "10\n", "19\n"]} | 296 | 108 |
coding | Solve the programming task below in a Python markdown code block.
Chef has an array of N numbers and a magic function which can swap two array values if their distance is strictly greater than K units. Since his friend Pishty is obsessed with sorted array, Chef wants to make the lexicographically minimum array possible... | {"inputs": ["6 2\n4 6 3 2 5 1"], "outputs": ["1 2 3 4 5 6"]} | 436 | 36 |
coding | Solve the programming task below in a Python markdown code block.
In this Kata, you will be given a number `n` (`n > 0`) and your task will be to return the smallest square number `N` (`N > 0`) such that `n + N` is also a perfect square. If there is no answer, return `-1` (`nil` in Clojure, `Nothing` in Haskell, `None`... | {"functional": "_inputs = [[1], [2], [3], [4], [5], [7], [8], [9], [10], [11], [13], [17], [88901], [290101]]\n_outputs = [[-1], [-1], [1], [-1], [4], [9], [1], [16], [-1], [25], [36], [64], [5428900], [429235524]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n ... | 572 | 264 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given an integer array nums, return the number of subarrays filled with 0.
A subarray is a contiguous non-empty sequence of elements within an array.
Please complete the following python code precisely:
```python
cl... | {"functional": "def check(candidate):\n assert candidate(nums = [1,3,0,0,2,0,0,4]) == 6\n assert candidate(nums = [0,0,0,2,0,0]) == 9\n assert candidate(nums = [2,10,2019]) == 0\n\n\ncheck(Solution().zeroFilledSubarray)"} | 82 | 89 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
There are n employees, each with a unique id from 0 to n - 1.
You are given a 2D integer array logs where logs[i] = [idi, leaveTimei] where:
idi is the id of the employee that worked on the ith task, and
leaveTimei i... | {"functional": "def check(candidate):\n assert candidate(n = 10, logs = [[0,3],[2,5],[0,9],[1,15]]) == 1\n assert candidate(n = 26, logs = [[1,1],[3,7],[2,12],[7,17]]) == 3\n assert candidate(n = 2, logs = [[0,10],[1,20]]) == 0\n\n\ncheck(Solution().hardestWorker)"} | 202 | 112 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given the array nums consisting of 2n elements in the form [x1,x2,...,xn,y1,y2,...,yn].
Return the array in the form [x1,y1,x2,y2,...,xn,yn].
Please complete the following python code precisely:
```python
class Solu... | {"functional": "def check(candidate):\n assert candidate(nums = [2,5,1,3,4,7], n = 3) == [2,3,5,4,1,7] \n assert candidate(nums = [1,2,3,4,4,3,2,1], n = 4) == [1,4,2,3,3,2,4,1]\n assert candidate(nums = [1,1,2,2], n = 2) == [1,2,1,2]\n\n\ncheck(Solution().shuffle)"} | 102 | 133 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given a binary string s, and a 2D integer array queries where queries[i] = [firsti, secondi].
For the ith query, find the shortest substring of s whose decimal value, val, yields secondi when bitwise XORed wit... | {"functional": "def check(candidate):\n assert candidate(s = \"101101\", queries = [[0,5],[1,2]]) == [[0,2],[2,3]]\n assert candidate(s = \"0101\", queries = [[12,8]]) == [[-1,-1]]\n assert candidate(s = \"1\", queries = [[4,5]]) == [[0,0]]\n\n\ncheck(Solution().substringXorQueries)"} | 215 | 108 |
coding | Solve the programming task below in a Python markdown code block.
Back in 2015, Usain Bolt announced that he'll be retiring after the 2017 World Championship. Though his final season did not end gloriously, we all know that he is a true legend and we witnessed his peak during 2008 - 2013.
Post retirement, Usain Bolt i... | {"inputs": ["2\n10 100 10 10\n100 10 5 10"], "outputs": ["Bolt\nTiger"]} | 640 | 41 |
coding | Solve the programming task below in a Python markdown code block.
Sereja is hosting his birthday dinner. He invited his N close friends. Let us number the people from 1 to N according to the order in which they arrive at the event. The dinner is being held in long straight corridor in which people sit in a way such tha... | {"inputs": ["3\n1\n0\n3\n0 0 0\n5\n0 1 2 1 4"], "outputs": ["0\n0\n3"]} | 576 | 40 |
coding | Solve the programming task below in a Python markdown code block.
Kode Festival is an anual contest where the hardest stone in the world is determined. (Kode is a Japanese word for "hardness".)
This year, 2^N stones participated. The hardness of the i-th stone is A_i.
In the contest, stones are thrown at each other i... | {"inputs": ["2\n1\n5\n8\n0", "2\n0\n0\n0\n0", "2\n1\n5\n4\n19", "2\n1\n5\n8\n19", "2\n2\n11\n8\n0", "2\n2\n11\n6\n0", "2\n2\n11\n9\n0", "2\n2\n7\n9\n-2"], "outputs": ["4\n", "0\n", "11\n", "7\n", "1\n", "3\n", "9\n", "6\n"]} | 452 | 133 |
coding | Solve the programming task below in a Python markdown code block.
Somu went to the gym today. He decided to do X sets of squats. Each set consists of 15 squats. Determine the total number of squats that he did today.
------ Input Format ------
- The first line contains a single integer T — the number of test cases. ... | {"inputs": ["3\n1\n4\n99\n"], "outputs": ["15\n60\n1485\n"]} | 274 | 30 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given an array nums of non-negative integers. nums is considered special if there exists a number x such that there are exactly x numbers in nums that are greater than or equal to x.
Notice that x does not hav... | {"functional": "def check(candidate):\n assert candidate(nums = [3,5]) == 2\n assert candidate(nums = [0,0]) == -1\n assert candidate(nums = [0,4,3,0,4]) == 3\n assert candidate(nums = [3,6,7,7,0]) == -1\n\n\ncheck(Solution().specialArray)"} | 131 | 87 |
coding | Solve the programming task below in a Python markdown code block.
While most devs know about [big/little-endianness](https://en.wikipedia.org/wiki/Endianness), only a selected few know the secret of real hard core coolness with mid-endians.
Your task is to take a number and return it in its mid-endian format, putting ... | {"functional": "_inputs = [[9999999], [0], [658188], [168496141], [43135012110]]\n_outputs = [['96987F'], ['00'], ['0B0A0C'], ['0D0B0A0C'], ['0D0B0A0C0E']]\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 ... | 217 | 234 |
coding | Solve the programming task below in a Python markdown code block.
Read problem statements in [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Given a binary string $S$ consisting of $0's$ and $1's$, find whether there exists a rightwise [circular rotation] of the string such that every 2 adjacent $... | {"inputs": ["3\n4 1\n1100\n4 0\n0101\n6 1\n101001"], "outputs": ["YES\nNO\nYES"]} | 577 | 45 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given a binary array nums.
A subarray of an array is good if it contains exactly one element with the value 1.
Return an integer denoting the number of ways to split the array nums into good subarrays. As the ... | {"functional": "def check(candidate):\n assert candidate(nums = [0,1,0,0,1]) == 3\n assert candidate(nums = [0,1,0]) == 1\n\n\ncheck(Solution().numberOfGoodSubarraySplits)"} | 133 | 59 |
coding | Solve the programming task below in a Python markdown code block.
Today is the day of the CCDSAP exam. Chef is responsible for monitoring the exam. The hall in which the exam will be held contains $N$ seats (numbered $1$ through $N$) arranged in a row. Initially, each seat is either empty or occupied by a participant i... | {"inputs": ["4\n3\n011\n5\n10111\n1\n1\n6\n000111"], "outputs": ["1\nimpossible\n0\n3"]} | 506 | 46 |
coding | Solve the programming task below in a Python markdown code block.
Takahashi loves gold coins. He gains 1000 happiness points for each 500-yen coin he has and gains 5 happiness points for each 5-yen coin he has. (Yen is the currency of Japan.)
Takahashi has X yen. If he exchanges his money so that he will gain the most ... | {"inputs": ["1", "8", "0", "0\n", "-1", "-8", "42", "15"], "outputs": ["0\n", "5\n", "0", "0\n", "-505\n", "-510\n", "40\n", "15\n"]} | 266 | 70 |
coding | Solve the programming task below in a Python markdown code block.
Nukes has an integer that can be represented as the bitwise OR of one or more integers between A and B (inclusive). How many possible candidates of the value of Nukes's integer there are?
Constraints
* 1 ≤ A ≤ B < 2^{60}
* A and B are integers.
Input
... | {"inputs": ["7\n8", "7\n7", "7\n9", "7\n15", "7\n20", "7\n33", "7\n10", "7\n32"], "outputs": ["3\n", "1\n", "4", "9\n", "25\n", "52\n", "6\n", "51\n"]} | 195 | 85 |
coding | Solve the programming task below in a Python markdown code block.
A TV program called "Saizo" is popular in a certain country. In this program, participants challenge field athletics and get a prize if they successfully capture it.
Field athletics are made by arranging blocks of different heights in a row, and how to ... | {"inputs": ["5\n5\n5 101 5 98 117\n2\n3 100\n2\n101 26\n3\n22 86 50\n7\n123 17 959 901 2 971 1573", "5\n5\n10 101 5 50 59\n2\n20 100\n2\n100 30\n3\n5 86 50\n7\n123 82 959 319 41 971 275", "5\n5\n5 101 5 98 117\n2\n15 100\n2\n100 30\n3\n22 86 50\n7\n123 82 959 901 2 971 1573", "5\n5\n5 101 5 98 117\n2\n15 100\n2\n101 30... | 446 | 875 |
coding | Solve the programming task below in a Python markdown code block.
Chef has invested his money at an interest rate of X percent per annum while the current inflation rate is Y percent per annum.
An investment is called *good* if and only if the interest rate of the investment is at least twice of the inflation rate. ... | {"inputs": ["5\n7 4\n6 3\n2 4\n10 10\n20 1\n"], "outputs": ["NO\nYES\nNO\nNO\nYES\n"]} | 453 | 45 |
coding | Solve the programming task below in a Python markdown code block.
Consider an array $a$ of length $n$ with elements numbered from $1$ to $n$. It is possible to remove the $i$-th element of $a$ if $gcd(a_i, i) = 1$, where $gcd$ denotes the greatest common divisor. After an element is removed, the elements to the right a... | {"inputs": ["2 3\n", "4 2\n", "4 6\n", "2 1\n", "17957 2\n", "300000 1\n", "2 1000000000000\n", "1337 424242424242\n"], "outputs": ["6\n", "26\n", "1494\n", "1\n", "653647969\n", "299999\n", "138131255\n", "119112628\n"]} | 672 | 154 |
coding | Solve the programming task below in a Python markdown code block.
Nina received an odd New Year's present from a student: a set of $n$ unbreakable sticks. Each stick has a length, $\boldsymbol{l}$, and the length of the $i^{\mbox{th}}$ stick is $\boldsymbol{l_{i-1}}$. Deciding to turn the gift into a lesson, Nina asks ... | {"inputs": ["6\n1 2 3 4 5 6 \n", "8\n4 5 1 5 1 9 4 5 \n"], "outputs": ["0 \n", "3\n"]} | 729 | 54 |
coding | Solve the programming task below in a Python markdown code block.
In Aizu prefecture, we decided to create a new town to increase the population. To that end, we decided to cultivate a new rectangular land and divide this land into squares of the same size. The cost of developing this land is proportional to the number... | {"inputs": ["9 6 1", "3 3 1", "3 3 2", "2 1 8", "3 5 1", "3 6 2", "1 3 4", "5 1 1"], "outputs": ["6\n", "1\n", "2\n", "16\n", "15\n", "4\n", "12\n", "5\n"]} | 254 | 97 |
coding | Solve the programming task below in a Python markdown code block.
N hotels are located on a straight line. The coordinate of the i-th hotel (1 \leq i \leq N) is x_i.
Tak the traveler has the following two personal principles:
- He never travels a distance of more than L in a single day.
- He never sleeps in the open.... | {"inputs": ["9\n1 6 6 24 7 15 19 29 31\n10\n3\n2 8\n8 3\n1 2\n5 5", "9\n1 3 6 6 15 15 19 29 31\n10\n2\n1 8\n7 3\n1 2\n8 5", "9\n1 3 6 13 15 18 19 29 31\n10\n2\n1 8\n7 3\n6 7\n8 5", "9\n1 3 6 13 23 18 19 29 31\n10\n2\n1 8\n7 5\n6 7\n8 5", "9\n1 3 6 13 23 18 19 29 31\n12\n2\n1 8\n1 3\n9 7\n8 7", "9\n1 3 6 13 23 18 19 29 ... | 661 | 438 |
coding | Solve the programming task below in a Python markdown code block.
Read problems statements in Mandarin Chinese and Russian as well.
Alice and Bob are playing the game. Initially, there is a single rooted tree. Players take turns alternately, Alice starts.
In a single turn, Alice should choose any non-empty subset of... | {"inputs": ["3\n2\n1 2\n7\n1 3\n1 4\n4 2\n4 5\n4 6\n6 7\n1"], "outputs": ["2\n5\n1"]} | 407 | 50 |
coding | Solve the programming task below in a Python markdown code block.
Chef participated in a contest and got a rank X.
Chef is trying to find his name in the ranklist but there are too many pages.
Each page consists of 25 participants. Chef wants to find the exact page number which contains his name.
Help Chef find the... | {"inputs": ["4\n1\n34\n150\n74\n"], "outputs": ["1\n2\n6\n3\n"]} | 381 | 32 |
coding | Solve the programming task below in a Python markdown code block.
Complete the function that counts the number of unique consonants in a string (made up of printable ascii characters).
Consonants are letters used in English other than `"a", "e", "i", "o", "u"`. We will count `"y"` as a consonant.
Remember, your funct... | {"functional": "_inputs = [['sillystring'], ['aeiou'], ['abcdefghijklmnopqrstuvwxyz'], ['Count my unique consonants!!']]\n_outputs = [[7], [0], [21], [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_tol=tol, abs_tol=tol)\n i... | 246 | 183 |
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.
Guddu likes a girl that loves playing with numbers. She agreed to go on a date with Guddu, but only if he can solve the following problem:
An intege... | {"inputs": ["1\n2"], "outputs": ["28"]} | 383 | 15 |
coding | Solve the programming task below in a Python markdown code block.
Chef Loves to listen to remix songs, but currently he had already finished the entire playlist of remix songs.
As Chef is smart, so he thought let's make my own remix songs of the original songs.
Chef is not having much knowledge of making remix songs, s... | {"inputs": ["Mai Hu Jiyaan"], "outputs": ["Hu Mai Hu Hu Hu Jiyaan Hu"]} | 255 | 25 |
coding | Solve the programming task below in a Python markdown code block.
Read problems statements [Hindi] , [Vietnamese] , [Mandarin Chinese] , [Russian] and [Bengali] as well.
The last time in Byteland, Chef defeated the magician in his challenge and won a gold coin.
The magician does not want to give up his coin so easily... | {"inputs": ["4\n3 1\n3 2\n4 1\n1 5"], "outputs": ["0.500000\n1.000000\n0.500000\n1.000000"]} | 735 | 62 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given an integer array nums, return the number of triplets chosen from the array that can make triangles if we take them as side lengths of a triangle.
Please complete the following python code precisely:
```python
... | {"functional": "def check(candidate):\n assert candidate(nums = [2,2,3,4]) == 3\n assert candidate(nums = [4,2,3,4]) == 4\n\n\ncheck(Solution().triangleNumber)"} | 79 | 55 |
coding | Solve the programming task below in a Python markdown code block.
Snuke is going to open a contest named "AtCoder s Contest".
Here, s is a string of length 1 or greater, where the first character is an uppercase English letter, and the second and subsequent characters are lowercase English letters.
Snuke has decided to... | {"inputs": ["AtCoder X Contert", "AtCoder W Contert", "AtCoder V Contert", "AtCocer Y Cpnteqt", "AtCoder X Contest", "AtCoder X Contest\n", "AtCoder nSuke Contest", "AtCoder Sunke Contest"], "outputs": ["AXC\n", "AWC\n", "AVC\n", "AYC\n", "AXC", "AXC\n", "AnC\n", "ASC\n"]} | 211 | 107 |
coding | Solve the programming task below in a Python markdown code block.
Galois is one of the strongest chess players of Byteforces. He has even invented a new variant of chess, which he named «PawnChess».
This new game is played on a board consisting of 8 rows and 8 columns. At the beginning of every game some black and whi... | {"inputs": ["........\n........\n.B....B.\n....W...\n........\n..W.....\n........\n........\n", "..B.....\n..W.....\n......B.\n........\n.....W..\n......B.\n........\n........\n", ".BB.B.B.\nB..B..B.\n.B.BB...\nBB.....B\nBBB....B\nB..BB...\nBB.B...B\n....WWW.\n", "..BB....\n........\nWW.W..WW\nW...W...\n.W...W..\n.W..W... | 694 | 343 |
coding | Solve the programming task below in a Python markdown code block.
# Task
Consider the following operation:
We take a positive integer `n` and replace it with the sum of its `prime factors` (if a prime number is presented multiple times in the factorization of `n`, then it's counted the same number of times in the s... | {"functional": "_inputs = [[24], [35], [156], [4], [31]]\n_outputs = [[5], [7], [5], [4], [31]]\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... | 258 | 184 |
coding | Solve the programming task below in a Python markdown code block.
Find the longest substring within a string that contains at most 2 unique characters.
```
substring("a") => "a"
substring("aaa") => "aaa"
substring("abacd") => "aba"
substring("abacddcd") => "cddcd"
substring("cefageaacceaccacca") => "accacca"
```
This... | {"functional": "_inputs = [[''], ['a'], ['aa'], ['aaa'], ['ab'], ['aba'], ['abc'], ['abcba'], ['bbacc'], ['ccddeeff'], ['bbacddddcdd'], ['abcddeejabbedsajaajjaajjajajajjajjaaacedajajaj'], ['aaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbccccccccccccccccccccddddddddddddddddddddeeeeeeeeeeeeeeeeeeeeffffffffffffffffffffgggggggggg... | 228 | 516 |
coding | Solve the programming task below in a Python markdown code block.
Read problems statements in [Mandarin Chinese],[Vietnamese], and [Bengali] as well.
Today is Chef's birthday and he is looking forward to his gift. As usual, the gift is hidden and Chef has to follow a sequence of $N$ instructions to reach it.
Initiall... | {"inputs": ["3\n5\nLLLUR\n7\nLLLRUUD\n8\nLRULLUDU"], "outputs": ["0 1\n-1 1\n-2 2"]} | 531 | 43 |
coding | Solve the programming task below in a Python markdown code block.
You wrote all your unit test names in camelCase.
But some of your colleagues have troubles reading these long test names.
So you make a compromise to switch to underscore separation.
To make these changes fast you wrote a class to translate a camelCase ... | {"functional": "_inputs = [['ThisIsAUnitTest'], ['ThisShouldBeSplittedCorrectIntoUnderscore'], ['Calculate1Plus1Equals2'], ['Calculate15Plus5Equals20'], ['Calculate500DividedBy5Equals100'], ['Adding_3To_3ShouldBe_6'], ['This_Is_Already_Splitted_Correct'], ['ThisIs_Not_SplittedCorrect'], ['_IfATestStartAndEndsWithUnders... | 320 | 386 |
coding | Solve the programming task below in a Python markdown code block.
Lexicographic permutations are ordered combinations of a set of items ordered in a specific way.
For instance, the first 8 permutations of the digits 0123, in lexicographic order, are:
```
1st 0123
2nd 0132
3rd 0213
4th 0231
5th 0312
6th 0321
7th 1023
... | {"functional": "_inputs = [[1, 1], [12, 5], [1000, 7], [1000, 8], [1000000, 10], [874, 7], [100, 5], [400, 6], [900, 8], [3000000, 10], [1234567, 10], [654321, 10], [100000, 9], [33333, 8]]\n_outputs = [['0'], ['02431'], ['1325460'], ['02436571'], ['2783915460'], ['1234560'], ['40231'], ['314250'], ['02354761'], ['8241... | 351 | 416 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given a strictly increasing integer array rungs that represents the height of rungs on a ladder. You are currently on the floor at height 0, and you want to reach the last rung.
You are also given an integer d... | {"functional": "def check(candidate):\n assert candidate(rungs = [1,3,5,10], dist = 2) == 2\n assert candidate(rungs = [3,6,8,10], dist = 3) == 0\n assert candidate(rungs = [3,4,6,7], dist = 2) == 1\n assert candidate(rungs = [5], dist = 10) == 0\n\n\ncheck(Solution().addRungs)"} | 189 | 113 |
coding | Solve the programming task below in a Python markdown code block.
Recenlty Luba got a credit card and started to use it. Let's consider n consecutive days Luba uses the card.
She starts with 0 money on her account.
In the evening of i-th day a transaction a_{i} occurs. If a_{i} > 0, then a_{i} bourles are deposited t... | {"inputs": ["1 1\n2\n", "1 1\n1\n", "1 1\n1\n", "1 1\n2\n", "2 3\n2 0\n", "2 3\n2 0\n", "4 4\n2 2 0 1\n", "4 4\n2 2 0 1\n"], "outputs": ["-1\n", "0\n", "0\n", "-1\n", "0\n", "0\n", "-1\n", "-1\n"]} | 500 | 119 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given a string num consisting of digits only.
Return the largest palindromic integer (in the form of a string) that can be formed using digits taken from num. It should not contain leading zeroes.
Notes:
You ... | {"functional": "def check(candidate):\n assert candidate(num = \"444947137\") == \"7449447\"\n assert candidate(num = \"00009\") == \"9\"\n\n\ncheck(Solution().largestPalindromic)"} | 123 | 67 |
coding | Solve the programming task below in a Python markdown code block.
An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; R stands for red and W stands for white.
You can do the following two kinds of operations an... | {"inputs": ["2\nRQ", "2\nRS", "2\nRT", "2\nRU", "2\nRP", "2\nRO", "2\nRV", "2\nRN"], "outputs": ["0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n"]} | 297 | 79 |
coding | Solve the programming task below in a Python markdown code block.
Maya is teaching Alex about HyperText Markup Language (HTML). Alex is confused about div and span tags, so Maya decides to reduce the concept to a simpler visual by representing div tags as square brackets and span tags as parentheses. In other words, sh... | {"inputs": ["3\n1 1\n1 2\n2 2\n"], "outputs": ["3\n18\n160\n"]} | 671 | 33 |
coding | Solve the programming task below in a Python markdown code block.
Chef Ciel wants to put a fancy neon signboard over the entrance of her restaurant. She has not enough money to buy the new one so she bought some old neon signboard through the internet. Ciel was quite disappointed when she received her order - some of i... | {"inputs": ["5\n????CIELIS???E?\n????CIELISOUR???F\nT?KEITE?SY\n????????\n???C???", "5\n????CIELIS???E?\n????CIELISOUR???F\nT?KEITE?SY\n????????\n@??C???", "5\n????CIELIS???E?\n????CIELISOUR???F\nYS?ETIEK?T\n????????\n@??C???", "5\n????CIELIS???E?\n????CIELISOUR???F\nYS?ETIEK?T\n????>???\n@??C???", "5\n????CIELI?S??E?\... | 765 | 565 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.