formatted_conversations
stringlengths
1.13k
138k
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.King of Berland Berl IV has recently died. Hail Berl V! As a sign of the highest achievements of the deceased king the new king decide...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Today, Wet Shark is given *n* integers. Using any of these integers no more than once, Wet Shark wants to get maximum possible even (d...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Many countries have such a New Year or Christmas tradition as writing a letter to Santa including a wish list for presents. Vasya is a...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Polycarp has created his own training plan to prepare for the programming contests. He will train for $n$ days, all days are numbered ...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Kostya likes Codeforces contests very much. However, he is very disappointed that his solutions are frequently hacked. That's why he d...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Fangy the little walrus, as all the modern walruses, loves to communicate via text messaging. One day he faced the following problem: ...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.A non-empty string *s* is called binary, if it consists only of characters "0" and "1". Let's number the characters of binary string *...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.You are given *n* segments on a line. There are no ends of some segments that coincide. For each segment find the number of segments i...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Vasya has a beautiful garden where wonderful fruit trees grow and yield fantastic harvest every year. But lately thieves started to sn...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Mad scientist Mike entertains himself by arranging rows of dominoes. He doesn't need dominoes, though: he uses rectangular magnets ins...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.To quickly hire highly skilled specialists one of the new IT City companies made an unprecedented move. Every employee was granted a c...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.After 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. S...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Kirito is stuck on a level of the MMORPG he is playing now. To move on in the game, he's got to defeat all *n* dragons that live on th...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Vasya is studying number theory. He has denoted a function *f*(*a*,<=*b*) such that: - *f*(*a*,<=0)<==<=0; - *f*(*a*,<=*b*)<==<=1<=...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Andrewid the Android is a galaxy-famous detective. In his free time he likes to think about strings containing zeros and ones. Once h...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.In late autumn evening *n* robots gathered in the cheerful company of friends. Each robot has a unique identifier — an integer from 1 ...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.There were *n* groups of students which came to write a training contest. A group is either one person who can write the contest with ...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.We often have to copy large volumes of information. Such operation can take up many computer resources. Therefore, in this problem you...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Kolya loves putting gnomes at the circle table and giving them coins, and Tanya loves studying triplets of gnomes, sitting in the vert...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Polycarp has interviewed Oleg and has written the interview down without punctuation marks and spaces to save time. Thus, the intervie...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.As you probably know, Anton goes to school. One of the school subjects that Anton studies is Bracketology. On the Bracketology lessons...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.It is known that there are *k* fish species in the polar ocean, numbered from 1 to *k*. They are sorted by non-decreasing order of the...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Let's define a split of $n$ as a nonincreasing sequence of positive integers, the sum of which is $n$. For example, the following se...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.For some experiments little Petya needs a synchrophasotron. He has already got the device, all that's left is to set the fuel supply. ...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.A thief made his way to a shop. As usual he has his lucky knapsack with him. The knapsack can contain *k* objects. There are *n* kind...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.You are given an *n*<=×<=*m* rectangular table consisting of lower case English letters. In one operation you can completely remove on...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Ilya is working for the company that constructs robots. Ilya writes programs for entertainment robots, and his current project is "Bob...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Mr. Kitayuta has just bought an undirected graph with *n* vertices and *m* edges. The vertices of the graph are numbered from 1 to *n*...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Vasya has got many devices that work on electricity. He's got *n* supply-line filters to plug the devices, the *i*-th supply-line filt...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Vasya has *n* burles. One bottle of Ber-Cola costs *a* burles and one Bars bar costs *b* burles. He can buy any non-negative integer n...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Leonid works for a small and promising start-up that works on decoding the human genome. His duties include solving complex problems o...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Recently, Mike was very busy with studying for exams and contests. Now he is going to chill a bit by doing some sight seeing in the ci...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Arseniy is already grown-up and independent. His mother decided to leave him alone for *m* days and left on a vacation. She have prepa...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Mayor of city S just hates trees and lawns. They take so much space and there could be a road on the place they occupy! The Mayor thi...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Vanya walks late at night along a straight street of length *l*, lit by *n* lanterns. Consider the coordinate system with the beginnin...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.One popular website developed an unusual username editing procedure. One can change the username only by deleting some characters from...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.zscoder wants to generate an input file for some programming competition problem. His input is a string consisting of *n* letters 'a'...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.A boy Valera registered on site Codeforces as Valera, and wrote his first Codeforces Round #300. He boasted to a friend Arkady about w...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.You are given a sequence *a* consisting of *n* integers. You may partition this sequence into two sequences *b* and *c* in such a way ...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.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 su...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Nikephoros and Polycarpus play rock-paper-scissors. The loser gets pinched (not too severely!). Let us remind you the rules of this g...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.In a building where Polycarp lives there are equal number of flats on each floor. Unfortunately, Polycarp don't remember how many flat...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Vasya is pressing the keys on the keyboard reluctantly, squeezing out his ideas on the classical epos depicted in Homer's Odysseus... ...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Life in Bertown has become hard. The city has too many roads and the government spends too much to maintain them. There are *n* juncti...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Karen is getting ready for a new school day! It is currently hh:mm, given in a 24-hour format. As you know, Karen loves palindromes, ...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.There are *n* cities numbered from 1 to *n* in Berland. Some of them are connected by two-way roads. Each road has its own length — an...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Thor is getting used to the Earth. As a gift Loki gave him a smartphone. There are *n* applications on this phone. Thor is fascinated ...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Ivan has a robot which is situated on an infinite grid. Initially the robot is standing in the starting cell (0,<=0). The robot can pr...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake wei...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.You are given a positive integer $n$, written without leading zeroes (for example, the number 04 is incorrect). In one operation you...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Harry Water, Ronaldo, Her-my-oh-knee and their friends have started a new school year at their MDCS School of Speechcraft and Misery. ...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Valera the horse lives on a plane. The Cartesian coordinate system is defined on this plane. Also an infinite spiral is painted on the...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Petr stands in line of *n* people, but he doesn't know exactly which position he occupies. He can say that there are no less than *a* ...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Connect the countless points with lines, till we reach the faraway yonder. There are *n* points on a coordinate plane, the *i*-th of ...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.The dragon and the princess are arguing about what to do on the New Year's Eve. The dragon suggests flying to the mountains to watch f...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Once Vasya played bricks. All the bricks in the set had regular cubical shape. Vasya vas a talented architect, however the tower he bu...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Luba is surfing the Internet. She currently has *n* opened tabs in her browser, indexed from 1 to *n* from left to right. The mouse cu...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.In Chelyabinsk lives a much respected businessman Nikita with a strange nickname "Boss". Once Nikita decided to go with his friend Ale...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.There are *n* Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is ...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.As the guys fried the radio station facilities, the school principal gave them tasks as a punishment. Dustin's task was to add comment...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.You are given an array *a* of size *n*, and *q* queries to it. There are queries of two types: - 1 *l**i* *r**i* — perform a cyclic...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.The cows have just learned what a primitive root is! Given a prime *p*, a primitive root is an integer *x* (1<=≤<=*x*<=&lt;<=*p*) suc...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.A way to make a new task is to make it nondeterministic or probabilistic. For example, the hard task of Topcoder SRM 595, Constellatio...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Ann and Borya have *n* piles with candies and *n* is even number. There are *a**i* candies in pile with number *i*. Ann likes numbers...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Ehab is interested in the bitwise-xor operation and the special graphs. Mahmoud gave him a problem that combines both. He has a comple...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Vasya decided to write an anonymous letter cutting the letters out of a newspaper heading. He knows heading *s*1 and text *s*2 that he...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Two boys decided to compete in text typing on the site "Key races". During the competition, they have to type a text consisting of *s*...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.It is lunch time for Mole. His friend, Marmot, prepared him a nice game for lunch. Marmot brought Mole *n* ordered piles of worms suc...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.One 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...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Polycarpus has recently got interested in sequences of pseudorandom numbers. He learned that many programming languages generate such ...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.A one-dimensional Japanese crossword can be represented as a binary string of length *x*. An encoding of this crossword is an array *a...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.A car moves from point A to point B at speed *v* meters per second. The action takes place on the X-axis. At the distance *d* meters f...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Завтра у хоккейной команды, которой руководит Евгений, важный матч. Евгению нужно выбрать шесть игроков, которые выйдут на лед в старт...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.This task is very simple. Given a string *S* of length *n* and *q* queries each query is on the format *i* *j* *k* which means sort th...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Pari has a friend who loves palindrome numbers. A palindrome number is a number that reads the same forward or backward. For example 1...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Поликарп мечтает стать программистом и фанатеет от степеней двойки. Среди двух чисел ему больше нравится то, которое делится на большу...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Furik loves writing all sorts of problems, especially such that he can't solve himself. You've got one of his problems, the one Furik ...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.— This is not playing but duty as allies of justice, Nii-chan! — Not allies but justice itself, Onii-chan! With hands joined, go eve...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.ZS the Coder and Chris the Baboon arrived at the entrance of Udayland. There is a *n*<=×<=*n* magic grid on the entrance which is fill...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Squirrel Liss is interested in sequences. She also has preferences of integers. She thinks *n* integers *a*1,<=*a*2,<=...,<=*a**n* are...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Jon fought bravely to rescue the wildlings who were attacked by the white-walkers at Hardhome. On his arrival, Sam tells him that he w...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.You are given a sequence of positive integers *a*1,<=*a*2,<=...,<=*a**n*. While possible, you perform the following operation: find ...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.As technologies develop, manufacturers are making the process of unlocking a phone as user-friendly as possible. To unlock its new pho...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Fox 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 w...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.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 gr...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.The clique problem is one of the most well-known NP-complete problems. Under some simplification it can be formulated as follows. Cons...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Theater stage is a rectangular field of size *n*<=×<=*m*. The director gave you the stage's plan which actors will follow. For each ce...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.There are *n* student groups at the university. During the study day, each group can take no more than 7 classes. Seven time slots num...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.There are $n$ players sitting at the card table. Each player has a favorite number. The favorite number of the $j$-th player is $f_j$....
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Anton and Dasha like to play different games during breaks on checkered paper. By the 11th grade they managed to play all the games of...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Valera loves his garden, where *n* fruit trees grow. This year he will enjoy a great harvest! On the *i*-th tree *b**i* fruit grow, t...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.The DNA sequence for every living creature in Berland can be represented as a non-empty line consisting of lowercase Latin letters. Be...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Amr loves Chemistry, and specially doing experiments. He is preparing for a new interesting experiment. Amr has *n* different types o...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Several months later Alex finally got his brother Bob's creation by post. And now, in his turn, Alex wants to boast about something to...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.During the "Russian Code Cup" programming competition, the testing system stores all sent solutions for each participant. We know that...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Arya has *n* opponents in the school. Each day he will fight with all opponents who are present this day. His opponents have some figh...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.The year 2015 is almost over. Limak is a little polar bear. He has recently learnt about the binary system. He noticed that the passi...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.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 ticke...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Polycarp invited all his friends to the tea party to celebrate the holiday. He has *n* cups, one for each of his *n* friends, with vol...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Leha decided to move to a quiet town Vičkopolis, because he was tired by living in Bankopolis. Upon arrival he immediately began to ex...