
Month: May 2020


University Classes
There are n student groups at the university. During the study day, each group can take no more than 7 classes. Seven time slots numbered from 1 to 7 are allocated for the […]

Weather Tomorrow
Vasya came up with his own weather forecasting method. He knows the information about the average air temperature for each of the last n days. Assume that […]

Union of Doubly Linked Lists
Doubly linked list is one of the fundamental data structures. A doubly linked list is a sequence of elements, each containing information about the previous […]

Preparing for Merge Sort
Ivan has an array consisting of n different integers. He decided to reorder all elements in increasing order. Ivan loves merge sort so he decided to represent […]

Load Testing
Polycarp plans to conduct a load testing of its new project Fakebook. He already agreed with his friends that at certain points in time they […]

Sum of Nestings
Recall that the bracket sequence is considered regular if it is possible to insert symbols ‘+’ and ‘1’ into it so that the result is […]

Noise Level
The Berland’s capital has the form of a rectangle with sizes n × m quarters. All quarters are divided into three types: regular (labeled with the character ‘.’) — […]

Berland Elections
The elections to Berland parliament are happening today. Voting is in full swing! Totally there are n candidates, they are numbered from 1 to n. Based on election results k (1 ≤ k ≤ n) top […]

Berland SU Computer Network
In the computer network of the Berland State University there are n routers numbered from 1 to n. Some pairs of routers are connected by patch cords. Information can be […]

Travel Cards
In the evening Polycarp decided to analyze his today’s travel expenses on public transport. The bus system in the capital of Berland is arranged in […]

Students Initiation
Soon the first year students will be initiated into students at the University of Berland. The organizers of the initiation come up with a program […]

Tom Riddle’s Diary
Harry Potter is on a mission to destroy You-Know-Who’s Horcruxes. The first Horcrux that he encountered in the Chamber of Secrets is Tom Riddle’s diary. […]

Marvolo Gaunt’s Ring
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo […]

Salazar Slytherin’s Locket
Harry came to know from Dumbledore that Salazar Slytherin’s locket is a horcrux. This locket was present earlier at 12 Grimmauld Place, the home of […]

Helga Hufflepuff’s Cup
Harry, Ron and Hermione have figured out that Helga Hufflepuff’s cup is a horcrux. Through her encounter with Bellatrix Lestrange, Hermione came to know that […]


Rowena Ravenclaw’s Diadem
Harry, upon inquiring Helena Ravenclaw’s ghost, came to know that she told Tom Riddle or You-know-who about Rowena Ravenclaw’s diadem and that he stole it […]

Desk Disorder
A new set of desks just arrived, and it’s about time! Things were getting quite cramped in the office. You’ve been put in charge of […]

Save the problem
Attention: we lost all the test cases for this problem, so instead of solving the problem, we need you to generate test cases. We’re going […]