formatted_conversations stringlengths 1.13k 138k |
|---|
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.There are two types of burgers in your restaurant — hamburgers and chicken burgers! To assemble a hamburger you need two buns and a 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.You are given a string s consisting only of characters + and -. You perform some process with this string. This process can be describ... |
user: Generate an executable Python 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 participates in a ski race along the X axis. The start is at point 0, and the finish is at L, that is, at a distance L meters fr... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.You are given an array a consisting of n (n ≥ 3) positive integers. It is known that in this array, all the numbers except one are 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.Zart PMP is qualified for ICPC World Finals in Harbin, China. After team excursion to Sun Island Park for snow sculpture art expositio... |
user: Generate an executable Python 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 works as a DJ in the best Berland nightclub, and he often uses dubstep music in his performance. Recently, he has decided to 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.The Bitlandians are quite weird people. They do everything differently. They have a different alphabet so they have a different defini... |
user: Generate an executable Python 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 continued fraction of height n is a fraction of form <image>. You are given two rational numbers, one is represented as <image> 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.Valera has got n domino pieces in a row. Each piece consists of two halves — the upper one and the lower one. Each of the halves conta... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Bizon the Champion isn't just attentive, he also is very hardworking.
Bizon the Champion decided to paint his old fence his favorite ... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Nowadays it is becoming increasingly difficult to park a car in cities successfully. Let's imagine a segment of a street as long as 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.The country has n cities and n - 1 bidirectional roads, it is possible to get from every city to any other one if you move only along ... |
user: Generate an executable Python 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 country of Byalechinsk is running elections involving n candidates. The country consists of m cities. We know how many people in 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.At the entrance examination for the magistracy of the MSU Cyber-Mechanics Department Sasha got the question about Ford-Fulkerson algor... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Stepan has a very big positive integer.
Let's consider all cyclic shifts of Stepan's integer (if we look at his integer like at a str... |
user: Generate an executable Python 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 is a great fan of television.
He wrote down all the TV programs he is interested in for today. His list contains n shows, i-... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.A false witness that speaketh lies!
You are given a sequence containing n integers. There is a variable res that is equal to 0 initia... |
user: Generate an executable Python 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 set of n elements indexed from 1 to n. The weight of i-th element is wi. The weight of some subset of a given set is 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.Arnab is a robber and he has managed to rob N different strings from Akash. Now he decides to sell these strings in the market to make... |
user: Generate an executable Python 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 studying a swarm of N fireflies. Each firefly is moving in a straight line at a constant speed. You are standing at the center... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Anmol likes gems very much.
He has N packets of gems, here the ith packet contains Pi gems. You need to find the minimal number of pac... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Verma has got 2 arrays of integer numbers. He wished to find the sum of product of all numbers in first array with all the
numbers in ... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Our Code Monk recently learnt about Graphs and is very excited!
He went over to the Graph-making factory to watch some freshly prep... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Its Diwali time and little Roy thought of an interesting design for Rangoli.
He created an N x N grid. Roy fills some of the cells 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.Subly found a set of Numbers in his Dad's table. Subly examines that set and wants to know how many numbers in that set are not 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.Vivek and Sita are in a relationship. Both of them love playing with numbers and treat each other with puzzles every now and then.
Wh... |
user: Generate an executable Python 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 rated ... |
user: Generate an executable Python 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 the following operations on a string consisting of `A` and `B`:
1. Select a character in a string. If it is `A`, repl... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.<image>
Matryoshka is a wooden doll in the shape of a female figure and is a typical Russian folk craft. Matryoshka has a nested stru... |
user: Generate an executable Python 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 contest will be held at White Tiger University this year as well. There are several questions in the contest, each of wh... |
user: Generate an executable Python 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 long-established secondhand bookstore called JOI secondhand bookstore in your town, and you often use the JOI secondhand bo... |
user: Generate an executable Python 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 wizards. They are numbered from 1 to n, and the i-th wizard has the magical power ri (1 ≤ i ≤ n). Now they are confronting... |
user: Generate an executable Python 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 of you might have seen instruments like the figure below.
<image>
Figure 1: Spirograph
There are a fixed circle (indicated 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.You want to make change for $ n $ cents. Assuming that you have infinite supply of coins of 1, 5, 10 and / or 25 cents coins respectiv... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Leha is playing a very interesting game. The game will be played on a rectangular grid consisting of N rows and M columns. Initially 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.A number is called palindromic if its decimal representation is a palindrome. You are given a range, described by a pair of integers 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.You are given n segments on a number line; each endpoint of every segment has integer coordinates. Some segments can degenerate to poi... |
user: Generate an executable Python 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 permutations a and b, both consisting of n elements. Permutation of n elements is such a integer sequence that each ... |
user: Generate an executable Python 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 knows that if the sum of the digits of a number is divisible by 3, then the number itself is divisible by 3. He assumes 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.Gildong is playing a video game called Block Adventure. In Block Adventure, there are n columns of blocks in a row, and the columns ar... |
user: Generate an executable Python 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 plane. The i-th point has coordinates (x_i, y_i). You have two horizontal platforms, both of length k. Each pl... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Numbers 1, 2, 3, ... n (each integer from 1 to n once) are written on a board. In one operation you can erase any two numbers a and 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.You are given an array a of n integers. Define the cost of some array t as follows:
$$$cost(t) = ∑_{x ∈ set(t) } last(x) - first(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.You are given a non-empty string s consisting of lowercase letters. Find the number of pairs of non-overlapping palindromic substrings... |
user: Generate an executable Python 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 polar bears are going fishing. They plan to sail from (sx, sy) to (ex, ey). However, the boat can only sail by wind. At each secon... |
user: Generate an executable Python 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 R2 company has n employees working for it. The work involves constant exchange of ideas, sharing the stories of success and upcomi... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Toastman came up with a very easy task. He gives it to Appleman, but Appleman doesn't know how to solve it. Can you help him?
Given 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 decimal presentation of an integer. Let's call a number d-magic if digit d appears in decimal presentation of the 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.Little Joty has got a task to do. She has a line of n tiles indexed from 1 to n. She has to paint them in a strange pattern.
An unpai... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Sagheer is walking in the street when he comes to an intersection of two roads. Each road can be represented as two parts where each 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.You are given an image, that can be represented with a 2-d n by m grid of pixels. Each pixel of the image is either on or off, denoted... |
user: Generate an executable Python 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 times you recall a good old friend and everything you've come through together. Luckily there are social networks — they sto... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Daenerys Targaryen has set her eyes on The kingdom of Dorne. Dornishmen, known for their strong sense of national identity, have refus... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Quan_Lank loves awsome numbers. Awsome numbers are the positive integers whose decimal representations contain only the awsome 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.Today Oz wants to play with Lucky strings. A string S is called Lucky string if there exists a non-negative integer m such that S is 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.Ravi is very tensed nowadays because of the design project. He has not even decided the topic yet. Micro feels very bad for Ravi, so 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.Tom is off to a school Annual Day and is searching for a matching pair of socks. His drawer is filled with socks, each pair of a diffe... |
user: Generate an executable Python 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 enthusiastically participating in Virtual Boot Camp-14 and want to seriously learn programming. To be a good programmer you no... |
user: Generate an executable Python 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 two distinct integers A and B.
Print the integer K such that |A - K| = |B - K|.
If such an integer does not exist, print `IM... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.When Mr. X is away from home, he has decided to use his smartwatch to search the best route to go back home, to participate in ABC.
Y... |
user: Generate an executable Python 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 grid with 2 rows and 3 columns of squares. The color of the square at the i-th row and j-th column is represented by 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.Sig has built his own keyboard. Designed for ultimate simplicity, this keyboard only has 3 keys on it: the `0` key, the `1` key and 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.I have a plan to go on a school trip at a school. I conducted a questionnaire survey for that purpose. Students have student numbers 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.ICPC Ranking
Your mission in this problem is to write a program which, given the submission log of an ICPC (International Collegiate ... |
user: Generate an executable Python 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: Imagawayaki Man-Imagawayaki Man-
story
Imagawayaki Man is a hero of justice. The face is Imagawayaki with a diameter of 1 meter (... |
user: Generate an executable Python 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: Jam
problem
There are N cities in a country, numbered 1, \ 2, \ ..., \ N. These cities are connected in both directions by M road... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Oranges on Cans
square1001 You put a $ N $ can of aluminum on the table.
E869120 You put $ M $ of oranges on each aluminum can on 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.Write a program to find the remainder when two given numbers are divided.
Input
The first line contains an integer T, total number 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.Little Elephant from the Zoo of Lviv likes cards. He has N cards, each of which has one of 1000 colors. The colors 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 and Bob are playing chess on a huge chessboard with dimensions n × n. Alice has a single piece left — a queen, located at (a_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.The length of the longest common prefix of two strings s=s_1 s_2 … s_n and t = t_1 t_2 … t_m is defined as the maximum k ≤ min(n, m) 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.A frog is initially at position 0 on the number line. The frog has two positive integers a and b. From a position k, it can either jum... |
user: Generate an executable Python 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 may have already known that a standard ICPC team consists of exactly three members. The perfect team however has more restrictions... |
user: Generate an executable Python 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 people in this world, conveniently numbered 1 through n. They are using burles to buy goods and services. Occasionally, 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. There was once young lass called Mary,
Whose jokes were occasionally scary.
On this April's Fool
Fixed lim... |
user: Generate an executable Python 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 competitive eater, Alice is scheduling some practices for an eating contest on a magical calendar. The calendar is unusual because 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.Vova decided to clean his room. The room can be represented as the coordinate axis OX. There are n piles of trash in the room, coordin... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Andrey thinks he is truly a successful developer, but in reality he didn't know about the binary search algorithm until recently. Afte... |
user: Generate an executable Python 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 and your friends live in n houses. Each house is located on a 2D plane, in a point with integer coordinates. There might be differ... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.It is well known that Berland has n cities, which form the Silver ring — cities i and i + 1 (1 ≤ i < n) are connected by a road, as we... |
user: Generate an executable Python 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's finally decided to go on holiday! He packed up and headed for a ski resort.
Valera's fancied a ski trip but he soon realized... |
user: Generate an executable Python 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 translation from the Berland language into the Birland language is not an easy task. Those languages are very similar: a berlandis... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Scrooge McDuck keeps his most treasured savings in a home safe with a combination lock. Each time he wants to put there the treasures ... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Today Berland holds a lottery with a prize — a huge sum of money! There are k persons, who attend the lottery. Each of them will recei... |
user: Generate an executable Python 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 year 2015 is almost over.
Limak is a little polar bear. He has recently learnt about the binary system. He noticed that the passi... |
user: Generate an executable Python 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 History of Magic is perhaps the most boring subject in the Hogwarts school of Witchcraft and Wizardry. Harry Potter is usually asl... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Theater stage is a rectangular field of size n × m. The director gave you the stage's plan which actors will follow. For each cell 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.You are given sequence a1, a2, ..., an of integer numbers of length n. Your task is to find such subsequence that its sum is odd and 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.You are given an array a consisting of n elements. The imbalance value of some subsegment of this array is the difference between 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.Today at the lesson Vitya learned a very interesting function — mex. Mex of a sequence of numbers is the minimum non-negative number t... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.You are given an array a of size n, and q queries to it. There are queries of two types:
* 1 li ri — perform a cyclic shift of 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.A has a string consisting of some number of lowercase English letters 'a'. He gives it to his friend B who appends some number of lett... |
user: Generate an executable Python 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 company is going to hold a fair in Byteland. There are n towns in Byteland and m two-way roads between towns. Of course, you 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.In Byteland,people don't use standard e-mail services like gmail,yahoo-mail etc.Instead they have their own e-mail service know as Byt... |
user: Generate an executable Python 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'll be given an array A of N integers as input. For each element of the array A[i], print A[i]-1.
Input:
There will be N+1 iines ... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Pradeep Khicchar , a very influential ,dominating ,smart and definitely an intelligent guy, is very eager to get his patent on his fi... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.As we all know that power sets of any set are formed by taking i elements (where i is from 1 to n) and then random shuffling them lik... |
user: Generate an executable Python 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 had recently learnt about Bit manipulation and logic gates,now he is very excited about it.One day he came across a very interes... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.To round an integer a, it is customary to round to some multiple of a power of 10, and you will round it accordingly. This time, rules... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Dark completed with studying Strings last night and trying to solve the problem of primes numbers from last three months but did not s... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.