info
stringlengths
120
50k
question
stringlengths
504
10.4k
avg@8_qwen3_4b_instruct_2507
float64
0
0.88
{"tests": "{\"inputs\": [\"0100\\n0101\\n10100\\n01000\\n0101011\\n0011\\n011110\\n#\", \"0100\\n1101\\n10100\\n11000\\n0001011\\n0011\\n011110\\n#\", \"0100\\n1101\\n10000\\n10000\\n0001011\\n0011\\n011110\\n#\", \"0100\\n0101\\n10100\\n10001\\n0011011\\n1011\\n011110\\n#\", \"0100\\n0100\\n10100\\n10001\\n0011011\\n1...
Aka Beko, trying to escape from 40 bandits, got lost in the city of A. Aka Beko wants to go to City B, where the new hideout is, but the map has been stolen by a bandit. Kobborg, one of the thieves, sympathized with Aka Beko and felt sorry for him. So I secretly told Aka Beko, "I want to help you go to City B, but I w...
0
{"tests": "{\"inputs\": [[4.5], [7.1], [19.00384], [109.1], [66.4], [\"pippi\"], [{}]], \"outputs\": [[\"X--X--X\\n-X-X-X-\\n--XXX--\\nXXXXXXX\\n--XXX--\\n-X-X-X-\\nX--X--X\"], [\"X--XX--X\\n-X-XX-X-\\n--XXXX--\\nXXXXXXXX\\nXXXXXXXX\\n--XXXX--\\n-X-XX-X-\\nX--XX--X\"], [\"X--------XX--------X\\n-X-------XX-------X-\\n-...
Your aged grandfather is tragically optimistic about Team GB's chances in the upcoming World Cup, and has enlisted you to help him make [Union Jack](https://en.wikipedia.org/wiki/Union_Jack) flags to decorate his house with. ## Instructions * Write a function which takes as a parameter a number which represents the d...
0
{"tests": "{\"inputs\": [\"2008 2 29\\n2015 1 1\", \"1505 9 9\\n2001 11 3\", \"1505 9 9\\n2619 11 3\", \"1505 13 9\\n2619 11 3\", \"573 1 44\\n2015 1 1\", \"595 2 44\\n2015 2 1\", \"597 2 44\\n2015 2 1\", \"246 21 0\\n2619 11 5\", \"246 21 0\\n5129 11 5\", \"431 21 0\\n5129 11 5\", \"597 2 19\\n895 -2 1\", \"51 16 1\\n...
A trick of fate caused Hatsumi and Taku to come to know each other. To keep the encounter in memory, they decided to calculate the difference between their ages. But the difference in ages varies depending on the day it is calculated. While trying again and again, they came to notice that the difference of their ages w...
0
{"tests": "{\"inputs\": [\"6 5\\n1 1 . 0 0 4\\n1 . . . . .\\n. . 2 2 . .\\n. . 2 2 3 3\\nP . - . . .\\n5\\n0 50 5 10\\n1 20 0 10\\n2 10 5 15\\n3 150 3 5\\n4 100 8 9\\n0 0\", \"6 5\\n1 1 . 0 0 4\\n1 . . . . .\\n. . 2 2 . .\\n. . 2 2 3 3\\nP . . . . .\\n5\\n0 50 8 10\\n0 20 0 10\\n2 10 5 15\\n3 150 3 5\\n4 100 8 9\\n0 0\...
Better things, cheaper. There is a fierce battle at the time sale held in some supermarkets today. "LL-do" here in Aizu is one such supermarket, and we are holding a slightly unusual time sale to compete with other chain stores. In a general time sale, multiple products are cheaper at the same time, but at LL-do, the t...
0
{"tests": "{\"inputs\": [\"1\\n3 31\\n############################..#\\n.............................L.\\n############################..#\\n\", \"1\\n3 25\\n######################..#\\n.......................L.\\n######################..#\\n\", \"1\\n3 31\\n#############################..\\n...............................
There is a grid, consisting of n rows and m columns. Each cell of the grid is either free or blocked. One of the free cells contains a lab. All the cells beyond the borders of the grid are also blocked. A crazy robot has escaped from this lab. It is currently in some free cell of the grid. You can send one of the foll...
0
{"tests": "{\"inputs\": [\"3 3 2\", \"3 3 3\", \"3 2 3\", \"1 2 3\", \"1 4 3\", \"1 4 5\", \"1 6 5\", \"1 6 4\", \"1 8 4\", \"1 1 4\", \"3 2 1\", \"2 5 2\", \"6 3 2\", \"6 3 3\", \"3 2 6\", \"1 2 2\", \"1 3 3\", \"1 5 4\", \"3 3 1\", \"2 6 2\", \"6 3 6\", \"3 4 3\", \"1 2 1\", \"1 6 3\", \"2 5 4\", \"1 1 1\", \"3 5 1\"...
We have a grid with H rows and W columns of squares. We will represent the square at the i-th row from the top and j-th column from the left as (i,\ j). Also, we will define the distance between the squares (i_1,\ j_1) and (i_2,\ j_2) as |i_1 - i_2| + |j_1 - j_2|. Snuke is painting each square in red, yellow, green or...
0
{"tests": "{\"inputs\": [[5, 2, 3], [5, 3, 4], [5, 4, 3], [666, 665, 2], [3691401, 1892272, 5]], \"outputs\": [[false], [false], [true], [false], [false]]}", "source": "primeintellect"}
Your task it to return ```true``` if the fractional part (rounded to 1 digit) of the result (```a``` / ```b```) exists, more than ```0``` and is multiple of ```n```. Otherwise return ```false```. (For Python return True or False) All arguments are positive digital numbers. Rounding works like toFixed() method. (if mo...
0
{"tests": "{\"inputs\": [\"15\\n3 3 3 3 3 3 3 4 2 4 2 2 2 4 2\\n\", \"152\\n29 23 17 25 13 29 29 29 25 23 25 29 19 25 13 25 13 23 21 27 15 29 29 25 27 17 17 19 25 19 13 19 15 13 19 13 17 17 19 17 17 13 25 21 17 13 21 17 25 21 19 23 17 17 29 15 15 17 25 13 25 13 21 13 19 19 13 13 21 25 23 19 19 21 29 29 26 30 22 20 22 2...
Fox Ciel is participating in a party in Prime Kingdom. There are n foxes there (include Fox Ciel). The i-th fox is ai years old. They will have dinner around some round tables. You want to distribute foxes such that: 1. Each fox is sitting at some table. 2. Each table has at least 3 foxes sitting around it. 3...
0
{"tests": "{\"inputs\": [\"9\\npair int int int pair pair int int int int int pair pair pair pair pair pair int\\n\", \"2\\npair int int\\n\", \"4\\npair pair pair int int int int\\n\", \"5\\npair pair pair pair int int int int int\\n\", \"10\\npair int int int pair pair pair int int pair int pair int int int pair pair...
Vasya used to be an accountant before the war began and he is one of the few who knows how to operate a computer, so he was assigned as the programmer. We all know that programs often store sets of integers. For example, if we have a problem about a weighted directed graph, its edge can be represented by three integer...
0
{"tests": "{\"inputs\": [\"11\\n23\\n0\", \"11\\n45\\n0\", \"11\\n77\\n0\", \"11\\n13\\n0\", \"11\\n17\\n0\", \"11\\n25\\n0\", \"11\\n37\\n0\", \"11\\n5\\n0\", \"11\\n69\\n0\", \"11\\n19\\n0\", \"11\\n21\\n0\", \"11\\n27\\n0\", \"11\\n11\\n0\", \"11\\n31\\n0\", \"11\\n33\\n0\", \"11\\n29\\n0\", \"11\\n7\\n0\", \"11\\n3...
A prime number n (11, 19, 23, etc.) that divides by 4 and has 3 has an interesting property. The results of calculating the remainder of the square of a natural number (1, 2, ..., n -1) of 1 or more and less than n divided by n are the same, so they are different from each other. The number is (n -1) / 2. The set of n...
0
{"tests": "{\"inputs\": [\"1\\n6\", \"1\\n8\", \"1\\n12\", \"1\\n16\", \"1\\n1\", \"1\\n13\", \"1\\n25\", \"1\\n5\", \"1\\n2\", \"1\\n3\", \"1\\n10\", \"1\\n19\", \"1\\n23\", \"1\\n9\", \"1\\n17\", \"1\\n7\", \"1\\n18\", \"1\\n20\", \"1\\n21\", \"1\\n11\", \"1\\n29\", \"1\\n15\", \"1\\n14\", \"1\\n26\", \"1\\n28\", \"1...
An bydrocarbon is an organic compound which contains only carbons and hydrogens. An isomer is a compound that has the same number of carbons but different structures. Heptane, for example, is a hydrocarbon with 7 carbons. It has nine isomers. The structural formula of three are shown in Figure 1. Carbons are represente...
0
{"tests": "{\"inputs\": [\"2\\n3 2 7 4\\n9 9 1 9\", \"2\\n3 2 7 4\\n9 3 1 9\", \"2\\n3 2 7 4\\n9 3 1 15\", \"2\\n3 2 7 4\\n7 3 1 15\", \"2\\n3 2 4 4\\n7 3 1 15\", \"2\\n3 2 4 4\\n7 3 1 9\", \"2\\n3 2 6 4\\n7 3 1 9\", \"2\\n3 2 6 4\\n4 3 1 9\", \"2\\n3 2 6 4\\n4 3 2 9\", \"2\\n3 2 6 4\\n4 3 2 4\", \"2\\n3 4 6 4\\n4 3 2 ...
For a non-negative integer K, we define a fractal of level K as follows: * A fractal of level 0 is a grid with just one white square. * When K > 0, a fractal of level K is a 3^K \times 3^K grid. If we divide this grid into nine 3^{K-1} \times 3^{K-1} subgrids: * The central subgrid consists of only black squares. * Ea...
0
{"tests": "{\"inputs\": [[2], [3], [4], [5], [6], [-3], [-27]], \"outputs\": [[true], [false], [false], [false], [true], [false], [false]]}", "source": "primeintellect"}
## Task: You have to create a function `isPronic` to check whether the argument passed is a Pronic Number and return true if it is & false otherwise. ### Description: `Pronic Number` -A pronic number, oblong number, rectangular number or heteromecic number, is a number which is the product of two consecutive integers...
0
{"tests": "{\"inputs\": [\"10\\n96759 970434747560290241\\n95684 985325796232084031\\n99418 855577012478917561\\n98767 992053283401739711\\n99232 381986776210191990\\n97804 22743067342252513\\n95150 523980900658652001\\n98478 290982116558877566\\n98012 642382931526919655\\n96374 448615375338644407\\n\", \"10\\n72939 67...
What are you doing at the end of the world? Are you busy? Will you save us? <image> Nephren is playing a game with little leprechauns. She gives them an infinite array of strings, f0... ∞. f0 is "What are you doing at the end of the world? Are you busy? Will you save us?". She wants to let more people know about i...
0
{"tests": "{\"inputs\": [[3], [5], [-3], [-11], [-25], [0]], \"outputs\": [[\" 111 \\n 222 \\n1233321\\n1233321\\n1233321\\n 222 \\n 111 \"], [\" 11111 \\n 22222 \\n 33333 \\n 44444 \\n1234555554321\\n1234555554321\\n1234555554321\\n1234555554321\\n1234555554321\\n 44444 \\n 333...
< PREVIOUS KATA NEXT KATA > ###Task: You have to write a function `pattern` which returns the following Pattern(See Examples) upto (3n-2) rows, where n is parameter. * Note:`Returning` the pattern is not the same as `Printing` the pattern. ####Rules/Note: * The pattern should be created using only unit digits. * I...
0
{"tests": "{\"inputs\": [\"3776.5765005393655\\n1819.0\\n645.2\\n2004.1\\n1208.6\", \"3777.502968017379\\n1819.0\\n645.2\\n2004.1\\n1208.6\", \"3778.4165917426626\\n1819.0\\n645.2\\n2004.2183724359945\\n1208.6\", \"3779.3515835085277\\n1819.169376096264\\n645.2\\n2004.5930566110492\\n1208.6\", \"3779.3515835085277\\n18...
There is data that records the altitude of mountains that have been climbed so far. Create a program that reads this data and outputs the elevation difference between the highest and lowest mountains. Input The input is given in the following format: Mountain height ... ... The height of the mountain is given o...
0.5
{"tests": "{\"inputs\": [\"3 2\\n2 1 1\\n\", \"3 3\\n2 1 2\\n\", \"7 1\\n4 4 6 6 6 6 5\\n\", \"3 2\\n2 0 1\\n\", \"3 1\\n2 1 1\\n\", \"3 1\\n0 1 2\\n\", \"10 6\\n3 0 0 0 0 0 0 1 0 0\\n\", \"5 5\\n0 1 1 0 0\\n\", \"3 2\\n2 2 1\\n\", \"5 1\\n0 0 1 3 4\\n\", \"2 1\\n1 1\\n\", \"9 1\\n0 0 0 2 5 5 5 5 5\\n\", \"6 1\\n0 1 2 ...
There are n workers in a company, each of them has a unique id from 1 to n. Exaclty one of them is a chief, his id is s. Each worker except the chief has exactly one immediate superior. There was a request to each of the workers to tell how how many superiors (not only immediate). Worker's superiors are his immediate ...
0
{"tests": "{\"inputs\": [\"10 3 2\\n3 9\\n9 -1\\n0 7\\n6 8\\n5 4\\n8 2\\n1 10\\n7 6\\n4 5\\n2 1\\n\", \"1 1 0\\n0 -1\\n\", \"5 1 6\\n1 2\\n2 3\\n3 4\\n4 5\\n5 -1\\n\", \"5 3 974128233\\n547205043 5\\n318213550 1\\n122625404 4\\n184874700 2\\n669820978 -1\\n\", \"1 1 2\\n0 -1\\n\", \"1 1 1000000000\\n0 -1\\n\", \"5 3 38...
This is an interactive problem. You are given a sorted in increasing order singly linked list. You should find the minimum integer in the list which is greater than or equal to x. More formally, there is a singly liked list built on an array of n elements. Element with index i contains two integers: valuei is the int...
0.125
{"tests": "{\"inputs\": [\"333625\\n\", \"693549\\n\", \"757606\\n\", \"1000000\\n\", \"999228\\n\", \"443013\\n\", \"825195\\n\", \"160945\\n\", \"489857\\n\", \"563368\\n\", \"372544\\n\", \"315936\\n\", \"446167\\n\", \"797112\\n\", \"75417\\n\", \"119444\\n\", \"916542\\n\", \"5\\n\", \"4\\n\", \"101\\n\", \"533946...
Kavi has 2n points lying on the OX axis, i-th of which is located at x = i. Kavi considers all ways to split these 2n points into n pairs. Among those, he is interested in good pairings, which are defined as follows: Consider n segments with ends at the points in correspondent pairs. The pairing is called good, if fo...
0
{"tests": "{\"inputs\": [\"1\\n4 2 2\\n\", \"1\\n1000 999 1\\n\", \"1\\n7 2 1\\n\", \"1\\n1000 1 1\\n\", \"1\\n2 1 1\\n\", \"1\\n1000 1 1000\\n\", \"1\\n8 7 2\\n\", \"1\\n1000 998 1000\\n\", \"1\\n1000 500 123\\n\", \"1\\n1000 1 2\\n\", \"1\\n1000 999 2\\n\", \"1\\n7 2 2\\n\", \"1\\n1100 999 1\\n\", \"1\\n8 2 1\\n\", \...
Have you ever tasted Martian food? Well, you should. Their signature dish is served on a completely black plate with the radius of R, flat as a pancake. First, they put a perfectly circular portion of the Golden Honduras on the plate. It has the radius of r and is located as close to the edge of the plate as possible...
0
{"tests": "{\"inputs\": [\"5 1\\n1 1856513539 999999998 999999999 1000000000\", \"16 10\\n1 7 12 27 52 75 731 13856 395504 534840 1276551 903860 9384806 19108104 82684732 535447408\", \"2 100\\n1 13\", \"10 8851025\\n38 87 668 4845 22601 65499 90236 790604 4290609 4894746\", \"16 10\\n1 7 12 27 52 75 731 18298 395504 5...
Snuke has decided to use a robot to clean his room. There are N pieces of trash on a number line. The i-th piece from the left is at position x_i. We would like to put all of them in a trash bin at position 0. For the positions of the pieces of trash, 0 < x_1 < x_2 < ... < x_{N} \leq 10^{9} holds. The robot is initi...
0
{"tests": "{\"inputs\": [\"2\\ntako 2\\nyaki 1\\n0\\ntako yaki\", \"2\\ntako 3\\nyaji 1\\n-1\\noakt yaki\", \"2\\ntako 1\\nyaij 1\\n-2\\noajt yaki\", \"2\\ntako 1\\njiay 0\\n-2\\nouja yakg\", \"2\\npaks 1\\naxii -1\\n-3\\nokua hx`j\", \"2\\npaks 0\\naxii -1\\n-1\\nnkua hx`j\", \"2\\ntako 4\\nyaji 1\\n0\\ntbko yaki\", \...
Problem statement 2D, who is good at cooking, is trying to make lunch. Cooking requires all N ingredients a_ {0}, a_ {1},…, a_ {N−1}. Now, 2D's refrigerator doesn't contain any ingredients, so I have to go to the supermarket to buy it. At the supermarket, you can buy the material a_ {i} for the price x_ {i} yen. 2D ...
0.75
{"tests": "{\"inputs\": [\"7 5\\n2\\n1\\n2\\n3\\n2\\n1\\n2\\n-1\\n3\\n2\\n-3\", \"7 5\\n2\\n0\\n2\\n3\\n2\\n1\\n2\\n-1\\n3\\n2\\n-3\", \"7 5\\n2\\n1\\n1\\n3\\n2\\n1\\n2\\n-1\\n1\\n2\\n-3\", \"7 5\\n2\\n1\\n1\\n0\\n2\\n1\\n2\\n-1\\n1\\n2\\n-3\", \"7 5\\n2\\n1\\n2\\n3\\n0\\n1\\n2\\n-1\\n3\\n2\\n-1\", \"7 5\\n1\\n0\\n2\\n...
problem You are a traveler traveling on the JOI Highway. The JOI Highway is a road that extends straight from east to west, and there are n post towns on the JOI Highway. Numbered. The westernmost post town on the JOI highway is post town 1, and the easternmost post town is post town n. You have decided to depart fro...
0.875
{"tests": "{\"inputs\": [[542, 5], [1750, 6], [14990, 7], [3456, 4], [30500, 3], [62550, 5], [568525, 7], [9567100, 8]], \"outputs\": [[547], [1799], [14996], [3462], [30501], [62557], [568531], [9567115]]}", "source": "primeintellect"}
We define the function `f1(n,k)`, as the least multiple of `n` that has all its digits less than `k`. We define the function `f2(n,k)`, as the least multiple of `n` that has all the digits that are less than `k`. Each digit may occur more than once in both values of `f1(n,k)` and `f2(n,k)`. The possible values for ...
0
{"tests": "{\"inputs\": [\"3\\n111 SET c 1\\n12 SUB c c 4\\n777 SET a 4\", \"3\\n10 SET c 1\\n193 IF c 10\\n20 HALT\", \"6\\n10 SET c 1\\n20 SET h 5\\n100 ADD s s i\\n110 SUB i i c\\n120 IF i 100\\n200 HALT\", \"3\\n10 SET c 1\\n193 IF c 11\\n20 HALT\", \"3\\n10 SET c 0\\n193 IF c 11\\n20 HALT\", \"3\\n111 SET c 1\\n12...
Have you ever had an infinite loop when you ran a hard-working program? It would be convenient to be able to determine in advance whether a program will stop executing without having to execute it. Unfortunately, it is not possible to make such a decision for any program in the programming language you normally use. H...
0
{"tests": "{\"inputs\": [\"1\\n2\\n3\\n390\\n216\\n1546\\n314159265358979323\\n0\", \"1\\n2\\n2\\n390\\n1124\\n1546\\n314159265358979323\\n0\", \"1\\n2\\n3\\n390\\n216\\n1546\\n31125328462643205\\n0\", \"1\\n2\\n2\\n390\\n1124\\n1546\\n211760204581026131\\n0\", \"1\\n2\\n3\\n104\\n216\\n1546\\n31125328462643205\\n0\", ...
Number of tanka Wishing to die in the spring under the flowers This is one of the famous tanka poems that Saigyo Hoshi wrote. Tanka is a type of waka poem that has been popular in Japan for a long time, and most of it consists of five phrases and thirty-one sounds of 5, 7, 5, 7, and 7. By the way, the number 57577 c...
0
{"tests": "{\"inputs\": [[\"wHjMudLwtoPGocnJ\"], [\"eCEHWEPwwnvzMicyaRjk\"], [\"JKniLfLW\"], [\"EWlZlDFsEIBufsalqof\"], [\"IMBAWejlGRTDWetPS\"]], \"outputs\": [[\"Bronze!\"], [\"Bronze!\"], [\"Not even a medal!\"], [\"Silver!\"], [\"Gold!\"]]}", "source": "primeintellect"}
To celebrate the start of the Rio Olympics (and the return of 'the Last Leg' on C4 tonight) this is an Olympic inspired kata. Given a string of random letters, you need to examine each. Some letters naturally have 'rings' in them. 'O' is an obvious example, but 'b', 'p', 'e', 'A', etc are all just as applicable. 'B' e...
0
{"tests": "{\"inputs\": [\"5 1\\n1 1\\n1 -1\\n-1 1\\n-1 -1\\n2 0\\n\", \"5 2\\n1 1\\n1 -1\\n-1 1\\n-1 -1\\n2 0\\n\", \"1 1000000\\n1000000 -1000000\\n\", \"1 1000000\\n1000000 -1000000\\n\", \"5 2\\n1 1\\n1 -1\\n-1 1\\n-1 -2\\n2 0\\n\", \"5 1\\n1 1\\n1 -1\\n-1 1\\n-1 0\\n2 0\\n\", \"5 1\\n1 1\\n1 -2\\n-1 1\\n-1 0\\n2 0...
The Cybermen solved that first test much quicker than the Daleks. Luckily for us, the Daleks were angry (shocking!) and they destroyed some of the Cybermen. After the fighting stopped, Heidi gave them another task to waste their time on. There are $n$ points on a plane. Given a radius $r$, find the maximum number of ...
0.125
{"tests": "{\"inputs\": [\"10 3\\n-55\\n-35\\n-80\\n91\\n-96\\n-93\\n-39\\n-77\\n4\\n29\\n\", \"10 3\\n-6\\n2\\n79\\n-49\\n86\\n13\\n-31\\n-71\\n57\\n93\\n\", \"10 3\\n-38\\n68\\n-77\\n57\\n-35\\n28\\n-61\\n-9\\n3\\n60\\n\", \"10 3\\n-20\\n-63\\n-64\\n45\\n-84\\n-13\\n79\\n-31\\n70\\n-100\\n\", \"10 3\\n2\\n-100\\n50\\...
Programmer Sasha has recently begun to study data structures. His coach Stas told him to solve the problem of finding a minimum on the segment of the array in <image>, which Sasha coped with. For Sasha not to think that he had learned all, Stas gave him a new task. For each segment of the fixed length Sasha must find t...
0.5
{"tests": "{\"inputs\": [\"1 3000\\n2006 226621946\\n\", \"10 2\\n1 1\\n1 1\\n1 1\\n1 1\\n1 1\\n2 1\\n2 1\\n2 1\\n2 1\\n2 1\\n\", \"10 10\\n1 73\\n2 8\\n3 88\\n1 5\\n2 100\\n1 29\\n1 57\\n3 37\\n7 46\\n3 21\\n\", \"5 5\\n1 3\\n1 6\\n5 4\\n3 7\\n2 10\\n\", \"1 3000\\n918 548706881\\n\", \"10 10\\n7 29\\n10 31\\n9 40\\n5...
As you know, majority of students and teachers of Summer Informatics School live in Berland for the most part of the year. Since corruption there is quite widespread, the following story is not uncommon. Elections are coming. You know the number of voters and the number of parties — n and m respectively. For each vote...
0
{"tests": "{\"inputs\": [\"20\\n178461\\n767271\\n143872\\n917783\\n642681\\n496408\\n735441\\n899441\\n265715\\n772194\\n797342\\n833227\\n479407\\n800158\\n613225\\n498438\\n818615\\n750993\\n597881\\n142739\\n\", \"20\\n1\\n2\\n3\\n4\\n5\\n6\\n7\\n8\\n9\\n10\\n11\\n12\\n13\\n14\\n15\\n16\\n17\\n18\\n19\\n20\\n\", \"...
You need to find if a number can be expressed as sum of two perfect powers. That is, given x find if there exists non negative integers a, b, m, n such that a^m + b^n = x. Input First line of the input contains number of test cases T. It is followed by T lines, each line contains a sinle number x. Output For each te...
0
{"tests": "{\"inputs\": [[\"i am a frog.\"], [\"can you do it?\"], [\"seems like you understand!\"], [\"multisentence is good. is not it?\"], [\"green, red or orange - we all just frogs, do not you think so?\"]], \"outputs\": [[\"frog a am i.\"], [\"it do you can?\"], [\"understand you like seems!\"], [\"good is multis...
A little weird green frog speaks in a very strange variation of English: it reverses sentence, omitting all puntuation marks `, ; ( ) - ` except the final exclamation, question or period. We urgently need help with building a proper translator. To simplify the task, we always use lower-case letters. Apostrophes are fo...
0
{"tests": "{\"inputs\": [\"6\\n4 1\\n2 3 5 4\\n5 6\\n1 1 3 4 4\\n1 10\\n2\\n2 10\\n11 9\\n2 10\\n12 11\\n5 18\\n81 324 218 413 324\\n\", \"3\\n5 15\\n5 15 8 10 10\\n6 5\\n2 3 15 4 15 7\\n8 7\\n12 14 9 7 15 14 8 3\\n\", \"3\\n5 15\\n5 15 8 10 10\\n6 5\\n2 3 15 4 15 7\\n8 7\\n12 14 9 7 15 14 8 3\\n\", \"3\\n5 15\\n5 15 8...
You are given a sequence $a$ consisting of $n$ integers $a_1, a_2, \dots, a_n$, and an integer $x$. Your task is to make the sequence $a$ sorted (it is considered sorted if the condition $a_1 \le a_2 \le a_3 \le \dots \le a_n$ holds). To make the sequence sorted, you may perform the following operation any number of t...
0.625
{"tests": "{\"inputs\": [\"8\\n2 4 1 3 4 2 1 2\\n\", \"5\\n1 1 2 1 2\\n\", \"98\\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 8...
You have an array $a_1, a_2, \dots, a_n$. Let's call some subarray $a_l, a_{l + 1}, \dots , a_r$ of this array a subpermutation if it contains all integers from $1$ to $r-l+1$ exactly once. For example, array $a = [2, 2, 1, 3, 2, 3, 1]$ contains $6$ subarrays which are subpermutations: $[a_2 \dots a_3]$, $[a_2 \dots ...
0.375
{"tests": "{\"inputs\": [\"5 5 2\\n1 2 100\\n2 3 100\\n3 4 100\\n4 5 20\\n2 5 5\\n5 50\\n4 1\\n\", \"2 1 5\\n1 2 4\\n2 3\\n2 5\\n2 4\\n2 4\\n2 5\\n\", \"3 3 6\\n1 2 499999999\\n2 3 500000000\\n1 3 999999999\\n2 499999999\\n2 500000000\\n2 499999999\\n3 999999999\\n3 1000000000\\n3 1000000000\\n\", \"2 1 1\\n1 2 1\\n2 1...
Jzzhu is the president of country A. There are n cities numbered from 1 to n in his country. City 1 is the capital of A. Also there are m roads connecting the cities. One can go from city ui to vi (and vise versa) using the i-th road, the length of this road is xi. Finally, there are k train routes in the country. One ...
0
{"tests": "{\"inputs\": [\"4\\n5\\n1 2 3 4 5\\n2\\n10\\n2 4 2 4 2 4 2 4 2 4\\n3\\n3\\n-10 -5 -10\\n-8\\n3\\n9 9 -3\\n5\\n\", \"1\\n10\\n5 -9 -1 6 -6 5 -6 -8 5 3\\n0\\n\", \"10\\n1\\n62169\\n62169\\n1\\n49900\\n49900\\n1\\n-45220\\n-45220\\n1\\n45734\\n45734\\n1\\n-77581\\n-77581\\n1\\n-48287\\n-48287\\n1\\n53304\\n5330...
You are given an array of integers $a_1, a_2, \ldots, a_n$ and an integer $x$. You need to select the maximum number of elements in the array, such that for every subsegment $a_l, a_{l + 1}, \ldots, a_r$ containing strictly more than one element $(l < r)$, either: At least one element on this subsegment is not select...
0
{"tests": "{\"inputs\": [\"4\\n3\\n1 4 2\\n1 3 1\\n2\\n2 4\\n2 3\\n2\\n1 1000000000\\n1 1000000000\\n4\\n3 10 5 8\\n2 5 2 4\\n\", \"4\\n3\\n1 4 2\\n1 3 1\\n2\\n2 4\\n2 3\\n2\\n1 1100000000\\n1 1000000000\\n4\\n3 10 5 8\\n2 5 2 4\\n\", \"4\\n3\\n1 6 2\\n1 3 1\\n2\\n2 4\\n2 3\\n2\\n1 1100000000\\n1 1000000000\\n4\\n3 10 ...
Consider an infinite triangle made up of layers. Let's number the layers, starting from one, from the top of the triangle (from top to bottom). The $k$-th layer of the triangle contains $k$ points, numbered from left to right. Each point of an infinite triangle is described by a pair of numbers $(r, c)$ ($1 \le c \le r...
0
{"tests": "{\"inputs\": [\"314159265 7\\n21662711\\n77271666\\n89022761\\n156626166\\n160332356\\n166902656\\n453863319\", \"6 6\\n1\\n2\\n3\\n6\\n7\\n9\", \"10 3\\n2\\n7\\n17\", \"391985414 7\\n21662711\\n77271666\\n89022761\\n156626166\\n160332356\\n166902656\\n453863319\", \"10 3\\n2\\n7\\n20\", \"10 3\\n2\\n7\\n29\...
Takahashi Lake has a perimeter of L. On the circumference of the lake, there is a residence of the lake's owner, Takahashi. Each point on the circumference of the lake has a coordinate between 0 and L (including 0 but not L), which is the distance from the Takahashi's residence, measured counter-clockwise. There are N...
0
{"tests": "{\"inputs\": [\"1\\n-751115 -925948\\n\", \"1\\n-751115 -1566406\\n\", \"3\\n-1 -1\\n0 2\\n1 0\\n\", \"3\\n0 -1\\n0 2\\n2 0\\n\", \"1\\n-751115 -2469241\\n\", \"3\\n-1 -1\\n0 2\\n2 0\\n\", \"1\\n-751115 -4760337\\n\", \"1\\n-751115 -4345366\\n\", \"3\\n0 -1\\n0 2\\n1 0\\n\", \"1\\n-751115 -8685961\\n\", \"3\...
Recently Vasya learned that, given two points with different x coordinates, you can draw through them exactly one parabola with equation of type y = x^2 + bx + c, where b and c are reals. Let's call such a parabola an U-shaped one. Vasya drew several distinct points with integer coordinates on a plane and then drew an...
0.5
{"tests": "{\"inputs\": [\"1 2 3 2 5 6\\n6 5 4 3 2 1\", \"1 2 3 2 5 6\\n6 1 4 3 2 1\", \"1 2 3 2 5 6\\n6 0 4 3 2 1\", \"1 2 3 2 5 6\\n6 0 4 3 4 1\", \"1 2 3 2 7 6\\n6 0 4 3 4 1\", \"1 2 3 2 7 3\\n6 0 4 3 4 1\", \"1 2 2 2 7 6\\n6 0 4 3 4 1\", \"1 2 2 2 7 9\\n6 0 4 3 4 1\", \"1 2 2 2 7 9\\n6 0 4 5 4 1\", \"1 0 2 2 7 9\\n...
Write a program which reads the two dices constructed in the same way as Dice I, and determines whether these two dices are identical. You can roll a dice in the same way as Dice I, and if all integers observed from the six directions are the same as that of another dice, these dices can be considered as identical. Co...
0.375
{"tests": "{\"inputs\": [\"5\\n3\\n1 6\\n1 7\\n1 5\\n2\\n1 4\\n1 3\\n3\\n1 10\\n3 5\\n2 3\\n3\\n1 15\\n2 4\\n1 10\\n1\\n1 100\\n\", \"5\\n3\\n1 1\\n1 1\\n1 1\\n3\\n1 1\\n1 1\\n1 1\\n3\\n1 1\\n1 1\\n1 1\\n3\\n1 1\\n1 1\\n1 1\\n3\\n1 100\\n1 1\\n1 1\\n\", \"1\\n4\\n1 1\\n1 1\\n2 2\\n3 4\\n\", \"5\\n3\\n1 1\\n1 1\\n1 1\\n...
You are playing a computer card game called Splay the Sire. Currently you are struggling to defeat the final boss of the game. The boss battle consists of $n$ turns. During each turn, you will get several cards. Each card has two parameters: its cost $c_i$ and damage $d_i$. You may play some of your cards during each ...
0
{"tests": "{\"inputs\": [[1], [2], [13], [19], [41], [93]], \"outputs\": [[[1]], [[3, 5]], [[157, 159, 161, 163, 165, 167, 169, 171, 173, 175, 177, 179, 181]], [[343, 345, 347, 349, 351, 353, 355, 357, 359, 361, 363, 365, 367, 369, 371, 373, 375, 377, 379]], [[1641, 1643, 1645, 1647, 1649, 1651, 1653, 1655, 1657, 1659,...
Given a triangle of consecutive odd numbers: ``` 1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 ... ``` find the triangle's row knowing its index (the rows are 1-indexed), e.g.: ``` odd_row(1) == [1] odd_row(2) == [3, 5] odd_row(3) == [7, 9, 11] ``` **...
0
{"tests": "{\"inputs\": [\"bbabb\\nbababbbbab\\n\", \"ab\\nbbbba\\n\", \"xzzxxxzxzzzxzzzxxzzxzzxzxzxxzxxzxxzxzzxxzxxzxxxzxzxzxxzzxxxxzxzzzxxxzxzxxxzzxxzxxzxxzzxxzxxzxzxzzzxzzzzxzxxzzxzxxzxxzzxzxzx\\nzzx\\n\", \"a\\nb\\n\", \"zxzxzxzxzxzxzx\\nd\\n\", \"pfdempfohomnpgbeegikfmflnalbbajpnpgeacaicoehopgnabnklheepnlnflohjegc...
One day Polycarpus got hold of two non-empty strings s and t, consisting of lowercase Latin letters. Polycarpus is quite good with strings, so he immediately wondered, how many different pairs of "x y" are there, such that x is a substring of string s, y is a subsequence of string t, and the content of x and y is the s...
0.25
{"tests": "{\"inputs\": [\"5 3 10\\n1 2 3 4 5\\nRGBRR\\n\", \"2 1 15\\n5 6\\nRG\\n\", \"6 1 21\\n4 2 3 5 1 6\\nRGBGRB\\n\", \"6 1 21\\n6 5 4 3 2 1\\nRGBRGB\\n\", \"1 1 10\\n10\\nR\\n\", \"2 1 10\\n5 5\\nRG\\n\", \"2 1 10\\n5 6\\nRR\\n\", \"5 3 10\\n1 2 3 4 5\\nRGBRG\\n\", \"9 1 6\\n1 1 1 3 3 3 2 2 2\\nRGGBRRGBB\\n\", \...
There are $n$ candy boxes in front of Tania. The boxes are arranged in a row from left to right, numbered from $1$ to $n$. The $i$-th box contains $r_i$ candies, candies have the color $c_i$ (the color can take one of three values ​​— red, green, or blue). All candies inside a single box have the same color (and it is ...
0
{"tests": "{\"inputs\": [\"9714431\", \"16612328\", \"23422731\", \"754526\", \"955577\", \"75547\", \"2112\", \"799\", \"88\", \"32523857\", \"4787\", \"1859551\", \"135661\", \"3675\", \"156692\", \"167918384\", \"83994\", \"4837847\", \"14513597\", \"15282598\", \"12659326\", \"1468417\", \"6280\", \"115464\", \"523...
If you visit Aizu Akabeko shrine, you will find a unique paper fortune on which a number with more than one digit is written. Each digit ranges from 1 to 9 (zero is avoided because it is considered a bad omen in this shrine). Using this string of numeric values, you can predict how many years it will take before your ...
0
{"tests": "{\"inputs\": [[\"foefet\", \"toffee\"], [\"Buckethead\", \"DeathCubeK\"], [\"Twoo\", \"WooT\"], [\"dumble\", \"bumble\"], [\"ound\", \"round\"], [\"apple\", \"pale\"]], \"outputs\": [[true], [true], [true], [false], [false], [false]]}", "source": "taco"}
An **anagram** is the result of rearranging the letters of a word to produce a new word. **Note:** anagrams are case insensitive Complete the function to return `true` if the two arguments given are anagrams of each other; return `false` otherwise. ## Examples * `"foefet"` is an anagram of `"toffee"` * `"Buckethe...
0.125
{"tests": "{\"inputs\": [\"3\\n0 1 1\\n\", \"4\\n0 0 1 2\\n\", \"2\\n0 0\\n\", \"4\\n0 1 1 0\\n\", \"3\\n0 1 0\\n\", \"2\\n0 1\\n\", \"8\\n0 0 2 0 3 0 3 2\\n\", \"3\\n0 1 2\\n\", \"10\\n0 0 2 2 3 2 3 3 1 3\\n\", \"6\\n0 0 0 2 0 1\\n\", \"10\\n0 1 2 0 4 5 3 6 0 5\\n\", \"4\\n0 0 1 1\\n\", \"3\\n0 0 0\\n\", \"9\\n0 1 0 1...
Arkady decides to observe a river for n consecutive days. The river's water level on each day is equal to some real value. Arkady goes to the riverside each day and makes a mark on the side of the channel at the height of the water level, but if it coincides with a mark made before, no new mark is created. The water d...
0
{"tests": "{\"inputs\": [\"1 2 1\\n2 4 4\\n0 2 1\\n7 6 7\\n5 2 3\", \"6 2 4\\n33189 87907 277349742\\n71616 46764 575306520\\n8801 53151 327161251\\n58589 4337 796697686\\n66854 17565 289910583\\n50598 35195 478112689\\n13919 88414 103962455\\n7953 69657 699253752\\n42489 98144 468443709\\n2332 42580 752437097\\n39752 ...
There are X+Y+Z people, conveniently numbered 1 through X+Y+Z. Person i has A_i gold coins, B_i silver coins and C_i bronze coins. Snuke is thinking of getting gold coins from X of those people, silver coins from Y of the people and bronze coins from Z of the people. It is not possible to get two or more different col...
0
{"tests": "{\"inputs\": [\"7 6\\nAlena\\nOlya\\nVanya\\nBrus\\nJohn\\nAlice\\nMariana\\nAlena John\\nAlena Alice\\nOlya John\\nOlya Alice\\nVanya John\\nVanya Alice\\n\", \"7 6\\nj\\nZ\\nPZNeTyY\\nm\\na\\nUj\\nsuaaSiKcK\\nUj PZNeTyY\\na j\\nPZNeTyY Z\\nPZNeTyY j\\nm PZNeTyY\\nm j\\n\", \"15 3\\na\\nYclKFJoaIA\\nhalYcB\...
When little Petya grew up and entered the university, he started to take part in АСМ contests. Later he realized that he doesn't like how the АСМ contests are organised: the team could only have three members (and he couldn't take all his friends to the competitions and distribute the tasks between the team members eff...
0.625
{"tests": "{\"inputs\": [[\"x - 5 = 20\"], [\"5 * x + 5 = 30\"], [\"20 = 5 * x - 5\"], [\"24 = 4 + 5 * x\"], [\"x = 5\"], [\"x * 100 = 700\"], [\"2 * x + 5 = 105\"], [\"2 * x = 198\"], [\"x - 100 + 2 - 50 = 52\"], [\"x / 3 = 33\"], [\"x + 80 = 20\"], [\"x + 20 = -60\"], [\"5 * x + 20 - x = 60\"], [\"x + x + 6 = 10\"], ...
# Solve For X You will be given an equation as a string and you will need to [solve for X](https://www.mathplacementreview.com/algebra/basic-algebra.php#solve-for-a-variable) and return x's value. For example: ```python solve_for_x('x - 5 = 20') # should return 25 solve_for_x('20 = 5 * x - 5') # should return 5 solv...
0
{"tests": "{\"inputs\": [\"3\\n1 2\\n1 3\\n\", \"2\\n1 2\\n\", \"5\\n1 2\\n2 3\\n3 4\\n3 5\\n\", \"8\\n1 2\\n2 3\\n3 4\\n3 5\\n3 6\\n6 7\\n6 8\\n\", \"5\\n1 2\\n1 3\\n3 4\\n3 5\", \"5\\n1 2\\n1 4\\n3 4\\n3 5\", \"5\\n1 2\\n1 4\\n5 4\\n3 5\", \"3\\n2 3\\n1 3\", \"5\\n1 2\\n2 3\\n2 4\\n3 5\", \"5\\n1 2\\n1 5\\n3 4\\n3 5\...
We have a tree with N vertices numbered 1 to N. The i-th edge in this tree connects Vertex a_i and b_i. For each k=1, ..., N, solve the problem below: - Consider writing a number on each vertex in the tree in the following manner: - First, write 1 on Vertex k. - Then, for each of the numbers 2, ..., N in this order,...
0
{"tests": "{\"inputs\": [\"5 5 5 5 5 5\\n\", \"4 4 4 4 2 2\\n\", \"1 1 2 2 3 4\\n\", \"1 3 3 3 4 5\\n\", \"4 4 5 6 7 8\\n\", \"4 4 4 4 4 5\\n\", \"5 5 5 6 6 6\\n\", \"4 4 2 2 2 2\\n\", \"1 1 3 3 3 5\\n\", \"1 8 9 1 1 1\\n\", \"9 9 9 1 9 9\\n\", \"4 4 4 4 4 2\\n\", \"1 1 2 2 2 2\\n\", \"1 1 1 1 1 2\\n\", \"4 4 4 4 4 3\\...
Two polar bears Menshykov and Uslada from the St.Petersburg zoo and elephant Horace from the Kiev zoo got six sticks to play with and assess the animals' creativity. Menshykov, Uslada and Horace decided to make either an elephant or a bear from those sticks. They can make an animal from sticks in the following way: ...
0
{"tests": "{\"inputs\": [\"4\\n337 780 799 10 796 875 331 223 941 67 268 483 390 565 116 355\", \"2\\n1 1 1 2\", \"2\\n1 2 1 3\", \"4\\n337 780 799 10 796 875 331 223 1804 67 268 483 390 565 116 355\", \"2\\n1 1 1 3\", \"2\\n2 2 1 3\", \"4\\n337 780 799 10 796 875 331 223 1804 67 268 483 390 565 20 355\", \"2\\n2 1 1 1...
Snuke found a random number generator. It generates an integer between 0 and 2^N-1 (inclusive). An integer sequence A_0, A_1, \cdots, A_{2^N-1} represents the probability that each of these integers is generated. The integer i (0 \leq i \leq 2^N-1) is generated with probability A_i / S, where S = \sum_{i=0}^{2^N-1} A_i...
0
{"tests": "{\"inputs\": [\"8\\n4 5\\n1 2\\n6 3\\n2 3\\n2 8\\n4 7\\n2 4\\n\", \"7\\n2 7\\n2 6\\n4 7\\n7 3\\n7 5\\n1 7\\n\", \"3\\n1 2\\n3 2\\n\", \"2\\n2 1\\n\", \"10\\n5 4\\n5 2\\n3 7\\n9 3\\n3 2\\n3 1\\n3 8\\n9 10\\n1 6\\n\", \"6\\n2 1\\n3 2\\n4 1\\n5 4\\n1 6\\n\", \"5\\n3 5\\n4 3\\n2 4\\n1 2\\n\", \"6\\n4 6\\n1 5\\n5...
Nauuo is a girl who loves drawing circles. One day she has drawn a circle and wanted to draw a tree on it. The tree is a connected undirected graph consisting of n nodes and n-1 edges. The nodes are numbered from 1 to n. Nauuo wants to draw a tree on the circle, the nodes of the tree should be in n distinct points o...
0
{"tests": "{\"inputs\": [\"5 328 249\\n62 265\\n32 271\\n72 237\\n28 99\\n22 364\\n\", \"4 337 873\\n62 81\\n87 481\\n39 1189\\n45 450\\n\", \"2 1000 1\\n100 1\\n100 1\\n\", \"5 351 183\\n16 337\\n19 221\\n81 359\\n87 253\\n5 240\\n\", \"3 100 5\\n100 1\\n100 1\\n100 1\\n\", \"10 1000 8\\n100 1\\n100 1\\n100 1\\n100 1\...
Vasya’s elder brother Petya loves playing computer games. In one of his favourite computer games Petya reached the final level where a fight with the boss take place. While playing the game Petya found spell scrolls and now he is about to use them. Let’s describe the way fighting goes on this level: 1) The boss has t...
0
{"tests": "{\"inputs\": [\"1071 1029\\n5 3\\n0 0\", \"1251 1029\\n5 3\\n0 0\", \"1251 1802\\n5 3\\n0 0\", \"1071 446\\n5 3\\n0 0\", \"1071 2\\n5 3\\n0 0\", \"1071 1029\\n2 3\\n0 0\", \"1251 3458\\n5 3\\n0 0\", \"826 2\\n5 3\\n0 0\", \"1251 3458\\n10 3\\n0 0\", \"1164 1029\\n4 3\\n0 0\", \"1251 3458\\n10 6\\n0 0\", \"83...
The greatest common divisor is an indispensable element in mathematics handled on a computer. Using the greatest common divisor can make a big difference in the efficiency of the calculation. One of the algorithms to find the greatest common divisor is "Euclidean algorithm". The flow of the process is shown below. <im...
0
{"tests": "{\"inputs\": [\"3 3 3 2\\n1 1\\n2 1\\n3 1\\n2 3\\n\", \"3 5 3 2\\n1 2\\n2 3\\n3 1\\n1 5\\n\", \"3 6 3 2\\n1 6\\n2 2\\n3 4\\n1 6\\n\", \"2 2 2 2\\n1 1\\n1 2\\n1 2\\n\", \"5 5 10 3\\n3 1\\n3 2\\n3 5\\n1 5\\n2 1\\n2 5\\n1 2\\n1 4\\n3 3\\n2 4\\n2 1 5\\n\", \"5 3 10 3\\n5 3\\n1 1\\n2 2\\n1 3\\n3 2\\n5 2\\n2 3\\n2...
You are on the island which can be represented as a $n \times m$ table. The rows are numbered from $1$ to $n$ and the columns are numbered from $1$ to $m$. There are $k$ treasures on the island, the $i$-th of them is located at the position $(r_i, c_i)$. Initially you stand at the lower left corner of the island, at t...
0
{"tests": "{\"inputs\": [[1221], [110011], [1456009006541], [123322], [1], [152], [9999], [\"ACCDDCCA\"], [\"@14AbC\"], [\"1221\"], [-450]], \"outputs\": [[true], [true], [true], [false], [true], [false], [true], [\"Not valid\"], [\"Not valid\"], [\"Not valid\"], [\"Not valid\"]]}", "source": "taco"}
A palindrome is a word, phrase, number, or other sequence of characters which reads the same backward as forward. Examples of numerical palindromes are: 2332 110011 54322345 For a given number `num`, write a function to test if it's a numerical palindrome or not and return a boolean (true if it is and false if ...
0
{"tests": "{\"inputs\": [\"3\\n4 5 7\\n\", \"2\\n1 1\\n\", \"10\\n38282 53699 38282 38282 38282 38282 38282 38282 38282 38282\\n\", \"10\\n50165 50165 50165 50165 50165 50165 50165 50165 50165 50165\\n\", \"10\\n83176 83176 83176 23495 83176 8196 83176 23495 83176 83176\\n\", \"10\\n32093 36846 32093 32093 36846 36846 ...
Edogawa Conan got tired of solving cases, and invited his friend, Professor Agasa, over. They decided to play a game of cards. Conan has n cards, and the i-th card has a number a_{i} written on it. They take turns playing, starting with Conan. In each turn, the player chooses a card and removes it. Also, he removes al...
0
{"tests": "{\"inputs\": [\"5 5\\n1 2 3 4 5\\n1 2 1 4 5\\n5 5\\n2 5 4 1 3\\n4 1 5 3 2\\n5 5\\n1 2 3 4 5\\n3 3 3 4 5\\n3 3\\n7 7 7\\n7 7 7\\n3 3\\n4 4 4\\n4 3 4\\n4 3\\n4 2 2 4\\n4 2 1\\n4 4\\n2 8 8 8\\n2 3 8 3\\n10 10\\n9 9 9 9 9 9 9 9 9 9\\n9 9 9 9 9 9 9 9 9 9\\n10 9\\n20 1 20 20 20 20 20 18 20 20\\n20 20 20 20 7 20 20...
International Center for Picassonian Cubism is a Spanish national museum of cubist artworks, dedicated to Pablo Picasso. The center held a competition for an artwork that will be displayed in front of the facade of the museum building. The artwork is a collection of cubes that are piled up on the ground and is intended...
0
{"tests": "{\"inputs\": [\"3 7 3\\n0 1 1 1\\n0 1 1 2\\n1 1 3 4\\n1 1 1 1\\n1 2 1 2\\n3 1 1 3\\n2 2 2 1\", \"5 10 5\\n0 1 1 2\\n0 2 1 2\\n0 1 2 3\\n1 2 0 2\\n1 4 2 3\\n2 1 1 1\\n2 1 1 2\\n3 3 2 3\\n4 1 1 2\\n4 2 1 2\", \"5 10 5\\n0 1 1 2\\n0 2 1 2\\n0 1 2 3\\n1 2 0 2\\n1 4 2 3\\n2 1 1 1\\n2 1 1 2\\n3 3 2 4\\n4 1 1 2\\n4...
Problem Yamano Mifune Gakuen's 1st grade G group is a class where female students carrying misfortune gather. They face various challenges every day with the goal of being happy. In their class, they can take practical happiness courses as part of the test of happiness. From Monday to Friday, there are classes from 1...
0.625
{"tests": "{\"inputs\": [\"3\\n14 1\\n+--++---++-++-\\n1 14\\n14 3\\n+--++---+++---\\n1 14\\n6 12\\n3 10\\n4 10\\n+-+-\\n1 1\\n1 2\\n1 3\\n1 4\\n2 2\\n2 3\\n2 4\\n3 3\\n3 4\\n4 4\\n\", \"3\\n14 1\\n+--++---++-++-\\n1 14\\n14 3\\n+--++---+++---\\n1 14\\n6 7\\n3 10\\n4 10\\n+-+-\\n1 1\\n1 2\\n1 3\\n1 4\\n2 2\\n2 3\\n2 4\...
This is the easy version of the problem. The difference between the versions is that the easy version does not require you to output the numbers of the rods to be removed. You can make hacks only if all versions of the problem are solved. Stitch likes experimenting with different machines with his friend Sparky. Today...
0
{"tests": "{\"inputs\": [\"4\\n0 3\\n3 3\\n3 4\\n4 4\\n\", \"1\\n73 18\\n\", \"1\\n25 6\\n\", \"24\\n19 9\\n20 9\\n21 9\\n22 9\\n23 9\\n24 9\\n25 9\\n26 9\\n27 9\\n28 9\\n29 9\\n30 9\\n31 9\\n32 9\\n1000000000 999999999\\n999999996 999999999\\n999999997 999999999\\n1000000000 6\\n1000000000 3\\n1000000000 9\\n999999999...
Alice and Bob play a game. There is a paper strip which is divided into n + 1 cells numbered from left to right starting from 0. There is a chip placed in the n-th cell (the last one). Players take turns, Alice is first. Each player during his or her turn has to move the chip 1, 2 or k cells to the left (so, if the ch...
0
{"tests": "{\"inputs\": [\"5\\n1 2 1 3 6\\n\", \"5\\n3 2 5 4 10\\n\", \"4\\n1 1 1 1\\n\", \"1\\n1000000000\\n\", \"2\\n921 921\\n\", \"2\\n1000000000 1\\n\", \"11\\n3 10 20 13 18 12 6 5 19 10 8\\n\", \"19\\n3 1 16 11 12 10 3 13 12 9 1 9 8 4 19 16 19 3 3\\n\", \"4\\n11 6 1 16\\n\", \"19\\n10 10 8 11 6 1 6 13 8 20 8 14 9...
You went to the store, selling $n$ types of chocolates. There are $a_i$ chocolates of type $i$ in stock. You have unlimited amount of cash (so you are not restricted by any prices) and want to buy as many chocolates as possible. However if you buy $x_i$ chocolates of type $i$ (clearly, $0 \le x_i \le a_i$), then for a...
0
{"tests": "{\"inputs\": [\"5\\n1 2 2 1 3\\n\", \"5\\n1 2 2 1 1\\n\", \"100\\n7 4 5 5 10 10 5 8 5 7 4 5 4 6 8 8 2 6 3 3 10 7 10 8 6 2 7 3 9 7 7 2 4 5 2 4 9 5 10 1 10 5 10 4 1 3 4 2 6 9 9 9 10 6 2 5 6 1 8 10 4 10 3 4 10 5 5 4 10 4 5 3 7 10 2 7 3 6 9 6 1 6 5 5 4 6 6 4 4 1 5 1 6 6 6 8 8 6 2 6\\n\", \"100\\n82 51 81 14 37 1...
One day you wanted to read something, so you went to your bookshelf to grab some book. But when you saw how messy the bookshelf was you decided to clean it up first. There are $n$ books standing in a row on the shelf, the $i$-th book has color $a_i$. You'd like to rearrange the books to make the shelf look beautiful....
0
{"tests": "{\"inputs\": [\"6 1\\n10.245\\n\", \"6 2\\n10.245\\n\", \"3 100\\n9.2\\n\", \"12 5\\n872.04488525\\n\", \"35 8\\n984227318.2031144444444444494637612\\n\", \"320 142\\n2704701300865535.43222331223343411413001111322010242013132301034414420112430314444444444444444444444444444444444444444444444444444444444444444...
Efim just received his grade for the last test. He studies in a special school and his grade can be equal to any positive decimal fraction. First he got disappointed, as he expected a way more pleasant result. Then, he developed a tricky plan. Each second, he can ask his teacher to round the grade at any place after th...
0
{"tests": "{\"inputs\": [[\"Joe had a bad day\"], [\"Joe had some bad days\"], [\"Joe is having no fun\"], [\"Sometimes joe cries for hours\"], [\"Joe is having lots of fun\"], [\"Joe is working hard a lot\"], [\"Joe listened to the noise and it was an onamonapia\"], [\"Joe listened to the noises and there were some on...
KISS stands for Keep It Simple Stupid. It is a design principle for keeping things simple rather than complex. You are the boss of Joe. Joe is submitting words to you to publish to a blog. He likes to complicate things. Define a function that determines if Joe's work is simple or complex. Input will be non emtpy st...
0.875
{"tests": "{\"inputs\": [[[1, 1, 1, 2, 1, 1]], [[0, 0, 0.55, 0, 0]], [[4, 4, 4, 3, 4, 4, 4, 4]], [[5, 5, 5, 5, 4, 5, 5, 5]], [[6, 6, 6, 6, 6, 5, 6, 6]], [[7, 7, 7, 7, 7, 7, 6, 7]], [[8, 8, 8, 8, 8, 8, 8, 7]], [[3, 3, 3, 3, 3, 3, 3, 2]], [[2, 2, 2, 2, 2, 2, 2, 1]], [[0, 1, 1, 1, 1, 1, 1, 1]]], \"outputs\": [[2], [0.55],...
There is an array with some numbers. All numbers are equal except for one. Try to find it! ```python find_uniq([ 1, 1, 1, 2, 1, 1 ]) == 2 find_uniq([ 0, 0, 0.55, 0, 0 ]) == 0.55 ``` It’s guaranteed that array contains at least 3 numbers. The tests contain some very huge arrays, so think about performance. This is t...
0.125
{"tests": "{\"inputs\": [\"2 4\\n\", \"5 3\\n\", \"1 1\\n\", \"1 2\\n\", \"2 1\\n\", \"1000000000 1\\n\", \"1 1000000000\\n\", \"1000000000 1000000000\\n\", \"49464524 956817411\\n\", \"917980664 839933539\\n\", \"491529509 18016963\\n\", \"65078353 196100387\\n\", \"933594493 374183811\\n\", \"1000000000 956817411\\n\...
You are given $a$ uppercase Latin letters 'A' and $b$ letters 'B'. The period of the string is the smallest such positive integer $k$ that $s_i = s_{i~mod~k}$ ($0$-indexed) for each $i$. Note that this implies that $k$ won't always divide $a+b = |s|$. For example, the period of string "ABAABAA" is $3$, the period of ...
0
{"tests": "{\"inputs\": [\"5 1 2 0 1 2\\n\", \"1 1 1 -1 -1 2\\n\", \"1 1 1 1 1 0\\n\", \"2 2 1 -2 -2 5\\n\", \"1000000000 1 1 1 1 1000000000000000000\\n\", \"1000000000 1 2 -100 -100 1\\n\", \"3 2 2 -100 -100 2\\n\", \"1000000000 1000000000 1000000000 100 -100 1000000000000000000\\n\", \"907122235 107269653 309181328 2...
Our bear's forest has a checkered field. The checkered field is an n × n table, the rows are numbered from 1 to n from top to bottom, the columns are numbered from 1 to n from left to right. Let's denote a cell of the field on the intersection of row x and column y by record (x, y). Each cell of the field contains grow...
0
{"tests": "{\"inputs\": [\"2\\n4\\n4 8 9 6\\n6\\n2 1 7 4 0 0\\n\", \"2\\n4\\n8 8 9 6\\n6\\n2 1 7 4 0 0\\n\", \"2\\n4\\n8 8 9 8\\n6\\n2 0 7 4 0 0\\n\", \"2\\n4\\n3 8 14 6\\n6\\n2 1 7 4 0 0\\n\", \"2\\n4\\n3 8 14 6\\n6\\n2 0 7 4 0 0\\n\", \"2\\n4\\n3 8 1 6\\n6\\n2 0 7 4 0 0\\n\", \"2\\n4\\n8 8 9 8\\n6\\n2 1 2 4 0 0\\n\",...
Little Dormi received a histogram with $n$ bars of height $a_1, a_2, \ldots, a_n$ for Christmas. However, the more he played with his new histogram, the more he realized its imperfections, so today he wanted to modify it to his liking. To modify the histogram, Little Dormi is able to perform the following operation an...
0
{"tests": "{\"inputs\": [\"50 4 12\\nto tail\\n00000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000001000100000000000000000000000000000000000000010000000010000000000000000000000000000000000000000001\\n\", \"3 1 3\\nto head\\n1011111111111111101111011011111111011101111111...
A stowaway and a controller play the following game. The train is represented by n wagons which are numbered with positive integers from 1 to n from the head to the tail. The stowaway and the controller are initially in some two different wagons. Every minute the train can be in one of two conditions — moving or idle...
0
{"tests": "{\"inputs\": [\"8 1 10 2 6 4\\n\", \"8 1 10 2 6 5\\n\", \"9 1 10 9 2 9\\n\", \"20 15 25 3 5 7\\n\", \"722593107 305596769 756141045 457450188 53 829308825\\n\", \"999999999999999998 3 999999999999999999 399999999999999999 5 999999999999999996\\n\", \"999999999999999999 1 1000000000000000000 10000000000000000...
In recent years John has very successfully settled at his new job at the office. But John doesn't like to idly sit around while his code is compiling, so he immediately found himself an interesting distraction. The point of his distraction was to maintain a water level in the water cooler used by other zebras. Origina...
0
{"tests": "{\"inputs\": [\"6\\n1 0 1 1 0 1\\n1 2 2 2 2\\n\", \"5\\n1 0 1 0 1\\n1 1 1 1\\n\", \"8\\n1 0 0 1 0 1 1 0\\n1 1 2 2 3 3 3\\n\", \"9\\n1 1 0 0 1 0 1 0 1\\n1 1 2 2 3 3 4 4\\n\", \"100\\n0 1 0 0 1 0 1 0 0 0 0 0 1 0 0 1 1 1 1 0 0 1 0 1 1 0 1 0 0 0 0 1 0 1 1 1 1 0 0 1 0 1 0 0 1 0 0 1 0 0 0 0 0 0 1 0 0 1 0 0 0 0 1 0...
Now Serval is a junior high school student in Japari Middle School, and he is still thrilled on math as before. As a talented boy in mathematics, he likes to play with numbers. This time, he wants to play with numbers on a rooted tree. A tree is a connected graph without cycles. A rooted tree has a special vertex ca...
0
{"tests": "{\"inputs\": [\"syvncqmfhautvxudqdhggz\\nhrpxzeghsocjpicuixskfuzupytsgjsdiyb\\nybcmnmnbpndbxlxbzhbfnqvwcffvrdhtickyqhupmcehls\\n\", \"iefouqzxoyuieqdzalfktehtvdbvjmeubju\\nocotspetkkhvwfgaqynhovjwjhciefouqzxoyuieqdzalfktehtvdbvjmeubjubcmnvpwgdpnchqhzjrchyrfpvigubp\\nycnhjwgbocotspetkkhvwfgaqynhovjwjhcief\\n\...
Sometimes it is hard to prepare tests for programming problems. Now Bob is preparing tests to new problem about strings — input data to his problem is one string. Bob has 3 wrong solutions to this problem. The first gives the wrong answer if the input data contains the substring s1, the second enters an infinite loop i...
0
{"tests": "{\"inputs\": [\"20 17\\n407 2799 2032 2154 8119 9404 6718 7914 916 4720 1267 9403 5497 4518 9072 7828 8364 8230 3057 7770\\n\", \"2 1\\n1 2\\n\", \"1 2\\n10\\n\", \"2 1\\n8 20\\n\", \"5 1\\n1 2 3 4 5\\n\", \"50 25\\n1498786 501094 6396443 1167317 719496 636212 1912961 3111395 9572144 6277130 9288513 7311574 ...
Vasya has found a piece of paper with a coordinate system written on it. There are n distinct squares drawn in this coordinate system. Let's number the squares with integers from 1 to n. It turned out that points with coordinates (0, 0) and (ai, ai) are the opposite corners of the i-th square. Vasya wants to find such...
0
{"tests": "{\"inputs\": [\"3\\n0 2 0\\n3 0 1\\n\", \"3\\n0 2 0\\n1 0 3\\n\", \"11\\n0 0 0 5 0 0 0 4 0 0 11\\n9 2 6 0 8 1 7 0 3 0 10\\n\", \"8\\n0 0 0 0 0 0 0 0\\n7 8 1 2 3 4 5 6\\n\", \"8\\n0 0 0 0 4 5 7 8\\n0 6 0 0 0 1 2 3\\n\", \"8\\n0 0 0 0 0 0 7 8\\n0 1 2 3 4 5 0 6\\n\", \"1\\n1\\n0\\n\", \"1\\n0\\n1\\n\", \"2\\n0 ...
Nauuo is a girl who loves playing cards. One day she was playing cards but found that the cards were mixed with some empty ones. There are $n$ cards numbered from $1$ to $n$, and they were mixed with another $n$ empty cards. She piled up the $2n$ cards and drew $n$ of them. The $n$ cards in Nauuo's hands are given. T...
0
{"tests": "{\"inputs\": [[[1, 1, 5, 6, 9, 16, 27], 4], [[1, 1, 3, 3], 2], [[4, 8, 12, 12, 3, 6, 2], 6], [[1, 2, 3, 4, 5, 6, 7], 7], [[1, 6, 2, 3, 7, 8, 7], 0], [[1, 2, 3, 4], 0], [[1, 1, 1, 1], 0], [[], 3]], \"outputs\": [[3], [4], [3], [0], [1], [0], [6], [0]]}", "source": "taco"}
Write a function that accepts two arguments: an array/list of integers and another integer (`n`). Determine the number of times where two integers in the array have a difference of `n`. For example: ``` [1, 1, 5, 6, 9, 16, 27], n=4 --> 3 # (1,5), (1,5), (5,9) [1, 1, 3, 3], n=2 --> 4 # (1,3), (1,3), ...
0
{"tests": "{\"inputs\": [[[1, 2, 3, 4, 6, 9, 10, 15, 69], 11], [[1, 2, 3, 4, 6, 9, 10, 11, 15, 69], 11], [[1, 2, 3, 4, 6, 9, 10, 11, 15, 29, 69], 11], [[1, 2, 3, 4, 6, 9, 10, 11, 15, 29, 38, 47, 56, 65, 69, 74, 83, 92], 11], [[1, 2, 3, 4, 6, 9, 10, 11, 15, 18, 23, 69], 18], [[1, 2, 3, 4, 6, 9, 10, 15, 69], 34], [[1, 2,...
At the start of each season, every player in a football team is assigned their own unique squad number. Due to superstition or their history certain numbers are more desirable than others. Write a function generateNumber() that takes two arguments, an array of the current squad numbers (squad) and the new player's des...
0
{"tests": "{\"inputs\": [\"(1?1)\\n1 0\\n\", \"(2?(1?2))\\n1 1\\n\", \"((1?(5?7))?((6?2)?7))\\n3 2\\n\", \"((1?(5?7))?((6?2)?7))\\n2 3\\n\", \"((4?3)?(((2?(4?((4?((2?(3?(7?3)))?(((((3?(6?2))?3)?(((((6?6)?(1?5))?((8?8)?1))?(5?((7?((6?((((3?8)?8)?(8?5))?7))?8))?((8?(2?8))?3))))?6))?(8?(7?5)))?8)))?((((7?(4?3))?4)?5)?((1?...
Ancient Egyptians are known to have understood difficult concepts in mathematics. The ancient Egyptian mathematician Ahmes liked to write a kind of arithmetic expressions on papyrus paper which he called as Ahmes arithmetic expression. An Ahmes arithmetic expression can be defined as: "d" is an Ahmes arithmetic expr...
0
{"tests": "{\"inputs\": [\"1 1\\n\", \"1 2\\n\", \"2 1\\n\", \"2 2\\n\", \"2 3\\n\", \"4 1\\n\", \"5 1\\n\", \"5 2\\n\", \"5 3\\n\", \"5 4\\n\", \"5 5\\n\", \"5 6\\n\", \"5 9\\n\", \"5 10\\n\", \"5 11\\n\", \"674098 1358794\\n\", \"3983458 7761504\\n\", \"4841874 9131511\\n\", \"667586 5534221\\n\", \"1526002 6904227\\...
A girl named Xenia has a cupboard that looks like an arc from ahead. The arc is made of a semicircle with radius r (the cupboard's top) and two walls of height h (the cupboard's sides). The cupboard's depth is r, that is, it looks like a rectangle with base r and height h + r from the sides. The figure below shows what...
0
{"tests": "{\"inputs\": [\"100 100 1 1\\n50 0 50 100 50\\n640 480 1 2\\n0 0 640 480 100\\n0 0 0 0\", \"100 100 1 1\\n62 0 50 100 50\\n640 480 1 1\\n0 0 640 480 100\\n0 0 0 0\", \"100 100 1 1\\n50 0 50 100 50\\n640 480 1 2\\n0 0 640 480 110\\n0 0 0 0\", \"100 100 1 1\\n76 0 50 100 50\\n640 480 1 1\\n0 0 640 480 100\\n0 ...
Nathan O. Davis is challenging a kind of shooter game. In this game, enemies emit laser beams from outside of the screen. A laser beam is a straight line with a certain thickness. Nathan moves a circular-shaped machine within the screen, in such a way it does not overlap a laser beam. As in many shooters, the machine i...
0
{"tests": "{\"inputs\": [\"1\\n1\\n1\\n\", \"1\\n1\\n1000000000\\n\", \"5\\n16 2 8 19 4\\n10 9 10 10 10\\n\", \"5\\n12 19 11 13 16\\n14 14 14 14 15\\n\", \"2\\n1 5\\n3 4\\n\", \"5\\n19 9 3 20 2\\n11 11 10 11 10\\n\", \"20\\n53 86 76 100 16 12 13 97 79 23 28 64 42 10 23 56 59 76 48 12\\n48 49 49 49 48 49 48 49 49 49 48 ...
There are n stones arranged on an axis. Initially the i-th stone is located at the coordinate s_i. There may be more than one stone in a single place. You can perform zero or more operations of the following type: * take two stones with indices i and j so that s_i ≤ s_j, choose an integer d (0 ≤ 2 ⋅ d ≤ s_j - s_i)...
0
{"tests": "{\"inputs\": [[1], [5], [10], [20], [40], [41], [80], [26], [0], [499]], \"outputs\": [[0.1], [0.49], [0.97], [1.93], [3.85], [3.95], [7.7], [2.52], [0.0], [48.06]]}", "source": "taco"}
You and your best friend Stripes have just landed your first high school jobs! You'll be delivering newspapers to your neighbourhood on weekends. For your services you'll be charging a set price depending on the quantity of the newspaper bundles. The cost of deliveries is: - $3.85 for 40 newspapers - $1.93 for 20 - $...
0.875
{"tests": "{\"inputs\": [\"10 2 5\\n\", \"21 4 6\\n\", \"1337 7 7\\n\", \"455678451 22 17\\n\", \"21 7 9\\n\", \"51 9 11\\n\", \"302 17 21\\n\", \"3 4 14\\n\", \"2 14 19\\n\", \"58 11 7\\n\", \"65 14 11\\n\", \"31 5 18\\n\", \"59 19 5\\n\", \"98 12 22\\n\", \"181 21 13\\n\", \"18 14 5\\n\", \"25 15 20\\n\", \"97 14 11\...
Let's call the set of positive integers $S$ correct if the following two conditions are met: $S \subseteq \{1, 2, \dots, n\}$; if $a \in S$ and $b \in S$, then $|a-b| \neq x$ and $|a-b| \neq y$. For the given values $n$, $x$, and $y$, you have to find the maximum size of the correct set. -----Input----- A single ...
0
{"tests": "{\"inputs\": [\"3\\n4 1 7\\n\", \"1\\n10\\n\", \"4\\n1 3 5 9\\n\", \"4\\n4 3 4 5\\n\", \"2\\n2 4\\n\", \"4\\n1 3 4 5\\n\", \"2\\n3 3\\n\", \"2\\n13 2\\n\", \"5\\n2 2 2 2 2\\n\", \"6\\n11 1 7 9 5 13\\n\", \"2\\n100000000 1\\n\", \"5\\n2 3 1 4 6\\n\", \"5\\n1 2 2 3 4\\n\", \"3\\n1 4 2\\n\", \"3\\n8 8 8\\n\", \...
Everybody knows what an arithmetic progression is. Let us remind you just in case that an arithmetic progression is such sequence of numbers a_1, a_2, ..., a_{n} of length n, that the following condition fulfills: a_2 - a_1 = a_3 - a_2 = a_4 - a_3 = ... = a_{i} + 1 - a_{i} = ... = a_{n} - a_{n} - 1. For example, seque...
0
{"tests": "{\"inputs\": [\"3\\n0\\n0\\n1000000010\", \"4\\n11\\n5\\n10\\n6\", \"4\\n6\\n5\\n10\\n6\", \"4\\n6\\n5\\n20\\n6\", \"4\\n2\\n5\\n20\\n6\", \"4\\n2\\n5\\n10\\n6\", \"4\\n2\\n5\\n10\\n5\", \"4\\n0\\n5\\n10\\n5\", \"4\\n0\\n7\\n10\\n5\", \"4\\n0\\n7\\n10\\n1\", \"4\\n0\\n7\\n10\\n0\", \"3\\n0\\n0\\n0000000000\"...
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 perform a very large number of calculations to improve the calculation power and raise awareness. Exponentiation is an operation that easily produces large numbers....
0
{"tests": "{\"inputs\": [\"3\\n2 3 3 1 2 1 2 1 3\\n3 2 2 1 1 1 3 3 2\", \"3\\n1 1 1 2 2 2 3 3 3\\n2 1 1 1 2 2 3 3 3\", \"3\\n1 1 1 2 2 2 3 3 3\\n1 1 1 2 3 2 3 3 2\", \"3\\n2 3 3 1 2 1 2 1 3\\n3 2 1 2 1 1 3 3 2\", \"3\\n2 3 1 1 3 2 2 1 3\\n1 2 1 3 1 2 3 2 3\", \"3\\n3 3 1 1 3 2 2 1 2\\n1 1 2 3 2 2 3 1 3\", \"3\\n2 3 3 1...
Given are integer sequences A and B of length 3N. Each of these two sequences contains three copies of each of 1, 2, \dots, N. In other words, A and B are both arrangements of (1, 1, 1, 2, 2, 2, \dots, N, N, N). Tak can perform the following operation to the sequence A arbitrarily many times: * Pick a value from 1, 2...
0
{"tests": "{\"inputs\": [\"4\\n5\\n1 2 2 1 3\\n3\\n1 1 1\\n4\\n1 1000 101 1000\\n4\\n1 2 3 4\\n\", \"1\\n5\\n6756657 32231 86 234 23442\\n\", \"1\\n2\\n7 7\\n\", \"1\\n2\\n7 7\\n\", \"1\\n5\\n6756657 32231 86 234 23442\\n\", \"4\\n5\\n1 2 2 1 3\\n3\\n1 1 1\\n4\\n1 1000 101 1000\\n4\\n1 2 3 4\\n\", \"1\\n2\\n11 7\\n\", ...
There are $n$ districts in the town, the $i$-th district belongs to the $a_i$-th bandit gang. Initially, no districts are connected to each other. You are the mayor of the city and want to build $n-1$ two-way roads to connect all districts (two districts can be connected directly or through other connected districts)....
0
{"tests": "{\"inputs\": [\"3\\n101\\n3 3\\n3 2\\n3 1\\n\", \"4\\n1111\\n3 4\\n5 2\\n3 1\\n3 2\\n\", \"6\\n011100\\n5 3\\n5 5\\n2 4\\n3 5\\n4 2\\n1 5\\n\", \"1\\n0\\n1 5\\n\", \"20\\n00101101001100000010\\n1 1\\n5 3\\n3 3\\n4 5\\n1 4\\n5 2\\n4 2\\n4 4\\n5 1\\n1 1\\n5 3\\n2 4\\n2 4\\n1 2\\n2 3\\n1 4\\n1 5\\n1 3\\n3 4\\n4...
It is a holiday season, and Koala is decorating his house with cool lights! He owns $n$ lights, all of which flash periodically. After taking a quick glance at them, Koala realizes that each of his lights can be described with two parameters $a_i$ and $b_i$. Light with parameters $a_i$ and $b_i$ will toggle (on to off...
0
{"tests": "{\"inputs\": [\"27 29\\n12 11\\n21 20\\n19 26\\n16 24\\n22 4\\n1 3\\n23 5\\n9 1\\n4 3\\n21 23\\n22 8\\n14 6\\n25 13\\n7 20\\n9 16\\n3 20\\n23 19\\n17 10\\n13 18\\n8 14\\n23 25\\n25 27\\n19 15\\n19 15\\n17 24\\n12 27\\n18 11\\n25 5\\n22 17\\n\", \"15 29\\n6 11\\n14 3\\n10 4\\n14 7\\n6 14\\n7 15\\n13 8\\n10 13...
A ski base is planned to be built in Walrusland. Recently, however, the project is still in the constructing phase. A large land lot was chosen for the construction. It contains n ski junctions, numbered from 1 to n. Initially the junctions aren't connected in any way. In the constructing process m bidirectional ski r...
0.75
{"tests": "{\"inputs\": [[0], [1], [5], [43], [91], [101], [239]], \"outputs\": [[{}], [{\"P\": 1}], [{\"N\": 1}], [{\"Q\": 1, \"D\": 1, \"N\": 1, \"P\": 3}], [{\"H\": 1, \"Q\": 1, \"D\": 1, \"N\": 1, \"P\": 1}], [{\"H\": 2, \"P\": 1}], [{\"H\": 4, \"Q\": 1, \"D\": 1, \"P\": 4}]]}", "source": "taco"}
# Making Change Complete the method that will determine the minimum number of coins needed to make change for a given amount in American currency. Coins used will be half-dollars, quarters, dimes, nickels, and pennies, worth 50¢, 25¢, 10¢, 5¢ and 1¢, respectively. They'll be represented by the symbols `H`, `Q`, `D`, ...
0
{"tests": "{\"inputs\": [\"3 5\\n..+.#\\n#+..+\\n+.#+.\\n\", \"4 10\\n...+.##+.+\\n+#++..+++#\\n++.#++++..\\n.+##.++#.+\\n\", \"2 2\\n..\\n++\\n\", \"5 1\\n.\\n.\\n.\\n.\\n.\\n\", \"20 20\\n..+#+.+++.+++#+..#++\\n..####+++#..++#+.+.+\\n+.+..+++..#.++++++++\\n+##++..+.##..#+++.++\\n++.+.+.+.++++.+++.++\\n.+++++.+#+++++....
Joe has been hurt on the Internet. Now he is storming around the house, destroying everything in his path. Joe's house has n floors, each floor is a segment of m cells. Each cell either contains nothing (it is an empty cell), or has a brick or a concrete wall (always something one of three). It is believed that each f...
0
{"tests": "{\"inputs\": [[0], [3], [16], [32], [49], [89], [327], [363], [366], [512], [656], [1038], [1052], [1222], [1235], [1302], [1735], [1757], [1974], [2048]], \"outputs\": [[0], [7], [171], [683], [1215], [3715], [52239], [60195], [62063], [174763], [209095], [699451], [700379], [757295], [762019], [832559], [1...
Introduction It's been more than 20 minutes since the negligent waiter has taken your order for the house special prime tofu steak with a side of chili fries. Out of boredom, you start fiddling around with the condiments tray. To be efficient, you want to be familiar with the choice of sauces and spices before your o...
0
{"tests": "{\"inputs\": [\"aaaccabcbc\\nabcbabbbaa\\n\", \"nclmevhtio\\nefnepwqphvwxiyguotuk\\n\", \"zkccmpbrfadhkukfvkci\\nfopwpsbztb\\n\", \"abbbaabbba\\nbaaaababbb\\n\", \"aaaccabcbc\\nacbbabbbaa\\n\", \"nclmevhtio\\nefneowqphvwxiyguotuk\\n\", \"zkcbmpbrfadhkukfvkci\\nfopwpsbztb\\n\", \"abbbaabbba\\nbbaaababbb\\n\",...
You are given two strings x and y, both consist only of lowercase Latin letters. Let |s| be the length of string s. Let's call a sequence a a merging sequence if it consists of exactly |x| zeros and exactly |y| ones in some order. A merge z is produced from a sequence a by the following rules: * if a_i=0, then re...
0
{"tests": "{\"inputs\": [\"||+|=|||||\\n\", \"|||||+||=||\\n\", \"|+|=||||||\\n\", \"||||+||=||||||\\n\", \"||||||||||||+|||||||||||=||||||||||||||||||||||\\n\", \"||||||||||||||||||+||||||||||||||||||=||||||||||||||||||||||||||||||||||||||||||\\n\", \"|||||||||||||||||||||||||||||||||||||||||||||||||+|||||||||||||||||...
When new students come to the Specialized Educational and Scientific Centre (SESC) they need to start many things from the beginning. Sometimes the teachers say (not always unfairly) that we cannot even count. So our teachers decided to teach us arithmetics from the start. And what is the best way to teach students add...
0
{"tests": "{\"inputs\": [\"-957757861 308710346 45337024\\n\", \"1 2000000000 -1\\n\", \"999999999 -1000000000 500000000\\n\", \"427055698 738296578 -52640953\\n\", \"592707810 829317963 -753392742\\n\", \"-1548994394 -1586527767 -1203252104\\n\", \"1000000013 -1 135\\n\", \"546348890 -29226055 -341135185\\n\", \"70140...
A line on the plane is described by an equation Ax + By + C = 0. You are to find any point on this line, whose coordinates are integer numbers from - 5·1018 to 5·1018 inclusive, or to find out that such points do not exist. Input The first line contains three integers A, B and C ( - 2·109 ≤ A, B, C ≤ 2·109) — corres...
0.375
{"tests": "{\"inputs\": [\"1 1 1\\n\", \"3 1 4\\n\", \"1000 123456 654321\\n\", \"305 337309 378395\\n\", \"108 531040 908573\\n\", \"575 39377 68346\\n\", \"66 199449 266025\\n\", \"781 817338 452871\\n\", \"99 534023 117289\\n\", \"156 78149 46740\\n\", \"57 339480 774350\\n\", \"270 967166 795005\\n\", \"628 446579 ...
You are given three integers k, p_{a} and p_{b}. You will construct a sequence with the following algorithm: Initially, start with the empty sequence. Each second, you do the following. With probability p_{a} / (p_{a} + p_{b}), add 'a' to the end of the sequence. Otherwise (with probability p_{b} / (p_{a} + p_{b})), a...
0
{"tests": "{\"inputs\": [\"3 6 3\\n2 1 3\\n1 2 3 1 2 3\\n1 5\\n2 6\\n3 5\\n\", \"2 4 3\\n2 1\\n1 1 2 2\\n1 2\\n2 3\\n3 4\\n\", \"1 1 1\\n1\\n1\\n1 1\\n\", \"1 1 1\\n1\\n1\\n1 1\\n\", \"2 4 3\\n2 1\\n1 1 2 2\\n2 2\\n2 3\\n3 4\\n\", \"3 6 3\\n2 1 3\\n1 1 3 1 2 3\\n1 5\\n2 6\\n3 5\\n\", \"3 6 3\\n2 1 3\\n1 2 3 1 2 3\\n1 5...
Recently Lynyrd and Skynyrd went to a shop where Lynyrd bought a permutation $p$ of length $n$, and Skynyrd bought an array $a$ of length $m$, consisting of integers from $1$ to $n$. Lynyrd and Skynyrd became bored, so they asked you $q$ queries, each of which has the following form: "does the subsegment of $a$ from ...
0.5
{"tests": "{\"inputs\": [[\"abcdefg\", \"abcqetg\"], [\"Hello World!\", \"hello world.\"], [\"FixedGrey\", \"FixedGrey\"], [\"HACKER\", \"H4CK3R\"], [\"This is a really long sentence.\", \"That is a_really long sentence,\"], [\"\", \"\"], [\"abcdefghijklmnopqrstuvwxyz\", \"zyxwvutsrqponmlkjihgfedcba\"], [\"YOLO lol\", ...
This kata is part of the collection [Mary's Puzzle Books](https://www.codewars.com/collections/marys-puzzle-books). Mary brought home a "spot the differences" book. The book is full of a bunch of problems, and each problem consists of two strings that are similar. However, in each string there are a few characters tha...
0