source
int64
2
2
difficulty
int64
7
25
name
stringlengths
9
60
description
stringlengths
164
7.12k
public_tests
dict
private_tests
dict
cf_rating
int64
0
3.5k
cf_points
float64
0
4k
2
10
1000_D. Yet Another Problem On a Subsequence
The sequence of integers a_1, a_2, ..., a_k is called a good array if a_1 = k - 1 and a_1 > 0. For example, the sequences [3, -1, 44, 0], [1, -99] are good arrays, and the sequences [3, 7, 8], [2, 5, 4, 1], [0] — are not. A sequence of integers is called good if it can be divided into a positive number of good arrays....
{ "input": [ "4\n1 1 1 1\n", "3\n2 1 1\n" ], "output": [ "7\n", "2\n" ] }
{ "input": [ "1\n1\n", "1\n0\n" ], "output": [ "0\n", "0\n" ] }
1,900
0
2
7
106_A. Card Game
There is a card game called "Durak", which means "Fool" in Russian. The game is quite popular in the countries that used to form USSR. The problem does not state all the game's rules explicitly — you can find them later yourselves if you want. To play durak you need a pack of 36 cards. Each card has a suit ("S", "H", ...
{ "input": [ "C\n7H AS\n", "H\nQH 9S\n", "S\n8D 6D\n" ], "output": [ "NO\n", "YES\n", "YES\n" ] }
{ "input": [ "H\nQD KD\n", "D\n9S 8S\n", "H\nTH 8H\n", "D\nAC KS\n", "H\nAH KH\n", "H\nAD KD\n", "D\n8S 6C\n", "H\nAC QC\n", "H\nJC JH\n", "H\n7D 6D\n", "H\nJS TS\n", "C\n6C 6D\n", "H\n9D 8S\n", "C\nJC AH\n", "H\n9C 8D\n", "S\n7S JS\n", "H\n8H 8D\n",...
1,000
500
2
20
1090_M. The Pleasant Walk
There are n houses along the road where Anya lives, each one is painted in one of k possible colors. Anya likes walking along this road, but she doesn't like when two adjacent houses at the road have the same color. She wants to select a long segment of the road such that no two adjacent houses have the same color. H...
{ "input": [ "8 3\n1 2 3 3 2 1 2 2\n" ], "output": [ "4" ] }
{ "input": [ "3 3\n1 2 3\n", "4 2\n1 1 2 2\n", "100 100\n82 51 81 14 37 17 78 92 64 15 8 86 89 8 87 77 66 10 15 12 100 25 92 47 21 78 20 63 13 49 41 36 41 79 16 87 87 69 3 76 80 60 100 49 70 59 72 8 38 71 45 97 71 14 76 54 81 4 59 46 39 29 92 3 49 22 53 99 59 52 74 31 92 43 42 23 44 9 82 47 7 40 12 9 3 55...
1,000
0
2
9
110_C. Lucky Sum of Digits
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Petya wonders eagerly what minimum lucky number has the sum of digits equal to n. Help him cope with...
{ "input": [ "11\n", "10\n" ], "output": [ "47\n", "-1\n" ] }
{ "input": [ "999980\n", "9854\n", "10000\n", "474\n", "999990\n", "10000\n", "1000\n", "999990\n", "10417\n", "1000000\n", "3840\n", "7\n", "4\n", "11000\n", "1024\n", "800000\n", "111\n", "888887\n", "999998\n", "3840\n", "10691\n",...
1,000
500
2
12
1157_F. Maximum Balanced Circle
There are n people in a row. The height of the i-th person is a_i. You can choose any subset of these people and try to arrange them into a balanced circle. A balanced circle is such an order of people that the difference between heights of any adjacent people is no more than 1. For example, let heights of chosen peop...
{ "input": [ "3\n5 1 4\n", "7\n4 3 5 1 2 2 1\n", "5\n3 7 5 1 5\n", "7\n2 2 3 2 1 2 2\n" ], "output": [ "2\n4 5\n", "5\n1 2 3 2 1 \n", "2\n5 5 \n", "7\n1 2 3 2 2 2 2 \n" ] }
{ "input": [ "4\n200000 200000 200000 200000\n", "1\n200000\n", "3\n200000 200000 200000\n", "2\n200000 200000\n", "1\n1\n", "10\n2 3 6 7 4 6 3 2 6 6\n", "7\n4 3 5 1 2 2 1\n", "5\n20 21 22 23 24\n" ], "output": [ "4\n200000 200000 200000 200000 \n", "1\n200000 \n", "3\n...
2,000
0
2
9
1215_C. Swap Letters
Monocarp has got two strings s and t having equal length. Both strings consist of lowercase Latin letters "a" and "b". Monocarp wants to make these two strings s and t equal to each other. He can do the following operation any number of times: choose an index pos_1 in the string s, choose an index pos_2 in the string...
{ "input": [ "1\na\nb\n", "8\nbabbaabb\nabababaa\n", "4\nabab\naabb\n" ], "output": [ "-1\n", "3\n2 6\n1 3\n7 8\n", "2\n3 3\n3 2\n" ] }
{ "input": [ "10\naaaaaaaaaa\nbbbbbbbbbb\n", "101\nbabbbbabbbbaabbbbbbbabbbababababbbbbbbbabaababbababbaaabbababbbbbbbbbaabbbababbbbbabbbbbabbbaabbbaabb\nbbabbbbbbabbbbbbbbbbbabbbbbbbbbbabbabbbbbbbbbbbabbababbbabbabbbbbbbbbbbbbaabbbabbbbabbabbbbababbbbbab\n", "100\nbbbabbababbbbbbabbbbbbbbabbbbbbbbbbbbbbb...
1,500
1,750
2
11
1238_E. Keyboard Purchase
You have a password which you often type — a string s of length n. Every character of this string is one of the first m lowercase Latin letters. Since you spend a lot of time typing it, you want to buy a new keyboard. A keyboard is a permutation of the first m Latin letters. For example, if m = 3, then there are six ...
{ "input": [ "15 4\nabacabadabacaba\n", "6 3\naacabc\n", "6 4\naaaaaa\n" ], "output": [ "16\n", "5\n", "0\n" ] }
{ "input": [ "44 20\nbcdefghijklmnopqrstabcdefghijklmnopqrstatata\n", "44 20\ncdefghijklmnopqrstabcdefghijklmnopqrstabtata\n" ], "output": [ "61\n", "62\n" ] }
2,200
0
2
7
1280_A. Cut and Paste
We start with a string s consisting only of the digits 1, 2, or 3. The length of s is denoted by |s|. For each i from 1 to |s|, the i-th character of s is denoted by s_i. There is one cursor. The cursor's location ℓ is denoted by an integer in \{0, …, |s|\}, with the following meaning: * If ℓ = 0, then the cursor...
{ "input": [ "4\n5\n231\n7\n2323\n6\n333\n24\n133321333\n" ], "output": [ "25\n1438\n1101\n686531475\n" ] }
{ "input": [ "1\n1000000\n221\n", "9\n1500\n1212\n1500\n1221\n1500\n122\n1500\n12121\n1500\n22\n1500\n1111112111111112\n1500\n1111111111221111111\n1500\n111111122\n1500\n11111121111121111111\n", "1\n1000000\n22\n", "1\n1000000\n1212\n", "1\n1000000\n2211\n", "1\n1000000\n2112\n", "1\n10000...
1,700
500
2
11
12_E. Start of the season
Before the start of the football season in Berland a strange magic ritual is held. The most experienced magicians have to find a magic matrix of the size n × n (n is even number). Gods will never allow to start the championship without it. Matrix should contain integers from 0 to n - 1, main diagonal should contain onl...
{ "input": [ "2\n", "4\n" ], "output": [ "0 1 \n1 0 \n", "0 2 3 1 \n2 0 1 3 \n3 1 0 2 \n1 3 2 0 \n" ] }
{ "input": [ "16\n", "12\n", "66\n", "66\n", "40\n", "100\n", "80\n", "8\n", "128\n", "12\n", "10\n", "144\n", "14\n", "96\n", "88\n", "32\n", "20\n", "18\n", "40\n", "88\n", "18\n", "16\n", "128\n", "14\n", "96\n", ...
2,100
0
2
7
1324_A. Yet Another Tetris Problem
You are given some Tetris field consisting of n columns. The initial height of the i-th column of the field is a_i blocks. On top of these columns you can place only figures of size 2 × 1 (i.e. the height of this figure is 2 blocks and the width of this figure is 1 block). Note that you cannot rotate these figures. Yo...
{ "input": [ "4\n3\n1 1 3\n4\n1 1 2 1\n2\n11 11\n1\n100\n" ], "output": [ "YES\nNO\nYES\nYES\n" ] }
{ "input": [ "1\n12\n2 2 2 2 1 2 2 2 2 2 2 2\n", "1\n1\n1\n", "1\n3\n1 1 2\n" ], "output": [ "NO\n", "YES\n", "NO\n" ] }
900
0
2
7
1385_A. Three Pairwise Maximums
You are given three positive (i.e. strictly greater than zero) integers x, y and z. Your task is to find positive integers a, b and c such that x = max(a, b), y = max(a, c) and z = max(b, c), or determine that it is impossible to find such a, b and c. You have to answer t independent test cases. Print required a, b a...
{ "input": [ "5\n3 2 3\n100 100 100\n50 49 49\n10 30 20\n1 1000000000 1000000000\n" ], "output": [ "YES\n3 2 2\nYES\n100 100 100\nNO\nNO\nYES\n1000000000 1 1\n" ] }
{ "input": [ "1\n127869 127869 127869\n", "1\n78738 78738 78738\n", "2\n5 7 7\n6 7 3\n", "5\n3 2 3\n100 100 100\n50 49 49\n10 30 20\n1 1000000000 1000000000\n", "1\n12789 12789 12789\n", "1\n78788 78788 78788\n" ], "output": [ "YES\n127869 127869 127869\n", "YES\n78738 78738 78738\...
800
0
2
10
1406_D. Three Sequences
You are given a sequence of n integers a_1, a_2, …, a_n. You have to construct two sequences of integers b and c with length n that satisfy: * for every i (1≤ i≤ n) b_i+c_i=a_i * b is non-decreasing, which means that for every 1<i≤ n, b_i≥ b_{i-1} must hold * c is non-increasing, which means that for every 1<...
{ "input": [ "4\n2 -1 7 3\n2\n2 4 -3\n3 4 2\n", "6\n-9 -10 -9 -6 -5 4\n3\n2 6 -9\n1 2 -10\n4 6 -3\n", "1\n0\n2\n1 1 -1\n1 1 -1\n" ], "output": [ "5\n5\n6\n", "3\n3\n3\n1\n", "0\n0\n-1\n" ] }
{ "input": [ "1\n-101\n1\n1 1 5\n" ], "output": [ "-50\n-48\n" ] }
2,200
2,000
2
11
1427_E. Xum
You have a blackboard and initially only an odd number x is written on it. Your goal is to write the number 1 on the blackboard. You may write new numbers on the blackboard with the following two operations. * You may take two numbers (not necessarily distinct) already on the blackboard and write their sum on the ...
{ "input": [ "3\n", "123\n" ], "output": [ "\n5\n3 + 3\n3 ^ 6\n3 + 5\n3 + 6\n8 ^ 9\n", "\n10\n123 + 123\n123 ^ 246\n141 + 123\n246 + 123\n264 ^ 369\n121 + 246\n367 ^ 369\n30 + 30\n60 + 60\n120 ^ 121\n" ] }
{ "input": [ "804351\n", "9\n", "123789\n", "986115\n", "983041\n", "500001\n", "999995\n", "999999\n", "524295\n", "282147\n", "158421\n", "524289\n", "525313\n", "1025\n", "7\n", "123461\n", "8193\n", "999997\n", "11\n", "6565\n", "...
2,500
1,500
2
11
1450_E. Capitalism
A society can be represented by a connected, undirected graph of n vertices and m edges. The vertices represent people, and an edge (i,j) represents a friendship between people i and j. In society, the i-th person has an income a_i. A person i is envious of person j if a_j=a_i+1. That is if person j has exactly 1 more...
{ "input": [ "1 0\n", "4 4\n1 2 1\n2 3 0\n3 4 1\n4 1 1\n", "6 6\n1 2 0\n3 2 0\n2 5 0\n6 5 1\n6 3 0\n2 4 1\n" ], "output": [ "\nYES\n0\n0 \n", "\nNO\n", "\nYES\n3\n3 2 1 3 1 0 \n" ] }
{ "input": [ "50 49\n46 6 1\n35 27 1\n9 40 1\n43 36 1\n7 45 1\n47 46 1\n49 43 1\n4 48 1\n16 34 1\n13 22 1\n41 47 1\n6 20 1\n29 7 1\n48 14 1\n8 23 1\n21 30 1\n14 19 1\n23 31 1\n45 37 1\n19 11 1\n28 38 1\n17 21 1\n5 25 1\n26 12 1\n36 24 1\n24 17 1\n22 5 1\n33 35 1\n25 16 1\n32 26 1\n40 10 1\n18 1 1\n2 4 1\n31 33 1\...
2,700
2,500
2
9
1474_C. Array Destruction
You found a useless array a of 2n positive integers. You have realized that you actually don't need this array, so you decided to throw out all elements of a. It could have been an easy task, but it turned out that you should follow some rules: 1. In the beginning, you select any positive integer x. 2. Then you ...
{ "input": [ "4\n2\n3 5 1 2\n3\n1 1 8 8 64 64\n2\n1 1 2 4\n5\n1 2 3 4 5 6 7 14 3 11\n" ], "output": [ "\nYES\n6\n1 5\n2 3\nNO\nNO\nYES\n21\n14 7\n3 11\n5 6\n2 4\n3 1" ] }
{ "input": [ "6\n4\n5 6 9 13 36 42 47 60\n3\n1 2 3 4 5 6\n3\n1 2 3 3 5 6\n4\n5 22 42 47 49 54 69 123\n2\n1 1 2 2\n3\n1000000 1000000 990000 10000 900000 90000\n", "4\n2\n3 5 1 2\n3\n1 1 8 8 64 64\n2\n1 1 2 4\n5\n1 2 3 4 5 6 7 14 3 11\n" ], "output": [ "YES\n69\n60 9\n47 13\n42 5\n36 6\nYES\n10\n6 4\n5...
1,700
1,500
2
11
1523_E. Crypto Lights
<image> To monitor cryptocurrency exchange rates trader William invented a wonderful device consisting of n lights arranged in a row. The device functions in the following way: Initially, all lights on William's device are turned off. At the beginning of a new iteration the device randomly, with a uniform distributio...
{ "input": [ "3\n3 2\n15 2\n40 15\n" ], "output": [ "\n333333338\n141946947\n329622137\n" ] }
{ "input": [ "10\n100000 99995\n100000 100000\n100000 99998\n100000 99997\n100000 99997\n100000 99997\n100000 100000\n100000 99997\n100000 99999\n100000 99998\n", "10\n91147 3\n60637 60633\n58274 58270\n81624 62\n59542 17\n76280 76277\n78239 3\n84713 84710\n58143 58143\n85720 5\n", "10\n71414 65271\n72899...
2,600
2,250
2
10
155_D. Colliders
By 2312 there were n Large Hadron Colliders in the inhabited part of the universe. Each of them corresponded to a single natural number from 1 to n. However, scientists did not know what activating several colliders simultaneously could cause, so the colliders were deactivated. In 2312 there was a startling discovery:...
{ "input": [ "10 10\n+ 6\n+ 10\n+ 5\n- 10\n- 5\n- 6\n+ 10\n+ 3\n+ 6\n+ 3\n" ], "output": [ "Success\nConflict with 6\nSuccess\nAlready off\nSuccess\nSuccess\nSuccess\nSuccess\nConflict with 10\nAlready on\n" ] }
{ "input": [ "100 1\n+ 51\n", "100000 1\n+ 12345\n", "50 50\n+ 14\n+ 4\n+ 20\n+ 37\n+ 50\n+ 46\n+ 19\n- 20\n+ 25\n+ 47\n+ 10\n+ 6\n+ 34\n+ 12\n+ 41\n- 47\n+ 9\n+ 22\n+ 28\n- 41\n- 34\n+ 47\n+ 40\n- 12\n+ 42\n- 9\n- 4\n+ 15\n- 15\n+ 27\n+ 8\n+ 38\n+ 9\n+ 4\n+ 17\n- 8\n+ 13\n- 47\n+ 7\n- 9\n- 38\n+ 30\n+ 48...
1,600
1,000
2
10
177_D2. Encrypting Messages
The Smart Beaver from ABBYY invented a new message encryption method and now wants to check its performance. Checking it manually is long and tiresome, so he decided to ask the ABBYY Cup contestants for help. A message is a sequence of n integers a1, a2, ..., an. Encryption uses a key which is a sequence of m integers...
{ "input": [ "3 1 5\n1 2 3\n4\n", "4 3 2\n1 1 1 1\n1 1 1\n" ], "output": [ "0 1 2 ", "0 1 1 0 " ] }
{ "input": [ "20 15 17\n4 9 14 11 15 16 15 4 0 10 7 12 10 1 8 6 7 14 1 13\n6 3 14 8 8 11 16 4 5 9 2 13 6 14 15\n", "5 2 7\n0 0 1 2 4\n3 5\n" ], "output": [ "10 1 3 8 3 15 7 14 1 12 3 10 15 16 16 5 4 15 13 11 ", "3 1 2 3 2 " ] }
1,500
70
2
7
222_A. Shooshuns and Sequence
One day shooshuns found a sequence of n integers, written on a blackboard. The shooshuns can perform one operation with it, the operation consists of two steps: 1. Find the number that goes k-th in the current sequence and add the same number to the end of the sequence; 2. Delete the first number of the current s...
{ "input": [ "3 2\n3 1 1\n", "3 1\n3 1 1\n" ], "output": [ "1\n", "-1\n" ] }
{ "input": [ "10 3\n3 2 1 1 1 1 1 1 1 1\n", "10 10\n1 2 3 4 5 6 7 8 9 10\n", "10 2\n2 1 1 1 1 1 1 1 1 1\n", "10 1\n1 2 1 1 1 1 1 1 1 1\n", "10 2\n1 2 1 1 1 1 1 1 1 1\n", "2 1\n1 1\n", "20 9\n1 2 3 4 5 6 7 8 9 10 1 1 1 1 1 1 1 1 1 1\n", "20 10\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n"...
1,200
500
2
11
270_E. Flawed Flow
Emuskald considers himself a master of flow algorithms. Now he has completed his most ingenious program yet — it calculates the maximum flow in an undirected graph. The graph consists of n vertices and m edges. Vertices are numbered from 1 to n. Vertices 1 and n being the source and the sink respectively. However, his...
{ "input": [ "4 5\n1 2 10\n1 3 10\n2 3 5\n4 2 15\n3 4 5\n", "3 3\n3 2 10\n1 2 10\n3 1 5\n" ], "output": [ "0\n0\n1\n1\n0\n", "1\n0\n1\n" ] }
{ "input": [ "3 2\n1 2 1\n2 3 1\n", "2 1\n1 2 1\n", "10 17\n9 1 8\n7 10 1\n5 4 4\n1 10 1\n3 10 1\n10 5 1\n6 3 6\n10 4 1\n4 6 5\n7 5 3\n2 10 1\n9 3 7\n9 10 1\n8 10 1\n10 6 1\n2 7 2\n2 8 1\n", "3 3\n3 1 10000\n2 1 10000\n3 2 10000\n", "4 4\n4 3 5000\n1 2 10000\n3 1 5000\n4 2 10000\n", "2 1\n2 1 ...
2,100
1,500
2
8
294_B. Shaass and Bookshelf
Shaass has n books. He wants to make a bookshelf for all his books. He wants the bookshelf's dimensions to be as small as possible. The thickness of the i-th book is ti and its pages' width is equal to wi. The thickness of each book is either 1 or 2. All books have the same page heights. <image> Shaass puts the books...
{ "input": [ "3\n1 10\n2 1\n2 4\n", "5\n1 12\n1 3\n2 15\n2 5\n2 1\n" ], "output": [ "3\n", "5\n" ] }
{ "input": [ "1\n1 2\n", "1\n1 1\n", "100\n2 2\n1 2\n1 5\n1 5\n1 2\n1 4\n2 3\n1 2\n1 5\n2 1\n2 2\n2 4\n1 2\n2 3\n1 1\n1 1\n2 5\n2 3\n2 2\n1 2\n2 1\n2 2\n1 5\n2 1\n2 4\n1 4\n1 4\n2 2\n1 1\n2 4\n1 4\n2 4\n1 2\n2 3\n2 3\n1 5\n1 5\n2 3\n1 4\n1 5\n2 2\n1 3\n2 2\n2 2\n1 1\n2 1\n2 5\n1 1\n2 3\n2 5\n1 5\n1 3\n1 5...
1,700
1,000
2
8
365_B. The Fibonacci Segment
You have array a1, a2, ..., an. Segment [l, r] (1 ≤ l ≤ r ≤ n) is good if ai = ai - 1 + ai - 2, for all i (l + 2 ≤ i ≤ r). Let's define len([l, r]) = r - l + 1, len([l, r]) is the length of the segment [l, r]. Segment [l1, r1], is longer than segment [l2, r2], if len([l1, r1]) > len([l2, r2]). Your task is to find a ...
{ "input": [ "5\n1 1 1 1 1\n", "10\n1 2 3 5 8 13 21 34 55 89\n" ], "output": [ "2\n", "10\n" ] }
{ "input": [ "6\n10 20 30 10 40 50\n", "2\n1 3\n", "1\n1000\n", "2\n0 0\n", "4\n0 0 0 0\n", "1\n0\n", "5\n0 0 0 0 0\n", "5\n8 9 17 26 43\n", "3\n0 0 0\n", "12\n1 2 3 5 8 13 0 1 1 2 3 5\n", "2\n7 1\n", "51\n1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
1,100
1,000
2
7
389_A. Fox and Number Game
Fox Ciel is playing a game with numbers now. Ciel has n positive integers: x1, x2, ..., xn. She can do the following operation as many times as needed: select two different indexes i and j such that xi > xj hold, and then apply assignment xi = xi - xj. The goal is to make the sum of all numbers as small as possible. ...
{ "input": [ "2\n12 18\n", "3\n2 4 6\n", "5\n45 12 27 30 18\n", "2\n1 2\n" ], "output": [ "12\n", "6\n", "15\n", "2\n" ] }
{ "input": [ "5\n2 3 5 8 18\n", "2\n1 1\n", "100\n82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 8...
1,000
500
2
10
409_D. Big Data
Little Petya wanted to give an April Fools Day present to some scientists. After some hesitation he decided to give them the array that he got as a present in Codeforces Round #153 (Div.2). The scientists rejoiced at the gift and decided to put some important facts to this array. Here are the first few of the facts: ...
{ "input": [ "7\n", "1\n" ], "output": [ "0", "1" ] }
{ "input": [ "2\n", "11\n", "15\n", "13\n", "14\n", "16\n", "12\n", "5\n", "9\n", "8\n", "4\n", "6\n", "3\n", "10\n" ], "output": [ "0", "0", "1", "1", "0", "0", "0", "0", "1", "1", "1", "1", "0", "1" ...
1,700
0
2
7
45_A. Codecraft III
Today Vasya visited a widely known site and learned that the continuation of his favourite game Codecraft II will appear after exactly k months. He looked at the calendar and learned that at the moment is the month number s. Vasya immediately got interested in what month Codecraft III will appear. Help him understand t...
{ "input": [ "May\n24\n", "November\n3\n" ], "output": [ "May\n", "February\n" ] }
{ "input": [ "June\n97\n", "August\n0\n", "July\n33\n", "January\n0\n", "July\n4\n", "December\n1\n", "November\n47\n", "May\n44\n", "July\n77\n", "July\n2\n", "January\n11\n", "June\n1\n", "December\n49\n", "April\n0\n", "February\n22\n", "September\n3\...
900
0
2
10
529_D. Social Network
Polycarpus got an internship in one well-known social network. His test task is to count the number of unique users who have visited a social network during the day. Polycarpus was provided with information on all user requests for this time period. For each query, we know its time... and nothing else, because Polycarp...
{ "input": [ "4 2 10\n17:05:53\n17:05:58\n17:06:01\n22:39:47\n", "1 2 86400\n00:00:00\n" ], "output": [ "3\n1\n2\n2\n3\n", "No solution\n" ] }
{ "input": [ "10 3 30000\n00:06:54\n00:42:06\n03:49:45\n04:38:35\n05:33:30\n05:51:46\n10:46:34\n14:34:59\n14:40:06\n14:53:13\n", "1 1 86400\n00:00:00\n", "5 2 40000\n06:30:57\n07:27:25\n09:10:21\n11:05:03\n12:42:37\n", "7 4 30000\n05:08:54\n05:35:53\n06:03:20\n06:17:50\n09:29:46\n11:35:29\n14:49:02\n"...
2,100
1,250
2
7
555_A. Case of Matryoshkas
Andrewid the Android is a galaxy-famous detective. He is now investigating the case of vandalism at the exhibition of contemporary art. The main exhibit is a construction of n matryoshka dolls that can be nested one into another. The matryoshka dolls are numbered from 1 to n. A matryoshka with a smaller number can be ...
{ "input": [ "3 2\n2 1 2\n1 3\n", "7 3\n3 1 3 7\n2 2 5\n2 4 6\n" ], "output": [ "1", "10" ] }
{ "input": [ "3 2\n1 2\n2 1 3\n", "100 3\n45 1 2 3 4 5 6 7 8 9 19 21 24 27 28 30 34 35 37 39 40 41 42 43 46 47 48 51 52 55 58 59 61 63 64 66 69 71 76 80 85 86 88 89 94 99\n26 10 11 15 18 23 29 31 33 36 38 44 49 54 56 60 62 65 75 78 82 83 84 95 96 97 98\n29 12 13 14 16 17 20 22 25 26 32 45 50 53 57 67 68 70 72...
1,500
250
2
8
625_B. War of the Corporations
A long time ago, in a galaxy far far away two giant IT-corporations Pineapple and Gogol continue their fierce competition. Crucial moment is just around the corner: Gogol is ready to release it's new tablet Lastus 3000. This new device is equipped with specially designed artificial intelligence (AI). Employees of Pine...
{ "input": [ "intellect\ntell\n", "google\napple\n", "sirisiri\nsir\n" ], "output": [ "1", "0", "2" ] }
{ "input": [ "bbbbbb\nbb\n", "abcdabcv\nabcd\n", "sosossosos\nsos\n", "aaaaaaa\naaaa\n", "kek\nkekekek\n", "aaaaa\naaa\n", "abc\nabcabc\n", "abcabcabcabcabcabcabcabcabcabc\nabcabcabcabcabcabcabcabcabcabc\n", "tatatx\ntatx\n", "sxxsxxsxxd\nsxxsxxd\n", "abcabcabczabcabcabcz\n...
1,200
750
2
10
673_D. Bear and Two Paths
Bearland has n cities, numbered 1 through n. Cities are connected via bidirectional roads. Each road connects two distinct cities. No two roads connect the same pair of cities. Bear Limak was once in a city a and he wanted to go to a city b. There was no direct connection so he decided to take a long walk, visiting ea...
{ "input": [ "7 11\n2 4 7 3\n", "1000 999\n10 20 30 40\n" ], "output": [ "2 7 1 5 6 3 4\n7 2 1 5 6 4 3\n", "-1\n" ] }
{ "input": [ "700 699\n687 69 529 616\n", "4 6\n1 2 3 4\n", "6 6\n1 2 3 4\n", "1000 1577\n698 459 326 404\n", "5 7\n4 3 2 1\n", "4 6\n1 3 2 4\n", "1000 1234\n330 433 967 641\n", "765 766\n352 536 728 390\n", "4 5\n1 3 4 2\n", "57 88\n54 30 5 43\n", "999 1200\n753 805 280 77...
1,600
1,000
2
7
71_A. Way Too Long Words
Sometimes some words like "localization" or "internationalization" are so long that writing them many times in one text is quite tiresome. Let's consider a word too long, if its length is strictly more than 10 characters. All too long words should be replaced with a special abbreviation. This abbreviation is made lik...
{ "input": [ "4\nword\nlocalization\ninternationalization\npneumonoultramicroscopicsilicovolcanoconiosis\n" ], "output": [ "word\nl10n\ni18n\np43s\n" ] }
{ "input": [ "26\na\nb\nc\nd\ne\nf\ng\nh\ni\nj\nk\nl\nm\nn\no\np\nq\nr\ns\nt\nu\nv\nw\nx\ny\nz\n", "10\ngyartjdxxlcl\nfzsck\nuidwu\nxbymclornemdmtj\nilppyoapitawgje\ncibzc\ndrgbeu\nhezplmsdekhhbo\nfeuzlrimbqbytdu\nkgdco\n", "5\nabcdefgh\nabcdefghi\nabcdefghij\nabcdefghijk\nabcdefghijklm\n", "20\nlkpmx...
800
500
2
9
740_C. Alyona and mex
Alyona's mother wants to present an array of n non-negative integers to Alyona. The array should be special. Alyona is a capricious girl so after she gets the array, she inspects m of its subarrays. Subarray is a set of some subsequent elements of the array. The i-th subarray is described with two integers li and ri,...
{ "input": [ "5 3\n1 3\n2 5\n4 5\n", "4 2\n1 4\n2 4\n" ], "output": [ "2\n0 1 0 1 0\n", "3\n0 1 2 0\n" ] }
{ "input": [ "5 3\n1 3\n2 5\n4 5\n", "3 8\n1 2\n1 2\n1 1\n2 3\n2 3\n1 1\n1 3\n1 3\n", "6 8\n3 5\n3 6\n4 6\n2 5\n2 5\n1 3\n3 6\n3 5\n", "5 8\n3 4\n1 5\n3 4\n3 5\n3 4\n1 4\n1 5\n2 5\n", "7 9\n6 7\n1 2\n2 5\n4 7\n1 7\n5 6\n2 3\n6 7\n1 2\n", "7 7\n2 4\n1 4\n3 6\n2 6\n5 7\n3 6\n1 4\n", "8 7\n5 ...
1,700
500
2
8
764_B. Timofey and cubes
Young Timofey has a birthday today! He got kit of n cubes as a birthday present from his parents. Every cube has a number ai, which is written on it. Timofey put all the cubes in a row and went to unpack other presents. In this time, Timofey's elder brother, Dima reordered the cubes using the following rule. Suppose t...
{ "input": [ "8\n6 1 4 2 5 6 9 2\n", "7\n4 3 7 6 9 1 2\n" ], "output": [ "2 1 6 2 5 4 9 6\n", "2 3 9 6 7 1 4\n" ] }
{ "input": [ "5\n241218936 -825949895 -84926813 491336344 -872198236\n", "2\n1 2\n", "9\n-7 9 -4 9 -6 11 15 2 -10\n", "1\n1424\n", "2\n2 5\n", "6\n1 2 3 4 5 6\n", "2\n3 4\n", "42\n-557774624 828320986 -345782722 -62979938 -681259411 -945983652 -139095040 832293378 -82572118 432027535 8...
900
1,000
2
7
809_A. Do you want a date?
Leha decided to move to a quiet town Vičkopolis, because he was tired by living in Bankopolis. Upon arrival he immediately began to expand his network of hacked computers. During the week Leha managed to get access to n computers throughout the town. Incidentally all the computers, which were hacked by Leha, lie on the...
{ "input": [ "3\n4 3 1\n", "2\n4 7\n" ], "output": [ "9\n", "3\n" ] }
{ "input": [ "20\n2 6 8 9 20 23 27 36 43 49 63 65 70 71 85 87 89 91 94 97\n", "3\n465343471 465343474 465343473\n", "5\n999999984 999999997 999999994 999999991 999999982\n", "2\n1000000000 1\n", "1\n2\n", "5\n4 7 13 17 18\n", "5\n20 17 13 7 2\n", "1\n78091781\n", "5\n999999980 9999...
1,500
500
2
8
854_B. Maxim Buys an Apartment
Maxim wants to buy an apartment in a new house at Line Avenue of Metropolis. The house has n apartments that are numbered from 1 to n and are arranged in a row. Two apartments are adjacent if their indices differ by 1. Some of the apartments can already be inhabited, others are available for sale. Maxim often visits h...
{ "input": [ "6 3\n" ], "output": [ "1 3\n" ] }
{ "input": [ "999999998 333333333\n", "999999998 333333332\n", "89 4\n", "2 0\n", "8 8\n", "4 1\n", "9 4\n", "41949373 13173511\n", "966871928 890926970\n", "1 1\n", "1000000000 0\n", "77855558 49163875\n", "547575919 313272818\n", "7 2\n", "1000000000 10000...
1,200
1,000
2
8
902_B. Coloring a Tree
You are given a rooted tree with n vertices. The vertices are numbered from 1 to n, the root is the vertex number 1. Each vertex has a color, let's denote the color of vertex v by cv. Initially cv = 0. You have to color the tree into the given colors using the smallest possible number of steps. On each step you can c...
{ "input": [ "7\n1 1 2 3 1 4\n3 3 1 1 1 2 3\n", "6\n1 2 2 1 5\n2 1 1 1 1 1\n" ], "output": [ "5", "3" ] }
{ "input": [ "4\n1 1 2\n4 1 4 1\n", "4\n1 2 3\n4 1 2 4\n", "3\n1 2\n2 1 1\n", "3\n1 1\n2 2 2\n", "5\n1 2 1 4\n1 1 1 2 2\n", "3\n1 1\n1 2 2\n", "4\n1 2 2\n3 1 2 3\n", "4\n1 2 1\n1 2 3 4\n", "2\n1\n2 2\n", "4\n1 1 1\n3 1 3 1\n" ], "output": [ "2", "4", "2", "1...
1,200
1,000
2
12
952_F. 2 + 2 != 4
One very experienced problem writer decided to prepare a problem for April Fools Day contest. The task was very simple - given an arithmetic expression, return the result of evaluating this expression. However, looks like there is a bug in the reference solution... Input The only line of input data contains the arith...
{ "input": [ "2+2\n", "112-37\n", "8-7+6-5+4-3+2-1-0\n" ], "output": [ "-46\n", "375\n", "4\n" ] }
{ "input": [ "131+49+249+71-251-61+159-111+51\n", "150+222-3-90-248-187+198\n", "0-0-0-0-0-0-0-0-0-0\n", "240-120-234-156-207-189\n", "23+6-9\n", "101+200+195+231+107+222+146+254+160+209\n", "5-9-1-3+6+4-7+8-2\n", "1-2+3-4+5-6\n", "0+100+100+100+100+100+100+100+100+100\n", "255...
2,400
0
2
9
99_C. Help Victoria the Wise
Vasilisa the Wise from a far away kingdom got a present from her friend Helga the Wise from a farther away kingdom. The present is a surprise box, yet Vasilisa the Wise doesn't know yet what the surprise actually is because she cannot open the box. She hopes that you can help her in that. The box's lock is constructed...
{ "input": [ "YYYYYY\n", "BOOOOB\n", "ROYGBV\n" ], "output": [ "1\n", "2\n", "30\n" ] }
{ "input": [ "VYYYVV\n", "OBRRYY\n", "RRYOGB\n", "RROOYY\n", "GOGGVG\n", "GVGBVO\n", "BOBGBB\n", "OOYYBY\n", "VVRVVV\n", "VOVRBV\n", "YYYYRB\n", "OOOOOO\n", "VOBVYB\n", "RRRGRG\n", "RRRRRR\n", "YROVBG\n", "BVRYBV\n", "RRYYOO\n", "RYGOBG\n", ...
1,700
500
2
11
1055_E. Segments on the Line
You are a given a list of integers a_1, a_2, …, a_n and s of its segments [l_j; r_j] (where 1 ≤ l_j ≤ r_j ≤ n). You need to select exactly m segments in such a way that the k-th order statistic of the multiset of a_i, where i is contained in at least one segment, is the smallest possible. If it's impossible to select ...
{ "input": [ "4 3 2 2\n3 1 3 2\n1 2\n2 3\n4 4\n", "5 3 3 5\n5 5 2 1 1\n1 2\n2 3\n3 4\n", "5 2 1 1\n1 2 3 4 5\n2 4\n1 5\n" ], "output": [ "2\n", "-1\n", "1\n" ] }
{ "input": [ "10 1 1 8\n1 1 1 991992993 1 991992993 3 6664666 1000000000 999999999\n3 10\n", "10 5 4 10\n1 2 3 4 5 6 7 8 9 10\n3 8\n4 7\n5 6\n1 10\n2 9\n", "1 5 2 1\n1\n1 1\n1 1\n1 1\n1 1\n1 1\n", "6 3 2 3\n1000000000 1000000000 1000000000 3 1 2\n6 6\n5 5\n1 4\n", "10 5 2 4\n10 11 10 9 4 4 3 2 10 ...
2,500
2,750
2
12
1077_F1. Pictures with Kittens (easy version)
The only difference between easy and hard versions is the constraints. Vova likes pictures with kittens. The news feed in the social network he uses can be represented as an array of n consecutive pictures (with kittens, of course). Vova likes all these pictures, but some are more beautiful than the others: the i-th p...
{ "input": [ "4 3 1\n1 100 1 1\n", "5 2 3\n5 1 3 10 1\n", "6 1 5\n10 30 30 70 10 10\n" ], "output": [ "100", "18", "-1" ] }
{ "input": [ "14 5 1\n777952841 904112822 619719668 821319583 273287753 183942799 391488524 199988810 174106140 533625353 704165043 288839769 328084203 509492291\n", "1 1 1\n465559034\n", "1 1 1\n311658179\n", "14 5 2\n956036265 182694371 213500222 846949061 812445518 728421576 971517403 838140094 100...
1,900
0
2
9
1146_C. Tree Diameter
There is a weighted tree with n nodes and n-1 edges. The nodes are conveniently labeled from 1 to n. The weights are positive integers at most 100. Define the distance between two nodes to be the sum of edges on the unique path between the nodes. You would like to find the diameter of the tree. Diameter is the maximum ...
{ "input": [ "2\n5\n9\n6\n10\n9\n10\n2\n99\n" ], "output": [ "3 2 1 3 5 2 4\n2 3 2 3 1 4 5\n2 3 4 5 1 2 3\n-1 10\n5 4 1 3 5 7 9 2 4 6 8\n4 5 2 3 6 7 1 4 5 8 9\n4 5 4 5 6 7 1 2 3 8 9\n2 7 8 9 1 2 3 4 5 6 7\n-1 99\n" ] }
{ "input": [ "2\n5\n1 2 3\n2 3 4\n2 4 5\n4 5 1\n2\n1 2 99\n" ], "output": [ "1 4 1 2 3 4 5 \n1 2 1 2 3 \n1 1 1 4 \n1 4 5 1 2 3 4 \n-1 2\n1 2 1 2 3 \n1 1 1 2 \n1 2 3 1 2 \n-1 4\n" ] }
1,700
1,500
2
9
1167_C. News Distribution
In some social network, there are n users communicating with each other in m groups of friends. Let's analyze the process of distributing some news between users. Initially, some user x receives the news from some source. Then he or she sends the news to his or her friends (two users are friends if there is at least o...
{ "input": [ "7 5\n3 2 5 4\n0\n2 1 2\n1 1\n2 6 7\n" ], "output": [ "4 4 1 4 4 2 2 " ] }
{ "input": [ "7 2\n0\n0\n" ], "output": [ "1 1 1 1 1 1 1 " ] }
1,400
0
2
12
1185_F. Two Pizzas
A company of n friends wants to order exactly two pizzas. It is known that in total there are 9 pizza ingredients in nature, which are denoted by integers from 1 to 9. Each of the n friends has one or more favorite ingredients: the i-th of friends has the number of favorite ingredients equal to f_i (1 ≤ f_i ≤ 9) and y...
{ "input": [ "1 5\n9 9 8 7 6 5 4 3 2 1\n3 4 1 2 3 4\n1 4 5 6 7 8\n4 4 1 3 5 7\n1 4 2 4 6 8\n5 4 1 9 2 8\n", "3 4\n2 6 7\n4 2 3 9 5\n3 2 3 9\n100 1 7\n400 3 3 2 5\n100 2 9 2\n500 3 2 9 5\n", "4 3\n1 1\n1 2\n1 3\n1 4\n10 4 1 2 3 4\n20 4 1 2 3 4\n30 4 1 2 3 4\n" ], "output": [ "4 2\n", "2 3\n", ...
{ "input": [ "3 3\n1 9\n6 4 9 5 7 8 1\n3 5 8 3\n1 2 7 4\n1 2 5 9\n1 8 5 7 9 1 4 3 2 6\n", "1 2\n8 5 3 9 8 6 7 4 1\n1 7 3 8 2 6 5 7 9\n1 7 3 2 5 6 8 7 4\n", "1 4\n3 2 9 1\n1 6 3 1 5 8 9 7\n2 2 2 6\n1 1 7\n3 1 9\n", "1 2\n2 4 2\n2 1 3\n2 2 3 2\n", "1 4\n4 9 7 1 5\n1 8 8 1 9 6 5 7 3 2\n1 2 3 2\n1 3 8...
2,100
2,750
2
10
1204_D1. Kirk and a Binary String (easy version)
The only difference between easy and hard versions is the length of the string. You can hack this problem only if you solve both problems. Kirk has a binary string s (a string which consists of zeroes and ones) of length n and he is asking you to find a binary string t of the same length which satisfies the following ...
{ "input": [ "0111001100111011101000\n", "0001111\n", "110\n", "010\n" ], "output": [ "0011001100001011101000\n", "0000000\n", "010\n", "010\n" ] }
{ "input": [ "0010000110000100\n", "0000000000000000\n", "0000100010001110\n", "1111111111111111\n", "0100000001000001\n", "1001101000001101\n", "1\n", "0\n", "1111111111111010\n", "1111101000110110\n" ], "output": [ "0010000110000100\n", "0000000000000000\n", "...
2,000
1,500
2
8
1221_B. Knights
You are given a chess board with n rows and n columns. Initially all cells of the board are empty, and you have to put a white or a black knight into each cell of the board. A knight is a chess piece that can attack a piece in cell (x_2, y_2) from the cell (x_1, y_1) if one of the following conditions is met: * |x_...
{ "input": [ "3\n" ], "output": [ "WBW\nBWB\nWBW\n" ] }
{ "input": [ "6\n", "99\n", "37\n", "96\n", "5\n", "69\n", "55\n", "4\n", "76\n", "47\n", "3\n", "42\n", "97\n", "13\n", "7\n", "100\n", "10\n", "98\n", "56\n" ], "output": [ "WBWBWB\nBWBWBW\nWBWBWB\nBWBWBW\nWBWBWB\nBWBWBW\n", "WB...
1,100
0
2
9
1266_C. Diverse Matrix
Let a be a matrix of size r × c containing positive integers, not necessarily distinct. Rows of the matrix are numbered from 1 to r, columns are numbered from 1 to c. We can construct an array b consisting of r + c integers as follows: for each i ∈ [1, r], let b_i be the greatest common divisor of integers in the i-th ...
{ "input": [ "1 1\n", "2 2\n" ], "output": [ "0", "3 4 \n6 8 \n" ] }
{ "input": [ "9 1\n", "1 2\n", "2 3\n", "26 122\n", "3 1\n", "1 3\n", "2 1\n", "1 7\n", "132 1\n", "3 2\n", "2 2\n", "1 132\n", "500 1\n", "77 15\n", "13 56\n", "1 500\n", "492 71\n" ], "output": [ "2 3 4 5 6 7 8 9 10 \n", "2 3 \n", "...
1,400
1,250
2
11
1287_E1. Madhouse (Easy version)
This problem is different with hard version only by constraints on total answers length It is an interactive problem Venya joined a tour to the madhouse, in which orderlies play with patients the following game. Orderlies pick a string s of length n, consisting only of lowercase English letters. The player can ask tw...
{ "input": [ "4\n\na\naa\na\n\ncb\nb\nc\n\nc" ], "output": [ "? 1 4\n? 1 3\n! a^_f\n" ] }
{ "input": [ "99\nyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy\n", "4\nabcd\n", "100\ntssttststtssttsssttsssttttttsttttssstssstsstssstststttssssstttsssttststststtttsssstsstsssssttttttsst\n", "9\nrnnnqnnrn\n", "60\ndaddddpppddapapdpaapaadppppap...
2,400
750
2
11
1307_E. Cow and Treats
After a successful year of milk production, Farmer John is rewarding his cows with their favorite treat: tasty grass! On the field, there is a row of n units of grass, each with a sweetness s_i. Farmer John has m cows, each with a favorite sweetness f_i and a hunger value h_i. He would like to pick two disjoint subset...
{ "input": [ "3 2\n2 3 2\n3 1\n2 1\n", "5 2\n1 1 1 1 1\n1 2\n1 3\n", "5 1\n1 1 1 1 1\n2 5\n", "5 2\n1 1 1 1 1\n1 2\n1 4\n" ], "output": [ "2 4", "2 2", "0 1", "1 4" ] }
{ "input": [ "5 1\n1 1 1 1 1\n1 3\n", "5 1\n1 2 3 2 1\n1 2\n", "5 5\n1 1 1 1 1\n1 1\n1 2\n1 3\n1 4\n1 5\n", "2 1\n2 2\n1 1\n", "5 2\n1 1 1 1 1\n1 1\n1 3\n", "5 1\n1 1 1 1 1\n1 5\n", "1 1\n1\n1 1\n", "3 1\n1 3 2\n2 1\n", "6 4\n1 1 1 2 2 2\n1 1\n1 2\n2 1\n2 2\n", "2 1\n1 1\n1 1\n...
2,500
2,500
2
11
1330_E. Drazil Likes Heap
Drazil likes heap very much. So he created a problem with heap: There is a max heap with a height h implemented on the array. The details of this heap are the following: This heap contains exactly 2^h - 1 distinct positive non-zero integers. All integers are distinct. These numbers are stored in the array a indexed f...
{ "input": [ "2\n3 2\n7 6 3 5 4 2 1\n3 2\n7 6 5 4 3 2 1\n" ], "output": [ "10\n1 1 3 3 \n8\n1 1 1 3 \n" ] }
{ "input": [ "2\n3 2\n7 6 3 5 4 2 1\n3 2\n7 6 5 4 3 2 1\n" ], "output": [ "10\n1 1 3 3 \n8\n1 1 1 3 \n" ] }
2,400
1,500
2
11
1350_E. Orac and Game of Life
Please notice the unusual memory limit of this problem. Orac likes games. Recently he came up with the new game, "Game of Life". You should play this game on a black and white grid with n rows and m columns. Each cell is either black or white. For each iteration of the game (the initial iteration is 0), the color of...
{ "input": [ "3 3 3\n000\n111\n000\n1 1 1\n2 2 2\n3 3 3\n", "5 2 2\n01\n10\n01\n10\n01\n1 1 4\n5 1 4\n", "1 1 3\n0\n1 1 1\n1 1 2\n1 1 3\n", "5 5 3\n01011\n10110\n01101\n11010\n10101\n1 1 4\n1 2 3\n5 5 3\n" ], "output": [ "1\n1\n1\n", "0\n0\n", "0\n0\n0\n", "1\n0\n1\n" ] }
{ "input": [ "1 1 1\n1\n1 1 1000000000000000000\n", "2 2 1\n10\n11\n1 2 1000000000000000000\n", "1 1 1\n1\n1 1 1\n" ], "output": [ "1\n", "1\n", "1\n" ] }
2,000
1,250
2
10
1393_D. Rarity and New Dress
Carousel Boutique is busy again! Rarity has decided to visit the pony ball and she surely needs a new dress, because going out in the same dress several times is a sign of bad manners. First of all, she needs a dress pattern, which she is going to cut out from the rectangular piece of the multicolored fabric. The piec...
{ "input": [ "5 5\nzbacg\nbaaac\naaaaa\neaaad\nweadd\n", "3 3\naaa\naaa\naaa\n", "3 4\nabab\nbaba\nabab\n" ], "output": [ "31", "10", "12" ] }
{ "input": [ "1 1\nn\n" ], "output": [ "1" ] }
2,100
1,750
2
8
1436_B. Prime Square
Sasha likes investigating different math objects, for example, magic squares. But Sasha understands that magic squares have already been studied by hundreds of people, so he sees no sense of studying them further. Instead, he invented his own type of square — a prime square. A square of size n × n is called prime if ...
{ "input": [ "2\n4\n2\n" ], "output": [ "1 1 0 0 \n\n0 1 1 0 \n\n0 0 1 1 \n\n1 0 0 1 \n\n1 1 \n\n1 1 \n\n" ] }
{ "input": [ "10\n65\n70\n66\n68\n69\n62\n64\n63\n61\n67\n", "10\n12\n16\n13\n17\n14\n20\n19\n11\n18\n15\n", "10\n2\n3\n3\n2\n2\n3\n2\n3\n2\n3\n", "10\n30\n24\n21\n22\n25\n26\n27\n23\n29\n28\n", "1\n13\n", "1\n20\n", "10\n50\n49\n45\n46\n42\n44\n48\n41\n43\n47\n", "1\n15\n", "10\n3...
900
1,000
2
7
1486_A. Shifting Stacks
You have n stacks of blocks. The i-th stack contains h_i blocks and it's height is the number of blocks in it. In one move you can take a block from the i-th stack (if there is at least one block) and put it to the i + 1-th stack. Can you make the sequence of heights strictly increasing? Note that the number of stacks...
{ "input": [ "6\n2\n1 2\n2\n1 0\n3\n4 4 4\n2\n0 0\n3\n0 1 0\n4\n1000000000 1000000000 1000000000 1000000000\n" ], "output": [ "\nYES\nYES\nYES\nNO\nNO\nYES\n" ] }
{ "input": [ "1\n30\n1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000...
900
500
2
9
1536_C. Diluc and Kaeya
The tycoon of a winery empire in Mondstadt, unmatched in every possible way. A thinker in the Knights of Favonius with an exotic appearance. This time, the brothers are dealing with a strange piece of wood marked with their names. This plank of wood can be represented as a string of n characters. Each character is eit...
{ "input": [ "5\n3\nDDK\n6\nDDDDDD\n4\nDKDK\n1\nD\n9\nDKDKDDDDK\n" ], "output": [ "\n1 2 1 \n1 2 3 4 5 6 \n1 1 1 2 \n1 \n1 1 1 2 1 2 1 1 3 \n" ] }
{ "input": [ "20\n5\nDKDKD\n4\nKDKD\n2\nKD\n2\nKD\n1\nD\n3\nKDK\n3\nDKD\n4\nKDKD\n3\nDKD\n2\nDK\n1\nK\n4\nKDKD\n1\nD\n2\nKD\n3\nKDK\n3\nDKD\n1\nK\n2\nKD\n2\nKD\n2\nKD\n", "10\n9\nDDDDDDKDD\n10\nKKDDDDKKDK\n7\nKKDDKDK\n13\nKKKDDKDDDKKKD\n14\nKDDDDKDDKDKDKK\n9\nKKDDKDDKD\n14\nDKDKKKKKDDDKKK\n10\nKDKKDKKKKD\n11\...
1,500
1,500
2
10
230_D. Planets
Goa'uld Apophis captured Jack O'Neill's team again! Jack himself was able to escape, but by that time Apophis's ship had already jumped to hyperspace. But Jack knows on what planet will Apophis land. In order to save his friends, Jack must repeatedly go through stargates to get to this planet. Overall the galaxy has n...
{ "input": [ "3 1\n1 2 3\n0\n1 3\n0\n", "4 6\n1 2 2\n1 3 3\n1 4 8\n2 3 4\n2 4 5\n3 4 3\n0\n1 3\n2 3 4\n0\n" ], "output": [ "-1", "7" ] }
{ "input": [ "3 3\n1 2 3\n2 3 2\n1 3 6\n0\n1 3\n0\n", "6 7\n1 2 1\n1 3 8\n2 4 2\n4 3 3\n3 5 4\n4 6 100\n5 6 5\n0\n0\n1 7\n2 3 4\n0\n0\n", "2 0\n0\n0\n", "3 1\n1 2 3\n1 1\n1 5\n0\n", "3 3\n1 2 3\n2 3 2\n1 3 7\n0\n4 3 4 5 6\n0\n", "2 1\n1 2 3\n0\n3 3 4 5\n", "2 1\n1 2 3\n1 0\n0\n", "7 6\...
1,700
500
2
9
27_C. Unordered Subsequence
The sequence is called ordered if it is non-decreasing or non-increasing. For example, sequnces [3, 1, 1, 0] and [1, 2, 3, 100] are ordered, but the sequence [1, 3, 3, 1] is not. You are given a sequence of numbers. You are to find it's shortest subsequence which is not ordered. A subsequence is a sequence that can be...
{ "input": [ "5\n67 499 600 42 23\n", "3\n1 2 3\n", "3\n2 3 1\n" ], "output": [ "3\n1 3 4\n", "0\n", "3\n1 2 3\n" ] }
{ "input": [ "3\n3 1 2\n", "4\n-227347 -573134 -671045 11011\n", "1\n-895376\n", "5\n834472 -373089 441294 -633071 -957672\n", "2\n7 8\n", "3\n-771740 -255752 -300809\n", "2\n166442 61629\n" ], "output": [ "3\n1 2 3\n", "3\n1 3 4\n", "0\n", "3\n1 2 3\n", "0\n", ...
1,900
1,500
2
8
302_B. Eugeny and Play List
Eugeny loves listening to music. He has n songs in his play list. We know that song number i has the duration of ti minutes. Eugeny listens to each song, perhaps more than once. He listens to song number i ci times. Eugeny's play list is organized as follows: first song number 1 plays c1 times, then song number 2 plays...
{ "input": [ "1 2\n2 8\n1 16\n", "4 9\n1 2\n2 1\n1 1\n2 2\n1 2 3 4 5 6 7 8 9\n" ], "output": [ "1\n1\n", "1\n1\n2\n2\n3\n4\n4\n4\n4\n" ] }
{ "input": [ "3 3\n2 8\n5 1\n10 5\n13 16 62\n", "10 10\n3 1\n2 7\n5 1\n7 2\n9 10\n9 5\n2 5\n4 10\n9 9\n1 9\n26 34 37 141 146 201 239 245 296 299\n", "2 3\n500000000 1\n1 500000000\n499999999 500000000 500000001\n", "3 1\n2 50\n1 50\n1 50\n160\n", "2 3\n500000000 1\n500000000 1\n499999999 500000000...
1,200
1,000
2
7
350_A. TL
Valera wanted to prepare a Codesecrof round. He's already got one problem and he wants to set a time limit (TL) on it. Valera has written n correct solutions. For each correct solution, he knows its running time (in seconds). Valera has also wrote m wrong solutions and for each wrong solution he knows its running time...
{ "input": [ "3 1\n3 4 5\n6\n", "3 6\n4 5 2\n8 9 6 10 7 11\n" ], "output": [ "-1\n", "5\n" ] }
{ "input": [ "3 2\n10 20 30\n30 40\n", "1 1\n49\n100\n", "1 1\n4\n9\n", "1 1\n5\n20\n", "1 2\n1\n3 1\n", "1 1\n2\n4\n", "55 44\n93 17 74 15 34 16 41 80 26 54 94 94 86 93 20 44 63 72 39 43 67 4 37 49 76 94 5 51 64 74 11 47 77 97 57 30 42 72 71 26 8 14 67 64 49 57 30 23 40 4 76 78 87 78 79\n...
1,200
500
2
8
374_B. Inna and Nine
Inna loves digit 9 very much. That's why she asked Dima to write a small number consisting of nines. But Dima must have misunderstood her and he wrote a very large number a, consisting of digits from 1 to 9. Inna wants to slightly alter the number Dima wrote so that in the end the number contained as many digits nine ...
{ "input": [ "1\n", "123456789987654321\n", "369727\n" ], "output": [ "1\n", "1\n", "2\n" ] }
{ "input": [ "123456789\n", "3639272918194549\n", "1212172727\n", "1188\n", "1212121217272727121\n", "1121314151617181921222324252627282931323334353637383941424344454647484951525354556575859616263646566768697172737475767787981828384858687888991929394959696979899\n", "4444444444444454444444...
1,500
1,000
2
9
445_C. DZY Loves Physics
DZY loves Physics, and he enjoys calculating density. Almost everything has density, even a graph. We define the density of a non-directed graph (nodes and edges of the graph have some values) as follows: <image> where v is the sum of the values of the nodes, e is the sum of the values of the edges. Once DZY got a ...
{ "input": [ "2 1\n1 2\n1 2 1\n", "5 6\n13 56 73 98 17\n1 2 56\n1 3 29\n1 4 42\n2 3 95\n2 4 88\n3 4 63\n", "1 0\n1\n" ], "output": [ "3.0000000000\n", "2.9655172414\n", "0.0000000000\n" ] }
{ "input": [ "20 20\n265918 744212 196368 74731 293587 679367 460805 632939 453630 565881 835276 606327 181087 721045 219431 849838 370939 582350 335676 32244\n2 16 989\n14 19 628\n1 6 483\n5 8 733\n13 19 556\n10 17 911\n2 7 599\n13 17 390\n10 20 965\n9 11 449\n3 15 310\n3 6 557\n14 18 225\n1 18 703\n10 18 234\n6...
1,600
500
2
10
467_D. Fedor and Essay
After you had helped Fedor to find friends in the «Call of Soldiers 3» game, he stopped studying completely. Today, the English teacher told him to prepare an essay. Fedor didn't want to prepare the essay, so he asked Alex for help. Alex came to help and wrote the essay for Fedor. But Fedor didn't like the essay at all...
{ "input": [ "2\nRuruRu fedya\n1\nruruRU fedor\n", "3\nAbRb r Zz\n4\nxR abRb\naA xr\nzz Z\nxr y\n" ], "output": [ "1 10\n", "2 6\n" ] }
{ "input": [ "5\naa bb cc ee ff\n5\naa a\nbb aa\ncc bb\nee cc\nff bb\n", "2\nABBABAABBAABABBABAABABBAABBABAABBAABABBAABBABAABABBABAABBAABABBA ABBABAABBAABABBABAABABBAABBABAABBAABABBAABBABAABABBABAABBAABABA\n2\nABBABAABBAABABBABAABABBAABBABAABBAABABBAABBABAABABBABAABBAABABA neuzaiheshi\nABBABAABBAABABBABAABABB...
2,400
2,000
2
13
513_G2. Inversions problem
You are given a permutation of n numbers p1, p2, ..., pn. We perform k operations of the following type: choose uniformly at random two indices l and r (l ≤ r) and reverse the order of the elements pl, pl + 1, ..., pr. Your task is to find the expected value of the number of inversions in the resulting permutation. In...
{ "input": [ "3 4\n1 3 2\n", "3 1\n1 2 3\n" ], "output": [ "1.458333333333333\n", "0.833333333333333\n" ] }
{ "input": [ "4 1\n3 4 2 1\n", "2 4\n2 1\n", "29 139\n19 10 21 29 8 18 22 15 26 6 4 17 23 27 14 2 20 5 3 13 7 12 16 24 28 9 1 11 25\n", "3 4\n1 2 3\n", "1 4\n1\n", "4 4\n2 3 1 4\n", "5 1\n3 5 1 2 4\n", "29 140\n2 9 26 20 25 4 21 5 23 15 12 16 10 1 13 22 19 24 28 14 11 29 8 27 18 3 7 6 ...
2,400
5
2
11
53_E. Dead Ends
Life in Bertown has become hard. The city has too many roads and the government spends too much to maintain them. There are n junctions and m two way roads, at which one can get from each junction to any other one. The mayor wants to close some roads so that the number of roads left totaled to n - 1 roads and it were s...
{ "input": [ "4 6 2\n1 2\n2 3\n3 4\n4 1\n1 3\n2 4\n", "3 3 2\n1 2\n2 3\n1 3\n", "4 6 3\n1 2\n2 3\n3 4\n4 1\n1 3\n2 4\n" ], "output": [ "12\n", "3\n", "4\n" ] }
{ "input": [ "10 25 9\n10 8\n9 10\n6 9\n8 5\n1 7\n4 7\n5 3\n8 6\n9 2\n10 1\n7 2\n7 10\n3 1\n9 5\n4 10\n7 3\n5 7\n2 5\n6 1\n4 8\n2 4\n8 7\n8 2\n2 6\n5 10\n", "10 43 9\n7 1\n4 5\n8 3\n5 1\n2 5\n9 2\n8 4\n8 2\n5 8\n4 2\n9 8\n7 10\n10 2\n4 7\n9 5\n2 3\n8 6\n10 5\n6 4\n3 5\n8 1\n3 1\n3 7\n6 9\n4 10\n9 7\n6 3\n7 5\...
2,500
2,500
2
7
568_A. Primes or Palindromes?
Rikhail Mubinchik believes that the current definition of prime numbers is obsolete as they are too complex and unpredictable. A palindromic number is another matter. It is aesthetically pleasing, and it has a number of remarkable properties. Help Rikhail to convince the scientific community in this! Let us remind you...
{ "input": [ "1 1\n", "1 42\n", "6 4\n" ], "output": [ "40", "1", "172" ] }
{ "input": [ "10000 10000\n", "5858 674\n", "214 210\n", "10000 9999\n", "999 10000\n", "620 35\n", "10000 239\n", "5 8\n", "1307 3420\n", "7 267\n", "16 60\n", "241 10000\n", "238 9996\n", "239 10000\n", "42 1\n", "106 6\n", "4 9\n", "9999 9998\...
1,600
500
2
7
611_A. New Year and Days
Today is Wednesday, the third day of the week. What's more interesting is that tomorrow is the last day of the year 2015. Limak is a little polar bear. He enjoyed this year a lot. Now, he is so eager to the coming year 2016. Limak wants to prove how responsible a bear he is. He is going to regularly save candies for ...
{ "input": [ "4 of week\n", "30 of month\n" ], "output": [ "52", "11" ] }
{ "input": [ "25 of month\n", "6 of week\n", "8 of month\n", "10 of month\n", "28 of month\n", "17 of month\n", "26 of month\n", "29 of month\n", "6 of month\n", "31 of month\n", "24 of month\n", "2 of month\n", "11 of month\n", "23 of month\n", "27 of month...
900
500
2
23
630_P. Area of a Star
It was decided in IT City to distinguish successes of local IT companies by awards in the form of stars covered with gold from one side. To order the stars it is necessary to estimate order cost that depends on the area of gold-plating. Write a program that can calculate the area of a star. A "star" figure having n ≥ ...
{ "input": [ "7 10\n" ], "output": [ "108.395919545675\n" ] }
{ "input": [ "603530531 585244\n", "999999929 2\n", "999999929 1000000000\n", "7 1000\n", "5 1\n", "7369339 31415926\n", "2341 5001\n", "11 1000000000\n", "999999937 1\n" ], "output": [ "358676198261.124664068222\n", "4.188790246504\n", "1047197561626090240.00000000...
2,100
0
2
7
65_A. Harry Potter and Three Spells
A long time ago (probably even in the first book), Nicholas Flamel, a great alchemist and the creator of the Philosopher's Stone, taught Harry Potter three useful spells. The first one allows you to convert a grams of sand into b grams of lead, the second one allows you to convert c grams of lead into d grams of gold a...
{ "input": [ "1 1 0 1 1 1\n", "100 10 200 20 300 30\n", "1 0 1 2 1 2\n", "100 200 250 150 200 250\n", "100 50 50 200 200 100\n", "0 0 0 0 0 0\n", "100 1 100 1 0 1\n" ], "output": [ "Ron\n", "Hermione\n", "Hermione\n", "Ron\n", "Hermione\n", "Hermione\n", "Ro...
{ "input": [ "279 0 254 964 449 143\n", "0 891 0 0 0 529\n", "276 264 0 875 0 0\n", "6 2 3 6 2 2\n", "0 0 580 0 245 808\n", "835 0 116 0 9 552\n", "0 54 680 0 988 0\n", "635 63 924 0 0 0\n", "31 75 12 62 94 137\n", "2 3 2 1 6 6\n", "3 6 2 2 6 3\n", "544 0 837 0 498 0\n"...
1,800
500
2
7
729_A. Interview with Oleg
Polycarp has interviewed Oleg and has written the interview down without punctuation marks and spaces to save time. Thus, the interview is now a string s consisting of n lowercase English letters. There is a filler word ogo in Oleg's speech. All words that can be obtained from ogo by adding go several times to the end...
{ "input": [ "7\naogogob\n", "9\nogoogoogo\n", "13\nogogmgogogogo\n" ], "output": [ "a***b\n", "*********\n", "***gmg***\n" ] }
{ "input": [ "2\nog\n", "1\no\n", "60\nggoooogoggogooogogooggoogggggogogogggggogggogooogogogggogooo\n", "46\nsdfkogogogogergergogogergerogogogogoergoegogog\n", "15\nggooogoooggoggg\n", "15\nogogogogogogogo\n", "20\nooggooogooogooogooog\n", "100\nogogogogogoggogogogogogogoggogogogoogogg...
900
500
2
8
749_B. Parallelogram is Back
Long time ago Alex created an interesting problem about parallelogram. The input data for this problem contained four integer points on the Cartesian plane, that defined the set of vertices of some non-degenerate (positive area) parallelogram. Points not necessary were given in the order of clockwise or counterclockwis...
{ "input": [ "0 0\n1 0\n0 1\n" ], "output": [ "3\n-1 1\n1 -1\n1 1\n" ] }
{ "input": [ "-948 201\n-519 -713\n459 564\n", "-1000 1000\n1000 -1000\n-1000 -1000\n", "-6 2\n-10 -7\n9 -6\n", "-1 -1\n0 1\n1 1\n", "-1000 1000\n1000 -1000\n0 1\n", "-86 25\n-55 18\n58 24\n", "-33 60\n3 0\n-57 97\n", "-4 -5\n7 10\n3 -10\n", "21 185\n966 -167\n-291 -804\n", "-1...
1,200
1,000
2
7
772_A. Voltage Keepsake
You have n devices that you want to use simultaneously. The i-th device uses ai units of power per second. This usage is continuous. That is, in λ seconds, the device will use λ·ai units of power. The i-th device currently has bi units of power stored. All devices can store an arbitrary amount of power. You have a si...
{ "input": [ "3 5\n4 3\n5 2\n6 1\n", "1 100\n1 1\n", "2 1\n2 2\n2 1000\n" ], "output": [ "0.50000000\n", "-1\n", "1.99999999\n" ] }
{ "input": [ "20 16807\n75250 50074\n43659 8931\n11273 27545\n50879 77924\n37710 64441\n38166 84493\n43043 7988\n22504 82328\n31730 78841\n42613 44304\n33170 17710\n97158 29561\n70934 93100\n80279 51817\n95336 99098\n7827 13513\n29268 23811\n77634 80980\n79150 36580\n58822 11968\n", "1 1\n100 77\n", "5 10...
1,800
500
2
7
797_A. k-Factorization
Given a positive integer n, find k integers (not necessary distinct) such that all these integers are strictly greater than 1, and their product is equal to n. Input The first line contains two integers n and k (2 ≤ n ≤ 100000, 1 ≤ k ≤ 20). Output If it's impossible to find the representation of n as a product of k...
{ "input": [ "1024 5\n", "100000 2\n", "100000 20\n" ], "output": [ "2 2 2 2 64\n", "2 50000\n", "-1\n" ] }
{ "input": [ "15 6\n", "13 3\n", "35557 5\n", "95477 1\n", "11 1\n", "95477 4\n", "66049 2\n", "4 5\n", "16 5\n", "42439 3\n", "13 6\n", "12 3\n", "20 6\n", "10 5\n", "19 3\n", "9 6\n", "100000 10\n", "17 6\n", "16 6\n", "20 2\n", "92...
1,100
0
2
9
817_C. Really Big Numbers
Ivan likes to learn different things about numbers, but he is especially interested in really big numbers. Ivan thinks that a positive integer number x is really big if the difference between x and the sum of its digits (in decimal representation) is not less than s. To prove that these numbers may have different speci...
{ "input": [ "10 9\n", "12 1\n", "25 20\n" ], "output": [ "1\n", "3\n", "0\n" ] }
{ "input": [ "300 1000\n", "1000000000000000000 100000000000000\n", "1000000000000000000 10000000000000000\n", "6900 6885\n", "327170000015578 77230000029054\n", "17386 5814\n", "12515000022229 1791000022317\n", "24848 15384\n", "999 777\n", "109 91\n", "19 10\n", "20 5...
1,600
0
2
9
863_C. 1-2-3
Ilya is working for the company that constructs robots. Ilya writes programs for entertainment robots, and his current project is "Bob", a new-generation game robot. Ilya's boss wants to know his progress so far. Especially he is interested if Bob is better at playing different games than the previous model, "Alice". ...
{ "input": [ "8 1 1\n2 2 1\n3 3 1\n3 1 3\n1 1 1\n2 1 1\n1 2 3\n", "10 2 1\n1 1 1\n1 1 1\n1 1 1\n2 2 2\n2 2 2\n2 2 2\n", "5 1 1\n1 2 2\n2 2 2\n2 2 2\n1 2 2\n2 2 2\n2 2 2\n" ], "output": [ "5 2\n", "1 9\n", "0 0\n" ] }
{ "input": [ "1000000000000000000 2 3\n1 3 1\n2 3 3\n2 2 2\n1 2 3\n3 1 2\n2 2 2\n", "1 3 1\n1 3 3\n2 3 2\n2 1 3\n1 3 2\n3 3 2\n3 1 1\n", "1000000000005 1 1\n2 2 1\n3 3 1\n3 1 3\n1 1 1\n2 1 1\n1 2 3\n", "4 1 1\n1 1 2\n2 2 3\n3 3 1\n2 3 1\n2 3 1\n2 3 1\n", "999999999999999999 2 2\n2 3 2\n2 1 2\n1 3 ...
1,800
0
2
11
911_E. Stack Sorting
Let's suppose you have an array a, a stack s (initially empty) and an array b (also initially empty). You may perform the following operations until both a and s are empty: * Take the first element of a, push it into s and remove it from a (if a is not empty); * Take the top element from s, append it to the end ...
{ "input": [ "5 3\n2 3 1\n", "5 3\n3 2 1\n", "5 2\n3 4\n", "5 1\n3\n" ], "output": [ "-1", "3 2 1 5 4 ", "-1", "3 2 1 5 4 " ] }
{ "input": [ "10 7\n10 8 5 1 2 7 3\n", "4 3\n3 4 2\n", "10 4\n2 1 3 4\n", "10 4\n2 1 7 3\n", "20 5\n11 19 6 2 12\n", "2 1\n1\n", "10 3\n2 1 4\n", "4 3\n3 1 2\n", "10 9\n10 8 7 5 6 2 1 9 4\n", "200000 8\n197281 11492 67218 100058 179300 182264 17781 192818\n", "20 4\n2 10 4 ...
2,000
0
2
9
933_C. A Colourful Prospect
Firecrackers scare Nian the monster, but they're wayyyyy too noisy! Maybe fireworks make a nice complement. Little Tommy is watching a firework show. As circular shapes spread across the sky, a splendid view unfolds on the night of Lunar New Year's eve. A wonder strikes Tommy. How many regions are formed by the circl...
{ "input": [ "3\n0 0 2\n3 0 2\n6 0 2\n", "3\n0 0 1\n2 0 1\n4 0 1\n", "3\n0 0 2\n2 0 2\n1 1 2\n" ], "output": [ "6\n", "4\n", "8\n" ] }
{ "input": [ "3\n3 4 9\n2 -3 1\n-1 1 4\n", "3\n2 -5 2\n-5 -6 3\n-2 -2 3\n", "3\n-4 1 5\n-7 7 10\n-3 -4 8\n", "3\n5 -2 3\n1 1 2\n4 -3 7\n", "3\n-6 -6 7\n1 4 2\n0 -5 2\n", "3\n1 0 1\n-1 0 1\n0 1 1\n", "3\n5 2 4\n-3 6 4\n-6 -6 10\n", "2\n-10 -10 10\n10 10 10\n", "3\n-1 0 5\n5 0 5\n5 8...
2,700
1,500
2
9
987_C. Three displays
It is the middle of 2018 and Maria Stepanovna, who lives outside Krasnokamensk (a town in Zabaikalsky region), wants to rent three displays to highlight an important problem. There are n displays placed along a road, and the i-th of them can display a text with font size s_i only. Maria Stepanovna wants to rent such t...
{ "input": [ "3\n100 101 100\n2 4 5\n", "10\n1 2 3 4 5 6 7 8 9 10\n10 13 11 14 15 12 13 13 18 13\n", "5\n2 4 5 4 10\n40 30 20 10 40\n" ], "output": [ "-1\n", "33\n", "90\n" ] }
{ "input": [ "3\n1 2 3\n1 1 1\n", "20\n452405440 586588704 509061481 552472140 16115810 148658854 66743034 628305150 677780684 519361360 208050516 401554301 954478790 346543678 387546138 832279893 641889899 80960260 717802881 588066499\n61699500 83254572 59454419 27833657 55743179 99661234 94729965 75591136 6...
1,400
1,250
2
10
1012_D. AB-Strings
There are two strings s and t, consisting only of letters a and b. You can make the following operation several times: choose a prefix of s, a prefix of t and swap them. Prefixes can be empty, also a prefix can coincide with a whole string. Your task is to find a sequence of operations after which one of the strings ...
{ "input": [ "bbbb\naaa\n", "bab\nbb\n" ], "output": [ "0\n", "2\n1 0\n1 3\n" ] }
{ "input": [ "bbabab\nbababa\n", "bbbaa\naaaabb\n", "bbbbaa\nabbaba\n", "babbab\nabbbaa\n", "bbabab\nbbbbbb\n", "aabaaa\nbbbbbb\n", "abbbba\naaaaba\n", "baabab\nbbbbaa\n", "aababa\nbaabab\n", "bababa\nbbbabb\n", "baabaa\nbaabaa\n", "bbbbba\nbaaaba\n", "abbaba\nbbbbb...
2,800
2,250
2
10
1037_D. Valid BFS?
The [BFS](https://en.wikipedia.org/wiki/Breadth-first_search) algorithm is defined as follows. 1. Consider an undirected graph with vertices numbered from 1 to n. Initialize q as a new [queue](http://gg.gg/queue_en) containing only vertex 1, mark the vertex 1 as used. 2. Extract a vertex v from the head of the qu...
{ "input": [ "4\n1 2\n1 3\n2 4\n1 2 4 3\n", "4\n1 2\n1 3\n2 4\n1 2 3 4\n" ], "output": [ "No\n", "Yes\n" ] }
{ "input": [ "4\n1 2\n1 3\n1 4\n2 1 3 4\n", "4\n2 3\n3 4\n4 1\n2 3 4 1\n", "6\n1 2\n1 5\n2 3\n2 4\n5 6\n1 2 5 3 4 6\n", "4\n1 2\n1 3\n2 4\n4 2 1 3\n", "2\n1 2\n2 1\n", "8\n1 2\n1 6\n1 7\n8 2\n5 6\n6 4\n3 7\n1 6 7 2 5 4 3 8\n", "11\n1 2\n2 8\n3 7\n4 9\n5 10\n5 11\n6 4\n6 5\n7 1\n1 6\n1 6 7 ...
1,700
1,500
2
9
1129_C. Morse Code
In Morse code, an letter of English alphabet is represented as a string of some length from 1 to 4. Moreover, each Morse code representation of an English letter contains only dots and dashes. In this task, we will represent a dot with a "0" and a dash with a "1". Because there are 2^1+2^2+2^3+2^4 = 30 strings with le...
{ "input": [ "5\n1\n0\n1\n0\n1\n", "9\n1\n1\n0\n0\n0\n1\n1\n0\n1\n", "3\n1\n1\n1\n" ], "output": [ "1\n4\n10\n22\n43\n", "1\n3\n10\n24\n51\n109\n213\n421\n833\n", "1\n3\n7\n" ] }
{ "input": [ "3\n0\n0\n0\n", "2\n1\n0\n", "15\n1\n0\n0\n1\n0\n0\n0\n0\n1\n1\n1\n1\n1\n0\n0\n", "30\n1\n0\n1\n0\n1\n1\n0\n1\n1\n0\n1\n0\n1\n1\n0\n0\n1\n0\n0\n0\n1\n1\n1\n1\n1\n0\n1\n0\n0\n1\n", "1\n0\n", "20\n1\n1\n0\n0\n1\n1\n0\n0\n1\n1\n0\n0\n1\n1\n0\n0\n1\n1\n0\n0\n", "50\n1\n1\n0\n1\n0\...
2,400
1,500
2
10
1149_D. Abandoning Roads
Codefortia is a small island country located somewhere in the West Pacific. It consists of n settlements connected by m bidirectional gravel roads. Curiously enough, the beliefs of the inhabitants require the time needed to pass each road to be equal either to a or b seconds. It's guaranteed that one can go between any...
{ "input": [ "6 7 13 22\n1 2 13\n2 3 13\n1 4 22\n3 4 13\n4 5 13\n5 6 13\n6 1 13\n", "5 5 20 25\n1 2 25\n2 3 25\n3 4 20\n4 5 20\n5 1 20\n" ], "output": [ "0 13 26 39 26 13\n", "0 25 60 40 20\n" ] }
{ "input": [ "3 2 509529 5982470\n1 2 509529\n3 2 509529\n", "3 2 451715 1577270\n1 3 1577270\n1 2 1577270\n", "2 1 1 2\n2 1 1\n", "3 2 150319 5002968\n3 2 150319\n1 2 5002968\n", "2 1 9999999 10000000\n1 2 10000000\n", "3 3 1966851 6439891\n1 3 6439891\n1 2 1966851\n3 2 6439891\n", "3 3 2...
3,000
2,500
2
9
1189_C. Candies!
Consider a sequence of digits of length 2^k [a_1, a_2, …, a_{2^k}]. We perform the following operation with it: replace pairs (a_{2i+1}, a_{2i+2}) with (a_{2i+1} + a_{2i+2})mod 10 for 0≤ i<2^{k-1}. For every i where a_{2i+1} + a_{2i+2}≥ 10 we get a candy! As a result, we will get a sequence of length 2^{k-1}. Less for...
{ "input": [ "8\n8 7 3 1 7 0 9 4\n3\n1 8\n2 5\n7 7\n", "6\n0 1 2 3 3 5\n3\n1 2\n1 4\n3 6\n" ], "output": [ "3\n1\n0\n", "0\n0\n1\n" ] }
{ "input": [ "2\n9 9\n2\n1 1\n1 2\n", "4\n8 5 6 6\n3\n2 3\n2 3\n3 4\n", "1\n8\n1\n1 1\n", "20\n4 8 6 6 3 0 1 8 3 6 1 4 3 2 1 3 6 4 5 4\n15\n16 19\n3 10\n9 9\n3 18\n6 7\n15 18\n12 19\n17 18\n12 12\n6 9\n3 10\n1 2\n2 3\n4 19\n16 16\n", "10\n6 6 8 8 2 5 0 1 2 1\n5\n5 6\n3 6\n8 9\n7 8\n2 9\n" ], "...
1,400
1,250
2
9
1208_C. Magic Grid
Let us define a magic grid to be a square matrix of integers of size n × n, satisfying the following conditions. * All integers from 0 to (n^2 - 1) inclusive appear in the matrix exactly once. * [Bitwise XOR](https://en.wikipedia.org/wiki/Bitwise_operation#XOR) of all elements in a row or a column must be the sa...
{ "input": [ "4\n", "8\n" ], "output": [ "0 1 2 3\n4 5 6 7\n8 9 10 11\n12 13 14 15\n", "0 1 2 3 16 17 18 19 \n4 5 6 7 20 21 22 23 \n8 9 10 11 24 25 26 27 \n12 13 14 15 28 29 30 31 \n32 33 34 35 48 49 50 51 \n36 37 38 39 52 53 54 55 \n40 41 42 43 56 57 58 59 \n44 45 46 47 60 61 62 63 \n" ] }
{ "input": [ "44\n", "8\n", "148\n", "4\n", "64\n", "116\n", "100\n", "88\n" ], "output": [ "0 1 2 3 16 17 18 19 32 33 34 35 48 49 50 51 64 65 66 67 80 81 82 83 96 97 98 99 112 113 114 115 128 129 130 131 144 145 146 147 160 161 162 163 \n4 5 6 7 20 21 22 23 36 37 38 39 52 53 5...
1,800
1,500
2
9
1227_C. Messy
You are fed up with your messy room, so you decided to clean it up. Your room is a bracket sequence s=s_{1}s_{2}... s_{n} of length n. Each character of this string is either an opening bracket '(' or a closing bracket ')'. In one operation you can choose any consecutive substring of s and reverse it. In other words,...
{ "input": [ "4\n8 2\n()(())()\n10 3\n))()()()((\n2 1\n()\n2 1\n)(\n" ], "output": [ "1\n5 7\n5\n1 3\n3 5\n5 7\n6 9\n7 10\n0\n1\n1 2\n" ] }
{ "input": [ "4\n8 2\n()(())()\n10 3\n))()()()((\n2 1\n()\n2 1\n)(\n" ], "output": [ "1\n5 7\n5\n1 3\n3 5\n5 7\n6 9\n7 10\n0\n1\n1 2\n" ] }
1,700
1,250
2
10
1269_D. Domino for Young
You are given a Young diagram. Given diagram is a histogram with n columns of lengths a_1, a_2, …, a_n (a_1 ≥ a_2 ≥ … ≥ a_n ≥ 1). <image> Young diagram for a=[3,2,2,2,1]. Your goal is to find the largest number of non-overlapping dominos that you can draw inside of this histogram, a domino is a 1 × 2 or 2 × 1 recta...
{ "input": [ "5\n3 2 2 2 1\n" ], "output": [ "4\n" ] }
{ "input": [ "1\n300000\n", "10\n9 8 7 7 6 4 3 2 1 1\n", "100\n1980 1932 1906 1898 1892 1883 1877 1858 1842 1833 1777 1710 1689 1678 1660 1653 1648 1647 1644 1639 1635 1635 1593 1571 1534 1470 1440 1435 1389 1272 1269 1268 1263 1255 1249 1237 1174 1174 1128 1069 1067 981 979 979 951 915 911 906 863 826 81...
2,000
1,000
2
10
1291_D. Irreducible Anagrams
Let's call two strings s and t anagrams of each other if it is possible to rearrange symbols in the string s to get a string, equal to t. Let's consider two strings s and t which are anagrams of each other. We say that t is a reducible anagram of s if there exists an integer k ≥ 2 and 2k non-empty strings s_1, t_1, s_...
{ "input": [ "aaaaa\n3\n1 1\n2 4\n5 5\n", "aabbbbbbc\n6\n1 2\n2 4\n2 2\n1 9\n5 7\n3 5\n" ], "output": [ "Yes\nNo\nYes\n", "No\nYes\nYes\nYes\nNo\nNo\n" ] }
{ "input": [ "abca\n1\n1 4\n", "f\n1\n1 1\n" ], "output": [ "Yes\n", "Yes\n" ] }
1,800
1,000
2
11
1311_E. Construct the Binary Tree
You are given two integers n and d. You need to construct a rooted binary tree consisting of n vertices with a root at the vertex 1 and the sum of depths of all vertices equals to d. A tree is a connected graph without cycles. A rooted tree has a special vertex called the root. A parent of a vertex v is the last diffe...
{ "input": [ "3\n5 7\n10 19\n10 18\n" ], "output": [ "YES\n1 1 2 4 \nYES\n1 1 2 2 3 3 4 4 5 \nNO\n" ] }
{ "input": [ "7\n15 49\n13 77\n18 65\n9 30\n4 6\n11 44\n577 4729\n", "6\n81 2117\n4 6\n10 34\n3 2\n310 2837\n4 4\n", "16\n8 20\n6 14\n7 15\n7 14\n16 57\n3 2\n5 6\n11 27\n18 61\n15 48\n11 49\n11 26\n7 18\n424 4366\n4 5\n40 272\n", "6\n7 14\n579 4569\n3 2\n19 147\n3 3\n59 265\n", "8\n13 31\n20 110\n...
2,200
0
2
9
1334_C. Circle of Monsters
You are playing another computer game, and now you have to slay n monsters. These monsters are standing in a circle, numbered clockwise from 1 to n. Initially, the i-th monster has a_i health. You may shoot the monsters to kill them. Each shot requires exactly one bullet and decreases the health of the targeted monste...
{ "input": [ "1\n3\n7 15\n2 14\n5 3\n" ], "output": [ "6\n" ] }
{ "input": [ "1\n3\n1000000000000 1000000000000\n1000000000000 1000000000000\n1000000000000 1000000000000\n", "10\n8\n7 4\n9 10\n4 8\n3 1\n1 7\n9 5\n1 4\n2 5\n8\n9 8\n4 7\n7 7\n3 6\n8 9\n2 5\n4 9\n2 8\n7\n2 2\n2 7\n2 10\n8 6\n7 4\n2 6\n3 10\n4\n4 10\n7 5\n6 10\n9 8\n7\n8 9\n8 1\n3 4\n5 1\n3 10\n9 3\n5 5\n5\n6...
1,600
0
2
11
1354_E. Graph Coloring
You are given an undirected graph without self-loops or multiple edges which consists of n vertices and m edges. Also you are given three integers n_1, n_2 and n_3. Can you label each vertex with one of three numbers 1, 2 or 3 in such way, that: 1. Each vertex should be labeled by exactly one number 1, 2 or 3; ...
{ "input": [ "6 3\n2 2 2\n3 1\n5 4\n2 5\n", "5 9\n0 2 3\n1 2\n1 3\n1 5\n2 3\n2 4\n2 5\n3 4\n3 5\n4 5\n" ], "output": [ "YES\n211323", "NO\n" ] }
{ "input": [ "1 0\n1 0 0\n", "5000 0\n0 5000 0\n", "1 0\n0 1 0\n", "5000 1\n1000 0 4000\n444 789\n", "5000 0\n5000 0 0\n", "5000 5\n1000 1000 3000\n4 11\n11 7\n7 127\n127 999\n999 4\n", "10 3\n3 4 3\n1 3\n3 7\n7 1\n", "4 4\n1 2 1\n1 2\n2 3\n3 4\n1 4\n", "5000 1\n0 1 4999\n3801 107\...
2,100
0
2
10
1374_D. Zero Remainder Array
You are given an array a consisting of n positive integers. Initially, you have an integer x = 0. During one move, you can do one of the following two operations: 1. Choose exactly one i from 1 to n and increase a_i by x (a_i := a_i + x), then increase x by 1 (x := x + 1). 2. Just increase x by 1 (x := x + 1). ...
{ "input": [ "5\n4 3\n1 2 1 3\n10 6\n8 7 1 8 3 7 5 10 8 9\n5 10\n20 100 50 20 100500\n10 25\n24 24 24 24 24 24 24 24 24 24\n8 8\n1 2 3 4 5 6 7 8\n" ], "output": [ "6\n18\n0\n227\n8\n" ] }
{ "input": [ "1\n1 1000000000\n99999999\n", "1\n5 3\n20 100 50 20 1005002\n" ], "output": [ "900000002\n", "11\n" ] }
1,400
0
2
11
1397_E. Monster Invaders
Ziota found a video game called "Monster Invaders". Similar to every other shooting RPG game, "Monster Invaders" involves killing monsters and bosses with guns. For the sake of simplicity, we only consider two different types of monsters and three different types of guns. Namely, the two types of monsters are: *...
{ "input": [ "4 2 4 4 1\n4 5 1 2\n", "4 1 3 4 3\n3 2 5 1\n" ], "output": [ "31\n", "34\n" ] }
{ "input": [ "35 2 5 6 3\n6 8 3 4 2 1 1 10 8 1 2 4 4 2 10 1 1 6 3 8 10 6 3 8 10 8 9 7 9 10 3 9 4 6 7\n", "36 6 6 9 6\n3 5 8 7 6 8 1 5 10 10 8 5 10 9 8 1 9 7 2 1 8 8 6 1 6 7 4 3 10 2 5 8 4 1 1 4\n", "17 2 7 10 6\n10 5 9 2 7 5 6 10 9 7 10 3 10 2 9 10 1\n", "77 2 8 8 3\n7 9 3 6 2 7 8 4 4 1 8 6 1 7 6 3 4 ...
2,300
1,750
2
12
1490_F. Equalize the Array
Polycarp was gifted an array a of length n. Polycarp considers an array beautiful if there exists a number C, such that each number in the array occurs either zero or C times. Polycarp wants to remove some elements from the array a to make it beautiful. For example, if n=6 and a = [1, 3, 2, 1, 4, 2], then the followin...
{ "input": [ "3\n6\n1 3 2 1 4 2\n4\n100 100 4 100\n8\n1 2 3 3 3 2 6 6\n" ], "output": [ "\n2\n1\n2\n" ] }
{ "input": [ "1\n36\n1 2 2 3 3 11 11 4 4 5 5 5 6 6 6 6 7 7 7 7 8 8 8 8 9 9 9 9 10 10 10 10 12 12 12 12\n" ], "output": [ "12\n" ] }
1,500
0
2
8
1513_B. AND Sequences
A sequence of n non-negative integers (n ≥ 2) a_1, a_2, ..., a_n is called good if for all i from 1 to n-1 the following condition holds true: $$$a_1 \: \& \: a_2 \: \& \: ... \: \& \: a_i = a_{i+1} \: \& \: a_{i+2} \: \& \: ... \: \& \: a_n, where \&$$$ denotes the [bitwise AND operation](https://en.wikipedia.org/wiki...
{ "input": [ "4\n3\n1 1 1\n5\n1 2 3 4 5\n5\n0 2 0 3 0\n4\n1 3 5 1\n" ], "output": [ "\n6\n0\n36\n4\n" ] }
{ "input": [ "1\n2\n0 0\n" ], "output": [ "2\n" ] }
1,400
1,250
2
8
1540_B. Tree Array
You are given a tree consisting of n nodes. You generate an array from the tree by marking nodes one by one. Initially, when no nodes are marked, a node is equiprobably chosen and marked from the entire tree. After that, until all nodes are marked, a node is equiprobably chosen and marked from the set of unmarked no...
{ "input": [ "3\n1 2\n1 3\n", "6\n2 1\n2 3\n6 1\n1 4\n2 5\n", "5\n1 2\n1 3\n1 4\n2 5\n" ], "output": [ "166666669\n", "500000009\n", "500000007\n" ] }
{ "input": [ "4\n1 2\n2 3\n3 4\n", "2\n1 2\n" ], "output": [ "3\n", "500000004\n" ] }
2,300
1,250
2
7
20_A. BerOS file system
The new operating system BerOS has a nice feature. It is possible to use any number of characters '/' as a delimiter in path instead of one traditional '/'. For example, strings //usr///local//nginx/sbin// and /usr/local/nginx///sbin are equivalent. The character '/' (or some sequence of such characters) at the end of ...
{ "input": [ "//usr///local//nginx/sbin\n" ], "output": [ "/usr/local/nginx/sbin\n" ] }
{ "input": [ "/a//aa/a//\n", "/root/pokerband/trunk/server/game/code/src/main/java/com/uosipa/pokerband/gameserver/game/\n", "////////////////////////////////////////////////////////////////////////////////////////////////////\n", "/aa//b/aa\n", "/zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz...
1,700
500
2
7
260_A. Adding Digits
Vasya has got two number: a and b. However, Vasya finds number a too short. So he decided to repeat the operation of lengthening number a n times. One operation of lengthening a number means adding exactly one digit to the number (in the decimal notation) to the right provided that the resulting number is divisible by...
{ "input": [ "260 150 10\n", "5 4 5\n", "12 11 1\n" ], "output": [ "-1\n", "520000\n", "121\n" ] }
{ "input": [ "99991 623 36438\n", "5 10 1\n", "99252 9827 84849\n", "3 40 1\n", "14 12 99998\n", "93248 91435 1133\n", "1 11 3\n", "94885 55815 11417\n", "99492 58525 53481\n", "99313 9833 10561\n", "99858 28531 79193\n", "1 15 10\n", "99136 47208 42607\n", "3 1...
1,400
500
2
7
284_A. Cows and Primitive Roots
The cows have just learned what a primitive root is! Given a prime p, a primitive root <image> is an integer x (1 ≤ x < p) such that none of integers x - 1, x2 - 1, ..., xp - 2 - 1 are divisible by p, but xp - 1 - 1 is. Unfortunately, computing primitive roots can be time consuming, so the cows need your help. Given ...
{ "input": [ "5\n", "3\n" ], "output": [ "2", "1" ] }
{ "input": [ "19\n", "1097\n", "1987\n", "821\n", "1297\n", "2\n", "1583\n", "1597\n", "1949\n", "317\n", "1999\n", "431\n", "953\n", "31\n", "29\n", "211\n", "1277\n", "101\n", "751\n", "11\n", "607\n", "509\n", "1759\n", ...
1,400
500
2
13
39_G. Inverse Function
Petya wrote a programme on C++ that calculated a very interesting function f(n). Petya ran the program with a certain value of n and went to the kitchen to have some tea. The history has no records concerning how long the program had been working. By the time Petya returned, it had completed the calculations and had th...
{ "input": [ "17\nint f(int n)\n{\nif (n &lt; 100) return 17;\nif (n &gt; 99) return 27;\n}\n", "144\nint f(int n)\n{\nif (n == 0) return 0;\nif (n == 1) return n;\nreturn f(n - 1) + f(n - 2);\n}", "13\nint f(int n)\n{\nif (n == 0) return 0;\nreturn f(n - 1) + 1;\n}\n" ], "output": [ "-1", "24...
{ "input": [ "15\nint f(int n){if(n > 1)return f(n-2)/f(n-1)+15;if(n==0)return 0;if(n==1)return 1;}\n", "32763\nint f(int n){if (n < 1025) return n*5+12/6-n/3*15-7;return f(n/2)-f(n-7)*f(n-7)-1024;}\n", "12351\nint f(int n)\n{\nif (n < 3) return n;\nreturn f(n - 1) * n + f(n - 2) + f(n - 3) / 5;\n}\n", ...
2,400
0
2
7
44_A. Indian Summer
Indian summer is such a beautiful time of the year! A girl named Alyona is walking in the forest and picking a bouquet from fallen leaves. Alyona is very choosy — she doesn't take a leaf if it matches the color and the species of the tree of one of the leaves she already has. Find out how many leaves Alyona has picked....
{ "input": [ "3\noak yellow\noak yellow\noak yellow\n", "5\nbirch yellow\nmaple red\nbirch yellow\nmaple yellow\nmaple green\n" ], "output": [ "1", "4" ] }
{ "input": [ "20\nm vkfh\nvptikamead mvx\nitu mf\nklruxckw aqega\nekqkd enjllwol\ncc uybfdh\nimrfdngvo u\ne uh\ntwt jsslcfuogk\nbljwqsag tuqbdn\nqcv q\nasx gzhvwwmajj\nqcv q\nekqkd enjllwol\nasx gzhvwwmajj\nks vv\nkzyfi cn\ncc uybfdh\nitu mf\ncjbjhtbyvk vatwfmux\n", "1\nqvwli hz\n", "5\nxbnbkzn hp\nkaqkl ...
900
0
2
7
519_A. A and B and Chess
A and B are preparing themselves for programming contests. To train their logical thinking and solve problems better, A and B decided to play chess. During the game A wondered whose position is now stronger. For each chess piece we know its weight: * the queen's weight is 9, * the rook's weight is 5, * the ...
{ "input": [ "rnbqkbnr\npppppppp\n........\n........\n........\n........\nPPPPPPPP\nRNBQKBNR\n", "rppppppr\n...k....\n........\n........\n........\n........\nK...Q...\n........\n", "...QK...\n........\n........\n........\n........\n........\n........\n...rk...\n" ], "output": [ "Draw\n", "Blac...
{ "input": [ "....K...\n........\n........\n........\n........\n........\n........\n...Kk...\n", "........\n........\n........\n........\n........\n........\n........\n........\n", "N.......\nppp.....\n........\n........\n........\n........\n........\n........\n", "P.......\n........\n........\n.........
900
500
2
8
545_B. Equidistant String
Little Susie loves strings. Today she calculates distances between them. As Susie is a small girl after all, her strings contain only digits zero and one. She uses the definition of Hamming distance: We will define the distance between two strings s and t of the same length consisting of digits zero and one as the num...
{ "input": [ "0001\n1011\n", "000\n111\n" ], "output": [ "0011", "impossible\n" ] }
{ "input": [ "1010101011111110111111001111111111111111111111101101110111111111111110110110101011111110110111111101\n0101111111000100010100001100010101000000011000000000011011000001100100001110111011111000001110011111\n", "0000000001000000000000100000100001000000\n1111111011111101111111111111111111111111\n", ...
1,100
1,000
2
8
593_B. Anton and Lines
The teacher gave Anton a large geometry homework, but he didn't do it (as usual) as he participated in a regular round on Codeforces. In the task he was given a set of n lines defined by the equations y = ki·x + bi. It was necessary to determine whether there is at least one point of intersection of two of these lines,...
{ "input": [ "4\n1 2\n1 2\n1 0\n0 1\n0 2\n", "2\n1 3\n1 0\n0 2\n", "2\n1 3\n1 0\n-1 3\n", "2\n1 3\n1 0\n0 3\n" ], "output": [ "NO", "YES\n", "YES", "NO" ] }
{ "input": [ "2\n0 1000000\n1000000 1000000\n0 3\n", "2\n0 1\n1 0\n2 0\n", "2\n900000 1000000\n900000 1000000\n1000000 900000\n", "2\n0 1000000\n0 0\n1000000 1000000\n", "2\n0 1000000\n0 0\n2200 1\n", "2\n0 1000000\n1000000 0\n0 100\n", "15\n30 32\n-45 1\n-22 -81\n4 42\n-83 -19\n97 70\n55 ...
1,600
1,000