info stringlengths 120 50k | question stringlengths 504 10.4k | avg@8_qwen3_4b_instruct_2507 float64 0 0.88 |
|---|---|---|
{"tests": "{\"inputs\": [\"4\\n1 1 1 1\\n2 1 1 0\\n1 1 1 0\\n1 0 0 1\\n\", \"10\\n48 43 75 80 32 30 65 31 18 91\\n99 5 12 43 26 90 54 91 4 88\\n8 87 68 95 73 37 53 46 53 90\\n50 1 85 24 32 16 5 48 98 74\\n38 49 78 2 91 3 43 96 93 46\\n35 100 84 2 94 56 90 98 54 43\\n88 3 95 72 78 78 87 82 25 37\\n8 15 85 85 68 27 40 10... | Gargari is jealous that his friend Caisa won the game from the previous problem. He wants to prove that he is a genius.
He has a n × n chessboard. Each cell of the chessboard has a number written on it. Gargari wants to place two bishops on the chessboard in such a way that there is no cell that is attacked by both of... | 0 |
{"tests": "{\"inputs\": [\"3 3\\n1 2 B\\n3 1 R\\n3 2 B\\n\", \"6 5\\n1 3 R\\n2 3 R\\n3 4 B\\n4 5 R\\n4 6 R\\n\", \"4 5\\n1 2 R\\n1 3 R\\n2 3 B\\n3 4 B\\n1 4 B\\n\", \"6 6\\n1 2 R\\n1 3 R\\n2 3 R\\n4 5 B\\n4 6 B\\n5 6 B\\n\", \"3 3\\n1 2 R\\n1 3 R\\n2 3 R\\n\", \"11 7\\n1 2 B\\n1 3 R\\n3 2 R\\n4 5 R\\n6 7 R\\n8 9 R\\n10... | You are given an undirected graph that consists of n vertices and m edges. Initially, each edge is colored either red or blue. Each turn a player picks a single vertex and switches the color of all edges incident to it. That is, all red edges with an endpoint in this vertex change the color to blue, while all blue edge... | 0 |
{"tests": "{\"inputs\": [\"3 3\\n2\\nb\\nb\\nbbac\\n0\\na\\naca\\nacba\\n1\\nab\\nc\\nccb\\n\", \"5 5\\n2\\na\\nabcbb\\nabcaacac\\naab\\naaa\\n0\\nb\\nb\\nbb\\nbbaaaabca\\nbbcbbc\\n4\\ncbcb\\ncbcbac\\ncabbcbbca\\ncaca\\ncc\\n1\\nba\\nbacbbabcc\\nbaccac\\nbccababc\\na\\n3\\naaccacabac\\nacbb\\nacaaaac\\nc\\ncb\\n\", \"5... | While exploring the old caves, researchers found a book, or more precisely, a stash of mixed pages from a book. Luckily, all of the original pages are present and each page contains its number. Therefore, the researchers can reconstruct the book.
After taking a deeper look into the contents of these pages, linguists t... | 0 |
{"tests": "{\"inputs\": [\"2\\n1 2 3\\n12 34 56\\n\", \"1\\n2434 2442 14\\n\", \"1\\n10 20 10\\n\", \"1\\n3 4 5\\n\", \"1\\n2 1 2\\n\", \"1\\n5 4 3\\n\"], \"outputs\": [\"1\\n11\\n\", \"1\\n\", \"1\\n\", \"1\\n\", \"1\\n\", \"1\\n\"]}", "source": "primeintellect"} | Yura is tasked to build a closed fence in shape of an arbitrary non-degenerate simple quadrilateral. He's already got three straight fence segments with known lengths $a$, $b$, and $c$. Now he needs to find out some possible integer length $d$ of the fourth straight fence segment so that he can build the fence using th... | 0 |
{"tests": "{\"inputs\": [\"0\\n\", \"1\\n\", \"2\\n\", \"3\\n\", \"1234567894848\\n\"], \"outputs\": [\"4\\n3 3 3 3\\n\", \"3\\n1 0 3\\n\", \"2\\n2 2\\n\", \"7\\n27 0 0 0 0 0 0\\n\", \"10\\n1000 193 256 777 0 1 1192 1234567891011 48 425\\n\"]}", "source": "primeintellect"} | We have a sequence of length N consisting of non-negative integers. Consider performing the following operation on this sequence until the largest element in this sequence becomes N-1 or smaller.
- Determine the largest element in the sequence (if there is more than one, choose one). Decrease the value of this element... | 0 |
{"tests": "{\"inputs\": [\"3 2\\n353\\n\", \"4 2\\n1234\\n\", \"5 4\\n99999\\n\", \"5 4\\n41242\\n\", \"5 2\\n16161\\n\", \"2 1\\n33\\n\", \"2 1\\n99\\n\", \"2 1\\n31\\n\", \"2 1\\n33\\n\", \"5 1\\n99999\\n\", \"5 1\\n26550\\n\", \"5 1\\n22222\\n\", \"5 2\\n99999\\n\", \"5 2\\n16137\\n\", \"5 3\\n99999\\n\", \"5 3\\n91... | You are given an integer $x$ of $n$ digits $a_1, a_2, \ldots, a_n$, which make up its decimal notation in order from left to right.
Also, you are given a positive integer $k < n$.
Let's call integer $b_1, b_2, \ldots, b_m$ beautiful if $b_i = b_{i+k}$ for each $i$, such that $1 \leq i \leq m - k$.
You need to find t... | 0.875 |
{"tests": "{\"inputs\": [\"1 1 2 3 1 0\\n2 4 20\\n\", \"1 1 2 3 1 0\\n15 27 26\\n\", \"1 1 2 3 1 0\\n2 2 1\\n\", \"9999999999999999 1 2 2 0 0\\n10000000000000000 1 10000000000000000\\n\", \"9999999999999999 1 2 2 0 0\\n9999999999999999 1 10000000000000000\\n\", \"9999999999999998 1 2 2 0 0\\n9999999999999999 1 10000000... | THE SxPLAY & KIVΛ - 漂流 KIVΛ & Nikki Simmons - Perspectives
With a new body, our idol Aroma White (or should we call her Kaori Minamiya?) begins to uncover her lost past through the OS space.
The space can be considered a 2D plane, with an infinite number of data nodes, indexed from $0$, with their coordinates defined... | 0 |
{"tests": "{\"inputs\": [\"3\\n0 0 1\\n2 0 1\\n4 0 1\\n\", \"3\\n0 0 2\\n3 0 2\\n6 0 2\\n\", \"3\\n0 0 2\\n2 0 2\\n1 1 2\\n\", \"1\\n0 0 10\\n\", \"2\\n-10 10 1\\n10 -10 1\\n\", \"2\\n-6 6 9\\n3 -6 6\\n\", \"2\\n-10 -10 10\\n10 10 10\\n\", \"3\\n-4 1 5\\n-7 7 10\\n-3 -4 8\\n\", \"3\\n-2 8 10\\n3 -2 5\\n3 1 3\\n\", \"3\... | Firecrackers scare Nian the monster, but they're wayyyyy too noisy! Maybe fireworks make a nice complement.
Little Tommy is watching a firework show. As circular shapes spread across the sky, a splendid view unfolds on the night of Lunar New Year's eve.
A wonder strikes Tommy. How many regions are formed by the circl... | 0 |
{"tests": "{\"inputs\": [\"3 5\\n1 5 3\\n\", \"1 2\\n1\\n\", \"1 1\\n1\\n\", \"1 1\\n2\\n\", \"2 2\\n2 3\\n\", \"2 3\\n2 1\\n\", \"3 3\\n2 3 2\\n\", \"3 2\\n2 3 4\\n\", \"3 4\\n2 1 2\\n\", \"4 4\\n2 1 2 3\\n\", \"4 3\\n2 1 2 3\\n\", \"4 6\\n2 3 4 5\\n\", \"5 5\\n2 1 2 3 4\\n\", \"5 3\\n2 3 2 1 2\\n\", \"5 7\\n2 1 2 3 4... | A new dog show on TV is starting next week. On the show dogs are required to demonstrate bottomless stomach, strategic thinking and self-preservation instinct. You and your dog are invited to compete with other participants and naturally you want to win!
On the show a dog needs to eat as many bowls of dog food as poss... | 0.125 |
{"tests": "{\"inputs\": [\"1\\n\", \"2\\n\", \"3\\n\", \"4\\n\", \"5\\n\", \"6\\n\", \"7\\n\", \"8\\n\", \"9\\n\", \"10\\n\", \"11\\n\", \"12\\n\", \"13\\n\", \"14\\n\", \"15\\n\", \"16\\n\", \"17\\n\", \"18\\n\", \"19\\n\", \"20\\n\", \"21\\n\", \"22\\n\", \"23\\n\", \"24\\n\", \"25\\n\", \"26\\n\", \"27\\n\", \"28\\n... | Suppose you have two polynomials $A(x) = \sum_{k = 0}^{n} a_{k} x^{k}$ and $B(x) = \sum_{k = 0}^{m} b_{k} x^{k}$. Then polynomial $A(x)$ can be uniquely represented in the following way:$A(x) = B(x) \cdot D(x) + R(x), \operatorname{deg} R(x) < \operatorname{deg} B(x)$
This can be done using long division. Here, $\oper... | 0 |
{"tests": "{\"inputs\": [\"3 1 5 4\\n1 2 1 3\\n\", \"3 1 5 3\\n1 3 1\\n\", \"3 2 5 3\\n1 3 1\\n\", \"1 1 1 1\\n1\\n\", \"1 1 1 1\\n1\\n\", \"1 1 2 2\\n1 1\\n\", \"1 1 2 1\\n1\\n\", \"1 1 1 1\\n1\\n\", \"1 1 3 3\\n1 1 1\\n\", \"1 1 1 1\\n1\\n\", \"1 1 3 3\\n1 1 1\\n\", \"1 1 5 4\\n1 1 1 1\\n\", \"1 1 4 2\\n1 1\\n\", \"1... | The elections to Berland parliament are happening today. Voting is in full swing!
Totally there are n candidates, they are numbered from 1 to n. Based on election results k (1 ≤ k ≤ n) top candidates will take seats in the parliament.
After the end of the voting the number of votes for each candidate is calculated. I... | 0 |
{"tests": "{\"inputs\": [\"110\\n2\\n\", \"111111011\\n2\\n\", \"100011110011110110100\\n7\\n\", \"110100110\\n0\\n\", \"10000000000000000000000000000000000000000000\\n2\\n\", \"100000000000000000000100000000000010100100001001000010011101010\\n3\\n\", \"101010110000\\n3\\n\", \"11010110000\\n3\\n\", \"100\\n6\\n\", \"1... | The Travelling Salesman spends a lot of time travelling so he tends to get bored. To pass time, he likes to perform operations on numbers. One such operation is to take a positive integer x and reduce it to the number of bits set to 1 in the binary representation of x. For example for number 13 it's true that 13_10 = 1... | 0 |
{"tests": "{\"inputs\": [\"3 1 1 2 0 0\\n3\\n1 1\\n2 1\\n2 3\\n\", \"5 0 4 2 2 0\\n5\\n5 2\\n3 0\\n5 5\\n3 5\\n3 3\\n\", \"107 50 116 37 104 118\\n12\\n16 78\\n95 113\\n112 84\\n5 88\\n54 85\\n112 80\\n19 98\\n25 14\\n48 76\\n95 70\\n77 94\\n38 32\\n\", \"446799 395535 281981 494983 755701 57488\\n20\\n770380 454998\\n... | It was recycling day in Kekoland. To celebrate it Adil and Bera went to Central Perk where they can take bottles from the ground and put them into a recycling bin.
We can think Central Perk as coordinate plane. There are n bottles on the ground, the i-th bottle is located at position (x_{i}, y_{i}). Both Adil and Bera... | 0 |
{"tests": "{\"inputs\": [\"3 1 1\\n\", \"5 1 2\\n\", \"1000 1 1000\\n\", \"999999 1 1\\n\", \"1 2 179350\\n\", \"2 1 1\\n\", \"2 2 1\\n\", \"100000 1 10\\n\", \"1 999999 999999\\n\", \"100 220905 13\\n\", \"200000 2 4\\n\", \"1234 5 777\\n\", \"12345 3 50\\n\", \"10 12347 98765\\n\", \"1 999599 123123\\n\", \"1 8888 99... | The well-known Fibonacci sequence $F_0, F_1, F_2,\ldots $ is defined as follows: $F_0 = 0, F_1 = 1$. For each $i \geq 2$: $F_i = F_{i - 1} + F_{i - 2}$.
Given an increasing arithmetic sequence of positive integers with $n$ elements: $(a, a + d, a + 2\cdot d,\ldots, a + (n - 1)\cdot d)$.
You need to find another i... | 0 |
{"tests": "{\"inputs\": [\"1\\n-149.154.167.99\\n\", \"4\\n-149.154.167.99\\n+149.154.167.100/30\\n+149.154.167.128/25\\n-149.154.167.120/29\\n\", \"5\\n-127.0.0.4/31\\n+127.0.0.8\\n+127.0.0.0/30\\n-195.82.146.208/29\\n-127.0.0.6/31\\n\", \"2\\n+127.0.0.1/32\\n-127.0.0.1\\n\", \"1\\n-0.0.0.0/32\\n\", \"1\\n-0.0.0.10\\n... | Berkomnadzor — Federal Service for Supervision of Communications, Information Technology and Mass Media — is a Berland federal executive body that protects ordinary residents of Berland from the threats of modern internet.
Berkomnadzor maintains a list of prohibited IPv4 subnets (blacklist) and a list of allowed IPv4 ... | 0 |
{"tests": "{\"inputs\": [\"3 5\\n2 2 2 3 2\\n0 0 0 1 0\\n1 1 1 2 1\\n\", \"3 3\\n0 0 0\\n0 1 0\\n0 0 0\\n\", \"3 3\\n1 1 1\\n1 1 1\\n1 1 1\\n\", \"3 5\\n2 4 2 2 3\\n0 2 0 0 1\\n1 3 1 1 2\\n\", \"3 5\\n0 0 0 0 0\\n0 0 0 0 0\\n0 0 0 0 1\\n\", \"1 1\\n0\\n\", \"10 10\\n1 1 1 1 1 1 1 1 1 1\\n1 1 1 1 1 1 1 1 1 1\\n1 1 1 1 1... | On the way to school, Karen became fixated on the puzzle game on her phone! [Image]
The game is played as follows. In each level, you have a grid with n rows and m columns. Each cell originally contains the number 0.
One move consists of choosing one row or column, and adding 1 to all of the cells in that row or col... | 0 |
{"tests": "{\"inputs\": [\"4 2\\n1 3\\n1 4\\n\", \"7 8\\n1 6\\n2 6\\n3 5\\n3 6\\n4 3\\n5 1\\n5 2\\n5 3\\n\", \"2 2\\n1 2\\n2 1\\n\", \"1000000000 9\\n1 2\\n3 1\\n3 2\\n999999998 999999999\\n999999998 1000000000\\n999999999 999999999\\n999999999 999999997\\n1000000000 999999996\\n1000000000 999999997\\n\", \"1000000000 ... | Iahub got lost in a very big desert. The desert can be represented as a n × n square matrix, where each cell is a zone of the desert. The cell (i, j) represents the cell at row i and column j (1 ≤ i, j ≤ n). Iahub can go from one cell (i, j) only down or right, that is to cells (i + 1, j) or (i, j + 1).
Also, there a... | 0 |
{"tests": "{\"inputs\": [\"5\\n1 2 2 4 3\\n\", \"3\\n4 1 1\\n\", \"4\\n0 3 0 4\\n\", \"5\\n4 4 3 3 1\\n\", \"5\\n4 3 4 2 4\\n\", \"10\\n2 1 2 3 4 1 3 4 4 4\\n\", \"10\\n2 3 3 1 3 1 3 2 2 4\\n\", \"120\\n1 1 1 1 1 1 1 4 4 1 1 1 1 1 1 1 2 1 1 1 1 1 2 1 1 1 4 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 3 1 4 1 1 4 1 1 1 1 3 1 1 1 1 1 1... | A team of students from the city S is sent to the All-Berland Olympiad in Informatics. Traditionally, they go on the train. All students have bought tickets in one carriage, consisting of n compartments (each compartment has exactly four people). We know that if one compartment contain one or two students, then they ge... | 0 |
{"tests": "{\"inputs\": [\"4\\n2 3 1 4\\n\", \"4\\n4 4 4 4\\n\", \"4\\n2 1 4 3\\n\", \"5\\n2 4 3 1 2\\n\", \"5\\n2 2 4 4 5\\n\", \"5\\n2 4 5 4 2\\n\", \"10\\n8 10 4 3 2 1 9 6 5 7\\n\", \"10\\n10 1 4 8 5 2 3 7 9 6\\n\", \"10\\n6 4 3 9 5 2 1 10 8 7\\n\", \"100\\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23... | As you have noticed, there are lovely girls in Arpa’s land.
People in Arpa's land are numbered from 1 to n. Everyone has exactly one crush, i-th person's crush is person with the number crush_{i}. [Image]
Someday Arpa shouted Owf loudly from the top of the palace and a funny game started in Arpa's land. The rules ar... | 0.375 |
{"tests": "{\"inputs\": [\"1\\n\", \"2\\n\", \"8\\n\", \"52\\n\", \"53\\n\", \"3\\n\", \"4\\n\", \"5\\n\", \"6\\n\", \"7\\n\", \"9\\n\", \"10\\n\", \"11\\n\", \"12\\n\", \"13\\n\", \"14\\n\", \"15\\n\", \"16\\n\", \"17\\n\", \"18\\n\", \"19\\n\", \"20\\n\", \"21\\n\", \"22\\n\", \"23\\n\", \"24\\n\", \"25\\n\", \"26\\n... | Vasya and Petya wrote down all integers from 1 to n to play the "powers" game (n can be quite large; however, Vasya and Petya are not confused by this fact).
Players choose numbers in turn (Vasya chooses first). If some number x is chosen at the current turn, it is forbidden to choose x or all of its other positive in... | 0 |
{"tests": "{\"inputs\": [\"4\\nA\\nB\\nB\\nA\\n\", \"1000\\nB\\nB\\nB\\nB\\n\", \"2\\nB\\nA\\nA\\nA\\n\", \"2\\nA\\nB\\nA\\nA\\n\", \"2\\nB\\nB\\nA\\nA\\n\", \"2\\nA\\nA\\nB\\nA\\n\", \"2\\nB\\nA\\nB\\nA\\n\", \"2\\nA\\nB\\nB\\nA\\n\", \"2\\nB\\nB\\nB\\nA\\n\", \"2\\nA\\nA\\nA\\nB\\n\", \"2\\nB\\nA\\nA\\nB\\n\", \"2\\n... | Given are an integer N and four characters c_{\mathrm{AA}}, c_{\mathrm{AB}}, c_{\mathrm{BA}}, and c_{\mathrm{BB}}.
Here, it is guaranteed that each of those four characters is A or B.
Snuke has a string s, which is initially AB.
Let |s| denote the length of s.
Snuke can do the four kinds of operations below zero or mor... | 0 |
{"tests": "{\"inputs\": [\"5\\n4 2\\n1 1\\n0 1\\n2 3\\n\", \"1023\\n1 2\\n1 0\\n1 2\\n1 1\\n\", \"1023\\n1 2\\n1 2\\n1 2\\n1 2\\n\", \"2\\n0 1\\n1 0\\n1 0\\n0 1\\n\", \"17\\n15 12\\n15 12\\n12 14\\n1 11\\n\", \"29\\n4 0\\n1 1\\n25 20\\n16 0\\n\", \"91\\n9 64\\n75 32\\n60 81\\n35 46\\n\", \"91\\n38 74\\n66 10\\n40 76\\n... | Mike has a frog and a flower. His frog is named Xaniar and his flower is named Abol. Initially(at time 0), height of Xaniar is h_1 and height of Abol is h_2. Each second, Mike waters Abol and Xaniar.
[Image]
So, if height of Xaniar is h_1 and height of Abol is h_2, after one second height of Xaniar will become $(x_... | 0 |
{"tests": "{\"inputs\": [\"2\\n4 5\\n\", \"9\\n1 2 3 4 5 6 7 8 9\\n\", \"2\\n1 10000000\\n\", \"1\\n1\\n\", \"2\\n1 2\\n\", \"2\\n2 3\\n\", \"100\\n1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 51 53 55 57 59 61 63 65 67 69 71 73 75 77 79 81 83 85 87 89 91 93 95 97 99 101 103 105 107 109 111 113... | There are infinitely many cards, numbered 1, 2, 3, ...
Initially, Cards x_1, x_2, ..., x_N are face up, and the others are face down.
Snuke can perform the following operation repeatedly:
- Select a prime p greater than or equal to 3. Then, select p consecutive cards and flip all of them.
Snuke's objective is to have ... | 0 |
{"tests": "{\"inputs\": [\"2 2 2 1\\n\", \"1 2 3 4\\n\", \"2 2 2 3\\n\", \"3436 3436 46563 46564\\n\", \"15039 15038 34961 34961\\n\", \"26 25 24 26\\n\", \"67 66 33 34\\n\", \"145 145 105 107\\n\", \"211 209 91 91\\n\", \"119 146 31 2\\n\", \"197 280 249 164\\n\", \"1 0 0 1\\n\", \"0 0 1 2\\n\", \"1 0 0 0\\n\", \"104 ... | An integer sequence is called beautiful if the difference between any two consecutive numbers is equal to $1$. More formally, a sequence $s_1, s_2, \ldots, s_{n}$ is beautiful if $|s_i - s_{i+1}| = 1$ for all $1 \leq i \leq n - 1$.
Trans has $a$ numbers $0$, $b$ numbers $1$, $c$ numbers $2$ and $d$ numbers $3$. He wan... | 0 |
{"tests": "{\"inputs\": [\"1 1 1 8\\n\", \"4 2 2 6\\n\", \"3 7 4 6\\n\", \"4 5 1 1\\n\", \"12 12 1 1000\\n\", \"12 1 1000 1000\\n\", \"3 4 701 703\\n\", \"12 12 13 1000000000\\n\", \"3 4 999999999 1000000000\\n\", \"5 6 1000000000 1000000000\\n\", \"1 1 1 1\\n\", \"12 1 100000011 100000024\\n\", \"10 12 220000011 22000... | Sometimes Mister B has free evenings when he doesn't know what to do. Fortunately, Mister B found a new game, where the player can play against aliens.
All characters in this game are lowercase English letters. There are two players: Mister B and his competitor.
Initially the players have a string s consisting of the... | 0 |
{"tests": "{\"inputs\": [\"1\\n\", \"2\\n\", \"123\\n\", \"36018\\n\", \"1000\\n\", \"450002\\n\", \"450010\\n\", \"450015\\n\", \"450020\\n\", \"450030\\n\", \"91304885\\n\", \"7803372\\n\", \"89317875\\n\", \"1060874\\n\", \"78876118\\n\", \"18434582\\n\", \"15764866\\n\", \"79528725\\n\", \"52556425\\n\", \"86801054... | For a positive integer n, let us define f(n) as the number of digits in base 10.
You are given an integer S.
Count the number of the pairs of positive integers (l, r) (l \leq r) such that f(l) + f(l + 1) + ... + f(r) = S, and find the count modulo 10^9 + 7.
-----Constraints-----
- 1 \leq S \leq 10^8
-----Input-----
... | 0 |
{"tests": "{\"inputs\": [\"4\\n3 6 28 9\\n\", \"5\\n5 12 9 16 48\\n\", \"4\\n1 2 4 8\\n\", \"1\\n1000000000000000000\\n\", \"4\\n70369817919488 281474976710657 70368744177665 281476050452480\\n\", \"5\\n292733975779082240 18014398509482240 306244774661193728 4504699138998272 1099511628032\\n\", \"30\\n550292684800 2149... | You are given $n$ integer numbers $a_1, a_2, \dots, a_n$. Consider graph on $n$ nodes, in which nodes $i$, $j$ ($i\neq j$) are connected if and only if, $a_i$ AND $a_j\neq 0$, where AND denotes the bitwise AND operation.
Find the length of the shortest cycle in this graph or determine that it doesn't have cycles at al... | 0.375 |
{"tests": "{\"inputs\": [\"5 2 2\\n1 3 4 5 2\\n5 3 2 1 4\\n\", \"4 2 2\\n10 8 8 3\\n10 7 9 4\\n\", \"5 3 1\\n5 2 5 1 7\\n6 3 1 6 3\\n\", \"2 1 1\\n100 101\\n1 100\\n\", \"4 1 1\\n100 100 1 50\\n100 100 50 1\\n\", \"2 1 1\\n3 2\\n3 2\\n\", \"2 1 1\\n9 6\\n3 10\\n\", \"2 1 1\\n1 17\\n5 20\\n\", \"3 1 1\\n5 4 2\\n1 5 2\\n... | There are n students at Berland State University. Every student has two skills, each measured as a number: a_{i} — the programming skill and b_{i} — the sports skill.
It is announced that an Olympiad in programming and sports will be held soon. That's why Berland State University should choose two teams: one to take p... | 0 |
{"tests": "{\"inputs\": [\"2 1\\n1 2\\n\", \"4 3\\n1 2\\n1 3\\n1 4\\n\", \"4 4\\n1 2\\n1 3\\n1 4\\n3 4\\n\", \"1 0\\n\", \"8 28\\n3 2\\n4 2\\n7 4\\n6 3\\n3 7\\n8 1\\n3 4\\n5 1\\n6 5\\n5 3\\n7 1\\n5 8\\n5 4\\n6 1\\n6 4\\n2 1\\n4 1\\n8 2\\n7 2\\n6 8\\n8 4\\n6 7\\n3 1\\n7 8\\n3 8\\n5 7\\n5 2\\n6 2\\n\", \"8 28\\n3 2\\n4 2... | One day student Vasya was sitting on a lecture and mentioned a string s_1s_2... s_{n}, consisting of letters "a", "b" and "c" that was written on his desk. As the lecture was boring, Vasya decided to complete the picture by composing a graph G with the following properties: G has exactly n vertices, numbered from 1 t... | 0 |
{"tests": "{\"inputs\": [\"0 1 1\\n1 0 1\\n1 1 0\\n3\\n\", \"0 2 2\\n1 0 100\\n1 2 0\\n3\\n\", \"0 2 1\\n1 0 100\\n1 2 0\\n5\\n\", \"0 5835 1487\\n6637 0 9543\\n6961 6820 0\\n7\\n\", \"0 3287 5433\\n6796 0 5787\\n1445 6158 0\\n26\\n\", \"0 4449 3122\\n6816 0 8986\\n1048 1468 0\\n4\\n\", \"0 913 8129\\n8352 0 4408\\n907... | The Tower of Hanoi is a well-known mathematical puzzle. It consists of three rods, and a number of disks of different sizes which can slide onto any rod. The puzzle starts with the disks in a neat stack in ascending order of size on one rod, the smallest at the top, thus making a conical shape.
The objective of the pu... | 0 |
{"tests": "{\"inputs\": [\"11 11 5\\n\", \"11 2 3\\n\", \"1 5 9\\n\", \"2 3 3\\n\", \"1 1000000000 1000000000\\n\", \"2 3 5\\n\", \"1000000000 1000000000 1000000000\\n\", \"1 0 1\\n\", \"101 99 97\\n\", \"1000000000 0 1\\n\", \"137 137 136\\n\", \"255 255 255\\n\", \"1 0 1000000000\\n\", \"123 456 789\\n\", \"666666 66... | Misha and Vanya have played several table tennis sets. Each set consists of several serves, each serve is won by one of the players, he receives one point and the loser receives nothing. Once one of the players scores exactly k points, the score is reset and a new set begins.
Across all the sets Misha scored a points ... | 0 |
{"tests": "{\"inputs\": [\"3 2 6\\n\", \"4 2 20\\n\", \"8 10 9\\n\", \"43 50 140\\n\", \"251 79 76\\n\", \"892 67 1000\\n\", \"1000 1000 1000\\n\", \"87 4 1000\\n\", \"1 629 384378949109878497\\n\", \"2124 6621 12695\\n\", \"27548 68747 111\\n\", \"74974 46016 1000000000\\n\", \"223 844 704\\n\", \"1 558 743\\n\", \"43... | Julia is going to cook a chicken in the kitchen of her dormitory. To save energy, the stove in the kitchen automatically turns off after k minutes after turning on.
During cooking, Julia goes to the kitchen every d minutes and turns on the stove if it is turned off. While the cooker is turned off, it stays warm. The s... | 0 |
{"tests": "{\"inputs\": [\"2 2\\n..\\n..\\n\", \"4 4\\n....\\n#.#.\\n....\\n.#..\\n\", \"3 4\\n....\\n.##.\\n....\\n\", \"1 5\\n.....\\n\", \"5 1\\n.\\n.\\n.\\n.\\n.\\n\", \"1 3\\n.#.\\n\", \"6 1\\n.\\n.\\n#\\n.\\n.\\n.\\n\", \"5 2\\n..\\n..\\n..\\n..\\n#.\\n\", \"4 3\\n..#\\n...\\n..#\\n#..\\n\", \"5 4\\n...#\\n....\\... | All of us love treasures, right? That's why young Vasya is heading for a Treasure Island.
Treasure Island may be represented as a rectangular table $n \times m$ which is surrounded by the ocean. Let us number rows of the field with consecutive integers from $1$ to $n$ from top to bottom and columns with consecutive in... | 0.375 |
{"tests": "{\"inputs\": [\"6 1\\n10.245\\n\", \"6 2\\n10.245\\n\", \"3 100\\n9.2\\n\", \"12 5\\n872.04488525\\n\", \"35 8\\n984227318.2031144444444444494637612\\n\", \"320 142\\n2704701300865535.43222331223343411413001111322010242013132301034414420112430314444444444444444444444444444444444444444444444444444444444444444... | Efim just received his grade for the last test. He studies in a special school and his grade can be equal to any positive decimal fraction. First he got disappointed, as he expected a way more pleasant result. Then, he developed a tricky plan. Each second, he can ask his teacher to round the grade at any place after th... | 0 |
{"tests": "{\"inputs\": [\"1 2 3 4\\n\", \"1 2 2 1\\n\", \"10 7 28 21\\n\", \"0 0 0 0\\n\", \"49995000 11667 4308334 93096\\n\", \"499928010 601314341 398636540 499991253\\n\", \"0 2548 1752 650\\n\", \"0 0 0 45\\n\", \"105 2 598 780\\n\", \"1 0 0 0\\n\", \"0 0 0 1\\n\", \"0 0 1 0\\n\", \"0 1 0 0\\n\", \"487577 9219238... | For each string s consisting of characters '0' and '1' one can define four integers a_00, a_01, a_10 and a_11, where a_{xy} is the number of subsequences of length 2 of the string s equal to the sequence {x, y}.
In these problem you are given four integers a_00, a_01, a_10, a_11 and have to find any non-empty string ... | 0 |
{"tests": "{\"inputs\": [\"7\\n*..P*P*\\n\", \"10\\n.**PP.*P.*\\n\", \"19\\n**P.*..*..P..*.*P**\\n\", \"12\\nP**.*P*P*P**\\n\", \"17\\n.*P*P**P**.**P...\\n\", \"58\\n..P.P*.P*.P...PPP...P*....*..*.**......*P.*P.....**P...*P*\\n\", \"10\\n..P*.P.*.*\\n\", \"10\\n***.*.*..P\\n\", \"15\\nP***..PPP..P*.P\\n\", \"15\\n*.*..... | A game field is a strip of 1 × n square cells. In some cells there are Packmen, in some cells — asterisks, other cells are empty.
Packman can move to neighboring cell in 1 time unit. If there is an asterisk in the target cell then Packman eats it. Packman doesn't spend any time to eat an asterisk.
In the initial mome... | 0 |
{"tests": "{\"inputs\": [\"1\\n\", \"2\\n\", \"3\\n\", \"4\\n\", \"0\\n\", \"30426905\\n\", \"38450759\\n\", \"743404\\n\", \"3766137\\n\", \"19863843\\n\", \"24562258\\n\", \"24483528\\n\", \"25329968\\n\", \"31975828\\n\", \"2346673\\n\", \"17082858\\n\", \"22578061\\n\", \"17464436\\n\", \"18855321\\n\", \"614109\\n... | Imagine you have an infinite 2D plane with Cartesian coordinate system. Some of the integral points are blocked, and others are not. Two integral points A and B on the plane are 4-connected if and only if: the Euclidean distance between A and B is one unit and neither A nor B is blocked; or there is some integral poi... | 0 |
{"tests": "{\"inputs\": [\"9 9 5 5 2 1\\n\", \"100 100 52 50 46 56\\n\", \"100 100 16 60 42 75\\n\", \"100 100 28 22 47 50\\n\", \"100 100 44 36 96 21\\n\", \"100 100 56 46 1 47\\n\", \"100 100 20 53 6 22\\n\", \"100 100 32 63 2 41\\n\", \"100 100 48 73 63 16\\n\", \"100 100 13 59 14 20\\n\", \"36830763 28058366 308273... | You are given a rectangle grid. That grid's size is n × m. Let's denote the coordinate system on the grid. So, each point on the grid will have coordinates — a pair of integers (x, y) (0 ≤ x ≤ n, 0 ≤ y ≤ m).
Your task is to find a maximum sub-rectangle on the grid (x_1, y_1, x_2, y_2) so that it contains the given poi... | 0 |
{"tests": "{\"inputs\": [\"5 1 2\\n9 7 11 15 5\\n\", \"2 100000 569\\n605 986\\n\", \"10 10 98\\n1 58 62 71 55 4 20 17 25 29\\n\", \"100 100 96\\n11 79 47 73 77 66 50 32 26 38 8 58 45 86 35 49 63 13 35 61 52 44 16 80 32 18 8 4 49 90 78 83 72 3 86 71 96 93 97 60 43 74 58 61 21 96 43 92 31 23 64 60 14 77 27 45 71 27 49 4... | Jon Snow now has to fight with White Walkers. He has n rangers, each of which has his own strength. Also Jon Snow has his favourite number x. Each ranger can fight with a white walker only if the strength of the white walker equals his strength. He however thinks that his rangers are weak and need to improve. Jon now t... | 0.125 |
{"tests": "{\"inputs\": [\"1 4\\n\", \"2 2\\n\", \"3 2\\n\", \"2 1\\n\", \"5 3\\n\", \"5 2\\n\", \"8 5\\n\", \"97 101\\n\", \"1 3\\n\", \"1000000000000000000 999999999999999999\\n\", \"55 89\\n\", \"610 987\\n\", \"4181 6765\\n\", \"46368 75025\\n\", \"832040 514229\\n\", \"5702887 9227465\\n\", \"701408733 433494437\\... | Alice and Bob decided to eat some fruit. In the kitchen they found a large bag of oranges and apples. Alice immediately took an orange for herself, Bob took an apple. To make the process of sharing the remaining fruit more fun, the friends decided to play a game. They put multiple cards and on each one they wrote a let... | 0 |
{"tests": "{\"inputs\": [\"1 1\\n\", \"3 2\\n\", \"199 200\\n\", \"1 1000000000000000000\\n\", \"3 1\\n\", \"21 8\\n\", \"18 55\\n\", \"1 2\\n\", \"2 1\\n\", \"1 3\\n\", \"2 3\\n\", \"1 4\\n\", \"5 2\\n\", \"2 5\\n\", \"4 5\\n\", \"3 5\\n\", \"13 4\\n\", \"21 17\\n\", \"5 8\\n\", \"13 21\\n\", \"74 99\\n\", \"2377 1055... | Mad scientist Mike is building a time machine in his spare time. To finish the work, he needs a resistor with a certain resistance value.
However, all Mike has is lots of identical resistors with unit resistance R_0 = 1. Elements with other resistance can be constructed from these resistors. In this problem, we will c... | 0.5 |
{"tests": "{\"inputs\": [\"6\\n2 0 3 0 1 1\\n\", \"1\\n0\\n\", \"6\\n3 2 2 2 1 1\\n\", \"3\\n3 2 1\\n\", \"4\\n2 2 1 1\\n\", \"4\\n3 3 2 1\\n\", \"4\\n3 3 3 1\\n\", \"4\\n1 2 3 1\\n\", \"4\\n1 1 3 1\\n\", \"4\\n1 3 1 1\\n\", \"4\\n2 3 1 1\\n\", \"1\\n2\\n\", \"1\\n3\\n\", \"1\\n1\\n\", \"4\\n3 2 3 1\\n\", \"6\\n0 0 1 3... | To improve the boomerang throwing skills of the animals, Zookeeper has set up an $n \times n$ grid with some targets, where each row and each column has at most $2$ targets each. The rows are numbered from $1$ to $n$ from top to bottom, and the columns are numbered from $1$ to $n$ from left to right.
For each column... | 0 |
{"tests": "{\"inputs\": [\"0 0 5 5\\n3 2\\n-1 -1\\n-1 0\\n\", \"0 0 0 1000\\n100 1000\\n-50 0\\n50 0\\n\", \"0 0 0 1000\\n100 5\\n0 -50\\n0 50\\n\", \"0 1000 0 0\\n50 10\\n-49 0\\n49 0\\n\", \"0 1000 0 0\\n50 10\\n0 -48\\n0 -49\\n\", \"0 0 0 -5000\\n100 20\\n-50 0\\n50 0\\n\", \"0 0 0 -350\\n55 5\\n0 -50\\n0 50\\n\", \... | A team of furry rescue rangers was sitting idle in their hollow tree when suddenly they received a signal of distress. In a few moments they were ready, and the dirigible of the rescue chipmunks hit the road.
We assume that the action takes place on a Cartesian plane. The headquarters of the rescuers is located at poi... | 0 |
{"tests": "{\"inputs\": [\"1 1\\n\", \"3 2\\n\", \"5 3\\n\", \"12 4\\n\", \"20 5\\n\", \"522 4575\\n\", \"1426 4445\\n\", \"81 3772\\n\", \"629 3447\\n\", \"2202 3497\\n\", \"2775 4325\\n\", \"3982 4784\\n\", \"2156 3417\\n\", \"902 1932\\n\", \"728 3537\\n\", \"739 3857\\n\", \"1918 4211\\n\", \"3506 4679\\n\", \"1000... | You have a team of N people. For a particular task, you can pick any non-empty subset of people. The cost of having x people for the task is x^{k}.
Output the sum of costs over all non-empty subsets of people.
-----Input-----
Only line of input contains two integers N (1 ≤ N ≤ 10^9) representing total number of pe... | 0 |
{"tests": "{\"inputs\": [\"3 2\\n\", \"4 4\\n\", \"7 3\\n\", \"31 8\\n\", \"1 1\\n\", \"10 2\\n\", \"33 22\\n\", \"50 50\\n\", \"1 2\\n\", \"1 3\\n\", \"2 1\\n\", \"2 2\\n\", \"2 3\\n\", \"3 1\\n\", \"3 3\\n\", \"3 4\\n\", \"4 1\\n\", \"4 2\\n\", \"4 3\\n\", \"4 5\\n\", \"5 1\\n\", \"5 2\\n\", \"5 3\\n\", \"5 4\\n\", \... | A never-ending, fast-changing and dream-like world unfolds, as the secret door opens.
A world is an unordered graph G, in whose vertex set V(G) there are two special vertices s(G) and t(G). An initial world has vertex set {s(G), t(G)} and an edge between them.
A total of n changes took place in an initial world. In e... | 0 |
{"tests": "{\"inputs\": [\"3 4 2\\n#..#\\n..#.\\n#...\\n\", \"5 4 5\\n#...\\n#.#.\\n.#..\\n...#\\n.#.#\\n\", \"3 3 2\\n...\\n.#.\\n...\\n\", \"3 3 2\\n#.#\\n...\\n#.#\\n\", \"7 7 18\\n#.....#\\n..#.#..\\n.#...#.\\n...#...\\n.#...#.\\n..#.#..\\n#.....#\\n\", \"5 9 19\\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\": [\"5 3 2\\n\", \"7 7 1\\n\", \"300000 300000 300000\\n\", \"100000 1 100000\\n\", \"12475 917 6727\\n\", \"143766 3908 5617\\n\", \"4215 367 89\\n\", \"267187 267187 1\\n\", \"2 2 1\\n\", \"2 1 2\\n\", \"130620 2 67832\\n\", \"161101 90817 3\\n\", \"273409 100000 100000\\n\", \"280218 38759 8901... | Determine if there exists a sequence obtained by permuting 1,2,...,N that satisfies the following conditions:
- The length of its longest increasing subsequence is A.
- The length of its longest decreasing subsequence is B.
If it exists, construct one such sequence.
-----Notes-----
A subsequence of a sequence P is a... | 0 |
{"tests": "{\"inputs\": [\"6\\n3 6 9 18 36 108\\n\", \"2\\n7 17\\n\", \"9\\n4 8 10 12 15 18 33 44 81\\n\", \"22\\n2 4 8 16 32 96 288 576 1728 3456 10368 20736 62208 186624 559872 1119744 3359232 10077696 30233088 90699264 181398528 544195584\\n\", \"14\\n122501 245002 367503 735006 1225010 4287535 8575070 21437675 4287... | Dima the hamster enjoys nibbling different things: cages, sticks, bad problemsetters and even trees!
Recently he found a binary search tree and instinctively nibbled all of its edges, hence messing up the vertices. Dima knows that if Andrew, who has been thoroughly assembling the tree for a long time, comes home and s... | 0 |
{"tests": "{\"inputs\": [\"4 3\\n3 1 4 2\\n\", \"1 1000\\n42\\n\", \"31 3767\\n16 192 152 78 224 202 186 52 118 19 13 38 199 196 35 295 100 64 205 37 166 124 169 214 66 243 134 192 253 270 92\\n\", \"15 12226\\n18 125 213 221 124 147 154 182 134 184 51 49 267 88 251\\n\", \"81 10683\\n3 52 265 294 213 242 185 151 27 16... | You are given an array of positive integers a_1, a_2, ..., a_{n} × T of length n × T. We know that for any i > n it is true that a_{i} = a_{i} - n. Find the length of the longest non-decreasing sequence of the given array.
-----Input-----
The first line contains two space-separated integers: n, T (1 ≤ n ≤ 100, 1 ≤ T... | 0 |
{"tests": "{\"inputs\": [\"3\\n1 2 3\\n\", \"3\\n2 3 1\\n\", \"3\\n3 2 1\\n\", \"2\\n1 2\\n\", \"2\\n2 1\\n\", \"10\\n10 1 9 2 8 3 7 4 6 5\\n\", \"108\\n1 102 33 99 6 83 4 20 61 100 76 71 44 9 24 87 57 2 81 82 90 85 12 30 66 53 47 36 43 29 31 64 96 84 77 23 93 78 58 68 42 55 13 70 62 19 92 14 10 65 63 75 91 48 11 105 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.5 |
{"tests": "{\"inputs\": [\"0 0 0\\n0 0 1\\n0 0 1\\n0 0 1\\n0 1 1\\n0 1 1\\n0 1 1\\n1 1 1\\n\", \"0 0 0\\n0 0 0\\n0 0 0\\n0 0 0\\n1 1 1\\n1 1 1\\n1 1 1\\n1 1 1\\n\", \"0 0 0\\n1 0 0\\n0 1 0\\n1 1 0\\n0 0 1\\n1 0 1\\n0 1 1\\n1 1 1\\n\", \"6 -2 -2\\n-5 1 -6\\n6 -6 7\\n6 3 4\\n9 -7 8\\n-9 -2 -6\\n-9 1 6\\n-9 -1 0\\n\", \"-... | Peter had a cube with non-zero length of a side. He put the cube into three-dimensional space in such a way that its vertices lay at integer points (it is possible that the cube's sides are not parallel to the coordinate axes). Then he took a piece of paper and wrote down eight lines, each containing three integers — c... | 0 |
{"tests": "{\"inputs\": [\"4\\n2 3 6 7\\n\", \"5\\n6 15 35 77 22\\n\", \"5\\n6 10 15 1000 75\\n\", \"3\\n8 1 6\\n\", \"4\\n84 33 80 6\\n\", \"5\\n1116 1968 609 9549 7067\\n\", \"3\\n130070951 898378379 47324156\\n\", \"6\\n10 7 9 8 3 3\\n\", \"5\\n89 20 86 81 62\\n\", \"9\\n3310 970 6688 5121 1365 3683 2311 198 5135\\n... | You are given an array of $n$ integers. You need to split all integers into two groups so that the GCD of all integers in the first group is equal to one and the GCD of all integers in the second group is equal to one.
The GCD of a group of integers is the largest non-negative integer that divides all the integers in ... | 0 |
{"tests": "{\"inputs\": [\"12\\n3 1 4 1 5 9 2 6 5 3 5 8\\n\", \"5\\n1 1 1 1 1\\n\", \"1\\n1000000000\\n\", \"1\\n1\\n\", \"2\\n1 2\\n\", \"2\\n1000000000 1000000000\\n\", \"3\\n1 2 3\\n\", \"3\\n1 2 2\\n\", \"3\\n1 1 1\\n\", \"4\\n1 2 3 4\\n\", \"4\\n1 2 3 3\\n\", \"4\\n1 1 2 2\\n\", \"4\\n1 1 1 4\\n\", \"5\\n5 3 5 6 3... | You are given $n$ integers. You need to choose a subset and put the chosen numbers in a beautiful rectangle (rectangular matrix). Each chosen number should occupy one of its rectangle cells, each cell must be filled with exactly one chosen number. Some of the $n$ numbers may not be chosen.
A rectangle (rectangular mat... | 0 |
{"tests": "{\"inputs\": [\"87654\\n30\\n\", \"87654\\n138\\n\", \"87654\\n45678\\n\", \"31415926535\\n1\\n\", \"1\\n31415926535\\n\", \"100000000000\\n1\\n\", \"100000000000\\n100000000000\\n\", \"100000000000\\n2\\n\", \"100000000000\\n3\\n\", \"100000000000\\n50000000000\\n\", \"100000000000\\n50000000001\\n\", \"100... | For integers b (b \geq 2) and n (n \geq 1), let the function f(b,n) be defined as follows:
- f(b,n) = n, when n < b
- f(b,n) = f(b,\,{\rm floor}(n / b)) + (n \ {\rm mod} \ b), when n \geq b
Here, {\rm floor}(n / b) denotes the largest integer not exceeding n / b,
and n \ {\rm mod} \ b denotes the remainder of n divid... | 0 |
{"tests": "{\"inputs\": [\"2 1\\n0 1\\n2 1\\n\", \"1 2\\n1\\n1\\n\", \"3 3\\n0 1 1\\n4 3 5\\n\", \"5 5\\n0 1 0 0 1\\n9 8 3 8 8\\n\", \"10 10\\n0 1 0 0 1 1 1 1 1 1\\n12 18 6 18 7 2 9 18 1 9\\n\", \"20 20\\n1 1 1 1 0 1 1 1 0 1 0 1 0 0 1 0 1 1 0 1\\n1 13 7 11 17 15 19 18 14 11 15 1 12 4 5 16 14 11 18 9\\n\", \"30 50\\n0 0... | The only difference between easy and hard versions is constraints.
Nauuo is a girl who loves random picture websites.
One day she made a random picture website by herself which includes $n$ pictures.
When Nauuo visits the website, she sees exactly one picture. The website does not display each picture with equal pro... | 0 |
{"tests": "{\"inputs\": [\"AJKEQSLOBSROFGZ\\nOVGURWZLWVLUXTH\\nOZ\\n\", \"AA\\nA\\nA\\n\", \"PWBJTZPQHA\\nZJMKLWSROQ\\nUQ\\n\", \"QNHRPFYMAAPJDUHBAEXNEEZSTMYHVGQPYKNMVKMBVSVLIYGUVMJHEFLJEPIWFHSLISTGOKRXNMSCXYKMAXBPKCOCNTIRPCUEPHXM\\nRRFCZUGFDRKKMQTOETNELXMEWGOCDHFKIXOPVHHEWTCDNXVFKFKTKNWKEIKTCMHMHDNCLLVQSGKHBCDDYVVVQIR... | In mathematics, a subsequence is a sequence that can be derived from another sequence by deleting some elements without changing the order of the remaining elements. For example, the sequence BDF is a subsequence of ABCDEF. A substring of a string is a continuous subsequence of the string. For example, BCD is a substri... | 0 |
{"tests": "{\"inputs\": [\"-++-\\n\", \"+-\\n\", \"++\\n\", \"-\\n\", \"+-+-\\n\", \"-+-\\n\", \"-++-+--+\\n\", \"+\\n\", \"-+\\n\", \"--\\n\", \"+++\\n\", \"--+\\n\", \"++--++\\n\", \"+-++-+\\n\", \"+-+--+\\n\", \"--++-+\\n\", \"-+-+--\\n\", \"+-+++-\\n\", \"-+-+-+\\n\", \"-++-+--++--+-++-\\n\", \"+-----+-++---+------... | Mad scientist Mike has just finished constructing a new device to search for extraterrestrial intelligence! He was in such a hurry to launch it for the first time that he plugged in the power wires without giving it a proper glance and started experimenting right away. After a while Mike observed that the wires ended u... | 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\", \"3 0 0\\n-1 1\\n0 3\\n1 1\\n\", \"3 -4 2\\n-3 2\\n5 -5\\n5 3\\n\", \"3 -84 8\\n-83 8\\n21 -62\\n3 53\\n\", \"6 -94 -51\\n-93 -51\\n48 -25\\n61 27\\n73 76\\n-10 87\\n-48 38\\n\", \"5 -94 52\\n-93 52\\n-78 -56\\n-54 -81\\n56... | 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\": [\"48\\n\", \"6\\n\", \"1\\n\", \"994\\n\", \"567000123\\n\", \"123830583943\\n\", \"3842529393411\\n\", \"999999993700000\\n\", \"2\\n\", \"7\\n\", \"8\\n\", \"9\\n\", \"112\\n\", \"113\\n\", \"114\\n\", \"265\\n\", \"995\\n\", \"200385\\n\", \"909383000\\n\", \"108000000057\\n\", \"38592592348... | Limak is a little polar bear. He plays by building towers from blocks. Every block is a cube with positive integer length of side. Limak has infinitely many blocks of each side length.
A block with side a has volume a^3. A tower consisting of blocks with sides a_1, a_2, ..., a_{k} has the total volume a_1^3 + a_2^3 + ... | 0 |
{"tests": "{\"inputs\": [\"2\\n)(\\n\", \"3\\n(()\\n\", \"2\\n()\\n\", \"10\\n)))))(((((\\n\", \"1\\n)\\n\", \"1\\n(\\n\", \"98\\n()()(((((((())))(((()))))(())(())()()(())())))))((()()()))()(((()))()()())((())(((()(((())))()))))\\n\", \"100\\n(()()((((())()()(()()())())))((((())(((()))()()()((()))(())))((()()(((()())))... | Petya's friends made him a birthday present — a bracket sequence. Petya was quite disappointed with his gift, because he dreamed of correct bracket sequence, yet he told his friends nothing about his dreams and decided to fix present himself.
To make everything right, Petya is going to move at most one bracket from i... | 0 |
{"tests": "{\"inputs\": [\"3\\n2 6 8\\n\", \"5\\n2 3 4 9 12\\n\", \"4\\n5 7 2 9\\n\", \"7\\n7 10 9 4 8 5 6\\n\", \"10\\n3 17 8 5 7 9 2 11 13 12\\n\", \"20\\n13 7 23 19 2 28 5 29 20 6 9 8 30 26 24 21 25 15 27 17\\n\", \"20\\n19 13 7 22 21 31 26 28 20 4 11 10 9 39 25 3 16 27 33 29\\n\", \"20\\n10 50 39 6 47 35 37 26 12 1... | SIHanatsuka - EMber SIHanatsuka - ATONEMENT
Back in time, the seven-year-old Nora used to play lots of games with her creation ROBO_Head-02, both to have fun and enhance his abilities.
One day, Nora's adoptive father, Phoenix Wyle, brought Nora $n$ boxes of toys. Before unpacking, Nora decided to make a fun game for ... | 0 |
{"tests": "{\"inputs\": [\"3\\n17 18\\n15 24\\n12 15\\n\", \"2\\n10 16\\n7 17\\n\", \"5\\n90 108\\n45 105\\n75 40\\n165 175\\n33 30\\n\", \"1\\n10 9\\n\", \"2\\n2 2\\n3 3\\n\", \"3\\n5 15\\n125 3\\n3 3\\n\", \"2\\n1999999973 1999999943\\n1999999973 1999999943\\n\", \"2\\n21 35\\n33 65\\n\", \"1\\n1000000007 998244353\\... | During the research on properties of the greatest common divisor (GCD) of a set of numbers, Ildar, a famous mathematician, introduced a brand new concept of the weakened common divisor (WCD) of a list of pairs of integers.
For a given list of pairs of integers $(a_1, b_1)$, $(a_2, b_2)$, ..., $(a_n, b_n)$ their WCD is... | 0.125 |
{"tests": "{\"inputs\": [\"2 1000000007\\n\", \"3 1000000009\\n\", \"50 111111113\\n\", \"3000 123456791\\n\", \"4 841234127\\n\", \"5 631912433\\n\", \"6 183839263\\n\", \"7 967326497\\n\", \"9 461901653\\n\", \"12 747607109\\n\", \"16 276468149\\n\", \"22 632333839\\n\", \"30 665143007\\n\", \"40 584739203\\n\", \"41... | In "Takahashi-ya", a ramen restaurant, basically they have one menu: "ramen", but N kinds of toppings are also offered. When a customer orders a bowl of ramen, for each kind of topping, he/she can choose whether to put it on top of his/her ramen or not. There is no limit on the number of toppings, and it is allowed to ... | 0 |
{"tests": "{\"inputs\": [\"3\\n0 2 0\\n3 0 1\\n\", \"3\\n0 2 0\\n1 0 3\\n\", \"11\\n0 0 0 5 0 0 0 4 0 0 11\\n9 2 6 0 8 1 7 0 3 0 10\\n\", \"8\\n0 0 0 0 0 0 0 0\\n7 8 1 2 3 4 5 6\\n\", \"8\\n0 0 0 0 4 5 7 8\\n0 6 0 0 0 1 2 3\\n\", \"8\\n0 0 0 0 0 0 7 8\\n0 1 2 3 4 5 0 6\\n\", \"1\\n1\\n0\\n\", \"1\\n0\\n1\\n\", \"2\\n0 ... | Nauuo is a girl who loves playing cards.
One day she was playing cards but found that the cards were mixed with some empty ones.
There are $n$ cards numbered from $1$ to $n$, and they were mixed with another $n$ empty cards. She piled up the $2n$ cards and drew $n$ of them. The $n$ cards in Nauuo's hands are given. T... | 0 |
{"tests": "{\"inputs\": [\"5 10 1 2 5\\n\", \"3 6 1 2 1\\n\", \"39 252 51 98 26\\n\", \"59 96 75 98 9\\n\", \"87 237 3 21 40\\n\", \"11 81 31 90 1\\n\", \"39 221 55 94 1\\n\", \"59 770 86 94 2\\n\", \"10000 1000000000 1 2 1\\n\", \"10000 1 999999999 1000000000 1\\n\", \"9102 808807765 95894 96529 2021\\n\", \"87 422 7 ... | On vacations n pupils decided to go on excursion and gather all together. They need to overcome the path with the length l meters. Each of the pupils will go with the speed equal to v_1. To get to the excursion quickly, it was decided to rent a bus, which has seats for k people (it means that it can't fit more than k p... | 0 |
{"tests": "{\"inputs\": [\"1\\n\", \"2\\n\", \"10\\n\", \"1000\\n\", \"2000\\n\", \"5000\\n\", \"10000\\n\", \"111199\\n\", \"101232812\\n\", \"1000000000\\n\", \"3\\n\", \"4\\n\", \"5\\n\", \"6\\n\", \"7\\n\", \"8\\n\", \"9\\n\", \"11\\n\", \"12\\n\", \"13\\n\", \"55\\n\", \"100\\n\", \"150\\n\", \"1200\\n\", \"999999... | Let's introduce a number system which is based on a roman digits. There are digits I, V, X, L which correspond to the numbers $1$, $5$, $10$ and $50$ respectively. The use of other roman digits is not allowed.
Numbers in this system are written as a sequence of one or more digits. We define the value of the sequence s... | 0 |
{"tests": "{\"inputs\": [\"4\\n4\\n-><-\\n5\\n>>>>>\\n3\\n<--\\n2\\n<>\\n\", \"36\\n2\\n--\\n2\\n>-\\n2\\n<-\\n2\\n->\\n2\\n>>\\n2\\n<>\\n2\\n-<\\n2\\n><\\n2\\n<<\\n3\\n---\\n3\\n>--\\n3\\n<--\\n3\\n->-\\n3\\n>>-\\n3\\n<>-\\n3\\n-<-\\n3\\n><-\\n3\\n<<-\\n3\\n-->\\n3\\n>->\\n3\\n<->\\n3\\n->>\\n3\\n>>>\\n3\\n<>>\\n3\\n-... | In the snake exhibition, there are $n$ rooms (numbered $0$ to $n - 1$) arranged in a circle, with a snake in each room. The rooms are connected by $n$ conveyor belts, and the $i$-th conveyor belt connects the rooms $i$ and $(i+1) \bmod n$. In the other words, rooms $0$ and $1$, $1$ and $2$, $\ldots$, $n-2$ and $n-1$, $... | 0 |
{"tests": "{\"inputs\": [\"5\\n1 1 1 1 1\\n\", \"3\\n1 2 3\\n\", \"5\\n1 2 3 2 2\\n\", \"1\\n10\\n\", \"2\\n1 100\\n\", \"2\\n2 2\\n\", \"10\\n2 2 4 4 3 1 1 2 3 2\\n\", \"10\\n32 48 20 20 15 2 11 5 10 34\\n\", \"10\\n99 62 10 47 53 9 83 33 15 24\\n\", \"10\\n1 2 3 4 5 6 7 8 9 10\\n\", \"10\\n5 1 6 2 8 3 4 10 9 7\\n\", ... | Welcome to Innopolis city. Throughout the whole year, Innopolis citizens suffer from everlasting city construction.
From the window in your room, you see the sequence of n hills, where i-th of them has height a_{i}. The Innopolis administration wants to build some houses on the hills. However, for the sake of city ap... | 0 |
{"tests": "{\"inputs\": [\"101101\\n110\\n\", \"10010110\\n100011\\n\", \"10\\n11100\\n\", \"11000000\\n0\\n\", \"10100110\\n10\\n\", \"10101000\\n101\\n\", \"11010010\\n11010\\n\", \"00101010\\n01101011\\n\", \"11111111\\n1\\n\", \"11011000\\n10\\n\", \"11111111\\n0000\\n\", \"11111111\\n1111\\n\", \"11111111\\n111111... | The new camp by widely-known over the country Spring Programming Camp is going to start soon. Hence, all the team of friendly curators and teachers started composing the camp's schedule. After some continuous discussion, they came up with a schedule $s$, which can be represented as a binary string, in which the $i$-th ... | 0 |
{"tests": "{\"inputs\": [\"5 5 2\\n1 1 1 1 1\\n1 1 1 1 1\\n1 1 0 1 1\\n1 1 1 1 1\\n1 1 1 1 1\\n\", \"3 4 1\\n1 0 0 0\\n0 1 1 1\\n1 1 1 0\\n\", \"3 4 1\\n1 0 0 1\\n0 1 1 0\\n1 0 0 1\\n\", \"8 1 4\\n0\\n0\\n0\\n1\\n0\\n1\\n1\\n0\\n\", \"3 10 7\\n0 1 0 0 1 0 1 0 0 0\\n0 0 1 1 0 0 0 1 0 1\\n1 0 1 1 1 0 1 1 0 0\\n\", \"4 9 ... | Sereja has an n × m rectangular table a, each cell of the table contains a zero or a number one. Sereja wants his table to meet the following requirement: each connected component of the same values forms a rectangle with sides parallel to the sides of the table. Rectangles should be filled with cells, that is, if a co... | 0 |
{"tests": "{\"inputs\": [\"6\\n11 6\\n10 4\\n01 3\\n00 3\\n00 7\\n00 9\\n\", \"5\\n11 1\\n01 1\\n00 100\\n10 1\\n01 1\\n\", \"6\\n11 19\\n10 22\\n00 18\\n00 29\\n11 29\\n10 28\\n\", \"3\\n00 5000\\n00 5000\\n00 5000\\n\", \"1\\n00 1\\n\", \"1\\n00 4\\n\", \"1\\n11 15\\n\", \"2\\n00 1\\n10 1\\n\", \"2\\n00 2\\n11 1\\n\"... | Elections in Berland are coming. There are only two candidates — Alice and Bob.
The main Berland TV channel plans to show political debates. There are $n$ people who want to take part in the debate as a spectator. Each person is described by their influence and political views. There are four kinds of political views:... | 0.125 |
{"tests": "{\"inputs\": [\"3 4 9\\n1 3 1 2\\n2 1 3\\n4 3 6\\n\", \"3 4 10\\n2 3 1 2\\n2 1 3\\n4 3 6\\n\", \"3 4 9\\n2 3 1 2\\n2 1 3\\n4 3 6\\n\", \"3 4 5\\n1 3 1 2\\n2 1 3\\n5 3 6\\n\", \"3 4 9\\n1 3 1 1\\n2 1 3\\n4 3 6\\n\", \"5 6 10\\n2 4 6 5 4 3\\n4 2 5 3 6\\n3 2 5 3 7\\n\", \"2 2 10\\n1 2\\n1 2\\n5 5\\n\", \"2 2 10... | Soon there will be held the world's largest programming contest, but the testing system still has m bugs. The contest organizer, a well-known university, has no choice but to attract university students to fix all the bugs. The university has n students able to perform such work. The students realize that they are the ... | 0 |
{"tests": "{\"inputs\": [\"4\\n\", \"7\\n\", \"11\\n\", \"12\\n\", \"20\\n\", \"22\\n\", \"25\\n\", \"27\\n\", \"13\\n\", \"14\\n\", \"15\\n\", \"16\\n\", \"17\\n\", \"18\\n\", \"19\\n\", \"8\\n\", \"10\\n\", \"21\\n\", \"1\\n\", \"30\\n\", \"40\\n\", \"79\\n\", \"66\\n\", \"34\\n\", \"37\\n\", \"28\\n\", \"33\\n\", \"... | Ivan places knights on infinite chessboard. Initially there are $n$ knights. If there is free cell which is under attack of at least $4$ knights then he places new knight in this cell. Ivan repeats this until there are no such free cells. One can prove that this process is finite. One can also prove that position in th... | 0 |
{"tests": "{\"inputs\": [\"3\\n4 5 7\\n\", \"2\\n1 1\\n\", \"10\\n38282 53699 38282 38282 38282 38282 38282 38282 38282 38282\\n\", \"10\\n50165 50165 50165 50165 50165 50165 50165 50165 50165 50165\\n\", \"10\\n83176 83176 83176 23495 83176 8196 83176 23495 83176 83176\\n\", \"10\\n32093 36846 32093 32093 36846 36846 ... | Edogawa Conan got tired of solving cases, and invited his friend, Professor Agasa, over. They decided to play a game of cards. Conan has n cards, and the i-th card has a number a_{i} written on it.
They take turns playing, starting with Conan. In each turn, the player chooses a card and removes it. Also, he removes al... | 0 |
{"tests": "{\"inputs\": [\"5 4\\n+ 1\\n+ 2\\n- 2\\n- 1\\n\", \"3 2\\n+ 1\\n- 2\\n\", \"2 4\\n+ 1\\n- 1\\n+ 2\\n- 2\\n\", \"5 6\\n+ 1\\n- 1\\n- 3\\n+ 3\\n+ 4\\n- 4\\n\", \"2 4\\n+ 1\\n- 2\\n+ 2\\n- 1\\n\", \"1 1\\n+ 1\\n\", \"2 1\\n- 2\\n\", \"3 5\\n- 1\\n+ 1\\n+ 2\\n- 2\\n+ 3\\n\", \"10 8\\n+ 1\\n- 1\\n- 2\\n- 3\\n+ 3\... | Nearly each project of the F company has a whole team of developers working on it. They often are in different rooms of the office in different cities and even countries. To keep in touch and track the results of the project, the F company conducts shared online meetings in a Spyke chat.
One day the director of the F ... | 0 |
{"tests": "{\"inputs\": [\"4 2\\n0101\\n\", \"6 1\\n010101\\n\", \"6 5\\n010101\\n\", \"4 1\\n0011\\n\", \"1 1\\n1\\n\", \"1 1\\n0\\n\", \"2 1\\n11\\n\", \"2 1\\n00\\n\", \"2 2\\n01\\n\", \"2 1\\n10\\n\", \"20 17\\n01001001101010111011\\n\", \"10 10\\n0111010011\\n\", \"10 5\\n0001000000\\n\", \"10 2\\n0000011000\\n\",... | "Duel!"
Betting on the lovely princess Claris, the duel between Tokitsukaze and Quailty has started.
There are $n$ cards in a row. Each card has two sides, one of which has color. At first, some of these cards are with color sides facing up and others are with color sides facing down. Then they take turns flipping ca... | 0 |
{"tests": "{\"inputs\": [\"3\\n-2 5 -1\\n\", \"2\\n-1 -3\\n\", \"5\\n0 0 0 0 0\\n\", \"36\\n-1000000 -1000000 -1000000 -1000000 -1000000 -1000000 -1000000 -1000000 -1000000 -1000000 -1000000 -1000000 -1000000 -1000000 -1000000 -1000000 -1000000 -1000000 -1000000 -1000000 -1000000 -1000000 -1000000 1 -1000000 -1000000 -... | Snuke has an integer sequence, a, of length N. The i-th element of a (1-indexed) is a_{i}.
He can perform the following operation any number of times:
- Operation: Choose integers x and y between 1 and N (inclusive), and add a_x to a_y.
He would like to perform this operation between 0 and 2N times (inclusive) so that... | 0 |
{"tests": "{\"inputs\": [\"3\\n0 0 10\\n\", \"5\\n0 1 2 3 4\\n\", \"4\\n0 0 0 0\\n\", \"9\\n0 1 0 2 0 1 1 2 10\\n\", \"1\\n0\\n\", \"2\\n0 0\\n\", \"2\\n0 1\\n\", \"2\\n100 99\\n\", \"9\\n0 1 1 0 2 0 3 45 4\\n\", \"10\\n1 1 1 1 2 2 2 2 2 2\\n\", \"100\\n50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 ... | Fox Ciel has n boxes in her room. They have the same size and weight, but they might have different strength. The i-th box can hold at most x_{i} boxes on its top (we'll call x_{i} the strength of the box).
Since all the boxes have the same size, Ciel cannot put more than one box directly on the top of some box. For ... | 0 |
{"tests": "{\"inputs\": [\"4\\n0 0\\n0 1\\n1 0\\n1 1\\n\", \"5\\n0 0\\n0 1\\n0 2\\n0 3\\n1 1\\n\", \"1\\n3141 2718\\n\", \"2\\n11 22\\n31 45\\n\", \"3\\n0 0\\n9998 9999\\n9997 9998\\n\", \"125\\n1364 2136\\n4530 5609\\n8555 7238\\n7151 4606\\n6464 8941\\n9723 9780\\n2138 3308\\n3013 3268\\n372 7398\\n7906 6497\\n8085 2... | You are given N points (x_i,y_i) located on a two-dimensional plane.
Consider a subset S of the N points that forms a convex polygon.
Here, we say a set of points S forms a convex polygon when there exists a convex polygon with a positive area that has the same set of vertices as S. All the interior angles of the polyg... | 0 |
{"tests": "{\"inputs\": [\"2\\n\", \"3\\n\", \"10\\n\", \"1000\\n\", \"4\\n\", \"5\\n\", \"6\\n\", \"7\\n\", \"8\\n\", \"9\\n\", \"11\\n\", \"12\\n\", \"13\\n\", \"14\\n\", \"15\\n\", \"16\\n\", \"32\\n\", \"64\\n\", \"128\\n\", \"256\\n\", \"512\\n\", \"20\\n\", \"40\\n\", \"80\\n\", \"160\\n\", \"320\\n\", \"640\\n\"... | A positive integer $a$ is given. Baron Munchausen claims that he knows such a positive integer $n$ that if one multiplies $n$ by $a$, the sum of its digits decreases $a$ times. In other words, $S(an) = S(n)/a$, where $S(x)$ denotes the sum of digits of the number $x$.
Find out if what Baron told can be true.
-----I... | 0 |
{"tests": "{\"inputs\": [\"5\\n\", \"2\\n\", \"8\\n\", \"9\\n\", \"2\\n\", \"6\\n\", \"72\\n\", \"1\\n\", \"23\\n\", \"52\\n\", \"32\\n\", \"25\\n\", \"54\\n\", \"20\\n\", \"34\\n\", \"23\\n\", \"41904\\n\", \"46684\\n\", \"72598\\n\", \"74320\\n\", \"16586\\n\", \"5014\\n\", \"73268\\n\", \"99182\\n\", \"5684\\n\", \"... | Bike is interested in permutations. A permutation of length n is an integer sequence such that each integer from 0 to (n - 1) appears exactly once in it. For example, [0, 2, 1] is a permutation of length 3 while both [0, 2, 2] and [1, 2, 3] is not.
A permutation triple of permutations of length n (a, b, c) is called a... | 0 |
{"tests": "{\"inputs\": [\"2 6 5\\n1 1 0 5000\\n3 2 0 5500\\n2 2 0 6000\\n15 0 2 9000\\n9 0 1 7000\\n8 0 2 6500\\n\", \"2 4 5\\n1 2 0 5000\\n2 1 0 4500\\n2 1 0 3000\\n8 0 1 6000\\n\", \"2 5 5\\n1 1 0 1\\n2 2 0 100\\n3 2 0 10\\n9 0 1 1000\\n10 0 2 10000\\n\", \"2 4 5\\n1 1 0 1\\n2 2 0 10\\n8 0 1 100\\n9 0 2 1000\\n\", \... | Country of Metropolia is holding Olympiad of Metrpolises soon. It mean that all jury members of the olympiad should meet together in Metropolis (the capital of the country) for the problem preparation process.
There are n + 1 cities consecutively numbered from 0 to n. City 0 is Metropolis that is the meeting point for... | 0 |
{"tests": "{\"inputs\": [\"1 1 45\\n\", \"6 4 30\\n\", \"100 100 0\\n\", \"100 100 30\\n\", \"303304 904227 3\\n\", \"217708 823289 162\\n\", \"872657 1807 27\\n\", \"787062 371814 73\\n\", \"925659 774524 134\\n\", \"852428 738707 49\\n\", \"991024 917226 95\\n\", \"938133 287232 156\\n\", \"76730 689942 119\\n\", \"5... | You are given two rectangles on a plane. The centers of both rectangles are located in the origin of coordinates (meaning the center of the rectangle's symmetry). The first rectangle's sides are parallel to the coordinate axes: the length of the side that is parallel to the Ox axis, equals w, the length of the side tha... | 0 |
{"tests": "{\"inputs\": [\"2 3\\nATK 2000\\nDEF 1700\\n2500\\n2500\\n2500\\n\", \"3 4\\nATK 10\\nATK 100\\nATK 1000\\n1\\n11\\n101\\n1001\\n\", \"2 4\\nDEF 0\\nATK 0\\n0\\n0\\n1\\n1\\n\", \"1 1\\nATK 100\\n99\\n\", \"4 8\\nDEF 100\\nDEF 200\\nDEF 300\\nATK 100\\n100\\n101\\n201\\n301\\n1\\n1\\n1\\n1\\n\", \"3 4\\nDEF 1... | Fox Ciel is playing a card game with her friend Jiro.
Jiro has n cards, each one has two attributes: position (Attack or Defense) and strength. Fox Ciel has m cards, each one has these two attributes too. It's known that position of all Ciel's cards is Attack.
Now is Ciel's battle phase, Ciel can do the following ope... | 0 |
{"tests": "{\"inputs\": [\"5 4\\n4 3 1 2 1\\n1 2 1 2 1\\n1 2 3 4 5 6 7 8 9\\n\", \"2 2\\n1 2\\n0 0\\n2 1 -100 -100\\n\", \"5 4\\n4 3 2 1 1\\n0 2 6 7 4\\n12 12 12 6 -3 -5 3 10 -4\\n\", \"7 5\\n4 3 2 3 2 1 1\\n6 8 9 1 2 0 5\\n14 6 0 14 -12 -2 -13 10 -14 -3 10 -9\\n\", \"7 4\\n1 4 3 2 1 3 1\\n8 2 2 1 4 3 2\\n-6 14 8 13 -8... | A popular reality show is recruiting a new cast for the third season! $n$ candidates numbered from $1$ to $n$ have been interviewed. The candidate $i$ has aggressiveness level $l_i$, and recruiting this candidate will cost the show $s_i$ roubles.
The show host reviewes applications of all candidates from $i=1$ to $i=n... | 0 |
{"tests": "{\"inputs\": [\"3\\n\", \"1\\n\", \"5\\n\", \"6\\n\", \"7\\n\", \"8\\n\", \"10\\n\", \"766\\n\", \"555\\n\", \"999\\n\", \"150\\n\", \"899\\n\", \"111\\n\", \"2\\n\", \"22\\n\", \"695\\n\", \"406\\n\", \"219\\n\", \"974\\n\", \"431\\n\", \"186\\n\", \"75\\n\", \"898\\n\", \"731\\n\", \"26\\n\", \"551\\n\", \... | Seyyed and MoJaK are friends of Sajjad. Sajjad likes a permutation. Seyyed wants to change the permutation in a way that Sajjad won't like it. Seyyed thinks more swaps yield more probability to do that, so he makes MoJaK to perform a swap between every pair of positions (i, j), where i < j, exactly once. MoJaK doesn't ... | 0 |
{"tests": "{\"inputs\": [\"3\\n1 2 3\\n\", \"3\\n2 1 2\\n\", \"6\\n8 6 5 10 9 14\\n\", \"6\\n4 6 1 9 6 10\\n\", \"6\\n6 8 10 5 7 4\\n\", \"5\\n4 5 7 10 9\\n\", \"6\\n7 4 4 2 6 1\\n\", \"5\\n9 7 4 4 1\\n\", \"6\\n9 7 3 6 10 10\\n\", \"6\\n5 10 7 2 3 5\\n\", \"6\\n6 3 4 5 5 5\\n\", \"6\\n4 5 10 1 2 2\\n\", \"6\\n2 10 3 7... | Given is an integer sequence of length N: A_1, A_2, \cdots, A_N.
An integer sequence X, which is also of length N, will be chosen randomly by independently choosing X_i from a uniform distribution on the integers 1, 2, \ldots, A_i for each i (1 \leq i \leq N).
Compute the expected value of the length of the longest inc... | 0 |
{"tests": "{\"inputs\": [\"5 6\\n1 2\\n1 3\\n2 3\\n2 5\\n3 4\\n4 5\\n\", \"4 4\\n1 2\\n1 3\\n1 4\\n3 4\\n\", \"1 0\\n\", \"2 1\\n2 1\\n\", \"3 2\\n1 3\\n2 3\\n\", \"22 31\\n5 11\\n6 3\\n10 1\\n18 20\\n3 21\\n12 10\\n15 19\\n1 17\\n17 18\\n2 21\\n21 7\\n2 15\\n3 2\\n19 6\\n2 19\\n13 16\\n21 19\\n13 5\\n19 3\\n12 22\\n9 ... | Arseny likes to organize parties and invite people to it. However, not only friends come to his parties, but friends of his friends, friends of friends of his friends and so on. That's why some of Arseny's guests can be unknown to him. He decided to fix this issue using the following procedure.
At each step he selects... | 0 |
{"tests": "{\"inputs\": [\"4\\n75 150 75 50\\n\", \"3\\n100 150 250\\n\", \"7\\n34 34 68 34 34 68 34\\n\", \"10\\n72 96 12 18 81 20 6 2 54 1\\n\", \"20\\n958692492 954966768 77387000 724664764 101294996 614007760 202904092 555293973 707655552 108023967 73123445 612562357 552908390 914853758 915004122 466129205 12285349... | Limak is an old brown bear. He often plays poker with his friends. Today they went to a casino. There are n players (including Limak himself) and right now all of them have bids on the table. i-th of them has bid with size a_{i} dollars.
Each player can double his bid any number of times and triple his bid any number ... | 0.375 |
{"tests": "{\"inputs\": [\"3 1\\n\", \"1 3\\n\", \"4 1\\n\", \"1000000000 1000000000\\n\", \"1000000000 1\\n\", \"991691248 43166756\\n\", \"973970808 679365826\\n\", \"404878182 80324806\\n\", \"405262931 391908625\\n\", \"758323881 37209930\\n\", \"405647680 36668977\\n\", \"750322953 61458580\\n\", \"406032429 31993... | There is a polyline going through points (0, 0) – (x, x) – (2x, 0) – (3x, x) – (4x, 0) – ... - (2kx, 0) – (2kx + x, x) – ....
We know that the polyline passes through the point (a, b). Find minimum positive value x such that it is true or determine that there is no such x.
-----Input-----
Only one line containing ... | 0.125 |
{"tests": "{\"inputs\": [\"3\\n1 1\\n1 2\\n1 111111111111\\n\", \"5\\n0 69\\n1 194\\n1 139\\n0 47\\n1 66\\n\", \"10\\n4 1825\\n3 75\\n3 530\\n4 1829\\n4 1651\\n3 187\\n4 584\\n4 255\\n4 774\\n2 474\\n\", \"1\\n0 1\\n\", \"1\\n999 1000000000000000000\\n\", \"10\\n1 8\\n1 8\\n9 5\\n0 1\\n8 1\\n7 3\\n5 2\\n0 9\\n4 6\\n9 4... | What are you doing at the end of the world? Are you busy? Will you save us?
[Image]
Nephren is playing a game with little leprechauns.
She gives them an infinite array of strings, f_{0... ∞}.
f_0 is "What are you doing at the end of the world? Are you busy? Will you save us?".
She wants to let more people know a... | 0 |
{"tests": "{\"inputs\": [\"? + ? - ? + ? + ? = 42\\n\", \"? - ? = 1\\n\", \"? = 1000000\\n\", \"? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? = 9\\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 co... | 0 |
{"tests": "{\"inputs\": [\"6\\n8 10 9 9 8 10\\n1 1 1 1 1 1\\n\", \"6\\n8 10 9 9 8 10\\n1 10 5 5 1 10\\n\", \"1\\n1\\n100\\n\", \"50\\n83 43 73 75 11 53 6 43 67 38 83 12 70 27 60 13 9 79 61 30 29 71 10 11 95 87 26 26 19 99 13 47 66 93 91 47 90 75 68 3 22 29 59 12 44 41 64 3 99 100\\n31 36 69 25 18 33 15 70 12 91 41 44 1... | You need to execute several tasks, each associated with number of processors it needs, and the compute power it will consume.
You have sufficient number of analog computers, each with enough processors for any task. Each computer can execute up to one task at a time, and no more than two tasks total. The first task ca... | 0 |
{"tests": "{\"inputs\": [\"5\\n2 2 3 4 6\\n\", \"4\\n2 4 6 8\\n\", \"3\\n2 6 9\\n\", \"15\\n10 10 10 10 10 10 21 21 21 21 21 21 21 21 21\\n\", \"12\\n10 10 14 14 14 14 14 14 14 14 21 21\\n\", \"5\\n10 10 14 21 21\\n\", \"9\\n10 10 10 10 10 14 14 21 21\\n\", \"9\\n10 10 10 10 10 10 10 10 21\\n\", \"13\\n10 10 10 15 15 1... | You have an array a with length n, you can perform operations. Each operation is like this: choose two adjacent elements from a, say x and y, and replace one of them with gcd(x, y), where gcd denotes the greatest common divisor.
What is the minimum number of operations you need to make all of the elements equal to 1?
... | 0 |
{"tests": "{\"inputs\": [\"abacabaca\\n\", \"abaca\\n\", \"gzqgchv\\n\", \"iosdwvzerqfi\\n\", \"oawtxikrpvfuzugjweki\\n\", \"abcdexyzzzz\\n\", \"affviytdmexpwfqplpyrlniprbdphrcwlboacoqec\\n\", \"lmnxtobrknqjvnzwadpccrlvisxyqbxxmghvl\\n\", \"hzobjysjhbebobkoror\\n\", \"glaoyryxrgsysy\\n\", \"aaaaaxyxxxx\\n\", \"aaaaax\\... | First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you should know l... | 0 |
{"tests": "{\"inputs\": [\"4 5\\n11..2\\n#..22\\n#.323\\n.#333\\n\", \"1 5\\n1#2#3\\n\", \"3 4\\n.2..\\n...3\\n.1#.\\n\", \"10 10\\n##.#..#.#2\\n...###....\\n#..#....##\\n.....#....\\n.#........\\n.....#####\\n...#..#...\\n....###...\\n###.##...#\\n.#...1#.3.\\n\", \"4 3\\n..#\\n.3.\\n..2\\n..1\\n\", \"5 5\\n.2...\\n#2... | The famous global economic crisis is approaching rapidly, so the states of Berman, Berance and Bertaly formed an alliance and allowed the residents of all member states to freely pass through the territory of any of them. In addition, it was decided that a road between the states should be built to guarantee so that on... | 0 |
{"tests": "{\"inputs\": [\"3 3 5\\n4 4 0\\n1 3\\n3 2\\n3 1\\n\", \"4 5 4\\n2 1 0 3\\n4 3\\n3 2\\n1 2\\n1 4\\n1 3\\n\", \"5 5 4\\n0 1 2 3 3\\n1 2\\n2 3\\n3 4\\n4 1\\n3 5\\n\", \"2 1 2\\n1 0\\n1 2\\n\", \"5 5 3\\n2 2 0 1 0\\n5 4\\n5 2\\n1 4\\n5 1\\n4 3\\n\", \"10 10 5\\n3 3 3 4 4 1 3 0 2 4\\n7 5\\n10 8\\n10 8\\n5 8\\n2 1... | BigData Inc. is a corporation that has n data centers indexed from 1 to n that are located all over the world. These data centers provide storage for client data (you can figure out that client data is really big!).
Main feature of services offered by BigData Inc. is the access availability guarantee even under the ci... | 0 |
{"tests": "{\"inputs\": [\"5 2\\n1 2\\n2 3\\n\", \"100 3\\n1 2\\n2 1\\n3 1\\n\", \"1 2\\n1 1\\n2 100\\n\", \"25 29\\n82963 53706\\n63282 73962\\n14996 48828\\n84392 31903\\n96293 41422\\n31719 45448\\n46772 17870\\n9668 85036\\n36704 83323\\n73674 63142\\n80254 1548\\n40663 44038\\n96724 39530\\n8317 42191\\n44289 1041... | Let's call an array consisting of n integer numbers a_1, a_2, ..., a_{n}, beautiful if it has the following property:
consider all pairs of numbers x, y (x ≠ y), such that number x occurs in the array a and number y occurs in the array a; for each pair x, y must exist some position j (1 ≤ j < n), such that at least... | 0 |
{"tests": "{\"inputs\": [\"1\\n\", \"4\\n\", \"3\\n\", \"8\\n\", \"10\\n\", \"100000000000000000\\n\", \"99999999999999999\\n\", \"50031545098999707\\n\", \"16677181699666569\\n\", \"72900000000000\\n\", \"99999999999999997\\n\", \"58061299250691018\\n\", \"49664023559436051\\n\", \"66708726798666276\\n\", \"2944243188... | Gerald has been selling state secrets at leisure. All the secrets cost the same: n marks. The state which secrets Gerald is selling, has no paper money, only coins. But there are coins of all positive integer denominations that are powers of three: 1 mark, 3 marks, 9 marks, 27 marks and so on. There are no coins of oth... | 0 |
{"tests": "{\"inputs\": [\"3\\n1 4\\n2 5\\n3 6\\n\", \"6\\n3 2\\n5 11\\n7 12\\n6 9\\n8 4\\n1 10\\n\", \"19\\n30 27\\n6 38\\n10 28\\n20 5\\n14 18\\n32 2\\n36 29\\n12 1\\n31 24\\n15 4\\n35 11\\n3 7\\n21 17\\n25 19\\n16 8\\n23 22\\n37 33\\n13 9\\n34 26\\n\", \"4\\n4 2\\n6 8\\n5 1\\n3 7\\n\", \"17\\n11 12\\n17 22\\n34 7\\n... | Note that girls in Arpa’s land are really attractive.
Arpa loves overnight parties. In the middle of one of these parties Mehrdad suddenly appeared. He saw n pairs of friends sitting around a table. i-th pair consisted of a boy, sitting on the a_{i}-th chair, and his girlfriend, sitting on the b_{i}-th chair. The chai... | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.