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.Its Diwali time and Little Roy's family is having a lot of guests. Guests come in families. Each guest family has M members. Roy's tas...
user: Generate an executable Python 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 set S. Generate T, a set that contains all subsets of S minus the null set and calculate A, XOR sum of the set T. S={1,2,3}...
user: Generate an executable Python 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, Vasya has decided to study about Numbers and Number Theory. One of her good friends Kolya is very good at the subject. To help ...
user: Generate an executable Python 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 N squares assigned the numbers 1,2,3,\ldots,N. Each square has an integer written on it, and the integer written on Square i 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.Given is a positive integer N. Find the number of permutations (P_1,P_2,\cdots,P_{3N}) of (1,2,\cdots,3N) that can be generated throug...
user: Generate an executable Python 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 string S of length N-1. Each character in S is `<` or `>`. A sequence of N non-negative integers, a_1,a_2,\cdots,a_N, is 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 flower bed, there are N flowers, numbered 1,2,......,N. Initially, the heights of all flowers are 0. You are given a sequence 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.The ABC number of a string T is the number of triples of integers (i, j, k) that satisfy all of the following conditions: * 1 ≤ i < 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.You are playing the following game with Joisino. * Initially, you have a blank sheet of paper. * Joisino announces a number. If 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.Squid loves painting vertices in graphs. There is a simple undirected graph consisting of N vertices numbered 1 through N, and M edge...
user: Generate an executable Python 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 task is to write a program which reads a text and prints two words. The first one is the word which is arise most frequently 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.The courier charges for a courier company are set according to size and weight as shown in the table below. A size | B size | C size ...
user: Generate an executable Python 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 Just Odd Inventions? The business of this company is to "just odd inventions". Here, it is abbreviated as JOI. JOI 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.Problem A graph is given in which N vertices, each numbered from 1 to N, are connected by N-1 undirected edges. For each vertex, outp...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.I'm traveling to a country with a rabbit. There are n cities in this country numbered from 1 to n, and the rabbit is now in city 1. 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.B --Doctor Course Is Recommended / D How about going forward? Story Since the person D decided to advance to D, he decided to take 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.We want to encode a given string $S$ to a binary string. Each alphabet character in $S$ should be mapped to a different variable-lengt...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Write a program which reads a sequence of $n$ integers $a_i (i = 1, 2, ... n)$, and prints the minimum value, maximum value and 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.Yesterday Chef had a great party and doesn't remember the way he celebreated it. But he found a strange paper in his kitchen containin...
user: Generate an executable Python 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, Chef prepared D brand new dishes. He named the i-th dish by a string Si. After the cooking, he decided to categorize each 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.XOXO likes to play with numbers.So,given a number N help XOXO to find whether it is a fibonacci number or not.It won't be hard!   Inp...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Chef has decided to arrange the free shuttle service for his employees. City of Bhiwani has a strange layout - all of its N shuttle bo...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Sonya decided that having her own hotel business is the best way of earning money because she can profit and rest wherever she 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.Consider a table of size n × m, initially fully white. Rows are numbered 1 through n from top to bottom, columns 1 through m from left...
user: Generate an executable Python 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 students in a university. The number of students is even. The i-th student has programming skill equal to a_i. The coach...
user: Generate an executable Python 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 denote that some array b is bad if it contains a subarray b_l, b_{l+1}, ..., b_{r} of odd length more than 1 (l < r and r - 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.Everyone knows that hobbits love to organize all sorts of parties and celebrations. There are n hobbits living in the Shire. They deci...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Welcome! Everything is fine. You have arrived in The Medium Place, the place between The Good Place and The Bad Place. You are assign...
user: Generate an executable Python 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 integers a_1, a_2, ..., a_n. For each a_i find its two divisors d_1 > 1 and d_2 > 1 such that \gcd(d_1 + d_2, a_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.There are n robbers at coordinates (a_1, b_1), (a_2, b_2), ..., (a_n, b_n) and m searchlight at coordinates (c_1, d_1), (c_2, d_2), .....
user: Generate an executable Python 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 asked to watch your nephew who likes to play with toy blocks in a strange way. He has n boxes and the i-th box has a_i blocks...
user: Generate an executable Python 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 found on the street an array a of n elements. Polycarp invented his criterion for the beauty of an array. He calls an array ...
user: Generate an executable Python 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 lived a good fairy A. One day a fine young man B came to her and asked to predict his future. The fairy looked ...
user: Generate an executable Python 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 a rectangular parallelepiped with integer edge lengths. You know the areas of its three faces that have a common vertex. 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.Yaroslav thinks that two strings s and w, consisting of digits and having length n are non-comparable if there are two numbers, i and ...
user: Generate an executable Python 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 it has been found out recently, all the Berland's current economical state can be described using a simple table n × m in size. 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 n pairs of socks. In the morning of each day Vasya has to put on a pair of socks before he goes to school. When he comes hom...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Breaking Good is a new video game which a lot of gamers want to have. There is a certain level in the game that is really difficult ev...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Soon a school Olympiad in Informatics will be held in Berland, n schoolchildren will participate there. At a meeting of the jury of 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.High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya deno...
user: Generate an executable Python 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.Palindromic characteristics of string s with length |s| is a sequence of |s| integers, where k-th number is the total number of non-em...
user: Generate an executable Python 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 have to deal with a very special network. The network consists of two parts: part A and part B. Each part co...
user: Generate an executable Python 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 xi. All these coordinates are distinct. Determine ...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Suppose you have two strings s and t, and their length is equal. You may perform the following operation any number of times: choose 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.Two famous competing companies ChemForces and TopChemist decided to show their sets of recently discovered chemical elements on an exh...
user: Generate an executable Python 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: Dom and Brian were trying to evade the truck drivers of Verone's gang. They were too fast, too furious for them, 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 have been given 3 integers l, r and k. Find how many numbers between l and r (both inclusive) are divisible by k. You do not need ...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Soumika has a string S and its starting index is 1. The string S consists of characters from 1-9. As she is very intelligent, she 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.The link to the Russian translation. Stefan is stuck in Marty's body and in order to fix him, Valerie has encountered a problem 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.In computer Science there is common need to generate random permutation. It can be seen as the shuffle of the numbers. Start with sort...
user: Generate an executable Python 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 N integers A[1] , A[2] , ... , A[N] . You have to answer Q queries. Each query consists of 3 integers L, R 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.We have A cards, each of which has an integer 1 written on it. Similarly, we also have B cards with 0s and C cards with -1s. We will ...
user: Generate an executable Python 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 will call a string obtained by arranging the characters contained in a string a in some order, an anagram of a. For example, `gree...
user: Generate an executable Python 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 beginning, Takahashi has A cookies, and Aoki has B cookies. They will perform the following operation alternately, starting 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.We call a 4-digit integer with three or more consecutive same digits, such as 1118, good. You are given a 4-digit integer N. Answer 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 are given two integers A and B as the input. Output the value of A + B. However, if A + B is 10 or greater, output `error` instea...
user: Generate an executable Python 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 lowercase English letter c, determine whether it is a vowel. Here, there are five vowels in the English alphabet: `a`, `e`, `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 lives on an infinite two-dimensional plane. He is going on an N-day trip. At the beginning of Day 1, he is at home. His plan 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.The Zuia Kingdom has finally emerged through annexation of $N$ cities, which are identified by index from $1$ to $N$. You are appointe...
user: Generate an executable Python 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, there are two pastry shops. One shop was very popular because its cakes are pretty tasty. However, there was a man who 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.Boy G was on a voyage with his father to celebrate his 13th birthday. However, during the voyage, unfortunately the ship was hit 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.A great king of a certain country suddenly decided to visit the land of a friendly country. The country is famous for trains, 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.Poisonous swamp You are playing a retro role-playing game. The field of this game is a grid of 100 squares vertically and 100 squares...
user: Generate an executable Python 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 N coins each of which has a value ai. Find the number of combinations that result when you choose K different coins in such 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.Division of Big Integers Given two integers $A$ and $B$, compute the quotient, $\frac{A}{B}$. Round down to the nearest decimal. Inp...
user: Generate an executable Python 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 few days ago Chef decided to cook a new dish – chocolate. This must be something amazing. The idea is that chocolate bar will be 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.Given three positive integers N, L and R, find the number of non-decreasing sequences of size at least 1 and at most N, such that 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.Chef talks a lot on his mobile phone. As a result he exhausts his talk-value (in Rokdas) very quickly. One day at a mobile recharge sh...
user: Generate an executable Python 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 internet protocols these days include the option of associating a media type with the content being sent. The type is usually inf...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Santosh has a farm at Byteland. He has a very big family to look after. His life takes a sudden turn and he runs into a financial cri...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Chef belongs to a very rich family which owns many gold mines. Today, he brought N gold coins and decided to form a triangle using 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.Polycarp loves ciphers. He has invented his own cipher called Right-Left. Right-Left cipher is used for strings. To encrypt the strin...
user: Generate an executable Python 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 came to a local shop and want to buy some chocolate bars. There are n bars in the shop, i-th of them costs a_i coins (and you 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.Three friends are going to meet each other. Initially, the first friend stays at the position x = a, the second friend stays at the po...
user: Generate an executable Python 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 string s of length n consisting of 0-s and 1-s. You build an infinite string t as a concatenation of an infinite number ...
user: Generate an executable Python 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 string s of length n. He decides to make the following modification to the string: 1. Pick an integer k, (1 ≤ k ≤ 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 likes studying at school a lot and he is always diligent about his homework. Polycarpus has never had any problems with nat...
user: Generate an executable Python 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 Petya likes to play very much. And most of all he likes to play the following game: He is given a sequence of N integer number...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Nikola owns a large warehouse which is illuminated by N light bulbs, numbered 1 to N. At the exit of the warehouse, there are S light ...
user: Generate an executable Python 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 permutation is a sequence of integers from 1 to n of length n containing each number exactly once. For example, [1], [4, 3, 5, 1, 2]...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Berland crossword is a puzzle that is solved on a square grid with n rows and n columns. Initially all the cells are white. To solve ...
user: Generate an executable Python 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 number is called 2050-number if it is 2050, 20500, ..., (2050 ⋅ 10^k for integer k ≥ 0). Given a number n, you are asked to represe...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Finally, you have defeated Razor and now, you are the Most Wanted street racer. Sergeant Cross has sent the full police force after 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.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 s 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.Simon has a rectangular table consisting of n rows and m columns. Simon numbered the rows of the table from top to bottom starting 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 have an array of positive integers a[1], a[2], ..., a[n] and a set of bad prime numbers b1, b2, ..., bm. The prime numbers that do...
user: Generate an executable Python 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 decided to watch the best moments of some movie. There are two buttons on your player: 1. Watch the current minute 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.One day n friends met at a party, they hadn't seen each other for a long time and so they decided to make a group photo together. Si...
user: Generate an executable Python 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 are to calculate the sum of all integers from 1 to n, but you should take all powers of two with minus in the sum....
user: Generate an executable Python 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 likes to play chess, and so does his friend Danik. Once they have played n games in a row. For each game it's known who was 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.In Berland it is the holiday of equality. In honor of the holiday the king decided to equalize the welfare of all citizens in Berland ...
user: Generate an executable Python 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 marmots have prepared a very easy problem for this year's HC2 – this one. It involves numbers n, k and a sequence of n positive 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.Connect the countless points with lines, till we reach the faraway yonder. There are n points on a coordinate plane, the i-th of whic...
user: Generate an executable Python 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. Everybody knows that positive integers are lucky if their decimal representation doesn't contain digits oth...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Unlike Knights of a Round Table, Knights of a Polygonal Table deprived of nobility and happy to kill each other. But each knight has 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.You are given a array of integers. Find the diff between the maximum average value and minimum average value of sub-sequences of array...
user: Generate an executable Python 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 was contesting to be the most stylist person in his college. He had to collect maximum points from the judges to be able to win....
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Now after having the event list, all the participants wanted to know where to go for their respective events, for this purpose they 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.PRAVAH, an annual techfest is being organised at SKIT. Naina comes up with an idea for an event Guess The Number. In this event, the c...