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.Euler's phi function for a positive integer N is usually denoted as φ(N) and defined as the number of positive integers less than or e...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.We have the following matrix 1 0 0 0 0 0 ... 2 2 0 0 0 0 ... 3 3 3 0 0 0 ... 4 4 4 4 0 0 ... 5 5 5 5 5 0 ... 6 6 6 6 6 6 ... and so...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Little Louis has recently learnt a new word in his English class which reads same from either end. He is curious to find more similar ...
user: Generate an executable Python 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 inversion in an array is a pair of indices (i, j) such that A[i] > A[j] and i < j, but you are given two arrays A and B and pairs ...
user: Generate an executable Python 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(A0, A1…. An-1) of n integers. Your task is to find the smallest number larger than a given no. X in the range [l,r] 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.Sherlock is following N criminals, which are right now in a 2D grid. Each criminal at t=0, decides to move in certain fixed direction....
user: Generate an executable Python 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 Monk wants to teach all its disciples a lesson about patience, since they are always in a hurry to do something crazy. To teach th...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Snuke is standing on a two-dimensional plane. In one operation, he can move by 1 in the positive x-direction, or move by 1 in the posi...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.There is an integer sequence A of length N whose values are unknown. Given is an integer sequence B of length N-1 which is known to s...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Joisino is planning to record N TV programs with recorders. The TV can receive C channels numbered 1 through C. The i-th program 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.There are N bags of biscuits. The i-th bag contains A_i biscuits. Takaki will select some of these bags and eat all of the biscuits 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.Snuke has decided to play with N cards and a deque (that is, a double-ended queue). Each card shows an integer from 1 through N, and 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.Obesity is cited as the cause of many adult diseases. In the past, with a few exceptions, it was unrelated to high school students. Ho...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Relative B came to Mr. A's house. He is 3 years old and loves blocks. The block he has is shaped like Figure 1. <image> Figure 1 Mr...
user: Generate an executable Python 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 boy PCK is playing with N electric metronomes. The i-th metronome is set to tick every t_i seconds. He started all of them simultane...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Here, we want to solve path planning for a mobile robot cleaning a rectangular room floor with furniture. Consider the room floor pav...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.In this problem, we consider a simple programming language that has only declarations of one- dimensional integer arrays and assignmen...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.B: Twins One twin was angry that it was not well known which of them was the older brother and which was the younger brother. Create...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.For a given polygon g and target points t, print "2" if g contains t, "1" if t is on a segment of g, "0" otherwise. g is represented ...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.For a sequence of integers $A = \\{a_0, a_1, ..., a_{n-1}\\}$ which is sorted by ascending order, eliminate all equivalent elements. ...
user: Generate an executable Python 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 Chef is learning differentiation and is amazed by the function e^x as it stays the same even after differentiation. Just for fu...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Pooja would like to withdraw X $US from an ATM. The cash machine will only accept the transaction if X is a multiple of 5, and Pooja's...
user: Generate an executable Python 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 G(S) denote the sum of the elements of set S and F(n) be the sum of G(s) for all subsets of the set consisting of the first n natu...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Lunar New Year is approaching, and you bought a matrix with lots of "crosses". This matrix M of size n × n contains only 'X' and '.' ...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.International Women's Day is coming soon! Polycarp is preparing for the holiday. There are n candy boxes in the shop for sale. The 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 an array a_1, a_2, ..., a_n and an integer k. You are asked to divide this array into k non-empty consecutive subarrays...
user: Generate an executable Python 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 boys and m girls attending a theatre club. To set a play "The Big Bang Theory", they need to choose a group containing exa...
user: Generate an executable Python 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 wants to buy exactly n shovels. The shop sells packages with shovels. The store has k types of packages: the package of the 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.Petya loves lucky numbers very much. Everybody knows that lucky numbers are positive integers whose decimal record contains only the l...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.AquaMoon has three integer arrays a, b, c of length n, where 1 ≤ a_i, b_i, c_i ≤ n for all i. In order to accelerate her potato farmi...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Nikephoros and Polycarpus play rock-paper-scissors. The loser gets pinched (not too severely!). Let us remind you the rules of this g...
user: Generate an executable Python 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 in the country where the Old Peykan lives. These cities are located on a straight line, we'll denote them from left...
user: Generate an executable Python 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 balls. They are arranged in a row. Each ball has a color (for convenience an integer) and an integer value. The color 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.Manao has a monitor. The screen of the monitor has horizontal to vertical length ratio a:b. Now he is going to watch a movie. The movi...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Once upon a time DravDe, an outstanding person famous for his professional achievements (as you must remember, he works in a warehouse...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Valera is a little boy. Yesterday he got a huge Math hometask at school, so Valera didn't have enough time to properly learn the Engli...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Many students live in a dormitory. A dormitory is a whole new world of funny amusements and possibilities but it does have its drawbac...
user: Generate an executable Python 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 Elements of Harmony are six supernatural artifacts representing subjective aspects of harmony. They are arguably the most powerful...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.ATMs of a well-known bank of a small country are arranged so that they can not give any amount of money requested by the user. Due 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.In the country there are exactly n cities numbered with positive integers from 1 to n. In each city there is an airport is located. 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.While Patrick was gone shopping, Spongebob decided to play a little trick on his friend. The naughty Sponge browsed through Patrick's ...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Professor GukiZ makes a new robot. The robot are in the point with coordinates (x1, y1) and should go to the point (x2, y2). In a sing...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Sonya was unable to think of a story for this problem, so here comes the formal description. You are given the array containing n pos...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Facetook is a well known social network website, and it will launch a new feature called Facetook Priority Wall. This feature will sor...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Andryusha is an orderly boy and likes to keep things in their place. Today he faced a problem to put his socks in the wardrobe. He ha...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Luba has to do n chores today. i-th chore takes ai units of time to complete. It is guaranteed that for every <image> the condition ai...
user: Generate an executable Python 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 newspaper is published in Walrusland. Its heading is s1, it consists of lowercase Latin letters. Fangy the little walrus wants to bu...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Ghosts live in harmony and peace, they travel the space without any purpose other than scare whoever stands in their way. There are n...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.You are given 'k' eggs and a 'n' storey building. The eggs MIGHT break if thrown down from a specific height (Note: It is NOT necessar...
user: Generate an executable Python 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 fashion show rates participants according to their level of hotness. Two different fashion shows were organized, one for men and the...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Description: Name string is a string consisting of letters "R","K" and "V". Today Oz wants to design a name string in a beautiful mann...
user: Generate an executable Python 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 main building of the nation is developing complex patterns as each day progresses. The task is to find the number of three sided 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.Kancha wants to participate in a new event of Technobyte. Event says that you have to write a number in seven segment display using ma...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Let f(x) represent the number of set bits (i.e. bit = 1) in the binary representation of non-negative integer x. For e.g. f(3) = 2, si...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Given is a number sequence A of length N. Find the number of integers i \left(1 \leq i \leq N\right) with the following property: * ...
user: Generate an executable Python 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 an immigration officer in the Kingdom of AtCoder. The document carried by an immigrant has some number of integers written 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.You have a digit sequence S of length 4. You are wondering which of the following formats S is in: * YYMM format: the last two digits...
user: Generate an executable Python 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 two positive integers A and B. It is known that A plus B equals N. Find the minimum possible value of "the sum of the d...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.A robot is put at the origin in a two-dimensional plane. Initially, the robot is facing in the positive x-axis direction. This robot ...
user: Generate an executable Python 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 hosting an sports meet. There are N people who will participate. These people are conveniently numbered 1 through N. Also...
user: Generate an executable Python 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 circle. The i-th box contains A_i stones. Determine whether it is possible to remove all the stones f...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.> Kyoto University Programming Contest is a programming contest voluntarily held by some Kyoto University students. This contest is ab...
user: Generate an executable Python 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 that records the customer number of the business partner and the trading date on a monthly basis. Please create a progra...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.At dusk in AIZU, it is crowded with tourists who hold their smartphones in the west sky and stop. AIZU is a big city with countless bu...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Starting with x and repeatedly multiplying by x, we can compute x31 with thirty multiplications: x2 = x × x, x3 = x2 × x, x4 = x3 × x...
user: Generate an executable Python 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 priority queue is a data structure which maintains a set $S$ of elements, each of with an associated value (key), and supports the f...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Chef has recently learnt some new facts about the famous number π. For example, he was surprised that ordinary fractions are sometimes...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Mirrored Strings Davy Jones needs to conquer a ship for his pirates. But the only rule he has to follow is to conquer only those ships...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Lapindrome is defined as a string which when split in the middle, gives two halves having the same characters and same frequency of ea...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Yesterday, the CS Club hosted a massive party that put all the frat parties to shame. Today, they have to clean up everything. They ...
user: Generate an executable Python 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 n words w[1..n], which originate from the same stem (e.g. grace, graceful, disgraceful, gracefully), we are interested in the or...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.There are n rectangles in a row. You can either turn each rectangle by 90 degrees or leave it as it is. If you turn a rectangle, its w...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.There is an array a of 2^{30} integers, indexed from 0 to 2^{30}-1. Initially, you know that 0 ≤ a_i < 2^{30} (0 ≤ i < 2^{30}), but 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.All bus tickets in Berland have their numbers. A number consists of n digits (n is even). Only k decimal digits d_1, d_2, ..., d_k 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.Polycarp wants to cook a soup. To do it, he needs to buy exactly n liters of water. There are only two types of water bottles in 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.Let's call (yet again) a string good if its length is even, and every character in odd position of this string is different from the n...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.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.There are n segments on a Ox axis [l_1, r_1], [l_2, r_2], ..., [l_n, r_n]. Segment [l, r] covers all points from l to r inclusive, so ...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.There is a building consisting of 10~000 apartments numbered from 1 to 10~000, inclusive. Call an apartment boring, if its number con...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.A tree is a connected graph that doesn't contain any cycles. The distance between two vertices of a tree is the length (in edges) of ...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Students of group 199 have written their lectures dismally. Now an exam on Mathematical Analysis is approaching and something has to 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.Daniel is organizing a football tournament. He has come up with the following tournament format: 1. In the first several (possibly...
user: Generate an executable Python 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 system of n vessels arranged one above the other as shown in the figure below. Assume that the vessels are numbered from 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.Alice likes word "nineteen" very much. She has a string s and wants the string to contain as many such words as possible. For that rea...
user: Generate an executable Python 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 well-known art union called "Kalevich is Alive!" manufactures objects d'art (pictures). The union consists of n painters who decided...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Sergey is testing a next-generation processor. Instead of bytes the processor works with memory cells consisting of n bits. These bits...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Nura wants to buy k gadgets. She has only s burles for that. She can buy each gadget for dollars or for pounds. So each gadget is sell...
user: Generate an executable Python 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 numbers of all offices in the new building of the Tax Office of IT City will have lucky numbers. Lucky number is a number that 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.A simple recommendation system would recommend a user things liked by a certain number of their friends. In this problem you will impl...
user: Generate an executable Python 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 in Bearland, numbered 1 through n. Cities are arranged in one long row. The distance between cities i and j is equa...
user: Generate an executable Python 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 is a little polar bear. As known, little bears loves spending their free time playing dice for chocolates. Once in a wonderful ...
user: Generate an executable Python 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 big company decided to launch a new series of rectangular displays, and decided that the display must have exactly n pixels. Your ...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Bitwise exclusive OR (or bitwise addition modulo two) is a binary operation which is equivalent to applying logical exclusive OR to ev...
user: Generate an executable Python 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 robber has attempted to rob a bank but failed to complete his task. However, he had managed to open all the safes. Oleg the bank cl...
user: Generate an executable Python 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 unrest in the Galactic Senate. Several thousand solar systems have declared their intentions to leave the Republic. Master He...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Those of you who are familiar with the TV Show Community and it's 'lovable' character, Abed, who likes to travel around dimensions, pa...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Exams are over !! Everyone is now in the mood to play the multiplayer game Counter-Strike 1.6. 12 players decide to play Counter-Strik...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Hansa did not have enough money to pay the bill of the party. Now she loves cupcakes (and can also eat any amount of it apparently), s...
user: Generate an executable Python 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 loves playing with maths.He is very fond of factorials.Now he is interested in knowing the last five digits n!(nth number factori...
user: Generate an executable Python 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 lost in a dense jungle and it is getting dark. There is at least one path that leads you to the city on the other side but you...