question_answer_string
stringlengths
111
33.1k
Question: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Everybody knows of [spaghetti sort](https://en.wikipedia.org/wiki/Spaghetti_sort). You decided to implement an analog sorting algo...
Question: Generate an executable Python 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 likes everything infinite. Now he is studying the properties of a sequence s, such that its first element is equal to a (s1 ...
Question: Generate an executable Python 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 the two versions is that this version asks the minimal possible answer. Homer likes arrays a lot. Tod...
Question: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.The blinds are known to consist of opaque horizontal stripes that can be rotated thus regulating the amount of light flowing in th...
Question: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Mister B once received a gift: it was a book about aliens, which he started read immediately. This book had c pages. At first day...
Question: Generate an executable Python 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 mysterious pathogen of ACM Nation multiplies mysteriously each day. Maria was able to decipher the pattern but unable to comp...
Question: Generate an executable Python 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 girlfriend are going to have a promenade. They are walking along the straight road which consists of segments placed ...
Question: Generate an executable Python 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 and B are preparing themselves for programming contests. B loves to debug his code. But before he runs the solution and starts ...
Question: Generate an executable Python 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 seeing the "ALL YOUR BASE ARE BELONG TO US" meme for the first time, numbers X and Y realised that they have different bases...
Question: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Therasa is a Nurse. She wants to give some tablets to the patients in her practice. All the patients sit in a line and each of th...
Question: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.We call two numbers x and y similar if they have the same parity (the same remainder when divided by 2), or if |x-y|=1. For exampl...
Question: Generate an executable Python 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 Given the integer n, output the smallest m such that nCm (the number of combinations that choose m out of n different one...
Question: Generate an executable Python 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 might have remembered Theatre square from the [problem 1A](https://codeforces.com/problemset/problem/1/A). Now it's finally ge...
Question: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Quite recently, a very smart student named Jury decided that lectures are boring, so he downloaded a game called "Black Square" on...
Question: Generate an executable Python 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 probably registered on Internet sites many times. And each time you should enter your invented password. Usually the regi...
Question: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Serval is fighting with a monster. The health of the monster is H. In one attack, Serval can decrease the monster's health by A....
Question: Generate an executable Python 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 an integer sequence A, whose length is N. Find the number of the non-empty contiguous subsequences of A whose sums are 0....
Question: Generate an executable Python 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 apples and P pieces of apple. We can cut an apple into three pieces of apple, and make one apple pie by simmering two p...
Question: Generate an executable Python 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 r red, g green and b blue balloons. To decorate a single table for the banquet you need exactly three balloons. Three bal...
Question: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Recall the definition of the Fibonacci numbers: f1 := 1 f2 := 2 fn := fn-1 + fn-2 (n ≥ 3) Given two numbers a and ...
Question: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Sam is dangerous boy. He like to fight with everyone who is more powerful than him. One day, Sam enters in the meeting of all gang...
Question: Generate an executable Python 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 success of IEEE code-quest depends on number of times the factor is present in a given string.Help core members to find them  ...
Question: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Ankit has a set of numbers and has recently studied set theory. He has created a power set of this set and is writing a program to...
Question: Generate an executable Python 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 is looking for Wobbly Numbers. An N-length wobbly number is of the form "ababababab..." and so on of length N, where a != b...
Question: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Yae joins a journey plan, in which parties will be held several times during the itinerary. She wants to participate in all of the...
Question: Generate an executable Python 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 doors of a palace, all of which are operated by a set of buttons. One day, Alice, who is just 8 years old, gets access...
Question: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Vitya has just started learning Berlanese language. It is known that Berlanese uses the Latin alphabet. Vowel letters are "a", "o"...
Question: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Snuke lives at position x on a number line. On this line, there are two stores A and B, respectively at position a and b, that off...
Question: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Continuing from previous version of codeXplod series i.e. CodeXplod 1.0,Chandu and daspal are still fighting over a matter of MOMO...
Question: Generate an executable Python 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 array A[1..N] of N non-negative integers, you need to find the median of the array. The median of an array is the middle ...
Question: Generate an executable Python 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 three houses on a number line: House 1, 2 and 3, with coordinates A, B and C, respectively. Print `Yes` if we pass the c...
Question: Generate an executable Python 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 mathematics, the absolute value (or modulus) |a| of a real number a is the numerical value of a without regard to its sign. So,...
Question: Generate an executable Python 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 football season has just ended in Berland. According to the rules of Berland football, each match is played between two teams....
Question: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Short Phrase A Short Phrase (aka. Tanku) is a fixed verse, inspired by Japanese poetry Tanka and Haiku. It is a sequence of words...
Question: Generate an executable Python 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 Vitaly loves different algorithms. Today he has invented a new algorithm just for you. Vitaly's algorithm works with string...
Question: Generate an executable Python 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. Some element of this array ai is a local minimum iff it is strictly less than both of its neighbours (th...
Question: Generate an executable Python 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 wants to water his only flower. Unfortunately, he has a very poor watering system that was designed for n flowers and so it...
Question: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Indian summer is such a beautiful time of the year! A girl named Alyona is walking in the forest and picking a bouquet from fallen...
Question: Generate an executable Python 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 decrypting the code Enigma crew came to know that there are N locations where bombs has been planted. X1, X2 …. Xn are the N...
Question: Generate an executable Python 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 point A with coordinate x = n on OX-axis. We'd like to find an integer point B (also on OX-axis), such that the absolute...
Question: Generate an executable Python 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 a_1, a_2, ..., a_n consisting of n integers. You can choose any non-negative integer D (i.e. D ≥ 0), and...
Question: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Sherlock Holmes has decided to start a new academy to some of the young lads. He has conducted several tests and finally selected ...
Question: Generate an executable Python 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 the easier version of the problem. In this version 1 ≤ n, m ≤ 100. You can hack this problem only if you solve and lock bo...
Question: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Ivan likes to learn different things about numbers, but he is especially interested in really big numbers. Ivan thinks that a posi...
Question: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Recently, a start up by two students of a state university of city F gained incredible popularity. Now it's time to start a new co...
Question: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Some country is populated by wizards. They want to organize a demonstration. There are n people living in the city, x of them are...
Question: Generate an executable Python 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 subsequence of length |x| of string s = s1s2... s|s| (where |s| is the length of string s) is a string x = sk1sk2... sk|x| (1 ≤ ...
Question: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Determine whether a text T includes a pattern P. Your program should answer for given queries consisting of P_i. Constraints * 1...
Question: Generate an executable Python 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 king's birthday dinner was attended by k guests. The dinner was quite a success: every person has eaten several dishes (though...
Question: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.In this problem, you are given list of N numbers from 1 to N. They may be written in any order. You are to create a special list o...
Question: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Small, but very brave, mouse Brain was not accepted to summer school of young villains. He was upset and decided to postpone his p...
Question: Generate an executable Python 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. Tomya like a positive integer p, and now she wants to get a receipt of Ciel's re...
Question: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Recently our Paroothi got a crush on a girl , as we all know he is not good with the girls so he asked Vikrant ( The stud ) for ex...
Question: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Our good friend Mole is trying to code a big message. He is typing on an unusual keyboard with characters arranged in following wa...
Question: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Mike has a frog and a flower. His frog is named Xaniar and his flower is named Abol. Initially(at time 0), height of Xaniar is h1 ...
Question: Generate an executable Python 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 transparent three-dimensional table, the height equals to H and the base is a two-dimensional table N∙M. The layer...
Question: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Seryozha has a very changeable character. This time he refused to leave the room to Dima and his girlfriend (her hame is Inna, by ...
Question: Generate an executable Python 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 all know, Chef is cooking string for long days, his new discovery on string is the longest common pattern length. The longes...
Question: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Step up and down Kazuki, commonly known as Kerr, who attends JAG University, was invited by your friend this summer to participat...
Question: Generate an executable Python 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 playing Neo in the legendary "Matrix" trilogy, Keanu Reeves started doubting himself: maybe we really live in virtual realit...
Question: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Akhil has many balls of white and black colors. One day, he was playing with them. During the play, he arranged the balls into two...
Question: Generate an executable Python 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 non-decreasing array of non-negative integers a_1, a_2, …, a_n. Also you are given a positive integer k. You want...
Question: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Comrade Dujikov is busy choosing artists for Timofey's birthday and is recieving calls from Taymyr from Ilia-alpinist. Ilia-alpin...
Question: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Bosky needs your help in completing his maths homework today. He has to solve some questions as homework from a book named Jungly ...
Question: Generate an executable Python 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 H rows and W columns of white square cells. You will choose h of the rows and w of the columns, and paint all of the ce...
Question: Generate an executable Python 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 weather in Takahashi's town changes day by day, in the following cycle: Sunny, Cloudy, Rainy, Sunny, Cloudy, Rainy, ... Given...
Question: Generate an executable Python 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 rush of modern life, people often forget how beautiful the world is. The time to enjoy those around them is so little that ...
Question: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Shortest Common Non-Subsequence A subsequence of a sequence $P$ is a sequence that can be derived from the original sequence $P$ ...
Question: Generate an executable Python 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 permutation of the numbers 1, 2, ..., n and m pairs of positions (aj, bj). At each step you can choose a pair fro...
Question: Generate an executable Python 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 \text{gcdSum} of a positive integer is the gcd of that integer with its sum of digits. Formally, \text{gcdSum}(x) = gcd(x, su...
Question: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of Mysterious Light. Three mirrors of le...
Question: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Soon after the Chunga-Changa island was discovered, it started to acquire some forms of civilization and even market economy. A ne...
Question: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.You have been given an array A of size N consisting of positive integers. You need to find and print the product of all the number...
Question: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.It's now the season of TAKOYAKI FESTIVAL! This year, N takoyaki (a ball-shaped food with a piece of octopus inside) will be serve...
Question: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Everyone knows the famous detective Sherlock. He has been handed over a new case of "The Abominable Bride". Each night she kills N...
Question: Generate an executable Python 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 wants to buy some food in the nearby shop. Initially, he has s burles on his card. Mishka can perform the following opera...
Question: Generate an executable Python 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 print coordinates $(x_i, y_i)$ of given $n$ points on the plane by the following criteria. 1. first by $x$-...
Question: Generate an executable Python 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 decided to have a look at the results of Berland 1910 Football Championship’s finals. Unfortunately he didn't find t...
Question: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Niwango-kun is an employee of Dwango Co., Ltd. One day, he is asked to generate a thumbnail from a video a user submitted. To gene...
Question: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Niwango created a playlist of N songs. The title and the duration of the i-th song are s_i and t_i seconds, respectively. It is gu...
Question: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Rajiv is given a problem in class. " Suppose N burnt candles together make a new candle. then how many new candles are created if...
Question: Generate an executable Python 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 any integer x, Aoki can do the operation below. Operation: Replace x with the absolute difference of x and K. You are give...
Question: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Kolya Gerasimov loves kefir very much. He lives in year 1984 and knows all the details of buying this delicious drink. One day, as...
Question: Generate an executable Python 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 cord whose length is a positive integer. We will perform the following condition until the length of the cord becomes at...
Question: Generate an executable Python 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 Latin letters. While there is at least one character in the string s that is rep...
Question: Generate an executable Python 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: IP Address (Internet Protocol Address) problem Since one number string is given, find the number of valid delimiters for IPv4...
Question: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.These days, Sid and Jake are learning about number theory. They have just visited the zoo and during the visit they have counted(y...
Question: Generate an executable Python 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 is a dumb guy, his learning curve is very slow. You are supposed to teach him n subjects, the ith subject has ci chapters. Wh...
Question: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Ehab has an array a of length n. He has just enough free time to make a new array consisting of n copies of the old array, written...
Question: Generate an executable Python 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 might have heard about our new goodie distribution program aka the "Laddu Accrual System". This problem is designed to give yo...
Question: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Fox Ciel has some flowers: r red flowers, g green flowers and b blue flowers. She wants to use these flowers to make several bouqu...
Question: Generate an executable Python 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 chess board with n rows and n columns. Initially all cells of the board are empty, and you have to put a white or ...
Question: Generate an executable Python 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 Description  You are an army personnel in the great army of the Zorin race, where you are a part of a team of n people. U...
Question: Generate an executable Python 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 an array t dominated by value v in the next situation. At first, array t should have at least 2 elements. Now, let's c...
Question: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Absent-minded Masha got set of n cubes for her birthday. At each of 6 faces of each cube, there is exactly one digit from 0 to 9....
Question: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.You are given a string s consisting of n lowercase Latin letters. n is even. For each position i (1 ≤ i ≤ n) in string s you are ...
Question: Generate an executable Python 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 has got a problem — somebody has been touching his sorted by non-decreasing array a of length n and possibly s...
Question: Generate an executable Python 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 cities and m bidirectional roads in Berland. The i-th road connects the cities x_i and y_i, and has the speed limit s_...
Question: Generate an executable Python 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 only consider strings consisting of lowercase English letters. Strings s and t are said to be isomorphic when...
Question: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.You are given an array of n integers: a_1, a_2, …, a_n. Your task is to find some non-zero integer d (-10^3 ≤ d ≤ 10^3) such that,...