task
stringlengths
0
154k
__index_level_0__
int64
0
39.2k
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: One of Timofey's birthday presents is a colourbook in a shape of an infinite plane. On the plane *n* rectangles with sides parallel to coordinate axes are situated. All sides of the rectangles have odd length. Rectangles cannot in...
5,200
Title: Места в самолёте Time Limit: None seconds Memory Limit: None megabytes Problem Description: В самолёте есть *n* рядов мест. Если смотреть на ряды сверху, то в каждом ряду есть 3 места слева, затем проход между рядами, затем 4 центральных места, затем ещё один проход между рядами, а затем ещё 3 места справа. ...
5,201
Title: Friends Time Limit: 1 seconds Memory Limit: 256 megabytes Problem Description: One day Igor K. stopped programming and took up math. One late autumn evening he was sitting at a table reading a book and thinking about something. The following statement caught his attention: "Among any six people there are ei...
5,202
Title: Pasha and Tea Time Limit: None seconds Memory Limit: None megabytes Problem Description: Pasha decided to invite his friends to a tea party. For that occasion, he has a large teapot with the capacity of *w* milliliters and 2*n* tea cups, each cup is for one of Pasha's friends. The *i*-th cup can hold at most ...
5,203
Title: Genetic engineering Time Limit: 2 seconds Memory Limit: 256 megabytes Problem Description: "Multidimensional spaces are completely out of style these days, unlike genetics problems" — thought physicist Woll and changed his subject of study to bioinformatics. Analysing results of sequencing he faced the follow...
5,204
Title: Forensic Examination Time Limit: None seconds Memory Limit: None megabytes Problem Description: The country of Reberland is the archenemy of Berland. Recently the authorities of Berland arrested a Reberlandian spy who tried to bring the leaflets intended for agitational propaganda to Berland illegally . The m...
5,205
Title: New Year and Fireworks Time Limit: None seconds Memory Limit: None megabytes Problem Description: One tradition of welcoming the New Year is launching fireworks into the sky. Usually a launched firework flies vertically upward for some period of time, then explodes, splitting into several parts flying in diff...
5,206
Title: Planning Time Limit: None seconds Memory Limit: None megabytes Problem Description: Helen works in Metropolis airport. She is responsible for creating a departure schedule. There are *n* flights that must depart today, the *i*-th of them is planned to depart at the *i*-th minute of the day. Metropolis airpor...
5,207
Title: Prime Gift Time Limit: None seconds Memory Limit: None megabytes Problem Description: Opposite to Grisha's nice behavior, Oleg, though he has an entire year at his disposal, didn't manage to learn how to solve number theory problems in the past year. That's why instead of Ded Moroz he was visited by his teamm...
5,208
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: It's another Start[c]up finals, and that means there is pizza to order for the onsite contestants. There are only 2 types of pizza (obviously not, but let's just pretend for the sake of the problem), and all pizzas contain exactly...
5,209
Title: Good Sequences Time Limit: None seconds Memory Limit: None megabytes Problem Description: Squirrel Liss is interested in sequences. She also has preferences of integers. She thinks *n* integers *a*1,<=*a*2,<=...,<=*a**n* are good. Now she is interested in good sequences. A sequence *x*1,<=*x*2,<=...,<=*x**k*...
5,210
Title: LLPS Time Limit: None seconds Memory Limit: None megabytes Problem Description: This problem's actual name, "Lexicographically Largest Palindromic Subsequence" is too long to fit into the page headline. You are given string *s* consisting of lowercase English letters only. Find its lexicographically largest ...
5,211
Title: Mean Requests Time Limit: None seconds Memory Limit: None megabytes Problem Description: In this problem you will have to deal with a real algorithm that is used in the VK social network. As in any other company that creates high-loaded websites, the VK developers have to deal with request statistics regular...
5,212
Title: Divisible by Seven Time Limit: None seconds Memory Limit: None megabytes Problem Description: You have number *a*, whose decimal representation quite luckily contains digits 1, 6, 8, 9. Rearrange the digits in its decimal representation so that the resulting number will be divisible by 7. Number *a* doesn't ...
5,213
Title: Robin Hood Time Limit: None seconds Memory Limit: None megabytes Problem Description: We all know the impressive story of Robin Hood. Robin Hood uses his archery skills and his wits to steal the money from rich, and return it to the poor. There are *n* citizens in Kekoland, each person has *c**i* coins. Each...
5,214
Title: Problems for Round Time Limit: None seconds Memory Limit: None megabytes Problem Description: There are *n* problems prepared for the next Codeforces round. They are arranged in ascending order by their difficulty, and no two problems have the same difficulty. Moreover, there are *m* pairs of similar problems...
5,215
Title: Square Time Limit: None seconds Memory Limit: None megabytes Problem Description: There is a square painted on a piece of paper, the square's side equals *n* meters. John Doe draws crosses on the square's perimeter. John paints the first cross in the lower left corner of the square. Then John moves along the ...
5,216
Title: Appleman and Toastman Time Limit: None seconds Memory Limit: None megabytes Problem Description: Appleman and Toastman play a game. Initially Appleman gives one group of *n* numbers to the Toastman, then they start to complete the following tasks: - Each time Toastman gets a group of numbers, he sums up all...
5,217
Title: Unbearable Controversy of Being Time Limit: None seconds Memory Limit: None megabytes Problem Description: Tomash keeps wandering off and getting lost while he is walking along the streets of Berland. It's no surprise! In his home town, for any pair of intersections there is exactly one way to walk from one i...
5,218
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: One day Greg and his friends were walking in the forest. Overall there were *n* people walking, including Greg. Soon he found himself in front of a river. The guys immediately decided to get across the river. Luckily, there was a ...
5,219
Title: Iron Man Time Limit: None seconds Memory Limit: None megabytes Problem Description: Tony Stark is playing a game with his suits (they have auto-pilot now). He lives in Malibu. Malibu has *n* junctions numbered from 1 to *n*, connected with *n*<=-<=1 roads. One can get from a junction to any other junction usi...
5,220
Title: Gotta Catch Em' All! Time Limit: None seconds Memory Limit: None megabytes Problem Description: Bash wants to become a Pokemon master one day. Although he liked a lot of Pokemon, he has always been fascinated by Bulbasaur the most. Soon, things started getting serious and his fascination turned into an obsess...
5,221
Title: Dress'em in Vests! Time Limit: None seconds Memory Limit: None megabytes Problem Description: The Two-dimensional kingdom is going through hard times... This morning the Three-Dimensional kingdom declared war on the Two-dimensional one. This (possibly armed) conflict will determine the ultimate owner of the s...
5,222
Title: Magic Trick Time Limit: None seconds Memory Limit: None megabytes Problem Description: Alex enjoys performing magic tricks. He has a trick that requires a deck of *n* cards. He has *m* identical decks of *n* different cards each, which have been mixed together. When Alex wishes to perform the trick, he grabs ...
5,223
Title: New Year and Rainbow Roads Time Limit: None seconds Memory Limit: None megabytes Problem Description: Roy and Biv have a set of *n* points on the infinite number line. Each point has one of 3 colors: red, green, or blue. Roy and Biv would like to connect all the points with some edges. Edges can be drawn be...
5,224
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: John Doe has an *n*<=×<=*m* table. John Doe can paint points in some table cells, not more than one point in one table cell. John Doe wants to use such operations to make each square subtable of size *n*<=×<=*n* have exactly *k* p...
5,225
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: Arkadiy has lots square photos with size *a*<=×<=*a*. He wants to put some of them on a rectangular wall with size *h*<=×<=*w*. The photos which Arkadiy will put on the wall must form a rectangular grid and the distances between...
5,226
Title: Cheaterius's Problem Time Limit: 2 seconds Memory Limit: 256 megabytes Problem Description: Cheaterius is a famous in all the Berland astrologist, magician and wizard, and he also is a liar and a cheater. One of his latest inventions is Cheaterius' amulets! They bring luck and wealth, but are rather expensive...
5,227
Title: Cakeminator Time Limit: None seconds Memory Limit: None megabytes Problem Description: You are given a rectangular cake, represented as an *r*<=×<=*c* grid. Each cell either has an evil strawberry, or is empty. For example, a 3<=×<=4 cake may look as follows: The cakeminator is going to eat the cake! Each ti...
5,228
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: Petya learned a new programming language CALPAS. A program in this language always takes one non-negative integer and returns one non-negative integer as well. In the language, there are only three commands: apply a bitwise opera...
5,229
Title: Design Tutorial: Learn from Life Time Limit: None seconds Memory Limit: None megabytes Problem Description: One way to create a task is to learn from life. You can choose some experience in real life, formalize it and then you will get a new task. Let's think about a scene in real life: there are lots of peo...
5,230
Title: Orientation of Edges Time Limit: None seconds Memory Limit: None megabytes Problem Description: Vasya has a graph containing both directed (oriented) and undirected (non-oriented) edges. There can be multiple edges between a pair of vertices. Vasya has picked a vertex *s* from the graph. Now Vasya wants to c...
5,231
Title: Big Secret Time Limit: None seconds Memory Limit: None megabytes Problem Description: Vitya has learned that the answer for The Ultimate Question of Life, the Universe, and Everything is not the integer 54 42, but an increasing integer sequence $a_1, \ldots, a_n$. In order to not reveal the secret earlier tha...
5,232
Title: Kuro and GCD and XOR and SUM Time Limit: None seconds Memory Limit: None megabytes Problem Description: Kuro is currently playing an educational game about numbers. The game focuses on the greatest common divisor (GCD), the XOR value, and the sum of two numbers. Kuro loves the game so much that he solves leve...
5,233
Title: Yaroslav and Arrangements Time Limit: None seconds Memory Limit: None megabytes Problem Description: Yaroslav calls an array of *r* integers *a*1,<=*a*2,<=...,<=*a**r* good, if it meets the following conditions: |*a*1<=-<=*a*2|<==<=1,<=|*a*2<=-<=*a*3|<==<=1,<=...,<=|*a**r*<=-<=1<=-<=*a**r*|<==<=1,<=|*a**r*<=-...
5,234
Title: Cthulhu Time Limit: 2 seconds Memory Limit: 256 megabytes Problem Description: ...Once upon a time a man came to the sea. The sea was stormy and dark. The man started to call for the little mermaid to appear but alas, he only woke up Cthulhu... Whereas on the other end of the world Pentagon is actively colle...
5,235
Title: Spiral Maximum Time Limit: None seconds Memory Limit: None megabytes Problem Description: Let's consider a *k*<=×<=*k* square, divided into unit squares. Please note that *k*<=≥<=3 and is odd. We'll paint squares starting from the upper left square in the following order: first we move to the right, then down...
5,236
Title: Restoration of the Permutation Time Limit: 1 seconds Memory Limit: 256 megabytes Problem Description: Let *A*<==<={*a*1,<=*a*2,<=...,<=*a**n*} be any permutation of the first *n* natural numbers {1,<=2,<=...,<=*n*}. You are given a positive integer *k* and another sequence *B*<==<={*b*1,<=*b*2,<=...,<=*b**n*}...
5,237
Title: Vladik and Memorable Trip Time Limit: None seconds Memory Limit: None megabytes Problem Description: Vladik often travels by trains. He remembered some of his trips especially well and I would like to tell you about one of these trips: Vladik is at initial train station, and now *n* people (including Vladik)...
5,238
Title: Connected Components? Time Limit: None seconds Memory Limit: None megabytes Problem Description: You are given an undirected graph consisting of *n* vertices and edges. Instead of giving you the edges that exist in the graph, we give you *m* unordered pairs (*x*,<=*y*) such that there is no edge between *x* ...
5,239
Title: HQ9+ Time Limit: None seconds Memory Limit: None megabytes Problem Description: HQ9+ is a joke programming language which has only four one-character instructions: - "H" prints "Hello, World!",- "Q" prints the source code of the program itself,- "9" prints the lyrics of "99 Bottles of Beer" song, - "+" in...
5,240
Title: Correct Bracket Sequence Editor Time Limit: None seconds Memory Limit: None megabytes Problem Description: Recently Polycarp started to develop a text editor that works only with correct bracket sequences (abbreviated as CBS). Note that a bracket sequence is correct if it is possible to get a correct mathem...
5,241
Title: Little Dima and Equation Time Limit: None seconds Memory Limit: None megabytes Problem Description: Little Dima misbehaved during a math lesson a lot and the nasty teacher Mr. Pickles gave him the following problem as a punishment. Find all integer solutions *x* (0<=&lt;<=*x*<=&lt;<=109) of the equation: w...
5,242
Title: Old Berland Language Time Limit: 2 seconds Memory Limit: 256 megabytes Problem Description: Berland scientists know that the Old Berland language had exactly *n* words. Those words had lengths of *l*1,<=*l*2,<=...,<=*l**n* letters. Every word consisted of two letters, 0 and 1. Ancient Berland people spoke qui...
5,243
Title: Diverse Team Time Limit: None seconds Memory Limit: None megabytes Problem Description: There are $n$ students in a school class, the rating of the $i$-th student on Codehorses is $a_i$. You have to form a team consisting of $k$ students ($1 \le k \le n$) such that the ratings of all team members are distinct...
5,244
Title: Lizards and Basements 2 Time Limit: 2 seconds Memory Limit: 64 megabytes Problem Description: This is simplified version of the problem used on the original contest. The original problem seems to have too difiicult solution. The constraints for input data have been reduced. Polycarp likes to play computer ro...
5,245
Title: Tetris Time Limit: None seconds Memory Limit: None megabytes Problem Description: You are given a following process. There is a platform with $n$ columns. $1 \times 1$ squares are appearing one after another in some columns on this platform. If there are no squares in the column, a square will occupy the bo...
5,246
Title: Football Kit Time Limit: None seconds Memory Limit: None megabytes Problem Description: Consider a football tournament where *n* teams participate. Each team has two football kits: for home games, and for away games. The kit for home games of the *i*-th team has color *x**i* and the kit for away games of this...
5,247
Title: Five-In-a-Row Time Limit: None seconds Memory Limit: None megabytes Problem Description: Alice and Bob play 5-in-a-row game. They have a playing field of size 10<=×<=10. In turns they put either crosses or noughts, one at a time. Alice puts crosses and Bob puts noughts. In current match they have made some t...
5,248
Title: Playing with Superglue Time Limit: None seconds Memory Limit: None megabytes Problem Description: Two players play a game. The game is played on a rectangular board with *n*<=×<=*m* squares. At the beginning of the game two different squares of the board have two chips. The first player's goal is to shift the...
5,249
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: Student Vladislav came to his programming exam completely unprepared as usual. He got a question about some strange algorithm on a graph — something that will definitely never be useful in real life. He asked a girl sitting next t...
5,250
Title: Touchy-Feely Palindromes Time Limit: None seconds Memory Limit: None megabytes Problem Description: The only line of the input contains a string of digits. The length of the string is between 1 and 10, inclusive. Output "Yes" or "No". Input Specification: The only line of the input contains a string of digi...
5,251
Title: Help Monks Time Limit: 2 seconds Memory Limit: 256 megabytes Problem Description: In a far away kingdom is the famous Lio Shan monastery. Gods constructed three diamond pillars on the monastery's lawn long ago. Gods also placed on one pillar *n* golden disks of different diameters (in the order of the diamete...
5,252
Title: none 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 need ...
5,253
Title: Timetable Time Limit: None seconds Memory Limit: None megabytes Problem Description: Ivan is a student at Berland State University (BSU). There are *n* days in Berland week, and each of these days Ivan might have some classes at the university. There are *m* working hours during each Berland day, and each le...
5,254
Title: Gosha is hunting Time Limit: None seconds Memory Limit: None megabytes Problem Description: Gosha is hunting. His goal is to catch as many Pokemons as possible. Gosha has *a* Poke Balls and *b* Ultra Balls. There are *n* Pokemons. They are numbered 1 through *n*. Gosha knows that if he throws a Poke Ball at t...
5,255
Title: Ciel and Flipboard Time Limit: None seconds Memory Limit: None megabytes Problem Description: Fox Ciel has a board with *n* rows and *n* columns, there is one integer in each cell. It's known that *n* is an odd number, so let's introduce . Fox Ciel can do the following operation many times: she choose a sub-...
5,256
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: Natalia Romanova is trying to test something on the new gun S.H.I.E.L.D gave her. In order to determine the result of the test, she needs to find the number of answers to a certain equation. The equation is of form: Where repr...
5,257
Title: ZS and The Birthday Paradox Time Limit: None seconds Memory Limit: None megabytes Problem Description: ZS the Coder has recently found an interesting concept called the Birthday Paradox. It states that given a random set of 23 people, there is around 50% chance that some two of them share the same birthday. Z...
5,258
Title: DZY Loves Chessboard Time Limit: None seconds Memory Limit: None megabytes Problem Description: DZY loves chessboard, and he enjoys playing with it. He has a chessboard of *n* rows and *m* columns. Some cells of the chessboard are bad, others are good. For every good cell, DZY wants to put a chessman on it. ...
5,259
Title: Chocolate Bar Time Limit: None seconds Memory Limit: None megabytes Problem Description: You have a rectangular chocolate bar consisting of *n*<=×<=*m* single squares. You want to eat exactly *k* squares, so you may need to break the chocolate bar. In one move you can break any single rectangular piece of c...
5,260
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: How many specific orders do you know? Ascending order, descending order, order of ascending length, order of ascending polar angle... Let's have a look at another specific order: *d*-sorting. This sorting is applied to the strings...
5,261
Title: Let's Watch Football Time Limit: None seconds Memory Limit: None megabytes Problem Description: Valeric and Valerko missed the last Euro football game, so they decided to watch the game's key moments on the Net. They want to start watching as soon as possible but the connection speed is too low. If they turn ...
5,262
Title: Ilya and Bank Account Time Limit: None seconds Memory Limit: None megabytes Problem Description: Ilya is a very clever lion, he lives in an unusual city ZooVille. In this city all the animals have their rights and obligations. Moreover, they even have their own bank accounts. The state of a bank account is an...
5,263
Title: Rain and Umbrellas Time Limit: None seconds Memory Limit: None megabytes Problem Description: Polycarp lives on a coordinate line at the point $x = 0$. He goes to his friend that lives at the point $x = a$. Polycarp can move only from left to right, he can pass one unit of length each second. Now it's rainin...
5,264
Title: Concise and clear Time Limit: None seconds Memory Limit: None megabytes Problem Description: Vasya is a regular participant at programming contests and is already experienced in finding important sentences in long statements. Of course, numbers constraints are important — factorization of a number less than 1...
5,265
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: Paladin Manao caught the trail of the ancient Book of Evil in a swampy area. This area contains *n* settlements numbered from 1 to *n*. Moving through the swamp is very difficult, so people tramped exactly *n*<=-<=1 paths. Each of...
5,266
Title: Travelling Salesman and Special Numbers Time Limit: None seconds Memory Limit: None megabytes Problem Description: The Travelling Salesman spends a lot of time travelling so he tends to get bored. To pass time, he likes to perform operations on numbers. One such operation is to take a positive integer *x* and...
5,267
Title: Olesya and Rodion Time Limit: None seconds Memory Limit: None megabytes Problem Description: Olesya loves numbers consisting of *n* digits, and Rodion only likes numbers that are divisible by *t*. Find some number that satisfies both of them. Your task is: given the *n* and *t* print an integer strictly larg...
5,268
Title: Wooden Fence Time Limit: None seconds Memory Limit: None megabytes Problem Description: Vasya has recently bought some land and decided to surround it with a wooden fence. He went to a company called "Wooden board" that produces wooden boards for fences. Vasya read in the catalog of products that the company...
5,269
Title: Okabe and El Psy Kongroo Time Limit: None seconds Memory Limit: None megabytes Problem Description: Okabe likes to take walks but knows that spies from the Organization could be anywhere; that's why he wants to know how many different walks he can take in his city safely. Okabe's city can be represented as al...
5,270
Title: Letters Time Limit: None seconds Memory Limit: None megabytes Problem Description: There are $n$ dormitories in Berland State University, they are numbered with integers from $1$ to $n$. Each dormitory consists of rooms, there are $a_i$ rooms in $i$-th dormitory. The rooms in $i$-th dormitory are numbered fro...
5,271
Title: Mogohu-Rea Idol Time Limit: 3 seconds Memory Limit: 256 megabytes Problem Description: A long time ago somewhere in the depths of America existed a powerful tribe governed by the great leader Pinnie-the-Wooh. Once the tribe conquered three Maya cities. Pinnie-the-Wooh grew concerned: there had to be some cont...
5,272
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: Dima is a beginner programmer. During his working process, he regularly has to repeat the following operation again and again: to remove every second element from the array. One day he has been bored with easy solutions of this pr...
5,273
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: To get money for a new aeonic blaster, ranger Qwerty decided to engage in trade for a while. He wants to buy some number of items (or probably not to buy anything at all) on one of the planets, and then sell the bought items on an...
5,274
Title: Egg Roulette Time Limit: None seconds Memory Limit: None megabytes Problem Description: The game of Egg Roulette is played between two players. Initially 2*R* raw eggs and 2*C* cooked eggs are placed randomly into a carton. The shells are left on so there is no way to distinguish a raw egg from a cooked egg. ...
5,275
Title: Labyrinth-2 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
5,276
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: Piet is one of the most known visual esoteric programming languages. The programs in Piet are constructed from colorful blocks of pixels and interpreted using pretty complicated rules. In this problem we will use a subset of Piet ...
5,277
Title: Stack Sorting Time Limit: None seconds Memory Limit: None megabytes Problem Description: Let's suppose you have an array *a*, a stack *s* (initially empty) and an array *b* (also initially empty). You may perform the following operations until both *a* and *s* are empty: - Take the first element of *a*, pu...
5,278
Title: Reberland Linguistics Time Limit: None seconds Memory Limit: None megabytes Problem Description: First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental kn...
5,279
Title: Benches Time Limit: None seconds Memory Limit: None megabytes Problem Description: The city park of IT City contains *n* east to west paths and *n* north to south paths. Each east to west path crosses each north to south path, so there are *n*2 intersections. The city funded purchase of five benches. To make...
5,280
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: Arkady and Kirill visited an exhibition of rare coins. The coins were located in a row and enumerated from left to right from 1 to *k*, each coin either was laid with its obverse (front) side up, or with its reverse (back) side up...
5,281
Title: Conveyor Belts Time Limit: None seconds Memory Limit: None megabytes Problem Description: Automatic Bakery of Cyberland (ABC) recently bought an *n*<=×<=*m* rectangle table. To serve the diners, ABC placed seats around the table. The size of each seat is equal to a unit square, so there are 2(*n*<=+<=*m*) sea...
5,282
Title: Peterson Polyglot Time Limit: None seconds Memory Limit: None megabytes Problem Description: Peterson loves to learn new languages, but his favorite hobby is making new ones. Language is a set of words, and word is a sequence of lowercase Latin letters. Peterson makes new language every morning. It is diffic...
5,283
Title: Xenia and String Problem Time Limit: None seconds Memory Limit: None megabytes Problem Description: Xenia the coder went to The Olympiad of Informatics and got a string problem. Unfortunately, Xenia isn't fabulous in string algorithms. Help her solve the problem. String *s* is a sequence of characters *s*1*s...
5,284
Title: Polycarp's problems Time Limit: None seconds Memory Limit: None megabytes Problem Description: Polycarp is an experienced participant in Codehorses programming contests. Now he wants to become a problemsetter. He sent to the coordinator a set of *n* problems. Each problem has it's quality, the quality of the...
5,285
Title: Fafa and Ancient Mathematics Time Limit: None seconds Memory Limit: None megabytes Problem Description: Ancient Egyptians are known to have understood difficult concepts in mathematics. The ancient Egyptian mathematician Ahmes liked to write a kind of arithmetic expressions on papyrus paper which he called as...
5,286
Title: Abracadabra Time Limit: None seconds Memory Limit: None megabytes Problem Description: Polycarpus analyzes a string called abracadabra. This string is constructed using the following algorithm: - On the first step the string consists of a single character "a". - On the *k*-th step Polycarpus concatenates ...
5,287
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: Recently, Pari and Arya did some research about NP-Hard problems and they found the minimum vertex cover problem very interesting. Suppose the graph *G* is given. Subset *A* of its vertices is called a vertex cover of this graph,...
5,288
Title: Contest Time Limit: None seconds Memory Limit: None megabytes Problem Description: Misha and Vasya participated in a Codeforces contest. Unfortunately, each of them solved only one problem, though successfully submitted it at the first attempt. Misha solved the problem that costs *a* points and Vasya solved t...
5,289
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: Limak is a little polar bear. He doesn't have many toys and thus he often plays with polynomials. He considers a polynomial valid if its degree is *n* and its coefficients are integers not exceeding *k* by the absolute value. Mor...
5,290
Title: Educational Game Time Limit: None seconds Memory Limit: None megabytes Problem Description: The Smart Beaver from ABBYY began to develop a new educational game for children. The rules of the game are fairly simple and are described below. The playing field is a sequence of *n* non-negative integers *a**i* nu...
5,291
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: A subsequence of length |*x*| of string *s*<==<=*s*1*s*2... *s*|*s*| (where |*s*| is the length of string *s*) is a string *x*<==<=*s**k*1*s**k*2... *s**k*|*x*| (1<=≤<=*k*1<=&lt;<=*k*2<=&lt;<=...<=&lt;<=*k*|*x*|<=≤<=|*s*|). You'v...
5,292
Title: Centroids Time Limit: None seconds Memory Limit: None megabytes Problem Description: Tree is a connected acyclic graph. Suppose you are given a tree consisting of *n* vertices. The vertex of this tree is called centroid if the size of each connected component that appears if this vertex is removed from the tr...
5,293
Title: Robot Control Time Limit: None seconds Memory Limit: None megabytes Problem Description: The boss of the Company of Robot is a cruel man. His motto is "Move forward Or Die!". And that is exactly what his company's product do. Look at the behavior of the company's robot when it is walking in the directed graph...
5,294
Title: Festival Organization Time Limit: None seconds Memory Limit: None megabytes Problem Description: The Prodiggers are quite a cool band and for this reason, they have been the surprise guest at the ENTER festival for the past 80 years. At the beginning of their careers, they weren’t so successful, so they had t...
5,295
Title: Wizards and Trolleybuses Time Limit: None seconds Memory Limit: None megabytes Problem Description: In some country live wizards. They love to ride trolleybuses. A city in this country has a trolleybus depot with *n* trolleybuses. Every day the trolleybuses leave the depot, one by one and go to the final sta...
5,296
Title: Buggy Sorting Time Limit: None seconds Memory Limit: None megabytes Problem Description: Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of *n* integers *a*1,<=*a*2,<=...,<=*a*...
5,297
Title: Average Score Time Limit: 2 seconds Memory Limit: 256 megabytes Problem Description: After the educational reform Polycarp studies only two subjects at school, Safety Studies and PE (Physical Education). During the long months of the fourth term, he received *n* marks in them. When teachers wrote a mark in th...
5,298
Title: Balanced Substring Time Limit: None seconds Memory Limit: None megabytes Problem Description: You are given a string *s* consisting only of characters 0 and 1. A substring [*l*,<=*r*] of *s* is a string *s**l**s**l*<=+<=1*s**l*<=+<=2... *s**r*, and its length equals to *r*<=-<=*l*<=+<=1. A substring is called...
5,299