info stringlengths 120 50k | question stringlengths 504 10.4k | avg@8_qwen3_4b_instruct_2507 float64 0 0.88 |
|---|---|---|
{"tests": "{\"inputs\": [\"2 0\\n\", \"4 2\\n3 2\\n1 4\\n\", \"3 3\\n1 2\\n3 1\\n2 3\\n\", \"10 10\\n1 5\\n1 8\\n1 9\\n5 8\\n8 9\\n4 7\\n2 3\\n3 10\\n2 6\\n2 10\\n\", \"100000 0\\n\", \"3 1\\n2 3\\n\", \"2 1\\n1 2\\n\", \"6 9\\n1 2\\n1 4\\n1 5\\n2 3\\n2 5\\n2 6\\n3 5\\n4 6\\n5 6\\n\", \"1 0\\n\", \"15 10\\n2 3\\n5 4\\n... | Ujan has a lot of useless stuff in his drawers, a considerable part of which are his math notebooks: it is time to sort them out. This time he found an old dusty graph theory notebook with a description of a graph.
It is an undirected weighted graph on n vertices. It is a complete graph: each pair of vertices is conne... | 0 |
{"tests": "{\"inputs\": [\"4\\n4\\nLRUD\\n4\\nLURD\\n5\\nRRUDU\\n5\\nLLDDR\\n\", \"1\\n10\\nRULLDRRULD\\n\", \"1\\n23\\nRUURRDDLLUUURRRDDDLLLUD\\n\", \"1\\n23\\nRUURRDDLLUUURRRDDDLLLUD\\n\", \"1\\n10\\nRULLDRRULD\\n\", \"4\\n4\\nLRUD\\n4\\nLURD\\n5\\nRRUDU\\n5\\nRDDLL\\n\", \"4\\n4\\nLRUD\\n4\\nLURD\\n5\\nDRURU\\n5\\nR... | There is a robot on a coordinate plane. Initially, the robot is located at the point $(0, 0)$. Its path is described as a string $s$ of length $n$ consisting of characters 'L', 'R', 'U', 'D'.
Each of these characters corresponds to some move: 'L' (left): means that the robot moves from the point $(x, y)$ to the poin... | 0.375 |
{"tests": "{\"inputs\": [\"26\\nabcdefghijklmnopqrstuvwxyzfgvnsltvvohywvqhuhtydghtthgdythuhqvwyhovvtlsnvgfzyxwvutsrqponmlkjihgfedcba\\n\", \"26\\n?b????g????l?????rs???????s?f?ceiww??ok????u??qwm???q?fu??wkkoh??wie??f???yx?vuts?q??nm?????g??dc??\\n\", \"2\\nababaaaababaaaababbaaabaabaaaabbbabaababababaaaaaaaaaaaabababa... | Vasya has recently finished writing a book. Now he faces the problem of giving it the title. Vasya wants the title to be vague and mysterious for his book to be noticeable among others. That's why the title should be represented by a single word containing at least once each of the first k Latin letters and not contain... | 0 |
{"tests": "{\"inputs\": [\"? - ? + ? + ? - ? + ? - ? + ? + ? + ? + ? + ? + ? + ? - ? + ? + ? - ? + ? + ? - ? + ? + ? - ? + ? + ? + ? + ? + ? + ? + ? + ? - ? + ? - ? + ? + ? - ? + ? - ? + ? + ? + ? + ? + ? + ? - ? + ? - ? + ? - ? + ? + ? + ? + ? + ? + ? - ? + ? - ? + ? + ? + ? + ? - ? + ? + ? + ? + ? + ? + ? + ? - ? - ?... | You are given a rebus of form ? + ? - ? + ? = n, consisting of only question marks, separated by arithmetic operation '+' and '-', equality and positive integer n. The goal is to replace each question mark with some positive integer from 1 to n, such that equality holds.
Input
The only line of the input contains a re... | 0 |
{"tests": "{\"inputs\": [[5, []], [0, []], [9, []], [0, [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [25, 26], [26, 27], [27, 28], [2... | "The Shell Game" involves cups upturned on a playing surface, with a ball placed underneath one of them. The index of the cups are swapped around multiple times. After that the players will try to find which cup contains the ball.
Your task is as follows. Given the cup that the ball starts under, and list of swaps, ... | 0 |
{"tests": "{\"inputs\": [[1], [5], [16], [27], [121]], \"outputs\": [[\"odd\"], [\"even\"], [\"odd\"], [\"even\"], [\"odd\"]]}", "source": "primeintellect"} | Given an integer `n` return `"odd"` if the number of its divisors is odd. Otherwise return `"even"`.
**Note**: big inputs will be tested.
## Examples:
All prime numbers have exactly two divisors (hence `"even"`).
For `n = 12` the divisors are `[1, 2, 3, 4, 6, 12]` – `"even"`.
For `n = 4` the divisors are `[1, 2, 4... | 0 |
{"tests": "{\"inputs\": [\"2148437504\\n\", \"2190530369\\n\", \"1024000007\\n\", \"3758096389\\n\", \"8589942369\\n\", \"5159780354\\n\", \"2684354990\\n\", \"134217734\\n\", \"8707129352\\n\", \"1160290644\\n\", \"145746783\\n\", \"8719074755\\n\", \"1550072581\\n\", \"3710937503\\n\", \"1222800277\\n\", \"1073746202... | Vasya is a regular participant at programming contests and is already experienced in finding important sentences in long statements. Of course, numbers constraints are important — factorization of a number less than 1000000 is easier than of a number less than 1000000000. However, sometimes it's hard to understand the ... | 0 |
{"tests": "{\"inputs\": [\"2\\n3 2\\n7 6 3 5 4 2 1\\n3 2\\n7 6 5 4 3 2 1\\n\", \"2\\n3 2\\n7 6 3 5 4 2 1\\n3 2\\n14 6 5 4 3 2 1\\n\", \"2\\n3 1\\n7 6 3 5 4 2 1\\n3 2\\n14 6 5 4 3 2 1\\n\", \"2\\n3 2\\n7 6 3 5 4 2 1\\n3 1\\n23 6 5 4 3 2 1\\n\", \"2\\n3 1\\n7 6 3 5 4 2 1\\n3 1\\n23 6 5 4 3 2 1\\n\", \"2\\n3 2\\n7 6 3 5 4... | Drazil likes heap very much. So he created a problem with heap:
There is a max heap with a height h implemented on the array. The details of this heap are the following:
This heap contains exactly 2^h - 1 distinct positive non-zero integers. All integers are distinct. These numbers are stored in the array a indexed f... | 0 |
{"tests": "{\"inputs\": [\"100\\n79 79 79 97 97 97 64 64 64 2 2 2 38 38 38 65 65 65 10 10 10 25 25 25 53 53 53 73 73 73 11 11 11 29 29 29 93 93 93 73 73 73 89 89 89 72 72 72 49 49 49 78 78 78 92 92 92 90 90 90 95 95 95 92 92 92 12 12 12 65 65 65 81 81 81 5 5 5 21 21 21 94 94 94 51 51 51 44 44 44 55 55 55 47 47 47 24 24... | You are given an array a consisting of n integers. We denote the subarray a[l..r] as the array [a_l, a_{l + 1}, ..., a_r] (1 ≤ l ≤ r ≤ n).
A subarray is considered good if every integer that occurs in this subarray occurs there exactly thrice. For example, the array [1, 2, 2, 2, 1, 1, 2, 2, 2] has three good subarrays... | 0.25 |
{"tests": "{\"inputs\": [\"9\\n1500\\n1212\\n1500\\n1221\\n1500\\n122\\n1500\\n12121\\n1500\\n22\\n1500\\n1111112111111112\\n1500\\n1111111111221111111\\n1500\\n111111122\\n1500\\n11111121111121111111\\n\", \"1\\n1000000\\n22\\n\", \"1\\n941759\\n1223231111\\n\", \"1\\n1000000\\n2211\\n\", \"1\\n1000000\\n221\\n\", \"1... | We start with a string s consisting only of the digits 1, 2, or 3. The length of s is denoted by |s|. For each i from 1 to |s|, the i-th character of s is denoted by s_i.
There is one cursor. The cursor's location ℓ is denoted by an integer in \{0, …, |s|\}, with the following meaning:
* If ℓ = 0, then the cursor... | 0 |
{"tests": "{\"inputs\": [\"1\\n4\\n\", \"1\\n2\\n\", \"1\\n7\\n\", \"1\\n5\\n\", \"1\\n6\\n\", \"1\\n9\\n\", \"1\\n11\\n\", \"1\\n12\\n\", \"1\\n13\\n\", \"1\\n18\\n\", \"1\\n24\\n\", \"1\\n23\\n\", \"1\\n31\\n\", \"1\\n27\\n\", \"1\\n39\\n\", \"1\\n54\\n\", \"1\\n50\\n\", \"1\\n44\\n\", \"1\\n108\\n\", \"1\\n14\\n\", ... | n people came to a party. Then those, who had no friends among people at the party, left. Then those, who had exactly 1 friend among those who stayed, left as well. Then those, who had exactly 2, 3, ..., n - 1 friends among those who stayed by the moment of their leaving, did the same.
What is the maximum amount of pe... | 0 |
{"tests": "{\"inputs\": [[\"abjd####jfk#\"], [\"gfh#jds###d#dsd####dasdaskhj###dhkjs####df##s##d##\"], [\"831####jns###s#cas/*####-5##s##6+yqw87e##hfklsd-=-28##fds##\"], [\"######831###dhkj####jd#dsfsdnjkf###d####dasns\"], [\"\"], [\"#######\"], [\"####gfdsgf##hhs#dg####fjhsd###dbs########afns#######sdanfl##db#####s#a\... | Assume `"#"` is like a backspace in string. This means that string `"a#bc#d"` actually is `"bd"`
Your task is to process a string with `"#"` symbols.
## Examples
```
"abc#d##c" ==> "ac"
"abc##d######" ==> ""
"#######" ==> ""
"" ==> ""
```
Write your solution by modifying this code:
``... | 0 |
{"tests": "{\"inputs\": [\"1\\n6 9 0 0\\n4\\n3 2 0 4\\n1 3 0 0\\n4 4 2 1\\n4 2 0 0\\n0\", \"1\\n6 9 0 0\\n4\\n3 2 0 4\\n1 3 0 0\\n4 4 2 1\\n4 1 0 0\\n0\", \"1\\n6 9 0 0\\n4\\n3 1 0 4\\n1 3 0 0\\n5 4 2 1\\n4 1 0 0\\n0\", \"1\\n6 9 0 0\\n4\\n3 2 0 4\\n1 3 0 0\\n4 8 2 1\\n4 2 0 0\\n0\", \"1\\n6 9 0 0\\n4\\n3 3 0 4\\n1 3 0... | problem
Mobiles are widely known as moving works of art. The IOI Japan Committee has decided to create mobiles to publicize JOI. JOI public relations mobiles are sticks, strings, and weights. It is constructed as follows using the three types of elements of.
* One end of the bar is painted blue and the other end is p... | 0 |
{"tests": "{\"inputs\": [[[6, 6]], [[5, 6, 4]], [[3, 15, 8, 20]], [[6]], [[3, 3]], [[20]], [[3, 6]]], \"outputs\": [[3], [5], [44], [0], [0], [1], [0]]}", "source": "primeintellect"} | With one die of 6 sides we will have six different possible results:``` 1, 2, 3, 4, 5, 6``` .
With 2 dice of six sides, we will have 36 different possible results:
```
(1,1),(1,2),(2,1),(1,3),(3,1),(1,4),(4,1),(1,5),
(5,1), (1,6),(6,1),(2,2),(2,3),(3,2),(2,4),(4,2),
(2,5),(5,2)(2,6),(6,2),(3,3),(3,4),(4,3),(3,5),(5,... | 0 |
{"tests": "{\"inputs\": [\"3\\n2 2 2\\n\", \"2\\n2 3\\n\", \"3\\n1 1 1\\n\", \"1\\n1000000000\\n\", \"10\\n10 10 7 9 8 3 3 10 7 3\\n\", \"100\\n23 39 85 46 97 72 41 70 37 18 8 40 33 61 12 79 51 78 61 66 85 97 78 14 70 47 100 40 15 40 61 52 19 30 14 91 82 56 10 6 68 24 97 61 31 78 18 45 88 6 37 38 51 86 37 42 58 30 79 5... | You are given an array of $n$ positive integers $a_1, a_2, \ldots, a_n$. Your task is to calculate the number of arrays of $n$ positive integers $b_1, b_2, \ldots, b_n$ such that:
$1 \le b_i \le a_i$ for every $i$ ($1 \le i \le n$), and
$b_i \neq b_{i+1}$ for every $i$ ($1 \le i \le n - 1$).
The number of such array... | 0 |
{"tests": "{\"inputs\": [\"2\\n1 2 3 6\\n3 4 7 8\\n\", \"3\\n1 3 2 4\\n4 5 6 7\\n3 4 5 5\\n\", \"6\\n1 5 2 9\\n2 4 5 8\\n3 6 7 11\\n7 10 12 16\\n8 11 13 17\\n9 12 14 18\\n\", \"1\\n21044762 968128997 570202182 610619156\\n\", \"2\\n4 4 4 5\\n4 5 1 2\\n\", \"2\\n311374951 311375694 79710796 79710890\\n311374081 31137467... | Filled with optimism, Hyunuk will host a conference about how great this new year will be!
The conference will have $n$ lectures. Hyunuk has two candidate venues $a$ and $b$. For each of the $n$ lectures, the speaker specified two time intervals $[sa_i, ea_i]$ ($sa_i \le ea_i$) and $[sb_i, eb_i]$ ($sb_i \le eb_i$). If... | 0.875 |
{"tests": "{\"inputs\": [[1], [2], [3], [4], [5], [6], [7], [8], [9], [10], [11], [12], [20], [35], [36], [37], [100], [101], [102], [103], [104], [105], [190], [2890], [38890], [488890], [5888890], [3678608], [3678609], [3678610], [3678611], [3678612], [3678613], [3678614], [3897249], [3897189], [3897309], [3897369], ... | Ho ho! So you think you know integers, do you? Well then, young wizard, tell us what the Nth digit of the [Champernowne constant](https://en.wikipedia.org/wiki/Champernowne_constant) is!
The constant proceeds like this: `0.12345678910111213141516...`
I hope you see the pattern!
Conjure a function that will accept an... | 0 |
{"tests": "{\"inputs\": [\"1\\n1 0 0 1 0\\n\", \"1\\n2 0 0 1 1\\n\", \"1\\n2 0 1 2 1\\n\", \"1\\n1 1 0 1 1\\n\", \"1\\n1 0 1 2 0\\n\", \"1\\n1 1 0 2 0\\n\", \"1\\n1 1 1 2 1\\n\", \"1\\n2 1 0 2 1\\n\", \"1\\n2 1 0 1 2\\n\", \"1\\n1 2 0 1 2\\n\", \"1\\n2 0 2 2 2\\n\", \"1\\n1 1 2 3 1\\n\", \"1\\n1 2 0 2 1\\n\", \"1\\n1 1... | Input
The first line of the input contains a single integer N (1 ≤ N ≤ 24). The next N lines contain 5 space-separated integers each. The first three integers will be between 0 and 2, inclusive. The last two integers will be between 0 and 3, inclusive. The sum of the first three integers will be equal to the sum of th... | 0 |
{"tests": "{\"inputs\": [\"5\\n100\\n12\\n8\\n2021\\n10000\\n\", \"2\\n999999999\\n1000000000\\n\", \"1\\n721156322\\n\", \"1\\n721156322\\n\", \"2\\n999999999\\n1000000000\\n\", \"1\\n1156079886\\n\", \"2\\n836671254\\n1000000000\\n\", \"5\\n110\\n12\\n8\\n2021\\n10000\\n\", \"1\\n1668987868\\n\", \"2\\n817117042\\n10... | Alice has just learned addition. However, she hasn't learned the concept of "carrying" fully — instead of carrying to the next column, she carries to the column two columns to the left.
For example, the regular way to evaluate the sum $2039 + 2976$ would be as shown:
However, Alice evaluates it as shown:
In particul... | 0 |
{"tests": "{\"inputs\": [\"6 17 99\\n\", \"100 100 100\\n\", \"49 4 4\\n\", \"17 6 99\\n\", \"1 100 99\\n\", \"1 1 0\\n\", \"4 78 78\\n\", \"99 1 1\\n\", \"24 14 76\\n\", \"100 100 100\\n\", \"1 100 0\\n\", \"10 16 0\\n\", \"2 1 100\\n\", \"20 1 43\\n\", \"100 1 100\\n\", \"42 83 98\\n\", \"2 99 51\\n\", \"99 1 51\\n\"... | A progress bar is an element of graphical interface that displays the progress of a process for this very moment before it is completed. Let's take a look at the following form of such a bar.
A bar is represented as n squares, located in line. To add clarity, let's number them with positive integers from 1 to n from t... | 0 |
{"tests": "{\"inputs\": [[\"13:00\"], [\"13:09\"], [\"13:15\"], [\"13:29\"], [\"13:30\"], [\"13:31\"], [\"13:45\"], [\"13:59\"], [\"00:48\"], [\"00:08\"], [\"12:00\"], [\"00:00\"], [\"19:01\"], [\"07:01\"], [\"01:59\"], [\"12:01\"], [\"00:01\"], [\"11:31\"], [\"23:31\"], [\"11:45\"], [\"11:59\"], [\"23:45\"], [\"23:59\... | Given time in 24-hour format, convert it to words.
```
For example:
13:00 = one o'clock
13:09 = nine minutes past one
13:15 = quarter past one
13:29 = twenty nine minutes past one
13:30 = half past one
13:31 = twenty nine minutes to two
13:45 = quarter to two
00:48 = twelve minutes to one
00:08 = eight minutes p... | 0 |
{"tests": "{\"inputs\": [\"8\\n2\\nomura\\ntoshio\\nraku\\ntanaka\\ninura\\nyoshoi\\nhayashi\\nmiura\\n3\\n1\\ntasaka\\nnakata\\ntanaka\\n1\\n1\\nfoo\\n5\\n2\\npsqt\\nabcdef\\nabzdefa\\npqrst\\nabdxcef\\n0\", \"8\\n2\\nomura\\ntoshio\\nraku\\nt`naka\\nioura\\nyoshoi\\nhayashi\\nmiura\\n3\\n1\\ntasaka\\nnakata\\ntanaka\... | Meikyokan University is very famous for its research and education in the area of computer science. This university has a computer center that has advanced and secure computing facilities including supercomputers and many personal computers connected to the Internet.
One of the policies of the computer center is to le... | 0 |
{"tests": "{\"inputs\": [\"1 3\\n3 4\\n3 5\\n3 6\\n4 6\\n4 7\\n4 7\\n5 6\\n6 7\\n5 8\\n5 8\\n3 8\\n6 9\\n7 9\\n8 9\\n9 2\\n0 0\\n1 3\\n3 4\\n3 4\\n4 2\\n0 0\", \"1 3\\n3 4\\n3 5\\n3 6\\n4 6\\n4 7\\n4 7\\n5 6\\n6 7\\n5 8\\n1 8\\n3 8\\n6 9\\n7 9\\n8 9\\n9 2\\n0 0\\n1 3\\n3 4\\n3 4\\n4 2\\n1 0\", \"1 3\\n3 4\\n3 5\\n3 6\\... | In 1862, the lord of Aizu was ordered to serve as a guardian of Kyoto. The Kyoto Shugoshoku is an important role to protect Kyoto at the end of the Edo period when security has deteriorated. You have to patrol the city by sharing it with the shogunate and other clan. However, when it came time to decide the sharing rou... | 0 |
{"tests": "{\"inputs\": [\"2\\n6 2\\n1 2\", \"3\\n6 2 3\\n1 2\\n1 3\", \"1\\n10\", \"10\\n2 3 4 5 6 7 8 9 10 11\\n1 2\\n2 3\\n3 4\\n4 5\\n5 6\\n6 7\\n4 8\\n8 9\\n9 10\\n\", \"4\\n6 2 3 2\\n1 2\\n2 3\\n3 4\\n\", \"1\\n15\\n\", \"2\\n6 3\\n1 2\\n\", \"1\\n23\\n\", \"1\\n17\\n\", \"1\\n11\\n\", \"1\\n13\\n\", \"1\\n4\\n\"... | Ilya is very fond of graphs, especially trees. During his last trip to the forest Ilya found a very interesting tree rooted at vertex 1. There is an integer number written on each vertex of the tree; the number written on vertex i is equal to a_{i}.
Ilya believes that the beauty of the vertex x is the greatest common ... | 0.25 |
{"tests": "{\"inputs\": [[\"74/3\"], [\"9999/24\"], [\"74/30\"], [\"13/5\"], [\"5/3\"], [\"1/1\"], [\"10/10\"], [\"900/10\"], [\"9920/124\"], [\"6/2\"], [\"9/77\"], [\"96/100\"], [\"12/18\"], [\"6/36\"], [\"1/18\"], [\"-64/8\"], [\"-6/8\"], [\"-9/78\"], [\"-504/26\"], [\"-47/2\"], [\"-21511/21\"]], \"outputs\": [[\"24 ... | In Math, an improper fraction is a fraction where the numerator (the top number) is greater than or equal to the denominator (the bottom number) For example: ```5/3``` (five third).
A mixed numeral is a whole number and a fraction combined into one "mixed" number. For example: ```1 1/2``` (one and a half) is a mixed n... | 0 |
{"tests": "{\"inputs\": [[0], [1], [2], [3], [10]], \"outputs\": [[1], [2], [4], [7], [56]]}", "source": "primeintellect"} | # Task
A cake is sliced with `n` straight lines. Your task is to calculate the maximum number of pieces the cake can have.
# Example
For `n = 0`, the output should be `1`.
For `n = 1`, the output should be `2`.
For `n = 2`, the output should be `4`.
For `n = 3`, the output should be `7`.
See the followin... | 0 |
{"tests": "{\"inputs\": [\"2\\nP 1\\nP 2\\n2\\nP 2\\nM -2\\n0\", \"2\\nP 1\\nP 2\\n\\n2\\nP 0\\nM -2\\n\\n0\", \"2\\nP 1\\nP 4\\n\\n2\\nP 0\\nM -2\\n\\n0\", \"2\\nQ 1\\nP 4\\n\\n2\\nP -1\\nM -2\\n\\n0\", \"2\\nQ 1\\nP 4\\n\\n2\\nP -1\\nM -3\\n\\n0\", \"2\\nQ 2\\nP 4\\n\\n0\\nP 0\\nM -2\\n\\n0\", \"2\\nQ 2\\nP 8\\n\\n2\... | Did you ever hear about 'crossing the bridge noodle' ? Let me tell you that it's not some kind of bridge made of noodles. It's a dish, a kind of rice noodle soup. Mr.Ping makes the best noodle soup and his son Po is eagerly waiting for the user reviews in his father's blog. Users can vote with a (+) or a (-) and accord... | 0 |
{"tests": "{\"inputs\": [[\"\"], [{}], [\"abc\"], [\"2d6+3 abc\"], [\"abc 2d6+3\"], [\"2d6++4\"]], \"outputs\": [[false], [false], [false], [false], [false], [false]]}", "source": "primeintellect"} | # The die is cast!
Your task in this kata is to write a "dice roller" that interprets a subset of [dice notation](http://en.wikipedia.org/wiki/Dice_notation).
# Description
In most role-playing games, die rolls required by the system are given in the form `AdX`. `A` and `X` are variables, separated by the letter **d... | 0 |
{"tests": "{\"inputs\": [\"4 0 0\\n1 -1\\n1 3\\n3 3\\n3 -1\\n\", \"3 0 0\\n-10 1\\n0 2\\n1 1\\n\", \"3 0 0\\n-1 1\\n0 3\\n1 1\\n\", \"20 -999719 -377746\\n-999718 -377746\\n-997432 -940486\\n-982215 -950088\\n-903861 -997725\\n-127953 -999833\\n846620 -999745\\n920305 -992903\\n947027 -986746\\n991646 -959876\\n998264 ... | Peter got a new snow blower as a New Year present. Of course, Peter decided to try it immediately. After reading the instructions he realized that it does not work like regular snow blowing machines. In order to make it work, you need to tie it to some point that it does not cover, and then switch it on. As a result it... | 0 |
{"tests": "{\"inputs\": [\"5\\n1 2 3 5 4\\n1 5 3 2 4\\n\", \"5\\n1 4 3 2 5\\n-3 4 -10 2 7\\n\", \"2\\n2 1\\n-2 -3\\n\", \"10\\n4 7 3 2 5 1 9 10 6 8\\n-4 40 -46 -8 -16 4 -10 41 12 3\\n\", \"25\\n12 13 15 20 24 16 7 10 3 2 14 23 18 8 21 5 6 4 1 11 19 9 22 25 17\\n-2 -46 -23 -13 -46 -9 -5 -4 -10 -40 -36 -31 -45 -50 -47 -2... | Alice is visiting New York City. To make the trip fun, Alice will take photos of the city skyline and give the set of photos as a present to Bob. However, she wants to find the set of photos with maximum beauty and she needs your help.
There are $n$ buildings in the city, the $i$-th of them has positive height $h_i$. ... | 0.25 |
{"tests": "{\"inputs\": [[0], [-64], [2016], [1974], [-10], [666], [1857], [2000], [-300], [-1]], \"outputs\": [[\"0 has 366 days\"], [\"-64 has 366 days\"], [\"2016 has 366 days\"], [\"1974 has 365 days\"], [\"-10 has 365 days\"], [\"666 has 365 days\"], [\"1857 has 365 days\"], [\"2000 has 366 days\"], [\"-300 has 36... | A variation of determining leap years, assuming only integers are used and years can be negative and positive.
Write a function which will return the days in the year and the year entered in a string. For example 2000, entered as an integer, will return as a string 2000 has 366 days
There are a few assumptions we wi... | 0 |
{"tests": "{\"inputs\": [\"4\\n1 2 3\\n10 20 30\\n10\\n1 2 2 1 5 5 1 8 8\\n10 1 1 20 2 1 30 1 1\\n3\\n1 1\\n1 1\\n0\", \"4\\n1 2 3\\n10 20 30\\n10\\n1 2 2 1 5 5 1 8 8\\n10 1 1 20 1 1 0 1 1\\n3\\n1 1\\n1 1\\n0\", \"4\\n1 2 3\\n10 20 30\\n10\\n1 2 2 1 5 5 1 8 8\\n10 2 1 20 2 1 30 1 1\\n3\\n1 1\\n1 1\\n0\", \"4\\n1 2 3\\n... | Bridge Removal
ICPC islands once had been a popular tourist destination. For nature preservation, however, the government decided to prohibit entrance to the islands, and to remove all the man-made structures there. The hardest part of the project is to remove all the bridges connecting the islands.
There are n islan... | 0 |
{"tests": "{\"inputs\": [[null, 0], [\"\", 0], [\"This is a test!\", 0], [\"This is a test!\", 1], [\"This is a test!\", 3], [\"This is a test!\", 4], [\"This is a test!\", -1], [\"This is a test!\", -5], [\"Brrrr\", 99], [\"AEIOUaeiou\", 1]], \"outputs\": [[null], [\"\"], [\"This is a test!\"], [\"Thes is i tast!\"], ... | You get a "text" and have to shift the vowels by "n" positions to the right.
(Negative value for n should shift to the left.)
"Position" means the vowel's position if taken as one item in a list of all vowels within the string.
A shift by 1 would mean, that every vowel shifts to the place of the next vowel.
Shifting ov... | 0 |
{"tests": "{\"inputs\": [\"5 3 6 9\\n9 1 5 3 1\", \"21 10 0 4\\n5 2 13 -1 0\", \"21 7 1 4\\n0 2 23 -1 2\", \"9 3 1 9\\n22 2 6 2 0\", \"21 14 1 4\\n2 2 0 -1 2\", \"5 3 6 9\\n9 1 6 3 1\", \"8 3 6 9\\n9 1 6 3 1\", \"8 3 6 9\\n15 1 6 3 1\", \"8 3 6 9\\n15 0 6 3 1\", \"8 3 6 9\\n22 0 6 3 1\", \"11 3 6 9\\n22 0 6 3 1\", \"11... | Problem statement
AOR Ika got a cabbage with $ N $ leaves. The leaves of this cabbage are numbered $ 1, \ ldots, N $ in order from the outside, and the dirtiness of the $ i $ th leaf is $ D_i $. The larger this value is, the worse the degree of dirt is. AOR Ika-chan decided to use the cabbage leaves for cooking, so sh... | 0 |
{"tests": "{\"inputs\": [[[2, 10, 9, 3]], [[3, 4, 5, 7]], [[0, 2, 19, 4, 4]], [[3, 2, 1, 0]], [[3, 2, 10, 4, 1, 6]], [[1, 1, 8, 3, 1, 1]], [[0, 1, 2, 3]], [[1, 2, 3, 4]], [[0, -1, 1]], [[0, 2, 3]], [[0]], [[]], [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]], [[0, 1, 3, -2, 5, 4]], [[0, -1, -2, -3, -4]], [[1, -1, 3]], [[1, -1, 2, -2,... | A `Nice array` is defined to be an array where for every value `n` in the array, there is also an element `n-1` or `n+1` in the array.
example:
```
[2,10,9,3] is Nice array because
2=3-1
10=9+1
3=2+1
9=10-1
```
Write a function named `isNice`/`IsNice` that returns `true` if its array argument is a Nice array, else `... | 0 |
{"tests": "{\"inputs\": [[\"AUGUGA\"], [\"AUGUAUAAA\"], [\"UGCGAUGAAUGGGCUCGCUCC\"], [\"AUGUUAAUUUGA\"], [\"AUGUCCUUCCAUCAAGGAAACCAUGCGCGUUCAGCUUUCUGA\"], [\"AUGCUUCAAGUGCACUGGAAAAGGAGAGGGAAAACCAGUUGA\"], [\"AUGGCGUUCAGCUUUCUAUGGAGGGUAGUGUACCCAUGCUGA\"], [\"AUGCAGCUUUCUAUGGAGGGUAGUGUUAACUACCACGCCUGA\"], [\"AUGCUAUGGAGG... | The central dogma of molecular biology is that DNA is transcribed into RNA, which is then tranlsated into protein. RNA, like DNA, is a long strand of nucleic acids held together by a sugar backbone (ribose in this case). Each segment of three bases is called a codon. Molecular machines called ribosomes translate the RN... | 0 |
{"tests": "{\"inputs\": [[0, 1], [1, 2], [5, -1], [505, 4], [321, 123], [0, -1], [-50, 0], [-1, -5], [-5, -5], [-505, 4], [-321, 123], [0, 0], [-5, -1], [5, 1], [-17, -17], [17, 17]], \"outputs\": [[1], [3], [14], [127759], [44178], [-1], [-1275], [-15], [-5], [-127755], [-44055], [0], [-15], [15], [-17], [17]]}", "sou... | Given two integers `a` and `b`, which can be positive or negative, find the sum of all the numbers between including them too and return it. If the two numbers are equal return `a` or `b`.
**Note:** `a` and `b` are not ordered!
## Examples
```python
get_sum(1, 0) == 1 // 1 + 0 = 1
get_sum(1, 2) == 3 // 1 + 2 = 3... | 0 |
{"tests": "{\"inputs\": [[123], [-123], [1000], [4321234], [5], [0], [98989898]], \"outputs\": [[321], [-321], [1], [4321234], [5], [0], [89898989]]}", "source": "primeintellect"} | Given a number, write a function to output its reverse digits. (e.g. given 123 the answer is 321)
Numbers should preserve their sign; i.e. a negative number should still be negative when reversed.
### Examples
```
123 -> 321
-456 -> -654
1000 -> 1
```
Write your solution by modifying this code:
```python
def... | 0 |
{"tests": "{\"inputs\": [[[0, 0], [1, 1]], [[2, 6], [-2, -6]], [[10, -10], [-10, 10]], [[1, -35], [-12, 1]], [[1000, 15], [-7, -214]], [[0, 0], [0, 0]]], \"outputs\": [[[2, 2]], [[-6, -18]], [[-30, 30]], [[-25, 37]], [[-1014, -443]], [[0, 0]]]}", "source": "primeintellect"} | "Point reflection" or "point symmetry" is a basic concept in geometry where a given point, P, at a given position relative to a mid-point, Q has a corresponding point, P1, which is the same distance from Q but in the opposite direction.
## Task
Given two points P and Q, output the symmetric point of point P about Q.
... | 0 |
{"tests": "{\"inputs\": [\"5\\n3 4\\n3 2\\n3 1\\n13 7\\n1010000 9999999\\n\", \"1\\n1 1\\n\", \"1\\n632934461 955818012\\n\", \"1\\n632934461 955818012\\n\", \"1\\n1 1\\n\", \"1\\n632934461 286939621\\n\", \"1\\n1 2\\n\", \"5\\n3 4\\n3 2\\n3 1\\n13 7\\n1010000 14106652\\n\", \"1\\n632934461 107730378\\n\", \"1\\n2 2\\n... | A competitive eater, Alice is scheduling some practices for an eating contest on a magical calendar. The calendar is unusual because a week contains not necessarily $7$ days!
In detail, she can choose any integer $k$ which satisfies $1 \leq k \leq r$, and set $k$ days as the number of days in a week.
Alice is going t... | 0.125 |
{"tests": "{\"inputs\": [\"aaaaa\\n3\\n1 1\\n2 4\\n5 5\\n\", \"aabbbbbbc\\n6\\n1 2\\n2 4\\n2 2\\n1 9\\n5 7\\n3 5\\n\", \"f\\n1\\n1 1\\n\", \"f\\n1\\n1 1\\n\", \"abca\\n1\\n1 4\\n\", \"abca\\n1\\n2 4\\n\", \"aabbbbbbc\\n6\\n1 2\\n2 4\\n2 2\\n2 9\\n5 7\\n3 5\\n\", \"cbbbbbbaa\\n6\\n1 2\\n2 4\\n2 2\\n2 9\\n5 7\\n3 5\\n\",... | Let's call two strings $s$ and $t$ anagrams of each other if it is possible to rearrange symbols in the string $s$ to get a string, equal to $t$.
Let's consider two strings $s$ and $t$ which are anagrams of each other. We say that $t$ is a reducible anagram of $s$ if there exists an integer $k \ge 2$ and $2k$ non-empt... | 0 |
{"tests": "{\"inputs\": [\"1\\n2 3\\nRRGG\\nGGRB\\nBRRR\\nBRRR\", \"2\\n4 5\\n1 1\\nRRRR\\nRRGR\\nRBRR\\nRRRR\", \"2\\n4 5\\n2 1\\nRRRR\\nRRGR\\nRBRR\\nRRRR\", \"1\\n2 1\\nRRGG\\nGGRB\\nBRRR\\nBRRR\", \"1\\n2 1\\nGGRR\\nGGRB\\nBRRR\\nBRRR\", \"1\\n1 1\\nGGRR\\nGGRB\\nBRRR\\nBRRR\", \"1\\n2 3\\nRRGG\\nGGRB\\nBRRR\\nRRBR... | Training is indispensable for achieving good results at ICPC. Rabbit wants to win at ICPC, so he decided to practice today as well.
Today's training is to increase creativity by drawing pictures. Let's draw a pattern well using a square stamp.
I want to use stamps of various sizes to complete the picture of the red, ... | 0 |
{"tests": "{\"inputs\": [\"2\\n2\\n1 3\\n1 4\\n3\\n1 5\\n1 1\\n2 3\\n\", \"19\\n1\\n1 1\\n1\\n1 2\\n1\\n1 1000\\n1\\n1 2000\\n1\\n2 2\\n1\\n2 3\\n1\\n2 1000\\n1\\n2 2000\\n1\\n1999 1999\\n1\\n1999 2000\\n1\\n2000 2000\\n2\\n1 1\\n1 1\\n2\\n1 1\\n1 2\\n2\\n1 2\\n1 1\\n2\\n1 2000\\n1 1\\n2\\n1 1\\n1 2000\\n2\\n1 2000\\n2... | Recently n students from city S moved to city P to attend a programming camp.
They moved there by train. In the evening, all students in the train decided that they want to drink some tea. Of course, no two people can use the same teapot simultaneously, so the students had to form a queue to get their tea.
i-th stude... | 0 |
{"tests": "{\"inputs\": [[\"a-(b)\"], [\"a-(-b)\"], [\"a+(b)\"], [\"a+(-b)\"], [\"(((((((((-((-(((n))))))))))))))\"], [\"(((a-((((-(-(f)))))))))\"], [\"((((-(-(-(-(m-g))))))))\"], [\"(((((((m-(-(((((t)))))))))))))\"], [\"-x\"], [\"-(-(x))\"], [\"-((-x))\"], [\"-(-(-x))\"], [\"-(-(x-y))\"], [\"-(x-y)\"], [\"x-(y+z)\"], ... | In this Kata, you will be given a mathematical string and your task will be to remove all braces as follows:
```Haskell
solve("x-(y+z)") = "x-y-z"
solve("x-(y-z)") = "x-y+z"
solve("u-(v-w-(x+y))-z") = "u-v+w+x+y-z"
solve("x-(-y-z)") = "x+y+z"
```
There are no spaces in the expression. Only two operators are given: `"... | 0 |
{"tests": "{\"inputs\": [\"2 2 1\\nH 1\\n\", \"200000 200000 1\\nH 1\\n\", \"2 2 2\\nH 1\\nV 1\\n\", \"10 10 10\\nV 6\\nH 8\\nV 4\\nV 8\\nH 2\\nH 5\\nV 9\\nH 7\\nH 3\\nV 7\\n\", \"2 2 1\\nV 1\\n\", \"2 2 2\\nV 1\\nH 1\\n\", \"2 4 1\\nH 2\\n\", \"2 3 1\\nH 1\\n\", \"5 15 10\\nH 8\\nH 9\\nV 1\\nH 2\\nH 6\\nH 4\\nH 1\\nV ... | Leonid wants to become a glass carver (the person who creates beautiful artworks by cutting the glass). He already has a rectangular w mm × h mm sheet of glass, a diamond glass cutter and lots of enthusiasm. What he lacks is understanding of what to carve and how.
In order not to waste time, he decided to practice t... | 0.5 |
{"tests": "{\"inputs\": [\"4\\n3\\n12 16 14\\n1\\n1\\n3\\n1 2 3\\n6\\n81 75 75 93 93 87\\n\", \"4\\n3\\n12 16 14\\n1\\n1\\n3\\n1 2 3\\n6\\n8 75 75 93 93 87\\n\", \"4\\n3\\n12 16 14\\n1\\n1\\n3\\n1 2 1\\n6\\n81 75 75 93 93 87\\n\", \"4\\n3\\n12 19 14\\n1\\n1\\n3\\n1 2 3\\n6\\n8 75 80 93 133 87\\n\", \"4\\n3\\n12 18 14\\... | $n$ towns are arranged in a circle sequentially. The towns are numbered from $1$ to $n$ in clockwise order. In the $i$-th town, there lives a singer with a repertoire of $a_i$ minutes for each $i \in [1, n]$.
Each singer visited all $n$ towns in clockwise order, starting with the town he lives in, and gave exactly one... | 0 |
{"tests": "{\"inputs\": [\"?&?&?|?|?&?\", \"?|?&?|?&?&?\", \"?&?&?|?&?|?\", \"?&?|?|?&?&?\", \"?|?|?&?&?&?\", \"?&?&?&?|?|?\", \"?|?&?&?|?&?\", \"?&?|?&?&?|?\", \"?|?|?&?&??&\", \"?|?&?&?&?|?\", \"?|?&?|?&??&\", \"?&?|?|?&??&\", \"?|?|?&??&?&\", \"?|?|?&?&?&?\", \"?&?&?&?|?|?\", \"?|?&?&?|?&?\", \"?&?|?&?&?|?\", \"?&?&... | C: Short-circuit evaluation
problem
Naodai-kun and Hokkaido University-kun are playing games. Hokkaido University first generates the following logical formula represented by BNF.
<formula> :: = <or-expr>
<or-expr> :: = <and-expr>
| <or-expr> "|" <and-expr>
<and-expr> :: = <term>
| <and-expr> "&" <term>
<term> :: =... | 0 |
{"tests": "{\"inputs\": [\"1\\nx eazqyp pnop pngtg ye obmpngt xmybp mr lygw\", \"1\\nx pyqzae pnop pngtg ye obmpngt xmybp mr lygw\", \"1\\nx pyqzae pnop pngtg ye onmpbgt xmybp mr lygw\", \"1\\nx pyqzae pnop pngtg ye pnmobgt xmybp mr lygw\", \"1\\nx pyqzae pnop pngtg ye pnmobgt xmybp rm lygw\", \"1\\nx pyqzae pnop pngtg... | One of the simple ciphers is the affine cipher. First, replace the letters a to z with the numbers a = 0, b = 1, c = 2, ..., x = 23, y = 24, z = 25 and 0 to 25. Then replace the original alphabet with the following formula.
$ F (\ gamma) = (\ alpha \ cdot \ gamma + \ beta) $ mod $ 26 $
However, mod 26 represents the ... | 0.75 |
{"tests": "{\"inputs\": [\"O O .\\n O O . .\\n. . . . .\\n . . . .\\n . O .\\n\", \". . O\\n . O O .\\nO . O . O\\n O O O O\\n . . O\\n\", \". . .\\n . O . .\\n. O O . .\\n . . O .\\n . O .\\n\", \"O O O\\n O O . O\\nO . O O O\\n O . O O\\n O O .\\n\", \"O O O\\n O O . O\\nO . O O O\\n O O O O\\n . O O\\n\", \"O O... | Karlsson has visited Lillebror again. They found a box of chocolates and a big whipped cream cake at Lillebror's place. Karlsson immediately suggested to divide the sweets fairly between Lillebror and himself. Specifically, to play together a game he has just invented with the chocolates. The winner will get the cake a... | 0 |
{"tests": "{\"inputs\": [[1], [2], [3], [4], [5], [20], [30], [40], [43], [60], [70], [90], [200], [275]], \"outputs\": [[1], [2], [3], [5], [7], [627], [5604], [37338], [63261], [966467], [4087968], [56634173], [3972999029388], [1520980492851175]]}", "source": "primeintellect"} | # How many ways can you make the sum of a number?
From wikipedia: https://en.wikipedia.org/wiki/Partition_(number_theory)#
>In number theory and combinatorics, a partition of a positive integer *n*, also called an *integer partition*, is a way of writing n as a sum of positive integers. Two sums that differ only in t... | 0 |
{"tests": "{\"inputs\": [\"3\\n3\\n1 5\\n2 10\\n2 8\\n7\\n0 1\\n3 1\\n1 1\\n6 1\\n1 1\\n4 1\\n4 1\\n6\\n2 6\\n2 3\\n2 8\\n2 7\\n4 4\\n5 5\\n\", \"3\\n3\\n1 5\\n2 10\\n2 4\\n7\\n0 1\\n3 1\\n1 1\\n6 1\\n1 1\\n4 1\\n4 1\\n6\\n2 6\\n2 3\\n2 8\\n2 7\\n4 4\\n5 5\\n\", \"3\\n3\\n1 5\\n2 10\\n2 8\\n7\\n0 1\\n1 1\\n1 1\\n6 1\\n... | The only difference between easy and hard versions is constraints.
Now elections are held in Berland and you want to win them. More precisely, you want everyone to vote for you.
There are $n$ voters, and two ways to convince each of them to vote for you. The first way to convince the $i$-th voter is to pay him $p_i$ ... | 0 |
{"tests": "{\"inputs\": [\"4\\n\", \"10000\\n\", \"7\\n\", \"36\\n\", \"10\\n\", \"999999999999999999\\n\", \"789136710974630947\\n\", \"999999999999999989\\n\", \"1000000000000000000\\n\", \"776930\\n\", \"219760524792138559\\n\", \"58929554039\\n\", \"10\\n\", \"43\\n\", \"43\\n\", \"43\\n\", \"36\\n\", \"2\\n\", \"1... | Little X has met the following problem recently.
Let's define f(x) as the sum of digits in decimal representation of number x (for example, f(1234) = 1 + 2 + 3 + 4). You are to calculate <image>
Of course Little X has solved this problem quickly, has locked it, and then has tried to hack others. He has seen the foll... | 0 |
{"tests": "{\"inputs\": [\"3 0\\n1 1 1\\n\", \"5 1\\n-1 -2 -3 -4 5\\n\", \"13 2\\n3 1 4 1 5 -9 -2 -6 -5 -3 -5 -8 -9\\n\", \"70 2\\n1 1 1 1 1 -1 -1 -1 -1 -1 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3... | Wabbit is playing a game with $n$ bosses numbered from $1$ to $n$. The bosses can be fought in any order. Each boss needs to be defeated exactly once. There is a parameter called boss bonus which is initially $0$.
When the $i$-th boss is defeated, the current boss bonus is added to Wabbit's score, and then the value o... | 0 |
{"tests": "{\"inputs\": [\"3 3\\n5 4 6\\n\", \"6 3\\n1 2 3 2 2 3\\n\", \"6 3\\n1 2 4 1 2 3\\n\", \"7 3\\n50 17 81 25 42 39 96\\n\", \"1 1\\n1\\n\", \"1 1\\n1000000000000\\n\", \"3 3\\n14159 26535 89793\\n\", \"7 4\\n1 10000 1 1 1 1 10000\\n\", \"17 10\\n465 868 29 633 291 357 62 929 22 124 182 995 903 75 71 924 416\\n\... | You are given two arrays: an array $a$ consisting of $n$ zeros and an array $b$ consisting of $n$ integers.
You can apply the following operation to the array $a$ an arbitrary number of times: choose some subsegment of $a$ of length $k$ and add the arithmetic progression $1, 2, \ldots, k$ to this subsegment — i. e. ad... | 0 |
{"tests": "{\"inputs\": [\"15\\n987654329876543\\n\", \"1\\n4\\n\", \"15\\n028745260720699\\n\", \"1\\n9\\n\", \"8\\n68931246\\n\", \"2\\n26\\n\", \"1\\n2\\n\", \"9\\n987654321\\n\", \"1\\n8\\n\", \"2\\n99\\n\", \"10\\n3312667105\\n\", \"5\\n99999\\n\", \"1\\n6\\n\", \"15\\n012345781234578\\n\", \"9\\n234567899\\n\", \... | Drazil is playing a math game with Varda.
Let's define <image> for positive integer x as a product of factorials of its digits. For example, <image>.
First, they choose a decimal number a consisting of n digits that contains at least one digit larger than 1. This number may possibly start with leading zeroes. Then th... | 0 |
{"tests": "{\"inputs\": [[\"yellow violet black\"], [\"yellow violet red gold\"], [\"brown black green silver\"], [\"brown black black\"], [\"brown black brown gold\"], [\"red red brown\"], [\"orange orange brown gold\"], [\"yellow violet brown silver\"], [\"blue gray brown\"], [\"brown black red silver\"], [\"brown bl... | ## Overview
Resistors are electrical components marked with colorful stripes/bands to indicate both their resistance value in ohms and how tight a tolerance that value has. While you could always get a tattoo like Jimmie Rodgers to help you remember the resistor color codes, in the meantime, you can write a function th... | 0 |
{"tests": "{\"inputs\": [[1234], [4321], [1001], [1010], [12005000]], \"outputs\": [[4321], [1234], [1001], [101], [50021]]}", "source": "primeintellect"} | Impliment the reverse function, which takes in input n and reverses it. For instance, `reverse(123)` should return `321`. You should do this without converting the inputted number into a string.
Write your solution by modifying this code:
```python
def reverse(n):
```
Your solution should implemented in the functi... | 0 |
{"tests": "{\"inputs\": [[[1, 2, 3, 4, 5]], [[1, 2, 3, 4]], [[5, 3, 2, 1, 4]], [[1, 2, 3, 1, 1]], [[]]], \"outputs\": [[[2, 3, 4, 5]], [[2, 3, 4]], [[5, 3, 2, 4]], [[2, 3, 1, 1]], [[]]]}", "source": "primeintellect"} | # The museum of incredible dull things
The museum of incredible dull things wants to get rid of some exhibitions. Miriam, the interior architect, comes up with a plan to remove the most boring exhibitions. She gives them a rating, and then removes the one with the lowest rating.
However, just as she finished rating a... | 0 |
{"tests": "{\"inputs\": [[[\"yoda\", \"best\", \"has\"]], [[]], [[\"X-ray\"]], [[\"No\", \"No\"]], [[\"Chad\", \"Morocco\", \"India\", \"Algeria\", \"Botswana\", \"Bahamas\", \"Ecuador\", \"Micronesia\"]]], \"outputs\": [[\"yes\"], [\"\"], [\"X\"], [\"No\"], [\"Codewars\"]]}", "source": "primeintellect"} | Complete the function that takes an array of words.
You must concatenate the `n`th letter from each word to construct a new word which should be returned as a string, where `n` is the position of the word in the list.
For example:
```
["yoda", "best", "has"] --> "yes"
^ ^ ^
n=0 n=1 n=2
``... | 0 |
{"tests": "{\"inputs\": [\"36\\n6\\n165310\\n6\\n177978\\n6\\n211759\\n6\\n212643\\n6\\n229540\\n6\\n250029\\n6\\n211519\\n6\\n256097\\n6\\n163478\\n5\\n91505\\n5\\n79280\\n6\\n260629\\n6\\n128051\\n6\\n121972\\n6\\n261633\\n6\\n172044\\n6\\n119055\\n6\\n208323\\n6\\n149942\\n6\\n161236\\n6\\n177150\\n6\\n233766\\n5\\n... | Let's define a number ebne (even but not even) if and only if its sum of digits is divisible by 2 but the number itself is not divisible by 2. For example, 13, 1227, 185217 are ebne numbers, while 12, 2, 177013, 265918 are not. If you're still unsure what ebne numbers are, you can look at the sample notes for more clar... | 0 |
{"tests": "{\"inputs\": [\"5\\n1000000000000000000 352839520853234088 175235832528365792 753467583475385837 895062156280564685\\n\", \"1\\n4\\n\", \"1\\n15\\n\", \"1\\n1\\n\", \"3\\n6 1 14\\n\", \"4\\n1 2 2 16\\n\", \"3\\n6 1 2\\n\", \"4\\n1 2 4 22\\n\", \"5\\n1000000000000000000 352839520853234088 257894004782222768 8... | Vasya has a sequence a consisting of n integers a_1, a_2, ..., a_n. Vasya may pefrom the following operation: choose some number from the sequence and swap any pair of bits in its binary representation. For example, Vasya can transform number 6 (... 00000000110_2) into 3 (... 00000000011_2), 12 (... 000000001100_2), 10... | 0 |
{"tests": "{\"inputs\": [[\"fire\", \"water\", 100, 100], [\"grass\", \"water\", 100, 100], [\"electric\", \"fire\", 100, 100], [\"grass\", \"electric\", 57, 19], [\"grass\", \"water\", 40, 40], [\"grass\", \"fire\", 35, 5], [\"fire\", \"electric\", 10, 2]], \"outputs\": [[25], [100], [50], [150], [100], [175], [250]]}... | It's a Pokemon battle! Your task is to calculate the damage that a particular move would do using the following formula (not the actual one from the game):
Where:
* attack = your attack power
* defense = the opponent's defense
* effectiveness = the effectiveness of the attack based on the matchup (see explanation bel... | 0 |
{"tests": "{\"inputs\": [\"1\\n0 0 10 10\\n5 5 5 5\\n\", \"1\\n0 0 5 5\\n2 5 0 0\\n\", \"4\\n0 49998 2 50002\\n1 50000 0 0\\n1 50000 0 0\\n1 0 0 1\\n1 100000 0 -1\\n\", \"1\\n0 0 100000 100000\\n0 0 -1 -1\\n\", \"4\\n17501 63318 51967 74514\\n1305 84026 79493 -78504\\n41159 81000 -44104 -42722\\n31063 65435 25578 33487... | Igor the analyst fell asleep on the work and had a strange dream. In the dream his desk was crowded with computer mice, so he bought a mousetrap to catch them.
The desk can be considered as an infinite plane, then the mousetrap is a rectangle which sides are parallel to the axes, and which opposite sides are located i... | 0 |
{"tests": "{\"inputs\": [\"6\\n1 5\\n0 10\\n1 -5\\n0 5\\n1 11\\n0 -10\\n\", \"6\\n1 5\\n0 10\\n1 -5\\n1 5\\n1 11\\n0 -10\\n\", \"6\\n1 5\\n0 10\\n1 -5\\n0 5\\n1 11\\n0 -5\\n\", \"6\\n1 5\\n0 10\\n1 -5\\n0 5\\n1 3\\n0 -10\\n\", \"6\\n1 5\\n0 10\\n1 -5\\n1 7\\n1 11\\n0 -10\\n\", \"6\\n1 5\\n0 10\\n1 -5\\n1 5\\n1 18\\n0 -... | Polycarp plays a computer game (yet again). In this game, he fights monsters using magic spells.
There are two types of spells: fire spell of power $x$ deals $x$ damage to the monster, and lightning spell of power $y$ deals $y$ damage to the monster and doubles the damage of the next spell Polycarp casts. Each spell c... | 0 |
{"tests": "{\"inputs\": [\"4\\n4 2\\n8 2\\n1 5\\n1 1\\n2 1\\n2 0\\n10 6\\n14 6\\n2 20\\n9 10\\n13 18\\n15 12\\n11 7\\n\", \"4\\n4 2\\n8 2\\n1 5\\n1 1\\n2 1\\n2 0\\n10 6\\n14 6\\n2 20\\n5 10\\n13 18\\n15 12\\n11 7\\n\", \"4\\n4 2\\n8 2\\n1 5\\n1 1\\n2 1\\n2 0\\n10 6\\n14 6\\n2 20\\n5 10\\n16 18\\n15 12\\n11 7\\n\", \"4\... | On a circle lie $2n$ distinct points, with the following property: however you choose $3$ chords that connect $3$ disjoint pairs of points, no point strictly inside the circle belongs to all $3$ chords. The points are numbered $1, \, 2, \, \dots, \, 2n$ in clockwise order.
Initially, $k$ chords connect $k$ pairs of po... | 0 |
{"tests": "{\"inputs\": [\"5\\n8 3 2 1 4\\n3 7 2 4 8\\n9 2 8 9 10\\n2 3 6 10 1\\n8 2 2 8 4\\n\", \"8\\n1 1 10 1 8 4 8 7\\n9 3 3 2 2 6 2 4\\n7 4 3 5 10 3 5 1\\n8 4 4 10 4 5 9 4\\n5 5 5 2 6 7 1 8\\n4 10 1 3 2 4 8 3\\n8 1 10 2 8 2 2 4\\n2 10 6 8 10 2 8 4\\n\", \"10\\n10 8 6 5 9 8 2 5 3 2\\n3 1 8 6 8 10 5 5 7 8\\n5 9 7 7 4... | There is a square matrix n × n, consisting of non-negative integer numbers. You should find such a way on it that
* starts in the upper left cell of the matrix;
* each following cell is to the right or down from the current cell;
* the way ends in the bottom right cell.
Moreover, if we multiply together a... | 0 |
{"tests": "{\"inputs\": [\"4\\n1 1 1\\n1 1 1\\n1 1 1\\n2 2 2\\n2 2 2\\n2 2 2\\n4 3 3\\n5 2 2\\n4 3 3\\n6 1 1\\n6 1 1\\n6 1 -1\\n1 0 0\\n0 2 0\\n0 0 0\\n5 1 2\\n5 1 2\\n0 0 0\\n2 0 0\\n0 3 0\\n0 0 0\\n0 0 0\\n0 0 0\\n3 0 1\", \"4\\n1 1 1\\n1 2 1\\n1 1 1\\n2 2 2\\n2 2 2\\n2 2 2\\n4 3 3\\n5 2 2\\n4 3 3\\n6 1 1\\n6 1 1\\n6... | Let’s try a dice puzzle. The rules of this puzzle are as follows.
1. Dice with six faces as shown in Figure 1 are used in the puzzle.
<image>
Figure 1: Faces of a die
2. With twenty seven such dice, a 3 × 3 × 3 cube is built as shown in Figure 2.
<image>
Figure 2: 3 × 3 × 3 cube
3. When building up a cube made o... | 0 |
{"tests": "{\"inputs\": [\"3 2\\n\", \"2 4\\n\", \"5 14\\n\", \"0 4\", \"8 14\", \"0 14\", \"1 14\", \"2 14\", \"2 1\", \"0 1\", \"2 5\", \"2 26\", \"2 2\", \"0 5\", \"9 14\", \"0 28\", \"2 10\", \"0 2\", \"3 1\", \"1 5\", \"2 11\", \"0 3\", \"9 12\", \"1 28\", \"1 10\", \"4 2\", \"1 4\", \"3 11\", \"9 18\", \"1 7\", \... | In Finite Encyclopedia of Integer Sequences (FEIS), all integer sequences of lengths between 1 and N (inclusive) consisting of integers between 1 and K (inclusive) are listed.
Let the total number of sequences listed in FEIS be X. Among those sequences, find the (X/2)-th (rounded up to the nearest integer) lexicographi... | 0 |
{"tests": "{\"inputs\": [\"5\\n1 2\\n2 3\\n3 4\\n4 5\\n5\\n1 3 1 2 2\\n1 4 1 3 2\\n1 4 1 3 3\\n4 2 3 3 9\\n5 2 3 3 9\\n\", \"9\\n3 9\\n3 4\\n7 2\\n6 9\\n5 3\\n6 2\\n8 3\\n1 9\\n10\\n8 4 8 2 5\\n9 2 7 4 4\\n8 5 7 3 3\\n1 2 3 8 4\\n2 9 2 4 3\\n6 4 3 4 5\\n6 7 6 6 4\\n7 5 3 1 4\\n5 4 7 8 3\\n4 5 1 5 2\\n\", \"14\\n4 9\\n3... | Gildong was hiking a mountain, walking by millions of trees. Inspired by them, he suddenly came up with an interesting idea for trees in data structures: What if we add another edge in a tree?
Then he found that such tree-like graphs are called 1-trees. Since Gildong was bored of solving too many tree problems, he wan... | 0.25 |
{"tests": "{\"inputs\": [[2, 5], [3, 9], [16, 27], [11, 19], [14, 33], [1, 7.5], [6, 13]], \"outputs\": [[19.2], [16.0], [28.4], [27.8], [20.4], [6.4], [22.2]]}", "source": "primeintellect"} | An NBA game runs 48 minutes (Four 12 minute quarters). Players do not typically play the full game, subbing in and out as necessary. Your job is to extrapolate a player's points per game if they played the full 48 minutes.
Write a function that takes two arguments, ppg (points per game) and mpg (minutes per game) and ... | 0 |
{"tests": "{\"inputs\": [\"12 1 1\\n0 1 2 3 4 5 6 7 8 9 10 11\\n001010001000\\n001010001000 100\\n\", \"1 1 1\\n67\\n0\\n1 47\\n\", \"12 1 1\\n0 1 2 3 4 5 6 7 0 9 10 11\\n001010001000\\n001010001000 100\\n\", \"1 2 4\\n100\\n0\\n1\\n1 0\\n0 100\\n1 0\\n1 100\\n\", \"1 2 4\\n100\\n0\\n0\\n1 0\\n0 100\\n1 0\\n1 100\\n\",... | Childan is making up a legendary story and trying to sell his forgery — a necklace with a strong sense of "Wu" to the Kasouras. But Mr. Kasoura is challenging the truth of Childan's story. So he is going to ask a few questions about Childan's so-called "personal treasure" necklace.
This "personal treasure" is a multis... | 0.625 |
{"tests": "{\"inputs\": [[0, 5], [12345, 17], [313, 2], [832696988485, 170], [769832696988484, 170], [10395, 11], [31428, \"47\"], [1, 171], [7392984749, 900], [123, 0], [-987654321, 99], [999999, [101]], [10396, 11], [0, 1], [2017, 4], [769832696988485, 170]], \"outputs\": [[1808], [29535], [1], [769000000000000], [1]... | In this Kata you are a game developer and have programmed the #1 MMORPG(Massively Multiplayer Online Role Playing Game) worldwide!!! Many suggestions came across you to make the game better, one of which you are interested in and will start working on at once.
Players in the game have levels from 1 to 170, XP(short fo... | 0 |
{"tests": "{\"inputs\": [[\"abc\"], [\"aaabcccbaaa\"], [\"ccccc\"], [\"abababababababab\"], [\"aaaaa\"]], \"outputs\": [[\"bac\"], [\"bbbacccabbb\"], [\"ccccc\"], [\"babababababababa\"], [\"bbbbb\"]]}", "source": "primeintellect"} | Given a string made up of letters a, b, and/or c, switch the position of letters a and b (change a to b and vice versa). Leave any incidence of c untouched.
Example:
'acb' --> 'bca'
'aabacbaa' --> 'bbabcabb'
Write your solution by modifying this code:
```python
def switcheroo(string):
```
Your solution should im... | 0 |
{"tests": "{\"inputs\": [\"2 2\\n\", \"1 2\\n\", \"4 1\\n\", \"1 3\", \"1 1\", \"2 3\", \"2 5\", \"3 3\", \"2 6\", \"6 3\", \"2 8\", \"6 4\", \"3 6\", \"6 8\", \"3 8\", \"4 8\", \"4 2\", \"4 3\", \"4 5\", \"4 7\", \"5 7\", \"3 7\", \"2 7\", \"2 4\", \"4 4\", \"4 10\", \"6 10\", \"6 13\", \"2 13\", \"3 13\", \"3 1\", \"... | Let's define a good tree:It is a tree with k * n nodes labeled from 0 to k * n - 1
Node i and node j are not adjacent, for all 0 ≤ i, j < k * n such that i div k = j div k (here div means integer division. E.g. 7 div 2 = 3)
Given n and k, how many different good trees are there?
------ Input ------
Two integers n(... | 0 |
{"tests": "{\"inputs\": [[[2, 4, 7]], [[1, 1, 3, 4]], [[23]], [[-10, -10, -10, -10, -10, -9, -9, -9, -8, -8, -7, -6, -5, -4, -3, -2, -1, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, ... | # Task
Given a sorted array of integers `A`, find such an integer x that the value of `abs(A[0] - x) + abs(A[1] - x) + ... + abs(A[A.length - 1] - x)`
is the smallest possible (here abs denotes the `absolute value`).
If there are several possible answers, output the smallest one.
# Example
For `A = [2, 4, 7]`, th... | 0 |
{"tests": "{\"inputs\": [[\"is2 Thi1s T4est 3a\"], [\"4of Fo1r pe6ople g3ood th5e the2\"], [\"d4o dru7nken sh2all w5ith s8ailor wha1t 3we a6\"], [\"\"], [\"3 6 4 2 8 7 5 1 9\"]], \"outputs\": [[\"Thi1s is2 3a T4est\"], [\"Fo1r the2 g3ood 4of th5e pe6ople\"], [\"wha1t sh2all 3we d4o w5ith a6 dru7nken s8ailor\"], [\"\"],... | Your task is to sort a given string. Each word in the string will contain a single number. This number is the position the word should have in the result.
Note: Numbers can be from 1 to 9. So 1 will be the first word (not 0).
If the input string is empty, return an empty string.
The words in the input String will onl... | 0 |
{"tests": "{\"inputs\": [\"4\", \"1100000\", \"8\", \"0100000\", \"14\", \"0110000\", \"0110010\", \"6\", \"1100010\", \"0100100\", \"12\", \"0110100\", \"16\", \"1110010\", \"0110110\", \"0\", \"1000010\", \"0000010\", \"0100010\", \"0000100\", \"24\", \"1001000\", \"20\", \"1100100\", \"18\", \"44\", \"1110000\", \"0... | Given is a positive even number N.
Find the number of strings s of length N consisting of `A`, `B`, and `C` that satisfy the following condition:
* s can be converted to the empty string by repeating the following operation:
* Choose two consecutive characters in s and erase them. However, choosing `AB` or `BA` is no... | 0 |
{"tests": "{\"inputs\": [\"6 732284177\\n\", \"634 982032773\\n\", \"199862 999999937\\n\", \"2 554714911\\n\", \"124953 922406879\\n\", \"8045 992942057\\n\", \"200000 665880409\\n\", \"158032 121694641\\n\", \"199568 100000007\\n\", \"48 166017469\\n\", \"200000 187160003\\n\", \"199995 597768679\\n\", \"200000 55892... | This version of the problem differs from the next one only in the constraint on n.
Note that the memory limit in this problem is lower than in others.
You have a vertical strip with n cells, numbered consecutively from 1 to n from top to bottom.
You also have a token that is initially placed in cell n. You will move... | 0 |
{"tests": "{\"inputs\": [[\"GFEDCBA\", \"-----------------------\"], [\"GFEDCBA\", \"------------...-----------\"], [\"GFEDCBA\", \"------------.....---------\"], [\"GFEDCBA\", \"------.....------.....---------\"], [\"GFEDCBA\", \"------------...-----..----\"], [\"CBA\", \"--.--.---\"], [\"GFEDCBA\", \"------....-.---\... | # Background
My pet bridge-maker ants are marching across a terrain from left to right.
If they encounter a gap, the first one stops and then next one climbs over him, then the next, and the next, until a bridge is formed across the gap.
What clever little things they are!
Now all the other ants can walk over the ... | 0 |
{"tests": "{\"inputs\": [\"4\\n1\\n1337\\n3\\n10 8 10\\n5\\n1 2 3 4 5\\n3\\n7 77 777\\n\", \"1\\n1\\n6006\\n\", \"1\\n1\\n6006\\n\", \"1\\n1\\n2668\\n\", \"4\\n1\\n1337\\n3\\n10 8 1\\n5\\n1 2 3 4 5\\n3\\n7 77 777\\n\", \"1\\n1\\n865\\n\", \"1\\n1\\n483\\n\", \"1\\n1\\n132\\n\", \"1\\n1\\n245\\n\", \"1\\n1\\n78\\n\", \"... | One day, early in the morning, you decided to buy yourself a bag of chips in the nearby store. The store has chips of $n$ different flavors. A bag of the $i$-th flavor costs $a_i$ burles.
The store may run out of some flavors, so you'll decide which one to buy after arriving there. But there are two major flaws in thi... | 0 |
{"tests": "{\"inputs\": [[6], [34], [-291], [943], [-971]], \"outputs\": [[56], [7140], [0], [140205240], [0]]}", "source": "primeintellect"} | Your task is to return the sum of Triangular Numbers up-to-and-including the `nth` Triangular Number.
Triangular Number: "any of the series of numbers (1, 3, 6, 10, 15, etc.) obtained by continued summation of the natural numbers 1, 2, 3, 4, 5, etc."
```
[01]
02 [03]
04 05 [06]
07 08 09 [10]
11 12 13 14 [15]
16 17 18... | 0 |
{"tests": "{\"inputs\": [\"541 9\\nbxhwcmunbdxcatppdsw\\nshbppncwbnsxxnxunwsbncpdchcbcspdcppdchmbbcuapphpdxbpcswcxpxpdscxpddbcppdxhpxbuxxdbpdpuudb\\n\", \"8058035 2\\nrioqrqetkzfbldjiemsfzbhzfnwywmxxgdpyl\\ngfmhefhyyndzmsbfnefmwmpxfxfhflzplgoxfrrdxilibzlephlezisfztsfitnrzrilzmtipzofkrwlmhnifdzwexzzxjpy\\n\", \"1181362 ... | Let's introduce the designation <image>, where x is a string, n is a positive integer and operation " + " is the string concatenation operation. For example, [abc, 2] = abcabc.
We'll say that string s can be obtained from string t, if we can remove some characters from string t and obtain string s. For example, string... | 0 |
{"tests": "{\"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]], \"outputs\": [[1], [32], [5], [3], [1], [0], [4], [26], [19], [161], [961]]}", "source": "primein... | 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 going to need to be efficient, because we'll be testing some prett... | 0 |
{"tests": "{\"inputs\": [\"5 3\\n4 6 8 9 10\\n\", \"3 5\\n1 2 10\\n\", \"5 2\\n4 6 8 9 10\\n\", \"5 1000000000\\n1 2 3 999999999 1000000000\\n\", \"30 5\\n102 104 105 107 108 109 110 111 116 118 119 122 127 139 140 142 145 157 166 171 173 174 175 181 187 190 191 193 195 196\\n\", \"3 1\\n1 2 3\\n\", \"10 2\\n110 121 14... | An atom of element X can exist in n distinct states with energies E1 < E2 < ... < En. Arkady wants to build a laser on this element, using a three-level scheme. Here is a simplified description of the scheme.
Three distinct states i, j and k are selected, where i < j < k. After that the following process happens:
... | 0.625 |
{"tests": "{\"inputs\": [[\"a **& bZ\"], [\"Abc e $$ z\"], [\"!!a$%&RgTT\"], [\"\"], [\"abcdefghijklmnopqrstuvwxyz\"], [\"aaaaaaaaaaa\"], [\"&%&%/$%$%$%$%GYtf67fg34678hgfdyd\"]], \"outputs\": [[\"11000000000000000000000001\"], [\"11101000000000000000000001\"], [\"10000010000000000101000000\"], [\"0000000000000000000... | Create a function which accepts one arbitrary string as an argument, and return a string of length 26.
The objective is to set each of the 26 characters of the output string to either `'1'` or `'0'` based on the fact whether the Nth letter of the alphabet is present in the input (independent of its case).
So if an `'... | 0 |
{"tests": "{\"inputs\": [[50], [25], [52], [57], [75], [100], [521], [1], [5071], [705], [1241367], [50011117], [1002], [50011111112], [2057], [50001111312], [500111117], [64954713879], [71255535569], [72046951686], [68151901446], [3848363615], [75733989998], [87364011400], [2992127830], [98262144757], [81737102196], [... | In this Kata, you will be given a number and your task will be to rearrange the number so that it is divisible by `25`, but without leading zeros. Return the minimum number of digit moves that are needed to make this possible. If impossible, return `-1` ( `Nothing` in Haskell ).
For example:
More examples in test cas... | 0 |
{"tests": "{\"inputs\": [\"10\\n1 1 1 1 8 7 1 1 1 1\\n14\", \"4\\n45 34 1 34 \\n90\", \"1000\\n84 87 78 16 94 36 87 93 50 22 63 28 91 60 64 27 41 27 73 37 12 69 68 30 83 31 63 24 68 36 30 3 23 59 70 68 94 57 12 43 30 74 22 20 85 38 99 25 16 71 14 27 92 81 57 74 63 71 97 82 6 26 85 28 37 6 47 30 14 58 25 96 83 46 15 68 ... | You have a part to play in the Wars to Come.
As everyone knows, Lord Stannis Baratheon (First of His Name, King of the Andals and the First Men, Lord of the Seven Kingdoms and Protector of the Realm) is one true king. Now, he wants to conquer the North. To conquer, he needs to expand his army. And since, Winter is com... | 0 |
{"tests": "{\"inputs\": [\"2\\n1000 1\\n\", \"5\\n2 2 1 1 3\\n\", \"100\\n12 18 1 1 14 23 1 1 22 5 7 9 7 1 1 1 3 8 4 2 1 6 9 1 3 2 11 1 11 2 3 2 1 4 2 7 1 16 3 4 2 13 3 1 5 11 2 10 20 24 3 21 5 2 6 2 1 10 10 5 17 1 1 4 19 8 5 5 3 9 4 2 7 8 10 4 9 1 3 3 9 7 6 4 4 3 6 8 12 1 3 6 2 1 8 4 1 15 2 5\\n\", \"50\\n7 1 6 5 15 3... | A permutation is a sequence of integers from 1 to n of length n containing each number exactly once. For example, (1), (4, 3, 5, 1, 2), (3, 2, 1) are permutations, and (1, 1), (4, 3, 1), (2, 3, 4) are not.
There are many tasks on permutations. Today you are going to solve one of them. Let’s imagine that somebody took... | 0 |
{"tests": "{\"inputs\": [\"4\\n3\\n1 2 3\\n6\\n1 3 2 6 5 4\\n4\\n4 1 3 2\\n8\\n3 2 1 6 7 8 5 4\\n\", \"4\\n3\\n1 2 3\\n6\\n1 3 2 6 5 4\\n4\\n4 1 3 2\\n8\\n3 0 1 6 7 8 5 4\\n\", \"4\\n3\\n1 2 3\\n6\\n1 3 2 6 5 4\\n4\\n4 1 3 2\\n8\\n3 2 1 6 7 1 5 4\\n\", \"4\\n3\\n1 2 0\\n6\\n1 3 2 6 5 4\\n4\\n4 1 3 2\\n8\\n3 0 1 6 7 8 5... | You are given a permutation p consisting of n integers 1, 2, ..., n (a permutation is an array where each element from 1 to n occurs exactly once).
Let's call an array a bipartite if the following undirected graph is bipartite:
* the graph consists of n vertices;
* two vertices i and j are connected by an edge i... | 0 |
{"tests": "{\"inputs\": [\"3\\n6\\n1 5 4 3 2 6\\n5 3 1 4 6 2\\n6\\n3 5 4 6 2 1\\n3 6 4 5 2 1\\n1\\n1\\n1\\n\", \"3\\n8\\n1 2 3 4 5 6 7 8\\n1 2 3 4 5 7 8 6\\n7\\n1 2 3 4 5 6 7\\n2 1 5 3 6 7 4\\n4\\n1 2 3 4\\n1 4 2 3\\n\", \"1\\n10\\n5 3 7 4 6 10 9 8 1 2\\n2 7 1 3 9 4 8 10 5 6\\n\", \"1\\n10\\n3 4 1 2 7 6 10 9 5 8\\n4 6 ... | Tokitsukaze has two colorful tapes. There are $n$ distinct colors, numbered $1$ through $n$, and each color appears exactly once on each of the two tapes. Denote the color of the $i$-th position of the first tape as $ca_i$, and the color of the $i$-th position of the second tape as $cb_i$.
Now Tokitsukaze wants to sel... | 0 |
{"tests": "{\"inputs\": [\"3\\n3 4\\n1 3\\n1 5\\n\", \"5\\n2 7\\n2 8\\n1 2\\n2 4\\n1 8\\n\", \"1\\n8 2\\n\", \"8\\n1 8\\n1 6\\n1 5\\n1 3\\n1 3\\n1 8\\n1 7\\n1 3\\n\", \"4\\n4 1\\n2 2\\n1 6\\n1 2\\n\", \"8\\n1 63658803333197\\n1 26806908300107\\n1 37622010993115\\n1 8932487734606\\n1 55358687683237\\n1 44940811911137\\n... | Lena is the most economical girl in Moscow. So, when her dad asks her to buy some food for a trip to the country, she goes to the best store — "PriceFixed". Here are some rules of that store:
The store has an infinite number of items of every product.
All products have the same price: $2$ rubles per item.
For every... | 0 |
{"tests": "{\"inputs\": [\"1\\n0 0\\n1 2 3 4 5 6\\nRRRRBBBBLLLLFFFF\\n2\\n0 0\\n1 1 1 1 1 1\\nRRR\\n2 2\\n100 100 100 100 100 100\\nFFF\\n1\\n1010 -1000\\n1 2 3 4 5 6\\nLFRB\\n4\\n-3 -4\\n1 2 3 4 5 6\\nBBBBBBBB\\n4 -3\\n11 12 13 14 15 16\\nLLLLLLLL\\n3 4\\n21 22 23 24 25 26\\nFFFFFFFF\\n-4 3\\n31 32 33 34 35 36\\nRRRRR... | Dice Stamp
Dice stamp
At a local fair, you found a game store you've never seen before. This is a game in which N 6-sided dice are dropped and rolled on the board. More precisely, N buttons are tied to N dice on a one-to-one basis, and pressing the button causes the corresponding dice to fall onto the board. It is a ... | 0 |
{"tests": "{\"inputs\": [\"3 3 1\\n\", \"300 2 300\\n\", \"4000 4000 1\\n\", \"4000 4000 100\\n\", \"4 2 3\\n\", \"3 300 300\\n\", \"4000 100 4000\\n\", \"3 300 1\\n\", \"300 300 1\\n\", \"4000 1000 3000\\n\", \"3 2 4000\\n\", \"4 3 2\\n\", \"3 2 300\\n\", \"4000 3998 2\\n\", \"100 200 300\\n\", \"300 300 300\\n\", \"3... | Polycarpus is sure that his life fits the description: "first there is a white stripe, then a black one, then a white one again". So, Polycarpus is sure that this rule is going to fulfill during the next n days. Polycarpus knows that he is in for w good events and b not-so-good events. At least one event is going to ta... | 0 |
{"tests": "{\"inputs\": [\"5 2797 5925 9\\n\", \"6 1976 8455 3\\n\", \"72 8534 7042 65\\n\", \"4 495 8813 1\\n\", \"100 5635 9099 23\\n\", \"72 6791 8546 46\\n\", \"72 5272 4552 64\\n\", \"1 47 80 68\\n\", \"10000 10000 10000 10000\\n\", \"48 7946 7992 72\\n\", \"48 6428 9807 83\\n\", \"2 5000 12 3\\n\", \"10 1000 100 ... | A lot of people in Berland hates rain, but you do not. Rain pacifies, puts your thoughts in order. By these years you have developed a good tradition — when it rains, you go on the street and stay silent for a moment, contemplate all around you, enjoy freshness, think about big deeds you have to do.
Today everything ... | 0.25 |
{"tests": "{\"inputs\": [[[2, 3, 2], [0, 1, 0]], [[5, 1, 1], [0, 1, 0]], [[3, 3, 4], [0, 1, 0]], [[9, 7, 1, 1], [1, 1, 0, 0]], [[9, 1, 1, 7], [1, 1, 0, 0]]], \"outputs\": [[true], [false], [false], [true], [false]]}", "source": "primeintellect"} | A stick is balanced horizontally on a support. Will it topple over or stay balanced? (This is a physics problem: imagine a real wooden stick balanced horizontally on someone's finger or on a narrow table, for example).
The stick is represented as a list, where each entry shows the mass in that part of the stick.
The... | 0 |
{"tests": "{\"inputs\": [[1], [4], [5], [12], [25], [30], [4096]], \"outputs\": [[1], [3], [2], [6], [3], [8], [13]]}", "source": "primeintellect"} | Count the number of divisors of a positive integer `n`.
Random tests go up to `n = 500000`.
## Examples
```python
divisors(4) == 3 # 1, 2, 4
divisors(5) == 2 # 1, 5
divisors(12) == 6 # 1, 2, 3, 4, 6, 12
divisors(30) == 8 # 1, 2, 3, 5, 6, 10, 15, 30
```
Write your solution by modifying this code:
```python
def... | 0 |
{"tests": "{\"inputs\": [\"5\\n4\\n1 2 -1 2\\n3\\n1 1 -2\\n5\\n2 0 -2 2 -1\\n3\\n-2 -1 -1\\n3\\n-1 -2 -2\\n\", \"1\\n1\\n1\\n\", \"1\\n100\\n2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2... | You are given an array $a$ consisting of $n$ integers. For each $i$ ($1 \le i \le n$) the following inequality is true: $-2 \le a_i \le 2$.
You can remove any number (possibly $0$) of elements from the beginning of the array and any number (possibly $0$) of elements from the end of the array. You are allowed to delete... | 0 |
{"tests": "{\"inputs\": [\"3\\n5\\n2 1 2 1 1\\n4\\n11 2 2 2\\n1\\n998244353\\n\", \"3\\n5\\n1 1 2 1 1\\n4\\n11 2 2 2\\n1\\n998244353\\n\", \"3\\n5\\n2 2 2 1 1\\n4\\n11 2 2 2\\n1\\n998244353\\n\", \"3\\n5\\n1 1 1 1 1\\n4\\n11 2 3 2\\n1\\n998244353\\n\", \"3\\n5\\n1 1 0 1 1\\n4\\n11 2 2 3\\n1\\n998244353\\n\", \"3\\n5\\n... | In the 2050 Conference, some people from the competitive programming community meet together and are going to take a photo. The n people form a line. They are numbered from 1 to n from left to right. Each of them either holds a cardboard with the letter 'C' or a cardboard with the letter 'P'.
Let C=\\{c_1,c_2,...,c_m\... | 0 |
{"tests": "{\"inputs\": [\"3 3\\n2 4 6\", \"3 1\\n3 4 7\", \"3 1\\n1 5 2\", \"0 1\\n2 5 4\", \"1 0\\n2 7 4\", \"5 3\\n3 4 7\", \"3 1\\n5 4 7\", \"3 0\\n2 5 2\", \"5 3\\n1 4 7\", \"6 1\\n5 4 7\", \"5 0\\n2 5 2\", \"7 0\\n4 5 2\", \"8 2\\n3 7 1\", \"8 2\\n4 7 2\", \"2 0\\n3\", \"3 3\\n3 5 7\", \"5 3\\n3 5 7\", \"2 1\\n3 ... | There are 2^N players, numbered 1, 2, ..., 2^N. They decided to hold a tournament.
The tournament proceeds as follows:
* Choose a permutation of 1, 2, ..., 2^N: p_1, p_2, ..., p_{2^N}.
* The players stand in a row in the order of Player p_1, Player p_2, ..., Player p_{2^N}.
* Repeat the following until there is only ... | 0 |
{"tests": "{\"inputs\": [[4], [7], [11], [30], [-5], [0], [3]], \"outputs\": [[\" A \\n A A \\n A A A \\nA A\"], [\" A \\n A A \\n A A \\n A A A A \\n A A \\nA A\"], [\" A \\n A A \\n A A \\n A A \\n A A ... | - Input: Integer `n`
- Output: String
Example:
`a(4)` prints as
```
A
A A
A A A
A A
```
`a(8)` prints as
```
A
A A
A A
A A
A A A A A
A A
A A
A A
```
`a(12)` prints as
```
A
A A... | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.