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.Himu wants to go on a long drive with his girlfriend. There are N cities numbered from 1 to N, and every city is connected to every ot...
user: Generate an executable Python 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 FULL binary tree i.e. each node except leaves has two children. The magic sum between any two leaf nodes (both possibly sa...
user: Generate an executable Python 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 Nice-P sequence is defined as a sequence such that a1 x a2=1 (mod p), a2 x a3=1 (mod p) ..., an-1 x an = 1 (mod p). In addition, a1,...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.You are given two circles C1 & C2 (centers , and radii are given), if area of circle-1 is A1 and that of circle-2 is A2 , you have 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.There is a mysterious temple in Mysteryland. The door of the temple is always closed.It can only be opened by a unique procedure.There...
user: Generate an executable Python 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 predicted by the great Gods, Little Arjit has got nothing to do this summer. (Are you surprised?) But, he's not one of those people...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Xsquare got bored playing with the arrays all the time. Therefore, he has decided to play with the strings. Xsquare called a string P ...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Fennec is fighting with N monsters. The health of the i-th monster is H_i. Fennec can do the following two actions: * Attack: Fenne...
user: Generate an executable Python 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 be given a string S of length 3 representing the weather forecast for three days in the past. The i-th character (1 \leq 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.In your garden, there is a long and narrow flowerbed that stretches infinitely to the east. You have decided to plant N kinds of flowe...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Hexwamp is a strange swamp, paved with regular hexagonal dimples. Hexerpents crawling in this area are serpents adapted to the environ...
user: Generate an executable Python 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 be a connected undirected graph where N vertices of G are labeled by numbers from 1 to N. G is simple, i.e. G has no self loops ...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.E-training Nene is writing a program to look up $ N $ integers $ V_1, V_2, V_3, \ cdots, V_N $ for programming training. As told by ...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.For given a sequence $A = \\{a_0, a_1, ..., a_{n-1}\\}$, print the previous permutation and the next permutation in lexicographic orde...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Problem Statement Past In the year of 2048, the Virtual Reality Massively Multiplayer Online Role-Playing Game (VRMMORPG), Code Art 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.In CycleLand Jack and Jenny are two friends.They want to go CycleSchool By a cycle ( Assume that they live in same house) . Distance 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.The Gray code (see wikipedia for more details) is a well-known concept. One of its important properties is that every two adjacent num...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Tug of war is a sport that directly puts two teams against each other in a test of strength. During school days, both Chef Shifu 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.A tourist is visiting Byteland. The tourist knows English very well. The language of Byteland is rather different from English. To be ...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Nazar, a student of the scientific lyceum of the Kingdom of Kremland, is known for his outstanding mathematical abilities. Today a mat...
user: Generate an executable Python 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.Recently Polycarp noticed that some of the buttons of his keyboard are malfunctioning. For simplicity, we assume that Polycarp's keybo...
user: Generate an executable Python 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 had three strings a, b and s, which consist of lowercase English letters. The lengths of strings a and b are equal to n, the len...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Pasha loves to send strictly positive integers to his friends. Pasha cares about security, therefore when he wants to send an integer ...
user: Generate an executable Python 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 directed graph of n vertices and m edges. Vertices are numbered from 1 to n. There is a token in vertex 1. The follow...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Monocarp wants to draw four line segments on a sheet of paper. He wants the i-th segment to have its length equal to a_i (1 ≤ i ≤ 4). ...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Furik loves math lessons very much, so he doesn't attend them, unlike Rubik. But now Furik wants to get a good mark for math. For that...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Hooray! Berl II, the king of Berland is making a knight tournament. The king has already sent the message to all knights in the kingdo...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Vanya loves playing. He even has a special set of cards to play with. Each card has a single integer. The number on the card can be po...
user: Generate an executable Python 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 Mike was walking in the subway, all the stuff in his back-bag dropped on the ground. There were several fax messages among them....
user: Generate an executable Python 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 making bad dives into swimming pools, Wilbur wants to build a swimming pool in the shape of a rectangle in his backyard. He has ...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.A flowerbed has many flowers and two fountains. You can adjust the water pressure and set any values r1(r1 ≥ 0) and r2(r2 ≥ 0), givin...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.ZS the Coder has recently found an interesting concept called the Birthday Paradox. It states that given a random set of 23 people, 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.Bob recently read about bitwise operations used in computers: AND, OR and XOR. He have studied their properties and invented a new gam...
user: Generate an executable Python 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 just invented a new binary protocol for data transmission. He is encoding positive integer decimal number to binary strin...
user: Generate an executable Python 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 and Watson were good friends. They both were solving a mystery. But they got hungry and wanted to eat something. Hence they 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.2^N participants (P1 , P2 , P3 .... , P2^N ) have enrolled for a knockout chess tournament. In the first round, each participant P2k-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.A drunk person was moving from one point on the street to another point on the same street. His starting point was between two manhole...
user: Generate an executable Python 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 Monty is very fond of Fibonacci numbers and challenges his friend Lopa that he can solve any question regarding the same. Lopa ...
user: Generate an executable Python 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 of you know the famous Fibonacci sequence F: F[1] = 1 F[2] = 1 F[i] = F[i - 1] + F[i - 2] for i > 2 Thus each number in sequence...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Sandy is given an array of N integers which is a permutation of the first N natural numbers. He can swap any two elements of the array...
user: Generate an executable Python 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 Timmy is exceptionally good at math tables, so his maths teacher decided to make things a bit more interesting. His teacher tak...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Separatist Always finding new ways to destroy the Republic forces by surprise attacks. Now they trapped the Republic fleet near the ...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.There are N piles of stones. The i-th pile has A_i stones. Aoki and Takahashi are about to use them to play the following game: * St...
user: Generate an executable Python 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 connected undirected graph with N vertices and M edges. The vertices are numbered 1 to N, and the edges are described by 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.Consider the following arithmetic progression with n terms: * x, x + d, x + 2d, \ldots, x + (n-1)d What is the product of all term...
user: Generate an executable Python 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 X-layered kagami mochi (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) h...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Alice and Bob are controlling a robot. They each have one switch that controls the robot. Alice started holding down her button A seco...
user: Generate an executable Python 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 K pieces of cakes. Mr. Takahashi would like to eat one cake per day, taking K days to eat them all. There are T types of ca...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Fukushima Prefecture is also famous for producing fruits, and among them, peaches and apples boast one of the highest production volum...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Water Country Water Deven has n cities. Each city is surrounded by water and looks like an island country. Water Deven has m bridges, ...
user: Generate an executable Python 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, the researchers who discovered and investigated the ancient nation Iwashiro, finally discovered the temple in the center of Iwashi...
user: Generate an executable Python 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 K Counting Cycles Given an undirected graph, count the number of simple cycles in the graph. Here, a simple cycle is a connec...
user: Generate an executable Python 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 A: Swap crypto A 2D enthusiast at R University, he often writes embarrassing sentences that blush when seen by people. Theref...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Problem Statement One day, my grandmas left $N$ cookies. My elder sister and I were going to eat them immediately, but there was 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.Problem statement Meatishi can increase or decrease the number of fingers. There are n buns in front of Nikunishi-kun. Meatishi is tr...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.For a given sequence $A = \\{a_0, a_1, ... a_{n-1}\\}$, the number of pairs $(i, j)$ where $a_i > a_j$ and $i < j$, is called the numb...
user: Generate an executable Python 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 and Hanako are playing card games. They have n cards each, and they compete n turns. At each turn Taro and Hanako respectively pu...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Abhi and his friends (Shanky,Anku and Pandey) love to play with strings. Abhi invented a simple game. He will give a string S to his 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.Are you fond of collecting some kind of stuff? Mike is crazy about collecting stamps. He is an active member of Stamp Collecting Сommu...
user: Generate an executable Python 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. This problem deals with the I/O methods used in codechef. You are supposed to print the integer in its reverse fo...
user: Generate an executable Python 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 n coins, the value of the i-th coin is a_i. Polycarp wants to distribute all the coins between his pockets, but he cannot...
user: Generate an executable Python 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 chessboard of size n × n. It is filled with numbers from 1 to n^2 in the following way: the first ⌈ (n^2)/(2) ⌉ number...
user: Generate an executable Python 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 long stick, consisting of m segments enumerated from 1 to m. Each segment is 1 centimeter long. Sadly, some segments are br...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Nick had received an awesome array of integers a=[a_1, a_2, ..., a_n] as a gift for his 5 birthday from his mother. He was already goi...
user: Generate an executable Python 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 play a computer game. In this game, you lead a party of m heroes, and you have to clear a dungeon with n monsters. Each monster is...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Vova had a pretty weird sleeping schedule. There are h hours in a day. Vova will sleep exactly n times. The i-th time he will sleep ex...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Wabbit is trying to move a box containing food for the rest of the zoo in the coordinate plane from the point (x_1,y_1) to the point (...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Ridbit starts with an integer n. In one move, he can perform one of the following operations: * divide n by one of its proper div...
user: Generate an executable Python 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. Check if n has an odd divisor, greater than one (does there exist such a number x (x > 1) that n is divisi...
user: Generate an executable Python 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 you know, Bob's brother lives in Flatland. In Flatland there are n cities, connected by n - 1 two-way roads. The cities are numbere...
user: Generate an executable Python 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 an initially empty cauldron, and you want to brew a potion in it. The potion consists of two ingredients: magic essence and 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.Recently a top secret mission to Mars has taken place. As a result, scientists managed to obtain some information about the Martian DN...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.You've got string s, consisting of small English letters. Some of the English letters are good, the rest are bad. A substring s[l...r...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.A + B is often used as an example of the easiest problem possible to show some contest platform. However, some scientists have observe...
user: Generate an executable Python 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 circular array a0, a1, ..., an - 1. There are two types of operations with it: * inc(lf, rg, v) — this operation inc...
user: Generate an executable Python 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 the robot lies in an infinite rectangular grid. Calvin's source code contains a list of n commands, each either 'U', 'R', '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.Tired of boring dates, Leha and Noora decided to play a game. Leha found a tree with n vertices numbered from 1 to n. We remind you 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.Harry Potter is on a mission to destroy You-Know-Who's Horcruxes. The first Horcrux that he encountered in the Chamber of Secrets is 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.Ivan's classes at the university have just finished, and now he wants to go to the local CFK cafe and eat some fried chicken. CFK sel...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.And again a misfortune fell on Poor Student. He is being late for an exam. Having rushed to a bus stop that is in point (0, 0), he go...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.After a lot of hard work, Goyal has finally completed his app. But before he launches it, he needs to test it. His friends are helping...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Now After eliminating the invalid registrations they are planning to form connections to the participants laptops. The connection 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.Write a program to find the mode of a given list of integers. Mode of a number is defined as the number which is most frequently occur...
user: Generate an executable Python 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 your program in Ruby which takes an un-indented Ruby code as string and outputs the indented Ruby code as string. Input Format ...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Arya is new to matrices. With lots of subtopics in the chapter, he finds it difficult in getting good in all of them. As of now, he is...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Some people remain old fashioned and John is one of them. He doesn't like the new smart phones with full keypads and still uses the ol...
user: Generate an executable Python 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 has a very pretty girlfriend. He chats with her all day and night through his phone. His phone lacks a QWERTY keypad, instead it ...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Tom is very weak at maths, his teacher gave him a simple problem of dividing two numbers but as usual Tom is having difficulty solving...
user: Generate an executable Python 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 string S consisting of lowercase English letters. If the length of S is at most K, print S without change. If the length o...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.For a finite set of integers X, let f(X)=\max X - \min X. Given are N integers A_1,...,A_N. We will choose K of them and let S be 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.In 2028 and after a continuous growth, AtCoder Inc. finally built an empire with six cities (City 1, 2, 3, 4, 5, 6)! There are five m...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.There is a train going from Station A to Station B that costs X yen (the currency of Japan). Also, there is a bus going from Station ...
user: Generate an executable Python 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 wants to evaluate the formula "A op B". Here, A and B are integers, and the binary operator op is either `+` or `-`. Your task...
user: Generate an executable Python 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 that extracts n different numbers from the numbers 0 to 100 and outputs the number of combinations that add up to s. 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.Mr. Kobou found a bundle of old paper when he was cleaning his family home. On each paper, two series of numbers are written. Strange ...
user: Generate an executable Python 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 many blue cards and red cards on the table. For each card, an integer number greater than 1 is printed on its face. The same...
user: Generate an executable Python 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 Rolling Block is a game in which a rectangular parallelepiped metal body is rotated and moved, and dropped into a hole 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.Princess, a Cryptanalyst Decryption of the princess English text is not available in this practice contest. A brave princess in a p...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Sliding GCD Problem Statement For the set S of natural numbers, let f (S) be the number of elements in the set \\ {GCD (T) | T ⊆ S, ...