problem_statement
stringlengths
147
8.53k
input
stringlengths
1
771
output
stringlengths
1
592
time_limit
stringclasses
32 values
memory_limit
stringclasses
21 values
tags
stringlengths
6
168
C. Ela and Cricketstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputEla likes Chess a lot. During breaks, she usually challenges her co-worker in DTL to some chess games. She's not an expert at classic chess, but she's very interested in Chess variants, where she has ...
687 2 8 2 7 15 182 2 1 2 2 15 582 2 1 2 2 16 681 1 1 2 2 15 582 2 1 2 2 18 888 8 8 7 7 84 8
YES NO YES NO YES YES
1 second
256 megabytes
['constructive algorithms', 'games', 'implementation', 'math', '*1500']
B. Ela's Fitness and the Luxury Numbertime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputWhile working at DTL, Ela is very aware of her physical and mental health. She started to practice various sports, such as Archery, Yoga, and Football.Since she started engaging in ...
58 198 20119 1211 1000000000000000001234567891011 1000000000000000000
5 6 2 948683296 2996666667
1 second
256 megabytes
['binary search', 'implementation', 'math', '*1300']
A. Ela Sorting Bookstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputEla loves reading a lot, just like her new co-workers in DTL! On her first day after becoming an engineer in DTL, she is challenged by a co-worker to sort a heap of books into different compartments ...
512 3cabccadabaac12 6cabccadabaac12 12cabccadabaac25 1abcdefghijklmnopqrstuvwxy10 5bcdxedbcfg
edb ccbbba bbbbbaaaaaaa z aaaaa
1 second
256 megabytes
['greedy', 'implementation', 'strings', '*900']
E. Swap and Taketime limit per test2 secondsmemory limit per test1024 megabytesinputstandard inputoutputstandard outputYou're given an array consisting of n integers. You have to perform n turns.Initially your score is 0.On the i-th turn, you are allowed to leave the array as it is or swap any one pair of 2 adjacent el...
2 3 1
6
2 seconds
1024 megabytes
['dp', 'greedy', '*2600']
D. Equal Binary Subsequencestime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputEverool has a binary string s of length 2n. Note that a binary string is a string consisting of only characters 0 and 1. He wants to partition s into two disjoint equal subsequences. He needs...
4 2 1010 3 100010 2 1111 2 1110
0 1 2 2 3 5 1 2 5 3 2 3 4 1 4 -1
1 second
256 megabytes
['constructive algorithms', 'geometry', 'greedy', 'implementation', 'strings', '*2200']
C2. Good Subarrays (Hard Version)time limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis is the hard version of this problem. In this version, we have queries. Note that we do not have multiple test cases in this version. You can make hacks only if both versions of the...
4 2 4 1 4 3 2 4 3 3 2 1
6 10 5
3 seconds
256 megabytes
['binary search', 'data structures', 'dp', 'two pointers', '*2400']
C1. Good Subarrays (Easy Version)time limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis is the easy version of this problem. In this version, we do not have queries. Note that we have multiple test cases in this version. You can make hacks only if both versions of the ...
331 2 331 1 142 1 4 3
6 3 7
1 second
256 megabytes
['binary search', 'data structures', 'schedules', 'two pointers', '*1300']
B. Playing with GCDtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an integer array a of length n. Does there exist an array b consisting of n+1 positive integers such that a_i=\gcd (b_i,b_{i+1}) for all i (1 \leq i \leq n)? Note that \gcd(x, y) denotes...
4134324 234 2 441 1 1 1
YES YES NO YES
1 second
256 megabytes
['math', 'number theory', '*1200']
A. Make A Equal to Btime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given two arrays a and b of n elements, each element is either 0 or 1.You can make operations of 2 kinds. Pick an index i and change a_i to 1-a_i. Rearrange the array a however you want. F...
531 0 10 0 141 1 0 00 1 1 121 11 141 0 0 10 1 1 0101
1 2 0 1 1
1 second
256 megabytes
['brute force', 'greedy', 'sortings', '*800']
F. Pebbles and Beadstime limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere are two currencies: pebbles and beads. Initially you have a pebbles, b beads.There are n days, each day you can exchange one currency for another at some exchange rate.On day i, you can exchan...
32 6 02 34 23 0 64 2 102 3 101 10 10331000
6 8 4 6 9.000000 10.33
4 seconds
256 megabytes
['data structures', 'geometry', '*2900']
E. House Planningtime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere are n houses in your city arranged on an axis at points h_1, h_2, \ldots, h_n. You want to build a new house for yourself and consider two options where to place it: points p_1 and p_2.As you lik...
4155210 125 20210 3326 6940 2 1 22 2 1 0
YES 5 0 10 NO YES 0 43 33 69 YES 1 0 3 3 1 1
3 seconds
256 megabytes
['constructive algorithms', 'data structures', 'graph matchings', 'greedy', '*2400']
D. Meta-settime limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou like the card board game "Set". Each card contains k features, each of which is equal to a value from the set \{0, 1, 2\}. The deck contains all possible variants of cards, that is, there are 3^k differe...
8 4 0 0 0 0 0 0 0 1 0 0 0 2 0 0 1 0 0 0 2 0 0 1 0 0 1 0 0 0 2 2 0 0
1
4 seconds
256 megabytes
['brute force', 'combinatorics', 'data structures', 'hashing', 'math', '*1700']
C. Phase Shifttime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere was a string s which was supposed to be encrypted. For this reason, all 26 lowercase English letters were arranged in a circle in some order, afterwards, each letter in s was replaced with the one t...
51a2ba10codeforces26abcdefghijklmnopqrstuvwxyz26abcdefghijklmnopqrstuvwxzy
b ac abcdebfadg bcdefghijklmnopqrstuvwxyza bcdefghijklmnopqrstuvwxyaz
3 seconds
256 megabytes
['dfs and similar', 'dsu', 'graphs', 'greedy', 'implementation', 'strings', '*1400']
B. Tea with Tangerinestime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere are n pieces of tangerine peel, the i-th of them has size a_i. In one step it is possible to divide one piece of size x into two pieces of positive integer sizes y and z so that y + z = x.You...
351 2 3 4 5110335600 900 1300 2000 2550
10 0 4
1 second
256 megabytes
['greedy', 'math', '*900']
A. Working Weektime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYour working week consists of n days numbered from 1 to n, after day n goes day 1 again. And 3 of them are days off. One of the days off is the last day, day n. You have to decide when the other two are.C...
36101033
0 1 342
1 second
256 megabytes
['constructive algorithms', 'greedy', 'math', '*800']
F. Zeros and Onestime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputLet S be the Thue-Morse sequence. In other words, S is the 0-indexed binary string with infinite length that can be constructed as follows: Initially, let S be "0". Then, we perform the following op...
61 15 1034 21173 3419124639 5634877212073412269 96221437021
1 6 95 20 28208137 48102976088
3 seconds
256 megabytes
['bitmasks', 'divide and conquer', 'dp', 'math', '*2500']
E. Rectangular Congruencetime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a prime number n, and an array of n integers b_1,b_2,\ldots, b_n, where 0 \leq b_i < n for each 1 \le i \leq n.You have to find a matrix a of size n \times n such that all of the f...
2 0 0
0 1 0 0
1 second
256 megabytes
['constructive algorithms', 'number theory', '*2100']
D. Slime Escapetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are playing a game called Slime Escape. The game takes place on a number line. Initially, there are n slimes. For all positive integers i where 1 \le i \le n, the i-th slime is located at position i ...
67 4-1 -2 -3 6 -2 -3 -13 1232 -500 -7007 4-1 -2 -4 6 -2 -4 -18 4-100 10 -7 6 -2 -3 6 -108 2-999 0 -2 3 4 5 6 77 37 3 3 4 2 1 1
YES YES NO YES NO YES
2 seconds
256 megabytes
['data structures', 'dp', 'greedy', 'two pointers', '*1800']
C. Removing Smallest Multiplestime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a set S, which contains the first n positive integers: 1, 2, \ldots, n.You can perform the following operation on S any number of times (possibly zero): Choose a positive i...
6611111171101001400004001081001010115110011100101100
0 11 4 4 17 60
2 seconds
256 megabytes
['greedy', 'math', '*1200']
B. Bright, Nice, Brillianttime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere is a pyramid which consists of n floors. The floors are numbered from top to bottom in increasing order. In the pyramid, the i-th floor consists of i rooms.Denote the j-th room on the i-t...
3123
1 1 1 1 1 1 1 1 0 1
1 second
256 megabytes
['constructive algorithms', '*800']
A. Select Three Stickstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given n sticks with positive integral length a_1, a_2, \ldots, a_n.You can perform the following operation any number of times (possibly zero): choose one stick, then either increase or d...
431 2 347 3 7 353 4 2 1 183 1 4 1 5 9 2 6
2 4 1 1
1 second
256 megabytes
['brute force', 'greedy', 'sortings', '*800']
E. Conveyortime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere is a conveyor with 120 rows and 120 columns. Each row and column is numbered from 0 to 119, and the cell in i-th row and j-th column is denoted as (i, j). The top leftmost cell is (0, 0). Each cell has...
61 1 05 1 30 0 02 4 52 0 21547748756 100 111
NO YES YES NO YES YES
3 seconds
256 megabytes
['constructive algorithms', 'dp', 'math', '*2700']
D2. Zero-One (Hard Version)time limit per test3 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputThis is the hard version of this problem. In this version, n \le 5000 holds, and this version has no restriction between x and y. You can make hacks only if both versions of the problem are s...
65 8 901001001016 2 110000011000005 7 201000110117 8 3011100101000016 3 40100011010005 10 10110001100
8 10 -1 6 7 0
3 seconds
512 megabytes
['dp', 'greedy', '*2000']
D1. Zero-One (Easy Version)time limit per test3 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputThis is the easy version of the problem. In this version, n \le 3000, x \ge y holds. You can make hacks only if both versions of the problem are solved.You are given two binary strings a and ...
45 8 701001001015 7 201000110117 8 3011100101000015 10 10110001100
8 -1 6 0
3 seconds
512 megabytes
['constructive algorithms', 'greedy', 'math', '*1400']
C. Parity Shuffle Sortingtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an array a with n non-negative integers. You can apply the following operation on it. Choose two indices l and r (1 \le l < r \le n). If a_l + a_r is odd, do a_r := a_l. If a_l...
327 851 1000000000 3 0 510
0 2 3 4 1 2 0
2 seconds
256 megabytes
['constructive algorithms', 'sortings', '*1300']
B. Rule of Leaguetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere is a badminton championship in which n players take part. The players are numbered from 1 to n. The championship proceeds as follows: player 1 and player 2 play a game, then the winner and player...
55 2 08 1 23 0 02 0 16 3 0
1 1 4 4 -1 -1 2 -1
2 seconds
256 megabytes
['constructive algorithms', 'math', '*900']
A. Consecutive Sumtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an array a with n integers. You can perform the following operation at most k times: Choose two indices i and j, in which i \,\bmod\, k = j \,\bmod\, k (1 \le i < j \le n). Swap a_i and...
53 25 6 01 175 37 0 4 0 44 22 7 3 43 31000000000 1000000000 999999997
11 7 15 10 2999999997
1 second
256 megabytes
['greedy', 'sortings', '*800']
E. Locationtime limit per test3 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputYou are given two arrays of integers a_1, a_2, \ldots, a_n and b_1, b_2, \ldots, b_n. You need to handle q queries of the following two types: 1 l r x: assign a_i := x for all l \leq i \leq r; 2 l r: find th...
10 106 10 15 4 9 25 2 3 5 301 2 3 4 6 9 12 15 18 302 1 101 7 10 92 5 101 1 6 142 4 72 3 91 2 9 302 1 42 3 72 5 10
1 2 12 2 10 5 2
3 seconds
512 megabytes
['data structures', 'dp', 'math', 'number theory', '*2800']
D2. Balance (Hard version)time limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis is the hard version of the problem. The only difference is that in this version there are remove queries.Initially you have a set containing one element — 0. You need to handle q queries ...
18+ 1+ 2? 1+ 4? 2+ 6? 3+ 7+ 8? 1? 2+ 5? 1+ 1000000000000000000? 1000000000000000000- 4? 1? 2
3 6 3 3 10 3 2000000000000000000 3 4
3 seconds
256 megabytes
['brute force', 'data structures', 'number theory', '*2400']
D1. Balance (Easy version)time limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis is the easy version of the problem. The only difference is that in this version there are no "remove" queries.Initially you have a set containing one element — 0. You need to handle q que...
15+ 1+ 2? 1+ 4? 2+ 6? 3+ 7+ 8? 1? 2+ 5? 1+ 1000000000000000000? 1000000000000000000
3 6 3 3 10 3 2000000000000000000
3 seconds
256 megabytes
['brute force', 'data structures', 'implementation', 'number theory', '*1500']
C2. Sheikh (Hard Version)time limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis is the hard version of the problem. The only difference is that in this version q = n.You are given an array of integers a_1, a_2, \ldots, a_n.The cost of a subsegment of the array [l, r],...
61 101 12 25 101 22 23 30 2 41 31 22 34 40 12 8 31 41 32 42 35 521 32 32 32 101 51 41 32 53 57 70 1 0 1 0 1 01 73 62 51 44 72 62 7
1 1 1 1 2 2 1 1 1 1 2 2 2 3 2 3 2 3 2 3 2 3 2 3 2 3 2 3 3 4 2 4 4 6 2 4 2 4 4 6 2 4 2 4
4 seconds
256 megabytes
['binary search', 'bitmasks', 'brute force', 'greedy', 'implementation', 'two pointers', '*2100']
C1. Sheikh (Easy version)time limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis is the easy version of the problem. The only difference is that in this version q = 1.You are given an array of integers a_1, a_2, \ldots, a_n.The cost of a subsegment of the array [l, r],...
61 101 12 15 101 23 10 2 41 34 10 12 8 31 45 121 32 32 32 101 57 10 1 0 1 0 1 01 7
1 1 1 1 1 1 2 3 2 3 2 4
4 seconds
256 megabytes
['binary search', 'bitmasks', 'greedy', 'two pointers', '*1800']
B. Ugutime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputA binary string is a string consisting only of the characters 0 and 1. You are given a binary string s_1 s_2 \ldots s_n. It is necessary to make this string non-decreasing in the least number of operations. In oth...
811210310141100511001610001010000011000070101010
0 1 2 1 2 3 1 5
1 second
256 megabytes
['brute force', 'dp', 'greedy', 'implementation', '*900']
A. Bestietime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an array a consisting of n integers a_1, a_2, \ldots, a_n. Friends asked you to make the greatest common divisor (GCD) of all numbers in the array equal to 1. In one operation, you can do the foll...
9111222 433 6 945 10 15 205120 60 80 40 806150 90 180 120 60 3062 4 6 9 12 18630 60 90 120 125 125
0 1 2 2 1 3 3 0 1
1 second
256 megabytes
['brute force', 'combinatorics', 'constructive algorithms', 'implementation', 'math', 'number theory', '*1000']
F. Function Sumtime limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputSuppose you have an integer array a_1, a_2, \dots, a_n.Let \operatorname{lsl}(i) be the number of indices j (1 \le j < i) such that a_j < a_i.Analogically, let \operatorname{grr}(i) be the number of indi...
3 3
28
4 seconds
256 megabytes
['brute force', 'combinatorics', 'dp', 'fft', 'math', '*2500']
E. Graph Costtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an initially empty undirected graph with n nodes, numbered from 1 to n (i. e. n nodes and 0 edges). You want to add m edges to the graph, so the graph won't contain any self-loop or multiple ...
44 16 109 410 11
2 -1 7 21
2 seconds
256 megabytes
['dp', 'greedy', 'math', 'number theory', '*2000']
D. Valiant's New Maptime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputGame studio "DbZ Games" wants to introduce another map in their popular game "Valiant". This time, the map named "Panvel" will be based on the city of Mumbai.Mumbai can be represented as n \times m ...
42 22 34 51 31 2 32 34 4 32 1 45 61 9 4 6 5 810 9 5 8 11 624 42 32 8 11 123 1 9 69 13 313 22 60 12 14 17
2 1 1 3
2 seconds
256 megabytes
['binary search', 'brute force', 'data structures', 'dp', 'two pointers', '*1700']
C. Even Subarraystime limit per test2.5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an integer array a_1, a_2, \dots, a_n (1 \le a_i \le n).Find the number of subarrays of a whose \operatorname{XOR} has an even number of divisors. In other words, find all pairs of indi...
433 1 254 2 1 5 344 4 4 475 7 3 7 1 7 3
4 11 0 20
2.5 seconds
256 megabytes
['bitmasks', 'brute force', 'hashing', 'math', 'number theory', '*1700']
B. Kill Demodogstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputDemodogs from the Upside-down have attacked Hawkins again. El wants to reach Mike and also kill as many Demodogs in the way as possible.Hawkins can be represented as an n \times n grid. The number of Dem...
423501000000000
14154 44484 171010650 999589541
1 second
256 megabytes
['greedy', 'math', '*1100']
A. Joey Takes Moneytime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputJoey is low on money. His friend Chandler wants to lend Joey some money, but can't give him directly, as Joey is too proud of himself to accept it. So, in order to trick him, Chandler asks Joey to pla...
332 3 221 331000000 1000000 1
28308 8088 2022000000004044
1 second
256 megabytes
['greedy', 'math', '*800']
F. Almost Sortedtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a permutation p of length n and a positive integer k. Consider a permutation q of length n such that for any integers i and j, where 1 \le i < j \le n, we have p_{q_i} \le p_{q_j} + k.Find...
1 1 1
0
2 seconds
256 megabytes
['bitmasks', 'data structures', 'dp', '*2700']
E. Maximums and Minimumstime limit per test5 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputYou are given an array a_1, a_2, \ldots, a_n of positive integers.Find the number of pairs of indices (l, r), where 1 \le l \le r \le n, that pass the check. The check is performed in the follow...
61122 422 342 4 7 14716 5 18 7 7 12 14616 14 2 6 16 2
1 3 2 7 10 19
5 seconds
512 megabytes
['combinatorics', 'data structures', 'divide and conquer', 'number theory', '*2700']
D. Prefixes and Suffixestime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou have two strings s_1 and s_2 of length n, consisting of lowercase English letters. You can perform the following operation any (possibly zero) number of times: Choose a positive integer 1 \...
73cbcaba5abcaacbabb5abcaacbabz1aa1ab6abadaaadaaba8abcabdaaadabcaba
YES YES NO YES NO NO YES
1 second
256 megabytes
['constructive algorithms', 'strings', 'two pointers', '*2200']
C. Minimum Notationtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou have a string s consisting of digits from 0 to 9 inclusive. You can perform the following operation any (possibly zero) number of times: You can choose a position i and delete a digit d on the i...
404829901314752277691991
02599 9 01 111334567888999
1 second
256 megabytes
['data structures', 'greedy', 'math', 'sortings', '*1200']
B. Meeting on the Linetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputn people live on the coordinate line, the i-th one lives at the point x_i (1 \le i \le n). They want to choose a position x_0 to meet. The i-th person will spend |x_i - x_0| minutes to get to the ...
710323 10 021 40 031 2 30 0 031 2 34 1 233 3 35 3 365 4 7 2 10 43 2 5 1 4 6
0 2 2.5 2 1 3 6
2 seconds
256 megabytes
['binary search', 'geometry', 'greedy', 'implementation', 'math', 'ternary search', '*1600']
A. Planetstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputOne day, Vogons wanted to build a new hyperspace highway through a distant system with n planets. The i-th planet is on the orbit a_i, there could be multiple planets on the same orbit. It's a pity that all th...
410 12 1 4 5 2 4 5 5 1 25 23 2 1 2 22 21 12 21 2
4 4 2 2
1 second
256 megabytes
['data structures', 'greedy', 'sortings', '*800']
G. Cut Substringstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given two non-empty strings s and t, consisting of Latin letters.In one move, you can choose an occurrence of the string t in the string s and replace it with dots.Your task is to remove all oc...
8abababacababaabadddddddddddxyzxyzxyzabcabcdabacabaabacaabcdefaaaaaaaaaaaaaaaaaaa
2 2 1 4 2 1 0 1 1 1 0 1 8 1 3 6
2 seconds
256 megabytes
['combinatorics', 'dp', 'hashing', 'strings', 'two pointers', '*2100']
F. Kirei and the Linear Functiontime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputGiven the string s of decimal digits (0-9) of length n.A substring is a sequence of consecutive characters of a string. The substring of this string is defined by a pair of indexes — wit...
510030044 11 2 11795720074 22 7 32 7 41112 12 2 600001 21 4 01 4 14841 52 2 02 3 71 2 53 3 82 2 6
2 4 1 5 1 2 -1 -1 1 2 -1 -1 1 3 1 3 -1 -1 -1 -1 -1 -1
3 seconds
256 megabytes
['hashing', 'math', '*1900']
E. Guess the Cycle Sizetime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis is an interactive problem.I want to play a game with you...We hid from you a cyclic graph of n vertices (3 \le n \le 10^{18}). A cyclic graph is an undirected graph of n vertices that form on...
1 2 -1
? 1 2 ? 1 3 ? 1 4 ! 3
1 second
256 megabytes
['interactive', 'probabilities', '*1800']
D. Friends and the Restauranttime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputA group of n friends decide to go to a restaurant. Each of the friends plans to order meals for x_i burles and has a total of y_i burles (1 \le i \le n). The friends decide to split their v...
668 3 9 2 4 55 3 1 4 5 1041 2 3 41 1 2 232 3 71 3 1062 3 6 9 5 73 2 7 10 6 1065 4 2 1 8 1001 1 1 1 1 20061 4 1 2 4 21 3 3 2 3 4
2 0 1 3 1 3
2 seconds
256 megabytes
['greedy', 'sortings', 'two pointers', '*1200']
C. Jumping on Tilestime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputPolycarp was given a row of tiles. Each tile contains one lowercase letter of the Latin alphabet. The entire sequence of tiles forms the string s.In other words, you are given a string s consisting of...
6logiccodeforcesbcaaaaaaaaaaaaadbaadabadto
9 4 1 4 3 5 16 10 1 8 3 4 9 5 2 6 7 10 1 2 1 3 0 11 1 8 10 4 3 5 7 2 9 6 11 3 10 1 9 5 4 7 3 8 6 2 10 5 2 1 2
1 second
256 megabytes
['constructive algorithms', 'strings', '*1100']
B. Decode Stringtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputPolycarp has a string s consisting of lowercase Latin letters.He encodes it using the following algorithm.He goes through the letters of the string s from left to right and for each letter Polycarp consi...
963150454110071213121612012018315045615018035190711111107111110051111142606
code aj abacaba ll codeforces aaaak aaaaj aaaaa zf
1 second
256 megabytes
['greedy', 'strings', '*800']
A. Two Elevatorstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputVlad went into his appartment house entrance, now he is on the 1-th floor. He was going to call the elevator to go up to his apartment.There are only two elevators in his house. Vlad knows for sure that:...
31 2 33 1 23 2 1
1 3 2
1 second
256 megabytes
['math', '*800']
G. Illuminationtime limit per test8 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputConsider a segment [0, d] of the coordinate line. There are n lanterns and m points of interest in this segment.For each lantern, you can choose its power — an integer between 0 and d (inclusive). A lant...
6 1 1 4 3 3 2 1 5
48 47 47
8 seconds
512 megabytes
['binary search', 'bitmasks', 'brute force', 'combinatorics', 'dp', 'math', 'two pointers', '*2700']
F. Fishermentime limit per test6 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputThere are n fishermen who have just returned from a fishing trip. The i-th fisherman has caught a fish of size a_i.The fishermen will choose some order in which they are going to tell the size of the fish t...
7 1 8 2 3 2 2 3
33
6 seconds
512 megabytes
['flows', 'graph matchings', 'greedy', '*3100']
E. Red-Black Peppertime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputMonocarp is going to host a party for his friends. He prepared n dishes and is about to serve them. First, he has to add some powdered pepper to each of them — otherwise, the dishes will be pretty ta...
3 5 10 100 50 2 2 4 2 3 1 1 3 2 2 2
62 112 107 -1
2 seconds
256 megabytes
['brute force', 'data structures', 'greedy', 'math', 'number theory', '*2300']
D. Letter Pickingtime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputAlice and Bob are playing a game. Initially, they are given a non-empty string s, consisting of lowercase Latin letters. The length of the string is even. Each player also has a string of their own, in...
2forcesabba
Alice Draw
2 seconds
512 megabytes
['constructive algorithms', 'dp', 'games', 'two pointers', '*1800']
C. Digital Logarithmtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputLet's define f(x) for a positive integer x as the length of the base-10 representation of x without leading zeros. I like to call it a digital logarithm. Similar to a digital root, if you are famili...
411100041 2 3 43 1 4 232 9 31 100 91075019 709259 5 611271314 9024533 81871864 9 3 6 48659503 2 371245467 6 7 37376159 8 364036498 52295554 169
2 0 2 18
2 seconds
256 megabytes
['data structures', 'greedy', 'sortings', '*1400']
B. Best Permutationtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputLet's define the value of the permutation p of n integers 1, 2, ..., n (a permutation is an array where each element from 1 to n occurs exactly once) as follows: initially, an integer variable x is ...
3456
2 1 3 4 1 2 3 4 5 4 5 1 2 3 6
2 seconds
256 megabytes
['constructive algorithms', 'greedy', '*800']
A. Colored Balls: Revisitedtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe title is a reference to the very first Educational Round from our writers team, Educational Round 18.There is a bag, containing colored balls. There are n different colors of balls, numbe...
331 1 11924 7
3 1 2
2 seconds
256 megabytes
['brute force', 'greedy', 'implementation', 'sortings', '*800']
H. Mainak and the Bleeding Polygontime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputMainak has a convex polygon \mathcal P with n vertices labelled as A_1, A_2, \ldots, A_n in a counter-clockwise fashion. The coordinates of the i-th point A_i are given by (x_i, y_i), w...
4 4 5 4 1 7 1 7 5
1.17809724510
1 second
256 megabytes
['binary search', 'geometry', 'implementation', 'math', '*3500']
G. A Certain Magical Partytime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere are n people at a party. The i-th person has an amount of happiness a_i.Every person has a certain kind of personality which can be represented as a binary integer b. If b = 0, it means ...
4 1 2 4 4 1 1 0 0
2
2 seconds
256 megabytes
['combinatorics', 'data structures', 'greedy', 'sortings', '*3300']
F. Late For Work (submissions are not allowed)time limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis problem was copied by the author from another online platform. Codeforces strongly condemns this action and therefore further submissions to this problem are not accep...
5 10 4 2 7 3 3 6 5 2 8 0 1 2 3 4
11
3 seconds
256 megabytes
['data structures', 'greedy', 'schedules', 'shortest paths', '*2900']
E. Almost Perfecttime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputA permutation p of length n is called almost perfect if for all integer 1 \leq i \leq n, it holds that \lvert p_i - p^{-1}_i \rvert \le 1, where p^{-1} is the inverse permutation of p (i.e. p^{-1}_{k_1...
32350
2 4 830690567
3 seconds
256 megabytes
['combinatorics', 'fft', 'math', '*2400']
D. Edge Splittime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a connected, undirected and unweighted graph with n vertices and m edges. Notice the limit on the number of edges: m \le n + 2.Let's say we color some of the edges red and the remaining edges...
45 71 22 33 44 55 11 33 54 41 22 31 43 46 71 21 33 44 51 45 66 22 11 2
0111010 1001 0001111 0
2 seconds
256 megabytes
['brute force', 'constructive algorithms', 'dfs and similar', 'dsu', 'graphs', 'probabilities', 'trees', '*2000']
C. Jatayu's Balanced Bracket Sequencetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputLast summer, Feluda gifted Lalmohan-Babu a balanced bracket sequence s of length 2 n.Topshe was bored during his summer vacations, and hence he decided to draw an undirected graph o...
41()3()(())3((()))4(())(())
1 2 3 3
2 seconds
256 megabytes
['data structures', 'dsu', 'graphs', 'greedy', '*1300']
B. Mainak and Interesting Sequencetime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputMainak has two positive integers n and m.Mainak finds a sequence a_1, a_2, \ldots, a_n of n positive integers interesting, if for all integers i (1 \le i \le n), the bitwise XOR of all ...
4 1 3 6 12 2 1 3 6
Yes 3 Yes 1 3 2 2 3 1 No Yes 2 2 2
1 second
256 megabytes
['bitmasks', 'constructive algorithms', 'math', '*1100']
A. Mainak and Arraytime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputMainak has an array a_1, a_2, \ldots, a_n of n positive integers. He will do the following operation to this array exactly once: Pick a subsegment of this array and cyclically rotate it by any amount...
561 3 9 11 5 712039 99 99942 1 8 132 1 5
10 0 990 7 4
1 second
256 megabytes
['greedy', 'math', '*900']
M. Moving Both Handstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputPak Chanek is playing one of his favourite board games. In the game, there is a directed graph with N vertices and M edges. In the graph, edge i connects two different vertices U_i and V_i with a len...
5 7 1 2 2 2 4 1 4 1 4 2 5 3 5 4 1 5 2 4 2 1 1
1 -1 3 4
1 second
256 megabytes
['dp', 'graphs', 'shortest paths', '*1800']
L. Lemper Cooking Competitiontime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputPak Chanek is participating in a lemper cooking competition. In the competition, Pak Chanek has to cook lempers with N stoves that are arranged sequentially from stove 1 to stove N. Initiall...
7 2 -1 -1 5 2 -2 9
4
1 second
256 megabytes
['data structures', '*2400']
K. Kingdom of Criticismtime limit per test3 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputPak Chanek is visiting a kingdom that earned a nickname "Kingdom of Criticism" because of how often its residents criticise each aspect of the kingdom. One aspect that is often criticised is the ...
5 2 6 5 6 2 9 1 5 10 2 5 1 1 3 3 3 6 3 8 9 1 2 9 2 3 2 2 2 4
10 7 9 7
3 seconds
512 megabytes
['data structures', 'dsu', '*2500']
J. Journeytime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputOne day, Pak Chanek who is already bored of being alone at home decided to go traveling. While looking for an appropriate place, he found that Londonesia has an interesting structure.According to the informati...
4 1 2 4 2 3 5 3 4 4
8
1 second
256 megabytes
['dp', 'trees', '*2500']
I. Imitating the Key Treetime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputPak Chanek has a tree called the key tree. This tree consists of N vertices and N-1 edges. The edges of the tree are numbered from 1 to N-1 with edge i connecting vertices U_i and V_i. Initially...
4 3 2 1 3 4 3
540
1 second
256 megabytes
['combinatorics', 'dsu', 'trees', '*2800']
H. Hot Black Hot Whitetime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputOne day, you are accepted as being Dr. Chanek's assistant. The first task given by Dr. Chanek to you is to take care and store his magical stones.Dr. Chanek has N magical stones with N being an eve...
4 4 10 9 14
0 1001
1 second
256 megabytes
['constructive algorithms', 'math', '*1800']
G. Garagetime limit per test1 secondmemory limit per test128 megabytesinputstandard inputoutputstandard outputPak Chanek plans to build a garage. He wants the garage to consist of a square and a right triangle that are arranged like the following illustration. Define a and b as the lengths of two of the sides in the r...
3
7
1 second
128 megabytes
['binary search', 'geometry', 'math', '*1500']
F. Field Photographytime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputPak Chanek is traveling to Manado. It turns out that OSN (Indonesian National Scientific Olympiad) 2019 is being held. The contestants of OSN 2019 are currently lining up in a field to be photographe...
3 1 5 10 11 8 8 2 12 5
2 3
1 second
256 megabytes
['bitmasks', 'data structures', 'sortings', '*2100']
E. Electrical Efficiencytime limit per test3 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputIn the country of Dengkleknesia, there are N factories numbered from 1 to N. Factory i has an electrical coefficient of A_i. There are also N-1 power lines with the j-th power line connecting fa...
3 1 2 3 1 2 2 3
0
3 seconds
512 megabytes
['combinatorics', 'data structures', 'dp', 'math', 'number theory', 'trees', '*2500']
D. Deducing Sortabilitytime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputLet's say Pak Chanek has an array A consisting of N positive integers. Pak Chanek will do a number of operations. In each operation, Pak Chanek will do the following: Choose an index p (1 \leq ...
6 3 1 4 5
17 1 3 4
2 seconds
512 megabytes
['binary search', 'bitmasks', 'math', '*2900']
C. Circular Mirrortime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputPak Chanek has a mirror in the shape of a circle. There are N lamps on the circumference numbered from 1 to N in clockwise order. The length of the arc from lamp i to lamp i+1 is D_i for 1 \leq i \leq ...
4 2 10 10 6 14
10
1 second
256 megabytes
['binary search', 'combinatorics', 'geometry', 'math', 'two pointers', '*2000']
B. Basketball Togethertime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputA basketball competition is held where the number of players in a team does not have a maximum or minimum limit (not necessarily 5 players in one team for each match). There are N candidate players...
6 180 90 80 70 60 50 100
2
1 second
256 megabytes
['binary search', 'greedy', 'sortings', '*1000']
A. Accumulation of Dominoestime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputPak Chanek has a grid that has N rows and M columns. Each row is numbered from 1 to N from top to bottom. Each column is numbered from 1 to M from left to right.Each tile in the grid contains ...
3 4
9
1 second
256 megabytes
['math', '*800']
G. Even-Odd XORtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputGiven an integer n, find any array a of n distinct nonnegative integers less than 2^{31} such that the bitwise XOR of the elements on odd indices equals the bitwise XOR of the elements on even indices.Inp...
7 8 3 4 5 6 7 9
4 2 1 5 0 6 7 3 2 1 3 2 1 3 0 2 0 4 5 3 4 1 2 12 3 8 1 2 3 4 5 6 7 8 2 3 7 4 0 5 6 9
1 second
256 megabytes
['bitmasks', 'constructive algorithms', 'greedy', '*1500']
F. L-shapestime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputAn L-shape is a figure on gridded paper that looks like the first four pictures below. An L-shape contains exactly three shaded cells (denoted by *), which can be rotated in any way. You are given a rectangu...
106 10........**.**......*..*..*.........**......*.....*..**....**6 10....*...**.**......*..*..*.........**......*.....*..**....**3 3...***...4 4.*..**....**..*.5 4.*..**........**..*.3 2.****.2 3*...**3 2..***.3 3.***.***.3 3..*.**..*
YES NO NO NO YES NO NO YES NO NO
1 second
256 megabytes
['dfs and similar', 'implementation', '*1700']
E. Counting Rectanglestime limit per test6 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou have n rectangles, the i-th rectangle has height h_i and width w_i.You are asked q queries of the form h_s \ w_s \ h_b \ w_b. For each query output, the total area of rectangles you own that c...
32 12 33 21 1 3 45 51 12 23 34 45 53 3 6 62 1 4 51 1 2 101 1 100 1001 1 3 33 1999 999999 999999 9981 1 1000 1000
6 41 9 0 54 4 2993004
6 seconds
256 megabytes
['brute force', 'data structures', 'dp', 'implementation', '*1600']
D. Linetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere are n people in a horizontal line, each looking either to the left or the right. Each person counts the number of people in the direction they are looking. The value of the line is the sum of each person's...
63LLR5LRRLL1L12LRRRLLLRLLRL10LLLLLRRRRR9LRLRLRLRL
3 5 5 16 16 16 16 16 0 86 95 98 101 102 102 102 102 102 102 102 102 29 38 45 52 57 62 65 68 69 70 44 50 54 56 56 56 56 56 56
2 seconds
256 megabytes
['greedy', 'sortings', '*1100']
C. Word Gametime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThree guys play a game: first, each person writes down n distinct words of length 3. Then, they total up the number of points as follows: if a word was written by one person — that person gets 3 points, i...
31abcdefabc3orz for qaqqaq orz forcod for ces5iat roc hem ica llybac ter iol ogi stsbac roc lly iol iat
1 3 1 2 2 6 9 11 5
1 second
256 megabytes
['data structures', 'implementation', '*800']
B. Colourblindnesstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputVasya has a grid with 2 rows and n columns. He colours each cell red, green, or blue.Vasya is colourblind and can't distinguish green from blue. Determine if Vasya will consider the two rows of the gri...
62RGRB4GRBGGBGB5GGGGGBBBBB7BBBBBBBRRRRRRR8RGBRRGBRRGGRRBGR1GG
YES NO YES NO YES YES
1 second
256 megabytes
['implementation', '*800']
A. Spell Checktime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputTimur likes his name. As a spelling of his name, he allows any permutation of the letters of the name. For example, the following strings are valid spellings of his name: Timur, miurT, Trumi, mriTu. Note t...
105Timur5miurT5Trumi5mriTu5timur4Timr6Timuur10codeforces10TimurTimur5TIMUR
YES YES YES YES NO NO NO NO NO NO
1 second
256 megabytes
['implementation', '*800']
F. Matching Reductiontime limit per test8 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputYou are given a bipartite graph with n_1 vertices in the first part, n_2 vertices in the second part, and m edges. The maximum matching in this graph is the maximum possible (by size) subset of edg...
3 4 4 4 2 2 1 3 2 1 3 4 1 2 1 2
1 -4 3 === 2 1 2 === 1 2 2 === 1 2
8 seconds
512 megabytes
['brute force', 'constructive algorithms', 'dfs and similar', 'flows', 'graph matchings', 'graphs', 'interactive', '*2800']
E. Prefix Function Queriestime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a string s, consisting of lowercase Latin letters.You are asked q queries about it: given another string t, consisting of lowercase Latin letters, perform the following steps: c...
aba 6 caba aba bababa aaaa b forces
0 1 2 3 1 2 3 2 3 4 5 6 7 1 1 1 1 2 0 0 0 0 0 0
2 seconds
256 megabytes
['dfs and similar', 'dp', 'hashing', 'string suffix structures', 'strings', 'trees', '*2200']
D. Maximum ANDtime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given two arrays a and b, consisting of n integers each.Let's define a function f(a, b) as follows: let's define an array c of size n, where c_i = a_i \oplus b_i (\oplus denotes bitwise XOR); t...
351 0 0 3 32 3 2 1 031 1 10 0 380 1 2 3 4 5 6 77 6 5 4 3 2 1 0
2 0 7
3 seconds
256 megabytes
['bitmasks', 'dfs and similar', 'divide and conquer', 'greedy', 'sortings', '*1800']
C. Min-Max Array Transformationtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an array a_1, a_2, \dots, a_n, which is sorted in non-descending order. You decided to perform the following steps to create array b_1, b_2, \dots, b_n: Create an array d ...
432 3 57 11 1311000500041 2 3 41 2 3 4410 20 30 4022 33 33 55
5 4 2 11 10 8 4000 4000 0 0 0 0 0 0 0 0 12 2 3 15 23 13 3 15
2 seconds
256 megabytes
['binary search', 'greedy', 'two pointers', '*1400']
B. Deadly Lasertime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe robot is placed in the top left corner of a grid, consisting of n rows and m columns, in a cell (1, 1).In one step, it can move into a cell, adjacent by a side to the current one: (x, y) \rightarro...
32 3 1 3 02 3 1 3 15 5 3 4 1
3 -1 8
2 seconds
256 megabytes
['implementation', '*1000']
A. Imagetime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputYou have an image file of size 2 \times 2, consisting of 4 pixels. Each pixel can have one of 26 different colors, denoted by lowercase Latin letters.You want to recolor some of the pixels of the image so that ...
5rbbrccwbaaaaabcdyyxx
1 2 0 3 1
2 seconds
512 megabytes
['greedy', 'implementation', '*800']
E. Misha and Paintingstime limit per test3.5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputMisha has a square n \times n matrix, where the number in row i and column j is equal to a_{i, j}. Misha wants to modify the matrix to contain exactly k distinct integers. To achieve this goal, ...
3 4 1 1 1 1 1 2 3 4 5
1
3.5 seconds
256 megabytes
['constructive algorithms', 'data structures', 'greedy', 'implementation', 'math', '*2700']
D2. Xor-Subsequence (hard version)time limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputIt is the hard version of the problem. The only difference is that in this version a_i \le 10^9.You are given an array of n integers a_0, a_1, a_2, \ldots a_{n - 1}. Bryap wants to fin...
321 255 2 4 3 1103 8 8 2 9 1 6 2 8 3
2 3 6
2 seconds
512 megabytes
['bitmasks', 'data structures', 'dp', 'strings', 'trees', '*2400']
D1. Xor-Subsequence (easy version)time limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputIt is the easy version of the problem. The only difference is that in this version a_i \le 200.You are given an array of n integers a_0, a_1, a_2, \ldots a_{n - 1}. Bryap wants to find...
321 255 2 4 3 1103 8 8 2 9 1 6 2 8 3
2 3 6
2 seconds
512 megabytes
['bitmasks', 'brute force', 'dp', 'strings', 'trees', 'two pointers', '*1800']
C. Cornerstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a matrix consisting of n rows and m columns. Each cell of this matrix contains 0 or 1.Let's call a square of size 2 \times 2 without one corner cell an L-shape figure. In one operation you can ta...
44 31011110111103 41110011101112 200002 21111
8 9 0 2
1 second
256 megabytes
['greedy', 'implementation', '*1200']
B. Interesting Sumtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an array a that contains n integers. You can choose any proper subsegment a_l, a_{l + 1}, \ldots, a_r of this array, meaning you can choose any two integers 1 \le l \le r \le n, where r -...
4 8 1 2 2 3 1 5 6 1 5 1 2 3 100 200 4 3 3 3 3 6 7 8 3 1 1 8
9 297 0 14
1 second
256 megabytes
['brute force', 'data structures', 'greedy', 'math', 'sortings', '*800']
A. Burenka Plays with Fractionstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputBurenka came to kindergarden. This kindergarten is quite strange, so each kid there receives two fractions (\frac{a}{b} and \frac{c}{d}) with integer numerators and denominators. Then chil...
82 1 1 16 3 2 11 2 2 30 1 0 1000 1 228 179100 3 25 6999999999 300000000 666666666 10000000033 15 0 84
1 0 2 0 1 1 1 1
1 second
256 megabytes
['math', 'number theory', '*900']