task
stringlengths
0
154k
__index_level_0__
int64
0
39.2k
Title: Coprime Arrays Time Limit: None seconds Memory Limit: None megabytes Problem Description: Let's call an array *a* of size *n* coprime iff *gcd*(*a*1,<=*a*2,<=...,<=*a**n*)<==<=1, where *gcd* is the greatest common divisor of the arguments. You are given two numbers *n* and *k*. For each *i* (1<=≀<=*i*<=≀<=*k...
4,200
Title: Hitchhiking in the Baltic States Time Limit: None seconds Memory Limit: None megabytes Problem Description: Leha and Noora decided to go on a trip in the Baltic States. As you know from the previous problem, Leha has lost his car on the parking of the restaurant. Unfortunately, requests to the watchman didn't...
4,201
Title: The Labyrinth Time Limit: None seconds Memory Limit: None megabytes Problem Description: You are given a rectangular field of *n*<=Γ—<=*m* cells. Each cell is either empty or impassable (contains an obstacle). Empty cells are marked with '.', impassable cells are marked with '*'. Let's call two empty cells adj...
4,202
Title: A and B and Interesting Substrings Time Limit: None seconds Memory Limit: None megabytes Problem Description: A and B are preparing themselves for programming contests. After several years of doing sports programming and solving many problems that require calculating all sorts of abstract objects, A and B al...
4,203
Title: Beautiful IP Addresses Time Limit: None seconds Memory Limit: None megabytes Problem Description: The problem uses a simplified TCP/IP address model, please read the statement carefully. An IP address is a 32-bit integer, represented as a group of four decimal 8-bit integers (without leading zeroes), separat...
4,204
Title: Pineapple Incident Time Limit: None seconds Memory Limit: None megabytes Problem Description: Ted has a pineapple. This pineapple is able to bark like a bulldog! At time *t* (in seconds) it barks for the first time. Then every *s* seconds after it, it barks twice with 1 second interval. Thus it barks at times...
4,205
Title: Dima and Horses Time Limit: None seconds Memory Limit: None megabytes Problem Description: Dima came to the horse land. There are *n* horses living in the land. Each horse in the horse land has several enemies (enmity is a symmetric relationship). The horse land isn't very hostile, so the number of enemies of...
4,206
Title: Harry Potter and Three Spells Time Limit: 2 seconds Memory Limit: 256 megabytes Problem Description: 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...
4,207
Title: String Typing Time Limit: None seconds Memory Limit: None megabytes Problem Description: You are given a string *s* consisting of *n* lowercase Latin letters. You have to type this string using your keyboard. Initially, you have an empty string. Until you type the whole string, you may perform the following ...
4,208
Title: Diagonal Walking Time Limit: None seconds Memory Limit: None megabytes Problem Description: Mikhail walks on a 2D plane. He can go either up or right. You are given a sequence of Mikhail's moves. He thinks that this sequence is too long and he wants to make it as short as possible. In the given sequence movi...
4,209
Title: Tree Time Limit: None seconds Memory Limit: None megabytes Problem Description: Little X has a tree consisting of *n* nodes (they are numbered from 1 to *n*). Each edge of the tree has a positive length. Let's define the distance between two nodes *v* and *u* (we'll denote it *d*(*v*,<=*u*)) as the sum of the...
4,210
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: The mobile application store has a new game called "Subway Roller". The protagonist of the game Philip is located in one end of the tunnel and wants to get out of the other one. The tunnel is a rectangular field consisting of thr...
4,211
Title: Squares and not squares Time Limit: None seconds Memory Limit: None megabytes Problem Description: Ann and Borya have *n* piles with candies and *n* is even number. There are *a**i* candies in pile with number *i*. Ann likes numbers which are square of some integer and Borya doesn't like numbers which are sq...
4,212
Title: A and B and Compilation Errors Time Limit: None seconds Memory Limit: None megabytes Problem Description: A and B are preparing themselves for programming contests. B loves to debug his code. But before he runs the solution and starts debugging, he has to first compile the code. Initially, the compiler disp...
4,213
Title: Hellish Constraints Time Limit: None seconds Memory Limit: None megabytes Problem Description: Katya recently started to invent programming tasks and prepare her own contests. What she does not like is boring and simple constraints. Katya is fed up with all those "*N* does not exceed a thousand" and "the sum ...
4,214
Title: Meeting Time Limit: None seconds Memory Limit: None megabytes Problem Description: The Super Duper Secret Meeting of the Super Duper Secret Military Squad takes place in a Super Duper Secret Place. The place is an infinite plane with introduced Cartesian coordinate system. The meeting table is represented as ...
4,215
Title: I_love_\%username\% Time Limit: None seconds Memory Limit: None megabytes Problem Description: Vasya adores sport programming. He can't write programs but he loves to watch the contests' progress. Vasya even has a favorite coder and Vasya pays special attention to him. One day Vasya decided to collect the re...
4,216
Title: Primes or Palindromes? Time Limit: None seconds Memory Limit: None megabytes Problem Description: 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 nu...
4,217
Title: Developing Game Time Limit: None seconds Memory Limit: None megabytes Problem Description: Pavel is going to make a game of his dream. However, he knows that he can't make it on his own so he founded a development company and hired *n* workers of staff. Now he wants to pick *n* workers from the staff who will...
4,218
Title: Stairs and Lines Time Limit: None seconds Memory Limit: None megabytes Problem Description: You are given a figure on a grid representing stairs consisting of 7 steps. The width of the stair on height *i* is *w**i* squares. Formally, the figure is created by consecutively joining rectangles of size *w**i*<=Γ—<...
4,219
Title: Watchmen Time Limit: None seconds Memory Limit: None megabytes Problem Description: Watchmen are in a danger and Doctor Manhattan together with his friend Daniel Dreiberg should warn them as soon as possible. There are *n* watchmen on a plane, the *i*-th watchman is located at point (*x**i*,<=*y**i*). They n...
4,220
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: You are given an *n*<=Γ—<=*m* rectangular table consisting of lower case English letters. In one operation you can completely remove one column from the table. The remaining parts are combined forming a new table. For example, afte...
4,221
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: As we all know, Max is the best video game player among her friends. Her friends were so jealous of hers, that they created an actual game just to prove that she's not the best at games. The game is played on a directed acyclic gr...
4,222
Title: Weakness and Poorness Time Limit: None seconds Memory Limit: None megabytes Problem Description: You are given a sequence of n integers *a*1,<=*a*2,<=...,<=*a**n*. Determine a real number *x* such that the weakness of the sequence *a*1<=-<=*x*,<=*a*2<=-<=*x*,<=...,<=*a**n*<=-<=*x* is as small as possible. ...
4,223
Title: World of Tank Time Limit: None seconds Memory Limit: None megabytes Problem Description: Vitya loves programming and problem solving, but sometimes, to distract himself a little, he plays computer games. Once he found a new interesting game about tanks, and he liked it so much that he went through almost all ...
4,224
Title: Gifts by the List Time Limit: None seconds Memory Limit: None megabytes Problem Description: Sasha lives in a big happy family. At the Man's Day all the men of the family gather to celebrate it following their own traditions. There are *n* men in Sasha's family, so let's number them with integers from 1 to *n...
4,225
Title: none 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 that ...
4,226
Title: Little Artem and Random Variable 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 inte...
4,227
Title: Fractal Time Limit: 2 seconds Memory Limit: 64 megabytes Problem Description: Ever since Kalevitch, a famous Berland abstractionist, heard of fractals, he made them the main topic of his canvases. Every morning the artist takes a piece of graph paper and starts with making a model of his future canvas. He tak...
4,228
Title: Theatre Square Time Limit: 1 seconds Memory Limit: 256 megabytes Problem Description: Theatre Square in the capital city of Berland has a rectangular shape with the size *n*<=Γ—<=*m* meters. On the occasion of the city's anniversary, a decision was taken to pave the Square with square granite flagstones. Each ...
4,229
Title: Anton and Digits Time Limit: None seconds Memory Limit: None megabytes Problem Description: Recently Anton found a box with digits in his room. There are *k*2 digits 2, *k*3 digits 3, *k*5 digits 5 and *k*6 digits 6. Anton's favorite integers are 32 and 256. He decided to compose this integers from digits he...
4,230
Title: Cardiogram Time Limit: None seconds Memory Limit: None megabytes Problem Description: In this problem, your task is to use ASCII graphics to paint a cardiogram. A cardiogram is a polyline with the following corners: That is, a cardiogram is fully defined by a sequence of positive integers *a*1,<=*a*2,<=......
4,231
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: Karen has just arrived at school, and she has a math test today! The test is about basic addition and subtraction. Unfortunately, the teachers were too busy writing tasks for Codeforces rounds, and had no time to make an actual t...
4,232
Title: Special Graph Time Limit: None seconds Memory Limit: None megabytes Problem Description: In this problem you will need to deal with an *n*<=Γ—<=*m* grid graph. The graph's vertices are the nodes of the *n*<=Γ—<=*m* grid. The graph's edges are all the sides and diagonals of the grid's unit squares. The figure b...
4,233
Title: Team Arrangement Time Limit: 3 seconds Memory Limit: 256 megabytes Problem Description: Recently personal training sessions have finished in the Berland State University Olympiad Programmer Training Centre. By the results of these training sessions teams are composed for the oncoming team contest season. Each...
4,234
Title: Help King Time Limit: 2 seconds Memory Limit: 256 megabytes Problem Description: This is the modification of the problem used during the official round. Unfortunately, author's solution of the original problem appeared wrong, so the problem was changed specially for the archive. Once upon a time in a far awa...
4,235
Title: More Cowbell Time Limit: None seconds Memory Limit: None megabytes Problem Description: Kevin Sun wants to move his precious collection of *n* cowbells from Naperthrill to Exeter, where there is actually grass instead of corn. Before moving, he must pack his cowbells into *k* boxes of a fixed size. In order t...
4,236
Title: BerOS file system Time Limit: 2 seconds Memory Limit: 64 megabytes Problem Description: 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/n...
4,237
Title: Yaroslav and Divisors Time Limit: None seconds Memory Limit: None megabytes Problem Description: Yaroslav has an array *p*<==<=*p*1,<=*p*2,<=...,<=*p**n* (1<=≀<=*p**i*<=≀<=*n*), consisting of *n* distinct integers. Also, he has *m* queries: - Query number *i* is represented as a pair of integers *l**i*, *r*...
4,238
Title: Labyrinth-5 Time Limit: None seconds Memory Limit: None megabytes Problem Description: See the problem statement here: [http://codeforces.com/contest/921/problem/01](//codeforces.com/contest/921/problem/01). Input Specification: none Output Specification: none Note: none
4,239
Title: Xor-MST Time Limit: None seconds Memory Limit: None megabytes Problem Description: You are given a complete undirected graph with *n* vertices. A number *a**i* is assigned to each vertex, and the weight of an edge between vertices *i* and *j* is equal to *a**i*<=*xor*<=*a**j*. Calculate the weight of the min...
4,240
Title: Strange Game On Matrix Time Limit: None seconds Memory Limit: None megabytes Problem Description: Ivan is playing a strange game. He has a matrix *a* with *n* rows and *m* columns. Each element of the matrix is equal to either 0 or 1. Rows and columns are 1-indexed. Ivan can replace any number of ones in thi...
4,241
Title: Party Time Limit: None seconds Memory Limit: None megabytes Problem Description: Note the unusual memory limit for the problem. People working in MDCS (Microsoft Development Center Serbia) like partying. They usually go to night clubs on Friday and Saturday. There are *N* people working in MDCS and there ar...
4,242
Title: Discounts Time Limit: None seconds Memory Limit: None megabytes Problem Description: One day Polycarpus stopped by a supermarket on his way home. It turns out that the supermarket is having a special offer for stools. The offer is as follows: if a customer's shopping cart contains at least one stool, the cust...
4,243
Title: Bear and Forgotten Tree 3 Time Limit: None seconds Memory Limit: None megabytes Problem Description: A tree is a connected undirected graph consisting of *n* vertices and *n*<=<=-<=<=1 edges. Vertices are numbered 1 through *n*. Limak is a little polar bear and Radewoosh is his evil enemy. Limak once had a t...
4,244
Title: Mahmoud and Ehab and the wrong algorithm Time Limit: None seconds Memory Limit: None megabytes Problem Description: Mahmoud was trying to solve the vertex cover problem on trees. The problem statement is: Given an undirected tree consisting of *n* nodes, find the minimum number of vertices that cover all the...
4,245
Title: Suggested Friends Time Limit: None seconds Memory Limit: None megabytes Problem Description: Polycarpus works as a programmer in a start-up social network. His boss gave his a task to develop a mechanism for determining suggested friends. Polycarpus thought much about the task and came to the folowing conclus...
4,246
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: You are given a connected weighted graph with *n* vertices and *m* edges. The graph doesn't contain loops nor multiple edges. Consider some edge with id *i*. Let's determine for this edge the maximum integer weight we can give to ...
4,247
Title: Maze Time Limit: None seconds Memory Limit: None megabytes Problem Description: A maze is represented by a tree (an undirected graph, where exactly one way exists between each pair of vertices). In the maze the entrance vertex and the exit vertex are chosen with some probability. The exit from the maze is sou...
4,248
Title: Kids' Riddle Time Limit: None seconds Memory Limit: None megabytes Problem Description: Programmers' kids solve this riddle in 5-10 minutes. How fast can you do it? Input Specification: The input contains a single integer *n* (0<=≀<=*n*<=≀<=2000000000). Output Specification: Output a single integer. Demo I...
4,249
Title: Tournament-graph Time Limit: None seconds Memory Limit: None megabytes Problem Description: In this problem you have to build tournament graph, consisting of *n* vertices, such, that for any oriented pair of vertices (*v*,<=*u*) (*v*<=β‰ <=*u*) there exists a path from vertex *v* to vertex *u* consisting of no ...
4,250
Title: Blood Cousins Time Limit: None seconds Memory Limit: None megabytes Problem Description: Polycarpus got hold of a family relationship tree. The tree describes family relationships of *n* people, numbered 1 through *n*. Each person in the tree has no more than one parent. Let's call person *a* a 1-ancestor of...
4,251
Title: Little Pony and Crystal Mine Time Limit: None seconds Memory Limit: None megabytes Problem Description: Twilight Sparkle once got a crystal from the Crystal Mine. A crystal of size *n* (*n* is odd; *n*<=&gt;<=1) is an *n*<=Γ—<=*n* matrix with a diamond inscribed into it. You are given an odd integer *n*. You ...
4,252
Title: Arrays Time Limit: None seconds Memory Limit: None megabytes Problem Description: You are given two arrays *A* and *B* consisting of integers, sorted in non-decreasing order. Check whether it is possible to choose *k* numbers in array *A* and choose *m* numbers in array *B* so that any number chosen in the fi...
4,253
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: As a German University in Cairo (GUC) student and a basketball player, Herr Wafa was delighted once he heard the news. GUC is finally participating in the Annual Basketball Competition (ABC). A team is to be formed of *n* player...
4,254
Title: Subarray Cuts Time Limit: None seconds Memory Limit: None megabytes Problem Description: You are given an array of length *n* and a number *k*. Let's pick *k* non-overlapping non-empty subarrays of the initial array. Let *s**i* be the sum of the *i*-th subarray in order from left to right. Compute the maximum...
4,255
Title: Arrival of the General Time Limit: None seconds Memory Limit: None megabytes Problem Description: A Ministry for Defense sent a general to inspect the Super Secret Military Squad under the command of the Colonel SuperDuper. Having learned the news, the colonel ordered to all *n* squad soldiers to line up on t...
4,256
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: Valery is very interested in magic. Magic attracts him so much that he sees it everywhere. He explains any strange and weird phenomenon through intervention of supernatural forces. But who would have thought that even in a regular...
4,257
Title: Palindromes Time Limit: None seconds Memory Limit: None megabytes Problem Description: Friday is Polycarpus' favourite day of the week. Not because it is followed by the weekend, but because the lessons on Friday are 2 IT lessons, 2 math lessons and 2 literature lessons. Of course, Polycarpus has prepared to ...
4,258
Title: Collective Mindsets (hard) Time Limit: None seconds Memory Limit: None megabytes Problem Description: Heidi got one brain, thumbs up! But the evening isn't over yet and one more challenge awaits our dauntless agent: after dinner, at precisely midnight, the *N* attendees love to play a very risky game... Ever...
4,259
Title: Petya and File System Time Limit: 3 seconds Memory Limit: 256 megabytes Problem Description: Recently, on a programming lesson little Petya showed how quickly he can create files and folders on the computer. But he got soon fed up with this activity, and he decided to do a much more useful thing. He decided t...
4,260
Title: Run for beer Time Limit: None seconds Memory Limit: None megabytes Problem Description: People in BubbleLand like to drink beer. Little do you know, beer here is so good and strong that every time you drink it your speed goes 10 times slower than before you drank it. Birko lives in city Beergrade, but wants ...
4,261
Title: Cycles in product Time Limit: None seconds Memory Limit: None megabytes Problem Description: Consider a tree (that is, an undirected connected graph without loops) $T_1$ and a tree $T_2$. Let's define their cartesian product $T_1 \times T_2$ in a following way. Let $V$ be the set of vertices in $T_1$ and $U$...
4,262
Title: Goodbye Souvenir Time Limit: None seconds Memory Limit: None megabytes Problem Description: I won't feel lonely, nor will I be sorrowful... not before everything is buried. A string of *n* beads is left as the message of leaving. The beads are numbered from 1 to *n* from left to right, each having a shape nu...
4,263
Title: Merge Sort Time Limit: None seconds Memory Limit: None megabytes Problem Description: Merge sort is a well-known sorting algorithm. The main function that sorts the elements of array *a* with indices from [*l*,<=*r*) can be implemented as follows: 1. If the segment [*l*,<=*r*) is already sorted in non-desce...
4,264
Title: Round House Time Limit: None seconds Memory Limit: None megabytes Problem Description: Vasya lives in a round building, whose entrances are numbered sequentially by integers from 1 to *n*. Entrance *n* and entrance 1 are adjacent. Today Vasya got bored and decided to take a walk in the yard. Vasya lives in e...
4,265
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: A factory produces thimbles in bulk. Typically, it can produce up to *a* thimbles a day. However, some of the machinery is defective, so it can currently only produce *b* thimbles each day. The factory intends to choose a *k*-day ...
4,266
Title: Souvenirs Time Limit: None seconds Memory Limit: None megabytes Problem Description: Artsem is on vacation and wants to buy souvenirs for his two teammates. There are *n* souvenir shops along the street. In *i*-th shop Artsem can buy one souvenir for *a**i* dollars, and he cannot buy more than one souvenir in...
4,267
Title: Letter A Time Limit: 1 seconds Memory Limit: 64 megabytes Problem Description: Little Petya learns how to write. The teacher gave pupils the task to write the letter *A* on the sheet of paper. It is required to check whether Petya really had written the letter *A*. You are given three segments on the plane. ...
4,268
Title: Bargaining Table Time Limit: 2 seconds Memory Limit: 256 megabytes Problem Description: Bob wants to put a new bargaining table in his office. To do so he measured the office room thoroughly and drew its plan: Bob's office room is a rectangular room *n*<=Γ—<=*m* meters. Each square meter of the room is either ...
4,269
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: I won't feel lonely, nor will I be sorrowful... not before everything is buried. A string of *n* beads is left as the message of leaving. The beads are numbered from 1 to *n* from left to right, each having a shape numbered by in...
4,270
Title: Traffic Lights Time Limit: 2 seconds Memory Limit: 256 megabytes Problem Description: A car moves from point A to point B at speed *v* meters per second. The action takes place on the X-axis. At the distance *d* meters from A there are traffic lights. Starting from time 0, for the first *g* seconds the green ...
4,271
Title: Permutation Game Time Limit: None seconds Memory Limit: None megabytes Problem Description: *n* children are standing in a circle and playing a game. Children's numbers in clockwise order form a permutation *a*1,<=*a*2,<=...,<=*a**n* of length *n*. It is an integer sequence such that each integer from 1 to *n...
4,272
Title: Magnets Time Limit: None seconds Memory Limit: None megabytes Problem Description: Mad scientist Mike entertains himself by arranging rows of dominoes. He doesn't need dominoes, though: he uses rectangular magnets instead. Each magnet has two poles, positive (a "plus") and negative (a "minus"). If two magnets...
4,273
Title: Start of the session Time Limit: 2 seconds Memory Limit: 256 megabytes Problem Description: 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...
4,274
Title: Connecting Universities Time Limit: None seconds Memory Limit: None megabytes Problem Description: Treeland is a country in which there are *n* towns connected by *n*<=-<=1 two-way road such that it's possible to get from any town to any other town. In Treeland there are 2*k* universities which are located ...
4,275
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: This time the Berland Team Olympiad in Informatics is held in a remote city that can only be reached by one small bus. Bus has *n* passenger seats, seat *i* can be occupied only by a participant from the city *a**i*. Today the bu...
4,276
Title: Jeff and Permutation Time Limit: None seconds Memory Limit: None megabytes Problem Description: Jeff's friends know full well that the boy likes to get sequences and arrays for his birthday. Thus, Jeff got sequence *p*1,<=*p*2,<=...,<=*p**n* for his birthday. Jeff hates inversions in sequences. An inversion ...
4,277
Title: Heap Operations Time Limit: None seconds Memory Limit: None megabytes Problem Description: Petya has recently learned data structure named "Binary heap". The heap he is now operating with allows the following operations: - put the given number into the heap; - get the value of the minimum element in the ...
4,278
Title: Kay and Eternity Time Limit: None seconds Memory Limit: None megabytes Problem Description: Snow Queen told Kay to form a word "eternity" using pieces of ice. Kay is eager to deal with the task, because he will then become free, and Snow Queen will give him all the world and a pair of skates. Behind the pala...
4,279
Title: Monitor Time Limit: 0 seconds Memory Limit: 64 megabytes Problem Description: Reca company makes monitors, the most popular of their models is AB999 with the screen size *a*<=Γ—<=*b* centimeters. Because of some production peculiarities a screen parameters are integer numbers. Recently the screen sides ratio *...
4,280
Title: Anton and currency you all know Time Limit: None seconds Memory Limit: None megabytes Problem Description: Berland, 2016. The exchange rate of currency you all know against the burle has increased so much that to simplify the calculations, its fractional part was neglected and the exchange rate is now assumed...
4,281
Title: Shortest Path Time Limit: 3 seconds Memory Limit: 256 megabytes Problem Description: In Ancient Berland there were *n* cities and *m* two-way roads of equal length. The cities are numbered with integers from 1 to *n* inclusively. According to an ancient superstition, if a traveller visits three cities *a**i*,...
4,282
Title: The Modcrab Time Limit: None seconds Memory Limit: None megabytes Problem Description: Vova is again playing some computer game, now an RPG. In the game Vova's character received a quest: to slay the fearsome monster called Modcrab. After two hours of playing the game Vova has tracked the monster and analyze...
4,283
Title: Two Substrings Time Limit: None seconds Memory Limit: None megabytes Problem Description: You are given string *s*. Your task is to determine if the given string *s* contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order). Input Specification: The only line of input contain...
4,284
Title: Minimal string Time Limit: None seconds Memory Limit: None megabytes Problem Description: Petya recieved a gift of a string *s* with length up to 105 characters for his birthday. He took two more empty strings *t* and *u* and decided to play a game. This game has two possible moves: - Extract the first char...
4,285
Title: Codeforces World Finals Time Limit: 2 seconds Memory Limit: 256 megabytes Problem Description: The king Copa often has been reported about the Codeforces site, which is rapidly getting more and more popular among the brightest minds of the humanity, who are using it for training and competing. Recently Copa u...
4,286
Title: View Angle Time Limit: None seconds Memory Limit: None megabytes Problem Description: Flatland has recently introduced a new type of an eye check for the driver's licence. The check goes like that: there is a plane with mannequins standing on it. You should tell the value of the minimum angle with the vertex ...
4,287
Title: Collecting Beats is Fun Time Limit: None seconds Memory Limit: None megabytes Problem Description: Cucumber boy is fan of Kyubeat, a famous music game. Kyubeat has 16 panels for playing arranged in 4<=Γ—<=4 table. When a panel lights up, he has to press that panel. Each panel has a timing to press (the preff...
4,288
Title: Hierarchy Time Limit: 2 seconds Memory Limit: 64 megabytes Problem Description: Nick's company employed *n* people. Now Nick needs to build a tree hierarchy of Β«supervisor-surbodinateΒ» relations in the company (this is to say that each employee, except one, has exactly one supervisor). There are *m* applicati...
4,289
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: Bessie the cow and her best friend Elsie each received a sliding puzzle on Pi Day. Their puzzles consist of a 2<=Γ—<=2 grid and three tiles labeled 'A', 'B', and 'C'. The three tiles sit on top of the grid, leaving one grid cell em...
4,290
Title: Bear and Fair Set Time Limit: None seconds Memory Limit: None megabytes Problem Description: Limak is a grizzly bear. He is big and dreadful. You were chilling in the forest when you suddenly met him. It's very unfortunate for you. He will eat all your cookies unless you can demonstrate your mathematical skil...
4,291
Title: Simple Cycles Edges Time Limit: None seconds Memory Limit: None megabytes Problem Description: You are given an undirected graph, consisting of $n$ vertices and $m$ edges. The graph does not necessarily connected. Guaranteed, that the graph does not contain multiple edges (more than one edges between a pair o...
4,292
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: Kostya is a progamer specializing in the discipline of Dota 2. Valve Corporation, the developer of this game, has recently released a new patch which turned the balance of the game upside down. Kostya, as the captain of the team, ...
4,293
Title: LRU Time Limit: None seconds Memory Limit: None megabytes Problem Description: While creating high loaded systems one should pay a special attention to caching. This problem will be about one of the most popular caching algorithms called LRU (Least Recently Used). Suppose the cache may store no more than *k*...
4,294
Title: Perpetual Subtraction Time Limit: None seconds Memory Limit: None megabytes Problem Description: There is a number *x* initially written on a blackboard. You repeat the following action a fixed amount of times: 1. take the number *x* currently written on a blackboard and erase it 1. select an integer unif...
4,295
Title: Bash Plays with Functions Time Limit: None seconds Memory Limit: None megabytes Problem Description: Bash got tired on his journey to become the greatest Pokemon master. So he decides to take a break and play with functions. Bash defines a function *f*0(*n*), which denotes the number of ways of factoring *n*...
4,296
Title: Panoramix's Prediction Time Limit: 2 seconds Memory Limit: 256 megabytes Problem Description: A prime number is a number which has exactly two distinct divisors: one and itself. For example, numbers 2, 7, 3 are prime, and 1, 6, 4 are not. The next prime number after *x* is the smallest prime number greater t...
4,297
Title: Game of Stones Time Limit: None seconds Memory Limit: None megabytes Problem Description: Sam has been teaching Jon the Game of Stones to sharpen his mind and help him devise a strategy to fight the white walkers. The rules of this game are quite simple: - The game starts with *n* piles of stones indexed fr...
4,298
Title: Wizards and Numbers Time Limit: None seconds Memory Limit: None megabytes Problem Description: In some country live wizards. They love playing with numbers. The blackboard has two numbers written on it β€” *a* and *b*. The order of the numbers is not important. Let's consider *a*<=≀<=*b* for the sake of defin...
4,299