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.Takahashi will do a tap dance. The dance is described by a string S where each character is `L`, `R`, `U`, or `D`. These character...
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 converts uppercase/lowercase letters to lowercase/uppercase for a given string. Constraints * The length 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.Polycarp has an array a consisting of n integers. He wants to play a game with this array. The game consists of several moves. 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.Given a string S, count the number of non empty sub strings that are palindromes. A sub string is any continuous sequence of chara...
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 likes arrays a lot. Today, he found an array A consisting of N positive integers. Let L denote the sorted (in non-increasing ...
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.Capitalization is writing a word with its first letter as a capital letter. Your task is to capitalize the given word. Note, 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.There are n points on a coordinate axis OX. The i-th point is located at the integer point x_i and has a speed v_i. It is guarante...
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 Chiku is very choosy about numbers. He considers 0 and 1 together as bad omen. So he hates 0 and 1 appearing adjacent to ea...
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 end of the school year is near and Ms. Manana, the teacher, will soon have to say goodbye to a yet another class. She decided ...
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.C: Prayer (Pray) Some twins are famous for praying before the contest. There are four integers $ H, W, X, Y $, and it seems unlu...
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 N cards. A number a_i is written on the i-th card. Alice and Bob will play a game using these cards. In this game, Alice 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.There are N monsters, numbered 1, 2, ..., N. Initially, the health of Monster i is A_i. Below, a monster with at least 1 health ...
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 CODE FESTIVAL XXXX, there are N+1 participants from all over the world, including Takahashi. Takahashi checked and found 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.Dreamoon wants to climb up a stair of n steps. He can climb 1 or 2 steps at each move. Dreamoon wants the number of moves to be 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.Statement: Write a code to display all the non-prime numbers upto N. Input: Only the value of N. Output: The numbers which are 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.You are given three integers, A, B and C. Among them, two are the same, but the remaining one is different from the rest. For exam...
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 three integers A, B and C. Determine whether C is not less than A and not greater than B. Constraints * -100≤A,B,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.Genos needs your help. He was asked to solve the following programming problem by Saitama: The length of some string s is denoted...
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.Polycarp plays a well-known computer game (we won't mention its name). In this game, he can craft tools of two types — shovels 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.You are given an integer N. Consider all possible segments on the coordinate axis with endpoints at integer points with coordinate...
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.Find a cycle in a directed graph G(V, E). Constraints * 1 ≤ |V| ≤ 100 * 0 ≤ |E| ≤ 1,000 * si ≠ ti Input A directed graph G is ...
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.Awruk is taking part in elections in his school. It is the final round. He has only one opponent — Elodreip. The are n students in...
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 Petya has recently started attending a programming club. Naturally he is facing the problem of choosing a programming langu...
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 will turn on the air conditioner if, and only if, the temperature of the room is 30 degrees Celsius or above. The current tem...
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.Bozo is shifting his house. He has some balls and boxes which he has to shift. He now wonders how large a ball he can fit in a giv...
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.Does \sqrt{a} + \sqrt{b} < \sqrt{c} hold? Constraints * 1 \leq a, b, c \leq 10^9 * All values in input are integers. Input Inp...
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 can perfectly predict the price of a certain stock for the next N days. You would like to profit on this knowledge, but only w...
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.Tak has N cards. On the i-th (1 \leq i \leq N) card is written an integer x_i. He is selecting one or more cards from these N card...
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 roads. The i-th road (1≤i≤M) connects two cities a_i and b_i (1≤a_i,b_i≤N) bidirectionally. There may be ...
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 us consider sets of positive integers less than or equal to n. Note that all elements of a set are different. Also note that 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.There is data of up to 100 characters per line, consisting of half-width alphabetic character strings. Some lines are symmetric (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.While Tom Cruise(Cage) fighting in the movie "Edge of Tomorrow", he finds himself in a modern lab, where he needs to kill the brai...
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, Anton has found a set. The set consists of small English letters. Anton carefully wrote out all the letters from the set...
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 Cybermen and the Daleks have long been the Doctor's main enemies. Everyone knows that both these species enjoy destroying ever...
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 Third Doctor Who once correctly said that travel between parallel universes is "like travelling sideways". However, he incorre...
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 of lower case letters. Your task is to figure out the index of the character on whose removal it will make ...
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 a string S consisting of N uppercase English letters. You are allowed to perform at most one operation of following kind:...
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.John Doe has found the beautiful permutation formula. Let's take permutation p = p1, p2, ..., pn. Let's define transformation f 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.Bear Limak likes watching sports on TV. He is going to watch a game today. The game lasts 90 minutes and there are no breaks. Eac...
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 is studying number theory. He has denoted a function f(a, b) such that: * f(a, 0) = 0; * f(a, b) = 1 + f(a, b - gcd(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.Mr. Sreeniketan the owner of Madras Super Kings is a very superstitious owner. He believes that certain gestures help the team 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.Ilya is an experienced player in tic-tac-toe on the 4 × 4 field. He always starts and plays with Xs. He played a lot of games toda...
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 uppercase English letters. Find the length of the longest ACGT string that is a substring (...
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 Artem found a grasshopper. He brought it to his house and constructed a jumping area for him. The area looks like a strip ...
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 Petya likes points a lot. Recently his mom has presented him n points lying on the line OX. Now Petya is wondering in how m...
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 reads an integer $S$ [second] and converts it to $h:m:s$ where $h$, $m$, $s$ denote hours, minutes (less tha...
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.Modern cryptosystems rely heavily on our inability to factor large integers quickly as the basis for their security. They need a q...
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 an English learner, sometimes you cannot remember the entire spelling of English words perfectly, but you can only remember 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.Calvin is driving his favorite vehicle on the 101 freeway. He notices that the check engine light of his vehicle is on, and he wan...
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.NITMAS Fest is live. The members of the community are very busy. People from different colleges have come to compete. But, Naveen ...
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 his wife's tragic death, Eurydice, Orpheus descended to the realm of death to see her. Reaching its gates was uneasy, but pa...
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.Platypus Perry is on a mission again. This time, Dr. Heinz Doofenshmirtz has plotted a bomb in the centre of Danville town. He wi...
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 princess is going to escape the dragon's cave, and she needs to plan it carefully. The princess runs at vp miles per hour, an...
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 new operating system BerOS has a nice feature. It is possible to use any number of characters '/' as a delimiter in path inste...
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.Find the difference of two sets $A = \\{a_0, a_1, ..., a_{n-1}\\}$ and $B = \\{b_0, b_1, ..., b_{m-1}\\}$, $A - B$. Constraints ...
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 of n integers and an integer s. It is guaranteed that n is odd. In one operation you can either increase...
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 is a legend in the IT City college. A student that failed to answer all questions on the game theory exam is given one more ...
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 that the m-coder Tournament will happen soon. m schools participate in the tournament, and only one student from e...
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 days ago, I learned the concept of LCM (least common multiple). I've played with it for several times and I want to make a bi...
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 programming competition site AtCode regularly holds programming contests. The next contest on AtCode is called ABC, which is ra...
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 string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (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 benches in the Berland Central park. It is known that a_i people are currently sitting on the i-th bench. Another m pe...
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're giving away nice huge bags containing number tiles! A bag we want to present to you contains n tiles. Each of them has a sin...
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 McD's Burger, n hungry burger fans are ordering burgers. The ith order is placed by the ith fan at ti time and it takes di time...
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 is a game called "I Wanna Be the Guy", consisting of n levels. Little X and his friend Little Y are addicted to the game. Ea...
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.On Children's Day, the child got a toy from Delayyy as a present. However, the child is so naughty that he can't wait to destroy 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.Polycarp plays "Game 23". Initially he has a number n and his goal is to transform it to m. In one move, he can multiply n by 2 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.Alice and Bob are fighting over who is a superior debater. However they wish to decide this in a dignified manner. So they decide...
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.Iroha has a sequence of N strings S_1, S_2, ..., S_N. The length of each string is L. She will concatenate all of the strings in ...
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.Bob came to a cash & carry store, put n items into his trolley, and went to the checkout counter to pay. Each item is described 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.A sweet little monster Om Nom loves candies very much. One day he found himself in a rather tricky situation that required him 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.There is a farm whose length and width are A yard and B yard, respectively. A farmer, John, made a vertical road and a horizontal ...
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 reads an integer n and prints the number of prime numbers which are less than or equal to n. A prime 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.Vasilisa the Wise from the Kingdom of Far Far Away got a magic box with a secret as a present from her friend Hellawisa the Wise f...
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.Zookeeper is playing a game. In this game, Zookeeper must use bombs to bomb a string that consists of letters 'A' and 'B'. He can ...
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.Taro's Shopping Mammy decided to give Taro his first shopping experience. Mammy tells him to choose any two items he wants from 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.On the way to Rio de Janeiro Ostap kills time playing with a grasshopper he took with him in a special box. Ostap builds a line of...
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 play a stone removing game. Initially, n stones are arranged on a circle and numbered 1, ... , n clockwise (Figure 1). You ...
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 integer number n. The following algorithm is applied to it: 1. if n = 0, then end algorithm; 2. find the sm...
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 little bear Limak plays a game. He has five cards. There is one number written on each card. Each number is a positive integer. ...
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.Seeing the current political scenario in the city of Delhi,and the clean sweep of the Aam Aadmi Party, you are wondering that its ...
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 convex polygon consisting of N vertices is given. The coordinates of each vertex are represented counterclockwise by (X1, Y1), (...
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.Baby Ehab is known for his love for a certain operation. He has an array a of length n, and he decided to keep doing the following...
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 boxes arranged in a row from left to right. The i-th box from the left contains A_i candies. You will take out the ca...
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 there be a function f(N) such that f(N) denotes number of zeroes at the end of N! (factorial of N). For example, f(5) = 1 bec...
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.Pratyush, a six year old kid has just learnt how to write 1 through 1000 in decimal number system(DNS). Being a very curious kid, ...
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.Cucumber boy is fan of Kyubeat, a famous music game. Kyubeat has 16 panels for playing arranged in 4 × 4 table. When a panel ligh...
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 sandglass that runs for X seconds. The sand drops from the upper bulb at a rate of 1 gram per second. That is, the upper...
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.Panda has started learning about subsets. His professor gave him a simple task. Given a list of numbers, Panda has to choose the 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.The state space of the output of this problem (and as a matter of fact, all the problems in this Cook-Off) is - 2 to the power 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.Fox Ciel has n boxes in her room. They have the same size and weight, but they might have different strength. The i-th box can hol...
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 is trying rock climbing but he is awful at it. There are n holds on the wall, i-th hold is at height ai off the ground. Bes...
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.Takahashi has N blue cards and M red cards. A string is written on each card. The string written on the i-th blue card is s_i, 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.You are given a positive integer x. Find any such 2 positive integers a and b such that GCD(a,b)+LCM(a,b)=x. As a reminder, GCD(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.Kevin Sun wants to move his precious collection of n cowbells from Naperthrill to Exeter, where there is actually grass instead of...
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 consisting of n integers a_1, a_2, ..., a_n. Initially a_x = 1, all other elements are equal to 0. You hav...
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.Takahashi has N days of summer vacation. His teacher gave him M summer assignments. It will take A_i days for him to do the i-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.You are given three integers x, y and n. Your task is to find the maximum integer k such that 0 ≤ k ≤ n that k mod x = y, where mo...
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.Lets think of an infinite series of numbers such that the difference between any two consecutive numbers is d. Let the first numbe...
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.Mrityunjay is a high-school teacher, currently coaching students for JEE (Joint Entrance Exam). Mrityunjay every year gives prizes...