task
stringlengths
0
154k
__index_level_0__
int64
0
39.2k
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: In the Isle of Guernsey there are *n* different types of coins. For each *i* (1<=≤<=*i*<=≤<=*n*), coin of type *i* is worth *a**i* cents. It is possible that *a**i*<==<=*a**j* for some *i* and *j* (*i*<=≠<=*j*). Bessie has some ...
3,100
Title: Inna and Pink Pony Time Limit: None seconds Memory Limit: None megabytes Problem Description: Dima and Inna are doing so great! At the moment, Inna is sitting on the magic lawn playing with a pink pony. Dima wanted to play too. He brought an *n*<=×<=*m* chessboard, a very tasty candy and two numbers *a* and *...
3,101
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: In Absurdistan, there are *n* towns (numbered 1 through *n*) and *m* bidirectional railways. There is also an absurdly simple road network — for each pair of different towns *x* and *y*, there is a bidirectional road between towns...
3,102
Title: Shoe Store Time Limit: None seconds Memory Limit: None megabytes Problem Description: The warehouse in your shop has *n* shoe pairs. Each pair is characterized by two integers: its price *c**i* and its size *s**i*. We know that on this very day all numbers *s**i* are different, that is, there is no more than ...
3,103
Title: Where Are My Flakes? Time Limit: 2 seconds Memory Limit: 256 megabytes Problem Description: One morning the Cereal Guy found out that all his cereal flakes were gone. He found a note instead of them. It turned out that his smart roommate hid the flakes in one of *n* boxes. The boxes stand in one row, they are...
3,104
Title: A Compatible Pair Time Limit: None seconds Memory Limit: None megabytes Problem Description: Nian is a monster which lives deep in the oceans. Once a year, it shows up on the land, devouring livestock and even people. In order to keep the monster away, people fill their villages with red colour, light, and cr...
3,105
Title: Shortest Path Problem? Time Limit: None seconds Memory Limit: None megabytes Problem Description: You are given an undirected graph with weighted edges. The length of some path between two vertices is the bitwise xor of weights of all edges belonging to this path (if some edge is traversed more than once, the...
3,106
Title: Magical Boxes Time Limit: None seconds Memory Limit: None megabytes Problem Description: Emuskald is a well-known illusionist. One of his trademark tricks involves a set of magical boxes. The essence of the trick is in packing the boxes inside other boxes. From the top view each magical box looks like a squa...
3,107
Title: Helper Time Limit: 2 seconds Memory Limit: 256 megabytes Problem Description: It's unbelievable, but an exam period has started at the OhWord University. It's even more unbelievable, that Valera got all the tests before the exam period for excellent work during the term. As now he's free, he wants to earn mon...
3,108
Title: Send the Fool Further! (medium) Time Limit: None seconds Memory Limit: None megabytes Problem Description: Thank you for helping Heidi! It is now the second of April, but she has been summoned by Jenny again. The pranks do not seem to end... In the meantime, Heidi has decided that she does not trust her frie...
3,109
Title: Fortune Telling Time Limit: 2 seconds Memory Limit: 256 megabytes Problem Description: Marina loves Sasha. But she keeps wondering whether Sasha loves her. Of course, the best way to know it is fortune telling. There are many ways of telling fortune, but Marina has picked the easiest one. She takes in her han...
3,110
Title: Shortest Path Queries Time Limit: None seconds Memory Limit: None megabytes Problem Description: You are given an undirected connected graph with weighted edges. The length of some path between two vertices is the bitwise xor of weights of all edges belonging to this path (if some edge is traversed more than ...
3,111
Title: Game Time Limit: None seconds Memory Limit: None megabytes Problem Description: Two players play a game. Initially there are $n$ integers $a_1, a_2, \ldots, a_n$ written on the board. Each turn a player selects one number and erases it from the board. This continues until there is only one number left on the...
3,112
Title: Next Round Time Limit: None seconds Memory Limit: None megabytes Problem Description: "Contestant who earns a score equal to or greater than the *k*-th place finisher's score will advance to the next round, as long as the contestant earns a positive score..." — an excerpt from contest rules. A total of *n* p...
3,113
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: Vasya should paint a fence in front of his own cottage. The fence is a sequence of *n* wooden boards arranged in a single row. Each board is a 1 centimeter wide rectangle. Let's number the board fence using numbers 1,<=2,<=...,<=*...
3,114
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: Andryusha has found a perplexing arcade machine. The machine is a vertically adjusted board divided into square cells. The board has *w* columns numbered from 1 to *w* from left to right, and *h* rows numbered from 1 to *h* from t...
3,115
Title: Banana Time Limit: None seconds Memory Limit: None megabytes Problem Description: Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly *n* stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a stri...
3,116
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: I have an undirected graph consisting of *n* nodes, numbered 1 through *n*. Each node has at most two incident edges. For each pair of nodes, there is at most an edge connecting them. No edge connects a node to itself. I would li...
3,117
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: Vasya's telephone contains *n* photos. Photo number 1 is currently opened on the phone. It is allowed to move left and right to the adjacent photo by swiping finger over the screen. If you swipe left from the first photo, you reac...
3,118
Title: Bishwock Time Limit: None seconds Memory Limit: None megabytes Problem Description: Bishwock is a chess figure that consists of three squares resembling an "L-bar". This figure can be rotated by 90, 180 and 270 degrees so it can have four possible states: Bishwocks don't attack any squares and can even occup...
3,119
Title: SwapSort Time Limit: None seconds Memory Limit: None megabytes Problem Description: In this problem your goal is to sort an array consisting of *n* integers in at most *n* swaps. For the given array find the sequence of swaps that makes the array sorted in the non-descending order. Swaps are performed consecu...
3,120
Title: Tape Programming Time Limit: None seconds Memory Limit: None megabytes Problem Description: There is a programming language in which every program is a non-empty sequence of "&lt;" and "&gt;" signs and digits. Let's explain how the interpreter of this programming language works. A program is interpreted using...
3,121
Title: Happy Farm 5 Time Limit: 2 seconds Memory Limit: 256 megabytes Problem Description: The Happy Farm 5 creators decided to invent the mechanism of cow grazing. The cows in the game are very slow and they move very slowly, it can even be considered that they stand still. However, carnivores should always be chas...
3,122
Title: Three States Time Limit: None seconds Memory Limit: None megabytes Problem Description: The famous global economic crisis is approaching rapidly, so the states of Berman, Berance and Bertaly formed an alliance and allowed the residents of all member states to freely pass through the territory of any of them. ...
3,123
Title: Area of a Star Time Limit: None seconds Memory Limit: None megabytes Problem Description: It was decided in IT City to distinguish successes of local IT companies by awards in the form of stars covered with gold from one side. To order the stars it is necessary to estimate order cost that depends on the area ...
3,124
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: You are given *n* numbers *a*1,<=*a*2,<=...,<=*a**n*. You can perform at most *k* operations. For each operation you can multiply one of the numbers by *x*. We want to make as large as possible, where denotes the bitwise OR. F...
3,125
Title: New Year Tree Time Limit: None seconds Memory Limit: None megabytes Problem Description: The New Year holidays are over, but Resha doesn't want to throw away the New Year tree. He invited his best friends Kerim and Gural to help him to redecorate the New Year tree. The New Year tree is an undirected tree wit...
3,126
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: For months Maxim has been coming to work on his favorite bicycle. And quite recently he decided that he is ready to take part in a cyclists' competitions. He knows that this year *n* competitions will take place. During the *i*-t...
3,127
Title: Zublicanes and Mumocrates Time Limit: None seconds Memory Limit: None megabytes Problem Description: It's election time in Berland. The favorites are of course parties of zublicanes and mumocrates. The election campaigns of both parties include numerous demonstrations on *n* main squares of the capital of Ber...
3,128
Title: Gadgets for dollars and pounds Time Limit: None seconds Memory Limit: None megabytes Problem Description: Nura wants to buy *k* gadgets. She has only *s* burles for that. She can buy each gadget for dollars or for pounds. So each gadget is selling only for some type of currency. The type of currency and the c...
3,129
Title: New Year and Ancient Prophecy Time Limit: None seconds Memory Limit: None megabytes Problem Description: Limak is a little polar bear. In the snow he found a scroll with the ancient prophecy. Limak doesn't know any ancient languages and thus is unable to understand the prophecy. But he knows digits! One frag...
3,130
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: This is an interactive problem. The judge has a hidden rooted full binary tree with *n* leaves. A full binary tree is one where every node has either 0 or 2 children. The nodes with 0 children are called the leaves of the tree. S...
3,131
Title: Perfect Encoding Time Limit: None seconds Memory Limit: None megabytes Problem Description: You are working as an analyst in a company working on a new system for big data storage. This system will store $n$ different objects. Each object should have a unique ID. To create the system, you choose the paramete...
3,132
Title: The Tournament Time Limit: None seconds Memory Limit: None megabytes Problem Description: This problem consists of three subproblems: for solving subproblem C1 you will receive 4 points, for solving subproblem C2 you will receive 4 points, and for solving subproblem C3 you will receive 8 points. Manao decide...
3,133
Title: Trains and Statistic Time Limit: None seconds Memory Limit: None megabytes Problem Description: Vasya commutes by train every day. There are *n* train stations in the city, and at the *i*-th station it's possible to buy only tickets to stations from *i*<=+<=1 to *a**i* inclusive. No tickets are sold at the la...
3,134
Title: Mahmoud and Longest Uncommon Subsequence Time Limit: None seconds Memory Limit: None megabytes Problem Description: While Mahmoud and Ehab were practicing for IOI, they found a problem which name was Longest common subsequence. They solved it, and then Ehab challenged Mahmoud with another problem. Given two ...
3,135
Title: Madness Time Limit: None seconds Memory Limit: None megabytes Problem Description: The second semester starts at the University of Pavlopolis. After vacation in Vičkopolis Noora needs to return to Pavlopolis and continue her study. Sometimes (or quite often) there are teachers who do not like you. Incidental...
3,136
Title: Registration System Time Limit: 5 seconds Memory Limit: 64 megabytes Problem Description: A new e-mail service "Berlandesk" is going to be opened in Berland in the near future. The site administration wants to launch their project as soon as possible, that's why they ask you to help. You're suggested to imple...
3,137
Title: Inversions problem Time Limit: None seconds Memory Limit: None megabytes Problem Description: You are given a permutation of *n* numbers *p*1,<=*p*2,<=...,<=*p**n*. We perform *k* operations of the following type: choose uniformly at random two indices *l* and *r* (*l*<=≤<=*r*) and reverse the order of the el...
3,138
Title: Flights Time Limit: None seconds Memory Limit: None megabytes Problem Description: LiLand is a country, consisting of *n* cities. The cities are numbered from 1 to *n*. The country is well known because it has a very strange transportation system. There are many one-way flights that make it possible to travel...
3,139
Title: Servers Time Limit: None seconds Memory Limit: None megabytes Problem Description: There are *n* servers in a laboratory, each of them can perform tasks. Each server has a unique id — integer from 1 to *n*. It is known that during the day *q* tasks will come, the *i*-th of them is characterized with three in...
3,140
Title: Matrix Time Limit: None seconds Memory Limit: None megabytes Problem Description: You have a string of decimal digits *s*. Let's define *b**ij*<==<=*s**i*·*s**j*. Find in matrix *b* the number of such rectangles that the sum *b**ij* for all cells (*i*,<=*j*) that are the elements of the rectangle equals *a* i...
3,141
Title: Supercentral Point Time Limit: None seconds Memory Limit: None megabytes Problem Description: One day Vasya painted a Cartesian coordinate system on a piece of paper and marked some set of points (*x*1,<=*y*1),<=(*x*2,<=*y*2),<=...,<=(*x**n*,<=*y**n*). Let's define neighbors for some fixed point from the give...
3,142
Title: The Bakery Time Limit: None seconds Memory Limit: None megabytes Problem Description: Some time ago Slastyona the Sweetmaid decided to open her own bakery! She bought required ingredients and a wonder-oven which can bake several types of cakes, and opened the bakery. Soon the expenses started to overcome the...
3,143
Title: Prizes, Prizes, more Prizes Time Limit: None seconds Memory Limit: None megabytes Problem Description: Vasya, like many others, likes to participate in a variety of sweepstakes and lotteries. Now he collects wrappings from a famous chocolate bar "Jupiter". According to the sweepstake rules, each wrapping has ...
3,144
Title: Satellites Time Limit: None seconds Memory Limit: None megabytes Problem Description: Real Cosmic Communications is the largest telecommunication company on a far far away planet, located at the very edge of the universe. RCC launches communication satellites. The planet is at the very edge of the universe, ...
3,145
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: Leha like all kinds of strange things. Recently he liked the function *F*(*n*,<=*k*). Consider all possible *k*-element subsets of the set [1,<=2,<=...,<=*n*]. For subset find minimal element in it. *F*(*n*,<=*k*) — mathematical e...
3,146
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: One day, Hongcow goes to the store and sees a brand new deck of *n* special cards. Each individual card is either red or blue. He decides he wants to buy them immediately. To do this, he needs to play a game with the owner of the ...
3,147
Title: Runner's Problem Time Limit: None seconds Memory Limit: None megabytes Problem Description: You are running through a rectangular field. This field can be represented as a matrix with 3 rows and *m* columns. (*i*,<=*j*) denotes a cell belonging to *i*-th row and *j*-th column. You start in (2,<=1) and have t...
3,148
Title: Riverside Curio Time Limit: None seconds Memory Limit: None megabytes Problem Description: Arkady decides to observe a river for *n* consecutive days. The river's water level on each day is equal to some real value. Arkady goes to the riverside each day and makes a mark on the side of the channel at the heig...
3,149
Title: Nuclear Fusion Time Limit: 1 seconds Memory Limit: 256 megabytes Problem Description: There is the following puzzle popular among nuclear physicists. A reactor contains a set of *n* atoms of some chemical elements. We shall understand the phrase "atomic number" as the number of this atom's element in the per...
3,150
Title: Igor and his way to work Time Limit: None seconds Memory Limit: None megabytes Problem Description: Woken up by the alarm clock Igor the financial analyst hurried up to the work. He ate his breakfast and sat in his car. Sadly, when he opened his GPS navigator, he found that some of the roads in Bankopolis, th...
3,151
Title: Bad Luck Island Time Limit: None seconds Memory Limit: None megabytes Problem Description: The Bad Luck Island is inhabited by three kinds of species: *r* rocks, *s* scissors and *p* papers. At some moments of time two random individuals meet (all pairs of individuals can meet equiprobably), and if they belon...
3,152
Title: Free Market Time Limit: None seconds Memory Limit: None megabytes Problem Description: John Doe has recently found a "Free Market" in his city — that is the place where you can exchange some of your possessions for other things for free. John knows that his city has *n* items in total (each item is unique)....
3,153
Title: Games with Rectangle Time Limit: None seconds Memory Limit: None megabytes Problem Description: In this task Anna and Maria play the following game. Initially they have a checkered piece of paper with a painted *n*<=×<=*m* rectangle (only the border, no filling). Anna and Maria move in turns and Anna starts. ...
3,154
Title: Cows and Cool Sequences Time Limit: None seconds Memory Limit: None megabytes Problem Description: Bessie and the cows have recently been playing with "cool" sequences and are trying to construct some. Unfortunately they are bad at arithmetic, so they need your help! A pair (*x*,<=*y*) of positive integers i...
3,155
Title: Permutation Cycle Time Limit: None seconds Memory Limit: None megabytes Problem Description: For a permutation *P*[1... *N*] of integers from 1 to *N*, function *f* is defined as follows: Let *g*(*i*) be the minimum positive integer *j* such that *f*(*i*,<=*j*)<==<=*i*. We can show such *j* always exists. F...
3,156
Title: Numbers on the blackboard Time Limit: None seconds Memory Limit: None megabytes Problem Description: A sequence of *n* integers is written on a blackboard. Soon Sasha will come to the blackboard and start the following actions: let *x* and *y* be two adjacent numbers (*x* before *y*), then he can remove them ...
3,157
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: Polycarp has a strict daily schedule. He has *n* alarms set for each day, and the *i*-th alarm rings each day at the same time during exactly one minute. Determine the longest time segment when Polycarp can sleep, i. e. no alarm ...
3,158
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: Codeforces is a wonderful platform and one its feature shows how much someone contributes to the community. Every registered user has contribution — an integer number, not necessarily positive. There are *n* registered users and t...
3,159
Title: Inversion Counting Time Limit: None seconds Memory Limit: None megabytes Problem Description: A permutation of size *n* is an array of size *n* such that each integer from 1 to *n* occurs exactly once in this array. An inversion in a permutation *p* is a pair of indices (*i*,<=*j*) such that *i*<=&gt;<=*j* an...
3,160
Title: A Creative Cutout Time Limit: None seconds Memory Limit: None megabytes Problem Description: Everything red frightens Nian the monster. So do red paper and... you, red on Codeforces, potential or real. Big Banban has got a piece of paper with endless lattice points, where lattice points form squares with the...
3,161
Title: Queries for Number of Palindromes Time Limit: None seconds Memory Limit: None megabytes Problem Description: You've got a string *s*<==<=*s*1*s*2... *s*|*s*| of length |*s*|, consisting of lowercase English letters. There also are *q* queries, each query is described by two integers *l**i*,<=*r**i* (1<=≤<=*l*...
3,162
Title: Plane of Tanks: Pro Time Limit: None seconds Memory Limit: None megabytes Problem Description: Vasya has been playing Plane of Tanks with his friends the whole year. Now it is time to divide the participants into several categories depending on their results. A player is given a non-negative integer number ...
3,163
Title: Paper Airplanes Time Limit: None seconds Memory Limit: None megabytes Problem Description: To make a paper airplane, one has to use a rectangular piece of paper. From a sheet of standard size you can make $s$ airplanes. A group of $k$ people decided to make $n$ airplanes each. They are going to buy several p...
3,164
Title: Straight <<A>> Time Limit: None seconds Memory Limit: None megabytes Problem Description: Noora is a student of one famous high school. It's her final year in school — she is going to study in university next year. However, she has to get an «A» graduation certificate in order to apply to a prestigious one. ...
3,165
Title: Okabe and City Time Limit: None seconds Memory Limit: None megabytes Problem Description: Okabe likes to be able to walk through his city on a path lit by street lamps. That way, he doesn't get beaten up by schoolchildren. Okabe's city is represented by a 2D grid of cells. Rows are numbered from 1 to *n* fro...
3,166
Title: Cowmpany Cowmpensation Time Limit: None seconds Memory Limit: None megabytes Problem Description: Allen, having graduated from the MOO Institute of Techcowlogy (MIT), has started a startup! Allen is the president of his startup. He also hires $n-1$ other employees, each of which is assigned a direct superior....
3,167
Title: Bash's Big Day Time Limit: None seconds Memory Limit: None megabytes Problem Description: Bash has set out on a journey to become the greatest Pokemon master. To get his first Pokemon, he went to Professor Zulu's Lab. Since Bash is Professor Zulu's favourite student, Zulu allows him to take as many Pokemon fr...
3,168
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: Test data generation is not an easy task! Often, generating big random test cases is not enough to ensure thorough testing of solutions for correctness. For example, consider a problem from an old Codeforces round. Its input form...
3,169
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: International Abbreviation Olympiad takes place annually starting from 1989. Each year the competition receives an abbreviation of form IAO'y, where *y* stands for some number of consequent last digits of the current year. Organiz...
3,170
Title: Bear and Finding Criminals Time Limit: None seconds Memory Limit: None megabytes Problem Description: There are *n* cities in Bearland, numbered 1 through *n*. Cities are arranged in one long row. The distance between cities *i* and *j* is equal to |*i*<=-<=*j*|. Limak is a police officer. He lives in a city...
3,171
Title: Uniformly Branched Trees Time Limit: None seconds Memory Limit: None megabytes Problem Description: A tree is a connected graph without cycles. Two trees, consisting of *n* vertices each, are called isomorphic if there exists a permutation *p*:<={1,<=...,<=*n*}<=→<={1,<=...,<=*n*} such that the edge (*u*,<=*...
3,172
Title: The Last Fight Between Human and AI Time Limit: None seconds Memory Limit: None megabytes Problem Description: 100 years have passed since the last victory of the man versus computer in Go. Technologies made a huge step forward and robots conquered the Earth! It's time for the final fight between human and ro...
3,173
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: Arkady decides to observe a river for *n* consecutive days. The river's water level on each day is equal to some real value. Arkady goes to the riverside each day and makes a mark on the side of the channel at the height of the w...
3,174
Title: Tourist Reform Time Limit: None seconds Memory Limit: None megabytes Problem Description: Berland is a tourist country! At least, it can become such — the government of Berland is confident about this. There are *n* cities in Berland, some pairs of which are connected by two-ways roads. Each road connects t...
3,175
Title: Sequence Formatting Time Limit: 2 seconds Memory Limit: 256 megabytes Problem Description: Polycarp is very careful. He even types numeric sequences carefully, unlike his classmates. If he sees a sequence without a space after the comma, with two spaces in a row, or when something else does not look neat, he ...
3,176
Title: A Vital Problem Time Limit: None seconds Memory Limit: None megabytes Problem Description: Polycarp has a strict daily schedule. He has *n* alarms set for each day, and the *i*-th alarm rings each day at the same time during exactly one minute. Determine the longest time segment when Polycarp can sleep, i. e...
3,177
Title: Party Time Limit: None seconds Memory Limit: None megabytes Problem Description: Arseny likes to organize parties and invite people to it. However, not only friends come to his parties, but friends of his friends, friends of friends of his friends and so on. That's why some of Arseny's guests can be unknown t...
3,178
Title: Strongly Connected City 2 Time Limit: None seconds Memory Limit: None megabytes Problem Description: Imagine a city with *n* junctions and *m* streets. Junctions are numbered from 1 to *n*. In order to increase the traffic flow, mayor of the city has decided to make each street one-way. This means in the str...
3,179
Title: Opposites Attract Time Limit: None seconds Memory Limit: None megabytes Problem Description: Everybody knows that opposites attract. That is the key principle of the "Perfect Matching" dating agency. The "Perfect Matching" matchmakers have classified each registered customer by his interests and assigned to t...
3,180
Title: Kolya and Tandem Repeat Time Limit: None seconds Memory Limit: None megabytes Problem Description: Kolya got string *s* for his birthday, the string consists of small English letters. He immediately added *k* more characters to the right of the string. Then Borya came and said that the new string contained a...
3,181
Title: Endless Roses Most Beautiful Time Limit: None seconds Memory Limit: None megabytes Problem Description: Arkady decided to buy roses for his girlfriend. A flower shop has white, orange and red roses, and the total amount of them is *n*. Arkady thinks that red roses are not good together with white roses, so h...
3,182
Title: Spoilt Permutation Time Limit: 2 seconds Memory Limit: 256 megabytes Problem Description: Vasya collects coins: he has exactly one coin for every year from 1 to *n*. Naturally, Vasya keeps all the coins in his collection in the order in which they were released. Once Vasya's younger brother made a change — he...
3,183
Title: Passwords Time Limit: None seconds Memory Limit: None megabytes Problem Description: Vanya is managed to enter his favourite site Codehorses. Vanya uses *n* distinct passwords for sites at all, however he can't remember which one exactly he specified during Codehorses registration. Vanya will enter passwords...
3,184
Title: Permutations Time Limit: None seconds Memory Limit: None megabytes Problem Description: You are given a permutation *p* of numbers 1,<=2,<=...,<=*n*. Let's define *f*(*p*) as the following sum: Find the lexicographically *m*-th permutation of length *n* in the set of permutations having the maximum possible ...
3,185
Title: Keyboard Layouts Time Limit: None seconds Memory Limit: None megabytes Problem Description: There are two popular keyboard layouts in Berland, they differ only in letters positions. All the other keys are the same. In Berland they use alphabet with 26 letters which coincides with English alphabet. You are gi...
3,186
Title: Drazil and His Happy Friends Time Limit: None seconds Memory Limit: None megabytes Problem Description: Drazil has many friends. Some of them are happy and some of them are unhappy. Drazil wants to make all his friends become happy. So he invented the following plan. There are *n* boys and *m* girls among hi...
3,187
Title: Splitting the Uniqueness Time Limit: None seconds Memory Limit: None megabytes Problem Description: Polar bears like unique arrays — that is, arrays without repeated elements. You have got a unique array *s* with length *n* containing non-negative integers. Since you are good friends with Alice and Bob, you...
3,188
Title: Vasily the Bear and Painting Square Time Limit: None seconds Memory Limit: None megabytes Problem Description: Vasily the bear has two favorite integers *n* and *k* and a pencil. Besides, he's got *k* jars with different water color paints. All jars are numbered in some manner from 1 to *k*, inclusive. The ja...
3,189
Title: Aztec Catacombs Time Limit: None seconds Memory Limit: None megabytes Problem Description: Indiana Jones found ancient Aztec catacombs containing a golden idol. The catacombs consists of $n$ caves. Each pair of caves is connected with a two-way corridor that can be opened or closed. The entrance to the cataco...
3,190
Title: Maximum Submatrix 2 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 t...
3,191
Title: Multiplication Table Time Limit: 2 seconds Memory Limit: 64 megabytes Problem Description: Petya studies positional notations. He has already learned to add and subtract numbers in the systems of notations with different radices and has moved on to a more complicated action — multiplication. To multiply large...
3,192
Title: Day at the Beach Time Limit: None seconds Memory Limit: None megabytes Problem Description: One day Squidward, Spongebob and Patrick decided to go to the beach. Unfortunately, the weather was bad, so the friends were unable to ride waves. However, they decided to spent their time building sand castles. At th...
3,193
Title: Flights for Regular Customers Time Limit: None seconds Memory Limit: None megabytes Problem Description: In the country there are exactly *n* cities numbered with positive integers from 1 to *n*. In each city there is an airport is located. Also, there is the only one airline, which makes *m* flights. Unfort...
3,194
Title: Minimum spanning tree for each edge Time Limit: None seconds Memory Limit: None megabytes Problem Description: Connected undirected weighted graph without self-loops and multiple edges is given. Graph contains *n* vertices and *m* edges. For each edge (*u*,<=*v*) find the minimal possible weight of the spann...
3,195
Title: Memory Manager Time Limit: 1 seconds Memory Limit: 64 megabytes Problem Description: There is little time left before the release of the first national operating system BerlOS. Some of its components are not finished yet — the memory manager is among them. According to the developers' plan, in the first relea...
3,196
Title: Balloons Time Limit: None seconds Memory Limit: None megabytes Problem Description: There are quite a lot of ways to have fun with inflatable balloons. For example, you can fill them with water and see what happens. Grigory and Andrew have the same opinion. So, once upon a time, they went to the shop and bou...
3,197
Title: Buy One, Get One Free Time Limit: None seconds Memory Limit: None megabytes Problem Description: A nearby pie shop is having a special sale. For each pie you pay full price for, you may select one pie of a strictly lesser value to get for free. Given the prices of all the pies you wish to acquire, determine t...
3,198
Title: Transformation: from A to B Time Limit: None seconds Memory Limit: None megabytes Problem Description: Vasily has a number *a*, which he wants to turn into a number *b*. For this purpose, he can do two types of operations: - multiply the current number by 2 (that is, replace the number *x* by 2·*x*); - app...
3,199