info
stringlengths
120
50k
question
stringlengths
504
10.4k
avg@8_qwen3_4b_instruct_2507
float64
0
0.88
{"tests": "{\"inputs\": [\"0 0 1 2\\n1\\n0 1\\n2 2\", \"0 -1 0 2\\n0\\n2 2\", \"1 0 0 2\\n0\\n2 2\", \"0 0 0 2\\n6\\n0 1\\n1 -1\\n1 0\\n0 -1\\n-1 -1\\n-1 0\\n2 2\", \"1 2 0 0\\n1\\n-1 0\\n4 2\", \"-11 -1 1 0\\n1\\n-1 -2\\n21 33\", \"-11 -1 1 -1\\n1\\n-1 -2\\n21 33\", \"-6 -1 1 -1\\n1\\n-1 -2\\n21 33\", \"-17 -1 1 -1\\n...
The full exploration sister is a very talented woman. Your sister can easily count the number of routes in a grid pattern if it is in the thousands. You and your exploration sister are now in a room lined with hexagonal tiles. The older sister seems to be very excited about the hexagon she sees for the first time. The ...
0
{"tests": "{\"inputs\": [\"100020001\\n\", \"100000000000000000222\\n\", \"8008\\n\", \"10000555\\n\", \"20020201\\n\", \"7\\n\", \"10001\\n\", \"2000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002\\n\", \"8059\\n\", \"100000001\\n\", \"200000000000000111\\n\", \"200093\...
A positive integer number n is written on a blackboard. It consists of not more than 105 digits. You have to transform it into a beautiful number by erasing some of the digits, and you want to erase as few digits as possible. The number is called beautiful if it consists of at least one digit, doesn't have leading zer...
0
{"tests": "{\"inputs\": [[\"A6C2E5Z9A4.-F%8.08.\"], [\"PP P6A6T5F5S3.-Z%1.11.hgr\"], [\"A6A1E3A8M2.-Q%8.88.\"], [\"d G8H1E2O9N3.-W%8.56. f\"], [\"B4A1D1I8B4.-E%8.76.\"], [\"ffr65A C8K4D9U7V5.-Y%8.00.\"], [\" 76 B2L4D0A8C6.-T%8.90. lkd\"], [\"B2L4D0A8C6.-T%8.90\"], [\"B2L4D0AFC6.-T%8.90.\"], [\"B4A1D1I8B4\"], ...
Chuck has lost count of how many asses he has kicked... Chuck stopped counting at 100,000 because he prefers to kick things in the face instead of counting. That's just who he is. To stop having to count like a mere mortal chuck developed his own special code using the hairs on his beard. You do not need to know the ...
0
{"tests": "{\"inputs\": [\"8\\n285 224 U\\n130 175 R\\n111 198 D\\n121 188 L\\n201 116 U\\n112 121 R\\n145 239 D\\n185 107 L\", \"4\\n20 30 U\\n30 20 R\\n20 10 D\\n19 20 L\", \"4\\n20 9 U\\n30 20 R\\n20 10 D\\n10 20 L\", \"8\\n285 68 U\\n70 175 R\\n111 192 D\\n15 123 L\\n200 116 U\\n0 121 R\\n119 240 D\\n99 107 L\", \"...
M-kun is a brilliant air traffic controller. On the display of his radar, there are N airplanes numbered 1, 2, ..., N, all flying at the same altitude. Each of the airplanes flies at a constant speed of 0.1 per second in a constant direction. The current coordinates of the airplane numbered i are (X_i, Y_i), and the d...
0.875
{"tests": "{\"inputs\": [\"4\\n25 4\\n9 20\\n1 1 10\\n25 4\\n12 20\\n1 1 10\\n100 1\\n45 2\\n0 4 10\\n9 2\\n69 2\\n4 2 7\\n\", \"1\\n1 1\\n10000100000 1\\n200000 1 1\\n\", \"1\\n1 1\\n10000100000 1\\n199999 1 1\\n\", \"1\\n1 1\\n10000100000 1\\n199998 1 1\\n\", \"1\\n1 1\\n10000200001 1\\n199999 1 1\\n\", \"1\\n1 1\\n1...
Monocarp is playing a computer game. In this game, his character fights different monsters. A fight between a character and a monster goes as follows. Suppose the character initially has health $h_C$ and attack $d_C$; the monster initially has health $h_M$ and attack $d_M$. The fight consists of several steps: the ch...
0.125
{"tests": "{\"inputs\": [\"5\\n1000000000 1000000000 1000000000 1000000000 1000000000\\n100000 100000 100000 100000 100000\\n\", \"10\\n14 31 50 67 42 44 86 82 35 63\\n76 17 26 44 60 54 50 73 71 70\\n\", \"10\\n4 4 1 2 2 2 5 4 1 5\\n28 81 36 44 2 40 39 43 36 33\\n\", \"10\\n69564153 558821634 273092444 121621442 354953...
VK news recommendation system daily selects interesting publications of one of n disjoint categories for each user. Each publication belongs to exactly one category. For each category i batch algorithm selects a_i publications. The latest A/B test suggests that users are reading recommended publications more actively ...
0
{"tests": "{\"inputs\": [[0], [1], [2], [3], [4]], \"outputs\": [[0], [1], [2], [2], [3]]}", "source": "primeintellect"}
I assume most of you are familiar with the ancient legend of the rice (but I see wikipedia suggests [wheat](https://en.wikipedia.org/wiki/Wheat_and_chessboard_problem), for some reason) problem, but a quick recap for you: a young man asks as a compensation only `1` grain of rice for the first square, `2` grains for the...
0
{"tests": "{\"inputs\": [\"2\\n2\\n2 2\\n1\\n6\", \"2\\n2\\n2 1\\n1\\n6\", \"2\\n2\\n2 2\\n1\\n8\", \"2\\n2\\n4 2\\n1\\n6\", \"2\\n1\\n2 1\\n1\\n1\", \"2\\n3\\n3 2\\n1\\n8\", \"2\\n3\\n4 2\\n0\\n1\", \"2\\n3\\n4 7\\n0\\n6\", \"2\\n3\\n5 2\\n0\\n2\", \"2\\n4\\n4 9\\n0\\n6\", \"2\\n6\\n4 11\\n0\\n6\", \"2\\n0\\n2 2\\n1\\...
Read problems statements in Mandarin Chinese and Russian. Rupsa recently started to intern under Chef. He gave her N type of ingredients of varying quantity A_{1}, A_{2}, ..., A_{N} respectively to store it. But as she is lazy to arrange them she puts them all in a storage box. Chef comes up with a new recipe and ...
0
{"tests": "{\"inputs\": [\"aab\\n\", \"bcbc\\n\", \"ddd\\n\", \"ddc\", \"aaa\", \"adad\", \"bbcc\", \"dec\", \"aa`\", \"ccbb\", \"eec\", \"aa_\", \"ccbc\", \"cee\", \"ba_\", \"cbbc\", \"ece\", \"_ab\", \"ccba\", \"eed\", \"`ab\", \"ccab\", \"dee\", \"`ba\", \"bcac\", \"eee\", \"`b`\", \"bcca\", \"dfe\", \"ab`\", \"bcc`...
Let x be a string of length at least 1. We will call x a good string, if for any string y and any integer k (k \geq 2), the string obtained by concatenating k copies of y is different from x. For example, a, bbc and cdcdc are good strings, while aa, bbbb and cdcdcd are not. Let w be a string of length at least 1. For a...
0.875
{"tests": "{\"inputs\": [\"6\\ncbabc\\nab\\nzza\\nba\\na\\nnutforajaroftuna\\n\", \"6\\ncbabc\\nab\\nzza\\nba\\na\\nnutforajaroftuna\\n\", \"6\\ncbabc\\n`b\\nzza\\nba\\na\\nnutforajaroftuna\\n\", \"6\\ncbabc\\nba\\nzza\\nba\\na\\nnutforajaroftuna\\n\", \"6\\ncbabc\\n`b\\nzza\\nab\\na\\nnutforajaroftuna\\n\", \"6\\ncbab...
A palindrome is a string that reads the same backward as forward. For example, the strings "z", "aaa", "aba", and "abccba" are palindromes, but "codeforces" and "ab" are not. You hate palindromes because they give you déjà vu. There is a string $s$. You must insert exactly one character 'a' somewhere in $s$. If it is ...
0
{"tests": "{\"inputs\": [[[2, -4, 6, -6]], [[7, -3, -10]], [[7, -8, 1, -2]], [[8, 10, -6, -7, 9]], [[-3, 4, -10, 2, -6]], [[2, -6, -4, 1, -8, -2]], [[16, 25, -48, -47, -37, 41, -2]], [[-30, -11, 36, 38, 34, -5, -50]], [[-31, -5, 11, -42, -22, -46, -4, -28]], [[46, 39, -45, -2, -5, -6, -17, -32, 17]], [[-9, -8, -6, -46,...
# Scenario With **_Cereal crops_** like wheat or rice, before we can eat the grain kernel, we need to remove that inedible hull, or *to separate the wheat from the chaff*. ___ # Task **_Given_** a *sequence of n integers* , **_separate_** *the negative numbers (chaff) from positive ones (wheat).* ___ # Notes * *...
0
{"tests": "{\"inputs\": [\"4\\nababa\\nba\\nababa\\nbb\\naaa\\naaaa\\naababa\\nababa\\n\", \"1\\naababa\\nababa\\n\", \"10\\npaxghjnihn\\nhn\\nhdmevxvn\\nn\\nazdfhfxem\\nxem\\neowhldode\\ndode\\nwlclsnht\\nct\\nbpflheocamv\\nv\\nflejfh\\nhixqqbnikthccagc\\ndugt\\neebmbpykcsmi\\noivgrzwppny\\nzhfyiuu\\nebkqjcbcwviqkojnz...
You are given two strings $s$ and $t$, both consisting of lowercase English letters. You are going to type the string $s$ character by character, from the first character to the last one. When typing a character, instead of pressing the button corresponding to it, you can press the "Backspace" button. It deletes the l...
0
{"tests": "{\"inputs\": [[7], [25], [50], [100], [1000], [10000]], \"outputs\": [[18], [107], [304], [993], [63589], [4721110]]}", "source": "primeintellect"}
Consider a sequence generation that follows the following steps. We will store removed values in variable `res`. Assume `n = 25`: ```Haskell -> [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] Let's remove the first number => res = [1]. We get.. -> [2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21...
0
{"tests": "{\"inputs\": [[[]], [[{\"range\": 5, \"damaged\": false}]], [[{\"range\": 5, \"damaged\": false}, {\"range\": 15, \"damaged\": true}]], [[{\"range\": 5}, {\"range\": 10, \"damaged\": true}, {\"damaged\": true}]], [[{\"range\": 10, \"damaged\": true}, {\"damaged\": true}]]], \"outputs\": [[false], [true], [tr...
Check your arrows You have a quiver of arrows, but some have been damaged. The quiver contains arrows with an optional range information (different types of targets are positioned at different ranges), so each item is an arrow. You need to verify that you have some good ones left, in order to prepare for battle: ```py...
0
{"tests": "{\"inputs\": [\"3 300\\n100 46 150\\n100 50 150\\n100 50 150\\n3 300\\n100 50 150\\n100 50 150\\n200 50 150\\n9 18\\n3 1 1\\n3 1 1\\n3 1 1\\n4 100 1\\n5 100 1\\n5 100 1\\n10 5 3\\n10 5 3\\n1 7 1000\\n10 18\\n1 2 3\\n2 3 4\\n3 4 5\\n4 5 6\\n5 6 7\\n6 7 8\\n7 8 9\\n8 9 10\\n9 10 11\\n10 11 12\\n0 0\", \"3 300\...
The customer telephone support center of the computer sales company called JAG is now in- credibly confused. There are too many customers who request the support, and they call the support center all the time. So, the company wants to figure out how many operators needed to handle this situation. For simplicity, let u...
0
{"tests": "{\"inputs\": [\"100 2 8\\n00\\n00\\n00\\n00\\n00\\n00\\n00\\n00\\n00\\n00\\n00\\n00\\n00\\n00\\n00\\n00\\n00\\n00\\n00\\n00\\n00\\n00\\n00\\n00\\n00\\n00\\n00\\n00\\n00\\n00\\n00\\n00\\n00\\n00\\n00\\n00\\n00\\n00\\n00\\n00\\n00\\n00\\n00\\n00\\n00\\n00\\n00\\n00\\n00\\n00\\n00\\n00\\n00\\n00\\n00\\n00\\n00\...
On some square in the lowest row of a chessboard a stands a pawn. It has only two variants of moving: upwards and leftwards or upwards and rightwards. The pawn can choose from which square of the lowest row it can start its journey. On each square lay from 0 to 9 peas. The pawn wants to reach the uppermost row having c...
0
{"tests": "{\"inputs\": [\"9\\n9 4\\n7 5\\n4 1\\n6 5\\n5 2\\n3 1\\n2 1\\n8 3\\n3\\n9 7 2\\n1 6 4\\n8 4 1\\n\", \"7\\n3 4\\n2 3\\n6 5\\n2 7\\n5 2\\n1 2\\n6\\n5 6 2\\n3 2 4\\n5 1 1\\n2 4 3\\n3 7 4\\n6 5 2\\n\", \"3\\n2 3\\n2 1\\n3\\n3 2 3\\n3 1 2\\n1 2 4\\n\", \"7\\n2 7\\n4 2\\n6 5\\n2 1\\n1 3\\n5 4\\n5\\n1 4 2\\n7 3 1\\...
There are n railway stations in Berland. They are connected to each other by n-1 railway sections. The railway network is connected, i.e. can be represented as an undirected tree. You have a map of that network, so for each railway section you know which stations it connects. Each of the n-1 sections has some integer...
0.25
{"tests": "{\"inputs\": [\"57319 68943\", \"25 10\", \"1000000000000000000 1000000000010000000\", \"10 36\", \"105904 68943\", \"25 12\", \"1000000001000000000 1000000000010000000\", \"10 48\", \"109335 68943\", \"13 12\", \"1000001001000000000 1000000000010000000\", \"13 48\", \"49791 68943\", \"6 12\", \"100000100100...
Problem There are $ 2 $ teams, Team UKU and Team Ushi. Initially, Team UKU has $ N $ people and Team Uku has $ M $ people. Team UKU and Team Ushi decided to play a game called "U & U". "U & U" has a common score for $ 2 $ teams, and the goal is to work together to minimize the common score. In "U & U", everyone's phys...
0
{"tests": "{\"inputs\": [\"7\\n1 2\\n1 2\\n3 2\\n1 1 2 2 3 3\\n3 3\\n3 4 4 1 1 1 1 1 2\\n2 2\\n1 1 2 1\\n4 2\\n50 50 50 50 3 50 50 50\\n4 2\\n6 6 6 6 2 2 9 6\\n2 9\\n1 3 3 3 3 3 1 1 3 1 3 1 1 3 3 1 1 3\\n\", \"7\\n1 2\\n1 2\\n3 2\\n1 1 2 2 3 6\\n3 3\\n3 4 4 1 1 1 1 1 2\\n2 2\\n1 1 2 1\\n4 2\\n50 50 50 50 3 50 50 50\\n4...
It is the hard version of the problem. The only difference is that in this version $1 \le n \le 300$. In the cinema seats can be represented as the table with $n$ rows and $m$ columns. The rows are numbered with integers from $1$ to $n$. The seats in each row are numbered with consecutive integers from left to right: ...
0
{"tests": "{\"inputs\": [\"2 1\\n1 2\\n\", \"2 2\\n1 2\\n\", \"3 1\\n3 2\\n3 1\\n\", \"5 2\\n2 1\\n2 3\\n5 3\\n4 1\\n\", \"4 4\\n3 2\\n4 3\\n2 1\\n\", \"21 1\\n1 2\\n2 3\\n3 4\\n4 5\\n5 6\\n6 7\\n7 8\\n8 9\\n9 10\\n10 11\\n11 12\\n12 13\\n5 14\\n14 15\\n14 16\\n14 17\\n14 18\\n14 19\\n14 20\\n14 21\\n\", \"6 5\\n1 2\\n...
Two players, Red and Blue, are at it again, and this time they're playing with crayons! The mischievous duo is now vandalizing a rooted tree, by coloring the nodes while playing their favorite game. The game works as follows: there is a tree of size n, rooted at node 1, where each node is initially white. Red and Blue...
0
{"tests": "{\"inputs\": [\"6\\n4\\n2\\n2\\n4\\n2\\n4\", \"5\\n1\\n4\\n1\\n2\\n2\", \"6\\n4\\n2\\n2\\n1\\n2\\n4\", \"6\\n4\\n1\\n2\\n1\\n2\\n4\", \"7\\n1\\n2\\n1\\n2\\n3\\n3\\n2\", \"6\\n3\\n2\\n2\\n2\\n2\\n4\", \"7\\n1\\n3\\n1\\n2\\n1\\n3\\n2\", \"7\\n1\\n3\\n1\\n2\\n4\\n3\\n2\", \"7\\n1\\n3\\n1\\n2\\n2\\n3\\n2\", \"6\...
There are N stones arranged in a row. The i-th stone from the left is painted in the color C_i. Snuke will perform the following operation zero or more times: * Choose two stones painted in the same color. Repaint all the stones between them, with the color of the chosen stones. Find the number of possible final s...
0
{"tests": "{\"inputs\": [\"4 5\\n..XXX\\n...X.\\n...X.\\n...X.\\n5\\n1 3\\n3 3\\n4 5\\n5 5\\n1 5\\n\", \"1 1\\nX\\n1\\n1 1\\n\", \"1 1\\n.\\n1\\n1 1\\n\", \"3 3\\n..X\\n.X.\\nX..\\n10\\n1 3\\n1 3\\n1 3\\n2 3\\n1 3\\n1 2\\n1 3\\n2 2\\n2 3\\n2 2\\n\", \"3 3\\n...\\nXXX\\nXX.\\n10\\n2 3\\n1 2\\n2 2\\n1 3\\n2 3\\n1 2\\n1 3...
The problem statement looms below, filling you with determination. Consider a grid in which some cells are empty and some cells are filled. Call a cell in this grid exitable if, starting at that cell, you can exit the grid by moving up and left through only empty cells. This includes the cell itself, so all filled in ...
0
{"tests": "{\"inputs\": [\"100 5\\n101 101 5 5\\n110 110 2 3\\n-112 -100 9 11\\n-208 160 82 90\\n-110 108 10 2\\n10 11\\n15 0 5 1\\n25 0 5 1\\n35 0 5 1\\n45 0 5 1\\n55 0 5 1\\n65 0 5 1\\n75 0 5 1\\n85 0 5 1\\n95 0 5 1\\n-19 0 5 20\\n-30 0 500 5\\n0 0\", \"100 5\\n101 101 5 5\\n110 110 2 3\\n-112 -100 5 11\\n-208 160 82...
In 40XX, the Earth was invaded by aliens! Already most of the Earth has been dominated by aliens, leaving Tsuruga Castle Fortress as the only remaining defense base. Suppression units are approaching the Tsuruga Castle Fortress one after another. <image> But hope remains. The ultimate defense force weapon, the ultra...
0
{"tests": "{\"inputs\": [[\"Robin Singh\"], [\"CodeWars\"], [\"I love arrays they are my favorite\"], [\"1 2 3\"], [\"\"]], \"outputs\": [[[\"Robin\", \"Singh\"]], [[\"CodeWars\"]], [[\"I\", \"love\", \"arrays\", \"they\", \"are\", \"my\", \"favorite\"]], [[\"1\", \"2\", \"3\"]], [[\"\"]]]}", "source": "primeintellect"...
Write a function to split a string and convert it into an array of words. For example: ```python "Robin Singh" ==> ["Robin", "Singh"] "I love arrays they are my favorite" ==> ["I", "love", "arrays", "they", "are", "my", "favorite"] ``` Write your solution by modifying this code: ```python def string_to_array(s): ...
0
{"tests": "{\"inputs\": [\"3\\n4 4\\n1 1 1 1\\n3 1\\n1 2 3\\n3 3\\n1 2 3\\n\", \"10\\n2 2\\n4 3\\n2 2\\n13 13\\n2 2\\n9 11\\n2 1\\n14 5\\n2 1\\n13 2\\n2 2\\n4 5\\n2 1\\n11 14\\n2 2\\n15 3\\n2 2\\n12 10\\n2 2\\n13 12\\n\", \"10\\n3 2\\n3 6 1\\n3 3\\n9 0 2\\n3 3\\n8 8 2\\n4 2\\n9 0 0 1\\n4 4\\n5 3 0 2\\n4 4\\n2 8 6 0\\n5...
Hanh lives in a shared apartment. There are $n$ people (including Hanh) living there, each has a private fridge. $n$ fridges are secured by several steel chains. Each steel chain connects two different fridges and is protected by a digital lock. The owner of a fridge knows passcodes of all chains connected to it. A f...
0
{"tests": "{\"inputs\": [\"7\\n0 blue 4\\n0 red 1\\n0 white 5\\n1 red\\n1 blue\\n0 black 16\\n1 black\", \"7\\n0 blue 4\\n0 red 1\\n0 white 3\\n1 red\\n1 blue\\n0 black 8\\n1 black\", \"7\\n0 blue 5\\n0 red 1\\n0 white 5\\n1 red\\n1 blue\\n0 black 16\\n1 black\", \"7\\n0 blue 4\\n0 red 1\\n0 white 5\\n1 red\\n1 blue\\n...
For a dictionary $M$ that stores elements formed by a pair of a string key and an integer value, perform a sequence of the following operations. Note that each key in $M$ must be unique. * insert($key$, $x$): Insert an element formed by a pair of $key$ and $x$ to $M$. If there is an element with $key$, replace the cor...
0
{"tests": "{\"inputs\": [\"4 9 30 10 3 1\\n\", \"4 9 24 10 3 1\\n\", \"196112 214848 221935 465535 132387 3661\\n\", \"1 9 10 5 5 3\\n\", \"626 705 1000 10072 858 35\\n\", \"1 8 10 3 3 3\\n\", \"5010 6384 10000 9022 3213 187\\n\", \"1 8 10 5 5 3\\n\", \"140 149 150 13 78 3\\n\", \"140 149 150 18 80 3\\n\", \"2 9 10 8 5...
It's a beautiful April day and Wallace is playing football with his friends. But his friends do not know that Wallace actually stayed home with Gromit and sent them his robotic self instead. Robo-Wallace has several advantages over the other guys. For example, he can hit the ball directly to the specified point. And ye...
0
{"tests": "{\"inputs\": [\"6\\n3 7\\n4 12\\n2 1000000000\\n7 97\\n1000000000 1000000000\\n2 1\\n\", \"7\\n2 1\\n2 1\\n2 1\\n2 1\\n2 1\\n2 1\\n2 1\\n\", \"1\\n841 4832526\\n\", \"7\\n2 1\\n2 1\\n2 1\\n2 1\\n2 1\\n2 1\\n2 1\\n\", \"1\\n841 4832526\\n\", \"1\\n870 4832526\\n\", \"6\\n2 7\\n4 12\\n2 1000000000\\n7 97\\n100...
You are given two positive integers $n$ and $k$. Print the $k$-th positive integer that is not divisible by $n$. For example, if $n=3$, and $k=7$, then all numbers that are not divisible by $3$ are: $1, 2, 4, 5, 7, 8, 10, 11, 13 \dots$. The $7$-th number among them is $10$. -----Input----- The first line contains a...
0.875
{"tests": "{\"inputs\": [\"3\\n5\\n2 1 aa\\n1 2 a\\n2 3 a\\n1 2 b\\n2 3 abca\\n2\\n1 5 mihai\\n2 2 buiucani\\n3\\n1 5 b\\n2 3 a\\n2 4 paiu\\n\", \"1\\n5\\n2 1 bb\\n1 2 b\\n2 3 b\\n1 2 c\\n2 3 bcdbweakpretests\\n\", \"1\\n2\\n1 1 ab\\n2 1 ab\\n\", \"1\\n2\\n1 3 c\\n2 3 b\\n\", \"1\\n3\\n2 1 z\\n2 1 a\\n1 1 z\\n\", \"1\\...
Alperen has two strings, $s$ and $t$ which are both initially equal to "a". He will perform $q$ operations of two types on the given strings: $1 \;\; k \;\; x$ — Append the string $x$ exactly $k$ times at the end of string $s$. In other words, $s := s + \underbrace{x + \dots + x}_{k \text{ times}}$. $2 \;\; k \;\; x...
0
{"tests": "{\"inputs\": [\"1 1\\n-16\", \"5 3\\n-10 10 -18 10 -10\", \"4 2\\n7 -10 -10 10\", \"4 2\\n7 -6 -10 12\", \"4 2\\n7 -6 -10 20\", \"4 2\\n9 -1 -10 20\", \"4 2\\n13 -1 -10 20\", \"4 2\\n3 -1 -10 20\", \"4 3\\n3 -1 -10 20\", \"4 3\\n3 -1 -1 20\", \"10 5\\n5 -4 -5 -8 -4 0 2 -4 0 7\", \"4 4\\n9 -1 -10 20\", \"4 3\...
There are N squares aligned in a row. The i-th square from the left contains an integer a_i. Initially, all the squares are white. Snuke will perform the following operation some number of times: * Select K consecutive squares. Then, paint all of them white, or paint all of them black. Here, the colors of the squares...
0
{"tests": "{\"inputs\": [\"6\\n1 0 0\\n1\\n1 0 0\\n2\\n1 0 1\\n1\\n1 0 1\\n2\\n1 1 1\\n1\\n1 1 1\\n2\\n\", \"7\\n5 2 4\\n3 1 1 2 5\\n5 3 4\\n1 1 2 1 2\\n4 0 4\\n5 5 3 3\\n4 1 4\\n2 3 2 3\\n6 1 2\\n3 2 1 1 1 1\\n6 2 4\\n3 3 2 1 1 1\\n6 2 6\\n1 1 3 2 1 1\\n\", \"7\\n5 2 4\\n3 1 1 2 5\\n5 3 4\\n1 1 2 1 2\\n4 0 4\\n5 5 3 3...
In the game of Mastermind, there are two players — Alice and Bob. Alice has a secret code, which Bob tries to guess. Here, a code is defined as a sequence of n colors. There are exactly n+1 colors in the entire universe, numbered from 1 to n+1 inclusive. When Bob guesses a code, Alice tells him some information about ...
0
{"tests": "{\"inputs\": [[\"AAA\", [1]], [\"AAA\", [2]], [\"AAA\", [-1]], [\"AAAA\", [2]], [\"AGGTGACACCGCAAGCCTTATATTAGC\"], [\"AGGTGACACCGCAAGCCTTATATTAGC\", [1, 2]], [\"AGGTGACACCGCAAGCCTTATATTAGC\", [2, 1]], [\"AGGTGACACCGCAAGCCTTATATTAGC\", []], [\"\"], [\"\", []]], \"outputs\": [[[\"K\"]], [[\"\"]], [[\"F\"]], [[...
In genetics a reading frame is a way to divide a sequence of nucleotides (DNA bases) into a set of consecutive non-overlapping triplets (also called codon). Each of this triplets is translated into an amino-acid during a translation process to create proteins. In a single strand of DNA you find 3 Reading frames, for e...
0
{"tests": "{\"inputs\": [\"2 5000\\n\", \"3 5000\\n\", \"182 6\\n\", \"364 4\\n\", \"1 5000\\n\", \"72 72\\n\", \"5 1\\n\", \"500 5000\\n\", \"75 16\\n\", \"212 14\\n\", \"277 5\\n\", \"4 5\\n\", \"321 24\\n\", \"4 3\\n\", \"500 1\\n\", \"481 11\\n\", \"76 2\\n\", \"496 4\\n\", \"74 9\\n\", \"100 5000\\n\", \"166 5\\n\...
You are given two positive integers d and s. Find minimal positive integer n which is divisible by d and has sum of digits equal to s. Input The first line contains two positive integers d and s (1 ≤ d ≤ 500, 1 ≤ s ≤ 5000) separated by space. Output Print the required number or -1 if it doesn't exist. Examples In...
0
{"tests": "{\"inputs\": [\"3 5\\n1 4 4 3 4\\n1 4 1 4 2\\n1 4 4 4 3\\n\", \"1 1\\n1\\n\", \"1 1\\n2\\n\", \"3 1\\n1\\n1\\n1\\n\", \"1 1\\n1\\n\", \"1 1\\n2\\n\", \"3 1\\n1\\n1\\n1\\n\", \"3 1\\n1\\n1\\n2\\n\", \"3 5\\n1 4 4 3 4\\n1 4 2 4 2\\n1 4 4 4 3\\n\", \"3 5\\n1 4 4 3 4\\n1 4 2 4 2\\n1 3 4 4 3\\n\", \"3 5\\n1 4 4 3...
Monocarp is playing a game "Assimilation IV". In this game he manages a great empire: builds cities and conquers new lands. Monocarp's empire has $n$ cities. In order to conquer new lands he plans to build one Monument in each city. The game is turn-based and, since Monocarp is still amateur, he builds exactly one Mon...
0.375
{"tests": "{\"inputs\": [\"10\\n8 2\\n5 6\\n1 8\\n2 9\\n1 4\\n8 10\\n10 5\\n2 7\\n2 3\\n\", \"5\\n5 1\\n5 2\\n5 3\\n5 4\\n\", \"30\\n17 27\\n30 7\\n4 3\\n25 12\\n7 10\\n1 11\\n14 13\\n3 23\\n4 20\\n7 29\\n22 30\\n18 24\\n26 21\\n3 15\\n23 19\\n20 26\\n16 14\\n25 16\\n18 2\\n16 6\\n18 9\\n26 18\\n22 25\\n22 5\\n1 8\\n28...
You are given a tree with n nodes. You have to write non-negative integers on its edges so that the following condition would be satisfied: For every two nodes i, j, look at the path between them and count the sum of numbers on the edges of this path. Write all obtained sums on the blackboard. Then every integer from ...
0
{"tests": "{\"inputs\": [[2], [1, 12, 34], [1009, 2], [1, 1, 13], [2, 5, 8], [1, 8, 27]], \"outputs\": [[\"2\"], [\"01\\n12\\n34\"], [\"1009\\n0002\"], [\"01\\n01\\n13\"], [\"2\\n5\\n8\"], [\"01\\n08\\n27\"]]}", "source": "primeintellect"}
Given some positive integers, I wish to print the integers such that all take up the same width by adding a minimum number of leading zeroes. No leading zeroes shall be added to the largest integer. For example, given `1, 23, 2, 17, 102`, I wish to print out these numbers as follows: ```python 001 023 002 017 102 ```...
0
{"tests": "{\"inputs\": [\"z\\na\\n\", \"abc\\naaac\\n\", \"bcbcdddbbd\\nbcbcdbdbbd\\n\", \"aaabccadac\\nacabbbabaa\\n\", \"a\\nb\\n\", \"acaccaaadz\\ncaadccaaaa\\n\", \"aa\\nab\\n\", \"abacaba\\naba\\n\", \"aabbaa\\naaaaaaaaaaaaaaaaaaaa\\n\", \"ac\\na\\n\", \"a\\na\\n\", \"aabbaa\\ncaaaaaaaaa\\n\", \"aaaaaaaaa\\na\\n\...
Everything got unclear to us in a far away constellation Tau Ceti. Specifically, the Taucetians choose names to their children in a very peculiar manner. Two young parents abac and bbad think what name to give to their first-born child. They decided that the name will be the permutation of letters of string s. To keep...
0.125
{"tests": "{\"inputs\": [\"2 1000000000\\n2 1\\n\", \"2 1\\n2 1\\n\", \"4 1\\n4 1\\n2 4\\n3 1\\n\", \"3 1000000000\\n3 2\\n2 1\\n\", \"4 1\\n1 3\\n1 4\\n2 1\\n\", \"4 1\\n2 3\\n1 4\\n2 1\\n\", \"6 1\\n2 1\\n4 3\\n2 5\\n5 4\\n5 6\\n\", \"6 1\\n2 1\\n2 3\\n2 5\\n2 4\\n5 6\\n\", \"4 5\\n1 2\\n1 3\\n1 4\\n\", \"6 2\\n2 1\\...
You are given a tree (an undirected connected graph without cycles) and an integer s. Vanya wants to put weights on all edges of the tree so that all weights are non-negative real numbers and their sum is s. At the same time, he wants to make the diameter of the tree as small as possible. Let's define the diameter of...
0
{"tests": "{\"inputs\": [\"2\\n1 1 4\\n2 2 3\", \"2\\n1 1 3\\n2 2 3\", \"2\\n1 1 4\\n2 0 0\", \"2\\n0 1 1\\n2 0 0\", \"2\\n1 1 2\\n2 0 0\", \"2\\n1 1 0\\n3 0 0\", \"2\\n1 1 2\\n3 2 3\", \"2\\n1 1 4\\n2 2 5\", \"2\\n1 0 5\\n2 1 3\", \"2\\n1 1 4\\n4 2 5\", \"2\\n1 0 8\\n1 -1 3\", \"2\\n1 1 7\\n2 2 6\", \"2\\n1 2 7\\n2 3 ...
Ievan Ritola is a researcher of behavioral ecology. Her group visited a forest to analyze an ecological system of some kinds of foxes. The forest can be expressed as a two-dimensional plane. With her previous research, foxes in the forest are known to live at lattice points. Here, lattice points are the points whose x...
0
{"tests": "{\"inputs\": [[5], [12], [13], [16], [17], [20], [9001], [9004], [9005], [9008], [90001], [90002], [90004], [90005], [90009], [900001], [900004], [900005], [9000001], [9000004], [90000001], [90000004], [900000012], [9000000041]], \"outputs\": [[[[3, 1]]], [[[4, 1]]], [[[7, 3]]], [[[4, 0]]], [[[9, 4]]], [[[6,...
In mathematics, a [Diophantine equation](https://en.wikipedia.org/wiki/Diophantine_equation) is a polynomial equation, usually with two or more unknowns, such that only the integer solutions are sought or studied. In this kata we want to find all integers `x, y` (`x >= 0, y >= 0`) solutions of a diophantine equation o...
0
{"tests": "{\"inputs\": [[[1, 2, 3], [1, 3]], [[6, 1, 3, 6, 8, 2], [3, 6, 6, 1, 2]], [[7], []], [[4, 3, 3, 61, 8, 8], [8, 61, 8, 3, 4]], [[0, 0, 0, 0, 0], [0, 0, 0, 0]]], \"outputs\": [[2], [8], [7], [3], [0]]}", "source": "primeintellect"}
Given two integer arrays where the second array is a shuffled duplicate of the first array with one element missing, find the missing element. Please note, there may be duplicates in the arrays, so checking if a numerical value exists in one and not the other is not a valid solution. ``` find_missing([1, 2, 2, 3], [1...
0
{"tests": "{\"inputs\": [[25], [47], [1], [3], [1234567]], \"outputs\": [[[1, 1, 1, -1, -1]], [[1, 1, -1, 1, 1, 1]], [[1]], [[1, 1]], [[1, 1, -1, -1, 1, -1, 1, 1, -1, 1, -1, 1, 1, -1, 1, -1, -1, -1, -1, 1, 1]]]}", "source": "primeintellect"}
Normally, we decompose a number into binary digits by assigning it with powers of 2, with a coefficient of `0` or `1` for each term: `25 = 1*16 + 1*8 + 0*4 + 0*2 + 1*1` The choice of `0` and `1` is... not very binary. We shall perform the *true* binary expansion by expanding with powers of 2, but with a coefficient o...
0
{"tests": "{\"inputs\": [\"3\\n-1000000000 1000000000\\n1000000000 0\\n1000 -1000000000\\n3\\n1000 -999999999\\n1000 0\\n1001 0\\n\", \"4\\n0 3\\n3 0\\n0 -3\\n-3 0\\n4\\n2 2\\n2 -2\\n-2 -2\\n-2 2\\n\", \"4\\n0 0\\n9 4\\n12 -5\\n5 -5\\n4\\n2 0\\n2 3\\n5 3\\n5 0\\n\", \"6\\n3 3\\n3 -3\\n0 -4\\n-4 -1\\n-4 2\\n1 5\\n9\\n0 ...
You've got another geometrical task. You are given two non-degenerate polygons A and B as vertex coordinates. Polygon A is strictly convex. Polygon B is an arbitrary polygon without any self-intersections and self-touches. The vertices of both polygons are given in the clockwise order. For each polygon no three consecu...
0.875
{"tests": "{\"inputs\": [\"5 5\\n10\\n2 4 420\\n4 5 974\\n5 1 910\\n1 3 726\\n1 2 471\\n5 2 94\\n3 2 307\\n2 5 982\\n5 4 848\\n3 5 404\\n\", \"5 4\\n4\\n5 4 614\\n4 1 177\\n1 3 66\\n5 2 43\\n\", \"3 2\\n10\\n2 3 290\\n3 1 859\\n3 1 852\\n1 2 232\\n1 2 358\\n2 1 123\\n1 3 909\\n2 1 296\\n1 3 119\\n1 2 584\\n\", \"1 1\\n...
Bankopolis is an incredible city in which all the n crossroads are located on a straight line and numbered from 1 to n along it. On each crossroad there is a bank office. The crossroads are connected with m oriented bicycle lanes (the i-th lane goes from crossroad ui to crossroad vi), the difficulty of each of the lan...
0.125
{"tests": "{\"inputs\": [\"3 2 11\", \"3 0 11\", \"2 2 28\", \"3 5 28\", \"5 4 11\", \"5 3 17\", \"5 4 18\", \"6 4 12\", \"4 3 5\", \"4 8 5\", \"4 3 10\", \"11 3 9\", \"8 10 37\", \"8 6 37\", \"8 6 42\", \"8 6 39\", \"8 6 77\", \"8 9 77\", \"3 0 22\", \"3 1 22\", \"5 1 22\", \"5 0 22\", \"5 0 25\", \"3 0 25\", \"3 1 7\...
F: Grid number problem Ebi-chan is trying to write exactly one integer from 1 to 2 \ times n in a grid with n columns horizontally and 2 rows vertically. Only one integer can be written to each cell in the grid. It's not fun just to write normally, so I set the following rules. * The absolute value of the differen...
0
{"tests": "{\"inputs\": [\"10 1 1 1 2 0 10\\n1 1\\n2 1\\n3 0\\n4 0\\n5 1\\n6 1\\n7 1\\n8 1\\n9 1\\n10 1\\n\", \"10 1 1 1 2 0 10\\n1 1\\n2 1\\n3 0\\n4 0\\n5 1\\n6 1\\n14 1\\n8 1\\n9 1\\n10 1\\n\", \"5 1 1 1 4 0 5\\n1 0\\n2 1\\n3 1\\n4 0\\n5 0\\n\", \"1 1 2 1 2 1 2\\n1 1\\n\", \"5 1 1 0 4 0 5\\n1 0\\n2 1\\n3 1\\n4 0\\n5 ...
There are two main kinds of events in the life of top-model: fashion shows and photo shoots. Participating in any of these events affects the rating of appropriate top-model. After each photo shoot model's rating increases by a and after each fashion show decreases by b (designers do too many experiments nowadays). Mor...
0.625
{"tests": "{\"inputs\": [\"11\\n\", \"0\\n\", \"17\\n\", \"18855321\\n\", \"34609610\\n\", \"25\\n\", \"9\\n\", \"40000000\\n\", \"17464436\\n\", \"38450759\\n\", \"395938\\n\", \"39099999\\n\", \"8\\n\", \"4\\n\", \"30426905\\n\", \"7\\n\", \"17082858\\n\", \"46341\\n\", \"46340\\n\", \"39999996\\n\", \"6\\n\", \"1282...
Imagine you have an infinite 2D plane with Cartesian coordinate system. Some of the integral points are blocked, and others are not. Two integral points A and B on the plane are 4-connected if and only if: * the Euclidean distance between A and B is one unit and neither A nor B is blocked; * or there is some inte...
0
{"tests": "{\"inputs\": [\"3 0 2\\n0.4085591484323763\\n0.00000100000\\n0.37500000000\", \"3 0 2\\n0.14744802999270293\\n0.37499999977\\n1.00000000000\", \"4 0 2\\n0.10000000000\\n0.50000000000\\n1.00000000000\", \"3 0 3\\n0.20000000000\\n0.00000100000\\n0.37500000000\", \"3 0 2\\n0.14744802999270293\\n1.14144761193850...
Miki is a high school student. She has a part time job, so she cannot take enough sleep on weekdays. She wants to take good sleep on holidays, but she doesn't know the best length of sleeping time for her. She is now trying to figure that out with the following algorithm: 1. Begin with the numbers K, R and L. 2. She t...
0
{"tests": "{\"inputs\": [[[3]], [[3, 13]], [[30, 34, 330]], [[3, 12, 5, 8, 30, 13]], [[]], [null]], \"outputs\": [[3], [16], [0], [16], [0], [0]]}", "source": "primeintellect"}
The magic sum of 3s is calculated on an array by summing up odd numbers which include the digit `3`. Write a function `magic_sum` which accepts an array of integers and returns the sum. *Example:* `[3, 12, 5, 8, 30, 13]` results in `16` (`3` + `13`) If the sum cannot be calculated, `0` should be returned. Write your...
0
{"tests": "{\"inputs\": [\"5 2\\nwelcome\\nto\\nthe\\nmatrix\\nneo\\n\", \"6 4\\ndog\\ncat\\ncow\\nhot\\nice\\nlol\\n\", \"4 1\\naa\\naba\\nba\\nbba\\n\", \"2 2\\naba\\naa\\n\", \"5 6\\nabas\\ndsfdf\\nabacaba\\ndartsidius\\nkolobok\\n\", \"3 8\\nso\\nbad\\ntest\\n\", \"3 3\\naa\\nabb\\ncc\\n\", \"1 3\\nab\\n\", \"4 2\\...
Andrew, Fedor and Alex are inventive guys. Now they invent the game with strings for two players. Given a group of n non-empty strings. During the game two players build the word together, initially the word is empty. The players move in turns. On his step player must add a single letter in the end of the word, the re...
0
{"tests": "{\"inputs\": [\"2\\n1 2\\n3 2\\n\", \"3\\n8 3\\n0 1\\n4 8\\n\", \"1\\n1 1\\n\", \"2\\n1 3\\n3 1\", \"1\\n0 0\", \"2\\n1 5\\n5 1\", \"3\\n8 3\\n-1 1\\n5 8\", \"2\\n0 2\\n3 1\", \"2\\n0 1\\n3 2\", \"2\\n1 4\\n5 2\", \"3\\n8 3\\n-1 0\\n4 8\", \"1\\n2 2\", \"1\\n-1 -1\", \"2\\n1 0\\n1 2\", \"2\\n2 3\\n2 1\", \"1...
You are given sequences A and B consisting of non-negative integers. The lengths of both A and B are N, and the sums of the elements in A and B are equal. The i-th element in A is A_i, and the i-th element in B is B_i. Tozan and Gezan repeats the following sequence of operations: - If A and B are equal sequences, term...
0
{"tests": "{\"inputs\": [\"5\\n6\\n3 2 5 6\\n2 4 6\\n3 1 3 4\\n2 1 3\\n4 1 2 4 6\\n5\\n2 2 3\\n2 1 2\\n2 1 4\\n2 4 5\\n7\\n3 1 2 6\\n4 1 3 5 6\\n2 1 2\\n3 4 5 7\\n6 1 2 3 4 5 6\\n3 1 3 6\\n2\\n2 1 2\\n5\\n2 2 5\\n3 2 3 5\\n4 2 3 4 5\\n5 1 2 3 4 5\\n\", \"1\\n6\\n4 2 3 4 5\\n2 1 2\\n2 3 5\\n2 2 5\\n6 1 2 3 4 5 6\\n\", \...
We guessed a permutation $p$ consisting of $n$ integers. The permutation of length $n$ is the array of length $n$ where each element from $1$ to $n$ appears exactly once. This permutation is a secret for you. For each position $r$ from $2$ to $n$ we chose some other index $l$ ($l < r$) and gave you the segment $p_l, p...
0
{"tests": "{\"inputs\": [[\"Hello\"], [314159], [\"314159\"], [[]], [{}], [true], [[1, 2, 3]]], \"outputs\": [[\"olleH\"], [951413], [\"951413\"], [[]], [{}], [true], [[1, 2, 3]]]}", "source": "primeintellect"}
You have to create a function named reverseIt. Write your function so that in the case a string or a number is passed in as the data , you will return the data in reverse order. If the data is any other type, return it as it is. Examples of inputs and subsequent outputs: ``` "Hello" -> "olleH" "314159" -> "951413" ...
0
{"tests": "{\"inputs\": [\"-12 -35\\n\", \"-215 -996\\n\", \"-96 -556\\n\", \"-1000 0\\n\", \"20 -21\\n\", \"0 0\\n\", \"207 -224\\n\", \"-668 970\\n\", \"-496 -644\\n\", \"253 -204\\n\", \"-129 489\\n\", \"15 -8\\n\", \"-589 952\\n\", \"0 2\\n\", \"-216 -90\\n\", \"-72 -646\\n\", \"280 342\\n\", \"0 1000\\n\", \"875 -...
Not so long ago as a result of combat operations the main Berland place of interest — the magic clock — was damaged. The cannon's balls made several holes in the clock, that's why the residents are concerned about the repair. The magic clock can be represented as an infinite Cartesian plane, where the origin correspond...
0
{"tests": "{\"inputs\": [\"10 5\\nzlsssrxujq\\n4 5\\n0 0\\n0 0\\n10 9\\n0 0\\n0 3\\n0 6\\n0 0\\n8 7\\n0 2\\n\", \"50 50\\navzqjbotzkdbrhpknuxxcndqnnkfpthvjriridgnocygczqeyy\\n3 50\\n0 0\\n24 47\\n0 0\\n0 0\\n0 36\\n0 0\\n42 0\\n0 0\\n0 0\\n0 0\\n2 9\\n40 0\\n0 0\\n0 0\\n0 0\\n20 0\\n5 0\\n11 32\\n0 0\\n8 30\\n0 34\\n0 ...
A binary tree of n nodes is given. Nodes of the tree are numbered from 1 to n and the root is the node 1. Each node can have no child, only one left child, only one right child, or both children. For convenience, let's denote l_u and r_u as the left and the right child of the node u respectively, l_u = 0 if u does not ...
0
{"tests": "{\"inputs\": [\"10 5 5\\n45 45 12 67 32 6 125 33 89 100\\n6 3 78\\n1 2 23\\n5 7 17\\n9 2 90\\n4 8 39\\n\", \"16 12 2\\n215685056 606689499 786509392 322681480 170763622 255981931 402020260 580776290 525819654 50248606 830314959 223078821 851769718 76817680 251067040 491418559\\n14 4 951819487\\n4 2 770897556...
When Kefa came to the restaurant and sat at a table, the waiter immediately brought him the menu. There were n dishes. Kefa knows that he needs exactly m dishes. But at that, he doesn't want to order the same dish twice to taste as many dishes as possible. Kefa knows that the i-th dish gives him ai units of satisfact...
0
{"tests": "{\"inputs\": [\"3\\n3\\n111\\n2\\n21\\n4\\n2122\\n\", \"3\\n3\\n111\\n2\\n21\\n4\\n2122\\n\", \"3\\n3\\n111\\n2\\n12\\n4\\n2122\\n\", \"3\\n3\\n111\\n2\\n11\\n4\\n2122\\n\", \"3\\n3\\n111\\n1\\n1\\n4\\n2122\\n\", \"3\\n3\\n111\\n2\\n22\\n4\\n2122\\n\", \"3\\n3\\n111\\n2\\n21\\n4\\n2122\\n\"], \"outputs\": [\...
A chess tournament will be held soon, where $n$ chess players will take part. Every participant will play one game against every other participant. Each game ends in either a win for one player and a loss for another player, or a draw for both players. Each of the players has their own expectations about the tournamen...
0
{"tests": "{\"inputs\": [\"2\\n1\\n37\\n2\\n100 100\\n\", \"1\\n1\\n1\\n\", \"1\\n1\\n1000000000\\n\", \"1\\n50\\n260939408 52936453 298470524 981491199 699765 834662291 553329721 651730905 665925345 395625534 162042985 788733611 54572656 795877605 826562363 882540598 190947839 644851021 335204703 226590818 150893107 9...
Mike and Joe are playing a game with some stones. Specifically, they have $n$ piles of stones of sizes $a_1, a_2, \ldots, a_n$. These piles are arranged in a circle. The game goes as follows. Players take turns removing some positive number of stones from a pile in clockwise order starting from pile $1$. Formally, if ...
0.375
{"tests": "{\"inputs\": [\"kkkkkkz\\n\", \"ghhggh\\n\", \"kkkkkkz\\n\", \"abbaab\\n\", \"akakak\\n\"], \"outputs\": [\"15\\n\", \"4\\n\", \"15\\n\", \"4\\n\", \"2\\n\"]}", "source": "primeintellect"}
Consider a string, $S$, of $n$ lowercase English letters where each character, $s_i$ ($0\leq i<n)$, denotes the letter at index $\boldsymbol{i}$ in $S$. We define an $(a,b,c,d)$ palindromic tuple of $S$ to be a sequence of indices in $S$ satisfying the following criteria: $\boldsymbol{s_{a}}=\boldsymbol{s_{d}}$, meani...
0
{"tests": "{\"inputs\": [\"1\\n1 0 1 1\\n10000 10000 10000 10000\", \"2\\n10 3 1 2\\n2 4 1 3\\n1 2 1 1\", \"2\\n10 3 1 2\\n2 4 1 3\\n1 3 1 1\", \"2\\n10 3 1 2\\n3 4 1 3\\n1 3 1 1\", \"2\\n10 3 2 2\\n3 4 1 3\\n1 3 1 1\", \"1\\n1 0 1 1\\n10000 10010 10000 10000\", \"1\\n1 0 1 1\\n10000 10010 10000 10100\", \"1\\n1 0 1 1\...
A rabbit is playing a role-playing game. Just before entering the castle, he was ambushed by an enemy! It was a battle between one hero operated by a rabbit and n enemies. Each character has four stats, health hi, attack power ai, defense power di, and agility si. I = 0 is the information of the main character, 1 ≤ i ...
0.375
{"tests": "{\"inputs\": [\"5 3\\n10 14 19 34 33\\n\", \"9 14\\n1 3 5 110 24 21 34 5 3\\n\", \"9 73\\n67597 52981 5828 66249 75177 64141 40773 79105 16076\\n\", \"5 3\\n10 4 19 34 33\", \"9 14\\n1 3 5 110 24 21 34 2 3\", \"9 73\\n67597 52981 5828 18 75177 64141 40773 79105 16076\", \"5 1\\n10 4 19 34 33\", \"9 14\\n1 3 ...
Takahashi has come to a party as a special guest. There are N ordinary guests at the party. The i-th ordinary guest has a power of A_i. Takahashi has decided to perform M handshakes to increase the happiness of the party (let the current happiness be 0). A handshake will be performed as follows: - Takahashi chooses on...
0
{"tests": "{\"inputs\": [\"1 1 1000000 1000000 0 0\\n2\\n2 1\\n1 2\\n\", \"1000 0 100000000 100000000 0 0\\n2\\n999 0\\n1100 0\\n\", \"1231231 2342342 123124 123151 12315 12312\\n1\\n354345 234234\\n\", \"446799 395535 281981 494983 755701 57488\\n20\\n770380 454998\\n147325 211816\\n818964 223521\\n408463 253399\\n491...
It was recycling day in Kekoland. To celebrate it Adil and Bera went to Central Perk where they can take bottles from the ground and put them into a recycling bin. We can think Central Perk as coordinate plane. There are n bottles on the ground, the i-th bottle is located at position (xi, yi). Both Adil and Bera can c...
0
{"tests": "{\"inputs\": [[\"1 tomato\"], [\"0 tomato\"], [\"1 ananas\"], [\"2 bananas\"], [\"3 bananas\"], [\"10 bananas\"], [\"111 bananas\"], [\"6 birds with 2 wings each = 12 legs\"], [\"\\n3 pigs\\nmet 1 wolf\\n2 days ago\"]], \"outputs\": [[\"1 tomato\"], [\"0 tomato\"], [\"1 ananas\"], [\"2 bubanana\"], [\"3 bana...
Once upon a time, a CodeWarrior, after reading a [discussion on what can be the plural](http://www.codewars.com/kata/plural/discuss/javascript), took a look at [this page](http://en.wikipedia.org/wiki/Grammatical_number#Types_of_number ) and discovered that **more than 1** "kind of plural" may exist. For example [Sur...
0
{"tests": "{\"inputs\": [[\")()(\"], [\"((()\"], [\"(((\"], [\"())(((\"], [\"())()))))()()(\"]], \"outputs\": [[2], [1], [-1], [3], [4]]}", "source": "primeintellect"}
Given a string, return the minimal number of parenthesis reversals needed to make balanced parenthesis. For example: ```Javascript solve(")(") = 2 Because we need to reverse ")" to "(" and "(" to ")". These are 2 reversals. solve("(((())") = 1 We need to reverse just one "(" parenthesis to make it balanced. solve("(...
0
{"tests": "{\"inputs\": [[[3, 2, 6, 2, 1, 3]], [[3, 2, 6, 2]], [[]], [[1, 100, 4, 2, 4]], [[-1, 1, -1]]], \"outputs\": [[[[3, 3], [2, 2], [6], [1]]], [[[3], [2, 2], [6]]], [[]], [[[1], [100], [4, 4], [2]]], [[[-1, -1], [1]]]]}", "source": "primeintellect"}
Sam is an avid collector of numbers. Every time he finds a new number he throws it on the top of his number-pile. Help Sam organise his collection so he can take it to the International Number Collectors Conference in Cologne. Given an array of numbers, your function should return an array of arrays, where each subar...
0
{"tests": "{\"inputs\": [\"halasouqgfxfcrwhqgllaqiphaxekljz\\n87\\n\", \"fntrmjfquczybyjllywsqwllsxdmqynmyfcqhakftitvvfbxtqktbfsvvvanjbkqubyxu\\n63\\n\", \"abcdefghijklmnopqrsttsrqponmlkjihgfedcba\\n0\\n\", \"aaaaaaaaaaaaaaaaaaaaaeeeeeeeeeeeeeeeeeeee\\n20\\n\", \"abcdefghijklmnopqrstuvwxyz\\n17\\n\", \"abcdefghijjihged...
Once when Gerald studied in the first year at school, his teacher gave the class the following homework. She offered the students a string consisting of n small Latin letters; the task was to learn the way the letters that the string contains are written. However, as Gerald is too lazy, he has no desire whatsoever to l...
0
{"tests": "{\"inputs\": [\"2 0\\n1 0\\n\", \"3 1\\n2 3\\n0 1 1\\n\", \"4 2\\n1 3\\n2 4\\n0 1 0 1\\n\", \"10 10\\n2 1\\n3 1\\n4 1\\n3 5\\n6 2\\n5 7\\n1 8\\n5 9\\n10 5\\n7 2\\n1 0 0 0 1 1 1 0 0 1\\n\", \"10 10\\n1 2\\n2 3\\n3 4\\n2 5\\n3 6\\n7 4\\n8 7\\n9 1\\n7 10\\n5 3\\n1 0 0 1 1 0 0 1 1 1\\n\", \"10 10\\n1 2\\n3 1\\n4...
Twilight Sparkle learnt that the evil Nightmare Moon would return during the upcoming Summer Sun Celebration after one thousand years of imprisonment on the moon. She tried to warn her mentor Princess Celestia, but the princess ignored her and sent her to Ponyville to check on the preparations for the celebration. <im...
0
{"tests": "{\"inputs\": [[2, [\"e|-------5-7-----7-|-8-----8-2-----2-|-0---------0-----|-----------------|\", \"B|-----5-----5-----|---5-------3-----|---1---1-----1---|-0-1-1-----------|\", \"G|---5---------5---|-----5-------2---|-----2---------2-|-0-2-2-----------|\", \"D|-7-------6-------|-5-------4-------|-3--------...
You are to write a function to transpose a guitar tab up or down a number of semitones. The amount to transpose is a number, positive or negative. The tab is given as an array, with six elements for each guitar string (fittingly passed as strings). Output your tab in a similar form. Guitar tablature (or 'tab') is an a...
0
{"tests": "{\"inputs\": [\"4\\n2:2,3-1:4\\n3:4,3,1\\n3:2,4,1\\n1:2-2:1,3\\n\", \"10\\n2:7,4-2:5,8-1:3-1:6-1:2-2:10,9\\n9:6,7,3,4,10,8,9,5,1\\n9:2,1,7,6,9,4,8,10,5\\n8:5,2,1,3,6,9,10,8-1:7\\n1:8-8:9,10,2,6,3,1,7,4\\n9:8,4,1,2,10,9,7,3,5\\n9:1,3,6,2,9,10,5,8,4\\n9:5,2,7,3,6,4,10,1,9\\n9:3,7,6,8,10,5,1,2,4\\n1:9-8:2,7,3,6...
In the computer network of the Berland State University there are n routers numbered from 1 to n. Some pairs of routers are connected by patch cords. Information can be transmitted over patch cords in both direction. The network is arranged in such a way that communication between any two routers (directly or through o...
0
{"tests": "{\"inputs\": [\"3 6\\n..#..#\\n......\\n#####.\\n1 1 2 1 1 1\\n\", \"3 10\\n#..###..##\\n...#..###.\\n.###..##..\\n1 1 1 3 1 1 2 2 2 1\\n\", \"1 1\\n.\\n0\\n\", \"1 1\\n#\\n1\\n\", \"3 3\\n#.#\\n#..\\n##.\\n2 1 1\\n\", \"3 3\\n#.#\\n.#.\\n##.\\n2 2 1\\n\", \"3 3\\n#.#\\n#..\\n##.\\n3 1 0\\n\", \"3 3\\n#.#\\n...
This is the easy version of the problem. The difference between the versions is the constraints on a_i. You can make hacks only if all versions of the problem are solved. Little Dormi has recently received a puzzle from his friend and needs your help to solve it. The puzzle consists of an upright board with n rows a...
0
{"tests": "{\"inputs\": [\"2 -1\\nba\\n\", \"3 -7\\nabc\\n\", \"7 -475391\\nqohshra\\n\", \"3 -3\\nabc\\n\", \"3 -1\\nabc\\n\", \"3 1\\nabc\\n\", \"3 3\\nabc\\n\", \"3 5\\nabc\\n\", \"3 7\\nabc\\n\", \"2 393216\\nrt\\n\", \"3 1536\\nljm\\n\", \"4 -16777248\\nfyyy\\n\", \"2 393217\\nrt\\n\", \"3 3404\\nljm\\n\", \"4 962...
You've got a string $S$ consisting of $n$ lowercase English letters from your friend. It turned out that this is a number written in poman numerals. The poman numeral system is long forgotten. All that's left is the algorithm to transform number from poman numerals to the numeral system familiar to us. Characters of $S...
0
{"tests": "{\"inputs\": [[\"professionals\"], [\"i\"], [\"\"], [\"me\"], [\"you\"], [\"card-carrying\"], [\"shan't\"], [\"-dcba\"], [\"dcba.\"], [\"you've gotta dance like there's nobody watching, love like you'll never be hurt, sing like there's nobody listening, and live like it's heaven on earth.\"]], \"outputs\": [...
Background There is a message that is circulating via public media that claims a reader can easily read a message where the inner letters of each words is scrambled, as long as the first and last letters remain the same and the word contains all the letters. Another example shows that it is quite difficult to read the...
0
{"tests": "{\"inputs\": [\"A+A++A\\nZ-Z--Z+-Z\\n[ESRVEER]\\nJ---?---J\\n++++++++A+++Z-----------A+++Z\\n[[++-+--?[--++-?++-+++L]][-+-----+-O]]++++---+L\\n.\", \"A+A++A\\nZ-ZZ--+-Z\\n[ESRVEER]\\nJ---?---J\\n++++++++A+++Z-----------A+++Z\\n[[++-+--?[--++-?++-+++L]][-+-----+-O]]++++---+L\\n.\", \"A+A++A\\nZ-Z--Z+-Z\\n[ESR...
Broken crypto generator JAG (Japanese Alumni Group) is a mysterious organization composed of many programmers, and in order to enter the building where the headquarters of this organization is located, it is necessary to solve the ciphertext generated by a certain machine every time. This ciphertext consists of the sy...
0
{"tests": "{\"inputs\": [\"6 0\", \"5 5\\n1 2\\n2 3\\n3 1\\n4 5\\n5 1\", \"7 0\", \"6 4\\n2 3\\n3 4\\n4 3\\n5 4\", \"4 0\", \"8 0\", \"1 0\", \"11 0\", \"13 0\", \"6 4\\n2 3\\n3 5\\n4 3\\n5 4\", \"3 0\", \"5 5\\n1 2\\n2 3\\n3 4\\n4 5\\n5 2\", \"6 4\\n2 2\\n3 4\\n4 3\\n5 4\", \"17 0\", \"6 4\\n2 3\\n1 5\\n4 3\\n5 4\", \...
Natsuki and her friends were taken to the space by an alien and made friends with a lot of aliens. During the space travel, she discovered that aliens’ hands were often very different from humans’. Generally speaking, in a kind of aliens, there are N fingers and M bend rules on a hand. Each bend rule describes that a f...
0
{"tests": "{\"inputs\": [[12, 5, \"January\"], [12, 1, \"February\"], [12, 1, \"March\"], [12, 12, \"September\"], [12, 5, \"March\"], [100, 5, \"March\"], [100, 52, \"July\"], [100, 51, \"July\"], [100, 53, \"July\"]], \"outputs\": [[\"You are on track.\"], [\"You are on track.\"], [\"You are 1 behind schedule.\"], [\...
Given the number pledged for a year, current value and name of the month, return string that gives information about the challenge status: - ahead of schedule - behind schedule - on track - challenge is completed Examples: `(12, 1, "February")` - should return `"You are on track."` `(12, 1, "March")` - should retur...
0
{"tests": "{\"inputs\": [\"2\\n6\\nLRRRLL\\n3\\nLRL\\n\", \"2\\n6\\nLLRRRL\\n3\\nLRL\\n\", \"2\\n6\\nLLRRRL\\n3\\nRLL\\n\", \"2\\n6\\nLRRRLL\\n3\\nRLL\\n\", \"2\\n6\\nLLRRRL\\n3\\nLLR\\n\", \"2\\n6\\nLRRRLL\\n3\\nLLR\\n\", \"2\\n6\\nLRLRRL\\n3\\nLRL\\n\", \"2\\n6\\nRRLRLL\\n3\\nRLL\\n\", \"2\\n6\\nRRRLLL\\n3\\nLLR\\n\"...
There are $n + 1$ cities, numbered from $0$ to $n$. $n$ roads connect these cities, the $i$-th road connects cities $i - 1$ and $i$ ($i \in [1, n]$). Each road has a direction. The directions are given by a string of $n$ characters such that each character is either L or R. If the $i$-th character is L, it means that ...
0
{"tests": "{\"inputs\": [[\"10:00\"], [\"10:45\"], [\"15:05\"], [\"06:10\"], [\"05:10\"], [\"04:50\"], [\"05:55\"], [\"23:57\"], [\"00:00\"], [\"23:55\"]], \"outputs\": [[10], [10], [5], [0], [45], [65], [0], [358], [355], [0]]}", "source": "primeintellect"}
It's been a tough week at work and you are stuggling to get out of bed in the morning. While waiting at the bus stop you realise that if you could time your arrival to the nearest minute you could get valuable extra minutes in bed. There is a bus that goes to your office every 15 minute, the first bus is at `06:00`, ...
0
{"tests": "{\"inputs\": [[4, 123], [123, 4567], [2, 10], [2, 2], [7, 7], [7, 2], [21, 3], [0, 2], [2, 0], [4, -7], [-7, 4]], \"outputs\": [[1860], [86469], [20], [0], [0], [0], [0], [\"INVALID\"], [\"INVALID\"], [\"INVALID\"], [\"INVALID\"]]}", "source": "primeintellect"}
## Your Job Find the sum of all multiples of `n` below `m` ## Keep in Mind * `n` and `m` are natural numbers (positive integers) * `m` is **excluded** from the multiples ## Examples Write your solution by modifying this code: ```python def sum_mul(n, m): ``` Your solution should implemented in...
0
{"tests": "{\"inputs\": [\"5 5\\n.....\\n.#...\\n.....\\n.....\\n#.###\\n\", \"3 4\\n..##\\n....\\n..#.\\n\", \"2 42\\n..........#.......#..........###........#.\\n.....#######.......#..#....#...##.........\\n\", \"6 8\\n...##...\\n.#.#.#.#\\n#.#.#.#.\\n.#.#.#.#\\n#.#.#.#.\\n#.......\\n\", \"4 3\\n#.#\\n.##\\n...\\n.#....
"The Chamber of Secrets has been opened again" — this news has spread all around Hogwarts and some of the students have been petrified due to seeing the basilisk. Dumbledore got fired and now Harry is trying to enter the Chamber of Secrets. These aren't good news for Lord Voldemort. The problem is, he doesn't want anyb...
0
{"tests": "{\"inputs\": [\"3 1\\n3 1 4\\n5 3 2\\n\", \"7 3\\n27 18 28 18 28 46 1000000000\\n1000000000 1 7\\n1000000000 2 10\\n1000000000 3 12\\n\", \"3 1\\n2 1 4\\n5 3 2\", \"7 3\\n27 18 28 18 28 46 1000000000\\n1000000010 1 7\\n1000000000 2 10\\n1000000000 3 12\", \"7 3\\n27 18 28 18 28 46 1000000000\\n1000000010 1 7...
We have a sequence of k numbers: d_0,d_1,...,d_{k - 1}. Process the following q queries in order: - The i-th query contains three integers n_i, x_i, and m_i. Let a_0,a_1,...,a_{n_i - 1} be the following sequence of n_i numbers: \begin{eqnarray} a_j = \begin{cases} x_i & ( j = 0 ) \\ a_{j - 1} + d_{(j - 1)~\text...
0
{"tests": "{\"inputs\": [\"5 20\\n5 5 1 4\\n1 4 3\\n2 4 1\\n1 5 5\\n5 1 4\\n5 1 5\\n1 5 5\\n5 4 4\\n2 3 3\\n4 4 1\\n1 4 1\\n4 5 4\\n1 4 5\\n4 1 5\\n2 4 2\\n4 3 3\\n2 5 5\\n1 5 4\\n3 3 4\\n5 5 1\\n3 4 1\\n\", \"2 4\\n1\\n1 1 1\\n1 1 2\\n1 2 2\\n2 2 2\\n\", \"5 20\\n4 1 1 4\\n2 2 5\\n3 2 5\\n2 3 4\\n4 2 5\\n4 1 2\\n5 3 1...
Misha and Grisha are funny boys, so they like to use new underground. The underground has n stations connected with n - 1 routes so that each route connects two stations, and it is possible to reach every station from any other. The boys decided to have fun and came up with a plan. Namely, in some day in the morning M...
0.25
{"tests": "{\"inputs\": [\"2\\n17 25\\n4\\n17 45\\n4\\n17 25\\n7\\n1 35\\n0\", \"2\\n19 25\\n4\\n17 37\\n4\\n17 47\\n7\\n0 63\\n0\", \"2\\n14 25\\n4\\n3 37\\n4\\n17 47\\n7\\n0 63\\n0\", \"2\\n13 25\\n3\\n17 45\\n4\\n17 25\\n7\\n1 35\\n0\", \"2\\n14 25\\n4\\n17 37\\n0\\n17 47\\n7\\n0 63\\n0\", \"2\\n13 25\\n3\\n17 45\\n...
In 20XX, the Aizu Chuo Road, which has a total distance of 58km and 6 sections from Atsushiokanomachi, Kitakata City to Minamiaizucho, is scheduled to be completed and opened. For half a year after opening, the toll will be halved for vehicles that pass the departure IC or arrival IC between 17:30 and 19:30 and have a...
0
{"tests": "{\"inputs\": [\"2\\n-10 1 10 1\\n4\\n-6 2 -2 -2 0 1\\n-6 -2 -2 2 1 0\\n6 2 2 -2 0 0\\n6 -2 2 2 1 1\\n8 12 -7 -3\\n8\\n4 -5 4 -2 1 1\\n4 -2 4 9 1 0\\n6 9 6 14 1 1\\n-5 6 7 6 0 0\\n1 0 1 10 0 0\\n-5 0 -5 10 0 1\\n-7 0 7 0 0 1\\n-1 0 -1 -5 0 1\", \"2\\n-10 1 10 1\\n4\\n-6 2 -2 -2 0 1\\n-6 -2 -2 2 1 0\\n6 2 2 -2...
Nate U. Smith runs a railroad company in a metropolitan area. In addition to his railroad company, there are rival railroad companies in this metropolitan area. The two companies are in a competitive relationship with each other. In this metropolitan area, all lines are routed by the line segment connecting the statio...
0.375
{"tests": "{\"inputs\": [\"2 2 0 0 0 1\", \"421 435 196 169 388 5\", \"1 2 0 0 0 0\", \"421 435 196 91 388 9\", \"5 6 0 0 4 4\", \"1 10 0 1 0 9\", \"421 435 196 169 388 12\", \"421 435 196 169 388 10\", \"421 435 196 118 388 0\", \"421 92 17 19 388 10\", \"1 18 0 0 0 9\", \"421 435 196 169 135 9\", \"5 11 0 0 4 4\", \"...
Problem There is a grid of $ R \ times C $ squares with $ (0, 0) $ in the upper left and $ (R-1, C-1) $ in the lower right. When you are in a square ($ e $, $ f $), from there $ (e + 1, f) $, $ (e-1, f) $, $ (e, f + 1) $, $ (e) , f-1) $, $ (e, 0) $, $ (e, C-1) $, $ (0, f) $, $ (R-1, f) $ can be moved at a cost of $ 1 ...
0.125
{"tests": "{\"inputs\": [\"20\\n594\", \"10\\n26\", \"20\\n704\", \"10\\n27\", \"20\\n41\", \"10\\n15\", \"20\\n2\", \"10\\n29\", \"20\\n0\", \"10\\n52\", \"20\\n1\", \"10\\n86\", \"20\\n-1\", \"10\\n55\", \"20\\n-2\", \"10\\n80\", \"20\\n-4\", \"10\\n45\", \"20\\n-7\", \"10\\n83\", \"20\\n-11\", \"10\\n148\", \"20\\n-...
Problem Find the angle between the two given angles θ1 and θ2. Here, the angle between them is defined as "θ1 & plus; t'when t'is the one with the smallest absolute value among the t satisfying θ1 & plus; t = θ2 − t" as shown in the figure below. A image of angles Constraints The input satisfies the following condi...
0.125
{"tests": "{\"inputs\": [\"4\\n3 0 3\\n4 -3 5\\n42 -33 55\\n69 -42 146\\n\", \"10\\n20000 -431912570 597469643\\n20000 -13928452 414987414\\n20000 -472808872 367983694\\n20000 -84913058 517394906\\n20000 -514402152 597357115\\n20000 -720971736 526102810\\n20000 -416160739 748291750\\n20000 -665939649 743938438\\n20000 ...
Let's call an integer array $a_1, a_2, \dots, a_n$ good if $a_i \neq i$ for each $i$. Let $F(a)$ be the number of pairs $(i, j)$ ($1 \le i < j \le n$) such that $a_i + a_j = i + j$. Let's say that an array $a_1, a_2, \dots, a_n$ is excellent if: $a$ is good; $l \le a_i \le r$ for each $i$; $F(a)$ is the maximum po...
0
{"tests": "{\"inputs\": [\"6 37\\n5\\n9\\n24\\n18\\n26\\n33\", \"4 1\\n1\\n2\\n7\\n9\", \"4 1\\n1\\n1\\n11\\n2\", \"6 37\\n5\\n16\\n13\\n18\\n26\\n33\", \"4 25\\n9\\n15\\n20\\n15\", \"6 37\\n5\\n6\\n24\\n18\\n26\\n33\", \"6 37\\n6\\n16\\n13\\n18\\n26\\n16\", \"6 37\\n5\\n9\\n24\\n9\\n26\\n35\", \"6 37\\n6\\n16\\n13\\n1...
I have a lot of friends. Every friend is very small. I often go out with my friends. Put some friends in your backpack and go out together. Every morning I decide which friends to go out with that day. Put friends one by one in an empty backpack. I'm not very strong. Therefore, there is a limit to the weight of friends...
0
{"tests": "{\"inputs\": [\"10\\n1\\n248618\\n3\\n12 10 8\\n6\\n100 11 15 9 7 8\\n4\\n0 1 1 0\\n2\\n0 0\\n2\\n0 1\\n2\\n1 0\\n2\\n1 1\\n3\\n0 1 0\\n3\\n1 0 1\\n\", \"10\\n1\\n248618\\n3\\n12 10 8\\n6\\n100 11 15 9 2 8\\n4\\n0 1 1 0\\n2\\n0 0\\n2\\n0 1\\n2\\n1 0\\n2\\n1 1\\n3\\n0 1 0\\n3\\n1 0 1\\n\", \"10\\n1\\n451008\\...
You're given an array $a_1, \ldots, a_n$ of $n$ non-negative integers. Let's call it sharpened if and only if there exists an integer $1 \le k \le n$ such that $a_1 < a_2 < \ldots < a_k$ and $a_k > a_{k+1} > \ldots > a_n$. In particular, any strictly increasing or strictly decreasing array is sharpened. For example: ...
0
{"tests": "{\"inputs\": [[null], [3], [\"Dermatoglyphics\"], [\"isogram\"], [\"eleven\"], [\"moOse\"], [\"isIsogram\"], [\"\"], [\"-.-\"], [\"subdermatoglyphic\"], [\"Alphabet\"], [\"thumbscrew-japingly\"], [\"Hjelmqvist-Gryb-Zock-Pfund-Wax\"], [\"Emily Jung Schwartzkopf\"], [\"aabbccddeeffgg\"]], \"outputs\": [[false]...
**An [isogram](https://en.wikipedia.org/wiki/Isogram)** (also known as a "nonpattern word") is a logological term for a word or phrase without a repeating letter. It is also used by some to mean a word or phrase in which each letter appears the same number of times, not necessarily just once. You task is to write a me...
0
{"tests": "{\"inputs\": [\"100\\n((()()))(()()))(())))((()((()()))(()))())((()(())(((())())((()))())))((()(())((())(())())))(()((())(\\n\", \"1\\n(\\n\", \"10\\n())(((()))\\n\", \"499\\n)(()))))(())(((())())()()(())))(()))))(())))()())()(((((()))()(())()()((()()(()())())))()(())()))())(())()(())))))((())()(((()))(())((...
This is a harder version of the problem. In this version, n ≤ 300 000. Vasya is an experienced developer of programming competitions' problems. As all great minds at some time, Vasya faced a creative crisis. To improve the situation, Petya gifted him a string consisting of opening and closing brackets only. Petya beli...
0
{"tests": "{\"inputs\": [\"3\\n3 1\\n1 3 2\\n1 2\\n2 2\\n1 2\\n1 2\\n1 2\\n7 5\\n1 2 5 4 3 6 7\\n1 2\\n6 7\\n3 4\\n1 2\\n2 3\\n\", \"5\\n2 0\\n1 2\\n2 1\\n1 2\\n1 2\\n2 1\\n2 1\\n1 2\\n3 9\\n1 2 3\\n1 2\\n1 3\\n2 3\\n1 2\\n1 3\\n2 3\\n1 2\\n1 3\\n2 3\\n3 0\\n3 2 1\\n\", \"5\\n2 0\\n1 2\\n2 1\\n1 2\\n1 2\\n2 1\\n2 1\\n1...
This is the hard version of the problem. The difference between the versions is that the easy version has no swap operations. You can make hacks only if all versions of the problem are solved. Pikachu is a cute and friendly pokémon living in the wild pikachu herd. But it has become known recently that infamous team R...
0.375
{"tests": "{\"inputs\": [\"5\\n2 1 3 5 4\", \"5\\n2 1 0 5 4\", \"5\\n4 1 0 5 4\", \"5\\n4 1 0 5 6\", \"5\\n4 0 0 5 6\", \"5\\n4 0 0 10 6\", \"5\\n4 0 0 10 12\", \"5\\n4 0 0 10 3\", \"5\\n4 0 0 11 3\", \"5\\n4 0 0 0 3\", \"5\\n4 0 1 0 3\", \"5\\n7 0 1 0 3\", \"5\\n7 0 2 0 3\", \"5\\n7 1 2 0 3\", \"5\\n2 1 0 1 4\", \"5\\...
G --Derangement / Derangement Story Person D is doing research on permutations. At one point, D found a permutation class called "Derangement". "It's cool to have a perfect permutation !!! And it starts with D !!!", the person of D who had a crush on Chunibyo decided to rewrite all the permutations given to him. Pro...
0.875
{"tests": "{\"inputs\": [\"5 3\", \"1 6\", \"13 13\", \"15 1\", \"56 159\", \"5 1\", \"19 13\", \"15 2\", \"43 159\", \"1 1\", \"27 2\", \"61 159\", \"0 2\", \"2 13\", \"16 2\", \"39 159\", \"11 2\", \"89 205\", \"102 205\", \"169 205\", \"3 6\", \"16 6\", \"5 13\", \"613 159\", \"13 15\", \"13 1\", \"5 2\", \"23 13\",...
Find the number, modulo 998244353, of sequences of length N consisting of 0, 1 and 2 such that none of their contiguous subsequences totals to X. Constraints * 1 \leq N \leq 3000 * 1 \leq X \leq 2N * N and X are integers. Input Input is given from Standard Input in the following format: N X Output Print the nu...
0
{"tests": "{\"inputs\": [\"1000 1\\n777 1\\n\", \"126 125\\n115 22\\n\", \"1000 1000\\n1 1\\n\", \"1000 2\\n987 2\\n\", \"1000 1\\n1 1\\n\", \"1 2\\n1 1\\n\", \"663 904\\n192 518\\n\", \"2 1\\n1 1\\n\", \"1000 2\\n1 1\\n\", \"293 183\\n279 21\\n\", \"1000 1\\n1000 1\\n\", \"812 240\\n561 19\\n\", \"552 36\\n199 35\\n\"...
You received as a gift a very clever robot walking on a rectangular board. Unfortunately, you understood that it is broken and behaves rather strangely (randomly). The board consists of N rows and M columns of cells. The robot is initially at some cell on the i-th row and the j-th column. Then at every step the robot c...
0
{"tests": "{\"inputs\": [[1.24], [7.304], [0.04], [1.04], [7.3004], [0.004], [693.230459]], \"outputs\": [[\"1 + 2/10 + 4/100\"], [\"7 + 3/10 + 4/1000\"], [\"4/100\"], [\"1 + 4/100\"], [\"7 + 3/10 + 4/10000\"], [\"4/1000\"], [\"600 + 90 + 3 + 2/10 + 3/100 + 4/10000 + 5/100000 + 9/1000000\"]]}", "source": "primeintellec...
# Write Number in Expanded Form - Part 2 This is version 2 of my ['Write Number in Exanded Form' Kata](https://www.codewars.com/kata/write-number-in-expanded-form). You will be given a number and you will need to return it as a string in [Expanded Form](https://www.mathplacementreview.com/arithmetic/decimals.php#writ...
0
{"tests": "{\"inputs\": [\"19 20 196\\n###.....##.#..#..##.\\n####............##..\\n###....#..#.#....#.#\\n##....###......#...#\\n.####...#.....#.##..\\n.###......#...#.#.#.\\n...##.#...#..#..#...\\n.....#.....#..#....#\\n.#.....##..#........\\n.##....#......#....#\\n....#.......#.......\\n......##..#........#\\n........
Pavel loves grid mazes. A grid maze is an n × m rectangle maze where each cell is either empty, or is a wall. You can go from one cell to another only if both cells are empty and have a common side. Pavel drew a grid maze with all empty cells forming a connected area. That is, you can go from any empty cell to any oth...
0
{"tests": "{\"inputs\": [[0.1], [0.01], [0.001], [0.0001], [1e-05], [1e-06]], \"outputs\": [[[10, 3.0418396189]], [[100, 3.1315929036]], [[1000, 3.1405926538]], [[10000, 3.1414926536]], [[100001, 3.1416026535]], [[1000001, 3.1415936536]]]}", "source": "primeintellect"}
The aim of the kata is to try to show how difficult it can be to calculate decimals of an irrational number with a certain precision. We have chosen to get a few decimals of the number "pi" using the following infinite series (Leibniz 1646–1716): PI / 4 = 1 - 1/3 + 1/5 - 1/7 + ... which gives an approximation of PI /...
0
{"tests": "{\"inputs\": [\"3 3\\n0 0 0\\n0 10000 0\\n0 0 0\\n\", \"3 3\\n1 10 1\\n1 10 1\\n1 10 1\\n\", \"3 3\\n0 0 0\\n0 100 0\\n0 0 0\\n\", \"4 5\\n87882 40786 3691 85313 46694\\n28884 16067 3242 97367 78518\\n4250 35501 9780 14435 19004\\n64673 65438 56977 64495 27280\\n\", \"3 3\\n1 1 1\\n0 10000 0\\n1 1 1\\n\", \"...
Summer is coming! It's time for Iahub and Iahubina to work out, as they both want to look hot at the beach. The gym where they go is a matrix a with n lines and m columns. Let number a[i][j] represents the calories burned by performing workout at the cell of gym in the i-th line and the j-th column. Iahub starts with ...
0
{"tests": "{\"inputs\": [\"a@mc@ks@gu@rl@gq@zq@iz@da@uq@mi@nf@zs@hi@we@ej@ke@vb@az@yz@yl@rr@gh@um@nv@qe@qq@de@dy@op@gt@vx@ak@q\\n\", \"aglvesxsmivijisod@mxcnbfcfgqfwjouidlsueaswf@obehqpvbkmukxkicyoknkbol@kutunggpoxxfpbe@qkhv@llddqqoyjeex@byvtlhbifqmvlukmrvgvpwrscwfhpuwyknwchqhrdqgarmnsdlqgf@lseltghg@bhuwbfjpsvayzk@fvwo...
Email address in Berland is a string of the form A@B, where A and B are arbitrary strings consisting of small Latin letters. Bob is a system administrator in «Bersoft» company. He keeps a list of email addresses of the company's staff. This list is as a large string, where all addresses are written in arbitrary order...
0
{"tests": "{\"inputs\": [\"1\\n3 1\\n1 2 3\\n4 5 6\\n4\", \"1\\n3 1\\n1 4 3\\n4 5 6\\n4\", \"1\\n6 1\\n1 4 3\\n4 5 6\\n1\", \"1\\n6 1\\n0 4 3\\n4 5 6\\n1\", \"1\\n3 1\\n1 2 1\\n4 5 6\\n4\", \"1\\n10 1\\n1 4 4\\n4 2 12\\n1\", \"1\\n10 1\\n1 4 4\\n4 2 12\\n0\", \"1\\n10 1\\n1 4 4\\n4 2 13\\n0\", \"1\\n3 1\\n1 4 3\\n4 10 ...
Read problems statements in Russian here The Head Chef is studying the motivation and satisfaction level of his chefs . The motivation and satisfaction of a Chef can be represented as an integer . The Head Chef wants to know the N th smallest sum of one satisfaction value and one motivation value for various values ...
0.5