problem_statement stringlengths 147 8.53k | input stringlengths 1 771 | output stringlengths 1 592 β | time_limit stringclasses 32
values | memory_limit stringclasses 21
values | tags stringlengths 6 168 |
|---|---|---|---|---|---|
C. Biathlontime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputPerhaps many have heard that the World Biathlon Championship has finished. Although our hero Valera was not present at this spectacular event himself and only watched it on TV, it excited him so much that he ... | Input32 15 210 150 11 33 04 04 0 | Output23 3 -1 | 1 second | 256 megabytes | ['binary search', 'implementation', '*1700'] |
A. Toy Armytime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe hero of our story, Valera, and his best friend Arcady are still in school, and therefore they spend all the free time playing turn-based strategy "GAGA: Go And Go Again". The gameplay is as follows. Ther... | Input2 | Output3 | 2 seconds | 256 megabytes | ['math', 'number theory', '*900'] |
E. Two Subsequencestime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputOn an IT lesson Valera studied data compression. The teacher told about a new method, which we shall now describe to you.Let {a1,βa2,β...,βan} be the given sequence of lines needed to be compressed. ... | Input3011001 | Output4 | 2 seconds | 256 megabytes | ['bitmasks', 'dp', '*2800'] |
D. Numberstime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputOne quite ordinary day Valera went to school (there's nowhere else he should go on a week day). In a maths lesson his favorite teacher Ms. Evans told students about divisors. Despite the fact that Valera love... | Input1 10 2 | Output5 | 3 seconds | 256 megabytes | ['dp', 'math', 'number theory', '*2400'] |
C. Tracktime limit per test5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou already know that Valery's favorite sport is biathlon. Due to your help, he learned to shoot without missing, and his skills are unmatched at the shooting range. But now a smaller task is to be performed, h... | Input5 3 2SbacccaaccccabT | Outputbcccc | 5 seconds | 256 megabytes | ['graphs', 'greedy', 'shortest paths', '*2400'] |
B. Doctortime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere are n animals in the queue to Dr. Dolittle. When an animal comes into the office, the doctor examines him, gives prescriptions, appoints tests and may appoint extra examination. Doc knows all the forest ... | Input3 31 2 1 | Output2 | 2 seconds | 256 megabytes | ['binary search', 'math', 'sortings', '*1800'] |
A. Magical Arraytime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputValery is very interested in magic. Magic attracts him so much that he sees it everywhere. He explains any strange and weird phenomenon through intervention of supernatural forces. But who would have th... | Input42 1 1 4 | Output5 | 2 seconds | 256 megabytes | ['math', '*1300'] |
E. Corridortime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputConsider a house plan. Let the house be represented by an infinite horizontal strip defined by the inequality β-βhββ€βyββ€βh. Strictly outside the house there are two light sources at the points (0,βf) and (0,... | Input1 1 2-1 1 | Output10.0000000000 | 2 seconds | 256 megabytes | ['geometry', '*2600'] |
D. Two out of Threetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputVasya has recently developed a new algorithm to optimize the reception of customer flow and he considered the following problem.Let the queue to the cashier contain n people, at that each of them is ... | Input41 2 3 4 | Output61 23 4 | 2 seconds | 256 megabytes | ['dp', '*2000'] |
C. General Mobilizationtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe Berland Kingdom is a set of n cities connected with each other with nβ-β1 railways. Each road connects exactly two different cities. The capital is located in city 1. For each city there is a... | Input440 10 30 201 2 12 3 14 2 1 | Output0 1 3 2 | 2 seconds | 256 megabytes | ['data structures', 'dfs and similar', 'sortings', '*2000'] |
B. Setstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputLittle Vasya likes very much to play with sets consisting of positive integers. To make the game more interesting, Vasya chose n non-empty sets in such a way, that no two of them have common elements.One day he ... | Input43 2 7 43 1 7 33 5 4 23 1 3 54 3 1 2 42 5 7 | Output1 7 2 2 4 2 1 3 1 5 | 2 seconds | 256 megabytes | ['constructive algorithms', 'hashing', 'implementation', '*1700'] |
A. Double Colatime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputSheldon, Leonard, Penny, Rajesh and Howard are in the queue for a "Double Cola" drink vending machine; there are no other people in the queue. The first one in the queue (Sheldon) buys a can, drinks it and... | Input1 | OutputSheldon | 1 second | 256 megabytes | ['implementation', 'math', '*1100'] |
E. Pairstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere are n students in Polycarp's class (including himself). A few days ago all students wrote an essay "My best friend". Each student's essay was dedicated to one of the students of class, to his/her best frie... | Input55 23 25 12 14 2 | Output2 25 34 2 | 1 second | 256 megabytes | ['dfs and similar', 'dp', 'dsu', 'graphs', 'implementation', 'trees', '*2700'] |
D. Polycarp's Picture Gallerytime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputPolycarp loves not only to take pictures, but also to show his photos to friends. On his personal website he has recently installed a widget that can display n photos with the scroll option... | Input4 31 3 5 | Output3 1 3 2 | 2 seconds | 256 megabytes | ['constructive algorithms', 'greedy', '*2100'] |
C. Average Scoretime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAfter 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 teache... | Input53 24 4 5 4 4 | Output1 1 2 1 2 | 2 seconds | 256 megabytes | ['greedy', 'math', 'sortings', '*1700'] |
B. Sequence Formattingtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputPolycarp 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 ... | Input1,2 ,3,..., 10 | Output1, 2, 3, ..., 10 | 2 seconds | 256 megabytes | ['implementation', 'strings', '*1700'] |
A. Plug-intime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputPolycarp thinks about the meaning of life very often. He does this constantly, even when typing in the editor. Every time he starts brooding he can no longer fully concentrate and repeatedly presses the keys t... | Inputhhoowaaaareyyoouu | Outputwre | 1 second | 256 megabytes | ['implementation', '*1400'] |
B. Depressiontime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputDo you remember a kind cartoon "Beauty and the Beast"? No, no, there was no firing from machine guns or radiation mutants time-travels!There was a beauty named Belle. Once she had violated the Beast's order... | Input12:00 | Output0 0 | 1 second | 256 megabytes | ['geometry', 'math', '*1200'] |
A. Panoramix's Predictiontime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputA prime number is a number which has exactly two distinct divisors: one and itself. For example, numbers 2, 7, 3 are prime, and 1, 6, 4 are not.The next prime number after x is the smallest pri... | Input3 5 | OutputYES | 2 seconds | 256 megabytes | ['brute force', '*800'] |
E. Security Systemtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputFox Ciel safely returned to her castle, but there was something wrong with the security system of the castle: sensors attached in the castle were covering her.Ciel is at point (1,β1) of the castle now,... | Input5 25 2 4 1 | OutputRRUURURU | 1 second | 256 megabytes | ['math', '*2900'] |
D. Passwordtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputFinally Fox Ciel arrived in front of her castle!She have to type a password to enter her castle. An input device attached to her castle is a bit unusual.The input device is a 1βΓβn rectangle divided into n sq... | Input10 8 21 2 3 5 6 7 8 93 5 | Output2 | 1 second | 256 megabytes | ['bitmasks', 'dp', 'shortest paths', '*2800'] |
C. Beavertime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAfter Fox Ciel got off a bus, she found that the bus she was on was a wrong bus and she lost her way in a strange town. However, she fortunately met her friend Beaver Taro and asked which way to go to her cast... | InputGo_straight_along_this_street5strlongtreebigintegerellipse | Output12 4 | 2 seconds | 256 megabytes | ['data structures', 'dp', 'greedy', 'hashing', 'strings', 'two pointers', '*1800'] |
B. Colorful Fieldtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputFox Ciel saw a large field while she was on a bus. The field was a nβΓβm rectangle divided into 1βΓβ1 cells. Some cells were wasteland, and other each cell contained crop plants: either carrots or kiwi... | Input4 5 5 64 31 33 32 53 21 31 42 32 41 11 1 | OutputWasteGrapesCarrotsKiwisCarrotsCarrots | 2 seconds | 256 megabytes | ['implementation', 'sortings', '*1400'] |
A. Bus Gametime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAfter Fox Ciel won an onsite round of a programming contest, she took a bus to return to her castle. The fee of the bus was 220 yen. She met Rabbit Hanako in the bus. They decided to play the following game ... | Input2 2 | OutputCiel | 2 seconds | 256 megabytes | ['greedy', '*1200'] |
E. Evacuationtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThey've screwed something up yet again... In one nuclear reactor of a research station an uncontrolled reaction is in progress and explosion which will destroy the whole station will happen soon.The station... | Input3 31YZ1YY1000YZ0YY003 | Output2 | 1 second | 256 megabytes | ['flows', 'graphs', 'shortest paths', '*2300'] |
D. Archer's Shottime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputA 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 cel... | Input3 | Output7 | 2 seconds | 256 megabytes | ['binary search', 'geometry', 'math', 'two pointers', '*2300'] |
C. Beaver Gametime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputTwo beavers, Timur and Marsel, play the following game.There are n logs, each of exactly m meters in length. The beavers move in turns. For each move a beaver chooses a log and gnaws it into some number (m... | Input1 15 4 | OutputTimur | 1 second | 256 megabytes | ['dp', 'games', 'number theory', '*2000'] |
B. Easter Eggstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe Easter Rabbit laid n eggs in a circle and is about to paint them. Each egg should be painted one color out of 7: red, orange, yellow, green, blue, indigo or violet. Also, the following conditions shou... | Input8 | OutputROYGRBIV | 2 seconds | 256 megabytes | ['constructive algorithms', 'implementation', '*1200'] |
A. Haikutime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputHaiku is a genre of Japanese traditional poetry.A haiku poem consists of 17 syllables split into three phrases, containing 5, 7 and 5 syllables correspondingly (the first phrase should contain exactly 5 syllabl... | Inputon codeforces beta round is running a rustling of keys | OutputYES | 2 seconds | 256 megabytes | ['implementation', 'strings', '*800'] |
E. Martian Foodtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputHave you ever tasted Martian food? Well, you should.Their signature dish is served on a completely black plate with the radius of R, flat as a pancake.First, they put a perfectly circular portion of the G... | Input24 3 14 2 2 | Output0.92307692310.6666666667 | 1 second | 256 megabytes | ['geometry', '*2800'] |
D. Domino Carpettime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output...Mike the TV greets you again! Tired of the monotonous furniture? Sick of gray routine? Dreaming about dizzying changes in your humble abode? We have something to offer you! This domino carpet for onl... | Input3 4##################O..#...#O.O#...##.O.#.O.#.O.#...##..O#...#O.O#...###################O.O#OOO#O.O#...##.O.#...#...#.O.##O.O#OOO#O.O#...###################O.O#...#O.O#...##...#...#...#.O.##O.O#...#O.O#...################## | Output3 | 2 seconds | 256 megabytes | ['dp', 'implementation', '*2300'] |
C. Beavermuncher-0xFFtime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output"Eat a beaver, save a tree!" β That will be the motto of ecologists' urgent meeting in Beaverley Hills.And the whole point is that the population of beavers on the Earth has reached incredible size... | Input51 3 1 3 22 53 44 51 54 | Output6 | 3 seconds | 256 megabytes | ['dfs and similar', 'dp', 'dsu', 'greedy', 'trees', '*2100'] |
B. Falling Anvilstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputFor some reason in many American cartoons anvils fall from time to time onto heroes' heads. Of course, safes, wardrobes, cruisers, planes fall sometimes too... But anvils do so most of all.Anvils come ... | Input24 21 2 | Output0.62500000000.5312500000 | 2 seconds | 256 megabytes | ['math', 'probabilities', '*1800'] |
A. Heroestime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe year of 2012 is coming...According to an ancient choradrican legend in this very year, in 2012, Diablo and his brothers Mephisto and Baal will escape from hell, and innumerable hordes of demons will enslav... | Input3Troll likes DraculDracul likes AnkaSnowy likes Hexadecimal210 200 180 | Output30 3 | 2 seconds | 256 megabytes | ['brute force', 'implementation', '*1400'] |
F. Touristtime limit per test0.5 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputTourist walks along the X axis. He can choose either of two directions and any speed not exceeding V. He can also stand without moving anywhere. He knows from newspapers that at time t1 in the point with coo... | Input3-1 142 740 82 | Output1 2 | 0.5 second | 256 megabytes | ['binary search', 'data structures', 'dp', '*2300'] |
E. Pointstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given N points on a plane. Write a program which will find the sum of squares of distances between all pairs of points.InputThe first line of input contains one integer number N (1ββ€βNββ€β100β000) β the ... | Input41 1-1 -11 -1-1 1 | Output32 | 1 second | 256 megabytes | ['implementation', 'math', '*1700'] |
D. Plus and xortime limit per test0.5 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputBitwise exclusive OR (or bitwise addition modulo two) is a binary operation which is equivalent to applying logical exclusive OR to every pair of bits located on the same positions in binary notation of... | Input14276 | Output33 109 | 0.5 second | 256 megabytes | ['dp', 'greedy', 'math', '*1700'] |
C. Mutationtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputScientists of planet Olympia are conducting an experiment in mutation of primitive organisms. Genome of organism from this planet can be represented as a string of the first K capital English letters. For eac... | Input5 3 13BACAC4 1 21 2 32 3 43 4 10 | Output5 | 1 second | 256 megabytes | ['bitmasks', 'dp', 'math', '*2700'] |
B. Micetime limit per test0.5 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputModern researches has shown that a flock of hungry mice searching for a piece of cheese acts as follows: if there are several pieces of cheese then each mouse chooses the closest one. After that all mice start ... | Input3 2 0 20 1 32 5 | Output1 | 0.5 second | 256 megabytes | ['greedy', 'two pointers', '*2100'] |
A. Gifttime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe kingdom of Olympia consists of N cities and M bidirectional roads. Each road connects exactly two cities and two cities can be connected with more than one road. Also it possible that some roads connect city... | Input3 32 11 2 10 151 2 4 201 3 5 1 | Output30 | 2 seconds | 256 megabytes | ['dsu', 'graphs', 'sortings', 'trees', '*2200'] |
E. Ship's Shortest Pathtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou have got a new job, and it's very interesting, you are a ship captain. Your first task is to move your ship from one point to another point, and for sure you want to move it at the minimum co... | Input1 7 6 744 2 4 12 3 12 3 2 | Output6.000000000 | 2 seconds | 256 megabytes | ['geometry', 'shortest paths', '*2400'] |
D. Big Maximum Sumtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAhmed and Mostafa used to compete together in many programming contests for several years. Their coach Fegla asked them to solve one challenging problem, of course Ahmed was able to solve it but Mosta... | Input3 43 1 6 -22 3 32 -5 12 3 1 3 | Output9 | 2 seconds | 256 megabytes | ['data structures', 'dp', 'greedy', 'implementation', 'math', 'trees', '*2000'] |
C. Modified GCDtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputWell, here is another math class task. In mathematics, GCD is the greatest common divisor, and it's an easy task to calculate the GCD between two positive integers.A common divisor for two positive numbe... | Input9 2731 510 119 11 | Output3-19 | 2 seconds | 256 megabytes | ['binary search', 'number theory', '*1600'] |
B. Facetook Priority Walltime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputFacetook is a well known social network website, and it will launch a new feature called Facetook Priority Wall. This feature will sort all posts from your friends according to the priority fac... | Inputahmed3ahmed posted on fatma's wallfatma commented on ahmed's postmona likes ahmed's post | Outputfatmamona | 2 seconds | 256 megabytes | ['expression parsing', 'implementation', 'strings', '*1500'] |
A. Life Without Zerostime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputCan you imagine our life if we removed all zeros from it? For sure we will have many problems.In this problem we will have a simple example if we removed all zeros from our life, it's the addition ... | Input101102 | OutputYES | 2 seconds | 256 megabytes | ['implementation', '*1000'] |
E. Shift It!time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere is a square box 6βΓβ6 in size. It contains 36 chips 1βΓβ1 in size. Those chips contain 36 different characters β "0"-"9" and "A"-"Z". There is exactly one chip with each character.You are allowed to m... | Input01W345729AB6CD8FGHIJELMNOPKRSTUVQXYZ | Output2R2U3 | 2 seconds | 256 megabytes | ['constructive algorithms', '*2800'] |
D. Hangertime limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputIn one very large and very respectable company there is a cloakroom with a coat hanger. It is represented by n hooks, positioned in a row. The hooks are numbered with positive integers from 1 to n from the lef... | Input9 11120 5 81130 3 890 6 960 1 9 | Output2325 | 4 seconds | 256 megabytes | ['data structures', '*2400'] |
C. Chessboard Billiardtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputLet's imagine: there is a chess piece billiard ball. Its movements resemble the ones of a bishop chess piece. The only difference is that when a billiard ball hits the board's border, it can refle... | Input3 4 | Output2 | 2 seconds | 256 megabytes | ['dfs and similar', 'dsu', 'graphs', 'number theory', '*2100'] |
B. Traintime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputA stowaway and a controller play the following game. The train is represented by n wagons which are numbered with positive integers from 1 to n from the head to the tail. The stowaway and the controller are ini... | Input5 3 2to head0001001 | OutputStowaway | 2 seconds | 256 megabytes | ['dp', 'games', 'greedy', '*1500'] |
A. Room Leadertime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputLet us remind you part of the rules of Codeforces. The given rules slightly simplified, use the problem statement as a formal document.In the beginning of the round the contestants are divided into rooms.... | Input5Petr 3 1 490 920 1000 1200 0tourist 2 0 490 950 1100 1400 0Egor 7 0 480 900 950 0 1000c00lH4x0R 0 10 150 0 0 0 0some_participant 2 1 450 720 900 0 0 | Outputtourist | 2 seconds | 256 megabytes | ['implementation', '*1000'] |
F. Plane of Tankstime limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputVasya plays the Plane of Tanks. The tanks in this game keep trying to finish each other off. But your "Pedalny" is not like that... He just needs to drive in a straight line from point A to point B on ... | Input0 0 10 015 -5 4.71238 10 | Output4.2441 | 4 seconds | 256 megabytes | ['brute force', 'geometry', '*2900'] |
E. Morrowindowstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputVasya plays The Elder Trolls III: Morrowindows. He has a huge list of items in the inventory, however, there is no limits on the size of things. Vasya does not know the total amount of items but he is su... | Input2 42 3 | Output2 | 2 seconds | 256 megabytes | ['math', 'number theory', '*2400'] |
D. FreeDivtime limit per test5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputVasya plays FreeDiv. In this game he manages a huge state, which has n cities and m two-way roads between them. Unfortunately, not from every city you can reach any other one moving along these roads. Therefo... | Input3 3 21 22 33 1 | Output0 | 5 seconds | 256 megabytes | ['dfs and similar', 'graphs', 'greedy', '*2200'] |
C. LionAge IItime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputVasya plays the LionAge II. He was bored of playing with a stupid computer, so he installed this popular MMORPG, to fight with his friends. Vasya came up with the name of his character β non-empty string s... | Inputwinner 44s e 7o s 8l o 13o o 8 | Output36 | 2 seconds | 256 megabytes | ['dp', '*1800'] |
B. Need For Braketime limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputVasya plays the Need For Brake. He plays because he was presented with a new computer wheel for birthday! Now he is sure that he will win the first place in the championship in his favourite racing com... | Input3teama 10teamb 20teamc 40210 20teama | Output2 3 | 4 seconds | 256 megabytes | ['binary search', 'greedy', 'sortings', '*2000'] |
A. The Elder Trolls IV: Oblivontime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputVasya plays The Elder Trolls IV: Oblivon. Oh, those creators of computer games! What they do not come up with! Absolutely unique monsters have been added to the The Elder Trolls IV: Obliv... | Input2 2 2 3 | Output8 | 2 seconds | 256 megabytes | ['greedy', 'math', '*1600'] |
I. Goofy Numberstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe non-negative integer a is a divisor of the non-negative integer b if and only if there exists a positive integer c such that aβΓβcβ=βb. Some numbers are really interesting. Commander Surena defines ... | Input99 | Outputhappier | 2 seconds | 256 megabytes | ['*special problem', 'implementation', '*1500'] |
H. Reverse It!time limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe 14th of March was the international day of mathematics, because of number Οβ=β3.1415926...In the occasion of this day Goofy Nephews Unity Organization (GNU) wants to publish the fastest program in mat... | Input23 | Output32 | 4 seconds | 256 megabytes | ['*special problem', 'implementation', '*1600'] |
G. Fibonacci armytime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputKing Cambyses loves Fibonacci numbers. He has several armies. Today he wants to make a new army for himself and he wants the number of men in this army to be the n-th Fibonacci number.Given n you shoul... | Input2 | Output2 | 2 seconds | 256 megabytes | ['*special problem', 'dp', '*1000'] |
F. Oiltime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAfter the nationalization of the oil industry, Dr. Mosaddegh wants to dig some oil wells to extract all the oil in Persian Gulf. But Persian Gulf is huge and has an infinite amount of oil. So Dr. Mosaddegh works ... | Input2 31 21 2 | Output2 | 2 seconds | 256 megabytes | ['*special problem', 'greedy', 'math', '*1900'] |
E. Ali goes shoppingtime limit per test5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAli Koochooloo is going to buy new clothes since we're reaching Noruz, the ancient Persian festival and the beginning of new Persian year.When Ali entered a shop, he saw that the shopkeeper was a pr... | Inputabab | Outputab | 5 seconds | 256 megabytes | ['*special problem', 'brute force', 'strings', '*1800'] |
D. Perse-scripttime limit per test7 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputTwo good friends were trying to make a new programming language called Perse-script.The most important part of this language is strings. A string in Perse-script is put between characters "So for example... | Input"HelloWorld" | Output"HelloWorld" | 7 seconds | 256 megabytes | ['*special problem', 'expression parsing', '*2300'] |
C. Extraordinarily Nice Numberstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe positive integer a is a divisor of the positive integer b if and only if there exists a positive integer c such that aβΓβcβ=βb. King Astyages thinks a positive integer x is extraordin... | Input2 | Outputyes | 2 seconds | 256 megabytes | ['*special problem', 'math', '*1200'] |
B. INI-filetime limit per test5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe INI file format is a de facto standard for configuration files. INI files are simple text files with a basic structure. They are commonly associated with Microsoft Windows, but are also used on other pla... | Input11a= 1b=aa = 2 ; comment[z]1=2[y]2=3[z]2=1[w] | Outputa=2b=a[w][y]2=3[z]1=22=1 | 5 seconds | 256 megabytes | ['*special problem', 'implementation', '*2200'] |
A. Goshtasp, Vishtasp and Eiditime limit per test5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputGoshtasp was known to be a good programmer in his school. One day Vishtasp, Goshtasp's friend, asked him to solve this task:Given a positive integer n, you should determine whether n is ri... | Input11 | Output11=11 | 5 seconds | 256 megabytes | ['*special problem', 'greedy', 'math', '*1800'] |
E. Nuclear Fusiontime limit per test1.5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere 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... | Input10 3Mn Co Li Mg C P F Zn Sc KSn Pt Y | OutputYESMn+C+K->SnCo+Zn+Sc->PtLi+Mg+P+F->Y | 1.5 seconds | 256 megabytes | ['bitmasks', 'dp', '*2200'] |
D. Solitairetime limit per test1.5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputVasya has a pack of 54 cards (52 standard cards and 2 distinct jokers). That is all he has at the moment. Not to die from boredom, Vasya plays Solitaire with them.Vasya lays out nm cards as a rectangle nβ... | Input4 62S 3S 4S 7S 8S AS5H 6H 7H 5S TC AC8H 9H TH 7C 8C 9C2D 2C 3C 4C 5C 6C | OutputNo solution. | 1.5 seconds | 256 megabytes | ['brute force', 'implementation', '*2200'] |
C. Round Table Knightstime limit per test0.5 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere are n knights sitting at the Round Table at an equal distance from each other. Each of them is either in a good or in a bad mood.Merlin, the wizard predicted to King Arthur that the next mo... | Input31 1 1 | OutputYES | 0.5 second | 256 megabytes | ['dp', 'math', 'number theory', '*1600'] |
B. Progress Bartime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputA progress bar is an element of graphical interface that displays the progress of a process for this very moment before it is completed. Let's take a look at the following form of such a bar.A bar is repr... | Input10 10 54 | Output10 10 10 10 10 4 0 0 0 0 | 1 second | 256 megabytes | ['implementation', 'math', '*1300'] |
A. Way Too Long Wordstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputSometimes some words like "localization" or "internationalization" are so long that writing them many times in one text is quite tiresome.Let's consider a word too long, if its length is strictly mo... | Input4wordlocalizationinternationalizationpneumonoultramicroscopicsilicovolcanoconiosis | Outputwordl10ni18np43s | 1 second | 256 megabytes | ['strings', '*800'] |
E. Information Reformtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThought it is already the XXI century, the Mass Media isn't very popular in Walrusland. The cities get news from messengers who can only travel along roads. The network of roads in Walrusland is bu... | Input8 102 5 9 11 15 19 201 41 31 74 62 82 33 5 | Output383 3 3 4 3 4 3 3 | 2 seconds | 256 megabytes | ['dp', 'implementation', 'trees', '*2700'] |
D. Professor's tasktime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputOnce a walrus professor Plato asked his programming students to perform the following practical task. The students had to implement such a data structure that would support a convex hull on some set o... | Input81 0 01 2 01 2 22 1 01 0 22 1 12 2 12 20 -1 | OutputYESYESYESNO | 1 second | 256 megabytes | ['data structures', 'geometry', '*2700'] |
C. Lucky Ticketstime limit per test1.5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputIn Walrusland public transport tickets are characterized by two integers: by the number of the series and by the number of the ticket in the series. Let the series number be represented by a and the t... | Input2 2 1 | Output1 1 | 1.5 seconds | 256 megabytes | ['binary search', 'data structures', 'sortings', 'two pointers', '*2200'] |
B. Text Messagingtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputFangy the little walrus, as all the modern walruses, loves to communicate via text messaging. One day he faced the following problem: When he sends large texts, they are split into parts each containing... | Input25Hello. I am a little walrus. | Output2 | 1 second | 256 megabytes | ['expression parsing', 'greedy', 'strings', '*1600'] |
A. Cookiestime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputFangy collects cookies. Once he decided to take a box and put cookies into it in some way. If we take a square kβΓβk in size, divided into blocks 1βΓβ1 in size and paint there the main diagonal together with c... | Input3 | Output9 | 1 second | 256 megabytes | ['math', '*1300'] |
E. Subsegmentstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputProgrammer Sasha has recently begun to study data structures. His coach Stas told him to solve the problem of finding a minimum on the segment of the array in , which Sasha coped with. For Sasha not to thi... | Input5 312233 | Output132 | 1 second | 256 megabytes | ['data structures', 'implementation', '*1800'] |
D. Dottime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAnton and Dasha like to play different games during breaks on checkered paper. By the 11th grade they managed to play all the games of this type and asked Vova the programmer to come up with a new game. Vova sugg... | Input0 0 2 31 11 2 | OutputAnton | 3 seconds | 256 megabytes | ['dp', 'games', '*1900'] |
C. Gametime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputIn one school with Vasya there is a student Kostya. Kostya does not like physics, he likes different online games. Every day, having come home, Kostya throws his bag in the farthest corner and sits down at his b... | Input2 3 2 5desolatorrefresherperseverancevanguard: desolator 1, refresher 1maelstorm: perseverance 21 desolator2 perseverance1 refresher2 desolator2 perseverance | Output1vanguard 12desolator 1maelstorm 1 | 2 seconds | 256 megabytes | ['implementation', '*2000'] |
B. Betstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputIn Chelyabinsk lives a much respected businessman Nikita with a strange nickname "Boss". Once Nikita decided to go with his friend Alex to the Summer Biathlon World Cup. Nikita, as a very important person, recei... | Input4 41 4 20 51 3 21 103 3 4 303 4 4 20 | Output60 | 2 seconds | 256 megabytes | ['greedy', 'implementation', '*1200'] |
A. Young Physicisttime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputA guy named Vasya attends the final grade of a high school. One day Vasya decided to watch a match of his favorite hockey team. And, as the boy loves hockey very much, even more than physics, he forgo... | Input34 1 7-2 4 -11 -5 -3 | OutputNO | 2 seconds | 256 megabytes | ['implementation', 'math', '*1000'] |
E. Contacttime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputLittle Petya is preparing for the first contact with aliens. He knows that alien spaceships have shapes of non-degenerate triangles and there will be exactly 4 ships. Landing platform for a ship can be made o... | Input0 0 1 0 1 20 0 0 2 2 20 0 3 0 1 20 0 3 0 2 2 | Output4 | 3 seconds | 256 megabytes | ['geometry', '*2900'] |
D. Half-decay treetime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputRecently Petya has become keen on physics. Anna V., his teacher noticed Petya's interest and gave him a fascinating physical puzzle β a half-decay tree. A half-decay tree is a complete binary tree wit... | Input1 4add 1 3add 2 10add 3 11decay | Output13.50000000 | 3 seconds | 256 megabytes | ['data structures', 'divide and conquer', 'dp', 'math', 'probabilities', '*2500'] |
C. Synchrophasotrontime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputFor some experiments little Petya needs a synchrophasotron. He has already got the device, all that's left is to set the fuel supply. Fuel comes through a system of nodes numbered from 1 to n and con... | Input21 2 1 2 3 | Output1 4 | 3 seconds | 256 megabytes | ['brute force', '*2200'] |
B. Energy exchangetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputIt is well known that the planet suffers from the energy crisis. Little Petya doesn't like that and wants to save the world. For this purpose he needs every accumulator to contain the same amount of e... | Input3 504 2 1 | Output2.000000000 | 2 seconds | 256 megabytes | ['binary search', '*1600'] |
A. Irrational problemtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputLittle Petya was given this problem for homework:You are given function (here represents the operation of taking the remainder). His task is to count the number of integers x in range [a;b] with ... | Input2 7 1 8 2 8 | Output0 | 2 seconds | 256 megabytes | ['implementation', 'number theory', '*1100'] |
E. Save the City!time limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputIn the town of Aalam-Aara (meaning the Light of the Earth), previously there was no crime, no criminals but as the time progressed, sins started creeping into the hearts of once righteous people. Seekin... | Input54 88 89 44 00 4 | Output5 | 1 second | 256 megabytes | ['geometry', '*2500'] |
D. Optical Experimenttime limit per test5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputProfessor Phunsuk Wangdu has performed some experiments on rays. The setup for n rays is as follows.There is a rectangular box having exactly n holes on the opposite faces. All rays enter from the ... | Input51 4 5 2 33 4 2 1 5 | Output3 | 5 seconds | 256 megabytes | ['binary search', 'data structures', 'dp', '*1900'] |
C. Sequence of Ballstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a sequence of balls A by your teacher, each labeled with a lowercase Latin letter 'a'-'z'. You don't like the given sequence. You want to change it into a new sequence, B that suits you... | Input1 1 1 1youshouldnotthoushaltnot | Output5 | 1 second | 256 megabytes | ['dp', '*2600'] |
B. Restoration of the Permutationtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputLet Aβ=β{a1,βa2,β...,βan} be any permutation of the first n natural numbers {1,β2,β...,βn}. You are given a positive integer k and another sequence Bβ=β{b1,βb2,β...,βbn}, where bi is the... | Input5 21 2 1 0 0 | Output4 1 5 2 3 | 1 second | 256 megabytes | ['greedy', '*1800'] |
A. Partial Teachertime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputA teacher decides to give toffees to his students. He asks n students to stand in a queue. Since the teacher is very partial, he follows the following rule to distribute toffees.He looks at the first t... | Input5LRLR | Output2 1 2 1 2 | 1 second | 256 megabytes | ['dp', 'graphs', 'greedy', 'implementation', '*1800'] |
E. Petya and Posttime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputLittle Vasya's uncle is a postman. The post offices are located on one circular road. Besides, each post office has its own gas station located next to it. Petya's uncle works as follows: in the mornin... | Input41 7 2 38 1 1 3 | Output22 4 | 2 seconds | 256 megabytes | ['data structures', 'dp', '*2000'] |
D. Petya and His Friendstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputLittle Petya has a birthday soon. Due this wonderful event, Petya's friends decided to give him sweets. The total number of Petya's friends equals to n.Let us remind you the definition of the gr... | Input3 | Output995511115 | 2 seconds | 256 megabytes | ['constructive algorithms', 'math', 'number theory', '*1700'] |
C. Petya and File Systemtime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputRecently, on a programming lesson little Petya showed how quickly he can create files and folders on the computer. But he got soon fed up with this activity, and he decided to do a much more use... | InputC:\folder1\file1.txt | Output0 1 | 3 seconds | 256 megabytes | ['data structures', 'implementation', '*1800'] |
B. Petya and Countrysidetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputLittle Petya often travels to his grandmother in the countryside. The grandmother has a large garden, which can be represented as a rectangle 1βΓβn in size, when viewed from above. This rectangl... | Input12 | Output1 | 2 seconds | 256 megabytes | ['brute force', 'implementation', '*1100'] |
A. Petya and Javatime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputLittle Petya has recently started attending a programming club. Naturally he is facing the problem of choosing a programming language. After long considerations he realized that Java is the best choice... | Input127 | Outputbyte | 2 seconds | 256 megabytes | ['implementation', 'strings', '*1300'] |
E. Harry Potter and Moving Staircasestime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputHarry Potter lost his Invisibility Cloak, running from the school caretaker Filch. Finding an invisible object is not an easy task. Fortunately, Harry has friends who are willing to... | Input6 41 21 32 34 5 | OutputYES23 1 2 32 3 53 5 4 54 5 63 6 5 3 | 2 seconds | 256 megabytes | ['dfs and similar', 'implementation', '*2900'] |
D. Harry Potter and the Sorting Hattime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAs you know, Hogwarts has four houses: Gryffindor, Hufflepuff, Ravenclaw and Slytherin. The sorting of the first-years into houses is done by the Sorting Hat. The pupils are called on... | Input11G????SS???H | OutputGryffindorRavenclaw | 2 seconds | 256 megabytes | ['brute force', 'dfs and similar', 'hashing', '*2200'] |
C. Harry Potter and the Golden Snitchtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputBrothers Fred and George Weasley once got into the sporting goods store and opened a box of Quidditch balls. After long and painful experiments they found out that the Golden Snitch... | Input40 0 00 10 010 10 010 0 00 0 01 15 5 25 | OutputYES25.500000000010.0000000000 4.5000000000 0.0000000000 | 2 seconds | 256 megabytes | ['binary search', 'geometry', '*2100'] |
B. Harry Potter and the History of Magictime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe History of Magic is perhaps the most boring subject in the Hogwarts school of Witchcraft and Wizardry. Harry Potter is usually asleep during history lessons, and his magical q... | Input3187519361721 | Output183518361921 | 1 second | 256 megabytes | ['brute force', 'greedy', 'implementation', '*1700'] |
A. Harry Potter and Three Spellstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputA long time ago (probably even in the first book), Nicholas Flamel, a great alchemist and the creator of the Philosopher's Stone, taught Harry Potter three useful spells. The first one a... | Input100 200 250 150 200 250 | OutputRon | 2 seconds | 256 megabytes | ['implementation', 'math', '*1800'] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.