info stringlengths 120 50k | question stringlengths 504 10.4k | avg@8_qwen3_4b_instruct_2507 float64 0 0.88 |
|---|---|---|
{"tests": "{\"inputs\": [\"3\\n1 1 3 16\\n3 2 2 7\\n4 3 8 1\", \"3\\n1 1 3 8\\n3 2 4 7\\n4 3 8 1\", \"3\\n1 1 3 12\\n3 2 4 7\\n4 3 8 1\", \"3\\n1 1 6 12\\n3 2 4 7\\n4 3 8 1\", \"3\\n1 1 10 12\\n3 2 4 7\\n4 3 8 1\", \"3\\n1 1 10 12\\n3 2 6 7\\n4 3 8 1\", \"3\\n1 1 10 12\\n3 3 6 7\\n4 3 8 1\", \"3\\n0 1 10 12\\n3 3 6 7\\... | You manage 4 buildings, each of which has 3 floors, each of which consists of 10 rooms. Write a program which reads a sequence of tenant/leaver notices, and reports the number of tenants for each room.
For each notice, you are given four integers b, f, r and v which represent that v persons entered to room r of fth fl... | 0.125 |
{"tests": "{\"inputs\": [\"5 1\\nAAAAA\", \"4 87042533\\nAABB\", \"5 2\\nAAABA\", \"5 1\\nAAABA\", \"5 3\\nAAABA\", \"5 1\\nAAAAB\", \"5 2\\nAAAAA\", \"5 1\\nAAABB\", \"5 3\\nAAAAA\", \"5 2\\nAAAAB\", \"5 1\\nAABBB\", \"5 2\\nAABAA\", \"5 1\\nABAAB\", \"5 2\\nAAABB\", \"1 3623191\\nBAAA\", \"1 47200304\\nBABA\", \"5 1\... | Takahashi has a lot of peculiar devices. These cylindrical devices receive balls from left and right. Each device is in one of the two states A and B, and for each state, the device operates as follows:
* When a device in state A receives a ball from either side (left or right), the device throws out the ball from the... | 0.125 |
{"tests": "{\"inputs\": [\"9\\nabbaaababaababbabb\", \"9\\nabbbaababbaaabbaba\", \"9\\naabaaabbbaababbabb\", \"9\\nababbaaabbabaabbba\", \"6\\naaababbaabbb\", \"6\\naaabbbbaaabb\", \"6\\naaabbbabaabb\", \"3\\nbabbaa\", \"6\\nbbaababbbaaa\", \"9\\nbbabbabaababaaabba\", \"3\\naabbba\", \"6\\nbbbabaabbaaa\", \"3\\nbababa\... | You are given a string S of length 2N, containing N occurrences of `a` and N occurrences of `b`.
You will choose some of the characters in S. Here, for each i = 1,2,...,N, it is not allowed to choose exactly one of the following two: the i-th occurrence of `a` and the i-th occurrence of `b`. (That is, you can only cho... | 0 |
{"tests": "{\"inputs\": [\"8\\n1 4\\n10 5\\n3 3\\n4 11\\n8 9\\n22 40\\n8 36\\n314159265 358979323\\n\", \"99\\n207579013 207579013\\n376140463 376140463\\n186969586 186969586\\n326402540 326402540\\n158176573 158176573\\n127860890 127860890\\n570870045 570870045\\n178509023 178509023\\n61263305 61263305\\n558212775 558... | 10^{10^{10}} participants, including Takahashi, competed in two programming contests.
In each contest, all participants had distinct ranks from first through 10^{10^{10}}-th.
The score of a participant is the product of his/her ranks in the two contests.
Process the following Q queries:
- In the i-th query, you are gi... | 0 |
{"tests": "{\"inputs\": [\"16677181699666569\\n\", \"52013157885656046\\n\", \"1129718145924\\n\", \"29442431889534807\\n\", \"3\\n\", \"58061299250691018\\n\", \"81\\n\", \"2\\n\", \"10\\n\", \"93886356235159944\\n\", \"72900000000000\\n\", \"243\\n\", \"70414767176369958\\n\", \"5559060566555523\\n\", \"9999999999999... | Gerald has been selling state secrets at leisure. All the secrets cost the same: n marks. The state which secrets Gerald is selling, has no paper money, only coins. But there are coins of all positive integer denominations that are powers of three: 1 mark, 3 marks, 9 marks, 27 marks and so on. There are no coins of oth... | 0 |
{"tests": "{\"inputs\": [\"4 2\\n\", \"1 10\\n\", \"6 3\\n\", \"1000000000 1000000000\\n\", \"1 1\\n\", \"1 1000000000\\n\", \"1000000000 1\\n\", \"1 660938501\\n\", \"2 61108425\\n\", \"3 563031691\\n\", \"4 989494029\\n\", \"1000000000 146388030\\n\", \"1000000000 121963892\\n\", \"1000000000 33979032\\n\", \"1000000... | Takahashi and Aoki are going to together construct a sequence of integers.
First, Takahashi will provide a sequence of integers a, satisfying all of the following conditions:
- The length of a is N.
- Each element in a is an integer between 1 and K, inclusive.
- a is a palindrome, that is, reversing the order of ele... | 0 |
{"tests": "{\"inputs\": [\"2 1 4\\n1 5 3\\n3 3 10\\n7 10 2\\n6 4 8\\n\", \"1 5 2\\n1 5 10\\n2 7 4\\n\", \"1 1 4\\n1 1000000 1000000\\n1 1 1000000\\n1 1000000 1\\n1 1 1\\n\", \"1000000 1000000 1\\n1000000 1000000 1000000\\n\", \"999999 1000000 1\\n1 1000000 1000000\\n\", \"1 1000000 1\\n1 1000000 1000000\\n\", \"1 5000 ... | Karafs is some kind of vegetable in shape of an 1 × h rectangle. Tavaspolis people love Karafs and they use Karafs in almost any kind of food. Tavas, himself, is crazy about Karafs. [Image]
Each Karafs has a positive integer height. Tavas has an infinite 1-based sequence of Karafses. The height of the i-th Karafs is ... | 0 |
{"tests": "{\"inputs\": [[[{\"name\": \"Linda\", \"results\": [\"XXO\", \"O\", \"XXO\", \"O\"]}, {\"name\": \"Vickie\", \"results\": [\"O\", \"X\", \"\", \"\"]}, {\"name\": \"Debbie\", \"results\": [\"XXO\", \"O\", \"XO\", \"XXX\"]}, {\"name\": \"Michelle\", \"results\": [\"XO\", \"XO\", \"XXX\", \"\"]}, {\"name\": \"C... | Your task is to determine the top 3 place finishes in a pole vault competition involving several different competitors. This is isn't always so simple, and it is often a source of confusion for people who don't know the actual rules.
Here's what you need to know:
As input, you will receive an array of objects. Each o... | 0 |
{"tests": "{\"inputs\": [[[1]], [[5]], [[1, 1]], [[5, 5]], [[5, 1]], [[5, 6]], [[1, 1, 1]], [[2, 2, 2]], [[3, 3, 3]], [[4, 4, 4]], [[5, 5, 5]], [[6, 6, 6]], [[1, 2, 1]], [[1, 1, 5]], [[5, 5, 6]], [[1, 5, 5]], [[1, 1, 1, 1]], [[2, 2, 2, 2]], [[3, 3, 3, 3]], [[4, 4, 4, 4]], [[5, 5, 5, 5]], [[6, 6, 6, 6]], [[1, 5, 5, 1]],... | Zonk is addictive dice game. In each round player rolls 6 dice. Then (s)he composes combinations from them. Each combination gives certain points.
Then player can take one or more dice combinations to his hand and re-roll remaining dice or save his score. Dice in player's hand won't be taken into account in subsequen... | 0 |
{"tests": "{\"inputs\": [\"3 0\\n\", \"3 1\\n2 > 3\\n\", \"4 1\\n3 = 6\\n\", \"5 2\\n1 < 2\\n9 > 10\\n\", \"35 0\\n\", \"10 5\\n17 <= 10\\n16 >= 18\\n9 > 18\\n8 = 8\\n6 >= 13\\n\", \"5 2\\n1 = 10\\n2 = 9\\n\", \"3 3\\n1 = 2\\n3 = 4\\n5 = 6\\n\", \"4 3\\n2 > 3\\n4 > 5\\n6 > 7\\n\", \"1 1\\n1 > 2\\n\", \"1 1\\n1 <= 2\\n\... | King of Berland Berl IV has recently died. Hail Berl V! As a sign of the highest achievements of the deceased king the new king decided to build a mausoleum with Berl IV's body on the main square of the capital.
The mausoleum will be constructed from 2n blocks, each of them has the shape of a cuboid. Each block has th... | 0 |
{"tests": "{\"inputs\": [\"0 55\\n0 1\\n0 2\\n0 3\\n10 1\\n10 2\\n10 3\\n10 4\\n10 5\\n10 6\\n11 1\\n11 2\\n11 3\\n100001 100\\n-1 -1\", \"0 55\\n0 1\\n0 2\\n0 3\\n10 1\\n10 2\\n10 3\\n10 4\\n10 5\\n10 1\\n11 1\\n11 2\\n11 3\\n100001 100\\n-1 -1\", \"0 55\\n0 1\\n0 2\\n0 3\\n10 1\\n10 2\\n10 3\\n10 4\\n10 5\\n19 6\\n11... | Professor Matsuzaki is a scientist studying the truth of the universe. Life, the universe, all the answers are said to be 42, but Professor Matsuzaki thinks that this alone is not enough to elucidate the truth of the universe. Professor Matsuzaki believes that the truth of the universe is represented by a function cons... | 0 |
{"tests": "{\"inputs\": [\"3 4\\n0 3 1\\n0 2 3 0\\n\", \"1 1\\n0\\n1\\n\", \"19 16\\n16 16 16 16 15 15 0 5 0 4 9 9 1 4 4 0 8 16 12\\n6 12 19 15 8 6 19 19 14 6 9 16 10 11 15 4\\n\", \"4 4\\n2 0 3 1\\n1 3 0 3\\n\", \"3 6\\n0 0 0\\n0 0 0 0 0 0\\n\", \"4 5\\n2 5 2 2\\n4 4 0 2 2\\n\", \"9 9\\n9 9 9 9 9 9 9 9 9\\n9 9 9 9 9 9... | Suppose there is a $h \times w$ grid consisting of empty or full cells. Let's make some definitions:
$r_{i}$ is the number of consecutive full cells connected to the left side in the $i$-th row ($1 \le i \le h$). In particular, $r_i=0$ if the leftmost cell of the $i$-th row is empty. $c_{j}$ is the number of consec... | 0 |
{"tests": "{\"inputs\": [\"1 2 11\\n\", \"576695 1234562 1234567\\n\", \"138 11711 11829\\n\", \"1000000000 100050 1000001\\n\", \"116482865 344094604 3271060\\n\", \"0 3 3\\n\", \"0 0 1\\n\", \"7004769 3114686 4659684\\n\", \"0 1 1\\n\", \"100 2 3\\n\", \"4 3 12\\n\", \"0 1000000000 10000000\\n\", \"6 4 10\\n\", \"0 7... | In a very ancient country the following game was popular. Two people play the game. Initially first player writes a string s1, consisting of exactly nine digits and representing a number that does not exceed a. After that second player looks at s1 and writes a string s2, consisting of exactly nine digits and representi... | 0 |
{"tests": "{\"inputs\": [[10], [30], [50], [100], [150], [200]], \"outputs\": [[[5, 4]], [[29, 20]], [[45, 36]], [[97, 72]], [[149, 140]], [[197, 28]]]}", "source": "taco"} | The pair of integer numbers `(m, n)`, such that `10 > m > n > 0`, (below 10), that its sum, `(m + n)`, and rest, `(m - n)`, are perfect squares, is (5, 4).
Let's see what we have explained with numbers.
```
5 + 4 = 9 = 3²
5 - 4 = 1 = 1²
(10 > 5 > 4 > 0)
```
The pair of numbers `(m, n)`, closest to and below 50, havi... | 0 |
{"tests": "{\"inputs\": [\"2 3\\na\\nb\\n\", \"3 1\\na\\nb\\nc\\n\", \"1 2\\nab\\n\", \"5 6\\nabas\\ndsfdf\\nabacaba\\ndartsidius\\nkolobok\\n\", \"4 2\\naaaa\\nbbbb\\nccccc\\ndumbavumba\\n\", \"3 8\\nso\\nbad\\ntest\\n\", \"5 2\\nwelcome\\nto\\nthe\\nmatrix\\nneo\\n\", \"6 4\\ndog\\ncat\\ncow\\nhot\\nice\\nlol\\n\", \... | Andrew, Fedor and Alex are inventive guys. Now they invent the game with strings for two players.
Given a group of n non-empty strings. During the game two players build the word together, initially the word is empty. The players move in turns. On his step player must add a single letter in the end of the word, the re... | 0 |
{"tests": "{\"inputs\": [\"5\\n100.1 90.1\\n0 0\\n0 10\\n7 5\\n10 0\\n10 10\", \"5\\n100.1 90.65666260699702\\n0 0\\n1 10\\n7 5\\n10 0\\n10 10\", \"5\\n100.1 90.1\\n0 0\\n0 10\\n5 5\\n10 0\\n10 4\", \"5\\n100.1 90.65666260699702\\n0 0\\n0 10\\n7 5\\n13 0\\n10 10\", \"5\\n100.1 90.65666260699702\\n1 0\\n1 10\\n8 10\\n10... | I'm traveling to a country with a rabbit. There are n cities in this country numbered from 1 to n, and the rabbit is now in city 1. City i is a point on the coordinate plane (xi, yi) ).
Rabbits travel to meet the following conditions.
* The travel path is a polygonal line, each part of which must be a line segment co... | 0 |
{"tests": "{\"inputs\": [\"10\\n3 5 1 3\\n0 0 1\\n2 1 4\\n2 5 2 3\\n1 0\\n3 2\\n1 20 2 4\\n0\\n16\\n6 20 2 5\\n1 1 0 1 0 0\\n0 8 2 9 11 6\\n4 16 3 6\\n1 0 1 1\\n8 3 5 6\\n6 20 3 6\\n0 1 0 0 1 0\\n20 11 3 20 16 17\\n7 17 1 6\\n1 1 0 1 0 0 0\\n1 7 0 11 10 15 10\\n6 17 2 6\\n0 0 1 0 0 1\\n7 6 3 7 10 12\\n5 17 2 5\\n1 1 1 ... | Petya has come to the math exam and wants to solve as many problems as possible. He prepared and carefully studied the rules by which the exam passes.
The exam consists of $n$ problems that can be solved in $T$ minutes. Thus, the exam begins at time $0$ and ends at time $T$. Petya can leave the exam at any integer tim... | 0 |
{"tests": "{\"inputs\": [\"2\\n3\\n3 3 3\\n4\\n1 2 3 3\", \"2\\n3\\n3 3 3\\n4\\n1 4 3 3\", \"2\\n3\\n3 5 3\\n4\\n1 2 3 3\", \"2\\n3\\n3 9 3\\n4\\n1 2 3 4\", \"2\\n3\\n3 5 4\\n4\\n1 2 3 3\", \"2\\n3\\n6 9 3\\n4\\n1 2 3 4\", \"2\\n3\\n2 3 3\\n4\\n1 1 6 6\", \"2\\n3\\n3 3 3\\n4\\n1 1 3 3\", \"2\\n3\\n5 3 2\\n4\\n1 1 3 3\"... | Read problems statements in Mandarin Chinese and Russian.
Chef loves to prepare delicious dishes. This time, Chef has decided to prepare a special dish for you, and needs to gather several apples to do so.
Chef has N apple trees in his home garden. Each tree has a certain (non-zero) number of apples on it. In order... | 0.875 |
{"tests": "{\"inputs\": [\"1 0\\n1\\n\", \"4 5\\n0 0 0 -1\\n1 2\\n2 3\\n3 4\\n1 4\\n2 4\\n\", \"2 1\\n1 1\\n1 2\\n\", \"3 3\\n0 -1 1\\n1 2\\n2 3\\n1 3\\n\", \"10 10\\n-1 -1 -1 -1 -1 -1 -1 -1 -1 -1\\n6 7\\n8 3\\n6 4\\n4 2\\n9 2\\n5 10\\n9 8\\n10 7\\n5 1\\n6 2\\n\", \"3 2\\n1 0 1\\n1 2\\n2 3\\n\", \"3 2\\n1 0 1\\n1 2\\n2... | Leha plays a computer game, where is on each level is given a connected graph with n vertices and m edges. Graph can contain multiple edges, but can not contain self loops. Each vertex has an integer d_{i}, which can be equal to 0, 1 or - 1. To pass the level, he needs to find a «good» subset of edges of the graph or ... | 0 |
{"tests": "{\"inputs\": [\"3 5\\n\", \"4 5\\n\", \"5 5\\n\", \"100000 2\\n\", \"100000 100000\\n\", \"100100 100000\", \"000000 2\", \"5 1\", \"100100 110000\", \"100111 100001\", \"100111 000101\", \"000011 001100\", \"000010 011000\", \"010010 011110\", \"011000 110111\", \"001000 110101\", \"001010 110101\", \"10010... | There is a bar of chocolate with a height of H blocks and a width of W blocks.
Snuke is dividing this bar into exactly three pieces.
He can only cut the bar along borders of blocks, and the shape of each piece must be a rectangle.
Snuke is trying to divide the bar as evenly as possible.
More specifically, he is trying ... | 0 |
{"tests": "{\"inputs\": [\"4 9 2 3\", \"3 1 3 12\", \"4 1 2 3\", \"2 1 2 3\", \"2 1 2 4\", \"3 1 2 4\", \"3 2 2 4\", \"3 4 2 4\", \"4 4 2 4\", \"4 3 2 4\", \"4 3 2 6\", \"3 3 2 6\", \"3 1 2 6\", \"3 1 2 12\", \"1 1 3 12\", \"1 1 3 7\", \"1 2 3 7\", \"1 2 5 7\", \"2 2 5 7\", \"2 2 0 7\", \"2 2 0 14\", \"0 2 0 14\", \"0 ... | J: City
Santa decides to deliver a present to a city.
The city has a rectangular shape divided into north-south $ H $ parcels x east-west $ W $ parcels, with one house delivering gifts to each parcel.
The $ X $ th section from the north and the $ Y $ th section from the west are represented by $ (X, Y) $.
Santa mov... | 0.5 |
{"tests": "{\"inputs\": [\"1 1\\n-2 1\\n4 1\\n\", \"0 0\\n36\\n-8\\n\", \"2 2\\n-4 2 1\\n-5 8 -19\\n\", \"84 54\\n82 -54 28 68 74 -61 54 98 59 67 -65 -1 16 65 -78 -16 61 -79 2 14 44 96 -62 77 51 87 37 66 65 28 88 -99 -21 -83 24 80 39 64 -65 45 86 -53 -49 94 -75 -31 -42 -1 -35 -18 74 30 31 -40 30 -6 47 58 -71 -21 20 13 ... | You are given two polynomials:
* P(x) = a0·xn + a1·xn - 1 + ... + an - 1·x + an and
* Q(x) = b0·xm + b1·xm - 1 + ... + bm - 1·x + bm.
Calculate limit <image>.
Input
The first line contains two space-separated integers n and m (0 ≤ n, m ≤ 100) — degrees of polynomials P(x) and Q(x) correspondingly.
The seco... | 0.5 |
{"tests": "{\"inputs\": [\"16\\n\", \"01.23400\\n\", \".100\\n\", \"100.\\n\", \"9000\\n\", \"0.0012\\n\", \"0001100\\n\", \"1\\n\", \"1.0000\\n\", \"2206815224318443962208128404511577750057653265995300414539703580103256087275661997018352502651118684\\n\", \".642190250125247518637240673193254850619739079359757454472743... | You are given a positive decimal number x.
Your task is to convert it to the "simple exponential notation".
Let x = a·10^{b}, where 1 ≤ a < 10, then in general case the "simple exponential notation" looks like "aEb". If b equals to zero, the part "Eb" should be skipped. If a is an integer, it should be written withou... | 0 |
{"tests": "{\"inputs\": [\"1 2 0\\n1\\n1 2 1\\n1\\n1 2 101\\n1 2 1\\n2\\n1 2 100\\n2 2 1\\n1 2\\n1 2 100\\n4 5 3\\n1 2 3 4\\n1 1 2\\n2 2 100\\n4 3 60\\n0 0 0\", \"1 2 0\\n1\\n1 2 1\\n1\\n1 2 101\\n1 2 1\\n2\\n1 2 100\\n2 2 1\\n1 2\\n1 2 100\\n4 5 3\\n1 2 3 4\\n1 1 2\\n2 2 100\\n4 3 27\\n0 0 0\", \"1 2 0\\n1\\n1 2 1\\n1... | Taro went to a toy store to buy a game of life made by Aizu Hobby. Life games are played using a board with squares and roulette. As shown in the figure, the board has one start point and one goal point, which are connected by a single grid. First, the pieces are placed in the square at the starting point, and the piec... | 0 |
{"tests": "{\"inputs\": [\"129630 805489 631548 761110 577559\\n\", \"7 9 481 961 9\\n\", \"581106 975502 703094 487920 637713\\n\", \"100 100 100 100 100\\n\", \"5 10 6361 6643 9\\n\", \"5 5 5 5 5\\n\", \"1 100000 1000 1 2\\n\", \"1 2 100 100 2\\n\", \"61097 812001 384947 188893 662044\\n\", \"1 3 100 100 3\\n\", \"10... | Bob is about to take a hot bath.
There are two taps to fill the bath: a hot water tap and a cold water tap. The cold water's temperature is t1, and the hot water's temperature is t2. The cold water tap can transmit any integer number of water units per second from 0 to x1, inclusive. Similarly, the hot water tap can ... | 0 |
{"tests": "{\"inputs\": [\"5 7\\n2 2 8 6 9\\n1 2\\n1 3\\n2 4\\n3 2\\n4 5\\n2 5\\n1 5\\n2\\n\", \"10 12\\n1 7 1 9 3 3 6 30 1 10\\n1 2\\n1 3\\n3 5\\n5 7\\n2 3\\n5 4\\n6 9\\n4 6\\n3 7\\n6 8\\n9 4\\n9 10\\n6\\n\", \"1 0\\n1000000000\\n1\\n\", \"2 1\\n999999999 2\\n1 2\\n2\\n\", \"3 2\\n1 1335 2\\n2 1\\n3 2\\n2\\n\", \"3 3\... | Alex decided to go on a touristic trip over the country.
For simplicity let's assume that the country has $n$ cities and $m$ bidirectional roads connecting them. Alex lives in city $s$ and initially located in it. To compare different cities Alex assigned each city a score $w_i$ which is as high as interesting city se... | 0 |
{"tests": "{\"inputs\": [\"2\\n3 7\\n24 25 27\\n10 7\\n51 52 53 54 55 56 57 58 59 60\\n\", \"2\\n3 7\\n24 25 27\\n10 7\\n51 52 53 54 55 56 57 58 42 60\\n\", \"2\\n3 7\\n24 25 40\\n10 7\\n51 52 53 54 55 56 57 58 42 60\\n\", \"2\\n3 7\\n24 25 40\\n10 7\\n25 52 53 54 55 54 57 58 42 60\\n\", \"2\\n3 7\\n24 25 27\\n10 7\\n7... | Nezzar's favorite digit among $1,\ldots,9$ is $d$. He calls a positive integer lucky if $d$ occurs at least once in its decimal representation.
Given $q$ integers $a_1,a_2,\ldots,a_q$, for each $1 \le i \le q$ Nezzar would like to know if $a_i$ can be equal to a sum of several (one or more) lucky numbers.
-----Input... | 0.25 |
{"tests": "{\"inputs\": [\"9\\n53 80 94 41 58 49 88 24 42\\n85 11 32 64 40 56 63 95 73\\n17 85 60 41 13 71 54 67 87\\n38 14 21 81 66 59 52 33 86\\n29 34 46 18 19 80 10 44 51\\n4 27 65 75 77 21 15 49 50\\n35 68 86 98 98 62 69 52 71\\n43 28 56 91 89 21 14 57 79\\n27 27 29 26 15 76 21 70 78\\n\", \"4\\n89 79 14 89\\n73 24... | Sherlock Holmes and Dr. Watson played some game on a checkered board n × n in size. During the game they put numbers on the board's squares by some tricky rules we don't know. However, the game is now over and each square of the board contains exactly one number. To understand who has won, they need to count the number... | 0.75 |
{"tests": "{\"inputs\": [\"3\\n1\\n1\\n5\\n1 4 5 9 10\\n2\\n3 4\\n\", \"3\\n1\\n1\\n5\\n1 4 5 9 10\\n2\\n1 4\\n\", \"3\\n1\\n1\\n5\\n1 4 5 9 10\\n2\\n2 4\\n\", \"3\\n1\\n1\\n5\\n1 4 5 7 10\\n2\\n1 4\\n\", \"3\\n1\\n1\\n5\\n1 4 5 8 10\\n2\\n2 4\\n\", \"3\\n1\\n1\\n5\\n1 2 5 9 10\\n2\\n2 4\\n\", \"3\\n1\\n1\\n5\\n1 2 5 9... | You have $2n$ integers $1, 2, \dots, 2n$. You have to redistribute these $2n$ elements into $n$ pairs. After that, you choose $x$ pairs and take minimum elements from them, and from the other $n - x$ pairs, you take maximum elements.
Your goal is to obtain the set of numbers $\{b_1, b_2, \dots, b_n\}$ as the result of... | 0 |
{"tests": "{\"inputs\": [\"6 7 1 6\\n1 2 2\\n1 3 10\\n2 3 7\\n2 4 8\\n3 5 3\\n4 5 2\\n5 6 1\\n\", \"3 3 1 3\\n1 2 10\\n2 3 10\\n1 3 100\\n\", \"2 2 1 2\\n1 2 1\\n1 2 2\\n\", \"2 1 1 2\\n1 2 1\\n\", \"3 3 1 3\\n1 2 10\\n2 3 10\\n1 3 19\\n\", \"4 3 1 4\\n1 2 1\\n2 3 1\\n3 4 1\\n\", \"4 4 1 4\\n1 2 1\\n2 3 1\\n3 4 1\\n1 3... | Berland has n cities, the capital is located in city s, and the historic home town of the President is in city t (s ≠ t). The cities are connected by one-way roads, the travel time for each of the road is a positive integer.
Once a year the President visited his historic home town t, for which his motorcade passes alo... | 0 |
{"tests": "{\"inputs\": [\"3\\n1 2 1 3\\n\", \"1\\n1 1\\n\", \"32\\n29 19 7 10 26 32 27 4 11 20 2 8 16 23 5 14 6 12 17 22 18 30 28 24 15 1 25 3 13 21 19 31 9\\n\", \"3\\n1 3 1 3\", \"3\\n1 0 0 2\", \"3\\n1 3 2 1\", \"3\\n1 3 1 2\", \"3\\n1 0 1 2\", \"3\\n1 0 1 0\", \"3\\n1 0 2 0\", \"3\\n2 0 2 0\", \"3\\n1 3 2 3\", \"3... | You are given an integer sequence of length n+1, a_1,a_2,...,a_{n+1}, which consists of the n integers 1,...,n.
It is known that each of the n integers 1,...,n appears at least once in this sequence.
For each integer k=1,...,n+1, find the number of the different subsequences (not necessarily contiguous) of the given se... | 0 |
{"tests": "{\"inputs\": [\"0 0 10 0 1 0 0\", \"1 1 1 0 0 0 0\", \"0 0 -1 0 2 0 2\", \"4 0 1 0 0 0 0\", \"0 3 0 0 1 0 0\", \"0 3 0 0 2 0 0\", \"6 0 2 0 0 0 0\", \"11 0 2 0 0 0 0\", \"14 0 2 0 0 0 0\", \"2 5 1 0 1 2 2\", \"23 0 2 0 0 0 0\", \"1 4 0 0 4 0 3\", \"1 0 0 1 7 -1 2\", \"10 1 2 0 0 -1 0\", \"1 13 1 0 1 -1 2\", ... | A tetromino is a figure formed by joining four squares edge to edge. We will refer to the following seven kinds of tetromino as I-, O-, T-, J-, L-, S- and Z-tetrominos, respectively:
a60bcb8e9e8f22e3af51049eda063392.png
Snuke has many tetrominos. The number of I-, O-, T-, J-, L-, S- and Z-tetrominos in his possession... | 0.125 |
{"tests": "{\"inputs\": [\"3 4\\n**oo\\noo*o\\n**oo\\n\", \"3 4\\n**oo\\noo**\\n**oo\\n\", \"2 2\\noo\\no*\\n\", \"1 4\\noooo\\n\", \"5 4\\noooo\\no*oo\\noooo\\n**oo\\nooo*\\n\", \"2 4\\noooo\\no*oo\\n\", \"2 4\\noooo\\no*oo\\n\", \"5 4\\noooo\\no*oo\\noooo\\n**oo\\nooo*\\n\", \"1 2\\noo\\no*\\n\", \"5 4\\noooo\\no*oo\... | You have a large rectangular board which is divided into $n \times m$ cells (the board has $n$ rows and $m$ columns). Each cell is either white or black.
You paint each white cell either red or blue. Obviously, the number of different ways to paint them is $2^w$, where $w$ is the number of white cells.
After painting... | 0 |
{"tests": "{\"inputs\": [\"AABCCBAAB\\nABCB\\n5\\n1 3 1 2\\n2 2 2 4\\n7 9 1 1\\n3 4 2 3\\n4 5 1 3\\n\", \"AAAAAA\\nAAAAAA\\n30\\n3 4 1 2\\n3 3 4 4\\n5 6 3 4\\n3 3 2 3\\n6 6 1 5\\n2 4 4 6\\n1 6 2 5\\n6 6 3 4\\n3 5 1 4\\n4 5 3 6\\n2 3 2 4\\n3 4 4 4\\n6 6 4 6\\n3 3 2 5\\n1 5 3 3\\n4 6 1 2\\n6 6 6 6\\n3 3 3 4\\n6 6 6 6\\n5... | Alice has a string consisting of characters 'A', 'B' and 'C'. Bob can use the following transitions on any substring of our string in any order any number of times: A $\rightarrow$ BC B $\rightarrow$ AC C $\rightarrow$ AB AAA $\rightarrow$ empty string
Note that a substring is one or more consecutive characters.... | 0 |
{"tests": "{\"inputs\": [\"5 7\\n1 2 3 4 5\", \"5 7\\n1 2 3 4 4\", \"5 13\\n1 2 3 4 4\", \"5 13\\n1 2 0 4 4\", \"5 7\\n1 2 3 4 3\", \"5 13\\n1 4 3 4 4\", \"5 13\\n1 3 0 4 4\", \"5 13\\n1 3 0 4 6\", \"5 7\\n1 0 0 5 4\", \"5 6\\n0 2 4 4 6\", \"1 13\\n1 17 0 4 6\", \"5 17\\n1 6 0 4 3\", \"1 20\\n1 17 2 0 6\", \"1 10\\n1 2... | Read problems statements in Mandarin Chinese and Russian.
For positive integer x let define function F(x) = 1 * (1! + x) + 2 * (2! + x) + .. + x * (x! + x).
"k!" means factorial: k! = 1 * 2 * .. * k
Chef wants to calculate F(p_{1}) + F(p_{2}) + ... + F(p_{n}).
As answer could be large, help him, calculate value ... | 0.875 |
{"tests": "{\"inputs\": [\"7\\n3,8\\n8,1,0\\n2,7,4,4\\n4,5,2,6,5\\n2,7,4,4\\n8,1,0\\n8,3\\n7\", \"7\\n3,8\\n8,1,0\\n2,7,4,4\\n4,5,2,6,5\\n2,7,4,4\\n8,1,0\\n8,3\\n3\", \"7\\n3,8\\n8,1,0\\n2,7,4,4\\n4,5,2,6,5\\n4,4,7,2\\n8,1,0\\n8,3\\n3\", \"7\\n3,8\\n8,1,0\\n2,7,4,4\\n4,5,2,6,5\\n4,4,7,2\\n8,1,0\\n8,3\\n0\", \"7\\n3,8\\... | <image>
Arrange integers (0 or more and 99 or less) in a rhombus as illustrated in Fig. 1. Create a program that reads the data representing the rhombus and outputs the maximum value of the sum of the integers that pass when starting from the top and proceeding to the bottom according to the following rules.
* At ea... | 0 |
{"tests": "{\"inputs\": [\"[([[)[(()[])[()][]()[[[)()[][[[()[]]]()]][\\n\", \"[[]\\n\", \"()()([]]\\n\", \"[(()[])]()[()[]]\\n\", \"[[])\\n\", \"][([))][[))[[((]][([(([[)]]])([)][([([[[[([))]])][[[[[([)]]([[(((]([(](([([[)[(]])(][(((][)[[)][)(][[)[[)])))[)]))]])[([[))(([(]][))([(]]][(])]))))))[[[[[([[([)[[[)[(([)[[(][(... | A bracket sequence is a string, containing only characters "(", ")", "[" and "]".
A correct bracket sequence is a bracket sequence that can be transformed into a correct arithmetic expression by inserting characters "1" and "+" between the original characters of the sequence. For example, bracket sequences "()[]", "([... | 0 |
{"tests": "{\"inputs\": [\"12\\n3\\n2\\n1\\n1\\n2\\n3\\n2\\n2\\n2\\n1\\n1\\n3\\n12\\n3\\n2\\n1\\n1\\n2\\n5\\n2\\n1\\n3\\n2\\n1\\n3\\n0\", \"12\\n3\\n2\\n1\\n1\\n2\\n3\\n2\\n2\\n2\\n1\\n1\\n3\\n12\\n3\\n2\\n2\\n1\\n2\\n5\\n2\\n1\\n3\\n2\\n1\\n3\\n0\", \"12\\n3\\n2\\n1\\n1\\n2\\n3\\n2\\n0\\n2\\n1\\n1\\n3\\n12\\n3\\n2\\n1... | problem
There are the following games.
N characters are lined up in a vertical row. The color of these characters is red, blue, or yellow, and in the initial state, four or more characters of the same color are not lined up in a row. The player can select a character at a certain position and change it to another col... | 0 |
{"tests": "{\"inputs\": [[[1, 2, 3, 4, 0]], [[16, 17, 4, 3, 5, 2]], [[-1, -29, -26, -2]], [[-36, -12, -27]], [[5, 2]], [[0, -1, -29, 3, 2]]], \"outputs\": [[[4]], [[17, 5, 2]], [[-1]], [[-36, -12]], [[5, 2]], [[0, -1, 3, 2]]]}", "source": "taco"} | # Definition
An **_element is leader_** *if it is greater than The Sum all the elements to its right side*.
____
# Task
**_Given_** an *array/list [] of integers* , **_Find_** *all the **_LEADERS_** in the array*.
___
# Notes
* **_Array/list_** size is *at least 3* .
* **_Array/list's numbers_** Will be **_mixt... | 0.25 |
{"tests": "{\"inputs\": [\"2 7\\n\", \"9 36\\n\", \"1 1\\n\", \"1 4\\n\", \"10 1\\n\", \"10 10\\n\", \"10 40\\n\", \"10 39\\n\", \"77 1\\n\", \"77 13\\n\", \"77 53\\n\", \"100 1\\n\", \"100 13\\n\", \"100 77\\n\", \"100 103\\n\", \"3 9\\n\", \"100 199\\n\", \"10 10\\n\", \"10 39\\n\", \"1 1\\n\", \"100 1\\n\", \"100 20... | Consider 2n rows of the seats in a bus. n rows of the seats on the left and n rows of the seats on the right. Each row can be filled by two people. So the total capacity of the bus is 4n.
Consider that m (m ≤ 4n) people occupy the seats in the bus. The passengers entering the bus are numbered from 1 to m (in the order... | 0.625 |
{"tests": "{\"inputs\": [\"5 5 0\\n3 1 3\\n832224 636838 995053 211585 505442 341920\\n\", \"34271 -17508 -6147\\n456 567 112\\n804178 307516 306399 18981 989216 228388\\n\", \"967 -1346 2551\\n769 331 28\\n458319 885170 877010 533360 723416 248230\\n\", \"-263980 -876063 613611\\n2 3 14\\n63640 300066 460766 222639 51... | One day Vasya was going home when he saw a box lying on the road. The box can be represented as a rectangular parallelepiped. Vasya needed no time to realize that the box is special, as all its edges are parallel to the coordinate axes, one of its vertices is at point (0, 0, 0), and the opposite one is at point (x1, y1... | 0.125 |
{"tests": "{\"inputs\": [\"10 45 9\\n2 1 428\\n3 1 610\\n3 2 357\\n4 1 855\\n4 2 528\\n4 3 508\\n5 1 425\\n5 2 185\\n5 3 349\\n5 4 845\\n6 1 206\\n6 2 969\\n6 3 153\\n6 4 854\\n6 5 640\\n7 1 87\\n7 2 250\\n7 3 953\\n7 4 456\\n7 5 742\\n7 6 588\\n8 1 641\\n8 2 898\\n8 3 396\\n8 4 960\\n8 5 654\\n8 6 410\\n8 7 640\\n9 1 ... | A country called Berland consists of n cities, numbered with integer numbers from 1 to n. Some of them are connected by bidirectional roads. Each road has some length. There is a path from each city to any other one by these roads. According to some Super Duper Documents, Berland is protected by the Super Duper Missile... | 0 |
{"tests": "{\"inputs\": [\"7\\n1 2 1 2 7 4 7\\n\", \"13\\n1 2 3 2 1 3 3 4 5 5 5 4 7\\n\", \"3\\n1 1 2\\n\", \"3\\n1 1 1\\n\", \"3\\n1 2 1\\n\", \"3\\n1 2 2\\n\", \"3\\n1 2 3\\n\"], \"outputs\": [\"2\\n\", \"7\\n\", \"0\\n\", \"1\\n\", \"1\\n\", \"0\\n\", \"0\\n\"]}", "source": "taco"} | You are given $n$ elements numbered from $1$ to $n$, the element $i$ has value $a_i$ and color $c_i$, initially, $c_i = 0$ for all $i$.
The following operation can be applied:
Select three elements $i$, $j$ and $k$ ($1 \leq i < j < k \leq n$), such that $c_i$, $c_j$ and $c_k$ are all equal to $0$ and $a_i = a_k$, the... | 0 |
{"tests": "{\"inputs\": [\"12\\n-83240790 -33942371\\n-83240805 -33942145\\n-83240821 -33941752\\n-83240424 -33941833\\n-83240107 -33942105\\n-83239958 -33942314\\n-83239777 -33942699\\n-83239762 -33942925\\n-83239746 -33943318\\n-83240143 -33943237\\n-83240460 -33942965\\n-83240609 -33942756\\n\", \"3\\n51800836 -5590... | You are given n points on the plane. The polygon formed from all the n points is strictly convex, that is, the polygon is convex, and there are no three collinear points (i.e. lying in the same straight line). The points are numbered from 1 to n, in clockwise order.
We define the distance between two points p_1 = (x_1... | 0 |
{"tests": "{\"inputs\": [\"3\\n2\\n5 orange\\n2 white\\n\", \"2\\n2\\n1 white\\n2 white\\n\", \"10\\n3\\n1 blue\\n4 red\\n5 orange\\n\", \"1\\n1\\n1 white\\n\", \"3\\n1\\n7 yellow\\n\", \"1\\n1\\n1 yellow\\n\", \"2\\n2\\n1 green\\n3 red\\n\", \"5\\n9\\n31 yellow\\n30 green\\n26 yellow\\n13 red\\n2 red\\n22 white\\n12 r... | It is the hard version of the problem. The difference is that in this version, there are nodes with already chosen colors.
Theofanis is starving, and he wants to eat his favorite food, sheftalia. However, he should first finish his homework. Can you help him with this problem?
You have a perfect binary tree of $2^k -... | 0 |
{"tests": "{\"inputs\": [\"0 1\\n1 999999999 1\\n\", \"0 5\\n1 96762320 50510976\\n243235878 312125306 50510976\\n326016273 338641867 50510976\\n385105810 445224816 50510976\\n456157384 569789185 50510976\\n\", \"4 7\\n1\\n2\\n3\\n4\\n1 1000000000 1\\n1 1000000000 2\\n1 1000000000 3\\n1 1000000000 4\\n1 1000000000 5\\n... | On a chessboard with a width of 10^9 and a height of 10^9, the rows are numbered from bottom to top from 1 to 10^9, and the columns are numbered from left to right from 1 to 10^9. Therefore, for each cell of the chessboard you can assign the coordinates (x,y), where x is the column number and y is the row number.
Ever... | 0 |
{"tests": "{\"inputs\": [\"2\\n4\\n1.000 31.000\\n12 3\\n20 6\\n30 1\\n5 1\\n3\\n1.000 30.000\\n1 10\\n10 10\\n20 8\\n\", \"2\\n4\\n1.000 31.000\\n12 3\\n20 6\\n30 1\\n5 1\\n3\\n1.000 30.000\\n1 10\\n10 8\\n20 8\\n\", \"2\\n4\\n1.000 31.000\\n12 0\\n20 6\\n31 0\\n5 0\\n3\\n1.000 30.000\\n1 10\\n10 8\\n20 5\\n\", \"2\\n... | Polycarp, Arkady's friend, prepares to the programming competition and decides to write a contest. The contest consists of $n$ problems and lasts for $T$ minutes. Each of the problems is defined by two positive integers $a_i$ and $p_i$ — its difficulty and the score awarded by its solution.
Polycarp's experience sugge... | 0 |
{"tests": "{\"inputs\": [\"4 3\\n2 14 3 4\\n\", \"5 2\\n0 2 1 255 254\\n\", \"10 3\\n112 184 161 156 118 231 191 128 91 229\\n\", \"9 3\\n174 149 118 124 166 146 219 233 107\\n\", \"8 4\\n180 195 13 195 61 24 132 160\\n\", \"1 4\\n51\\n\", \"2 4\\n218 213\\n\", \"3 3\\n212 167 3\\n\", \"100 7\\n39 242 238 155 95 30 129... | Professor Ibrahim has prepared the final homework for his algorithm’s class. He asked his students to implement the Posterization Image Filter.
Their algorithm will be tested on an array of integers, where the $i$-th integer represents the color of the $i$-th pixel in the image. The image is in black and white, theref... | 0 |
{"tests": "{\"inputs\": [[\"5 3 3\", \"0 3 8 5 12\", \"1 2\", \"1 3\", \"2 5\"], \"5 3 3\\n0 3 8 5 12\\n1 2\\n1 3\\n1 5\", \"5 3 3\\n0 3 8 8 12\\n1 3\\n1 3\\n2 5\", \"5 3 3\\n0 3 8 8 12\\n1 2\\n1 3\\n2 5\", \"5 6 3\\n0 3 8 8 12\\n1 2\\n1 3\\n2 5\", \"5 3 1\\n0 3 8 8 12\\n1 3\\n1 3\\n2 5\", \"5 3 3\\n0 3 15 8 12\\n1 2\\... | Nobody knows, but $N$ frogs live in Chef's garden.
Now they are siting on the X-axis and want to speak to each other. One frog can send a message to another one if the distance between them is less or equal to $K$.
Chef knows all $P$ pairs of frogs, which want to send messages. Help him to define can they or not!
Note ... | 0.25 |
{"tests": "{\"inputs\": [\"4 6\\ns 0 2\\ns 1 2\\ns 2 1\\nw 0\\ns 3 3\\ns 4 2\\n3 3\\ns 0 1\\ns 1 1\\ns 2 1\\n0 0\", \"4 6\\ns 0 2\\ns 1 3\\ns 2 1\\nw 0\\ns 3 3\\ns 4 2\\n3 3\\ns 0 1\\ns 0 1\\ns 2 1\\n0 0\", \"4 6\\ns 0 2\\ns 1 2\\ns 2 1\\nw 0\\ns 3 3\\ns 4 2\\n4 3\\ns 0 1\\ns 1 2\\ns 2 1\\n0 0\", \"4 6\\ns 0 3\\ns 1 3\... | Jack loved his house very much, because his lovely cats take a nap on the wall of his house almost every day. Jack loved cats very much.
Jack decided to keep an observation diary of the cats as a free study during the summer vacation. After observing for a while, he noticed an interesting feature of the cats.
The fen... | 0 |
{"tests": "{\"inputs\": [\"23\\n1 1 1\\n2 2 1\", \"23\\n1 2 1\\n2 1 1\", \"23\\n1 2 1\\n2 0 1\", \"23\\n0 2 1\\n2 0 1\", \"23\\n1 1 2\\n1 1 0\", \"23\\n1 1 1\\n2 0 1\", \"23\\n1 4 1\\n2 1 1\", \"23\\n1 1 2\\n2 3 0\", \"23\\n0 2 1\\n4 0 1\", \"23\\n1 8 1\\n2 1 1\", \"23\\n0 2 1\\n1 0 1\", \"23\\n1 1 2\\n2 0 0\", \"23\\n... | The squirrel Chokudai has N acorns. One day, he decides to do some trades in multiple precious metal exchanges to make more acorns.
His plan is as follows:
1. Get out of the nest with N acorns in his hands.
2. Go to Exchange A and do some trades.
3. Go to Exchange B and do some trades.
4. Go to Exchange A and do some... | 0 |
{"tests": "{\"inputs\": [\"5 6\\n1 2 3 4 5\\n\", \"5 5\\n1 2 3 4 5\\n\", \"4 3\\n1 3 2 3\\n\", \"5 1000000000\\n500000000 500000000 500000000 500000000 500000000\\n\", \"5 999999999\\n500000000 500000000 500000000 500000000 500000000\\n\", \"6 1000000000\\n999999995 999999996 999999997 999999998 999999999 1000000000\\n... | Monocarp wants to watch $n$ videos. Each video is only one minute long, but its size may be arbitrary. The $i$-th video has the size $a_i$ megabytes. All videos are published on the Internet. A video should be downloaded before it can be watched. Monocarp has poor Internet connection — it takes exactly $1$ minute to do... | 0 |
{"tests": "{\"inputs\": [\"1\\n5\\n0 0\\n0 1\\n0 2\\n0 3\\n12\\n0 0\\n1 1\\n2 0\\n3 1\\n4 1\\n5 1\\n6 2\\n7 2\\n8 2\\n9 3\\n10 3\\n10\\n0 2\\n1 2\\n2 2\\n3 2\\n2 1\\n5 1\\n6 1\\n7 1\\n8 1\\n0\", \"1\\n5\\n0 0\\n0 1\\n0 2\\n0 3\\n12\\n0 0\\n1 0\\n2 0\\n3 1\\n4 1\\n5 1\\n6 2\\n7 2\\n8 2\\n9 3\\n10 3\\n10\\n0 2\\n1 3\\n2 ... | Pablo Squarson is a well-known cubism artist. This year's theme for Pablo Squarson is "Squares". Today we are visiting his studio to see how his masterpieces are given birth.
At the center of his studio, there is a huuuuuge table and beside it are many, many squares of the same size. Pablo Squarson puts one of the squ... | 0.875 |
{"tests": "{\"inputs\": [\"4\\n1 2 10\\n2 3 10\\n3 3 10\\n1 3 10\\n6\\n1 20 1000\\n3 25 10000\\n5 15 5000\\n22 300 5500\\n10 295 9000\\n7 7 6000\\n8\\n32 251 2261\\n123 281 1339\\n211 235 5641\\n162 217 7273\\n22 158 7851\\n194 198 9190\\n119 274 878\\n122 173 8640\\n0\", \"4\\n1 2 10\\n2 3 10\\n3 3 10\\n1 3 10\\n6\\n1... | You are appointed director of a famous concert hall, to save it from bankruptcy. The hall is very popular, and receives many requests to use its two fine rooms, but unfortunately the previous director was not very efficient, and it has been losing money for many years. The two rooms are of the same size and arrangement... | 0 |
{"tests": "{\"inputs\": [\"3\\n())\\n\", \"6\\n)))())\\n\", \"8\\n))))((((\\n\", \"8\\n(((())))\", \"3\\n)()\", \"6\\n)())))\", \"3\\n)))\", \"6\\n())())\", \"6\\n))())(\", \"6\\n))(()(\", \"8\\n))))(()(\", \"6\\n)))()(\", \"8\\n)((())))\", \"6\\n()(())\", \"6\\n)(())(\", \"8\\n))))((()\", \"8\\n))((()))\", \"6\\n())((... | You are given a string S of length N consisting of ( and ). Your task is to insert some number of ( and ) into S to obtain a correct bracket sequence.
Here, a correct bracket sequence is defined as follows:
- () is a correct bracket sequence.
- If X is a correct bracket sequence, the concatenation of (, X and ) in... | 0.625 |
{"tests": "{\"inputs\": [\"3\\n0\\n\", \"300\\n1100100\\n\", \"5000\\n01000001011101000100001101101111011001000110010101110010000\\n\", \"5000\\n01000001011101010100001101101111011001000110010101110010000\", \"3\\n-1\", \"300\\n1100000\", \"3\\n-122\", \"3\\n1\", \"5000\\n01000001011001010100001101101111011001000110010... | Sig has built his own keyboard. Designed for ultimate simplicity, this keyboard only has 3 keys on it: the 0 key, the 1 key and the backspace key.
To begin with, he is using a plain text editor with this keyboard. This editor always displays one string (possibly empty). Just after the editor is launched, this string is... | 0 |
{"tests": "{\"inputs\": [\"2 2\\n\", \"3 3\\n\", \"1 4\\n\", \"1 6\\n\", \"7 1\\n\", \"7 2\\n\", \"2 3\\n\", \"2 5\\n\", \"4 3\\n\", \"5 5\\n\", \"233 233\\n\", \"1000000000 1000000000\\n\", \"1 1\\n\", \"2 1\\n\", \"3 1\\n\", \"1 8\\n\", \"9 1\\n\", \"1 10\\n\", \"1 74074073\\n\", \"666666666 1\\n\", \"1 6144668\\n\",... | Little C loves number «3» very much. He loves all things about it.
Now he is playing a game on a chessboard of size $n \times m$. The cell in the $x$-th row and in the $y$-th column is called $(x,y)$. Initially, The chessboard is empty. Each time, he places two chessmen on two different empty cells, the Manhattan dist... | 0 |
{"tests": "{\"inputs\": [\"4\\n1 1 1\\n1 1 2\\n100 50 200\\n56220 47258 14497\\n\", \"1\\n1000000000000000000 500000000000000000 2\\n\", \"1\\n1000000000000000000 483271866988016482 2\\n\", \"4\\n1 1 1\\n1 0 2\\n100 50 200\\n56220 47258 14497\\n\", \"1\\n1000000000000000000 639232692548497767 2\\n\", \"4\\n1 1 1\\n0 0 ... | Theofanis decided to visit his uncle's farm. There are $s$ animals and $n$ animal pens on the farm. For utility purpose, animal pens are constructed in one row.
Uncle told Theofanis that a farm is lucky if you can distribute all animals in all pens in such a way that there are no empty pens and there is at least one c... | 0 |
{"tests": "{\"inputs\": [[\"123\", 10], [\"1234\", 10], [\"12345\", 10], [\"12365\", 10], [\"123220\", 10], [\"50041\", 6], [\"140410\", 6], [\"203230\", 6], [\"30043052\", 6]], \"outputs\": [[true], [false], [false], [true], [false], [true], [true], [true], [true]]}", "source": "taco"} | ### Background
I was reading a [book](http://www.amazon.co.uk/Things-Make-Do-Fourth-Dimension/dp/1846147646/) recently, "Things to Make and Do in the Fourth Dimension" by comedian and mathematician Matt Parker, and in the first chapter of the book Matt talks about problems he likes to solve in his head to take his min... | 0 |
{"tests": "{\"inputs\": [\"@\\n\", \"_@0.z\\n\", \"0000000a@000a111.r\\n\", \"a@0.\\n\", \"@0.z\\n\", \"@1.r\\n\", \"0@0.x\\n\", \"a@r.z\\n\", \"a@0z\\n\", \"a@.z\\n\", \"a_0.z\\n\", \"a0.z\\n\", \"@.\\n\", \"a@0._\\n\", \"a@\\n\", \"a@_.z\\n\", \"a@0.z\\n\", \"a\\n\", \".\\n\", \"0\\n\", \"a@0.1\\n\", \"A\\n\", \"b@r.... | One of the most important products of the R1 company is a popular @r1.com mail service. The R1 mailboxes receive and send millions of emails every day.
Today, the online news thundered with terrible information. The R1 database crashed and almost no data could be saved except for one big string. The developers assume ... | 0.5 |
{"tests": "{\"inputs\": [\"5\\n4 3 2\\n2 3 5\\n4 1 2\\n\", \"5\\n4 5 3\\n2 5 1\\n1 3 5\\n\", \"6\\n1 6 5\\n4 5 1\\n2 4 1\\n4 2 3\\n\", \"7\\n7 6 5\\n7 2 1\\n6 7 1\\n1 2 3\\n5 4 6\\n\", \"5\\n1 2 3\\n2 3 4\\n3 4 5\\n\", \"5\\n5 4 3\\n4 3 2\\n3 2 1\\n\", \"5\\n5 2 3\\n4 5 3\\n1 5 4\\n\", \"5\\n2 3 1\\n5 1 3\\n5 3 4\\n\",... | Bob is an avid fan of the video game "League of Leesins", and today he celebrates as the League of Leesins World Championship comes to an end!
The tournament consisted of $n$ ($n \ge 5$) teams around the world. Before the tournament starts, Bob has made a prediction of the rankings of each team, from $1$-st to $n$-th... | 0 |
{"tests": "{\"inputs\": [\"7 5 3\\n\", \"1000000000 1 2019\\n\", \"100 100000 1\\n\", \"6 4 5\\n\", \"172165 93846 84\\n\", \"9978 99 98615\\n\", \"9909 95875 20\\n\", \"42651129 26190 16875\\n\", \"5 8253 91700\\n\", \"14712 8142 9912\\n\", \"98898 1040 98615\\n\", \"79674 62280 77850\\n\", \"78139 77688 1161\\n\", \"... | A frog is initially at position $0$ on the number line. The frog has two positive integers $a$ and $b$. From a position $k$, it can either jump to position $k+a$ or $k-b$.
Let $f(x)$ be the number of distinct integers the frog can reach if it never jumps on an integer outside the interval $[0, x]$. The frog doesn't ne... | 0 |
{"tests": "{\"inputs\": [\"3 7 6\\n\", \"7 2 4\\n\", \"1 1 1\\n\", \"1 2 1\\n\", \"1 2 2\\n\", \"17708 35362 1558\\n\", \"72657 93778 50943\\n\", \"1000 7 3\\n\", \"1000 11 20\\n\", \"100000 2 100000\\n\", \"99999 2 1\\n\", \"38133 49787 9840\\n\", \"76730 91851 71438\\n\", \"7487 17563 1102\\n\", \"46084 75979 30535\\... | You are given three positive integers x, y, n. Your task is to find the nearest fraction to fraction [Image] whose denominator is no more than n.
Formally, you should find such pair of integers a, b (1 ≤ b ≤ n; 0 ≤ a) that the value $|\frac{x}{y} - \frac{a}{b}|$ is as minimal as possible.
If there are multiple "near... | 0 |
{"tests": "{\"inputs\": [\"2\\n3\\n4\\n\", \"1\\n10000001\\n\", \"1\\n69\\n\", \"1\\n10000001\\n\", \"1\\n69\\n\", \"1\\n10001001\\n\", \"1\\n70\\n\", \"2\\n2\\n4\\n\", \"1\\n11001001\\n\", \"1\\n29\\n\", \"1\\n11011001\\n\", \"1\\n30\\n\", \"1\\n01001001\\n\", \"1\\n25\\n\", \"1\\n19\\n\", \"1\\n00001000\\n\", \"1\\n0... | One evening Rainbow Dash and Fluttershy have come up with a game. Since the ponies are friends, they have decided not to compete in the game but to pursue a common goal.
The game starts on a square flat grid, which initially has the outline borders built up. Rainbow Dash and Fluttershy have flat square blocks with si... | 0 |
{"tests": "{\"inputs\": [\"3\\nKuroo\\nShiro\\nKatie\\n\", \"7\\ntreasurehunt\\nthreefriends\\nhiCodeforces\\n\", \"1\\nabcabc\\ncbabac\\nababca\\n\", \"15\\nfoPaErcvJ\\nmZaxowpbt\\nmkuOlaHRE\\n\", \"1\\naaaaaaaaaa\\nAAAAAAcAAA\\nbbbbbbzzbb\\n\", \"60\\nddcZYXYbZbcXYcZdYbddaddYaZYZdaZdZZdXaaYdaZZZaXZXXaaZbb\\ndcdXcYbca... | After the big birthday party, Katie still wanted Shiro to have some more fun. Later, she came up with a game called treasure hunt. Of course, she invited her best friends Kuro and Shiro to play with her.
The three friends are very smart so they passed all the challenges very quickly and finally reached the destination... | 0 |
{"tests": "{\"inputs\": [\"1 3\\n\", \"2 4\\n\", \"2 8\", \"1 10\", \"1 4\", \"2 3\", \"2 10\", \"4 3\", \"7 3\", \"7 6\", \"7 4\", \"7 5\", \"4 5\", \"1 5\", \"1 2\", \"0 2\", \"-1 2\", \"2 1\", \"1 1\", \"2 0\", \"2 6\", \"3 3\", \"7 1\", \"5 4\", \"7 10\", \"5 5\", \"2 5\", \"2 9\", \"3 6\", \"5 3\", \"7 12\", \"5 8... | Based on some criterion, Snuke divided the integers from 1 through 12 into three groups as shown in the figure below.
Given two integers x and y (1 ≤ x < y ≤ 12), determine whether they belong to the same group.
-----Constraints-----
- x and y are integers.
- 1 ≤ x < y ≤ 12
-----Input-----
Input is given from Stand... | 0 |
{"tests": "{\"inputs\": [\"6\\nW 0 2\\nW 1 2\\nD 0\\nW 2 4\\nR 3\\nR 2\\n1\\nR 1000000000\\n0\", \"6\\nW 0 2\\nW 0 2\\nD 0\\nW 2 4\\nR 3\\nR 2\\n1\\nR 1000000000\\n0\", \"6\\nW 0 2\\nW 0 2\\nD -1\\nW 2 4\\nR 2\\nR 2\\n1\\nR 0000000000\\n0\", \"6\\nW 0 2\\nW 1 2\\nD 0\\nW 2 4\\nR 5\\nR 2\\n1\\nR 1000000000\\n0\", \"6\\n... | You are a programmer on the development team for new recording media. This recording medium can be randomly accessed for reading and erasing data. On the other hand, when writing data, access is always performed in order from the beginning, and only the first free space found can be written.
You have begun to build a ... | 0 |
{"tests": "{\"inputs\": [\"4 2 3\\n1 2\\n2 3 4\\n\", \"5 5 2\\n3 4 1 2 5\\n2 3\\n\", \"100 69 31\\n1 3 4 5 6 7 8 9 10 11 12 14 15 16 17 18 19 20 21 24 26 27 29 31 37 38 39 40 44 46 48 49 50 51 53 55 56 57 58 59 60 61 63 64 65 66 67 68 69 70 71 72 74 76 77 78 79 80 81 82 83 89 92 94 95 97 98 99 100\\n2 13 22 23 25 28 30... | Pasha has two hamsters: Arthur and Alexander. Pasha put n apples in front of them. Pasha knows which apples Arthur likes. Similarly, Pasha knows which apples Alexander likes. Pasha doesn't want any conflict between the hamsters (as they may like the same apple), so he decided to distribute the apples between the hamste... | 0.875 |
{"tests": "{\"inputs\": [\"3 3\\n...\\n.#.\\n...\\n5 5\\n..#..\\n.....\\n#....\\n.....\\n.....\\n3 8\\n..#.....\\n........\\n.....#..\\n3 5\\n..#..\\n-....\\n..#..\\n4 4\\n....\\n....\\n..##\\n..#.\\n0 0\", \"3 3\\n...\\n.#.\\n...\\n5 5\\n..#..\\n.....\\n#....\\n../..\\n.....\\n3 8\\n..#.....\\n........\\n..#.....\\n3 ... | Go around the Labyrinth
Explorer Taro got a floor plan of a labyrinth. The floor of this labyrinth is in the form of a two-dimensional grid. Each of the cells on the floor plan corresponds to a room and is indicated whether it can be entered or not. The labyrinth has only one entrance located at the northwest corner, ... | 0 |
{"tests": "{\"inputs\": [\"3\\n8\\n1 0\\n4 1\\n2 0\\n4 1\\n5 1\\n6 1\\n3 0\\n2 0\\n4\\n1 1\\n1 1\\n2 1\\n2 1\\n9\\n2 0\\n2 0\\n4 1\\n4 1\\n4 1\\n7 0\\n7 1\\n7 0\\n7 1\\n\", \"3\\n8\\n1 0\\n4 1\\n2 0\\n4 1\\n5 1\\n6 1\\n3 0\\n2 0\\n4\\n1 1\\n1 1\\n2 1\\n2 1\\n9\\n2 0\\n2 0\\n4 1\\n4 1\\n4 1\\n7 0\\n9 1\\n7 0\\n7 1\\n\",... | This problem is a version of problem D from the same contest with some additional constraints and tasks.
There are $n$ candies in a candy box. The type of the $i$-th candy is $a_i$ ($1 \le a_i \le n$).
You have to prepare a gift using some of these candies with the following restriction: the numbers of candies of ea... | 0 |
{"tests": "{\"inputs\": [\"10 4\\ne\\n1 2 9 10\\n\", \"1 1\\na\\n1\\n\", \"10 0\\naaa\\n\", \"100000 0\\njlasosafuywefgwefdyktfwydugewdefwdulewdopqywgdwqdiuhdbcxxiuhfiehfewhfoewihfwoiefewiugwefgiuwgfiwefuiwgefwefwppoollmmzzqaayudgsufzxcvbnmasdfghjklqwertyuiop\\n\", \"10 5\\naa\\n1 2 3 7 9\\n\", \"173700 6\\nbcabcbcbcba... | Tavas is a strange creature. Usually "zzz" comes out of people's mouth while sleeping, but string s of length n comes out from Tavas' mouth instead.
<image>
Today Tavas fell asleep in Malekas' place. While he was sleeping, Malekas did a little process on s. Malekas has a favorite string p. He determined all positions... | 0.75 |
{"tests": "{\"inputs\": [\"6 2 3 3\\n7 10 50 12 1 8\\n\", \"1 1 100 99\\n100\\n\", \"7 4 2 1\\n1 3 5 4 2 7 6\\n\", \"2 1 49 2\\n50 50\\n\", \"2 1 100 2\\n1 101\\n\", \"2 1 49 2\\n50 50\\n\", \"2 1 100 2\\n1 101\\n\", \"2 2 49 2\\n50 50\\n\", \"7 4 2 1\\n1 3 4 4 2 7 6\\n\", \"6 2 3 2\\n7 10 50 12 1 8\\n\", \"2 1 100 2\\... | There are $n$ monsters standing in a row numbered from $1$ to $n$. The $i$-th monster has $h_i$ health points (hp). You have your attack power equal to $a$ hp and your opponent has his attack power equal to $b$ hp.
You and your opponent are fighting these monsters. Firstly, you and your opponent go to the first monste... | 0 |
{"tests": "{\"inputs\": [\"1\\n3\\n6\\n-2 2 -1 1 2 2 2 -1 1 -2 -2 -2\\n3\\n-1 -1 1 -1 1 1\\n4\\n3 3 -3 3 -3 -3 3 -3\", \"1\\n3\\n6\\n-2 2 -1 1 2 2 2 -1 1 -2 -2 -2\\n3\\n-1 -1 1 -1 1 1\\n4\\n3 3 -3 1 -3 -3 3 -3\", \"1\\n2\\n6\\n0 4 -1 1 2 1 0 -1 1 -2 -3 -2\\n2\\n-1 -1 1 -1 1 0\\n2\\n3 3 -2 1 -3 -3 3 -3\", \"1\\n1\\n6\\n... | Read problems statements in Mandarin Chinese and Russian.
Chef has N simple polygons (non self intersecting polygons) in which no two of them intersect with each other. For any two polygons P_{1}, P_{2}, either P_{1} lies inside P_{2} or vice versa.
Chef wants you to count number of polygons lying strictly inside ea... | 0 |
{"tests": "{\"inputs\": [\"2\\n3 1 4 2 5 6 7 8 9 10\\n11 9 8 7 6 5 4 3 2 1\", \"2\\n3 1 4 2 5 6 7 8 1 10\\n11 9 8 7 6 5 4 3 2 1\", \"2\\n3 1 4 2 5 6 7 8 1 10\\n11 7 8 7 6 5 4 3 2 1\", \"2\\n3 1 4 2 5 6 7 5 1 10\\n11 7 8 7 6 5 4 3 2 1\", \"2\\n3 1 4 2 5 6 7 5 1 10\\n11 10 8 7 6 5 4 3 2 1\", \"2\\n3 1 4 2 5 12 7 5 1 10\\... | <image>
There is a container that is bifurcated as shown in the figure. Drop 10 balls numbered from 1 to 10 through the opening A of the container and place the balls in the left cylinder B or the right cylinder C. Since plate D can rotate left and right around the fulcrum E, you can move plate D to decide whether to... | 0.875 |
{"tests": "{\"inputs\": [\"40\\n14\\n5\\n165\\n120\\n133\\n106\\n139\\n0\", \"40\\n14\\n5\\n98\\n120\\n133\\n106\\n139\\n0\", \"40\\n14\\n5\\n98\\n120\\n133\\n106\\n150\\n0\", \"40\\n14\\n5\\n70\\n120\\n133\\n106\\n150\\n0\", \"40\\n14\\n9\\n70\\n120\\n133\\n106\\n150\\n0\", \"40\\n14\\n9\\n70\\n72\\n133\\n106\\n150\\n... | The nth triangular number is defined as the sum of the first n positive integers. The nth tetrahedral number is defined as the sum of the first n triangular numbers. It is easy to show that the nth tetrahedral number is equal to n(n+1)(n+2) ⁄ 6. For example, the 5th tetrahedral number is 1+(1+2)+(1+2+3)+(1+2+3+4)+(1+2+... | 0.875 |
{"tests": "{\"inputs\": [\"4\\n1 1 4 9\\n\", \"4\\n4 3 2 1\\n\", \"3\\n4 2 1\\n\", \"8\\n42 1337 13 37 420 666 616 97\\n\", \"10\\n319645572 758298525 812547177 459359946 355467212 304450522 807957797 916787906 239781206 242840396\\n\", \"2\\n1 1\\n\", \"2\\n500000000 1000000000\\n\", \"2\\n500000001 1000000000\\n\", \... | $n$ fishermen have just returned from a fishing vacation. The $i$-th fisherman has caught a fish of weight $a_i$.
Fishermen are going to show off the fish they caught to each other. To do so, they firstly choose an order in which they show their fish (each fisherman shows his fish exactly once, so, formally, the order... | 0 |
{"tests": "{\"inputs\": [[[\"2+3i\", \"3-i\"]], [[\"2-3i\", \"3+i\"]], [[\"3\", \"-3+i\"]], [[]], [[\"3+4i\"]], [[\"123+456i\"]], [[\"0\"]], [[\"-i\"]], [[\"1\", \"1\"]], [[\"-5\", \"5\"]], [[\"1\", \"10\", \"100\", \"1000\"]], [[\"5+4i\", \"11+3i\"]], [[\"-2-4i\", \"-8+6i\"]], [[\"-1-i\", \"7+10i\"]], [[\"3+4i\", \"3-... | Your program will receive an array of complex numbers represented as strings. Your task is to write the `complexSum` function which have to return the sum as a string.
Complex numbers can be written in the form of `a+bi`, such as `2-3i` where `2` is the real part, `3` is the imaginary part, and `i` is the "imaginary ... | 0 |
{"tests": "{\"inputs\": [\"5 6 4 14\\n1 2 3 4 5\\n1 5 2\\n1 2 5\\n2 3 5\\n3 5 3\\n\", \"3 2 5 3\\n5 2 10\\n1 2 3\\n1 1 9\\n1 1 2\\n2 2 4\\n1 2 9\\n\", \"1 1 1 4\\n2\\n1 1 5\\n\", \"5 12 2 13\\n2 4 7 19 100\\n1 4 6\\n9 11 8\\n\", \"53 1 27 3\\n44 28 48 60 29 42 59 32 9 58 3 11 7 53 4 19 37 41 36 52 29 9 24 8 31 39 52 41... | You are playing a computer game, where you lead a party of $m$ soldiers. Each soldier is characterised by his agility $a_i$.
The level you are trying to get through can be represented as a straight line segment from point $0$ (where you and your squad is initially located) to point $n + 1$ (where the boss is located).... | 0 |
{"tests": "{\"inputs\": [[\"1*0\"], [\"*\"], [\"*1\"], [\"*2\"], [\"81234567890*\"], [\"41*\"], [\"*6\"], [\"2345*345729\"], [\"34234*2\"], [\"1234567890123456789012345678*0\"]], \"outputs\": [[[\"120\", \"150\", \"180\"]], [[\"0\", \"6\"]], [[]], [[\"12\", \"42\", \"72\"]], [[\"812345678904\"]], [[\"414\"]], [[\"6\", ... | # Task
A masked number is a string that consists of digits and one asterisk (`*`) that should be replaced by exactly one digit. Given a masked number `s`, find all the possible options to replace the asterisk with a digit to produce an integer divisible by 6.
# Input/Output
`[input]` string `s`
A masked number.
`1... | 0 |
{"tests": "{\"inputs\": [\"97\\n\", \"2028\\n\", \"1\\n\", \"10\\n\", \"168\\n\", \"999999\\n\", \"987654320023456789\\n\", \"1000000000000000000\\n\", \"74774\\n\", \"2\\n\", \"3\\n\", \"4\\n\", \"5\\n\", \"6\\n\", \"7\\n\", \"8\\n\", \"9\\n\", \"101010101\\n\", \"1010101010\\n\", \"707070707070707070\\n\", \"19293\\n... | This night wasn't easy on Vasya. His favorite team lost, and he didn't find himself victorious either — although he played perfectly, his teammates let him down every time. He had to win at least one more time, but the losestreak only grew longer and longer... It's no wonder he didn't get any sleep this night at all.
... | 0 |
{"tests": "{\"inputs\": [\"4 1 1\\n1 -1 -1\\n2 1 1\\n3 1 1\\n4 -1 -1\\n\", \"3 1 0\\n-1 1 0\\n0 0 -1\\n1 -1 -2\\n\", \"3 1 0\\n0 0 0\\n1 0 0\\n2 0 0\\n\", \"10 7 -626288749\\n795312099 49439844 266151109\\n-842143911 23740808 624973405\\n-513221420 -44452680 -391096559\\n-350963348 -5068756 -160670209\\n690883790 11897... | Ghosts live in harmony and peace, they travel the space without any purpose other than scare whoever stands in their way.
There are $n$ ghosts in the universe, they move in the $OXY$ plane, each one of them has its own velocity that does not change in time: $\overrightarrow{V} = V_{x}\overrightarrow{i} + V_{y}\overrig... | 0.625 |
{"tests": "{\"inputs\": [[20, 3], [20, 4], [20, 5], [20, 15], [100, 0], [1291, 5], [1291, 56], [1291, 1234], [12910, 15], [129100, 5]], \"outputs\": [[5985], [20349], [54264], [20349], [101], [6385476296235036], [15478983586799578981605681450735426444083026237083755223526535252775423299626083333014485638841019200], [15... | In the drawing below we have a part of the Pascal's triangle, lines are numbered from **zero** (top).
The left diagonal in pale blue with only numbers equal to 1 is diagonal **zero**, then in dark green
(1, 2, 3, 4, 5, 6, 7) is diagonal 1, then in pale green (1, 3, 6, 10, 15, 21) is
diagonal 2 and so on.
We want to c... | 0 |
{"tests": "{\"inputs\": [\"2\\n10 100\\n100 270\\n2\\n10 100\\n100 280\\n3\\n100 150\\n10 360\\n40 450\\n3\\n100 150\\n9 360\\n40 440\\n2\\n100 10\\n50 200\\n2\\n100 100\\n50 110\\n1\\n15 10\\n4\\n1 10\\n2 20\\n3 100\\n90 200\\n0\", \"2\\n10 100\\n100 270\\n2\\n10 100\\n110 280\\n3\\n100 150\\n10 360\\n40 450\\n3\\n100... | "Balloons should be captured efficiently", the game designer says. He is designing an oldfashioned game with two dimensional graphics. In the game, balloons fall onto the ground one after another, and the player manipulates a robot vehicle on the ground to capture the balloons. The player can control the vehicle to mov... | 0 |
{"tests": "{\"inputs\": [\"7\\n5 7\\n3 5\\n4 5\\n2 7\\n1 3\\n3 6\\n\", \"9\\n1 4\\n4 6\\n7 8\\n2 5\\n1 8\\n3 8\\n1 9\\n1 2\\n\", \"1\\n\", \"9\\n2 4\\n3 7\\n5 7\\n6 9\\n2 5\\n2 8\\n1 8\\n5 9\\n\", \"14\\n10 12\\n8 10\\n6 8\\n4 6\\n2 4\\n1 2\\n2 3\\n3 5\\n5 7\\n7 9\\n9 11\\n10 14\\n9 13\\n\", \"9\\n1 2\\n2 3\\n3 4\\n4 5... | You have given tree consist of n vertices. Select a vertex as root vertex that satisfies the condition below.
* For all vertices v_{1} and v_{2}, if distance(root, v_{1}) = distance(root, v_{2}) then degree(v_{1}) = degree(v_{2}), where degree means the number of vertices connected to that vertex, and distance means... | 0.625 |
{"tests": "{\"inputs\": [\"1\\n20\\n2\\n10 20\\n\", \"3\\n3 2 2\\n5\\n1 5 7 7 9\\n\", \"4\\n1 3 5 7\\n4\\n7 5 3 1\\n\", \"1\\n1\\n10\\n1 2 3 4 5 6 7 8 9 10\\n\", \"1\\n148\\n1\\n40\\n\", \"4\\n77 112 81 91\\n8\\n183 174 187 111 121 21 129 28\\n\", \"10\\n80 141 15 177 191 182 115 183 36 3\\n20\\n129 114 183 94 169 16 1... | You are given an array $A$, consisting of $n$ positive integers $a_1, a_2, \dots, a_n$, and an array $B$, consisting of $m$ positive integers $b_1, b_2, \dots, b_m$.
Choose some element $a$ of $A$ and some element $b$ of $B$ such that $a+b$ doesn't belong to $A$ and doesn't belong to $B$.
For example, if $A = [2, 1... | 0 |
{"tests": "{\"inputs\": [\"50\\n16 4\\n17 9\\n31 19\\n22 10\\n8 1\\n40 30\\n3 31\\n20 29\\n47 27\\n22 25\\n32 34\\n12 15\\n40 32\\n10 33\\n47 12\\n6 24\\n46 41\\n14 23\\n12 35\\n31 42\\n46 28\\n31 20\\n46 37\\n1 39\\n29 49\\n37 47\\n40 6\\n42 36\\n47 2\\n24 46\\n2 13\\n8 45\\n41 3\\n32 17\\n4 7\\n47 26\\n28 8\\n41 50\\... | Note that this is the first problem of the two similar problems. You can hack this problem only if you solve both problems.
You are given a tree with n nodes. In the beginning, 0 is written on all edges. In one operation, you can choose any 2 distinct leaves u, v and any real number x and add x to values written on al... | 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\": [\"3 1 2\\n1 1 1\\n\", \"4 2 3\\n1 2 4 8\\n\", \"2 1 2\\n12 9\\n\", \"2 1 2\\n12 7\\n\", \"3 1 3\\n3 2 0\\n\", \"5 10 8\\n1000000000 1000000000 1000000000 1000000000 1000000000\\n\", \"1 2 3\\n612635770\\n\", \"3 2 5\\n0 2 3\\n\", \"2 1 8\\n18 17\\n\", \"5 10 8\\n0 0 0 0 0\\n\", \"1 1 2\\n1\\n\"... | You are given n numbers a_1, a_2, ..., a_{n}. You can perform at most k operations. For each operation you can multiply one of the numbers by x. We want to make [Image] as large as possible, where $1$ denotes the bitwise OR.
Find the maximum possible value of [Image] after performing at most k operations optimally.
... | 0.75 |
{"tests": "{\"inputs\": [\"4\\n8 3\\n1 2\\n1 5\\n7 6\\n6 8\\n3 1\\n6 4\\n6 1\\n10 3\\n1 2\\n1 10\\n2 3\\n1 5\\n1 6\\n2 4\\n7 10\\n10 9\\n8 10\\n7 2\\n3 1\\n4 5\\n3 6\\n7 4\\n1 2\\n1 4\\n5 1\\n1 2\\n2 3\\n4 3\\n5 3\\n\", \"4\\n8 3\\n1 2\\n1 5\\n7 6\\n6 8\\n3 1\\n6 4\\n6 1\\n10 3\\n1 2\\n1 10\\n2 3\\n1 5\\n1 6\\n2 4\\n7 ... | You are given a tree (connected graph without cycles) consisting of $n$ vertices. The tree is unrooted — it is just a connected undirected graph without cycles.
In one move, you can choose exactly $k$ leaves (leaf is such a vertex that is connected to only one another vertex) connected to the same vertex and remove th... | 0 |
{"tests": "{\"inputs\": [\"saba\\n2\\n\", \"saddastavvat\\n2\\n\", \"aaaaaaaaaa\\n3\\n\", \"aaaaaa\\n3\\n\", \"abaacca\\n2\\n\", \"a\\n1\\n\", \"princeofpersia\\n1\\n\", \"xhwbdoryfiaxglripavycmxmcejbcpzidrqsqvikfzjyfnmedxrvlnusavyhillaxrblkynwdrlhthtqzjktzkullgrqsolqssocpfwcaizhovajlhmeibhiuwtxpljkyyiwykzpmazkkzampzky... | While Mike was walking in the subway, all the stuff in his back-bag dropped on the ground. There were several fax messages among them. He concatenated these strings in some order and now he has string s.
[Image]
He is not sure if this is his own back-bag or someone else's. He remembered that there were exactly k me... | 0.75 |
{"tests": "{\"inputs\": [\"7\\nabacaba\\nbacabaa\\n\", \"5\\nzcabd\\ndbacz\\n\", \"1\\na\\nb\\n\", \"5\\nahmad\\nyogaa\\n\", \"1\\na\\nb\\n\", \"5\\nahmad\\nyogaa\\n\", \"5\\nahmad\\nyngaa\\n\", \"7\\nabacaba\\naabacab\\n\", \"5\\nzcabd\\nebacz\\n\", \"7\\nabacaaa\\naabacab\\n\", \"5\\nzcabd\\neaacz\\n\", \"5\\nzcabd\\... | You are given two strings $a$ and $b$ consisting of lowercase English letters, both of length $n$. The characters of both strings have indices from $1$ to $n$, inclusive.
You are allowed to do the following changes: Choose any index $i$ ($1 \le i \le n$) and swap characters $a_i$ and $b_i$; Choose any index $i$ ($... | 0 |
{"tests": "{\"inputs\": [\"3\\n4\\n1 2\\n2 3\\n3 4\\n2\\n2 2\\n4\\n3 4\\n1 3\\n3 2\\n2\\n3 2\\n7\\n6 1\\n2 3\\n4 6\\n7 3\\n5 1\\n3 6\\n4\\n7 5 13 3\\n\", \"4\\n3\\n3 1\\n2 1\\n4\\n22861 20707 59627 9293\\n3\\n3 1\\n1 2\\n6\\n15767 40973 20807 24419 46439 33757\\n3\\n3 2\\n1 2\\n6\\n16493 54493 10799 37529 59743 30529\\... | You are given a tree that consists of $n$ nodes. You should label each of its $n-1$ edges with an integer in such way that satisfies the following conditions: each integer must be greater than $0$; the product of all $n-1$ numbers should be equal to $k$; the number of $1$-s among all $n-1$ integers must be minimum ... | 0 |
{"tests": "{\"inputs\": [[\"Code Wars\"], [\"does\"], [\"your\"], [\"solution\"], [\"work\"], [\"for\"], [\"these\"], [\"words\"], [\"DOES\"], [\"YOUR\"], [\"SOLUTION\"], [\"WORK\"], [\"FOR\"], [\"THESE\"], [\"WORDS\"], [\"Does\"], [\"Your\"], [\"Solution\"], [\"Work\"], [\"For\"], [\"These\"], [\"Words\"], [\"A\"], [\... | # Background
My TV remote control has arrow buttons and an `OK` button.
I can use these to move a "cursor" on a logical screen keyboard to type words...
# Keyboard
The screen "keyboard" layout looks like this
#tvkb {
width : 400px;
border: 5px solid gray; border-collapse: collapse;
}
#tvkb td {
... | 0 |
{"tests": "{\"inputs\": [[\"xyz\", -23, 6], [\"xyz\", 0, 4], [\"xyz\", 19, 2], [\"xyz\", -4, -4], [\"abcdefghijklmnopqrstuvwxyz\", 29, 1], [\"Hello! How are you?\", -14, 27], [\"1x2x3x4x\", 1532, 100], [\"1x2x3x4x\", -1532, -100], [\"112233\", 0, 0], [\"112233\", -1, 0], [\"112233\", 15824, 0]], \"outputs\": [[\"yzxyzx... | Create a function that accepts 3 inputs, a string, a starting location, and a length. The function needs to simulate the string endlessly repeating in both directions and return a substring beginning at the starting location and continues for length.
Example:
```python
endless_string('xyz', -23, 6) == 'yzxyzx'
```
To... | 0 |
{"tests": "{\"inputs\": [[1], [5], [12], [42], [88], [89], [92], [100], [111], [200], [2017]], \"outputs\": [[\"A\"], [\"C#\"], [\"G#\"], [\"D\"], [\"C\"], [\"A\"], [\"C\"], [\"G#\"], [\"G\"], [\"G#\"], [\"F\"]]}", "source": "taco"} | You're continuing to enjoy your new piano, as described in Piano Kata, Part 1. You're also continuing the exercise where you start on the very first (leftmost, lowest in pitch) key on the 88-key keyboard, which (as shown below) is the note A, with the little finger on your left hand, then the second key, which is the b... | 0 |
{"tests": "{\"inputs\": [\"1 1\\n\", \"3 2\\n\", \"3 3\\n\", \"1000000000000 1048576\\n\", \"35 4\\n\", \"70 32\\n\", \"79 32\\n\", \"63 16\\n\", \"6 4\\n\", \"82 16\\n\", \"4890852 16\\n\", \"473038165 2\\n\", \"326051437 4\\n\", \"170427799 16\\n\", \"168544291 8\\n\", \"82426873 1\\n\", \"175456797 16384\\n\", \"257... | Maxim loves to fill in a matrix in a special manner. Here is a pseudocode of filling in a matrix of size (m + 1) × (m + 1):
[Image]
Maxim asks you to count, how many numbers m (1 ≤ m ≤ n) are there, such that the sum of values in the cells in the row number m + 1 of the resulting matrix equals t.
Expression (x xor y... | 0 |
{"tests": "{\"inputs\": [\"abxxxaxbxaxxxba\\naba\\n\", \"ababababababababa\\naba\\n\", \"aaaaaaaaaaa\\nb\\n\", \"a\\nbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb... | Dreamoon has a string s and a pattern string p. He first removes exactly x characters from s obtaining string s' as a result. Then he calculates <image> that is defined as the maximal number of non-overlapping substrings equal to p that can be found in s'. He wants to make this number as big as possible.
More formally... | 0 |
{"tests": "{\"inputs\": [\"10 7 6 4\", \"10 8 6 4\", \"17 8 6 4\", \"17 8 6 6\", \"2 4 1 1\", \"100000 100000 99999 72298\", \"100000 100000 43938 55555\", \"10 13 6 4\", \"17 8 5 6\", \"3 4 1 1\", \"100000 100000 99999 39553\", \"100000 100000 43938 63714\", \"10 13 9 4\", \"19 8 5 6\", \"100000 100000 99999 33630\", ... | We have a large square grid with H rows and W columns. Iroha is now standing in the top-left cell. She will repeat going right or down to the adjacent cell, until she reaches the bottom-right cell.
However, she cannot enter the cells in the intersection of the bottom A rows and the leftmost B columns. (That is, there ... | 0 |
{"tests": "{\"inputs\": [\"5 6 3\\n5 4 3 2 1\\n\", \"5 6 3\\n5 5 5 5 5\\n\", \"5 6 3\\n1 2 1 1 1\\n\", \"10 100 80\\n76 75 73 71 76 74 73 70 78 75\\n\", \"10 100 88\\n11 23 69 6 71 15 25 1 43 37\\n\", \"10 100 81\\n100 97 96 98 98 95 100 97 97 99\\n\", \"10 1000000000 34\\n262467899 490831561 793808758 450543931 364178... | Vanya smashes potato in a vertical food processor. At each moment of time the height of the potato in the processor doesn't exceed h and the processor smashes k centimeters of potato each second. If there are less than k centimeters remaining, than during this second processor smashes all the remaining potato.
Vanya h... | 0 |
{"tests": "{\"inputs\": [\"2\\n\", \"54241012609\\n\", \"4294967318\\n\", \"370758709373\\n\", \"546739553053\\n\", \"922350872881\\n\", \"442654694329\\n\", \"832972004929\\n\", \"931667836027\\n\", \"6469693230\\n\", \"9\\n\", \"243\\n\", \"549755813888\\n\", \"902076349729\\n\", \"2000006\\n\", \"916517107801\\n\", ... | Ujan has been lazy lately, but now has decided to bring his yard to good shape. First, he decided to paint the path from his house to the gate.
The path consists of n consecutive tiles, numbered from 1 to n. Ujan will paint each tile in some color. He will consider the path aesthetic if for any two different tiles wit... | 0.375 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.