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 N sticks, the length of the i^th stick being ai . As your professor is very interested in triangles he gives you a probl...
user: Generate an executable Python 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 state consists of N cities. Some of these cities are connected to each other by one - way roads. The time taken to travel from a par...
user: Generate an executable Python 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 which comprises of lower case alphabets (a-z), upper case alphabets (A-Z), numbers, (0-9) and special character...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.SKIT’s canteen sells Patties in packages of 6, 9 or 20 . Thus, it is possible, for example, to buy exactly 15 Patties (with one packag...
user: Generate an executable Python 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 part to play in the Wars to Come. As everyone knows, Lord Stannis Baratheon (First of His Name, King of the Andals 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.Given is an integer x that is greater than or equal to 0, and less than or equal to 1. Output 1 if x is equal to 0, or 0 if x is equal...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Constraints * All values in input are integers. * 1\leq N, M\leq 12 * 1\leq X\leq 10^5 * 1\leq C_i \leq 10^5 * 0\leq A_{i, j} \leq 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.Takahashi has K 500-yen coins. (Yen is the currency of Japan.) If these coins add up to X yen or more, print `Yes`; otherwise, print `...
user: Generate an executable Python 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 one-off jobs available. If you take the i-th job and complete it, you will earn the reward of B_i after A_i days from the ...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.There are a total of A + B cats and dogs. Among them, A are known to be cats, but the remaining B are not known to be either cats or 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.You are given a string S consisting of lowercase English letters. Determine whether all the characters in S are different. Constraint...
user: Generate an executable Python 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 an image with a height of H pixels and a width of W pixels. Each of the pixels is represented by either `.` or `*`. The chara...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Based on the information of the time when study started and the time when study ended, check whether the total time studied in one day...
user: Generate an executable Python 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 ancient nation of Iwashiro, priests pray to calm disasters in the event of a disaster. The priest selects the character string...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Taro, a boy who hates any inefficiencies, pays coins so that the number of coins to be returned as change is minimized in order to 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.C: Digital Clock story Aizu Nyan has recently caught a cold. I can't get out of bed because I'm too lazy. The spicy appearance is 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.Min Element Given the sequence a_1, a_2, .., a_N. Find the minimum number in this sequence. If the minimum value is in more than on...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Write a program which manipulates a disjoint set S = {S1, S2, . . . , Sk}. First of all, the program should read an integer n, then m...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Remainder of Big Integers Given two integers $A$ and $B$, compute the remainder of $\frac{A}{B}$. Input Two integers $A$ and $B$ se...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Devu and Churu love to play games a lot. Today, they have an array A consisting of N positive integers. First they listed all N × (N+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.John Watson always knew that one of the favourite hobbies of Sherlock Holmes was to tinker with ciphers. Though Watson was not that go...
user: Generate an executable Python 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 an attempt to reduce the growing population, Archer was asked to come up with a plan. Archer being as intelligent as he is, came up...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Vadim and Roman like discussing challenging problems with each other. One day Vadim told his friend following problem: Given N points...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.For Turbo C++ Users : Read the following document before attempting the question : Problem description Logan is tired of not be...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Janusz is a businessman. He owns a company "Januszex", which produces games for teenagers. Last hit of Januszex was a cool one-person ...
user: Generate an executable Python 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 State University invites people from all over the world as guest students. You can come to the capital of Berland and study wi...
user: Generate an executable Python 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 is decorating his kitchen, more precisely, the floor. He has found a prime candidate for the tiles he will use. They come in a sim...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.n robots have escaped from your laboratory! You have to find them as soon as possible, because these robots are experimental, and thei...
user: Generate an executable Python 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 the number of elements in the array. You are given an array a consisting of n 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.Roma is playing a new expansion for his favorite game World of Darkraft. He made a new character and is going for his first grind. 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.Polycarp found under the Christmas tree an array a of n elements and instructions for playing with it: * At first, choose index 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.You've got string s, consisting of only lowercase English letters. Find its lexicographically maximum subsequence. We'll call a non-e...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Jabber ID on the national Berland service «Babber» has a form <username>@<hostname>[/resource], where * <username> — is a 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.Emuskald is a well-known illusionist. One of his trademark tricks involves a set of magical boxes. The essence of the trick is in pack...
user: Generate an executable Python 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 problem uses a simplified TCP/IP address model, please make sure you've read the statement attentively. Polycarpus has found a jo...
user: Generate an executable Python 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 one little known, but very beautiful country called Waterland, lives a lovely shark Valerie. Like all the sharks, she has several 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.In this problem we consider a special type of an auction, which is called the second-price auction. As in regular auction n bidders pl...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Alex doesn't like boredom. That's why whenever he gets bored, he comes up with games. One long winter evening he came up with a game 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.Petya studies in a school and he adores Maths. His class has been studying arithmetic expressions. On the last class the teacher wrote...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Misha and Vasya participated in a Codeforces contest. Unfortunately, each of them solved only one problem, though successfully submitt...
user: Generate an executable Python 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 got an important task — he should enumerate books in the library and label each book with its number. Each of the n books should...
user: Generate an executable Python 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 programing contest named SnakeUp, 2n people want to compete for it. In order to attend this contest, people need to form te...
user: Generate an executable Python 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. Let's call word any largest sequence of consecutive symbols without symbols ',' (comma) and ';' (semicolon). 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.Dexterina and Womandark have been arch-rivals since they’ve known each other. Since both are super-intelligent teenage girls, they’ve ...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Array of integers is unimodal, if: * it is strictly increasing in the beginning; * after that it is constant; * after that 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.Due to the recent popularity of the Deep learning new countries are starting to look like Neural Networks. That is, the countries are ...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Imp is in a magic forest, where xorangles grow (wut?) <image> A xorangle of order n is such a non-degenerate triangle, that lengths ...
user: Generate an executable Python 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 wants to remove duplicate (equal) elements. Petya wants to leave only the rightmost...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.View Russian Translation Limak is a little polar bear. Today he found something delicious in the snow. It's a square bar of chocolate...
user: Generate an executable Python 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 Pandey and GJ are coding buddies - since they are the part of ACM ICPC team together. But, GJ is fed up of Pandey's weird codin...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Programmer Deepak has created a program which calculates magical number as 2^n * 3^n * 5^n where "n" is an integer. Now he wants to 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.Mathematician Shikhar has invented a new type of fibonacci series in which fib(1)=a fib(2)=b fib(n)=(fib(n-1)+fib(n-2))%100000000...
user: Generate an executable Python 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 very famous football club Manchester United decided to popularize football in India by organizing a football fest. The fest had ma...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Xsquare get bored playing with the arrays all the time. So,he decided to buy a new character set to play with. Xsquare's character set...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Compute A \times B. Constraints * 1 \leq A \leq 100 * 1 \leq B \leq 100 * All values in input are integers. Input Input is given 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.Caracal is fighting with a monster. The health of the monster is H. Caracal can attack by choosing one monster. When a monster is at...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Takahashi's house has only one socket. Takahashi wants to extend it with some number of power strips, each with A sockets, into B 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.Takahashi has N balls with positive integers written on them. The integer written on the i-th ball is A_i. He would like to form some ...
user: Generate an executable Python 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, Takahashi was given the following problem from Aoki: * You are given a tree with N vertices and an integer K. The vertices 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.At Akabeko Elementary School, all the students participate in a slightly unusual jogging. Students run their own lap courses at their ...
user: Generate an executable Python 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 three dice brothers are triplets, one and the same, and three can be said to be one. Since they are triplets, they are indistingui...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Nate U. Smith runs a railroad company in a metropolitan area. In addition to his railroad company, there are rival railroad companies ...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Nathan O. Davis is trying to capture a game and struggling to get a very rare item. This rare item can be obtained by arranging specia...
user: Generate an executable Python 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 scientist Arthur C. McDonell is conducting a very complex chemical experiment. This experiment requires a large number of very simpl...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.F: Tea Party Yun decided to hold a tea party at the company. The shop sells $ N $ sets of bread, each containing $ A_1, A_2, A_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.Problem Alice and Bob are competing in the 50m dash. However, in this world, the higher the AOJ rate is, the better, so the higher 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.For given an integer $n$, print all permutations of $\\{1, 2, ..., n\\}$ in lexicographic order. Constraints * $1 \leq n \leq 9$ 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.Chef plays with the sequence of N numbers. During a single move Chef is able to choose a non-decreasing subsequence of the sequence 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.Least Distance Mr. John has a habit of implementing new programming methods. This time he needs your help to solve a problem. He needs...
user: Generate an executable Python 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 living in the dormitory of Berland State University. Each of them sometimes wants to use the kitchen, so the head...
user: Generate an executable Python 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 preparing a contest, and now he has written a statement for an easy problem. The statement is a string of length n consisting...
user: Generate an executable Python 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, Yasser and Adel are at the shop buying cupcakes. There are n cupcake types, arranged from 1 to n on the shelf, and there are 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.Gildong recently learned how to find the [longest increasing subsequence](https://en.wikipedia.org/wiki/Longest_increasing_subsequence...
user: Generate an executable Python 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 rooted tree consisting of n vertices numbered from 1 to n. The root of the tree is a vertex number 1. A tree is a 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.Lee just became Master in Codeforces, and so, he went out to buy some gifts for his friends. He bought n integers, now it's time to 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.Consider a conveyor belt represented using a grid consisting of n rows and m columns. The cell in the i-th row from the top and the 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.Meka-Naruto plays a computer game. His character has the following ability: given an enemy hero, deal a instant damage to him, 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.You are given a text that consists of lowercase Latin letters, spaces and punctuation marks (dot, comma, exclamation mark and 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.The Two-dimensional kingdom is going through hard times... This morning the Three-Dimensional kingdom declared war on the Two-dimensio...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Patrick has just finished writing a message to his sweetheart Stacey when he noticed that the message didn't look fancy. Patrick was 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.Little Petya likes arrays that consist of non-negative integers a lot. Recently his mom has presented him one such array consisting 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.Connected undirected graph without cycles is called a tree. Trees is a class of graphs which is interesting not only for people, but 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.This task will exclusively concentrate only on the arrays where all elements equal 1 and/or 2. Array a is k-period if its length is 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.Mashmokh's boss, Bimokh, didn't like Mashmokh. So he fired him. Mashmokh decided to go to university and participate in ACM instead 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.Tavas is a strange creature. Usually "zzz" comes out of people's mouth while sleeping, but string s of length n comes out from Tavas' ...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Gerald got a very curious hexagon for his birthday. The boy found out that all the angles of the hexagon are equal to <image>. Then 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.Sean is trying to save a large file to a USB flash drive. He has n USB flash drives with capacities equal to a1, a2, ..., an megabytes...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Professor Phunsuk Wangdu has performed some experiments on rays. The setup for n rays is as follows. There is a rectangular box havin...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Vasiliy has a car and he wants to get from home to the post office. The distance which he needs to pass equals to d kilometers. Vasil...
user: Generate an executable Python 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 kingdom of Olympia consists of N cities and M bidirectional roads. Each road connects exactly two cities and two cities can be 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.A very brave explorer Petya once decided to explore Paris catacombs. Since Petya is not really experienced, his exploration is just 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.In Python, code blocks don't have explicit begin/end or curly braces to mark beginning and end of the block. Instead, code blocks are ...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.The Rebel fleet is afraid that the Empire might want to strike back again. Princess Heidi needs to know if it is possible to assign 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.You work in a big office. It is a 9 floor building with an elevator that can accommodate up to 4 people. It is your responsibility 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.Aaryan went to school like any usual day, The teacher asked his crush the following question. Given an array of numbers, First she ha...
user: Generate an executable Python 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: Line segment intersection is one of the important part of mathematics. Bob will be given a set of n number of 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.Printf{}, Pappu Bhujia, mon_ki_onkh are playing Counter Strike 1.6 . Printf{} and Pappu Bhujia are in the same team (Counter Terrorist...
user: Generate an executable Python 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 Pragyan, every shop has their own discount methods to attract the customers. One discount method called Buy 1 Get 1 caught your fri...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Champa loved traveling the world. He loved going from one city to the other. Being the miser that he is, he never wishes spend any mon...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Milly is very much concern about her rank in her class. So to make her feel better , her friend Pranjul will give three numbers to her...