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.Read problem statements in [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well. There is a large tree house in an unkn...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Kornislav the turtle never has anything interesting to do. Since he’s going to live for three hundred years, he keeps trying to find 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.Mirko has found an old chessboard and a set of pieces in his attic. Unfortunately, the set contains only white pieces, and apparently ...
user: Generate an executable Python 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 to help a thief to steal as many as GoldCoins as possible from a GoldMine. There he saw N Gold Boxes an each Gold Boxes consi...
user: Generate an executable Python 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 two positive integers a and b, let g(a, b) = [gcd] (a, b) + [lcm](a, b). For a positive integer N, let f(N) denote the minimum v...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Read problems statements in Mandarin Chinese, Russian and Vietnamese as well. Little Churu is a naughty child, who likes to play wit...
user: Generate an executable Python 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 time ago, Chef bought X stocks at the cost of Rs. Y each. Today, Chef is going to sell all these X stocks at Rs. Z each. What 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.There are N trees in a particular region of forest with the trees number from 1 to N. Tarzan, our hero is standing on Tree Number 1. 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.Mirko is playing with stacks. In the beginning of the game, he has an empty stack denoted with number $0$. In the $i$-th step of the 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.After an unsuccessful attempt at claiming power peacefully, Borko has decided to tear down Mirko’s village hall, which was built for 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.You are given N elements, you can remove any two elements from the list, note their sum, and add the sum to the list. Repeat these ste...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Micro has just learnt about factorials. So he went to Ravi's room to boast about it. But Ravi being smart gave him a problem on factor...
user: Generate an executable Python 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-degenerate triangle (a non-degenerate triangle is a triangle with positive area). The vertices of the triangle hav...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.There are three horizontal wheels of letters stacked one on top of the other, all with the same number of columns. All wheels have one...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Read problems statements in [Hindi], [Mandarin Chinese], [Russian], [Vietnamese], and [Bengali] as well. You are given two integers $...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Given a set of n elements, find number of ways of partitioning it. Example 1: Input: N = 2 Output: 2 Explanation: Let the set be {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.You are given a matrix consisting of n rows and m columns. The matrix contains lowercase letters of the Latin alphabet. You can perfo...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Given a triangle array, return the minimum path sum to reach from top to bottom. For each step, you may move to an adjacent number 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.Provided an array Arr of N integers, you need to reverse a subarray of that array. The range of this subarray is given by L and R. 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.Given a string return all unique possible subsequences which start with vowel and end with consonant. A String is a subsequence of a 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.Read problems statements in Mandarin Chinese and Russian as well. Mike takes part in programming contests. His favourite topic is dy...
user: Generate an executable Python 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 2 strings A and B of the same length N. A contains '0', '1', and '?'; B contains only '0' and '1'. Your task is to find ...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Han didn’t want to study solo so he invited his friend Dominik to come over. After an eventful evening that will be remembered for a 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.Given two strings s1 and s2, The task is to convert s1 into a palindrome such that s1 contain s2 as a substring in a minimum number 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.You are given a sequence of integers a_{1},a_{2},a_{3}.....a_{n}. You are free to replace any integer with any other positive 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.Panda being a badass programmer is forever alone. So he had nothing to do on Valentine's Day. Instead he decides to take a walk. Durin...
user: Generate an executable Python 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 the lessons n groups of friends went outside and decided to visit Pawan to celebrate his birthday. We know that the i-th group 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.A club plans to hold a party and will invite some of its $n$ members. The $n$ members are identified by the numbers $1, 2, \dots, 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.The match is set and your team is ready to win! The team has $N$ players, each with the ability $A_{i}$. But you are not happy with ...
user: Generate an executable Python 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. Your task is to determine if the sum of ASCII values of all character results in a perfect square or not. If...
user: Generate an executable Python 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 pair of two very large positive integers is given. Find their sum. Example 1: Input: s1 = "63457", s2 = "645" Output: 64102 Explan...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Construct a binary tree of size N using two given arrays pre[] and preLN[]. Array pre[] represents preorder traversal of a binary tree...
user: Generate an executable Python 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 consisting of N integers A_{1},A_{2},…,A_{N}, determine if you can sort this array by applying the following operatio...
user: Generate an executable Python 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 word from the English dictionary is taken and arranged as a matrix. e.g. "MATHEMATICS" MATHE ATHEM THEMA HEMAT EMATI MATI...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Given a binary array arr of size N and an integer M. Find the maximum number of consecutive 1's produced by flipping at most M 0's. Example 1: Input: N = 3 arr[] = {1, 0, 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.Given a string, eliminate all “b” and “ac” in the string, replace them in-place and iterate over the string once. Example 1: Input: 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 two integers L and R find (number of composites - number of primes) between the range L and R (both inclusive). Example 1: Input...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Given an array A of N integers. You have to find whether a combination of four elements in the array whose sum is equal to a given value X exists or not. Example 1: Input: 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.Given a binary string S . Perform R iterations on string S, where in each iteration 0 becomes 01 and 1 becomes 10. Find the Nth charac...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Given a string. Count the number of Camel Case characters in it. Example 1: Input: S = "ckjkUUYII" Output: 5 Explanation: Camel Case 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.Six friends go on a trip and are looking for accommodation. After looking for hours, they find a hotel which offers two types of rooms...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Read problems statements in Mandarin chinese, Russian and Vietnamese as well. You are given a score log of a football match between ...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Dragonado rarely gets stuck on a problem, unless of course, if it's a XOR Problem. Dragonado while coming back from the Fruit Market...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Ma5termind is going through the Euler's book of knowledge when he finds the following function: def function(L,R): sum=0 for...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Peter is bored during his operating systems class, so he draws doodles on a sheet of paper. He feels like drawing abstract art using 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.Petya and his friend, robot Petya++, like to solve exciting math problems. One day Petya++ came up with the numbers $n$ and $x$ 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.When a contiguous block of text is selected in a PDF viewer, the selection is highlighted with a blue rectangle. In this PDF viewer, 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.Given the start time st and end time et of a race in the format hh:mm:ss. You task is to print the time taken to complete the race. 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.Prof. Lambda has N students in his class. Due to his ignorance his students has gone rogue on him and never comes to class on time. Pr...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.YouKn0wWho has an integer sequence $a_1, a_2, \ldots, a_n$. He will perform the following operation until the sequence becomes empty: ...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Satish wants to organize a dance party at IIIT BH-2 but unfortunately he has no money for it So he plan for funding from all boys to 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.Given an array of length N consisting of only 0s and 1s in random order. Modify the array to segregate 0s on left side and 1s on the 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.Having discolored his white socks in a rather beige shade (as seen on the picture), Luktas Svettocek realised he can’t just throw all ...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Given a set of coordinates points of the form [p, q] and a line L of the form ax + by + c = 0. The task is to find a point on a given ...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Given a number of friends who have to give or take some amount of money from one another. Design an algorithm by which the total cash ...
user: Generate an executable Python 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. You are also given an integer Q. Can you figure out the answer to each of the Q queries? Each que...
user: Generate an executable Python 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 bought N items from a shop. Although it is hard to carry all these items in hand, so Chef has to buy some polybags to store these...
user: Generate an executable Python 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 of us have read about factorials and Fibonacci numbers when we started studying algorithms. Today, we will be dealing with the fac...
user: Generate an executable Python 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 learn some new Python concepts! You have to generate a list of the first $N$ fibonacci numbers, $\mbox{o}$ being the first numbe...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.War is raging between Humans and Cyberdyne Systems. Our intel has shown that Cyberdyne has prepared a large army of terminators to ext...
user: Generate an executable Python 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 sequence [A1 , A2 ...An], the task is to find the maximum possible sum of increasing subsequence S of length K such 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.Cat Cink is participating in a party in Prime Kingdom. There are n Cates there (include Cat Cink). The i-th Cat is ai years old. 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.Tom is a string freak. He has got sequences of n words to manipulate. If in a sequence, two same words come together then hell destro...
user: Generate an executable Python 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 allocated himself a budget of P rupees to buy Diwali crackers. There are only 3 types of crackers available in the market 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.Given the time in numerals we may convert it into words, as shown below: $\begin{array}{l}5.00\rightarrow\:five \quad o'clock\\ 5.0...
user: Generate an executable Python 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 encoded string S consisting of alphabets(lowercase) and integers(1<=num<=9) is given, the task is to decode it and print the charac...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Finally, College has started calling students back to campus. There are so many students and thus due to some safety measures the coll...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Cooking Examinations Authority (C.E.A.) is conducting an Ordinary Cooking Level (O.C.L.) test, which tests the candidate skills on thr...
user: Generate an executable Python 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 a game. Initially, they are given a non-empty string $s$, consisting of lowercase Latin letters. The length ...
user: Generate an executable Python 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 tunnels of Cu Chi are an immense network of underground tunnels connecting rooms located in the Cu Chi District of Ho Chi Minh Cit...
user: Generate an executable Python 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$ points with integer coordinates on a coordinate axis $OX$. The coordinate of the $i$-th point is $x_i$. All points' ...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.From an array A containing N integers, you construct a binary string S of length (N - 1) as follows. For all 1 ≤ i < N: If A_{i} < 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.One day you were visiting a museum where you saw a modern piece of art that shows a grid of $N$ rows and $M$ columns. Each cell 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.*Chef has recently introduced a [feature], called WA Test Cases, which allows you to see the smallest test case that your WA code 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.Concatenate Two or more arrays can be concatenated together using the concatenate function with a tuple of the arrays to be joined:...
user: Generate an executable Python 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 using at most A number of 1s and at most B number of 2s. How many different evaluation results are possible when they are form...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Find the number of leaf nodes in a full k-ary tree of height m. Note: You have to return the answer module 10^{9}+7. Example 1: Inpu...
user: Generate an executable Python 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 two strings A and B of lengths N and M respectively. Chef can rearrange both strings in any way he wants. Let the rearranged...
user: Generate an executable Python 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 only $1$ TV in the common room, and as luck would have it, both the El Clasico football match and the India-Pakistan cricket ...
user: Generate an executable Python 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, 2 strings A and B of same length N are considered equivalent if following conditions are true for all 1 ≤ i, j ≤ 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.A professor went to a party. Being an erudite person, he classified the party into two categories. He proposed that if all the persons...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Last time, Dominic and his family brought it home, to the city they know best. After a fierce battle with Shaw in the town, the town 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.Quibdó in Colombia is one among the cities that receive maximum rainfall in the world. All year round, the city is covered in clouds....
user: Generate an executable Python 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 four different points in space. Find whether these points can form a square or not. Example 1: Input: x1 = 20, y1 = 10, x2 = 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.Given an array of integers arr[] of length N, every element appears thrice except for one which occurs once. Find that element which 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.You are given an integer $n$. Pair the integers $1$ to $2n$ (i.e. each integer should be in exactly one pair) so that each sum of matc...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Geek wants to make a special space for candies on his bookshelf. Currently, it has N books, each of whose height is represented by 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.Gray codes are a classic topic in information theory with a number of practical applications, none of which we are concerned with in 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.In geometry, ellipses are defined by two focal points $f_1, f_2$ and a length $D$. The ellipse consists of all points $p$ such 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.Captain America is hiding from Thanos in a maze full of N rooms connected by M gates. The maze is designed in such a way that each roo...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Given an integer K and a queue of integers, we need to reverse the order of the first K elements of the queue, leaving the other elements in the same relative order. Only foll...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Given a sentence in the form of a string in uppercase, convert it into its equivalent mobile numeric keypad sequence. Please note ther...
user: Generate an executable Python 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 Kanto region has $N$ junctions and $N - 1$ bidirectional roads. Junctions are numbered from $1$ to $N$, inclusive. All roads have ...
user: Generate an executable Python 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 positive integer N. Your task is to find the smallest number greater than or equal to N that is a prime and a pali...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Siddhant made a special series and named it as G.F Series. The series follows this trend T_{n}=(T_{n-2})^{2}-(T_{n-1}) in which 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.When the first scrollbars appeared on resizable windows during user interface development in the Elder Days, computer graphics were 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.Statisticians like to create a lot of statistics. One simple measure is the mean value: the sum of all values divided by the number of...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Your friend loves magic and he has coined a new term - "Magical number". To perform his magic, he needs that Magic number. There are N number of people in the magic show, seat...
user: Generate an executable Python 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 on your way to your first job interview as a program tester, and you are already late. The interview is in a skyscraper and 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.Given a string, remove characters until the string is made up of any two alternating characters. When you choose a character to remov...