task
stringlengths
0
154k
__index_level_0__
int64
0
39.2k
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: Ostap already settled down in Rio de Janiero suburb and started to grow a tree in his garden. Recall that a tree is a connected undirected acyclic graph. Ostap's tree now has *n* vertices. He wants to paint some vertices of the ...
2,500
Title: Blackjack Time Limit: 2 seconds Memory Limit: 256 megabytes Problem Description: One rainy gloomy evening when all modules hid in the nearby cafes to drink hot energetic cocktails, the Hexadecimal virus decided to fly over the Mainframe to look for a Great Idea. And she has found one! Why not make her own Co...
2,501
Title: Fix a Tree Time Limit: None seconds Memory Limit: None megabytes Problem Description: A tree is an undirected connected graph without cycles. Let's consider a rooted undirected tree with *n* vertices, numbered 1 through *n*. There are many ways to represent such a tree. One way is to create an array with *n*...
2,502
Title: k-d-sequence Time Limit: None seconds Memory Limit: None megabytes Problem Description: We'll call a sequence of integers a good *k*-*d* sequence if we can add to it at most *k* numbers in such a way that after the sorting the sequence will be an arithmetic progression with difference *d*. You got hold of so...
2,503
Title: Deleting Substrings Time Limit: None seconds Memory Limit: None megabytes Problem Description: SmallR likes a game called "Deleting Substrings". In the game you are given a sequence of integers *w*, you can modify the sequence and get points. The only type of modification you can perform is (unexpected, right...
2,504
Title: K-Dominant Character Time Limit: None seconds Memory Limit: None megabytes Problem Description: You are given a string *s* consisting of lowercase Latin letters. Character *c* is called *k*-dominant iff each substring of *s* with length at least *k* contains this character *c*. You have to find minimum *k* s...
2,505
Title: Pashmak and Buses Time Limit: None seconds Memory Limit: None megabytes Problem Description: Recently Pashmak has been employed in a transportation company. The company has *k* buses and has a contract with a school which has *n* students. The school planned to take the students to *d* different places for *d...
2,506
Title: Students Initiation Time Limit: None seconds Memory Limit: None megabytes Problem Description: Soon the first year students will be initiated into students at the University of Berland. The organizers of the initiation come up with a program for this holiday. In their opinion, it would be good if the first-ye...
2,507
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: Little Petya very much likes arrays consisting of *n* integers, where each of them is in the range from 1 to 109, inclusive. Recently he has received one such array as a gift from his mother. Petya didn't like it at once. He decid...
2,508
Title: Sereja and Mugs Time Limit: None seconds Memory Limit: None megabytes Problem Description: Sereja showed an interesting game to his friends. The game goes like that. Initially, there is a table with an empty cup and *n* water mugs on it. Then all players take turns to move. During a move, a player takes a non...
2,509
Title: Optimize! Time Limit: None seconds Memory Limit: None megabytes Problem Description: Manao is solving a problem with the following statement: He came up with a solution that produces the correct answers but is too slow. You are given the pseudocode of his solution, where the function getAnswer calculates the...
2,510
Title: Finals in arithmetic Time Limit: None seconds Memory Limit: None megabytes Problem Description: Vitya is studying in the third grade. During the last math lesson all the pupils wrote on arithmetic quiz. Vitya is a clever boy, so he managed to finish all the tasks pretty fast and Oksana Fillipovna gave him a n...
2,511
Title: GukiZ and Contest Time Limit: None seconds Memory Limit: None megabytes Problem Description: Professor GukiZ likes programming contests. He especially likes to rate his students on the contests he prepares. Now, he has decided to prepare a new contest. In total, *n* students will attend, and before the star...
2,512
Title: Fox And Travelling Time Limit: None seconds Memory Limit: None megabytes Problem Description: Fox Ciel is going to travel to New Foxland during this summer. New Foxland has *n* attractions that are linked by *m* undirected roads. Two attractions are called adjacent if they are linked by a road. Fox Ciel has ...
2,513
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: Iahub likes trees very much. Recently he discovered an interesting tree named propagating tree. The tree consists of *n* nodes numbered from 1 to *n*, each node *i* having an initial value *a**i*. The root of the tree is node 1. ...
2,514
Title: New Year Book Reading Time Limit: None seconds Memory Limit: None megabytes Problem Description: New Year is coming, and Jaehyun decided to read many books during 2015, unlike this year. He has *n* books numbered by integers from 1 to *n*. The weight of the *i*-th (1<=≀<=*i*<=≀<=*n*) book is *w**i*. As Jaehy...
2,515
Title: Playing with String Time Limit: None seconds Memory Limit: None megabytes Problem Description: Two people play the following string game. Initially the players have got some string *s*. The players move in turns, the player who cannot make a move loses. Before the game began, the string is written on a piec...
2,516
Title: Robot Bicorn Attack Time Limit: None seconds Memory Limit: None megabytes Problem Description: Vasya plays Robot Bicorn Attack. The game consists of three rounds. For each one a non-negative integer amount of points is given. The result of the game is the sum of obtained points. Vasya has already played thre...
2,517
Title: Archer's Shot Time Limit: 2 seconds Memory Limit: 256 megabytes Problem Description: A breakthrough among computer games, "Civilization XIII", is striking in its scale and elaborate details. Let's take a closer look at one of them. The playing area in the game is split into congruent cells that are regular h...
2,518
Title: Inna and Babies Time Limit: None seconds Memory Limit: None megabytes Problem Description: Inna, Dima and Sereja are in one room together. It's cold outside, so Sereja suggested to play a board game called "Babies". The babies playing board is an infinite plane containing *n* blue babies and *m* red ones. E...
2,519
Title: Substrings in a String Time Limit: None seconds Memory Limit: None megabytes Problem Description: Given a string *s*, process *q* queries, each having one of the following forms: - 1<=*i*<=*c* β€” Change the *i*-th character in the string to *c*. - 2<=*l*<=*r*<=*y* β€” Consider the substring of *s* starting at...
2,520
Title: Primes on Interval Time Limit: None seconds Memory Limit: None megabytes Problem Description: You've decided to carry out a survey in the theory of prime numbers. Let us remind you that a prime number is a positive integer that has exactly two distinct positive integer divisors. Consider positive integers *a...
2,521
Title: Help Farmer Time Limit: None seconds Memory Limit: None megabytes Problem Description: Once upon a time in the Kingdom of Far Far Away lived Sam the Farmer. Sam had a cow named Dawn and he was deeply attached to her. Sam would spend the whole summer stocking hay to feed Dawn in winter. Sam scythed hay and put...
2,522
Title: Frames Time Limit: 2 seconds Memory Limit: 256 megabytes Problem Description: Throughout Igor K.'s life he has had many situations worthy of attention. We remember the story with the virus, the story of his mathematical career and of course, his famous programming achievements. However, one does not always ad...
2,523
Title: Yaroslav and Permutations Time Limit: None seconds Memory Limit: None megabytes Problem Description: Yaroslav has an array that consists of *n* integers. In one second Yaroslav can swap two neighboring array elements. Now Yaroslav is wondering if he can obtain an array where any two neighboring elements would...
2,524
Title: Ilya And The Tree Time Limit: None seconds Memory Limit: None megabytes Problem Description: Ilya is very fond of graphs, especially trees. During his last trip to the forest Ilya found a very interesting tree rooted at vertex 1. There is an integer number written on each vertex of the tree; the number writte...
2,525
Title: Wet Shark and Odd and Even Time Limit: None seconds Memory Limit: None megabytes Problem Description: Today, Wet Shark is given *n* integers. Using any of these integers no more than once, Wet Shark wants to get maximum possible even (divisible by 2) sum. Please, calculate this value for Wet Shark. Note, th...
2,526
Title: Robot Vacuum Cleaner Time Limit: None seconds Memory Limit: None megabytes Problem Description: Pushok the dog has been chasing Imp for a few hours already. Fortunately, Imp knows that Pushok is afraid of a robot vacuum cleaner. While moving, the robot generates a string *t* consisting of letters 's' and '...
2,527
Title: Eight Point Sets Time Limit: None seconds Memory Limit: None megabytes Problem Description: Gerald is very particular to eight point sets. He thinks that any decent eight point set must consist of all pairwise intersections of three distinct integer vertical straight lines and three distinct integer horizonta...
2,528
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: Paul hates palindromes. He assumes that string *s* is tolerable if each its character is one of the first *p* letters of the English alphabet and *s* doesn't contain any palindrome contiguous substring of length 2 or more. Paul h...
2,529
Title: Power Consumption Calculation Time Limit: 1 seconds Memory Limit: 256 megabytes Problem Description: Tom is interested in power consumption of his favourite laptop. His laptop has three modes. In normal mode laptop consumes *P*1 watt per minute. *T*1 minutes after Tom moved the mouse or touched the keyboard f...
2,530
Title: Fruits Time Limit: 1 seconds Memory Limit: 256 megabytes Problem Description: The spring is coming and it means that a lot of fruits appear on the counters. One sunny day little boy Valera decided to go shopping. He made a list of *m* fruits he wanted to buy. If Valera want to buy more than one fruit of some ...
2,531
Title: Watching a movie Time Limit: None seconds Memory Limit: None megabytes Problem Description: You have decided to watch the best moments of some movie. There are two buttons on your player: 1. Watch the current minute of the movie. By pressing this button, you watch the current minute of the movie and the pl...
2,532
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: A very brave explorer Petya once decided to explore Paris catacombs. Since Petya is not really experienced, his exploration is just walking through the catacombs. Catacombs consist of several rooms and bidirectional passages betw...
2,533
Title: Minimize the error Time Limit: None seconds Memory Limit: None megabytes Problem Description: You are given two arrays *A* and *B*, each of size *n*. The error, *E*, between these two arrays is defined . You have to perform exactly *k*1 operations on array *A* and exactly *k*2 operations on array *B*. In one ...
2,534
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: Stepan had a favorite string *s* which consisted of the lowercase letters of the Latin alphabet. After graduation, he decided to remember it, but it was a long time ago, so he can't now remember it. But Stepan remembers some inf...
2,535
Title: Composing Of String Time Limit: None seconds Memory Limit: None megabytes Problem Description: Stepan has a set of *n* strings. Also, he has a favorite string *s*. Stepan wants to do the following. He will take some strings of his set and write them down one after another. It is possible that he will take s...
2,536
Title: Recover Polygon (easy) Time Limit: None seconds Memory Limit: None megabytes Problem Description: The zombies are gathering in their secret lair! Heidi will strike hard to destroy them once and for all. But there is a little problem... Before she can strike, she needs to know where the lair is. And the intel ...
2,537
Title: You're a Professional Time Limit: None seconds Memory Limit: None megabytes Problem Description: A simple recommendation system would recommend a user things liked by a certain number of their friends. In this problem you will implement part of such a system. You are given user's friends' opinions about a li...
2,538
Title: Magic Forest Time Limit: None seconds Memory Limit: None megabytes Problem Description: Imp is in a magic forest, where xorangles grow (wut?) A xorangle of order *n* is such a non-degenerate triangle, that lengths of its sides are integers not exceeding *n*, and the xor-sum of the lengths is equal to zero. I...
2,539
Title: Hexagons! Time Limit: None seconds Memory Limit: None megabytes Problem Description: After a probationary period in the game development company of IT City Petya was included in a group of the programmers that develops a new turn-based strategy game resembling the well known "Heroes of Might &amp; Magic". A p...
2,540
Title: Chocolate Time Limit: None seconds Memory Limit: None megabytes Problem Description: Bob loves everything sweet. His favorite chocolate bar consists of pieces, each piece may contain a nut. Bob wants to break the bar of chocolate into multiple pieces so that each part would contain exactly one nut and any bre...
2,541
Title: Polycarp's Pockets Time Limit: None seconds Memory Limit: None megabytes Problem Description: Polycarp has $n$ coins, the value of the $i$-th coin is $a_i$. Polycarp wants to distribute all the coins between his pockets, but he cannot put two coins with the same value into the same pocket. For example, if Po...
2,542
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: Andryusha goes through a park each day. The squares and paths between them look boring to Andryusha, so he decided to decorate them. The park consists of *n* squares connected with (*n*<=-<=1) bidirectional paths in such a way th...
2,543
Title: Beautiful Divisors Time Limit: None seconds Memory Limit: None megabytes Problem Description: Recently Luba learned about a special kind of numbers that she calls beautiful numbers. The number is called beautiful iff its binary representation consists of *k*<=+<=1 consecutive ones, and then *k* consecutive ze...
2,544
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: Nearly each project of the F company has a whole team of developers working on it. They often are in different rooms of the office in different cities and even countries. To keep in touch and track the results of the project, the ...
2,545
Title: Graph Cutting Time Limit: None seconds Memory Limit: None megabytes Problem Description: Little Chris is participating in a graph cutting contest. He's a pro. The time has come to test his skills to the fullest. Chris is given a simple undirected connected graph with *n* vertices (numbered from 1 to *n*) and...
2,546
Title: Machine Programming Time Limit: None seconds Memory Limit: None megabytes Problem Description: One remarkable day company "X" received *k* machines. And they were not simple machines, they were mechanical programmers! This was the last unsuccessful step before switching to android programmers, but that's anot...
2,547
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: After a wonderful evening in the restaurant the time to go home came. Leha as a true gentlemen suggested Noora to give her a lift. Certainly the girl agreed with pleasure. Suddenly one problem appeared: Leha cannot find his car on...
2,548
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: Yaroslav likes algorithms. We'll describe one of his favorite algorithms. 1. The algorithm receives a string as the input. We denote this input string as *a*. 1. The algorithm consists of some number of command. Π‘ommand number ...
2,549
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: A sum of *p* rubles is charged from Arkady's mobile phone account every day in the morning. Among the following *m* days, there are *n* days when Arkady will top up the account: in the day *d**i* he will deposit *t**i* rubles on h...
2,550
Title: Cosmic Tables Time Limit: None seconds Memory Limit: None megabytes Problem Description: The Free Meteor Association (FMA) has got a problem: as meteors are moving, the Universal Cosmic Descriptive Humorous Program (UCDHP) needs to add a special module that would analyze this movement. UCDHP stores some sec...
2,551
Title: Da Vinci Powers Time Limit: None seconds Memory Limit: None megabytes Problem Description: The input contains a single integer *a* (0<=≀<=*a*<=≀<=35). Output a single integer. Input Specification: The input contains a single integer *a* (0<=≀<=*a*<=≀<=35). Output Specification: Output a single integer. De...
2,552
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: Farmer John has just given the cows a program to play with! The program contains two integer variables, *x* and *y*, and performs the following operations on a sequence *a*1,<=*a*2,<=...,<=*a**n* of positive integers: 1. Initial...
2,553
Title: Not Equal on a Segment Time Limit: None seconds Memory Limit: None megabytes Problem Description: You are given array *a* with *n* integers and *m* queries. The *i*-th query is given with three integers *l**i*,<=*r**i*,<=*x**i*. For the *i*-th query find any position *p**i* (*l**i*<=≀<=*p**i*<=≀<=*r**i*) so ...
2,554
Title: Polo the Penguin and Segments Time Limit: None seconds Memory Limit: None megabytes Problem Description: Little penguin Polo adores integer segments, that is, pairs of integers [*l*;Β *r*] (*l*<=≀<=*r*). He has a set that consists of *n* integer segments: [*l*1;Β *r*1],<=[*l*2;Β *r*2],<=...,<=[*l**n*;Β *r**n*]...
2,555
Title: Sorting the Coins Time Limit: None seconds Memory Limit: None megabytes Problem Description: Recently, Dima met with Sasha in a philatelic store, and since then they are collecting coins together. Their favorite occupation is to sort collections of coins. Sasha likes having things in order, that is why he wan...
2,556
Title: Privatization Time Limit: None seconds Memory Limit: None megabytes Problem Description: There is a developed network of flights between Berland and Beerland. All of them belong to the Berland state company BerAvia. Each flight connects some Berland city with some Beerland city. For each flight airplanes fly ...
2,557
Title: R2D2 and Droid Army Time Limit: None seconds Memory Limit: None megabytes Problem Description: An army of *n* droids is lined up in one row. Each droid is described by *m* integers *a*1,<=*a*2,<=...,<=*a**m*, where *a**i* is the number of details of the *i*-th type in this droid's mechanism. R2-D2 wants to de...
2,558
Title: Tufurama Time Limit: None seconds Memory Limit: None megabytes Problem Description: One day Polycarp decided to rewatch his absolute favourite episode of well-known TV series "Tufurama". He was pretty surprised when he got results only for season 7 episode 3 with his search query of "Watch Tufurama season 3 e...
2,559
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: You've got string *s*, consisting of only lowercase English letters. Find its lexicographically maximum subsequence. We'll call a non-empty string *s*[*p*1*p*2... *p**k*]<==<=*s**p*1*s**p*2... *s**p**k*(1<=≀<=*p*1<=&lt;<=*p*2<=&l...
2,560
Title: Vladik and Favorite Game Time Limit: None seconds Memory Limit: None megabytes Problem Description: This is an interactive problem. Vladik has favorite game, in which he plays all his free time. Game field could be represented as *n*<=Γ—<=*m* matrix which consists of cells of three types: - Β«.Β» β€” normal c...
2,561
Title: Domino Effect Time Limit: None seconds Memory Limit: None megabytes Problem Description: Little Chris knows there's no fun in playing dominoes, he thinks it's too random and doesn't require skill. Instead, he decided to play with the dominoes and make a "domino show". Chris arranges *n* dominoes in a line, p...
2,562
Title: Large Bouquets Time Limit: None seconds Memory Limit: None megabytes Problem Description: A flower shop has got *n* bouquets, and the *i*-th bouquet consists of *a**i* flowers. Vasya, the manager of the shop, decided to make large bouquets from these bouquets. Vasya thinks that a bouquet is large if it is m...
2,563
Title: Number Clicker Time Limit: None seconds Memory Limit: None megabytes Problem Description: Allen is playing Number Clicker on his phone. He starts with an integer $u$ on the screen. Every second, he can press one of 3 buttons. 1. Turn $u \to u+1 \pmod{p}$. 1. Turn $u \to u+p-1 \pmod{p}$. 1. Turn $u \to u^...
2,564
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: We have a string of letters 'a' and 'b'. We want to perform some operations on it. On each step we choose one of substrings "ab" in the string and replace it with the string "bba". If we have no "ab" as a substring, our job is don...
2,565
Title: A Blend of Springtime Time Limit: None seconds Memory Limit: None megabytes Problem Description: "What a pity it's already late spring," sighs Mino with regret, "one more drizzling night and they'd be gone." "But these blends are at their best, aren't they?" Absorbed in the landscape, Kanno remains optimisti...
2,566
Title: Tic-Tac-Toe Time Limit: None seconds Memory Limit: None megabytes Problem Description: Two bears are playing tic-tac-toe via mail. It's boring for them to play usual tic-tac-toe game, so they are a playing modified version of this game. Here are its rules. The game is played on the following field. Players ...
2,567
Title: World Evil Time Limit: 5 seconds Memory Limit: 256 megabytes Problem Description: As a result of Pinky and Brain's mysterious experiments in the Large Hadron Collider some portals or black holes opened to the parallel dimension. And the World Evil has crept to the veil between their world and ours. Brain quic...
2,568
Title: Arthur and Questions Time Limit: None seconds Memory Limit: None megabytes Problem Description: After bracket sequences Arthur took up number theory. He has got a new favorite sequence of length *n* (*a*1,<=*a*2,<=...,<=*a**n*), consisting of integers and integer *k*, not exceeding *n*. This sequence had the...
2,569
Title: Instant Messanger Time Limit: None seconds Memory Limit: None megabytes Problem Description: User ainta decided to make a new instant messenger called "aintalk". With aintalk, each user can chat with other people. User ainta made the prototype of some functions to implement this thing. 1. login(*u*): User *...
2,570
Title: Maximum Waterfall Time Limit: None seconds Memory Limit: None megabytes Problem Description: Emuskald was hired to design an artificial waterfall according to the latest trends in landscape architecture. A modern artificial waterfall consists of multiple horizontal panels affixed to a wide flat wall. The wate...
2,571
Title: Stepan's Series Time Limit: None seconds Memory Limit: None megabytes Problem Description: Well, the series which Stepan watched for a very long time, ended. In total, the series had *n* episodes. For each of them, Stepan remembers either that he definitely has watched it, or that he definitely hasn't watched...
2,572
Title: Epic Game Time Limit: None seconds Memory Limit: None megabytes Problem Description: Simon and Antisimon play a game. Initially each player receives one fixed positive integer that doesn't change throughout the game. Simon receives number *a* and Antisimon receives number *b*. They also have a heap of *n* sto...
2,573
Title: Statistics of Recompressing Videos Time Limit: None seconds Memory Limit: None megabytes Problem Description: A social network for dogs called DH (DogHouse) has *k* special servers to recompress uploaded videos of cute cats. After each video is uploaded, it should be recompressed on one (any) of the servers, ...
2,574
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: The Little Elephant has an integer *a*, written in the binary notation. He wants to write this number on a piece of paper. To make sure that the number *a* fits on the piece of paper, the Little Elephant ought to delete exactly o...
2,575
Title: Vasya's Calendar Time Limit: None seconds Memory Limit: None megabytes Problem Description: Vasya lives in a strange world. The year has *n* months and the *i*-th month has *a**i* days. Vasya got a New Year present β€” the clock that shows not only the time, but also the date. The clock's face can display any ...
2,576
Title: Greenhouse Effect Time Limit: None seconds Memory Limit: None megabytes Problem Description: Emuskald is an avid horticulturist and owns the world's longest greenhouse β€” it is effectively infinite in length. Over the years Emuskald has cultivated *n* plants in his greenhouse, of *m* different plant species n...
2,577
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: A sequence of non-negative integers *a*1,<=*a*2,<=...,<=*a**n* of length *n* is called a wool sequence if and only if there exists two integers *l* and *r* (1<=≀<=*l*<=≀<=*r*<=≀<=*n*) such that . In other words each wool sequence ...
2,578
Title: Pens And Days Of Week Time Limit: None seconds Memory Limit: None megabytes Problem Description: Stepan has *n* pens. Every day he uses them, and on the *i*-th day he uses the pen number *i*. On the (*n*<=+<=1)-th day again he uses the pen number 1, on the (*n*<=+<=2)-th β€” he uses the pen number 2 and so on. ...
2,579
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: You are given a tree (a graph with *n* vertices and *n*<=-<=1 edges in which it's possible to reach any vertex from any other vertex using only its edges). A vertex can be destroyed if this vertex has even degree. If you destroy ...
2,580
Title: New Year and Forgotten Tree Time Limit: None seconds Memory Limit: None megabytes Problem Description: A tree is a connected undirected graph with *n*<=-<=1 edges, where *n* denotes the number of vertices. Vertices are numbered 1 through *n*. Limak is a little polar bear. His bear family prepares a New Year...
2,581
Title: Tanya and Toys Time Limit: None seconds Memory Limit: None megabytes Problem Description: In Berland recently a new collection of toys went on sale. This collection consists of 109 types of toys, numbered with integers from 1 to 109. A toy from the new collection of the *i*-th type costs *i* bourles. Tania h...
2,582
Title: The Text Splitting Time Limit: None seconds Memory Limit: None megabytes Problem Description: You are given the string *s* of length *n* and the numbers *p*,<=*q*. Split the string *s* to pieces of length *p* and *q*. For example, the string "Hello" for *p*<==<=2, *q*<==<=3 can be split to the two strings "H...
2,583
Title: Game of the Rows Time Limit: None seconds Memory Limit: None megabytes Problem Description: Daenerys Targaryen has an army consisting of *k* groups of soldiers, the *i*-th group contains *a**i* soldiers. She wants to bring her army to the other side of the sea to get the Iron Throne. She has recently bought a...
2,584
Title: Orange Time Limit: None seconds Memory Limit: None megabytes Problem Description: Input Specification: The first line of the input is a string (between 1 and 50 characters long, inclusive). Each character will be a letter of English alphabet, lowercase or uppercase. The second line of the input is an integ...
2,585
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: It's a beautiful April day and Wallace is playing football with his friends. But his friends do not know that Wallace actually stayed home with Gromit and sent them his robotic self instead. Robo-Wallace has several advantages ove...
2,586
Title: Different Subsets For All Tuples Time Limit: None seconds Memory Limit: None megabytes Problem Description: For a sequence *a* of *n* integers between 1 and *m*, inclusive, denote *f*(*a*) as the number of distinct subsequences of *a* (including the empty subsequence). You are given two positive integers *n*...
2,587
Title: Lorry Time Limit: 2 seconds Memory Limit: 64 megabytes Problem Description: A group of tourists is going to kayak and catamaran tour. A rented lorry has arrived to the boat depot to take kayaks and catamarans to the point of departure. It's known that all kayaks are of the same size (and each of them occupies...
2,588
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: A famous sculptor Cicasso goes to a world tour! Well, it is not actually a world-wide. But not everyone should have the opportunity to see works of sculptor, shouldn't he? Otherwise there will be no any exclusivity. So Cicasso wi...
2,589
Title: Hongcow Learns the Cyclic Shift Time Limit: None seconds Memory Limit: None megabytes Problem Description: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to m...
2,590
Title: Walking in the Rain Time Limit: None seconds Memory Limit: None megabytes Problem Description: In Berland the opposition is going to arrange mass walking on the boulevard. The boulevard consists of *n* tiles that are lain in a row and are numbered from 1 to *n* from right to left. The opposition should start ...
2,591
Title: Planets Time Limit: None seconds Memory Limit: None megabytes Problem Description: Goa'uld Apophis captured Jack O'Neill's team again! Jack himself was able to escape, but by that time Apophis's ship had already jumped to hyperspace. But Jack knows on what planet will Apophis land. In order to save his friend...
2,592
Title: Parade Time Limit: 2 seconds Memory Limit: 64 megabytes Problem Description: No Great Victory anniversary in Berland has ever passed without the war parade. This year is not an exception. That’s why the preparations are on in full strength. Tanks are building a line, artillery mounts are ready to fire, soldie...
2,593
Title: Full Binary Tree Queries Time Limit: None seconds Memory Limit: None megabytes Problem Description: You have a full binary tree having infinite levels. Each node has an initial value. If a node has value *x*, then its left child has value 2Β·*x* and its right child has value 2Β·*x*<=+<=1. The value of the ro...
2,594
Title: Shave Beaver! Time Limit: None seconds Memory Limit: None megabytes Problem Description: The Smart Beaver has recently designed and built an innovative nanotechnologic all-purpose beaver mass shaving machine, "Beavershave 5000". Beavershave 5000 can shave beavers by families! How does it work? Very easily! T...
2,595
Title: Pencils and Boxes Time Limit: None seconds Memory Limit: None megabytes Problem Description: Mishka received a gift of multicolored pencils for his birthday! Unfortunately he lives in a monochrome world, where everything is of the same color and only saturation differs. This pack can be represented as a seque...
2,596
Title: Organizing a Race Time Limit: None seconds Memory Limit: None megabytes Problem Description: Kekoland is a country with *n* beautiful cities numbered from left to right and connected by *n*<=-<=1 roads. The *i*-th road connects cities *i* and *i*<=+<=1 and length of this road is *w**i* kilometers. When you ...
2,597
Title: Fishes Time Limit: None seconds Memory Limit: None megabytes Problem Description: While Grisha was celebrating New Year with Ded Moroz, Misha gifted Sasha a small rectangular pond of size *n*<=Γ—<=*m*, divided into cells of size 1<=Γ—<=1, inhabited by tiny evil fishes (no more than one fish per cell, otherwise ...
2,598
Title: Pupils Redistribution Time Limit: None seconds Memory Limit: None megabytes Problem Description: In Berland each high school student is characterized by academic performance β€” integer value between 1 and 5. In high school 0xFF there are two groups of pupils: the group *A* and the group *B*. Each group consis...
2,599