info stringlengths 120 50k | question stringlengths 504 10.4k | avg@8_qwen3_4b_instruct_2507 float64 0 0.88 |
|---|---|---|
{"tests": "{\"inputs\": [\"3\\n0 0 100 100\\n60 100 50\\n100 100 10\\n80 80 50\\n4\\n0 0 100 100\\n50 50 50\\n150 50 50\\n50 150 50\\n150 150 50\\n0\", \"3\\n0 0 100 101\\n60 100 50\\n100 100 10\\n80 80 50\\n4\\n0 0 100 100\\n50 50 50\\n150 50 50\\n50 150 50\\n150 150 50\\n0\", \"3\\n0 0 100 101\\n60 100 50\\n100 110 1... | Maki is a house cat. One day she fortunately came at a wonderful-looking dried fish. Since she felt not hungry on that day, she put it up in her bed. However there was a problem; a rat was living in her house, and he was watching for a chance to steal her food. To secure the fish during the time she is asleep, she deci... | 0 |
{"tests": "{\"inputs\": [\"5 4\\n4\\n3\\n1\\n2\", \"4 3\\n1\\n2\\n3\", \"6 4\\n4\\n3\\n1\\n2\", \"4 3\\n2\\n2\\n4\", \"13 1\\n7\\n4\\n3\", \"6 4\\n1\\n2\\n1\\n2\", \"4 3\\n2\\n2\\n3\", \"5 3\\n2\\n2\\n3\", \"4 3\\n2\\n3\\n4\", \"4 3\\n3\\n3\\n4\", \"6 4\\n4\\n1\\n1\\n2\", \"5 3\\n4\\n2\\n3\", \"9 3\\n4\\n2\\n3\", \"9 3... | Problem Statement
Mr. Takatsuki, who is planning to participate in the Aizu training camp, has a poor house and always tries to save as much paper as possible. She decided to play a ghost leg with other participants to decide the team for the Aizu training camp.
How to make Amidakuji for this training camp is as foll... | 0.125 |
{"tests": "{\"inputs\": [\"3 5\\n0 1 2 1\\n0 2 3 2\\n0 3 3 3\\n1 2\\n1 3\", \"4 3\\n1 2\\n0 1 4 1\\n1 2\", \"4 3\\n1 2\\n0 2 4 1\\n1 2\", \"6 3\\n1 2\\n0 2 4 0\\n1 2\", \"4 3\\n1 2\\n0 2 4 1\\n0 2\", \"4 3\\n1 2\\n0 1 4 2\\n1 2\", \"3 5\\n0 1 0 1\\n0 2 3 2\\n0 3 3 3\\n1 2\\n1 3\", \"6 3\\n1 2\\n0 1 4 -1\\n1 2\", \"4 3\... | Write a program which manipulates a sequence A = {a1, a2, . . . , an} with the following operations:
* add(s, t, x): add x to as, as+1, ..., at.
* get(i): output the value of ai.
Note that the initial values of ai (i = 1, 2, . . . , n) are 0.
Constraints
* 1 ≤ n ≤ 100000
* 1 ≤ q ≤ 100000
* 1 ≤ s ≤ t ≤ n
* 1 ≤ i ≤... | 0 |
{"tests": "{\"inputs\": [\"1\\n2\\n88888 66666\\n\", \"10\\n283 463 213 777 346 201 463 283 102 999\\n2333333 6263423\\n\", \"8\\n2 3 5 6 1 7 9 10\\n23333 1\\n\", \"3\\n998244352 998244352 998244352\\n4 2\\n\", \"5\\n4 7 1 5 6\\n7 14187219\\n\", \"3\\n2 3 5\\n4 16\\n\", \"1\\n1\\n2 1\\n\", \"22\\n488943077 290998271 85... | Lunar New Year is approaching, and Bob received a gift from his friend recently — a recursive sequence! He loves this sequence very much and wants to play with it.
Let f_1, f_2, …, f_i, … be an infinite sequence of positive integers. Bob knows that for i > k, f_i can be obtained by the following recursive equation:
$... | 0 |
{"tests": "{\"inputs\": [\"5 2 1\\n0 1 0 1 0\\n\", \"6 2 1\\n1 0 0 1 0 1\\n\", \"1 1 1\\n0\\n\", \"100 1 1\\n0 0 0 1 1 0 1 0 1 0 1 0 0 1 0 0 1 1 0 0 1 0 1 1 1 1 1 1 1 0 1 1 1 0 0 0 0 0 0 1 1 0 0 0 1 0 1 0 0 1 0 1 1 0 0 1 0 0 0 1 1 1 1 1 0 0 0 0 0 1 0 0 0 0 1 0 0 0 1 1 0 1 1 0 1 1 1 0 1 1 0 1 1 0 0 1 1 0 1 1\\n\", \"3 1... | There is a robot staying at X=0 on the Ox axis. He has to walk to X=n. You are controlling this robot and controlling how he goes. The robot has a battery and an accumulator with a solar panel.
The i-th segment of the path (from X=i-1 to X=i) can be exposed to sunlight or not. The array s denotes which segments are ex... | 0 |
{"tests": "{\"inputs\": [\"6\\n7\\n2323216\\n1615124\\n1\\n3\\n4\\n2\\n13\\n24\\n2\\n12\\n34\\n3\\n536\\n345\\n2\\n46\\n54\\n\", \"6\\n7\\n2323216\\n1615124\\n1\\n3\\n4\\n2\\n14\\n24\\n2\\n12\\n34\\n3\\n536\\n345\\n2\\n46\\n54\\n\", \"6\\n7\\n2323216\\n1615124\\n1\\n3\\n4\\n2\\n13\\n24\\n2\\n12\\n34\\n3\\n536\\n525\\n2... | You are given a system of pipes. It consists of two rows, each row consists of n pipes. The top left pipe has the coordinates (1, 1) and the bottom right — (2, n).
There are six types of pipes: two types of straight pipes and four types of curved pipes. Here are the examples of all six types:
<image> Types of pipes
... | 0 |
{"tests": "{\"inputs\": [\"9\\n1\\n2\\n3\\n4\\n5\\n6\\n7\\n8\\n9\\n\", \"9\\n2\\n2\\n3\\n4\\n5\\n6\\n7\\n8\\n9\\n\", \"9\\n2\\n2\\n3\\n4\\n5\\n6\\n7\\n8\\n17\\n\", \"9\\n2\\n2\\n3\\n4\\n5\\n6\\n13\\n8\\n17\\n\", \"9\\n2\\n2\\n3\\n4\\n5\\n6\\n13\\n8\\n19\\n\", \"9\\n2\\n2\\n3\\n4\\n5\\n6\\n13\\n8\\n33\\n\", \"9\\n2\\n2\... | Consider the infinite sequence s of positive integers, created by repeating the following steps:
1. Find the lexicographically smallest triple of positive integers (a, b, c) such that
* a ⊕ b ⊕ c = 0, where ⊕ denotes the [bitwise XOR operation](https://en.wikipedia.org/wiki/Bitwise_operation#XOR).
* a, b, ... | 0 |
{"tests": "{\"inputs\": [\"5\\n4 1\\n0 1 3 4\\n3 1\\n0 1 4\\n3 0\\n0 1 4\\n3 2\\n0 1 2\\n3 2\\n1 2 3\\n\", \"1\\n6 2\\n0 1 2 3 6 8\\n\", \"7\\n5 1000000000\\n4 2 3 0 1\\n4 0\\n5 2 0 1\\n3 0\\n100 0 1\\n6 1234567\\n1 2 3 4 5 0\\n3 114514\\n8 0 4\\n1 1000000\\n0\\n1 10000000\\n1\\n\", \"1\\n5 3\\n0 1 3 10 4\\n\", \"1\\n3... | You are given a multiset S initially consisting of n distinct non-negative integers. A multiset is a set, that can contain some elements multiple times.
You will perform the following operation k times:
* Add the element ⌈(a+b)/(2)⌉ (rounded up) into S, where a = \operatorname{mex}(S) and b = max(S). If this numbe... | 0 |
{"tests": "{\"inputs\": [\"7\\n4 1 5 1\\n1 1 1 1\\n3 3 3 3\\n1 1 4 1\\n6 1 1 1\\n5 1 4 1\\n6 1 1 1\\n\", \"4\\n2 1 1 1\\n1 1 2 1\\n2 1 1 2\\n1 2 1 2\\n\", \"4\\n182 168 60 96\\n78 72 45 72\\n69 21 144 63\\n148 12 105 6\\n\", \"10\\n4 4 2 2\\n2 1 1 3\\n1 1 2 3\\n5 1 4 4\\n2 5 2 3\\n4 5 3 4\\n1 3 2 4\\n5 2 3 1\\n4 1 2 5\... | There are n points on an infinite plane. The i-th point has coordinates (x_i, y_i) such that x_i > 0 and y_i > 0. The coordinates are not necessarily integer.
In one move you perform the following operations:
* choose two points a and b (a ≠ b);
* move point a from (x_a, y_a) to either (x_a + 1, y_a) or (x_a, y... | 0 |
{"tests": "{\"inputs\": [\"1\\n42\\n\", \"5\\n1 2 3 4 5\\n\", \"3\\n1 2 2\\n\", \"5\\n5706 28146 23282 16828 9962\\n\", \"1\\n1000000\\n\", \"9\\n3 3 2 2 3 2 1 1 2\\n\", \"42\\n18468 6335 26501 19170 15725 11479 29359 26963 24465 5706 28146 23282 16828 9962 492 2996 11943 4828 5437 32392 14605 3903 154 293 12383 17422 ... | Sereja has a sequence that consists of n positive integers, a1, a2, ..., an.
First Sereja took a piece of squared paper and wrote all distinct non-empty non-decreasing subsequences of sequence a. Then for each sequence written on the squared paper, Sereja wrote on a piece of lines paper all sequences that do not exce... | 0 |
{"tests": "{\"inputs\": [\"6 2 3\\n1 2\\n1 5\\n2 3\\n3 4\\n4 5\\n5 6\\n\", \"10 1 0\\n3\\n10 1\\n9 4\\n4 5\\n6 4\\n2 4\\n7 5\\n8 3\\n5 3\\n1 3\\n\", \"5 2 1\\n1 5\\n1 2\\n2 3\\n3 4\\n4 5\\n\", \"5 2 0\\n1 2\\n1 2\\n2 3\\n3 4\\n4 5\\n\", \"50 2 5\\n9 14\\n46 34\\n40 35\\n44 30\\n32 16\\n1 38\\n48 2\\n17 14\\n50 25\\n6 1... | Paladin Manao caught the trail of the ancient Book of Evil in a swampy area. This area contains n settlements numbered from 1 to n. Moving through the swamp is very difficult, so people tramped exactly n - 1 paths. Each of these paths connects some pair of settlements and is bidirectional. Moreover, it is possible to r... | 0.875 |
{"tests": "{\"inputs\": [\"2 5 0\\n1 3 2 5 4\\n1 4 3 2 5\\n\", \"3 2 1\\n1 2\\n2 3\\n3 4\\n\", \"2 1 0\\n1\\n2\\n\", \"2 5 1\\n331081 525217 574775 753333 840639\\n225591 347017 538639 620341 994088\\n\", \"1 1 1\\n1\\n\", \"2 2 0\\n2 1\\n3 1\\n\", \"1 1 0\\n1\\n\", \"2 5 0\\n836096 600367 472071 200387 79763\\n714679 ... | Iahub wants to enhance his multitasking abilities. In order to do this, he wants to sort n arrays simultaneously, each array consisting of m integers.
Iahub can choose a pair of distinct indices i and j (1 ≤ i, j ≤ m, i ≠ j). Then in each array the values at positions i and j are swapped only if the value at position ... | 0 |
{"tests": "{\"inputs\": [\"3\\n3 1 2\\n\", \"4\\n4 3 2 1\\n\", \"1\\n1\\n\", \"6\\n2 1 6 5 3 4\\n\", \"11\\n7 3 5 2 10 1 9 6 8 4 11\\n\", \"8\\n1 2 6 4 5 7 8 3\\n\", \"6\\n2 1 4 5 6 3\\n\", \"4\\n3 4 1 2\\n\", \"6\\n4 1 2 3 6 5\\n\", \"2\\n2 1\\n\", \"3\\n3 2 1\\n\", \"4\\n2 3 4 1\\n\", \"2\\n1 2\\n\", \"5\\n5 3 2 1 4\... | A tree of size n is an undirected connected graph consisting of n vertices without cycles.
Consider some tree with n vertices. We call a tree invariant relative to permutation p = p1p2... pn, if for any two vertices of the tree u and v the condition holds: "vertices u and v are connected by an edge if and only if vert... | 0 |
{"tests": "{\"inputs\": [\"C:<span class=\\\"tex-span\\\">\\\\</span>file<span class=\\\"tex-span\\\">\\\\</span>file<span class=\\\"tex-span\\\">\\\\</span>file<span class=\\\"tex-span\\\">\\\\</span>file<span class=\\\"tex-span\\\">\\\\</span>file.txt\\nC:<span class=\\\"tex-span\\\">\\\\</span>file<span class=\\\"te... | Recently, on a programming lesson little Petya showed how quickly he can create files and folders on the computer. But he got soon fed up with this activity, and he decided to do a much more useful thing. He decided to calculate what folder contains most subfolders (including nested folders, nested folders of nested fo... | 0 |
{"tests": "{\"inputs\": [\"4\\n5 6 7 8 9 100\\n4 7 8 9 1\\n4 7 8 9 2\\n3 1 6 100\\n3 2 6 100\\n2 1 2\\n\", \"4\\n3 2 7 4\\n3 1 7 3\\n3 5 4 2\\n3 1 3 5\\n4 3 1 2 4\\n2 5 7\\n\", \"3\\n2 1 2\\n2 1 3\\n2 2 3\\n\", \"3\\n2 1 2\\n10 1 90 80 70 60 50 40 30 20 10\\n10 2 10 20 30 40 50 60 70 80 90\\n\", \"2\\n2 1 2\\n\", \"2\\... | Little Vasya likes very much to play with sets consisting of positive integers. To make the game more interesting, Vasya chose n non-empty sets in such a way, that no two of them have common elements.
One day he wanted to show his friends just how interesting playing with numbers is. For that he wrote out all possible... | 0 |
{"tests": "{\"inputs\": [\"8\\n4 4 4 2 2 100 100 100\\n\", \"4\\n2 5 5 2\\n\", \"5\\n6 3 4 1 5\\n\", \"6\\n10 10 50 10 50 50\\n\", \"100\\n45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 4... | Vasya has an array of integers of length n.
Vasya performs the following operations on the array: on each step he finds the longest segment of consecutive equal integers (the leftmost, if there are several such segments) and removes it. For example, if Vasya's array is [13, 13, 7, 7, 7, 2, 2, 2], then after one operat... | 0.875 |
{"tests": "{\"inputs\": [\"3\\n5 1\\n3\\n3 3\\n1 2 3\\n4 1\\n1\\n\", \"1\\n8 4\\n1 2 3 7\\n\", \"1\\n13 2\\n8 13\\n\", \"1\\n200 2\\n50 150\\n\", \"31\\n5 1\\n5\\n5 1\\n4\\n5 2\\n4 5\\n5 1\\n3\\n5 2\\n3 5\\n5 2\\n3 4\\n5 3\\n3 4 5\\n5 1\\n2\\n5 2\\n2 5\\n5 2\\n2 4\\n5 3\\n2 4 5\\n5 2\\n2 3\\n5 3\\n2 3 5\\n5 3\\n2 3 4\\... | It is winter now, and Max decided it's about time he watered the garden.
The garden can be represented as n consecutive garden beds, numbered from 1 to n. k beds contain water taps (i-th tap is located in the bed xi), which, if turned on, start delivering water to neighbouring beds. If the tap on the bed xi is turned ... | 0.25 |
{"tests": "{\"inputs\": [\"5\\n1 2 3 4 5\\n\\nSAMPLE\", \"100\\n100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 ... | A square pyramid of balls consists of square layers of balls stacked on top of each other. The i th (1-based indexing )layer from the top consists of exactly i^2 balls. Image
You have received one such beautiful square pyramid on your birthday, with each layer having a unique color. However, being the clumsy doofus yo... | 0 |
{"tests": "{\"inputs\": [\"1\\n5 4\\n1 4 4 4 1\\n\\nSAMPLE\", \"1\\n5 4\\n1 4 4 4 1\\n\\nSAMPEL\", \"1\\n5 7\\n1 4 4 4 0\\n\\nSAMPLE\", \"1\\n5 0\\n0 0 0 4 0\\n\\nSANPLE\", \"1\\n5 4\\n1 4 4 4 0\\n\\nSAMPLE\", \"1\\n5 12\\n1 4 4 4 0\\n\\nSAMPLE\", \"1\\n5 12\\n1 4 4 4 -1\\n\\nSAMPLE\", \"1\\n5 12\\n1 4 4 6 -1\\n\\nSAMP... | Xenny had N numbers and he loved equal triplets (An equal triplet is group of 3 numbers that are equal).
He defined a K-equal-triplet as a triplet in which all 3 integers were equal to K.
Given an integer K, he wanted to find out the probability of getting a K-equal triplet, from the N numbers.
Xenny is bad at underst... | 0.875 |
{"tests": "{\"inputs\": [\"15\\n123 119\\n129 120\\n132 112\\n126 109\\n118 103\\n115 109\\n102 100\\n130 120\\n105 105\\n132 115\\n104 102\\n107 107\\n127 116\\n121 104\\n121 115\\n8\\n8 234\\n9 244\\n10 226\\n11 227\\n12 240\\n13 237\\n14 206\\n15 227\", \"3\\n1 2\\n2 3\\n3 4\\n3\\n1 1\\n2 5\\n3 5\", \"15\\n123 119\\... | We have a rooted binary tree with N vertices, where the vertices are numbered 1 to N. Vertex 1 is the root, and the parent of Vertex i (i \geq 2) is Vertex \left[ \frac{i}{2} \right].
Each vertex has one item in it. The item in Vertex i has a value of V_i and a weight of W_i. Now, process the following query Q times:
... | 0 |
{"tests": "{\"inputs\": [\"3 2\\n1\\n2\\n3\\n1 2\\n1 3\", \"5 3\\n3\\n2\\n3\\n1\\n4\\n1 5\\n2 3\\n4 2\", \"9 5\\n3\\n1\\n4\\n1\\n5\\n9\\n2\\n6\\n5\\n3 5\\n8 9\\n7 9\\n3 2\\n3 8\", \"3 2\\n1\\n2\\n3\\n1 3\\n1 3\", \"5 3\\n3\\n2\\n3\\n2\\n4\\n1 5\\n2 3\\n4 2\", \"9 5\\n3\\n1\\n4\\n1\\n5\\n9\\n2\\n6\\n5\\n3 5\\n8 9\\n7 9\... | You are given an integer sequence of length N: A_1,A_2,...,A_N. Let us perform Q operations in order. The i-th operation is described by two integers X_i and Y_i. In this operation, we will choose one of the following two actions and perform it:
* Swap the values of A_{X_i} and A_{Y_i}
* Do nothing
There are 2^Q wa... | 0 |
{"tests": "{\"inputs\": [\"4\\n1000000\\n5\\n2\\n0 0.03125 3000\\n1 0.03125 3000\\n6620000\\n7\\n2\\n0 0.0732421875 42307\\n1 0.0740966796875 40942\\n39677000\\n4\\n4\\n0 0.0709228515625 30754\\n1 0.00634765625 26165\\n0 0.03662109375 79468\\n0 0.0679931640625 10932\\n10585000\\n6\\n4\\n1 0.0054931640625 59759\\n1 0.12... | The Ohgas are a prestigious family based on Hachioji. The head of the family, Mr. Nemochi Ohga, a famous wealthy man, wishes to increase his fortune by depositing his money to an operation company. You are asked to help Mr. Ohga maximize his profit by operating the given money during a specified period.
From a given l... | 0.875 |
{"tests": "{\"inputs\": [\"6 1 0 0\\n7 1 0 0\\n7 2 0 0\\n6 6 1 1\\n2\\n5\\n7 10 0 6\\n1\\n2\\n3\\n4\\n5\\n6\\n0 0 0 0\", \"6 1 0 0\\n7 1 0 0\\n7 2 0 0\\n6 6 1 1\\n2\\n5\\n7 10 0 6\\n2\\n2\\n3\\n4\\n5\\n6\\n0 0 0 0\", \"6 1 0 0\\n7 1 0 0\\n7 2 0 0\\n6 6 1 1\\n2\\n5\\n7 5 0 6\\n1\\n2\\n3\\n4\\n5\\n6\\n0 0 0 0\", \"6 2 0 ... | Here is a very simple variation of the game backgammon, named “Minimal Backgammon”. The game is played by only one player, using only one of the dice and only one checker (the token used by the player).
The game board is a line of (N + 1) squares labeled as 0 (the start) to N (the goal). At the beginning, the checker ... | 0 |
{"tests": "{\"inputs\": [\"4 2\\n9 2 7 11\\n2 9\\n6 2\\n7 3 6 12 16 9\\n2 9\\n5 2\\n7 3 6 12 17\\n2 9\\n7 5\\n15 21 33 48 51 75 111\\n36 54 57 93 113\\n0 0\", \"4 2\\n9 2 7 11\\n2 9\\n6 2\\n7 3 6 12 16 9\\n2 9\\n5 2\\n7 3 6 12 17\\n2 9\\n7 5\\n15 21 57 48 51 75 111\\n36 54 57 93 113\\n0 0\", \"4 2\\n9 2 7 11\\n2 9\\n6 ... | <!--
Problem C
-->
Balance Scale
You, an experimental chemist, have a balance scale and a kit of weights for measuring weights of powder chemicals.
For work efficiency, a single use of the balance scale should be enough for measurement of each amount. You can use any number of weights at a time, placing them eithe... | 0.375 |
{"tests": "{\"inputs\": [\"9\\n1 4 1 4 2 1 3 5 6\\n3\\n0 9 1\\n1 6 1\\n3 7 5\", \"9\\n1 4 1 4 2 0 3 5 6\\n3\\n0 9 1\\n1 6 1\\n3 7 5\", \"9\\n1 4 1 4 4 -1 3 5 6\\n3\\n0 9 1\\n0 6 1\\n3 7 5\", \"9\\n1 4 1 4 4 -1 3 5 6\\n3\\n0 9 1\\n0 6 2\\n2 7 5\", \"9\\n1 4 0 4 4 -1 3 5 6\\n3\\n0 9 1\\n0 6 2\\n2 7 5\", \"9\\n2 4 0 4 4 -... | For a given sequence of integers $A = \\{a_0, a_1, ..., a_{n-1}\\}$, perform the following operations.
* count($b, e, k$): print the number of the specific values $k$ in $a_b, a_{b+1}, ..., a_{e-1}$.
Constraints
* $1 \leq n \leq 1,000$
* $-1,000,000,000 \leq a_i, k_i \leq 1,000,000,000$
* $1 \leq q \leq 1,000$
* $0 ... | 0 |
{"tests": "{\"inputs\": [\"10 2\\n1 6\\n2 7\\n\", \"10 3\\n1 2\\n3 2\\n7 2\\n\", \"9 6\\n4 5\\n5 6\\n7 8\\n8 9\\n1 2\\n2 3\\n\", \"12 6\\n1 3\\n3 7\\n5 7\\n7 11\\n9 11\\n11 3\\n\", \"12 7\\n12 2\\n4 6\\n3 4\\n10 9\\n9 5\\n8 10\\n6 8\\n\", \"50 25\\n12 14\\n28 30\\n12 10\\n18 16\\n34 32\\n4 6\\n2 4\\n32 30\\n6 8\\n20 22... | Inaka has a disc, the circumference of which is n units. The circumference is equally divided by n points numbered clockwise from 1 to n, such that points i and i + 1 (1 ≤ i < n) are adjacent, and so are points n and 1.
There are m straight segments on the disc, the endpoints of which are all among the aforementioned ... | 0.875 |
{"tests": "{\"inputs\": [\"5 3\\n1 3 0 2 1\\n1 3\\n2 4\\n1 4\\n\", \"2 1\\n300000 300000\\n1 2\\n\", \"2 1\\n251736 300000\\n1 2\\n\", \"5 3\\n1 3 -1 2 1\\n1 3\\n2 4\\n1 4\\n\", \"5 3\\n1 3 0 2 2\\n1 3\\n2 5\\n1 4\\n\", \"5 3\\n1 3 -1 2 0\\n1 3\\n2 5\\n1 4\\n\", \"5 3\\n1 0 0 2 1\\n1 3\\n2 4\\n1 4\\n\", \"5 3\\n1 6 0 2... | Toad Pimple has an array of integers a_1, a_2, …, a_n.
We say that y is reachable from x if x<y and there exists an integer array p such that x = p_1 < p_2 < … < p_k=y, and a_{p_i} \& a_{p_{i+1}} > 0 for all integers i such that 1 ≤ i < k.
Here \& denotes the [bitwise AND operation](https://en.wikipedia.org/wiki/Bi... | 0.625 |
{"tests": "{\"inputs\": [\"3\\n1 1 1\\n1 0 1\\n1 1 1\\n1 1 1\\n0 0 0\\n1 0 1\\n\", \"2\\n1 1 1\\n0 0 1\\n1 1 1\\n1 1 0\\n\", \"16\\n1 1 1\\n1 1 0\\n1 1 0\\n1 1 0\\n1 1 0\\n1 0 1\\n1 0 1\\n1 0 1\\n1 0 1\\n0 1 1\\n0 1 1\\n0 1 1\\n0 1 1\\n1 1 1\\n1 1 1\\n1 1 1\\n1 1 1\\n0 0 0\\n1 0 0\\n0 1 0\\n1 1 0\\n0 0 0\\n1 0 0\\n0 0 ... | Daisy is a senior software engineer at RainyDay, LLC. She has just implemented three new features in their product: the first feature makes their product work, the second one makes their product fast, and the third one makes their product correct. The company encourages at least some testing of new features, so Daisy a... | 0 |
{"tests": "{\"inputs\": [\"3\\n2 69\\n68 70\\n6 4\\n4 4 4 4 4 4\\n9 38\\n-21 83 50 -59 -77 15 -71 -78 20\\n\", \"1\\n2 1\\n-10 13\\n\", \"1\\n3 4\\n5 5 5\\n\", \"1\\n2 2\\n0 5\\n\", \"1\\n4 4\\n3 6 6 2\\n\", \"1\\n4 4\\n3 3 5 6\\n\", \"1\\n3 3\\n4 2 3\\n\", \"1\\n4 2\\n1 1 3 4\\n\", \"7\\n2 7\\n7 1313\\n2 8\\n8 1211\\n... | A new agent called Killjoy invented a virus COVID-2069 that infects accounts on Codeforces. Each account has a rating, described by an integer (it can possibly be negative or very large).
Killjoy's account is already infected and has a rating equal to x. Its rating is constant. There are n accounts except hers, number... | 0.125 |
{"tests": "{\"inputs\": [\"6\\n7\\n3 4 5 2 9 1 1\\n4\\n9 2 7 1\\n11\\n8 4 3 1 2 7 8 7 9 4 2\\n1\\n42\\n2\\n11 7\\n8\\n1 1 1 1 1 1 1 1\\n\", \"1\\n1\\n45\\n\", \"1\\n1\\n99\\n\", \"1\\n1\\n20\\n\", \"1\\n1\\n24\\n\", \"1\\n1\\n3\\n\", \"1\\n4\\n1453324 2 1453324 1\\n\", \"1\\n1\\n21\\n\", \"1\\n1\\n97\\n\", \"1\\n1\\n23... | Polycarp has a favorite sequence a[1 ... n] consisting of n integers. He wrote it out on the whiteboard as follows:
* he wrote the number a_1 to the left side (at the beginning of the whiteboard);
* he wrote the number a_2 to the right side (at the end of the whiteboard);
* then as far to the left as possible ... | 0.375 |
{"tests": "{\"inputs\": [\"7\\n2 1\\n2 2\\n3 1\\n3 2\\n3 3\\n5 5\\n69 1337\\n\", \"1\\n999199999 999999999\\n\", \"1\\n730170941 999999999\\n\", \"7\\n2 1\\n2 2\\n3 1\\n3 2\\n3 3\\n5 5\\n69 1154\\n\", \"1\\n645073426 999999999\\n\", \"7\\n2 1\\n2 2\\n3 1\\n3 2\\n5 3\\n5 5\\n69 1154\\n\", \"1\\n957270328 999999999\\n\",... | Suppose you are living with two cats: A and B. There are n napping spots where both cats usually sleep.
Your cats like to sleep and also like all these spots, so they change napping spot each hour cyclically:
* Cat A changes its napping place in order: n, n - 1, n - 2, ..., 3, 2, 1, n, n - 1, ... In other words, a... | 0 |
{"tests": "{\"inputs\": [\"0 0\\n10 0\\n100 100 101 101\\n1 0 3 0\\n\", \"-1 3\\n1 3\\n0 2 0 4\\n0 0 0 1\\n\", \"0 0\\n1 1\\n0 1 1 0\\n-100 -100 -101 -101\\n\", \"0 0\\n1 1\\n0 1 1 0\\n-1 1 1 3\\n\", \"9293 -6547\\n4895 -9479\\n2738 -1395 8489 -8324\\n3540 -4860 -8555 1675\\n\", \"-8193 -8833\\n4353 -8260\\n2214 683 -8... | Victor and Peter are playing hide-and-seek. Peter has hidden, and Victor is to find him. In the room where they are playing, there is only one non-transparent wall and one double-sided mirror. Victor and Peter are points with coordinates (xv, yv) and (xp, yp) respectively. The wall is a segment joining points with coor... | 0 |
{"tests": "{\"inputs\": [\"5 6\\n+ 1\\n- 1\\n- 3\\n+ 3\\n+ 4\\n- 4\\n\", \"2 4\\n+ 1\\n- 1\\n+ 2\\n- 2\\n\", \"2 4\\n+ 1\\n- 2\\n+ 2\\n- 1\\n\", \"5 4\\n+ 1\\n+ 2\\n- 2\\n- 1\\n\", \"3 2\\n+ 1\\n- 2\\n\", \"10 6\\n+ 2\\n- 2\\n+ 2\\n- 2\\n+ 2\\n- 3\\n\", \"10 10\\n+ 1\\n- 1\\n- 2\\n+ 3\\n- 3\\n- 4\\n+ 5\\n- 5\\n- 6\\n+ ... | 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\": [\"6 9 2 4\\n\", \"6 5 4 3\\n\", \"6 10 2 4\\n\", \"1000000 1000000000 999999 1\\n\", \"140 480 1 40\\n\", \"1000000 1000000 500000 1000\\n\", \"2 1000000000 1 10000\\n\", \"100 70 70 2\\n\", \"3 1 2 1\\n\", \"51 81 36 38\\n\", \"10 8 6 2\\n\", \"100 159 80 2\\n\", \"6 4 4 2\\n\", \"1000000 1 1 ... | A bus moves along the coordinate line Ox from the point x = 0 to the point x = a. After starting from the point x = 0, it reaches the point x = a, immediately turns back and then moves to the point x = 0. After returning to the point x = 0 it immediately goes back to the point x = a and so on. Thus, the bus moves from ... | 0 |
{"tests": "{\"inputs\": [\"2\\n2 2\\n1 2\\n3 4\\n2\\n1 1 1\\n1 1 2\\n2 2\\n1 2\\n## 4\\n3\\n1 1 1\\n1 1 2\\n1 0 1\\n\\nSAMPLE\", \"2\\n2 2\\n0 2\\n3 4\\n2\\n1 1 1\\n1 1 2\\n2 2\\n1 2\\n## 4\\n3\\n1 1 1\\n1 1 2\\n1 0 1\\n\\nSAMPLE\", \"2\\n2 2\\n0 2\\n3 4\\n2\\n1 1 2\\n1 1 2\\n2 2\\n1 2\\n## 4\\n3\\n1 1 1\\n1 1 2\\n1 0 ... | You are given a cost matrix of dimensions m X n. The problem of finding the minimal path from top-left corner to some cell in the matrix is well studied. Here, we are gonna add a little twist.
To refresh your memory, the total cost of a path is sum total of cost of all cells visited in the path.
Only 2 moves are all... | 0.25 |
{"tests": "{\"inputs\": [\"6\\nabba\\n\\nSAMPLE\", \"6\\nbbba\\n\\nSAMPLE\", \"6\\nabaa\\n\\nSAMPLE\", \"6\\nabba\\n\\nELPMAS\", \"6\\nbabb\\n\\nRAMPLE\", \"6\\nbaab\\n\\nRAMPLE\", \"6\\nbbba\\n\\nRAMPLE\", \"6\\nbbba\\n\\nELPMAS\", \"6\\nbbba\\n\\nDLPMAS\", \"6\\nabba\\n\\nFLPMAS\", \"6\\nbbba\\n\\nSAMPLD\", \"6\\nabb... | Have you ever been a part of the exciting game Passing the Parcel ? Sid is on a school picnic with his classmates. The teacher decides to make the whole class play the game of Passing the Parcel. Since the
winner of the game gets lots of chocolates and ice cream as his/her prize, all the students are over-excited
abo... | 0 |
{"tests": "{\"inputs\": [\"4\\n3\\nabc\\n3\\nbba\\n4\\nabac\\n3\\nzyxSAMPLE\", \"4\\n3\\nabc\\n3\\nbba\\n4\\ncaba\\n3\\nzyxSAMPLE\", \"4\\n3\\nabc\\n3\\nbba\\n4\\naabc\\n3\\nzyxSAMPLE\", \"4\\n3\\nabc\\n3\\nbba\\n4\\ncaba\\n3\\nzzxSAMPLE\", \"4\\n3\\nabc\\n3\\nbba\\n4\\naabc\\n3\\nzxxSAMPLE\", \"4\\n3\\nabd\\n3\\nbba\\... | Roy has a string S of length N. String S is made of lower case English alphabets. He likes sorted strings. So he wonders how many substrings of S are sorted.
Given the string S, your task is to count the number of sorted substrings of S.
A string s is lexicographically sorted if si ≤ si+1 where 1 ≤ i ≤ N-1 (con... | 0 |
{"tests": "{\"inputs\": [\"869 120 1001\", \"2 2 1\", \"869 80 1001\", \"328 80 1001\", \"328 102 1011\", \"328 102 1111\", \"279 102 1111\", \"25 102 1111\", \"25 122 1111\", \"25 63 1111\", \"25 89 1111\", \"1486 120 1001\", \"869 80 1101\", \"328 117 1011\", \"40 102 1111\", \"328 60 1111\", \"117 102 1111\", \"24 1... | In 2937, DISCO creates a new universe called DISCOSMOS to celebrate its 1000-th anniversary.
DISCOSMOS can be described as an H \times W grid. Let (i, j) (1 \leq i \leq H, 1 \leq j \leq W) denote the square at the i-th row from the top and the j-th column from the left.
At time 0, one robot will be placed onto each s... | 0 |
{"tests": "{\"inputs\": [\"2 2 1\", \"2 3 2\", \"3 3 2\", \"3 3 3\", \"3 2 3\", \"1 2 3\", \"1 4 3\", \"1 4 5\", \"1 6 5\", \"1 6 4\", \"1 8 4\", \"1 1 4\", \"3 2 1\", \"2 5 2\", \"6 3 2\", \"6 3 3\", \"3 2 6\", \"1 2 2\", \"1 3 3\", \"1 5 4\", \"3 3 1\", \"2 6 2\", \"6 3 6\", \"3 4 3\", \"1 2 1\", \"1 6 3\", \"2 5 4\"... | We have a grid with H rows and W columns of squares. We will represent the square at the i-th row from the top and j-th column from the left as (i,\ j). Also, we will define the distance between the squares (i_1,\ j_1) and (i_2,\ j_2) as |i_1 - i_2| + |j_1 - j_2|.
Snuke is painting each square in red, yellow, green or... | 0 |
{"tests": "{\"inputs\": [\"7 1\\n5 2 1\", \"2 1\\n0 0 1000000000\", \"5 3\\n0 1 10\\n0 2 10\\n0 4 10\", \"7 1\\n6 2 1\", \"2 1\\n0 0 1000000010\", \"5 3\\n0 0 10\\n0 2 10\\n0 4 10\", \"9 1\\n6 2 1\", \"5 3\\n0 0 10\\n0 3 10\\n0 4 10\", \"9 1\\n7 2 1\", \"9 1\\n5 2 1\", \"7 1\\n5 4 1\", \"2 1\\n0 0 0000000000\", \"5 3\\... | We have a graph with N vertices, numbered 0 through N-1. Edges are yet to be added.
We will process Q queries to add edges. In the i-th (1≦i≦Q) query, three integers A_i, B_i and C_i will be given, and we will add infinitely many edges to the graph as follows:
* The two vertices numbered A_i and B_i will be connected... | 0 |
{"tests": "{\"inputs\": [\"3 4\\n15 15\\n0 0\", \"3 4\\n15 20\\n0 0\", \"3 4\\n15 24\\n0 0\", \"3 4\\n15 34\\n0 0\", \"4 4\\n15 34\\n0 0\", \"3 4\\n15 16\\n0 0\", \"3 5\\n15 34\\n0 0\", \"4 4\\n12 34\\n0 0\", \"1 4\\n15 16\\n0 0\", \"2 4\\n12 34\\n0 0\", \"2 1\\n12 34\\n0 0\", \"4 2\\n22 34\\n0 0\", \"4 3\\n22 34\\n0 0... | problem
A city in Canada where JOI lives is divided into a grid pattern by w roads that extend straight in the north-south direction and h roads that extend straight in the east-west direction.
The w roads in the north-south direction are numbered 1, 2, ..., w in order from the west. In addition, h roads in the east-... | 0 |
{"tests": "{\"inputs\": [\"1 1 1 1 1 1\\n1 1 1 0 0 0\\n1 0 0 0 1 1\\n3 0 0 3 0 0\\n3 1 0 1 3 1\\n1 2 0 2 0 1\\n0 0 1 1 0 3\\n1 0 0 1 1 0\\n0 0 0 0 0 0\", \"1 1 1 1 1 1\\n1 1 1 0 0 0\\n1 0 0 0 1 0\\n3 0 0 3 0 0\\n3 1 0 1 3 1\\n1 2 0 2 0 1\\n0 0 1 1 0 3\\n1 0 0 1 1 0\\n0 0 0 0 0 0\", \"1 1 1 1 1 1\\n1 1 1 0 0 0\\n1 0 0 0... | Currently, people's entertainment is limited to programming contests. The activity of the entertainment club of a junior high school to which she belongs is to plan and run a programming contest. Her job is not to create problems. It's a behind-the-scenes job of soliciting issues from many, organizing referees, and pro... | 0 |
{"tests": "{\"inputs\": [\"5 4\\n2 3\\n3 4\\n4 3\\n5 4\", \"5 0\", \"5 5\\n1 2\\n2 3\\n3 4\\n4 5\\n5 1\", \"6 0\", \"5 5\\n1 2\\n2 3\\n3 1\\n4 5\\n5 1\", \"7 0\", \"6 4\\n2 3\\n3 4\\n4 3\\n5 4\", \"4 0\", \"8 0\", \"1 0\", \"11 0\", \"13 0\", \"6 4\\n2 3\\n3 5\\n4 3\\n5 4\", \"3 0\", \"5 5\\n1 2\\n2 3\\n3 4\\n4 5\\n5 2... | Natsuki and her friends were taken to the space by an alien and made friends with a lot of aliens. During the space travel, she discovered that aliens’ hands were often very different from humans’. Generally speaking, in a kind of aliens, there are N fingers and M bend rules on a hand. Each bend rule describes that a f... | 0 |
{"tests": "{\"inputs\": [\"5\\n1 x 2 4 x\\n2\\nx x\\n2\\n1 2\\n2\\n2 1\\n2\\n1000000000 x\\n4\\nx 2 1 x\\n0\", \"5\\n0 x 2 4 x\\n2\\nx x\\n2\\n1 2\\n2\\n2 1\\n2\\n1000000000 x\\n4\\nx 2 1 x\\n0\", \"5\\n1 x 2 0 x\\n2\\nx x\\n2\\n1 2\\n2\\n2 1\\n2\\n1000000000 x\\n4\\nx 2 1 x\\n0\", \"5\\n0 x 2 4 x\\n2\\nx x\\n2\\n1 2\\... | Problem Statement
Nathan O. Davis is a student at the department of integrated systems.
Today's agenda in the class is audio signal processing. Nathan was given a lot of homework out. One of the homework was to write a program to process an audio signal. He copied the given audio signal to his USB memory and brought ... | 0 |
{"tests": "{\"inputs\": [\"4 3 3\\n1 1 2 3\", \"4 1 4\\n3 3 2 2\", \"6 2 2\\n0 2 2 2 2 0\", \"8 7 15\\n5 0 9 14 0 4 4 15\", \"8 10 18\\n2 12 16 14 18 4 17 16\", \"4 1 4\\n3 2 2 2\", \"6 2 2\\n1 2 2 2 2 0\", \"8 7 15\\n5 0 9 14 0 4 0 15\", \"8 10 18\\n2 12 16 14 18 4 17 10\", \"2 1 4\\n3 2 2 2\", \"8 7 15\\n5 0 1 14 0 4... | In the building of Jewelry Art Gallery (JAG), there is a long corridor in the east-west direction. There is a window on the north side of the corridor, and $N$ windowpanes are attached to this window. The width of each windowpane is $W$, and the height is $H$. The $i$-th windowpane from the west covers the horizontal r... | 0.375 |
{"tests": "{\"inputs\": [\"2\\n2\\n0 -4\\n8 0\\n2\\n0 -45\\n-3 0\", \"2\\n2\\n0 -4\\n8 0\\n2\\n0 -45\\n-2 0\", \"2\\n2\\n0 -4\\n6 0\\n2\\n0 -45\\n-2 1\", \"2\\n2\\n0 -8\\n10 0\\n2\\n0 -17\\n-3 -1\", \"2\\n2\\n0 -8\\n7 0\\n2\\n0 -45\\n-3 -1\", \"2\\n2\\n0 -8\\n2 0\\n2\\n0 -19\\n-2 0\", \"2\\n2\\n0 -4\\n8 0\\n2\\n0... | Everybody loves magic, especially magicians who compete for glory on the Byteland Magic Tournament. Magician Cyael is one such magician.
Cyael has been having some issues with her last performances and today she’ll have to perform for an audience of some judges, who will change her tournament ranking, possibly increasi... | 0 |
{"tests": "{\"inputs\": [\"5\\n6 3 2 5 0\\n1 2 10\\n2 3 3\\n2 4 1\\n1 5 1\\n\", \"3\\n1 3 3\\n1 2 2\\n1 3 2\\n\", \"10\\n28 8 0 1 5 2 9 1 2 81\\n10 1 9\\n6 5 78\\n8 4 38\\n3 10 74\\n8 6 41\\n7 2 21\\n9 2 54\\n2 6 90\\n4 1 30\\n\", \"10\\n67 9 7 2 33 5 1 7 43 55\\n2 4 38\\n2 5 77\\n9 8 91\\n9 5 8\\n10 5 4\\n2 6 49\\n9 1... | The Fair Nut is going to travel to the Tree Country, in which there are n cities. Most of the land of this country is covered by forest. Furthermore, the local road system forms a tree (connected graph without cycles). Nut wants to rent a car in the city u and go by a simple path to city v. He hasn't determined the pat... | 0 |
{"tests": "{\"inputs\": [\"5\\n1 4\\n2 5\\n3 1\\n4 5\\n\", \"10\\n7 4\\n2 7\\n10 2\\n5 6\\n9 5\\n1 9\\n8 6\\n3 7\\n10 9\\n\", \"10\\n10 9\\n9 1\\n8 3\\n3 4\\n5 8\\n6 5\\n1 8\\n6 7\\n7 2\\n\", \"3\\n3 1\\n2 1\\n\", \"2\\n2 1\\n\", \"64\\n2 20\\n37 55\\n42 29\\n36 54\\n35 50\\n60 41\\n25 61\\n31 51\\n9 43\\n26 28\\n48 56... | Asya loves animals very much. Recently, she purchased n kittens, enumerated them from 1 and n and then put them into the cage. The cage consists of one row of n cells, enumerated with integers from 1 to n from left to right. Adjacent cells had a partially transparent partition wall between them, hence there were n - 1 ... | 0 |
{"tests": "{\"inputs\": [\"7\\n\", \"1\\n\", \"39\\n\", \"15\\n\", \"524416\\n\", \"32661\\n\", \"13\\n\", \"776441\\n\", \"1365\\n\", \"85\\n\", \"4\\n\", \"42\\n\", \"917503\\n\", \"682\\n\", \"11061\\n\", \"524289\\n\", \"2\\n\", \"75861\\n\", \"2730\\n\", \"885114\\n\", \"187573\\n\", \"1557\\n\", \"524636\\n\", \"... | Cat Furrier Transform is a popular algorithm among cat programmers to create longcats. As one of the greatest cat programmers ever exist, Neko wants to utilize this algorithm to create the perfect longcat.
Assume that we have a cat with a number x. A perfect longcat is a cat with a number equal 2^m - 1 for some non-ne... | 0 |
{"tests": "{\"inputs\": [\"3\\n3\\n1 5\\n2 10\\n2 8\\n7\\n0 1\\n3 1\\n1 1\\n6 1\\n1 1\\n4 1\\n4 1\\n6\\n2 6\\n2 3\\n2 8\\n2 7\\n4 4\\n5 5\\n\", \"3\\n3\\n1 5\\n2 10\\n2 8\\n7\\n0 1\\n3 1\\n1 1\\n6 0\\n1 1\\n4 1\\n4 1\\n6\\n2 6\\n2 3\\n2 8\\n2 7\\n4 4\\n5 5\\n\", \"3\\n3\\n1 5\\n1 10\\n2 8\\n7\\n0 1\\n3 1\\n1 1\\n6 0\\n... | The only difference between easy and hard versions is constraints.
Now elections are held in Berland and you want to win them. More precisely, you want everyone to vote for you.
There are n voters, and two ways to convince each of them to vote for you. The first way to convince the i-th voter is to pay him p_i coins.... | 0 |
{"tests": "{\"inputs\": [\"4 3 7\\n7 4 17\\n3 0 8\\n11 2 0\\n13 3 5\\n3 1\\n2 1\\n4 1\\n\", \"4 3 7\\n7 4 17\\n3 0 8\\n11 2 0\\n14 3 5\\n3 1\\n2 1\\n4 3\\n\", \"4 3 7\\n7 4 17\\n3 0 8\\n11 2 0\\n13 3 5\\n3 1\\n2 1\\n4 3\\n\", \"3 2 1\\n1 0 1\\n1 0 1\\n1 0 1\\n3 1\\n3 2\\n\", \"4 4 1\\n1 0 30\\n0 1 1590\\n1 0 3728\\n1 2... | You play a strategic video game (yeah, we ran out of good problem legends). In this game you control a large army, and your goal is to conquer n castles of your opponent.
Let's describe the game process in detail. Initially you control an army of k warriors. Your enemy controls n castles; to conquer the i-th castle, y... | 0 |
{"tests": "{\"inputs\": [\"3 3\\n3 2 1\\n1 2 3\\n4 5 6\\n\", \"3 4\\n1 6 3 4\\n5 10 7 8\\n9 2 11 12\\n\", \"4 3\\n1 2 3\\n4 5 6\\n7 8 9\\n10 11 12\\n\", \"7 6\\n42104 92376 101047 169739 147311 6\\n9571 14822 9 147008 108070 179082\\n42935 148636 150709 15634 78694 117083\\n146754 101724 84463 16093 23 85271\\n153044 1... | You are given a rectangular matrix of size n × m consisting of integers from 1 to 2 ⋅ 10^5.
In one move, you can:
* choose any element of the matrix and change its value to any integer between 1 and n ⋅ m, inclusive;
* take any column and shift it one cell up cyclically (see the example of such cyclic shift belo... | 0 |
{"tests": "{\"inputs\": [\"4\\n1 3 5 7\\n1 5 5 7\\n100000 200000 300000 400000\\n1 1 977539810 977539810\\n\", \"1\\n1 3 4 7\\n\", \"14\\n2374453 2374454 8591131 23094546\\n5813291 5813292 9709163 35032815\\n4280399 23049698 23049701 34728360\\n15184184 18688462 22400847 22400849\\n24397371 31462070 33936330 33936331\\... | Ichihime is the current priestess of the Mahjong Soul Temple. She claims to be human, despite her cat ears.
These days the temple is holding a math contest. Usually, Ichihime lacks interest in these things, but this time the prize for the winner is her favorite — cookies. Ichihime decides to attend the contest. Now sh... | 0.25 |
{"tests": "{\"inputs\": [\"2\\n1 1\\n01000010\\n5 1\\n01101110\\n\", \"2\\n1 1\\n01000110\\n5 1\\n01101110\\n\", \"2\\n2 1\\n01000110\\n5 1\\n01101110\\n\", \"2\\n2 1\\n01000110\\n5 1\\n01101101\\n\", \"2\\n2 1\\n11000111\\n5 1\\n01101001\\n\", \"2\\n1 1\\n01000010\\n10 1\\n01101110\\n\", \"2\\n1 1\\n01000110\\n5 2\\n0... | Bertown is a city with n buildings in a straight line.
The city's security service discovered that some buildings were mined. A map was compiled, which is a string of length n, where the i-th character is "1" if there is a mine under the building number i and "0" otherwise.
Bertown's best sapper knows how to activate... | 0 |
{"tests": "{\"inputs\": [\"7\\n0010011\\n1111010\\n\", \"4\\n1010\\n1101\\n\", \"1\\n0\\n0\\n\", \"2\\n00\\n10\\n\", \"29\\n00001010001110100010011100110\\n11001110001010000110111110101\\n\", \"168\\n011111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111... | You are given two integers l and r in binary representation. Let g(x, y) be equal to the [bitwise XOR](https://en.wikipedia.org/wiki/Bitwise_operation#XOR) of all integers from x to y inclusive (that is x ⊕ (x+1) ⊕ ... ⊕ (y-1) ⊕ y). Let's define f(l, r) as the maximum of all values of g(x, y) satisfying l ≤ x ≤ y ≤ r.
... | 0 |
{"tests": "{\"inputs\": [\"2\\n3\\n0 2 2\\n4\\n2 3 1 10\\n\", \"1\\n5\\n3 3 3 2 2\\n\", \"1\\n4\\n3 3 3 0\\n\", \"1\\n4\\n0 3 3 3\\n\", \"1\\n5\\n1 8 7 7 1\\n\", \"1\\n3\\n0 0 0\\n\", \"15\\n2\\n660632533 660632533\\n2\\n774306959 774306959\\n2\\n971739496 784083784\\n2\\n775353256 672614891\\n2\\n403290217 403290217\\... | Baby Ehab is known for his love for a certain operation. He has an array a of length n, and he decided to keep doing the following operation on it:
* he picks 2 adjacent elements; he then removes them and places a single integer in their place: their [bitwise XOR](https://en.wikipedia.org/wiki/Bitwise_operation#XOR... | 0.5 |
{"tests": "{\"inputs\": [\"4\\n0.2 0.2 0.6 0.2\\n0.4 0.2 0.4 0.8\\n0.4998 0.4998 0.0004 0.1666\\n0.3125 0.6561 0.0314 0.2048\\n\", \"10\\n0.1816 0.7813 0.0371 0.6860\\n0.4789 0.1463 0.3748 0.6186\\n0.1431 0.3218 0.5351 0.6905\\n0.7071 0.0774 0.2155 0.1087\\n0.7082 0.0144 0.2774 0.7364\\n0.0824 0.4306 0.4870 0.5198\\n0.... | After defeating a Blacklist Rival, you get a chance to draw 1 reward slip out of x hidden valid slips. Initially, x=3 and these hidden valid slips are Cash Slip, Impound Strike Release Marker and Pink Slip of Rival's Car. Initially, the probability of drawing these in a random guess are c, m, and p, respectively. There... | 0 |
{"tests": "{\"inputs\": [\"5\\n\", \"4\\n\", \"2\\n\", \"3\\n\", \"1\\n\"], \"outputs\": [\"1\", \"2\", \"3\", \"1\", \"2\"]}", "source": "primeintellect"} | "This problem is rubbish! There is not statement, and there are only 5 test cases. The problemsetter took liberties with this problem!" — people complained in the comments to one round on Codeforces. And even more... No, wait, the checker for the problem was alright, that's a mercy.
Input
The only line of the input c... | 0 |
{"tests": "{\"inputs\": [\"5 4\\n1000000000000000\\n5 4 3 2 1\\n\", \"5 2\\n8\\n3 2 4 1 5\\n\", \"5 2\\n8\\n2 4 5 3 1\\n\", \"10 1\\n297\\n215 281 102 280 243 225 294 296 7383 2623\\n\", \"10 4\\n1834\\n11 44 49 420 93 653 306 596 535 842\\n\", \"10 2\\n1523\\n661 230 363 300 28 72 676 741 837 984\\n\", \"100 10\\n9199... | In the capital city of Berland, Bertown, demonstrations are against the recent election of the King of Berland. Berland opposition, led by Mr. Ovalny, believes that the elections were not fair enough and wants to organize a demonstration at one of the squares.
Bertown has n squares, numbered from 1 to n, they are numb... | 0 |
{"tests": "{\"inputs\": [\"4\\n1 2 2 1\\n2 3 4\\n\", \"4\\n1 1 1 1\\n1 3\\n\", \"2\\n1 1\\n0\\n\", \"3\\n1 1 1\\n0\\n\", \"8\\n1 1 2 1 1 2 1 1\\n2 7 8\\n\", \"8\\n3 3 1 1 1 1 3 3\\n1 6\\n\", \"4\\n1 1 1 1\\n2 3 4\\n\", \"6\\n2 1 1 2 1 1\\n1 5\\n\", \"20\\n3 3 3 2 2 3 1 1 3 2 1 3 3 1 2 3 1 1 3 3\\n1 16\\n\", \"14\\n1 2 ... | As you know, Vova has recently become a new shaman in the city of Ultima Thule. So, he has received the shaman knowledge about the correct bracket sequences. The shamans of Ultima Thule have been using lots of different types of brackets since prehistoric times. A bracket type is a positive integer. The shamans define ... | 0 |
{"tests": "{\"inputs\": [\"1 1\\n1 2\\n\", \"12 2\\n4 1\\n8 1\\n\", \"3 1\\n1 1\\n\", \"10 4\\n8 2\\n2 2\\n5 2\\n7 2\\n\", \"30 4\\n11 2\\n8 2\\n21 1\\n23 1\\n\", \"18 4\\n6 2\\n10 2\\n13 1\\n12 1\\n\", \"97 15\\n63 2\\n35 2\\n74 2\\n20 2\\n60 1\\n31 2\\n68 1\\n21 2\\n42 1\\n29 1\\n44 2\\n79 1\\n73 2\\n53 1\\n77 1\\n\"... | In a far away land, there are two cities near a river. One day, the cities decide that they have too little space and would like to reclaim some of the river area into land.
The river area can be represented by a grid with r rows and exactly two columns — each cell represents a rectangular area. The rows are numbered ... | 0 |
{"tests": "{\"inputs\": [\"10\\n0\\n1\\n0\\n1\\n2\\n0\\n1\\n2\\n3\\n0\\n\", \"4\\n1\\n2\\n3\\n0\\n\", \"55\\n73792\\n39309\\n73808\\n47389\\n34803\\n87947\\n32460\\n14649\\n70151\\n35816\\n8272\\n78886\\n71345\\n61907\\n16977\\n85362\\n0\\n43792\\n8118\\n83254\\n89459\\n32230\\n87068\\n82617\\n94847\\n83528\\n37629\\n3... | Dima has a birthday soon! It's a big day! Saryozha's present to Dima is that Seryozha won't be in the room and won't disturb Dima and Inna as they celebrate the birthday. Inna's present to Dima is a stack, a queue and a deck.
Inna wants her present to show Dima how great a programmer he is. For that, she is going to g... | 0 |
{"tests": "{\"inputs\": [\"3 2\\n8 3 8\\n1 2\\n2 3\\n\", \"3 2\\n8 12 8\\n1 2\\n2 3\\n\", \"20 10\\n512 64 536870912 256 1 262144 8 2097152 8192 524288 32 2 16 16777216 524288 64 268435456 256 67108864 131072\\n17 20\\n2 13\\n11 12\\n18 19\\n4 7\\n4 13\\n8 9\\n14 17\\n8 19\\n7 10\\n\", \"10 25\\n2048 536870912 64 65536... | You have written on a piece of paper an array of n positive integers a[1], a[2], ..., a[n] and m good pairs of integers (i1, j1), (i2, j2), ..., (im, jm). Each good pair (ik, jk) meets the following conditions: ik + jk is an odd number and 1 ≤ ik < jk ≤ n.
In one operation you can perform a sequence of actions:
* ... | 0 |
{"tests": "{\"inputs\": [\"2 4 3\\n13 20\\n1 1 14\\n1 2 30\\n2 1 6\\n3 2 2\\n\", \"10 6 6\\n2 2 1 8 5 3 8 5 3 4\\n3 8 5\\n3 10 1\\n3 7 8\\n2 3 5\\n1 5 1\\n3 8 5\\n\", \"1 1 1\\n8\\n2 1 8\\n\", \"10 10 10\\n8 8 8 8 8 8 8 8 8 8\\n2 5 8\\n2 4 8\\n2 1 8\\n2 7 8\\n2 10 8\\n2 9 8\\n2 6 8\\n2 3 8\\n2 2 8\\n2 8 8\\n\", \"10 7 ... | Vasya plays one very well-known and extremely popular MMORPG game. His game character has k skill; currently the i-th of them equals to ai. Also this game has a common rating table in which the participants are ranked according to the product of all the skills of a hero in the descending order.
Vasya decided to 'upgra... | 0 |
{"tests": "{\"inputs\": [\"4 2\\nxx\\ncf\\nae\\nxx\\n\", \"4 4\\nxxxx\\nxfax\\nxcex\\nxxxx\\n\", \"1 4\\nface\\n\", \"2 3\\nfac\\ncef\\n\", \"2 5\\nacdmw\\nefazb\\n\", \"5 5\\nacnbx\\nefacp\\nlrefa\\norqce\\nzvbay\\n\", \"5 5\\nbyjvu\\nkmaca\\nalefe\\nwcacg\\nrefez\\n\", \"5 5\\nkjxbw\\neacra\\nxefhx\\nucmcz\\npgtjk\\n... | The developers of Looksery have to write an efficient algorithm that detects faces on a picture. Unfortunately, they are currently busy preparing a contest for you, so you will have to do it for them.
In this problem an image is a rectangular table that consists of lowercase Latin letters. A face on the image is a 2 ... | 0.875 |
{"tests": "{\"inputs\": [\"1\\n\", \"3\\n\", \"99\\n\", \"19\\n\", \"536870910\\n\", \"100\\n\", \"987654321\\n\", \"8\\n\", \"13\\n\", \"1000000000\\n\", \"536870912\\n\", \"4124980\\n\", \"20\\n\", \"14\\n\", \"11\\n\", \"18\\n\", \"9\\n\", \"17\\n\", \"16\\n\", \"2\\n\", \"6\\n\", \"9999\\n\", \"10\\n\", \"4\\n\", \... | Way to go! Heidi now knows how many brains there must be for her to get one. But throwing herself in the midst of a clutch of hungry zombies is quite a risky endeavor. Hence Heidi wonders: what is the smallest number of brains that must be in the chest for her to get out at all (possibly empty-handed, but alive)?
The ... | 0 |
{"tests": "{\"inputs\": [\"4 4\\n\", \"31 8\\n\", \"3 2\\n\", \"7 3\\n\", \"6 1\\n\", \"50 33\\n\", \"48 20\\n\", \"3 1\\n\", \"3 4\\n\", \"4 1\\n\", \"50 50\\n\", \"6 6\\n\", \"8 5\\n\", \"3 3\\n\", \"10 4\\n\", \"6 7\\n\", \"1 2\\n\", \"4 2\\n\", \"7 5\\n\", \"7 6\\n\", \"2 2\\n\", \"50 2\\n\", \"4 5\\n\", \"7 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\": [\"5 1\\n-4 -5 -3 -2 -1\\n\", \"5 2\\n1 2 3 4 5\\n\", \"3 2\\n1 5 3\\n\", \"10 2\\n10 9 1 -9 -7 -9 3 8 -10 5\\n\", \"14 2\\n-14 84 44 46 -75 -75 77 -49 44 -82 -74 -51 -9 -50\\n\", \"9 3\\n2 2 2 2 9 2 2 2 2\\n\", \"5 2\\n5 2 1 9 3\\n\", \"7 3\\n1 1 1 10 1 1 1\\n\", \"2 2\\n-333653905 224013643\\n... | You are given an array a1, a2, ..., an consisting of n integers, and an integer k. You have to split the array into exactly k non-empty subsegments. You'll then compute the minimum integer on each subsegment, and take the maximum integer over the k obtained minimums. What is the maximum possible integer you can get?
D... | 0 |
{"tests": "{\"inputs\": [\"2 2\\nmain 192.168.0.2\\nreplica 192.168.0.1\\nblock 192.168.0.1;\\nproxy 192.168.0.2;\\n\", \"3 5\\ngoogle 8.8.8.8\\ncodeforces 212.193.33.27\\nserver 138.197.64.57\\nredirect 138.197.64.57;\\nblock 8.8.8.8;\\ncf 212.193.33.27;\\nunblock 8.8.8.8;\\ncheck 138.197.64.57;\\n\", \"2 2\\nmain 0.0... | As the guys fried the radio station facilities, the school principal gave them tasks as a punishment. Dustin's task was to add comments to nginx configuration for school's website. The school has n servers. Each server has a name and an ip (names aren't necessarily unique, but ips are). Dustin knows the ip and name of ... | 0.375 |
{"tests": "{\"inputs\": [\"19\\n3\\n4\\n2\\n\", \"9\\n2\\n3\\n1\\n\", \"5\\n5\\n2\\n20\\n\", \"1000000000\\n1999999999\\n789987\\n184569875\\n\", \"1000999777\\n1934999345\\n2356346\\n34534565\\n\", \"2000000000\\n2\\n1\\n2000000000\\n\", \"1999888325\\n3\\n2\\n2000000000\\n\", \"20\\n1\\n20\\n1\\n\", \"15\\n2\\n5\\n2\... | Right now she actually isn't. But she will be, if you don't solve this problem.
You are given integers n, k, A and B. There is a number x, which is initially equal to n. You are allowed to perform two types of operations:
1. Subtract 1 from x. This operation costs you A coins.
2. Divide x by k. Can be performed... | 0.125 |
{"tests": "{\"inputs\": [\"2\\n2 3\\n1 0\\n\\nSAMPLE\", \"2\\n3 3\\n1 0\\n\\nSAMPLE\", \"2\\n3 3\\n1 1\\n\\nSAMPLE\", \"2\\n3 0\\n1 1\\n\\nSAMPLE\", \"2\\n5 0\\n1 1\\n\\nSAMPLE\", \"2\\n5 0\\n1 2\\n\\nSAMPLE\", \"2\\n5 0\\n2 1\\n\\nSMAPLE\", \"2\\n5 -1\\n2 1\\n\\nSMAPLE\", \"2\\n5 -1\\n1 1\\n\\nSMAPLE\", \"2\\n2 -1\\n1... | Little Vaishnavi is bored during the vacation which is going on. Being the only little girl in the neighbourhood she did not have any one else to play with. Her parents are so strict that they will not let her out of the house even to see what the kids from the other houses are playing.
So she decided to make a game o... | 0 |
{"tests": "{\"inputs\": [\"3\\n4\\n0 1 1 0 \\n0 0 1 0 \\n0 0 0 0 \\n0 1 1 0 \\n4\\n0 0 0 1 \\n0 0 0 0 \\n1 1 1 0 \\n1 0 0 0 \\n4\\n0 1 1 0 \\n0 0 1 1 \\n0 0 0 0 \\n0 1 0 0 \\n \\nSAMPLE\", \"3\\n4\\n0 1 1 0 \\n0 0 1 0 \\n0 0 0 0 \\n0 1 1 0 \\n4\\n0 0 0 1 \\n0 0 0 0 \\n1 1 1 0 \\n1 0 0 0 \\n4\\n0 1 1 0 \\n0 0 1 1 \\n0 0... | Alfie was a prisoner in mythland. Though Alfie was a witty and intelligent guy.He was confident of escaping prison.After few days of observation,He figured out that the prison consists of (N × N) cells.i.e The shape of prison was (N × N) matrix. Few of the cells of the prison contained motion detectors.So Alfie planned... | 0.125 |
{"tests": "{\"inputs\": [\"1 1\\n1\\n1\", \"3 5\\n5\\n1 2 3 4 5\", \"2 2\\n3\\n2 1 1\", \"2 2\\n2\\n3 1 1\", \"2 1\\n1\\n2\", \"1 2\\n1\\n2\", \"2 2\\n3\\n1 1 2\", \"3 5\\n5\\n1 2 5 4 3\", \"1 4\\n2\\n3 1 0\", \"2 2\\n3\\n1 2 1\", \"2 2\\n2\\n2 2 1\", \"1 4\\n3\\n2 2 0\", \"3 5\\n5\\n1 2 6 4 2\", \"2 2\\n3\\n4 0 0\", \... | We have a grid with H rows and W columns of squares. Snuke is painting these squares in colors 1, 2, ..., N. Here, the following conditions should be satisfied:
* For each i (1 ≤ i ≤ N), there are exactly a_i squares painted in Color i. Here, a_1 + a_2 + ... + a_N = H W.
* For each i (1 ≤ i ≤ N), the squares painted i... | 0.125 |
{"tests": "{\"inputs\": [\"100000\", \"3\", \"10\", \"100001\", \"1\", \"15\", \"110001\", \"21\", \"110011\", \"39\", \"11\", \"6\", \"4\", \"7\", \"2\", \"101001\", \"8\", \"18\", \"110000\", \"111011\", \"30\", \"110111\", \"65\", \"5\", \"101000\", \"12\", \"110100\", \"111010\", \"40\", \"110010\", \"22\", \"9\", ... | Snuke loves working out. He is now exercising N times.
Before he starts exercising, his power is 1. After he exercises for the i-th time, his power gets multiplied by i.
Find Snuke's power after he exercises N times. Since the answer can be extremely large, print the answer modulo 10^{9}+7.
Constraints
* 1 ≤ N ≤ 10... | 0.75 |
{"tests": "{\"inputs\": [\"48 9297 240 126 32\\n20 3010 157 141 7\\n30 117002 5680 962 15\\n8 1673 1712 190 22\\n64 8478 87 54 307\\n23 5477 117 92 12\\n50 7558 1396 187 17\\n279 88677 4522 514 14\\n0\", \"48 9297 240 126 32\\n20 3010 157 141 7\\n30 117002 5680 962 15\\n8 1673 1712 190 22\\n64 8478 87 54 307\\n23 5477 ... | In April 2008, Aizuwakamatsu City succeeded in making yakitori with a length of 20 m 85 cm. The chicken used at this time is Aizu local chicken, which is a specialty of Aizu. Aizu local chicken is very delicious, but it is difficult to breed, so the production volume is small and the price is high.
<image>
Relative... | 0 |
{"tests": "{\"inputs\": [\"5\\n1.3\\n3\\n1\\n2\\n1\\n1.4\\n3\\n1\\n2\\n1\\n2.0\\n3\\n1\\n2\\n1\\n1.59\\n4\\n2\\n1\\n1\\n3\\n1.7143\\n4\\n1\\n2\\n3\\n5\", \"5\\n1.562976116968605\\n3\\n1\\n2\\n1\\n1.4\\n3\\n1\\n2\\n1\\n2.0\\n3\\n1\\n2\\n1\\n1.59\\n4\\n2\\n1\\n1\\n3\\n1.7143\\n4\\n1\\n2\\n3\\n5\", \"5\\n1.562976116968605... | There is a mysterious planet called Yaen, whose space is 2-dimensional. There are many beautiful stones on the planet, and the Yaen people love to collect them. They bring the stones back home and make nice mobile arts of them to decorate their 2-dimensional living rooms.
In their 2-dimensional world, a mobile is defi... | 0 |
{"tests": "{\"inputs\": [\"4 3\\n110\\n101\\n011\\n110\\n7 1\\n1\\n1\\n1\\n1\\n1\\n1\\n1\\n4 5\\n10000\\n01000\\n00100\\n00010\\n6 6\\n111111\\n011000\\n100000\\n000010\\n100001\\n100100\\n0 0\", \"4 3\\n110\\n101\\n011\\n110\\n7 1\\n0\\n1\\n1\\n1\\n1\\n1\\n1\\n4 5\\n10000\\n01000\\n00100\\n00010\\n6 6\\n111111\\n01100... | Making Lunch Boxes
Taro has been hooked on making lunch boxes recently. Taro has obtained a new lunch box recipe book today, and wants to try as many of the recipes listed in the book as possible.
Enough of the ingredients for all the recipes are at hand, but they all are in vacuum packs of two. If only one of them i... | 0.25 |
{"tests": "{\"inputs\": [\"3\\n1 2 3\", \"5\\n1 4 3 5 2\", \"10\\n3 1 5 2 7 4 9 6 10 8\", \"5\\n3 1 5 2 4\", \"10\\n3 0 5 2 7 4 9 6 10 8\", \"5\\n3 1 5 4 2\", \"3\\n1 3 2\", \"10\\n3 0 5 2 7 4 9 6 17 8\", \"10\\n3 0 5 1 7 4 9 6 17 8\", \"10\\n3 0 5 1 7 4 12 6 17 8\", \"10\\n3 0 5 2 7 4 9 6 11 8\", \"10\\n3 0 5 2 7 4 10... | A permutation of N numbers from 1 to N A1, A2, ……, AN is given. You can perform the operation reverse (i, j) to reverse the order of the numbers in the interval [i, j] (1 ≤ i ≤ j ≤ N) for this permutation. For example, if reverse (2, 4) is applied to [1, 2, 3, 4, 5], it becomes [1, 4, 3, 2, 5]. Calculate how many opera... | 0 |
{"tests": "{\"inputs\": [\"1 2 5\\n6\\n10000\", \"2 3 5\\n4 5\\n6 3\\n8 5\", \"3 3 10\\n10 9 6\\n8 7 3\\n7 5 1\", \"2 2 5\\n3 2\\n5 4\", \"3 3 10\\n10 9 6\\n14 7 3\\n7 5 1\", \"3 3 10\\n10 8 13\\n14 3 4\\n5 5 1\", \"3 3 10\\n10 8 13\\n14 3 4\\n5 4 1\", \"1 2 5\\n4\\n10000\", \"2 3 5\\n4 5\\n6 3\\n8 6\", \"2 2 6\\n3 2\\... | After many years of research, Ikta has acquired the ability to predict the future! The time and money he spent on this research was enormous, but it's finally time to be rewarded. To get the money back, Ikta decided to start investing in stocks.
Ikta does not currently own any shares, but owns x yen. He has invested i... | 0 |
{"tests": "{\"inputs\": [\"7\\nbanana\\nat\\ntomb\\nbus\\nsound\\ndoes\\nsome\", \"7\\nbanana\\nta\\ntomb\\nbus\\nsound\\ndoes\\nsome\", \"7\\nananab\\nta\\nsomb\\nbus\\nsound\\ndoes\\nsemo\", \"7\\nbanaoa\\nta\\ntomb\\nbus\\nsound\\ndoes\\nsome\", \"7\\nbanaoa\\nta\\nuomb\\nbus\\nsound\\ndoes\\nsome\", \"7\\nbanaoa\\n... | D: Shiritori Compression
problem
Ebi-chan and Kana-chan did a shiritori. Ebi-chan is looking at the memo of the word that came out in Shiritori.
Ebi-chan wants to remove redundant continuous subsequences from this word sequence w_1, w_2, ..., w_N until they no longer exist. The redundant continuous subsequence that ... | 0.25 |
{"tests": "{\"inputs\": [\"64783 68943\", \"20 10\", \"1000000000000000000 1000000000000000000\", \"10 20\", \"57319 68943\", \"25 10\", \"1000000000000000000 1000000000010000000\", \"10 36\", \"105904 68943\", \"25 12\", \"1000000001000000000 1000000000010000000\", \"10 48\", \"109335 68943\", \"13 12\", \"10000010010... | Problem
There are $ 2 $ teams, Team UKU and Team Ushi. Initially, Team UKU has $ N $ people and Team Uku has $ M $ people. Team UKU and Team Ushi decided to play a game called "U & U". "U & U" has a common score for $ 2 $ teams, and the goal is to work together to minimize the common score. In "U & U", everyone's phys... | 0 |
{"tests": "{\"inputs\": [\"3\\n3 0 1 3\\n1 3\\n3 0 1 2\\n8\\n1 0\\n2 1\\n3 1\\n4 2\\n5 2\\n6 2\\n7 2\\n8 2\", \"3\\n3 0 1 3\\n1 3\\n3 0 0 2\\n8\\n1 0\\n2 1\\n3 1\\n4 2\\n5 2\\n6 2\\n7 2\\n8 2\", \"3\\n3 0 1 3\\n0 3\\n3 0 0 2\\n8\\n1 0\\n2 1\\n3 1\\n4 2\\n5 2\\n6 2\\n7 2\\n8 2\", \"3\\n3 0 1 3\\n1 3\\n3 0 0 2\\n8\\n1 0\... | A state with $n$ flags of ON or OFF can be represented by a sequence of bits where $0, 1, ..., n-1$ th flag corresponds to 1 (ON) or 0 (OFF). The state can be managed by the corresponding decimal integer, because the sequence of bits is a binary representation where each bit is 0 or 1.
On the other hand, a mask is a s... | 0 |
{"tests": "{\"inputs\": [\"3\\n2\\n5 -5\\n2\\n-5 5\\n3\\n1 2 -3\", \"3\\n1\\n5 -5\\n2\\n-5 5\\n3\\n1 2 -3\", \"3\\n2\\n5 -5\\n2\\n-5 5\\n3\\n0 3 -3\", \"3\\n1\\n5 -5\\n1\\n-5 5\\n2\\n1 3 -4\", \"3\\n1\\n5 -5\\n2\\n-8 8\\n2\\n1 2 -3\", \"3\\n1\\n5 -5\\n1\\n-5 5\\n3\\n1 2 -3\", \"3\\n2\\n5 -5\\n2\\n-5 5\\n2\\n1 2 -3\", \... | DevuLand is a very strange place. There are n villages in it. Some of the villages are occupied by dinosaurs while the remaining ones by villagers.
You are given the information of DevuLand
by an array D of size n. If D[i] is non-negative, it means that there are D[i] villagers in that village.
Otherwise, it means t... | 0 |
{"tests": "{\"inputs\": [\"1\\n5 2 3\\n1 4\\n3 5\\n1 5\", \"1\\n5 2 3\\n1 4\\n3 5\\n0 5\", \"1\\n5 2 3\\n1 3\\n3 5\\n1 5\", \"1\\n5 2 3\\n2 4\\n3 5\\n0 5\", \"1\\n5 2 3\\n2 4\\n2 5\\n0 5\", \"1\\n5 2 3\\n2 4\\n2 8\\n0 5\", \"1\\n10 2 3\\n1 6\\n3 5\\n1 5\", \"1\\n4 2 3\\n1 6\\n3 9\\n1 5\", \"1\\n5 2 3\\n5 4\\n2 5\\n0 3\... | At the end of a busy day, The Chef and his assistants play a game together. The game is not just for fun but also used to decide who will have to clean the kitchen. The Chef is a Game Master, so his concern is how to manage the game but not how to win the game like his assistants do.
The game requires players to find... | 0.25 |
{"tests": "{\"inputs\": [\"2\\n12\\n11 8\\n7 5\\n\", \"3\\n1\\n1 4 1\\n2 5 3\\n\", \"6\\n2\\n4 6 3 3 5 6\\n2 6 3 6 5 3\\n\", \"90\\n35\\n1 68 16 30 24 1 1 1 35 1 1 67 1 1 1 1 33 16 37 77 83 1 77 26 1 1 68 67 70 62 1 47 1 1 1 84 1 65 1 32 83 1 1 1 28 1 71 76 84 1 1 5 1 74 10 1 1 1 38 87 13 1 7 66 81 49 1 9 1 11 1 25 1 1... | Natasha is going to fly on a rocket to Mars and return to Earth. Also, on the way to Mars, she will land on n - 2 intermediate planets. Formally: we number all the planets from 1 to n. 1 is Earth, n is Mars. Natasha will make exactly n flights: 1 → 2 → … n → 1.
Flight from x to y consists of two phases: take-off from ... | 0.375 |
{"tests": "{\"inputs\": [\"3\\n1 2 3\\n3\\n1 2 3\\n\", \"5\\n11 2 3 5 7\\n4\\n11 7 3 7\\n\", \"2\\n1 2\\n1\\n100\\n\", \"2\\n2 3\\n1\\n2\\n\", \"49\\n63 13 6 1 50 37 1 1 1 6 34 9 4 2 1 2 3 46 11 1 2 3 4 1 6 74 7 3 1 1 31 18 20 15 1 74 6 2 1 1 6 46 13 29 2 20 44 1 1\\n45\\n54 19 5 1 1 3 81 1 4 3 1 5 1 28 18 3 5 1 23 33 ... | Vasya has two arrays A and B of lengths n and m, respectively.
He can perform the following operation arbitrary number of times (possibly zero): he takes some consecutive subsegment of the array and replaces it with a single element, equal to the sum of all elements on this subsegment. For example, from the array [1, ... | 0 |
{"tests": "{\"inputs\": [\"5\\n1 2 0 2 1\\n3\\n1 0 1\\n\", \"7\\n2 3 1 6 5 4 6\\n4\\n1 3 5 6\\n\", \"9\\n7 4 4 5 0 6 5 4 10\\n4\\n5 2 10 9\\n\", \"13\\n55 160 86 99 92 148 81 36 216 191 214 127 44\\n85\\n92 12 64 21 221 225 119 243 147 47 244 112 212 237 209 121 81 239 43 104 3 254 52 13 1 210 28 18 199 75 251 146 77 2... | This problem differs from one which was on the online contest.
The sequence a1, a2, ..., an is called increasing, if ai < ai + 1 for i < n.
The sequence s1, s2, ..., sk is called the subsequence of the sequence a1, a2, ..., an, if there exist such a set of indexes 1 ≤ i1 < i2 < ... < ik ≤ n that aij = sj. In other wo... | 0 |
{"tests": "{\"inputs\": [\"14 5\\n48 19 6 9 50 20 3 42 38 43 36 21 44 6\\n\", \"2 2\\n49 100\\n\", \"4 2\\n32 100 33 1\\n\", \"1 100\\n79\\n\", \"50 3\\n33 7 96 30 68 37 44 50 100 71 12 100 72 43 17 75 59 96 16 34 25 3 90 45 7 55 92 59 30 25 96 23 40 41 95 99 93 79 89 11 76 60 4 100 75 14 37 39 87 47\\n\", \"100 10\\n3... | Vasya likes taking part in Codeforces contests. When a round is over, Vasya follows all submissions in the system testing tab.
There are n solutions, the i-th of them should be tested on a_i tests, testing one solution on one test takes 1 second. The solutions are judged in the order from 1 to n. There are k testing p... | 0.875 |
{"tests": "{\"inputs\": [\"3\\n1 5 10\\n3 5 7\\n\", \"5\\n2 2 7 4 9\\n5 4 5 5 5\\n\", \"1\\n1\\n1\\n\", \"1\\n1\\n1000000000\\n\", \"5\\n16 2 8 19 4\\n10 9 10 10 10\\n\", \"5\\n12 19 11 13 16\\n14 14 14 14 15\\n\", \"2\\n1 5\\n3 4\\n\", \"5\\n19 9 3 20 2\\n11 11 10 11 10\\n\", \"20\\n53 86 76 100 16 12 13 97 79 23 28 6... | There are n stones arranged on an axis. Initially the i-th stone is located at the coordinate s_i. There may be more than one stone in a single place.
You can perform zero or more operations of the following type:
* take two stones with indices i and j so that s_i ≤ s_j, choose an integer d (0 ≤ 2 ⋅ d ≤ s_j - s_i)... | 0 |
{"tests": "{\"inputs\": [\"2 3\\nPPW\\nW.P\\n\", \"3 3\\nP.W\\n.P.\\nW.P\\n\", \"10 10\\nPPPPPPPPPP\\nPPPPPPPWPP\\nPPPPPPPPPP\\nPPPPPPPPPP\\nPPPPPPPPPP\\nPPPPPPPPPP\\nPPPPPPPPPP\\nPPPPPPPPPP\\nPPPPPPPPPP\\nPPPPPPPPPP\\n\", \"10 1\\n.\\nW\\nW\\nP\\nP\\n.\\n.\\n.\\nW\\nP\\n\", \"4 8\\n..PW..WW\\nWWPP.PP.\\nP...PW.P\\nP.W... | Once upon a time there were several little pigs and several wolves on a two-dimensional grid of size n × m. Each cell in this grid was either empty, containing one little pig, or containing one wolf.
A little pig and a wolf are adjacent if the cells that they are located at share a side. The little pigs are afraid of ... | 0.75 |
{"tests": "{\"inputs\": [\"3 2\\n0 0\\n0 0\\n0 0\\n\", \"3 3\\n1 1 1\\n1 1 1\\n0 1 1\\n\", \"3 3\\n1 0 1\\n1 0 1\\n0 0 0\\n\", \"4 4\\n1 1 1 1\\n1 1 1 1\\n0 1 0 0\\n0 0 0 0\\n\", \"2 2\\n1 1\\n1 0\\n\", \"4 4\\n1 1 0 0\\n1 1 1 0\\n1 0 1 1\\n1 0 1 1\\n\", \"3 3\\n1 1 0\\n1 1 0\\n1 0 0\\n\", \"3 3\\n0 1 0\\n0 1 1\\n0 1 1... | You are given two matrices A and B. Each matrix contains exactly n rows and m columns. Each element of A is either 0 or 1; each element of B is initially 0.
You may perform some operations with matrix B. During each operation, you choose any submatrix of B having size 2 × 2, and replace every element in the chosen sub... | 0.125 |
{"tests": "{\"inputs\": [\"10 2\\n7 6 18 6 16 18 1 17 17\\n6 9 3 10 9 1 10 1 5\\n\", \"10 1\\n3 2 3 1 3 3 1 4 1\\n1 2 3 4 4 1 2 1 3\\n\", \"10 2\\n7 6 18 6 16 18 1 17 17\\n6 17 3 10 9 1 10 1 5\\n\", \"10 1\\n3 0 3 1 3 3 1 4 1\\n1 2 3 4 4 1 2 1 3\\n\", \"10 2\\n7 6 18 6 16 18 2 17 17\\n6 17 3 10 9 1 10 1 5\\n\", \"10 1\... | You are planning to buy an apartment in a n-floor building. The floors are numbered from 1 to n from the bottom to the top. At first for each floor you want to know the minimum total time to reach it from the first (the bottom) floor.
Let:
* a_i for all i from 1 to n-1 be the time required to go from the i-th floor... | 0 |
{"tests": "{\"inputs\": [\"3\\n1\\n1\\n5\\n1 4 5 9 10\\n2\\n3 4\\n\", \"3\\n1\\n1\\n5\\n1 4 5 9 10\\n2\\n1 4\\n\", \"3\\n1\\n1\\n5\\n1 4 5 9 10\\n2\\n2 4\\n\", \"3\\n1\\n1\\n5\\n1 4 5 7 10\\n2\\n1 4\\n\", \"3\\n1\\n1\\n5\\n1 4 5 8 10\\n2\\n2 4\\n\", \"3\\n1\\n1\\n5\\n1 2 5 9 10\\n2\\n2 4\\n\", \"3\\n1\\n1\\n5\\n1 2 5 9... | You have 2n integers 1, 2, ..., 2n. You have to redistribute these 2n elements into n pairs. After that, you choose x pairs and take minimum elements from them, and from the other n - x pairs, you take maximum elements.
Your goal is to obtain the set of numbers \\{b_1, b_2, ..., b_n\} as the result of taking elements ... | 0 |
{"tests": "{\"inputs\": [\"1 3\\n\", \"5 5\\n\", \"773 467\\n\", \"50 372\\n\", \"329 31\\n\", \"155 534\\n\", \"267 270\\n\", \"459 487\\n\", \"377 720\\n\", \"0 1000\\n\", \"713 65\\n\", \"1000 483\\n\", \"100 1\\n\", \"67 420\\n\", \"1000 0\\n\", \"132 781\\n\", \"10 583\\n\", \"815 665\\n\", \"691 417\\n\", \"226 7... | The dragon and the princess are arguing about what to do on the New Year's Eve. The dragon suggests flying to the mountains to watch fairies dancing in the moonlight, while the princess thinks they should just go to bed early. They are desperate to come to an amicable agreement, so they decide to leave this up to chanc... | 0.25 |
{"tests": "{\"inputs\": [\"6\\n4\\n..*.\\n....\\n*...\\n....\\n2\\n*.\\n.*\\n2\\n.*\\n.*\\n3\\n*.*\\n...\\n...\\n5\\n.....\\n..*..\\n.....\\n.*...\\n.....\\n4\\n....\\n....\\n*...\\n*...\\n\", \"6\\n4\\n..*.\\n....\\n*...\\n....\\n2\\n*.\\n.*\\n2\\n*.\\n.*\\n3\\n*.*\\n...\\n...\\n5\\n.....\\n..*..\\n.....\\n.*...\\n...... | There is a square field of size n × n in which two cells are marked. These cells can be in the same row or column.
You are to mark two more cells so that they are the corners of a rectangle with sides parallel to the coordinate axes.
For example, if n=4 and a rectangular field looks like this (there are asterisks in ... | 0.125 |
{"tests": "{\"inputs\": [\"3 4\\n1 2 3\\n\", \"3 10\\n10 20 30\\n\", \"100 37\\n20 20 3 35 36 14 30 9 33 36 32 46 43 22 43 50 34 6 13 25 1 34 10 6 21 30 19 17 1 23 9 23 38 21 7 43 49 28 33 42 4 19 39 23 12 42 31 13 26 23 1 26 24 48 10 6 12 48 40 18 10 26 9 5 22 45 46 23 46 34 34 45 3 7 16 39 14 29 48 1 12 37 4 20 29 26... | A median in an array with the length of n is an element which occupies position number <image> after we sort the elements in the non-decreasing order (the array elements are numbered starting with 1). A median of an array (2, 6, 1, 2, 3) is the number 2, and a median of array (0, 96, 17, 23) — the number 17.
We define... | 0 |
{"tests": "{\"inputs\": [\"8\\n\", \"7\\n\", \"44\\n\", \"30\\n\", \"987549745\\n\", \"674810014\\n\", \"545794012\\n\", \"15478459\\n\", \"1000\\n\", \"1000000\\n\", \"794512405\\n\", \"42\\n\", \"10000\\n\", \"25\\n\", \"245\\n\", \"301542785\\n\", \"9\\n\", \"10000000\\n\", \"10\\n\", \"40\\n\", \"74\\n\", \"6874584... | There have recently been elections in the zoo. Overall there were 7 main political parties: one of them is the Little Elephant Political Party, 6 other parties have less catchy names.
Political parties find their number in the ballot highly important. Overall there are m possible numbers: 1, 2, ..., m. Each of these 7... | 0 |
{"tests": "{\"inputs\": [\"2\\n1 1\\n\", \"3\\n1 2 1\\n\", \"2\\n1 2\\n\", \"3\\n299 290 288\\n\", \"3\\n124 47 228\\n\", \"2\\n41 29\\n\", \"2\\n15 9\\n\", \"3\\n299 299 298\\n\", \"3\\n4 19 23\\n\", \"1\\n6\\n\", \"2\\n183 113\\n\", \"3\\n0 87 87\\n\", \"3\\n299 299 299\\n\", \"2\\n159 98\\n\", \"2\\n80 130\\n\", \"3... | Since most contestants do not read this part, I have to repeat that Bitlandians are quite weird. They have their own jobs, their own working method, their own lives, their own sausages and their own games!
Since you are so curious about Bitland, I'll give you the chance of peeking at one of these games.
BitLGM and Bi... | 0 |
{"tests": "{\"inputs\": [\"1\\n3\\n\", \"4\\n0 1 1 1\\n\", \"1\\n2000000000\\n\", \"26\\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 2\\n\", \"1\\n0\\n\", \"1\\n1\\n\", \"1\\n1646661570\\n\", \"1\\n2\\n\", \"1\\n4\\n\", \"1\\n110164340\\n\", \"1\\n8\\n\", \"1\\n7\\n\", \"1\\n127913041\\n\", \"1\\n12\\n\", \"1\\n1... | Ivan has got an array of n non-negative integers a1, a2, ..., an. Ivan knows that the array is sorted in the non-decreasing order.
Ivan wrote out integers 2a1, 2a2, ..., 2an on a piece of paper. Now he wonders, what minimum number of integers of form 2b (b ≥ 0) need to be added to the piece of paper so that the sum o... | 0.125 |
{"tests": "{\"inputs\": [\"2\\nXX\\n\", \"6\\nxXXxXx\\n\", \"4\\nxxXx\\n\", \"4\\nXXXX\\n\", \"200\\nxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\\n\", \"104\\nxxXx... | Pasha has many hamsters and he makes them work out. Today, n hamsters (n is even) came to work out. The hamsters lined up and each hamster either sat down or stood up.
For another exercise, Pasha needs exactly <image> hamsters to stand up and the other hamsters to sit down. In one minute, Pasha can make some hamster e... | 0.875 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.