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.You are given a sequence of length N: A_1, A_2, ..., A_N. For each integer i between 1 and N (inclusive), answer the following questio...
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 cubes stacked vertically on a desk. You are given a string S of length N. The color of the i-th cube from the bottom is 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.There are N children, numbered 1, 2, ..., N. Snuke has decided to distribute x sweets among them. He needs to give out all the x swee...
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 elementary school student Takahashi has come to a variety store. He has two coins, A-yen and B-yen coins (yen is the currency of 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.We have a string s consisting of lowercase English letters. Snuke is partitioning s into some number of non-empty substrings. Let 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.You are given a string S consisting of letters `b`, `d`, `p` and `q`. Determine whether S is a mirror string. Here, a mirror string 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.Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of Mysterious Light. Three mirrors of length...
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.problem You are looking for a constellation in a picture of the starry sky. The photo always contains exactly one figure with the sam...
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 upon a time, there was a king who loved beautiful costumes very much. The king had a special cocoon bed to make excellent cloth 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.Let us consider sets of positive integers less than or equal to n. Note that all elements of a set are different. Also note that the 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.Background The kindergarten attached to the University of Aizu is a kindergarten where children who love programming gather. Yu, one ...
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.Differential pulse code modulation is one of the compression methods mainly used when compressing audio signals. The audio signal 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.Problem Statement We found a dictionary of the Ancient Civilization Mayo (ACM) during excavation of the ruins. After analysis 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.problem AOR Ika is studying to pass the test. AOR Ika-chan solved the $ N $ question. After that, round the solved problem according...
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.Problem Statement You are given a list of $N$ intervals. The $i$-th interval is $[l_i, r_i)$, which denotes a range of numbers greate...
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.Sherlock Holmes has decided to start a new academy to some of the young lads. He has conducted several tests and finally selected N eq...
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 coins, the value of the i-th coin is a_i. It is guaranteed that all the values are integer powers of 2 (i.e. a_i = 2^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.Buber is a Berland technology company that specializes in waste of investor's money. Recently Buber decided to transfer its infrastruc...
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 string s of length n consisting of only characters > and <. You may do some operations with this string, for 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.Let c be some positive integer. Let's call an array a_1, a_2, …, a_n of positive integers c-array, if for all i condition 1 ≤ a_i ≤ 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.There were n types of swords in the theater basement which had been used during the plays. Moreover there were exactly x swords of eac...
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 integer x represented as a product of n its prime divisors p_1 ⋅ p_2, ⋅ … ⋅ p_n. Let S be the set of all positive int...
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 has an array a of length n. He has just enough free time to make a new array consisting of n copies of the old array, written bac...
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.Hilbert's Hotel is a very unusual hotel since the number of rooms is infinite! In fact, there is exactly one room for every integer, 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.Polycarp plays a well-known computer game (we won't mention its name). In this game, he can craft tools of two types — shovels and swo...
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.Utkarsh is forced to play yet another one of Ashish's games. The game progresses turn by turn and as usual, Ashish moves first. Consi...
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 often uses his smartphone. He has already installed n applications on it. Application with number i takes up a_i units of mem...
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 a CEO of a big construction company. And as any other big boss he has a spacious, richly furnished office with two crystal ch...
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 armchairs, numbered from 1 to n from left to right. Some armchairs are occupied by people (at most one person per armchair...
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.Sherlock Holmes and Dr. Watson played some game on a checkered board n × n in size. During the game they put numbers on the board's sq...
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.Bob came to a cash & carry store, put n items into his trolley, and went to the checkout counter to pay. Each item is described by its...
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 got an array a, consisting of n integers. The array elements are indexed from 1 to n. Let's determine a two step operation like...
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 foggy Stockholm morning, Karlsson decided to snack on some jam in his friend Lillebror Svantenson's house. Fortunately for Karlsso...
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.Dima got into number sequences. Now he's got sequence a1, a2, ..., an, consisting of n positive integers. Also, Dima has got a functio...
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 psychos standing in a line. Each psycho is assigned a unique integer from 1 to n. At each step every psycho who has an id ...
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.Dima and Inna love spending time together. The problem is, Seryozha isn't too enthusiastic to leave his room for some reason. But Dima...
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 blinds are known to consist of opaque horizontal stripes that can be rotated thus regulating the amount of light flowing in the ro...
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 chessboard n × m in size is given. During the zero minute we repaint all the black squares to the 0 color. During the i-th minute we...
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 Children's Day, the child got a toy from Delayyy as a present. However, the child is so naughty that he can't wait to destroy the 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.You have two friends. You want to present each of them several positive integers. You want to present cnt1 numbers to the first friend...
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 Geometry. One day he came up with a very interesting problem. Amr has a circle of radius r and center in point (x, y). 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.Andrewid the Android is a galaxy-famous detective. He is now investigating the case of vandalism at the exhibition of contemporary art...
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 GCD table G of size n × n for an array of positive integers a of length n is defined by formula <image> Let us remind you 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.Kevin Sun has just finished competing in Codeforces Round #334! The round was 120 minutes long and featured five problems with maximum...
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.Andrew and Jerry are playing a game with Harry as the scorekeeper. The game consists of three rounds. In each round, Andrew and Jerry ...
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's telephone contains n photos. Photo number 1 is currently opened on the phone. It is allowed to move left and right to the adja...
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.Anastasia loves going for a walk in Central Uzhlyandian Park. But she became uninterested in simple walking, so she began to collect U...
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 of 2012 is coming... According to an ancient choradrican legend in this very year, in 2012, Diablo and his brothers Mephisto...
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 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.It's May in Flatland, and there are m days in this month. Despite the fact that May Holidays are canceled long time ago, employees 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.You are running through a rectangular field. This field can be represented as a matrix with 3 rows and m columns. (i, j) denotes a 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.Bhavana and Bhuvana place bet every time they see something interesting that can occur with a probability 0.5. Both of them place a 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.Given the value of n, print the n'th prime number. Input : A single integer n. Output : A single number which is the n'th prime numb...
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.Yesterday Oz heard a story about insect colony. The specialty of insects is that they splits sometimes i.e an insect of size A can spl...
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 size N. You need to select K elements from the array such that the difference between the max number among 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.In a mystical TimeLand, a person's health and wealth is measured in terms of time(seconds) left. Suppose a person there has 24x60x60 ...
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.Sita loves chocolate and Ram being his boyfriend wants to give Sita as many chocolates as he can. So, he goes to a chocolate store wit...
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.Maga and Alex are good at string manipulation problems. Just now they have faced a problem related to string. But it is not a standard...
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.Given is a positive integer N. How many tuples (A,B,C) of positive integers satisfy A \times B + C = N? Constraints * 2 \leq N \leq ...
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 have caught N sardines. The deliciousness and fragrantness of the i-th sardine is A_i and B_i, respectively. We will choose one 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.There are N people numbered 1 to N. Each person wears a red hat or a blue hat. You are given a string s representing the colors of 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."Pizza At", a fast food chain, offers three kinds of pizza: "A-pizza", "B-pizza" and "AB-pizza". A-pizza and B-pizza are completely di...
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 only six months until Christmas, and AtCoDeer the reindeer is now planning his travel to deliver gifts. There are N houses along...
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.Tak has N cards. On the i-th (1 \leq i \leq N) card is written an integer x_i. He is selecting one or more cards from these N cards, 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.There is data on sales of your company. Your task is to write a program which identifies good workers. The program should read a list...
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 nth triangular number is defined as the sum of the first n positive integers. The nth tetrahedral number is defined as the sum 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.There are several towns on a highway. The highway has no forks. Given the distances between the neighboring towns, we can calculate al...
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.G: Minimum Enclosing Rectangle-Minimum Enclosing Rectangle- story Hello everyone! It's Airi Aiza from the Hachimori Naka Prokon Club...
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.Given a matrix (H × W) which contains only 1 and 0, find the area of the largest rectangle which only contains 0s. Constraints * 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.Addition of Big Integers Given two integers $A$ and $B$, compute the sum, $A + B$. Input Two integers $A$ and $B$ separated by a sp...
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 country of Numberia, there is a city called Primeland. Sherry is one of the rich inhabitants of the city, who likes to collect ...
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.Do you know that The Chef has a special interest in palindromes? Yes he does! Almost all of the dishes in his restaurant is named by 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.Natasha is going to fly to Mars. She needs to build a rocket, which consists of several stages in some order. Each of the stages is 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.Vasya has recently got a job as a cashier at a local store. His day at work is L minutes long. Vasya has already memorized n regular 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.Recently, Masha was presented with a chessboard with a height of n and a width of m. The rows on the chessboard are numbered from 1 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.Everybody knows that the m-coder Tournament will happen soon. m schools participate in the tournament, and only one student from 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.The only difference between easy and hard versions is constraints. The BerTV channel every day broadcasts one episode of one of 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.You are given a board of size n × n, where n is odd (not divisible by 2). Initially, each cell of the board contains one figure. In 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.Alica and Bob are playing a game. Initially they have a binary string s consisting of only characters 0 and 1. Alice and Bob make al...
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 princess is going to escape the dragon's cave, and she needs to plan it carefully. The princess runs at vp miles per hour, and 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.Another programming contest is over. You got hold of the contest's final results table. The table has the following data. For each tea...
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.PMP is getting a warrior. He is practicing a lot, but the results are not acceptable yet. This time instead of programming contests, 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.John Doe started thinking about graphs. After some thought he decided that he wants to paint an undirected graph, containing exactly 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.Little Elephant loves magic squares very much. A magic square is a 3 × 3 table, each cell contains some positive integer. At that 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.Recently a serious bug has been found in the FOS code. The head of the F company wants to find the culprit and punish him. For that, 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.Bizon the Champion isn't just a bison. He also is a favorite of the "Bizons" team. At a competition the "Bizons" got the following 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.Today there is going to be an unusual performance at the circus — hamsters and tigers will perform together! All of them stand in circ...
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 schoolboy named Vasya loves reading books on programming and mathematics. He has recently read an encyclopedia article that describe...
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 sequence of cubes and exactly one integer is written on each cube. Vasya exhibited all his cubes in a row. So the sequence...
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 has a ticket consisting of 6 digits. In one move she can choose digit in any position and replace it with arbitrary digit. She wa...
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 perfectly predict the price of a certain stock for the next N days. You would like to profit on this knowledge, but only want ...
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 positive integers a1, a2, ..., an. For every ai you need to find a positive integer ki such that the decimal notation...
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 string s consisting of n lowercase Latin letters. Let's denote k-substring of s as a string subsk = sksk + 1..sn + 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.Two strings are said to be anagrams of each other if the letters of one string may be rearranged to make the other string. 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.All the students in NIT are very lazy. They want to have maximum time for rest. But due to college rules, they must maintain 75% atten...
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.Monk visits the land of Islands. There are a total of N islands numbered from 1 to N. Some pairs of islands are connected to each ot...
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.Given an integer N. Find out the PermutationSum where PermutationSum for integer N is defined as the maximum sum of difference of adj...
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.Roy wants to change his profile picture on Facebook. Now Facebook has some restriction over the dimension of picture that we can uploa...
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.Yes, you read it right - Little Jhool is back, but no, he's not over his break up, still. And he's sad, broken and depressed; thus, 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.To become a millionaire, M-kun has decided to make money by trading in the next N days. Currently, he has 1000 yen and no stocks - onl...