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 some beautiful girls in Arpa’s land as mentioned before. Once Arpa came up with an obvious problem: Given an array and a 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.Artsem is on vacation and wants to buy souvenirs for his two teammates. There are n souvenir shops along the street. In i-th shop Arts...
user: Generate an executable Python 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 Cartesian coordinate system is set in the sky. There you can see n stars, the i-th has coordinates (xi, yi), a maximum brightness ...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Nagini, being a horcrux You-know-who created with the murder of Bertha Jorkins, has accumulated its army of snakes and is launching an...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.A positive integer is called a 2-3-integer, if it is equal to 2x·3y for some non-negative integers x and y. In other words, these inte...
user: Generate an executable Python 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 string is a palindrome if it reads the same from the left to the right and from the right to the left. For example, the strings "kek...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Bholu the Pandit on this New Year wanted to divide his Cuboidal Packaging block into cubes. But he loves uniformity so he asks you 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.Poornimites are taught to add multi-digit numbers from right-to-left one digit at a time. Many find the "carry" operation - in which 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.Subodh is having N branches, where each branches have positive integral student. A minimize operation is performed on the branch such ...
user: Generate an executable Python 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 time is 1st January 20000014 Gazu is depressed with his life as he thinks there is nothing unique about him. One day he meets a tr...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.My flatmate, Sayan, went to the game show called Takeshi's castle.It is a game show in which you need to pass different game challenge...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.X and Y are sitting beside a footpath on a bench on Marine Drive having a look at the beautiful sea. (Anyone from Mumbai here ?). X 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.Let us denote by f(x, m) the remainder of the Euclidean division of x by m. Let A be the sequence that is defined by the initial valu...
user: Generate an executable Python 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 wants to be a member of some web service. He tried to register himself with the ID S, which turned out to be already used b...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.There are 2000001 stones placed on a number line. The coordinates of these stones are -1000000, -999999, -999998, \ldots, 999999, 1000...
user: Generate an executable Python 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 of length 2 or 3 consisting of lowercase English letters. If the length of the string is 2, print it as is; 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 are given a string S of length N consisting of `(` and `)`. Your task is to insert some number of `(` and `)` into S to obtain a c...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Your task is to develop a tiny little part of spreadsheet software. Write a program which adds up columns and rows of given table 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.problem There are many $ N $ colored balls of different weights in the queue. The queue is in ascending order from the beginning: $ 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.F: Substring decomposition problem Given the two strings S and T and the integer k. Considering consecutive substrings of length k o...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.You have 4 bags A, B, C and D each of which includes N coins (there are totally 4N coins). Values of the coins in each bag are ai, bi,...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Tomya is a girl. She loves Chef Ciel very much. Today, too, Tomya is going to Ciel's restaurant. Of course, Tomya would like to go 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.Simple Factorial You are asked to calculate factorials of some small positive integers. Input   Input Tips: An integer T, denoting 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.This is a very easy warm-up problem. You are given a string. Your task is to determine whether number of occurrences of some 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.Chef and his little brother are playing with sticks. They have total N sticks. Length of i-th stick is Ai. Chef asks his brother to c...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.One day, Yuhao came across a problem about checking if some bracket sequences are correct bracket sequences. A bracket sequence is 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.You are given 4n sticks, the length of the i-th stick is a_i. You have to create n rectangles, each rectangle will consist of exactly...
user: Generate an executable Python 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 lucky numbers are positive integers whose decimal representation contains only the luc...
user: Generate an executable Python 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 the set of all nonnegative integers: {0, 1, 2, ...}. Given two integers a and b (1 ≤ a, b ≤ 10^4). We paint all the numbers 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.To become the king of Codeforces, Kuroni has to solve the following problem. He is given n numbers a_1, a_2, ..., a_n. Help Kuroni 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.Omkar is building a waterslide in his water park, and he needs your help to ensure that he does it as efficiently as possible. Omkar ...
user: Generate an executable Python 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 city of D consists of n towers, built consecutively on a straight line. The height of the tower that goes i-th (from left to right...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.One day Vasya was on a physics practical, performing the task on measuring the capacitance. He followed the teacher's advice and did 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.The new "Die Hard" movie has just been released! There are n people at the cinema box office standing in a huge line. Each of them has...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Good old Berland has n cities and m roads. Each road connects a pair of distinct cities and is bidirectional. Between any pair of citi...
user: Generate an executable Python 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 positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.A tourist hiked along the mountain range. The hike lasted for n days, during each day the tourist noted height above the sea level. 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.Even the most successful company can go through a crisis period when you have to make a hard decision — to restructure, discard and me...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.<image> One morning the Cereal Guy found out that all his cereal flakes were gone. He found a note instead of them. It turned out tha...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.One company of IT City decided to create a group of innovative developments consisting from 5 to 7 people and hire new employees for 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.A year ago on the bench in public park Leha found an array of n numbers. Leha believes that permutation p is right if for all 1 ≤ 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.Mahmoud and Ehab play a game called the even-odd game. Ehab chooses his favorite integer n and then they take turns, starting from Mah...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.See Russian Translation W.T.H.S.E.C Confused? Well it stands for Welcome To HackerEarth September Easy Challenge :). It's quite amaz...
user: Generate an executable Python 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 about to play a simplified "battleship" game with your little brother. The board for this game is a rectangular grid with R row...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Raju is very fond of strings.Once he was playing a game with his friend.His friend gave him a string to decipher.As Raju is not very ...
user: Generate an executable Python 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 empty graph of N vertices and M queries of two types: Given a number X answer what is the shortest distance 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.Arnab is given a string, but being the evil Lord he is, he has his own whims and fantasies about the string he wants to keep with hims...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Raghav is good in mathematics. He loves to ask puzzles with his friends. One day, he decides to challenge his friend Aditya who is not...
user: Generate an executable Python 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 grid with H horizontal rows and W vertical columns. Let (i,j) denote the square at the i-th row from the top and the j-th 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.Along a road running in an east-west direction, there are A shrines and B temples. The i-th shrine from the west is located at a dista...
user: Generate an executable Python 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 3×3 square grid, where each square contains a lowercase English letters. The letter in the square at the i-th row from the t...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.You are given an undirected connected graph with N vertices and M edges that does not contain self-loops and double edges. The i-th ed...
user: Generate an executable Python 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 ask you to select some number of positive integers, and calculate the sum of them. It is allowed to select as many integers as 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.You have N cups and 1 ball. The cups are arranged in a row, from left to right. You turned down all the cups, then inserted the ball...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Brain training puzzle games are popular from children to adults. We decided to make a puzzle game and play with everyone so that we 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.Give you N cards. Only one natural number is written on each card. However, the same number is never written. From now on, as a quest...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.problem You have to play a darts game with the following rules. You can throw up to four arrows towards the target. You don't have 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 north country is conquered by the great shogun-sama (which means king). Recently many beautiful dice which were made by order 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.Vectors have their directions and two vectors make an angle between them. Given a set of three-dimensional vectors, your task is to fi...
user: Generate an executable Python 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 Taro decided to watch one movie every day at a nearby movie theater during the summer vacation. (Taro has 31 days of summer v...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Yui Hirasawa, who attends private Sakuragaoka Girls' High School, has to make a career hope by the day after tomorrow, but the trouble...
user: Generate an executable Python 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 "Rooks Game" is a single-player game and uses a chessboard which has $N \times N$ grid and $M$ rook pieces. A rook...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.<image> A directed acyclic graph (DAG) can be used to represent the ordering of tasks. Tasks are represented by vertices and constra...
user: Generate an executable Python 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 country which recently got invaded by a fleet of aliens. They started living with the people there. Relations between the 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.Tic-Tac-Toe used to be Chef's favourite game during his childhood. Reminiscing in his childhood memories, he decided to create his own...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Problem You are living in 2050, People do not work any more. Only surrogates (clone having same features & DNA characteristics) work ...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.According to folklore, the great mathematician Gauss was able to calculate the sum of the first 50 natural numbers in mere seconds. 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.You are given a sequence a1, a2, ..., aN. Find the smallest possible value of ai + aj, where 1 ≤ i < j ≤ N. Input The first line 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.Little girl Tanya climbs the stairs inside a multi-storey building. Every time Tanya climbs a stairway, she starts counting steps from...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Mishka got a six-faced dice. It has integer numbers from 2 to 7 written on its faces (all numbers on faces are different, so this is 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.Sasha is a very happy guy, that's why he is always on the move. There are n cities in the country where Sasha lives. They are all loca...
user: Generate an executable Python 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 0-1 rectangular matrix. What is the number of squares in it? A square is a solid square frame (border) with linewidth ...
user: Generate an executable Python 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 and his friends want to visit a new restaurant. The restaurant has n tables arranged along a straight line. People are alread...
user: Generate an executable Python 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. In one move, you can choose some integer k from 1 to 10 and add it to a or subtract it from a. 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's town has a train system that has 100 trains that travel from the bottom end to the top end and 100 trains that travel from 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 an integer n, find the maximum value of integer k such that the following condition holds: n & (n-1) & (n-2) & (n-3) & ... (k)...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Any resemblance to any real championship and sport is accidental. The Berland National team takes part in the local Football champion...
user: Generate an executable Python 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 magic number is a number formed by concatenation of numbers 1, 14 and 144. We can use each of these numbers any number of times. 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.Developers often face with regular expression patterns. A pattern is usually defined as a string consisting of characters and metachar...
user: Generate an executable Python 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 is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He wo...
user: Generate an executable Python 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 industrial factory is reforming working plan. The director suggested to set a mythical detail production norm. If at the beginning...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.An n × n table a is defined as follows: * The first row and the first column contain ones, that is: ai, 1 = a1, i = 1 for all i = 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.Polycarp and Vasiliy love simple logical games. Today they play a game with infinite chessboard and one pawn for each player. Polycarp...
user: Generate an executable Python 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 9-th grade student Gabriel noticed a caterpillar on a tree when walking around in a forest after the classes. The caterpillar was ...
user: Generate an executable Python 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 is in the palace that can be represented as a grid n × m. Each room contains a single chest, an the room located in the i-th row...
user: Generate an executable Python 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 broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format hours cha...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Vladik had started reading a complicated book about algorithms containing n pages. To improve understanding of what is written, his fr...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Let's call the roundness of the number the number of zeros to which it ends. You have an array of n numbers. You need to choose a sub...
user: Generate an executable Python 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 some ambiguities when one writes Berland names with the letters of the Latin alphabet. For example, the Berland sound u can...
user: Generate an executable Python 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 decided to buy roses for his girlfriend. A flower shop has white, orange and red roses, and the total amount of them is n. Ark...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Billi was on date with his girlfriend Ketty. They had the following conversation Ketty :- "Billi, How much do u love me?" Billi :- "...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Navi is a counter strike pro. He always say how good he is at counter strike. After being tired of Navi, his friends decided to test 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.Today is Tom's Birthday. His Mom gifted him two sets of integers to play with, set Q and set R. R is the transformation of set Q. Both...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Ranjan came to know about competitive programming today and created an account on Hackerearth. With his full determination he starte...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.King Tle4Ever of Time Limit Exceeded is really fascinated about Tic Tac Toe. He organizes a national level contest for Tic Tac Toe eve...
user: Generate an executable Python 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 strings S and T consisting of lowercase English letters. Concatenate T and S in this order, without space in between, 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.There are N squares arranged in a row from left to right. The height of the i-th square from the left is H_i. For each square, you 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.Snuke has an empty sequence a. He will perform N operations on this sequence. In the i-th operation, he chooses an integer j satisfy...
user: Generate an executable Python 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 of length 3 consisting of `a`, `b` and `c`. Determine if S can be obtained by permuting `abc`. Constraints ...
user: Generate an executable Python 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 is now competing in a programming contest, but he received TLE in a problem where the answer is `YES` or `NO`. When he chec...