info
stringlengths
120
50k
question
stringlengths
504
10.4k
avg@8_qwen3_4b_instruct_2507
float64
0
0.88
{"tests": "{\"inputs\": [[10, 5], [7, 4], [4, 5], [100, 40], [1500, 751], [0, 1]], \"outputs\": [[true], [false], [false], [true], [false], [false]]}", "source": "primeintellect"}
A hero is on his way to the castle to complete his mission. However, he's been told that the castle is surrounded with a couple of powerful dragons! each dragon takes 2 bullets to be defeated, our hero has no idea how many bullets he should carry.. Assuming he's gonna grab a specific given number of bullets and move fo...
0
{"tests": "{\"inputs\": [\"8\\n0 blue 4\\n0 red 1\\n0 white 5\\n1 red\\n1 bmue\\n2 red\\n1 black\\n1 red\", \"8\\n0 blue 4\\n0 red 1\\n0 white 5\\n1 erd\\n1 bmue\\n2 red\\n1 black\\n1 red\", \"8\\n0 blue 4\\n0 der 1\\n0 white 10\\n1 etd\\n1 bmue\\n2 der\\n0 black\\n1 des\", \"8\\n0 blue 4\\n0 red 1\\n0 white 5\\n1 red\...
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$. * get($key$): Print the value with the specified $...
0
{"tests": "{\"inputs\": [\"4\\n2 5 2 8\", \"2\\n4 4\", \"4\\n2 9 3 8\", \"4\\n0 9 3 8\", \"2\\n3 8\", \"2\\n4 1\", \"4\\n2 1 3 1\", \"2\\n24 8\", \"2\\n5 8\", \"2\\n15 11\", \"2\\n7 8\", \"4\\n3 12 6 4\", \"2\\n10 16\", \"4\\n2 5 3 8\", \"2\\n4 7\", \"2\\n4 8\", \"4\\n0 1 3 8\", \"4\\n0 1 2 8\", \"2\\n4 0\", \"4\\n1 1 ...
Niwango-kun has \\(N\\) chickens as his pets. The chickens are identified by numbers \\(1\\) to \\(N\\), and the size of the \\(i\\)-th chicken is a positive integer \\(a_i\\). \\(N\\) chickens decided to take each other's hand (wing) and form some cycles. The way to make cycles is represented by a permutation \\(p\\)...
0
{"tests": "{\"inputs\": [\"8\\n-7 9 6 9\\n-5 5 6 5\\n-10 -5 10 -5\\n-6 9 -9 -1\\n6 9 9 -6\\n-1 -2 -3 10\\n1 -2 3 10\\n-2 -3 2 -3\\n8\\n-7 9 5 7\\n-5 5 6 5\\n-10 -5 10 -5\\n-6 9 -9 -6\\n6 9 9 -6\\n-1 -2 -3 10\\n1 -2 3 10\\n-2 -3 2 -3\\n0\", \"8\\n-7 9 6 9\\n1 5 12 5\\n-10 -5 12 -5\\n-6 9 -9 -1\\n6 9 9 -1\\n-1 -2 -4 10\\...
Once upon a time when people still believed in magic, there was a great wizard Aranyaka Gondlir. After twenty years of hard training in a deep forest, he had finally mastered ultimate magic, and decided to leave the forest for his home. Arriving at his home village, Aranyaka was very surprised at the extraordinary des...
0
{"tests": "{\"inputs\": [\"4\\n2 5 6 8\\n\", \"3\\n1 2 3\\n\", \"5\\n1 2 4 6 20\\n\", \"2\\n6 9\\n\", \"5\\n3 4 7 8 8\\n\", \"5\\n4 9 11 12 16\\n\", \"7\\n4 13 14 19 29 61 92\\n\", \"8\\n1 1 2 4 8 14 15 31\\n\", \"23\\n1 1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 32768 65536 131072 262144 524288 1048576 209...
Arkady owns a non-decreasing array $a_1, a_2, \ldots, a_n$. You are jealous of its beauty and want to destroy this property. You have a so-called XOR-gun that you can use one or more times. In one step you can select two consecutive elements of the array, let's say $x$ and $y$, remove them from the array and insert th...
0
{"tests": "{\"inputs\": [[0], [1], [2], [3], [5]], \"outputs\": [[[]], [[[1]]], [[[1, 0], [0, 1]]], [[[1, 0, 0], [0, 1, 0], [0, 0, 1]]], [[[1, 0, 0, 0, 0], [0, 1, 0, 0, 0], [0, 0, 1, 0, 0], [0, 0, 0, 1, 0], [0, 0, 0, 0, 1]]]]}", "source": "primeintellect"}
Create an identity matrix of the specified size( >= 0). Some examples: ``` (1) => [[1]] (2) => [ [1,0], [0,1] ] [ [1,0,0,0,0], [0,1,0,0,0], (5) => [0,0,1,0,0], [0,0,0,1,0], [0,0,0,0,1] ] ``` Write your solution by modifying this code: ```python def get_matrix(n):...
0
{"tests": "{\"inputs\": [\"20 10 10 \\n30 10 10\", \"5 5 5 \\n15 5 5\", \"25 30 5 \\n25 35 10\", \"5 5 5 \\n10 5 5\", \"5 5 5 \\n20 5 5\", \"20 10 10 \\n60 10 10\", \"20 10 10\\n40 10 10\", \"100 60 52 \\n200 90 45\", \"25 35 5\\n25 45 5\", \"25 30 5\\n20 32 10\"], \"outputs\": [\"Y\", \"T\", \"Y\", \"Y\", \"Y\", \"N\"...
Tom is solving an IQ quiz in which he is stuck in a question which says that there are two circles whose center coordinates and radius are given. Now Tom has to find whether the two circles overlap, do not overlap or are tangential with each other. Help Tom in solving the problem. Input: The input to the problem wil...
0
{"tests": "{\"inputs\": [\"1 2 10\\n01\\n4 1 5 2\\n1 2 1 4\\n3 4 3 5\\n1 3 1 5\\n4 3 5 5\\n1 1 3 3\\n1 3 4 5\\n3 2 3 4\\n3 1 5 2\\n3 1 3 5\\n\", \"1 2 10\\n01\\n4 1 5 1\\n1 2 1 4\\n3 4 3 5\\n1 3 1 5\\n4 3 5 5\\n1 1 3 3\\n1 3 4 5\\n3 2 3 4\\n3 1 5 2\\n3 1 3 5\\n\", \"2 2 5\\n10\\n11\\n1 1 8 8\\n2 4 5 6\\n1 2 7 8\\n3 3 6...
Vus the Cossack has a field with dimensions n × m, which consists of "0" and "1". He is building an infinite field from this field. He is doing this in this way: 1. He takes the current field and finds a new inverted field. In other words, the new field will contain "1" only there, where "0" was in the current field...
0
{"tests": "{\"inputs\": [[7, \"Armenian Dram\"], [322, \"Armenian Dram\"], [25, \"Bangladeshi Taka\"], [730, \"Bangladeshi Taka\"], [37, \"Croatian Kuna\"], [40, \"Croatian Kuna\"], [197, \"Czech Koruna\"], [333, \"Czech Koruna\"], [768, \"Dominican Peso\"], [983, \"Dominican Peso\"]], \"outputs\": [[\"You now have 334...
You are currently in the United States of America. The main currency here is known as the United States Dollar (USD). You are planning to travel to another country for vacation, so you make it today's goal to convert your USD (all bills, no cents) into the appropriate currency. This will help you be more prepared for w...
0
{"tests": "{\"inputs\": [\"100 3\\n45 1 2 3 4 5 6 7 8 9 19 21 24 27 28 30 34 35 37 39 40 41 42 43 46 47 48 51 52 55 58 59 61 63 64 66 69 71 76 80 85 86 88 89 94 99\\n26 10 11 15 18 23 29 31 33 36 38 44 49 54 56 60 62 65 75 78 82 83 84 95 96 97 98\\n29 12 13 14 16 17 20 22 25 26 32 45 50 53 57 67 68 70 72 73 74 77 79 81...
Andrewid the Android is a galaxy-famous detective. He is now investigating the case of vandalism at the exhibition of contemporary art. The main exhibit is a construction of n matryoshka dolls that can be nested one into another. The matryoshka dolls are numbered from 1 to n. A matryoshka with a smaller number can be ...
0
{"tests": "{\"inputs\": [\"3\\n0 0 100 101\\n60 100 50\\n100 100 10\\n80 80 50\\n4\\n0 0 100 100\\n50 50 50\\n150 50 50\\n50 150 50\\n150 150 50\\n0\", \"3\\n0 0 100 101\\n60 100 50\\n100 110 10\\n25 80 50\\n4\\n0 0 100 100\\n50 50 50\\n150 50 50\\n50 150 50\\n150 150 50\\n0\", \"3\\n0 0 100 101\\n60 100 50\\n100 110 1...
Maki is a house cat. One day she fortunately came at a wonderful-looking dried fish. Since she felt not hungry on that day, she put it up in her bed. However there was a problem; a rat was living in her house, and he was watching for a chance to steal her food. To secure the fish during the time she is asleep, she deci...
0
{"tests": "{\"inputs\": [[[5, 8, 12, 18, 22]], [[7, 15, 12, 18, 22]], [[25, 42, 12, 18, 22]], [[1, 8, 12, 18, 5]], [[13, 12, 5, 61, 22]]], \"outputs\": [[13], [19], [30], [6], [17]]}", "source": "primeintellect"}
Create a function that returns the sum of the two lowest positive numbers given an array of minimum 4 positive integers. No floats or non-positive integers will be passed. For example, when an array is passed like `[19, 5, 42, 2, 77]`, the output should be `7`. `[10, 343445353, 3453445, 3453545353453]` should return ...
0
{"tests": "{\"inputs\": [[\"1\", 1], [\"1\", 3], [\"1\", 5], [\"22\", 10], [\"14\", 2]], \"outputs\": [[\"1\"], [\"21\"], [\"111221\"], [\"22\"], [\"1114\"]]}", "source": "primeintellect"}
The look and say sequence is a sequence in which each number is the result of a "look and say" operation on the previous element. Considering for example the classical version startin with `"1"`: `["1", "11", "21, "1211", "111221", ...]`. You can see that the second element describes the first as `"1(times number)1"`,...
0
{"tests": "{\"inputs\": [[1, 1], [5, 1], [3, 4], [5, 6], [10, 10], [100, 3], [123, 456]], \"outputs\": [[2], [6], [35], [462], [184756], [176851], [448843261729071620474858205566477025894357385375655014634306680560209909590802545266425906052279365647506075241055256064119806400]]}", "source": "primeintellect"}
You have a grid with `$m$` rows and `$n$` columns. Return the number of unique ways that start from the top-left corner and go to the bottom-right corner. You are only allowed to move right and down. For example, in the below grid of `$2$` rows and `$3$` columns, there are `$10$` unique paths: ``` o----o----o----o | ...
0
{"tests": "{\"inputs\": [\"44 20\\nbcdefghijklmnopqrstabcdefghijklmnopqrstatata\\n\", \"44 20\\ncdefghijklmnopqrstabcdefghijklmnopqrstabtata\\n\", \"44 20\\natatbatsrqponmlkjihgfedcbatsrqponmlkjihgfedc\\n\", \"4 4\\naaaaaa\\n\", \"44 20\\natatbatsrqponmlkjihgfedcbetsrqponmlkjihgfadc\\n\", \"4 4\\nabaaaa\\n\", \"44 20\\...
You have a password which you often type — a string s of length n. Every character of this string is one of the first m lowercase Latin letters. Since you spend a lot of time typing it, you want to buy a new keyboard. A keyboard is a permutation of the first m Latin letters. For example, if m = 3, then there are six ...
0
{"tests": "{\"inputs\": [\"1\\n1 1 1 1\", \"2\\n2 4 25 104\\n1 9 7 321\", \"2\\n2 4 25 28\\n1 9 13 321\", \"2\\n2 4 4 51\\n1 4 13 252\", \"2\\n3 4 4 51\\n2 4 13 335\", \"2\\n3 4 4 51\\n2 4 13 360\", \"2\\n2 4 24 306\\n1 9 7 321\", \"8\\n2 9 297 297\\n8 6 359 211\\n8 16 28 233\\n7 9 113 143\\n3 18 315 190\\n10 18 277 30...
Problem Neat lives on the world line for a total of 360 days until the 30th of every month for 1 year and 12 months. In that world, N consecutive holidays with the same schedule were applied to people all over the world every year. Consecutive holidays i are consecutive Vi days starting from Mi month Di day. NEET is ...
0
{"tests": "{\"inputs\": [\"7\\nshf\\nsells\\nsea\\nshells\\nby\\nthe\\nseashore\", \"7\\nshf\\nsells\\nsea\\nshells\\nby\\nteh\\nseashore\", \"7\\nshf\\nsells\\nsea\\nshells\\nby\\nthd\\nseashore\", \"7\\nshf\\nsells\\nsea\\nshells\\nbx\\nthd\\nseashore\", \"7\\nshf\\nsells\\naes\\nshells\\nbx\\nthd\\nseashore\", \"7\\...
Problem Here is a list of strings. Let's take a break and play with shiritori. Shiritori is performed according to the following rules. 1. First of all, select one of your favorite strings from the list and exclude that string from the list. 2. Next, select one character string from the list in which the last charact...
0.125
{"tests": "{\"inputs\": [\"87654\\n30\\n\", \"87654\\n138\\n\", \"87654\\n45678\\n\", \"31415926535\\n1\\n\", \"1\\n31415926535\\n\", \"100000000000\\n1\\n\", \"100000000000\\n100000000000\\n\", \"100000000000\\n2\\n\", \"100000000000\\n3\\n\", \"100000000000\\n50000000000\\n\", \"100000000000\\n50000000001\\n\", \"100...
For integers b (b \geq 2) and n (n \geq 1), let the function f(b,n) be defined as follows: - f(b,n) = n, when n < b - f(b,n) = f(b,\,{\rm floor}(n / b)) + (n \ {\rm mod} \ b), when n \geq b Here, {\rm floor}(n / b) denotes the largest integer not exceeding n / b, and n \ {\rm mod} \ b denotes the remainder of n divid...
0.125
{"tests": "{\"inputs\": [\"6\\n8\\n1,2,2,2\\n1,3,4,3\\n1,4,4,2\\n2,5,3,2\\n3,4,4,2\\n3,6,1,2\\n4,6,1,1\\n5,6,2,2\\n2,4,50,30\", \"6\\n8\\n1,2,2,2\\n1,3,4,3\\n1,4,4,2\\n2,5,3,2\\n3,4,4,2\\n3,6,1,2\\n4,6,1,1\\n2,1,6,5\\n2,4,50,30\", \"6\\n8\\n1,2,2,2\\n0,3,4,3\\n2,4,4,1\\n2,5,3,2\\n3,4,2,4\\n3,6,1,2\\n4,6,1,1\\n5,6,2,2\\...
One day, the lord ordered a carpenter to "build a sturdy and large building where the townspeople could evacuate in the event of a typhoon or earthquake." However, large thick pillars are needed to complete the sturdy and large building. There is no such big pillar in the town. So the carpenter decided to go to a dista...
0
{"tests": "{\"inputs\": [\"1 1\\n1543\\n\", \"2 1\\n179\\n1329\\n\", \"2 2\\n1 2\\n3 1\\n\", \"2 1\\n179\\n179\\n\", \"1 2\\n57 57\\n\", \"4 3\\n1 2 3\\n10 11 4\\n9 12 5\\n8 7 6\\n\", \"1 4\\n1 5 4 3\\n\", \"3 1\\n1\\n7\\n9\\n\", \"5 5\\n1 2 10 1 1\\n2 1 20 2 1\\n11 13 14 15 16\\n2 5 10 3 7\\n1 1 1 1 1\\n\", \"1 2\\n66...
Dora loves adventures quite a lot. During some journey she encountered an amazing city, which is formed by n streets along the Eastern direction and m streets across the Southern direction. Naturally, this city has nm intersections. At any intersection of i-th Eastern street and j-th Southern street there is a monument...
0
{"tests": "{\"inputs\": [[1], [1000], [100.2346], [1000000000.23], [9123.212], [-1], [-1000000.123], [-2000.0], [-999.9999], [-1234567.0001236]], \"outputs\": [[\"1\"], [\"1,000\"], [\"100.235\"], [\"1,000,000,000.23\"], [\"9,123.212\"], [\"-1\"], [\"-1,000,000.123\"], [\"-2,000\"], [\"-1,000\"], [\"-1,234,567\"]]}", "...
Your task is to convert a given number into a string with commas added for easier readability. The number should be rounded to 3 decimal places and the commas should be added at intervals of three digits before the decimal point. There does not need to be a comma at the end of the number. You will receive both positi...
0
{"tests": "{\"inputs\": [\"HEISEI 1 1 8\\nHEISEI 31 4 30\\nIESIEH 31 5 1\\nHEISEI 99 12 31\\nHEISEI 38 8 30\\nHEISEI 98 2 22\\nHEISEI 2 3 26\\nHEISEI 28 4 23\\n#\", \"HEISEI 1 1 8\\nHEISEI 31 4 30\\nIESIEH 31 5 1\\nHEISEI 99 12 31\\nHEISEI 38 8 30\\nHEISEI 98 2 22\\nHEISEI 3 3 26\\nHEISEI 28 4 23\\n#\", \"HEISEI 1 1 8\...
Revised The current era, Heisei, will end on April 30, 2019, and a new era will begin the next day. The day after the last day of Heisei will be May 1, the first year of the new era. In the system developed by the ACM-ICPC OB / OG Association (Japanese Alumni Group; JAG), the date uses the Japanese calendar (the Japa...
0.25
{"tests": "{\"inputs\": [\"6\\n\", \"89\\n\", \"15\\n\", \"91\\n\", \"76\\n\", \"80\\n\", \"96\\n\", \"72\\n\", \"79\\n\", \"5\\n\", \"74\\n\", \"97\\n\", \"47\\n\", \"50\\n\", \"3\\n\", \"7\\n\", \"94\\n\", \"20\\n\", \"75\\n\", \"66\\n\", \"46\\n\", \"14\\n\", \"71\\n\", \"22\\n\", \"81\\n\", \"56\\n\", \"12\\n\", \"...
Consider some square matrix A with side n consisting of zeros and ones. There are n rows numbered from 1 to n from top to bottom and n columns numbered from 1 to n from left to right in this matrix. We'll denote the element of the matrix which is located at the intersection of the i-row and the j-th column as Ai, j. L...
0
{"tests": "{\"inputs\": [\"3\\n6\\n101101\\n10\\n1001101101\\n4\\n1100\\n\", \"3\\n6\\n101101\\n10\\n1001101101\\n4\\n1100\\n\", \"3\\n6\\n100101\\n10\\n1001101101\\n4\\n1100\\n\", \"3\\n6\\n101101\\n10\\n1001001101\\n4\\n1100\\n\", \"3\\n6\\n101101\\n10\\n1001101101\\n4\\n0100\\n\", \"3\\n6\\n101101\\n10\\n1001000101\...
A sequence of brackets is called balanced if one can turn it into a valid math expression by adding characters '+' and '1'. For example, sequences '(())()', '()', and '(()(()))' are balanced, while ')(', '(()', and '(()))(' are not. You are given a binary string $s$ of length $n$. Construct two balanced bracket sequen...
0
{"tests": "{\"inputs\": [\"4 4 2 1 4\\n1 2 2 1\\n2 3 2 1\\n3 4 5 1\\n2 4 4 2\\n3 1\\n3 6\\n10 5 3\\n\\n10\\n2 0 1 1 2\\n1\\n\\n1\\n4 5 2 4 1\\n4 3 10 1\\n3 2 2 1\\n3 4 1 2\\n3 2 5 2\\n2 1 10 1\\n3 3\\n20 30\\n3 2 1\\n5 10\\n3 2 1\\n5 5 2 1 5\\n1 2 10 2\\n1 3 20 2\\n2 4 20 1\\n3 4 10 1\\n4 5 20 1\\n2 2\\n20\\n4 1\\n20\\...
Tokyo has a very complex railway system. For example, there exists a partial map of lines and stations as shown in Figure D-1. <image> Figure D-1: A sample railway network Suppose you are going to station D from station A. Obviously, the path with the shortest distance is A->B->D. However, the path with the shortes...
0
{"tests": "{\"inputs\": [[\"\"], [\"..........\"], [\"P..\"], [\"P....\"], [\"P......P......\"], [\"P.P..\"], [\"P.P.P....\"], [\".....P.P........P....\"], [\".....P......P.P..P....\"], [\"P.O....\"], [\"P......P.O....\"], [\"P..OP..P..\"], [\"P......P..OP..P...\"], [\"..P...O.....\"]], \"outputs\": [[\"\"], [\"0000000...
# Situation You have been hired by a company making electric garage doors. Accidents with the present product line have resulted in numerous damaged cars, broken limbs and several killed pets. Your mission is to write a safer version of their controller software. # Specification We always start with a closed door. The...
0
{"tests": "{\"inputs\": [\"50 12346\\n376 144139\\n927438 667387\\n18 3312\\n9 3142\\n25 1299\\n111 33333\\n103 862150\\n6 1104\\n0 0\", \"50 12346\\n712 144139\\n927438 667387\\n23 3312\\n9 3142\\n25 1299\\n111 33333\\n103 862150\\n6 1104\\n0 0\", \"81 12346\\n376 144139\\n927438 927438\\n18 3312\\n9 3142\\n25 1299\\n...
You have just been put in charge of developing a new shredder for the Shredding Company. Although a ``normal'' shredder would just shred sheets of paper into little pieces so that the contents would become unreadable, this new shredder needs to have the following unusual basic characteristics. * The shredder takes as ...
0.5
{"tests": "{\"inputs\": [\"5 0\\n5 5 4 1 2\\n\", \"10 -10\\n5 5 1 7 4 1 2 4 9 2\\n\", \"10 0\\n5 5 1 7 4 1 2 4 9 2\\n\", \"10 -10\\n5 5 1 0 5 1 2 4 9 2\\n\", \"5 0\\n5 5 4 0 2\\n\", \"10 -10\\n5 5 1 7 4 1 0 4 9 2\\n\", \"10 -12\\n5 5 1 0 5 1 2 4 9 2\\n\", \"10 -10\\n5 5 1 0 4 1 0 4 9 2\\n\", \"10 0\\n5 9 1 12 0 2 2 4 1...
During the last Sereja's Codesecrof round the server crashed many times, so the round was decided to be made unrated for some participants. Let's assume that n people took part in the contest. Let's assume that the participant who got the first place has rating a1, the second place participant has rating a2, ..., the...
0
{"tests": "{\"inputs\": [[\"HELLO WORLD\"], [\"SOS\"], [\"1836\"], [\"THE QUICK BROWN FOX\"], [\"JUMPED OVER THE\"], [\"LAZY DOG\"], [\"WOLFRAM ALPHA 1\"], [\"CodeWars Rocks\"], [\"\"], [\"Final basic test\"]], \"outputs\": [[\".... . .-.. .-.. --- .-- --- .-. .-.. -..\"], [\"... --- ...\"], [\".---- ---.. ...-- -......
Write a function that will encrypt a given sentence into International Morse Code, both the input and out puts will be strings. Characters should be separated by a single space. Words should be separated by a triple space. For example, "HELLO WORLD" should return -> ".... . .-.. .-.. --- .-- --- .-. .-.. -.." To f...
0
{"tests": "{\"inputs\": [\"111199\\n\", \"1000\\n\", \"10000\\n\", \"11\\n\", \"244\\n\", \"1000000000\\n\", \"14\\n\", \"55\\n\", \"2000\\n\", \"116\\n\", \"20\\n\", \"6\\n\", \"600000000\\n\", \"198\\n\", \"12\\n\", \"999999999\\n\", \"100\\n\", \"83\\n\", \"13\\n\", \"8\\n\", \"150\\n\", \"4\\n\", \"35\\n\", \"70900...
Let's introduce a number system which is based on a roman digits. There are digits I, V, X, L which correspond to the numbers 1, 5, 10 and 50 respectively. The use of other roman digits is not allowed. Numbers in this system are written as a sequence of one or more digits. We define the value of the sequence simply as...
0
{"tests": "{\"inputs\": [[\"Hi, how are you today?\"], [\"I think it would be nice if we could all get along.\"], [\"Let's eat, Grandma!\"], [\"Woot woot woot woot woot woot!\"], [\"Hi, I can have cheeseburger?\"], [\"Sometimes I use ? in the middle of a sentence; is that ok?!\"], [\"Unto us a child is born.\"], [\"Wha...
The internet is a very confounding place for some adults. Tom has just joined an online forum and is trying to fit in with all the teens and tweens. It seems like they're speaking in another language! Help Tom fit in by translating his well-formatted English into n00b language. The following rules should be observed: ...
0
{"tests": "{\"inputs\": [\"2 2 1 2\\n1 2\\n2 1\\n\", \"2 1 1 1\\n1 2\\n3\\n\", \"10 4 2 4\\n3 2 3 3 3 1 3 3 2 3\\n2 2 2 3\\n\", \"10 3 3 2\\n2 2 3 2 1 3 1 3 2 3\\n2 3\\n\", \"4 2 1 2\\n1 1 2 2\\n2 2\\n\", \"1 1 1 1\\n500000\\n500000\\n\", \"10 3 3 2\\n2 1 1 2 1 1 2 1 1 2\\n2 2\\n\", \"10 5 2 2\\n2 2 2 2 2 1 1 1 1 1\\n3...
At the first holiday in spring, the town Shortriver traditionally conducts a flower festival. Townsfolk wear traditional wreaths during these festivals. Each wreath contains exactly k flowers. The work material for the wreaths for all n citizens of Shortriver is cut from the longest flowered liana that grew in the tow...
0
{"tests": "{\"inputs\": [\"90\\n35\\n1 68 16 30 24 1 1 1 35 1 1 67 1 1 1 1 33 16 37 77 83 1 77 26 1 1 68 67 70 62 1 47 1 1 1 84 1 65 1 32 83 1 1 1 28 1 71 76 84 1 1 5 1 74 10 1 1 1 38 87 13 1 7 66 81 49 1 9 1 11 1 25 1 1 1 1 7 1 1 36 61 47 51 1 1 69 40 1 37 1\\n40 1 21 1 19 51 37 52 64 1 86 1 5 24 1 1 1 19 36 1 1 77 24...
Natasha is going to fly on a rocket to Mars and return to Earth. Also, on the way to Mars, she will land on n - 2 intermediate planets. Formally: we number all the planets from 1 to n. 1 is Earth, n is Mars. Natasha will make exactly n flights: 1 → 2 → … n → 1. Flight from x to y consists of two phases: take-off from ...
0.5
{"tests": "{\"inputs\": [[0], [1], [4], [56], [128], [500], [562], [74864], [3991700], [950811894]], \"outputs\": [[0], [1], [2], [7], [11], [22], [23], [273], [1997], [30835]]}", "source": "primeintellect"}
A high school has a strange principal. On the first day, he has his students perform an odd opening day ceremony: There are number of lockers "n" and number of students "n" in the school. The principal asks the first student to go to every locker and open it. Then he has the second student go to every second locker an...
0
{"tests": "{\"inputs\": [\"35 2 5 6 3\\n6 8 3 4 2 1 1 10 8 1 2 4 4 2 10 1 1 6 3 8 10 6 3 8 10 8 9 7 9 10 3 9 4 6 7\\n\", \"36 6 6 9 6\\n3 5 8 7 6 8 1 5 10 10 8 5 10 9 8 1 9 7 2 1 8 8 6 1 6 7 4 3 10 2 5 8 4 1 1 4\\n\", \"17 2 7 10 6\\n10 5 9 2 7 5 6 10 9 7 10 3 10 2 9 10 1\\n\", \"77 2 8 8 3\\n7 9 3 6 2 7 8 4 4 1 8 6 1 ...
Ziota found a video game called "Monster Invaders". Similar to every other shooting RPG game, "Monster Invaders" involves killing monsters and bosses with guns. For the sake of simplicity, we only consider two different types of monsters and three different types of guns. Namely, the two types of monsters are: *...
0
{"tests": "{\"inputs\": [\"4 6\\n7\\n2\\n3\\n5\", \"4 6\\n4\\n1\\n3\\n5\", \"1 6\\n4\\n2\\n3\\n1\", \"4 10\\n7\\n1\\n3\\n5\", \"4 11\\n5\\n2\\n3\\n5\", \"4 5\\n4\\n2\\n3\\n1\", \"1 6\\n3\\n2\\n3\\n1\", \"1 6\\n2\\n2\\n3\\n1\", \"4 9\\n7\\n2\\n3\\n5\", \"1 6\\n1\\n0\\n1\\n1\", \"4 11\\n5\\n2\\n1\\n5\", \"1 5\\n4\\n2\\n1...
problem There are fine icicles under the eaves of JOI's house in Canada. Because of this, JOI decided to investigate the icicles. There are N (2 ≤ N ≤ 100000 = 105) icicles under the eaves of JOI's house. These icicles are aligned and i cm (1 ≤ i ≤ N) from the left edge of the eaves. There are i-th icicles at the pos...
0
{"tests": "{\"inputs\": [[\"Welcome home\", \"secret\"], [\"hello\", \"wednesday\"], [\"HELLO\", \"wednesday\"], [\"HeLlO\", \"wednesday\"], [\"WELCOME HOME\", \"gridlocked\"], [\"alpha bravo charlie\", \"delta\"], [\"Home Base\", \"seven\"], [\"basecamp\", \"covert\"], [\"one two three\", \"rails\"], [\"Test\", \"unbu...
Third day at your new cryptoanalyst job and you come across your toughest assignment yet. Your job is to implement a simple keyword cipher. A keyword cipher is a type of monoalphabetic substitution where two parameters are provided as such (string, keyword). The string is encrypted by taking the keyword, dropping any l...
0
{"tests": "{\"inputs\": [\"0 1 1 2 3 100\\n50\", \"1 1 1 2 3 110\\n50\", \"3 1 1 2 3 100\\n49\\n50\\n74\", \"2 1 1 2 3 100\\n49\\n72\\n74\", \"2 1 1 2 4 100\\n49\\n72\\n40\", \"1 1 1 3 3 110\\n50\", \"3 1 1 2 3 110\\n49\\n50\\n51\", \"0 1 1 2 3 000\\n50\", \"0 1 1 2 3 101\\n97\", \"1 1 1 1 3 110\\n50\", \"1 1 1 3 3 111...
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 develop physical strength and judgment by running on a straight road. The rabbit is now standing at the starting line and looking out over a long, long road. There...
0
{"tests": "{\"inputs\": [\"3 2 1\\n0 1 2\\n1 2 3\\n1\\n4 5 2\\n0 1 1\\n0 2 1\\n1 2 1\\n1 3 1\\n2 3 1\\n1\\n2\\n0 0 1\", \"3 2 1\\n0 1 2\\n1 2 3\\n1\\n4 5 2\\n0 1 2\\n0 2 1\\n1 2 1\\n1 3 1\\n2 3 1\\n1\\n2\\n0 0 1\", \"3 2 1\\n0 1 2\\n1 2 3\\n1\\n4 5 2\\n0 1 2\\n0 3 1\\n1 2 1\\n1 3 1\\n2 3 1\\n1\\n2\\n0 0 1\", \"3 2 1\\n...
The best night ever in the world has come! It's 8 p.m. of December 24th, yes, the night of Cristmas Eve. Santa Clause comes to a silent city with ringing bells. Overtaking north wind, from a sleigh a reindeer pulls she shoot presents to soxes hanged near windows for children. The sleigh she is on departs from a big ch...
0
{"tests": "{\"inputs\": [\"2\\n3 1\", \"4\\n1 2 3 3\", \"2\\n4 1\", \"4\\n1 2 5 3\", \"2\\n3 0\", \"4\\n1 2 8 3\", \"4\\n1 0 12 4\", \"4\\n1 0 12 6\", \"4\\n1 0 1 6\", \"4\\n1 0 1 7\", \"4\\n1 0 11 4\", \"4\\n1 -1 12 11\", \"4\\n2 0 -1 25\", \"4\\n1 -2 12 11\", \"4\\n0 -1 0 36\", \"2\\n25 2\", \"4\\n-1 -1 0 36\", \"2\\...
Read problems statements in Mandarin Chinese, Russian and Vietnamese as well. Phantasialand boasts of its famous theme park. The park is frequently visited. It is quite large park that some tourists visit it more than once to fully appreciate its offerings. One day, our Chefs decided to visit the park. There are tota...
0.125
{"tests": "{\"inputs\": [\"5 5\\n1 3\\n2 3\\n1 4\\n2 2\\n1 2\\n\", \"200000 0\\n\", \"176527 15\\n1 81279\\n2 22308\\n2 133061\\n1 80744\\n2 44603\\n1 170938\\n2 139754\\n2 15220\\n1 172794\\n1 159290\\n2 156968\\n1 56426\\n2 77429\\n1 97459\\n2 71282\\n\", \"2463 0\", \"176527 15\\n1 81279\\n2 22308\\n2 168987\\n1 807...
There is a grid with N rows and N columns of squares. Let (i, j) be the square at the i-th row from the top and the j-th column from the left. Each of the central (N-2) \times (N-2) squares in the grid has a black stone on it. Each of the 2N - 1 squares on the bottom side and the right side has a white stone on it. Q q...
0
{"tests": "{\"inputs\": [[0.1], [0.15], [0.5], [0.75], [0.9]], \"outputs\": [[132], [160], [538], [3088], [21780]]}", "source": "primeintellect"}
Working from left-to-right if no digit is exceeded by the digit to its left it is called an increasing number; for example, 134468. Similarly if no digit is exceeded by the digit to its right it is called a decreasing number; for example, 66420. We shall call a positive integer that is neither increasing nor decreasi...
0
{"tests": "{\"inputs\": [\"3\\n100000\\n30000\\n29639\", \"2\\n0\\n2\", \"2\\n1\\n0\", \"3\\n000000\\n30000\\n29639\", \"2\\n1\\n1\", \"3\\n000001\\n30000\\n29639\", \"2\\n2\\n1\", \"3\\n000011\\n30000\\n29639\", \"3\\n000010\\n30000\\n29639\", \"2\\n2\\n2\", \"3\\n100010\\n30000\\n29639\", \"2\\n2\\n3\", \"3\\n100010\...
There is an apple tree that bears apples of N colors. The N colors of these apples are numbered 1 to N, and there are a_i apples of Color i. You and Lunlun the dachshund alternately perform the following operation (starting from you): * Choose one or more apples from the tree and eat them. Here, the apples chosen at ...
0
{"tests": "{\"inputs\": [[\"123,.)(!?\", 10], [\"\", 10], [null, 10], [\" \", 10], [\"Hello world!\", 127], [\"eBIIL TLOIA!\", -127], [\"ksdjai8983hdk?}{\", 15], [\"Hello world!\", 0]], \"outputs\": [[\"123,.)(!?\"], [\"\"], [\"\"], [\"\"], [\"eBIIL TLOIA!\"], [\"Hello world!\"], [\"zHsypx8983wsz?}{\"], [\"Hello worl...
Let’s get to know our hero: Agent #134 - Mr. Slayer. He was sent by his CSV agency to Ancient Rome in order to resolve some important national issues. However, something incredible has happened - the enemies have taken Julius Caesar as a prisoner!!! Caesar, not a simple man as you know, managed to send cryptic messag...
0
{"tests": "{\"inputs\": [\"5\\n5 4 3 2 1\\n5\\n7 7 7 7 7\\n10\\n186 8 42 24 154 40 10 56 122 141\\n0\", \"5\\n5 4 3 2 1\\n5\\n7 12 2 0 7\\n10\\n372 8 42 18 154 40 10 56 122 141\\n0\", \"5\\n5 4 3 4 1\\n5\\n7 11 7 7 14\\n0\\n186 8 42 24 154 21 10 56 122 72\\n0\", \"5\\n5 4 3 4 1\\n5\\n13 11 1 7 14\\n0\\n186 8 64 24 241 ...
A linear congruential generator produces a series R(⋅) of pseudo-random numbers by the following for- mulas: <image> where S, A, C, and M are all parameters. In this problem, 0 ≤ S, A, C ≤ 15 and M = 256. Now suppose we have some input string I(⋅), where each character in the string is an integer between 0 and (M - ...
0
{"tests": "{\"inputs\": [\"1\\n5 1 3\\n\", \"1\\n6 3 4\\n\", \"25\\n5 1 1\\n5 2 3\\n5 5 5\\n5 5 1\\n5 4 4\\n10 1 2\\n10 3 7\\n10 10 10\\n10 3 1\\n10 7 6\\n1000000 21232 1234\\n999999 999999 999999\\n1000000 300001 701321\\n1000000 290001 679121\\n500000 98765 123456\\n100 1 1\\n1000000000 1 1000000000\\n1000000000 1 50...
Nikolay has only recently started in competitive programming, but already qualified to the finals of one prestigious olympiad. There going to be $n$ participants, one of whom is Nikolay. Like any good olympiad, it consists of two rounds. Tired of the traditional rules, in which the participant who solved the largest nu...
0.125
{"tests": "{\"inputs\": [\"4 1\", \"110 50\", \"4 0\", \"010 50\", \"110 89\", \"110 12\", \"010 4\", \"010 1\", \"3 2\", \"3 1\", \"010 6\", \"010 2\", \"010 3\", \"011 1\", \"011 2\", \"15 1\", \"14 1\", \"7 1\", \"22 2\", \"22 4\", \"011 6\", \"100 10\", \"100 9\", \"011 10\", \"6 4\", \"010 7\", \"12 4\", \"011 7\"...
Problem C: Earn Big A group of N people is trying to challenge the following game to earn big money. First, N participants are isolated from each other. From this point, they are not allowed to contact each other, or to leave any information for other participants. The game organizer leads each participant, one by on...
0.375
{"tests": "{\"inputs\": [\"13 17\\nBBABBBAABABBA\\n7 1\\n7 9\\n11 12\\n3 9\\n11 9\\n2 1\\n11 5\\n12 11\\n10 8\\n1 11\\n1 8\\n7 7\\n9 10\\n8 8\\n8 12\\n6 2\\n9 11\", \"13 17\\nBBABBBAABABBA\\n7 1\\n7 9\\n11 12\\n3 9\\n11 9\\n2 1\\n11 5\\n10 11\\n10 8\\n1 11\\n1 8\\n7 7\\n9 10\\n8 8\\n8 12\\n6 2\\n9 11\", \"4 3\\nABAB\\n...
You are given an undirected graph consisting of N vertices and M edges. The vertices are numbered 1 to N, and the edges are numbered 1 to M. In addition, each vertex has a label, `A` or `B`. The label of Vertex i is s_i. Edge i bidirectionally connects vertex a_i and b_i. The phantom thief Nusook likes to choose some ...
0
{"tests": "{\"inputs\": [\"6\\n1 4\\n9 9\\n5 7\\n12 29\\n137 591\\n1 1000000\\n\", \"20\\n862 928\\n758 964\\n541 789\\n622 943\\n328 900\\n14 764\\n217 972\\n461 847\\n442 468\\n900 986\\n518 529\\n938 993\\n549 851\\n690 944\\n484 601\\n320 910\\n98 868\\n816 915\\n765 880\\n551 770\\n\", \"20\\n862 928\\n758 964\\n5...
You're given Q queries of the form (L, R). For each query you have to find the number of such x that L ≤ x ≤ R and there exist integer numbers a > 0, p > 1 such that x = a^{p}. -----Input----- The first line contains the number of queries Q (1 ≤ Q ≤ 10^5). The next Q lines contains two integers L, R each (1 ≤ L ≤...
0
{"tests": "{\"inputs\": [\"8\\n1\\n1\\n1\\n1\\n0\\n0\\n0\\n0\\n8\\n1\\n0\\n1\\n1\\n0\\n0\\n0\\n1\\n0\", \"8\\n1\\n1\\n1\\n1\\n0\\n0\\n0\\n0\\n8\\n1\\n0\\n0\\n1\\n0\\n0\\n0\\n1\\n0\", \"8\\n1\\n0\\n1\\n1\\n0\\n0\\n0\\n0\\n4\\n1\\n0\\n1\\n1\\n0\\n0\\n0\\n1\\n0\", \"8\\n1\\n0\\n1\\n1\\n0\\n0\\n0\\n0\\n2\\n1\\n0\\n1\\n1\\n...
problem Play by arranging white and black stones on the table. First, place the stones on the left edge of the table. Then place the stones in the second place from the left. Repeat this n times to arrange n stones in a horizontal row. However, when placing a new i-th go stone, replace the go stone on the table accord...
0
{"tests": "{\"inputs\": [\"4\\n0 2\\n0 0\\n-2 0\\n1 0\", \"4\\n0 1\\n1 -1\\n0 -1\\n1 1\", \"3\\n-2 -1\\n0 0\\n1 1\", \"4\\n0 1\\n1 -1\\n-1 -1\\n1 1\", \"3\\n-2 -1\\n0 0\\n1 0\", \"4\\n0 1\\n1 -1\\n-1 0\\n1 1\", \"3\\n-1 -1\\n0 0\\n1 0\", \"3\\n-1 -1\\n0 -1\\n1 0\", \"3\\n-2 -1\\n0 -1\\n1 0\", \"3\\n-2 -1\\n0 -1\\n0 0\"...
Open Binary and Object Group organizes a programming contest every year. Mr. Hex belongs to this group and joins the judge team of the contest. This year, he created a geometric problem with its solution for the contest. The problem required a set of points forming a line-symmetric polygon for the input. Preparing the ...
0.625
{"tests": "{\"inputs\": [\"5\\n12\\n5 4 4 3 2 2 1 1 1 1 1 1\\n4\\n4 3 2 1\\n1\\n1000000\\n20\\n20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1\\n32\\n64 64 63 58 58 58 58 58 37 37 37 37 34 34 28 28 28 28 28 28 24 24 19 17 17 17 17 16 16 16 16 11\\n\", \"5\\n12\\n5 4 4 3 2 2 1 1 1 1 1 1\\n4\\n4 3 2 1\\n1\\n1000000\\n...
So the Beautiful Regional Contest (BeRC) has come to an end! $n$ students took part in the contest. The final standings are already known: the participant in the $i$-th place solved $p_i$ problems. Since the participants are primarily sorted by the number of solved problems, then $p_1 \ge p_2 \ge \dots \ge p_n$. Help ...
0
{"tests": "{\"inputs\": [\"5\\n8 6 9 1 0\", \"5\\n0 6 9 1 0\", \"5\\n1 1 1 1 0\", \"5\\n0 1 1 2 4\", \"5\\n0 6 6 1 0\", \"5\\n0 5 6 1 0\", \"5\\n0 5 6 2 0\", \"5\\n0 5 6 3 0\", \"5\\n0 4 6 3 0\", \"5\\n-1 4 6 3 0\", \"5\\n-1 4 9 3 0\", \"5\\n-1 4 0 3 0\", \"5\\n-1 4 -1 3 0\", \"5\\n0 4 -1 3 0\", \"5\\n0 4 0 3 0\", \"5\...
Auction square1001 You were watching a certain auction. An auction is a transaction in which when there are a large number of buyers and the number of items is limited, the one with the highest price is given the right to buy. (From the 7th edition of the Shinmei Kokugo Dictionary) The rules of the auction here are ...
0.25
{"tests": "{\"inputs\": [\"RL\", \"RLLRRLLLRRRLLLLRR\", \"QL\", \"RLLRRLLMRRRLLLLRR\", \"LQ\", \"KR\", \"KQ\", \"QK\", \"RK\", \"SK\", \"KS\", \"RJ\", \"QJ\", \"QI\", \"PI\", \"PJ\", \"JP\", \"JQ\", \"JO\", \"OJ\", \"OK\", \"KO\", \"PK\", \"KP\", \"IQ\", \"JR\", \"IR\", \"RI\", \"RH\", \"HR\", \"NJ\", \"JN\", \"JS\", \...
You are playing a game called Guru Guru Gururin. In this game, you can move with the vehicle called Gururin. There are two commands you can give to Gururin: 'R' and 'L'. When 'R' is sent, Gururin rotates clockwise by 90 degrees. Otherwise, when 'L' is sent, Gururin rotates counterclockwise by 90 degrees. During the ga...
0.625
{"tests": "{\"inputs\": [[\"15 20 60 75 80 100\"], [\"9 9 12 12 12 15 16 20\"], [\"4131 5508 7344 7803 8397 8667 9792 10404 11196 11556 13872 14553 14742 14928 15408 17631 18496 19404 19656 19904 20544 20925 21816 23508 23598 23949 25872 26208 27900 29088 31344 31464 31932 34496 34944 37200 38784 41792 41952 42576 4960...
Your friend Cody has to sell a lot of jam, so he applied a good 25% discount to all his merchandise. Trouble is that he mixed all the prices (initial and discounted), so now he needs your cool coding skills to filter out only the discounted prices. For example, consider this inputs: ``` "15 20 60 75 80 100" "9 9 12 1...
0
{"tests": "{\"inputs\": [[\"ccccoodeffffiiighhhhhhhhhhttttttts\"], [\"soooooldieeeeeer\"], [\"ccccoooooooooooooooooooooooddee\"], [\"wwwwaaaarrioooorrrrr\"], [\"gztxxxxxggggggggggggsssssssbbbbbeeeeeeehhhmmmmmmmitttttttlllllhkppppp\"]], \"outputs\": [[3], [0], [1], [2], [2]]}", "source": "primeintellect"}
# Task You are given a string `s`. Let's call its substring a group, if all letters in it are adjacent and the same(such as `"aa","bbb","cccc"`..). Let's call the substiring with 2 or more adjacent group a big group(such as `"aabb","bbccc"`...). Your task is to count the number of `big groups` in the given string. ...
0
{"tests": "{\"inputs\": [[[3, 6], [14, 6]], [[-2, 5], [-2, -10], 2], [[1, 2], [4, 6]], [[5, 3], [10, 15], 2], [[-2, -10], [6, 5]], [[4, 7], [6, 2], 3], [[-4, -5], [-5, -4], 1], [[3, 8], [3, 8]], [[-3, 8], [3, 8]], [[3, 8], [3, -8]]], \"outputs\": [[11], [15], [5], [13], [17], [5.385], [1.4], [0], [6], [16]]}", "source"...
Construct a function 'coordinates', that will return the distance between two points on a cartesian plane, given the x and y coordinates of each point. There are two parameters in the function, ```p1``` and ```p2```. ```p1``` is a list ```[x1,y1]``` where ```x1``` and ```y1``` are the x and y coordinates of the first ...
0
{"tests": "{\"inputs\": [[2, 6], [5, 20], [2, 100], [10, 30], [200, 220]], \"outputs\": [[{\"2\": [\"None\"], \"3\": [\"None\"], \"4\": [2], \"5\": [\"None\"], \"6\": [2, 3]}], [{\"5\": [\"None\"], \"6\": [2, 3], \"7\": [\"None\"], \"8\": [2, 4], \"9\": [3], \"10\": [2, 5], \"11\": [\"None\"], \"12\": [2, 3, 4, 6], \"1...
The objective of this Kata is to write a function that creates a dictionary of factors for a range of numbers. The key for each list in the dictionary should be the number. The list associated with each key should possess the factors for the number. If a number possesses no factors (only 1 and the number itself), the...
0
{"tests": "{\"inputs\": [[1], [2], [13], [19], [41], [42], [74], [86], [93], [101]], \"outputs\": [[1], [8], [2197], [6859], [68921], [74088], [405224], [636056], [804357], [1030301]]}", "source": "primeintellect"}
Given the triangle of consecutive odd numbers: ``` 1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 ... ``` Calculate the row sums of this triangle from the row index (starting at index 1) e.g.: ```python row_sum_odd_numbers(1); # 1 row_sum_odd_numbers(2); # 3 ...
0
{"tests": "{\"inputs\": [[1024, \"4:3\"], [1280, \"16:9\"], [3840, \"32:9\"], [1600, \"4:3\"], [1280, \"5:4\"], [2160, \"3:2\"], [1920, \"16:9\"], [5120, \"32:9\"]], \"outputs\": [[\"1024x768\"], [\"1280x720\"], [\"3840x1080\"], [\"1600x1200\"], [\"1280x1024\"], [\"2160x1440\"], [\"1920x1080\"], [\"5120x1440\"]]}", "so...
Cheesy Cheeseman just got a new monitor! He is happy with it, but he just discovered that his old desktop wallpaper no longer fits. He wants to find a new wallpaper, but does not know which size wallpaper he should be looking for, and alas, he just threw out the new monitor's box. Luckily he remembers the width and the...
0
{"tests": "{\"inputs\": [[\"p0F2LF2RqP0\"], [\"p1P2P3qp2P1qp3P1qP3\"], [\"p1P2qp2P3qP4p3P4qp4P1q\"], [\"p1P2P4qp2P3qp3P4qP1p4P1q\"], [\"p1P2P3qP2P1p2P3qp3P4qp4P1q\"], [\"p1P2qp2P3qp3P4qP6p4P1qp5P7qp6P5qp7P6qP1\"], [\"P1P2P7p1P2qp2P3qp3P4qp4P1qp5P7qp6P5qp7P5q\"], [\"P2P7P6p1P2qp2P3qp3P4qp4P1qp5P8qp6P5qp7P5qp8P7q\"], [\"...
# 'Magic' recursion call depth number This Kata was designed as a Fork to the one from donaldsebleung Roboscript series with a reference to: https://www.codewars.com/collections/roboscript It is not more than an extension of Roboscript infinite "single-" mutual recursion handling to a "multiple-" case. One can supp...
0
{"tests": "{\"inputs\": [\"3 3\\n\", \"7 4\\n\", \"2 8\\n\", \"34 69\\n\", \"8935891487501725 71487131900013807\\n\", \"470060730774588924 727173667167621133\\n\", \"95 427\\n\", \"985 1653\\n\", \"435 1515\\n\", \"1717 879\\n\", \"407 113\\n\", \"753 271\\n\", \"6261 668\\n\", \"2651 1994\\n\", \"4997 4748\\n\", \"407...
You are given two positive integers $x$ and $y$. You can perform the following operation with $x$: write it in its binary form without leading zeros, add $0$ or $1$ to the right of it, reverse the binary form and turn it into a decimal number which is assigned as the new value of $x$. For example: $34$ can be turned ...
0
{"tests": "{\"inputs\": [[0], [1], [2], [3], [4], [5], [6], [10], [20], [50]], \"outputs\": [[0], [0], [0], [525], [8325], [95046], [987048], [9999722967], [99999999999959940181], [99999999999999999999999999999999999999912040301674]]}", "source": "primeintellect"}
A `bouncy number` is a positive integer whose digits neither increase nor decrease. For example, 1235 is an increasing number, 5321 is a decreasing number, and 2351 is a bouncy number. By definition, all numbers under 100 are non-bouncy, and 101 is the first bouncy number. Determining if a number is bouncy is easy, bu...
0
{"tests": "{\"inputs\": [\"5\\n0 1 5 2 6\\n\", \"7\\n6 9 8 7 3 5 2\\n\", \"7\\n32 35 2 20 52 59 28\\n\", \"31\\n59 189 95 1 107 144 39 5 174 124 100 46 94 84 67 26 56 165 140 157 128 130 35 14 24 182 90 66 173 62 109\\n\", \"2\\n0 1000000000\\n\", \"3\\n4 9 1\\n\", \"7\\n12 11 0 13 3 1 9\\n\", \"2\\n9 8\\n\", \"13\\n30...
For a given sequence of distinct non-negative integers $(b_1, b_2, \dots, b_k)$ we determine if it is good in the following way: Consider a graph on $k$ nodes, with numbers from $b_1$ to $b_k$ written on them. For every $i$ from $1$ to $k$: find such $j$ ($1 \le j \le k$, $j\neq i$), for which $(b_i \oplus b_j)$ is t...
0
{"tests": "{\"inputs\": [[[1, 2, 3, 6, 4, 1, 2, 3, 2, 1]], [[3, 2, 3, 6, 4, 1, 2, 3, 2, 1, 2, 3]], [[3, 2, 3, 6, 4, 1, 2, 3, 2, 1, 2, 2, 2, 1]], [[2, 1, 3, 1, 2, 2, 2, 2, 1]], [[2, 1, 3, 1, 2, 2, 2, 2]], [[2, 1, 3, 2, 2, 2, 2, 5, 6]], [[2, 1, 3, 2, 2, 2, 2, 1]], [[1, 2, 5, 4, 3, 2, 3, 6, 4, 1, 2, 3, 3, 4, 5, 3, 2, 1, 2...
In this kata, you will write a function that returns the positions and the values of the "peaks" (or local maxima) of a numeric array. For example, the array `arr = [0, 1, 2, 5, 1, 0]` has a peak at position `3` with a value of `5` (since `arr[3]` equals `5`). ~~~if-not:php,cpp,java,csharp The output will be returned...
0
{"tests": "{\"inputs\": [\"3\\n(1+2)*3+3\\n3\\n1*1*1+1*1*1\\n587\\n1*(2*3*4)+5+((6+7*8))*(9)\\n0\", \"3\\n(1+2)*3+3\\n3\\n1*1*1+1*1*1\\n721\\n1*(2*3*4)+5+((6+7*8))*(9)\\n0\", \"3\\n(1+2)*3+3\\n3\\n1*1*1+1*1+1\\n1480\\n1*(2*3*4)+5+((6+7*8))*(9)\\n0\", \"3\\n(1+2)*3+3\\n1\\n1*1*1+1*1*1\\n587\\n1*(2*3*4)+5+((6+7*8))*(9)\\...
Expression Mining Consider an arithmetic expression built by combining single-digit positive integers with addition symbols `+`, multiplication symbols `*`, and parentheses `(` `)`, defined by the following grammar rules with the start symbol `E`. E ::= T | E '+' T T ::= F | T '*' F F ::= '1' | '2' | '3' | '4' | '5'...
0
{"tests": "{\"inputs\": [\"7\\n1\\n2\\n2\\n3\\n1\\n4\", \"5\\n1\\n1\\n1\\n4\", \"5\\n1\\n0\\n1\\n3\", \"7\\n1\\n4\\n2\\n3\\n1\\n3\", \"5\\n0\\n0\\n1\\n3\", \"4\\n3\\n4\\n0\", \"7\\n1\\n4\\n2\\n3\\n1\\n4\", \"5\\n1\\n1\\n1\\n3\", \"7\\n1\\n4\\n2\\n3\\n1\\n7\", \"7\\n1\\n2\\n1\\n3\\n1\\n0\", \"4\\n3\\n4\\n1\", \"5\\n0\\n...
N contestants participated in a competition. The total of N-1 matches were played in a knockout tournament. For some reasons, the tournament may not be "fair" for all the contestants. That is, the number of the matches that must be played in order to win the championship may be different for each contestant. The struct...
0
{"tests": "{\"inputs\": [\"00000000111111110000000011111111000000001111111100000000111111110000000011111111000000001111111100000000111111110000000111111111\\n10000000111111110000000011111111000000001111111100000000111111110000000011111111000000001111111100000000111111110000000011111111\\n0101010101010101010101010101010...
Problem Statement Let's consider operations on monochrome images that consist of hexagonal pixels, each of which is colored in either black or white. Because of the shape of pixels, each of them has exactly six neighbors (e.g. pixels that share an edge with it.) "Filtering" is an operation to determine the color of a...
0.125
{"tests": "{\"inputs\": [[90, 120], [2, 4], [100, 1000], [3, 15], [114, 200], [3, 118]], \"outputs\": [[7], [3], [11], [6], [157], [121]]}", "source": "primeintellect"}
# Task Given two integers `a` and `b`, return the sum of the numerator and the denominator of the reduced fraction `a/b`. # Example For `a = 2, b = 4`, the result should be `3` Since `2/4 = 1/2 => 1 + 2 = 3`. For `a = 10, b = 100`, the result should be `11` Since `10/100 = 1/10 => 1 + 10 = 11`. For `a = 5, b = 5`...
0
{"tests": "{\"inputs\": [\"7\\n1010001\", \"50\\n10101000010011011110001001111110001101010111100110\", \"7\\n1000001\", \"50\\n10101000010011011010001001111110001101010111100100\", \"50\\n10101000010011011010001001111110001101010111000100\", \"50\\n10101000010011010010001001111110001101010111000100\", \"7\\n1101001\", ...
N cells are arranged in a row. Some of them may contain tokens. You are given a string s that consists of `0`s and `1`s. If the i-th character of s is `1`, the i-th cell (from left) contains a token. Otherwise, it doesn't contain a token. Snuke wants to perform the following operation as many times as possible. In eac...
0
{"tests": "{\"inputs\": [\"12\\n11 4\\n9 2\\n10000 100\\n1000000000 2345\\n123456 1234567\\n123456 65536\\n5 55\\n5 3\\n2323 10\\n999111000 232323\\n999888777 777888999\\n999888777 777\\n\", \"17\\n1 1000000000\\n1000000000 1\\n1000000000 1000000000\\n1000000000 999999999\\n999999999 1000000000\\n1 2\\n2 1\\n2 3\\n3 2\...
Once n people simultaneously signed in to the reception at the recently opened, but already thoroughly bureaucratic organization (abbreviated TBO). As the organization is thoroughly bureaucratic, it can accept and cater for exactly one person per day. As a consequence, each of n people made an appointment on one of the...
0
{"tests": "{\"inputs\": [\"7 7\\n64 16 50 18 66 25 60\\n8 4 10 2 3 5 2\\n\", \"1 1\\n1\\n2\\n\", \"2 5\\n6 3\\n4 2\\n\", \"3 200000\\n6 4 8\\n3 2 2\\n\", \"3 200000\\n8 5 9\\n1 8 1\\n\", \"7 200000\\n63 48 70 14 63 69 40\\n9 4 10 7 9 3 8\\n\", \"3 100\\n2 7 3\\n10 3 5\\n\", \"4 4\\n3 4 4 3\\n2 2 1 1\\n\", \"7 200000\\n...
Berland SU holds yet another training contest for its students today. n students came, each of them brought his laptop. However, it turned out that everyone has forgot their chargers! Let students be numbered from 1 to n. Laptop of the i-th student has charge a_i at the beginning of the contest and it uses b_i of char...
0
{"tests": "{\"inputs\": [\"1\\n[\\n[\", \"52\\nRvvttdWIyyPPQFFZZssffEEkkaSSDKqcibbeYrhAljCCGGJppHHn\\nRLLwwdWIxxNNQUUXXVVMMooCBaggDKqcimmeYrhAljOOTTJuuzzn\", \"3\\naab\\nacc\", \"3\\nbab\\nbab\", \"3\\naab\\ncbb\", \"3\\naab\\nbbb\", \"3\\naab\\nbcb\", \"3\\naab\\nbdb\", \"52\\nnHHppJGGCCjlAhrYebbicqKDSSakkEEffssZZFFQP...
We have a board with a 2 \times N grid. Snuke covered the board with N dominoes without overlaps. Here, a domino can cover a 1 \times 2 or 2 \times 1 square. Then, Snuke decided to paint these dominoes using three colors: red, cyan and green. Two dominoes that are adjacent by side should be painted by different colors...
0
{"tests": "{\"inputs\": [[1, [1, 2, 5, 10]], [5, [1, 2, 5, 10]], [6, [1, 3, 5, 10]], [10, [1, 2, 5, 10]], [12, [1, 3, 5, 10]], [53, [1, 2, 5, 25]], [7, [1, 1, 1, 25]], [76, [1, 3, 4, 10]], [33, [1, 6, 9, 10]], [63, [1, 2, 9, 10]], [239, [1, 2, 3, 10]], [333, [1, 1, 5, 25]], [543, [1, 3, 5, 25]], [777, [1, 2, 3, 10]], [...
Coffee Vending Machine Problems [Part 1] You have a vending machine, but it can not give the change back. You decide to implement this functionality. First of all, you need to know the minimum number of coins for this operation (i'm sure you don't want to return 100 pennys instead of 1$ coin). So, find an optimal numb...
0
{"tests": "{\"inputs\": [\"5 4 10\\n4 3 1\\n6 4 3\\n3 2 4\\n2 2 1\\n8 5 3\\n1 2\\n2 3\\n3 4\\n4 5\\n3 3 1000\\n1000 1 100\\n1 7 100\\n10 9 100\\n1 2\\n2 3\\n3 2\\n1 0 5\\n25 25 2\\n1 0 25\\n25 25 2\\n5 5 100\\n1 1 20\\n1 1 20\\n10 1 1\\n10 1 1\\n10 1 1\\n1 2\\n2 1\\n3 4\\n4 5\\n5 3\\n3 3 100\\n70 20 10\\n50 16 20\\n90 ...
Problem Statement You want to compete in ICPC (Internet Contest of Point Collection). In this contest, we move around in $N$ websites, numbered $1$ through $N$, within a time limit and collect points as many as possible. We can start and end on any website. There are $M$ links between the websites, and we can move be...
0
{"tests": "{\"inputs\": [\"5 1\\n1 1 1 1 1\\n1 3\\n\", \"5 1\\n1 2 3 2 1\\n1 2\\n\", \"5 5\\n1 1 1 1 1\\n1 1\\n1 2\\n1 3\\n1 4\\n1 5\\n\", \"2 1\\n2 2\\n1 1\\n\", \"5 2\\n1 1 1 1 1\\n1 1\\n1 3\\n\", \"5 1\\n1 1 1 1 1\\n1 5\\n\", \"1 1\\n1\\n1 1\\n\", \"3 1\\n1 3 2\\n2 1\\n\", \"6 4\\n1 1 1 2 2 2\\n1 1\\n1 2\\n2 1\\n2 2...
After a successful year of milk production, Farmer John is rewarding his cows with their favorite treat: tasty grass! On the field, there is a row of n units of grass, each with a sweetness s_i. Farmer John has m cows, each with a favorite sweetness f_i and a hunger value h_i. He would like to pick two disjoint subset...
0
{"tests": "{\"inputs\": [\"5\\n2 4 4 0 2\\n\", \"7\\n6 4 0 2 4 0 2\\n\", \"8\\n7 5 1 1 7 3 5 3\\n\", \"8\\n7 5 1 2 7 3 5 3\", \"7\\n6 4 0 2 4 0 4\", \"5\\n0 4 4 0 2\", \"7\\n6 4 0 2 4 -1 4\", \"5\\n0 4 4 0 1\", \"7\\n6 4 0 2 8 -1 4\", \"5\\n0 4 1 0 1\", \"7\\n6 4 0 2 8 0 4\", \"5\\n0 4 0 0 1\", \"7\\n6 4 1 2 8 0 4\", \...
There are N people, conveniently numbered 1 through N. They were standing in a row yesterday, but now they are unsure of the order in which they were standing. However, each person remembered the following fact: the absolute difference of the number of the people who were standing to the left of that person, and the nu...
0.875
{"tests": "{\"inputs\": [\"5 4 2\\n1 2 5\\n1 3 9\\n2 4 0\\n2 5 1\", \"5 4 2\\n1 4 5\\n1 3 9\\n2 4 0\\n2 5 1\", \"5 4 2\\n1 2 5\\n1 3 9\\n2 4 -1\\n2 5 1\", \"5 4 2\\n1 4 5\\n1 3 12\\n2 4 0\\n2 5 1\", \"5 4 2\\n1 4 3\\n1 3 12\\n2 4 0\\n2 5 1\", \"5 4 2\\n1 2 5\\n1 3 4\\n2 4 0\\n2 5 1\", \"5 4 2\\n1 4 5\\n1 3 1\\n2 4 0\\n...
Read problems statements in Mandarin Chinese and Russian as well. Mike is given an undirected graph G of N vertices and M edges. A non-negative integer X_{i} is assigned to the i'th vertex of G, for 1 ≤ i ≤ N. Mike was asked to assign labels to each edge of the graph so that the following condition is satisfied: ...
0
{"tests": "{\"inputs\": [\"3\\n49 50 87 78 41\\n27 61 100 45 84\\n28 36 40 95 66\\n2\\n100 100 100 100 100\\n0 0 0 0 0\\n1\\n89 90 85 93 82\\n0\", \"2\\n100 101 100 100 100\\n0 0 0 0 0\", \"3\\n49 50 87 78 41\\n27 61 100 45 84\\n28 88 40 95 23\", \"3\\n49 50 87 78 41\\n27 61 100 45 84\\n28 36 40 95 66\\n2\\n100 100 100...
Yui Hirasawa, who attends private Sakuragaoka Girls' High School, has to make a career hope by the day after tomorrow, but the trouble is that she hasn't decided anything yet. When I consulted with my friend Wa, I knew that my first choice was K University, so I consulted with my career guidance teacher to see if I cou...
0
{"tests": "{\"inputs\": [\"5\\n3\\n1 2 1\\n3\\n1 1 2\\n5\\n2 2 2 1 3\\n5\\n2100 1900 1600 3000 1600\\n2\\n2443 2445\\n\", \"1\\n13\\n1 2 2 3 1 3 2 1 2 1 2 2 2\\n\", \"1\\n8\\n3 4 6 4 4 6 4 3\\n\", \"2\\n4\\n1 1 1 1\\n3\\n1 2 3\\n\", \"2\\n4\\n1 1 1 1\\n3\\n1 3 4\\n\", \"1\\n8\\n2 2 4 3 1 2 1 1\\n\", \"1\\n13\\n1 2 2 3 ...
During cleaning the coast, Alice found $n$ piles of stones. The $i$-th pile has $a_i$ stones. Piles $i$ and $i + 1$ are neighbouring for all $1 \leq i \leq n - 1$. If pile $i$ becomes empty, piles $i - 1$ and $i + 1$ doesn't become neighbouring. Alice is too lazy to remove these stones, so she asked you to take this ...
0
{"tests": "{\"inputs\": [\"4 1 4\\n3 2 2 2\", \"6 2 2\\n1 2 2 2 2 0\", \"8 7 15\\n5 0 9 14 0 4 0 15\", \"8 10 18\\n2 12 16 14 18 4 17 10\", \"2 1 4\\n3 2 2 2\", \"8 7 15\\n5 0 1 14 0 4 0 15\", \"8 10 18\\n2 12 16 14 18 6 17 10\", \"8 7 15\\n5 -1 1 14 0 4 0 15\", \"8 10 18\\n2 12 5 14 18 6 17 10\", \"8 10 18\\n2 12 5 14...
In the building of Jewelry Art Gallery (JAG), there is a long corridor in the east-west direction. There is a window on the north side of the corridor, and $N$ windowpanes are attached to this window. The width of each windowpane is $W$, and the height is $H$. The $i$-th windowpane from the west covers the horizontal r...
0.125
{"tests": "{\"inputs\": [[\"0789456123\"], [\"000\"], [\"94561\"], [\"\"], [\"919\"]], \"outputs\": [[\"0123456789\"], [\"000\"], [\"34567\"], [\"\"], [\"373\"]]}", "source": "primeintellect"}
Having two standards for a keypad layout is inconvenient! Computer keypad's layout: Cell phone keypad's layout: Solve the horror of unstandartized keypads by providing a function that converts computer input to a number as if it was typed by a phone. Example: "789" -> "123" Notes: You get a string wit...
0
{"tests": "{\"inputs\": [\"3\\n0 6 0\", \"3\\n0 2 1\", \"3\\n1 4 1\", \"3\\n0 11 -1\", \"3\\n0 10 -1\", \"3\\n1 7 2\", \"3\\n0 5 -1\", \"3\\n0 3 -1\", \"3\\n2 8 -2\", \"3\\n2 14 -2\", \"3\\n2 17 -2\", \"3\\n1 32 -1\", \"3\\n1 57 -1\", \"3\\n0 72 2\", \"3\\n0 0 0\", \"3\\n1 0 0\", \"3\\n1 -4 1\", \"3\\n2 27 -2\", \"3\\n...
At the pancake shop you work for, pancake dough is lined up in a row on an elongated iron plate and baked. Pancakes can be completed by turning them over with a spatula several times. How many times you turn it over to complete it depends on the pancake. Since the spatula is large, two adjacent pancakes will be turned...
0
{"tests": "{\"inputs\": [[[8, 8], \"1|22|4444|88888888\"], [[4, 4], \"1|22|4444|88888888\"], [[2, 2], \"1|22|4444|88888888\"], [[1, 1], \"1|22|4444|88888888\"], [[3, 4], \"24|444|888888\"], [[4, 8], \"2|44|8888\"], [[2, 4], \"2|44|8888\"], [[1, 2], \"2|44|8888\"], [[10, 8], \"14|444488|888824\"], [[6, 4], \"222|444444|...
Your task is to validate rhythm with a meter. _________________________________________________ Rules: 1. Rhythmic division requires that in one whole note (1) there are two half notes (2) or four quarter notes (4) or eight eighth notes (8). Examples: 1 = 2 + 2, 1 = 4 + 4 + 4 + 4 ... Note that: 2 = 4 + 4, 4 = 8 + 8...
0
{"tests": "{\"inputs\": [\"2\\n2 4\", \"4\\n3 3 3 2\", \"10\\n1000 193 256 777 0 2 1192 1234567891011 48 425\", \"2\\n2 7\", \"10\\n1000 193 256 777 0 2 1192 2138223215855 48 425\", \"2\\n0 7\", \"10\\n1000 193 256 777 0 2 2173 2138223215855 48 425\", \"4\\n1 6 3 4\", \"10\\n1000 193 256 777 0 2 2173 2532903011866 48 4...
We have a sequence of length N consisting of non-negative integers. Consider performing the following operation on this sequence until the largest element in this sequence becomes N-1 or smaller. (The operation is the same as the one in Problem D.) * Determine the largest element in the sequence (if there is more than...
0.25
{"tests": "{\"inputs\": [\"4\\n2 -1 7 3\\n2\\n2 4 -3\\n3 4 2\\n\", \"6\\n-9 -10 -9 -6 -5 4\\n3\\n2 6 -9\\n1 2 -10\\n4 6 -3\\n\", \"1\\n0\\n2\\n1 1 -1\\n1 1 -1\\n\", \"1\\n-101\\n1\\n1 1 5\\n\", \"1\\n-78\\n1\\n1 1 5\\n\", \"4\\n2 0 7 3\\n2\\n2 4 -3\\n3 4 2\\n\", \"6\\n-9 -10 -9 -6 -4 4\\n3\\n2 6 -9\\n1 2 -10\\n4 6 -3\\...
You are given a sequence of $n$ integers $a_1, a_2, \ldots, a_n$. You have to construct two sequences of integers $b$ and $c$ with length $n$ that satisfy: for every $i$ ($1\leq i\leq n$) $b_i+c_i=a_i$ $b$ is non-decreasing, which means that for every $1<i\leq n$, $b_i\geq b_{i-1}$ must hold $c$ is non-increasing, ...
0.375
{"tests": "{\"inputs\": [[1], [5000], [7500], [8300], [14313], [20005], [18331], [18332]], \"outputs\": [[4], [5074], [7293], [8320], [14313], [20293], [17944], [18720]]}", "source": "primeintellect"}
The first positive integer, `n`, with its value `4n² + 1`, being divisible by `5` and `13` is `4`. (condition 1) It can be demonstrated that we have infinite numbers that may satisfy the above condition. If we name **ai**, the different terms of the sequence of numbers with this property, we define `S(n)` as: We a...
0
{"tests": "{\"inputs\": [\"1\\n.\\n\", \"6\\n.EEEEE\\n.EEEEE\\n......\\n......\\n......\\nEEEEEE\\n\", \"3\\nEEE\\n..E\\n...\\n\", \"3\\nE..\\nEEE\\nE..\\n\", \"17\\nEE...E.EE.EE..E..\\nE.....EE..E..E..E\\nEEEE.EEEE..E..E.E\\n.E.E.EEE.EEEEE...\\nEEEEEEEEEEEEEEEEE\\nEE.E.EEEEE.E.....\\n..E.EE.EEE.E....E\\n.E..E..E...EE....
You are an adventurer currently journeying inside an evil temple. After defeating a couple of weak zombies, you arrived at a square room consisting of tiles forming an n × n grid. The rows are numbered 1 through n from top to bottom, and the columns are numbered 1 through n from left to right. At the far side of the ro...
0
{"tests": "{\"inputs\": [[1], [2], [3], [4], [15], [150], [100], [500], [1000], [10000]], \"outputs\": [[1], [5], [15], [34], [1695], [1687575], [500050], [62500250], [500000500], [500000005000]]}", "source": "primeintellect"}
Imagine a triangle of numbers which follows this pattern: * Starting with the number "1", "1" is positioned at the top of the triangle. As this is the 1st row, it can only support a single number. * The 2nd row can support the next 2 numbers: "2" and "3" * Likewise, the 3rd row, can only support the next 3 numbers:...
0
{"tests": "{\"inputs\": [\"20 3\\n10 6\\n2 6\\n19 4\\n15 6\\n20 13\\n9 11\\n8 1\\n12 4\\n7 8\\n16 3\\n18 17\\n8 16\\n12 5\\n13 7\\n9 4\\n14 16\\n8 9\\n10 18\\n9 17\\n\", \"10 0\\n10 6\\n6 5\\n1 3\\n6 1\\n7 10\\n2 8\\n9 7\\n3 4\\n3 8\\n\", \"20 2\\n3 14\\n13 1\\n4 3\\n13 5\\n12 20\\n19 12\\n6 3\\n12 15\\n11 2\\n11 17\\n...
You are given an integer k and an undirected tree, consisting of n vertices. The length of a simple path (a path in which each vertex appears at most once) between some pair of vertices is the number of edges in this path. A diameter of a tree is the maximum length of a simple path between all pairs of vertices of thi...
0.25
{"tests": "{\"inputs\": [[\".... . .-.. .-.. --- .-- --- .-. .-.. -..\"], [\".---- ... - .- -. -.. ..--- -. -..\"], [\".. .- -- .- - . ... -\"], [\".- -... -.-. -.. . ..-. --. .... .. .--- -.- .-.. -- -. --- .--. --.- .-. ... - ..- ...- .-- -..- -.-- --.. ----- .---- ..--- ...-- ....- ..... -.... --... ---.. ----...
Oh no! You have stumbled upon a mysterious signal consisting of beeps of various lengths, and it is of utmost importance that you find out the secret message hidden in the beeps. There are long and short beeps, the longer ones roughly three times as long as the shorter ones. Hmm... that sounds familiar. That's righ...
0
{"tests": "{\"inputs\": [\"3\\n1 1\\n5 2\\n6 3\", \"4\\n1 5\\n4 7\\n2 1\\n6 4\", \"10\\n1375710043 178537096\\n705445072 318106937\\n472381277 579910117\\n353498483 865935868\\n383133839 231371336\\n378371075 681212831\\n304570952 16537461\\n955719384 267238505\\n844917655 218662351\\n550309930 62731178\", \"10\\n13757...
We have N balance beams numbered 1 to N. The length of each beam is 1 meters. Snuke walks on Beam i at a speed of 1/A_i meters per second, and Ringo walks on Beam i at a speed of 1/B_i meters per second. Snuke and Ringo will play the following game: * First, Snuke connects the N beams in any order of his choice and m...
0
{"tests": "{\"inputs\": [\"5 8\\n121351 0 13513 0 165454\\n\", \"9 5\\n0 0 0 0 0 0 0 0 6\\n\", \"6 6\\n0 10 0 0 10 0\\n\", \"6 2\\n1000000000 1000000000 1000000000 1000000000 1000000000 1000000000\\n\", \"19 100000\\n1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1\\n\", \"1 1\\n15141354\\n\", \"5 3\\n0 0 14 0 0\\n\", \"20 20\\n0...
Professor GukiZ is concerned about making his way to school, because massive piles of boxes are blocking his way. In total there are n piles of boxes, arranged in a line, from left to right, i-th pile (1 ≤ i ≤ n) containing ai boxes. Luckily, m students are willing to help GukiZ by removing all the boxes from his way...
0
{"tests": "{\"inputs\": [\"5 0\\n5 3 4 1 2\\n\", \"10 -10\\n5 5 1 7 5 1 2 4 9 2\\n\", \"5 0\\n5 3 5 1 2\\n\", \"10 -10\\n5 4 1 7 5 1 2 4 9 2\\n\", \"10 -10\\n5 4 1 7 5 1 1 4 9 2\\n\", \"10 -4\\n5 4 1 7 5 1 2 4 9 2\\n\", \"10 -13\\n5 7 1 1 5 1 1 4 9 2\\n\", \"10 -6\\n5 2 1 9 5 2 4 4 9 2\\n\", \"10 -10\\n4 4 1 7 5 1 1 1 ...
During the last Sereja's Codesecrof round the server crashed many times, so the round was decided to be made unrated for some participants. Let's assume that n people took part in the contest. Let's assume that the participant who got the first place has rating a_1, the second place participant has rating a_2, ..., t...
0.125
{"tests": "{\"inputs\": [\"9\\n2\\n2\\n3\\n4\\n5\\n6\\n7\\n8\\n9\\n\", \"9\\n2\\n2\\n3\\n4\\n5\\n6\\n7\\n8\\n17\\n\", \"9\\n2\\n2\\n3\\n4\\n5\\n6\\n13\\n8\\n17\\n\", \"9\\n2\\n2\\n3\\n4\\n5\\n6\\n13\\n8\\n19\\n\", \"9\\n2\\n2\\n3\\n4\\n5\\n6\\n13\\n8\\n33\\n\", \"9\\n2\\n2\\n3\\n4\\n5\\n9\\n13\\n8\\n33\\n\", \"9\\n2\\n...
Consider the infinite sequence s of positive integers, created by repeating the following steps: 1. Find the lexicographically smallest triple of positive integers (a, b, c) such that * a ⊕ b ⊕ c = 0, where ⊕ denotes the [bitwise XOR operation](https://en.wikipedia.org/wiki/Bitwise_operation#XOR). * a, b, ...
0
{"tests": "{\"inputs\": [\"3\\n3 26\\n10 12\\n1 4\\n10 11\\n1 1337\\n1 1000000000\\n5 26\\n4 4\\n2 4\\n6 8\\n5 6\\n2 7\\n\", \"1\\n1 1000000000\\n1000000000 1000000000\\n\", \"1\\n1 1000000000\\n1000000000 1000000000\\n\", \"3\\n3 26\\n10 12\\n1 4\\n10 11\\n1 1337\\n1 1000000000\\n5 26\\n4 4\\n0 4\\n6 8\\n5 6\\n2 7\\n\...
You are the head of a large enterprise. $n$ people work at you, and $n$ is odd (i. e. $n$ is not divisible by $2$). You have to distribute salaries to your employees. Initially, you have $s$ dollars for it, and the $i$-th employee should get a salary from $l_i$ to $r_i$ dollars. You have to distribute salaries in such...
0.125
{"tests": "{\"inputs\": [\"10\\n10 11 10 11 10 11 10 11 10 11\\n\", \"20\\n2 3 4 5 6 7 8 9 8 7 6 5 4 3 2 1 5 6 5 6\\n\", \"8\\n1 2 2 2 2 3 3 3\\n\", \"4\\n294368194 294368194 294368194 294368195\\n\", \"3\\n1 2 1000000000\\n\", \"5\\n650111756 650111755 650111754 650111755 650111756\\n\", \"8\\n1 2 3 2 3 2 3 2\\n\", \"...
One day Anna got the following task at school: to arrange several numbers in a circle so that any two neighboring numbers differs exactly by 1. Anna was given several numbers and arranged them in a circle to fulfill the task. Then she wanted to check if she had arranged the numbers correctly, but at this point her youn...
0
{"tests": "{\"inputs\": [[40], [250], [260], [230], [60]], \"outputs\": [[[0, 0, 2]], [[2, 1, 0]], [[2, 0, 3]], [[1, 1, 4]], [[0, 0, 3]]]}", "source": "primeintellect"}
## Task An `ATM` ran out of 10 dollar bills and only has `100, 50 and 20` dollar bills. Given an amount between `40 and 10000 dollars (inclusive)` and assuming that the ATM wants to use as few bills as possible, determinate the minimal number of 100, 50 and 20 dollar bills the ATM needs to dispense (in that order)....
0
{"tests": "{\"inputs\": [\"4\\n24 99\\n15 68\\n12 90\\n95 66\", \"3\\n0 46\\n94 8\\n46 57\", \"4\\n24 99\\n15 44\\n12 90\\n95 66\", \"3\\n0 46\\n9 8\\n46 57\", \"4\\n18 99\\n15 44\\n12 90\\n95 66\", \"3\\n1 46\\n9 8\\n46 57\", \"4\\n18 99\\n15 44\\n3 90\\n95 66\", \"3\\n1 63\\n9 8\\n46 57\", \"4\\n18 99\\n15 44\\n3 90\...
Playing with Stones Koshiro and Ukiko are playing a game with black and white stones. The rules of the game are as follows: 1. Before starting the game, they define some small areas and place "one or more black stones and one or more white stones" in each of the areas. 2. Koshiro and Ukiko alternately select an area ...
0.125
{"tests": "{\"inputs\": [\"4\\n4 1\\n3 0 1 2\\n4 1\\n0 2 4 5\\n7 2\\n4 13 0 0 13 1337 1000000000\\n6 2\\n1 2 8 0 0 0\\n\", \"1\\n5 1\\n5 4 3 1 2\\n\", \"1\\n5 1\\n1 2 3 4 5\\n\", \"5\\n5 1\\n1 2 3 4 5\\n5 1\\n1 2 3 4 5\\n5 1\\n1 2 3 4 5\\n5 1\\n1 2 3 4 5\\n5 1\\n1 2 3 4 5\\n\", \"1\\n10 5\\n0 1 2 3 100 101 102 102 102 ...
You are given an array $a$ of $n$ non-negative integers. In one operation you can change any number in the array to any other non-negative integer. Let's define the cost of the array as $\operatorname{DIFF}(a) - \operatorname{MEX}(a)$, where $\operatorname{MEX}$ of a set of non-negative integers is the smallest non-ne...
0