task_type stringclasses 4
values | problem stringlengths 14 5.23k | solution stringlengths 1 8.29k | problem_tokens int64 9 1.02k | solution_tokens int64 1 1.98k |
|---|---|---|---|---|
coding | Solve the programming task below in a Python markdown code block.
Neko loves divisors. During the latest number theory lesson, he got an interesting exercise from his math teacher.
Neko has two integers $a$ and $b$. His goal is to find a non-negative integer $k$ such that the least common multiple of $a+k$ and $b+k$ i... | {"inputs": ["1 1\n", "2 3\n", "2 2\n", "2 6\n", "6 9\n", "2 3\n", "2 2\n", "2 6\n"], "outputs": ["0", "0", "0", "0", "0", "0\n", "0\n", "0\n"]} | 307 | 81 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given a positive integer n, you can do the following operation any number of times:
Add or subtract a power of 2 from n.
Return the minimum number of operations to make n equal to 0.
A number x is power of 2... | {"functional": "def check(candidate):\n assert candidate(n = 39) == 3\n assert candidate(n = 54) == 3\n\n\ncheck(Solution().minOperations)"} | 112 | 45 |
coding | Solve the programming task below in a Python markdown code block.
You are given a binary string S. You need to transform this string into another string of equal length consisting only of zeros, with the minimum number of operations.
A single operation consists of taking some prefix of the string S and flipping all its... | {"inputs": ["01001001"], "outputs": ["6"]} | 444 | 19 |
coding | Solve the programming task below in a Python markdown code block.
The window of Takahashi's room has a width of A. There are two curtains hung over the window, each of which has a horizontal length of B. (Vertically, the curtains are long enough to cover the whole window.)
We will close the window so as to minimize the... | {"inputs": ["3 0", "1 0", "2 0", "1 1\n", "16 4", "35 7", "20 7", "20 8"], "outputs": ["3\n", "1\n", "2\n", "0\n", "8\n", "21\n", "6\n", "4\n"]} | 229 | 84 |
coding | Solve the programming task below in a Python markdown code block.
Harry Water, Ronaldo, Her-my-oh-knee and their friends have started a new school year at their MDCS School of Speechcraft and Misery. At the time, they are very happy to have seen each other after a long time. The sun is shining, birds are singing, flowe... | {"inputs": ["2\n1\n3\n", "2\n1\n4\n", "2\n0\n4\n", "2\n1\n1\n", "2\n1\n8\n", "2\n1\n9\n", "2\n1\n2\n", "2\n1\n6\n"], "outputs": ["6\n", "8\n", "0\n", "2\n", "16\n", "18\n", "4\n", "12\n"]} | 478 | 105 |
coding | Solve the programming task below in a Python markdown code block.
At the end of a busy day, The Chef and his assistants play a game together. The game is not just for fun but also used to decide who will have to clean the kitchen. The Chef is a Game Master, so his concern is how to manage the game but not how to win th... | {"inputs": ["1\n5 2 3\n1 4\n3 5\n1 5", "1\n5 2 3\n1 4\n3 5\n0 5", "1\n5 2 3\n1 3\n3 5\n1 5", "1\n5 2 3\n2 4\n3 5\n0 5", "1\n5 2 3\n2 4\n2 5\n0 5", "1\n5 2 3\n2 4\n2 8\n0 5", "1\n4 2 3\n1 6\n3 9\n1 5", "1\n5 2 3\n5 4\n2 5\n0 3"], "outputs": ["1", "0\n", "4\n", "1\n", "2\n", "6\n", "7\n", "5\n"]} | 608 | 205 |
coding | Solve the programming task below in a Python markdown code block.
There is a tree with N vertices, numbered 1 through N. The i-th of the N-1 edges connects vertices a_i and b_i.
Currently, there are A_i stones placed on vertex i. Determine whether it is possible to remove all the stones from the vertices by repeatedly... | {"inputs": ["3\n2 2 1\n1 2\n2 3", "3\n1 1 1\n1 2\n2 3", "3\n1 2 0\n1 2\n2 3", "3\n2 2 2\n1 2\n2 3", "3\n2 1 1\n1 2\n2 3", "3\n0 2 0\n1 2\n2 3", "3\n3 1 1\n1 2\n2 3", "3\n2 2 0\n1 2\n2 3"], "outputs": ["NO\n", "YES\n", "NO\n", "YES\n", "NO\n", "NO\n", "NO\n", "NO\n"]} | 372 | 174 |
coding | Solve the programming task below in a Python markdown code block.
Integral numbers can be even or odd.
Even numbers satisfy `n = 2m` ( with `m` also integral ) and we will ( completely arbitrarily ) think of odd numbers as `n = 2m + 1`.
Now, some odd numbers can be more odd than others: when for some `n`, `m` is mor... | {"functional": "_inputs = [[[1, 2]], [[1, 3]], [[1, 5]], [[]], [[0]], [[0, 1]], [[1, 3, 5, 7]], [[2, 4]], [[-1]], [[-1, -1]], [[-1, 0, 1]], [[-3, 3]], [[-5, 3]]]\n_outputs = [[1], [3], [None], [None], [0], [1], [7], [None], [-1], [None], [-1], [3], [None]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(... | 240 | 269 |
coding | Solve the programming task below in a Python markdown code block.
Hamed has recently found a string t and suddenly became quite fond of it. He spent several days trying to find all occurrences of t in other strings he had. Finally he became tired and started thinking about the following problem. Given a string s how ma... | {"inputs": ["a\na\n", "a\nb\n", "a\na\n", "a\nb\n", "c\nc\n", "a\nc\n", "b\nc\n", "c\nb\n"], "outputs": ["1\n", "0\n", "1", "0", "1\n", "0\n", "0\n", "0\n"]} | 407 | 84 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given an integer num, return three consecutive integers (as a sorted array) that sum to num. If num cannot be expressed as the sum of three consecutive integers, return an empty array.
Please complete the following ... | {"functional": "def check(candidate):\n assert candidate(num = 33) == [10,11,12]\n assert candidate(num = 4) == []\n\n\ncheck(Solution().sumOfThree)"} | 87 | 53 |
coding | Solve the programming task below in a Python markdown code block.
In africa jungle , there were zebra's who liked to spit.
There owner watched them for whole day and noted in his sheet where each zebra spitted.
Now he's in a confusion and wants to know if in the jungle there are two zebra's which spitted at each other.... | {"inputs": ["2\n0 1\n1 -1"], "outputs": ["YES"]} | 292 | 20 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given two strings, word1 and word2. You want to construct a string in the following manner:
Choose some non-empty subsequence subsequence1 from word1.
Choose some non-empty subsequence subsequence2 from word2... | {"functional": "def check(candidate):\n assert candidate(word1 = \"cacb\", word2 = \"cbba\") == 5\n assert candidate(word1 = \"ab\", word2 = \"ab\") == 3\n assert candidate(word1 = \"aa\", word2 = \"bb\") == 0\n\n\ncheck(Solution().longestPalindrome)"} | 200 | 79 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
There is a bi-directional graph with n vertices, where each vertex is labeled from 0 to n - 1. The edges in the graph are represented by a given 2D integer array edges, where edges[i] = [ui, vi] denotes an edge betwee... | {"functional": "def check(candidate):\n assert candidate(n = 7, edges = [[0,1],[1,2],[2,0],[3,4],[4,5],[5,6],[6,3]]) == 3\n assert candidate(n = 4, edges = [[0,1],[0,2]]) == -1\n\n\ncheck(Solution().findShortestCycle)"} | 182 | 87 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
The school cafeteria offers circular and square sandwiches at lunch break, referred to by numbers 0 and 1 respectively. All students stand in a queue. Each student either prefers square or circular sandwiches.
The num... | {"functional": "def check(candidate):\n assert candidate(students = [1,1,0,0], sandwiches = [0,1,0,1]) == 0 \n assert candidate(students = [1,1,1,0,0,1], sandwiches = [1,0,0,0,1,1]) == 3\n\n\ncheck(Solution().countStudents)"} | 263 | 88 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given n orders, each order consists of a pickup and a delivery service.
Count all valid pickup/delivery possible sequences such that delivery(i) is always after of pickup(i).
Since the answer may be too large, return... | {"functional": "def check(candidate):\n assert candidate(n = 1) == 1\n assert candidate(n = 2) == 6\n assert candidate(n = 3) == 90\n\n\ncheck(Solution().countOrders)"} | 106 | 56 |
coding | Solve the programming task below in a Python markdown code block.
You are given a positive integer $x$.
You can apply the following operation to the number: remove one occurrence of any digit in such a way that the resulting number does not contain any leading zeroes and is still a positive integer. For example, $1014... | {"inputs": ["5\n10000\n4\n1337\n0\n987654321\n6\n66837494128\n5\n7808652\n3\n"], "outputs": ["1\n1337\n321\n344128\n7052\n"]} | 417 | 86 |
coding | Solve the programming task below in a Python markdown code block.
```if-not:racket
Write a function called `repeat_str` which repeats the given string `src` exactly `count` times.
```
```if:racket
Write a function called `repeat-string` which repeats the given string `str` exactly `count` times.
```
Also feel free to r... | {"functional": "_inputs = [[4, 'a'], [3, 'hello '], [2, 'abc']]\n_outputs = [['aaaa'], ['hello hello hello '], ['abcabc']]\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)):\... | 96 | 181 |
coding | Solve the programming task below in a Python markdown code block.
Read problem statements in [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
You are an administrator of a popular quiz website. Every day, you hold a quiz on the website.
There are $N$ users (numbered $1$ through $N$) and $M$ admins ... | {"inputs": ["3\n1 1 1\n1\n1 1 2\n1 1\n5 5 10\n2 5 2 5 2 4 10 10 10 10"], "outputs": ["0\n1 1\n2 2 5"]} | 570 | 71 |
coding | Solve the programming task below in a Python markdown code block.
Mr. Anant Asankhya is the manager at the INFINITE hotel. The hotel has an infinite amount of rooms.
One fine day, a finite number of tourists come to stay at the hotel.
The tourists consist of:
→ A Captain.
→ An unknown group of families consisting... | {"inputs": ["5\n1 2 3 6 5 4 4 2 5 3 6 1 6 5 3 2 4 1 2 5 1 4 3 6 8 4 3 1 5 6 2 \n"], "outputs": ["8\n"]} | 419 | 77 |
coding | Solve the programming task below in a Python markdown code block.
Nicholas, a painter is going to paint several new canvases. Nicholas is sure that the canvases will turn out so great that each one will need framing and being hung on the wall. Frames are what Nicholas decided to begin with.
Nicholas has n sticks whos... | {"inputs": ["1\n1\n", "1\n10\n", "1\n20\n", "1\n37\n", "2\n1 1\n", "2\n3 5\n", "2\n5 5\n", "2\n5 6\n"], "outputs": ["0", "0", "0\n", "0\n", "0", "0", "0\n", "0\n"]} | 341 | 93 |
coding | Solve the programming task below in a Python markdown code block.
A person is said to be sleep deprived if he slept strictly less than 7 hours in a day.
Chef was only able to sleep X hours yesterday. Determine if he is sleep deprived or not.
------ Input Format ------
- The first line contains a single integer T — ... | {"inputs": ["3\n4\n7\n10\n"], "outputs": ["YES\nNO\nNO\n"]} | 265 | 25 |
coding | Solve the programming task below in a Python markdown code block.
Snuke, a water strider, lives in a rectangular pond that can be seen as a grid with H east-west rows and W north-south columns. Let (i,j) be the square at the i-th row from the north and j-th column from the west.
Some of the squares have a lotus leaf on... | {"inputs": ["1 6 4\n1 1 1 1\n......", "1 6 4\n1 2 1 6\n......", "1 6 1\n1 1 1 6\n......", "1 6 2\n1 1 1 1\n......", "1 8 1\n1 1 1 6\n......", "1 6 4\n1 1 1 4\n......", "1 6 4\n1 1 1 1\n...-..", "1 8 2\n1 1 1 1\n......"], "outputs": ["0\n", "1\n", "5\n", "0\n", "5\n", "1\n", "0\n", "0\n"]} | 664 | 176 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
A phrase is a palindrome if, after converting all uppercase letters into lowercase letters and removing all non-alphanumeric characters, it reads the same forward and backward. Alphanumeric characters include letters ... | {"functional": "def check(candidate):\n assert candidate(s = \"race a car\") == False\n assert candidate(s = \" \") == True\n\n\ncheck(Solution().isPalindrome)"} | 103 | 43 |
coding | Solve the programming task below in a Python markdown code block.
Bhallaladeva was an evil king who ruled the kingdom of Maahishmati. He wanted to erect a 100ft golden statue of himself and he looted gold from several places for this. He even looted his own people, by using the following unfair strategy:
There are N ho... | {"inputs": ["4\n3 2 1 4\n2\n0\n2"], "outputs": ["10\n3"]} | 736 | 29 |
coding | Solve the programming task below in a Python markdown code block.
Squid loves painting vertices in graphs.
There is a simple undirected graph consisting of N vertices numbered 1 through N, and M edges. Initially, all the vertices are painted in color 0. The i-th edge bidirectionally connects two vertices a_i and b_i. ... | {"inputs": ["7 7\n1 2\n1 3\n1 4\n4 5\n5 6\n5 7\n2 3\n2\n6 0 1\n1 2 2", "7 7\n1 2\n1 3\n1 4\n4 5\n5 3\n5 7\n2 3\n2\n6 0 1\n1 2 1", "7 7\n1 2\n1 3\n1 4\n4 6\n5 6\n5 7\n2 3\n2\n6 0 1\n1 2 2", "7 7\n1 2\n1 3\n1 3\n4 5\n5 3\n5 7\n2 3\n2\n6 0 1\n1 2 1", "7 7\n1 1\n2 3\n1 4\n4 5\n5 5\n5 7\n2 3\n2\n6 1 1\n1 2 2", "7 7\n1 2\n1 ... | 499 | 651 |
coding | Solve the programming task below in a Python markdown code block.
Consider the infinite x$x$ axis. There are N$N$ impacts on this X-axis at integral points (X1$X_1$,X2$X_2$,....XN$X_N$) (all distinct) . An impact at a point X$X$i propagates such that at a point X$X$0, the effect of the impact is K|Xi−X0|$K^{|X_i - X_0... | {"inputs": ["2\n4 3 10 10\n2 3 10 10"], "outputs": ["no\nyes"]} | 441 | 34 |
coding | Solve the programming task below in a Python markdown code block.
Little walrus Fangy loves math very much. That's why when he is bored he plays with a number performing some operations.
Fangy takes some positive integer x and wants to get a number one from it. While x is not equal to 1, Fangy repeats the following ac... | {"inputs": ["1\n", "11\n", "101010\n", "111010\n", "111110\n", "110010\n", "110011\n", "111011\n"], "outputs": ["0\n", "3\n", "9\n", "8\n", "7\n", "9\n", "9\n", "8\n"]} | 334 | 101 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given two 0-indexed binary strings s and target of the same length n. You can do the following operation on s any number of times:
Choose two different indices i and j where 0 <= i, j < n.
Simultaneously, rep... | {"functional": "def check(candidate):\n assert candidate(s = \"1010\", target = \"0110\") == True\n assert candidate(s = \"11\", target = \"00\") == False\n\n\ncheck(Solution().makeStringsEqual)"} | 240 | 60 |
coding | Solve the programming task below in a Python markdown code block.
In order to win over and get noticed by his favorite streamer Daenerys, Jon decides to donate a significant amount of money . Every donation made to Daenerys is of $at$ $least$ $1$ $beastcoin$ and is displayed on Daenerys's stream alongside any message w... | {"inputs": ["2\n3\n7"], "outputs": ["4\n8"]} | 436 | 18 |
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 sum of every tree node's tilt.
The tilt of a tree node is the absolute difference between the sum of all left subtree node values and all right subtree node values. If a nod... | {"functional": "def check(candidate):\n assert candidate(root = tree_node([1,2,3])) == 1\n assert candidate(root = tree_node([4,2,9,3,5,None,7])) == 15\n assert candidate(root = tree_node([21,7,14,1,1,2,2,3,3])) == 9\n\n\ncheck(Solution().findTilt)"} | 184 | 96 |
coding | Solve the programming task below in a Python markdown code block.
The goal of this Kata is to return the greatest distance of index positions between matching number values in an array or 0 if there are no matching values.
Example:
In an array with the values [0, 2, 1, 2, 4, 1] the greatest index distance is between... | {"functional": "_inputs = [[[9, 7, 1, 2, 3, 7, 0, -1, -2]], [[0, 7, 0, 2, 3, 7, 0, -1, -2]], [[1, 2, 3, 4]]]\n_outputs = [[4], [6], [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, (l... | 236 | 224 |
coding | Solve the programming task below in a Python markdown code block.
You are given two integers N \ ( N ≥ 2) and S. You have to construct an array A containing N integers such that:
0 ≤ A_{i} ≤ S for each 1 ≤ i ≤ N
A_{1} + A_{2} + \ldots + A_{N} = S
A_{1} \mathbin{\&} A_{2} \mathbin{\&} \ldots \mathbin{\&} A_{N} = 0, wher... | {"inputs": ["4\n2 7\n3 6\n5 21\n100 256455\n"], "outputs": ["4\n3\n5\n2570\n"]} | 497 | 47 |
coding | Solve the programming task below in a Python markdown code block.
Allen is hosting a formal dinner party. 2n people come to the event in n pairs (couples). After a night of fun, Allen wants to line everyone up for a final picture. The 2n people line up, but Allen doesn't like the ordering. Allen prefers if each pair oc... | {"inputs": ["1\n1 1\n", "2\n1 2 1 2\n", "2\n2 1 1 2\n", "2\n1 1 2 2\n", "2\n2 1 2 1\n", "2\n2 2 1 1\n", "2\n1 2 2 1\n", "3\n1 2 3 3 1 2\n"], "outputs": ["0", "1", "2", "0\n", "1\n", "0\n", "2\n", "5"]} | 446 | 130 |
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.
You are given a sequence $A_{1}, A_{2}, \ldots, A_{N}$. You may perform the following operation any number of times: select any two adjacent elements... | {"inputs": ["4\n2\n7 4\n3\n1 2 2\n5\n5 5 5 5 5\n8\n7 2 4 1 6 8 3 9"], "outputs": ["No\nYes\nNo\nYes"]} | 667 | 62 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given a m x n binary matrix mat. In one step, you can choose one cell and flip it and all the four neighbors of it if they exist (Flip is changing 1 to 0 and 0 to 1). A pair of cells are called neighbors if they share... | {"functional": "def check(candidate):\n assert candidate(mat = [[0,0],[0,1]]) == 3\n assert candidate(mat = [[0]]) == 0\n assert candidate(mat = [[1,0,0],[1,0,0]]) == -1\n\n\ncheck(Solution().minFlips)"} | 163 | 72 |
coding | Solve the programming task below in a Python markdown code block.
Vitaly is a very weird man. He's got two favorite digits a and b. Vitaly calls a positive integer good, if the decimal representation of this integer only contains digits a and b. Vitaly calls a good number excellent, if the sum of its digits is a good n... | {"inputs": ["1 3 3\n", "7 8 2\n", "6 9 1\n", "6 9 1\n", "7 8 2\n", "7 8 1\n", "3 8 2\n", "1 4 3\n"], "outputs": ["1\n", "0\n", "2\n", "2\n", "0\n", "2\n", "0\n", "0\n"]} | 302 | 102 |
coding | Solve the programming task below in a Python markdown code block.
------Read problems statements in Hindi,
Mandarin chinese
, Russian and Vietnamese as well. ------
During Eid, it's a tradition that each father gives his kids money which they can spend on entertainment.
Chef has $N$ coins; let's denote the value of ... | {"inputs": ["2\n3\n1 4 2\n3\n1 3 3"], "outputs": ["1\n0"]} | 499 | 30 |
coding | Solve the programming task below in a Python markdown code block.
Problem statement
JOI decided to start a new social game from tomorrow.
In this social game, you can log in up to once a day, and you will get A coins each time you log in.
Also, if you log in for 7 consecutive days from Monday to Sunday, you will get... | {"inputs": ["4 0 2", "0 1 3", "3 0 19", "2 0 19", "4 0 19", "8 0 22", "6 0 43", "2 0 31"], "outputs": ["1\n", "21\n", "7\n", "10\n", "5\n", "3\n", "8\n", "16\n"]} | 536 | 103 |
coding | Solve the programming task below in a Python markdown code block.
There is a very long bench. The bench is divided into M sections, where M is a very large integer.
Initially, the bench is vacant. Then, M people come to the bench one by one, and perform the following action:
* We call a section comfortable if the sec... | {"inputs": ["1\nX", "3\n---", "5\n-X--X", "5\n-X-X-", "5\nX-X--", "5\n-XX--", "5\n---XX", "5\n--XX-"], "outputs": ["500000004 0 500000003", "0 0 0", "0 0 1\n", "500000004 0 500000002\n", "0 0 666666672\n", "0 0 0\n", "0 0 0\n", "0 0 0\n"]} | 632 | 158 |
coding | Solve the programming task below in a Python markdown code block.
JJ gives you a number N and challenges you to construct a permutation P of length N such that:
|P_{i + 1} - P_{i}| ≥ 2 for all 1 ≤ i ≤ N - 1 (Here |x| denotes the absolute value of x)
Can you complete JJ's challenge?
As a reminder, a permutation of len... | {"inputs": ["2\n2\n6\n"], "outputs": ["-1\n1 4 2 5 3 6\n"]} | 393 | 31 |
coding | Solve the programming task below in a Python markdown code block.
Chef is fan of pairs and he likes all things that come in pairs. He even has a doll collection in which the dolls come in pairs. One day while going through his collection he found that there are odd number of dolls. Someone had stolen a doll!!!
Help c... | {"inputs": ["1\n3\n1 \n2\n1", "1\n3\n2 \n2\n1", "1\n3\n0 \n2\n0", "1\n3\n1 \n4\n1", "1\n3\n1 \n8\n1", "1\n1\n7 \n6\n1", "1\n3\n2 \n1\n1", "1\n3\n0 \n1\n0"], "outputs": ["2", "1\n", "2\n", "4\n", "8\n", "7\n", "2\n", "1\n"]} | 258 | 133 |
coding | Solve the programming task below in a Python markdown code block.
The king's birthday dinner was attended by $k$ guests. The dinner was quite a success: every person has eaten several dishes (though the number of dishes was the same for every person) and every dish was served alongside with a new set of kitchen utensil... | {"inputs": ["1 1\n9\n", "1 2\n7\n", "1 1\n7\n", "1 2\n1\n", "1 1\n14\n", "1 1\n14\n", "5 2\n1 2 2 1 3\n", "5 2\n1 2 2 1 3\n"], "outputs": ["0\n", "1\n", "0\n", "1\n", "0\n", "0\n", "1\n", "1\n"]} | 613 | 120 |
coding | Solve the programming task below in a Python markdown code block.
Tracy loves Donuts. She purchased a lots of Donuts for her birthday party. She learnt to calculate the area of the circle a few days back and she is fascinated to know the area of the donuts as well !! Help her finding the area of the Donuts…..
-----Inp... | {"inputs": ["2\n5\n12"], "outputs": ["78.5\n452.16"]} | 179 | 27 |
coding | Solve the programming task below in a Python markdown code block.
Professor GukiZ is concerned about making his way to school, because massive piles of boxes are blocking his way.
In total there are n piles of boxes, arranged in a line, from left to right, i-th pile (1 ≤ i ≤ n) containing ai boxes. Luckily, m student... | {"inputs": ["1 1\n1\n", "1 1\n2\n", "1 1\n3\n", "2 1\n2 1\n", "2 1\n1 1\n", "3 2\n1 0 4\n", "3 2\n1 0 3\n", "3 2\n1 0 2\n"], "outputs": [" 2", "3\n", "4\n", "5\n", " 4", "6\n", "5\n", " ... | 617 | 121 |
coding | Solve the programming task below in a Python markdown code block.
Squirrel Liss loves nuts. There are n trees (numbered 1 to n from west to east) along a street and there is a delicious nut on the top of each tree. The height of the tree i is h_{i}. Liss wants to eat all nuts.
Now Liss is on the root of the tree with ... | {"inputs": ["1\n1\n", "1\n1\n", "1\n2\n", "1\n3\n", "1\n4\n", "1\n6\n", "1\n5\n", "1\n8\n"], "outputs": ["2\n", "2\n", "3\n", "4\n", "5\n", "7\n", "6\n", "9\n"]} | 336 | 86 |
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.
Initially, there is a number n on the chalkboard. On each player's turn, that player makes a move consisting of:
Choosing any x with 0 < x < n and n... | {"functional": "def check(candidate):\n assert candidate(n = 2) == True\n assert candidate(n = 3) == False\n\n\ncheck(Solution().divisorGame)"} | 151 | 42 |
coding | Solve the programming task below in a Python markdown code block.
You are given a positive integer $x$. Check whether the number $x$ is representable as the sum of the cubes of two positive integers.
Formally, you need to check if there are two integers $a$ and $b$ ($1 \le a, b$) such that $a^3+b^3=x$.
For example, i... | {"inputs": ["1\n999999999999\n", "1\n999999999999\n", "1\n1000000000000\n", "1\n1000000000000\n", "2\n405527623378\n5204291237\n", "2\n620475187705\n5204291237\n", "2\n620475187705\n5369629849\n", "2\n392481106372\n5369629849\n"], "outputs": ["NO\n", "NO\n", "NO\n", "NO\n", "NO\nNO\n", "NO\nNO\n", "NO\nNO\n", "NO\nNO\n... | 521 | 228 |
coding | Solve the programming task below in a Python markdown code block.
Snuke has a rooted tree with N+1 vertices.
The vertices are numbered 0 through N, and Vertex 0 is the root of the tree.
The parent of Vertex i (1 \leq i \leq N) is Vertex p_i.
Besides this tree, Snuke also has an box which is initially empty and many mar... | {"inputs": ["2\n0 1", "2\n0 0", "2\n0 0\n", "5\n0 1 1 0 3", "5\n0 1 1 1 4", "5\n0 1 0 0 4", "5\n0 1 4 0 4", "5\n0 1 1 0 4"], "outputs": ["12\n", "8", "8\n", "128\n", "120\n", "88\n", "96\n", "96"]} | 412 | 131 |
coding | Solve the programming task below in a Python markdown code block.
In all schools in Buryatia, in the $1$ class, everyone is told the theory of Fibonacci strings.
"A block is a subsegment of a string where all the letters are the same and are bounded on the left and right by the ends of the string or by letters other t... | {"inputs": ["6\n1\n1\n2\n1 1\n2\n1 2\n3\n3 1 3\n2\n7 5\n6\n26 8 3 4 13 34\n"], "outputs": ["YES\nYES\nNO\nYES\nNO\nYES\n"]} | 725 | 71 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given a positive integer n, find the smallest integer which has exactly the same digits existing in the integer n and is greater in value than n. If no such positive integer exists, return -1.
Note that the returned i... | {"functional": "def check(candidate):\n assert candidate(n = 12) == 21\n assert candidate(n = 21) == -1\n\n\ncheck(Solution().nextGreaterElement)"} | 124 | 47 |
coding | Solve the programming task below in a Python markdown code block.
A sequence of positive integers is called great for a positive integer $x$, if we can split it into pairs in such a way that in each pair the first number multiplied by $x$ is equal to the second number. More formally, a sequence $a$ of size $n$ is great... | {"inputs": ["1\n2 42951\n100000 132704\n", "1\n2 8\n600349032 507824960\n", "1\n2 50000\n90000 205032704\n", "1\n2 70000\n70000 605032704\n", "1\n2 800000\n800000 49872896\n", "1\n2 5\n705032704 1000000000\n", "1\n2 444\n902178848 98765432\n", "1\n2 500\n10000000 705032704\n"], "outputs": ["2\n", "2\n", "2\n", "2\n", "... | 630 | 264 |
coding | Solve the programming task below in a Python markdown code block.
Given an array of ints, return the index such that the sum of the elements to the right of that index equals the sum of the elements to the left of that index. If there is no such index, return `-1`. If there is more than one such index, return the left-... | {"functional": "_inputs = [[[1, 2, 3, 5, 3, 2, 1]], [[1, 12, 3, 3, 6, 3, 1]], [[10, 20, 30, 40]]]\n_outputs = [[3], [2], [-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 if isinstance(a, (list, tuple... | 274 | 216 |
coding | Solve the programming task below in a Python markdown code block.
Cengiz recently learned Fibonacci numbers and now he is studying different algorithms to find them. After getting bored of reading them, he came with his own new type of numbers that he named XORinacci numbers. He defined them as follows: $f(0) = a$; ... | {"inputs": ["1\n1 2 3\n", "1\n1 2 3\n", "1\n1 3 3\n", "1\n1 3 4\n", "1\n1 0 4\n", "1\n6 3 5\n", "1\n1 3 6\n", "1\n1 0 7\n"], "outputs": ["1\n", "1\n", "1\n", "3\n", "0\n", "5\n", "1\n", "0\n"]} | 335 | 118 |
coding | Solve the programming task below in a Python markdown code block.
You are given a chessboard of size 1 × n. It is guaranteed that n is even. The chessboard is painted like this: "BWBW...BW".
Some cells of the board are occupied by the chess pieces. Each cell contains no more than one chess piece. It is known that the ... | {"inputs": ["2\n2\n", "2\n2\n", "2\n1\n", "6\n1 2 6\n", "6\n1 5 6\n", "6\n1 4 5\n", "6\n3 5 6\n", "6\n3 4 5\n"], "outputs": ["0\n", "0\n", "0\n", "2\n", "2\n", "1\n", "2\n", "2\n"]} | 465 | 106 |
coding | Solve the programming task below in a Python markdown code block.
We have a deck consisting of N cards. Each card has an integer written on it. The integer on the i-th card from the top is a_i.
Two people X and Y will play a game using this deck. Initially, X has a card with Z written on it in his hand, and Y has a car... | {"inputs": ["5 1 1\n1 1 1 1 1\n", "1 1 1\n1000000000\n", "3 100 100\n10 1000 100\n", "3 100 1000\n10 100 100\n"], "outputs": ["0\n", "999999999\n", "900\n", "900\n"]} | 366 | 119 |
coding | Solve the programming task below in a Python markdown code block.
```if:python,php
In this kata you will have to write a function that takes `litres` and `price_per_litre` as arguments. Purchases of 2 or more litres get a discount of 5 cents per litre, purchases of 4 or more litres get a discount of 10 cents per litre,... | {"functional": "_inputs = [[10, 21.5], [40, 10], [15, 5.83]]\n_outputs = [[212.5], [390], [83.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 if isinstance(a, (list, tuple)):\n if len(a) != len... | 315 | 195 |
coding | Solve the programming task below in a Python markdown code block.
A remote island chain contains n islands, labeled 1 through n. Bidirectional bridges connect the islands to form a simple cycle — a bridge connects islands 1 and 2, islands 2 and 3, and so on, and additionally a bridge connects islands n and 1. The cente... | {"inputs": ["2\n1 0\n0 1\n", "2\n0 1\n0 1\n", "2\n1 0\n1 0\n", "2\n1 0\n1 0\n", "2\n0 1\n0 1\n", "2\n1 0\n0 1\n", "3\n1 0 2\n2 0 1\n", "3\n0 2 1\n1 2 0\n"], "outputs": ["YES\n", "YES\n", "YES\n", "YES", "YES", "YES", "YES\n", "YES\n"]} | 539 | 139 |
coding | Solve the programming task below in a Python markdown code block.
Because my other two parts of the serie were pretty well received I decided to do another part.
Puzzle Tiles
You will get two Integer n (width) and m (height) and your task is to draw following pattern. Each line is seperated with '\n'.
Both integers... | {"functional": "_inputs = [[1, 1], [3, 2]]\n_outputs = [[' _( )__\\n _| _|\\n(_ _ (_\\n |__( )_|'], [' _( )__ _( )__ _( )__\\n _| _| _| _|\\n(_ _ (_ _ (_ _ (_\\n |__( )_|__( )_|__( )_|\\n |_ |_ |_ |_\\n _) _ _) _ _) _ _)\\n |__( )_|__( )_|__( )_|']]\nimport math\ndef _deep... | 395 | 263 |
coding | Solve the programming task below in a Python markdown code block.
Chef played an interesting game yesterday. This game is played with two variables $X$ and $Y$; initially, $X = Y = 0$. Chef may make an arbitrary number of moves (including zero). In each move, he must perform the following process:
- Choose any positive... | {"inputs": ["3\n3\n8\n9"], "outputs": ["3\n5\n6"]} | 342 | 22 |
coding | Solve the programming task below in a Python markdown code block.
Algorithmic predicament - Bug Fixing #9
Oh no! Timmy's algorithim has gone wrong! help Timmy fix his algorithim!
Task
Your task is to fix timmy's algorithim so it returns the group name with the highest total age.
You will receive two groups of `peo... | {"functional": "_inputs = [[[{'name': 'kay', 'age': 1}, {'name': 'john', 'age': 13}, {'name': 'kay', 'age': 76}], [{'name': 'john', 'age': 1}, {'name': 'alice', 'age': 77}]], [[{'name': 'kay', 'age': 1}, {'name': 'john', 'age': 13}, {'name': 'kay', 'age': 76}], [{'name': 'john', 'age': 1}, {'name': 'alice', 'age': 76}]... | 179 | 506 |
coding | Solve the programming task below in a Python markdown code block.
In this Kata you need to write the method SharedBits that returns true if 2 integers share at least two '1' bits. For simplicity assume that all numbers are positive
For example
int seven = 7; //0111
int ten = 10; //1010
int fifteen = 15; //1111
... | {"functional": "_inputs = [[1, 2], [16, 8], [1, 1], [2, 3], [7, 10], [43, 77], [7, 15], [23, 7]]\n_outputs = [[False], [False], [False], [False], [False], [True], [True], [True]]\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=... | 224 | 226 |
coding | Solve the programming task below in a Python markdown code block.
With the college fest approaching soon, Manasa is following a strict dieting regime . Today, she just cannot resist her temptation for having a pizza. An inner conflict ensues, and she decides that she will have a pizza, only if she comes up with a solut... | {"inputs": ["3\n1 2 3\n"], "outputs": ["40392\n"]} | 496 | 24 |
coding | Solve the programming task below in a Python markdown code block.
In the advanced algorithm class, n2 students sit in n rows and n columns. One day, a professor who teaches this subject comes into the class, asks the shortest student in each row to lift up his left hand, and the tallest student in each column to lift u... | {"inputs": ["3\n1 2 3\n4 5 6\n7 5 9\n3\n1 2 3\n1 8 9\n4 5 6\n0", "3\n0 2 3\n4 5 7\n7 1 9\n3\n0 2 3\n7 8 6\n1 5 6\n0", "3\n1 1 3\n0 2 6\n7 9 9\n3\n1 4 3\n7 8 9\n4 8 6\n0", "3\n2 2 3\n4 4 6\n7 4 9\n3\n1 4 3\n7 8 9\n4 8 6\n0", "3\n1 2 3\n4 5 6\n7 8 9\n3\n1 2 3\n7 8 9\n4 5 6\n0", "3\n1 2 3\n4 5 6\n7 10 9\n3\n1 2 3\n7 8 9\n... | 311 | 400 |
coding | Solve the programming task below in a Python markdown code block.
A string is binary, if it consists only of characters "0" and "1".
String v is a substring of string w if it has a non-zero length and can be read starting from some position in string w. For example, string "010" has six substrings: "0", "1", "0", "01"... | {"inputs": ["1\n0\n", "2\n1\n", "1\n1\n", "0\n1\n", "2\n0\n", "0\n0\n", "0\n00\n", "1\n00\n"], "outputs": ["0\n", "0\n", "1\n", "0\n", "0\n", "1\n", "3\n", "0\n"]} | 376 | 88 |
coding | Solve the programming task below in a Python markdown code block.
In an attempt to control the rise in population, Archer was asked to come up with a plan. This time he is targeting marriages. Archer, being as intelligent as he is, came up with the following plan:
A man with name M is allowed to marry a woman with nam... | {"inputs": ["3\njohn johanna\nira ira\nkayla jayla", "3\njohn johanna\nira ria\nkayla jayla", "3\njohn johanna\nria ria\nkayla jayla", "3\njogn johanna\nria qia\nkayma jayla", "3\nipoh o`gomka\nbjr bjr\njmya` aayjk", "3\njohn johanna\nria ria\nkayma jayla", "3\njohn johanna\nria qia\nkayma jayla", "3\nngoj johanna\nria... | 517 | 227 |
coding | Solve the programming task below in a Python markdown code block.
Rock... Paper!
After Karen have found the deterministic winning (losing?) strategy for rock-paper-scissors, her brother, Koyomi, comes up with a new game as a substitute. The game works as follows.
A positive integer n is decided first. Both Koyomi and... | {"inputs": ["1\n2\n3\n", "1\n1\n3\n", "1\n6\n7\n", "1\n1\n3\n", "1\n2\n3\n", "1\n6\n7\n", "1\n1\n4\n", "1\n8\n7\n"], "outputs": ["Karen\n", "Karen\n", "Karen\n", "Karen\n", "Karen\n", "Karen\n", "Karen\n", "Karen\n"]} | 619 | 102 |
coding | Solve the programming task below in a Python markdown code block.
Write function bmi that calculates body mass index (bmi = weight / height ^ 2).
if bmi <= 18.5 return "Underweight"
if bmi <= 25.0 return "Normal"
if bmi <= 30.0 return "Overweight"
if bmi > 30 return "Obese"
Also feel free to reuse/extend the follo... | {"functional": "_inputs = [[50, 1.8], [80, 1.8], [90, 1.8], [110, 1.8], [50, 1.5]]\n_outputs = [['Underweight'], ['Normal'], ['Overweight'], ['Obese'], ['Normal']]\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=to... | 103 | 212 |
coding | Solve the programming task below in a Python markdown code block.
Given are two strings s and t consisting of lowercase English letters. Determine if there exists an integer i satisfying the following condition, and find the minimum such i if it exists.
- Let s' be the concatenation of 10^{100} copies of s. t is a sub... | {"inputs": ["d\nd\n", "j\nw\n", "zv\nz\n", "jh\nh\n", "l\nll\n", "s\nsv\n", "csnteot\nson", "vtaletn\ntnn"], "outputs": ["1\n", "-1\n", "1\n", "2\n", "2\n", "-1\n", "10\n", "14\n"]} | 365 | 93 |
coding | Solve the programming task below in a Python markdown code block.
Read problem statements in [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
You are given an integer N and a digit D. Find the minimum non-negetive integer you should add to N such that the final value of N does not contain the digit ... | {"inputs": ["5\n21 5\n8 8\n100 0\n5925 9\n434356 3\n"], "outputs": ["0\n1\n11\n75\n5644\n"]} | 467 | 58 |
coding | Solve the programming task below in a Python markdown code block.
The chef is playing a game of long distance. Chef has a number K and he wants to find the longest distance between the index of the first and the last occurrence of K in a given array of N numbers.
-----Input:-----
- First-line will contain $T$, the num... | {"inputs": ["2\n2 6\n2 3 4 2 1 6\n4 6\n2 3 4 2 1 6"], "outputs": ["3\n0"]} | 318 | 46 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
In a garden represented as an infinite 2D grid, there is an apple tree planted at every integer coordinate. The apple tree planted at an integer coordinate (i, j) has |i| + |j| apples growing on it.
You will buy an ax... | {"functional": "def check(candidate):\n assert candidate(neededApples = 1) == 8\n assert candidate(neededApples = 13) == 16\n assert candidate(neededApples = 1000000000) == 5040\n\n\ncheck(Solution().minimumPerimeter)"} | 175 | 79 |
coding | Solve the programming task below in a Python markdown code block.
Little town Nsk consists of n junctions connected by m bidirectional roads. Each road connects two distinct junctions and no two roads connect the same pair of junctions. It is possible to get from any junction to any other junction by these roads. The d... | {"inputs": ["2 1 2 1\n1 2\n", "2 1 2 1\n1 2\n", "2 1 2 2\n1 2\n", "2 1 1 2\n1 2\n", "3 2 2 3\n1 2\n2 3\n", "3 2 1 3\n1 2\n2 3\n", "3 2 2 3\n1 2\n2 3\n", "3 2 1 3\n1 2\n2 3\n"], "outputs": ["0\n", "0\n", "0\n", "0\n", "1\n", "0\n", "1\n", "0\n"]} | 527 | 166 |
coding | Solve the programming task below in a Python markdown code block.
You are given the array $a$ consisting of $n$ positive (greater than zero) integers.
In one move, you can choose two indices $i$ and $j$ ($i \ne j$) such that the absolute difference between $a_i$ and $a_j$ is no more than one ($|a_i - a_j| \le 1$) and ... | {"inputs": ["1\n1\n23\n", "1\n1\n46\n", "1\n1\n114\n", "1\n1\n157\n", "1\n1\n305\n", "1\n1\n292\n", "1\n1\n430\n", "2\n3\n1 2 2\n4\n5 5 5 5\n"], "outputs": ["YES\n", "YES\n", "YES\n", "YES\n", "YES\n", "YES\n", "YES\n", "YES\nYES\n"]} | 544 | 130 |
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, return the kth largest element in the array.
Note that it is the kth largest element in the sorted order, not the kth distinct element.
Can you solve it without sorting?
... | {"functional": "def check(candidate):\n assert candidate(nums = [3,2,1,5,6,4], k = 2) == 5\n assert candidate(nums = [3,2,3,1,2,4,5,5,6], k = 4) == 4\n\n\ncheck(Solution().findKthLargest)"} | 103 | 82 |
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 of length n and an integer k. In an operation, you can choose an element and multiply it by 2.
Return the maximum possible value of nums[0] | nums[1] | ... | nums[n - 1] th... | {"functional": "def check(candidate):\n assert candidate(nums = [12,9], k = 1) == 30\n assert candidate(nums = [8,1,2], k = 2) == 35\n\n\ncheck(Solution().maximumOr)"} | 142 | 62 |
coding | Solve the programming task below in a Python markdown code block.
Erelong Leha was bored by calculating of the greatest common divisor of two factorials. Therefore he decided to solve some crosswords. It's well known that it is a very interesting occupation though it can be very difficult from time to time. In the cour... | {"inputs": ["1 1\na\na\n", "1 1\na\nz\n", "1 1\nz\nz\n", "1 1\na\nz\n", "1 1\nz\nz\n", "1 1\na\na\n", "1 1\n{\nz\n", "1 1\n|\nz\n"], "outputs": ["0\n\n", "1\n1 \n", "0\n\n", "1\n1 \n", "0\n\n", "0\n\n", "1\n1\n", "1\n1\n"]} | 449 | 130 |
coding | Solve the programming task below in a Python markdown code block.
There are N cities in Republic of AtCoder. The size of the i-th city is A_{i}. Takahashi would like to build N-1 bidirectional roads connecting two cities so that any city can be reached from any other city by using these roads.
Assume that the cost of ... | {"inputs": ["3 1\n2 100 1", "3 1\n0 100 1", "3 2\n1 100 1", "3 1\n0 101 1", "3 4\n1 100 1", "3 1\n4 110 1", "3 1\n1 100 1", "3 1000\n1 101 1"], "outputs": ["107\n", "104\n", "109\n", "105\n", "115\n", "119\n", "106", "2204\n"]} | 344 | 161 |
coding | Solve the programming task below in a Python markdown code block.
Consider a sequence, which is formed by the following rule: next term is taken as the smallest possible non-negative integer, which is not yet in the sequence, so that `no 3` terms of sequence form an arithmetic progression.
## Example
`f(0) = 0` -- sm... | {"functional": "_inputs = [[0], [1], [2], [3], [4], [5], [334], [123], [546], [1634], [14514]]\n_outputs = [[0], [1], [3], [4], [9], [10], [7329], [1084], [19929], [79707], [2305425]]\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... | 338 | 247 |
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.
A tuple $(a, b, c)$ is considered good if it consists of three prime numbers $a$, $b$ and $c$ such that $a < b < c ≤ N$ and $a + b = c$.
Two tuples... | {"inputs": ["2\n3\n6"], "outputs": ["0\n1"]} | 352 | 18 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given an array of strings words representing an English Dictionary, return the longest word in words that can be built one character at a time by other words in words.
If there is more than one possible answer, return... | {"functional": "def check(candidate):\n assert candidate(words = [\"w\",\"wo\",\"wor\",\"worl\", \"world\"]) == \"world\"\n assert candidate(words = [\"a\", \"banana\", \"app\", \"appl\", \"ap\", \"apply\", \"apple\"]) == \"apple\"\n\n\ncheck(Solution().longestWord)"} | 138 | 78 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given a 0-indexed integer 2D array nodes, your task is to determine if the given array represents the preorder traversal of some binary tree.
For each index i, nodes[i] = [id, parentId], where id is the id of the node... | {"functional": "def check(candidate):\n assert candidate(nodes = [[0,-1],[1,0],[2,0],[3,2],[4,2]]) == True\n assert candidate(nodes = [[0,-1],[1,0],[2,0],[3,1],[4,1]]) == False\n\n\ncheck(Solution().isPreorder)"} | 197 | 78 |
coding | Solve the programming task below in a Python markdown code block.
Read problems statements in Mandarin Chinese, Russian and Vietnamese as well.
Chef cooks nice receipes in the cafeteria of his company. The cafe contains N boxes with food enumerated from 1 to N and are placed in a circle in clocwise order (boxes 1 and... | {"inputs": ["3\n4\n1 1 1 1\n4\n3 0 0 0\n4\n0 0 0 2"], "outputs": ["4\n1\n2"]} | 602 | 46 |
coding | Solve the programming task below in a Python markdown code block.
One beautiful July morning a terrible thing happened in Mainframe: a mean virus Megabyte somehow got access to the memory of his not less mean sister Hexadecimal. He loaded there a huge amount of n different natural numbers from 1 to n to obtain total co... | {"inputs": ["1\n", "2\n", "7\n", "9\n", "3\n", "4\n", "6\n", "8\n"], "outputs": ["1\n", "1\n", "1\n", "1\n", "1\n", "1\n", "1\n", "1\n"]} | 201 | 70 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
There are n persons on a social media website. You are given an integer array ages where ages[i] is the age of the ith person.
A Person x will not send a friend request to a person y (x != y) if any of the following c... | {"functional": "def check(candidate):\n assert candidate(ages = [16,16]) == 2\n assert candidate(ages = [16,17,18]) == 2\n assert candidate(ages = [20,30,100,110,120]) == 3\n\n\ncheck(Solution().numFriendRequests)"} | 200 | 86 |
coding | Solve the programming task below in a Python markdown code block.
You have full control over a robot that walks around in a rectangular field paved with square tiles like a chessboard. There are m columns of tiles from west to east, and n rows of tiles from south to north (1 <= m, n <= 100). Each tile is given a pair o... | {"inputs": ["6 5\nFORWARD 3\nRIGHT\nFORWARD 5\nLEFT\nBACKWARD 2\nSTOP\n5 1\nFORWARD 2\nSTOP\n0 0", "6 5\nFORWARD 3\nRIGHT\nFORWARD 5\nLEFT\nBACKWARD 3\nSTOP\n3 1\nFORWARD 2\nSTOP\n0 0", "6 6\nFORDARW 1\nRIGHT\nFORWARD 5\nLEFT\nBACKWARD 3\nSTOP\n3 2\nFORWARD 2\nSTOP\n0 0", "1 2\nFORDARW 3\nRIGHT\nFORWARD 5\nLEFT\nBACKWA... | 612 | 425 |
coding | Solve the programming task below in a Python markdown code block.
Mike decided to teach programming to children in an elementary school. He knows that it is not an easy task to interest children in that age to code. That is why he decided to give each child two sweets.
Mike has $n$ sweets with sizes $a_1, a_2, \ldots,... | {"inputs": ["2\n2 1\n", "2\n2 1\n", "2\n3 1\n", "2\n3 2\n", "2\n5 2\n", "2\n7 2\n", "2\n4 1\n", "2\n1 2\n"], "outputs": ["1\n", "1\n", "1\n", "1\n", "1\n", "1\n", "1\n", "1\n"]} | 616 | 102 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given two 0-indexed integer arrays nums1 and nums2, each of length n, and a 1-indexed 2D array queries where queries[i] = [xi, yi].
For the ith query, find the maximum value of nums1[j] + nums2[j] among all in... | {"functional": "def check(candidate):\n assert candidate(nums1 = [4,3,1,2], nums2 = [2,4,9,5], queries = [[4,1],[1,3],[2,5]]) == [6,10,7]\n assert candidate(nums1 = [3,2,5], nums2 = [2,3,4], queries = [[4,4],[3,2],[1,1]]) == [9,9,9]\n assert candidate(nums1 = [2,1], nums2 = [2,3], queries = [[3,3]]) == [-1]\n\... | 178 | 150 |
coding | Solve the programming task below in a Python markdown code block.
You are given a sequence of integers $A_1, A_2, \ldots, A_N$. This sequence is circular ― for each valid $i$, the element $A_{i+1}$ follows after $A_i$, and the element $A_1$ follows after $A_N$.
You may insert any positive integers at any positions you ... | {"inputs": ["1\n5\n3 6 4 5 9"], "outputs": ["3 1 1 0"]} | 539 | 30 |
coding | Solve the programming task below in a Python markdown code block.
MoEngage goes shopping with Chef. There are N ingredients placed on a line, numbered 1 to N from left to right.
At any point in time, MoEngage can choose the ingredient numbered x and do one of the following operations:
If the chosen ingredient is not t... | {"inputs": ["3\n1\n3\n4\n4\n2 1 3 2\n4 2 4 3\n7\n3 10 5 2 8 3 9\n8 6 11 5 9 13 7\n"], "outputs": ["0\n5\n32\n"]} | 759 | 76 |
coding | Solve the programming task below in a Python markdown code block.
From "ftying rats" to urban saniwation workers - can synthetic biology tronsform how we think of pigeons?
The upiquitous pigeon has long been viewed as vermin - spleading disease, scavenging through trush, and defecating in populous urban spases. Yet t... | {"inputs": ["5\n1 2 3 4 5\n", "5\n1 2 3 7 5\n", "5\n1 2 3 4 5\n", "5\n0 2 3 14 5\n", "5\n1 2 3 14 5\n", "5\n27 30 8 6 3\n", "5\n27 60 8 6 3\n", "5\n27 30 8 32 3\n"], "outputs": ["4\n", "4\n", "4\n", "5\n", "4\n", "13\n", "13\n", "13\n"]} | 352 | 162 |
coding | Solve the programming task below in a Python markdown code block.
There is a game called "I Wanna Be the Guy", consisting of n levels. Little X and his friend Little Y are addicted to the game. Each of them wants to pass the whole game.
Little X can pass only p levels of the game. And Little Y can pass only q levels o... | {"inputs": ["1\n0\n0\n", "1\n0\n0\n", "1\n0\n1 1\n", "1\n1 1\n0\n", "100\n0\n0\n", "1\n0\n1 1\n", "1\n1 1\n0\n", "100\n0\n0\n"], "outputs": ["Oh, my keyboard!\n", "Oh, my keyboard!\n", "I become the guy.\n", "I become the guy.\n", "Oh, my keyboard!\n", "I become the guy.\n", "I become the guy.\n", "Oh, my keyboard!\n"]... | 363 | 146 |
coding | Solve the programming task below in a Python markdown code block.
You've got a rectangular parallelepiped with integer edge lengths. You know the areas of its three faces that have a common vertex. Your task is to find the sum of lengths of all 12 edges of this parallelepiped.
Input
The first and the single line cont... | {"inputs": ["9 9 9\n", "1 9 9\n", "4 2 2\n", "2 1 2\n", "4 4 4\n", "8 4 2\n", "6 1 6\n", "2 2 1\n"], "outputs": ["36", "44\n", "20\n", "16\n", "24\n", "28\n", "32\n", "16\n"]} | 204 | 109 |
coding | Solve the programming task below in a Python markdown code block.
You are given an array A consisting of N integers.
In one operation, you can:
Choose any two indices i and j (i \neq j);
Subtract min(A_{i} , A_{j}) from both A_{i} and A_{j}. Note that min(A_{i} , A_{j}) denotes the minimum of A_{i} and A_{j}.
Determi... | {"inputs": ["3\n2\n1 1 \n3 \n1 3 1\n4\n1 3 1 3\n"], "outputs": ["1\n1 2\n-1\n2\n1 3\n2 4"]} | 680 | 56 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
There are n servers numbered from 0 to n - 1 connected by undirected server-to-server connections forming a network where connections[i] = [ai, bi] represents a connection between servers ai and bi. Any server can rea... | {"functional": "def check(candidate):\n assert candidate(n = 4, connections = [[0,1],[1,2],[2,0],[1,3]]) == [[1,3]]\n assert candidate(n = 2, connections = [[0,1]]) == [[0,1]]\n\n\ncheck(Solution().criticalConnections)"} | 144 | 77 |
coding | Solve the programming task below in a Python markdown code block.
A disease is spreading through ChefLand!
The disease spreads as follows:
At the end of day 0, a single person is infected with the disease.
During the next 10 days, the number of infected people doubles each day, until the disease has spread to all peop... | {"inputs": ["4\n100 3\n2000 10\n6000 11\n10 11"], "outputs": ["8\n1024\n3072\n10"]} | 631 | 53 |
coding | Solve the programming task below in a Python markdown code block.
Given an array (arr) as an argument complete the function `countSmileys` that should return the total number of smiling faces.
Rules for a smiling face:
- Each smiley face must contain a valid pair of eyes. Eyes can be marked as `:` or `;`
- A smiley ... | {"functional": "_inputs = [[[]], [[':D', ':~)', ';~D', ':)']], [[':)', ':(', ':D', ':O', ':;']], [[';]', ':[', ';*', ':$', ';-D']]]\n_outputs = [[0], [4], [2], [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=t... | 312 | 208 |
coding | Solve the programming task below in a Python markdown code block.
Since Grisha behaved well last year, at New Year's Eve he was visited by Ded Moroz who brought an enormous bag of gifts with him! The bag contains n sweet candies from the good ol' bakery, each labeled from 1 to n corresponding to its tastiness. No two c... | {"inputs": ["4 3\n", "6 6\n", "2 2\n", "1 1\n", "8 2\n", "3 3\n", "4 1\n", "5 2\n"], "outputs": ["7\n", "7\n", "3\n", "1\n", "15\n", "3\n", "4\n", "7\n"]} | 378 | 87 |
coding | Solve the programming task below in a Python markdown code block.
Read problems statements in Mandarin chinese, Russian and Vietnamese as well.
Masha has $N$ minions. Each minion has two characteristics: power $a$ and endurance $b$. Masha thinks that a non-empty set of minions $\{m_{1}, m_{2}, \dots, m_{k}\}$ with ch... | {"inputs": ["2\n3\n1 4\n3 3\n2 1\n2\n3 5\n1 4"], "outputs": ["2\n0"]} | 535 | 38 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given a string containing digits from 2-9 inclusive, return all possible letter combinations that the number could represent. Return the answer in any order.
A mapping of digits to letters (just like on the telephone ... | {"functional": "def check(candidate):\n assert candidate(digits = \"23\") == [\"ad\",\"ae\",\"af\",\"bd\",\"be\",\"bf\",\"cd\",\"ce\",\"cf\"]\n assert candidate(digits = \"\") == []\n assert candidate(digits = \"2\") == [\"a\",\"b\",\"c\"]\n\n\ncheck(Solution().letterCombinations)"} | 108 | 82 |
coding | Solve the programming task below in a Python markdown code block.
One day, Chef prepared D brand new dishes. He named the i-th dish by a string Si. After the cooking, he decided to categorize each of these D dishes as special or not.
A dish Si is called special if it's name (i.e. the string Si) can be represented in t... | {"inputs": ["3\naba\nabac\nabcd", "3\naba\nabac\naacd", "3\nbca\nb`dc\naabd", "3\ncdd\n_a_a\n_ed[", "3\nfda\n`a`a\nb`Ze", "3\naba\nabac\ndaca", "3\naba\nabac\ndaac", "3\naba\nabac\nadac"], "outputs": ["YES\nNO\nNO", "YES\nNO\nNO\n", "NO\nNO\nNO\n", "YES\nYES\nNO\n", "NO\nYES\nNO\n", "YES\nNO\nNO\n", "YES\nNO\nNO\n", "Y... | 494 | 163 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.