info stringlengths 120 50k | question stringlengths 504 10.4k | avg@8_qwen3_4b_instruct_2507 float64 0 0.88 |
|---|---|---|
{"tests": "{\"inputs\": [\"5\\n1 1\\n1 3\\n2 2\\n3 3\\n5 3\\n\", \"2\\n1329 2007\\n179 57\\n\", \"2\\n1329 2007\\n118 57\\n\", \"5\\n2 1\\n1 3\\n2 2\\n3 3\\n5 3\\n\", \"2\\n1329 2465\\n118 57\\n\", \"5\\n2 1\\n1 3\\n2 2\\n1 3\\n5 3\\n\", \"2\\n152 2465\\n118 57\\n\", \"5\\n4 1\\n1 3\\n2 2\\n1 3\\n5 3\\n\", \"2\\n152 33... | Due to the coronavirus pandemic, city authorities obligated citizens to keep a social distance. The mayor of the city Semyon wants to light up Gluharniki park so that people could see each other even at night to keep the social distance.
The park is a rectangular table with n rows and m columns, where the cells of the... | 0.625 |
{"tests": "{\"inputs\": [\"abcdd\\n\", \"abbcdddeaaffdfouurtytwoo\\n\", \"nnnnnnnnnnnnnnnnaaag\\n\", \"arexjrujgilmbbao\\n\", \"gggggggggggggglllll\\n\", \"bbccccbbbccccbbbccccbbbcccca\\n\", \"iiiiiitttttyyyyyyyyp\\n\", \"yaryoznawafbayjwkfl\\n\", \"hhgxwyrjemygfgs\\n\", \"rrrccccccyyyyyyyyyyf\\n\", \"nnnnnnwwwwwwxll\\... | Some time ago Lesha found an entertaining string s consisting of lowercase English letters. Lesha immediately developed an unique algorithm for this string and shared it with you. The algorithm is as follows.
Lesha chooses an arbitrary (possibly zero) number of pairs on positions (i, i + 1) in such a way that the foll... | 0 |
{"tests": "{\"inputs\": [\"1\\n4\\n4 3 2 1\\n\", \"3\\n3 2 1\\n4 3 5\\n6 1\\n2\\n\", \"2\\n35 7\\n6 8 35 9 28 25 10 41 33 39 19 24 5 12 30 40 18 2 4 11 32 13 31 21 14 27 3 34 37 16 17 29 1 42 36\\n20 23 38 15 26 7 22\\n\", \"3\\n36 28 14\\n46 15 35 60 41 65 73 33 18 20 68 22 28 23 67 44 2 24 21 51 37 3 48 69 12 50 32 7... | You've got table a, consisting of n rows, numbered from 1 to n. The i-th line of table a contains ci cells, at that for all i (1 < i ≤ n) holds ci ≤ ci - 1.
Let's denote s as the total number of cells of table a, that is, <image>. We know that each cell of the table contains a single integer from 1 to s, at that all ... | 0.25 |
{"tests": "{\"inputs\": [\"2 1\\n\", \"4 1\\n\", \"7 4\\n\", \"1 0\\n\", \"3 2\\n\", \"10 3\\n\", \"7 7\\n\", \"999 300\\n\", \"1000 999\\n\", \"10 0\\n\", \"5 4\\n\", \"1000 900\\n\", \"999 600\\n\", \"1000 998\\n\", \"999 998\\n\", \"999 989\\n\", \"4 2\\n\", \"8 4\\n\", \"3 0\\n\", \"2 2\\n\", \"999 13\\n\", \"999 1... | Permutation p is an ordered set of integers p1, p2, ..., pn, consisting of n distinct positive integers, each of them doesn't exceed n. We'll denote the i-th element of permutation p as pi. We'll call number n the size or the length of permutation p1, p2, ..., pn.
We'll call position i (1 ≤ i ≤ n) in permutation p1, p... | 0 |
{"tests": "{\"inputs\": [\"2 100 10\\n100 11\\n90 9\\n\", \"2 10 3\\n100 3\\n99 1\\n\", \"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\\n1... | 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\": [\"1000000\\n\", \"23\\n\", \"15\\n\", \"12\\n\", \"738457\\n\", \"46220\\n\", \"59\\n\", \"58134\\n\", \"19\\n\", \"192\\n\", \"999987\\n\", \"58113\\n\", \"14568\\n\", \"13\\n\", \"21\\n\", \"22\\n\", \"999999\\n\", \"765\\n\", \"100007\\n\", \"57114\\n\", \"74752\\n\", \"1289\\n\", \"869\\n\"... | One way to create a task is to learn from math. You can generate some random math statement or modify some theorems to get something new and build a new task from that.
For example, there is a statement called the "Goldbach's conjecture". It says: "each even number no less than four can be expressed as the sum of two ... | 0 |
{"tests": "{\"inputs\": [\"1023\\n1 2\\n1 0\\n1 2\\n1 1\\n\", \"5\\n4 2\\n1 1\\n0 1\\n2 3\\n\", \"999983\\n1 37827\\n1 1\\n2 192083\\n3 0\\n\", \"999983\\n420528 808305\\n387096 497121\\n596163 353326\\n47177 758204\\n\", \"3\\n0 2\\n1 0\\n2 0\\n2 1\\n\", \"999961\\n744938 661980\\n845908 76370\\n237399 381935\\n418010... | Mike has a frog and a flower. His frog is named Xaniar and his flower is named Abol. Initially(at time 0), height of Xaniar is h1 and height of Abol is h2. Each second, Mike waters Abol and Xaniar.
<image>
So, if height of Xaniar is h1 and height of Abol is h2, after one second height of Xaniar will become <image> an... | 0 |
{"tests": "{\"inputs\": [\"1 3\\n1 1 0 1 0 0\\n\", \"2 2\\n0 0 0 1\\n1 0 1 1\\n\", \"1 1\\n0 0\\n\", \"1 1\\n0 1\\n\", \"1 100\\n0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0... | One day Vitaly was going home late at night and wondering: how many people aren't sleeping at that moment? To estimate, Vitaly decided to look which windows are lit in the house he was passing by at that moment.
Vitaly sees a building of n floors and 2·m windows on each floor. On each floor there are m flats numbered ... | 0 |
{"tests": "{\"inputs\": [\"5\\n1 2 3 4 5\\n\", \"7\\n4 4 4 4 7 7 7\\n\", \"3\\n2 2 3\\n\", \"4\\n2 3 3 4\\n\", \"91\\n4 6 23 23 23 23 23 28 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 47 47 47 54 54 54 54 54 54 54 58 58 58 58 58 58 69 69 69 69 69 69 69 69 69 69 69 69 70 70 70 70 70 70 70 70 70 70 ... | Recently, Mike was very busy with studying for exams and contests. Now he is going to chill a bit by doing some sight seeing in the city.
City consists of n intersections numbered from 1 to n. Mike starts walking from his house located at the intersection number 1 and goes along some sequence of intersections. Walking... | 0.25 |
{"tests": "{\"inputs\": [\"3\\n123\\n321\\n\", \"2\\n88\\n00\\n\", \"9\\n777777777\\n777777777\\n\", \"5\\n11222\\n22111\\n\", \"10\\n8104381743\\n8104381743\\n\", \"8\\n88888888\\n98769876\\n\", \"3\\n112\\n111\\n\", \"9\\n353589343\\n280419388\\n\", \"1\\n4\\n5\\n\", \"100\\n631749422082281871941140403034638286979613... | After the fourth season Sherlock and Moriary have realized the whole foolishness of the battle between them and decided to continue their competitions in peaceful game of Credit Cards.
Rules of this game are simple: each player bring his favourite n-digit credit card. Then both players name the digits written on their... | 0.125 |
{"tests": "{\"inputs\": [\"107 109\\n\", \"0 10\\n\", \"2 4\\n\", \"1 3\\n\", \"998244355 998244359\\n\", \"1 22\\n\", \"1230 1232\\n\", \"0 0\\n\", \"0 4\\n\", \"1000000000000000000 1000000000000000000\\n\", \"0 11\\n\", \"101 1002\\n\", \"2 3\\n\", \"0 100000000000\\n\", \"6 19\\n\", \"24 25\\n\", \"12 23\\n\", \"419... | Even if the world is full of counterfeits, I still regard it as wonderful.
Pile up herbs and incense, and arise again from the flames and ashes of its predecessor — as is known to many, the phoenix does it like this.
The phoenix has a rather long lifespan, and reincarnates itself once every a! years. Here a! denotes ... | 0.5 |
{"tests": "{\"inputs\": [\"4\\n170 30 150 10\\n\", \"3\\n100 100 160\\n\", \"4\\n90 90 90 90\\n\", \"1\\n360\\n\", \"4\\n70 80 110 100\\n\", \"8\\n10 10 70 70 90 90 10 10\\n\", \"5\\n211 113 25 9 2\\n\", \"9\\n40 20 20 20 20 20 20 40 160\\n\", \"130\\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ... | Students Vasya and Petya are studying at the BSU (Byteland State University). At one of the breaks they decided to order a pizza. In this problem pizza is a circle of some radius. The pizza was delivered already cut into n pieces. The i-th piece is a sector of angle equal to ai. Vasya and Petya want to divide all piece... | 0.625 |
{"tests": "{\"inputs\": [\"1000000007\\n\", \"2018\\n\", \"2000000000\\n\", \"10000000000\\n\", \"2148437504\\n\", \"2190530369\\n\", \"1024000007\\n\", \"3758096389\\n\", \"8589942369\\n\", \"5159780354\\n\", \"2684354990\\n\", \"134217734\\n\", \"8707129352\\n\", \"1160290644\\n\", \"145746783\\n\", \"8719074755\\n\"... | Vasya is a regular participant at programming contests and is already experienced in finding important sentences in long statements. Of course, numbers constraints are important — factorization of a number less than 1000000 is easier than of a number less than 1000000000. However, sometimes it's hard to understand the ... | 0 |
{"tests": "{\"inputs\": [\"lov3333333asdafajfgnkdfn33333e\\n\\nSAMPLE\", \"eeflaegzqpdlxswgunhnlglqhycorbcwdfhclmcrwekkzsvoosmfblljeenwfjyoifcvxihhhbeyhmhlkvtsekeglaovjnsi\", \"evol\", \"lov\", \"lovvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvve\", \"isnjvoalgekestvklhmhyebhhhixvcfioyjfwneejllbfmsoov... | After minting loads of money from innocent people by using the psychic powers (As we saw in the previous question!) - little Jhool managed to woo his girlfriend big Jhool! And now, he's in love - madly, madly in love with his girlfriend.
But the road to love is not easy as they say, little Jhool and big Jhool live in... | 0.625 |
{"tests": "{\"inputs\": [\"6\\nvinay\\nvainy\\nvinit\\nviint\\navinash\\naasivnh\\n\\nSAMPLE\", \"24\\nabcd\\nabdc\\nacbd\\nacdb\\nadbc\\nadcb\\nbacd\\nbadc\\nbcad\\nbcda\\nbdac\\nbdca\\ncabd\\ncadb\\ncbad\\ncbda\\ncdab\\ncdba\\ndabc\\ndacb\\ndbac\\ndbca\\ndcab\\ndcba\", \"24\\nabcd\\nabdc\\nacbd\\nacdb\\nadbc\\nadcb\\... | See Russian Translation
It's a fine sunny afternoon today in California. Looking at the pleasant weather, Sumit is all ready to go out and play with his friend Rohil. Unfortunately, Rohil is down with fever. Seeing that his friend is ill, Sumit decides not to go out - instead play with Rohil inside the house. Sumit lo... | 0.25 |
{"tests": "{\"inputs\": [\"9\\n1 2\\n2 3\\n4 2\\n1 7\\n6 1\\n2 5\\n5 9\\n6 8\", \"6\\n1 6\\n2 1\\n5 2\\n3 4\\n2 3\", \"19\\n2 4\\n15 8\\n1 16\\n1 3\\n12 19\\n1 18\\n7 11\\n11 15\\n12 9\\n1 6\\n7 14\\n18 2\\n13 12\\n13 5\\n16 13\\n7 1\\n11 10\\n7 17\", \"3\\n1 2\\n2 3\", \"6\\n1 6\\n2 1\\n5 1\\n3 4\\n2 3\", \"19\\n2 4\\... | We have a tree G with N vertices numbered 1 to N. The i-th edge of G connects Vertex a_i and Vertex b_i.
Consider adding zero or more edges in G, and let H be the graph resulted.
Find the number of graphs H that satisfy the following conditions, modulo 998244353.
* H does not contain self-loops or multiple edges.
* ... | 0 |
{"tests": "{\"inputs\": [\"4\\n337 780 799 10 796 875 331 223 941 67 148 483 390 565 116 355\", \"2\\n1 1 1 1\", \"2\\n1 2 1 2\", \"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... | 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\": [\"3\\n1 -1 1\\n2 2\\n2 2\", \"3\\n-1 0 2\\n1 1\\n2\", \"5\\n0 1 3 6 10\\n3 10\\n2 3 4\", \"3\\n1 0 1\\n2 2\\n2 2\", \"5\\n0 1 3 6 17\\n3 10\\n2 3 4\", \"3\\n2 0 1\\n2 2\\n2 2\", \"5\\n0 1 3 6 17\\n3 10\\n3 3 4\", \"5\\n0 1 3 6 17\\n3 1\\n3 3 4\", \"3\\n1 -1 1\\n2 3\\n2 2\", \"3\\n0 0 2\\n1 1\\n... | There are N rabbits on a number line. The rabbits are conveniently numbered 1 through N. The coordinate of the initial position of rabbit i is x_i.
The rabbits will now take exercise on the number line, by performing sets described below. A set consists of M jumps. The j-th jump of a set is performed by rabbit a_j (2≤... | 0 |
{"tests": "{\"inputs\": [\"3649596966777\\n6358665788577\\n9118992346175\\n9643871425498\\n7755542764533\\n1133557799246\", \"3649596966777\\n4672433573317\\n9118992346175\\n9643871425498\\n7755542764533\\n1133557799246\", \"3649596966777\\n7685559208632\\n9118992346175\\n9643871425498\\n7755542764533\\n1133557799246\"... | There is a puzzle to complete by combining 14 numbers from 1 to 9. Complete by adding another number to the given 13 numbers.
The conditions for completing the puzzle are
* You must have one combination of the same numbers.
* The remaining 12 numbers are 4 combinations of 3 numbers.
The combination of three numbers i... | 0 |
{"tests": "{\"inputs\": [\"3 3\", \"-3 3\", \"-4 3\", \"3 0\", \"-6 3\", \"0 0\", \"-2 3\", \"5 0\", \"-1 3\", \"-12 3\", \"1 0\", \"-2 1\", \"-15 3\", \"-4 1\", \"-23 3\", \"0 1\", \"-4 0\", \"-5 3\", \"0 2\", \"-6 1\", \"-2 5\", \"0 4\", \"-9 1\", \"-2 8\", \"1 2\", \"-9 2\", \"-3 8\", \"1 3\", \"-9 3\", \"-3 7\", \"... | The appearance of the sun is called "sunrise" and the hiding is called "sunset". What is the exact time when the sun is on the horizon?
As shown in the figure below, we will represent the sun as a circle and the horizon as a straight line. At this time, the time of "sunrise" and "sunset" of the sun is the moment when ... | 0.375 |
{"tests": "{\"inputs\": [\"1 1\\n180 90 2\\n1 1\\n180 180 20\\n2 10\\n360 -360 5\\n-90 360 8\\n3 2\\n100 60 9\\n-72 -72 10\\n-45 -225 5\\n0 0\", \"1 1\\n180 90 2\\n1 1\\n180 180 20\\n2 10\\n360 -360 5\\n-9 360 8\\n3 2\\n100 60 9\\n-72 -72 10\\n-45 -225 5\\n0 0\", \"1 1\\n180 90 2\\n1 1\\n180 180 20\\n2 13\\n360 -360 5\... | International Car Production Company (ICPC), one of the largest automobile manufacturers in the world, is now developing a new vehicle called "Two-Wheel Buggy". As its name suggests, the vehicle has only two wheels. Quite simply, "Two-Wheel Buggy" is made up of two wheels (the left wheel and the right wheel) and a axle... | 0 |
{"tests": "{\"inputs\": [\"7 8 4000\\n0 1 1\\n1 0 1\\n1 2 2\\n2 3 2\\n3 4 2\\n5 4 3\\n3 5 4\\n5 6 5\", \"2 0 1\", \"3 9 89\\n2 0 2\\n1 0 3\\n2 0 1\\n2 0 3\\n0 1 1\\n0 1 2\\n1 2 3\\n0 1 1\\n1 0 2\", \"2 0 2\", \"3 9 89\\n2 0 2\\n1 0 3\\n2 1 1\\n2 0 3\\n0 1 1\\n0 1 2\\n1 2 3\\n0 1 1\\n1 0 2\", \"7 8 4000\\n0 1 1\\n1 0 1\... | The University of Aizu Elementary School (Aizu University and Small) is famous as one of Japan's leading competition programmer training schools. Of course, it is essential to practice the algorithm even when attending an athletic meet. Of course you, the director of the competitive programming department, want to win ... | 0 |
{"tests": "{\"inputs\": [\"b1/1b\\n1 1 1 2\\nb5/bbbbbb\\n2 4 1 4\\nb2b2b/7\\n1 4 2 4\\n#\", \"b1/1b\\n1 1 1 2\\nb5/bbbbbb\\n2 4 1 4\\nb2b2b/7\\n1 4 2 6\\n#\", \"b1/1b\\n1 1 1 2\\nb5/bbbbbb\\n2 4 1 5\\nb2b2b/7\\n1 4 2 4\\n#\", \"b1/1b\\n1 1 1 2\\nb5/bbbbbb\\n2 4 1 4\\nb2b2b/7\\n1 4 1 4\\n#\", \"b1/1b\\n1 1 1 2\\nb5/bbbb... | jfen
There is a one-person game to play on the H × W board. This game is a game to move 0 or 1 balls in each cell. You were playing this game and found it difficult to move the ball accurately from cell to cell because the ball is so round. So you decided to make a robot that would move the ball as instructed. Here, t... | 0 |
{"tests": "{\"inputs\": [\"1 1 1\\n1 1\", \"5 10 3\\n3 9\\n2 8\\n5 1\", \"10 10 1\\n6 6\", \"5 10 3\\n3 9\\n2 8\\n2 1\", \"8 10 1\\n6 6\", \"5 10 3\\n3 9\\n2 8\\n1 1\", \"10 10 3\\n3 9\\n2 8\\n1 1\", \"5 10 3\\n1 9\\n2 8\\n5 1\", \"10 10 1\\n6 2\", \"13 10 3\\n3 9\\n2 6\\n1 1\", \"5 19 3\\n2 9\\n2 8\\n1 1\", \"26 10 3\... | Problem
There are $ N $ streetlights on a two-dimensional square of $ W \ times H $.
Gaccho wants to start with $ (1,1) $ and go to $ (W, H) $.
Gaccho is afraid of dark places, so he only wants to walk in the squares that are brightened by the streetlights.
Initially, all streetlights only brighten the squares with th... | 0 |
{"tests": "{\"inputs\": [\"3\\n<<>>\\n><\\n<>>>\", \"3\\n<<>>\\n<>\\n<>>>\", \"3\\n><<>\\n<>\\n<>>>\", \"3\\n><<>\\n><\\n<>>>\", \"3\\n<<>>\\n><\\n<>>?\", \"3\\n><<>\\n<>\\n><>?\", \"3\\n><<>\\n><\\n>><>\", \"3\\n<<>>\\n<>\\n>>><\", \"3\\n<<>>\\n><\\n>>><\", \"3\\n<>><\\n<>\\n>>><\", \"3\\n<>><\\n<>\\n<>>?\", \"3\\n<>>... | Lira is now very keen on compiler development. :)
She knows that one of the most important components of a compiler, is its parser.
A parser is, in simple terms, a software component that processes text, and checks it's semantic correctness, or, if you prefer, if the text is properly built.
As an example, in declaring... | 0.625 |
{"tests": "{\"inputs\": [\"5 1\\n5 4 2 4 5\\n2\\n5\\n\", \"3 3\\n1 2 3\\n1 2 3\\n9\\n\", \"100 1\\n1525 1915 925 1023 803 904 802 1943 954 23 258 505 972 571 1291 1024 161 461 1020 880 67 1975 1612 1599 1024 682 1810 500 1068 1992 1834 79 476 842 1366 17 1307 1595 587 367 1961 1018 960 1699 1799 1453 1890 1003 780 601 ... | You are given two arrays a and b of positive integers, with length n and m respectively.
Let c be an n × m matrix, where c_{i,j} = a_i ⋅ b_j.
You need to find a subrectangle of the matrix c such that the sum of its elements is at most x, and its area (the total number of elements) is the largest possible.
Formally... | 0.375 |
{"tests": "{\"inputs\": [\"3\\n10 4 5 2\\n5 1 3 4\\n20 4 19 3\\n\", \"1\\n123 123 123 123\\n\", \"1\\n1000000000 5 999999999 1\\n\", \"1\\n1000000000 1 1000000000 2\\n\", \"5\\n20 10 2 9\\n1000000000 2 89 4\\n1000000000 2 89 8\\n1000000000 89 1 1000000000\\n1000000000 1000000000 2 3\\n\", \"1\\n1010 1010 1010 1010\\n\"... | Vasya is reading a e-book. The file of the book consists of n pages, numbered from 1 to n. The screen is currently displaying the contents of page x, and Vasya wants to read the page y. There are two buttons on the book which allow Vasya to scroll d pages forwards or backwards (but he cannot scroll outside the book). F... | 0 |
{"tests": "{\"inputs\": [\"3 0\\nPasha\\nLesha\\nVanya\\n\", \"3 1\\nPetya\\nVasya\\nMasha\\nPetya Vasya\\n\", \"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\\... | 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.75 |
{"tests": "{\"inputs\": [\"2\\n-3 1\\n1 3 5 7 9 11\\n1000000000 1000000000\\n1000000000 1000000000 1000000000 1000000000 1000000000 1000000000\\n\", \"1\\n-1000000000 -1000000000\\n10000 20000 30000 40000 50000 60000\\n\", \"1\\n0 0\\n1 2 3 4 5 6\\n\", \"1\\n-1000000000 -1000000000\\n10000 20000 30000 40000 81069 60000... | Lindsey Buckingham told Stevie Nicks ["Go your own way"](https://www.youtube.com/watch?v=6ul-cZyuYq4). Nicks is now sad and wants to go away as quickly as possible, but she lives in a 2D hexagonal world.
Consider a hexagonal tiling of the plane as on the picture below.
<image>
Nicks wishes to go from the cell marked... | 0 |
{"tests": "{\"inputs\": [\"3\\n2 3 4\\n2 2\\n2 3 4\\n3 2\\n2 4 3\\n3 2\\n\", \"1\\n2 4 2\\n999999 1000000\\n\", \"1\\n2 1000000000 1\\n999999 1000000\\n\", \"1\\n3 1000000000 1\\n1000000 1000000 1000000\\n\", \"4\\n2 3 1\\n999999 1000000\\n2 3 2\\n999999 1000000\\n2 3 1\\n1000000 999999\\n2 3 1\\n100 1000000\\n\", \"1\... | There is a graph of n rows and 10^6 + 2 columns, where rows are numbered from 1 to n and columns from 0 to 10^6 + 1:
<image>
Let's denote the node in the row i and column j by (i, j).
Initially for each i the i-th row has exactly one obstacle — at node (i, a_i). You want to move some obstacles so that you can reach ... | 0 |
{"tests": "{\"inputs\": [\"5\\n0 11 12 13 14\\n\", \"3\\n1 2 3\\n\", \"4\\n0 4 0 4\\n\", \"1\\n100000\\n\", \"3\\n0 0 3\\n\", \"1\\n100010\\n\", \"5\\n0 11 1 13 14\\n\", \"5\\n0 12 1 13 14\\n\", \"3\\n0 3 3\\n\", \"3\\n0 1 2\\n\", \"4\\n2 1 0 1\\n\", \"4\\n0 6 0 6\\n\", \"4\\n4 0 0 0\\n\", \"5\\n1 3 0 13 48\\n\", \"5\\... | An array is called beautiful if all the elements in the array are equal.
You can transform an array using the following steps any number of times:
1. Choose two indices i and j (1 ≤ i,j ≤ n), and an integer x (1 ≤ x ≤ a_i). Let i be the source index and j be the sink index.
2. Decrease the i-th element by x, an... | 0 |
{"tests": "{\"inputs\": [\"6\\n1 0\\n0 3\\n1 8\\n0 2\\n0 3\\n0 0\\n\", \"3\\n1 3\\n1 2\\n0 5\\n\", \"20\\n0 569\\n1 328\\n1 74\\n1 88\\n1 90\\n1 124\\n0 78\\n0 39\\n1 9\\n1 59\\n1 41\\n1 73\\n1 45\\n0 45\\n0 13\\n1 39\\n0 24\\n0 37\\n0 95\\n0 70\\n\", \"50\\n1 574339\\n0 409333\\n0 330634\\n0 420557\\n0 323095\\n0 6339... | The board has got a painted tree graph, consisting of n nodes. Let us remind you that a non-directed graph is called a tree if it is connected and doesn't contain any cycles.
Each node of the graph is painted black or white in such a manner that there aren't two nodes of the same color, connected by an edge. Each edge... | 0 |
{"tests": "{\"inputs\": [\"7\\n4 7\\n5 0\\n0 0\\n6 1\\n0 2\\n0 4\\n1 0\\n\", \"100\\n0 0\\n0 0\\n0 0\\n0 0\\n0 0\\n0 0\\n0 0\\n0 0\\n0 0\\n0 0\\n0 0\\n0 0\\n0 0\\n0 0\\n0 0\\n0 0\\n0 0\\n0 0\\n0 0\\n0 0\\n0 0\\n0 0\\n0 0\\n0 0\\n0 0\\n0 0\\n0 0\\n0 0\\n0 0\\n0 0\\n0 0\\n0 0\\n0 0\\n0 0\\n0 0\\n0 0\\n0 0\\n0 0\\n0 0\\n0... | Doubly linked list is one of the fundamental data structures. A doubly linked list is a sequence of elements, each containing information about the previous and the next elements of the list. In this problem all lists have linear structure. I.e. each element except the first has exactly one previous element, each eleme... | 0.5 |
{"tests": "{\"inputs\": [\"4940\\n5000\\n\", \"3921\\n10000\\n\", \"123\\n222\\n\", \"920491855\\n281495062\\n\", \"122112\\n221112\\n\", \"100011\\n100100\\n\", \"4444222277779999\\n4444222277771111\\n\", \"9912346\\n9912345\\n\", \"9087645\\n9087640\\n\", \"20123\\n21022\\n\", \"109823464\\n901234467\\n\", \"53436\\n... | You are given two positive integer numbers a and b. Permute (change order) of the digits of a to construct maximal number not exceeding b. No number in input and/or output can start with the digit 0.
It is allowed to leave a as it is.
Input
The first line contains integer a (1 ≤ a ≤ 1018). The second line contains i... | 0 |
{"tests": "{\"inputs\": [\"4 2\\n1 2 4\\n2 3 7\\n6 20 1 25\\n\", \"3 3\\n1 2 1\\n2 3 1\\n1 3 1\\n30 10 20\\n\", \"7 7\\n1 6 745325\\n2 3 3581176\\n2 4 19\\n3 6 71263060078\\n5 4 141198\\n7 4 163953\\n5 6 15994\\n1 297404206755 82096176217 14663411 187389745 21385 704393\\n\", \"4 2\\n1 2 7\\n2 3 7\\n6 20 1 25\\n\", \"4... | Musicians of a popular band "Flayer" have announced that they are going to "make their exit" with a world tour. Of course, they will visit Berland as well.
There are n cities in Berland. People can travel between cities using two-directional train routes; there are exactly m routes, i-th route can be used to go from c... | 0.75 |
{"tests": "{\"inputs\": [\"4\\n1 3 9 7\\n\\nSAMPLE\", \"4\\n1 3 9 7\", \"4\\n1 3 17 7\", \"4\\n1 3 9 7\\n\\nRAMPLE\", \"4\\n1 5 3 7\", \"4\\n1 5 3 11\", \"4\\n1 3 6 10\", \"4\\n1 3 1 3\\n\\nR@LOLF\", \"4\\n0 3 10 3\\n\\nR@LOLF\", \"4\\n1 3 10 10\", \"4\\n1 3 13 7\\n\\nEAPMLS\", \"4\\n1 3 10 14\", \"4\\n1 5 6 0\", \"4\\... | N boys are sitting in a circle. Each of them have some apples in their hand. You find that the total number of the apples can be divided by N. So you want to divide the apples equally among all the boys. But they are so lazy that each one of them only wants to give one apple to one of the neighbors at one step. Calcula... | 0 |
{"tests": "{\"inputs\": [\"2 2\\n1 3 A\\n3 5 B\\n\\nSAMPLE\", \"4 11\\n72 11 L\\n1 3 Y\\n2 5 d\\n1 4 v\\n70 12 B\\n5 6 C\\n72 10 f\\n141 12 s\\n1 3 n\\n12646 19 L\\n1 5 x\", \"5 4\\n178 12 q\\n3 8 7\\n1 9 1\\n1 1 u\", \"6 6\\n29 10 X\\n499 15 f\\n6 7 0\\n1 5 L\\n6288 20 e\\n2689 20 N\", \"6 9\\n5601 18 M\\n1 4 Q\\n1 3 ... | “Can you answer this million dollar question ?” said the presenter to Little Achraf.
“Yes”, he responded.
“Ok … here is the question”.
We define a sequence A of strings of order L as follows:
A[n] = \sum\limits_{i = 0}^{L-1} A[n-L+i]; n ≥ L+1; where addition refers to string concatenation
A[n] ∈ [a-z A-Z 0-9]; ... | 0 |
{"tests": "{\"inputs\": [\"6\\n1\\n2 5\\n2 7\\n2 9\\n1\\n1\\n\\nSAMPLE\", \"2\\n1\\n1\", \"6\\n1\\n2 4\\n2 7\\n2 9\\n1\\n1\\n\\nSAMPLE\", \"6\\n1\\n2 4\\n2 1\\n2 9\\n1\\n1\\n\\nQAMSLE\", \"6\\n1\\n2 -1\\n2 7\\n2 16\\n1\\n1\\n\\nSALPLE\", \"6\\n1\\n2 7\\n2 2\\n2 9\\n1\\n1\\n\\nQAMSLE\", \"6\\n1\\n2 5\\n2 7\\n2 5\\n1\\n1... | Our monk loves food. Hence,he took up position of a manager at Sagar,a restaurant that serves people with delicious food packages. It is a very famous place and people are always queuing up to have one of those packages. Each package has a cost associated with it. The packages are kept as a pile.
The job of a manager... | 0.75 |
{"tests": "{\"inputs\": [\"2\\n4 2 7 4\\n9 9 1 9\", \"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 ... | 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\": [\"9\\n2 3 5 4 1 2 4 2 1\", \"2\\n2 2\", \"9\\n27 18 28 18 28 45 90 45 23\", \"5\\n2 1 2 1 2\", \"9\\n3 3 5 4 1 2 4 2 1\", \"9\\n21 18 28 18 28 45 90 45 23\", \"9\\n2 3 7 4 1 2 4 2 1\", \"9\\n21 18 3 18 28 45 90 45 23\", \"9\\n2 3 4 4 1 2 4 2 1\", \"9\\n21 18 3 18 46 45 90 45 23\", \"9\\n2 3 2 4... | Let us consider a grid of squares with 10^9 rows and N columns. Let (i, j) be the square at the i-th column (1 \leq i \leq N) from the left and j-th row (1 \leq j \leq 10^9) from the bottom.
Snuke has cut out some part of the grid so that, for each i = 1, 2, ..., N, the bottom-most h_i squares are remaining in the i-t... | 0 |
{"tests": "{\"inputs\": [\"4 2 3\\n10 20 10 10\", \"5 1 5\\n1000000000000000 999999999999999 999999999999998 999999999999997 999999999999996\", \"5 2 2\\n1 2 3 4 5\", \"4 2 6\\n10 20 10 10\", \"5 2 2\\n1 0 3 4 5\", \"4 2 6\\n10 20 10 5\", \"4 2 6\\n2 20 10 5\", \"5 1 5\\n1000000000000000 999999999999999 999999999999998... | You are given N items.
The value of the i-th item (1 \leq i \leq N) is v_i.
Your have to select at least A and at most B of these items.
Under this condition, find the maximum possible arithmetic mean of the values of selected items.
Additionally, find the number of ways to select items so that the mean of the values o... | 0 |
{"tests": "{\"inputs\": [\"1111\\n00001\\n0110\\n01011\\n0010\\n01111\\n0010\\n01001\\n0111\", \"1111\\n00001\\n0110\\n01011\\n0010\\n01111\\n0010\\n01011\\n0111\", \"1111\\n00001\\n0110\\n01011\\n0010\\n01111\\n1010\\n01011\\n0111\", \"1111\\n00001\\n0110\\n01111\\n0010\\n00011\\n1010\\n01011\\n0111\", \"1111\\n00001\... | Seen from above, there is a grid-like square shaped like Figure 1. The presence or absence of "walls" on each side of this grid is represented by a sequence of 0s and 1s. Create a program that stands at point A, puts your right hand on the wall, keeps walking in the direction of the arrow, and outputs the route to retu... | 0 |
{"tests": "{\"inputs\": [\"3\\n111 SET c 1\\n12 SUB c c 2\\n777 SET a 4\", \"3\\n10 SET c 1\\n120 IF c 10\\n20 HALT\", \"6\\n10 SET c 1\\n20 SET i 5\\n100 ADD s s i\\n110 SUB i i c\\n120 IF i 100\\n200 HALT\", \"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... | 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\": [\"None\", \"5 2\\n2 2 1\\n2 1 3\", \"Npne\", \"5 2\\n2 1 1\\n2 1 3\", \"Nnpe\", \"9 2\\n2 1 1\\n2 1 3\", \"Nope\", \"1 2\\n2 1 1\\n2 1 3\", \"Nopd\", \"1 2\\n2 1 1\\n2 2 3\", \"dpoN\", \"1 2\\n2 1 1\\n2 2 0\", \"cpoN\", \"1 2\\n2 1 0\\n2 2 0\", \"cNop\", \"cNpo\", \"opNc\", \"opNd\", \"odNp\", ... | JOI is playing with a nail in the board. As shown in the figure below, JOI stabbed nails in the shape of an equilateral triangle with N sides. A nails are lined up in the ath line (1 ≤ a ≤ N) from the top. The bth nail (1 ≤ b ≤ a) from the left is represented by (a, b).
<image>
Figure 1: Arrangement of nails (when N =... | 0 |
{"tests": "{\"inputs\": [\"3\\n1 1\\n3 4\\n6 0\\n\\n7\\n0 0\\n10 10\\n0 20\\n10 30\\n0 40\\n100 40\\n100 0\\n\\n0\", \"3\\n1 1\\n3 4\\n6 0\\n\\n7\\n0 0\\n10 10\\n0 20\\n10 33\\n0 40\\n100 40\\n100 0\\n\\n0\", \"3\\n1 1\\n3 4\\n6 0\\n\\n7\\n0 0\\n10 10\\n0 20\\n10 33\\n0 40\\n110 40\\n100 0\\n\\n0\", \"3\\n1 1\\n3 4\\n6... | Polygons are the most fundamental objects in geometric processing. Complex figures are often represented and handled as polygons with many short sides. If you are interested in the processing of geometric data, you'd better try some programming exercises about basic operations on polygons.
Your job in this problem is ... | 0.375 |
{"tests": "{\"inputs\": [\"4\\n800\\n700\\n1600\\n600\\n4\\n300\\n700\\n1600\\n600\\n4\\n300\\n700\\n1600\\n650\\n3\\n1000\\n2000\\n500\\n3\\n250\\n250\\n1000\\n4\\n1251\\n667\\n876\\n299\\n0\", \"4\\n800\\n700\\n1600\\n600\\n4\\n300\\n700\\n1600\\n30\\n4\\n300\\n700\\n1600\\n650\\n3\\n1000\\n2000\\n500\\n3\\n250\\n250... | 500-yen Saving
"500-yen Saving" is one of Japanese famous methods to save money. The method is quite simple; whenever you receive a 500-yen coin in your change of shopping, put the coin to your 500-yen saving box. Typically, you will find more than one million yen in your saving box in ten years.
Some Japanese people... | 0 |
{"tests": "{\"inputs\": [\"A+A++A\\nZ-Z--Z+-Z\\n[ESREVER]\\nJ---?---J\\n++++++++A+++Z-----------A+++Z\\n[[++-+--?[--++-?++-+++L]][-+-----+-O]]++++---+L\\n.\", \"A+A++A\\nZ-Z--Z+-Z\\n[ESRVEER]\\nJ---?---J\\n++++++++A+++Z-----------A+++Z\\n[[++-+--?[--++-?++-+++L]][-+-----+-O]]++++---+L\\n.\", \"A+A++A\\nZ-ZZ--+-Z\\n[ESR... | Broken crypto generator
JAG (Japanese Alumni Group) is a mysterious organization composed of many programmers, and in order to enter the building where the headquarters of this organization is located, it is necessary to solve the ciphertext generated by a certain machine every time. This ciphertext consists of the sy... | 0 |
{"tests": "{\"inputs\": [\"5\\n5\\n1\\n4\\n3\\n2\", \"3\\n3\\n2\\n1\", \"5\\n5\\n1\\n4\\n5\\n2\", \"3\\n6\\n2\\n1\", \"5\\n6\\n1\\n4\\n5\\n2\", \"3\\n0\\n2\\n1\", \"5\\n6\\n1\\n4\\n9\\n2\", \"3\\n-1\\n2\\n1\", \"5\\n6\\n1\\n4\\n6\\n2\", \"3\\n0\\n2\\n0\", \"5\\n5\\n1\\n4\\n9\\n2\", \"3\\n0\\n1\\n0\", \"5\\n7\\n1\\n4\\n... | Shell Sort
Shell Sort is a generalization of Insertion Sort to arrange a list of $n$ elements $A$.
1 insertionSort(A, n, g)
2 for i = g to n-1
3 v = A[i]
4 j = i - g
5 while j >= 0 && A[j] > v
6 A[j+g] = A[j]
7 j = j - g
8 cnt++
9 A[j+g... | 0.625 |
{"tests": "{\"inputs\": [\"2 2\\nAG\\nCT\\n\", \"3 5\\nAGCAG\\nAGCAG\\nAGCAG\\n\", \"2 2\\nTG\\nAC\\n\", \"2 2\\nAG\\nTC\\n\", \"2 2\\nGA\\nTC\\n\", \"3 5\\nGACGA\\nAGCAG\\nAGCAG\\n\", \"2 2\\nTG\\nCA\\n\", \"2 2\\nGA\\nCT\\n\", \"2 2\\nGT\\nAC\\n\", \"2 2\\nGT\\nCA\\n\", \"3 5\\nAGGAC\\nGACGA\\nGACGA\\n\", \"3 5\\nAGC... | You are given an n × m table, consisting of characters «A», «G», «C», «T». Let's call a table nice, if every 2 × 2 square contains all four distinct characters. Your task is to find a nice table (also consisting of «A», «G», «C», «T»), that differs from the given table in the minimum number of characters.
Input
First... | 0 |
{"tests": "{\"inputs\": [\"3 4\\n0 1 0 1\\n1 0 1 0\\n0 1 0 1\\n1 1 1 1\\n1 1 1 1\\n1 1 1 1\\n\", \"6 7\\n0 0 1 1 0 0 1\\n0 1 0 0 1 0 1\\n0 0 0 1 0 0 1\\n1 0 1 0 1 0 0\\n0 1 0 0 1 0 1\\n0 1 0 1 0 0 1\\n1 1 0 1 0 1 1\\n0 1 1 0 1 0 0\\n1 1 0 1 0 0 1\\n1 0 1 0 0 1 0\\n0 1 1 0 1 0 0\\n0 1 1 1 1 0 1\\n\", \"3 3\\n0 1 0\\n0 1... | Ramesses came to university to algorithms practice, and his professor, who is a fairly known programmer, gave him the following task.
You are given two matrices A and B of size n × m, each of which consists of 0 and 1 only. You can apply the following operation to the matrix A arbitrary number of times: take any subma... | 0.25 |
{"tests": "{\"inputs\": [\"4\\n2 4\\n1 3\\n3 12\\n3 4 5\\n1 5\\n5\\n2 10\\n15 4\\n\", \"1\\n10 999999733\\n25 68 91 55 36 29 96 4 63 3\\n\", \"1\\n1 11\\n5\\n\", \"1\\n2 9\\n2 4\\n\", \"1\\n19 1000000000\\n15 8 22 12 10 16 2 17 14 7 20 23 9 18 3 19 21 11 1\\n\", \"1\\n1 5\\n2\\n\", \"1\\n10 999999733\\n25 68 91 55 36 2... | Bessie has way too many friends because she is everyone's favorite cow! Her new friend Rabbit is trying to hop over so they can play!
More specifically, he wants to get from (0,0) to (x,0) by making multiple hops. He is only willing to hop from one point to another point on the 2D plane if the Euclidean distance betw... | 0.375 |
{"tests": "{\"inputs\": [\"6\\n5\\n1 4 3 2 1\\n6\\n2 4 1 3 2 1\\n4\\n2 1 1 3\\n4\\n1 3 3 1\\n12\\n2 1 3 4 5 6 7 8 9 1 10 2\\n3\\n1 1 1\\n\", \"6\\n5\\n1 4 3 1 1\\n6\\n2 4 1 3 2 1\\n4\\n2 1 1 3\\n4\\n1 3 3 1\\n12\\n2 1 3 4 5 6 7 8 9 1 10 2\\n3\\n1 1 1\\n\", \"6\\n5\\n1 4 3 2 1\\n6\\n2 4 1 3 3 1\\n4\\n2 1 1 3\\n4\\n1 3 3... | The sequence of m integers is called the permutation if it contains all integers from 1 to m exactly once. The number m is called the length of the permutation.
Dreamoon has two permutations p_1 and p_2 of non-zero lengths l_1 and l_2.
Now Dreamoon concatenates these two permutations into another sequence a of length... | 0.75 |
{"tests": "{\"inputs\": [\"10\\n1111100000\\n1111100001\\n\", \"6\\n010000\\n000001\\n\", \"10\\n1111100000\\n0000011111\\n\", \"8\\n10101010\\n01010101\\n\", \"10\\n1010111110\\n1011101101\\n\", \"12\\n011001010101\\n111001010101\\n\", \"10\\n1100000100\\n0010000011\\n\", \"10\\n0111101111\\n0111111110\\n\", \"3\\n000... | Naman has two binary strings s and t of length n (a binary string is a string which only consists of the characters "0" and "1"). He wants to convert s into t using the following operation as few times as possible.
In one operation, he can choose any subsequence of s and rotate it clockwise once.
For example, if s = ... | 0 |
{"tests": "{\"inputs\": [\"2 3\\n16 16 16\\n16 16 16\\n\", \"2 2\\n1 2\\n2 3\\n\", \"2 2\\n3 11\\n12 8\\n\", \"2 3\\n16 16 11\\n16 16 16\\n\", \"2 2\\n1 2\\n3 3\\n\", \"2 2\\n6 11\\n12 8\\n\", \"2 2\\n1 2\\n2 5\\n\", \"2 2\\n1 2\\n4 3\\n\", \"2 2\\n1 1\\n4 3\\n\", \"2 2\\n1 1\\n8 3\\n\", \"2 2\\n6 10\\n12 8\\n\", \"1 2... | You are given a matrix a consisting of positive integers. It has n rows and m columns.
Construct a matrix b consisting of positive integers. It should have the same size as a, and the following conditions should be met:
* 1 ≤ b_{i,j} ≤ 10^6;
* b_{i,j} is a multiple of a_{i,j};
* the absolute value of the dif... | 0 |
{"tests": "{\"inputs\": [\"1 2\\n2 2\\n\", \"2 3\\n1 2\\n2 3\\n\", \"6 6\\n2 1\\n3 2\\n2 5\\n3 3\\n5 1\\n2 1\\n\", \"100 1500\\n3 3\\n3 2\\n1 3\\n3 1\\n2 3\\n3 2\\n3 2\\n2 1\\n3 1\\n2 3\\n3 3\\n3 1\\n1 1\\n3 1\\n3 3\\n2 2\\n2 2\\n1 2\\n1 1\\n3 1\\n2 2\\n2 3\\n2 3\\n2 2\\n3 3\\n3 2\\n1 1\\n3 3\\n2 2\\n1 3\\n3 3\\n3 1\\n... | Vasya has recently bought some land and decided to surround it with a wooden fence.
He went to a company called "Wooden board" that produces wooden boards for fences. Vasya read in the catalog of products that the company has at its disposal n different types of wood. The company uses the i-th type of wood to produce ... | 0 |
{"tests": "{\"inputs\": [\"4\\n1 2 1\\n2 3 2\\n3 4 3\\n1\\n1\\n1\\n1\\n\", \"4\\n1 2 1\\n2 3 2\\n3 4 3\\n4\\n4\\n4\\n4\\n\", \"1\\n1\\n\", \"10\\n2 1 559\\n3 1 5707\\n4 2 9790\\n5 3 1591\\n6 1 7113\\n7 6 2413\\n8 6 3006\\n9 4 1935\\n10 6 5954\\n1\\n1\\n1\\n1\\n1\\n1\\n1\\n1\\n1\\n1\\n\", \"10\\n2 1 8760\\n3 1 3705\\n4 ... | DZY loves planting, and he enjoys solving tree problems.
DZY has a weighted tree (connected undirected graph without cycles) containing n nodes (they are numbered from 1 to n). He defines the function g(x, y) (1 ≤ x, y ≤ n) as the longest edge in the shortest path between nodes x and y. Specially g(z, z) = 0 for every... | 0 |
{"tests": "{\"inputs\": [\"3\\n1 1\\n2 2\\n3 3\\n\", \"3\\n1 10\\n0 10\\n10 10\\n\", \"17\\n68 69\\n47 48\\n30 31\\n52 54\\n41 43\\n33 35\\n38 40\\n56 58\\n45 46\\n92 93\\n73 74\\n61 63\\n65 66\\n37 39\\n67 68\\n77 78\\n28 30\\n\", \"26\\n1 2\\n1 2\\n1 2\\n1 2\\n1 2\\n1 2\\n1 2\\n1 2\\n1 2\\n1 2\\n1 2\\n1 2\\n1 2\\n1 2... | George has recently entered the BSUCP (Berland State University for Cool Programmers). George has a friend Alex who has also entered the university. Now they are moving into a dormitory.
George and Alex want to live in the same room. The dormitory has n rooms in total. At the moment the i-th room has pi people living... | 0.875 |
{"tests": "{\"inputs\": [\"9\\n1 2 3 1 2 1 4 2 5\\n\", \"4\\n4 3 2 1\\n\", \"4\\n1 2 2 3\\n\", \"2\\n1000 1\\n\", \"5\\n2 2 1 1 3\\n\", \"100\\n12 18 1 1 14 23 1 1 22 5 7 9 7 1 1 1 3 8 4 2 1 6 9 1 3 2 11 1 11 2 3 2 1 4 2 7 1 16 3 4 2 13 3 1 5 11 2 10 20 24 3 21 5 2 6 2 1 10 10 5 17 1 1 4 19 8 5 5 3 9 4 2 7 8 10 4 9 1 3... | A permutation is a sequence of integers from 1 to n of length n containing each number exactly once. For example, (1), (4, 3, 5, 1, 2), (3, 2, 1) are permutations, and (1, 1), (4, 3, 1), (2, 3, 4) are not.
There are many tasks on permutations. Today you are going to solve one of them. Let’s imagine that somebody took... | 0 |
{"tests": "{\"inputs\": [\"-60\\n\", \"60\\n\", \"6678504591813508\\n\", \"44\\n\", \"225\\n\", \"-45\\n\", \"-358\\n\", \"46\\n\", \"-999999999999999415\\n\", \"-999999999999999639\\n\", \"-44\\n\", \"-999999999999999325\\n\", \"999999999999999326\\n\", \"316\\n\", \"359\\n\", \"999999999999999416\\n\", \"-135\\n\", \... | Vasya started working in a machine vision company of IT City. Vasya's team creates software and hardware for identification of people by their face.
One of the project's know-how is a camera rotating around its optical axis on shooting. People see an eye-catching gadget — a rotating camera — come up to it to see it be... | 0.75 |
{"tests": "{\"inputs\": [\"5 5\\n2 1\\n1 3\\n2 3\\n2 5\\n4 3\\n\", \"4 3\\n2 1\\n1 3\\n4 3\\n\", \"6 5\\n1 2\\n2 3\\n4 5\\n4 6\\n5 6\\n\", \"10 45\\n3 5\\n2 3\\n4 8\\n2 5\\n6 8\\n5 7\\n2 1\\n3 7\\n5 10\\n6 1\\n9 4\\n3 6\\n9 10\\n6 7\\n1 7\\n7 9\\n6 9\\n9 3\\n4 2\\n2 6\\n5 6\\n5 8\\n3 4\\n10 8\\n7 8\\n4 6\\n9 1\\n5 9\\n... | Berland has n cities connected by m bidirectional roads. No road connects a city to itself, and each pair of cities is connected by no more than one road. It is not guaranteed that you can get from any city to any other one, using only the existing roads.
The President of Berland decided to make changes to the road sy... | 0.25 |
{"tests": "{\"inputs\": [\"0 1 0 1 1 0\\n3\\nXL\\nS,M\\nXL,XXL\\n\", \"1 1 2 0 1 1\\n5\\nS\\nM\\nS,M\\nXXL,XXXL\\nXL,XXL\\n\", \"5 1 5 2 4 3\\n20\\nL,XL\\nS,M\\nL,XL\\nXXL,XXXL\\nS,M\\nS,M\\nXL,XXL\\nL,XL\\nS,M\\nL,XL\\nS,M\\nM,L\\nXXL,XXXL\\nXXL,XXXL\\nL\\nXXL,XXXL\\nXL,XXL\\nM,L\\nS,M\\nXXL\\n\", \"1 2 4 4 1 1\\n10\\... | The organizers of a programming contest have decided to present t-shirts to participants. There are six different t-shirts sizes in this problem: S, M, L, XL, XXL, XXXL (sizes are listed in increasing order). The t-shirts are already prepared. For each size from S to XXXL you are given the number of t-shirts of this si... | 0 |
{"tests": "{\"inputs\": [\"6 3 2\\n1 5 6\\n1 2\\n1 3\\n1 4\\n1 5\\n5 6\\n\", \"6 2 4\\n1 6\\n1 2\\n2 3\\n3 4\\n4 5\\n5 6\\n\", \"6 2 4\\n1 6\\n1 2\\n2 3\\n3 4\\n4 5\\n5 6\\n\", \"2 1 1\\n1\\n1 2\\n\", \"11 1 5\\n6\\n1 2\\n2 3\\n3 4\\n4 5\\n5 6\\n6 7\\n7 8\\n8 9\\n9 10\\n10 11\\n\", \"10 1 5\\n5\\n1 2\\n2 3\\n3 4\\n4 5\... | Inzane finally found Zane with a lot of money to spare, so they together decided to establish a country of their own.
Ruling a country is not an easy job. Thieves and terrorists are always ready to ruin the country's peace. To fight back, Zane and Inzane have enacted a very effective law: from each city it must be pos... | 0 |
{"tests": "{\"inputs\": [\"1 2\\n10 10\\n12 4\", \"100 1\\n101 101\\n102 1\", \"12000 15700\\n3390000000 3810000000\\n5550000000 2130000000\", \"1 2\\n10 10\\n12 5\", \"100 1\\n111 101\\n102 1\", \"100 2\\n100 101\\n102 1\", \"1 1\\n1 20\\n12 5\", \"100 2\\n100 101\\n102 0\", \"1 1\\n2 20\\n12 5\", \"100 2\\n100 111\\n... | Takahashi and Aoki are training for long-distance races in an infinitely long straight course running from west to east.
They start simultaneously at the same point and moves as follows towards the east:
* Takahashi runs A_1 meters per minute for the first T_1 minutes, then runs at A_2 meters per minute for the subse... | 0 |
{"tests": "{\"inputs\": [\"4 12\", \"8 20\", \"1 1\", \"1 12\", \"4 20\", \"1 0\", \"1 2\", \"4 24\", \"1 -1\", \"6 24\", \"6 36\", \"6 10\", \"6 17\", \"6 32\", \"5 32\", \"5 52\", \"5 10\", \"2 16\", \"1 16\", \"3 19\", \"5 19\", \"4 28\", \"8 28\", \"22 28\", \"22 14\", \"16 14\", \"16 3\", \"16 1\", \"16 2\", \"1 -... | You are given positive integers A and B.
If A is a divisor of B, print A + B; otherwise, print B - A.
Constraints
* All values in input are integers.
* 1 \leq A \leq B \leq 20
Input
Input is given from Standard Input in the following format:
A B
Output
If A is a divisor of B, print A + B; otherwise, print B -... | 0.75 |
{"tests": "{\"inputs\": [\"6\\n40\", \"101\\n80\", \"3\\n100\", \"6\\n36\", \"101\\n141\", \"3\\n101\", \"6\\n38\", \"101\\n233\", \"3\\n111\", \"6\\n59\", \"101\\n416\", \"3\\n001\", \"6\\n106\", \"101\\n221\", \"3\\n011\", \"6\\n174\", \"101\\n27\", \"3\\n010\", \"6\\n95\", \"101\\n37\", \"3\\n110\", \"6\\n180\", \"1... | Aoki is in search of Takahashi, who is missing in a one-dimentional world. Initially, the coordinate of Aoki is 0, and the coordinate of Takahashi is known to be x, but his coordinate afterwards cannot be known to Aoki.
Time is divided into turns. In each turn, Aoki and Takahashi take the following actions simultaneou... | 0.125 |
{"tests": "{\"inputs\": [\"3 2\\n0 1 2\\n1 2 1\\n2 1\\n0 1 100\\n2 1\\n0 1 0\\n2 1\\n0 1 -1\\n0 0\", \"3 2\\n0 1 2\\n1 2 1\\n2 1\\n0 1 100\\n2 1\\n0 0 0\\n2 1\\n0 1 -1\\n0 0\", \"3 2\\n0 1 2\\n1 2 1\\n2 1\\n1 1 100\\n2 1\\n0 0 0\\n2 1\\n0 1 -1\\n0 0\", \"3 2\\n0 2 2\\n0 2 1\\n2 1\\n0 1 100\\n2 1\\n0 1 0\\n2 1\\n0 1 -1\... | Mr. Dango's family has an extremely huge number of members. Once it had about 100 members, and now it has as many as population of a city. It is jokingly guessed that the member might fill this planet in the near future.
Mr. Dango's family, the huge family, is getting their new house. Scale of the house is as large as... | 0 |
{"tests": "{\"inputs\": [\"3 40\\n.a....a....a....a....f....f....f....f...\\nbc#.#cd#.#de#.#eb#.#cb#.#dc#.#ed#.#eb#.\\n.#....#....#....#....#....#....#....#...\", \"3 40\\n.a....a....a....a....f....f....f....f...\\nbc#.#cd#.#de#.#eb#.#cb#.#dc#.#ed#.#be#.\\n.#....#....#....#....#....#....#....#...\", \"3 40\\n.a....a...... | Mary Thomas has a number of sheets of squared paper. Some of squares are painted either in black or some colorful color (such as red and blue) on the front side. Cutting off the unpainted part, she will have eight opened-up unit cubes. A unit cube here refers to a cube of which each face consists of one square.
She is... | 0 |
{"tests": "{\"inputs\": [[\"foefet\", \"toffee\"], [\"Buckethead\", \"DeathCubeK\"], [\"Twoo\", \"WooT\"], [\"dumble\", \"bumble\"], [\"ound\", \"round\"], [\"apple\", \"pale\"]], \"outputs\": [[true], [true], [true], [false], [false], [false]]}", "source": "primeintellect"} | 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 |
{"tests": "{\"inputs\": [\"10\\n4 6\\n4 2\\n10 3\\n6 3\\n7 8\\n2 5\\n0 3\\n6 1\\n4 1\\n10 9\\n\", \"90\\n1 1\\n2 1\\n3 1\\n4 1\\n5 1\\n6 1\\n7 1\\n8 1\\n9 1\\n1 2\\n2 2\\n3 2\\n4 2\\n5 2\\n6 2\\n7 2\\n8 2\\n9 2\\n1 3\\n2 3\\n3 3\\n4 3\\n5 3\\n6 3\\n7 3\\n8 3\\n9 3\\n1 4\\n2 4\\n3 4\\n4 4\\n5 4\\n6 4\\n7 4\\n8 4\\n9 4\\... | For some reason in many American cartoons anvils fall from time to time onto heroes' heads. Of course, safes, wardrobes, cruisers, planes fall sometimes too... But anvils do so most of all.
Anvils come in different sizes and shapes. Quite often they get the hero stuck deep in the ground. But have you ever thought who ... | 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.5 |
{"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\": [[\"I will build a huge wall\"], [\"HUUUUUGEEEE WAAAAAALL\"], [\"MEXICAAAAAAAANS GOOOO HOOOMEEEE\"], [\"America NUUUUUKEEEE Oooobaaaamaaaaa\"], [\"listen migrants: IIII KIIIDD YOOOUUU NOOOOOOTTT\"]], \"outputs\": [[0], [4], [2.5], [1.89], [1.56]]}", "source": "primeintellect"} | We all love the future president (or Führer or duce or sōtō as he could find them more fitting) donald trump, but we might fear that some of his many fans like John Miller or John Barron are not making him justice, sounding too much like their (and our as well, of course!) hero and thus risking to compromise him.
For ... | 0 |
{"tests": "{\"inputs\": [[[]], [[\"Peter\"]], [[\"Jacob\", \"Alex\"]], [[\"Max\", \"John\", \"Mark\"]], [[\"Alex\", \"Jacob\", \"Mark\", \"Max\"]]], \"outputs\": [[\"no one likes this\"], [\"Peter likes this\"], [\"Jacob and Alex like this\"], [\"Max, John and Mark like this\"], [\"Alex, Jacob and 2 others like this\"]... | You probably know the "like" system from Facebook and other pages. People can "like" blog posts, pictures or other items. We want to create the text that should be displayed next to such an item.
Implement a function `likes :: [String] -> String`, which must take in input array, containing the names of people who like... | 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\": [\"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\": [[[1, 2, 3, 4, 5], 1], [[1, 2, 3, 4, 5], 2], [[1, 2, 3, 4, 5], 3], [[1, 2, 3, 4, 5], 6], [[1, 2, 3, 4, 5], 0]], \"outputs\": [[[15]], [[9, 6]], [[5, 7, 3]], [[1, 2, 3, 4, 5, 0]], [[]]]}", "source": "primeintellect"} | Born a misinterpretation of [this kata](https://www.codewars.com/kata/simple-fun-number-334-two-beggars-and-gold/), your task here is pretty simple: given an array of values and an amount of beggars, you are supposed to return an array with the sum of what each beggar brings home, assuming they all take regular turns, ... | 0 |
{"tests": "{\"inputs\": [\"3\\n+ 489111368\\n+ 489111368\\n+ 489111368\\n\", \"3\\n+ 202794029\\n+ 810021800\\n+ 810021800\\n\", \"2\\n+ 717107178\\n+ 717107178\\n\", \"4\\n+ 68335221\\n+ 68335221\\n+ 68335221\\n-\\n\", \"3\\n-\\n-\\n-\\n\", \"4\\n+ 637139306\\n-\\n+ 637139306\\n-\\n\", \"3\\n+ 59671102\\n+ 59671102\\n... | You are given a sequence A, where its elements are either in the form + x or -, where x is an integer.
For such a sequence S where its elements are either in the form + x or -, define f(S) as follows:
* iterate through S's elements from the first one to the last one, and maintain a multiset T as you iterate through... | 0 |
{"tests": "{\"inputs\": [\"5 4\\n1 1 3\\n2 3 90\\n2 5 48\\n1 4 1\\n\", \"1 1\\n2 1 302\\n\", \"1 1\\n2 1 302\\n\", \"50 50\\n1 41 261\\n2 47 324\\n1 41 256\\n1 31 339\\n2 23 116\\n2 44 184\\n2 32 115\\n1 40 301\\n2 40 303\\n1 29 309\\n2 49 348\\n2 47 356\\n1 41 263\\n2 42 276\\n1 45 135\\n1 33 226\\n2 31 166\\n1 50 171... | Roger is a robot. He has an arm that is a series of n segments connected to each other. The endpoints of the i-th segment are initially located at points (i - 1, 0) and (i, 0). The endpoint at (i - 1, 0) is colored red and the endpoint at (i, 0) is colored blue for all segments. Thus, the blue endpoint of the i-th segm... | 0.25 |
{"tests": "{\"inputs\": [\"5 4\\n3\\n1 1\\n3 4\\n5 6\", \"6 4\\n3\\n1 1\\n1 4\\n5 6\", \"6 4\\n3\\n1 1\\n1 4\\n5 12\", \"6 4\\n3\\n0 1\\n1 4\\n5 12\", \"5 4\\n3\\n1 1\\n3 4\\n5 2\", \"5 4\\n3\\n1 1\\n3 4\\n7 6\", \"6 4\\n3\\n1 0\\n1 4\\n5 6\", \"6 4\\n3\\n1 1\\n1 3\\n5 12\", \"6 4\\n3\\n0 1\\n1 4\\n5 0\", \"5 4\\n3\\n1... | At the end of last year, Santa Claus forgot to give Christmas presents to the children in JOI village. Therefore, I decided to deliver the chocolate cake to the children as an apology. The day to deliver is approaching tomorrow, so it's time to come up with a move plan.
JOI village is divided into a grid shape by W ro... | 0 |
{"tests": "{\"inputs\": [[[1, 120], [2, 60], 4], [[1, 120], [2, 60], 8], [[1, 120], [4, 30], 8], [[1, 120], [3, 60], 9], [[1, 120], [3, 60], 27], [[1, 120], [9, 30], 27], [[1, 81], [2, 27], 4], [[1, 81], [2, 27], 8], [[1, 81], [4, 9], 8], [[1, 81], [5, 27], 25], [[1, 81], [5, 27], 125], [[1, 81], [25, 9], 125], [[4, 30... | A [Power Law](https://en.wikipedia.org/wiki/Power_law) distribution occurs whenever "a relative change in one quantity results in a proportional relative change in the other quantity." For example, if *y* = 120 when *x* = 1 and *y* = 60 when *x* = 2 (i.e. *y* halves whenever *x* doubles) then when *x* = 4, *y* = 30 and... | 0 |
{"tests": "{\"inputs\": [\"4\\n4 3\\nBRBB\\nRBR\\n4 7\\nBRBR\\nRRBRBRB\\n3 4\\nRBR\\nBRBR\\n5 4\\nBRBRR\\nBRBR\\n\", \"23\\n1 1\\nR\\nB\\n1 1\\nR\\nB\\n1 1\\nR\\nB\\n1 1\\nR\\nB\\n1 1\\nR\\nB\\n1 1\\nR\\nB\\n1 1\\nR\\nB\\n1 1\\nR\\nB\\n1 1\\nR\\nB\\n1 1\\nR\\nB\\n1 1\\nR\\nB\\n1 1\\nR\\nB\\n1 1\\nR\\nB\\n1 1\\nR\\nB\\n... | There are two towers consisting of blocks of two colors: red and blue. Both towers are represented by strings of characters B and/or R denoting the order of blocks in them from the bottom to the top, where B corresponds to a blue block, and R corresponds to a red block.
These two towers are represented by strings BRBB... | 0.125 |
{"tests": "{\"inputs\": [\"10\\n5 6\\n1 1 1 1 1\\n8 32\\n100 52 13 6 9 4 100 35\\n1 1\\n5\\n4 5\\n4 3 2 1\\n5 9\\n2 3 1 4 1\\n5 8\\n2 3 1 4 1\\n4 3\\n2 3 4 1\\n4 9\\n5 4 3 3\\n2 14\\n7 5\\n5 600000000\\n500000000 400000000 300000000 200000000 100000000\\n\", \"1\\n5 5\\n7 7 9 1 1\\n\", \"1\\n10 5\\n100 100 100 100 100 ... | The only difference between the easy and hard versions are the locations you can teleport to.
Consider the points $0,1,\dots,n+1$ on the number line. There is a teleporter located on each of the points $1,2,\dots,n$. At point $i$, you can do the following:
Move left one unit: it costs $1$ coin.
Move right one unit: ... | 0 |
{"tests": "{\"inputs\": [[1, 1], [1, 2], [2, 1], [2, 2], [6, 6]], \"outputs\": [[[[\"O\"]]], [[[\"O\", \"X\"]]], [[[\"O\"], [\"X\"]]], [[[\"O\", \"X\"], [\"X\", \"O\"]]], [[[\"O\", \"X\", \"O\", \"X\", \"O\", \"X\"], [\"X\", \"O\", \"X\", \"O\", \"X\", \"O\"], [\"O\", \"X\", \"O\", \"X\", \"O\", \"X\"], [\"X\", \"O\", ... | A grid is a perfect starting point for many games (Chess, battleships, Candy Crush!).
Making a digital chessboard I think is an interesting way of visualising how loops can work together.
Your task is to write a function that takes two integers `rows` and `columns` and returns a chessboard pattern as a two dimensiona... | 0 |
{"tests": "{\"inputs\": [\"4\\n10.00000 10.00000 10.00000\\n20.00000 10.00000 10.00000\\n20.00000 20.00000 10.00000\\n10.00000 20.00000 10.00000\\n4\\n10.00000 10.063097698119668 10.00000\\n10.00000 50.00000 50.00000\\n50.00000 10.00000 50.00000\\n50.00000 50.00000 10.00000\\n0\", \"4\\n10.00000 10.00000 10.00000\\n20.... | During a voyage of the starship Hakodate-maru (see Problem A), researchers found strange synchronized movements of stars. Having heard these observations, Dr. Extreme proposed a theory of "super stars". Do not take this term as a description of actors or singers. It is a revolutionary theory in astronomy.
According to... | 0 |
{"tests": "{\"inputs\": [\"10 4\\n2 2 2 2 2 2 2 2 2 2\\n\", \"1 125\\n5\\n\", \"8 32\\n2 2 2 2 2 2 2 2\\n\", \"1 8\\n2\\n\", \"12 100\\n1766 1766 1766 1766 1766 1766 1766 1766 1766 1766 1766 1766\\n\", \"2 16\\n8 8\\n\", \"1 1\\n1\\n\", \"2 16\\n8 4\\n\", \"91 4900\\n630 630 70 630 910 630 630 630 770 70 770 630 630 77... | Today Pari and Arya are playing a game called Remainders.
Pari chooses two positive integer x and k, and tells Arya k but not x. Arya have to find the value <image>. There are n ancient numbers c1, c2, ..., cn and Pari has to tell Arya <image> if Arya wants. Given k and the ancient values, tell us if Arya has a winnin... | 0 |
{"tests": "{\"inputs\": [\"637107829 -403198378 -2 -2\\n\", \"847094637 -152905363 -1000000000 -1000000000\\n\", \"2408736 -3517525 413342 557733\\n\", \"20 1 -5 -1\\n\", \"-186611 -745388 -776721 -308073\\n\", \"1234577 1234573 -3 3\\n\", \"0 10 -1 1\\n\", \"44789577 44789576 -1 0\\n\", \"0 15 5 5\\n\", \"1000000000 -... | The King of Flatland will organize a knights' tournament! The winner will get half the kingdom and the favor of the princess of legendary beauty and wisdom. The final test of the applicants' courage and strength will be a fencing tournament. The tournament is held by the following rules: the participants fight one on o... | 0 |
{"tests": "{\"inputs\": [\"869 80 1001\", \"328 80 1001\", \"328 102 1011\", \"328 102 1111\", \"279 102 1111\", \"25 102 1111\", \"25 122 1111\", \"25 63 1111\", \"25 89 1111\", \"1486 120 1001\", \"869 80 1101\", \"328 117 1011\", \"40 102 1111\", \"328 60 1111\", \"117 102 1111\", \"24 102 1111\", \"9 122 1111\", \"... | In 2937, DISCO creates a new universe called DISCOSMOS to celebrate its 1000-th anniversary.
DISCOSMOS can be described as an H \times W grid. Let (i, j) (1 \leq i \leq H, 1 \leq j \leq W) denote the square at the i-th row from the top and the j-th column from the left.
At time 0, one robot will be placed onto each s... | 0 |
{"tests": "{\"inputs\": [\"8\", \"10010000000\", \"14\", \"10010000001\", \"13\", \"10000000001\", \"2\", \"10000001001\", \"4\", \"3\", \"10000000010\", \"6\", \"10010001000\", \"25\", \"10010010001\", \"23\", \"10000000011\", \"11000001001\", \"5\", \"10010100000\", \"11\", \"10010000100\", \"38\", \"11010010001\", \... | FizzBuzz is a game in which integers of 1 or more are spoken in order according to the following rules.
* "Fizz" when divisible by 3
* "Buzz" when divisible by 5
* "FizzBuzz" when divisible by both 3 and 5
* At other times, that number
An example of the progress of the game is shown below.
1, 2, Fizz, 4, Buzz,... | 0 |
{"tests": "{\"inputs\": [\"0?1\\n2 3\\n\", \"?????\\n13 37\\n\", \"?10?\\n239 7\\n\", \"01101001\\n5 7\\n\", \"0101010??01???101????10101??11??00\\n1000000 1000000\\n\", \"?00?0?0??00100?00?001111?11???1010110100?00?0?1?1?1001??001010?011???0000???????1111?1?101100110?001\\n801448 0\\n\", \"?\\n940946 502068\\n\", \"1?... | Currently, XXOC's rap is a string consisting of zeroes, ones, and question marks. Unfortunately, haters gonna hate. They will write $x$ angry comments for every occurrence of subsequence 01 and $y$ angry comments for every occurrence of subsequence 10. You should replace all the question marks with 0 or 1 in such a way... | 0 |
{"tests": "{\"inputs\": [\"1\\n0\\n1\\n1\\n1\\n1 0\\n\", \"4\\n0 0 0 0\\n2\\n2 3\\n1\\n2\\n3\\n2 4 1\\n4\\n3 1 2 2\\n6\\n1 0\\n2 0\\n3 -1\\n4 -2\\n1 1\\n1 5\\n\", \"4\\n4 -5 -3 -1\\n2\\n2 3\\n1\\n2\\n3\\n2 4 1\\n4\\n3 1 2 1\\n6\\n1 0\\n3 0\\n3 -1\\n4 -2\\n1 1\\n1 5\\n\", \"4\\n0 0 0 0\\n2\\n2 3\\n1\\n2\\n3\\n2 4 1\\n4\... | Gildong is experimenting with an interesting machine Graph Traveler. In Graph Traveler, there is a directed graph consisting of n vertices numbered from 1 to n. The i-th vertex has m_i outgoing edges that are labeled as e_i[0], e_i[1], …, e_i[m_i-1], each representing the destination vertex of the edge. The graph can h... | 0 |
{"tests": "{\"inputs\": [\"7 7 7\\n1\\n2\\n3\\n4\\n5\\n6\\n7\\n\", \"4 2 8\\n1\\n3\\n4\\n2\\n3\\n4\\n1\\n2\\n\", \"9 4 9\\n1\\n2\\n3\\n4\\n5\\n6\\n7\\n8\\n9\\n\", \"7 5 7\\n1\\n2\\n3\\n4\\n5\\n6\\n7\\n\", \"15 10 15\\n1\\n2\\n3\\n4\\n5\\n6\\n7\\n8\\n9\\n10\\n11\\n12\\n13\\n14\\n15\\n\", \"4 0 4\\n1\\n2\\n3\\n4\\n\", \"... | After all the events in Orlando we all know, Sasha and Roma decided to find out who is still the team's biggest loser. Thankfully, Masha found somewhere a revolver with a rotating cylinder of n bullet slots able to contain exactly k bullets, now the boys have a chance to resolve the problem once and for all.
Sasha se... | 0 |
{"tests": "{\"inputs\": [\"3 3 2\\n12 578 1435\\n59 471605241352156968 431565444592236940\\n0 0 0\", \"3 3 2\\n12 578 1954\\n59 471605241352156968 431565444592236940\\n0 0 0\", \"3 3 2\\n12 785 2214\\n59 471605241352156968 431565444592236940\\n0 0 0\", \"4 3 2\\n12 578 1954\\n59 471605241352156968 431565444592236940\\n... | Folding a Ribbon
Think of repetitively folding a very long and thin ribbon. First, the ribbon is spread out from left to right, then it is creased at its center, and one half of the ribbon is laid over the other. You can either fold it from the left to the right, picking up the left end of the ribbon and laying it ove... | 0 |
{"tests": "{\"inputs\": [[135, 20], [200, 8], [270, 2], [360, 1], [400, 0]], \"outputs\": [[282], [253], [289], [360], [0]]}", "source": "primeintellect"} | You just got done with your set at the gym, and you are wondering how much weight you could lift if you did a single repetition. Thankfully, a few scholars have devised formulas for this purpose (from [Wikipedia](https://en.wikipedia.org/wiki/One-repetition_maximum)) :
### Epley
### McGlothin
### Lombardi
Your ... | 0 |
{"tests": "{\"inputs\": [\"5 4\\n1 4 2 3 5\\n\", \"8 4\\n4 2 4 2 4 2 4 2\\n\", \"10 7\\n14 15 92 65 35 89 79 32 38 46\\n\", \"5 1\\n1 4 2 3 5\", \"10 7\\n14 15 101 65 35 89 79 32 38 46\", \"10 8\\n14 26 111 65 35 89 95 32 38 46\", \"10 3\\n14 26 111 65 35 89 95 32 38 46\", \"5 8\\n1 4 2 3 5\", \"10 7\\n18 15 92 65 35 8... | Given are a sequence of N positive integers A_1, A_2, \ldots, A_N, and a positive integer K.
Find the number of non-empty contiguous subsequences in A such that the remainder when dividing the sum of its elements by K is equal to the number of its elements. We consider two subsequences different if they are taken from ... | 0.5 |
{"tests": "{\"inputs\": [\"4181 6765\\n\", \"416445288135075809 416445288135075809\\n\", \"964542760623675601 965233603018687501\\n\", \"2 1000000000000000000\\n\", \"999999999999999999 999999999999999998\\n\", \"498454011879264 806515533049393\\n\", \"1 1000000000000000000\\n\", \"519421744863260201 572972909476222789... | Alice and Bob decided to eat some fruit. In the kitchen they found a large bag of oranges and apples. Alice immediately took an orange for herself, Bob took an apple. To make the process of sharing the remaining fruit more fun, the friends decided to play a game. They put multiple cards and on each one they wrote a let... | 0.125 |
{"tests": "{\"inputs\": [\"1\\n1010\\n\", \"6\\n12\\n10000000000000000000000000000000000000000000\\n3030\\n3112\\n99771122997711229977112299778700000006\\n99771122997711229977112299778699999996\\n\", \"1\\n100001\\n\", \"4\\n12\\n1000\\n1001\\n1002\\n\", \"3\\n100001\\n100000\\n100002\\n\", \"1\\n10000001\\n\", \"2\\n1... | Yes, that's another problem with definition of "beautiful" numbers.
Let's call a positive integer x beautiful if its decimal representation without leading zeroes contains even number of digits, and there exists a permutation of this representation which is palindromic. For example, 4242 is a beautiful number, since i... | 0 |
{"tests": "{\"inputs\": [\"1 100\\n79\\n\", \"50 3\\n33 7 96 30 68 37 44 50 100 71 12 100 72 43 17 75 59 96 16 34 25 3 90 45 7 55 92 59 30 25 96 23 40 41 95 99 93 79 89 11 76 60 4 100 75 14 37 39 87 47\\n\", \"100 10\\n3 114 77 78 105 87 6 122 141 100 75 118 64 18 88 37 109 72 31 101 36 10 62 18 52 17 149 115 22 150 13... | Vasya likes taking part in Codeforces contests. When a round is over, Vasya follows all submissions in the system testing tab.
There are n solutions, the i-th of them should be tested on a_i tests, testing one solution on one test takes 1 second. The solutions are judged in the order from 1 to n. There are k testing p... | 0.375 |
{"tests": "{\"inputs\": [[\"lamppu\"], [\"lamppu sofia\"], [\"silly game\"], [\"aeiou\"], [\"xyz lamppu\"], [\"\"], [\"lAmppU\"], [\"silly grrr\"]], \"outputs\": [[\"komppu-lantti\"], [\"komppu-lantti kofia-sontti\"], [\"kolly-sintti kome-gantti\"], [\"koeiou-antti\"], [\"koz-xyntti komppu-lantti\"], [\"\"], [\"komppU-... | Kontti language is a finnish word play game.
You add `-kontti` to the end of each word and then swap their characters until and including the first vowel ("aeiouy");
For example the word `tame` becomes `kome-tantti`; `fruity` becomes `koity-fruntti` and so on.
If no vowel is present, the word stays the same.
Write... | 0 |
{"tests": "{\"inputs\": [[5], [10], [20], [59], [105], [785], [1001], [8009], [9999999999999], [9999999999998], [9999999999995], [9999999949950]], \"outputs\": [[10], [27], [66], [249], [510], [5364], [7077], [73241], [300880375389561], [300880375389537], [300880375389493], [300880373832097]]}", "source": "primeintelle... | In this Kata we focus on finding a sum S(n) which is the total number of divisors taken for all natural numbers less or equal to n. More formally, we investigate the sum of n components denoted by d(1) + d(2) + ... + d(n) in which for any i starting from 1 up to n the value of d(i) tells us how many distinct numbers di... | 0 |
{"tests": "{\"inputs\": [\"1 393\\n\", \"1 995\\n\", \"999 1000\\n\", \"1000 997\\n\", \"728 174\\n\", \"961 61\\n\", \"997 1000\\n\", \"998 998\\n\", \"675 710\\n\", \"449 838\\n\", \"1 865\\n\", \"1 1\\n\", \"635 458\\n\", \"755 458\\n\", \"995 1\\n\", \"999 997\\n\", \"936 759\\n\", \"860 762\\n\", \"2 992\\n\", \"7... | Once upon a time in the Kingdom of Far Far Away lived Sir Lancelot, the chief Royal General. He was very proud of his men and he liked to invite the King to come and watch drill exercises which demonstrated the fighting techniques and tactics of the squad he was in charge of. But time went by and one day Sir Lancelot h... | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.