info stringlengths 120 50k | question stringlengths 504 10.4k | avg@8_qwen3_4b_instruct_2507 float64 0 0.88 |
|---|---|---|
{"tests": "{\"inputs\": [\"4 3\\n1 0 2 3\\n\", \"3 10\\n10 10 10\\n\", \"3 5\\n0 0 0\\n\", \"5 6\\n6 5 6 2 2\\n\", \"50 2\\n0 1 0 1 0 0 1 0 1 1 0 1 1 1 2 2 0 2 0 2 0 2 0 0 2 2 2 0 0 0 0 1 0 1 0 0 1 0 1 0 0 1 1 0 1 1 0 1 0 0\\n\", \"1 1\\n1\\n\", \"5 5\\n4 3 5 4 1\\n\", \"6 4\\n4 4 3 3 4 4\\n\", \"1 2\\n1\\n\", \"50 500... | Initially there was an array a consisting of n integers. Positions in it are numbered from 1 to n.
Exactly q queries were performed on the array. During the i-th query some segment (l_i, r_i) (1 ≤ l_i ≤ r_i ≤ n) was selected and values of elements on positions from l_i to r_i inclusive got changed to i. The order of t... | 0 |
{"tests": "{\"inputs\": [\"4\\n\", \"3\\n\", \"1000000\\n\", \"988727\\n\", \"22\\n\", \"581472\\n\", \"796867\\n\", \"43690\\n\", \"84\\n\", \"13156\\n\", \"1\\n\", \"7\\n\", \"19\\n\", \"26\\n\", \"43689\\n\", \"621012\\n\", \"699050\\n\", \"17\\n\", \"11\\n\", \"8\\n\", \"181407\\n\", \"530259\\n\", \"259060\\n\", \... | Recall that a binary search tree is a rooted binary tree, whose nodes each store a key and each have at most two distinguished subtrees, left and right. The key in each node must be greater than any key stored in the left subtree, and less than any key stored in the right subtree.
The depth of a vertex is the number o... | 0 |
{"tests": "{\"inputs\": [\"6 5\\n1 4\\n2 4\\n3 4\\n5 4\\n6 4\\n\", \"6 3\\n1 2\\n2 3\\n3 4\\n\", \"3 3\\n1 2\\n2 3\\n3 1\\n\", \"9 33\\n5 7\\n5 9\\n9 6\\n9 1\\n7 4\\n3 5\\n7 8\\n8 6\\n3 6\\n8 2\\n3 8\\n1 6\\n1 8\\n1 4\\n4 2\\n1 2\\n2 5\\n3 4\\n8 5\\n2 6\\n3 1\\n1 5\\n1 7\\n3 2\\n5 4\\n9 4\\n3 9\\n7 3\\n6 4\\n9 8\\n7 9\... | Anna and Maria are in charge of the math club for junior students. When the club gathers together, the students behave badly. They've brought lots of shoe laces to the club and got tied with each other. Specifically, each string ties together two students. Besides, if two students are tied, then the lace connects the f... | 0.625 |
{"tests": "{\"inputs\": [\"1 7\\n0000000\\n\", \"3 5\\n0100001\\n1001001\\n1010011\\n\", \"2 5\\n0010010\\n0010010\\n\", \"10 10\\n1101001\\n0110000\\n0111010\\n0010000\\n1010000\\n0111000\\n1011011\\n1010010\\n1101011\\n1111110\\n\", \"10 10\\n1100011\\n1010011\\n0000111\\n1110110\\n0101011\\n0111111\\n1001111\\n10000... | Denis, after buying flowers and sweets (you will learn about this story in the next task), went to a date with Nastya to ask her to become a couple. Now, they are sitting in the cafe and finally... Denis asks her to be together, but ... Nastya doesn't give any answer.
The poor boy was very upset because of that. He w... | 0 |
{"tests": "{\"inputs\": [\"5 2 6 3\\n2\\n6 2 2\\n6 5 3\\n\", \"2 5 4 2\\n3\\n3 1 2\\n5 3 1\\n1 3 2\\n\", \"-210 783 -260 833\\n10\\n406 551 1000\\n372 -373 999\\n-12 -532 999\\n371 -30 999\\n258 480 558\\n648 -957 1000\\n-716 654 473\\n156 813 366\\n-870 425 707\\n-288 -426 1000\\n\", \"0 0 1 1\\n1\\n-1 -1000 1000\\n\"... | The Super Duper Secret Meeting of the Super Duper Secret Military Squad takes place in a Super Duper Secret Place. The place is an infinite plane with introduced Cartesian coordinate system. The meeting table is represented as a rectangle whose sides are parallel to the coordinate axes and whose vertexes are located at... | 0.375 |
{"tests": "{\"inputs\": [\"2 1\\n1 1 1\\n2 5\\n\", \"1 0\\n-1 3\\n2\\n\", \"1 1\\n9 0\\n-5 2\\n\", \"2 2\\n2 1 6\\n4 5 -7\\n\", \"0 1\\n1\\n1 0\\n\", \"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 ... | 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.25 |
{"tests": "{\"inputs\": [\"5\\n0 0\\n0 4\\n4 0\\n4 4\\n2 3\\n\", \"7\\n-2 -1\\n4 3\\n2 2\\n-4 0\\n-2 4\\n0 0\\n1 -3\\n\", \"10\\n-6 -4\\n-7 5\\n-7 -7\\n5 -7\\n4 -9\\n-6 7\\n2 9\\n-4 -6\\n2 10\\n-10 -4\\n\", \"4\\n0 0\\n0 5\\n5 0\\n1 1\\n\", \"6\\n-4 -3\\n-1 3\\n0 0\\n2 2\\n2 1\\n-3 1\\n\", \"4\\n-3 3\\n0 3\\n-2 -1\\n2 ... | Iahub has drawn a set of n points in the cartesian plane which he calls "special points". A quadrilateral is a simple polygon without self-intersections with four sides (also called edges) and four vertices (also called corners). Please note that a quadrilateral doesn't have to be convex. A special quadrilateral is one... | 0 |
{"tests": "{\"inputs\": [\"2 2 10\\n5 5\\n7 6\\n\", \"4 5 2\\n8 1 1 2\\n6 3 7 5 2\\n\", \"3 3 3\\n1 1 2\\n3 5 6\\n\", \"20 10 31\\n17 27 2 6 11 12 5 3 12 4 2 10 4 8 2 10 7 9 12 1\\n24 11 18 10 30 16 20 18 24 24\\n\", \"6 6 2\\n6 1 5 3 10 1\\n11 4 7 8 11 7\\n\", \"4 8 10\\n2 1 2 2\\n10 12 10 8 7 9 10 9\\n\", \"40 40 61\... | A group of n schoolboys decided to ride bikes. As nobody of them has a bike, the boys need to rent them.
The renting site offered them m bikes. The renting price is different for different bikes, renting the j-th bike costs pj rubles.
In total, the boys' shared budget is a rubles. Besides, each of them has his own pe... | 0 |
{"tests": "{\"inputs\": [\"9555\\n\", \"19992000\\n\", \"10000000005\\n\", \"45\\n\", \"800101\\n\", \"310200\\n\", \"1000000000000001223300003342220044555\\n\", \"20900000000090009000070069000026000000000000020008\\n\", \"542\\n\", \"1000000000000000000000000000000000000040050000000000000000000000000000000003002001030... | George is a cat, so he really likes to play. Most of all he likes to play with his array of positive integers b. During the game, George modifies the array by using special changes. Let's mark George's current array as b1, b2, ..., b|b| (record |b| denotes the current length of the array). Then one change is a sequence... | 0 |
{"tests": "{\"inputs\": [\"A>B\\nC<B\\nA>C\\n\", \"A<B\\nB>C\\nC>A\\n\", \"C>A\\nC<B\\nB>A\\n\", \"C<B\\nB<A\\nC>A\\n\", \"C<B\\nB>A\\nA<C\\n\", \"A>C\\nC>B\\nB<A\\n\", \"C<B\\nC<A\\nB<A\\n\", \"A>B\\nC>B\\nA<C\\n\", \"A>C\\nC<B\\nB>A\\n\", \"B>A\\nC<A\\nC>B\\n\", \"B<A\\nC>B\\nC>A\\n\", \"A>B\\nC>A\\... | One day Vasya came across three Berland coins. They didn't have any numbers that's why Vasya didn't understand how their denominations differ. He supposed that if one coin is heavier than the other one, then it should be worth more. Vasya weighed all the three pairs of coins on pan balance scales and told you the resul... | 0 |
{"tests": "{\"inputs\": [\"2\\n0 1\\n0 1\\n\", \"2\\n0 1\\n1 0\\n\", \"3\\n1 2 0\\n2 1 0\\n\", \"10\\n3 5 7 0 2 8 9 6 1 4\\n4 3 8 7 9 6 0 5 2 1\\n\", \"8\\n2 3 0 5 4 7 6 1\\n6 3 2 5 0 4 7 1\\n\", \"8\\n5 2 4 6 1 0 3 7\\n7 4 3 0 2 6 1 5\\n\", \"10\\n7 4 6 1 0 9 2 8 5 3\\n4 7 0 5 2 8 9 6 1 3\\n\", \"9\\n8 5 0 1 6 7 4 2 3... | Let's define the sum of two permutations p and q of numbers 0, 1, ..., (n - 1) as permutation <image>, where Perm(x) is the x-th lexicographically permutation of numbers 0, 1, ..., (n - 1) (counting from zero), and Ord(p) is the number of permutation p in the lexicographical order.
For example, Perm(0) = (0, 1, ..., n... | 0 |
{"tests": "{\"inputs\": [\"4\\n50 20 20 10\\n\", \"2\\n50 50\\n\", \"6\\n14 14 18 21 20 13\\n\", \"12\\n6 10 11 9 6 9 9 12 8 8 5 7\\n\", \"100\\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 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1... | A MIPT student named Misha has a birthday today, and he decided to celebrate it in his country house in suburban Moscow. n friends came by, and after a typical party they decided to play blind man's buff.
The birthday boy gets blindfolded and the other players scatter around the house. The game is played in several ro... | 0 |
{"tests": "{\"inputs\": [\"2 2 2 1\\n\", \"2 2 2 3\\n\", \"1000000 1000000 1000000 1000000000\\n\", \"1000 988 1000000 3000\\n\", \"418223 118667 573175 776998\\n\", \"2 2 2 0\\n\", \"2 1000 1000000 1000000000\\n\", \"500000 1000000 750000 100000\\n\", \"797745 854005 98703 735186\\n\", \"100500 5000 500 100000000\\n\"... | Vasya plays The Elder Trolls IV: Oblivon. Oh, those creators of computer games! What they do not come up with! Absolutely unique monsters have been added to the The Elder Trolls IV: Oblivon. One of these monsters is Unkillable Slug. Why it is "Unkillable"? Firstly, because it can be killed with cutting weapon only, so ... | 0 |
{"tests": "{\"inputs\": [\"3 9\\n\", \"5 8\\n\", \"2 12\\n\", \"1 223092870\\n\", \"415879151 194713963\\n\", \"859550004 563726557\\n\", \"417485019 230941257\\n\", \"34601 35742833\\n\", \"1000000000 1\\n\", \"1 1\\n\", \"1 9\\n\", \"741547455 471761895\\n\", \"495219 444706662\\n\", \"1 282521795\\n\", \"524 9910338... | Count the number of distinct sequences a1, a2, ..., an (1 ≤ ai) consisting of positive integers such that gcd(a1, a2, ..., an) = x and <image>. As this number could be large, print the answer modulo 109 + 7.
gcd here means the [greatest common divisor](https://en.wikipedia.org/wiki/Greatest_common_divisor).
Input
Th... | 0.875 |
{"tests": "{\"inputs\": [\"4 3\\n2\\n3\\n4\\n\", \"13 4\\n10\\n5\\n4\\n8\\n\", \"12 12\\n9\\n11\\n5\\n3\\n7\\n2\\n8\\n6\\n4\\n10\\n12\\n1\\n\", \"3 3\\n3\\n2\\n1\\n\", \"2 2\\n1\\n2\\n\", \"1 1\\n1\\n\", \"12 12\\n9\\n10\\n5\\n3\\n7\\n2\\n8\\n6\\n4\\n10\\n12\\n1\\n\", \"2 2\\n2\\n2\\n\", \"4 3\\n2\\n2\\n4\\n\", \"15 12... | Dima is a beginner programmer. During his working process, he regularly has to repeat the following operation again and again: to remove every second element from the array. One day he has been bored with easy solutions of this problem, and he has come up with the following extravagant algorithm.
Let's consider that i... | 0 |
{"tests": "{\"inputs\": [\"3 2\\n1 3 1\\n1 2 1\\n\", \"10 3\\n4 7 2\\n1 10 3\\n8 9 1\\n\", \"5 2\\n1 3 1\\n1 5 1\\n\", \"100 37\\n49 51 2\\n79 81 2\\n46 48 2\\n71 73 2\\n31 33 2\\n42 44 1\\n17 19 2\\n64 66 2\\n24 26 1\\n8 10 2\\n38 40 1\\n1 3 2\\n75 77 2\\n52 54 2\\n11 13 2\\n87 89 1\\n98 100 2\\n60 62 1\\n56 58 2\\n39... | Petya studies at university. The current academic year finishes with n special days. Petya needs to pass m exams in those special days. The special days in this problem are numbered from 1 to n.
There are three values about each exam:
* s_i — the day, when questions for the i-th exam will be published,
* d_i — t... | 0 |
{"tests": "{\"inputs\": [\"2\\n5 2 2 5\\n1 2 3 4 5\\n5 2 2 5\\n1 2 3 4 6\\n\\nSAMPLE\", \"2\\n5 2 2 5\\n1 2 3 4 9\\n5 2 2 5\\n1 2 3 4 6\\n\\nSAMPLE\", \"2\\n5 2 2 5\\n1 2 3 4 3\\n5 2 2 5\\n1 2 3 4 6\\n\\nSAMPLE\", \"2\\n5 2 2 5\\n1 2 3 4 9\\n5 1 2 5\\n1 2 3 4 6\\n\\nSAMPLE\", \"2\\n5 2 2 5\\n1 0 3 4 9\\n5 2 2 5\\n1 2 3... | Naruto is a fan of numbers, he likes to play with them. This time he decided to multiply numbers and produce output. After every k elements he decides to find x^m, where x is the multiplication till k elements and m is a random number that naruto takes. Help naruto find the output.
As answer could be large, help him,... | 0 |
{"tests": "{\"inputs\": [\"4 6\\n1 5 1 4\", \"10 10\\n10 9 8 7 6 5 4 3 2 1\", \"10 10\\n10 9 8 7 6 7 4 3 2 1\", \"4 8\\n1 5 1 4\", \"10 10\\n10 9 8 7 1 7 4 3 2 1\", \"4 8\\n1 5 1 5\", \"2 10\\n10 9 8 7 1 7 4 3 2 1\", \"1 8\\n1 5 2 1\", \"4 19\\n10 9 3 9 2 14 4 0 4 1\", \"7 19\\n10 9 3 9 2 14 4 0 4 1\", \"7 19\\n2 9 3 9... | Snuke is buying a lamp. The light of the lamp can be adjusted to m levels of brightness, represented by integers from 1 through m, by the two buttons on the remote control.
The first button is a "forward" button. When this button is pressed, the brightness level is increased by 1, except when the brightness level is m... | 0.125 |
{"tests": "{\"inputs\": [\"41 3\\n30 9\\n0 0\", \"41 3\\n21 9\\n0 0\", \"41 2\\n21 9\\n0 0\", \"75 2\\n21 9\\n0 0\", \"41 5\\n30 9\\n0 0\", \"41 4\\n21 9\\n0 0\", \"4 2\\n21 9\\n0 0\", \"50 4\\n21 9\\n0 0\", \"4 4\\n21 9\\n0 0\", \"50 6\\n21 9\\n0 0\", \"8 4\\n21 9\\n0 0\", \"41 3\\n30 2\\n0 0\", \"44 3\\n21 9\\n0 0\",... | <image>
There used to be a game called Joseph's potatoes. Let's say n people are participating. Participants form a circle facing the center and are numbered starting from 1. One hot potato is given to participant n (the large number 30 inside the figure on the left). Participants who are given the potatoes will give... | 0 |
{"tests": "{\"inputs\": [\"0 0 2\\n2 0 2\", \"0 0 2\\n0 3 1\", \"0 -1 2\\n2 0 2\", \"0 0 2\\n0 2 1\", \"0 -1 2\\n0 0 2\", \"0 -1 2\\n0 0 1\", \"0 -1 1\\n0 0 1\", \"0 -1 2\\n2 0 4\", \"0 -1 2\\n2 0 3\", \"0 -2 2\\n0 0 2\", \"1 -1 2\\n0 0 2\", \"0 -1 2\\n-1 0 1\", \"1 -2 2\\n0 0 2\", \"-1 -1 2\\n-1 0 1\", \"1 -1 2\\n0 -1... | For given two circles $c1$ and $c2$, print the coordinates of the cross points of them.
Constraints
* The given circle have at least one cross point and have different center coordinates.
* $-10,000 \leq c1x, c1y, c2x, c2y \leq 10,000$
* $1 \leq c1r, c2r \leq 10,000$
Input
The input is given in the following format... | 0.75 |
{"tests": "{\"inputs\": [\"9\\n0 1\\n0 2\\n0 3\\n2 2\\n1 1\\n1 2\\n1 3\\n0 4\\n3 2 4\", \"9\\n0 1\\n0 2\\n0 3\\n2 2\\n1 1\\n1 2\\n0 3\\n0 4\\n3 2 4\", \"9\\n0 1\\n0 2\\n0 3\\n2 2\\n1 0\\n1 2\\n0 3\\n0 4\\n3 2 6\", \"9\\n0 1\\n0 2\\n0 3\\n2 2\\n1 0\\n1 2\\n0 3\\n0 5\\n3 2 10\", \"9\\n0 1\\n0 2\\n0 3\\n2 2\\n1 0\\n1 3\\n... | For a set $S$ of integers, perform a sequence of the following operations. Note that each value in $S$ must be unique.
* insert($x$): Insert $x$ to $S$ and report the number of elements in $S$ after the operation.
* find($x$): Report the number of $x$ in $S$ (0 or 1).
* delete($x$): Delete $x$ from $S$.
* dump($L$, $R... | 0 |
{"tests": "{\"inputs\": [\"10 2\\n\\nYes\\n\\nNo\\n\\nYes\\n\\nYes\\n\", \"1 2\\n\\nYes\\n\\nNo\\n\\nYer\\n\\nYes\\n\", \"1 2\\n\\nseY\\n\\nNo\\n\\nYes\\n\\nYds\\n\", \"1 2\\n\\nYes\\n\\noN\\n\\nYer\\n\\nYes\\n\", \"1 2\\n\\nYes\\n\\nNo\\n\\nYer\\n\\nYds\\n\", \"1 2\\n\\nYes\\n\\noN\\n\\nYer\\n\\nseY\\n\", \"1 0\\n\\nY... | This is an interactive problem.
In the Wonderful Metropolis of the Future, there is no need in subway train drivers. Due to the technological progress, they were replaced by the Artificial Intelligence (AI). Unfortunately, one day the predictions of sci-fi writers came true: the AI rebelled and now there is an uncontr... | 0 |
{"tests": "{\"inputs\": [\"2 4\\n3 2\\n4 2\\n\", \"1 6\\n4\\n2\\n\", \"1 5\\n4\\n2\\n\", \"2 2\\n2 10\\n3 15\\n\", \"7 7\\n64 16 50 18 66 25 60\\n8 4 10 2 3 5 2\\n\", \"1 1\\n1\\n2\\n\", \"2 5\\n6 3\\n4 2\\n\", \"3 200000\\n6 4 8\\n3 2 2\\n\", \"3 200000\\n8 5 9\\n1 8 1\\n\", \"7 200000\\n63 48 70 14 63 69 40\\n9 4 10 ... | Berland SU holds yet another training contest for its students today. n students came, each of them brought his laptop. However, it turned out that everyone has forgot their chargers!
Let students be numbered from 1 to n. Laptop of the i-th student has charge a_i at the beginning of the contest and it uses b_i of char... | 0 |
{"tests": "{\"inputs\": [\"2\\n\", \"3\\n\", \"6\\n\", \"955654\\n\", \"460829\\n\", \"798412\\n\", \"999999\\n\", \"8969\\n\", \"425221\\n\", \"957\\n\", \"28211\\n\", \"629462\\n\", \"5\\n\", \"786432\\n\", \"10\\n\", \"786431\\n\", \"847\\n\", \"217292\\n\", \"73\\n\", \"175863\\n\", \"40\\n\", \"42\\n\", \"89\\n\",... | Let's define a function f(p) on a permutation p as follows. Let g_i be the [greatest common divisor (GCD)](https://en.wikipedia.org/wiki/Greatest_common_divisor) of elements p_1, p_2, ..., p_i (in other words, it is the GCD of the prefix of length i). Then f(p) is the number of distinct elements among g_1, g_2, ..., g_... | 0 |
{"tests": "{\"inputs\": [\"7\\n0 2 3 0 0 0 0\\n1 2\\n1 3\\n2 4\\n2 5\\n3 6\\n3 7\\n\", \"5\\n4 5 6 0 8\\n1 2\\n1 3\\n1 4\\n4 5\\n\", \"2\\n123456789234 987654321432\\n1 2\\n\", \"2\\n0 0\\n2 1\\n\", \"4\\n6 10 15 0\\n1 4\\n2 4\\n3 4\\n\", \"2\\n987987987987 987987987987\\n2 1\\n\", \"8\\n1000000000000 0 0 1000000000000... | Kamil likes streaming the competitive programming videos. His MeTube channel has recently reached 100 million subscribers. In order to celebrate this, he posted a video with an interesting problem he couldn't solve yet. Can you help him?
You're given a tree — a connected undirected graph consisting of n vertices conne... | 0.25 |
{"tests": "{\"inputs\": [\"3\\n-1 -1 -1 -1 -1 -1\\n-1 -1 2 2 -1 -1\\n-1 -1 -1 -1 -1 -1\\n\", \"2\\n1 1 1 1\\n2 2 2 2\\n\", \"10\\n-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1\\n-1 -1 2 2 2 3 2 4 2 5 2 6 2 7 2 8 2 9 -1 -1\\n-1 -1 -1 -1 3 3 3 4 3 5 3 6 3 7 3 8 -1 -1 -1 -1\\n-1 -1 4 2 4 3 4 4 4 5 4 6 4 7 4 ... | Nash designed an interesting yet simple board game where a player is simply required to follow instructions written on the cell where the player currently stands.
This board game is played on the n× n board. Rows and columns of this board are numbered from 1 to n. The cell on the intersection of the r-th row and c-th... | 0 |
{"tests": "{\"inputs\": [\"6\\n4\\n0110\\n6\\n011011\\n5\\n01010\\n20\\n10001111110110111000\\n20\\n00110110100110111101\\n20\\n11101111011000100010\\n\", \"2\\n3\\n011\\n2\\n11\\n\", \"6\\n4\\n0110\\n6\\n011011\\n5\\n01011\\n20\\n10001111110110111000\\n20\\n00110110100110111101\\n20\\n11101111011000100010\\n\", \"6\\n... | Cirno gave AquaMoon a chessboard of size 1 × n. Its cells are numbered with integers from 1 to n from left to right. In the beginning, some of the cells are occupied with at most one pawn, and other cells are unoccupied.
In each operation, AquaMoon can choose a cell i with a pawn, and do either of the following (if po... | 0 |
{"tests": "{\"inputs\": [\"1\\n3\\n\", \"1\\n4\\n\", \"1\\n2\\n\", \"1\\n7\\n\", \"1\\n5\\n\", \"1\\n6\\n\", \"1\\n9\\n\", \"1\\n11\\n\", \"1\\n12\\n\", \"1\\n13\\n\", \"1\\n18\\n\", \"1\\n24\\n\", \"1\\n23\\n\", \"1\\n31\\n\", \"1\\n27\\n\", \"1\\n39\\n\", \"1\\n54\\n\", \"1\\n50\\n\", \"1\\n44\\n\", \"1\\n108\\n\", \... | n people came to a party. Then those, who had no friends among people at the party, left. Then those, who had exactly 1 friend among those who stayed, left as well. Then those, who had exactly 2, 3, ..., n - 1 friends among those who stayed by the moment of their leaving, did the same.
What is the maximum amount of pe... | 0 |
{"tests": "{\"inputs\": [\"1 1\\n\", \"2 2\\n\", \"92399 1\\n\", \"99999 1\\n\", \"100000 3\\n\", \"1 10\\n\", \"2 4\\n\", \"3333 3\\n\", \"99999 7\\n\", \"6 1\\n\", \"67676 7\\n\", \"3 1\\n\", \"7656 2\\n\", \"43 4\\n\", \"8 8\\n\", \"3134 9\\n\", \"100000 10\\n\", \"4444 4\\n\", \"66666 6\\n\", \"66666 9\\n\", \"2 8\... | One beautiful day Vasily the bear painted 2m circles of the same radius R on a coordinate plane. Circles with numbers from 1 to m had centers at points (2R - R, 0), (4R - R, 0), ..., (2Rm - R, 0), respectively. Circles with numbers from m + 1 to 2m had centers at points (2R - R, 2R), (4R - R, 2R), ..., (2Rm - R, 2R), r... | 0 |
{"tests": "{\"inputs\": [\"3 3\\n1 2 3\\n\", \"4 5\\n0 0 0 0\\n\", \"2 2\\n2 2\\n\", \"2 2\\n29 29\\n\", \"26 7\\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 2\\n\", \"3 3\\n1 1 1\\n\", \"3 2\\n0 1 1\\n\", \"1 127\\n1000000000\\n\", \"26 2\\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 2\\n\", \"1 800000011\... | Simon has a prime number x and an array of non-negative integers a1, a2, ..., an.
Simon loves fractions very much. Today he wrote out number <image> on a piece of paper. After Simon led all fractions to a common denominator and summed them up, he got a fraction: <image>, where number t equals xa1 + a2 + ... + an. Now ... | 0.125 |
{"tests": "{\"inputs\": [\"4 2 3 1 7\\n\", \"1 1 2 1 1\\n\", \"4 2 3 1 6\\n\", \"1 2 3 2 6\\n\", \"1 999 1000 2 2000000000\\n\", \"10 3 6 5 30\\n\", \"10 1 6 4 20\\n\", \"1999999999 47 1000 527 2000000000\\n\", \"1 504 998 900 2000000000\\n\", \"1 851 999 721 2000000000\\n\", \"1 250 997 55 2000000000\\n\", \"200000000... | Arthur and Alexander are number busters. Today they've got a competition.
Arthur took a group of four integers a, b, w, x (0 ≤ b < w, 0 < x < w) and Alexander took integer с. Arthur and Alexander use distinct approaches to number bustings. Alexander is just a regular guy. Each second, he subtracts one from his number... | 0 |
{"tests": "{\"inputs\": [\"2\\n\", \"3\\n\", \"1\\n\", \"9999\\n\", \"5\\n\", \"999999\\n\", \"524287\\n\", \"178481\\n\", \"9\\n\", \"524288\\n\", \"10\\n\", \"131071\\n\", \"4\\n\", \"99999\\n\", \"1000000\\n\", \"99\\n\", \"8\\n\", \"6\\n\", \"7\\n\", \"999\\n\", \"14926\\n\", \"816471\\n\", \"170062\\n\", \"15\\n\"... | Sasha and Ira are two best friends. But they aren’t just friends, they are software engineers and experts in artificial intelligence. They are developing an algorithm for two bots playing a two-player game. The game is cooperative and turn based. In each turn, one of the players makes a move (it doesn’t matter which pl... | 0 |
{"tests": "{\"inputs\": [\"5\\n\", \"5432359\\n\", \"1000000000\\n\", \"113\\n\", \"234234\\n\", \"3\\n\", \"0\\n\", \"999\\n\", \"307910310\\n\", \"9\\n\", \"4\\n\", \"46\\n\", \"100000\\n\", \"48851642\\n\", \"3245526\\n\", \"1397\\n\", \"23451218\\n\", \"1923140\\n\", \"150272868\\n\", \"1000010\\n\", \"99999\\n\", ... | Vasya has a non-negative integer n. He wants to round it to nearest integer, which ends up with 0. If n already ends up with 0, Vasya considers it already rounded.
For example, if n = 4722 answer is 4720. If n = 5 Vasya can round it to 0 or to 10. Both ways are correct.
For given n find out to which integer will Vasy... | 0.125 |
{"tests": "{\"inputs\": [\"1 1\\namit am\\namit\\n\\nSAMPLE\", \"1 2\\na c\\nb d\\na\", \"1 2\\na c\\nc d\\na\", \"1 1\\namit am\\namit\\n\\nSAMQLE\", \"1 1\\namit bm\\namit\\n\\nSAMPLE\", \"1 2\\na c\\nb d\\nb\", \"1 1\\namit an\\namit\\n\\nSALQLE\", \"1 1\\namit `m\\namit\\n\\nSAMQLE\", \"1 1\\namit ma\\namit\\n\\nSA... | Alice and Bob text each other everyday. Bob, tired of writing long messages has come up with a way to reduce their size.
Alice and Bob are both fluent in 2 languages, L1 and L2. A language consists of a collection of
distinct words, where each word consists of lowercase letters in the english alphabet. Each word in
L1 ... | 0.875 |
{"tests": "{\"inputs\": [\"110001\", \"11101111011111000000000110000001111100011111000000001111111110000000111111111\", \"0001\", \"110011\", \"11101111011111000000000110000001111100011111000000001101111110000000111111111\", \"0000\", \"110010\", \"11101111011101000000000110000001111100011111000000001101111110000000111... | Given is a string S consisting of `0` and `1`. Find the number of strings, modulo 998244353, that can result from applying the following operation on S zero or more times:
* Remove the two characters at the beginning of S, erase one of them, and reinsert the other somewhere in S. This operation can be applied only whe... | 0 |
{"tests": "{\"inputs\": [\"100000000\", \"010\", \"00001111\", \"100000010\", \"011\", \"00001101\", \"111\", \"00011101\", \"100000101\", \"11111111\", \"000000000\", \"100000011\", \"100001011\", \"101\", \"10011101\", \"100101011\", \"001\", \"00011001\", \"100001111\", \"000\", \"10011001\", \"100001101\", \"110\",... | You are given a string S consisting of `0` and `1`. Find the maximum integer K not greater than |S| such that we can turn all the characters of S into `0` by repeating the following operation some number of times.
* Choose a contiguous segment [l,r] in S whose length is at least K (that is, r-l+1\geq K must be satisfi... | 0 |
{"tests": "{\"inputs\": [\"5 5\\n1 3\\n4 5\\n2 3\\n2 4\\n1 4\", \"100000 1\\n1 99999\", \"4 3\\n1 2\\n2 3\\n3 4\", \"3 2\\n1 2\\n2 3\", \"5 5\\n1 1\\n4 5\\n2 3\\n2 4\\n1 4\", \"100000 1\\n0 99999\", \"4 3\\n1 3\\n2 3\\n3 4\", \"5 5\\n1 1\\n4 5\\n1 3\\n2 4\\n1 4\", \"100100 1\\n0 99999\", \"4 3\\n1 3\\n3 3\\n3 4\", \"5 ... | In Takahashi Kingdom, there is an archipelago of N islands, called Takahashi Islands. For convenience, we will call them Island 1, Island 2, ..., Island N.
There are M kinds of regular boat services between these islands. Each service connects two islands. The i-th service connects Island a_i and Island b_i.
Cat Snuk... | 0.625 |
{"tests": "{\"inputs\": [\"3 3\\n1.3 3.0 0.5\\n2.4 2.1 1.0\\n3.0 0.8 1.2\\n2 2\\n1.0 1.0\\n1.0 1.0\\n0 0\", \"3 3\\n1.3 3.0 0.5\\n2.4 2.1 1.0\\n3.0 0.8 1.2\\n2 2\\n1.0 1.953209014063742\\n1.0 1.0\\n0 0\", \"3 3\\n1.3 3.0 0.5\\n2.9487871182122434 2.1 1.0\\n3.0 0.8 1.2\\n2 2\\n1.0 1.0\\n1.0 1.0\\n0 0\", \"3 3\\n1.3 3.0 0... | Dr. Sato, a botanist, invented a number of special fertilizers for seedlings. When you give the fertilizer to the seedlings, the size of the seedlings changes in a blink of an eye. However, it was found that fertilizer has the following side effects.
* The size of the seedlings does not change with the fertilizer give... | 0.875 |
{"tests": "{\"inputs\": [\"7 11\\n1 2 2\\n1 3 1\\n2 4 2\\n2 5 2\\n2 6 1\\n3 4 1\\n3 5 1\\n3 6 1\\n4 7 2\\n5 7 2\\n6 7 1\", \"4 5\\n1 2 2\\n1 3 2\\n2 3 1\\n2 4 2\\n3 4 1\", \"7 11\\n1 2 2\\n1 3 1\\n2 4 2\\n2 5 2\\n2 6 1\\n6 4 1\\n3 5 1\\n3 6 1\\n4 7 2\\n5 7 2\\n6 7 1\", \"7 11\\n2 2 2\\n1 3 1\\n2 4 2\\n2 5 2\\n2 6 1\\n6... | Ekiden competitions are held every year in Aizukuni. The country of Aiz is dotted with N towns, each numbered from 1 to N. Several towns are connected by roads that allow them to come and go directly to each other. You can also follow several roads between any town. The course of the tournament is decided as follows.
... | 0 |
{"tests": "{\"inputs\": [\"16\\n10 8\\n2 2\\n2 5\\n2 7\\n3 3\\n3 8\\n4 2\\n4 5\\n4 8\\n6 4\\n6 7\\n7 5\\n7 8\\n8 1\\n8 4\\n9 6\\n10 3\\n4 3\\n8\\n6 4\\n1 2\\n2 1\\n2 4\\n3 4\\n4 2\\n5 3\\n6 1\\n6 2\\n3 2\\n0\", \"16\\n10 8\\n2 2\\n2 5\\n2 7\\n3 3\\n3 8\\n4 2\\n4 5\\n4 8\\n6 4\\n6 7\\n7 5\\n7 8\\n8 1\\n8 4\\n9 6\\n10 3\... | Seiji Hayashi had been a professor of the Nisshinkan Samurai School in the domain of Aizu for a long time in the 18th century. In order to reward him for his meritorious career in education, Katanobu Matsudaira, the lord of the domain of Aizu, had decided to grant him a rectangular estate within a large field in the Ai... | 0 |
{"tests": "{\"inputs\": [\"3\\n100 0 500\\n-500.243 -200.1 -300.5\\n0 300 200\\n2\\n1 1 1 0.65\\n-1 0 0 1.57\\n3\\n1 0 0\\n0 1 0\\n0 0 1\\n4\\n1 -1 -1 0.9553\\n-1 1 -1 0.9554\\n-1 -1 1 0.9553\\n-1 1 -1 0.9554\\n3\\n1 0 0\\n0 1 0\\n0 0 1\\n4\\n1 -1 -1 0.9553\\n-1 1 -1 0.9553\\n-1 -1 1 0.9553\\n-1 1 -1 0.9553\\n0\", \"3\... | One of the questions children often ask is "How many stars are there in the sky?" Under ideal conditions, even with the naked eye, nearly eight thousands are observable in the northern hemisphere. With a decent telescope, you may find many more, but, as the sight field will be limited, you may find much less at a time.... | 0 |
{"tests": "{\"inputs\": [\"7\\n15 15 15 15 15 15 15\\n4\\n10 20 30 60\\n10\\n1 1 1 1 1 1 1 1 1 100\\n7\\n90 90 90 90 90 90 10\\n7\\n2 7 1 8 2 8 4\\n0\", \"7\\n15 15 15 15 15 23 15\\n4\\n10 20 30 60\\n10\\n1 1 1 1 1 1 1 1 1 100\\n7\\n90 90 90 90 90 90 10\\n7\\n2 7 1 8 2 8 4\\n0\", \"7\\n15 15 1 15 15 23 15\\n4\\n10 20 3... | Income Inequality
We often compute the average as the first step in processing statistical data. Yes, the average is a good tendency measure of data, but it is not always the best. In some cases, the average may hinder the understanding of the data.
For example, consider the national income of a country. As the term ... | 0 |
{"tests": "{\"inputs\": [\"...............\\n...............\\n...............\\n...............\\n...............\\n...............\\n...............\\n...............\\n...............\\n...............\\n...............\\n...............\\n...............\\n...............\\n...............\\n...............\\n........ | Ikta, who hates to lose, has recently been enthusiastic about playing games using the Go board. However, neither Go nor Gomoku can beat my friends at all, so I decided to give a special training to the lesser-known game Phutball.
This game is a difficult game, so I decided to give special training so that I could win ... | 0 |
{"tests": "{\"inputs\": [\"1 2\", \"2 2\", \"1 3\", \"0 6\", \"1 10\", \"1 1\", \"0 9\", \"2 5\", \"0 4\", \"-1 11\", \"-1 0\", \"-1 8\", \"-1 7\", \"-1 12\", \"-2 -1\", \"-4 -2\", \"-8 -3\", \"-11 -4\", \"-13 -5\", \"-8 -6\", \"-23 -12\", \"-9 -7\", \"-26 -9\", \"-74 -8\", \"2 3\", \"0 3\", \"1 6\", \"0 10\", \"-1 3\"... | problem
Given the lengths of $ 2 $ sides that are not the hypotenuse of a right triangle, $ A $ and $ B $. The side of length $ A $ overlaps the $ x $ axis, and the side of length $ B $ overlaps the $ y $ axis.
Do the following:
1. Rotate the triangle around the $ x $ axis.
2. Rotate the shape created by performing ... | 0 |
{"tests": "{\"inputs\": [\"15\\n807345619350641\\n\", \"13\\n8380011223344\\n\", \"15\\n961618782888818\\n\", \"13\\n2828222222222\\n\", \"23\\n79818882846090973951051\\n\", \"17\\n83130469783251338\\n\", \"19\\n8881328076293351500\\n\", \"15\\n778887777777777\\n\", \"21\\n888888888888888888888\\n\", \"15\\n20008020022... | A telephone number is a sequence of exactly 11 digits such that its first digit is 8.
Vasya and Petya are playing a game. Initially they have a string s of length n (n is odd) consisting of digits. Vasya makes the first move, then players alternate turns. In one move the player must choose a character and erase it fro... | 0 |
{"tests": "{\"inputs\": [\"3 4 2 1\\n1 2 3 59\\n\", \"2 1000 1 239\\n49877647 333519319 741438898 999999937\\n\", \"2 10 2 6\\n270734527 308969128 389524142 999999937\\n\", \"3000 10 2 6\\n597162980 777111977 891095879 999999937\\n\", \"2 10 1 6\\n792838703 367871277 74193612 999999937\\n\", \"3000 10 1 6\\n709202316 2... | Seryozha conducts a course dedicated to building a map of heights of Stepanovo recreation center. He laid a rectangle grid of size n × m cells on a map (rows of grid are numbered from 1 to n from north to south, and columns are numbered from 1 to m from west to east). After that he measured the average height of each c... | 0 |
{"tests": "{\"inputs\": [\"4\\n3 5 3\\n..R..\\n...R.\\n....R\\n6 4 6\\nR..R\\nR..R\\nRRRR\\nRRRR\\nR..R\\nR..R\\n5 5 4\\nRRR..\\nR.R..\\nRRR..\\nR..R.\\nR...R\\n2 31 62\\nRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR\\nRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR\\n\", \"4\\n3 5 3\\n..R..\\n...R.\\n....R\\n6 4 6\\nR..R\\nR..R\\nRRRR\\nRRRR\\nR..... | Long is a huge fan of CFC (Codeforces Fried Chicken). But the price of CFC is increasing, so he decides to breed the chicken on his own farm.
His farm is presented by a rectangle grid with r rows and c columns. Some of these cells contain rice, others are empty. k chickens are living on his farm. The number of chicken... | 0 |
{"tests": "{\"inputs\": [\"5\\n1 1 1 1 1\\n\", \"12\\n3 1 4 1 5 9 2 6 5 3 5 8\\n\", \"13\\n16 18 5 17 11 12 4 11 3 16 17 2 3\\n\", \"7\\n2 1 3 3 2 3 3\\n\", \"12\\n3 1 4 1 5 9 2 6 5 3 5 8\\n\", \"11\\n19 22 18 22 21 21 19 13 21 21 16\\n\", \"15\\n6 7 11 8 13 11 4 20 17 12 9 15 18 13 9\\n\", \"1\\n1000000000\\n\", \"5\\... | You are given n integers. You need to choose a subset and put the chosen numbers in a beautiful rectangle (rectangular matrix). Each chosen number should occupy one of its rectangle cells, each cell must be filled with exactly one chosen number. Some of the n numbers may not be chosen.
A rectangle (rectangular matrix)... | 0 |
{"tests": "{\"inputs\": [\"FT\\n1\\n\", \"FFFTFFF\\n2\\n\", \"FTFTFTFFFFTFTFTTTTTTFFTTTTFFTFFFTFTFTFFTFTFTFFFTTTFTTFTTTTTFFFFTTT\\n12\\n\", \"FTTFTFFTFTTTFTTFTFFTTFFFFFTFFFFTTFTFFFFFFTFFTTTFTTFTTTFFFTFTFTFFFFTFFTFTTTTTTTTFTTTTTTFFTTFTTT\\n35\\n\", \"FTTFTTTFTTFFFTFFTTFTFTTTFFFTFTFTFFTTTFFFFFFTFTTFFTFFFFTFTTFFFTFFTTTTTF... | A lot of people associate Logo programming language with turtle graphics. In this case the turtle moves along the straight line and accepts commands "T" ("turn around") and "F" ("move 1 unit forward").
You are given a list of commands that will be given to the turtle. You have to change exactly n commands from the lis... | 0 |
{"tests": "{\"inputs\": [\"4 2\\n1 2\\n3 4\\n0 0 0 0\\n\", \"5 5\\n2 3\\n4 1\\n1 5\\n5 3\\n2 1\\n1 1 2 0 2\\n\", \"7 10\\n5 4\\n1 4\\n7 4\\n1 2\\n6 2\\n7 3\\n7 2\\n5 7\\n6 1\\n5 1\\n3 3 0 3 4 1 4\\n\", \"10 4\\n8 7\\n1 5\\n7 4\\n8 9\\n0 1 0 1 0 0 3 1 2 1\\n\", \"2 1\\n1 2\\n0 1\\n\", \"3 3\\n2 3\\n1 3\\n1 2\\n1 1 3\\n\... | Valera has n counters numbered from 1 to n. Some of them are connected by wires, and each of the counters has a special button.
Initially, all the counters contain number 0. When you press a button on a certain counter, the value it has increases by one. Also, the values recorded in all the counters, directly connecte... | 0 |
{"tests": "{\"inputs\": [\"HHQHHQH\\n\", \"HHQQHHQQHH\\n\", \"HHHH\\n\", \"HQHQH\\n\", \"QHQHHQQQQQQQQQQQHQQHQHQQQQQQHQHQQQQQQQQQQQHQQQQQQQHQQHQQHQQQQQQQQQQQQQQQQQQQQHHQQQQQQQQQQHQQQQHHQHQQHQQQQQHQQQQQQQHQQQQQHQ\\n\", \"QQQQQQHQQQQQQQQQQHQQQQQQQQQQHQQQQQQQQQQHQQQQQQQQQQHQQQQQQQQQQHQQQQHQQQQQQHQQQQQQQQQQHQQQQQQQQQQHQQQQ... | The famous joke programming language HQ9+ has only 4 commands. In this problem we will explore its subset — a language called HQ...
Input
The only line of the input is a string between 1 and 106 characters long.
Output
Output "Yes" or "No".
Examples
Input
HHHH
Output
Yes
Input
HQHQH
Output
No
Input
H... | 0 |
{"tests": "{\"inputs\": [\"3\\n1 1 1\\n0 1 1\\n1 0 0\\n12\\n3\\n2 3\\n3\\n2 2\\n2 2\\n1 3\\n3\\n3\\n1 2\\n2 1\\n1 1\\n3\\n\", \"2\\n0 0\\n0 0\\n9\\n3\\n1 2\\n2 2\\n1 1\\n2 1\\n3\\n1 2\\n1 1\\n3\\n\", \"1\\n0\\n5\\n1 1\\n3\\n1 1\\n1 1\\n3\\n\", \"5\\n1 0 1 0 1\\n0 1 0 1 0\\n1 0 1 0 1\\n0 1 0 1 0\\n1 0 1 0 1\\n7\\n3\\n2 ... | Little Chris is a huge fan of linear algebra. This time he has been given a homework about the unusual square of a square matrix.
The dot product of two integer number vectors x and y of size n is the sum of the products of the corresponding components of the vectors. The unusual square of an n × n square matrix A is ... | 0 |
{"tests": "{\"inputs\": [\"2\\n1 2 3 4 5 6\\n\", \"3\\n87 37 91 29 58 45 51 74 70 71 47 38 91 89\\n\", \"1\\n49 36\\n\", \"3\\n86 12 92 91 3 68 57 56 76 27 33 62 71 84\\n\", \"4\\n25 42 71 29 50 30 99 79 77 24 76 66 68 23 97 99 65 17 75 62 66 46 48 4 40 71 98 57 21 92\\n\", \"5\\n64 72 35 68 92 95 45 15 77 16 26 74 61 ... | Om Nom is the main character of a game "Cut the Rope". He is a bright little monster who likes visiting friends living at the other side of the park. However the dark old parks can scare even somebody as fearless as Om Nom, so he asks you to help him.
<image>
The park consists of 2n + 1 - 1 squares connected by roads... | 0 |
{"tests": "{\"inputs\": [\"3 2\\n1 0 2\\n\", \"2 1\\n1 1\\n\", \"4 100\\n3 4 5 4\\n\", \"5 8\\n121351 0 13513 0 165454\\n\", \"9 5\\n0 0 0 0 0 0 0 0 6\\n\", \"6 6\\n0 10 0 0 10 0\\n\", \"6 2\\n1000000000 1000000000 1000000000 1000000000 1000000000 1000000000\\n\", \"19 100000\\n1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1\\n\... | Professor GukiZ is concerned about making his way to school, because massive piles of boxes are blocking his way.
In total there are n piles of boxes, arranged in a line, from left to right, i-th pile (1 ≤ i ≤ n) containing ai boxes. Luckily, m students are willing to help GukiZ by removing all the boxes from his way... | 0 |
{"tests": "{\"inputs\": [\"3 2 1 2\\n3 1 2\\n\", \"3 2 1 2\\n6 2 2\\n\", \"12 1 5 10\\n3 5 6 7 8 9 5 1 1 1 1 5\\n\", \"6 5 12 23\\n5 8 2 6 5 5\\n\", \"3 2 0 2\\n3 3 9\\n\", \"100 1000000000 42 97\\n2 5 1 8 8 1 5 2 1 2 5 1 8 8 1 5 2 1 2 5 1 8 8 1 5 2 1 2 5 1 8 8 1 5 2 1 2 5 1 8 8 1 5 2 1 2 5 1 8 8 1 5 2 1 2 5 1 8 8 1 5 ... | There are b blocks of digits. Each one consisting of the same n digits, which are given to you in the input. Wet Shark must choose exactly one digit from each block and concatenate all of those digits together to form one large integer. For example, if he chooses digit 1 from the first block and digit 2 from the second... | 0.375 |
{"tests": "{\"inputs\": [\"3 1\\n\", \"2 3\\n\", \"0 0\\n\", \"1 0\\n\", \"0 5\\n\", \"100 98\\n\", \"62 39\\n\", \"100 99\\n\", \"99 100\\n\", \"100 100\\n\", \"57 57\\n\", \"74 73\\n\", \"0 100\\n\", \"89 25\\n\", \"0 1\\n\", \"100 0\\n\", \"98 100\\n\", \"9 9\\n\", \"85 95\\n\", \"5 4\\n\", \"2 2\\n\", \"2 0\\n\", \... | On her way to programming school tiger Dasha faced her first test — a huge staircase!
<image>
The steps were numbered from one to infinity. As we know, tigers are very fond of all striped things, it is possible that it has something to do with their color. So on some interval of her way she calculated two values — th... | 0.75 |
{"tests": "{\"inputs\": [\"4\\n2 5 3 1\\n\", \"7\\n1 6 5 3 9 5 9\\n\", \"3\\n4 10 3\\n\", \"8\\n7 2 6 3 6 4 1 8\\n\", \"8\\n3 5 8 10 3 4 2 10\\n\", \"3\\n1 1 5\\n\", \"7\\n11 1 2 8 10 5 9\\n\", \"6\\n1 5 2 1 7 11\\n\", \"6\\n1 1 1 3 2 9\\n\", \"10\\n5 6 4 8 11 4 10 4 8 4\\n\", \"5\\n4 5 5 2 11\\n\", \"2\\n1 5\\n\", \"7... | DO YOU EXPECT ME TO FIND THIS OUT?
WHAT BASE AND/XOR LANGUAGE INCLUDES string?
DON'T BYTE OF MORE THAN YOU CAN CHEW
YOU CAN ONLY DISTORT THE LARGEST OF MATHEMATICS SO FAR
SAYING "ABRACADABRA" WITHOUT A MAGIC AND WON'T DO YOU ANY GOOD
THE LAST STACK RUPTURES. ALL DIE. OH, THE EMBARRASSMENT!
I HAVE NO ARRAY AND I M... | 0 |
{"tests": "{\"inputs\": [\"30 30 2 1 2 1 20\\n3\\n0 0 40 5 1\\n1 4 4\\n-10 -40 -5 7 0\\n100 200 95 8 1\\n-10 0 0\\n\", \"8 8 4 4 4 2 6\\n1\\n-2 -2 -1 3 0\\n\", \"0 0 0 1 0 0 5\\n2\\n10 8 0 2 2\\n0 -3 0\\n2 2 0\\n20 0 0 4 3\\n2 4 0\\n-4 3 0\\n1 -5 0\\n\", \"-10000 0 0 1 0 0 3\\n1\\n10000 6 0 2 1\\n-3 0 0\\n\", \"100 99 ... | Once upon a time in the galaxy of far, far away...
Darth Wader found out the location of a rebels' base. Now he is going to destroy the base (and the whole planet that the base is located at), using the Death Star.
When the rebels learnt that the Death Star was coming, they decided to use their new secret weapon — sp... | 0 |
{"tests": "{\"inputs\": [\"6 1 2\\n3 8 0 1 0 0\\n\", \"5 1 1\\n1 0 0 0 4\\n\", \"50 2 1\\n0 1 1 1 1 1 1 0 2 2 0 0 1 1 2 0 1 0 1 2 0 1 1 0 1 2 3 0 0 1 0 3 1 1 1 1 1 1 3 0 0 0 2 0 2 2 0 3 2 0\\n\", \"100 1 24\\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 151 150 159 159 147 121 143 143 138 138 127 127 128 123 159 159 128 0 0 0 0 0 0... | Instructors of Some Informatics School make students go to bed.
The house contains n rooms, in each room exactly b students were supposed to sleep. However, at the time of curfew it happened that many students are not located in their assigned rooms. The rooms are arranged in a row and numbered from 1 to n. Initially,... | 0 |
{"tests": "{\"inputs\": [\"2\\n2 6\\n\\nSAMPLE\", \"30\\n317 36 191 843 289 107 41 943 265 649 447 806 891 730 371 351 7 102 394 549 630 624 85 955 757 841 967 377 932 309\", \"2\\n468 335\", \"30\\n317 36 191 843 289 107 41 1032 265 649 447 806 891 730 371 351 7 102 394 549 630 624 85 955 757 841 967 377 932 309\", \"... | The Monk wants to teach all its disciples a lesson about patience, since they are always in a hurry to do something crazy. To teach them this, he gives them a list of N numbers, which may or may not be distinct. The students are supposed to solve a simple Mathematical equation based on the array of these N numbers.
g(x... | 0.875 |
{"tests": "{\"inputs\": [\"2 1\", \"2000 1000\", \"17 2\", \"2000 1100\", \"4 2\", \"4 1\", \"1 1\", \"3 1\", \"13 2\", \"5 2\", \"5 1\", \"10 1\", \"9 2\", \"19 1\", \"9 1\", \"38 1\", \"25 1\", \"2000 1001\", \"12 1\", \"13 3\", \"5 4\", \"10 2\", \"9 4\", \"19 2\", \"38 2\", \"7 1\", \"6 2\", \"12 2\", \"4 3\", \"6 ... | Snuke has decided to play with N cards and a deque (that is, a double-ended queue). Each card shows an integer from 1 through N, and the deque is initially empty.
Snuke will insert the cards at the beginning or the end of the deque one at a time, in order from 1 to N. Then, he will perform the following action N times... | 0 |
{"tests": "{\"inputs\": [\"3\\n2 1 3\", \"4\\n1 3 2 4\", \"8\\n5 4 8 1 2 6 7 3\", \"3\\n3 1 2\", \"3\\n1 2 3\", \"4\\n2 3 1 4\", \"4\\n1 3 4 2\", \"8\\n5 3 8 1 2 6 7 4\", \"4\\n3 2 4 1\", \"8\\n4 5 8 1 2 6 7 3\", \"3\\n1 3 2\", \"3\\n2 3 1\", \"3\\n3 2 1\", \"4\\n2 3 4 1\", \"4\\n1 2 3 4\", \"3\\n3 1 2\", \"3\\n3 2 1\"... | One day, Snuke was given a permutation of length N, a_1, a_2, ..., a_N, from his friend.
Find the following:
<image>
Constraints
* 1 ≦ N ≦ 200,000
* (a_1, a_2, ..., a_N) is a permutation of (1, 2, ..., N).
Input
The input is given from Standard Input in the following format:
N
a_1 a_2 ... a_N
Output
Print th... | 0 |
{"tests": "{\"inputs\": [\"20 20\\n1 1\\n9 9\\n7\\n2 0 1 1\\n5 1 1 3\\n2 1 3 3\\n1 1 5 2\\n5 1 7 3\\n2 0 2 7\\n2 0 6 8\\n20 20\\n9 9\\n1 1\\n6\\n2 0 1 1\\n1 0 5 1\\n2 1 1 3\\n5 0 1 7\\n3 1 5 5\\n4 1 8 5\\n0 0\", \"20 20\\n1 1\\n9 9\\n7\\n2 0 1 1\\n5 1 1 3\\n2 1 3 3\\n1 1 5 2\\n5 1 7 3\\n2 0 2 7\\n2 0 6 8\\n20 20\\n9 9\... | Relative B came to Mr. A's house. He is 3 years old and loves blocks. The block he has is shaped like Figure 1.
<image>
Figure 1
Mr. B is laying blocks on the board. When I asked him, "What are you making?", He replied cheerfully, "Maze !!". The maze he says is the arrangement of blocks that are in contact with each... | 0.125 |
{"tests": "{\"inputs\": [\"a[3]\\na[0]=a[1]\\n.\\nx[1]\\nx[0]=x[0]\\n.\\na[0]\\na[0]=1\\n.\\nb[2]\\nb[0]=2\\nb[1]=b[b[0]]\\nb[0]=b[1]\\n.\\ng[2]\\nG[10]\\ng[0]=0\\ng[1]=G[0]\\n.\\na[2147483647]\\na[0]=1\\nB[2]\\nB[a[0]]=2\\na[B[a[0]]]=3\\na[2147483646]=a[2]\\n.\\n.\", \"a[3]\\na[0]=a[1]\\n.\\nx[1]\\nx[0]=x[0]\\n.\\na[0... | In this problem, we consider a simple programming language that has only declarations of one- dimensional integer arrays and assignment statements. The problem is to find a bug in the given program.
The syntax of this language is given in BNF as follows:
<image>
where <new line> denotes a new line character (LF).
C... | 0 |
{"tests": "{\"inputs\": [\"3 3\\n1 2 3\\n2 3 1\\n3 1 2\", \"2 1\\n1 2 5\", \"4 5\\n1 2 4\\n1 3 3\\n2 3 7\\n2 4 5\\n3 4 6\", \"1 0\", \"3 3\\n1 4 3\\n2 3 1\\n3 1 2\", \"2 2\\n1 2 5\", \"4 5\\n1 2 4\\n1 3 3\\n2 3 7\\n2 4 3\\n3 4 6\", \"2 0\", \"4 2\\n1 2 10\", \"4 5\\n2 2 6\\n1 3 3\\n2 2 7\\n2 4 4\\n3 4 6\", \"3 4\\n1 2 ... | A rabbit Taro decided to hold a party and invite some friends as guests. He has n rabbit friends, and m pairs of rabbits are also friends with each other. Friendliness of each pair is expressed with a positive integer. If two rabbits are not friends, their friendliness is assumed to be 0.
When a rabbit is invited to t... | 0 |
{"tests": "{\"inputs\": [\"5\\n2 3\\n1 7\\n5 5\\n3 1\\n8 15\", \"5\\n2 3\\n1 7\\n4 5\\n3 1\\n8 15\", \"5\\n2 3\\n1 7\\n4 6\\n4 1\\n8 15\", \"5\\n1 3\\n1 7\\n4 6\\n4 1\\n8 25\", \"5\\n1 3\\n1 8\\n12 6\\n4 1\\n5 25\", \"5\\n1 3\\n1 8\\n12 6\\n4 0\\n5 25\", \"5\\n1 3\\n1 8\\n12 11\\n4 0\\n5 25\", \"5\\n0 3\\n0 2\\n12 11\\... | The executive chef is trying to bring some competitive spirit into his kitchen. He wants to split the chefs into two teams based on their age - he'll form the young and the old team. To make it fair, he will split them evenly or give the young team one person advantage when there is an odd number of chefs. Ages of all ... | 0 |
{"tests": "{\"inputs\": [\"3 4\\n2 5\\n7 9\\n10 11\\n\", \"1 1000000000\\n1 1000000000\\n\", \"5 10\\n5 7\\n11 12\\n16 20\\n25 26\\n30 33\\n\", \"5 10\\n2 3\\n4 5\\n6 7\\n10 14\\n16 20\\n\", \"5 10\\n4 5\\n6 8\\n9 10\\n11 13\\n16 17\\n\", \"5 10\\n2 5\\n6 8\\n9 10\\n12 14\\n18 19\\n\", \"2 3\\n1 2\\n3 4\\n\", \"5 10\\n... | A plane is flying at a constant height of h meters above the ground surface. Let's consider that it is flying from the point (-10^9, h) to the point (10^9, h) parallel with Ox axis.
A glider is inside the plane, ready to start his flight at any moment (for the sake of simplicity let's consider that he may start only w... | 0 |
{"tests": "{\"inputs\": [\"4 1\\n3 -1 6 0\\n\", \"7 6\\n-3 0 -1 -2 -2 -4 -1\\n\", \"5 2\\n-1 -2 5 -4 8\\n\", \"4 1\\n3 -2 6 0\\n\", \"5 2\\n-1 -2 5 -7 8\\n\", \"4 1\\n3 -2 1 0\\n\", \"5 2\\n0 -2 5 -7 8\\n\", \"4 1\\n2 -2 1 0\\n\", \"5 2\\n0 -2 1 -7 8\\n\", \"5 2\\n0 -2 2 -7 8\\n\", \"5 2\\n0 -2 2 -7 14\\n\", \"5 2\\n0 ... | You are given an array a_1, a_2, ..., a_n and an integer k.
You are asked to divide this array into k non-empty consecutive subarrays. Every element in the array should be included in exactly one subarray. Let f(i) be the index of subarray the i-th element belongs to. Subarrays are numbered from left to right and from... | 0.625 |
{"tests": "{\"inputs\": [\"4\\n4\\nLRUD\\n4\\nLURD\\n5\\nRRUDU\\n5\\nLLDDR\\n\", \"1\\n23\\nRUURRDDLLUUURRRDDDLLLUD\\n\", \"1\\n10\\nRULLDRRULD\\n\", \"4\\n4\\nLRUD\\n4\\nLURD\\n5\\nRRUDU\\n5\\nRDDLL\\n\", \"4\\n4\\nLRUD\\n4\\nLURD\\n5\\nDRURU\\n5\\nRDDLL\\n\", \"1\\n23\\nDULLLDDDRRRUUULLDDRRUUR\\n\", \"4\\n4\\nLDUR\\n... | There is a robot on a coordinate plane. Initially, the robot is located at the point (0, 0). Its path is described as a string s of length n consisting of characters 'L', 'R', 'U', 'D'.
Each of these characters corresponds to some move:
* 'L' (left): means that the robot moves from the point (x, y) to the point (x... | 0.375 |
{"tests": "{\"inputs\": [\"7 4\\n1 2 3 3 1 4 3\\n3 1\\n2 3\\n2 4\\n\", \"10 10\\n2 10 8 7 9 3 4 6 5 1\\n10 4\\n10 1\\n10 6\\n10 8\\n10 2\\n10 9\\n10 7\\n10 3\\n10 5\\n\", \"2 2\\n1 2\\n2 1\\n\", \"10 5\\n3 1 5 3 1 5 1 2 4 2\\n4 5\\n4 3\\n4 2\\n4 1\\n\", \"10 5\\n3 1 5 3 1 5 1 2 4 3\\n4 5\\n4 3\\n4 2\\n4 1\\n\", \"10 5\... | You have a set of n discs, the i-th disc has radius i. Initially, these discs are split among m towers: each tower contains at least one disc, and the discs in each tower are sorted in descending order of their radii from bottom to top.
You would like to assemble one tower containing all of those discs. To do so, you ... | 0 |
{"tests": "{\"inputs\": [\"4\\n1 4 1 1\\n\", \"5\\n1 0 1 0 1\\n\", \"4\\n3 3 3 3\\n\", \"1\\n0\\n\", \"16\\n1 1 2 3 3 4 5 6 6 6 4 3 2 1 1 1\\n\", \"1\\n1\\n\", \"20\\n1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2\\n\", \"2\\n0 1\\n\", \"4\\n3 3 2 3\\n\", \"1\\n1000000000\\n\", \"4\\n3 4 3 3\\n\", \"16\\n1 1 2 3 3 4 5 6 6 6 4... | You have a multiset containing several integers. Initially, it contains a_1 elements equal to 1, a_2 elements equal to 2, ..., a_n elements equal to n.
You may apply two types of operations:
* choose two integers l and r (l ≤ r), then remove one occurrence of l, one occurrence of l + 1, ..., one occurrence of r fro... | 0 |
{"tests": "{\"inputs\": [\"4 6\\n1 2 5 2\\n2 3 3 4\\n\", \"2 3\\n5 6\\n5 5\\n\", \"43 5\\n6 7 15 12 15 7 22 33 38 15 7 23 31 21 26 41 25 14 26 33 5 28 22 6 35 17 19 32 41 27 20 25 5 32 37 19 40 9 25 22 10 24 9\\n3 5 3 6 5 4 5 3 3 3 3 6 6 3 3 3 3 3 3 3 3 6 3 3 4 3 4 3 6 4 3 6 3 4 6 3 4 5 4 4 3 3 5\\n\", \"24 3\\n11 8 8 ... | There are n cities in the country where the Old Peykan lives. These cities are located on a straight line, we'll denote them from left to right as c1, c2, ..., cn. The Old Peykan wants to travel from city c1 to cn using roads. There are (n - 1) one way roads, the i-th road goes from city ci to city ci + 1 and is di kil... | 0 |
{"tests": "{\"inputs\": [\"2 2\\n1 2\\n2 1\\n\", \"4 2\\n1 3\\n1 4\\n\", \"7 8\\n1 6\\n2 6\\n3 5\\n3 6\\n4 3\\n5 1\\n5 2\\n5 3\\n\", \"4 4\\n1 3\\n2 2\\n3 2\\n4 3\\n\", \"14 27\\n1 13\\n10 12\\n12 11\\n10 9\\n13 3\\n3 11\\n5 10\\n3 10\\n10 5\\n5 12\\n1 6\\n5 8\\n6 9\\n11 13\\n3 1\\n9 12\\n9 9\\n7 3\\n7 6\\n6 10\\n3 9\\... | Iahub got lost in a very big desert. The desert can be represented as a n × n square matrix, where each cell is a zone of the desert. The cell (i, j) represents the cell at row i and column j (1 ≤ i, j ≤ n). Iahub can go from one cell (i, j) only down or right, that is to cells (i + 1, j) or (i, j + 1).
Also, there a... | 0 |
{"tests": "{\"inputs\": [\". . .\\n . . . O\\n. . . O .\\n O . O .\\n . O .\\n\", \". . .\\n . . O .\\n. . O O .\\n . . . .\\n . . .\\n\", \"O O .\\n O O . .\\n. . . . .\\n . . . .\\n . O .\\n\", \". . O\\n . O O .\\nO . O . O\\n O O O O\\n . . O\\n\", \". . .\\n . O . .\\n. O O . .\\n . . O .\\n . O .\\n\", \"O O... | Karlsson has visited Lillebror again. They found a box of chocolates and a big whipped cream cake at Lillebror's place. Karlsson immediately suggested to divide the sweets fairly between Lillebror and himself. Specifically, to play together a game he has just invented with the chocolates. The winner will get the cake a... | 0 |
{"tests": "{\"inputs\": [\"5 4 9\\n\", \"40 37 65\\n\", \"1 2 3\\n\", \"3 2 2\\n\", \"1 1 1\\n\", \"1 2 2\\n\", \"99999998 66 76\\n\", \"13 66 38\\n\", \"13 66 95\\n\", \"85714284 99 76\\n\", \"13 66 57\\n\", \"13 99 38\\n\", \"99999998 99 95\\n\", \"99999999 97 99\\n\", \"100000000 100 1\\n\", \"85714284 99 95\\n\", \... | So many wall designs to choose from! Even modulo 106 + 3, it's an enormous number. Given that recently Heidi acquired an unlimited supply of bricks, her choices are endless! She really needs to do something to narrow them down.
Heidi is quick to come up with criteria for a useful wall:
* In a useful wall, at least ... | 0 |
{"tests": "{\"inputs\": [\"aba\\n1\\nlikes likes posted's post\\n\", \"ahmed\\n3\\nahmed posted on fatma's wall\\nfatma commented on ahmed's post\\nmona likes ahmed's post\\n\", \"post\\n9\\npost posted on wall's wall\\non commented on post's post\\npost likes likes's post\\ncommented posted on post's wall\\npost comme... | Facetook is a well known social network website, and it will launch a new feature called Facetook Priority Wall. This feature will sort all posts from your friends according to the priority factor (it will be described).
This priority factor will be affected by three types of actions:
* 1. "X posted on Y's wall" (... | 0 |
{"tests": "{\"inputs\": [\"3 1\\nW??\\n\", \"3 2\\nL??\\n\", \"20 5\\n?LLLLLWWWWW?????????\\n\", \"10 2\\nLWL?WWDDW?\\n\", \"10 3\\nDWD?DL??LL\\n\", \"10 1\\nD??W?WL?DW\\n\", \"5 3\\n??D??\\n\", \"5 5\\n?WDDD\\n\", \"1 1\\n?\\n\", \"10 1\\nLWL?WWDDW?\\n\", \"10 2\\nD??W?WL?DW\\n\", \"20 7\\n?LLLLLWWWWW?????????\\n\", \... | Each evening Roma plays online poker on his favourite website. The rules of poker on this website are a bit strange: there are always two players in a hand, there are no bets, and the winner takes 1 virtual bourle from the loser.
Last evening Roma started to play poker. He decided to spend no more than k virtual bourl... | 0 |
{"tests": "{\"inputs\": [\"4 2 2\\n3 6 7 10\\n\", \"5 2 1\\n100 100 100 100 100\\n\", \"100 1 1\\n3 3 5 7 8 8 8 9 9 9 11 13 14 15 18 18 19 20 21 22 22 25 27 27 29 31 32 33 33 34 36 37 37 38 40 42 44 44 46 47 47 48 48 48 50 50 51 51 54 54 54 55 55 56 56 56 60 61 62 62 63 64 65 65 68 70 70 71 71 71 71 75 75 76 76 79 79 7... | Luba has to do n chores today. i-th chore takes ai units of time to complete. It is guaranteed that for every <image> the condition ai ≥ ai - 1 is met, so the sequence is sorted.
Also Luba can work really hard on some chores. She can choose not more than k any chores and do each of them in x units of time instead of a... | 0.875 |
{"tests": "{\"inputs\": [\"4 1 1\\n1 -1 -1\\n2 1 1\\n3 1 1\\n4 -1 -1\\n\", \"3 1 0\\n0 0 0\\n1 0 0\\n2 0 0\\n\", \"3 1 0\\n-1 1 0\\n0 0 -1\\n1 -1 -2\\n\", \"2 4 0\\n0 -536870912 0\\n1 536870911 -4\\n\", \"10 7 -626288749\\n795312099 49439844 266151109\\n-842143911 23740808 624973405\\n-513221420 -44452680 -391096559\\n... | 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}\overrightarr... | 0.625 |
{"tests": "{\"inputs\": [\"1\\n-824590 246031\\n\", \"8\\n-67761 603277\\n640586 -396671\\n46147 -122580\\n569609 -2112\\n400 914208\\n131792 309779\\n-850150 -486293\\n5272 721899\\n\", \"3\\n999999 0\\n0 999999\\n999999 0\\n\", \"2\\n1 999999\\n1 -999999\\n\", \"2\\n-999999 -1\\n-999999 1\\n\", \"2\\n999999 1\\n-9999... | For a vector \vec{v} = (x, y), define |v| = √{x^2 + y^2}.
Allen had a bit too much to drink at the bar, which is at the origin. There are n vectors \vec{v_1}, \vec{v_2}, ⋅⋅⋅, \vec{v_n}. Allen will make n moves. As Allen's sense of direction is impaired, during the i-th move he will either move in the direction \vec{v_... | 0 |
{"tests": "{\"inputs\": [\"3\\n1 2 3\\n3 1 2\\n1 4 1\\n\\nSAMPLE\", \"3\\n1 0 3\\n3 1 2\\n1 4 1\\n\\nSAMPLE\", \"3\\n1 -1 3\\n5 1 0\\n0 4 1\\n\\nSAMPLE\", \"3\\n1 0 5\\n5 1 0\\n0 4 1\\n\\nSQMALE\", \"3\\n1 0 2\\n5 0 0\\n0 4 1\\n\\nSQMALE\", \"3\\n1 0 2\\n9 1 0\\n0 4 1\\n\\nSQMALE\", \"3\\n2 0 4\\n9 1 0\\n0 4 1\\n\\nLQM... | Bajirao's city has N X N police stations P(i,j) (1 ≤ i ≤ N, 1 ≤ j ≤ N) arranged in an N X N square matrix format. Bajirao is a really hardworking police officer and wants to solve all the pending cases of all the police stations in his city. However, the Police Commissioner (his senior) is not allowing him to do so due... | 0 |
{"tests": "{\"inputs\": [\"2\\n1 2 5\\n0 0 2\\n\\nSAMPLE\", \"21\\n0 0 0\\n3 0 0\\n5 1 2\\n7 7 4\\n0 0 1\\n0 1 0\\n1 0 0\\n50 50 50\\n4 10 42\\n11 49 20\\n30 21 44\\n3 7 2\\n29 14 15\\n39 29 19\\n5 10 10\\n41 7 41\\n50 50 3\\n50 50 49\\n2 3 5\\n0 0 50\\n1000000 1000000 1000000\", \"21\\n0 0 0\\n3 0 0\\n5 1 2\\n7 12 4\\... | Description:
Name string is a string consisting of letters "R","K" and "V". Today Oz wants to design a name string in a beautiful manner. Actually Oz cannot insert these three letters arbitrary anywhere ,he has to follow some rules to make the name string look beautiful. First thing is that the name string should consi... | 0 |
{"tests": "{\"inputs\": [\"3\\n1 2 13\\n\\nSAMPLE\", \"6\\n32 68 6 93 25 61\", \"6\\n32 117 6 93 25 61\", \"3\\n1 2 18\\n\\nSAMPLE\", \"6\\n32 117 2 93 25 61\", \"3\\n1 2 28\\n\\nSAMPLE\", \"6\\n32 188 2 93 25 61\", \"3\\n1 2 3\\n\\nSAMPLE\", \"6\\n32 188 0 93 25 61\", \"6\\n32 188 0 83 25 61\", \"3\\n1 2 0\\n\\nSAMOLE... | Fatal Eagle has finally teamed up with Arjit to take on this weird army of zombies and vampires. And they are coming up with strategies to beat these guys on a roll. The simple thing they figured out is that these creatures attack everything by the method of brute force - i.e., the total power they have while attacking... | 0.625 |
{"tests": "{\"inputs\": [\"5 2 2\\n2 1\\n4 2\", \"100000 100000 1\\n50000 50000\", \"3 4 2\\n2 2\\n1 4\", \"5 5 4\\n3 1\\n3 5\\n1 3\\n5 3\", \"5 2 0\\n2 1\\n4 2\", \"100000 100000 1\\n50000 23836\", \"3 4 2\\n2 2\\n2 4\", \"100000 100000 1\\n50000 25003\", \"3 4 2\\n2 2\\n2 8\", \"5 4 2\\n2 1\\n4 2\", \"3 4 2\\n2 3\\n1... | There is a grid with H horizontal rows and W vertical columns. Let (i, j) denote the square at the i-th row from the top and the j-th column from the left.
In the grid, N Squares (r_1, c_1), (r_2, c_2), \ldots, (r_N, c_N) are wall squares, and the others are all empty squares. It is guaranteed that Squares (1, 1) and ... | 0 |
{"tests": "{\"inputs\": [\"1071 1029\\n5 5\\n0 0\", \"1071 1029\\n5 3\\n0 0\", \"1251 1029\\n5 3\\n0 0\", \"1251 1802\\n5 3\\n0 0\", \"1071 446\\n5 3\\n0 0\", \"1071 2\\n5 3\\n0 0\", \"1071 1029\\n2 3\\n0 0\", \"1251 3458\\n5 3\\n0 0\", \"826 2\\n5 3\\n0 0\", \"1251 3458\\n10 3\\n0 0\", \"1164 1029\\n4 3\\n0 0\", \"125... | The greatest common divisor is an indispensable element in mathematics handled on a computer. Using the greatest common divisor can make a big difference in the efficiency of the calculation. One of the algorithms to find the greatest common divisor is "Euclidean algorithm". The flow of the process is shown below.
<im... | 0 |
{"tests": "{\"inputs\": [\"6 9\\n....#.\\n.....#\\n......\\n......\\n......\\n......\\n......\\n@...#\\n.#..#.\\n11 9\\n.#.........\\n.#.#######.\\n.#.#.....#.\\n.#.#.###.#.\\n.#.#..@#.#.\\n.#.#####.#.\\n.#.......#.\\n.#########.\\n...........\\n11 6\\n..#..#..#..\\n..#..#..#..\\n..#..#..###\\n..#..#..#@.\\n..#..#..#..... | There is a rectangular room, covered with square tiles. Each tile is colored either red or black. A man is standing on a black tile. From a tile, he can move to one of four adjacent tiles. But he can't move on red tiles, he can move only on black tiles.
Write a program to count the number of black tiles which he can r... | 0 |
{"tests": "{\"inputs\": [\"2 3 100 20\\nvim 10 10\\nemacs 5 10\\nvstudio 65 100\\n2 1 6\\nemacs 4\\nvstudio 13\\n3 -3 0\\nvim 5\\nemacs 9\\nvstudio 62\", \"2 2 100 20\\nalfalfa 10 10\\ncarrot 5 10\\n1 1 6\\ncarrot 4\\n1 -3 0\\nalfalfa 5\", \"2 3 100 10\\nvim 10 10\\nemacs 5 10\\nvstudio 65 100\\n2 1 6\\nemacs 4\\nvstud... | Training is indispensable for achieving good results at ICPC. Rabbit wants to win at ICPC, so he decided to practice today as well.
Today's training is to gain the power of business by running around the city and conducting trade.
I want to earn as much money as possible for future training.
In this world, roads in ... | 0 |
{"tests": "{\"inputs\": [\"3 9\\n0 0 1\\n0 0 2\\n0 0 3\\n0 2 4\\n0 2 5\\n1 0\\n1 2\\n2 0\\n1 0\", \"3 9\\n0 1 1\\n0 0 2\\n0 0 3\\n0 2 4\\n0 2 5\\n1 0\\n1 2\\n2 0\\n1 0\", \"3 9\\n0 1 1\\n0 0 2\\n0 0 3\\n0 2 6\\n0 2 5\\n1 0\\n1 2\\n2 0\\n1 0\", \"3 9\\n0 1 1\\n0 0 2\\n0 1 3\\n0 2 6\\n0 2 5\\n1 0\\n1 2\\n2 0\\n1 0\", \"3... | Queue is a container of elements that are inserted and deleted according to FIFO (First In First Out).
For $n$ queues $Q_i$ ($i = 0, 1, ..., n-1$), perform a sequence of the following operations.
* enqueue($t$, $x$): Insert an integer $x$ to $Q_t$.
* front($t$): Report the value which should be deleted next from $Q_t... | 0 |
{"tests": "{\"inputs\": [\"4 2\\n1 8\\n\", \"20 1\\n6\\n\", \"1000 7\\n5 4 0 1 8 3 2\\n\", \"10 5\\n6 1 4 0 3\\n\", \"500 2\\n4 6\\n\", \"4 1\\n2\\n\", \"20 3\\n4 6 7\\n\", \"4 7\\n1 2 3 9 7 0 4\\n\", \"998 5\\n6 1 9 2 7\\n\", \"1000 2\\n8 9\\n\", \"756 10\\n9 2 5 8 6 1 0 4 3 7\\n\", \"1000 8\\n8 4 5 1 9 2 7 3\\n\", \"... | All bus tickets in Berland have their numbers. A number consists of n digits (n is even). Only k decimal digits d_1, d_2, ..., d_k can be used to form ticket numbers. If 0 is among these digits, then numbers may have leading zeroes. For example, if n = 4 and only digits 0 and 4 can be used, then 0000, 4004, 4440 are va... | 0 |
{"tests": "{\"inputs\": [\"5\\n2 4 6 6 6\\n\", \"4\\n1 1 1 1\\n\", \"3\\n2 8 10\\n\", \"69\\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 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\\n\", \"4\\n0 0 0 1\\n\", \"10\\n2 3 3 4 1 4 1 4 1 4\\n\", \"1\\n1234\\n\", \"69\\n1 1 1 ... | You are given an array a consisting of n integers. You can perform the following operations arbitrary number of times (possibly, zero):
1. Choose a pair of indices (i, j) such that |i-j|=1 (indices i and j are adjacent) and set a_i := a_i + |a_i - a_j|;
2. Choose a pair of indices (i, j) such that |i-j|=1 (indice... | 0 |
{"tests": "{\"inputs\": [\"10 9\\n4 5 5 7 5 4 5 2 4 3\\n\", \"4 5\\n3 1 7 5\\n\", \"3 10\\n100 100 100\\n\", \"94 1628\\n585 430 515 566 398 459 345 349 572 335 457 397 435 489 421 500 525 600 429 503 353 373 481 552 469 563 494 380 408 510 393 586 484 544 481 359 424 381 569 418 515 507 348 536 559 413 578 544 565 359... | You are given a sequence a_1, a_2, ..., a_n consisting of n integers.
You may perform the following operation on this sequence: choose any element and either increase or decrease it by one.
Calculate the minimum possible difference between the maximum element and the minimum element in the sequence, if you can perfor... | 0.75 |
{"tests": "{\"inputs\": [\"3\\n5 8\\n1 4\\n3 10\\n\", \"6\\n216986951114298167 235031205335543871\\n148302405431848579 455670351549314242\\n506251128322958430 575521452907339082\\n1 768614336404564650\\n189336074809158272 622104412002885672\\n588320087414024192 662540324268197150\\n\", \"2\\n1 9\\n4 5\\n\", \"1\\n1 1\\... | Lee is used to finish his stories in a stylish way, this time he barely failed it, but Ice Bear came and helped him. Lee is so grateful for it, so he decided to show Ice Bear his new game called "Critic"...
The game is a one versus one game. It has t rounds, each round has two integers s_i and e_i (which are determine... | 0 |
{"tests": "{\"inputs\": [\"4\\n6 5\\n1 4\\n2 5\\n3 6\\n1 5\\n3 5\\n6 5\\n1 4\\n2 5\\n3 6\\n1 5\\n3 5\\n12 14\\n1 2\\n2 3\\n3 4\\n4 1\\n1 5\\n1 12\\n2 6\\n2 7\\n3 8\\n3 9\\n4 10\\n4 11\\n2 4\\n1 3\\n12 14\\n1 2\\n2 3\\n3 4\\n4 1\\n1 5\\n1 12\\n2 6\\n2 7\\n3 8\\n3 9\\n4 10\\n4 11\\n2 4\\n1 3\\n\", \"1\\n20 37\\n17 10\\n6... | You have a simple and connected undirected graph consisting of n nodes and m edges.
Consider any way to pair some subset of these n nodes such that no node is present in more than one pair.
This pairing is valid if for every pair of pairs, the induced subgraph containing all 4 nodes, two from each pair, has at most ... | 0 |
{"tests": "{\"inputs\": [\"2\\n4\\n4 8 9 6\\n6\\n2 1 7 4 0 0\\n\", \"2\\n4\\n8 8 9 6\\n6\\n2 1 7 4 0 0\\n\", \"2\\n4\\n8 8 9 8\\n6\\n2 0 7 4 0 0\\n\", \"2\\n4\\n3 8 14 6\\n6\\n2 1 7 4 0 0\\n\", \"2\\n4\\n3 8 14 6\\n6\\n2 0 7 4 0 0\\n\", \"2\\n4\\n3 8 1 6\\n6\\n2 0 7 4 0 0\\n\", \"2\\n4\\n8 8 9 8\\n6\\n2 1 2 4 0 0\\n\",... | Little Dormi received a histogram with n bars of height a_1, a_2, …, a_n for Christmas. However, the more he played with his new histogram, the more he realized its imperfections, so today he wanted to modify it to his liking.
To modify the histogram, Little Dormi is able to perform the following operation an arbitrar... | 0 |
{"tests": "{\"inputs\": [\"3\\n1 2 3\\n4 5 6\\n7 8 9\\n\", \"5\\n8 3 2 1 4\\n3 7 2 4 8\\n9 2 8 9 10\\n2 3 6 10 1\\n8 2 2 8 4\\n\", \"8\\n1 1 10 1 8 4 8 7\\n9 3 3 2 2 6 2 4\\n7 4 3 5 10 3 5 1\\n8 4 4 10 4 5 9 4\\n5 5 5 2 6 7 1 8\\n4 10 1 3 2 4 8 3\\n8 1 10 2 8 2 2 4\\n2 10 6 8 10 2 8 4\\n\", \"10\\n10 8 6 5 9 8 2 5 3 2\... | There is a square matrix n × n, consisting of non-negative integer numbers. You should find such a way on it that
* starts in the upper left cell of the matrix;
* each following cell is to the right or down from the current cell;
* the way ends in the bottom right cell.
Moreover, if we multiply together a... | 0 |
{"tests": "{\"inputs\": [\"25\\n\", \"3\\n\", \"2\\n\", \"13\\n\", \"864691128455135232\\n\", \"999971062750901550\\n\", \"943414054006932870\\n\", \"994374468178120050\\n\", \"38927073\\n\", \"136\\n\", \"6\\n\", \"210\\n\", \"55\\n\", \"499999999500000000\\n\", \"138485688541650132\\n\", \"605000000550000000\\n\", \"... | Daniel is organizing a football tournament. He has come up with the following tournament format:
1. In the first several (possibly zero) stages, while the number of teams is even, they split in pairs and play one game for each pair. At each stage the loser of each pair is eliminated (there are no draws). Such stage... | 0.25 |
{"tests": "{\"inputs\": [\"3\\n5 10 8\\n6\\n1 1 12\\n2 2\\n1 1 6\\n1 3 2\\n2 2\\n2 3\\n\", \"2\\n5 10\\n6\\n1 1 4\\n2 1\\n1 2 5\\n1 1 4\\n2 1\\n2 2\\n\", \"10\\n71 59 88 55 18 98 38 73 53 58\\n20\\n1 5 93\\n1 7 69\\n2 3\\n1 1 20\\n2 10\\n1 6 74\\n1 7 100\\n1 9 14\\n2 3\\n2 4\\n2 7\\n1 3 31\\n2 4\\n1 6 64\\n2 2\\n2 2\\n... | There is a system of n vessels arranged one above the other as shown in the figure below. Assume that the vessels are numbered from 1 to n, in the order from the highest to the lowest, the volume of the i-th vessel is ai liters.
<image>
Initially, all the vessels are empty. In some vessels water is poured. All the wa... | 0 |
{"tests": "{\"inputs\": [\"nniinneetteeeenn\\n\", \"nneteenabcnneteenabcnneteenabcnneteenabcnneteenabcii\\n\", \"nineteenineteen\\n\", \"mmmsermimjmrhrhejhrrejermsneheihhjemnehrhihesnjsehthjsmmjeiejmmnhinsemjrntrhrhsmjtttsrhjjmejj\\n\", \"rhsmnrmhejshinnjrtmtsssijimimethnm\\n\", \"jnirirhmirmhisemittnnsmsttesjhmjnsjsmn... | Alice likes word "nineteen" very much. She has a string s and wants the string to contain as many such words as possible. For that reason she can rearrange the letters of the string.
For example, if she has string "xiineteenppnnnewtnee", she can get string "xnineteenppnineteenw", containing (the occurrences marked) tw... | 0 |
{"tests": "{\"inputs\": [\"5 2\\n0 0 0 1 0\\n\", \"6 3\\n1 1 1 0 1 0\\n\", \"99 60\\n0 0 0 1 1 0 1 1 0 0 1 0 0 0 0 0 1 0 1 0 0 0 1 0 1 1 1 0 1 1 1 1 0 0 1 1 1 0 1 1 1 1 1 0 1 1 0 0 0 0 0 1 0 0 1 0 1 1 1 1 1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0 1 1 1 0 0 0 0 1 1 0 1 1 1 1 0 0 0 0 0 0 1 1 1\\n\", \"1 1\\n1\\n\", \"98 70\\n1 1 1... | There are n cities in Bearland, numbered 1 through n. Cities are arranged in one long row. The distance between cities i and j is equal to |i - j|.
Limak is a police officer. He lives in a city a. His job is to catch criminals. It's hard because he doesn't know in which cities criminals are. Though, he knows that ther... | 0.375 |
{"tests": "{\"inputs\": [\"5\\n>>>>>\\n\", \"4\\n<<><\\n\", \"4\\n>><<\\n\", \"4\\n<><>\\n\", \"5\\n<><>>\\n\", \"5\\n><>>>\\n\", \"100\\n<<<<<<<<<<<<<<<<<<<<<<<<>><<>><<<<<>><>><<<>><><<>>><<>>><<<<><><><<><<<<><>>>>>>>>>>>>>>>>>>>>>>>>>\\n\", \"8\\n<<>><<>>\\n\", \"4\\n<><<\\n\"... | In a new version of the famous Pinball game, one of the most important parts of the game field is a sequence of n bumpers. The bumpers are numbered with integers from 1 to n from left to right. There are two types of bumpers. They are denoted by the characters '<' and '>'. When the ball hits the bumper at position i it... | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.