info stringlengths 120 50k | question stringlengths 504 10.4k | avg@8_qwen3_4b_instruct_2507 float64 0 0.88 |
|---|---|---|
{"tests": "{\"inputs\": [\"4 2\\n1 2\\n2 3\\n\", \"2 0\\n\", \"3 2\\n1 3\\n2 3\\n\", \"5 4\\n5 2\\n3 2\\n5 4\\n3 1\\n\", \"5 3\\n3 2\\n1 3\\n5 4\\n\", \"5 0\\n\", \"100 50\\n2 1\\n3 4\\n6 5\\n7 8\\n9 10\\n11 12\\n13 14\\n12 13\\n18 17\\n21 22\\n20 23\\n20 21\\n25 26\\n28 27\\n30 29\\n32 31\\n34 35\\n33 35\\n34 32\\n37 ... | You are given a forest β an undirected graph with $n$ vertices such that each its connected component is a tree.
The diameter (aka "longest shortest path") of a connected undirected graph is the maximum number of edges in the shortest path between any pair of its vertices.
You task is to add some edges (possibly zero... | 0 |
{"tests": "{\"inputs\": [\"3 6 5 4\\n\", \"40 40 40 60\\n\", \"201 101 101 200\\n\", \"1000000000 666666667 666666667 666666666\\n\", \"600000000 900000000 500000000 1000000000\\n\", \"2 2 3 2\\n\", \"10101000 101000 10001000 10100000\\n\", \"3 999999990 999999991 999999992\\n\", \"500000000 500000001 999999999 1000000... | Polycarp has guessed three positive integers $a$, $b$ and $c$. He keeps these numbers in secret, but he writes down four numbers on a board in arbitrary order β their pairwise sums (three numbers) and sum of all three numbers (one number). So, there are four numbers on a board in random order: $a+b$, $a+c$, $b+c$ and $... | 0.25 |
{"tests": "{\"inputs\": [\"9\\nRBGRRBRGG\\n\", \"8\\nBBBGBRRR\\n\", \"13\\nBBRRRRGGGGGRR\\n\", \"1\\nB\\n\", \"2\\nBB\\n\", \"3\\nRGG\\n\", \"5\\nGBBRG\\n\", \"500\\nBRGRRBBGGRBBRBBGGGRBGBGRGRRBRRRBGRBGBRGGGRBBRRBBBRGGBGBBBGGGRGRBBBRBGGBRGGGBRGGRBRGBBGBRRGGBGRGBGGGGGRBBRGBGGRBGGGRBRGGBBGRBBRRRGBRRBGGBGBGGGGRBGRGRRGGGBR... | You have a garland consisting of $n$ lamps. Each lamp is colored red, green or blue. The color of the $i$-th lamp is $s_i$ ('R', 'G' and 'B' β colors of lamps in the garland).
You have to recolor some lamps in this garland (recoloring a lamp means changing its initial color to another) in such a way that the obtained ... | 0 |
{"tests": "{\"inputs\": [\"7\\n3 3 4 7 5 6 8\\n\", \"6\\n1 3 5 2 4 6\\n\", \"4\\n10 9 8 7\\n\", \"9\\n6 7 8 3 4 5 9 10 11\\n\", \"1\\n1337\\n\", \"2\\n456 123\\n\", \"7\\n100 3 4 7 5 6 8\\n\", \"7\\n3 3 4 5 6 7 8\\n\", \"12\\n1 2 3 4 5 6 7 8 9 10 11 12\\n\"], \"outputs\": [\"4\\n2 3 5 6 \\n\", \"2\\n1 4 \\n\", \"1\\n1 ... | You are given an integer array of length $n$.
You have to choose some subsequence of this array of maximum length such that this subsequence forms a increasing sequence of consecutive integers. In other words the required sequence should be equal to $[x, x + 1, \dots, x + k - 1]$ for some value $x$ and length $k$.
Su... | 0 |
{"tests": "{\"inputs\": [\"3\\nBRB\\n\", \"7\\nRGBGRBB\\n\", \"1\\nB\\n\", \"2\\nBB\\n\", \"10\\nGGBRGRBGGR\\n\", \"100\\nRGBBBGRBGRGBRBRRBGRGBBBGRGBBRBGBRRGGGBRGRRRGBGGGBBBBRGRGGBBRGGBBRRGRBRRRBRBBRGBRRBGRRGBBBRRBBRGGRRGR\\n\", \"500\\nBRGRRBBGGRBBRBBGGGRBGBGRGRRBRRRBGRBGBRGGGRBBRRBBBRGGBGBBBGGGRGRBBBRBGGBRGGGBRGGRBRG... | You have a garland consisting of $n$ lamps. Each lamp is colored red, green or blue. The color of the $i$-th lamp is $s_i$ ('R', 'G' and 'B' β colors of lamps in the garland).
You have to recolor some lamps in this garland (recoloring a lamp means changing its initial color to another) in such a way that the obtained ... | 0.125 |
{"tests": "{\"inputs\": [\"5\\n2 4 6 6 6\\n\", \"3\\n2 8 10\\n\", \"4\\n1 1 1 1\\n\", \"1\\n1234\\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\", \"10\\n2 3 3 4 1 4 1 4 1 4\\n\", \"4\\n0 0 0 1\\n\"], \"outputs\":... | You are given an array $a$ consisting of $n$ integers. You can perform the following operations arbitrary number of times (possibly, zero):
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|$; Choose a pair of indices $(i, j)$ such that $|i-j|=... | 0 |
{"tests": "{\"inputs\": [\"7 2\\n11 11\\n9 11\\n7 8\\n8 9\\n7 8\\n9 11\\n7 9\\n\", \"5 1\\n29 30\\n30 30\\n29 29\\n28 30\\n30 30\\n\", \"6 1\\n2 3\\n3 3\\n2 3\\n2 2\\n2 3\\n2 3\\n\", \"16 3\\n181 182\\n183 184\\n179 181\\n178 178\\n182 185\\n177 184\\n179 184\\n176 184\\n177 184\\n176 176\\n176 185\\n183 185\\n175 177\... | The only difference between easy and hard versions is constraints.
You are given $n$ segments on the coordinate axis $OX$. Segments can intersect, lie inside each other and even coincide. The $i$-th segment is $[l_i; r_i]$ ($l_i \le r_i$) and it covers all integer points $j$ such that $l_i \le j \le r_i$.
The integer... | 0 |
{"tests": "{\"inputs\": [\"7\\n7 2 7 3 3 1 4\\n\", \"5\\n4 3 1 5 3\\n\", \"5\\n1 1 2 1 2\\n\", \"5\\n0 1 2 3 4\\n\", \"1\\n1337\\n\", \"7\\n1 2 3 3 3 3 4\\n\", \"1\\n0\\n\"], \"outputs\": [\"YES\\n2\\n3 7 \\n5\\n7 4 3 2 1 \\n\", \"YES\\n1\\n3 \\n4\\n5 4 3 1 \\n\", \"NO\\n\", \"YES\\n0\\n\\n5\\n4 3 2 1 0 \\n\", \"YES\\n... | Two integer sequences existed initially β one of them was strictly increasing, and the other one β strictly decreasing.
Strictly increasing sequence is a sequence of integers $[x_1 < x_2 < \dots < x_k]$. And strictly decreasing sequence is a sequence of integers $[y_1 > y_2 > \dots > y_l]$. Note that the empty sequenc... | 0 |
{"tests": "{\"inputs\": [\"5\\n3 2 3\\n100 100 100\\n50 49 49\\n10 30 20\\n1 1000000000 1000000000\\n\", \"2\\n5 7 7\\n6 7 3\\n\", \"1\\n127869 127869 127869\\n\", \"1\\n12789 12789 12789\\n\", \"1\\n78738 78738 78738\\n\", \"1\\n78788 78788 78788\\n\"], \"outputs\": [\"YES\\n2 2 3\\nYES\\n100 100 100\\nNO\\nNO\\nYES\\... | You are given three positive (i.e. strictly greater than zero) integers $x$, $y$ and $z$.
Your task is to find positive integers $a$, $b$ and $c$ such that $x = \max(a, b)$, $y = \max(a, c)$ and $z = \max(b, c)$, or determine that it is impossible to find such $a$, $b$ and $c$.
You have to answer $t$ independent test... | 0 |
{"tests": "{\"inputs\": [\"5 5\\n1 2\\n2 3\\n3 5\\n4 3\\n1 5\\n\", \"4 6\\n1 2\\n1 3\\n1 4\\n2 3\\n2 4\\n3 4\\n\", \"8 9\\n1 2\\n2 3\\n2 5\\n1 6\\n3 4\\n6 5\\n4 5\\n2 7\\n5 8\\n\", \"2 1\\n1 2\\n\", \"5 6\\n1 5\\n2 5\\n3 5\\n4 5\\n2 3\\n1 2\\n\", \"5 6\\n2 1\\n2 3\\n2 4\\n2 5\\n3 4\\n3 5\\n\"], \"outputs\": [\"4 3\\n3 ... | You are given an undirected unweighted connected graph consisting of $n$ vertices and $m$ edges. It is guaranteed that there are no self-loops or multiple edges in the given graph.
Your task is to find any spanning tree of this graph such that the maximum degree over all vertices is maximum possible. Recall that the d... | 0 |
{"tests": "{\"inputs\": [\"8\\n2 2\\n1 4\\n2 3\\n3 1\\n3 4\\n1 1\\n4 3\\n1 2\\n\", \"5\\n2 1\\n1 0\\n2 0\\n3 2\\n0 3\\n\", \"9\\n1 1\\n3 4\\n4 3\\n1 4\\n1 2\\n3 1\\n2 3\\n2 2\\n1 5\\n\", \"9\\n1 4\\n2 3\\n3 4\\n4 3\\n2 2\\n1 2\\n1 1\\n3 1\\n5 3\\n\", \"1\\n1000000000 1000000000\\n\", \"39\\n27 47\\n30 9\\n18 28\\n49 16... | Maksim walks on a Cartesian plane. Initially, he stands at the point $(0, 0)$ and in one move he can go to any of four adjacent points (left, right, up, down). For example, if Maksim is currently at the point $(0, 0)$, he can go to any of the following points in one move: $(1, 0)$; $(0, 1)$; $(-1, 0)$; $(0, -1)$. ... | 0 |
{"tests": "{\"inputs\": [\"6 2 3 3\\n7 10 50 12 1 8\\n\", \"1 1 100 99\\n100\\n\", \"7 4 2 1\\n1 3 5 4 2 7 6\\n\", \"2 1 49 2\\n50 50\\n\", \"2 1 100 2\\n1 101\\n\"], \"outputs\": [\"5\\n\", \"1\\n\", \"6\\n\", \"0\\n\", \"1\\n\"]}", "source": "primeintellect"} | There are $n$ monsters standing in a row numbered from $1$ to $n$. The $i$-th monster has $h_i$ health points (hp). You have your attack power equal to $a$ hp and your opponent has his attack power equal to $b$ hp.
You and your opponent are fighting these monsters. Firstly, you and your opponent go to the first monste... | 0 |
{"tests": "{\"inputs\": [\"6 3\\n3 2 0 6 10 12\\n\", \"4 2\\n0 1 2 3\\n\", \"1 1\\n1000000000\\n\", \"6 3\\n3 2 0 6 10 11\\n\", \"100 25\\n6745 2075 7499 7517 1776 5164 2335 2745 4465 1457 7565 2232 2486 9025 8059 9646 8017 7662 9690 3352 2306 366 7422 1073 7169 8966 4506 8225 5614 8628 2908 7452 9625 9332 7097 353 104... | You are given an array consisting of $n$ integers $a_1, a_2, \dots, a_n$, and a positive integer $m$. It is guaranteed that $m$ is a divisor of $n$.
In a single move, you can choose any position $i$ between $1$ and $n$ and increase $a_i$ by $1$.
Let's calculate $c_r$ ($0 \le r \le m-1)$ β the number of elements havin... | 0 |
{"tests": "{\"inputs\": [\"5 6\\n1 2 0 2 0\\n2 4\\n3 3\\n1 5\\n1 2\\n1 5\\n2 3\\n\", \"5 3\\n4 2 1 3 2\\n3 5\\n4 2\\n2 5\\n\", \"78 36\\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0\\n1 52\\n2 6\\n9 43\\n10 52... | The only difference between easy and hard versions is constraints.
Ivan plays a computer game that contains some microtransactions to make characters look cooler. Since Ivan wants his character to be really cool, he wants to use some of these microtransactions β and he won't start playing until he gets all of them.
E... | 0 |
{"tests": "{\"inputs\": [\"5\\n1 1 3 4 2\\n\", \"6\\n1 5 12 13 2 15\\n\", \"10\\n1 2 5 129 185 581 1041 1909 1580 8150\\n\", \"6\\n1 1 2 2 3 3\\n\", \"10\\n716243820 716243820 716243820 716243820 716243820 716243820 716243820 716243820 716243820 716243820\\n\"], \"outputs\": [\"3 1\\n1 1 1 1 1 \\n\", \"7 2\\n2 2 1 1 2 ... | There are $n$ students at your university. The programming skill of the $i$-th student is $a_i$. As a coach, you want to divide them into teams to prepare them for the upcoming ICPC finals. Just imagine how good this university is if it has $2 \cdot 10^5$ students ready for the finals!
Each team should consist of at l... | 0 |
{"tests": "{\"inputs\": [\"5\\n5009\\n7\\n9876\\n10000\\n10\\n\", \"7\\n1\\n1\\n1\\n1\\n1\\n1\\n1\\n\", \"2\\n9999\\n52\\n\", \"2\\n999\\n52\\n\", \"2\\n954\\n18\\n\"], \"outputs\": [\"2\\n9 5000 \\n1\\n7 \\n4\\n6 70 800 9000 \\n1\\n10000 \\n1\\n10 \\n\", \"1\\n1 \\n1\\n1 \\n1\\n1 \\n1\\n1 \\n1\\n1 \\n1\\n1 \\n1\\n1 \\... | A positive (strictly greater than zero) integer is called round if it is of the form d00...0. In other words, a positive integer is round if all its digits except the leftmost (most significant) are equal to zero. In particular, all numbers from $1$ to $9$ (inclusive) are round.
For example, the following numbers are ... | 0 |
{"tests": "{\"inputs\": [\"3\\n20 10 20\\n\", \"4\\n10 10 10 10\\n\", \"6\\n5 4 5 4 4 5\\n\", \"2\\n1 4\\n\", \"5\\n13 16 20 18 11\\n\"], \"outputs\": [\"43\\n1 3 2 \\n\", \"64\\n2 1 4 3 \\n\", \"69\\n6 1 3 5 2 4 \\n\", \"3\\n2 1 \\n\", \"138\\n3 4 2 1 5 \\n\"]}", "source": "primeintellect"} | Recently Vasya decided to improve his pistol shooting skills. Today his coach offered him the following exercise. He placed $n$ cans in a row on a table. Cans are numbered from left to right from $1$ to $n$. Vasya has to knock down each can exactly once to finish the exercise. He is allowed to choose the order in which... | 0 |
{"tests": "{\"inputs\": [\"3\\n1 10 100\\n\", \"4\\n1 2 3 4\\n\", \"3\\n1 4 1\\n\", \"2\\n1 1\\n\", \"6\\n2 7 1 8 2 8\\n\"], \"outputs\": [\"Yes\\n\", \"No\\n\", \"Yes\\n\", \"No\\n\", \"Yes\\n\"]}", "source": "primeintellect"} | We have a sequence of length N, a = (a_1, a_2, ..., a_N).
Each a_i is a positive integer.
Snuke's objective is to permute the element in a so that the following condition is satisfied:
- For each 1 β€ i β€ N - 1, the product of a_i and a_{i + 1} is a multiple of 4.
Determine whether Snuke can achieve his objective.
---... | 0 |
{"tests": "{\"inputs\": [\"4\\n47\\n74\\n477\\n4747477\", \"4\\n47\\n47\\n477\\n4747477\", \"4\\n7\\n47\\n477\\n4747477\", \"4\\n4\\n47\\n477\\n4747477\", \"4\\n7\\n7\\n477\\n4747477\", \"4\\n7\\n44\\n477\\n4747477\", \"4\\n44\\n74\\n477\\n4747477\", \"4\\n7\\n44\\n7\\n4747477\", \"4\\n47\\n44\\n477\\n4747477\", \"4\\n... | A Little Elephant from the Zoo of Lviv likes lucky strings, i.e., the strings that consist only of the lucky digits 4 and 7.
The Little Elephant calls some string T of the length M balanced if there exists at least one integer X (1 β€ X β€ M) such that the number of digits 4 in the substring T[1, X - 1] is equal to the n... | 0.625 |
{"tests": "{\"inputs\": [\"2\\n1 2\\n\", \"3\\n1 2\\n2 3\\n\", \"5\\n1 2\\n1 3\\n1 4\\n2 5\\n\", \"6\\n1 2\\n1 3\\n1 4\\n2 5\\n2 6\\n\", \"50\\n16 4\\n17 9\\n31 19\\n22 10\\n8 1\\n40 30\\n3 31\\n20 29\\n47 27\\n22 25\\n32 34\\n12 15\\n40 32\\n10 33\\n47 12\\n6 24\\n46 41\\n14 23\\n12 35\\n31 42\\n46 28\\n31 20\\n46 37\... | Note that this is the first problem of the two similar problems. You can hack this problem only if you solve both problems.
You are given a tree with n nodes. In the beginning, 0 is written on all edges. In one operation, you can choose any 2 distinct leaves u, v and any real number x and add x to values written on al... | 0 |
{"tests": "{\"inputs\": [\"3\\n0 0 0\\n\", \"5\\n0 1 1 1 10\\n\", \"2\\n0 1\\n\", \"100\\n0 0 57 121 57 0 19 251 19 301 19 160 57 578 664 57 19 50 0 621 91 5 263 34 5 96 713 649 22 22 22 5 108 198 1412 1147 84 1326 1777 0 1780 132 2000 479 1314 525 68 690 1689 1431 1288 54 1514 1593 1037 1655 807 465 1674 1747 1982 423... | An array of integers p_{1},p_{2}, β¦,p_{n} is called a permutation if it contains each number from 1 to n exactly once. For example, the following arrays are permutations: [3,1,2], [1], [1,2,3,4,5] and [4,3,1,2]. The following arrays are not permutations: [2], [1,1], [2,3,4].
There is a hidden permutation of length n.
... | 0 |
{"tests": "{\"inputs\": [\"3\\n10 20 10\\n6\\n1 1\\n2 1\\n2 2\\n3 1\\n3 2\\n3 3\\n\", \"7\\n1 2 1 3 1 2 1\\n9\\n2 1\\n2 2\\n3 1\\n3 2\\n3 3\\n1 1\\n7 1\\n7 7\\n7 4\\n\", \"2\\n1 10\\n3\\n2 2\\n2 1\\n1 1\\n\", \"2\\n3922 3922\\n3\\n2 2\\n2 1\\n1 1\\n\", \"1\\n1000000000\\n1\\n1 1\\n\", \"1\\n1\\n3\\n1 1\\n1 1\\n1 1\\n\"... | This is the easier version of the problem. In this version 1 β€ n, m β€ 100. You can hack this problem only if you solve and lock both problems.
You are given a sequence of integers a=[a_1,a_2,...,a_n] of length n. Its subsequence is obtained by removing zero or more elements from the sequence a (they do not necessarily... | 0.5 |
{"tests": "{\"inputs\": [\"5 3\\n00011\\n3\\n1 2 3\\n1\\n4\\n3\\n3 4 5\\n\", \"8 6\\n00110011\\n3\\n1 3 8\\n5\\n1 2 5 6 7\\n2\\n6 8\\n2\\n3 5\\n2\\n4 7\\n1\\n2\\n\", \"19 5\\n1001001001100000110\\n2\\n2 3\\n2\\n5 6\\n2\\n8 9\\n5\\n12 13 14 15 16\\n1\\n19\\n\", \"7 3\\n0011100\\n3\\n1 4 6\\n3\\n3 4 7\\n2\\n2 3\\n\", \"1... | There are n lamps on a line, numbered from 1 to n. Each one has an initial state off (0) or on (1).
You're given k subsets A_1, β¦, A_k of \{1, 2, ..., n\}, such that the intersection of any three subsets is empty. In other words, for all 1 β€ i_1 < i_2 < i_3 β€ k, A_{i_1} β© A_{i_2} β© A_{i_3} = β
.
In one operation, you ... | 0 |
{"tests": "{\"inputs\": [\"1 2\\n3 4\\n5 6\\n\", \"11 10\\n13 8\\n5 16\\n\", \"3 7\\n4 6\\n5 5\\n\", \"10 10\\n10 10\\n10 10\\n\", \"3 14\\n8 9\\n10 7\\n\", \"12 11\\n11 12\\n16 7\\n\", \"12 17\\n10 19\\n13 16\\n\", \"9 12\\n3 17\\n10 10\\n\", \"10 7\\n4 13\\n11 6\\n\", \"7 9\\n4 12\\n5 11\\n\", \"2 4\\n1 5\\n3 3\\n\",... | Vasilisa the Wise from the Kingdom of Far Far Away got a magic box with a secret as a present from her friend Hellawisa the Wise from the Kingdom of A Little Closer. However, Vasilisa the Wise does not know what the box's secret is, since she cannot open it again. She hopes that you will help her one more time with tha... | 0.875 |
{"tests": "{\"inputs\": [\"3\\n3 3\\n1 -3 4\\n1 5 2\\n2 2\\n-2 0\\n1 2\\n2 2\\n0 1\\n1 2\\n\", \"3\\n3 3\\n1 -3 4\\n1 5 2\\n2 2\\n-4 0\\n1 2\\n2 2\\n0 1\\n1 2\\n\", \"3\\n3 3\\n1 -3 4\\n1 5 2\\n2 2\\n-2 0\\n1 2\\n2 2\\n0 2\\n1 2\\n\", \"3\\n3 3\\n2 -3 4\\n1 5 2\\n2 2\\n-4 0\\n1 2\\n2 2\\n0 1\\n1 2\\n\", \"3\\n3 3\\n0 -... | Polycarp was dismantling his attic and found an old floppy drive on it. A round disc was inserted into the drive with n integers written on it.
Polycarp wrote the numbers from the disk into the a array. It turned out that the drive works according to the following algorithm:
* the drive takes one positive number x... | 0.125 |
{"tests": "{\"inputs\": [\"5\\n1912 1\\n5 6\\n999 1\\n88 2\\n12 100\\n\", \"5\\n90 94\\n26 25\\n64 84\\n14 6\\n20 96\\n\", \"5\\n90 94\\n26 25\\n64 84\\n18 6\\n20 96\\n\", \"5\\n1912 1\\n5 6\\n999 1\\n88 2\\n11 100\\n\", \"5\\n90 94\\n26 25\\n64 84\\n22 6\\n20 96\\n\", \"5\\n1912 1\\n5 6\\n999 1\\n88 2\\n6 100\\n\", \"... | You are given an integer n. You have to apply m operations to it.
In a single operation, you must replace every digit d of the number with the decimal representation of integer d + 1. For example, 1912 becomes 21023 after applying the operation once.
You have to find the length of n after applying m operations. Since... | 0.5 |
{"tests": "{\"inputs\": [\"3\\n2 3 4\\n2 1\\n1\\n-1\\n\", \"100\\n95 54 23 27 51 58 94 34 29 95 53 53 8 5 64 32 17 62 14 37 26 95 27 85 94 37 85 72 88 69 43 9 60 3 48 26 81 48 89 56 34 28 2 63 26 6 13 19 99 41 70 24 92 41 9 73 52 42 34 98 16 82 7 81 28 80 18 33 90 69 19 13 51 96 8 21 86 32 96 7 5 42 52 87 24 82 14 88 4... | This is the easy version of the problem. The only difference is that in this version q = 1. You can make hacks only if both versions of the problem are solved.
There is a process that takes place on arrays a and b of length n and length n-1 respectively.
The process is an infinite sequence of operations. Each operat... | 0 |
{"tests": "{\"inputs\": [\"6\\n1 4 3 3 5 7\\n3 7 5 4 3\\n4 3 7 5\\n\", \"5\\n1 5 8 123 7\\n123 7 5 1\\n5 1 7\\n\", \"3\\n1 2 3\\n3 2\\n2\\n\", \"3\\n84 30 9\\n9 84\\n9\\n\", \"4\\n1 5 7 8\\n1 5 7\\n1 5\\n\", \"3\\n796067435 964699482 819602309\\n964699482 796067435\\n964699482\\n\", \"10\\n460626451 802090732 277246428... | A and B are preparing themselves for programming contests.
B loves to debug his code. But before he runs the solution and starts debugging, he has to first compile the code.
Initially, the compiler displayed n compilation errors, each of them is represented as a positive integer. After some effort, B managed to fix s... | 0 |
{"tests": "{\"inputs\": [\"5\\n1 2\\n2 1\\n5 10\\n10 9\\n20 1\\n\", \"5\\n1 2\\n2 1\\n5 10\\n10 9\\n19 1\\n\", \"4\\n10 4\\n15 1\\n19 3\\n20 1\\n\", \"2\\n1 999999999\\n1000000000 1000000000\\n\", \"67\\n1 1\\n3 8\\n4 10\\n7 8\\n9 2\\n10 1\\n11 5\\n12 8\\n13 4\\n16 6\\n18 3\\n19 3\\n22 5\\n24 6\\n27 5\\n28 3\\n29 3\\n3... | Little Susie listens to fairy tales before bed every day. Today's fairy tale was about wood cutters and the little girl immediately started imagining the choppers cutting wood. She imagined the situation that is described below.
There are n trees located along the road at points with coordinates x1, x2, ..., xn. Each ... | 0 |
{"tests": "{\"inputs\": [\"? - ? = 1\\n\", \"? + ? - ? + ? + ? = 42\\n\", \"? = 1000000\\n\", \"? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? - ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ... | You are given a rebus of form ? + ? - ? + ? = n, consisting of only question marks, separated by arithmetic operation '+' and '-', equality and positive integer n. The goal is to replace each question mark with some positive integer from 1 to n, such that equality holds.
Input
The only line of the input contains a re... | 0 |
{"tests": "{\"inputs\": [\"6 10\\nalloc 5\\nalloc 3\\nerase 1\\nalloc 6\\ndefragment\\nalloc 6\\n\", \"3 1\\nerase -1\\nerase 0\\nerase -2147483648\\n\", \"26 25\\ndefragment\\nerase 1\\nerase -1560200883\\nalloc 44\\ndefragment\\nalloc 75\\nalloc 22\\ndefragment\\nerase 4\\ndefragment\\nalloc 57\\nalloc 53\\nerase 4\\... | There is little time left before the release of the first national operating system BerlOS. Some of its components are not finished yet β the memory manager is among them. According to the developers' plan, in the first release the memory manager will be very simple and rectilinear. It will support three operations:
... | 0 |
{"tests": "{\"inputs\": [\"3\\n3 2 1\\n\", \"3\\n1 2 3\\n\", \"3\\n2 3 1\\n\", \"4\\n1 2 4 3\\n\", \"4\\n2 1 4 3\\n\", \"10\\n1 2 10 9 7 4 8 3 6 5\\n\", \"10\\n1 7 10 6 5 2 3 8 9 4\\n\", \"4\\n4 3 2 1\\n\", \"4\\n2 1 3 4\\n\", \"10\\n1 10 9 5 3 2 4 7 8 6\\n\", \"4\\n2 3 1 4\\n\", \"4\\n2 4 3 1\\n\", \"10\\n1 5 10 8 4 3... | Some time ago Mister B detected a strange signal from the space, which he started to study.
After some transformation the signal turned out to be a permutation p of length n or its cyclic shift. For the further investigation Mister B need some basis, that's why he decided to choose cyclic shift of this permutation whi... | 0.875 |
{"tests": "{\"inputs\": [\"3\\n3 2 1\\n1 2 3\\n1 1\\n1 2\\n\", \"3\\n1 2 3\\n3 2 1\\n1 1\\n1 1\\n\", \"5\\n27468 7465 74275 40573 40155\\n112071 76270 244461 264202 132397\\n1 777133331\\n2 107454154\\n3 652330694\\n4 792720519\\n\", \"5\\n78188 56310 79021 70050 65217\\n115040 5149 128449 98357 36580\\n1 451393770\\n2... | Igor is a post-graduate student of chemistry faculty in Berland State University (BerSU). He needs to conduct a complicated experiment to write his thesis, but laboratory of BerSU doesn't contain all the materials required for this experiment.
Fortunately, chemical laws allow material transformations (yes, chemistry i... | 0.125 |
{"tests": "{\"inputs\": [\"5 10\\n-5 0 10 -11 0\\n\", \"5 10\\n-1 5 0 -5 3\\n\", \"3 4\\n-10 0 20\\n\", \"9 13\\n6 14 19 5 -5 6 -10 20 8\\n\", \"8 9\\n6 -1 5 -5 -8 -7 -8 -7\\n\", \"10 7\\n-9 3 -4 -22 4 -17 0 -14 3 -2\\n\", \"6 2\\n-2 3 0 -2 0 0\\n\", \"5 10\\n-8 -24 0 -22 12\\n\", \"5 13756\\n-2 -9 -10 0 10\\n\", \"7 3... | Recenlty Luba got a credit card and started to use it. Let's consider n consecutive days Luba uses the card.
She starts with 0 money on her account.
In the evening of i-th day a transaction ai occurs. If ai > 0, then ai bourles are deposited to Luba's account. If ai < 0, then ai bourles are withdrawn. And if ai = 0, ... | 0 |
{"tests": "{\"inputs\": [\"5\\n0 1 2 1 2\\n\", \"4\\n0 1 2 3\\n\", \"21\\n11 19 4 19 6 0 13 7 6 2 5 3 16 10 1 9 15 21 9 21 2\\n\", \"100\\n57 85 27 81 41 27 73 10 73 95 91 90 89 41 86 44 6 20 9 13 46 73 56 19 37 32 40 42 79 76 96 5 6 8 76 52 14 86 33 69 100 95 58 87 43 47 17 39 48 28 77 65 100 100 41 39 87 5 61 67 94 6... | You are given a tree (a graph with n vertices and n - 1 edges in which it's possible to reach any vertex from any other vertex using only its edges).
A vertex can be destroyed if this vertex has even degree. If you destroy a vertex, all edges connected to it are also deleted.
Destroy all vertices in the given tree or... | 0 |
{"tests": "{\"inputs\": [\"5 1 5\\n0\\n3 3 3 3 3\\n\", \"4 3 4\\n1 2 3\\n1 10 100 1000\\n\", \"7 4 3\\n2 4 5 6\\n3 14 15\\n\", \"6 2 3\\n1 3\\n1 2 3\\n\", \"3 1 2\\n2\\n1 1\\n\", \"3 1 2\\n1\\n8 61\\n\", \"3 0 3\\n\\n334 500 1001\\n\", \"20 16 16\\n1 2 3 4 5 6 8 9 10 11 13 14 15 16 18 19\\n2 1 1 1 1 1 3 3 2 2 1 3 3 3 3... | Adilbek's house is located on a street which can be represented as the OX axis. This street is really dark, so Adilbek wants to install some post lamps to illuminate it. Street has n positions to install lamps, they correspond to the integer numbers from 0 to n - 1 on the OX axis. However, some positions are blocked an... | 0 |
{"tests": "{\"inputs\": [\"2\\n1 23\\n\\nSAMPLE\", \"47\\n169884146 730277703 8645016 732791141 331583052 25104065 895622218 478600214 924154067 813310590 389843997 977252329 338578814 512086554 953548504 508435813 602216502 773835133 194230149 661387945 354427757 690709868 320153566 468158534 287696464 210587004 73462... | As you know Appu created aversion to Maths after that maths problem given by his teacher.So he stopped studying and began to do farming. He has some land where he starts growing sugarcane. At the end of the season he grew N sugarcanes. Is Appu satisfied??. No,
He wants all his sugar canes to be of the same height. He g... | 0.75 |
{"tests": "{\"inputs\": [\"2 4\\n0 0 1 1\\n0 0 1 1\\n\\nSAMPLE\", \"2 3\\n1 1 1\\n0 1 0\", \"2 2\\n1 0\\n0 1\", \"3 3\\n0 1 0\\n1 0 1\\n0 1 0\", \"2 2\\n0 0\\n1 0\", \"2 2\\n0 1\\n1 0\", \"4 6\\n1 0 1 0 0 1 \\n0 0 1 1 1 1 \\n1 1 1 1 1 1 \\n1 0 0 1 1 1\", \"2 3\\n1 1 0\\n0 1 0\", \"3 3\\n0 1 0\\n1 0 1\\n0 1 -1\", \"4 6\... | Golu is given a task of clearing coins fallen down on floor. Naughty being his modus operandi, he thought of playing a game while clearing coins. He arranges the coins like an M X N matrix with random heads (1) and tails (0).
In every move, he chooses a sub-matrix of size L X B [such that max(L,B) >1] and interchange... | 0 |
{"tests": "{\"inputs\": [\"4\\nSSSSEEEECCCCEECCCC\\nCCCCCSSSSEEECCCCSS\\nSSSSSEEESSCCCCCCCS\\nEESSSSCCCCCCSSEEEESAMPLE\", \"4\\nSSSSEEEECCCCEECCCC\\nCCCCCSSSSEEECCCCSS\\nSCCCCCCCSSEEESSSSS\\nEESSSSCCCCCCSSEEEESAMPLE\", \"4\\nCCCCEECBCCEEEESSSS\\nCCCCCSSSSEEECCCCSS\\nSSSSSEEESSCCCCCCCS\\nEESSSSCCCCCCSSEEEESAMPLE\", \"4\... | Roy is going through the dark times of his life. Recently his girl friend broke up with him and to overcome the pain of acute misery he decided to restrict himself to Eat-Sleep-Code life cycle. For N days he did nothing but eat, sleep and code.
A close friend of Roy kept an eye on him for last N days. For every sing... | 0.5 |
{"tests": "{\"inputs\": [\"2 5\", \"9 9\", \"5 10\", \"2 8\", \"9 5\", \"7 10\", \"3 8\", \"9 8\", \"7 7\", \"6 8\", \"7 9\", \"7 8\", \"7 3\", \"7 2\", \"9 2\", \"9 4\", \"9 6\", \"5 6\", \"2 6\", \"2 2\", \"8 5\", \"5 1\", \"4 8\", \"3 9\", \"2 3\", \"2 4\", \"2 1\", \"5 3\", \"1 3\", \"4 5\", \"1 1\", \"3 3\", \"7 1... | Having learned the multiplication table, Takahashi can multiply two integers between 1 and 9 (inclusive) together. He cannot do any other calculation.
Given are two integers A and B.
If Takahashi can calculate A \times B, print the result; if he cannot, print `-1` instead.
Constraints
* 1 \leq A \leq 20
* 1 \leq B ... | 0.875 |
{"tests": "{\"inputs\": [\"0.0,0.0,1.0,0.0,1.0,1.0,0.0,1.0\\n0.0,0.0,3.0,0.0,1.0,1.0,1.0,3.0\", \"0.0,0.0,1.0,0.0,1.0,1.0,0.0,0.1\\n0.0,0.0,3.0,0.0,1.0,1.0,1.0,3.0\", \"1.0,0.0,0.1,0.1,0.0,0.1,0.0,0.0\\n0.3,0.1,0.1,1.1,0.0,0.3,0.0,0.0\", \"1.0,0.0,0.2,0.1,0.0,0.1,0.0,1.0\\n0.3,0.0,0.1,0.1,0.0,0.3,0.0,0.0\", \"1.0,0.0,0... | 4 different points on the plane Read the coordinates of $ A (x_a, y_a) $, $ B (x_b, y_b) $, $ C (x_c, y_c) $, $ D (x_d, y_d) $ and read those 4 points Create a program that outputs YES if there is no dent in the quadrangle $ ABCD $ with the coordinates as the vertices, and NO if there is a dent.
A quadrangle with a de... | 0.625 |
{"tests": "{\"inputs\": [\"1\\n100000 2\", \"3\\n2 1\\n1 3\\n2 2\", \"1\\n100010 2\", \"3\\n2 1\\n1 3\\n2 0\", \"1\\n100010 3\", \"3\\n2 1\\n1 3\\n2 1\", \"1\\n100011 3\", \"3\\n2 1\\n1 5\\n2 2\", \"1\\n000011 3\", \"3\\n2 1\\n1 5\\n3 2\", \"1\\n000011 1\", \"3\\n3 1\\n1 5\\n3 2\", \"3\\n3 1\\n1 5\\n2 2\", \"1\\n100111... | PCK, which recycles Aizu's precious metal, Aizunium, has a network all over the country and collects Aizunium with many collection vehicles. This company standardizes the unit of weight and number of lumps for efficient processing.
A unit called "bokko" is used for the weight of the lump. x Bocco's Aidunium weighs 2 x... | 0 |
{"tests": "{\"inputs\": [\"6 1 2 3 4 5\", \"6 200 2 3 4 5\", \"6 1 2 3 4 7\", \"6 106 2 3 4 5\", \"6 2 2 3 4 7\", \"6 159 2 3 4 5\", \"6 200 2 3 8 8\", \"6 159 2 3 3 5\", \"6 3 1 3 4 8\", \"22 144 2 3 3 5\", \"17 144 2 3 6 5\", \"9 5 1 3 15 9\", \"17 22 2 3 6 7\", \"6 373 2 3 4 5\", \"6 200 2 4 8 5\", \"6 159 2 4 4 5\"... | I have n tickets for a train with a rabbit. Each ticket is numbered from 0 to n β 1, and you can use the k ticket to go to pβ
ak + qβ
bk station.
Rabbit wants to go to the all-you-can-eat carrot shop at the station m station ahead of the current station, but wants to walk as short as possible. The stations are lined up ... | 0 |
{"tests": "{\"inputs\": [\"5 2\\n3 1 5 4 2\\n5 2\\n5 4\\n\", \"3 3\\n3 1 2\\n1 2\\n3 1\\n3 2\\n\", \"2 1\\n1 2\\n1 2\\n\", \"10 23\\n6 9 8 10 4 3 7 1 5 2\\n7 2\\n3 2\\n2 4\\n2 3\\n7 5\\n6 4\\n10 7\\n7 1\\n6 8\\n6 2\\n8 10\\n3 5\\n3 1\\n6 1\\n10 2\\n8 2\\n10 1\\n7 4\\n10 5\\n6 9\\n6 5\\n9 1\\n10 4\\n\", \"2 0\\n1 2\\n\"... | At the big break Nastya came to the school dining room. There are n pupils in the school, numbered from 1 to n. Unfortunately, Nastya came pretty late, so that all pupils had already stood in the queue, i.e. Nastya took the last place in the queue. Of course, it's a little bit sad for Nastya, but she is not going to de... | 0 |
{"tests": "{\"inputs\": [\"5\\n3\\n1 6\\n1 7\\n1 5\\n2\\n1 4\\n1 3\\n3\\n1 10\\n3 5\\n2 3\\n3\\n1 15\\n2 4\\n1 10\\n1\\n1 100\\n\", \"5\\n3\\n1 1\\n1 1\\n1 1\\n3\\n1 1\\n1 1\\n1 1\\n3\\n1 1\\n1 1\\n1 1\\n3\\n1 1\\n1 1\\n1 1\\n3\\n1 100\\n1 1\\n1 1\\n\", \"1\\n4\\n1 1\\n1 1\\n2 2\\n3 4\\n\", \"5\\n3\\n1 1\\n1 1\\n1 1\\n... | You are playing a computer card game called Splay the Sire. Currently you are struggling to defeat the final boss of the game.
The boss battle consists of n turns. During each turn, you will get several cards. Each card has two parameters: its cost c_i and damage d_i. You may play some of your cards during each turn i... | 0 |
{"tests": "{\"inputs\": [\"3\\n12 3 45\\n\", \"2\\n123 456\\n\", \"20\\n76 86 70 7 16 24 10 62 26 29 40 65 55 49 34 55 92 47 43 100\\n\", \"100\\n6591 1074 3466 3728 549 5440 533 3543 1536 2967 1587 304 6326 6410 8670 6736 4482 8431 1697 9264 8338 2995 3725 1805 488 4563 4261 6025 2602 1892 9297 4359 1139 7117 1423 483... | 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, ..., 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, the st... | 0 |
{"tests": "{\"inputs\": [\"5 9\\n10345\\n23456\\n34567\\n45678\\n56789\\n\", \"2 10\\n12\\n43\\n\", \"3 12\\n1423\\n6624\\n6625\\n\", \"49 749442\\n8888888\\n8888888\\n8888888\\n5777777\\n5777777\\n5777777\\n5777777\\n5777777\\n5777777\\n5777777\\n5777777\\n5777777\\n5111111\\n5111111\\n5666666\\n5666666\\n5666666\\n56... | Piet is one of the most known visual esoteric programming languages. The programs in Piet are constructed from colorful blocks of pixels and interpreted using pretty complicated rules. In this problem we will use a subset of Piet language with simplified rules.
The program will be a rectangular image consisting of col... | 0 |
{"tests": "{\"inputs\": [\"AprilFool\\n14\\n\", \"qH\\n2\\n\", \"nifzlTLaeWxTD\\n0\\n\", \"WlwbRjvrOZakKXqecEdlrCnmvXQtLKBsy\\n5\\n\", \"LiqWMLEULRhW\\n1\\n\", \"kGqopTbelcDUcoZgnnRYXgPCRQwSLoqeIByFWDI\\n26\\n\", \"DuFhhnq\\n4\\n\", \"aaaaAaaaaaaAAaaAaaAaAaaaAaaaaaAAaaAAAAAaaAaAAAAaAA\\n4\\n\", \"VtQISIHREYaEGPustEkzJR... | <image>
Input
The first line of the input is a string (between 1 and 50 characters long, inclusive). Each character will be a letter of English alphabet, lowercase or uppercase.
The second line of the input is an integer between 0 and 26, inclusive.
Output
Output the required string.
Examples
Input
AprilFool
14... | 0 |
{"tests": "{\"inputs\": [\"6 2\\n2 3 0 5 6 0\\n\", \"6 2\\n0 0 1 0 4 5\\n\", \"6 1\\n2 0 4 0 6 0\\n\", \"4 1\\n0 0 0 0\\n\", \"20 20\\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\\n\", \"10 4\\n0 1 4 2 7 0 10 0 5 8\\n\", \"10 7\\n10 8 6 5 0 0 0 4 3 9\\n\", \"10 1\\n8 7 0 2 0 10 0 0 3 5\\n\", \"10 7\\n7 9 2 10 0 0 0 3 5 1\\... | In the rush of modern life, people often forget how beautiful the world is. The time to enjoy those around them is so little that some even stand in queues to several rooms at the same time in the clinic, running from one queue to another.
(Cultural note: standing in huge and disorganized queues for hours is a native ... | 0 |
{"tests": "{\"inputs\": [\"4 5\\n1 2 3 1\\n2 1 2 8\\n2 3 4 7\\n1 1 3 3\\n2 3 4 8\\n\", \"4 5\\n1 2 3 1\\n2 1 2 8\\n2 3 4 7\\n1 1 3 3\\n2 3 4 13\\n\", \"4 5\\n1 2 3 1\\n2 1 2 8\\n2 3 4 7\\n1 1 3 3\\n2 3 4 8\\n\", \"1 4\\n1 1 1 2\\n2 1 1 6\\n1 1 1 1\\n2 1 1 7\\n\", \"2 2\\n2 1 2 8\\n2 1 2 7\\n\", \"97 29\\n2 78 82 356152... | Levko loves array a1, a2, ... , an, consisting of integers, very much. That is why Levko is playing with array a, performing all sorts of operations with it. Each operation Levko performs is of one of two types:
1. Increase all elements from li to ri by di. In other words, perform assignments aj = aj + di for all j ... | 0 |
{"tests": "{\"inputs\": [\"3 2\\n1 2\\n2 3\\n\", \"3 3\\n1 2\\n2 3\\n3 1\\n\", \"8 12\\n1 2\\n2 3\\n3 4\\n4 1\\n1 3\\n2 4\\n3 5\\n3 6\\n5 6\\n6 7\\n6 8\\n7 8\\n\", \"9 12\\n1 2\\n2 3\\n4 5\\n5 6\\n6 7\\n7 8\\n1 4\\n4 7\\n2 5\\n5 8\\n3 6\\n6 9\\n\", \"5 4\\n2 1\\n3 2\\n4 3\\n5 4\\n\", \"4 4\\n1 2\\n2 3\\n3 1\\n1 4\\n\",... | Little Chris is participating in a graph cutting contest. He's a pro. The time has come to test his skills to the fullest.
Chris is given a simple undirected connected graph with n vertices (numbered from 1 to n) and m edges. The problem is to cut it into edge-distinct paths of length 2. Formally, Chris has to partiti... | 0 |
{"tests": "{\"inputs\": [\"3 5\\n1 2 3\\n1 3 2 3 1\\n\", \"50 50\\n75 71 23 37 28 23 69 75 5 62 3 11 96 100 13 50 57 51 8 90 4 6 84 27 11 89 95 81 10 62 48 52 69 87 97 95 30 74 21 42 36 64 31 80 81 50 56 53 33 99\\n26 30 5 33 35 29 6 15 36 17 32 16 14 1 29 34 22 40 12 42 38 48 39 50 13 47 18 43 10 8 49 45 11 31 21 37 4... | New Year is coming, and Jaehyun decided to read many books during 2015, unlike this year. He has n books numbered by integers from 1 to n. The weight of the i-th (1 β€ i β€ n) book is wi.
As Jaehyun's house is not large enough to have a bookshelf, he keeps the n books by stacking them vertically. When he wants to read a... | 0 |
{"tests": "{\"inputs\": [\"16\\n.**.*..*.***.**.\\n\", \"11\\n.*.*...*.*.\\n\", \"20\\n.*..*...*....*.....*\\n\", \"97\\n****.***.***.*..**.**.*.*.***.*............*..*......*.***.**.*.***.*.***.*..*.**.*.***.**.*****.\\n\", \"5\\n*.***\\n\", \"4\\n****\\n\", \"11\\n.*.*.*.*...\\n\", \"72\\n.***.**.*.*...*****.*.*.*.*.... | In this problem you will meet the simplified model of game King of Thieves.
In a new ZeptoLab game called "King of Thieves" your aim is to reach a chest with gold by controlling your character, avoiding traps and obstacles on your way.
<image>
An interesting feature of the game is that you can design your own levels... | 0.125 |
{"tests": "{\"inputs\": [\"1.1 3.4 2.5\\n\", \"1.9 1.8 1.7\\n\", \"2.0 2.0 2.0\\n\", \"1.0 200.0 200.0\\n\", \"0.2 0.1 0.6\\n\", \"1.9 3.0 4.1\\n\", \"51.8 51.8 7.1\\n\", \"113.9 125.2 88.8\\n\", \"1.9 4.8 3.9\\n\", \"2.2 148.1 138.0\\n\", \"1.0 200.0 1.0\\n\", \"1.7 4.5 4.2\\n\", \"0.2 0.6 0.3\\n\", \"200.0 200.0 0.1\... | Wet Shark asked Rat Kwesh to generate three positive real numbers x, y and z, from 0.1 to 200.0, inclusive. Wet Krash wants to impress Wet Shark, so all generated numbers will have exactly one digit after the decimal point.
Wet Shark knows Rat Kwesh will want a lot of cheese. So he will give the Rat an opportunity to ... | 0 |
{"tests": "{\"inputs\": [\"5 5 13 0 4\\n0 1 5\\n2 1 2\\n3 2 3\\n1 4 0\\n4 3 4\\n\", \"2 1 123456789 0 1\\n0 1 0\\n\", \"2 1 999999999 1 0\\n0 1 1000000000\\n\", \"7 9 999999999 0 3\\n0 1 0\\n1 2 0\\n2 3 0\\n0 4 1\\n4 1 1\\n1 5 499999999\\n5 2 499999999\\n2 6 1\\n6 3 1\\n\", \"7 9 320 0 3\\n0 1 0\\n1 2 0\\n2 3 0\\n0 4 1... | ZS the Coder has drawn an undirected graph of n vertices numbered from 0 to n - 1 and m edges between them. Each edge of the graph is weighted, each weight is a positive integer.
The next day, ZS the Coder realized that some of the weights were erased! So he wants to reassign positive integer weight to each of the edg... | 0 |
{"tests": "{\"inputs\": [\"14\\n\", \"2128506\\n\", \"11\\n\", \"571576\\n\", \"61441\\n\", \"143165576\\n\", \"1919020031\\n\", \"1204252996\\n\", \"210637432\\n\", \"724264821\\n\", \"1741\\n\", \"619489590\\n\", \"1199537418\\n\", \"1075765759\\n\", \"747976826\\n\", \"638486017\\n\", \"58438190\\n\", \"1285316221\\... | Programmers' kids solve this riddle in 5-10 minutes. How fast can you do it?
Input
The input contains a single integer n (0 β€ n β€ 2000000000).
Output
Output a single integer.
Examples
Input
11
Output
2
Input
14
Output
0
Input
61441
Output
2
Input
571576
Output
10
Input
2128506
Output
3... | 0 |
{"tests": "{\"inputs\": [\"0 1 1 1 1 0\\n\", \"1 1 0 0 1000 1000\\n\", \"264193194 -448876521 736684426 -633906160 -328597212 -47935734\\n\", \"-357531221 381512519 -761132895 -224448284 328888775 -237692564\\n\", \"-1000000000 -1000000000 0 0 1000000000 999999999\\n\", \"0 2 4 5 4 0\\n\", \"0 0 2 45 0 90\\n\", \"-1000... | Arpa is taking a geometry exam. Here is the last problem of the exam.
You are given three points a, b, c.
Find a point and an angle such that if we rotate the page around the point by the angle, the new position of a is the same as the old position of b, and the new position of b is the same as the old position of c.... | 0 |
{"tests": "{\"inputs\": [\"5\\n3 2 1 6 5\\n\", \"4\\n3 3 3 3\\n\", \"228\\n1 3 1 7 1 3 1 15 1 3 1 7 1 3 1 31 1 3 1 7 1 3 1 15 1 3 1 7 1 3 1 63 1 3 1 7 1 3 1 15 1 3 1 7 1 3 1 31 1 3 1 7 1 3 1 15 1 3 1 7 1 3 1 127 1 3 1 7 1 3 1 15 1 3 1 7 1 3 1 31 1 3 1 7 1 3 1 15 1 3 1 7 1 3 1 63 1 3 1 7 1 3 1 15 1 3 1 7 1 3 1 31 1 3 1 ... | Disclaimer: there are lots of untranslateable puns in the Russian version of the statement, so there is one more reason for you to learn Russian :)
Rick and Morty like to go to the ridge High Cry for crying loudly β there is an extraordinary echo. Recently they discovered an interesting acoustic characteristic of this... | 0.625 |
{"tests": "{\"inputs\": [\"5 5\\n1 2\\n3 4\\n3 2\\n4 2\\n2 5\\n\", \"7 20\\n4 6\\n6 7\\n4 5\\n1 2\\n2 4\\n1 7\\n3 5\\n2 1\\n6 2\\n6 1\\n7 3\\n3 2\\n3 6\\n3 1\\n3 4\\n2 5\\n1 6\\n7 4\\n6 3\\n7 5\\n\", \"8 23\\n1 2\\n1 4\\n1 6\\n1 8\\n2 3\\n2 4\\n2 5\\n2 6\\n2 7\\n2 8\\n3 4\\n3 5\\n3 6\\n3 7\\n3 8\\n4 5\\n4 6\\n4 7\\n5 6... | You are given an undirected graph consisting of n vertices and <image> edges. Instead of giving you the edges that exist in the graph, we give you m unordered pairs (x, y) such that there is no edge between x and y, and if some pair of vertices is not listed in the input, then there is an edge between these vertices.
... | 0.125 |
{"tests": "{\"inputs\": [\"2 0\\n1 1 1 1\\n\", \"2 2\\n0 1 2 3\\n2 5\\n0 4\\n\", \"1 0\\n2 3\\n\", \"2 0\\n1 1 0 1\\n\", \"2 2\\n0 1 2 3\\n2 1\\n0 4\\n\", \"1 0\\n2 1\\n\", \"2 0\\n1 0 0 1\\n\", \"2 2\\n0 1 2 4\\n2 1\\n0 4\\n\", \"2 2\\n0 1 2 4\\n3 1\\n0 4\\n\", \"2 2\\n0 1 0 4\\n3 1\\n0 4\\n\", \"2 2\\n0 1 0 4\\n2 1\\... | Allen and Bessie are playing a simple number game. They both know a function f: \{0, 1\}^n β R, i. e. the function takes n binary arguments and returns a real value. At the start of the game, the variables x_1, x_2, ..., x_n are all set to -1. Each round, with equal probability, one of Allen or Bessie gets to make a mo... | 0.75 |
{"tests": "{\"inputs\": [\"2\\n5 156\\n16 40\\n\\nSAMPLE\", \"4\\n39 20\\n183 11\\n551 27\\n85 16\", \"8\\n4 65\\n5 12\\n7 24\\n9 38\\n12 24\\n14 10\\n65 75\\n31 26\", \"4\\n39 18\\n183 11\\n551 27\\n85 16\", \"8\\n4 65\\n5 12\\n7 21\\n9 38\\n12 24\\n14 10\\n65 75\\n31 26\", \"2\\n5 156\\n28 40\\n\\nSAMPLE\", \"4\\n49 ... | Professor Sharma gives the following problem to his students: given two integers X( β₯ 2) and Y( β₯ 2)
and tells them to find the smallest positive integral exponent E such that the decimal expansion of X^E begins with Y.
For example, if X = 8 and Y= 51, then X^3 = 512 begins with Y= 51, so E= 3.
Professor Sharma has a... | 0.375 |
{"tests": "{\"inputs\": [\"11 7 5\\n24979445 861648772 623690081 433933447 476190629 262703497 211047202 971407775 628894325 731963982 822804784\", \"5 3 2\\n4 3 1 5 2\", \"10 1 6\\n1 1 2 3 5 8 13 21 34 55\", \"11 7 5\\n24979445 861648772 623690081 433933447 476190629 262703497 147009374 971407775 628894325 731963982 8... | You are given an integer sequence A of length N and an integer K. You will perform the following operation on this sequence Q times:
* Choose a contiguous subsequence of length K, then remove the smallest element among the K elements contained in the chosen subsequence (if there are multiple such elements, choose one ... | 0.125 |
{"tests": "{\"inputs\": [\"15 22\\n8 13 33418\\n14 15 55849\\n7 10 15207\\n4 6 64328\\n6 9 86902\\n15 7 46978\\n8 14 53526\\n1 2 8720\\n14 12 37748\\n8 3 61543\\n6 5 32425\\n4 11 20932\\n3 12 55123\\n8 2 45333\\n9 12 77796\\n3 9 71922\\n12 15 70793\\n2 4 25485\\n11 6 1436\\n2 7 81563\\n7 11 97843\\n3 1 40491\", \"2 1\\... | Mole decided to live in an abandoned mine. The structure of the mine is represented by a simple connected undirected graph which consists of N vertices numbered 1 through N and M edges. The i-th edge connects Vertices a_i and b_i, and it costs c_i yen (the currency of Japan) to remove it.
Mole would like to remove som... | 0 |
{"tests": "{\"inputs\": [\"3 3\\n1 2\\n2 3\\n3 3\", \"7 9\\n1 7\\n5 9\\n5 7\\n5 9\\n1 1\\n6 8\\n3 4\", \"7 9\\n1 9\\n5 9\\n5 7\\n5 9\\n1 1\\n6 8\\n3 4\", \"7 9\\n1 9\\n9 9\\n5 7\\n5 9\\n1 1\\n6 8\\n3 4\", \"7 11\\n1 9\\n5 9\\n5 7\\n5 9\\n1 1\\n6 8\\n3 4\", \"7 9\\n1 9\\n9 9\\n5 7\\n5 9\\n1 1\\n8 8\\n3 4\", \"7 9\\n1 6\... | Snuke has decided to play a game, where the player runs a railway company. There are M+1 stations on Snuke Line, numbered 0 through M. A train on Snuke Line stops at station 0 and every d-th station thereafter, where d is a predetermined constant for each train. For example, if d = 3, the train stops at station 0, 3, 6... | 0.5 |
{"tests": "{\"inputs\": [\"10000\\n5000 3150\\n5000 5000\\n0 0\\n5000 1050\\n5000 3980\\n5000 210\\n5000 5000\\n5000 5000\\n0 0\\n5000 2100\\n5000 2100\\n5000 2100\\n29170\\n100000 100000\\n100000 100000\\n100000 100000\\n100000 100000\\n100000 100000\\n100000 100000\\n100000 100000\\n100000 100000\\n100000 100000\\n10... | You want to go on a trip with a friend. However, friends who have a habit of spending money cannot easily save travel expenses. I don't know when my friends will go on a trip if they continue their current lives. So, if you want to travel early, you decide to create a program to help your friends save in a planned mann... | 0 |
{"tests": "{\"inputs\": [\"2008 2 29\\n2015 3 1\", \"1999 9 9\\n2001 11 3\", \"2008 2 29\\n2015 1 1\", \"1505 9 9\\n2001 11 3\", \"1505 9 9\\n2619 11 3\", \"1505 13 9\\n2619 11 3\", \"573 1 44\\n2015 1 1\", \"595 2 44\\n2015 2 1\", \"597 2 44\\n2015 2 1\", \"246 21 0\\n2619 11 5\", \"246 21 0\\n5129 11 5\", \"431 21 0\... | A trick of fate caused Hatsumi and Taku to come to know each other. To keep the encounter in memory, they decided to calculate the difference between their ages. But the difference in ages varies depending on the day it is calculated. While trying again and again, they came to notice that the difference of their ages w... | 0 |
{"tests": "{\"inputs\": [\"3 5 10\\nred\\n0 0 0\\n5 0 0\\ngreen\\n0 5 5\\n5 6 1\\nblue\\n0 40 5\\n5 0 0\\n3 10 5\\natom\\n0 47 32\\n5 -10 -7\\n10 1 0\\npluto\\n0 0 0\\n7 0 0\\n10 3 3\\ngesicht\\n0 25 7\\n5 -7 -2\\n10 -1 10\\n4 100 7\\nimpulse\\n0 -500 0\\n100 10 1\\nfreedom\\n0 -491 0\\n100 9 2\\ndestiny\\n0 -472 0\\n1... | A new type of mobile robot has been developed for environmental earth observation. It moves around on the ground, acquiring and recording various sorts of observational data using high precision sensors. Robots of this type have short range wireless communication devices and can exchange observational data with ones ne... | 0 |
{"tests": "{\"inputs\": [\"3\\n6 11 24\", \"3\\n6 11 30\", \"3\\n6 11 12\", \"3\\n6 13 24\", \"3\\n6 4 30\", \"3\\n12 11 12\", \"3\\n6 20 24\", \"3\\n6 7 30\", \"3\\n11 20 24\", \"3\\n10 7 30\", \"3\\n1 15 12\", \"3\\n8 7 30\", \"3\\n1 1 12\", \"3\\n11 12 15\", \"3\\n8 7 11\", \"3\\n14 14 26\", \"3\\n7 15 28\", \"3\\n1... | KM country has N kinds of coins and each coin has its value a_i.
The king of the country, Kita_masa, thought that the current currency system is poor, and he decided to make it beautiful by changing the values of some (possibly no) coins.
A currency system is called beautiful if each coin has an integer value and the... | 0.25 |
{"tests": "{\"inputs\": [\"11\\n1 2 3 4 5 6 7 8 9 10 11\\n1\\n1 4 7\", \"11\\n1 2 3 4 5 6 7 8 9 10 11\\n2\\n1 4 7\", \"11\\n1 2 3 4 5 6 2 8 9 10 11\\n2\\n1 4 1\", \"11\\n1 2 3 3 5 6 2 8 9 10 11\\n2\\n1 4 1\", \"11\\n1 2 3 3 5 6 2 8 18 10 11\\n2\\n1 4 1\", \"11\\n1 0 3 3 5 6 2 8 18 10 11\\n2\\n1 4 1\", \"11\\n1 0 3 3 5 ... | Write a program which reads a sequence of integers $A = \\{a_0, a_1, ..., a_{n-1}\\}$ and swap specified elements by a list of the following operation:
* swapRange($b, e, t$): For each integer $k$ ($0 \leq k < (e - b)$, swap element $(b + k)$ and element $(t + k)$.
Constraints
* $1 \leq n \leq 1,000$
* $-1,000,000,0... | 0 |
{"tests": "{\"inputs\": [\"1 5 3\\n1 3\\n1 1\\n1 5\\n\", \"2 2 3\\n1 2\\n2 2\\n2 1\\n\", \"4 3 6\\n1 2\\n1 3\\n2 2\\n2 3\\n3 1\\n3 3\\n\", \"20 20 20\\n18 16\\n4 20\\n2 5\\n7 4\\n11 13\\n6 10\\n20 8\\n14 6\\n3 12\\n5 1\\n16 7\\n10 9\\n1 11\\n12 18\\n19 15\\n13 19\\n17 3\\n9 17\\n15 2\\n8 14\\n\", \"20 20 1\\n17 13\\n\"... | Innopolis University scientists continue to investigate the periodic table. There are nΒ·m known elements and they form a periodic table: a rectangle with n rows and m columns. Each element can be described by its coordinates (r, c) (1 β€ r β€ n, 1 β€ c β€ m) in the table.
Recently scientists discovered that for every four... | 0 |
{"tests": "{\"inputs\": [\"3 8\\n6 5 8\\n\", \"7 20\\n21 15 12 11 20 19 12\\n\", \"3 1\\n1 2 5\\n\", \"1 1\\n100000\\n\", \"5 1\\n2 2 4 6 1\\n\", \"3 10\\n5 5 10\\n\", \"1 1\\n1\\n\", \"3 4\\n1 2 5\\n\", \"1 100\\n88\\n\", \"1 100\\n105\\n\", \"3 2\\n1 2 5\\n\", \"3 10\\n5 3 10\\n\", \"3 4\\n0 2 5\\n\", \"1 100\\n5\\n\... | You are given an array a of n integers and an integer s. It is guaranteed that n is odd.
In one operation you can either increase or decrease any single element by one. Calculate the minimum number of operations required to make the median of the array being equal to s.
The median of the array with odd length is the ... | 0 |
{"tests": "{\"inputs\": [\"4\\nsword weapon 10 2 3 2\\npagstarmor armor 0 15 3 1\\niceorb orb 3 2 13 2\\nlongbow weapon 9 1 2 1\\n6\\nmike gladiator 5 longbow\\nbobby sentry 6 pagstarmor\\npetr gladiator 7 iceorb\\nteddy physician 6 sword\\nblackjack sentry 8 sword\\njoe physician 6 iceorb\\n\", \"4\\nsword weapon 10 2... | Each item in the game has a level. The higher the level is, the higher basic parameters the item has. We shall consider only the following basic parameters: attack (atk), defense (def) and resistance to different types of impact (res).
Each item belongs to one class. In this problem we will only consider three of such... | 0 |
{"tests": "{\"inputs\": [\"6 8\\nabdabc\\n+ 1 a\\n+ 1 d\\n+ 2 b\\n+ 2 c\\n+ 3 a\\n+ 3 b\\n+ 1 c\\n- 2\\n\", \"6 8\\nabbaab\\n+ 1 a\\n+ 2 a\\n+ 3 a\\n+ 1 b\\n+ 2 b\\n+ 3 b\\n- 1\\n+ 2 z\\n\", \"1 1\\nt\\n+ 2 p\\n\", \"2 12\\naa\\n+ 1 a\\n+ 2 a\\n+ 3 a\\n- 1\\n+ 1 a\\n- 2\\n+ 2 a\\n- 3\\n+ 3 a\\n+ 2 a\\n- 1\\n- 3\\n\", \... | During the archaeological research in the Middle East you found the traces of three ancient religions: First religion, Second religion and Third religion. You compiled the information on the evolution of each of these beliefs, and you now wonder if the followers of each religion could coexist in peace.
The Word of Uni... | 0.375 |
{"tests": "{\"inputs\": [\"10\\n1\\n248618\\n3\\n12 10 8\\n6\\n100 11 15 9 7 8\\n4\\n0 1 1 0\\n2\\n0 0\\n2\\n0 1\\n2\\n1 0\\n2\\n1 1\\n3\\n0 1 0\\n3\\n1 0 1\\n\", \"10\\n1\\n248618\\n3\\n12 10 8\\n6\\n100 11 15 9 2 8\\n4\\n0 1 1 0\\n2\\n0 0\\n2\\n0 1\\n2\\n1 0\\n2\\n1 1\\n3\\n0 1 0\\n3\\n1 0 1\\n\", \"10\\n1\\n451008\\... | You're given an array a_1, β¦, a_n of n non-negative integers.
Let's call it sharpened if and only if there exists an integer 1 β€ k β€ n such that a_1 < a_2 < β¦ < a_k and a_k > a_{k+1} > β¦ > a_n. In particular, any strictly increasing or strictly decreasing array is sharpened. For example:
* The arrays [4], [0, 1], [... | 0 |
{"tests": "{\"inputs\": [\"3\\n4 2\\nabca\\n1 3\\n10 5\\ncodeforces\\n2 8 3 2 9\\n26 10\\nqwertyuioplkjhgfdsazxcvbnm\\n20 10 1 2 3 5 10 5 9 4\\n\", \"2\\n2 2\\nyz\\n1 1\\n2 2\\nyz\\n1 1\\n\", \"1\\n11 2\\nthisisatest\\n3 5\\n\", \"2\\n2 2\\nyz\\n1 1\\n2 2\\nzy\\n1 1\\n\", \"1\\n11 2\\nthisisatest\\n3 7\\n\", \"3\\n4 2\... | You want to perform the combo on your opponent in one popular fighting game. The combo is the string s consisting of n lowercase Latin letters. To perform the combo, you have to press all buttons in the order they appear in s. I.e. if s="abca" then you have to press 'a', then 'b', 'c' and 'a' again.
You know that you ... | 0.125 |
{"tests": "{\"inputs\": [\"4\\n1 3 2 4\\n\", \"2\\n-492673762 -496405053\\n\", \"13\\n-958184557 -577042357 -616514099 -553646903 -719490759 -761325526 -210773060 -44979753 864458686 -387054074 546903944 638449520 299190036\\n\", \"5\\n450402558 -840167367 -231820501 586187125 -627664644\\n\", \"32\\n474784688 67167188... | You are given an array a of n integers.
You want to make all elements of a equal to zero by doing the following operation exactly three times:
* Select a segment, for each number in this segment we can add a multiple of len to it, where len is the length of this segment (added integers can be different).
It can... | 0 |
{"tests": "{\"inputs\": [\"3\\n5\\n3 5 2 1 4\\n1\\n1\\n4\\n4 3 1 2\\n\", \"3\\n5\\n3 5 1 2 4\\n1\\n1\\n4\\n4 3 1 2\\n\", \"3\\n5\\n4 5 2 1 3\\n1\\n1\\n4\\n4 3 1 2\\n\", \"3\\n5\\n3 4 2 1 5\\n1\\n1\\n4\\n4 3 1 2\\n\", \"3\\n5\\n2 5 3 1 4\\n1\\n1\\n4\\n4 3 1 2\\n\", \"3\\n5\\n4 5 1 2 3\\n1\\n1\\n4\\n4 3 1 2\\n\"], \"outp... | A permutation β is a sequence of length n integers from 1 to n, in which all the numbers occur exactly once. For example, [1], [3, 5, 2, 1, 4], [1, 3, 2] β permutations, and [2, 3, 2], [4, 3, 1], [0] β no.
Polycarp was recently gifted a permutation a[1 ... n] of length n. Polycarp likes trees more than permutations, s... | 0.875 |
{"tests": "{\"inputs\": [\"4\\n10 21\\n31 10\\n0 1\\n10 30\\n\", \"7\\n576460752303423487 2\\n82 9\\n101 104\\n10 21\\n31 10\\n0 1\\n10 30\\n\", \"1\\n128817972817282999 327672410994637530\\n\", \"66\\n7 0\\n5 7\\n1 3\\n3 2\\n3 5\\n0 6\\n1 2\\n0 7\\n4 5\\n4 7\\n5 1\\n2 0\\n4 0\\n0 5\\n3 6\\n7 3\\n6 0\\n5 2\\n6 6\\n1 7\... | In some country live wizards. They love playing with numbers.
The blackboard has two numbers written on it β a and b. The order of the numbers is not important. Let's consider a β€ b for the sake of definiteness. The players can cast one of the two spells in turns:
* Replace b with b - ak. Number k can be chosen by... | 0 |
{"tests": "{\"inputs\": [\"1 1 1\\n\", \"3 1 0\\n\", \"9 530792195 6\\n\", \"0 0 10\\n\", \"1944219055 454183506 1369298327\\n\", \"914835 2742837 9234739\\n\", \"10 10 0\\n\", \"2 2 0\\n\", \"0 0 1\\n\", \"3 10 1007169359\\n\", \"0 1 0\\n\", \"1016450951 2 9\\n\", \"0 2 10\\n\", \"2147483648 0 2147483647\\n\", \"92134... | Flatland is inhabited by pixels of three colors: red, green and blue. We know that if two pixels of different colors meet in a violent fight, only one of them survives the fight (that is, the total number of pixels decreases by one). Besides, if pixels of colors x and y (x β y) meet in a violent fight, then the pixel t... | 0 |
{"tests": "{\"inputs\": [\"7\\n1 2\\n2 3\\n3 1\\n4 5\\n5 6\\n6 7\\n\", \"2\\n1 2\\n\", \"4\\n1 4\\n3 1\\n3 4\\n\", \"5\\n4 1\\n4 3\\n5 3\\n2 4\\n\", \"21\\n7 15\\n13 1\\n14 3\\n4 10\\n2 3\\n16 18\\n17 20\\n16 20\\n8 4\\n3 12\\n2 17\\n13 11\\n16 1\\n13 2\\n13 5\\n8 9\\n6 14\\n3 17\\n16 9\\n13 8\\n\", \"3\\n3 1\\n3 2\\n\... | Berland Government decided to improve relations with neighboring countries. First of all, it was decided to build new roads so that from each city of Berland and neighboring countries it became possible to reach all the others. There are n cities in Berland and neighboring countries in total and exactly n - 1 two-way r... | 0 |
{"tests": "{\"inputs\": [\"3 4 2\\n#..#\\n..#.\\n#...\\n\", \"5 4 5\\n#...\\n#.#.\\n.#..\\n...#\\n.#.#\\n\", \"19 20 196\\n###.....##.#..#..##.\\n####............##..\\n###....#..#.#....#.#\\n##....###......#...#\\n.####...#.....#.##..\\n.###......#...#.#.#.\\n...##.#...#..#..#...\\n.....#.....#..#....#\\n.#.....##..#.... | Pavel loves grid mazes. A grid maze is an n Γ m rectangle maze where each cell is either empty, or is a wall. You can go from one cell to another only if both cells are empty and have a common side.
Pavel drew a grid maze with all empty cells forming a connected area. That is, you can go from any empty cell to any oth... | 0 |
{"tests": "{\"inputs\": [\"3 1 4\\n\", \"2 2 10\\n\", \"5 5 16808\\n\", \"1 4 10\\n\", \"2 2 5\\n\", \"9 9 1000000000\\n\", \"3 17 999999997\\n\", \"3 3 64\\n\", \"5 1 64\\n\", \"29 2 1000000000\\n\", \"1010 1 1000000000\\n\", \"3 2 27\\n\", \"1 1 60\\n\", \"2 4 64\\n\", \"2 2 64\\n\", \"3 4 1000\\n\", \"2 3 64\\n\", \... | You all know the Dirichlet principle, the point of which is that if n boxes have no less than n + 1 items, that leads to the existence of a box in which there are at least two items.
Having heard of that principle, but having not mastered the technique of logical thinking, 8 year olds Stas and Masha invented a game. T... | 0 |
{"tests": "{\"inputs\": [\"3\\n2 3 3\\n\", \"4\\n0 1 2 3\\n\", \"6\\n5 2 0 5 2 1\\n\", \"2\\n1 31\\n\", \"2\\n1 0\\n\", \"10\\n450661 128600 993228 725823 293549 33490 843121 903634 556169 448234\\n\", \"1\\n1\\n\", \"5\\n1 3 5 7 9\\n\", \"6\\n524 529 5249 524 529 529\\n\", \"3\\n1 2 3\\n\", \"2\\n0 1\\n\", \"55\\n0 1 ... | Jzzhu have n non-negative integers a1, a2, ..., an. We will call a sequence of indexes i1, i2, ..., ik (1 β€ i1 < i2 < ... < ik β€ n) a group of size k.
Jzzhu wonders, how many groups exists such that ai1 & ai2 & ... & aik = 0 (1 β€ k β€ n)? Help him and print this number modulo 1000000007 (109 + 7). Operation x & y deno... | 0.625 |
{"tests": "{\"inputs\": [\"3 2\\n? 1 2\\n\", \"5 1\\n-10 -9 ? -7 -6\\n\", \"5 3\\n4 6 7 2 9\\n\", \"7 2\\n-10 0 ? 1 ? 2 10\\n\", \"1 1\\n0\\n\", \"5 1\\n-3 -2 -1 0 1\\n\", \"7 1\\n-4 ? ? ? ? ? 2\\n\", \"17 1\\n? -13 ? ? ? -3 ? ? ? ? ? 10 ? ? ? ? 100\\n\", \"3 1\\n-5 ? 0\\n\", \"7 2\\n-10 0 ? 1 6 2 ?\\n\", \"3 1\\n-3 ? ... | After bracket sequences Arthur took up number theory. He has got a new favorite sequence of length n (a1, a2, ..., an), consisting of integers and integer k, not exceeding n.
This sequence had the following property: if you write out the sums of all its segments consisting of k consecutive elements (a1 + a2 ... + ak, ... | 0 |
{"tests": "{\"inputs\": [\"5 2\\n3 -5 3 -5 3\\n\", \"3 2\\n1 2 4\\n\", \"6 3\\n4 3 4 3 2 5\\n\", \"30 2\\n-999999924 -499999902 500000091 -999999998 500000030 -999999934 500000086 -499999918 -499999998 67 -999999964 -499999975 -499999947 -499999925 3 -499999985 14 500000015 500000022 88 25 -499999909 500000051 -4999999... | You've got array A, consisting of n integers and a positive integer k. Array A is indexed by integers from 1 to n.
You need to permute the array elements so that value
<image> became minimal possible. In particular, it is allowed not to change order of elements at all.
Input
The first line contains two integers n,... | 0 |
{"tests": "{\"inputs\": [\"3 0 0\\n0 1\\n-1 2\\n1 2\\n\", \"4 1 -1\\n0 0\\n1 2\\n2 0\\n1 1\\n\", \"4 0 0\\n1 -1\\n1 3\\n3 3\\n3 -1\\n\", \"3 0 0\\n-10 1\\n0 2\\n1 1\\n\", \"3 0 0\\n-1 1\\n0 3\\n1 1\\n\", \"20 -999719 -377746\\n-999718 -377746\\n-997432 -940486\\n-982215 -950088\\n-903861 -997725\\n-127953 -999833\\n846... | Peter got a new snow blower as a New Year present. Of course, Peter decided to try it immediately. After reading the instructions he realized that it does not work like regular snow blowing machines. In order to make it work, you need to tie it to some point that it does not cover, and then switch it on. As a result it... | 0 |
{"tests": "{\"inputs\": [\"4 2\\n1 2\\n2 3\\n\", \"3 3\\n1 2\\n2 3\\n1 3\\n\", \"10 16\\n6 10\\n5 2\\n6 4\\n6 8\\n5 3\\n5 4\\n6 2\\n5 9\\n5 7\\n5 1\\n6 9\\n5 8\\n5 10\\n6 1\\n6 7\\n6 3\\n\", \"10 9\\n2 5\\n2 4\\n2 7\\n2 9\\n2 3\\n2 8\\n2 6\\n2 10\\n2 1\\n\", \"20 22\\n3 18\\n9 19\\n6 15\\n7 1\\n16 8\\n18 7\\n12 3\\n18 ... | Recently, Pari and Arya did some research about NP-Hard problems and they found the minimum vertex cover problem very interesting.
Suppose the graph G is given. Subset A of its vertices is called a vertex cover of this graph, if for each edge uv there is at least one endpoint of it in this set, i.e. <image> or <image>... | 0 |
{"tests": "{\"inputs\": [\"3 2\\n1 3\\n1 1\\n0\\n2\\n\", \"2 2\\n1 2\\n1 1\\n1\\n\", \"5 6\\n2 2 3\\n2 4 5\\n1 4\\n1 5\\n0\\n1\\n\", \"11 20\\n1 2\\n2 7 6\\n1 7\\n4 10 9 3 2\\n2 9 2\\n1 3\\n0\\n0\\n3 1 6 7\\n4 11 7 5 6\\n2 2 8\\n4\\n\", \"5 5\\n1 2\\n1 3\\n2 1 4\\n1 5\\n0\\n1\\n\", \"5 5\\n1 2\\n1 3\\n2 2 4\\n1 5\\n0\\... | Petya and Vasya arranged a game. The game runs by the following rules. Players have a directed graph consisting of n vertices and m edges. One of the vertices contains a chip. Initially the chip is located at vertex s. Players take turns moving the chip along some edge of the graph. Petya goes first. Player who can't m... | 0 |
{"tests": "{\"inputs\": [\"2\\n2\\n3\\n\\n\\nSAMPLE\", \"2\\n1\\n3\\n\\n\\nSAMPLE\", \"2\\n2\\n3\\n\\n\\nSBMPLE\", \"2\\n2\\n2\\n\\n\\nELPMBS\", \"2\\n4\\n2\\n\\n\\nELPMBS\", \"2\\n3\\n3\\n\\n\\nFLQMBS\", \"2\\n5\\n2\\n\\n\\nELPMBS\", \"2\\n3\\n1\\n\\n\\nFLQMBS\", \"2\\n1\\n5\\n\\n\\nEANPLS\", \"2\\n1\\n8\\n\\n\\nEANPL... | In code world all genders are considered equal ( It means their is nothing like male or female). Now their are N distinct persons living in this hypothetical world. Each person can pair up with any other person or can even remain single. One day Vbhu planned to visit code world. Being a maths guy , he always try to b... | 0.75 |
{"tests": "{\"inputs\": [\"3\\n4 1\\n5 2\\n6 3\", \"4\\n1 5\\n4 7\\n2 1\\n8 4\", \"2\\n3 2\\n1 2\", \"10\\n866111664 178537096\\n705445072 318106937\\n472381277 579910117\\n353498483 865935868\\n383133839 231371336\\n378371075 681212831\\n304570952 16537461\\n955719384 267238505\\n844917655 218662351\\n550309930 627311... | We have N balance beams numbered 1 to N. The length of each beam is 1 meters. Snuke walks on Beam i at a speed of 1/A_i meters per second, and Ringo walks on Beam i at a speed of 1/B_i meters per second.
Snuke and Ringo will play the following game:
* First, Snuke connects the N beams in any order of his choice and m... | 0 |
{"tests": "{\"inputs\": [\"4\", \"3\", \"2\", \"6\", \"7\", \"8\", \"10\", \"1\", \"5\", \"9\", \"001\", \"010\", \"5\", \"6\", \"1\", \"9\", \"7\", \"2\", \"10\", \"8\", \"001\", \"010\"], \"outputs\": [\"0 111 157 193\\n111 0 224 239\\n157 224 0 258\\n193 239 258 0\", \"0 6 15\\n6 0 21\\n15 21 0\", \"0 1\\n1 0\\n\", ... | Diverta City is a new city consisting of N towns numbered 1, 2, ..., N.
The mayor Ringo is planning to connect every pair of two different towns with a bidirectional road. The length of each road is undecided.
A Hamiltonian path is a path that starts at one of the towns and visits each of the other towns exactly once... | 0 |
{"tests": "{\"inputs\": [\"3 9 1\\n1 3 8\", \"2 1000000000 1000000000\\n1 999999999\", \"3 9 3\\n1 3 8\", \"3 9 1\\n2 3 8\", \"2 1000000000 1000000000\\n1 199586132\", \"3 9 3\\n1 3 7\", \"3 9 3\\n1 0 7\", \"2 1000001000 1000000000\\n2 199586132\", \"3 9 5\\n1 0 7\", \"2 1010001000 1000000000\\n2 199586132\", \"2 10100... | Imagine a game played on a line. Initially, the player is located at position 0 with N candies in his possession, and the exit is at position E. There are also N bears in the game. The i-th bear is located at x_i. The maximum moving speed of the player is 1 while the bears do not move at all.
When the player gives a c... | 0 |
{"tests": "{\"inputs\": [\"2\\n17 25\\n4\\n17 45\\n4\\n17 25\\n7\\n19 35\\n0\", \"2\\n17 25\\n4\\n17 45\\n4\\n17 25\\n7\\n1 35\\n0\", \"2\\n19 25\\n4\\n17 37\\n4\\n17 47\\n7\\n0 63\\n0\", \"2\\n14 25\\n4\\n3 37\\n4\\n17 47\\n7\\n0 63\\n0\", \"2\\n13 25\\n3\\n17 45\\n4\\n17 25\\n7\\n1 35\\n0\", \"2\\n14 25\\n4\\n17 37\\... | In 20XX, the Aizu Chuo Road, which has a total distance of 58km and 6 sections from Atsushiokanomachi, Kitakata City to Minamiaizucho, is scheduled to be completed and opened.
For half a year after opening, the toll will be halved for vehicles that pass the departure IC or arrival IC between 17:30 and 19:30 and have a... | 0 |
{"tests": "{\"inputs\": [\"2 2 1\\n2 3 1\\n3 2 3\\n2 3 5\", \"2 2 1\\n2 3 1\\n3 2 3\\n1 3 5\", \"4 2 1\\n2 3 1\\n3 2 3\\n1 3 5\", \"2 2 1\\n2 3 1\\n3 2 5\\n1 3 5\", \"2 2 0\\n2 3 1\\n3 2 3\\n2 3 5\", \"2 2 1\\n2 3 1\\n1 2 3\\n1 3 5\", \"4 2 1\\n2 3 1\\n3 2 3\\n1 3 0\", \"2 2 1\\n2 3 1\\n1 2 5\\n1 3 5\", \"2 2 0\\n2 3 0... | Problem
KND is a student programmer at the University of Aizu. His chest is known to be very sexy.
<image>
For simplicity, the part of the skin that can be seen from the chest is represented by the isosceles triangle ABC in the figure. However, due to the slack in the clothes, the two sides AC and BC (where these l... | 0.25 |
{"tests": "{\"inputs\": [\"1\\n1 1 1 1\\n10000 10000 10000 10000\", \"2\\n10 3 1 2\\n2 4 1 3\\n2 2 1 1\", \"1\\n1 0 1 1\\n10000 10000 10000 10000\", \"2\\n10 3 1 2\\n2 4 1 3\\n1 2 1 1\", \"2\\n10 3 1 2\\n2 4 1 3\\n1 3 1 1\", \"2\\n10 3 1 2\\n3 4 1 3\\n1 3 1 1\", \"2\\n10 3 2 2\\n3 4 1 3\\n1 3 1 1\", \"1\\n1 0 1 1\\n100... | A rabbit is playing a role-playing game. Just before entering the castle, he was ambushed by an enemy!
It was a battle between one hero operated by a rabbit and n enemies. Each character has four stats, health hi, attack power ai, defense power di, and agility si. I = 0 is the information of the main character, 1 β€ i ... | 0 |
{"tests": "{\"inputs\": [\"4\\n1 2 1 16\\n\", \"3\\n6 7 14\\n\", \"5\\n1000000000000000000 352839520853234088 175235832528365792 753467583475385837 895062156280564685\\n\", \"1\\n15\\n\", \"1\\n4\\n\", \"1\\n17\\n\", \"3\\n10 7 14\\n\", \"3\\n10 7 16\\n\", \"1\\n7\\n\", \"1\\n24\\n\", \"1\\n9\\n\", \"1\\n2\\n\", \"1\\n... | Vasya has a sequence a consisting of n integers a_1, a_2, ..., a_n. Vasya may pefrom the following operation: choose some number from the sequence and swap any pair of bits in its binary representation. For example, Vasya can transform number 6 (... 00000000110_2) into 3 (... 00000000011_2), 12 (... 000000001100_2), 10... | 0 |
{"tests": "{\"inputs\": [\"1\\n3\\n1 2\\n2 3\\n1\\n1\\n1\\n2\\n2\\n1\\n\", \"2\\n6\\n1 2\\n1 3\\n1 4\\n4 5\\n4 6\\n4\\n1 3 4 5\\n3\\n3 5 2\\n3\\n6\\n1 2\\n1 3\\n1 4\\n4 5\\n4 6\\n3\\n1 2 3\\n3\\n4 1 6\\n5\\n\", \"1\\n1\\n1\\n1\\n1\\n1\\n1\\n\", \"1\\n3\\n2 3 1\\n1 2\\n2 3\\n1\\n1\\n1\\n2\\n\", \"2\\n6\\n5 3 2 4 1 6\\n1... | You are playing a strange game with Li Chen. You have a tree with n nodes drawn on a piece of paper. All nodes are unlabeled and distinguishable. Each of you independently labeled the vertices from 1 to n. Neither of you know the other's labelling of the tree.
You and Li Chen each chose a subtree (i.e., a connected su... | 0 |
{"tests": "{\"inputs\": [\"10 30 10\\n\", \"2 6 3\\n\", \"5 20 11\\n\", \"1 5000 4999\\n\", \"2 1 0\\n\", \"83 2813 123\\n\", \"93 2364 2364\\n\", \"100 1 0\\n\", \"21 862 387\\n\", \"1 1 0\\n\", \"93 2364 1182\\n\", \"1 0 0\\n\", \"100 5000 30\\n\", \"100 0 0\\n\", \"45 2315 2018\\n\", \"45 886 245\\n\", \"69 813 598\... | Hasan loves playing games and has recently discovered a game called TopScore. In this soccer-like game there are p players doing penalty shoot-outs. Winner is the one who scores the most. In case of ties, one of the top-scorers will be declared as the winner randomly with equal probability.
They have just finished the... | 0 |
{"tests": "{\"inputs\": [\"30 60 3 1\\n\", \"20 0 15 5\\n\", \"10 51 5 4\\n\", \"728961319347 33282698448966372 52437 42819\\n\", \"461788563846 36692905412962338 93797 64701\\n\", \"567018385179 15765533940665693 35879 13819\\n\", \"21644595275 987577030498703 66473 35329\\n\", \"1000000000000 1000000000000 6 3\\n\", ... | The football season has just ended in Berland. According to the rules of Berland football, each match is played between two teams. The result of each match is either a draw, or a victory of one of the playing teams. If a team wins the match, it gets w points, and the opposing team gets 0 points. If the game results in ... | 0.625 |
{"tests": "{\"inputs\": [\"5\\n12\\n5 4 4 3 2 2 1 1 1 1 1 1\\n4\\n4 3 2 1\\n1\\n1000000\\n20\\n20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1\\n32\\n64 64 63 58 58 58 58 58 37 37 37 37 34 34 28 28 28 28 28 28 24 24 19 17 17 17 17 16 16 16 16 11\\n\", \"5\\n12\\n5 4 4 3 2 2 1 1 1 1 1 1\\n4\\n4 3 2 1\\n1\\n1000000\\n... | So the Beautiful Regional Contest (BeRC) has come to an end! n students took part in the contest. The final standings are already known: the participant in the i-th place solved p_i problems. Since the participants are primarily sorted by the number of solved problems, then p_1 β₯ p_2 β₯ ... β₯ p_n.
Help the jury distrib... | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.