info stringlengths 120 50k | question stringlengths 504 10.4k | avg@8_qwen3_4b_instruct_2507 float64 0 0.88 |
|---|---|---|
{"tests": "{\"inputs\": [\"2\\n-1 -1\\n0 1\\n\", \"4\\n1 1\\n1 2\\n2 1\\n2 2\\n\", \"6\\n0 2\\n-1 1\\n1 -2\\n2 1\\n-2 1\\n-2 0\\n\", \"6\\n-1 2\\n0 -1\\n-1 -2\\n0 1\\n-1 0\\n1 0\\n\", \"1\\n0 0\\n\", \"10\\n504155727 -77293021\\n-155983273 -43296260\\n-548837441 -43296260\\n88335251 -77293021\\n970294418 -43296260\\n-1... | You are given n distinct points on a plane with integral coordinates. For each point you can either draw a vertical line through it, draw a horizontal line through it, or do nothing.
You consider several coinciding straight lines as a single one. How many distinct pictures you can get? Print the answer modulo 109 + 7.... | 0 |
{"tests": "{\"inputs\": [\"3 5\\n1 2 3\\n\", \"7 2\\n2 3 6 4 5 7 1\\n\", \"8 4\\n1 3 4 5 5 3 4 1\\n\", \"12 10\\n1 1 10 10 10 10 10 10 9 10 10 10\\n\", \"15 10\\n4 5 5 5 5 5 5 5 5 5 5 5 5 5 1\\n\", \"15 5\\n1 67 1 100 67 34 67 34 34 1 1 34 34 1 67\\n\", \"15 5\\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\\n\", \"9 10\\n20 54 35 72 ... | Since you are the best Wraith King, Nizhniy Magazin «Mir» at the centre of Vinnytsia is offering you a discount.
You are given an array a of length n and an integer c.
The value of some array b of length k is the sum of its elements except for the <image> smallest. For example, the value of the array [3, 1, 6, 5, 2]... | 0 |
{"tests": "{\"inputs\": [\"5 1\\n1 2 3 4 5\\n1 2 3 4 5\\n\", \"1 0\\n2\\n3\\n\", \"4 2\\n4 5 9 7\\n1 2 11 33\\n\", \"3 0\\n1 2 3\\n10 20 30\\n\", \"2 0\\n2 3\\n3 3\\n\", \"11 10\\n1 2 3 4 5 6 7 8 9 10 11\\n1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000... | Unlike Knights of a Round Table, Knights of a Polygonal Table deprived of nobility and happy to kill each other. But each knight has some power and a knight can kill another knight if and only if his power is greater than the power of victim. However, even such a knight will torment his conscience, so he can kill no mo... | 0.5 |
{"tests": "{\"inputs\": [\"385900\\n123000\", \"8072\\n3072\", \"508\\n540\", \"854000\\n854000\", \"8072\\n3981\", \"508\\n548\", \"854000\\n731377\", \"8072\\n3039\", \"508\\n594\", \"854000\\n186396\", \"8072\\n2060\", \"508\\n968\", \"508\\n703\", \"508\\n559\", \"508\\n294\", \"8072\\n3200\", \"508\\n307\", \"8540... | PRAVAH, an annual techfest is being organised at SKIT. Naina comes up with an idea for an event Guess The Number. In this event, the computer thinks up a random number and the player is asked to guess that number and enter it in the system. if the number is correct, the player wins.
Rakesh, a student who is good at ha... | 0.875 |
{"tests": "{\"inputs\": [\"2\\n1 2\", \"10\\n1 2 1 3 2 4 2 5 8 1\", \"10\\n1 2 2 3 2 4 2 5 8 1\", \"10\\n1 3 2 3 2 4 2 5 8 1\", \"10\\n1 3 2 3 2 4 4 5 8 1\", \"2\\n1 0\", \"10\\n1 2 1 3 2 4 1 5 8 1\", \"10\\n1 2 1 3 2 4 2 5 8 0\", \"10\\n1 3 2 4 2 4 2 5 8 1\", \"10\\n1 3 2 6 2 4 4 5 8 1\", \"2\\n1 1\", \"10\\n1 2 1 3 2... | Snuke loves constructing integer sequences.
There are N piles of stones, numbered 1 through N. The pile numbered i consists of a_i stones.
Snuke will construct an integer sequence s of length Σa_i, as follows:
1. Among the piles with the largest number of stones remaining, let x be the index of the pile with the sma... | 0 |
{"tests": "{\"inputs\": [\"6\\n0 1 80\\n1 2 20\\n0 2 60\\n2 3 50\\n3 4 60\\n1 4 90\\n2\\n0 1 1\\n1 2 1\\n0\", \"6\\n0 1 80\\n1 2 20\\n0 2 60\\n2 3 50\\n3 4 66\\n1 4 90\\n2\\n0 1 1\\n1 2 1\\n0\", \"6\\n0 1 80\\n1 2 20\\n0 2 60\\n2 3 50\\n3 4 66\\n0 4 90\\n2\\n0 1 1\\n1 2 1\\n0\", \"6\\n0 1 80\\n1 2 20\\n0 2 60\\n2 2 50\... | Mr. A, who will graduate next spring, decided to move when he got a job. The company that finds a job has offices in several towns, and the offices that go to work differ depending on the day. So Mr. A decided to live in a town where he had a short time to go to any office.
So you decided to find the most convenient t... | 0 |
{"tests": "{\"inputs\": [\"2 15\\n3 5\\n50 50\", \"4 100\\n2 3 5 7\\n80 60 40 20\", \"4 210\\n2 3 5 7\\n80 60 40 20\", \"2 15\\n3 5\\n50 72\", \"4 100\\n1 3 5 7\\n80 60 40 20\", \"4 210\\n2 2 5 7\\n80 60 40 20\", \"2 15\\n3 5\\n32 72\", \"4 100\\n1 3 8 7\\n80 60 40 20\", \"2 210\\n2 2 5 7\\n80 60 40 20\", \"2 15\\n3 5\... | Given n integers a1, a2,…, an and n integers p1, p2,…, pn, integer m. The operation of selecting the kth integer ak with a probability of pk [%] is performed for each k (1 ≤ k ≤ n), and 0 or more and n or less integers are selected. Find the expected number of integers between 1 and m that are divisible by at least one... | 0 |
{"tests": "{\"inputs\": [\"0\", \"1\", \"2\", \"3\", \"001\", \"000\", \"6\", \"4\", \"10\", \"5\", \"7\", \"17\", \"11\", \"12\", \"18\", \"9\", \"35\", \"15\", \"8\", \"29\", \"14\", \"41\", \"27\", \"62\", \"30\", \"25\", \"42\", \"58\", \"21\", \"83\", \"98\", \"178\", \"209\", \"375\", \"51\", \"79\", \"65\", \"28... | Ikta loves fast programs. Recently, I'm trying to speed up the division program. However, it doesn't get much faster, so I thought it would be better to make it faster only for "common sense and typical" inputs. The problem Ikta is trying to solve is as follows.
For a given non-negative integer n, divide p (n) − 1-dig... | 0 |
{"tests": "{\"inputs\": [\"6000 5000 20 10 400 300\", \"10 10 8 8 8 8\", \"6000 5000 20 2 400 300\", \"6000 5000 20 2 400 204\", \"6000 5000 20 2 499 204\", \"274 5000 28 1 499 204\", \"274 4268 28 0 499 209\", \"274 8140 32 0 499 209\", \"274 14753 32 0 499 132\", \"6000 5000 20 10 400 575\", \"16 16 8 8 8 8\", \"16 1... | Problem
You brought a flat, holeless donut with a $ W $ horizontal $ H $ vertical $ H $ rectangle for ACPC.
Place this donut on the $ 2 $ dimension plane coordinate $ (0,0) $ with the center of the donut so that the side of length H and the $ y $ axis are parallel.
On the ACPC $ 1 $ day you ate a donut that was in t... | 0 |
{"tests": "{\"inputs\": [\"4\\n2 0 2\", \"4\\n2 0 3\", \"4\\n2 1 2\", \"4\\n0 0 3\", \"4\\n2 0 1\", \"4\\n1 0 2\", \"4\\n1 1 0\", \"4\\n1 2 -2\", \"4\\n1 3 0\", \"4\\n2 1 3\", \"4\\n0 0 1\", \"4\\n0 1 3\", \"4\\n0 1 1\", \"4\\n0 1 5\", \"4\\n0 1 2\", \"4\\n0 2 1\", \"4\\n0 1 0\", \"4\\n0 2 0\", \"4\\n0 0 0\", \"4\\n0 3... | You are given a set $T$, which is a subset of $S$. The set $S$ consists of $0, 1, ... n-1$. Print all subsets of $T$. Note that we represent $0, 1, ... n-1$ as 00...0001, 00...0010, 00...0100, ..., 10...0000 in binary respectively and the integer representation of a subset is calculated by bitwise OR of existing elemen... | 0 |
{"tests": "{\"inputs\": [\"5 4\\n2 -2 3 1 4\\n3 5\\n3 4\\n2 4\\n2 5\\n\", \"1 0\\n1000000\\n\", \"5 4\\n2 -2 3 1 2\\n1 3\\n4 5\\n2 5\\n1 3\\n\", \"5 50\\n-5 4 -4 -1 5\\n4 5\\n4 5\\n1 1\\n1 5\\n1 1\\n1 1\\n3 5\\n4 5\\n5 5\\n1 1\\n3 3\\n1 4\\n1 3\\n4 5\\n4 5\\n5 5\\n1 3\\n2 3\\n3 4\\n5 5\\n1 2\\n4 4\\n2 2\\n1 3\\n5 5\\n2... | The only difference between easy and hard versions is a number of elements in the array.
You are given an array a consisting of n integers. The value of the i-th element of the array is a_i.
You are also given a set of m segments. The j-th segment is [l_j; r_j], where 1 ≤ l_j ≤ r_j ≤ n.
You can choose some subset of... | 0 |
{"tests": "{\"inputs\": [\"4\\n0011\\n1100\\n\", \"4\\n0011\\n0101\\n\", \"8\\n00100101\\n01111100\\n\", \"6\\n000000\\n111111\\n\", \"10\\n0011101001\\n1000101110\\n\", \"4\\n0011\\n1100\\n\", \"6\\n111100\\n111000\\n\", \"8\\n11111111\\n11110000\\n\", \"2\\n10\\n10\\n\", \"8\\n11100000\\n00101111\\n\", \"2\\n10\\n01\... | Polycarp is a head of a circus troupe. There are n — an even number — artists in the troupe. It is known whether the i-th artist can perform as a clown (if yes, then c_i = 1, otherwise c_i = 0), and whether they can perform as an acrobat (if yes, then a_i = 1, otherwise a_i = 0).
Split the artists into two performance... | 0 |
{"tests": "{\"inputs\": [\"7\\n2 1 1\\n3 2 0\\n4 2 1\\n5 2 0\\n6 7 1\\n7 2 1\\n\", \"2\\n1 2 1\\n\", \"2\\n1 2 0\\n\", \"7\\n2 1 1\\n3 2 0\\n4 2 1\\n5 4 0\\n6 7 1\\n7 2 1\\n\", \"7\\n2 1 1\\n3 2 1\\n4 2 1\\n5 2 0\\n6 7 1\\n7 2 1\\n\", \"7\\n2 1 1\\n3 2 0\\n4 2 1\\n5 2 0\\n6 7 0\\n7 2 1\\n\", \"7\\n3 1 1\\n3 2 0\\n4 2 1... | You are given a tree (an undirected connected acyclic graph) consisting of n vertices and n - 1 edges. A number is written on each edge, each number is either 0 (let's call such edges 0-edges) or 1 (those are 1-edges).
Let's call an ordered pair of vertices (x, y) (x ≠ y) valid if, while traversing the simple path fro... | 0 |
{"tests": "{\"inputs\": [\"3\\n7 11\\n2 9 1 3 18 1 4\\n4 35\\n11 9 10 7\\n1 8\\n5\\n\", \"7\\n10 11\\n2 2 2 6 5 3 4 4 4 100000000\\n4 102\\n98 1 3 99\\n4 103\\n5 98 1 97\\n11 1000000000\\n100000000 100000002 100000000 100000000 100000000 100000000 100000000 100000000 100000000 100000000 99999999\\n8 90\\n20 8 20 20 20 ... | New Year is coming! Vasya has prepared a New Year's verse and wants to recite it in front of Santa Claus.
Vasya's verse contains n parts. It takes a_i seconds to recite the i-th part. Vasya can't change the order of parts in the verse: firstly he recites the part which takes a_1 seconds, secondly — the part which take... | 0 |
{"tests": "{\"inputs\": [\"2\\n\\n\\n0\", \"2\\n\\n1 1 2 2\\n\\n0\\n\", \"2\\n1 2 1 2\\n\", \"4\\n2 4 3 1 3 4 2 1\\n\", \"10\\n1 10 6 4 3 5 10 9 3 8 1 2 6 4 7 5 2 9 7 8\\n\", \"1\\n1 1\\n\", \"5\\n2 4 2 1 5 3 3 1 5 4\\n\", \"10\\n10 1 9 8 7 2 4 5 6 3 10 1 9 8 7 2 4 5 6 3\\n\", \"4\\n1 4 4 2 3 1 2 3\\n\", \"5\\n5 3 4 2 ... | This is an interactive problem.
Consider a fixed positive integer n. Two players, First and Second play a game as follows:
1. First considers the 2n numbers 1, 2, ..., 2n, and partitions them as he wants into n disjoint pairs.
2. Then, Second chooses exactly one element from each of the pairs that First created (... | 0 |
{"tests": "{\"inputs\": [\"3\\n\\n6 7\\n1 2\\n1 3\\n2 5\\n2 4\\n5 1\\n3 6\\n6 2\\n\\n2 2\\n1 2\\n2 1\\n\\n6 8\\n1 2\\n1 5\\n2 6\\n6 1\\n2 3\\n3 4\\n4 2\\n5 4\\n\", \"3\\n\\n6 7\\n1 2\\n1 3\\n2 5\\n2 4\\n5 1\\n3 6\\n6 2\\n\\n2 2\\n1 2\\n2 1\\n\\n6 8\\n1 2\\n1 5\\n2 6\\n6 1\\n2 3\\n2 4\\n4 2\\n5 4\\n\", \"3\\n\\n6 7\\n1 ... | There are n cities in Berland. The city numbered 1 is the capital. Some pairs of cities are connected by a one-way road of length 1.
Before the trip, Polycarp for each city found out the value of d_i — the shortest distance from the capital (the 1-st city) to the i-th city.
Polycarp begins his journey in the city wit... | 0.125 |
{"tests": "{\"inputs\": [\"5\\n10101011011\\n0000\\n11111\\n110\\n1100\\n\", \"9\\n11\\n11\\n11\\n11\\n11\\n11\\n11\\n11\\n11\\n\", \"1\\n0000011111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111100\\n\", \"1\\n000001111111111111111111111111111111111111111111111111111111111111111... | You are given a string s, consisting only of characters '0' or '1'. Let |s| be the length of s.
You are asked to choose some integer k (k > 0) and find a sequence a of length k such that:
* 1 ≤ a_1 < a_2 < ... < a_k ≤ |s|;
* a_{i-1} + 1 < a_i for all i from 2 to k.
The characters at positions a_1, a_2, ...,... | 0.125 |
{"tests": "{\"inputs\": [\"5 5 1\\n0 -1 0 1 -1\\n0 20 0 0 -1\\n-1 -1 -1 -1 -1\\n3 0 0 0 0\\n-1 0 0 0 0\\n\", \"2 3 1000000000\\n0 0 0\\n0 0 0\\n\", \"10 5 2\\n0 3 0 0 0\\n0 0 0 0 0\\n0 0 0 0 0\\n-1 0 0 0 0\\n0 0 0 6 0\\n0 0 0 0 8\\n0 0 5 6 0\\n0 0 0 5 -1\\n0 0 0 0 10\\n0 0 0 0 0\\n\", \"10 2 2\\n0 -1\\n0 10\\n8 4\\n0 0... | Dima overslept the alarm clock, which was supposed to raise him to school.
Dima wonders if he will have time to come to the first lesson. To do this, he needs to know the minimum time it will take him to get from home to school.
The city where Dima lives is a rectangular field of n × m size. Each cell (i, j) on this ... | 0.75 |
{"tests": "{\"inputs\": [\"6 5 4 3 2 1\\n\", \"10 10 1 1 10 10\\n\", \"1 6 1 2 1 6\\n\", \"24 32 6 2 7 4\\n\", \"45 62 28 48 28 50\\n\", \"100 32 71 12 71 22\\n\", \"57 85 29 40 29 69\\n\", \"95 28 50 12 50 13\\n\", \"5 4 1 1 5 4\\n\", \"100 100 1 1 100 100\\n\", \"51 76 50 5 45 76\\n\", \"37 100 33 13 32 30\\n\", \"47... | Two players play a game. The game is played on a rectangular board with n × m squares. At the beginning of the game two different squares of the board have two chips. The first player's goal is to shift the chips to the same square. The second player aims to stop the first one with a tube of superglue.
We'll describe ... | 0 |
{"tests": "{\"inputs\": [\"4 3\\n1 2\\n2 3\\n3 4\\n\", \"4 4\\n1 2\\n2 3\\n3 4\\n4 1\\n\", \"4 4\\n1 2\\n2 3\\n3 1\\n1 4\\n\", \"4 3\\n1 2\\n1 3\\n1 4\\n\", \"4 4\\n1 2\\n2 3\\n3 4\\n4 2\\n\", \"10 9\\n10 6\\n3 4\\n8 9\\n8 4\\n6 1\\n2 9\\n5 1\\n7 5\\n10 3\\n\", \"10 14\\n3 2\\n7 2\\n6 4\\n8 1\\n3 9\\n5 6\\n6 3\\n4 1\\n... | This problem uses a simplified network topology model, please read the problem statement carefully and use it as a formal document as you develop the solution.
Polycarpus continues working as a system administrator in a large corporation. The computer network of this corporation consists of n computers, some of them a... | 0.625 |
{"tests": "{\"inputs\": [\"2 2\\n2 6\\n3 100\\n\", \"2 3\\n10 10\\n1 1 1\\n\", \"10 10\\n269584761 865524829 265226347 963092340 261501474 16861445 221090297 746538035 842020225 649641719\\n49728483 423679832 107851851 179960003 345895125 400584885 460489835 377856735 506736683 676996548\\n\", \"3 4\\n337369924 2788487... | Piegirl was asked to implement two table join operation for distributed database system, minimizing the network traffic.
Suppose she wants to join two tables, A and B. Each of them has certain number of rows which are distributed on different number of partitions. Table A is distributed on the first cluster consisting... | 0 |
{"tests": "{\"inputs\": [\"AB\\nXC\\nAC\\nBX\\n\", \"AB\\nXC\\nXB\\nAC\\n\", \"CX\\nBA\\nAX\\nBC\\n\", \"XB\\nAC\\nBX\\nAC\\n\", \"BA\\nXC\\nXB\\nAC\\n\", \"CA\\nBX\\nCB\\nXA\\n\", \"AC\\nBX\\nCB\\nAX\\n\", \"BC\\nXA\\nXC\\nAB\\n\", \"XA\\nCB\\nBA\\nCX\\n\", \"CA\\nXB\\nXB\\nCA\\n\", \"AC\\nXB\\nBA\\nCX\\n\", \"AX\\nCB... | Bessie the cow and her best friend Elsie each received a sliding puzzle on Pi Day. Their puzzles consist of a 2 × 2 grid and three tiles labeled 'A', 'B', and 'C'. The three tiles sit on top of the grid, leaving one grid cell empty. To make a move, Bessie or Elsie can slide a tile adjacent to the empty cell into the em... | 0 |
{"tests": "{\"inputs\": [\"hi\\nbob\\n\", \"abca\\naccepted\\n\", \"abacaba\\nabcdcba\\n\", \"edbcd\\nd\\n\", \"aa\\nzzaa\\n\", \"aaaaaaaaaaaa\\naaa\\n\", \"aaaaaabbbbbbaaaaaa\\naba\\n\", \"a\\naaa\\n\", \"ab\\naba\\n\", \"aaaaaaaaa\\na\\n\", \"njtdhyqundyedsjyvy\\nypjrs\\n\", \"bacb\\nccacacbacbccbbccccaccccccbcbabbba... | You are given two strings a and b. You have to remove the minimum possible number of consecutive (standing one after another) characters from string b in such a way that it becomes a subsequence of string a. It can happen that you will not need to remove any characters at all, or maybe you will have to remove all of th... | 0.5 |
{"tests": "{\"inputs\": [\")(()()\\n\", \"()()()\\n\", \")))\\n\", \"())(()(())(()()))()()(()((()(())()))(()()(()()(())()()())))()()(()(((((()())(((())(((())((()(()()())()(()())()((((())()()(((()(((()(())()()((()(()(((()(((()()())(()((())()))())((()()())(()())(((((((()((((()())(()(\\n\", \"((\\n\", \"()))))))))))))))))... | As you probably know, Anton goes to school. One of the school subjects that Anton studies is Bracketology. On the Bracketology lessons students usually learn different sequences that consist of round brackets (characters "(" and ")" (without quotes)).
On the last lesson Anton learned about the regular simple bracket s... | 0 |
{"tests": "{\"inputs\": [\"2 3 7\\n\", \"1 2 0\\n\", \"1 10 1\\n\", \"53 101 6\\n\", \"567 1580 0\\n\", \"69168 84860 4\\n\", \"35 111 4\\n\", \"99971 99989 0\\n\", \"25102 31579 2\\n\", \"13805 15538 3\\n\", \"38790 39359 0\\n\", \"2 3 0\\n\", \"7 31 3\\n\", \"1 9 0\\n\", \"45 97 0\\n\", \"1636 3269 6\\n\", \"8 51 0\\... | You have a fraction <image>. You need to find the first occurrence of digit c into decimal notation of the fraction after decimal point.
Input
The first contains three single positive integers a, b, c (1 ≤ a < b ≤ 105, 0 ≤ c ≤ 9).
Output
Print position of the first occurrence of digit c into the fraction. Positions... | 0.75 |
{"tests": "{\"inputs\": [\"4\\n{ { { } .\\n} { .\\n{ } { } { } .\\n{ } { } } .\\n\\nSAMPLE\", \"4\\n{ { { } .\\n} { .\\n{ } { } { } .\\n{ } { } } .\\n\\nELPMAS\", \"4\\n{ { { } .\\n} { .\\n{ } { } | } -\\n{ } { } } .\\n\\nFLPMAS\", \"4\\n{ { { } .\\n} | -\\n{ } { } { } .\\n{ } { } } .\\n\\nASMPLE\", \"4\\n{ { { ~ -\\n}... | Task is simple. You are provided with a string of curly brackets and you have to do the following -
Print 0 if the brackets are balanced.
Print k if it is unbalanced, where k is the number of actions performed to balance it.
Print -1 if it cannot be balanced.
Definition of a Balanced String -
{ } is a balanced strin... | 0 |
{"tests": "{\"inputs\": [\"3\\n7 6 8\", \"2\\n1000000000 1000000000\", \"3\\n12 15 18\", \"3\\n7 6 7\", \"2\\n1000010000 1000000000\", \"3\\n12 29 18\", \"2\\n1000000000 1000001000\", \"3\\n4 8 7\", \"2\\n1001000000 1000001000\", \"3\\n9 28 18\", \"3\\n9 28 30\", \"2\\n1001100000 1000001100\", \"2\\n1101000000 10000011... | There are N integers, A_1, A_2, ..., A_N, written on the blackboard.
You will choose one of them and replace it with an integer of your choice between 1 and 10^9 (inclusive), possibly the same as the integer originally written.
Find the maximum possible greatest common divisor of the N integers on the blackboard afte... | 0 |
{"tests": "{\"inputs\": [\"3\\n10 -3\\n50 4\\n100 -5\", \"3\\n2 10\\n3 -20\\n6 15\", \"5\\n56 114834\\n72 -149861\\n100 190757\\n192 -132693\\n240 133108\", \"3\\n10 -3\\n50 4\\n101 -5\", \"3\\n2 18\\n3 -20\\n6 15\", \"5\\n56 114834\\n72 -134386\\n100 190757\\n192 -132693\\n240 133108\", \"3\\n10 -3\\n91 4\\n101 -5\", ... | Consider an infinite sequence a_1, a_2, … Initially, the values of all the terms are 0, and from this state we will sequentially perform Q operations. The i-th operation (1 ≤ i ≤ Q) is as follows:
* For every positive integer j, add x_i to the value of a_{j × m_i}.
Find the value of the largest term after these Q o... | 0.125 |
{"tests": "{\"inputs\": [\"6 6\\nS.1..4\\n3..5..\\n..4.1.\\n4....5\\n.2.32.\\n5.1..G\\n3 2\\n...\\nS.G\\n0 0\", \"6 6\\nS.1..4\\n5..3..\\n..4.1.\\n4....5\\n.2.32.\\n5.1..G\\n3 2\\n...\\nS.G\\n0 0\", \"6 6\\nS.1..4\\n3..5..\\n..4.1.\\n4...5.\\n.2.32.\\n5.1..G\\n3 2\\n...\\nS.G\\n0 0\", \"6 6\\nS.1..4\\n4..5..\\n..4.1.\\... | A popular game in a certain country, Pachimon Creature, has been remade and released in Japan. If you love games, after playing this game many times, you've come to think about how you can clear it the fastest. However, no matter how much you think about it, you didn't know the fastest way to capture it, so you decided... | 0.125 |
{"tests": "{\"inputs\": [\"3\\n4\\n0\", \"3\\n7\\n0\", \"3\\n3\\n0\", \"3\\n0\\n0\", \"3\\n1\\n0\", \"3\\n2\\n0\", \"3\\n-1\\n0\", \"3\\n5\\n0\", \"3\\n8\\n0\", \"3\\n6\\n0\", \"3\\n9\\n0\", \"3\\n0\\n-1\", \"3\\n0\\n1\", \"3\\n0\\n-2\", \"3\\n0\\n2\", \"3\\n0\\n-4\", \"3\\n0\\n-5\", \"3\\n0\\n3\", \"3\\n0\\n-3\", \"3\... | The fundamental idea in the JPEG compression algorithm is to sort coeffi- cient of given image by zigzag path and encode it. In this problem, we don’t discuss about details of the algorithm, but you are asked to make simple pro- gram. You are given single integer N , and you must output zigzag path on a matrix where si... | 0.125 |
{"tests": "{\"inputs\": [\"10 5\\nkkkkkwwwww\\nw#wwwrwwww\\nwwwwbgwwww\\nkwwmcwwwkk\\nkkwywwwkkk\\nrgbcmy\\n10 5\\nkkkkkkkkkk\\nk#kkkkkkkk\\nkwkkkkkwwk\\nkcmyrgbwwk\\nkwwwwwwwwk\\ncmyrgb\\n10 5\\nkkkkkkkkkk\\nk#kkkkkkkk\\nkwkkkkkwkk\\nkcmyrgbwwk\\nkwwwwwwwwk\\ncmyrgb\\n0 0\", \"10 5\\nkkkkkwwwww\\nw#wwwrwwww\\nwwwwbgww... | On a small planet named Bandai, a landing party of the starship Tadamigawa discovered colorful cubes traveling on flat areas of the planet surface, which the landing party named beds. A cube appears at a certain position on a bed, travels on the bed for a while, and then disappears. After a longtime observation, a scie... | 0 |
{"tests": "{\"inputs\": [\"160\\n1 1 2 0\\n160\\n1 0 2 10\\n0\", \"160\\n1 1 4 0\\n160\\n1 0 2 10\\n0\", \"160\\n1 1 4 0\\n58\\n2 0 4 10\\n0\", \"160\\n1 1 4 0\\n46\\n2 0 4 10\\n0\", \"160\\n1 1 4 0\\n160\\n0 0 2 10\\n0\", \"160\\n1 1 2 0\\n160\\n1 -1 1 10\\n0\", \"160\\n1 1 4 0\\n109\\n2 0 7 10\\n0\", \"160\\n0 1 4 0\... | Mr. Bill is shopping at the store. There are some coins in his wallet (10-yen coins, 50-yen coins, 100-yen coins, 500-yen coins), but he is now trying to consume as much of this coin as possible. In other words, by paying for the goods with an appropriate number of coins, we are trying to minimize the total number of c... | 0 |
{"tests": "{\"inputs\": [\"5 5\\n%#... ...#%\\n.#.#. .#.#.\\n.#.#. .#.#.\\n.#.#. .#.#.\\n...#L R#...\\n3 2\\n.L. .R#\\n%.. .%.\\n4 1\\nL.%. %..R\\n0 0\", \"5 5\\n%#... ...#%\\n.#.#. .#.#.\\n.#.#. .#.#.\\n.#.#. .#.#.\\n...#L R#...\\n3 2\\n.L. .R#\\n%.. .&.\\n4 1\\nL.%. %..R\\n0 0\", \"5 5\\n%#... .%.#.\\n.#.#. .#.#.\\n.... | Twin adventurers Rin and Len are searching for treasure in the Mirror Cave. The cave has two pairs of rooms, the Hall of Mirrors, and an expensive treasure lies behind the door of the room.
For convenience, each of the two rooms is considered to have W × H cells arranged in a grid pattern. The outside of the room is s... | 0 |
{"tests": "{\"inputs\": [\"4\\n0 1\\n1 1\\n1 2\\n2 2\", \"11\\n63 106\\n87 143\\n102 132\\n115 169\\n74 145\\n41 177\\n56 130\\n28 141\\n19 124\\n0 156\\n22 183\", \"4\\n0 1\\n1 1\\n1 2\\n3 2\", \"11\\n63 106\\n87 143\\n102 132\\n115 169\\n74 145\\n41 177\\n56 130\\n28 102\\n19 124\\n0 156\\n22 183\", \"4\\n0 2\\n1 1\\... | Sunake is in the form of a polygonal line consisting of n vertices (without self-intersection). First, Sunake-kun's i-th vertex is at (xi, yi). You can move continuously by translating or rotating, but you cannot deform (change the length of the polygonal line or the angle between the two line segments). y = 0 is the w... | 0 |
{"tests": "{\"inputs\": [\"4 5 2 3\", \"4 9 2 3\", \"3 1 3 12\", \"4 1 2 3\", \"2 1 2 3\", \"2 1 2 4\", \"3 1 2 4\", \"3 2 2 4\", \"3 4 2 4\", \"4 4 2 4\", \"4 3 2 4\", \"4 3 2 6\", \"3 3 2 6\", \"3 1 2 6\", \"3 1 2 12\", \"1 1 3 12\", \"1 1 3 7\", \"1 2 3 7\", \"1 2 5 7\", \"2 2 5 7\", \"2 2 0 7\", \"2 2 0 14\", \"0 2... | J: City
Santa decides to deliver a present to a city.
The city has a rectangular shape divided into north-south $ H $ parcels x east-west $ W $ parcels, with one house delivering gifts to each parcel.
The $ X $ th section from the north and the $ Y $ th section from the west are represented by $ (X, Y) $.
Santa mov... | 0.5 |
{"tests": "{\"inputs\": [\"3 2\\n1 2 3\", \"3 3\\n3 2 1\", \"3 3\\n2 3 1\", \"3 2\\n1 2 5\", \"3 1\\n3 2 1\", \"0 3\\n2 3 1\", \"0 4\\n2 3 1\", \"0 3\\n3 3 1\", \"3 2\\n2 2 3\", \"3 2\\n2 2 5\", \"0 3\\n4 3 1\", \"0 4\\n3 3 1\", \"0 3\\n3 0 1\", \"0 2\\n2 2 3\", \"0 2\\n4 3 1\", \"0 3\\n3 1 1\", \"0 2\\n2 4 3\", \"0 2\... | Problem
Given a permutation of length $ N $ $ P = \\ {P_1, P_2, \ ldots, P_N \\} $ and the integer $ K $.
Determine if the permutation $ P $ can be monotonically increased by repeating the following operation any number of times $ 0 $ or more.
* Choose the integer $ x \ (0 \ le x \ le N-K) $. Patrol right shift aroun... | 0 |
{"tests": "{\"inputs\": [\"8 8\\n(()(()))\\n\", \"6 4\\n()(())\\n\", \"20 10\\n((()))()((()()(())))\\n\", \"2 2\\n()\\n\", \"40 30\\n((((((((()()()))))))))((())((()())))(())\\n\", \"6 2\\n()(())\\n\", \"40 22\\n((((((((()()()))))))))((())((()())))(())\\n\", \"40 32\\n((((((((()()()))))))))((())((()())))(())\\n\", \"8 8... | A bracket sequence is a string containing only characters "(" and ")". A regular bracket sequence is a bracket sequence that can be transformed into a correct arithmetic expression by inserting characters "1" and "+" between the original characters of the sequence. For example, bracket sequences "()()" and "(())" are r... | 0.125 |
{"tests": "{\"inputs\": [\"4 3\\n2 1 3\\n4 3 4\\n2 4 1\\n\", \"8 10\\n1 2 1\\n2 3 2\\n2 4 5\\n1 4 2\\n6 3 3\\n6 1 3\\n3 5 2\\n3 7 1\\n4 8 1\\n6 2 4\\n\", \"1 0\\n\", \"3 3\\n1 2 1\\n2 3 3\\n1 3 3\\n\", \"3 3\\n1 2 1\\n2 3 2\\n1 3 3\\n\", \"5 6\\n1 2 2\\n2 3 1\\n4 5 3\\n2 4 2\\n1 4 2\\n1 5 3\\n\", \"6 7\\n1 2 1\\n2 3 1\... | You are given an undirected weighted connected graph with n vertices and m edges without loops and multiple edges.
The i-th edge is e_i = (u_i, v_i, w_i); the distance between vertices u_i and v_i along the edge e_i is w_i (1 ≤ w_i). The graph is connected, i. e. for any pair of vertices, there is at least one path be... | 0.25 |
{"tests": "{\"inputs\": [\"4\\n4\\n1 3 1 3\\n3\\n3 3 2\\n5\\n2 3 3 4 2\\n3\\n1 1 2\\n\", \"1\\n6\\n1 1 3 2 10000 1000\\n\", \"2\\n3\\n1 2 3\\n6\\n1 1 3 2 10000 1000\\n\", \"1\\n9\\n3 3 3 3 3 3 3 3 4\\n\", \"1\\n6\\n100 50 50 50 50 50\\n\", \"2\\n3\\n1 2 0\\n6\\n1 1 3 2 10000 1000\\n\", \"1\\n9\\n3 3 3 3 3 3 5 3 4\\n\",... | Let's denote a k-step ladder as the following structure: exactly k + 2 wooden planks, of which
* two planks of length at least k+1 — the base of the ladder;
* k planks of length at least 1 — the steps of the ladder;
Note that neither the base planks, nor the steps planks are required to be equal.
For example... | 0.75 |
{"tests": "{\"inputs\": [\"4\\n3 2 5 3\\n\", \"3\\n4 3 6\\n\", \"4\\n11 5 2 7\\n\", \"3\\n2 5 3\\n\", \"100\\n7585 5510 1017 4329 2840 8171 5089 1873 7308 9656 6833 7578 4914 6658 4408 7122 5265 1204 9800 3150 2151 6906 6041 3973 931 7239 4421 4211 156 8655 4266 3543 9752 3117 2731 6052 8950 9391 6367 996 9973 629 9489... | Your favorite music streaming platform has formed a perfectly balanced playlist exclusively for you. The playlist consists of n tracks numbered from 1 to n. The playlist is automatic and cyclic: whenever track i finishes playing, track i+1 starts playing automatically; after track n goes track 1.
For each track i, you... | 0.125 |
{"tests": "{\"inputs\": [\"2\\n3 3\\n3 1 2\\n3 2 1\\n7 2\\n2 1 7 3 4 5 6\\n3 1\\n\", \"2\\n3 3\\n3 1 2\\n3 2 1\\n7 2\\n4 1 7 3 4 5 6\\n3 1\\n\", \"2\\n3 3\\n3 1 2\\n3 2 1\\n7 2\\n2 1 7 3 4 5 6\\n6 1\\n\", \"2\\n3 3\\n3 1 2\\n3 2 1\\n7 2\\n2 1 7 3 4 5 6\\n4 1\\n\", \"2\\n3 3\\n3 1 2\\n3 2 1\\n7 2\\n2 1 7 3 5 7 6\\n2 1\\... | Santa has to send presents to the kids. He has a large stack of n presents, numbered from 1 to n; the topmost present has number a_1, the next present is a_2, and so on; the bottom present has number a_n. All numbers are distinct.
Santa has a list of m distinct presents he has to send: b_1, b_2, ..., b_m. He will send... | 0 |
{"tests": "{\"inputs\": [\"5 4\\n4 3 2 1 1\\n0 2 6 7 4\\n12 12 12 6 -3 -5 3 10 -4\\n\", \"2 2\\n1 2\\n0 0\\n2 1 -100 -100\\n\", \"5 4\\n4 3 1 2 1\\n1 2 1 2 1\\n1 2 3 4 5 6 7 8 9\\n\", \"7 4\\n1 4 3 2 1 3 1\\n8 2 2 1 4 3 2\\n-6 14 8 13 -8 -6 -23 1 -17 9 -13\\n\", \"15 15\\n14 4 3 11 4 6 10 7 9 12 7 8 3 9 12\\n814 3633 1... | 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 by increasing ... | 0 |
{"tests": "{\"inputs\": [\"1\\n3 1\\n2 1\\n3 1\\n\", \"1\\n3 2\\n1 2\\n1 3\\n\", \"1\\n1 1\\n\", \"10\\n8 2\\n1 5\\n7 4\\n8 5\\n5 6\\n8 7\\n2 8\\n1 3\\n10 5\\n10 1\\n4 7\\n6 4\\n4 3\\n8 1\\n1 2\\n1 4\\n5 1\\n1 9\\n2 2\\n2 1\\n9 3\\n9 6\\n1 7\\n2 6\\n7 3\\n6 8\\n1 6\\n5 1\\n6 4\\n8 6\\n3 1\\n8 6\\n2 4\\n5 7\\n8 4\\n1 8\... | Ayush and Ashish play a game on an unrooted tree consisting of n nodes numbered 1 to n. Players make the following move in turns:
* Select any leaf node in the tree and remove it together with any edge which has this node as one of its endpoints. A leaf node is a node with degree less than or equal to 1.
A tree... | 0 |
{"tests": "{\"inputs\": [\"6\\n3 4\\n1 2\\n5 6\\n5 7\\n7 4\\n8 9\\n9 8\\n2 5\\n1 1\\n1 1\\n2 2\\n2 2\\n1 100\\n10 10\\n10 10\\n1 2\\n4 5\\n8 4\\n2 2\\n1 1\\n1 1\\n1 2\\n3 4\\n1 2\\n1 1\\n1 1\\n\", \"1\\n2 18\\n1 2\\n3 4\\n1 3\\n2 4\\n\", \"1\\n2 4\\n1 3\\n2 1\\n1 2\\n3 1\\n\", \"1\\n2 8\\n1 2\\n3 4\\n1 2\\n2 1\\n\", \"... | Masha has n types of tiles of size 2 × 2. Each cell of the tile contains one integer. Masha has an infinite number of tiles of each type.
Masha decides to construct the square of size m × m consisting of the given tiles. This square also has to be a symmetric with respect to the main diagonal matrix, and each cell of ... | 0 |
{"tests": "{\"inputs\": [\"6 7 4\\n\", \"5 5 2\\n\", \"44 58 5\\n\", \"17 17 3\\n\", \"2 5 2\\n\", \"60 60 1\\n\", \"100 1 1\\n\", \"16 16 2\\n\", \"3 4 1\\n\", \"1 100 2\\n\", \"19 19 10\\n\", \"20 5 6\\n\", \"78 95 39\\n\", \"86 74 37\\n\", \"86 74 38\\n\", \"86 74 36\\n\", \"17 15 3\\n\", \"1 100 3\\n\", \"16 15 3\\... | You've got a rectangular table with length a and width b and the infinite number of plates of radius r. Two players play the following game: they take turns to put the plates on the table so that the plates don't lie on each other (but they can touch each other), and so that any point on any plate is located within the... | 0.5 |
{"tests": "{\"inputs\": [\"2\\n\", \"3\\n\", \"1\\n\", \"474\\n\", \"232\\n\", \"300\\n\", \"377\\n\", \"48\\n\", \"252\\n\", \"406\\n\", \"253\\n\", \"276\\n\", \"122\\n\", \"499\\n\", \"5\\n\", \"496\\n\", \"478\\n\", \"351\\n\", \"497\\n\", \"378\\n\", \"464\\n\", \"331\\n\", \"153\\n\", \"500\\n\", \"7\\n\", \"211\... | A triangular number is the number of dots in an equilateral triangle uniformly filled with dots. For example, three dots can be arranged in a triangle; thus three is a triangular number. The n-th triangular number is the number of dots in a triangle with n dots on a side. <image>. You can learn more about these numbers... | 0.875 |
{"tests": "{\"inputs\": [\"4\\n2 3\\n3 1\\n6 1\\n0 2\\n\", \"2\\n4 4\\n12 5\\n\", \"3\\n0 1\\n2 1\\n4 1\\n\", \"2\\n0 1000000000\\n1000000000 1000000000\\n\", \"1\\n0 1\\n\", \"12\\n66 4\\n12 4\\n60 4\\n24 4\\n48 4\\n0 4\\n36 4\\n30 4\\n6 4\\n54 4\\n42 4\\n18 4\\n\", \"1\\n42 23\\n\", \"2\\n0 1\\n1000000000 1\\n\", \"2... | The clique problem is one of the most well-known NP-complete problems. Under some simplification it can be formulated as follows. Consider an undirected graph G. It is required to find a subset of vertices C of the maximum size such that any two of them are connected by an edge in graph G. Sounds simple, doesn't it? No... | 0.25 |
{"tests": "{\"inputs\": [\"8.549e3\\n\", \"0.33e0\\n\", \"8.549e2\\n\", \"4.6329496401734172195e50\\n\", \"8.1089882894234341219420177467603732503076124872188628349726911362800974096687340341040683238197289136e31\\n\", \"8.25983e5\\n\", \"7.0e100\\n\", \"2.062909480759549113230626474704224392848630338479195122036209624... | Barney is standing in a bar and starring at a pretty girl. He wants to shoot her with his heart arrow but he needs to know the distance between him and the girl to make his shot accurate.
<image>
Barney asked the bar tender Carl about this distance value, but Carl was so busy talking to the customers so he wrote the ... | 0.125 |
{"tests": "{\"inputs\": [\"4\\n0 0 0\\n2 0 0\\n2 2 0\\n0 2 0\\n4\\n1 1 -1\\n1 1 1\\n1 3 1\\n1 3 -1\\n\", \"4\\n4 -2 0\\n4 3 0\\n-3 3 0\\n-3 -2 0\\n4\\n6 -2 0\\n3 2 2\\n-3 7 0\\n3 4 6\\n\", \"4\\n-10 5 0\\n25 18 0\\n23 8 0\\n-9 0 0\\n5\\n7 12 -5\\n7 0 -10\\n7 3 8\\n7 10 7\\n7 6 0\\n\", \"5\\n942 -816 0\\n573 1114 0\\n-8... | Cowboy Beblop is a funny little boy who likes sitting at his computer. He somehow obtained two elastic hoops in the shape of 2D polygons, which are not necessarily convex. Since there's no gravity on his spaceship, the hoops are standing still in the air. Since the hoops are very elastic, Cowboy Beblop can stretch, rot... | 0 |
{"tests": "{\"inputs\": [\"3\\n1 1 1\\n1 -1 1\\n1 1 1\\n\", \"5\\n10 10 10 -1 -1\\n-1 10 10 10 10\\n-1 10 10 10 10\\n\", \"4\\n-2 -1 2 2\\n-2 0 0 1\\n1 -2 2 -1\\n\", \"5\\n150684603 -262756669 -629261226 393751321 700168705\\n853551233 -595914191 -266257139 165068700 494943072\\n328547487 63141018 -951406530 -212389249... | You are given a rectangular table 3 × n. Each cell contains an integer. You can move from one cell to another if they share a side.
Find such path from the upper left cell to the bottom right cell of the table that doesn't visit any of the cells twice, and the sum of numbers written in the cells of this path is maximu... | 0 |
{"tests": "{\"inputs\": [\"1\\n1\\n\", \"5\\n5 1 2 3 4\\n\", \"26\\n23 14 15 19 9 22 20 12 5 4 21 1 16 8 6 11 3 17 2 10 24 26 13 18 25 7\\n\", \"3\\n3 2 1\\n\", \"87\\n66 53 79 35 24 61 22 70 29 43 6 21 75 4 85 2 37 18 65 49 40 82 58 73 33 87 71 19 34 83 84 25 56 48 9 63 38 20 67 32 74 42 51 39 11 1 78 86 44 64 81 17 6... | You are given a permutation p of length n. Remove one element from permutation to make the number of records the maximum possible.
We remind that in a sequence of numbers a1, a2, ..., ak the element ai is a record if for every integer j (1 ≤ j < i) the following holds: aj < ai.
Input
The first line contains the onl... | 0.5 |
{"tests": "{\"inputs\": [\"25\", \"22\", \"13\", \"18\", \"4\", \"8\", \"6\", \"0\", \"-1\", \"-2\", \"1\", \"2\", \"3\", \"7\", \"5\", \"-4\", \"-3\", \"-6\", \"-10\", \"-7\", \"-8\", \"10\", \"9\", \"11\", \"19\", \"15\", \"-5\", \"14\", \"12\", \"17\", \"16\", \"21\", \"-12\", \"-9\", \"-16\", \"-15\", \"20\", \"-11... | In some other world, today is December D-th.
Write a program that prints `Christmas` if D = 25, `Christmas Eve` if D = 24, `Christmas Eve Eve` if D = 23 and `Christmas Eve Eve Eve` if D = 22.
Constraints
* 22 \leq D \leq 25
* D is an integer.
Input
Input is given from Standard Input in the following format:
D
... | 0 |
{"tests": "{\"inputs\": [\"aba\\n4\", \"atcoderandatcodeer\\n5\", \"z\\n1\", \"aba\\n5\", \"y\\n1\", \"aba\\n1\", \"{\\n1\", \"|\\n1\", \"bba\\n4\", \"atcoderandatcodeer\\n2\", \"aab\\n5\", \"cba\\n4\", \"atcoderandatcodeer\\n4\", \"aca\\n2\", \"atcoderandatcodeer\\n3\", \"ada\\n2\", \"ada\\n4\", \"c`a\\n1\", \"aea\\n4... | You are given a string s. Among the different substrings of s, print the K-th lexicographically smallest one.
A substring of s is a string obtained by taking out a non-empty contiguous part in s. For example, if s = `ababc`, `a`, `bab` and `ababc` are substrings of s, while `ac`, `z` and an empty string are not. Also,... | 0.125 |
{"tests": "{\"inputs\": [\"8\\n3 1 2 3 3 1 5 3\\n7\\n5 2 5 3 4 5 5\\n0\", \"8\\n3 1 2 3 3 1 5 3\\n7\\n5 2 5 3 4 0 5\\n0\", \"8\\n3 1 2 3 3 1 5 3\\n7\\n5 0 5 3 4 5 5\\n0\", \"8\\n3 1 3 3 3 1 5 3\\n7\\n1 2 0 3 4 0 5\\n0\", \"8\\n2 3 0 3 6 4 6 9\\n7\\n0 4 0 5 6 0 0\\n0\", \"8\\n3 0 3 3 3 1 5 3\\n7\\n5 2 5 3 4 5 5\\n0\", \... | On a clear night, a boy, Campanella looked up at the sky, there were many stars which have different colors such as red, yellow, green, blue, purple, etc. He was watching the stars and just lost track of time. Presently, he wondered,
| <image>
---|---
"There are many stars in the space. What color is the universe if... | 0 |
{"tests": "{\"inputs\": [\"3 5 6\\n1 18\\n2 19\\n1 2\\n3 4 1\\n1 1\\n2 1\\n3 1\\n0 2 5\\n0 0 0\", \"3 5 6\\n1 18\\n2 31\\n1 2\\n3 4 1\\n1 1\\n2 1\\n3 1\\n0 2 5\\n0 0 0\", \"3 5 6\\n1 35\\n2 31\\n1 2\\n3 4 1\\n1 1\\n2 1\\n3 1\\n0 2 5\\n0 0 0\", \"3 5 6\\n1 48\\n2 31\\n1 2\\n3 4 1\\n1 1\\n2 1\\n3 1\\n0 2 5\\n0 0 0\", \"3... | Today is the birthday of Mr. Bon Vivant, who is known as one of the greatest patissiers in the world. Those who are invited to his birthday party are gourmets from around the world. They are eager to see and eat his extremely creative cakes. Now a large box-shaped cake is being carried into the party. It is not beautif... | 0 |
{"tests": "{\"inputs\": [\"2 0 0 10 10\\n1 1\\n4 4\\n2 0 0 10 10\\n1 1\\n6 6\\n2 0 0 10 10\\n1 1\\n5 5\\n0 0 0 0 0\", \"2 0 0 10 10\\n2 1\\n4 4\\n2 0 0 10 10\\n1 1\\n6 6\\n2 0 0 10 10\\n1 1\\n5 5\\n0 0 0 0 0\", \"2 0 0 13 10\\n2 1\\n4 0\\n2 0 0 10 18\\n1 1\\n6 6\\n4 0 0 10 10\\n1 1\\n5 5\\n0 0 0 0 0\", \"2 0 0 10 10\\n... | Peace, which was supposed to last forever, suddenly ended. The Demon King, who had been sealed long ago, has finally revived. But when the world was about to be covered in darkness, a brave man appeared. The hero then set out on a journey to collect legendary crystals scattered around the world. Legend has it that if y... | 0 |
{"tests": "{\"inputs\": [\"2 2 1\\nL\\nG.\\n#S\\n2 2 2\\nRR\\nG.\\n.S\\n3 3 6\\nLLLLLL\\nG#.\\n...\\n.#S\\n0 0 0\", \"2 2 1\\nL\\nG.\\nS\\n2 2 2\\nRR\\nG.\\n.S\\n3 3 6\\nLLLLLL\\nG#.\\n...\\n.#S\\n0 0 0\", \"2 3 1\\nL\\nG.\\n#S\\n2 2 2\\nRR\\nG.\\n.S\\n3 3 6\\nLLLLLL\\nG#.\\n...\\n.#S\\n0 0 0\", \"2 3 1\\nL\\nG.\\n#S\\... | A robot in a two-dimensional maze again. The maze has an entrance and an exit this time, though.
Just as in the previous problem, the maze is made up of H × W grid cells, its upper side faces north, and each cell is either empty or wall. Unlike the previous, on the other hand, one of the empty cells is connected to th... | 0 |
{"tests": "{\"inputs\": [\"2 2\\n1 2\\n4 8\", \"2 2\\n1 2\\n0 8\", \"2 2\\n1 2\\n-1 8\", \"2 2\\n1 2\\n-1 12\", \"2 2\\n1 2\\n-2 12\", \"0 2\\n1 2\\n-2 12\", \"2 2\\n1 2\\n0 14\", \"2 2\\n1 2\\n0 24\", \"1 2\\n0 1\\n-3 12\", \"1 2\\n0 2\\n-3 12\", \"1 2\\n0 3\\n-3 12\", \"2 2\\n0 3\\n-3 12\", \"2 2\\n0 3\\n-5 9\", \"3 ... | K: Relief (Angel Relief)
Tenma, an angel, decides to save a city.
The city has a rectangular shape divided into north-south $ H $ parcels x east-west $ W $ parcels, with houses in each parcel.
The $ X $ th section from the north and the $ Y $ th section from the west are represented by $ (X, Y) $.
The house in parc... | 0 |
{"tests": "{\"inputs\": [\"10\\nAND 9 4\\nIN 1\\nIN 1\\nXOR 6 5\\nAND 3 7\\nIN 0\\nNOT 10\\nIN 1\\nIN 1\\nAND 2 8\\n\", \"3\\nAND 2 3\\nIN 1\\nIN 0\\n\", \"3\\nOR 2 3\\nIN 1\\nIN 1\\n\", \"40\\nOR 9 2\\nAND 30 31\\nIN 1\\nIN 1\\nIN 0\\nOR 25 21\\nIN 1\\nXOR 20 10\\nAND 24 34\\nIN 0\\nIN 0\\nNOT 16\\nAND 14 4\\nIN 0\\nA... | Natasha travels around Mars in the Mars rover. But suddenly it broke down, namely — the logical scheme inside it. The scheme is an undirected tree (connected acyclic graph) with a root in the vertex 1, in which every leaf (excluding root) is an input, and all other vertices are logical elements, including the root, whi... | 0.25 |
{"tests": "{\"inputs\": [\"5 3 5\\n4 4\\n3 5\\n2 4\\n3 4\\n3 5\\n\", \"50 50 1\\n1 50\\n\", \"50 41 1\\n1 50\\n\", \"5 5 5\\n4 4\\n3 5\\n2 4\\n3 4\\n3 5\\n\", \"5 5 5\\n4 4\\n3 5\\n2 3\\n3 3\\n3 5\\n\", \"5 5 5\\n1 4\\n3 5\\n2 3\\n3 3\\n3 5\\n\", \"50 50 1\\n2 50\\n\", \"5 3 5\\n4 2\\n3 5\\n2 4\\n3 4\\n3 5\\n\", \"5 5 ... | You are given a chessboard consisting of n rows and n columns. Rows are numbered from bottom to top from 1 to n. Columns are numbered from left to right from 1 to n. The cell at the intersection of the x-th column and the y-th row is denoted as (x, y). Furthermore, the k-th column is a special column.
Initially, the ... | 0 |
{"tests": "{\"inputs\": [\"5\\n2 2\\n10\\n11\\n3 3\\n011\\n101\\n110\\n4 4\\n1111\\n0110\\n0110\\n1111\\n5 5\\n01011\\n11001\\n00010\\n11011\\n10000\\n2 3\\n011\\n101\\n\", \"5\\n2 2\\n10\\n11\\n3 3\\n011\\n101\\n110\\n4 4\\n1111\\n0110\\n0110\\n1111\\n5 5\\n01011\\n11001\\n00010\\n11011\\n10000\\n2 3\\n011\\n101\\n\",... | This is the hard version of the problem. The difference between the versions is in the number of possible operations that can be made. You can make hacks if and only if you solved both versions of the problem.
You are given a binary table of size n × m. This table consists of symbols 0 and 1.
You can make such operat... | 0 |
{"tests": "{\"inputs\": [\"8\\n4\\n1 2 4 5\\n3\\n1 3 5\\n3\\n2 6 8\\n2\\n1 2\\n1\\n50\\n5\\n3 4 5 6 8\\n3\\n1 25 26\\n6\\n1 2 4 8 16 32\\n\", \"1\\n2\\n1 50\\n\", \"1\\n2\\n2 50\\n\", \"8\\n4\\n1 2 4 5\\n3\\n1 3 5\\n3\\n2 6 8\\n2\\n1 2\\n1\\n50\\n5\\n3 4 5 6 8\\n3\\n1 4 26\\n6\\n1 2 4 8 16 32\\n\", \"1\\n2\\n2 12\\n\",... | Argus was charged with guarding Io, which is not an ordinary cow. Io is quite an explorer, and she wanders off rather frequently, making Argus' life stressful. So the cowherd decided to construct an enclosed pasture for Io.
There are n trees growing along the river, where Argus tends Io. For this problem, the river ca... | 0.75 |
{"tests": "{\"inputs\": [\"6\\n549871\\n\", \"7\\n1198733\\n\", \"7\\n1198733\\n\", \"22\\n7135498415686025907059\\n\", \"72\\n491925337784111770500147619881727525570039735507439360627744863794794290\\n\", \"9\\n988808426\\n\", \"49\\n2429965524999668169991253653390090510755018570235\\n\", \"100\\n400422312494273064023... | Phone number in Berland is a sequence of n digits. Often, to make it easier to memorize the number, it is divided into groups of two or three digits. For example, the phone number 1198733 is easier to remember as 11-987-33. Your task is to find for a given phone number any of its divisions into groups of two or three d... | 0 |
{"tests": "{\"inputs\": [\"4\\n2 4 1\\n\", \"3\\n1 2\\n\", \"71\\n2 50 62 41 50 16 65 6 49 47 45 43 41 39 37 35 33 31 29 27 25 23 21 19 17 15 13 11 9 7 5 3 1 26 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40 42 44 46 48 50 14 6 67 54 54 620768469 637608010 27 54 18 49\\n\", \"10\\n6 7 5 3 1 5 2 4 6\\n\", \"98\... | Farmer John has just given the cows a program to play with! The program contains two integer variables, x and y, and performs the following operations on a sequence a1, a2, ..., an of positive integers:
1. Initially, x = 1 and y = 0. If, after any step, x ≤ 0 or x > n, the program immediately terminates.
2. The p... | 0 |
{"tests": "{\"inputs\": [\"2 5\\n\", \"2 4\\n\", \"6 5\\n\", \"1 4\\n\", \"4 1\\n\", \"2 6\\n\", \"1 3\\n\", \"5 1\\n\", \"4 4\\n\", \"2 3\\n\", \"5 6\\n\", \"2 1\\n\", \"4 6\\n\", \"1 6\\n\", \"1 1\\n\", \"4 5\\n\", \"6 6\\n\", \"5 2\\n\", \"6 2\\n\", \"5 4\\n\", \"4 2\\n\", \"2 2\\n\", \"3 6\\n\", \"6 3\\n\", \"5 5\\... | Two players are playing a game. First each of them writes an integer from 1 to 6, and then a dice is thrown. The player whose written number got closer to the number on the dice wins. If both payers have the same difference, it's a draw.
The first player wrote number a, the second player wrote number b. How many ways ... | 0.625 |
{"tests": "{\"inputs\": [\"10 3 2\\n\", \"7 1 2\\n\", \"94268 714 345\\n\", \"1000000000000000000 1000000000 2000000000\\n\", \"40525189 6365 12730\\n\", \"321076647734423976 7 8\\n\", \"370330636048898430 61721772674816405 6\\n\", \"19 1 19\\n\", \"674664088 435395270 5\\n\", \"262610 5583 4717\\n\", \"799999999999999... | Vector Willman and Array Bolt are the two most famous athletes of Byteforces. They are going to compete in a race with a distance of L meters today.
<image>
Willman and Bolt have exactly the same speed, so when they compete the result is always a tie. That is a problem for the organizers because they want a winner.
... | 0.125 |
{"tests": "{\"inputs\": [\"7 4\\n1 1 3 3 5 3\\n1\\n2\\n3\\n5\\n\", \"2 2\\n1\\n1\\n2\\n\", \"7 4\\n1 1 3 3 4 3\\n1\\n2\\n3\\n5\\n\", \"7 4\\n1 1 3 3 4 3\\n1\\n4\\n3\\n5\\n\", \"2 2\\n1\\n1\\n1\\n\", \"7 4\\n1 1 3 3 4 3\\n2\\n4\\n3\\n5\\n\", \"7 4\\n1 1 3 3 4 3\\n1\\n4\\n3\\n1\\n\", \"7 4\\n1 1 3 3 4 3\\n1\\n1\\n3\\n5\\... | After the piece of a devilish mirror hit the Kay's eye, he is no longer interested in the beauty of the roses. Now he likes to watch snowflakes.
Once upon a time, he found a huge snowflake that has a form of the tree (connected acyclic graph) consisting of n nodes. The root of tree has index 1. Kay is very interested ... | 0 |
{"tests": "{\"inputs\": [\"4 5 5 6\\n4 3\\n1 3\\n3 3\\n2 5\\n3 2\\n1 3\\n1 4\\n2 3\\n2 4\\n1 1\\n1 1\\n\", \"5 5 1 3\\n2 2\\n2 2\\n2 2\\n2 2\\n\", \"1 6 3 12\\n1 2\\n1 4\\n1 6\\n1 1\\n1 2\\n1 6\\n1 2\\n1 5\\n1 3\\n1 4\\n1 5\\n1 5\\n1 4\\n1 6\\n1 3\\n\", \"1 2 1 2\\n1 1\\n1 2\\n1 1\\n\", \"3 3 3 5\\n1 1\\n2 2\\n3 3\\n1 ... | Fox Ciel saw a large field while she was on a bus. The field was a n × m rectangle divided into 1 × 1 cells. Some cells were wasteland, and other each cell contained crop plants: either carrots or kiwis or grapes.
After seeing the field carefully, Ciel found that the crop plants of each cell were planted in following... | 0.125 |
{"tests": "{\"inputs\": [\"4\\n1000 100 10 1\\n\", \"2\\n1 2\\n\", \"22\\n33 2 19 26 18 13 27 9 25 35 6 24 20 22 11 5 1 30 17 15 7 29\\n\", \"22\\n133295371 188010892 71730560 209842234 193069109 184556873 87395258 234247052 230809052 211444018 148989732 17810977 158722706 11753932 100093528 1000000000 43672080 6135758... | You are given an array a with n distinct integers. Construct an array b by permuting a such that for every non-empty subset of indices S = {x1, x2, ..., xk} (1 ≤ xi ≤ n, 0 < k < n) the sums of elements on that positions in a and b are different, i. e.
<image>
Input
The first line contains one integer n (1 ≤ n ≤ 22)... | 0 |
{"tests": "{\"inputs\": [\"3\\n2 6 3\\n4\\n1 1 2 2\\n1 1 3 3\\n2 1 9\\n1 1 3 2\\n\", \"5\\n1 2 3 4 5\\n6\\n1 1 4 2\\n2 3 6\\n1 1 4 2\\n1 1 5 2\\n2 5 10\\n1 1 5 2\\n\", \"1\\n1000000000\\n1\\n1 1 1 1000000000\\n\", \"4\\n3 3 7 7\\n1\\n1 1 4 3\\n\", \"4\\n3 3 14 7\\n1\\n1 1 4 3\\n\", \"3\\n2 6 3\\n4\\n1 1 2 2\\n1 1 3 3\\... | Bash likes playing with arrays. He has an array a1, a2, ... an of n integers. He likes to guess the greatest common divisor (gcd) of different segments of the array. Of course, sometimes the guess is not correct. However, Bash will be satisfied if his guess is almost correct.
Suppose he guesses that the gcd of the ele... | 0.5 |
{"tests": "{\"inputs\": [\"3 4\\n\", \"3 6\\n\", \"3 9\\n\", \"3888 723508350\\n\", \"4096 287894773\\n\", \"20555 592508508\\n\", \"649229491 965270051\\n\", \"1000000000 1000000000\\n\", \"13179877 557546766\\n\", \"71233638 269883787\\n\", \"5 50\\n\", \"469621113 834270209\\n\", \"8711 269883787\\n\", \"2601 698964... | The weather is fine today and hence it's high time to climb the nearby pine and enjoy the landscape.
The pine's trunk includes several branches, located one above another and numbered from 2 to y. Some of them (more precise, from 2 to p) are occupied by tiny vile grasshoppers which you're at war with. These grasshoppe... | 0 |
{"tests": "{\"inputs\": [\"7\\n3 4 1 2 2 1 1\\n\", \"5\\n10 40 20 50 30\\n\", \"5\\n1 1 3 1 1\\n\", \"34\\n967614464 967614464 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 100000... | You are given an array of positive integers. While there are at least two equal elements, we will perform the following operation. We choose the smallest value x that occurs in the array 2 or more times. Take the first two occurrences of x in this array (the two leftmost occurrences). Remove the left of these two occur... | 0.125 |
{"tests": "{\"inputs\": [\"1\\n3\\n1 2\\n2 3\\n1 3\\n\\nSAMPLE\", \"1\\n3\\n1 2\\n2 3\\n1 3\", \"1\\n3\\n1 3\\n2 3\\n1 3\", \"1\\n3\\n1 3\\n1 3\\n1 3\", \"1\\n3\\n1 3\\n2 3\\n1 4\", \"1\\n2\\n2 2\\n2 2\\n1 3\", \"1\\n3\\n1 3\\n1 6\\n4 9\", \"1\\n3\\n3 5\\n8 2\\n1 4\", \"1\\n2\\n1 3\\n1 3\\n1 3\", \"1\\n2\\n1 3\\n1 4\\n... | The Monk wants to buy some cities. To buy two cities, he needs to buy the road connecting those two cities. Now, you are given a list of roads, bought by the Monk. You need to tell how many cities did the Monk buy.
Input:
First line contains an integer T, denoting the number of test cases. The first line of each tes... | 0.125 |
{"tests": "{\"inputs\": [\"3\\nhack\\n5!\\ni_?_uSAMPLE\", \"10\\no3fmci,o2p\\nc8tllmhzg7\\n747kdw9lo3\\nsj8cz3cvmo\\ns3szaonxca\\npir_be2g1p\\n23?behplex\\nd4hiyu65r6\\n6rtnnrjj0!\\n7u7mlvsfd0\", \"10\\no3fmci,o2p\\nc8tllmhzg7\\n747kdw9lo3\\nsj8cz3cvmo\\ns3szaonxca\\npir_be2g1p\\n23?behplex\\nd4hiyu65r6\\n6rtnnrjj0!\\n... | Roy frequently needs to use his old Nokia cell phone for texting whose keypad looks exactly as shown below.
You may be already familiar with the working of the keypad, however if you're not we shall see a few examples.
To type "b", we need to press "2" twice. To type "?" we need to press "1" thrice. To type "5" w... | 0 |
{"tests": "{\"inputs\": [\"2\\n1000\", \"1\\n10\", \"2\\n1001\", \"1\\n11\", \"1\\n0\", \"1\\n13\", \"2\\n1010\", \"2\\n1100\", \"2\\n1110\", \"2\\n0001\", \"2\\n0101\", \"1\\n12\", \"2\\n0111\", \"2\\n1111\", \"2\\n0011\", \"2\\n0010\", \"2\\n0100\", \"2\\n1101\", \"2\\n1011\", \"2\\n0110\", \"1\\n17\", \"1\\n1\", \"1... | Given are a positive integer N and a sequence of length 2^N consisting of 0s and 1s: A_0,A_1,\ldots,A_{2^N-1}. Determine whether there exists a closed curve C that satisfies the condition below for all 2^N sets S \subseteq \\{0,1,\ldots,N-1 \\}. If the answer is yes, construct one such closed curve.
* Let x = \sum_{i ... | 0 |
{"tests": "{\"inputs\": [\"23\\n1 1 1\\n2 1 1\", \"23\\n1 1 1\\n2 2 1\", \"23\\n1 2 1\\n2 1 1\", \"23\\n1 2 1\\n2 0 1\", \"23\\n0 2 1\\n2 0 1\", \"23\\n1 1 2\\n1 1 0\", \"23\\n1 1 1\\n2 0 1\", \"23\\n1 4 1\\n2 1 1\", \"23\\n1 1 2\\n2 3 0\", \"23\\n0 2 1\\n4 0 1\", \"23\\n1 8 1\\n2 1 1\", \"23\\n0 2 1\\n1 0 1\", \"23\\n... | The squirrel Chokudai has N acorns. One day, he decides to do some trades in multiple precious metal exchanges to make more acorns.
His plan is as follows:
1. Get out of the nest with N acorns in his hands.
2. Go to Exchange A and do some trades.
3. Go to Exchange B and do some trades.
4. Go to Exchange A and do some... | 0 |
{"tests": "{\"inputs\": [\"2\\n2\\n2\\n100\", \"30\\n40\\n50\\n6000\", \"5\\n1\\n0\\n150\", \"2\\n2\\n4\\n100\", \"30\\n40\\n77\\n6000\", \"5\\n0\\n0\\n150\", \"30\\n47\\n77\\n6000\", \"5\\n0\\n0\\n0\", \"2\\n2\\n5\\n100\", \"2\\n2\\n10\\n100\", \"30\\n47\\n77\\n10696\", \"5\\n0\\n1\\n0\", \"2\\n0\\n10\\n100\", \"30\\n... | You have A 500-yen coins, B 100-yen coins and C 50-yen coins (yen is the currency of Japan). In how many ways can we select some of these coins so that they are X yen in total?
Coins of the same kind cannot be distinguished. Two ways to select coins are distinguished when, for some kind of coin, the numbers of that co... | 0 |
{"tests": "{\"inputs\": [\"7\", \"299\", \"8\", \"203\", \"3\", \"45\", \"6\", \"22\", \"10\", \"35\", \"17\", \"52\", \"12\", \"84\", \"24\", \"2\", \"14\", \"0\", \"1\", \"39\", \"580\", \"9\", \"200\", \"4\", \"48\", \"13\", \"19\", \"16\", \"26\", \"40\", \"21\", \"60\", \"5\", \"11\", \"25\", \"733\", \"198\", \"2... | We will call a string x good if it satisfies the following condition:
* Condition: x can be represented as a concatenation of two copies of another string y of length at least 1.
For example, `aa` and `bubobubo` are good; an empty string, `a`, `abcabcabc` and `abba` are not good.
Eagle and Owl created a puzzle on ... | 0 |
{"tests": "{\"inputs\": [\"3\\n3 2 1\", \"3\\n2 3 1\", \"2\\n1 2\", \"2\\n1 0\", \"2\\n0 -1\", \"3\\n2 0 1\", \"3\\n1 3 2\", \"3\\n1 -1 0\", \"3\\n0 2 1\", \"3\\n0 1 2\", \"3\\n2 1 0\", \"2\\n2 1\", \"2\\n2 -1\", \"2\\n-1 0\", \"2\\n0 1\", \"2\\n-1 2\", \"3\\n1 0 2\", \"3\\n-1 3 1\", \"3\\n-1 0 1\", \"3\\n0 -1 1\", \"3... | You are given a permutation p of the set {1, 2, ..., N}. Please construct two sequences of positive integers a_1, a_2, ..., a_N and b_1, b_2, ..., b_N satisfying the following conditions:
* 1 \leq a_i, b_i \leq 10^9 for all i
* a_1 < a_2 < ... < a_N
* b_1 > b_2 > ... > b_N
* a_{p_1}+b_{p_1} < a_{p_2}+b_{p_2} < ... < a... | 0 |
{"tests": "{\"inputs\": [\"2 1 1\\n1 2 no\\n2 1 no\\n3 2 1\\n1 1 yes\\n2 2 yes\\n3 3 yes\\n2 2 1\\n1 2 yes\\n2 3 no\\n5 4 3\\n1 2 yes\\n1 3 no\\n4 5 yes\\n5 6 yes\\n6 7 no\\n0 0 0\", \"2 1 1\\n1 2 no\\n2 1 no\\n3 2 1\\n1 1 sey\\n2 2 yes\\n3 3 yes\\n2 2 1\\n1 2 yes\\n2 3 no\\n5 4 3\\n1 2 yes\\n1 3 no\\n4 5 yes\\n5 6 yes... | After having drifted about in a small boat for a couple of days, Akira Crusoe Maeda was finally cast ashore on a foggy island. Though he was exhausted and despaired, he was still fortunate to remember a legend of the foggy island, which he had heard from patriarchs in his childhood. This must be the island in the legen... | 0.375 |
{"tests": "{\"inputs\": [\"3 4\\nS.M\\n...\\n...\\nM.G\", \"3 4\\nM.S\\n...\\n...\\nM.G\", \"3 4\\nM.S\\n...\\n...\\nG.M\", \"3 4\\nS.N\\n...\\n...\\nM.G\", \"3 4\\nM.S\\n...\\n...\\nMG.\", \"3 4\\nL.S\\n...\\n...\\nN.G\", \"3 4\\nL.S\\n...\\n...\\nNG.\", \"3 4\\nM.S\\n...\\n...\\n.GM\", \"3 4\\n.MS\\n...\\n...\\nM.G\"... | C: Acrophobia
Yayoi Takasugi is a super-selling idol. There is one thing she is not good at. It's a high place ... She is extremely afraid of heights. This time, due to the producer's inadequacy, she decided to take on the following challenges on a variety show.
This location will be held in a room in a ninja mansion... | 0 |
{"tests": "{\"inputs\": [\"6 10 3 4\\n##########\\n#........#\\n#...D....#\\n#........#\\n#........#\\n##########\\n2 4 6\\n3 2 0\\n7 4 2\\n8 4 3\\n1 4 1\", \"6 10 3 4\\n##########\\n#........#\\n#...D....\\\"\\n#........#\\n#........#\\n##########\\n2 4 6\\n3 2 0\\n7 4 2\\n8 4 3\\n1 4 1\", \"6 10 3 4\\n##########\\n#.... | C --Dowsing Machine
Story
People make noise with X and Y, but the coming era will be "D". "Paklin Monster D" is a very popular game in which "D people" search for treasure using the "D machine" developed by the secret society "R team".
In this game, the person D in the square with the grid map repeatedly moves to th... | 0 |
{"tests": "{\"inputs\": [\"5\\n1 2 3 4 5\", \"5\\n1 2 3 0 5\", \"5\\n1 2 3 0 2\", \"5\\n1 2 4 0 2\", \"5\\n1 4 4 0 2\", \"5\\n1 4 4 1 2\", \"5\\n1 4 4 2 2\", \"5\\n1 6 4 2 2\", \"5\\n1 8 4 2 2\", \"5\\n1 8 3 2 2\", \"5\\n1 8 3 2 1\", \"5\\n2 8 3 2 1\", \"5\\n2 8 3 2 0\", \"5\\n2 8 3 3 0\", \"5\\n4 8 3 3 0\", \"5\\n4 6 ... | Kattapa, as you all know was one of the greatest warriors of his time. The kingdom of Maahishmati had never lost a battle under him (as army-chief), and the reason for that was their really powerful army, also called as Mahasena.
Kattapa was known to be a very superstitious person. He believed that a soldier is "lucky"... | 0.625 |
{"tests": "{\"inputs\": [\"15 2\\n1 2 3 1 2 3 1 2 3 1 2 3 1 2 3\\n\", \"5 4\\n1 4 5 60 4\\n\", \"3 1\\n1 1 1\\n\", \"1 200000\\n1\\n\", \"2 2\\n1 1\\n\", \"3 1\\n3 2 1\\n\", \"1 1\\n2\\n\", \"2 2\\n2 1\\n\", \"10 7\\n14 20 3 3 8 16 17 13 6 4\\n\", \"3 1\\n1 3 2\\n\", \"2 1\\n1 2\\n\", \"4 3\\n3 5 2 3\\n\", \"1 1\\n1\\n... | You are given an integer sequence a_1, a_2, ..., a_n.
Find the number of pairs of indices (l, r) (1 ≤ l ≤ r ≤ n) such that the value of median of a_l, a_{l+1}, ..., a_r is exactly the given number m.
The median of a sequence is the value of an element which is in the middle of the sequence after sorting it in non-dec... | 0.125 |
{"tests": "{\"inputs\": [\"6 3 2\\n1 1 -1 -1 -1 -1\\n\", \"5 2 3\\n1 -1 1 -1 2\\n\", \"10 42 7\\n-1 -1 -1 -1 -1 -1 -1 -1 -1 -1\\n\", \"1 100 1\\n-1\\n\", \"1 100 2\\n-1\\n\", \"6 3 2\\n1 1 -1 -1 0 -1\\n\", \"5 2 3\\n2 -1 1 -1 2\\n\", \"5 2 3\\n2 -1 2 -1 2\\n\", \"6 3 4\\n1 1 -1 -1 1 -1\\n\", \"6 3 2\\n1 2 -1 -1 -1 -1\\... | Vasya has got an array consisting of n integers, and two integers k and len in addition. All numbers in the array are either between 1 and k (inclusive), or equal to -1. The array is good if there is no segment of len consecutive equal numbers.
Vasya will replace each -1 with some number from 1 to k (inclusive) in suc... | 0 |
{"tests": "{\"inputs\": [\"4 6 3\\n1 1 2 3\\n2 6 1 2\\n2 6 2 4\\n\", \"999999937 999999874000003969 1\\n1 979917353 2 983249032983207370\\n\", \"1 1 10\\n1 1 1 1\\n1 1 1 1\\n1 1 2 1\\n1 1 1 1\\n2 1 2 1\\n2 1 1 1\\n1 1 2 1\\n1 1 2 1\\n2 1 1 1\\n2 1 1 1\\n\", \"3 9 1\\n1 1 2 4\\n\", \"2 3 5\\n2 3 1 2\\n2 3 2 3\\n1 1 1 1\... | Amugae is in a very large round corridor. The corridor consists of two areas. The inner area is equally divided by n sectors, and the outer area is equally divided by m sectors. A wall exists between each pair of sectors of same area (inner or outer), but there is no wall between the inner area and the outer area. A wa... | 0 |
{"tests": "{\"inputs\": [\"6 11\\n1 3\\n1 4\\n1 5\\n1 6\\n2 3\\n2 4\\n2 5\\n2 6\\n3 4\\n3 5\\n3 6\\n\", \"3 0\\n\", \"1 0\\n\", \"2 0\\n\", \"2 1\\n1 2\\n\", \"3 1\\n2 3\\n\", \"10 10\\n1 5\\n1 8\\n1 9\\n5 8\\n8 9\\n4 7\\n2 3\\n3 10\\n2 6\\n2 10\\n\", \"3 3\\n1 2\\n3 1\\n2 3\\n\", \"6 9\\n1 2\\n1 4\\n1 5\\n2 3\\n2 5\\n... | Ujan has a lot of useless stuff in his drawers, a considerable part of which are his math notebooks: it is time to sort them out. This time he found an old dusty graph theory notebook with a description of a graph.
It is an undirected weighted graph on n vertices. It is a complete graph: each pair of vertices is conne... | 0 |
{"tests": "{\"inputs\": [\"5\\n6\\n111010\\n1\\n0\\n1\\n1\\n2\\n11\\n6\\n101010\\n\", \"5\\n6\\n111010\\n1\\n1\\n1\\n1\\n2\\n11\\n6\\n101010\\n\", \"5\\n6\\n111000\\n1\\n1\\n1\\n1\\n2\\n11\\n6\\n101010\\n\", \"5\\n6\\n011011\\n1\\n0\\n1\\n1\\n2\\n11\\n6\\n111000\\n\", \"5\\n6\\n111111\\n1\\n0\\n1\\n1\\n2\\n11\\n6\\n101... | You have a string s consisting of n characters. Each character is either 0 or 1.
You can perform operations on the string. Each operation consists of two steps:
1. select an integer i from 1 to the length of the string s, then delete the character s_i (the string length gets reduced by 1, the indices of characters ... | 0 |
{"tests": "{\"inputs\": [\"5\\n10\\n0111010000\\n0100101100\\n4\\n0000\\n0000\\n3\\n001\\n000\\n12\\n010101010101\\n100110011010\\n6\\n000111\\n110100\\n\", \"5\\n10\\n0111010000\\n0100101100\\n4\\n0000\\n0000\\n3\\n000\\n000\\n12\\n010101010101\\n100110011010\\n6\\n000111\\n110100\\n\", \"5\\n10\\n0111010000\\n0101101... | There is a binary string a of length n. In one operation, you can select any prefix of a with an equal number of 0 and 1 symbols. Then all symbols in the prefix are inverted: each 0 becomes 1 and each 1 becomes 0.
For example, suppose a=0111010000.
* In the first operation, we can select the prefix of length 8 sin... | 0 |
{"tests": "{\"inputs\": [\"3\\n2\\n1 6\\n3 8\\n1 2\\n3\\n1 3\\n4 6\\n7 9\\n1 2\\n2 3\\n6\\n3 14\\n12 20\\n12 19\\n2 12\\n10 17\\n3 17\\n3 2\\n6 5\\n1 5\\n2 6\\n4 6\\n\", \"3\\n2\\n1 6\\n3 8\\n1 2\\n3\\n1 3\\n4 6\\n7 9\\n1 2\\n2 3\\n6\\n4 14\\n12 20\\n12 19\\n2 12\\n10 17\\n3 17\\n3 2\\n6 5\\n1 5\\n2 6\\n4 6\\n\", \"3\\... | Parsa has a humongous tree on n vertices.
On each vertex v he has written two integers l_v and r_v.
To make Parsa's tree look even more majestic, Nima wants to assign a number a_v (l_v ≤ a_v ≤ r_v) to each vertex v such that the beauty of Parsa's tree is maximized.
Nima's sense of the beauty is rather bizarre. He de... | 0.125 |
{"tests": "{\"inputs\": [\"5\\n1 2 2\\n2 3 2\\n3 4 2\\n4 5 2\\n\", \"5\\n1 2 1\\n2 3 2\\n2 4 1\\n4 5 1\\n\", \"5\\n1 2 2\\n1 3 2\\n1 4 2\\n1 5 2\\n\", \"4\\n1 2 2\\n2 3 1\\n2 4 2\\n\", \"5\\n1 5 1\\n5 4 2\\n4 3 1\\n3 2 2\\n\", \"10\\n1 10 2\\n10 9 2\\n10 8 2\\n9 7 2\\n8 6 1\\n7 5 1\\n6 4 1\\n5 3 1\\n4 2 1\\n\", \"2\\n1... | The city Valera lives in is going to hold elections to the city Parliament.
The city has n districts and n - 1 bidirectional roads. We know that from any district there is a path along the roads to any other district. Let's enumerate all districts in some way by integers from 1 to n, inclusive. Furthermore, for each r... | 0 |
{"tests": "{\"inputs\": [\"5 33\\n2 1 3 3 10\\n1 11 3\\n2 5 3 3 6\\n2 3 1 10 3\\n2 6 3 3 5\\n\", \"2 33\\n2 5 1 2 14\\n1 3 11\\n\", \"2 33\\n2 1 3 10 3\\n1 11 3\\n\", \"3 228385\\n2 307 733 43 78\\n2 252 801 157 169\\n3 86 346 133 886 467 173\\n\", \"9 81812\\n8 31 410 547 18 22 77 449 5 491 8 10 382 746 21 61 523\\n1 ... | Today s kilometer long auto race takes place in Berland. The track is represented by a straight line as long as s kilometers. There are n cars taking part in the race, all of them start simultaneously at the very beginning of the track. For every car is known its behavior — the system of segments on each of which the s... | 0 |
{"tests": "{\"inputs\": [\"3 4\\n001000\\n000010\\n000010\\n\", \"2 2\\n0010\\n0100\\n\", \"4 3\\n01110\\n01110\\n01110\\n01110\\n\", \"8 8\\n0111111110\\n0111101110\\n0111111110\\n0111111110\\n0111111110\\n0110111100\\n0101111110\\n0110111110\\n\", \"5 44\\n0001010010001111111001111111000010100100000010\\n000111100111... | Some people leave the lights at their workplaces on when they leave that is a waste of resources. As a hausmeister of DHBW, Sagheer waits till all students and professors leave the university building, then goes and turns all the lights off.
The building consists of n floors with stairs at the left and the right sides... | 0 |
{"tests": "{\"inputs\": [\"4\\n1 100\\n100 1\\n1 100\\n100 1\\n\", \"3\\n1 1\\n100 100\\n1 1\\n\", \"3\\n4 5\\n4 5\\n4 10\\n\", \"3\\n3 3\\n2 0\\n1 2\\n\", \"4\\n1 3\\n2 3\\n3 1\\n1 0\\n\", \"5\\n2 0\\n3 0\\n3 0\\n3 5\\n2 4\\n\", \"3\\n1 3\\n1 3\\n2 1\\n\", \"3\\n1 3\\n2 1\\n3 0\\n\", \"9\\n4 7\\n2 0\\n7 3\\n9 5\\n8 8\... | Mayor of city S just hates trees and lawns. They take so much space and there could be a road on the place they occupy!
The Mayor thinks that one of the main city streets could be considerably widened on account of lawn nobody needs anyway. Moreover, that might help reduce the car jams which happen from time to time o... | 0 |
{"tests": "{\"inputs\": [\"4 4 2 0 1 1\\n\", \"10 10 10 1 -1 0\\n\", \"4 3 2 2 -1 1\\n\", \"584801838 775270595 121061956 644380885 -1 1\\n\", \"603278410 844534002 499505824 32181172 1 -1\\n\", \"320049957 92820858 176731509 15650804 1 1\\n\", \"1000000000 999999999 999999998 999999999 1 1\\n\", \"978089453 426264909 ... | Consider a [billiard table](https://en.wikipedia.org/wiki/Billiard_table) of rectangular size n × m with four pockets. Let's introduce a coordinate system with the origin at the lower left corner (see the picture).
<image>
There is one ball at the point (x, y) currently. Max comes to the table and strikes the ball. ... | 0 |
{"tests": "{\"inputs\": [\"2\\n3 10\\n2 8\\n\\nSAMPLE\", \"2\\n3 10\\n1 8\\n\\nSAMPLE\", \"2\\n3 10\\n1 16\\n\\nSAMPLE\", \"2\\n4 10\\n1 16\\n\\nSAMPLE\", \"2\\n1 4\\n2 8\\n\\nSAMPLE\", \"2\\n3 4\\n2 8\\n\\nSAMPLE\", \"2\\n3 8\\n2 8\\n\\nSAMPLE\", \"2\\n4 9\\n1 16\\n\\nSAMPLE\", \"2\\n3 10\\n2 8\\n\\nSAMELP\", \"2\\n3 ... | Rufus wants to go to the Lily's birthday party to surprise Lily. But Lily's party invitation has a unique code on it which is in the form X-Y(e.g. 123-456). So Rufus need a invitation but he fails to get the invitation.
So he decided to make a invitation on his own with a fake code on it. But each code has a unique ch... | 0.875 |
{"tests": "{\"inputs\": [\"3 2\\n10 10 1\\n10 10 1\\n1 1 10\", \"3 1\\n5 3 2\\n1 4 8\\n7 6 9\", \"3 1\\n10 10 1\\n10 10 1\\n1 1 10\", \"3 2\\n5 10 1\\n10 10 1\\n1 1 10\", \"1 1\\n5 3 2\\n1 4 8\\n7 6 9\", \"3 2\\n5 10 1\\n10 6 1\\n1 1 10\", \"3 2\\n5 10 1\\n10 6 1\\n1 1 15\", \"1 1\\n1 3 2\\n1 4 8\\n7 12 9\", \"3 1\\n18... | You are given a grid of N rows and M columns. The square at the i-th row and j-th column will be denoted as (i,j). A nonnegative integer A_{i,j} is written for each square (i,j).
You choose some of the squares so that each row and column contains at most K chosen squares. Under this constraint, calculate the maximum v... | 0 |
{"tests": "{\"inputs\": [\"4\\n5 7\", \"7\\n500 600\", \"1\\n11 11\", \"4\\n5 9\", \"4\\n1 1\", \"4\\n2 9\", \"4\\n2 16\", \"4\\n2 23\", \"4\\n0 23\", \"4\\n1 23\", \"4\\n1 20\", \"4\\n1 8\", \"4\\n1 11\", \"4\\n1 15\", \"4\\n1 2\", \"4\\n2 2\", \"4\\n1 7\", \"7\\n500 983\", \"4\\n1 9\", \"4\\n4 16\", \"4\\n2 37\", \"4... | Takahashi the Jumbo will practice golf.
His objective is to get a carry distance that is a multiple of K, while he can only make a carry distance of between A and B (inclusive).
If he can achieve the objective, print `OK`; if he cannot, print `NG`.
Constraints
* All values in input are integers.
* 1 \leq A \leq B \... | 0.5 |
{"tests": "{\"inputs\": [\"zyxwvutsrqponmlkjihgfedcba\", \"atcoder\", \"abcdefghijklmnopqrstuvwzyx\", \"abc\", \"redocta\", \"azcdefghijklmnopqrstuvwbyx\", \"cba\", \"redoctb\", \"bca\", \"bac\", \"abd\", \"atcodes\", \"abcdefghijklmnopqrytuvwzsx\", \"btcoder\", \"bad\", \"acb\", \"cab\", \"dba\", \"atcored\", \"qedoct... | Gotou just received a dictionary. However, he doesn't recognize the language used in the dictionary. He did some analysis on the dictionary and realizes that the dictionary contains all possible diverse words in lexicographical order.
A word is called diverse if and only if it is a nonempty string of English lowercase... | 0 |
{"tests": "{\"inputs\": [\"2 4\", \"1 3\", \"2 8\", \"1 10\", \"1 4\", \"2 3\", \"2 10\", \"4 3\", \"7 3\", \"7 6\", \"7 4\", \"7 5\", \"4 5\", \"1 5\", \"1 2\", \"0 2\", \"-1 2\", \"2 1\", \"1 1\", \"2 0\", \"2 6\", \"3 3\", \"7 1\", \"5 4\", \"7 10\", \"5 5\", \"2 5\", \"2 9\", \"3 6\", \"5 3\", \"7 12\", \"5 8\", \"... | Based on some criterion, Snuke divided the integers from 1 through 12 into three groups as shown in the figure below. Given two integers x and y (1 ≤ x < y ≤ 12), determine whether they belong to the same group.
b4ab979900ed647703389d4349eb84ee.png
Constraints
* x and y are integers.
* 1 ≤ x < y ≤ 12
Input
Input i... | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.