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.Polycarp is crazy about round numbers. He especially likes the numbers divisible by 10*k*. In the given number of *n* Polycarp wants ...
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.Petya loves lucky numbers very much. Everybody knows that lucky numbers are positive integers whose decimal record contains only the l...
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.Meg the Rabbit decided to do something nice, specifically — to determine the shortest distance between two points on the surface of ou...
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 have a rectangular chocolate bar consisting of *n*<=×<=*m* single squares. You want to eat exactly *k* squares, so you may need 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.Iahub and his friend Floyd have started painting a wall. Iahub is painting the wall red and Floyd is painting it pink. You can conside...
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.Consider a table *G* of size *n*<=×<=*m* such that *G*(*i*,<=*j*)<==<=*GCD*(*i*,<=*j*) for all 1<=≤<=*i*<=≤<=*n*,<=1<=≤<=*j*<=≤<=*m*. ...
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 day Vasya was sitting on a not so interesting Maths lesson and making an origami from a rectangular *a* mm <=×<= *b* mm sheet of p...
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 *n* dice *d*1,<=*d*2,<=...,<=*d**n*. The *i*-th dice shows numbers from 1 to *d**i*. Polycarp rolled all the dice and 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.A little boy Gerald entered a clothes shop and found out something very unpleasant: not all clothes turns out to match. For example, 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.Two integers *x* and *y* are compatible, if the result of their bitwise "AND" equals zero, that is, *a* &amp; *b*<==<=0. For example, ...
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 names of two days of the week. Please, determine whether it is possible that during some non-leap year the first day 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.Leha like all kinds of strange things. Recently he liked the function *F*(*n*,<=*k*). Consider all possible *k*-element subsets 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.Fox Ciel has a board with *n* rows and *n* columns. So, the board consists of *n*<=×<=*n* cells. Each cell contains either a symbol '....
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.Petya loves hockey very much. One day, as he was watching a hockey match, he fell asleep. Petya dreamt of being appointed to change 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.Theatre Square in the capital city of Berland has a rectangular shape with the size *n*<=×<=*m* meters. On the occasion of the city'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.And now the numerous qualifying tournaments for one of the most prestigious Russian contests Russian Codec Cup are over. All *n* parti...
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 is playing a strange game. He has a matrix *a* with *n* rows and *m* columns. Each element of the matrix is equal to either 0 or...
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.An elephant decided to visit his friend. It turned out that the elephant's house is located at point 0 and his friend's house is locat...
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.Since Sonya is interested in robotics too, she decided to construct robots that will read and recognize numbers. Sonya has drawn $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.Bimokh is Mashmokh's boss. For the following *n* days he decided to pay to his workers in a new way. At the beginning of each day 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.Ivan has got an array of *n* non-negative integers *a*1,<=*a*2,<=...,<=*a**n*. Ivan knows that the array is sorted in the non-decreasi...
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.Young Timofey has a birthday today! He got kit of *n* cubes as a birthday present from his parents. Every cube has a number *a**i*, wh...
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.Your security guard friend recently got a new job at a new security company. The company requires him to patrol an area of the city en...
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 may have heard of the pie rule before. It states that if two people wish to fairly share a slice of pie, one person should cut 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.There is a game called "I Wanna Be the Guy", consisting of *n* levels. Little X and his friend Little Y are addicted to the game. Each...
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* beacons located at distinct positions on a number line. The *i*-th beacon has position *a**i* and power level *b**i*. Wh...
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.Your city has *n* junctions. There are *m* one-way roads between the junctions. As a mayor of the city, you have to ensure the securit...
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 this problem you will meet the simplified model of game King of Thieves. In a new ZeptoLab game called "King of Thieves" your aim ...
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 owns a shop in the capital of Berland. Recently the criminal activity in the capital increased, so Polycarp is thinking about...
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.According to rules of the Berland fashion, a jacket should be fastened by all the buttons except only one, but not necessarily it shou...
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 the city of Ultima Thule job applicants are often offered an IQ test. The test is as follows: the person gets a piece of squared ...
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.Ksusha the Squirrel is standing at the beginning of a straight road, divided into *n* sectors. The sectors are numbered 1 to *n*, 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.Limak is a little polar bear. He has *n* balls, the *i*-th ball has size *t**i*. Limak wants to give one ball to each of his three fr...
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.Dreamoon is standing at the position 0 on a number line. Drazil is sending a list of commands through Wi-Fi to Dreamoon's smartphone 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.Imagine that you are in a building that has exactly *n* floors. You can move between the floors in a lift. Let's number the floors fro...
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 the string *s* of length *n* and the numbers *p*,<=*q*. Split the string *s* to pieces of length *p* and *q*. For examp...
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 developers of Looksery have to write an efficient algorithm that detects faces on a picture. Unfortunately, they are currently bus...
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.Programmer Sasha has recently begun to study data structures. His coach Stas told him to solve the problem of finding a minimum 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.Heidi got one brain, thumbs up! But the evening isn't over yet and one more challenge awaits our dauntless agent: after dinner, at pre...
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.Kyoya Ootori has a bag with *n* colored balls that are colored with *k* different colors. The colors are labeled from 1 to *k*. Balls ...
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 tourist hiked along the mountain range. The hike lasted for *n* days, during each day the tourist noted height above the sea level. ...
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.Igor is in the museum and he wants to see as many pictures as possible. Museum can be represented as a rectangular field of *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.Polycarpus loves lucky numbers. Everybody knows that lucky numbers are positive integers, whose decimal representation (without leadin...
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.Yaroslav has an array, consisting of (2·*n*<=-<=1) integers. In a single operation Yaroslav can change the sign of exactly *n* element...
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.Tom is interested in power consumption of his favourite laptop. His laptop has three modes. In normal mode laptop consumes *P*1 watt p...
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.Lavrenty, a baker, is going to make several buns with stuffings and sell them. Lavrenty has *n* grams of dough as well as *m* differe...
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 have a team of *N* people. For a particular task, you can pick any non-empty subset of people. The cost of having *x* people for 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.Arthur has bought a beautiful big table into his new flat. When he came home, Arthur noticed that the new table is unstable. In total...
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.Bike loves looking for the second maximum element in the sequence. The second maximum element in the sequence of distinct numbers *x*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.Limak and Radewoosh are going to compete against each other in the upcoming algorithmic contest. They are equally skilled but they won...
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.Petya has a string of length *n* consisting of small and large English letters and digits. He performs *m* operations. Each operation...
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 monster is attacking the Cyberland! Master Yang, a braver, is going to beat the monster. Yang and the monster each have 3 attribute...
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 a lover of bacteria. You want to raise some bacteria in a box. Initially, the box is empty. Each morning, you can put any nu...
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.Limak is an old brown bear. He often plays poker with his friends. Today they went to a casino. There are *n* players (including Limak...
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.Long ago, when Petya was a schoolboy, he was very much interested in the Petr# language grammar. During one lesson Petya got intereste...
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 Berland University is preparing to celebrate the 256-th anniversary of its founding! A specially appointed Vice Rector for the cel...
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.International Abbreviation Olympiad takes place annually starting from 1989. Each year the competition receives an abbreviation of for...
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 might have heard about the next game in Lara Croft series coming out this year. You also might have watched its trailer. Though yo...
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.Vika has *n* jars with paints of distinct colors. All the jars are numbered from 1 to *n* and the *i*-th jar contains *a**i* liters 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.On her way to programming school tiger Dasha faced her first test — a huge staircase! The steps were numbered from one to infinity. 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.Alex was programming while Valentina (his toddler daughter) got there and started asking many questions about the round brackets (or p...
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* points on a straight line, and the *i*-th point among them is located at *x**i*. All these coordinates are distinct. De...
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* consisting of *n* elements. The imbalance value of some subsegment of this array is the difference between ...
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 day Alex decided to remember childhood when computers were not too powerful and lots of people played only default games. Alex enj...
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 seems like the year of 2013 came only yesterday. Do you know a curious fact? The year of 2013 is the first year after the old 1987 ...
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*<=×<=*m* table. Each cell of the table is colored white or black. Find the number of non-empty sets of cells such tha...
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.Being a nonconformist, Volodya is displeased with the current state of things, particularly with the order of natural numbers (natural...
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.Maxim has opened his own restaurant! The restaurant has got a huge table, the table's length is *p* meters. Maxim has got a dinner pa...
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 is a long plate *s* containing *n* digits. Iahub wants to delete some digits (possibly none, but he is not allowed to delete all...
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.Genos recently installed the game Zuma on his phone. In Zuma there exists a line of *n* gemstones, the *i*-th of which has color *c**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.Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the ar...
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.Gerald is setting the New Year table. The table has the form of a circle; its radius equals *R*. Gerald invited many guests and is con...
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've gotten an *n*<=×<=*m* sheet of squared paper. Some of its squares are painted. Let's mark the set of all painted squares as *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.You can't possibly imagine how cold our friends are this winter in Nvodsk! Two of them play the following game to warm up: initially 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.Noora is a student of one famous high school. It's her final year in school — she is going to study in university next year. However, ...
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 have a Petri dish with bacteria and you are preparing to dive into the harsh micro-world. But, unfortunately, you don't have any m...
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.Consider a football tournament where *n* teams participate. Each team has two football kits: for home games, and for away games. The k...
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 an experienced player in tic-tac-toe on the 4<=×<=4 field. He always starts and plays with Xs. He played a lot of games today ...
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.Jack decides to invite Emma out for a dinner. Jack is a modest student, he doesn't want to go to an expensive restaurant. Emma is a gi...
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 got string *s* for his birthday, the string consists of small English letters. He immediately added *k* more characters to the r...
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 each positive integer *n* consider the integer ψ(*n*) which is obtained from *n* by replacing every digit *a* in the decimal notat...
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.Вася купил стол, у которого *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 collects coins: he has exactly one coin for every year from 1 to *n*. Naturally, Vasya keeps all the coins in his collection in ...
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.Slastyona and her loyal dog Pushok are playing a meaningless game that is indeed very interesting. The game consists of multiple roun...
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.Students Vasya and Petya are studying at the BSU (Byteland State University). At one of the breaks they decided to order a pizza. In 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.Recently a dog was bought for Polycarp. The dog's name is Cormen. Now Polycarp has a lot of troubles. For example, Cormen likes going ...
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 Ancient Berland there were *n* cities and *m* two-way roads of equal length. The cities are numbered with integers from 1 to *n* in...
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 Patrick waits for a visit from his friend Spongebob. To prepare for the visit, Patrick needs to buy some goodies in two stores l...
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.Vera adores poems. All the poems Vera knows are divided into quatrains (groups of four lines) and in each quatrain some lines contain ...
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 have two variables *a* and *b*. Consider the following sequence of actions performed with these variables: 1. If *a*<==<=0 or *b*...
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.Arkady plays Gardenscapes a lot. Arkady wants to build two new fountains. There are *n* available fountains, for each fountain its bea...
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 the Lion wants to help all his friends with passing exams. They need to solve the following problem to pass the IT exam. You've ...
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.*n* soldiers stand in a circle. For each soldier his height *a**i* is known. A reconnaissance unit can be made of such two neighbourin...
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'll define *S*(*n*) for positive integer *n* as follows: the number of the *n*'s digits in the decimal base. For example, *S*(893)<=...
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 of integers. Vasya can permute (change order) its integers. He wants to do it so that as many as possible integ...
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 *n* friends in Tarasov city. Polycarpus knows phone numbers of all his friends: they are strings *s*1,<=*s*2,<=...,<=*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.Petya loves computer games. Finally a game that he's been waiting for so long came out! The main character of this game has *n* diffe...
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 has arrived at Udayland! They walked in the park where *n* trees grow. They decided to be naughty 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.A well-known art union called "Kalevich is Alive!" manufactures objects d'art (pictures). The union consists of *n* painters who decid...
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 is playing a very interesting computer game, but now he is stuck at one of the levels. To pass to the next level he has to prepa...