info stringlengths 120 50k | question stringlengths 504 10.4k | avg@8_qwen3_4b_instruct_2507 float64 0 0.88 |
|---|---|---|
{"tests": "{\"inputs\": [\"4 5 3\\n3 5 1 2\\n\", \"10 10 1\\n10 5 7 4 6 3 2 1 9 8\\n\", \"1 4 3\\n3\\n\", \"2 5 2\\n5 3\\n\", \"3 6 4\\n3 1 4\\n\", \"4 100 44\\n90 96 41 35\\n\", \"5 200 33\\n116 168 48 180 164\\n\", \"10 20 19\\n9 15 11 18 20 5 16 12 3 17\\n\", \"20 1000 344\\n133 431 634 493 866 325 757 21 291 908 50... | Recently Monocarp got a job. His working day lasts exactly $m$ minutes. During work, Monocarp wants to drink coffee at certain moments: there are $n$ minutes $a_1, a_2, \dots, a_n$, when he is able and willing to take a coffee break (for the sake of simplicity let's consider that each coffee break lasts exactly one min... | 0 |
{"tests": "{\"inputs\": [\"4 1\\n1 2 1 5\\n\", \"4 1\\n1 2 3 4\\n\", \"50 1\\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50\\n\", \"10 1\\n1 2 3 4 5 6 7 8 9 10\\n\", \"50 5\\n232 6 11 16 21 26 31 36 41 46 665 56 61 66 71 76 6... | The Queen of England has n trees growing in a row in her garden. At that, the i-th (1 ≤ i ≤ n) tree from the left has height a_{i} meters. Today the Queen decided to update the scenery of her garden. She wants the trees' heights to meet the condition: for all i (1 ≤ i < n), a_{i} + 1 - a_{i} = k, where k is the number ... | 0 |
{"tests": "{\"inputs\": [\"4 4\\n1 2\\n1 3\\n4 2\\n4 3\\n\", \"3 3\\n1 2\\n2 3\\n3 1\\n\", \"3 0\\n\", \"6 3\\n1 2\\n4 3\\n6 5\\n\", \"100000 0\\n\", \"5 4\\n1 2\\n1 3\\n1 4\\n1 5\\n\", \"6 3\\n1 2\\n2 3\\n4 5\\n\", \"5 5\\n1 2\\n2 3\\n3 4\\n4 5\\n5 1\\n\", \"59139 0\\n\", \"9859 0\\n\", \"25987 0\\n\", \"9411 0\\n\", ... | After Vitaly was expelled from the university, he became interested in the graph theory.
Vitaly especially liked the cycles of an odd length in which each vertex occurs at most once.
Vitaly was wondering how to solve the following problem. You are given an undirected graph consisting of n vertices and m edges, not ne... | 0 |
{"tests": "{\"inputs\": [\"2 2\\n\", \"2 4\\n\", \"20 10\\n\", \"1000 1000\\n\", \"1 1000\\n\", \"1000 122\\n\", \"1 2\\n\", \"1 1\\n\", \"2 1\\n\", \"15 22\\n\", \"2 3\\n\", \"2 5\\n\", \"432 333\\n\", \"17 23\\n\", \"843 134\\n\", \"912 584\\n\", \"88 88\\n\", \"3 16\\n\"], \"outputs\": [\"16\\n\", \"64\\n\", \"75497... | Bob is decorating his kitchen, more precisely, the floor. He has found a prime candidate for the tiles he will use. They come in a simple form factor — a square tile that is diagonally split into white and black part as depicted in the figure below. [Image]
The dimension of this tile is perfect for this kitchen, as h... | 0.75 |
{"tests": "{\"inputs\": [\"5\\n1 0 1\\n20 1 0\\n300 0 1\\n4000 0 0\\n50000 1 0\\n1 2\\n2 3\\n2 4\\n1 5\\n\", \"5\\n10000 0 1\\n2000 1 0\\n300 0 1\\n40 0 0\\n1 1 0\\n1 2\\n2 3\\n2 4\\n1 5\\n\", \"2\\n109 0 1\\n205 0 1\\n1 2\\n\", \"8\\n82 0 0\\n3 1 1\\n53 0 0\\n5 0 0\\n81 0 1\\n56 1 0\\n99 1 0\\n87 0 1\\n5 7\\n2 8\\n4 7... | Ashish has a tree consisting of $n$ nodes numbered $1$ to $n$ rooted at node $1$. The $i$-th node in the tree has a cost $a_i$, and binary digit $b_i$ is written in it. He wants to have binary digit $c_i$ written in the $i$-th node in the end.
To achieve this, he can perform the following operation any number of times... | 0 |
{"tests": "{\"inputs\": [\"6 8\\nBBBBBBBB\\nBBBBBBBB\\nBBBBBBBB\\nWWWWWWWW\\nWWWWWWWW\\nWWWWWWWW\\n\", \"3 3\\nWBW\\nBWW\\nWWW\\n\", \"3 6\\nWWBBWW\\nWWBBWW\\nWWBBWW\\n\", \"4 4\\nBBBB\\nBBBB\\nBBBB\\nBBBW\\n\", \"10 9\\nBWWWBWWBB\\nBBWWBWBBW\\nBBWBWBWBB\\nBWBWBBBBB\\nBBWBWBWBW\\nBWWBWWBBW\\nWBWWWBWWW\\nWBBWBWBWW\\nBBW... | The first algorithm for detecting a face on the image working in realtime was developed by Paul Viola and Michael Jones in 2001. A part of the algorithm is a procedure that computes Haar features. As part of this task, we consider a simplified model of this concept.
Let's consider a rectangular image that is represent... | 0 |
{"tests": "{\"inputs\": [\"2 2 10\\n5 5\\n7 6\\n\", \"4 5 2\\n8 1 1 2\\n6 3 7 5 2\\n\", \"1 1 2\\n1\\n2\\n\", \"4 1 1\\n3 2 3 2\\n3\\n\", \"1 4 1\\n3\\n2 4 5 5\\n\", \"3 3 3\\n1 1 2\\n3 5 6\\n\", \"4 5 6\\n5 1 7 2\\n8 7 3 9 8\\n\", \"4 8 10\\n2 1 2 2\\n10 12 10 8 7 9 10 9\\n\", \"8 4 18\\n9 4 2 2 7 5 1 1\\n11 12 8 9\\n... | 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 p_{j} rubles.
In total, the boys' shared budget is a rubles. Besides, each of them has his own... | 0 |
{"tests": "{\"inputs\": [\"4 1\\n1 3\\n\", \"34 7\\n10 28\\n10 19\\n10 13\\n24 10\\n10 29\\n20 10\\n10 26\\n\", \"84 3\\n39 19\\n55 73\\n42 43\\n\", \"84 0\\n\", \"34 7\\n11 32\\n33 29\\n17 16\\n15 5\\n13 25\\n8 19\\n20 4\\n\", \"43 21\\n38 19\\n43 8\\n40 31\\n3 14\\n24 21\\n12 17\\n1 9\\n5 27\\n25 37\\n11 6\\n13 26\\n... | A country has n cities. Initially, there is no road in the country. One day, the king decides to construct some roads connecting pairs of cities. Roads can be traversed either way. He wants those roads to be constructed in such a way that it is possible to go from each city to any other city by traversing at most two r... | 0 |
{"tests": "{\"inputs\": [\"9\\n88 22 83 14 95 91 98 53 11\\n3 24\\n7 -8\\n1 67\\n1 64\\n9 65\\n5 12\\n6 -80\\n3 8\\n\", \"6\\n53 82 15 77 71 23\\n5 -77\\n6 -73\\n2 0\\n1 26\\n4 -92\\n\", \"10\\n99 60 68 46 51 11 96 41 48 99\\n4 50\\n6 -97\\n3 -92\\n7 1\\n9 99\\n2 79\\n1 -15\\n8 -68\\n5 -84\\n\", \"8\\n53 41 22 22 34 95... | Alyona decided to go on a diet and went to the forest to get some apples. There she unexpectedly found a magic rooted tree with root in the vertex 1, every vertex and every edge of which has a number written on.
The girl noticed that some of the tree's vertices are sad, so she decided to play with them. Let's call ver... | 0 |
{"tests": "{\"inputs\": [\"3 2 2\\n\", \"3 2 1\\n\", \"7 2 3\\n\", \"9 2 3\\n\", \"2 1 1000\\n\", \"1000 2 8\\n\", \"513 2 9\\n\", \"82 3 4\\n\", \"244 3 5\\n\", \"1000 999 1\\n\", \"1 1 1\\n\", \"1 1 2\\n\", \"2 1 1\\n\", \"1 2 1\\n\", \"5 3 2\\n\", \"1 1000000000 1\\n\", \"27 3 3\\n\", \"1 1 10\\n\"], \"outputs\": [\... | Recently Pashmak has been employed in a transportation company. The company has k buses and has a contract with a school which has n students. The school planned to take the students to d different places for d days (each day in one place). Each day the company provides all the buses for the trip. Pashmak has to arrang... | 0 |
{"tests": "{\"inputs\": [\"3\\n3 2 3\\n4 3 2\\n3 1 3\\n1 2\\n2 3\\n\", \"5\\n3 4 2 1 2\\n4 2 1 5 4\\n5 3 2 1 1\\n1 2\\n3 2\\n4 3\\n5 3\\n\", \"5\\n3 4 2 1 2\\n4 2 1 5 4\\n5 3 2 1 1\\n1 2\\n3 2\\n4 3\\n5 4\\n\", \"4\\n4 7 3 2\\n2 3 7 2\\n1 1 2 1\\n4 3\\n1 2\\n3 2\\n\", \"7\\n1 8 3 2 6 3 2\\n2 6 6 5 4 1 9\\n6 4 7 1 5 5 2... | You are given a tree consisting of $n$ vertices. A tree is an undirected connected acyclic graph. [Image] Example of a tree.
You have to paint each vertex into one of three colors. For each vertex, you know the cost of painting it in every color.
You have to paint the vertices so that any path consisting of exactly ... | 0 |
{"tests": "{\"inputs\": [\"4 2\\n1 100\\n40 70\\n120 130\\n125 180\\n\", \"3 2\\n1 12\\n15 20\\n25 30\\n\", \"5 2\\n1 10\\n5 15\\n14 50\\n30 70\\n99 100\\n\", \"7 6\\n-8 6\\n7 9\\n-10 -5\\n-6 10\\n-7 -3\\n5 8\\n4 10\\n\", \"9 6\\n-7 -3\\n-3 10\\n-6 1\\n-1 8\\n-9 4\\n-7 -6\\n-5 -3\\n-10 -2\\n3 4\\n\", \"7 7\\n9 10\\n-5 ... | All our characters have hobbies. The same is true for Fedor. He enjoys shopping in the neighboring supermarket.
The goods in the supermarket have unique integer ids. Also, for every integer there is a product with id equal to this integer. Fedor has n discount coupons, the i-th of them can be used with products with ... | 0 |
{"tests": "{\"inputs\": [\"1 2\\nDI\\n\", \"2 2\\nMA\\nID\\n\", \"5 5\\nDIMAD\\nDIMAI\\nDIMAM\\nDDMAA\\nAAMID\\n\", \"1 1\\nI\\n\", \"5 5\\nDIMAD\\nADDDI\\nMDDDM\\nIDDDA\\nDAMID\\n\", \"5 5\\nAAAAA\\nAAAAA\\nAAAAA\\nAAAAA\\nAAAAA\\n\", \"1 1\\nD\\n\", \"1 4\\nDIMA\\n\", \"4 1\\nD\\nI\\nM\\nA\\n\", \"2 2\\nDI\\nAM\\n\",... | Inna and Dima bought a table of size n × m in the shop. Each cell of the table contains a single letter: "D", "I", "M", "A".
Inna loves Dima, so she wants to go through his name as many times as possible as she moves through the table. For that, Inna acts as follows:
initially, Inna chooses some cell of the table w... | 0 |
{"tests": "{\"inputs\": [\"2\\n\", \"10\\n\", \"1000000\\n\", \"1\\n\", \"17\\n\", \"3\\n\", \"5\\n\", \"6\\n\", \"7\\n\", \"8\\n\", \"9\\n\", \"103\\n\", \"11\\n\", \"152\\n\", \"987654\\n\", \"123452\\n\", \"78266\\n\", \"4\\n\"], \"outputs\": [\"8\\n\", \"19210869\\n\", \"739718215\\n\", \"1\\n\", \"466150679\\n\", ... | Let $n$ be an integer. Consider all permutations on integers $1$ to $n$ in lexicographic order, and concatenate them into one big sequence $P$. For example, if $n = 3$, then $P = [1, 2, 3, 1, 3, 2, 2, 1, 3, 2, 3, 1, 3, 1, 2, 3, 2, 1]$. The length of this sequence is $n \cdot n!$.
Let $1 \leq i \leq j \leq n \cdot n!$ ... | 0 |
{"tests": "{\"inputs\": [\"4\\n\", \"3\\n\", \"6\\n\", \"10\\n\", \"67\\n\", \"159\\n\", \"2\\n\", \"5\\n\", \"7\\n\", \"8\\n\", \"9\\n\", \"89\\n\", \"38\\n\", \"34\\n\", \"93\\n\", \"41\\n\", \"72\\n\", \"179\\n\"], \"outputs\": [\"1 2 1 \", \"2 1\", \"1 2 1 3 2 \", \"1 2 1 3 2 4 1 2 3 \", \"1 2 1 3 2 4 1 2 3 5 2 6 4... | You're given an integer $n$. For every integer $i$ from $2$ to $n$, assign a positive integer $a_i$ such that the following conditions hold: For any pair of integers $(i,j)$, if $i$ and $j$ are coprime, $a_i \neq a_j$. The maximal value of all $a_i$ should be minimized (that is, as small as possible).
A pair of int... | 0 |
{"tests": "{\"inputs\": [\"4\\ngarage for sa-le\\n\", \"4\\nEdu-ca-tion-al Ro-unds are so fun\\n\", \"1\\nj\\n\", \"10\\nb\\n\", \"1\\nQGVsfZevMD\\n\", \"1\\nqUOYCytbKgoGRgaqhjrohVRxKTKjjOUPPnEjiXJWlvpCyqiRzbnpyNqDylWverSTrcgZpEoDKhJCrOOvsuXHzkPtbXeKCKMwUTVk\\n\", \"100000\\nBGRHXGrqgjMxCBCdQTCpQyHNMkraTRxhyZBztkxXNFEK... | The main city magazine offers its readers an opportunity to publish their ads. The format of the ad should be like this:
There are space-separated non-empty words of lowercase and uppercase Latin letters.
There are hyphen characters '-' in some words, their positions set word wrapping points. Word can include more th... | 0 |
{"tests": "{\"inputs\": [\"0000000101\\n3\\n\", \"1000000000\\n2\\n\", \"1000000000\\n1\\n\", \"1001100000\\n11\\n\", \"0100000001\\n10\\n\", \"0110110000\\n12\\n\", \"0111100111\\n32\\n\", \"0000001100\\n52\\n\", \"0000000000\\n1\\n\", \"0000000001\\n1\\n\", \"0000010000\\n2\\n\", \"1100000000\\n3\\n\", \"1110010000\\... | Xenia has a set of weights and pan scales. Each weight has an integer weight from 1 to 10 kilos. Xenia is going to play with scales and weights a little. For this, she puts weights on the scalepans, one by one. The first weight goes on the left scalepan, the second weight goes on the right scalepan, the third one goes ... | 0 |
{"tests": "{\"inputs\": [\"3\\n2 4 3\\n\", \"5\\n1 2 3 4 4\\n\", \"3\\n13 8 5\\n\", \"4\\n1 10 100 1000\\n\", \"3\\n1 1000000000 999999999\\n\", \"35\\n5856 4937422 170055 7988916 88598426 20915252 3051495 1885928 720361 2233 12926337 842 231953689 24812 33 260 33841588 54756839 15334 275154 40145 982571591 375308952 5... | You are given $n$ numbers $a_1, a_2, \ldots, a_n$. Is it possible to arrange them in a circle in such a way that every number is strictly less than the sum of its neighbors?
For example, for the array $[1, 4, 5, 6, 7, 8]$, the arrangement on the left is valid, while arrangement on the right is not, as $5\ge 4 + 1$ and... | 0 |
{"tests": "{\"inputs\": [\"5\\n1 2 2 2 2\\n\", \"3\\n1 1 1\\n\", \"3\\n3 3 3\\n\", \"1\\n1\\n\", \"1\\n963837006\\n\", \"5\\n1 3 3 5 3\\n\", \"100\\n5 5 2 4 5 4 4 4 4 2 5 3 4 2 4 4 1 1 5 3 2 2 1 3 3 2 5 3 4 5 1 3 5 4 4 4 3 1 4 4 3 4 5 2 5 4 2 1 2 2 3 5 5 5 1 4 5 3 1 4 2 2 5 1 5 3 4 1 5 1 2 2 3 5 1 3 2 4 2 4 2 2 4 1 3 5... | Pavel has several sticks with lengths equal to powers of two.
He has $a_0$ sticks of length $2^0 = 1$, $a_1$ sticks of length $2^1 = 2$, ..., $a_{n-1}$ sticks of length $2^{n-1}$.
Pavel wants to make the maximum possible number of triangles using these sticks. The triangles should have strictly positive area, each s... | 0 |
{"tests": "{\"inputs\": [\"5\\n1 2 2 1 2\\n\", \"8\\n1 2 2 1 2 1 1 2\\n\", \"1\\n2\\n\", \"1\\n1\\n\", \"2\\n2 2\\n\", \"2\\n1 2\\n\", \"2\\n1 1\\n\", \"10\\n2 2 2 2 2 2 1 2 1 1\\n\", \"10\\n2 1 1 2 1 2 1 2 2 1\\n\", \"10\\n1 1 1 1 1 1 1 1 1 1\\n\", \"10\\n1 1 1 1 2 1 1 1 1 1\\n\", \"10\\n2 1 2 2 2 2 2 2 2 2\\n\", \"10... | Smart Beaver decided to be not only smart, but also a healthy beaver! And so he began to attend physical education classes at school X. In this school, physical education has a very creative teacher. One of his favorite warm-up exercises is throwing balls. Students line up. Each one gets a single ball in the beginning.... | 0 |
{"tests": "{\"inputs\": [\"1\\n10\\nG\\n\", \"2\\n10 10\\nWL\\n\", \"2\\n1 2\\nWL\\n\", \"3\\n10 10 10\\nGLW\\n\", \"2\\n2 10\\nGL\\n\", \"1\\n10\\nW\\n\", \"1\\n9\\nW\\n\", \"1\\n9\\nG\\n\", \"2\\n10 10\\nGL\\n\", \"3\\n10 10 50\\nWGL\\n\", \"3\\n10 9 10\\nGLW\\n\", \"2\\n100 100\\nWG\\n\", \"2\\n100 100\\nGW\\n\", \"... | Bob is a duck. He wants to get to Alice's nest, so that those two can duck! [Image] Duck is the ultimate animal! (Image courtesy of See Bang)
The journey can be represented as a straight line, consisting of $n$ segments. Bob is located to the left of the first segment, while Alice's nest is on the right of the last s... | 0 |
{"tests": "{\"inputs\": [\"9 2\\n6 19 3 4 4 2 6 7 8\\n\", \"1 1\\n7\\n\", \"2 1\\n135072 38422\\n\", \"2 2\\n51200 19970\\n\", \"37 13\\n164823 8992 21818 77521 130870 83201 174985 168799 9565 84443 105083 54131 130813 42829 98759 60103 198520 125068 59611 45609 124003 106143 54167 179002 103755 152802 146640 38512 913... | Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$.
Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons.
Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t... | 0 |
{"tests": "{\"inputs\": [\"2\\n\", \"4\\n\", \"1\\n\", \"3\\n\", \"5\\n\", \"6\\n\", \"7\\n\", \"8\\n\", \"9\\n\", \"10\\n\", \"15\\n\", \"16\\n\", \"17\\n\", \"33\\n\", \"79\\n\", \"27\\n\", \"55\\n\"], \"outputs\": [\"2\\n1 1\\n2 1\", \"3\\n1 1\\n2 1\\n3 1\\n3 2\", \"1\\n1 1\", \"2\\n1 1\\n2 1\\n2 2\", \"3\\n1 1\\n2 ... | Nauuo is a girl who loves playing chess.
One day she invented a game by herself which needs $n$ chess pieces to play on a $m\times m$ chessboard. The rows and columns are numbered from $1$ to $m$. We denote a cell on the intersection of the $r$-th row and $c$-th column as $(r,c)$.
The game's goal is to place $n$ ches... | 0 |
{"tests": "{\"inputs\": [\"5\\noxxxx\\nx...x\\nx...x\\nx...x\\nxxxxo\\n\", \"6\\n.x.x..\\nx.x.x.\\n.xo..x\\nx..ox.\\n.x.x.x\\n..x.x.\\n\", \"3\\no.x\\noxx\\no.x\\n\", \"1\\no\\n\", \"2\\nox\\n.o\\n\", \"5\\n.xxo.\\n..oxo\\nx.oxo\\no..xo\\noooox\\n\", \"8\\n..xox.xo\\n..xxx.xx\\n........\\n........\\n........\\n........... | Igor has been into chess for a long time and now he is sick of the game by the ordinary rules. He is going to think of new rules of the game and become world famous.
Igor's chessboard is a square of size n × n cells. Igor decided that simple rules guarantee success, that's why his game will have only one type of piece... | 0 |
{"tests": "{\"inputs\": [\"4\\n\", \"1\\n\", \"2\\n\", \"3\\n\", \"5\\n\", \"17\\n\", \"6\\n\", \"7\\n\", \"8\\n\", \"9\\n\", \"10\\n\", \"11\\n\", \"12\\n\", \"13\\n\", \"14\\n\", \"16\\n\", \"23\\n\"], \"outputs\": [\"16\\n0 0\\n0 1\\n1 0\\n1 1\\n1 2\\n2 1\\n2 2\\n2 3\\n3 2\\n3 3\\n3 4\\n4 3\\n4 4\\n4 5\\n5 4\\n5 5\\... | Leo Jr. draws pictures in his notebook with checkered sheets (that is, each sheet has a regular square grid printed on it). We can assume that the sheets are infinitely large in any direction.
To draw a picture, Leo Jr. colors some of the cells on a sheet gray. He considers the resulting picture beautiful if the follo... | 0 |
{"tests": "{\"inputs\": [\"7 3\\n1 2 3 4 3 2 6\\n6 3 1 4 2 2 3\\n\", \"4 4\\n0 1 2 3\\n0 1 2 3\\n\", \"5 3\\n1 2 3 4 0\\n4 1 2 14 3\\n\", \"1 1\\n0\\n10000\\n\", \"1 2\\n0\\n10000\\n\", \"1 10000000000\\n0\\n10000\\n\", \"2 3\\n0 0\\n4 7\\n\", \"2 3\\n0 1\\n4 7\\n\", \"2 3\\n1 0\\n4 7\\n\", \"2 3\\n1 1\\n4 7\\n\", \"3 ... | You are given a functional graph. It is a directed graph, in which from each vertex goes exactly one arc. The vertices are numerated from 0 to n - 1.
Graph is given as the array f_0, f_1, ..., f_{n} - 1, where f_{i} — the number of vertex to which goes the only arc from the vertex i. Besides you are given array with w... | 0.125 |
{"tests": "{\"inputs\": [\"3\\n1 1 2\\n2 3 1\\n6 4 1\\n\", \"3\\n1 5 2\\n1 1 1\\n1 2 3\\n\", \"1\\n1\\n\", \"4\\n1 1 1 1\\n1 11 1 2\\n2 5 1 4\\n3 9 4 1\\n\", \"4\\n1 1 1 1\\n1 7 1 1\\n1 3 1 2\\n2 6 3 1\\n\", \"4\\n1 1 1 1\\n1 12 1 2\\n4 4 1 3\\n5 10 6 1\\n\", \"4\\n1 1 1 1\\n1 13 1 2\\n4 5 1 3\\n5 11 6 1\\n\", \"4\\n1 ... | Okabe needs to renovate the Future Gadget Laboratory after he tried doing some crazy experiments! The lab is represented as an n by n square grid of integers. A good lab is defined as a lab in which every number not equal to 1 can be expressed as the sum of a number in the same row and a number in the same column. In o... | 0.75 |
{"tests": "{\"inputs\": [\"2 1\\nRL\\n\", \"2 1\\nLR\\n\", \"4 2\\nRLRL\\n\", \"3 2\\nRRL\\n\", \"3 2\\nLRL\\n\", \"250 2188894\\nLRLLLRRLRLRRLLRRRRRRRRRLRRLLRLLRLRLRLRRLLLRRLLLRLRRRRRRRLLLRRRRRLLLLRLRRRLRRRLLLLLLLLRRLRRLLRRRLLLRLLRRRLLRRLRLRLLLRLRRLLRRRRLRRLRLLLLRLRRLLLLLRRLRLRRRLLLRRLLLRRRLLRLRRRLRRRRRLRRLRRLLLRLRRRL... | There are $n$ children, who study at the school №41. It is well-known that they are good mathematicians. Once at a break, they arranged a challenge for themselves. All children arranged in a row and turned heads either to the left or to the right.
Children can do the following: in one second several pairs of neighbori... | 0 |
{"tests": "{\"inputs\": [\"3 3 2\\n1 2 1\\n3 2 1\\n1 3 3\\n\", \"4 5 2\\n4 1 8\\n2 4 1\\n2 1 3\\n3 4 9\\n3 1 5\\n\", \"5 5 4\\n1 2 999999999\\n2 3 999999999\\n3 4 999999999\\n1 5 999999999\\n5 4 999999999\\n\", \"4 5 0\\n4 1 8\\n2 4 1\\n2 1 3\\n3 4 9\\n3 1 5\\n\", \"4 3 3\\n1 2 1000000000\\n2 3 1000000000\\n3 4 1000000... | You are given an undirected connected weighted graph consisting of $n$ vertices and $m$ edges. Let's denote the length of the shortest path from vertex $1$ to vertex $i$ as $d_i$.
You have to erase some edges of the graph so that at most $k$ edges remain. Let's call a vertex $i$ good if there still exists a path from... | 0 |
{"tests": "{\"inputs\": [\"4\\n5 5 7 2\\n\", \"3\\n1 2 3\\n\", \"3\\n3 1 10\\n\", \"1\\n0\\n\", \"1\\n7\\n\", \"2\\n3 4\\n\", \"10\\n2 1 0 0 0 2 2 1 1 0\\n\", \"10\\n5 3 2 0 6 5 4 1 6 2\\n\", \"10\\n63366411 57391809 217887804 43036621 397716019 878676084 451005539 537039674 935482853 474757099\\n\", \"100\\n3 2 1 3 2 ... | You are given an array $a_1, a_2, \dots, a_n$ of integer numbers.
Your task is to divide the array into the maximum number of segments in such a way that:
each element is contained in exactly one segment; each segment contains at least one element; there doesn't exist a non-empty subset of segments such that bitw... | 0 |
{"tests": "{\"inputs\": [\"4\\n\", \"5\\n\", \"1000000\\n\", \"999999\\n\", \"524288\\n\", \"524287\\n\", \"890123\\n\", \"2\\n\", \"3\\n\", \"7\\n\", \"6\\n\", \"8\\n\", \"9\\n\", \"10\\n\", \"887726\\n\", \"314159\\n\", \"10239\\n\", \"997263\\n\", \"233557\\n\", \"1000\\n\", \"102\\n\", \"777777\\n\"], \"outputs\": ... | You are given an integer L. Construct a directed graph that satisfies the conditions below. The graph may contain multiple edges between the same pair of vertices. It can be proved that such a graph always exists.
- The number of vertices, N, is at most 20. The vertices are given ID numbers from 1 to N.
- The number ... | 0 |
{"tests": "{\"inputs\": [\"4\\n92 31\\n0 7\\n31 0\\n7 141\\n\", \"2\\n0 1\\n2 0\\n\", \"3\\n0 2\\n1 3\\n2 0\\n\", \"4\\n101 0\\n0 102\\n102 100\\n103 101\\n\", \"5\\n0 1\\n1 4\\n4 0\\n3 2\\n5 3\\n\", \"6\\n10001 0\\n0 10005\\n10003 10001\\n10002 10000\\n10005 10002\\n10004 10003\\n\", \"3\\n0 743259\\n72866 70294\\n743... | During the lunch break all n Berland State University students lined up in the food court. However, it turned out that the food court, too, has a lunch break and it temporarily stopped working.
Standing in a queue that isn't being served is so boring! So, each of the students wrote down the number of the student ID of... | 0 |
{"tests": "{\"inputs\": [\"2\\n1 1\\n\", \"3\\n3 4 2\\n\", \"1\\n1\\n\", \"1\\n1000000000\\n\", \"3\\n1 2 3\\n\", \"2\\n2 3\\n\", \"5\\n1 4 2 1 1\\n\", \"15\\n2 72 77 69 62 73 58 9 4 95 97 14 41 79 34\\n\", \"1\\n1\\n\", \"10\\n529280935 122195401 684409084 743180136 724768643 211207376 167236398 696535490 425348743 1\... | Long ago, Vasily built a good fence at his country house. Vasily calls a fence good, if it is a series of n consecutively fastened vertical boards of centimeter width, the height of each in centimeters is a positive integer. The house owner remembers that the height of the i-th board to the left is h_{i}.
Today Vasily... | 0 |
{"tests": "{\"inputs\": [\"6\\n\", \"3\\n\", \"1\\n\", \"2\\n\", \"4\\n\", \"5\\n\", \"7\\n\", \"8\\n\", \"9\\n\", \"10\\n\", \"13\\n\", \"16\\n\", \"25\\n\", \"29\\n\", \"120\\n\", \"128\\n\"], \"outputs\": [\"6\\n5 3 1 6 4 2 \", \"2\\n1 3\", \"1\\n1 \", \"1\\n1\", \"4\\n3 1 4 2 \", \"5\\n5 3 1 4 2 \", \"7\\n7 5 3 1 6... | An exam for n students will take place in a long and narrow room, so the students will sit in a line in some order. The teacher suspects that students with adjacent numbers (i and i + 1) always studied side by side and became friends and if they take an exam sitting next to each other, they will help each other for sur... | 0 |
{"tests": "{\"inputs\": [\"4 3\\n0 1 0 1\\n0 1\\n1 2\\n2 3\\n\", \"4 3\\n1 1 1 0\\n0 1\\n0 2\\n3 0\\n\", \"10 39\\n0 1 0 1 0 1 1 0 1 1\\n0 1\\n0 2\\n0 3\\n0 4\\n0 5\\n0 6\\n1 2\\n1 3\\n1 4\\n1 5\\n1 6\\n1 7\\n1 8\\n1 9\\n2 3\\n2 4\\n2 5\\n2 6\\n2 7\\n2 8\\n2 9\\n3 4\\n3 6\\n3 7\\n3 8\\n3 9\\n4 5\\n4 6\\n4 7\\n4 9\\n5 6... | You are given a program you want to execute as a set of tasks organized in a dependency graph. The dependency graph is a directed acyclic graph: each task can depend on results of one or several other tasks, and there are no directed circular dependencies between tasks. A task can only be executed if all tasks it depen... | 0 |
{"tests": "{\"inputs\": [\"2 2\\n4 1\\n\", \"3 1\\n2\\n\", \"5 5\\n25 24 23 22 21\\n\", \"1 30\\n8 22 13 25 10 30 12 27 6 4 7 2 20 16 26 14 15 17 23 3 24 9 5 11 29 1 19 28 21 18\\n\", \"30 1\\n29\\n\", \"1 1\\n1\\n\", \"2 1\\n1\\n\", \"1 2\\n2 1\\n\", \"1 3\\n2 3 1\\n\", \"2 3\\n3 2 1\\n\", \"3 3\\n6 7 8\\n\", \"3 1\\n... | One day Ms Swan bought an orange in a shop. The orange consisted of n·k segments, numbered with integers from 1 to n·k.
There were k children waiting for Ms Swan at home. The children have recently learned about the orange and they decided to divide it between them. For that each child took a piece of paper and wrote... | 0 |
{"tests": "{\"inputs\": [\"2 3\\n-1 -1\\n\", \"5 2\\n1 -1 -1 1 2\\n\", \"5 3\\n1 -1 -1 1 2\\n\", \"4 200000\\n-1 -1 12345 -1\\n\", \"9 3\\n-1 -1 -1 -1 1 2 3 -1 -1\\n\", \"10 5\\n4 -1 -1 1 -1 -1 -1 2 -1 -1\\n\", \"10 8\\n-1 3 5 2 4 -1 -1 1 -1 -1\\n\", \"10 11\\n-1 11 -1 -1 -1 -1 10 -1 -1 -1\\n\", \"10 14\\n-1 9 11 11 -1... | Let's denote that some array $b$ is bad if it contains a subarray $b_l, b_{l+1}, \dots, b_{r}$ of odd length more than $1$ ($l < r$ and $r - l + 1$ is odd) such that $\forall i \in \{0, 1, \dots, r - l\}$ $b_{l + i} = b_{r - i}$.
If an array is not bad, it is good.
Now you are given an array $a_1, a_2, \dots, a_n$. S... | 0 |
{"tests": "{\"inputs\": [\"3 6\\nXXXXXX\\nXXXXXX\\nXXXXXX\\n\", \"10 10\\n.XXXXXX...\\n.XXXXXX...\\n.XXXXXX...\\n.XXXXXX...\\n.XXXXXXXX.\\n...XXXXXX.\\n...XXXXXX.\\n...XXXXXX.\\n...XXXXXX.\\n..........\\n\", \"4 5\\nX....\\n..XXX\\n..XXX\\n..XXX\\n\", \"1 1\\nX\\n\", \"10 12\\n...X..X..XX.\\n.....X......\\n..X............ | The Berland Forest can be represented as an infinite cell plane. Every cell contains a tree. That is, contained before the recent events.
A destructive fire raged through the Forest, and several trees were damaged by it. Precisely speaking, you have a $n \times m$ rectangle map which represents the damaged part of the... | 0 |
{"tests": "{\"inputs\": [\"aaaaa\\naa\\n\", \"axbaxxb\\nab\\n\", \"aabb\\nab\\n\", \"aaaaaaaaaaaaaaa\\na\\n\", \"aaaaaaaaaaa\\nb\\n\", \"ababababababababa\\naba\\n\", \"axxbaxxbaxxb\\nab\\n\", \"axaxxbaxabxbaxxbxb\\nab\\n\", \"ababcc\\nabc\\n\", \"a\\na\\n\", \"a\\nb\\n\", \"a\\naa\\n\", \"a\\nab\\n\", \"a\\nbbbbbbbbbb... | 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 $\operatorname{occ}(s^{\prime}, p)$ 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... | 0 |
{"tests": "{\"inputs\": [\"3\\n4 8 2\\n\", \"3\\n3 5 6\\n\", \"2\\n50000 100000\\n\", \"2\\n99999 99998\\n\", \"17\\n1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 32768 65536\\n\", \"19\\n1 2 3 4 6 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 32768 65536\\n\", \"20\\n1 2 3 4 6 8 16 20 32 64 128 256 512 102... | Amr loves Chemistry, and specially doing experiments. He is preparing for a new interesting experiment.
Amr has n different types of chemicals. Each chemical i has an initial volume of a_{i} liters. For this experiment, Amr has to mix all the chemicals together, but all the chemicals volumes must be equal first. So hi... | 0 |
{"tests": "{\"inputs\": [\"5 4 2 2\\n1 2 3 2 1\\n3 2 1 2 3\\n1 1\\n2 1\\n1 2\\n2 2\\n\", \"4 3 2 200\\n69 70 71 72\\n104 105 106 107\\n1 1\\n2 2\\n1 2\\n\", \"4 3 1 1000000000\\n900000 910000 940000 990000\\n990000 999000 999900 999990\\n1 87654\\n2 76543\\n1 65432\\n\", \"5 5 3 1000000\\n921 853 547 187 164\\n711 462 ... | Nura wants to buy k gadgets. She has only s burles for that. She can buy each gadget for dollars or for pounds. So each gadget is selling only for some type of currency. The type of currency and the cost in that currency are not changing.
Nura can buy gadgets for n days. For each day you know the exchange rates of dol... | 0 |
{"tests": "{\"inputs\": [\"3\\n3 5\\n1 2\\n3 4\\n2 1000000000\\n1 1\\n999999999 999999999\\n10 3\\n5 10\\n7 8\\n\", \"1\\n200000 88635750\\n4971058 40181766\\n6012372 78925196\\n\", \"1\\n200000 598920770\\n24529366 24846325\\n35694819 90253337\\n\", \"1\\n1 1\\n1 1\\n1 1\\n\", \"1\\n4 9\\n4 10\\n5 5\\n\", \"1\\n1 1\\n... | You are given two lists of segments $[al_1, ar_1], [al_2, ar_2], \dots, [al_n, ar_n]$ and $[bl_1, br_1], [bl_2, br_2], \dots, [bl_n, br_n]$.
Initially, all segments $[al_i, ar_i]$ are equal to $[l_1, r_1]$ and all segments $[bl_i, br_i]$ are equal to $[l_2, r_2]$.
In one step, you can choose one segment (either from ... | 0 |
{"tests": "{\"inputs\": [\"8 8 0 2 8 3 4 5\\n\", \"10 10 7 0 5 8 2 11\\n\", \"10 10 0 7 5 8 2 11\\n\", \"10 10 -7 0 5 8 2 11\\n\", \"10 10 0 -7 5 8 2 11\\n\", \"10 10 7 7 5 8 2 11\\n\", \"10 10 7 -7 5 8 2 11\\n\", \"10 10 -7 7 5 8 2 11\\n\", \"10 10 -7 -7 5 8 2 11\\n\", \"669 649 952 535 380 408 58 532\\n\", \"90 798 4... | Petya has recently started working as a programmer in the IT city company that develops computer games.
Besides game mechanics implementation to create a game it is necessary to create tool programs that can be used by game designers to create game levels. Petya's first assignment is to create a tool that allows to pa... | 0 |
{"tests": "{\"inputs\": [\"5 1\\nAABBB\\n\", \"5 1\\nABABB\\n\", \"26 1\\nABCDEFGHIJKLMNOPQRSTUVWXYZ\\n\", \"27 1\\nABCDEFGHIJKLMNOPQRSTUVWXYZA\\n\", \"5 2\\nABACA\\n\", \"6 2\\nABCABC\\n\", \"8 3\\nABCBCDCA\\n\", \"73 2\\nDEBECECBBADAADEAABEAEEEAEBEAEBCDDBABBAEBACCBEEBBAEADEECACEDEEDABACDCDBBBD\\n\", \"44 15\\nHGJIFCG... | [Image]
It's the end of July – the time when a festive evening is held at Jelly Castle! Guests from all over the kingdom gather here to discuss new trends in the world of confectionery. Yet some of the things discussed here are not supposed to be disclosed to the general public: the information can cause discord in t... | 0.5 |
{"tests": "{\"inputs\": [\"5\\n4 5 3 5\\n6 7 4 6\\n\", \"3\\n2 4\\n3 2\\n\", \"8\\n2 3 1 1 2 4 3\\n3 4 4 2 5 5 4\\n\", \"2\\n1\\n1000000000\\n\", \"10\\n1 1 1 3 2 1 1 2 1\\n3 2 3 3 3 2 3 3 3\\n\", \"10\\n1 1 4 2 2 1 7 6 7\\n8 9 7 4 6 3 8 7 9\\n\", \"20\\n2 3 2 6 1 1 2 5 2 3 3 1 2 2 3 2 6 1 3\\n2 7 3 6 5 7 3 5 3 6 7 7 7... | A permutation of length $k$ is a sequence of $k$ integers from $1$ to $k$ containing each integer exactly once. For example, the sequence $[3, 1, 2]$ is a permutation of length $3$.
When Neko was five, he thought of an array $a$ of $n$ positive integers and a permutation $p$ of length $n - 1$. Then, he performed the f... | 0 |
{"tests": "{\"inputs\": [\"3\\n\", \"5\\n\", \"13\\n\", \"1\\n\", \"2\\n\", \"4\\n\", \"6\\n\", \"15\\n\", \"16\\n\", \"7\\n\", \"8\\n\", \"9\\n\", \"10\\n\", \"11\\n\", \"12\\n\", \"14\\n\"], \"outputs\": [\"18\\n\", \"1800\\n\", \"695720788\\n\", \"1\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"150347555\\n\", \"0\\n\", \"6... | Permutation p is an ordered set of integers p_1, p_2, ..., p_{n}, consisting of n distinct positive integers, each of them doesn't exceed n. We'll denote the i-th element of permutation p as p_{i}. We'll call number n the size or the length of permutation p_1, p_2, ..., p_{n}.
Petya decided to introduce the sum ... | 0 |
{"tests": "{\"inputs\": [\"3\\naAbB\\n\", \"4\\naBaCaB\\n\", \"5\\nxYyXzZaZ\\n\", \"26\\naAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyY\\n\", \"26\\nzAyBxCwDvEuFtGsHrIqJpKoLnMmNlOkPjQiRhSgTfUeVdWcXbY\\n\", \"5\\naArRaRaR\\n\", \"2\\ndA\\n\", \"2\\ncB\\n\", \"10\\nhNcMeXsSlHsUwYeMcA\\n\", \"100\\nqDpInBmCrFwXpDbFgOz... | After a hard day Vitaly got very hungry and he wants to eat his favorite potato pie. But it's not that simple. Vitaly is in the first room of the house with n room located in a line and numbered starting from one from left to right. You can go from the first room to the second room, from the second room to the third ro... | 0 |
{"tests": "{\"inputs\": [\"5\\n1 2 3 1 2\\n\", \"5\\n1 -2 3 1 -2\\n\", \"2\\n0 0\\n\", \"3\\n0 -1 0\\n\", \"3\\n1 1 1\\n\", \"4\\n-1 1 1 -1\\n\", \"4\\n-1 1 -1 1\\n\", \"2\\n-1 -1\\n\", \"3\\n-1 0 -1\\n\", \"6\\n-1 3 3 5 5 -1\\n\", \"2\\n-1000000000 -1000000000\\n\", \"3\\n-1000000000 -1000000000 -1000000000\\n\", \"3\... | — Oh my sweet Beaverette, would you fancy a walk along a wonderful woodland belt with me?
— Of course, my Smart Beaver! Let us enjoy the splendid view together. How about Friday night?
At this point the Smart Beaver got rushing. Everything should be perfect by Friday, so he needed to prepare the belt to the upcom... | 0 |
{"tests": "{\"inputs\": [\"2\\n\", \"3\\n\", \"4\\n\", \"5\\n\", \"6\\n\", \"50\\n\", \"51\\n\", \"52\\n\", \"53\\n\", \"54\\n\", \"100\\n\", \"101\\n\", \"102\\n\", \"103\\n\", \"104\\n\"], \"outputs\": [\"1 \", \"1 1 \", \"1 1 2 \", \"1 1 1 2 \", \"1 1 1 2 3 \", \"1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 3 3 4 5 5 5 6 7 7 7 7... | Kate has a set $S$ of $n$ integers $\{1, \dots, n\} $.
She thinks that imperfection of a subset $M \subseteq S$ is equal to the maximum of $gcd(a, b)$ over all pairs $(a, b)$ such that both $a$ and $b$ are in $M$ and $a \neq b$.
Kate is a very neat girl and for each $k \in \{2, \dots, n\}$ she wants to find a subse... | 0 |
{"tests": "{\"inputs\": [\"6\\n3 1 0\\n0 3 0\\n2 2 0\\n1 0 0\\n1 3 0\\n0 1 0\\n\", \"8\\n0 1 1\\n1 0 1\\n1 1 0\\n1 1 1\\n2 2 2\\n3 2 2\\n2 3 2\\n2 2 3\\n\", \"2\\n-32839949 -68986721 41592956\\n-32839949 -31435211 41592956\\n\", \"10\\n-93796614 30297417 22968703\\n-91631822 -13274485 54175787\\n-91631822 30297417 2296... | This is an easier version of the problem. In this version, $n \le 2000$.
There are $n$ distinct points in three-dimensional space numbered from $1$ to $n$. The $i$-th point has coordinates $(x_i, y_i, z_i)$. The number of points $n$ is even.
You'd like to remove all $n$ points using a sequence of $\frac{n}{2}$ snaps.... | 0 |
{"tests": "{\"inputs\": [\"4\\n-5 R\\n0 P\\n3 P\\n7 B\\n\", \"5\\n10 R\\n14 B\\n16 B\\n21 R\\n32 R\\n\", \"10\\n66 R\\n67 R\\n72 R\\n73 R\\n76 R\\n78 B\\n79 B\\n83 B\\n84 B\\n85 P\\n\", \"10\\n61 R\\n64 R\\n68 R\\n71 R\\n72 R\\n73 R\\n74 P\\n86 P\\n87 B\\n90 B\\n\", \"15\\n-9518 R\\n-6858 P\\n-6726 B\\n-6486 R\\n-4496 ... | The cities of Byteland and Berland are located on the axis $Ox$. In addition, on this axis there are also disputed cities, which belong to each of the countries in their opinion. Thus, on the line $Ox$ there are three types of cities: the cities of Byteland, the cities of Berland, disputed cities.
Recently, the pr... | 0 |
{"tests": "{\"inputs\": [\"5\\n1 2\\n2 3\\n3 4\\n4 5\\n5 1\\n1 3\\n2 4\\n3 5\\n4 1\\n5 2\\n\", \"6\\n5 6\\n4 3\\n5 3\\n2 4\\n6 1\\n3 1\\n6 2\\n2 5\\n1 4\\n3 6\\n1 2\\n4 5\\n\", \"5\\n3 2\\n4 2\\n4 1\\n2 1\\n2 5\\n3 1\\n4 5\\n3 5\\n4 3\\n1 5\\n\", \"7\\n4 5\\n6 2\\n4 1\\n3 1\\n3 2\\n7 5\\n2 1\\n7 6\\n6 3\\n5 2\\n6 4\\n4... | One day Vasya came up to the blackboard and wrote out n distinct integers from 1 to n in some order in a circle. Then he drew arcs to join the pairs of integers (a, b) (a ≠ b), that are either each other's immediate neighbors in the circle, or there is number c, such that a and с are immediate neighbors, and b and c ar... | 0 |
{"tests": "{\"inputs\": [\"6 4 10\\n3 1 1 1 2 2\\n7\\n8\\n9\\n10\\n11\\n12\\n13\\n14\\n15\\n16\\n\", \"4 5 4\\n4 4 5 1\\n15\\n9\\n13\\n6\\n\", \"1 1 20\\n1\\n2\\n5\\n200\\n199\\n198\\n24\\n123\\n100\\n101\\n100\\n3\\n6\\n200\\n193\\n191\\n24\\n123\\n78\\n109\\n13\\n\", \"1 100 20\\n5\\n2\\n3\\n4\\n5\\n100\\n101\\n102\\... | Misha was interested in water delivery from childhood. That's why his mother sent him to the annual Innovative Olympiad in Irrigation (IOI). Pupils from all Berland compete there demonstrating their skills in watering. It is extremely expensive to host such an olympiad, so after the first $n$ olympiads the organizers i... | 0 |
{"tests": "{\"inputs\": [\"2 999\\n400000 1 2\\n500000 1 1\\n\", \"2 1000\\n400000 500 1\\n600000 500 2\\n\", \"2 99999\\n500 1 1\\n499 10000 2\\n\", \"26 10\\n495492 7 1\\n256604 5 2\\n511773 3 2\\n590712 4 1\\n206826 7 2\\n817878 4 2\\n843915 1 1\\n349160 3 1\\n351298 4 1\\n782251 8 2\\n910928 4 1\\n662354 4 2\\n4686... | n people are standing on a coordinate axis in points with positive integer coordinates strictly less than 10^6. For each person we know in which direction (left or right) he is facing, and his maximum speed.
You can put a bomb in some point with non-negative integer coordinate, and blow it up. At this moment all peopl... | 0 |
{"tests": "{\"inputs\": [\"7\\n1 3 1 3 2 1 2\\n\", \"4\\n2 1 1 2\\n\", \"1\\n2\\n\", \"2\\n3 1\\n\", \"3\\n2 1 2\\n\", \"3\\n1 2 3\\n\", \"12\\n3 3 3 3 3 3 3 3 1 3 3 2\\n\", \"60\\n3 3 1 2 2 1 3 1 1 1 3 2 2 2 3 3 1 3 2 3 2 2 1 3 3 2 3 1 2 2 2 1 3 2 1 1 3 3 1 1 1 3 1 2 1 1 3 3 3 2 3 2 3 2 2 2 1 1 1 2\\n\", \"12\\n3 1 1 ... | The School №0 of the capital of Berland has n children studying in it. All the children in this school are gifted: some of them are good at programming, some are good at maths, others are good at PE (Physical Education). Hence, for each child we know value t_{i}: t_{i} = 1, if the i-th child is good at programming, t... | 0 |
{"tests": "{\"inputs\": [\"5 7\\n2 3 5 4 1\\n\", \"10 10\\n9 1 1 1 1 1 1 1 1 1\\n\", \"5 10\\n3 1 4 2 4\\n\", \"1 1\\n1\\n\", \"2 1\\n1 1\\n\", \"10 20\\n3 2 8 6 6 9 6 10 10 5\\n\", \"100 2000\\n12 82 30 95 4 97 12 10 75 13 98 68 54 63 62 85 15 73 15 58 2 51 38 35 74 11 67 48 42 30 75 41 59 10 42 28 6 40 88 47 58 23 81... | Alyona has recently bought a miniature fridge that can be represented as a matrix with $h$ rows and $2$ columns. Initially there is only one shelf at the bottom of the fridge, but Alyona can install arbitrary number of shelves inside the fridge between any two rows. A shelf is two cells wide, does not occupy any space ... | 0 |
{"tests": "{\"inputs\": [\"3 4\\n>>>>\\n>>>>\\n>>>>\\n\", \"3 3\\n>>>\\n<<<\\n>>>\\n\", \"3 2\\n==\\n=<\\n==\\n\", \"1 1\\n<\\n\", \"1 1\\n=\\n\", \"3 3\\n<<<\\n<<=\\n<<=\\n\", \"3 3\\n><>\\n>><\\n><<\\n\", \"11 23\\n>><>>>>>>>><>>>>>>>>>>>\\n<<<>>>>>>>><>><><>>><>>\\n<<<>><<<><><><<><<>><>>\\n><<>>>>>>>><>><><>>><>>\\... | Mr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method of review — in each restaurant Mr. Apple orders two sets of dishes on two different days. All the d... | 0 |
{"tests": "{\"inputs\": [\"5 3 1\\n5 4 3 5 2\\n\", \"5 3 1\\n5 4 3 5 5\\n\", \"5 3 1\\n5 4 4 5 5\\n\", \"3 2 7\\n5 4 2\\n\", \"100 1 1\\n-1 -1 -2 0 -2 -1 0 0 0 0 2 2 2 2 2 1 0 1 1 1 1 0 1 0 2 0 0 1 1 1 2 2 1 0 0 2 0 1 2 1 2 1 2 2 0 2 0 1 1 0 2 1 1 2 1 1 0 2 2 0 1 1 1 1 1 1 0 2 2 2 2 0 0 0 0 2 2 1 0 2 0 0 2 0 2 1 0 2 2 ... | Recently Maxim has found an array of n integers, needed by no one. He immediately come up with idea of changing it: he invented positive integer x and decided to add or subtract it from arbitrary array elements. Formally, by applying single operation Maxim chooses integer i (1 ≤ i ≤ n) and replaces the i-th element of ... | 0 |
{"tests": "{\"inputs\": [\"10 6 100\\n17 5\\n\", \"11 6 100\\n12 5\\n\", \"25 27 91\\n10 87\\n\", \"79 4 68\\n9 65\\n\", \"9 1 20\\n4 19\\n\", \"6 6 100\\n12 5\\n\", \"9 76 78\\n86 69\\n\", \"62 21 10\\n47 2\\n\", \"4 1 2\\n10 1\\n\", \"1 1 2\\n3 1\\n\", \"14 5 2\\n99 1\\n\", \"20 1 5\\n8 4\\n\", \"12 12 19\\n83 8\\n\"... | Vova is again playing some computer game, now an RPG. In the game Vova's character received a quest: to slay the fearsome monster called Modcrab.
After two hours of playing the game Vova has tracked the monster and analyzed its tactics. The Modcrab has h_2 health points and an attack power of a_2. Knowing that, Vova h... | 0 |
{"tests": "{\"inputs\": [\"2 3 2\\n**.\\n...\\n\", \"1 2 2\\n..\\n\", \"3 3 4\\n.*.\\n*.*\\n.*.\\n\", \"4 4 2\\n....\\n....\\n....\\n....\\n\", \"1 1 1\\n.\\n\", \"1 1 1\\n*\\n\", \"2 2 2\\n.*\\n*.\\n\", \"1 1 1000\\n.\\n\", \"1 1 2000\\n*\\n\", \"5 5 3\\n.....\\n.....\\n*...*\\n*....\\n.*...\\n\", \"3 3 1\\n.*.\\n.*.\... | Suppose that you are in a campus and have to go for classes day by day. As you may see, when you hurry to a classroom, you surprisingly find that many seats there are already occupied. Today you and your friends went for class, and found out that some of the seats were occupied.
The classroom contains $n$ rows of seat... | 0 |
{"tests": "{\"inputs\": [\"4\\nabab\\naabb\\n\", \"1\\na\\nb\\n\", \"8\\nbabbaabb\\nabababaa\\n\", \"2\\nbb\\nbb\\n\", \"10\\naaaaabbbbb\\nababaaaaab\\n\", \"10\\nbbbbbbbbbb\\naaaaaaaaaa\\n\", \"6\\naaaaaa\\naabaaa\\n\", \"1\\nb\\nb\\n\", \"5\\nbaaaa\\nabaaa\\n\", \"10\\naabaaaaaab\\nbaaaaaabbb\\n\", \"100\\nbbbabbabab... | Monocarp has got two strings $s$ and $t$ having equal length. Both strings consist of lowercase Latin letters "a" and "b".
Monocarp wants to make these two strings $s$ and $t$ equal to each other. He can do the following operation any number of times: choose an index $pos_1$ in the string $s$, choose an index $pos_2$... | 0 |
{"tests": "{\"inputs\": [\"2 1\\n1 2 0\\n\", \"4 4\\n1 2 1\\n1 3 0\\n2 3 1\\n3 4 1\\n\", \"8 9\\n1 2 0\\n8 3 0\\n2 3 1\\n1 4 1\\n8 7 0\\n1 5 1\\n4 6 1\\n5 7 0\\n6 8 0\\n\", \"9 10\\n1 2 0\\n2 3 0\\n1 4 1\\n4 5 1\\n4 6 1\\n6 7 1\\n1 7 0\\n1 8 0\\n7 8 0\\n9 7 1\\n\", \"5 6\\n1 2 0\\n3 2 0\\n5 1 1\\n1 3 1\\n5 3 0\\n4 3 1\... | Breaking Good is a new video game which a lot of gamers want to have. There is a certain level in the game that is really difficult even for experienced gamers.
Walter William, the main character of the game, wants to join a gang called Los Hermanos (The Brothers). The gang controls the whole country which consists of... | 0 |
{"tests": "{\"inputs\": [\"abab\\nba\\n\", \"defineintlonglong\\nsignedmain\\n\", \"rotator\\nrotator\\n\", \"cacdcdbbbb\\nbdcaccdbbb\\n\", \"f\\np\\n\", \"baabbaaaaa\\nababa\\n\", \"cbaabccadacadbaacbadddcdabcacdbbabccbbcbbcbbaadcabadcbdcadddccbbbbdacdbcbaddacaadbcddadbabbdbbacabdd\\ncccdacdabbacbbcacdca\\n\", \"tqlrr... | Kaavi, the mysterious fortune teller, deeply believes that one's fate is inevitable and unavoidable. Of course, she makes her living by predicting others' future. While doing divination, Kaavi believes that magic spells can provide great power for her to see the future. [Image]
Kaavi has a string $T$ of length $m$ an... | 0 |
{"tests": "{\"inputs\": [\"10 15 2\\n2\\n10 13\\n\", \"8 17 3\\n4\\n3 4 5 8\\n\", \"7 14 3\\n2\\n1 2\\n\", \"30 70 10\\n3\\n30 32 35\\n\", \"21 56 7\\n5\\n1 2 3 4 5\\n\", \"10 1000000000 25\\n20\\n1 1 5 7 8 10 12 22 44 47 73 77 82 83 89 141 142 168 195 199\\n\", \"30 60 3\\n10\\n1 5 6 10 12 13 18 23 24 25\\n\", \"61 10... | Finally! Vasya have come of age and that means he can finally get a passport! To do it, he needs to visit the passport office, but it's not that simple. There's only one receptionist at the passport office and people can queue up long before it actually opens. Vasya wants to visit the passport office tomorrow.
He know... | 0 |
{"tests": "{\"inputs\": [\"3 2\\n\", \"10 3\\n\", \"314159265 35\\n\", \"1000000000 100\\n\", \"900000000 89\\n\", \"899999999 92\\n\", \"900000001 97\\n\", \"243551227 80\\n\", \"1 100\\n\", \"779283406 99\\n\", \"16 20\\n\", \"123454321 88\\n\", \"123454320 80\\n\", \"123454322 68\\n\", \"2 100\\n\"], \"outputs\": [\... | Find the number of sequences of length K consisting of positive integers such that the product of any two adjacent elements is at most N, modulo 10^9+7.
-----Constraints-----
- 1\leq N\leq 10^9
- 1 2\leq K\leq 100 (fixed at 21:33 JST)
- N and K are integers.
-----Input-----
Input is given from Standard Input in th... | 0 |
{"tests": "{\"inputs\": [\"2 2 4\\n\", \"12 21 10\\n\", \"3 1 8\\n\", \"100 100 1000000\\n\", \"100 100 1\\n\", \"22 75 24126\\n\", \"45 72 83481\\n\", \"47 29 44734\\n\", \"2 75 25\\n\", \"82 84 416241\\n\", \"56 32 30430\\n\", \"28 37 11105\\n\", \"39 18 23359\\n\", \"79 6 29018\\n\", \"68 68 313904\\n\"], \"outputs\... | Takahashi has a water bottle with the shape of a rectangular prism whose base is a square of side a~\mathrm{cm} and whose height is b~\mathrm{cm}. (The thickness of the bottle can be ignored.)
We will pour x~\mathrm{cm}^3 of water into the bottle, and gradually tilt the bottle around one of the sides of the base.
When ... | 0 |
{"tests": "{\"inputs\": [\"3\\n1 4 5\\n\", \"1\\n1\\n\", \"1\\n1000000\\n\", \"2\\n2 999999\\n\", \"9\\n1 2 3 100 500000 500001 999901 999997 999999\\n\", \"3\\n999998 999999 1000000\\n\", \"3\\n1 2 3\\n\", \"3\\n5 345435 999996\\n\", \"6\\n1 10 100 1000 10000 1000000\\n\", \"2\\n1 1000000\\n\", \"2\\n500000 500001\\n\... | Little Chris is very keen on his toy blocks. His teacher, however, wants Chris to solve more problems, so he decided to play a trick on Chris.
There are exactly s blocks in Chris's set, each block has a unique number from 1 to s. Chris's teacher picks a subset of blocks X and keeps it to himself. He will give them bac... | 0 |
{"tests": "{\"inputs\": [\"5 5\\n\", \"4 3\\n\", \"5 1\\n\", \"1 100000\\n\", \"96024 12472\\n\", \"21741 3575\\n\", \"58934 6404\\n\", \"89829 8298\\n\", \"5499 1023\\n\", \"247 3270\\n\", \"58413 1253\\n\", \"100000 1\\n\", \"1 1\\n\", \"100000 14047\\n\"], \"outputs\": [\"2\\n4 5\\n\", \"3\\n2 3 1\\n\", \"-1\\n\", \... | At the children's day, the child came to Picks's house, and messed his house up. Picks was angry at him. A lot of important things were lost, in particular the favorite set of Picks.
Fortunately, Picks remembers something about his set S: its elements were distinct integers from 1 to limit; the value of $\sum_{x \in... | 0 |
{"tests": "{\"inputs\": [\"5\\ngennady\\ngalya\\nboris\\nbill\\ntoshik\\nbilbo\\ntorin\\ngendalf\\nsmaug\\ngaladriel\\n\", \"1\\na\\na\\n\", \"2\\na\\na\\na\\na\\n\", \"2\\na\\nb\\na\\na\\n\", \"2\\nb\\nb\\na\\na\\n\", \"2\\na\\nb\\na\\nb\\n\", \"10\\nbaa\\na\\nba\\naabab\\naa\\nbaab\\nbb\\nabbbb\\na\\na\\na\\nba\\nba\... | Teachers of one programming summer school decided to make a surprise for the students by giving them names in the style of the "Hobbit" movie. Each student must get a pseudonym maximally similar to his own name. The pseudonym must be a name of some character of the popular saga and now the teachers are busy matching ps... | 0 |
{"tests": "{\"inputs\": [\"3\\n1 2 3\\n\", \"4\\n2 1 3 2\\n\", \"17\\n1 45 22 39 28 23 23 100 500 778 777 778 1001 1002 1005 1003 1005\\n\", \"101\\n1 50 170 148 214 153 132 234 181 188 180 225 226 200 197 122 181 168 87 220 223 160 235 94 257 145 199 235 102 146 119 60 109 134 209 260 210 191 180 271 236 195 155 169 1... | One day Squidward, Spongebob and Patrick decided to go to the beach. Unfortunately, the weather was bad, so the friends were unable to ride waves. However, they decided to spent their time building sand castles.
At the end of the day there were n castles built by friends. Castles are numbered from 1 to n, and the heig... | 0.25 |
{"tests": "{\"inputs\": [\"6\\n3 1 0\\n0 3 0\\n2 2 0\\n1 0 0\\n1 3 0\\n0 1 0\\n\", \"8\\n0 1 1\\n1 0 1\\n1 1 0\\n1 1 1\\n2 2 2\\n3 2 2\\n2 3 2\\n2 2 3\\n\", \"2\\n-32839949 -68986721 41592956\\n-32839949 -31435211 41592956\\n\", \"2\\n34319950 -11299623 -19866275\\n34319950 -11299623 98728529\\n\", \"2\\n62887961 73879... | This is a harder version of the problem. In this version, $n \le 50\,000$.
There are $n$ distinct points in three-dimensional space numbered from $1$ to $n$. The $i$-th point has coordinates $(x_i, y_i, z_i)$. The number of points $n$ is even.
You'd like to remove all $n$ points using a sequence of $\frac{n}{2}$ snap... | 0 |
{"tests": "{\"inputs\": [\"4\\n4 0 11 6\\n\", \"1\\n13\\n\", \"5\\n315479581 954336048 124252105 880492165 179952043\\n\", \"2\\n151282707 316934479\\n\", \"5\\n809571641 29322377 935888946 833709370 2457463\\n\", \"1\\n901418150\\n\", \"2\\n512483 512483\\n\", \"10\\n268439624 335544469 2491136 151142938 168395872 536... | Anu has created her own function $f$: $f(x, y) = (x | y) - y$ where $|$ denotes the bitwise OR operation. For example, $f(11, 6) = (11|6) - 6 = 15 - 6 = 9$. It can be proved that for any nonnegative numbers $x$ and $y$ value of $f(x, y)$ is also nonnegative.
She would like to research more about this function and has... | 0 |
{"tests": "{\"inputs\": [\"5 2\\n\", \"3 0\\n\", \"3 2\\n\", \"1 0\\n\", \"2 0\\n\", \"2 1\\n\", \"10 4\\n\", \"6 3\\n\", \"1 0\\n\", \"4 0\\n\", \"4 1\\n\", \"4 2\\n\", \"4 3\\n\", \"3 1\\n\"], \"outputs\": [\"1 5 2 4 3\\n\", \"1 2 3\\n\", \"3 2 1\\n\", \"1\\n\", \"1 2\\n\", \"2 1\\n\", \"10 9 8 7 1 2 3 4 5 6\\n\", \"... | Permutation p is an ordered set of integers p_1, p_2, ..., p_{n}, consisting of n distinct positive integers, each of them doesn't exceed n. We'll denote the i-th element of permutation p as p_{i}. We'll call number n the size or the length of permutation p_1, p_2, ..., p_{n}.
The decreasing coefficient of permu... | 0 |
{"tests": "{\"inputs\": [\"3\\n1 4 6\\n\", \"4\\n2 3 6 6\\n\", \"3\\n6 15 10\\n\", \"4\\n2 3 5 7\\n\", \"6\\n10 8 75 6 7 35\\n\", \"1\\n1\\n\", \"2\\n1 1\\n\", \"2\\n8 32\\n\", \"1\\n97969\\n\", \"2\\n313 313\\n\", \"2\\n97969 97969\\n\", \"8\\n6 15 35 77 143 221 34 26\\n\", \"1\\n998\\n\", \"3\\n2 2 2\\n\"], \"outputs... | You are given an array $a$ of length $n$ that has a special condition: every element in this array has at most 7 divisors. Find the length of the shortest non-empty subsequence of this array product of whose elements is a perfect square.
A sequence $a$ is a subsequence of an array $b$ if $a$ can be obtained from $b$ b... | 0.5 |
{"tests": "{\"inputs\": [\"4\\n0 0 0\\n2 0 0\\n2 2 0\\n0 2 0\\n4\\n1 1 -1\\n1 1 1\\n1 3 1\\n1 3 -1\\n\", \"4\\n4 -2 0\\n4 3 0\\n-3 3 0\\n-3 -2 0\\n4\\n6 -2 0\\n3 2 2\\n-3 7 0\\n3 4 6\\n\", \"4\\n-6 6 0\\n13 9 0\\n15 -7 0\\n-5 -5 0\\n4\\n2 0 4\\n2 6 8\\n2 12 1\\n2 4 -4\\n\", \"3\\n2 16 0\\n8 -6 -8\\n8 3 8\\n4\\n-10 5 0\... | Cowboy Beblop is a funny little boy who likes sitting at his computer. He somehow obtained two elastic hoops in the shape of 2D polygons, which are not necessarily convex. Since there's no gravity on his spaceship, the hoops are standing still in the air. Since the hoops are very elastic, Cowboy Beblop can stretch, rot... | 0 |
{"tests": "{\"inputs\": [\"4 9\\n1 4 3\\n2 4\\n3 3 1\\n1 2 3\\n2 2\\n3 1 2\\n1 3 1\\n2 2\\n3 1 3\\n\", \"1 2\\n2 1\\n3 1 1\\n\", \"2 3\\n1 2 1\\n2 1\\n3 2 1\\n\", \"2 3\\n1 1 2\\n2 1\\n3 2 1\\n\", \"10 10\\n2 9\\n1 2 1\\n1 3 2\\n3 1 1\\n3 1 1\\n2 3\\n3 1 1\\n3 1 1\\n3 1 2\\n3 1 1\\n\", \"10 10\\n1 1 2\\n2 1\\n2 1\\n2 1... | There are n employees working in company "X" (let's number them from 1 to n for convenience). Initially the employees didn't have any relationships among each other. On each of m next days one of the following events took place: either employee y became the boss of employee x (at that, employee x didn't have a boss be... | 0.75 |
{"tests": "{\"inputs\": [\"1\\n13\\n\", \"4\\n1 2 3 4\\n\", \"16\\n978618343 473608041 799158564 800910753 461479363 520477481 780529176 678879534 118274424 720632652 639921017 582019792 143353286 537373229 944668919 758615621\\n\", \"16\\n521848329 105907607 414661942 473600423 264555612 186332345 774233687 736918178 ... | Ilya is a very good-natured lion. He likes maths. Of all mathematical objects, his favourite one is matrices. Now he's faced a complicated matrix problem he needs to solve.
He's got a square 2^{n} × 2^{n}-sized matrix and 4^{n} integers. You need to arrange all these numbers in the matrix (put each number in a single ... | 0 |
{"tests": "{\"inputs\": [\"4 4\\n4 3 1 6\\n\", \"5 2\\n3 2 0 2 7\\n\", \"3 3\\n2 3 1\\n\", \"10 3\\n1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000\\n\", \"5 4\\n0 554459682 978416312 784688178 954779973\\n\", \"5 2\\n1 554459683 978416312 784688178 95477997... | Little Vasya had n boxes with balls in the room. The boxes stood in a row and were numbered with numbers from 1 to n from left to right.
Once Vasya chose one of the boxes, let's assume that its number is i, took all balls out from it (it is guaranteed that this box originally had at least one ball), and began putting ... | 0 |
{"tests": "{\"inputs\": [\"3\\nrivest\\nshamir\\nadleman\\n\", \"10\\ntourist\\npetr\\nwjmzbmr\\nyeputons\\nvepifanov\\nscottwu\\noooooooooooooooo\\nsubscriber\\nrowdark\\ntankengineer\\n\", \"10\\npetr\\negor\\nendagorion\\nfeferivan\\nilovetanyaromanova\\nkostka\\ndmitriyh\\nmaratsnowbear\\nbredorjaguarturnik\\ncgyfo... | Fox Ciel is going to publish a paper on FOCS (Foxes Operated Computer Systems, pronounce: "Fox"). She heard a rumor: the authors list on the paper is always sorted in the lexicographical order.
After checking some examples, she found out that sometimes it wasn't true. On some papers authors' names weren't sorted in l... | 0 |
{"tests": "{\"inputs\": [\"5\\n2 0\\n0 0\\n1 0\\n1 1\\n0 1\\n0 -1 -2 1 0\\n\", \"3\\n1 0\\n0 0\\n2 0\\n0 1 2\\n\", \"9\\n0 0\\n1 0\\n2 0\\n0 1\\n1 1\\n2 1\\n1 2\\n2 2\\n0 2\\n0 0 0 -1 -1 -2 1 1 2\\n\", \"18\\n0 0\\n0 1\\n0 2\\n0 3\\n0 4\\n0 5\\n0 6\\n0 7\\n0 8\\n0 9\\n0 10\\n0 11\\n0 12\\n0 13\\n0 14\\n0 15\\n0 16\\n1 ... | Wilbur is playing with a set of n points on the coordinate plane. All points have non-negative integer coordinates. Moreover, if some point (x, y) belongs to the set, then all points (x', y'), such that 0 ≤ x' ≤ x and 0 ≤ y' ≤ y also belong to this set.
Now Wilbur wants to number the points in the set he has, that is ... | 0 |
{"tests": "{\"inputs\": [\"5\\n1 2 3 2 1\\n\", \"3\\n10 6 8\\n\", \"7\\n1 2 1 2 1 2 1\\n\", \"7\\n1 2 1 2 1 3 1\\n\", \"1\\n1\\n\", \"5\\n1 1 4 2 2\\n\", \"6\\n1 3 4 3 5 4\\n\", \"100\\n82 51 81 14 37 17 78 92 64 15 8 86 89 8 87 77 66 10 15 12 100 25 92 47 21 78 20 63 13 49 41 36 41 79 16 87 87 69 3 76 80 60 100 49 70 ... | This is an easier version of the problem. In this version $n \le 1000$
The outskirts of the capital are being actively built up in Berland. The company "Kernel Panic" manages the construction of a residential complex of skyscrapers in New Berlskva. All skyscrapers are built along the highway. It is known that the comp... | 0 |
{"tests": "{\"inputs\": [\"6\\n2 2 1 3 4 1\\n\", \"3\\n2 2 9\\n\", \"5\\n10 100 111 1 2\\n\", \"10\\n1 2 3 4 1 2 3 4 5 6\\n\", \"50\\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\\n\", \"100\\n1 838 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1... | Kefa decided to make some money doing business on the Internet for exactly n days. He knows that on the i-th day (1 ≤ i ≤ n) he makes a_{i} money. Kefa loves progress, that's why he wants to know the length of the maximum non-decreasing subsegment in sequence a_{i}. Let us remind you that the subsegment of the sequence... | 0.625 |
{"tests": "{\"inputs\": [\"4\\n0 0\\n0 1\\n1 1\\n1 0\\n\", \"6\\n5 0\\n10 0\\n12 -4\\n10 -8\\n5 -8\\n3 -4\\n\", \"19\\n449447997 711296339\\n530233434 692216537\\n535464528 613140435\\n535533467 100893188\\n530498867 -265063956\\n519107979 -271820709\\n482156929 -287792333\\n-303730271 -287970295\\n-416935204 -26334820... | You are given a convex polygon P with n distinct vertices p_1, p_2, ..., p_{n}. Vertex p_{i} has coordinates (x_{i}, y_{i}) in the 2D plane. These vertices are listed in clockwise order.
You can choose a real number D and move each vertex of the polygon a distance of at most D from their original positions.
Find the ... | 0.375 |
{"tests": "{\"inputs\": [\"110\\n\", \"010\\n\", \"0001111\\n\", \"0111001100111011101000\\n\", \"0\\n\", \"1\\n\", \"0000000000000000\\n\", \"0100000001000001\\n\", \"0000100010001110\\n\", \"1001101000001101\\n\", \"0010000110000100\\n\", \"1111101000110110\\n\", \"1111111111111010\\n\", \"1111111111111111\\n\"], \"o... | The only difference between easy and hard versions is the length of the string. You can hack this problem if you solve it. But you can hack the previous problem only if you solve both problems.
Kirk has a binary string $s$ (a string which consists of zeroes and ones) of length $n$ and he is asking you to find a binary... | 0 |
{"tests": "{\"inputs\": [\"3\\nabb\\ndad\\n\", \"8\\ndrpepper\\ncocacola\\n\", \"1\\nh\\np\\n\", \"2\\nxc\\nda\\n\", \"3\\nbab\\naab\\n\", \"15\\nxrezbaoiksvhuww\\ndcgcjrkafntbpbl\\n\", \"3\\nbaa\\nbba\\n\", \"10\\ndaefcecfae\\nccdaceefca\\n\", \"10\\nfdfbffedbc\\ncfcdddfbed\\n\", \"100\\nbltlukvrharrgytdxnbjailgafwdme... | Valya and Tolya are an ideal pair, but they quarrel sometimes. Recently, Valya took offense at her boyfriend because he came to her in t-shirt with lettering that differs from lettering on her pullover. Now she doesn't want to see him and Tolya is seating at his room and crying at her photos all day long.
This story c... | 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\": [\"?aa?\\nab\\n\", \"??b?\\nza\\n\", \"abcd\\nabacaba\\n\", \"mqwstphetbfrsyxuzdww\\nrutseqtsbh\\n\", \"????????????????????\\nxwkxsxlrre\\n\", \"fzjqgrgzzzghrwgwhfjq\\nggwfrjzzqh\\n\", \"ng?\\nvu\\n\", \"???\\nb\\n\", \"??a?\\na\\n\", \"c?aa???a?cdcc??\\nabcadbaccb\\n\", \"cc?cdb?????b?cc?b?\\n... | You are given two strings s and t consisting of small Latin letters, string s can also contain '?' characters.
Suitability of string s is calculated by following metric:
Any two letters can be swapped positions, these operations can be performed arbitrary number of times over any pair of positions. Among all resulti... | 0 |
{"tests": "{\"inputs\": [\"2 1\\n2 2\\n2 1000\\n\", \"1 100\\n1 1\\n\", \"3 5\\n4 3\\n5 2\\n6 1\\n\", \"1 1\\n1 87\\n\", \"1 1\\n100 77\\n\", \"5 10\\n3 81\\n3 49\\n1 20\\n1 12\\n1 30\\n\", \"5 10\\n4 3\\n1 54\\n2 57\\n2 31\\n1 99\\n\", \"5 10\\n2 81\\n3 31\\n4 49\\n1 35\\n1 67\\n\", \"10 1\\n1 92\\n1 92\\n1 92\\n1 92\... | You have n devices that you want to use simultaneously.
The i-th device uses a_{i} units of power per second. This usage is continuous. That is, in λ seconds, the device will use λ·a_{i} units of power. The i-th device currently has b_{i} units of power stored. All devices can store an arbitrary amount of power.
You ... | 0 |
{"tests": "{\"inputs\": [\"3 3\\n1 2 3\\n\", \"10 100000\\n1 2 3 4 5 6 7 8 9 10\\n\", \"2 100\\n1 2\\n\", \"10 100000\\n1 1 2 2 3 3 4 4 5 5\\n\", \"5 100000\\n1 1 1 1 1\\n\", \"1 0\\n1\\n\", \"2 1\\n1 1\\n\", \"2 1\\n2 2\\n\", \"86 95031\\n1 1 2 1 1 2 1 1 1 1 2 2 2 1 1 1 2 2 1 2 1 1 1 2 1 1 1 1 1 2 2 1 1 1 2 1 1 2 2 1 ... | When Darth Vader gets bored, he sits down on the sofa, closes his eyes and thinks of an infinite rooted tree where each node has exactly n sons, at that for each node, the distance between it an its i-th left child equals to d_{i}. The Sith Lord loves counting the number of nodes in the tree that are at a distance at m... | 0 |
{"tests": "{\"inputs\": [\"5\\n1 2 3 4 5\\n\", \"6\\n1 1 2 2 3 3\\n\", \"47\\n3 4 5 3 1 4 4 3 4 6 1 5 1 3 5 3 6 5 1 4 3 2 6 5 3 1 4 6 4 6 2 1 1 1 4 3 6 1 6 6 3 5 1 4 6 4 4\\n\", \"13\\n8 23 26 8 15 13 35 36 28 8 4 33 6\\n\", \"17\\n15 29 28 23 20 12 9 30 4 13 1 25 11 20 6 23 10\\n\", \"31\\n189 73 300 133 414 23 150 30... | Sereja loves integer sequences very much. He especially likes stairs.
Sequence a_1, a_2, ..., a_{|}a| (|a| is the length of the sequence) is stairs if there is such index i (1 ≤ i ≤ |a|), that the following condition is met: a_1 < a_2 < ... < a_{i} - 1 < a_{i} > a_{i} + 1 > ... > a_{|}a| - 1 > a_{|}a|.
For example, s... | 0 |
{"tests": "{\"inputs\": [\"4\\nc=aa#bb\\nd12=c\\nres=c^d12\\ntmp=aa$c\\n\", \"2\\nmax=aaaa$bbbb\\nmin=bbbb^aaaa\\n\", \"6\\nres=res\\nb=a\\nc=b\\nd=c\\nres=d\\nres=res\\n\", \"4\\nc=a\\na=b\\nb=c\\nres=a&b\\n\", \"1\\nres=res\\n\", \"6\\na=b\\nb=c\\nc=a\\nres=res&a\\nres=res#b\\nres=res^c\\n\", \"3\\na=res\\nres=x^y\\n... | Let's analyze a program written on some strange programming language. The variables in this language have names consisting of $1$ to $4$ characters, and each character is a lowercase or an uppercase Latin letter, or a digit. There is an extra constraint that the first character should not be a digit.
There are four ty... | 0 |
{"tests": "{\"inputs\": [\"3\\n1 2\\n1 3\\n\", \"6\\n1 2\\n1 3\\n2 4\\n2 5\\n5 6\\n\", \"7\\n3 2\\n5 7\\n4 2\\n7 6\\n6 3\\n1 6\\n\", \"7\\n5 6\\n2 6\\n6 4\\n6 1\\n6 3\\n6 7\\n\", \"7\\n2 1\\n4 7\\n2 3\\n6 4\\n7 3\\n1 5\\n\", \"7\\n6 4\\n3 7\\n3 5\\n1 3\\n4 2\\n7 4\\n\", \"4\\n2 3\\n2 4\\n2 1\\n\", \"5\\n1 3\\n4 3\\n2 5... | You are given a tree consisting of $n$ nodes. You want to write some labels on the tree's edges such that the following conditions hold:
Every label is an integer between $0$ and $n-2$ inclusive. All the written labels are distinct. The largest value among $MEX(u,v)$ over all pairs of nodes $(u,v)$ is as small as ... | 0 |
{"tests": "{\"inputs\": [\"8\\n1 2 7 3 4 8 5 6\\n\", \"6\\n25 1 2 3 14 36\\n\", \"20\\n1 20 2 19 3 18 4 17 5 16 6 15 7 14 8 13 9 12 10 11\\n\", \"7\\n1 2 5 7 3 4 6\\n\", \"1\\n1000000000\\n\", \"1\\n1\\n\", \"2\\n1 2\\n\", \"2\\n2 1\\n\", \"22\\n22 1 20 2 19 3 18 4 17 5 16 6 15 7 14 8 13 9 12 10 11 21\\n\", \"63\\n32 4... | For long time scientists study the behavior of sharks. Sharks, as many other species, alternate short movements in a certain location and long movements between locations.
Max is a young biologist. For $n$ days he watched a specific shark, and now he knows the distance the shark traveled in each of the days. All the d... | 0.125 |
{"tests": "{\"inputs\": [\"3\\n2\\n1234\\n0600\\n2\\n1337\\n1337\\n4\\n3139\\n3139\\n3139\\n3139\\n\", \"3\\n10\\n0000\\n0000\\n0000\\n0000\\n0000\\n0000\\n0000\\n0000\\n0000\\n0000\\n1\\n1234\\n7\\n1234\\n4567\\n8901\\n2345\\n6789\\n0123\\n4567\\n\", \"4\\n4\\n3139\\n3138\\n3138\\n3137\\n4\\n3138\\n3148\\n3148\\n3158\... | A PIN code is a string that consists of exactly $4$ digits. Examples of possible PIN codes: 7013, 0000 and 0990. Please note that the PIN code can begin with any digit, even with 0.
Polycarp has $n$ ($2 \le n \le 10$) bank cards, the PIN code of the $i$-th card is $p_i$.
Polycarp has recently read a recommendation th... | 0 |
{"tests": "{\"inputs\": [\"16\\nfun while return var { } ( ) , ; > = + ++ - --\\n9\\nfun fib(num) { # compute fibs\\n var return_value = 1, prev = 0, temp;\\n while (num > 0) {\\n temp = return_value; return_value = return_value + prev;\\n prev = temp;\\n num--;\\n }\\n return return_value;\\n}\\n\", \"10\... | International Coding Procedures Company (ICPC) writes all its code in Jedi Script (JS) programming language. JS does not get compiled, but is delivered for execution in its source form. Sources contain comments, extra whitespace (including trailing and leading spaces), and other non-essential features that make them qu... | 0 |
{"tests": "{\"inputs\": [\"4 3\\n1 7 3 5\\n\", \"5 5\\n1 10 100 1000 10000\\n\", \"2 2\\n52233 12247\\n\", \"3 2\\n4 4 4\\n\", \"10 3\\n10000 20000 30000 40000 50000 60000 70000 80000 90000 100000\\n\", \"6 4\\n36874 16401 3128 2000 1343 1260\\n\", \"12 7\\n15809 57514 78998 84734 87276 90593 95915 97387 98583 99971 99... | Let's call beauty of an array $b_1, b_2, \ldots, b_n$ ($n > 1$) — $\min\limits_{1 \leq i < j \leq n} |b_i - b_j|$.
You're given an array $a_1, a_2, \ldots a_n$ and a number $k$. Calculate the sum of beauty over all subsequences of the array of length exactly $k$. As this number can be very large, output it modulo $99... | 0 |
{"tests": "{\"inputs\": [\"7 3\\n1 5 16 18 7 2 10\\nbaaaaca\\n\", \"5 5\\n2 4 1 3 1000\\naaaaa\\n\", \"5 4\\n2 4 1 3 1000\\naaaaa\\n\", \"8 1\\n10 15 2 1 4 8 15 16\\nqqwweerr\\n\", \"6 3\\n14 18 9 19 2 15\\ncccccc\\n\", \"2 1\\n10 10\\nqq\\n\", \"1 1\\n10\\nz\\n\", \"1 1\\n1\\na\\n\", \"1 1\\n1000000000\\nz\\n\", \"38 ... | You are playing a new famous fighting game: Kortal Mombat XII. You have to perform a brutality on your opponent's character.
You are playing the game on the new generation console so your gamepad have $26$ buttons. Each button has a single lowercase Latin letter from 'a' to 'z' written on it. All the letters on button... | 0.5 |
{"tests": "{\"inputs\": [\"3\\n12 3 45\\n\", \"2\\n123 456\\n\", \"20\\n80 9 55 1 98 29 81 10 96 100 70 87 86 12 58 82 10 22 59 13\\n\", \"100\\n3615 1436 2205 5695 9684 7621 391 1579 557 420 1756 5265 247 5494 3509 6089 2931 7372 4939 8030 2901 1150 5389 7168 6213 2723 4301 7250 3857 9178 4723 1932 1161 1412 8200 5226... | This problem differs from the previous one only in the absence of the constraint on the equal length of all numbers $a_1, a_2, \dots, a_n$.
A team of SIS students is going to make a trip on a submarine. Their target is an ancient treasure in a sunken ship lying on the bottom of the Great Rybinsk sea. Unfortunately, th... | 0.375 |
{"tests": "{\"inputs\": [\"15 2\\n4\\nUURL\\n8\\nLRLLLLLLLL\\n\", \"1 1\\n1\\nL\\n\", \"1 1\\n1\\nR\\n\", \"1 1\\n1\\nU\\n\", \"1 10\\n1\\nURLRLULUR\\n1\\nLRRRURULULL\\n1\\nLURURRUUUU\\n1\\nRRULLLRRUL\\n1\\nUULLUURL\\n1\\nRLRRULUL\\n1\\nLURRLRUULRR\\n1\\nLULLULUUUL\\n1\\nURULLULL\\n1\\nLRRLRUUUURRLRRL\\n\", \"3 10\\n2\... | T is a complete binary tree consisting of n vertices. It means that exactly one vertex is a root, and each vertex is either a leaf (and doesn't have children) or an inner node (and has exactly two children). All leaves of a complete binary tree have the same depth (distance from the root). So n is a number such that n ... | 0 |
{"tests": "{\"inputs\": [\"5\\n1 2 1 3 6\\n\", \"5\\n3 2 5 4 10\\n\", \"4\\n1 1 1 1\\n\", \"1\\n1000000000\\n\", \"2\\n921 921\\n\", \"2\\n1000000000 1\\n\", \"11\\n3 10 20 13 18 12 6 5 19 10 8\\n\", \"19\\n3 1 16 11 12 10 3 13 12 9 1 9 8 4 19 16 19 3 3\\n\", \"4\\n11 6 1 16\\n\", \"19\\n10 10 8 11 6 1 6 13 8 20 8 14 9... | You went to the store, selling $n$ types of chocolates. There are $a_i$ chocolates of type $i$ in stock.
You have unlimited amount of cash (so you are not restricted by any prices) and want to buy as many chocolates as possible. However if you buy $x_i$ chocolates of type $i$ (clearly, $0 \le x_i \le a_i$), then for a... | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.