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.There are two rival donut shops. The first shop sells donuts at retail: each donut costs a dollars. The second shop sells donuts onl...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.So nearly half of the winter is over and Maria is dreaming about summer. She's fed up with skates and sleds, she was dreaming about Ho...
user: Generate an executable Python 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're given an array b of length n. Let's define another array a, also of length n, for which a_i = 2^{b_i} (1 ≤ i ≤ n). Valerii sa...
user: Generate an executable Python 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 a new computer game in which you have to fight monsters. In a dungeon you are trying to clear, you met three monsters;...
user: Generate an executable Python 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 dragon. Two dragon. Three dragon», — the princess was counting. She had trouble falling asleep, and she got bored of counting lam...
user: Generate an executable Python 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 numerated from 1 to n. The level of the i-th student is a_i. You need to split the students into stable groups. 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.Two integers x and y are compatible, if the result of their bitwise "AND" equals zero, that is, a & b = 0. For example, numbers 90 (10...
user: Generate an executable Python 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 consider equation: x2 + s(x)·x - n = 0, where x, n are positive integers, s(x) is the function, equal to the sum of digits of...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.The Little Elephant loves chess very much. One day the Little Elephant and his friend decided to play chess. They've got the chess 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.The classic programming language of Bitland is Bit++. This language is so peculiar and complicated. The language is that peculiar as ...
user: Generate an executable Python 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 is called the Champion for a reason. Bizon the Champion has recently got a present — a new glass cupboard with 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.One day a well-known sponsor of a well-known contest decided to give every participant of the contest a T-shirt as a present. A natura...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Vanya wants to pass n exams and get the academic scholarship. He will get the scholarship if the average grade mark for all the exams ...
user: Generate an executable Python 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 name of one small but proud corporation consists of n lowercase English letters. The Corporation has decided to try rebranding — 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're given a matrix A of size n × n. Let's call the matrix with nonnegative elements magic if it is symmetric (so aij = aji), aii =...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Stepan has the newest electronic device with a display. Different digits can be shown on it. Each digit is shown on a seven-section 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.Arkady plays Gardenscapes a lot. Arkady wants to build two new fountains. There are n available fountains, for each fountain its beaut...
user: Generate an executable Python 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 annual chess tournament is coming! Organizers have gathered 2·n chess players who should be divided into two teams with n peo...
user: Generate an executable Python 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 Polycarp decided to rewatch his absolute favourite episode of well-known TV series "Tufurama". He was pretty surprised when 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.Given a square matrix of size N×NN×N, calculate the absolute difference between the sums of its diagonals. Input Format The first li...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Geeko is very happy because his exam are over so he is busy in playing games and watching movies, today he has watched lord of 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.As the Monk is also taking part in the CodeMonk Series, this week he learned about hashing. Now he wants to practice some problems. So...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Chinna is preparing for an online entrance examination. The performance in the examination is measured on a rating scale of 1 to 10^6....
user: Generate an executable Python 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 has a matrix of size NxN. Rows and Columns are numbered from 0 to N-1. j^th column of i^th row contains i xor j. In other word...
user: Generate an executable Python 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 we have seen that Vaishnav was a smart kid and today he has grown up(but he is still childish) and he is in High school. Today 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.M-kun is a student in Aoki High School, where a year is divided into N terms. There is an exam at the end of each term. According to 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.Given are two integer sequences of N elements each: A_1,...,A_N and B_1,...,B_N. Determine if it is possible to do the following opera...
user: Generate an executable Python 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 rooted tree (see Notes) with N vertices numbered 1 to N. Each of the vertices, except the root, has a directed edge coming ...
user: Generate an executable Python 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 the base -2 representation of N. Here, S is the base -2 representation of N when the following are all satis...
user: Generate an executable Python 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 Takahashi Kingdom, which once existed, there are N cities, and some pairs of cities are connected bidirectionally by roads. The fol...
user: Generate an executable Python 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 loves "paper cutting": he cuts out characters from a newspaper headline and rearranges them to form another string. He will rec...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Sample testcase 3 has a mistake, so we erased this case and rejudged all solutions of this problem. (21:01) Snuke got a sequence $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.Ignoring the air resistance, velocity of a freely falling object $v$ after $t$ seconds and its drop $y$ in $t$ seconds are represented...
user: Generate an executable Python 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 frog is about to return to the burrow. The burrow is D centimeters ahead of the frog, and the frog goes straight toward the burrow. ...
user: Generate an executable Python 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 message from humans to extraterrestrial intelligence was sent through the Arecibo radio telescope in Puerto Rico on the afternoon 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 one of ICPC participants and in charge of developing a library for multiprecision numbers and radix conversion. You have just ...
user: Generate an executable Python 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 is an innocent man who used to live on the Earth. He had lived a really commonplace life, until the day when the Earth was dest...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Equation Identity English text is not available in this practice contest. In logical operations, only two types of values, T and 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.You are playing a coin puzzle. The rule of this puzzle is as follows: There are $N$ coins on a table. The $i$-th coin is a circle 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.Problem There are N sets of integers. Each of these sets is assigned a number from 1 to N. The number of elements in the i-th set 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.Write a program which reads two integers x and y, and prints them in ascending order. Constraints * 0 ≤ x, y ≤ 10000 * the number 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.Problem Statement A mountain hiker is descending from the mountain ranges. There are many mountains along his way each with it's own 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.Chef is on a vacation these days, so his friend Chefza is trying to solve Chef's everyday tasks. Today's task is to make a sweet roll....
user: Generate an executable Python 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 a rooted tree G, consisting of N vertices. Each edge of the tree has a color black or white. Once Chef's friend Ksen offered ...
user: Generate an executable Python 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 Ciel wants to put a fancy neon signboard over the entrance of her restaurant. She has not enough money to buy the new one so she ...
user: Generate an executable Python 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 war going on between two countries and the enemy of your country depends heavily on the transportation of Weapons between 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 game of billiards involves two players knocking 3 balls around on a green baize table. Well, there is more to it, but for our purp...
user: Generate an executable Python 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 players A and B have a list of n integers each. They both want to maximize the subtraction between their score and their opponent'...
user: Generate an executable Python 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 strip with an infinite number of cells. Cells are numbered starting with 0. Initially the cell i contains a ball with the 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.You are given array a of length n. You can choose one segment [l, r] (1 ≤ l ≤ r ≤ n) and integer value k (positive, negative or even z...
user: Generate an executable Python 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_1, a_2, ..., a_n of integer numbers. Your task is to divide the array into the maximum number of segments 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.Welcome to Codeforces Stock Exchange! We're pretty limited now as we currently allow trading on one stock, Codeforces Ltd. We hope you...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.It is a holiday season, and Koala is decorating his house with cool lights! He owns n lights, all of which flash periodically. After ...
user: Generate an executable Python 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 integers l and r. Find an integer x which satisfies the conditions below: * l ≤ x ≤ r. * All digits of x are differ...
user: Generate an executable Python 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 players decided to play one interesting card game. There is a deck of n cards, with values from 1 to n. The values of cards are 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.You have n students under your control and you have to compose exactly two teams consisting of some subset of your students. Each stud...
user: Generate an executable Python 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 running competition is going to be held soon. The stadium where the competition will be held can be represented by several segments ...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Sometimes it is not easy to come to an agreement in a bargain. Right now Sasha and Vova can't come to an agreement: Sasha names a pric...
user: Generate an executable Python 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 median of an array of integers of length n is the number standing on the ⌈ {n/2} ⌉ (rounding up) position in the non-decreasing orde...
user: Generate an executable Python 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 three bags. Each bag contains a non-empty multiset of numbers. You can perform a number of operations on these bags. 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.You are given an integer a that consists of n digits. You are also given a sequence of digits s of length m. The digit in position 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.Сity N. has a huge problem with roads, food and IT-infrastructure. In total the city has n junctions, some pairs of them are connected...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Permutation p is an ordered set of integers p1, p2, ..., pn, consisting of n distinct positive integers, each of them doesn't exceed 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.Certainly, everyone is familiar with tic-tac-toe game. The rules are very simple indeed. Two players take turns marking the cells in 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.Alas, finding one's true love is not easy. Masha has been unsuccessful in that yet. Her friend Dasha told Masha about a way to determi...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Polar bears Menshykov and Uslada from the zoo of St. Petersburg and elephant Horace from the zoo of Kiev got hold of lots of wooden cu...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Two soldiers are playing a game. At the beginning first of them chooses a positive integer n and gives it to the second soldier. Then ...
user: Generate an executable Python 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 on a math lesson the teacher told Vovochka that the Euler function of a positive integer φ(n) is an arithmetic function that cou...
user: Generate an executable Python 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.You are given two arithmetic progressions: a1k + b1 and a2l + b2. Find the number of integers x such that L ≤ x ≤ R and x = a1k' + b1 ...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Archeologists have found a secret pass in the dungeon of one of the pyramids of Cycleland. To enter the treasury they have to open 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.Okabe likes to take walks but knows that spies from the Organization could be anywhere; that's why he wants to know how many different...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Bishwock is a chess figure that consists of three squares resembling an "L-bar". This figure can be rotated by 90, 180 and 270 degrees...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Arjit, Protector of The Realm, has an important task at hand. M new subjects are soon going to become a part of The Realm. The Realm, ...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.How many different ways can you make change for an amount, given a list of coins? In this problem, your code will need to efficiently ...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Ramesh and Suresh are best friends. But they are fighting over money now. Suresh has given some money to Ramesh but he has forgotten 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.Little Syed loves brute force. He thinks that brute force can be the solution to any problem in the world. You give him any question, ...
user: Generate an executable Python 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 two integers, L and R, find the maximal value of A xor B, where A and B satisfy the following condition: L ≤ A ≤ B ≤ R Input ...
user: Generate an executable Python 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 Samu went out for a walk in the park but there weren't any of her friends with her. So she decided to enjoy by her own. Samu 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.As the students are back in hostel after a long time, the gamers have decided to have a LAN gaming competition to find out who has uti...
user: Generate an executable Python 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 will be given a contest schedule for D days. For each d=1,2,\ldots,D, calculate the satisfaction at the end of day d. Input 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.The window of Takahashi's room has a width of A. There are two curtains hung over the window, each of which has a horizontal length 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 N stones, numbered 1, 2, \ldots, N. For each i (1 \leq i \leq N), the height of Stone i is h_i. There is a frog who is init...
user: Generate an executable Python 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 lowercase English letters. We will write down this string, starting a new line after every w le...
user: Generate an executable Python 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 game is played on a strip consisting of N cells consecutively numbered from 1 to N. Alice has her token on cell A. Borys has his 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.There is a kangaroo at coordinate 0 on an infinite number line that runs from left to right, at time 0. During the period between time...
user: Generate an executable Python 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 interested in strings that satisfy the following conditions: * The length of the string is at least N. * The first N charact...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Aizu Gakuen High School holds a school festival every year. The most popular of these is the haunted house. The most popular reason 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.You have full control over a robot that walks around in a rectangular field paved with square tiles like a chessboard. There are m col...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Advanced Computer Music (ACM) sold a rhythm machine that plays music according to a pre-programmed rhythm. At one point, ACM was tryin...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Areas on the Cross-Section Diagram Your task is to simulate a flood damage. For a given cross-section diagram, reports areas of floo...
user: Generate an executable Python 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 $n \times m$ matrix $A$ and a $m \times l$ matrix $B$, and prints their product, a $n \times l$ matrix $...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Virat is a guy who likes solving problems very much. Today Virat’s friend Jadega gave him a problem to solve. Jadeja gives Virat three...
user: Generate an executable Python 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 the finance department of MAKAUT has lots of bills to pass and funds to allocate for puja and freshers so there is a mess in Fin...
user: Generate an executable Python 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 matrix of size N * N with rows numbered through 1 to N from top to bottom and columns through 1 to N from left to right. It...
user: Generate an executable Python 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 Ron of Byteland was poor at mathematics. He always used to get zero marks in mathematics test. One evening when he showed his 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.A version control system(VCS) is a repository of files, often the files for the source code of computer programs, with monitored acces...
user: Generate an executable Python 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 an array a consisting of n integers. He has learned partial sums recently, and now he can calculate the sum of elements on 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.After lessons Nastya decided to read a book. The book contains n chapters, going one after another, so that one page of the book belon...
user: Generate an executable Python 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 standing in a row. Two coaches are forming two teams — the first coach chooses the first team and the second coac...