problem stringlengths 14 4.09k | solution stringlengths 1 802k | task_type stringclasses 3
values | problem_tokens int64 5 895 |
|---|---|---|---|
Solve the programming task below in a Python markdown code block.
DNA sequencing data can be stored in many different formats. In this Kata, we will be looking at SAM formatting. It is a plain text file where every line (excluding the first header lines) contains data about a "read" from whatever sample the file comes ... | {"functional": "_inputs = [[['36M', 'CATAATACTTTACCTACTCTCAACAAATGCGGGAGA']], [['10M6H', 'GAGCGAGTGCGCCTTAC']], [['12S', 'TGTTTCTCCAAG']]]\n_outputs = [[True], ['Invalid cigar'], [False]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return math.isclose(a, b,... | coding | 440 |
Solve the programming task below in a Python markdown code block.
D: Sunburn-Suntan-
story
Aizunyan is a second-year student who belongs to the programming contest club of Wakagamatsu High School, commonly known as the Prokon club. Cute like an angel. Aizu Nyan is planning to participate in this summer festival, so I... | {"inputs": ["20\n1\n0 7", "20\n1\n3 7", "20\n1\n2 7", "20\n1\n0 3", "20\n1\n4 6", "20\n1\n6 7", "20\n1\n0 4", "20\n1\n1 4"], "outputs": ["7\n", "4\n", "5\n", "3\n", "2\n", "1\n", "4\n", "3\n"]} | coding | 679 |
Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given an array points, an integer angle, and your location, where location = [posx, posy] and points[i] = [xi, yi] both denote integral coordinates on the X-Y plane.
Initially, you are facing directly east fro... | {"functional": "def check(candidate):\n assert candidate(points = [[2,1],[2,2],[3,3]], angle = 90, location = [1,1]) == 3\n assert candidate(points = [[2,1],[2,2],[3,4],[1,1]], angle = 90, location = [1,1]) == 4\n assert candidate(points = [[1,0],[2,1]], angle = 13, location = [1,1]) == 1\n\n\ncheck(Solution()... | coding | 302 |
Please solve the programming task below using a self-contained code snippet in a markdown code block.
Balanced strings are those that have an equal quantity of 'L' and 'R' characters.
Given a balanced string s, split it into some number of substrings such that:
Each substring is balanced.
Return the maximum number o... | {"functional": "def check(candidate):\n assert candidate(s = \"RLRRLLRLRL\") == 4\n assert candidate(s = \"RLRRRLLRLL\") == 2\n assert candidate(s = \"LLLLRRRR\") == 1\n\n\ncheck(Solution().balancedStringSplit)"} | coding | 101 |
Solve the programming task below in a Python markdown code block.
You need to swap the head and the tail of the specified array:
the head (the first half) of array moves to the end, the tail (the second half) moves to the start.
The middle element (if it exists) leaves on the same position.
Return new array.
For ... | {"functional": "_inputs = [[[-1, 2]], [[1, 2, -3, 4, 5, 6, -7, 8]]]\n_outputs = [[[2, -1]], [[5, 6, -7, 8, 1, 2, -3, 4]]]\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... | coding | 223 |
Please solve the programming task below using a self-contained code snippet in a markdown code block.
We have n cities labeled from 1 to n. Two different cities with labels x and y are directly connected by a bidirectional road if and only if x and y share a common divisor strictly greater than some threshold. More fo... | {"functional": "def check(candidate):\n assert candidate(n = 6, threshold = 2, queries = [[1,4],[2,5],[3,6]]) == [False,False,True]\n assert candidate(n = 6, threshold = 0, queries = [[4,5],[3,4],[3,2],[2,6],[1,3]]) == [True,True,True,True,True]\n assert candidate(n = 5, threshold = 1, queries = [[4,5],[4,5],[... | coding | 247 |
Solve the programming task below in a Python markdown code block.
Read problem statements in [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
In Olympics, the countries are ranked by the total number of medals won. You are given six integers G_{1}, S_{1}, B_{1}, and G_{2}, S_{2}, B_{2}, the number o... | {"inputs": ["3\n10 20 30 0 29 30\n0 0 0 0 0 1\n1 1 1 0 0 0\n"], "outputs": ["1\n2\n1"]} | coding | 484 |
Solve the programming task below in a Python markdown code block.
There are N stores called Store 1, Store 2, \cdots, Store N. Takahashi, who is at his house at time 0, is planning to visit some of these stores.
It takes Takahashi one unit of time to travel from his house to one of the stores, or between any two store... | {"inputs": ["1 3\n0 0", "1 0\n1 0", "1 0\n1 1", "0 0\n1 1", "0 1\n1 1", "0 1\n2 1", "0 1\n4 1", "0 1\n4 2"], "outputs": ["1\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n"]} | coding | 439 |
Solve the programming task below in a Python markdown code block.
You've been in love with Coronavirus-chan for a long time, but you didn't know where she lived until now. And just now you found out that she lives in a faraway place called Naha.
You immediately decided to take a vacation and visit Coronavirus-chan. Y... | {"inputs": ["1 1\n1\n", "1 1\n1\n", "3 2\n1 3 1\n", "3 6\n3 3 3\n", "3 3\n1 1 1\n", "3 2\n3 3 3\n", "3 2\n3 4 3\n", "3 2\n1 1 2\n"], "outputs": ["1", "1\n", "5", "12", "3\n", "5\n", "7\n", "3\n"]} | coding | 721 |
Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given an integer n that consists of exactly 3 digits.
We call the number n fascinating if, after the following modification, the resulting number contains all the digits from 1 to 9 exactly once and does not c... | {"functional": "def check(candidate):\n assert candidate(n = 192) == True\n assert candidate(n = 100) == False\n\n\ncheck(Solution().isFascinating)"} | coding | 162 |
Solve the programming task below in a Python markdown code block.
Ivan is a student at Berland State University (BSU). There are n days in Berland week, and each of these days Ivan might have some classes at the university.
There are m working hours during each Berland day, and each lesson at the university lasts exac... | {"inputs": ["1 1 5\n1\n", "1 1 1\n0\n", "1 1 1\n1\n", "1 1 2\n1\n", "1 1 0\n1\n", "1 1 2\n0\n", "1 1 5\n1\n", "1 1 1\n1\n"], "outputs": ["0\n", "0\n", "0\n", "0\n", "1\n", "0\n", "0", "0"]} | coding | 537 |
Solve the programming task below in a Python markdown code block.
Natasha is planning an expedition to Mars for $n$ people. One of the important tasks is to provide food for each participant.
The warehouse has $m$ daily food packages. Each package has some food type $a_i$.
Each participant must eat exactly one food p... | {"inputs": ["1 1\n2\n", "1 1\n3\n", "1 1\n59\n", "1 1\n59\n", "1 1\n18\n", "100 1\n1\n", "1 1\n100\n", "50 1\n75\n"], "outputs": ["1\n", "1\n", "1\n", "1\n", "1\n", "0\n", "1\n", "0\n"]} | coding | 565 |
Solve the programming task below in a Python markdown code block.
Did you know that there are over 40,000 varieties of Rice in the world ? There are so many dishes that can be prepared with Rice too. A famous chef from Mumbai, Tid Gusto prepared a new dish and named it 'Tid Rice'. He posted the recipe in his newly desi... | {"inputs": ["3\n4\ntilak +\ntilak +\ntilak -\ntilak +\n3\nratna +\nshashi -\nratna -\n3\nbhavani -\nbhavani +\nbhavani -"], "outputs": ["1\n-2\n-1"]} | coding | 602 |
Solve the programming task below in a Python markdown code block.
Ashley likes playing with strings.
She gives Mojo a fun problem to solve. In her imaginary string world, a string of even length is called as "Doublindrome" if both halves of the string are palindromes (both halves have length equal to half of original ... | {"inputs": ["1\n8\nabbacddc"], "outputs": ["YES"]} | coding | 348 |
Solve the programming task below in a Python markdown code block.
Samantha and Sam are playing a numbers game. Given a number as a string, no leading zeros, determine the sum of all integer values of substrings of the string.
Given an integer as a string, sum all of its substrings cast as integers. As the number ... | {"inputs": ["16\n", "123\n"], "outputs": ["23\n", "164\n"]} | coding | 381 |
Solve the programming task below in a Python markdown code block.
For this problem you must create a program that says who ate the last cookie. If the input is a string then "Zach" ate the cookie. If the input is a float or an int then "Monica" ate the cookie. If the input is anything else "the dog" ate the cookie. The... | {"functional": "_inputs = [['Ryan'], [2.3], [26], [True], ['True'], [False], [1.98528462]]\n_outputs = [['Who ate the last cookie? It was Zach!'], ['Who ate the last cookie? It was Monica!'], ['Who ate the last cookie? It was Monica!'], ['Who ate the last cookie? It was the dog!'], ['Who ate the last cookie? It was Zac... | coding | 175 |
Solve the programming task below in a Python markdown code block.
Chef has decided to join a Gym in ChefLand and if possible, also hire a personal trainer at the gym. The monthly cost of the gym is X and personal training will cost him an additional Y per month. Chef's total budget per month is only Z. Print 1 if Chef ... | {"inputs": ["4\n1 2 3\n10 12 13\n23 1 22\n23 1 63"], "outputs": ["2\n1\n0\n2"]} | coding | 525 |
Solve the programming task below in a Python markdown code block.
Once upon a time, there was a hero and an old saint. And like in any story with a hero and an old saint, the old saint asked the hero — three questions!
But here's the twist: each question was a binary question, which means that the answer to each must... | {"inputs": ["2\n1 0 1\n1 1 0\n0 0 0\n1 1 1"], "outputs": ["Pass\nFail"]} | coding | 631 |
Solve the programming task below in a Python markdown code block.
For a given weighted undirected graph G(V, E), find the distance of the shortest route that meets the following criteria:
* It is a closed cycle where it ends at the same point it starts.
* The route must go through every edge at least once.
Constraint... | {"inputs": ["2 3\n0 1 1\n0 1 2\n0 1 3", "4 4\n0 1 1\n1 2 2\n1 3 3\n2 3 4", "6 4\n0 1 0\n1 2 2\n1 3 3\n2 3 4", "6 4\n0 1 0\n1 2 2\n1 3 6\n2 3 4", "6 4\n0 2 0\n1 2 3\n1 3 6\n2 3 4", "6 4\n0 2 0\n1 0 3\n1 4 6\n2 3 4", "6 4\n0 2 0\n1 0 3\n1 1 6\n2 5 4", "6 3\n0 2 0\n1 0 2\n1 1 6\n2 5 4"], "outputs": ["7", "11\n", "9\n", "1... | coding | 363 |
Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given an array of keywords words and a string s, make all appearances of all keywords words[i] in s bold. Any letters between <b> and </b> tags become bold.
Return s after adding the bold tags. The returned string sho... | {"functional": "def check(candidate):\n assert candidate(words = [\"ab\",\"bc\"], s = \"aabcd\") == \"a<b>abc</b>d\"\n assert candidate(words = [\"ab\",\"cb\"], s = \"aabcd\") == \"a<b>ab</b>cd\"\n\n\ncheck(Solution().boldWords)"} | coding | 119 |
Solve the programming task below in a Python markdown code block.
Two integers are coprimes if the their only greatest common divisor is 1.
## Task
In this kata you'll be given a number ```n >= 2``` and output a list with all positive integers less than ```gcd(n, k) == 1```, with ```k``` being any of the output number... | {"functional": "_inputs = [[2], [3], [6], [10], [20], [25], [30]]\n_outputs = [[[1]], [[1, 2]], [[1, 5]], [[1, 3, 7, 9]], [[1, 3, 7, 9, 11, 13, 17, 19]], [[1, 2, 3, 4, 6, 7, 8, 9, 11, 12, 13, 14, 16, 17, 18, 19, 21, 22, 23, 24]], [[1, 7, 11, 13, 17, 19, 23, 29]]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isin... | coding | 296 |
Solve the programming task below in a Python markdown code block.
.union()
The .union() operator returns the union of a set and the set of elements in an iterable.
Sometimes, the | operator is used in place of .union() operator, but it operates only on the set of elements in set.
Set is immutable to the .union() o... | {"inputs": ["9\n1 2 3 4 5 6 7 8 9\n9\n10 1 2 3 11 21 55 6 8\n"], "outputs": ["13\n"]} | coding | 684 |
Please solve the programming task below using a self-contained code snippet in a markdown code block.
There is a bookstore owner that has a store open for n minutes. You are given an integer array customers of length n where customers[i] is the number of the customers that enter the store at the start of the ith minut... | {"functional": "def check(candidate):\n assert candidate(customers = [1,0,1,2,1,1,7,5], grumpy = [0,1,0,1,0,1,0,1], minutes = 3) == 16\n assert candidate(customers = [1], grumpy = [0], minutes = 1) == 1\n\n\ncheck(Solution().maxSatisfied)"} | coding | 225 |
Solve the programming task below in a Python markdown code block.
For a non-negative integer K, we define a fractal of level K as follows:
* A fractal of level 0 is a grid with just one white square.
* When K > 0, a fractal of level K is a 3^K \times 3^K grid. If we divide this grid into nine 3^{K-1} \times 3^{K-1} su... | {"inputs": ["2\n3 2 7 4\n9 9 1 9", "2\n3 2 7 4\n9 3 1 9", "2\n3 2 4 4\n7 3 1 9", "2\n3 2 6 4\n7 3 1 9", "2\n3 2 6 4\n4 3 1 9", "2\n3 2 6 4\n4 3 2 9", "2\n3 2 6 4\n4 3 2 4", "2\n3 4 6 4\n4 3 2 4"], "outputs": ["6\n8\n", "6\n14\n", "3\n12\n", "5\n12\n", "5\n9\n", "5\n8\n", "5\n3\n", "3\n3\n"]} | coding | 556 |
Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given two arrays of positive integers, boxes and warehouse, representing the heights of some boxes of unit width and the heights of n rooms in a warehouse respectively. The warehouse's rooms are labelled from ... | {"functional": "def check(candidate):\n assert candidate(boxes = [4,3,4,1], warehouse = [5,3,3,4,1]) == 3\n assert candidate(boxes = [1,2,2,3,4], warehouse = [3,4,1,2]) == 3\n assert candidate(boxes = [1,2,3], warehouse = [1,2,3,4]) == 1\n\n\ncheck(Solution().maxBoxesInWarehouse)"} | coding | 211 |
Solve the programming task below in a Python markdown code block.
For a given sequence $A = \\{a_0, a_1, ... a_{n-1}\\}$, the number of pairs $(i, j)$ where $a_i > a_j$ and $i < j$, is called the number of inversions. The number of inversions is equal to the number of swaps of Bubble Sort defined in the following progr... | {"inputs": ["3\n6 1 2", "3\n6 1 0", "3\n6 2 0", "3\n6 2 1", "3\n6 2 2", "3\n6 0 1", "3\n1 0 0", "3\n1 0 1"], "outputs": ["2\n", "3\n", "3\n", "3\n", "2\n", "2\n", "2\n", "1\n"]} | coding | 326 |
Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given an integer array nums, return the most frequent even element.
If there is a tie, return the smallest one. If there is no such element, return -1.
Please complete the following python code precisely:
```python
... | {"functional": "def check(candidate):\n assert candidate(nums = [0,1,2,2,4,4,1]) == 2\n assert candidate(nums = [4,4,4,9,2,4]) == 4\n assert candidate(nums = [29,47,21,41,13,37,25,7]) == -1\n\n\ncheck(Solution().mostFrequentEven)"} | coding | 85 |
Solve the programming task below in a Python markdown code block.
Given an integer x, find 2 integers a and b such that:
* 1 ≤ a,b ≤ x
* b divides a (a is divisible by b).
* a ⋅ b>x.
* a/b<x.
Input
The only line contains the integer x (1 ≤ x ≤ 100).
Output
You should output two integers a and b, satis... | {"inputs": ["8\n", "7\n", "9\n", "4\n", "2\n", "5\n", "6\n", "3\n"], "outputs": ["3 3\n", "3 3\n", "4 4\n", "4 2\n", "2 2\n", "3 3\n", "3 3\n", "2 2\n"]} | coding | 148 |
Solve the programming task below in a Python markdown code block.
Vasya has a string $s$ of length $n$. He decides to make the following modification to the string: Pick an integer $k$, ($1 \leq k \leq n$). For $i$ from $1$ to $n-k+1$, reverse the substring $s[i:i+k-1]$ of $s$. For example, if string $s$ is qwer and... | {"inputs": ["1\n1\nk\n", "1\n1\nk\n", "1\n1\nj\n", "1\n1\ni\n", "1\n1\nh\n", "1\n3\nraq\n", "1\n3\nraq\n", "1\n3\nbab\n"], "outputs": ["k\n1\n", "k\n1\n", "j\n1\n", "i\n1\n", "h\n1\n", "aqr\n2\n", "aqr\n2\n", "abb\n2\n"]} | coding | 748 |
Solve the programming task below in a Python markdown code block.
You are given two integers $a$ and $m$. Calculate the number of integers $x$ such that $0 \le x < m$ and $\gcd(a, m) = \gcd(a + x, m)$.
Note: $\gcd(a, b)$ is the greatest common divisor of $a$ and $b$.
-----Input-----
The first line contains the sing... | {"inputs": ["3\n4 9\n5 10\n42 9999999967\n", "3\n4 5\n5 10\n42 9999999967\n", "3\n4 5\n8 10\n42 9999999967\n", "3\n4 9\n5 10\n42 9999999967\n", "3\n4 14\n5 10\n42 9999999967\n", "3\n4 27\n5 10\n42 9999999967\n", "3\n4 45\n5 10\n42 9999999967\n", "3\n4 75\n5 10\n42 9999999967\n"], "outputs": ["6\n1\n9999999966\n", "4\n1... | coding | 282 |
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 is a secret sequence $A_{1}, A_{2}, \ldots, A_{N}$. We do not know the elements of this sequence, but we know another sequence $B_{1}, B_{2}, \... | {"inputs": ["1\n5 3\n4 5 6 7\n1 2\n1 3\n4 1"], "outputs": ["4\nUNKNOWN\n5"]} | coding | 587 |
Solve the programming task below in a Python markdown code block.
Professor Sahil is a master artist, he always finds creative ways to teach lessons to his students.
Today in Painting class he took all the students of the class to a wall. Professor Sahil asked every student to paint the wall upto a certain integral hei... | {"inputs": ["3\n5 4\n1 2 3 4 5\n3 3 3 3 3\n5 4\n3 5 1 2 3\n1 2 3 4 3\n5 5 \n5 4 3 2 3\n1 2 3 4 5"], "outputs": ["1\n2\n3"]} | coding | 657 |
Solve the programming task below in a Python markdown code block.
The chef is trying to decode some pattern problems, Chef wants your help to code it. Chef has one number K to form a new pattern. Help the chef to code this pattern problem.
-----Input:-----
- First-line will contain $T$, the number of test cases. Then ... | {"inputs": ["4\n1\n2\n3\n4"], "outputs": ["0\n01\n10\n010\n101\n010\n0101\n1010\n0101\n1010"]} | coding | 216 |
Solve the programming task below in a Python markdown code block.
Write a function, `gooseFilter` / `goose-filter` / `goose_filter` /` GooseFilter`, that takes an array of strings as an argument and returns a filtered array containing the same elements but with the 'geese' removed.
The geese are any strings in the fol... | {"functional": "_inputs = [[['Mallard', 'Hook Bill', 'African', 'Crested', 'Pilgrim', 'Toulouse', 'Blue Swedish']], [['Mallard', 'Barbary', 'Hook Bill', 'Blue Swedish', 'Crested']], [['African', 'Roman Tufted', 'Toulouse', 'Pilgrim', 'Steinbacher']]]\n_outputs = [[['Mallard', 'Hook Bill', 'Crested', 'Blue Swedish']], [... | coding | 275 |
Solve the programming task below in a Python markdown code block.
The Cartesian coordinate system is set in the sky. There you can see n stars, the i-th has coordinates (x_{i}, y_{i}), a maximum brightness c, equal for all stars, and an initial brightness s_{i} (0 ≤ s_{i} ≤ c).
Over time the stars twinkle. At moment 0... | {"inputs": ["2 3 3\n1 1 1\n3 2 0\n2 1 1 2 2\n0 2 1 4 5\n5 1 1 5 5\n", "2 3 3\n1 1 1\n3 2 0\n2 1 1 1 2\n0 2 1 4 5\n5 1 1 5 5\n", "2 3 3\n1 2 1\n3 2 0\n2 1 1 2 2\n0 2 1 7 5\n5 1 1 5 1\n", "2 3 3\n1 2 1\n3 2 0\n0 1 1 2 2\n0 2 1 7 5\n5 1 1 5 5\n", "2 3 3\n1 2 1\n3 2 0\n0 1 1 2 2\n1 2 1 7 5\n5 1 1 5 5\n", "2 3 3\n1 1 1\n3 2... | coding | 755 |
Solve the programming task below in a Python markdown code block.
Harrenhal is the largest castle in the Seven Kingdoms and is the seat of House Whent in the Riverlands, on the north shore of the Gods Eye lake. Since the War of Conquest, however, it has become a dark and ruinous place.
(c) A Wiki of Ice and Fire
Now H... | {"inputs": ["1\nabbabaab\n\n"], "outputs": ["2"]} | coding | 670 |
Solve the programming task below in a Python markdown code block.
Programmers working on a large project have just received a task to write exactly m lines of code. There are n programmers working on a project, the i-th of them makes exactly ai bugs in every line of code that he writes.
Let's call a sequence of non-n... | {"inputs": ["1 1 1 1\n0\n", "1 1 1 1\n2\n", "1 2 1 1\n2\n", "2 2 1 1\n2\n", "1 5 1 10\n1\n", "1 5 1 13\n1\n", "1 5 5 1000\n1\n", "1 1 0 1000\n0\n"], "outputs": ["0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "1\n", "1\n"]} | coding | 419 |
Solve the programming task below in a Python markdown code block.
In this problem we consider a special type of an auction, which is called the second-price auction. As in regular auction n bidders place a bid which is price a bidder ready to pay. The auction is closed, that is, each bidder secretly informs the organiz... | {"inputs": ["2\n5 7\n", "2\n2 1\n", "2\n1 2\n", "2\n1 2\n", "2\n2 1\n", "2\n1 3\n", "2\n2 0\n", "2\n2 7\n"], "outputs": ["2 5\n", "1 1\n", "2 1\n", "2 1\n", "1 1\n", "2 1\n", "1 0\n", "2 2\n"]} | coding | 322 |
Solve the programming task below in a Python markdown code block.
The official capital and the cultural capital of Berland are connected by a single road running through n regions. Each region has a unique climate, so the i-th (1 ≤ i ≤ n) region has a stable temperature of ti degrees in summer.
This summer a group of ... | {"inputs": ["1 1000000\n4 4 6 2\n", "1 1000000\n4 4 4 2\n", "1 1000000\n4 3 6 2\n", "1 1000000\n1 3 6 2\n", "1 1000000\n1 3 6 4\n", "1 1000000\n1 1 6 4\n", "0 1000000\n1 1 6 2\n", "1 1000000\n4 3 4 2\n"], "outputs": ["6000002\n", "4000002\n", "6000002\n", "1000000\n", "2000000\n", "6000004\n", "0\n", "4000002\n"]} | coding | 686 |
Solve the programming task below in a Python markdown code block.
Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Chef has a combination lock with $N$ wheels (numbered $1$ through $N$). For each valid $i$, on the $i$-th wheel, the integers from $0$ to $A_{i}$ (in... | {"inputs": ["3\n2\n2 2\n2\n5 5\n3\n3 4 5"], "outputs": ["443664157\n221832079\n598946612"]} | coding | 718 |
Solve the programming task below in a Python markdown code block.
Vasya has got $n$ books, numbered from $1$ to $n$, arranged in a stack. The topmost book has number $a_1$, the next one — $a_2$, and so on. The book at the bottom of the stack has number $a_n$. All numbers are distinct.
Vasya wants to move all the books... | {"inputs": ["1\n1\n1\n", "1\n1\n1\n", "3\n1 2 3\n2 1 3\n", "3\n1 2 3\n2 1 1\n", "3\n1 2 3\n3 1 1\n", "3\n1 2 3\n3 2 1\n", "3\n1 2 3\n2 1 3\n", "5\n3 1 4 2 5\n4 5 1 3 2\n"], "outputs": ["1 \n", "1 ", "2 0 1 \n", "2 0 0\n", "3 0 0\n", "3 0 0\n", "2 0 1 ", "3 2 0 0 0 \n"]} | coding | 710 |
Solve the programming task below in a Python markdown code block.
We have a permutation p = {p_1,\ p_2,\ ...,\ p_n} of {1,\ 2,\ ...,\ n}.
Print the number of elements p_i (1 < i < n) that satisfy the following condition:
- p_i is the second smallest number among the three numbers p_{i - 1}, p_i, and p_{i + 1}.
-----C... | {"inputs": ["3\n1 2 3\n", "3\n1 3 2\n", "3\n2 1 3\n", "5\n2 3 5 4 2", "5\n2 1 5 4 2", "5\n2 6 4 8 3", "5\n2 1 5 4 3", "5\n2 1 2 4 3"], "outputs": ["1\n", "0\n", "0\n", "2\n", "1\n", "0\n", "1\n", "1\n"]} | coding | 284 |
Solve the programming task below in a Python markdown code block.
Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Let next(x) be the minimum lucky n... | {"inputs": ["3 4\n", "1 2\n", "5 6\n", "1 1\n", "4 7\n", "1 9\n", "6 6\n", "6 9\n"], "outputs": ["8\n", "8\n", "14\n", "4\n", "25\n", "125\n", "7\n", "102\n"]} | coding | 334 |
Please solve the programming task below using a self-contained code snippet in a markdown code block.
Alice and Bob have a different total number of candies. You are given two integer arrays aliceSizes and bobSizes where aliceSizes[i] is the number of candies of the ith box of candy that Alice has and bobSizes[j] is t... | {"functional": "def check(candidate):\n assert candidate(aliceSizes = [1,1], bobSizes = [2,2]) == [1,2]\n assert candidate(aliceSizes = [1,2], bobSizes = [2,3]) == [1,2]\n assert candidate(aliceSizes = [2], bobSizes = [1,3]) == [2,3]\n assert candidate(aliceSizes = [1,2,5], bobSizes = [2,4]) == [5,4]\n\n\nc... | coding | 237 |
Solve the programming task below in a Python markdown code block.
Our Chef is catering for a big corporate office party and is busy preparing different mouth watering dishes. The host has insisted that he serves his delicious cupcakes for dessert.
On the day of the party, the Chef was over-seeing all the food arrange... | {"inputs": ["4\n6\n4\n1\n1", "4\n2\n8\n2\n3", "4\n40\n1\n1\n3", "4\n40\n1\n2\n3", "4\n40\n1\n1\n5", "4\n40\n2\n1\n5", "4\n2\n16\n2\n3", "4\n40\n4\n1\n4"], "outputs": ["1\n0\n0\n0\n", "1\n2\n1\n2\n", "3\n0\n0\n2\n", "3\n0\n1\n2\n", "3\n0\n0\n4\n", "3\n1\n0\n4\n", "1\n0\n1\n2\n", "3\n0\n0\n0\n"]} | coding | 641 |
Solve the programming task below in a Python markdown code block.
Our lazy white falcon finally decided to learn heavy-light decomposition. Her teacher gave an assignment for her to practice this new technique. Please help her by solving this problem.
You are given a tree with $N$ nodes and each node's value is initi... | {"inputs": ["3 3\n0 1\n1 2\n1 0 1\n1 1 2\n2 0 2\n"], "outputs": ["2\n"]} | coding | 358 |
Solve the programming task below in a Python markdown code block.
Difference of Big Integers
Given two integers $A$ and $B$, compute the difference, $A - B$.
Input
Two integers $A$ and $B$ separated by a space character are given in a line.
Output
Print the difference in a line.
Constraints
* $-1 \times 10^{1000... | {"inputs": ["5 4", "5 5", "5 1", "4 1", "2 0", "8 0", "8 1", "0 1"], "outputs": ["1\n", "0\n", "4\n", "3\n", "2\n", "8\n", "7\n", "-1\n"]} | coding | 194 |
Solve the programming task below in a Python markdown code block.
There are $n$ participants in a competition, participant $i$ having a strength of $s_i$.
Every participant wonders how much of an advantage they have over the other best participant. In other words, each participant $i$ wants to know the difference betw... | {"inputs": ["5\n4\n4 7 3 5\n2\n1 2\n5\n1 2 3 4 5\n3\n4 9 4\n4\n4 4 4 4\n", "1\n23\n1 2 3 4 5 6 7 8 9 10 11 12 13 1 1 1 1 1 1 1 1 1 1\n"], "outputs": ["-3 2 -4 -2 \n-1 1 \n-4 -3 -2 -1 1 \n-5 5 -5 \n0 0 0 0 \n", "-12 -11 -10 -9 -8 -7 -6 -5 -4 -3 -2 -1 1 -12 -12 -12 -12 -12 -12 -12 -12 -12 -12 \n"]} | coding | 644 |
Solve the programming task below in a Python markdown code block.
Kakarot and Vegeta are both training their sons Goten and Trunks as only they can defeat Beerus. To train them, Kakarot lays out an undirected graph where each node is connected to every other node (even to itself). Each node also has a weight, which is ... | {"inputs": ["1\n2\n4 5 \n5 6"], "outputs": ["5"]} | coding | 735 |
Solve the programming task below in a Python markdown code block.
Chef has decided to arrange the free shuttle service for his employees. City of Bhiwani has a strange layout - all of its N shuttle boarding points are arranged in a circle, numbered from 1 to N in clockwise direction. Chef's restaurant is at boarding po... | {"inputs": ["3\n2\n3\n4", "3\n2\n3\n1", "3\n2\n5\n1", "3\n2\n2\n1", "3\n3\n2\n1", "3\n2\n3\n6", "3\n4\n3\n1", "3\n4\n3\n6"], "outputs": ["1\n2\n2", "1\n2\n1\n", "1\n4\n1\n", "1\n1\n1\n", "2\n1\n1\n", "1\n2\n2\n", "2\n2\n1\n", "2\n2\n2\n"]} | coding | 577 |
Solve the programming task below in a Python markdown code block.
Mid semester exams are approaching and 'IDC' wants to study with the toppers of the batch.
So he decide to take a temporary room near all the toppers of the computer science batch.
All room are on a straight line and room numbers are integers.
Since he... | {"inputs": ["100\n11\n81 79 91 64 24 32 75 29 51 26 62\n15\n51 3 37 48 8 14 97 73 9 46 93 64 25 26 43\n10\n11 85 50 43 77 67 19 9 94 0\n13\n21 80 74 15 31 29 4 32 38 18 81 63 28\n8\n57 92 4 35 36 73 98 76\n2\n50 95\n2\n59 89\n2\n72 10\n14\n98 26 25 28 30 9 66 1 90 81 29 70 21 0\n5\n83 28 17 85 23\n11\n97 12 44 21 75 37... | coding | 245 |
Solve the programming task below in a Python markdown code block.
You have a set of four (4) balls labeled with different numbers: ball_1 (1), ball_2 (2), ball_3 (3) and ball(4) and we have 3 equal boxes for distribute them. The possible combinations of the balls, without having empty boxes, are:
```
(1) (... | {"functional": "_inputs = [[4, 3], [4, 2], [4, 4], [4, 1], [4, 0], [4, 5], [20, 8]]\n_outputs = [[6], [7], [1], [1], [0], ['It cannot be possible!'], [15170932662679]]\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_to... | coding | 438 |
Solve the programming task below in a Python markdown code block.
A prime number is an integer greater than $1$ that has no positive divisors other than $1$ and itself.
We call a number megaprime if it is prime and all of its individual digits are prime. For example, $53$ is megaprime because it is prime and all its d... | {"inputs": ["1 100\n"], "outputs": ["8\n"]} | coding | 352 |
Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given an integer n indicating there are n people numbered from 0 to n - 1. You are also given a 0-indexed 2D integer array meetings where meetings[i] = [xi, yi, timei] indicates that person xi and person yi ha... | {"functional": "def check(candidate):\n assert candidate(n = 6, meetings = [[1,2,5],[2,3,8],[1,5,10]], firstPerson = 1) == [0,1,2,3,5]\n assert candidate(n = 4, meetings = [[3,1,3],[1,2,2],[0,3,3]], firstPerson = 3) == [0,1,3]\n assert candidate(n = 5, meetings = [[3,4,2],[1,2,1],[2,3,1]], firstPerson = 1) == ... | coding | 273 |
Solve the programming task below in a Python markdown code block.
You are given an array $a$ consisting of $n$ integers. Initially all elements of $a$ are either $0$ or $1$. You need to process $q$ queries of two kinds:
1 x : Assign to $a_x$ the value $1 - a_x$.
2 k : Print the $k$-th largest value of the array.
As ... | {"inputs": ["1 1\n0\n2 1\n", "1 1\n0\n2 1\n", "5 5\n1 1 0 1 0\n2 3\n1 2\n2 3\n2 1\n2 5\n", "5 5\n0 1 0 1 0\n2 3\n1 2\n2 3\n2 1\n2 5\n", "5 5\n1 1 1 1 0\n2 3\n1 2\n2 3\n2 1\n2 5\n", "5 5\n1 1 1 1 0\n2 3\n1 2\n2 3\n2 1\n2 2\n", "5 5\n0 1 0 0 0\n2 3\n1 2\n2 3\n2 1\n2 3\n", "5 5\n1 1 1 1 0\n2 5\n1 2\n2 3\n2 1\n2 5\n"], "ou... | coding | 633 |
Solve the programming task below in a Python markdown code block.
Your task is to create a new implementation of `modpow` so that it computes `(x^y)%n` for large `y`. The problem with the current implementation is that the output of `Math.pow` is so large on our inputs that it won't fit in a 64-bit float.
You're also ... | {"functional": "_inputs = [[11, 10, 300], [11, 100000, 49], [5, 100000000, 19], [2, 3, 5], [4, 12, 3], [200, 3000, 10], [8132, 21302, 5], [9, 193125, 37], [13, 81230123, 22], [29, 1013293125, 492], [31, 902938423012, 1023]]\n_outputs = [[1], [32], [5], [3], [1], [0], [4], [26], [19], [161], [961]]\nimport math\ndef _de... | coding | 121 |
Solve the programming task below in a Python markdown code block.
Does \sqrt{a} + \sqrt{b} < \sqrt{c} hold?
Constraints
* 1 \leq a, b, c \leq 10^9
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
a \ b \ c
Output
If \sqrt{a} + \sqrt{b} < \sqrt{c}, print `Yes... | {"inputs": ["2 1 9", "4 1 9", "4 0 9", "3 3 0", "1 0 9", "0 0 9", "2 5 0", "2 7 0"], "outputs": ["Yes\n", "No\n", "Yes\n", "No\n", "Yes\n", "Yes\n", "No\n", "No\n"]} | coding | 138 |
Solve the programming task below in a Python markdown code block.
You are given two positive integers $a$ and $b$. In one move you can increase $a$ by $1$ (replace $a$ with $a+1$). Your task is to find the minimum number of moves you need to do in order to make $a$ divisible by $b$. It is possible, that you have to mak... | {"inputs": ["1\n9 3\n", "1\n8 4\n", "1\n3 4\n", "1\n3 6\n", "1\n3 3\n", "1\n29 4\n", "1\n9 75\n", "1\n9 95\n"], "outputs": ["0\n", "0\n", "1\n", "3\n", "0\n", "3\n", "66\n", "86\n"]} | coding | 274 |
Solve the programming task below in a Python markdown code block.
Concatenation of two integers is obtained as follows: First, convert both integers to strings. Then concatenate both strings into one and convert this concatenated string back to integer.
For example, concatenation of 6 and 7 is CONC(6, 7) = 67, concate... | {"inputs": ["4\n2 10 52\n2 5\n3 58 100\n4 2 3\n4 100 1000\n1 10 100 1000\n5 28 102\n3 2 1 9 10\n"], "outputs": ["3\n0\n2\n11\n"]} | coding | 681 |
Solve the programming task below in a Python markdown code block.
You have been presented with a cipher, your goal is to re-create the cipher with little information. Use the examples provided to see if you can find a solution to how this cipher is made. You will be given no hints, only the handful of phrases that have... | {"functional": "_inputs = [['this will probably not be fun'], ['hopefully you will find satisfaction at least'], ['really this is very tedious'], ['if you made it this far you are a better programmer than i am']]\n_outputs = [['tiks zjop twrggfrf uwz kl pcx'], ['hprehxmoc ctx cmrs mqtl zjdqcqjnfsaa nh ztnhj'], ['rfclnb... | coding | 141 |
Solve the programming task below in a Python markdown code block.
You are given an array a_0, a_1, ..., a_{N-1} of length N. Process Q queries of the following types.
* `0 p x`: a_p \gets a_p + x
* `1 l r`: Print \sum_{i = l}^{r - 1}{a_i}.
Constraints
* 1 \leq N, Q \leq 500,000
* 0 \leq a_i, x \leq 10^9
* 0 \leq p <... | {"inputs": ["5 5\n0 1 8 4 7\n0 0 5\n1 2 4\n0 3 4\n1 0 5\n1 0 3", "5 5\n0 1 8 4 7\n0 0 5\n1 2 4\n0 3 4\n1 0 5\n1 1 3", "5 5\n1 2 3 4 5\n4 1 5\n1 2 4\n0 3 6\n1 0 5\n1 0 3", "5 5\n1 2 3 4 5\n1 1 5\n1 2 4\n0 3 10\n1 0 5\n1 0 3", "5 5\n1 2 5 4 5\n1 1 5\n1 2 4\n0 3 10\n1 0 5\n1 0 3", "5 5\n1 2 5 4 5\n1 1 2\n1 2 4\n0 3 10\n1 ... | coding | 292 |
Solve the programming task below in a Python markdown code block.
It is so boring in the summer holiday, isn't it? So Alice and Bob have invented a new game to play. The rules are as follows. First, they get a set of n distinct integers. And then they take turns to make the following moves. During each move, either Ali... | {"inputs": ["2\n2 3\n", "2\n5 3\n", "2\n4 6\n", "2\n2 6\n", "2\n6 2\n", "2\n1 2\n", "2\n2 6\n", "2\n6 2\n"], "outputs": ["Alice\n", "Alice\n", "Alice\n", "Alice\n", "Alice\n", "Bob\n", "Alice\n", "Alice\n"]} | coding | 374 |
Solve the programming task below in a Python markdown code block.
On a certain meeting of a ruling party "A" minister Pavel suggested to improve the sewer system and to create a new pipe in the city.
The city is an n × m rectangular squared field. Each square of the field is either empty (then the pipe can go in it), ... | {"inputs": ["2 2\n..\n..\n", "2 2\n..\n..\n", "3 3\n...\n..#\n...\n", "4 2\n..\n..\n..\n..\n", "4 2\n..\n..\n..\n..\n", "3 3\n...\n..#\n...\n", "4 5\n#...#\n#...#\n###.#\n###.#\n", "4 5\n#...#\n#...#\n#.###\n###.#\n"], "outputs": ["0\n", " 0\n", "3\n", "2\n"... | coding | 697 |
Solve the programming task below in a Python markdown code block.
Read problems statements in Mandarin chinese, Russian and Vietnamese as well.
Chef Dobby loves playing games, especially games related to numbers. So, today Bhuvan gave him a new game. The description of the game goes as follows :
Consider an array A... | {"inputs": ["3\n2 0 1"], "outputs": ["4"]} | coding | 479 |
Solve the programming task below in a Python markdown code block.
For a pole vaulter, it is very important to begin the approach run at the best possible starting mark. This is affected by numerous factors and requires fine-tuning in practice. But there is a guideline that will help a beginning vaulter start at approxi... | {"functional": "_inputs = [[1.52], [1.83], [1.22], [2.13], [1.75]]\n_outputs = [[9.45], [10.67], [8.27], [11.85], [10.36]]\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)):\... | coding | 335 |
Solve the programming task below in a Python markdown code block.
problem
There are $ N $ propositions, named $ 1, 2, \ cdots, N $, respectively. Also, $ M $ information about the propositions is given. The $ i $ th information is "$ a_i $$". Given in the form "b_i $", which means that $ a_i $ is $ b_i $. ("If" is a l... | {"inputs": ["5 2\n1 2\n2 2", "3 2\n1 2\n2 1", "3 2\n1 2\n3 1", "6 2\n1 2\n2 1", "9 2\n1 2\n2 4", "6 2\n1 1\n2 1", "4 2\n2 2\n3 1", "1 0\n2 2\n1 1"], "outputs": ["1\n2\n3\n4\n5\n", "1 2\n1 2\n3\n", "1\n2\n3\n", "1 2\n1 2\n3\n4\n5\n6\n", "1\n2\n3\n4\n5\n6\n7\n8\n9\n", "1\n2\n3\n4\n5\n6\n", "1\n2\n3\n4\n", "1\n"]} | coding | 245 |
Solve the programming task below in a Python markdown code block.
problem
Five students, Taro, Jiro, Saburo, Shiro, and Hanako, participated in the JOI High School class.
In this class, a final exam was conducted. All five people took the final exam. For students with a final exam score of 40 or higher, the final exa... | {"inputs": ["10\n3\n111\n19\n8", "10\n52\n011\n3\n1", "10\n3\n010\n24\n9", "10\n3\n010\n19\n9", "10\n3\n011\n19\n9", "10\n3\n011\n19\n8", "10\n9\n100\n30\n95", "10\n9\n110\n30\n95"], "outputs": ["54\n", "42\n", "40\n", "40\n", "40\n", "40\n", "63\n", "65\n"]} | coding | 155 |
Solve the programming task below in a Python markdown code block.
Read problems statements in Mandarin chinese, Russian and Vietnamese as well.
You are given a convex polygon with N vertices.
You have to find any ⌊N/10⌋ distinct points with integer coordinates that lie strictly inside the polygon, or determine that ... | {"inputs": ["1\n11\n0 0\n1 1\n2 3\n2 5\n0 10\n-2 10\n-5 9\n-8 7\n-8 4\n-6 1\n-2 0"], "outputs": ["0 1"]} | coding | 635 |
Solve the programming task below in a Python markdown code block.
Vasya has the sequence consisting of n integers. Vasya consider the pair of integers x and y k-interesting, if their binary representation differs from each other exactly in k bits. For example, if k = 2, the pair of integers x = 5 and y = 3 is k-interes... | {"inputs": ["2 0\n1 1\n", "2 0\n0 0\n", "2 1\n0 1\n", "2 1\n0 2\n", "2 1\n0 1\n", "2 0\n1 1\n", "2 1\n0 2\n", "2 0\n0 0\n"], "outputs": ["1\n", "1\n", "1\n", "1\n", "1\n", "1\n", "1\n", "1\n"]} | coding | 473 |
Solve the programming task below in a Python markdown code block.
We have N balls. The i-th ball has an integer A_i written on it.
For each k=1, 2, ..., N, solve the following problem and print the answer.
- Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the ... | {"inputs": ["4\n2 2 3 4", "4\n1 2 2 4", "4\n2 2 2 4", "4\n2 2 3 2", "4\n0 2 3 2", "4\n1 2 3 4", "4\n1 2 3 4\n", "5\n0 1 2 1 2"], "outputs": ["0\n0\n1\n1\n", "1\n0\n0\n1\n", "1\n1\n1\n3\n", "1\n1\n3\n1\n", "1\n0\n1\n0\n", "0\n0\n0\n0", "0\n0\n0\n0\n", "2\n1\n1\n1\n1\n"]} | coding | 274 |
Solve the programming task below in a Python markdown code block.
Generalized leap year
Normally, whether or not the year x is a leap year is defined as follows.
1. If x is a multiple of 400, it is a leap year.
2. Otherwise, if x is a multiple of 100, it is not a leap year.
3. Otherwise, if x is a multiple of 4, it i... | {"inputs": ["3 3 2014\n400\n101\n4\n1 1000 2949\n1\n2 1110 3333\n2\n4\n6 6 3370\n2\n5\n2\n9\n5\n13\n0 0 0", "3 3 2014\n400\n101\n4\n1 1000 2949\n1\n2 1110 3333\n2\n4\n6 6 3370\n2\n5\n21\n9\n3\n13\n0 0 0", "3 3 2014\n400\n101\n4\n1 1000 2949\n1\n2 1110 3333\n2\n4\n6 6 3370\n2\n5\n21\n9\n5\n13\n0 0 0", "3 3 2014\n400\n10... | coding | 618 |
Solve the programming task below in a Python markdown code block.
Leha somehow found an array consisting of n integers. Looking at it, he came up with a task. Two players play the game on the array. Players move one by one. The first player can choose for his move a subsegment of non-zero length with an odd sum of numb... | {"inputs": ["1\n0\n", "1\n1\n", "1\n2\n", "1\n1\n", "1\n0\n", "1\n2\n", "1\n3\n", "1\n4\n"], "outputs": ["Second\n", "First\n", "Second\n", "First\n", "Second\n", "Second\n", "First\n", "Second\n"]} | coding | 282 |
Solve the programming task below in a Python markdown code block.
You are given three integers, A, B and C.
Among them, two are the same, but the remaining one is different from the rest.
For example, when A=5,B=7,C=5, A and C are the same, but B is different.
Find the one that is different from the rest among the g... | {"inputs": ["5 8 5", "1 1 4", "1 1 5", "5 9 5", "5 6 5", "0 0 7", "1 1 3", "1 1 2"], "outputs": ["8\n", "4\n", "5\n", "9\n", "6\n", "7\n", "3\n", "2\n"]} | coding | 193 |
Solve the programming task below in a Python markdown code block.
# Task
Round the given number `n` to the nearest multiple of `m`.
If `n` is exactly in the middle of 2 multiples of m, return `n` instead.
# Example
For `n = 20, m = 3`, the output should be `21`.
For `n = 19, m = 3`, the output should be `18`.
... | {"functional": "_inputs = [[20, 3], [19, 3], [1, 10], [50, 100], [123, 456]]\n_outputs = [[21], [18], [0], [50], [0]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return math.isclose(a, b, rel_tol=tol, abs_tol=tol)\n if isinstance(a, (list, tuple)):\n ... | coding | 197 |
Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are the operator of a Centennial Wheel that has four gondolas, and each gondola has room for up to four people. You have the ability to rotate the gondolas counterclockwise, which costs you runningCost dollars.
Yo... | {"functional": "def check(candidate):\n assert candidate(customers = [8,3], boardingCost = 5, runningCost = 6) == 3\n assert candidate(customers = [10,9,6], boardingCost = 6, runningCost = 4) == 7\n assert candidate(customers = [3,4,0,5,1], boardingCost = 1, runningCost = 92) == -1\n\n\ncheck(Solution().minOpe... | coding | 306 |
Solve the programming task below in a Python markdown code block.
*This kata is based on [Project Euler Problem #349](https://projecteuler.net/problem=349). You may want to start with solving [this kata](https://www.codewars.com/kata/langtons-ant) first.*
---
[Langton's ant](https://en.wikipedia.org/wiki/Langton%27s_... | {"functional": "_inputs = [[0], [1], [2], [10], [100], [1000], [10000], [100000], [1000000], [10000000]]\n_outputs = [[0], [1], [2], [6], [20], [118], [720], [11108], [114952], [1153412]]\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,... | coding | 312 |
Solve the programming task below in a Python markdown code block.
Jem is famous for his laziness at school. He always leaves things to last minute. Now Jem has N problems in the assignment of "Advanced topics in algorithm" class to solved. The assignment is due tomorrow and as you may guess he hasn't touch any of the p... | {"inputs": ["2\n9 1 2\n123456 123456 123456"], "outputs": ["45\n131351258112"]} | coding | 610 |
Solve the programming task below in a Python markdown code block.
Chef wants to give a burger party to all his N friends i.e. he wants to buy one burger for each of his friends.
The cost of each burger is X rupees while Chef has a total of K rupees.
Determine whether he has enough money to buy a burger for each of h... | {"inputs": ["4\n5 10 70\n5 10 40\n10 40 400\n14 14 150\n"], "outputs": ["YES\nNO\nYES\nNO\n"]} | coding | 555 |
Solve the programming task below in a Python markdown code block.
Adam and Martha are planning to leave the city after their retirement and build a house in a huge land belonging to their family. To keep everyone happy, they want to build the house at a location having distance _a*d1_ from aunt Kimberly's house, where ... | {"inputs": ["3 4\n4 0\n0 0\n-2 -4\n-2 -1\n"], "outputs": ["-2.00 0.00\n"]} | coding | 408 |
Solve the programming task below in a Python markdown code block.
There are X+Y+Z people, conveniently numbered 1 through X+Y+Z. Person i has A_i gold coins, B_i silver coins and C_i bronze coins.
Snuke is thinking of getting gold coins from X of those people, silver coins from Y of the people and bronze coins from Z ... | {"inputs": ["1 2 1\n2 4 4\n0 2 1\n7 6 7\n5 2 3", "1 2 1\n2 4 4\n1 2 1\n7 6 2\n5 3 3", "1 2 1\n2 4 6\n0 2 1\n7 6 7\n5 2 3", "1 2 1\n2 4 4\n1 2 1\n7 0 2\n5 3 3", "1 2 1\n2 4 6\n0 2 1\n7 6 7\n9 2 3", "1 2 1\n2 4 7\n3 2 2\n7 6 7\n5 4 3", "1 2 1\n2 4 4\n3 2 1\n7 6 7\n5 2 3", "1 2 1\n2 4 4\n1 2 1\n7 6 11\n5 3 3"], "outputs":... | coding | 712 |
Solve the programming task below in a Python markdown code block.
Vera adores poems. All the poems Vera knows are divided into quatrains (groups of four lines) and in each quatrain some lines contain rhymes.
Let's consider that all lines in the poems consist of lowercase Latin letters (without spaces). Letters "a", "e... | {"inputs": ["1 1\na\ne\ne\na\n", "1 1\ne\na\ne\na\n", "1 1\na\ne\ne\ne\n", "1 1\ne\ne\ne\ne\n", "1 1\na\na\na\na\n", "1 1\na\ne\na\ne\n", "1 1\na\na\na\ne\n", "1 1\ne\na\ne\ne\n"], "outputs": ["abba\n", "abab\n", "NO\n", "aaaa\n", "aaaa\n", "abab\n", "NO\n", "NO\n"]} | coding | 688 |
Solve the programming task below in a Python markdown code block.
The only difference between easy and hard versions is the size of the input.
You are given a string $s$ consisting of $n$ characters, each character is 'R', 'G' or 'B'.
You are also given an integer $k$. Your task is to change the minimum number of cha... | {"inputs": ["1\n9 3\nRBGGGRBBGRRBBGGGGB\n", "1\n7 2\nBGGGGBBRRGBBRGGGBR\n", "1\n18 2\nRBGGGRBBGRRBBGGGGB\n", "1\n18 2\nRBGGGRBBGRRBBGGGGB\n", "1\n18 2\nBGGGGBBRRGBBRGGGBR\n", "1\n18 3\nRBGGGRBBGRRBBGGGGB\n", "1\n18 7\nBGGGGBBRRGBBRGGGBR\n", "1\n14 2\nBGGGGBBRRGBBRGGGBR\n"], "outputs": ["1\n", "0\n", "0\n", "0\n", "0\n"... | coding | 575 |
Please solve the programming task below using a self-contained code snippet in a markdown code block.
There is a country of n cities numbered from 0 to n - 1 where all the cities are connected by bi-directional roads. The roads are represented as a 2D integer array edges where edges[i] = [xi, yi, timei] denotes a road... | {"functional": "def check(candidate):\n assert candidate(maxTime = 30, edges = [[0,1,10],[1,2,10],[2,5,10],[0,3,1],[3,4,10],[4,5,15]], passingFees = [5,1,2,20,20,3]) == 11\n assert candidate(maxTime = 29, edges = [[0,1,10],[1,2,10],[2,5,10],[0,3,1],[3,4,10],[4,5,15]], passingFees = [5,1,2,20,20,3]) == 48\n ass... | coding | 299 |
Solve the programming task below in a Python markdown code block.
George decided to prepare a Codesecrof round, so he has prepared m problems for the round. Let's number the problems with integers 1 through m. George estimates the i-th problem's complexity by integer b_{i}.
To make the round good, he needs to put at l... | {"inputs": ["3 1\n2 3 4\n1\n", "3 1\n2 3 4\n0\n", "3 1\n2 6 4\n0\n", "3 1\n2 3 4\n1\n", "3 5\n1 2 3\n1 2 2 3 3\n", "3 5\n1 2 3\n1 1 1 1 1\n", "3 5\n1 0 3\n1 1 1 1 1\n", "3 5\n1 2 3\n1 2 1 3 3\n"], "outputs": ["3\n", "3\n", "3\n", "3\n", "0\n", "2\n", "1\n", "0\n"]} | coding | 600 |
Solve the programming task below in a Python markdown code block.
---
# Story
The Pied Piper has been enlisted to play his magical tune and coax all the rats out of town.
But some of the rats are deaf and are going the wrong way!
# Kata Task
How many deaf rats are there?
# Legend
* ```P``` = The Pied Piper
* ```... | {"functional": "_inputs = [['~O~O~O~O P'], ['P O~ O~ ~O O~'], ['~O~O~O~OP~O~OO~'], ['O~~OO~~OO~~OO~P~OO~~OO~~OO~~O'], ['~OP'], ['PO~'], ['O~P'], ['P~O'], [' P'], ['P '], [' P '], ['P']]\n_outputs = [[0], [1], [2], [8], [0], [0], [1], [1], [0], [0], [0], [0]]\nimport math\ndef _deep_eq(a, b,... | coding | 225 |
Solve the programming task below in a Python markdown code block.
Dhote and Shweta went on a tour by plane for the first time.Dhote was surprised by the conveyor belt at the airport.As Shweta was getting bored Dhote had an idea of playing a game with her.He asked Shweta to count the number of bags whose individual wei... | {"inputs": ["1\n4\n1 2 3 4"], "outputs": ["3"]} | coding | 291 |
Solve the programming task below in a Python markdown code block.
Polycarp is working on a new project called "Polychat". Following modern tendencies in IT, he decided, that this project should contain chat as well. To achieve this goal, Polycarp has spent several hours in front of his laptop and implemented a chat ser... | {"inputs": ["+adabacaba0\n", "+adabacab`0\n", "+acabadab\n+caba0aba\n", "+`cabadab\n+caba0aba\n", "+acabadab\n+caca0aba\n", "+acabadab\n+caba0ab`\n", "+cab\n+abac\n-abac\n+baca\n", "+dab\n+abac\n-abac\n+baca\n"], "outputs": ["0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n"]} | coding | 503 |
Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given two positive integers a and b, return the number of common factors of a and b.
An integer x is a common factor of a and b if x divides both a and b.
Please complete the following python code precisely:
```pyth... | {"functional": "def check(candidate):\n assert candidate(a = 12, b = 6) == 4\n assert candidate(a = 25, b = 30) == 2\n\n\ncheck(Solution().commonFactors)"} | coding | 89 |
Solve the programming task below in a Python markdown code block.
Jimmy loves playing with strings. He thinks string $\mbox{A}$ is similar to string $\mbox{B}$ if the following conditions are satisfied:
Both strings have the same length (i.e., $A=a_{0}a_{1}\ldots a_{n-1}$ and $B=b_0b_1\ldots b_{n-1}$).
For each valid... | {"inputs": ["8 4\ngiggabaj\n1 1\n1 2\n1 3\n2 4\n"], "outputs": ["8\n6\n2\n1\n"]} | coding | 651 |
Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given an m x n binary matrix mat, return the number of special positions in mat.
A position (i, j) is called special if mat[i][j] == 1 and all other elements in row i and column j are 0 (rows and columns are 0-indexed... | {"functional": "def check(candidate):\n assert candidate(mat = [[1,0,0],[0,0,1],[1,0,0]]) == 1\n assert candidate(mat = [[1,0,0],[0,1,0],[0,0,1]]) == 3\n\n\ncheck(Solution().numSpecial)"} | coding | 109 |
Solve the programming task below in a Python markdown code block.
Alice, Bob and Charlie are bidding for an artifact at an auction.
Alice bids A rupees, Bob bids B rupees, and Charlie bids C rupees (where A, B, and C are distinct).
According to the rules of the auction, the person who bids the highest amount will w... | {"inputs": ["4\n200 100 400\n155 1000 566\n736 234 470\n124 67 2\n"], "outputs": ["Charlie\nBob\nAlice\nAlice\n"]} | coding | 392 |
Solve the programming task below in a Python markdown code block.
You can print your name on a billboard ad. Find out how much it will cost you. Each letter has a default price of £30, but that can be different if you are given 2 parameters instead of 1.
You can not use multiplier "*" operator.
If your name would be ... | {"functional": "_inputs = [['Jeong-Ho Aristotelis'], ['Abishai Charalampos'], ['Idwal Augustin'], ['Hadufuns John', 20], ['Zoroaster Donnchadh'], ['Claude Miljenko'], ['Werner Vigi', 15], ['Anani Fridumar'], ['Paolo Oli'], ['Hjalmar Liupold', 40], ['Simon Eadwulf']]\n_outputs = [[600], [570], [420], [260], [570], [450]... | coding | 134 |
Solve the programming task below in a Python markdown code block.
One particularly well-known fact about zombies is that they move and think terribly slowly. While we still don't know why their movements are so sluggish, the problem of laggy thinking has been recently resolved. It turns out that the reason is not (as p... | {"inputs": ["2 1\n1 2\n", "2 1\n1 2\n", "3 2\n1 2\n2 3\n", "3 2\n1 2\n2 3\n", "3 3\n2 1\n1 3\n3 2\n", "3 3\n2 1\n1 3\n3 2\n", "4 4\n1 2\n2 3\n3 1\n4 1\n", "7 4\n1 2\n2 3\n3 1\n4 1\n"], "outputs": ["yes\n", "yes\n", "yes\n", "yes\n", "no\n", "no\n", "no\n", "no\n"]} | coding | 423 |
Solve the programming task below in a Python markdown code block.
Check Tutorial tab to know how to to solve.
Here is a sample line of code that can be executed in Python:
print("Hello, World!")
You can just as easily store a string as a variable and then print it to stdout:
my_string = "Hello, World!"
print(... | {"inputs": [""], "outputs": ["Hello World!\n"]} | coding | 132 |
Solve the programming task below in a Python markdown code block.
Vasya takes part in the orienteering competition. There are n checkpoints located along the line at coordinates x_1, x_2, ..., x_{n}. Vasya starts at the point with coordinate a. His goal is to visit at least n - 1 checkpoint in order to finish the compe... | {"inputs": ["1 0\n0\n", "1 5\n0\n", "1 7\n7\n", "1 0\n0\n", "1 7\n7\n", "1 5\n0\n", "1 7\n1\n", "1 2\n7\n"], "outputs": ["0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n"]} | coding | 443 |
Solve the programming task below in a Python markdown code block.
Create a function named `divisors`/`Divisors` that takes an integer `n > 1` and returns an array with all of the integer's divisors(except for 1 and the number itself), from smallest to largest. If the number is prime return the string '(integer) is prim... | {"functional": "_inputs = [[15], [253], [24], [13], [3], [29]]\n_outputs = [[[3, 5]], [[11, 23]], [[2, 3, 4, 6, 8, 12]], ['13 is prime'], ['3 is prime'], ['29 is prime']]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return math.isclose(a, b, rel_tol=tol, abs... | coding | 176 |
Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given a string s, and an array of pairs of indices in the string pairs where pairs[i] = [a, b] indicates 2 indices(0-indexed) of the string.
You can swap the characters at any pair of indices in the given pair... | {"functional": "def check(candidate):\n assert candidate(s = \"dcab\", pairs = [[0,3],[1,2]]) == \"bacd\"\n assert candidate(s = \"dcab\", pairs = [[0,3],[1,2],[0,2]]) == \"abcd\"\n assert candidate(s = \"cba\", pairs = [[0,1],[1,2]]) == \"abc\"\n\n\ncheck(Solution().smallestStringWithSwaps)"} | coding | 144 |
Solve the programming task below in a Python markdown code block.
A special type of prime is generated by the formula `p = 2^m * 3^n + 1` where `m` and `n` can be any non-negative integer.
The first `5` of these primes are `2, 3, 5, 7, 13`, and are generated as follows:
```Haskell
2 = 2^0 * 3^0 + 1
3 = 2^1 * 3^0 + 1
... | {"functional": "_inputs = [[0, 10], [0, 15], [0, 100], [100, 1000], [340, 500], [3400, 5000], [20000, 60000], [750000, 1000000], [300000, 900000], [100, 1000000], [500000, 1000000], [1000000, 1500000], [0, 1500000]]\n_outputs = [[4], [5], [10], [8], [2], [2], [2], [3], [6], [32], [5], [2], [44]]\nimport math\ndef _deep... | coding | 346 |
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"]} | coding | 229 |
Solve the programming task below in a Python markdown code block.
ABCXYZ company has up to 100 employees.
The company decides to create a unique identification number (UID) for each of its employees.
The company has assigned you the task of validating all the randomly generated UIDs.
A valid UID must follow the ru... | {"inputs": ["2\nB1CD102354\nB1CDEF2354\n"], "outputs": ["Invalid\nValid\n"]} | coding | 312 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.