task
stringlengths
0
154k
__index_level_0__
int64
0
39.2k
Title: New Year and Cake Time Limit: None seconds Memory Limit: None megabytes Problem Description: Limak is a little polar bear. According to some old traditions, his bear family prepared a New Year cake. And Limak likes cakes. As you may know, a New Year cake is a strictly convex polygon with *n* vertices. Paren...
1,400
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: Once upon a time in the Kingdom of Far Far Away lived Sir Lancelot, the chief Royal General. He was very proud of his men and he liked to invite the King to come and watch drill exercises which demonstrated the fighting techniques...
1,401
Title: Robot Sequence Time Limit: None seconds Memory Limit: None megabytes Problem Description: Calvin the robot lies in an infinite rectangular grid. Calvin's source code contains a list of *n* commands, each either 'U', 'R', 'D', or 'L' — instructions to move a single square up, right, down, or left, respectively...
1,402
Title: Game on Tree Time Limit: None seconds Memory Limit: None megabytes Problem Description: Momiji has got a rooted tree, consisting of *n* nodes. The tree nodes are numbered by integers from 1 to *n*. The root has number 1. Momiji decided to play a game on this tree. The game consists of several steps. On each ...
1,403
Title: Perishable Roads Time Limit: None seconds Memory Limit: None megabytes Problem Description: In the country of Never, there are *n* cities and a well-developed road system. There is exactly one bidirectional road between every pair of cities, thus, there are as many as roads! No two roads intersect, and no ro...
1,404
Title: Mike and Cellphone Time Limit: None seconds Memory Limit: None megabytes Problem Description: While swimming at the beach, Mike has accidentally dropped his cellphone into the water. There was no worry as he bought a cheap replacement phone with an old-fashioned keyboard. The keyboard has only ten digital equ...
1,405
Title: Cactus to Tree Time Limit: None seconds Memory Limit: None megabytes Problem Description: You are given a special connected undirected graph where each vertex belongs to at most one simple cycle. Your task is to remove as many edges as needed to convert this graph into a tree (connected graph with no cycles)...
1,406
Title: Runaway to a Shadow Time Limit: None seconds Memory Limit: None megabytes Problem Description: Dima is living in a dormitory, as well as some cockroaches. At the moment 0 Dima saw a cockroach running on a table and decided to kill it. Dima needs exactly *T* seconds for aiming, and after that he will precisel...
1,407
Title: Which floor? Time Limit: None seconds Memory Limit: None megabytes Problem Description: In a building where Polycarp lives there are equal number of flats on each floor. Unfortunately, Polycarp don't remember how many flats are on each floor, but he remembers that the flats are numbered from 1 from lower to u...
1,408
Title: Appleman and a Game Time Limit: None seconds Memory Limit: None megabytes Problem Description: Appleman and Toastman like games. Today they play a game with strings with the following rules. Firstly Toastman tells Appleman two strings *s* and *t* both consisting only of letters 'A', 'B', 'C', 'D'. Then Applem...
1,409
Title: Subway Time Limit: None seconds Memory Limit: None megabytes Problem Description: A subway scheme, classic for all Berland cities is represented by a set of *n* stations connected by *n* passages, each of which connects exactly two stations and does not pass through any others. Besides, in the classic scheme ...
1,410
Title: Mashmokh and Tokens Time Limit: None seconds Memory Limit: None megabytes Problem Description: Bimokh is Mashmokh's boss. For the following *n* days he decided to pay to his workers in a new way. At the beginning of each day he will give each worker a certain amount of tokens. Then at the end of each day each...
1,411
Title: Vladik and flights Time Limit: None seconds Memory Limit: None megabytes Problem Description: Vladik is a competitive programmer. This year he is going to win the International Olympiad in Informatics. But it is not as easy as it sounds: the question Vladik face now is to find the cheapest way to get to the o...
1,412
Title: Not Wool Sequences Time Limit: None seconds Memory Limit: None megabytes Problem Description: A sequence of non-negative integers *a*1,<=*a*2,<=...,<=*a**n* of length *n* is called a wool sequence if and only if there exists two integers *l* and *r* (1<=≤<=*l*<=≤<=*r*<=≤<=*n*) such that . In other words each ...
1,413
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: You play the game with your friend. The description of this game is listed below. Your friend creates *n* distinct strings of the same length *m* and tells you all the strings. Then he randomly chooses one of them. He chooses st...
1,414
Title: Sereja and the Arrangement of Numbers Time Limit: None seconds Memory Limit: None megabytes Problem Description: Let's call an array consisting of *n* integer numbers *a*1, *a*2, ..., *a**n*, beautiful if it has the following property: - consider all pairs of numbers *x*,<=*y* (*x*<=≠<=*y*), such that numbe...
1,415
Title: TV Game Time Limit: 2 seconds Memory Limit: 256 megabytes Problem Description: There is a new TV game on BerTV. In this game two players get a number *A* consisting of 2*n* digits. Before each turn players determine who will make the next move. Each player should make exactly *n* moves. On it's turn *i*-th pl...
1,416
Title: Palindrome Degree Time Limit: 1 seconds Memory Limit: 256 megabytes Problem Description: String *s* of length *n* is called *k*-palindrome, if it is a palindrome itself, and its prefix and suffix of length are (*k*<=-<=1)-palindromes. By definition, any string (even empty) is 0-palindrome. Let's call the pa...
1,417
Title: Constructing Tests Time Limit: None seconds Memory Limit: None megabytes Problem Description: Let's denote a *m*-free matrix as a binary (that is, consisting of only 1's and 0's) matrix such that every square submatrix of size *m*<=×<=*m* of this matrix contains at least one zero. Consider the following pro...
1,418
Title: Suitable Replacement Time Limit: None seconds Memory Limit: None megabytes Problem Description: You are given two strings *s* and *t* consisting of small Latin letters, string *s* can also contain '?' characters. Suitability of string *s* is calculated by following metric: Any two letters can be swapped po...
1,419
Title: Vanya and Fence Time Limit: None seconds Memory Limit: None megabytes Problem Description: Vanya and his friends are walking along the fence of height *h* and they do not want the guard to notice them. In order to achieve this the height of each of the friends should not exceed *h*. If the height of some pers...
1,420
Title: Case of Computer Network Time Limit: None seconds Memory Limit: None megabytes Problem Description: Andrewid the Android is a galaxy-known detective. Now he is preparing a defense against a possible attack by hackers on a major computer network. In this network are *n* vertices, some pairs of vertices are co...
1,421
Title: Nastya and a Wardrobe Time Limit: None seconds Memory Limit: None megabytes Problem Description: Nastya received a gift on New Year — a magic wardrobe. It is magic because in the end of each month the number of dresses in it doubles (i.e. the number of dresses becomes twice as large as it is in the beginning ...
1,422
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: You're a mikemon breeder currently in the middle of your journey to become a mikemon master. Your current obstacle is go through the infamous Biridian Forest. The forest The Biridian Forest is a two-dimensional grid consisting o...
1,423
Title: Writing a Song Time Limit: 2 seconds Memory Limit: 256 megabytes Problem Description: One of the Hedgehog and his friend's favorite entertainments is to take some sentence or a song and replace half of the words (sometimes even all of them) with each other's names. The friend's birthday is approaching and th...
1,424
Title: Modulo Sum Time Limit: None seconds Memory Limit: None megabytes Problem Description: You are given a sequence of numbers *a*1,<=*a*2,<=...,<=*a**n*, and a number *m*. Check if it is possible to choose a non-empty subsequence *a**i**j* such that the sum of numbers in this subsequence is divisible by *m*. In...
1,425
Title: Choosing Teams Time Limit: None seconds Memory Limit: None megabytes Problem Description: The Saratov State University Olympiad Programmers Training Center (SSU OPTC) has *n* students. For each student you know the number of times he/she has participated in the ACM ICPC world programming championship. Accordi...
1,426
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: Zxr960115 is owner of a large farm. He feeds *m* cute cats and employs *p* feeders. There's a straight road across the farm and *n* hills along the road, numbered from 1 to *n* from left to right. The distance between hill *i* and...
1,427
Title: Elevator Time Limit: None seconds Memory Limit: None megabytes Problem Description: You work in a big office. It is a 9 floor building with an elevator that can accommodate up to 4 people. It is your responsibility to manage this elevator. Today you are late, so there are queues on some floors already. For e...
1,428
Title: Pattern Time Limit: None seconds Memory Limit: None megabytes Problem Description: Developers often face with regular expression patterns. A pattern is usually defined as a string consisting of characters and metacharacters that sets the rules for your search. These patterns are most often used to check wheth...
1,429
Title: Sale Time Limit: 2 seconds Memory Limit: 256 megabytes Problem Description: Once Bob got to a sale of old TV sets. There were *n* TV sets at that sale. TV set with index *i* costs *a**i* bellars. Some TV sets have a negative price — their owners are ready to pay Bob if he buys their useless apparatus. Bob can...
1,430
Title: PolandBall and Polygon Time Limit: None seconds Memory Limit: None megabytes Problem Description: PolandBall has such a convex polygon with *n* veritces that no three of its diagonals intersect at the same point. PolandBall decided to improve it and draw some red segments. He chose a number *k* such that *g...
1,431
Title: Psychos in a Line Time Limit: None seconds Memory Limit: None megabytes Problem Description: There are *n* psychos standing in a line. Each psycho is assigned a unique integer from 1 to *n*. At each step every psycho who has an id greater than the psycho to his right (if exists) kills his right neighbor in th...
1,432
Title: Sasha and Sticks Time Limit: None seconds Memory Limit: None megabytes Problem Description: It's one more school day now. Sasha doesn't like classes and is always bored at them. So, each day he invents some game and plays in it alone or with friends. Today he invented one simple game to play with Lena, with ...
1,433
Title: Put Knight! Time Limit: None seconds Memory Limit: None megabytes Problem Description: Petya and Gena play a very interesting game "Put a Knight!" on a chessboard *n*<=×<=*n* in size. In this game they take turns to put chess pieces called "knights" on the board so that no two knights could threat each other....
1,434
Title: Interestring graph and Apples Time Limit: 1 seconds Memory Limit: 64 megabytes Problem Description: Hexadecimal likes drawing. She has drawn many graphs already, both directed and not. Recently she has started to work on a still-life «interesting graph and apples». An undirected graph is called interesting, i...
1,435
Title: Flow Control Time Limit: None seconds Memory Limit: None megabytes Problem Description: You have to handle a very complex water distribution system. The system consists of $n$ junctions and $m$ pipes, $i$-th pipe connects junctions $x_i$ and $y_i$. The only thing you can do is adjusting the pipes. You have t...
1,436
Title: Need For Brake Time Limit: 4 seconds Memory Limit: 256 megabytes Problem Description: Vasya plays the Need For Brake. He plays because he was presented with a new computer wheel for birthday! Now he is sure that he will win the first place in the championship in his favourite racing computer game! *n* racer...
1,437
Title: Secrets Time Limit: None seconds Memory Limit: None megabytes Problem Description: Gerald has been selling state secrets at leisure. All the secrets cost the same: *n* marks. The state which secrets Gerald is selling, has no paper money, only coins. But there are coins of all positive integer denominations th...
1,438
Title: Binary Tree on Plane Time Limit: None seconds Memory Limit: None megabytes Problem Description: A root tree is a directed acyclic graph that contains one node (root), from which there is exactly one path to any other node. A root tree is binary if each node has at most two outgoing arcs. When a binary tree ...
1,439
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: The Little Elephant has two permutations *a* and *b* of length *n*, consisting of numbers from 1 to *n*, inclusive. Let's denote the *i*-th (1<=≤<=*i*<=≤<=*n*) element of the permutation *a* as *a**i*, the *j*-th (1<=≤<=*j*<=≤<=*n...
1,440
Title: Vladik and chat Time Limit: None seconds Memory Limit: None megabytes Problem Description: Recently Vladik discovered a new entertainment — coding bots for social networks. He would like to use machine learning in his bots so now he want to prepare some learning data for them. At first, he need to download *...
1,441
Title: Music in Car Time Limit: None seconds Memory Limit: None megabytes Problem Description: Sasha reaches the work by car. It takes exactly *k* minutes. On his way he listens to music. All songs in his playlist go one by one, after listening to the *i*-th song Sasha gets a pleasure which equals *a**i*. The *i*-th...
1,442
Title: Caisa and Pylons Time Limit: None seconds Memory Limit: None megabytes Problem Description: Caisa solved the problem with the sugar and now he is on the way back to home. Caisa is playing a mobile game during his path. There are (*n*<=+<=1) pylons numbered from 0 to *n* in this game. The pylon with number 0...
1,443
Title: Playing with Paper Time Limit: None seconds Memory Limit: None megabytes Problem Description: One day Vasya was sitting on a not so interesting Maths lesson and making an origami from a rectangular *a* mm <=×<= *b* mm sheet of paper (*a*<=&gt;<=*b*). Usually the first step in making an origami is making a squ...
1,444
Title: Professor GukiZ's Robot Time Limit: None seconds Memory Limit: None megabytes Problem Description: Professor GukiZ makes a new robot. The robot are in the point with coordinates (*x*1,<=*y*1) and should go to the point (*x*2,<=*y*2). In a single step the robot can change any of its coordinates (maybe both of ...
1,445
Title: Little Robber Girl's Zoo Time Limit: None seconds Memory Limit: None megabytes Problem Description: Little Robber Girl likes to scare animals in her zoo for fun. She decided to arrange the animals in a row in the order of non-decreasing height. However, the animals were so scared that they couldn't stay in th...
1,446
Title: IQ Test Time Limit: None seconds Memory Limit: None megabytes Problem Description: Petya is preparing for IQ test and he has noticed that there many problems like: you are given a sequence, find the next number. Now Petya can solve only problems with arithmetic or geometric progressions. Arithmetic progressi...
1,447
Title: Good Subsegments Time Limit: None seconds Memory Limit: None megabytes Problem Description: A permutation $p$ of length $n$ is a sequence $p_1, p_2, \ldots, p_n$ consisting of $n$ distinct integers, each of which from $1$ to $n$ ($1 \leq p_i \leq n$) . Let's call the subsegment $[l,r]$ of the permutation goo...
1,448
Title: Civilization Time Limit: None seconds Memory Limit: None megabytes Problem Description: Andrew plays a game called "Civilization". Dima helps him. The game has *n* cities and *m* bidirectional roads. The cities are numbered from 1 to *n*. Between any pair of cities there either is a single (unique) path, or ...
1,449
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: Arkady needs your help again! This time he decided to build his own high-speed Internet exchange point. It should consist of *n* nodes connected with minimum possible number of wires into one network (a wire directly connects two ...
1,450
Title: Breaking Good Time Limit: None seconds Memory Limit: None megabytes Problem Description: Breaking Good is a new video game which a lot of gamers want to have. There is a certain level in the game that is really difficult even for experienced gamers. Walter William, the main character of the game, wants to jo...
1,451
Title: Tavas on the Path Time Limit: None seconds Memory Limit: None megabytes Problem Description: Tavas lives in Tavaspolis. Tavaspolis has *n* cities numbered from 1 to *n* connected by *n*<=-<=1 bidirectional roads. There exists a path between any two cities. Also each road has a length. Tavas' favorite strings...
1,452
Title: Duff and Weight Lifting Time Limit: None seconds Memory Limit: None megabytes Problem Description: Recently, Duff has been practicing weight lifting. As a hard practice, Malek gave her a task. He gave her a sequence of weights. Weight of *i*-th of them is 2*w**i* pounds. In each step, Duff can lift some of th...
1,453
Title: Stripe 2 Time Limit: 1 seconds Memory Limit: 64 megabytes Problem Description: Once Bob took a paper stripe of n squares (the height of the stripe is 1 square). In each square he wrote an integer number, possibly negative. He became interested in how many ways exist to cut this stripe into three pieces so tha...
1,454
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: You are given a matrix consisting of digits zero and one, its size is *n*<=×<=*m*. You are allowed to rearrange its rows. What is the maximum area of the submatrix that only consists of ones and can be obtained in the given proble...
1,455
Title: Crosses Time Limit: None seconds Memory Limit: None megabytes Problem Description: There is a board with a grid consisting of *n* rows and *m* columns, the rows are numbered from 1 from top to bottom and the columns are numbered from 1 from left to right. In this grid we will denote the cell that lies on row ...
1,456
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: A year ago on the bench in public park Leha found an array of *n* numbers. Leha believes that permutation *p* is right if for all 1<=≤<=*i*<=&lt;<=*n* condition, that *a**p**i*·*a**p**i*<=+<=1 is not perfect square, holds. Leha wa...
1,457
Title: Chat Time Limit: None seconds Memory Limit: None megabytes Problem Description: There are times you recall a good old friend and everything you've come through together. Luckily there are social networks — they store all your message history making it easy to know what you argued over 10 years ago. More form...
1,458
Title: Superior Periodic Subarrays Time Limit: None seconds Memory Limit: None megabytes Problem Description: You are given an infinite periodic array *a*0,<=*a*1,<=...,<=*a**n*<=-<=1,<=... with the period of length *n*. Formally, . A periodic subarray (*l*,<=*s*) (0<=≤<=*l*<=&lt;<=*n*, 1<=≤<=*s*<=&lt;<=*n*) of arra...
1,459
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: Fox Ciel is playing a card game with her friend Fox Jiro. There are *n* piles of cards on the table. And there is a positive integer on each card. The players take turns and Ciel takes the first turn. In Ciel's turn she takes a c...
1,460
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: Little Artyom decided to study probability theory. He found a book with a lot of nice exercises and now wants you to help him with one of them. Consider two dices. When thrown each dice shows some integer from 1 to *n* inclusive....
1,461
Title: World Eater Brothers Time Limit: None seconds Memory Limit: None megabytes Problem Description: You must have heard of the two brothers dreaming of ruling the world. With all their previous plans failed, this time they decided to cooperate with each other in order to rule the world. As you know there are *n...
1,462
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: Andrey needs one more problem to conduct a programming contest. He has *n* friends who are always willing to help. He can ask some of them to come up with a contest problem. Andrey knows one value for each of his fiends — the prob...
1,463
Title: Chess Championship Time Limit: None seconds Memory Limit: None megabytes Problem Description: Ostap is preparing to play chess again and this time he is about to prepare. Thus, he was closely monitoring one recent chess tournament. There were *m* players participating and each pair of players played exactly o...
1,464
Title: Permute Digits Time Limit: None seconds Memory Limit: None megabytes Problem Description: You are given two positive integer numbers *a* and *b*. Permute (change order) of the digits of *a* to construct maximal number not exceeding *b*. No number in input and/or output can start with the digit 0. It is allow...
1,465
Title: A Mist of Florescence Time Limit: None seconds Memory Limit: None megabytes Problem Description: "I've been here once," Mino exclaims with delight, "it's breathtakingly amazing." "What is it like?" "Look, Kanno, you've got your paintbrush, and I've got my words. Have a try, shall we?" There are four kinds...
1,466
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: As we all know, Dart is some kind of creature from Upside Down world. For simplicity, we call their kind pollywogs. Dart and *x*<=-<=1 other pollywogs are playing a game. There are *n* stones in a row, numbered from 1 through *n* ...
1,467
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: There is a straight line colored in white. *n* black segments are added on it one by one. After each segment is added, determine the number of connected components of black segments (i. e. the number of black segments in the unio...
1,468
Title: Sequence of Balls Time Limit: 1 seconds Memory Limit: 256 megabytes Problem Description: You are given a sequence of balls *A* by your teacher, each labeled with a lowercase Latin letter 'a'-'z'. You don't like the given sequence. You want to change it into a new sequence, *B* that suits you better. So, you a...
1,469
Title: Cactus Time Limit: None seconds Memory Limit: None megabytes Problem Description: A connected undirected graph is called a vertex cactus, if each vertex of this graph belongs to at most one simple cycle. A simple cycle in a undirected graph is a sequence of distinct vertices *v*1,<=*v*2,<=...,<=*v**t* (*t*<=...
1,470
Title: Perun, Ult! Time Limit: None seconds Memory Limit: None megabytes Problem Description: A lot of students spend their winter holidays productively. Vlad has advanced very well in doing so! For three days already, fueled by salads and tangerines — the leftovers from New Year celebration — he has been calibratin...
1,471
Title: Substitutes in Number Time Limit: None seconds Memory Limit: None megabytes Problem Description: Andrew and Eugene are playing a game. Initially, Andrew has string *s*, consisting of digits. Eugene sends Andrew multiple queries of type "*d**i*<=→<=*t**i*", that means "replace all digits *d**i* in string *s* w...
1,472
Title: Soldier and Bananas Time Limit: None seconds Memory Limit: None megabytes Problem Description: A soldier wants to buy *w* bananas in the shop. He has to pay *k* dollars for the first banana, 2*k* dollars for the second one and so on (in other words, he has to pay *i*·*k* dollars for the *i*-th banana). He h...
1,473
Title: Birthday Time Limit: None seconds Memory Limit: None megabytes Problem Description: A MIPT student named Misha has a birthday today, and he decided to celebrate it in his country house in suburban Moscow. *n* friends came by, and after a typical party they decided to play blind man's buff. The birthday boy g...
1,474
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: While resting on the ship after the "Russian Code Cup" a boy named Misha invented an interesting game. He promised to give his quadrocopter to whoever will be the first one to make a rectangular table of size *n*<=×<=*m*, consisti...
1,475
Title: Little Elephant and Chess Time Limit: None seconds Memory Limit: None megabytes Problem Description: The Little Elephant loves chess very much. One day the Little Elephant and his friend decided to play chess. They've got the chess pieces but the board is a problem. They've got an 8<=×<=8 checkered board, e...
1,476
Title: Cinema Line Time Limit: None seconds Memory Limit: None megabytes Problem Description: The new "Die Hard" movie has just been released! There are *n* people at the cinema box office standing in a huge line. Each of them has a single 100, 50 or 25 ruble bill. A "Die Hard" ticket costs 25 rubles. Can the bookin...
1,477
Title: Hard Process Time Limit: None seconds Memory Limit: None megabytes Problem Description: You are given an array *a* with *n* elements. Each element of *a* is either 0 or 1. Let's denote the length of the longest subsegment of consecutive elements in *a*, consisting of only numbers one, as *f*(*a*). You can ch...
1,478
Title: Anton and Polyhedrons Time Limit: None seconds Memory Limit: None megabytes Problem Description: Anton's favourite geometric figures are regular polyhedrons. Note that there are five kinds of regular polyhedrons: - Tetrahedron. Tetrahedron has 4 triangular faces. - Cube. Cube has 6 square faces. - Octahe...
1,479
Title: George and Accommodation Time Limit: None seconds Memory Limit: None megabytes Problem Description: George has recently entered the BSUCP (Berland State University for Cool Programmers). George has a friend Alex who has also entered the university. Now they are moving into a dormitory. George and Alex want ...
1,480
Title: A Prosperous Lot Time Limit: None seconds Memory Limit: None megabytes Problem Description: Apart from Nian, there is a daemon named Sui, which terrifies children and causes them to become sick. Parents give their children money wrapped in red packets and put them under the pillow, so that when Sui tries to a...
1,481
Title: Mr. Kitayuta's Gift Time Limit: None seconds Memory Limit: None megabytes Problem Description: Mr. Kitayuta has kindly given you a string *s* consisting of lowercase English letters. You are asked to insert exactly one lowercase English letter into *s* to make it a palindrome. A palindrome is a string that re...
1,482
Title: Pyramid of Glasses Time Limit: None seconds Memory Limit: None megabytes Problem Description: Mary has just graduated from one well-known University and is now attending celebration party. Students like to dream of a beautiful life, so they used champagne glasses to construct a small pyramid. The height of th...
1,483
Title: Bus of Characters Time Limit: None seconds Memory Limit: None megabytes Problem Description: In the Bus of Characters there are $n$ rows of seat, each having $2$ seats. The width of both seats in the $i$-th row is $w_i$ centimeters. All integers $w_i$ are distinct. Initially the bus is empty. On each of $2n$...
1,484
Title: Pastoral Oddities Time Limit: None seconds Memory Limit: None megabytes Problem Description: In the land of Bovinia there are *n* pastures, but no paths connecting the pastures. Of course, this is a terrible situation, so Kevin Sun is planning to rectify it by constructing *m* undirected paths connecting pair...
1,485
Title: Numbers Time Limit: 3 seconds Memory Limit: 256 megabytes Problem Description: One quite ordinary day Valera went to school (there's nowhere else he should go on a week day). In a maths lesson his favorite teacher Ms. Evans told students about divisors. Despite the fact that Valera loved math, he didn't find ...
1,486
Title: Broken Clock Time Limit: None seconds Memory Limit: None megabytes Problem Description: You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format hours change from 1 to 12, while in 24-hours it changes from 0 to 23. In both formats minutes cha...
1,487
Title: Cupboard and Balloons Time Limit: None seconds Memory Limit: None megabytes Problem Description: A girl named Xenia has a cupboard that looks like an arc from ahead. The arc is made of a semicircle with radius *r* (the cupboard's top) and two walls of height *h* (the cupboard's sides). The cupboard's depth is...
1,488
Title: Stepan and Vowels Time Limit: None seconds Memory Limit: None megabytes Problem Description: Stepan likes to repeat vowel letters when he writes words. For example, instead of the word "pobeda" he can write "pobeeeedaaaaa". Sergey does not like such behavior, so he wants to write a program to format the word...
1,489
Title: Help Far Away Kingdom Time Limit: 2 seconds Memory Limit: 256 megabytes Problem Description: In a far away kingdom lived the King, the Prince, the Shoemaker, the Dressmaker and many other citizens. They lived happily until great trouble came into the Kingdom. The ACMers settled there. Most damage those stran...
1,490
Title: Martian Clock Time Limit: None seconds Memory Limit: None megabytes Problem Description: Having stayed home alone, Petya decided to watch forbidden films on the Net in secret. "What ungentlemanly behavior!" — you can say that, of course, but don't be too harsh on the kid. In his country films about the Martia...
1,491
Title: Gennady the Dentist Time Limit: None seconds Memory Limit: None megabytes Problem Description: Gennady is one of the best child dentists in Berland. Today *n* children got an appointment with him, they lined up in front of his office. All children love to cry loudly at the reception at the dentist. We enumer...
1,492
Title: Eleventh Birthday Time Limit: None seconds Memory Limit: None megabytes Problem Description: It is Borya's eleventh birthday, and he has got a great present: *n* cards with numbers. The *i*-th card has the number *a**i* written on it. Borya wants to put his cards in a row to get one greater number. For exampl...
1,493
Title: Dima and Game Time Limit: None seconds Memory Limit: None megabytes Problem Description: Dima and Anya love playing different games. Now Dima has imagined a new game that he wants to play with Anya. Dima writes *n* pairs of integers on a piece of paper (*l**i*,<=*r**i*) (1<=≤<=*l**i*<=&lt;<=*r**i*<=≤<=*p*). ...
1,494
Title: Far Relative’s Birthday Cake Time Limit: None seconds Memory Limit: None megabytes Problem Description: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird! The cake is a *n*<=×<=*n* square consisting of equal squares with s...
1,495
Title: Room Leader Time Limit: 2 seconds Memory Limit: 256 megabytes Problem Description: Let us remind you part of the rules of Codeforces. The given rules slightly simplified, use the problem statement as a formal document. In the beginning of the round the contestants are divided into rooms. Each room contains e...
1,496
Title: Young Photographer Time Limit: 2 seconds Memory Limit: 64 megabytes Problem Description: Among other things, Bob is keen on photography. Especially he likes to take pictures of sportsmen. That was the reason why he placed himself in position *x*0 of a long straight racetrack and got ready to take pictures. Bu...
1,497
Title: Help Chef Gerasim Time Limit: 0 seconds Memory Limit: 256 megabytes Problem Description: In a far away kingdom young pages help to set the table for the King. As they are terribly mischievous, one needs to keep an eye on the control whether they have set everything correctly. This time the royal chef Gerasim ...
1,498
Title: Mahmoud and Ehab and the bipartiteness Time Limit: None seconds Memory Limit: None megabytes Problem Description: Mahmoud and Ehab continue their adventures! As everybody in the evil land knows, Dr. Evil likes bipartite graphs, especially trees. A tree is a connected acyclic graph. A bipartite graph is a gra...
1,499