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.Given an array 'D' with n elements: d[0], d[1], ..., d[n-1], you can perform the following two steps on the array. Randomly choose ...
user: Generate an executable Python 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 containing lower and uppercase alphabets, the task is to find the maximum number of characters between any two same (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.Swagnik loves Geometry. One day he came up with a very interesting problem. Swagnik has a circle of radius r and center in point (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.Characters in Star Wars each speak a language, but they typically understand a lot more languages that they don’t or can’t speak. 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.Bingu was testing all the strings he had at his place and found that most of them were prone to a vicious attack by Banju, his arch-en...
user: Generate an executable Python 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$ balloons floating in the air in a large room, lined up from left to right. Young Perica likes to play with arrows and 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.This is the easy version of the problem. The difference is that in this version the array can not contain zeros. You can make hacks on...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.You are given a string S. Every sub-string of identical letters is replaced by a single instance of that letter followed by the hexade...
user: Generate an executable Python 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. Given a board of N rows and M columns, place the minim...
user: Generate an executable Python 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 integers A_{1}, A_{2}, \ldots, A_{N}. You can perform the following operation any number of times: Select any index ...
user: Generate an executable Python 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 total number of Squares in a N*N chessboard. Example 1: Input: N = 1 Output: 1 Explanation: A 1*1 chessboard has only 1 squ...
user: Generate an executable Python 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 arrays A and B with N non-negative integers each. An array X of length N is called *good*, if: All elements of the arra...
user: Generate an executable Python 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 is standing at coordinate A while Chefina is standing at coordinate B. In one step, Chef can increase or decrease his coordinate...
user: Generate an executable Python 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 NxN matrix Mat. Sort all elements of the matrix. Example 1: Input: N=4 Mat=[[10,20,30,40], [15,25,35,45] [27,29,37,48] [32,...
user: Generate an executable Python 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 know students loves candies, so one day Teacher decided to give candies to M students. She brought along N boxes of candies. Box...
user: Generate an executable Python 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 : Baba wants to kill Guruji. He has a master plan but Guruji is prepared for him. Baba released a bacterial concentration 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.HTML Hypertext Markup Language is a standard markup language used for creating World Wide Web pages. Parsing Parsing is the proce...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.On March 14, the day of the number $\pi$ is celebrated all over the world. This is a very important mathematical constant equal to 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 is given two arrays A and B, each having N elements. In one move, Chef can choose an index i (1 ≤ i ≤ N-1), get (A_{i} - A_{i+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.Anmol loves Alupuri and can do anything for it. His best friend Bhavesh tells him that he will give him Alupuri treat if he successful...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.First Orchard is a cooperative game for children 2 years and up. In this simple game, the players pick colored fruits from trees in an...
user: Generate an executable Python 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 network of size $N$ contains $N$ computers connected by $N-1$ cables, so that there is exactly $1$ path between any pair of computer...
user: Generate an executable Python 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 is watching TV. The current volume of the TV is X. Pressing the volume up button of the TV remote increases the volume by 1 while...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Aladin was walking down the path one day when he found the strangest thing: $N$ empty boxes right next to a weird alien machine. After...
user: Generate an executable Python 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 Bluewater Geocloud Organization (BGO) has recently developed brand new software able to predict with pinpoint precision at which 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.The Indian bank issues coins in 4 denominations, ₹1, ₹2, ₹5 and ₹10. Given a limited supply of each of the above denominations, in 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.Buffalo Bill wishes to cross a $1000 \times 1000$ square field. A number of snakes are on the field at various positions, and each sna...
user: Generate an executable Python 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 string of binary number n. The task is to convert binary fractional n into its decimal equivalent. Example 1: Input: n = 11...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.AltF4 and his best friend CtrlF4 have been given a project on UV rays. They have been given N UV strips which they have to divide betw...
user: Generate an executable Python 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], [Vietnamese] and [Bengali] as well. Ash is trying to get visa to Chefland....
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Stanley has decided to buy a new desktop PC made by the company "Monoblock", and to solve captcha on their website, he needs to solve ...
user: Generate an executable Python 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 negative and non-negative integers. You have to make the array beautiful. An array is beautiful if two adjacent inte...
user: Generate an executable Python 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 buying lunch at a buffet. A number of different dishes are available, and you can mix and match them to your heart’s desire. 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.Chandu and chandni Talk on phone for a long time daily. Being afraid that someone will hear their private conversation chandu suggeste...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Brandon Greg Jr. is moving to the United States to double his salary. He has $n$ items that he needs to pack into $k$ big boxes. 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.You are given a string $s$, consisting only of Latin letters 'a', and a string $t$, consisting of lowercase Latin letters. In one mov...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Lena developed a sorting algorithm described by the following pseudocode: lena_sort(array nums) { if (nums.size <= 1) { 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.Seeing all other business tycoons from Gotham attending Vibrant Gujarat 2015, Bruce Wayne felt left out and decided he too would atten...
user: Generate an executable Python 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 mathematics, the [degree] of polynomials in one variable is the highest power of the variable in the algebraic expression with non-...
user: Generate an executable Python 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 competitive weightlifting, you must perform a sequence of lifts. You have a constant strength $s$, and a decreasing energy reserve ...
user: Generate an executable Python 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 factorial of $N$, written as $N!$, is defined as the product of all the integers from $1$ to $N$. For example, $3! = 1 \times 2 \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 a Binary Search Tree and a target value. You must find the maximum difference between the sum of node data from root 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.You are a person who is always fond of eating candies. Your friend gave you a candy of length N, to eat during the break period of you...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Ashish has a binary string $s$ of length $n$ that he wants to sort in non-decreasing order. He can perform the following operation: ...
user: Generate an executable Python 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 distinct integers. Calculate number of pairs (i,j) (1 ≤ i < j ≤ N), such that 2 \cdot (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.You are given an array a and you need to generate an array b. You are allowed to apply only one type of operation on the array a, any ...
user: Generate an executable Python 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. Chef is instructor of the famous course "Introduction ...
user: Generate an executable Python 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 [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well. Consider all matrices with $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.Dreaming of revolutionizing the tech industry and making the world a better place, Ging has recently moved to Silicon Valley to found ...
user: Generate an executable Python 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 has received a binary string of length N transmitted by Alice. He knows that due to errors in transmission, up to K bits might 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.Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well. Chef has a sequence of intege...
user: Generate an executable Python 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 is an artist and he is obsessed with palindromic number . He want to count the number of palidromic number can be generated 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.Given a list S that initially contains a single value 0. Below are the Q queries of the following types: 0 X: Insert X in the list 1...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Given a preOrder and inOrder traversal of a binary tree your task is to print the postOrder traversal of the tree .You are required to complete the function printPostOrder whi...
user: Generate an executable Python 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 [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well. Chefland is a country with $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.M items are to be delivered in a circle of size N. Find the position where the M-th item will be delivered if we start from a given 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.Consider a permutation, $p_i$, of integers from $1$ to $n$. Let's determine the $distance$ of $p_i$ to be the minimum absolute differe...
user: Generate an executable Python 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 has a string, s, of uppercase English letters. She writes down the string s on a paper k times. She wants to calculate the occure...
user: Generate an executable Python 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 is given two integers A and C such that A ≤ C. Chef wants to find whether there exists any integer B such that A, B, and C are ...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.So, here you are finally competing for the title of the champion of C3W. But before you go any further we've got something for you. 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.The construction worker previously known as Lars has many bricks of height $1$ and different lengths, and he is now trying to build 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.Given an array of N positive integers. The task is to find maximum value of |A[i] – A[j]| + |i – j|, where 0 <= i, j <= N – 1 and A[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.We call an quadruple of positive integers, $(W,X,Y,Z)$, beautiful if the following condition is true: $W\oplus X\oplus Y\oplus Z\neq0...
user: Generate an executable Python 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 wish to buy video games from the famous online video game store Mist. Usually, all games are sold at the same price, $\boldsymbol...
user: Generate an executable Python 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 unsorted array arr[] of size N, the task is to check whether the array consists of consecutive numbers or not. Example 1: Inp...
user: Generate an executable Python 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 four integers $n$, $B$, $x$ and $y$. You should build a sequence $a_0, a_1, a_2, \dots, a_n$ where $a_0 = 0$ and for eac...
user: Generate an executable Python 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 [Mandarin], [Bengali], and [Russian] as well. You are given a positive integer N. Consider a square grid 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.Given a string str you have to answer several queries on that string. In each query you will be provided two values L and R and you ha...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Over the years, Grandpa Bernie has traveled all over the world. He doesn’t travel that much anymore, but he loves to tell his grandchi...
user: Generate an executable Python 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 participant can make 1 submission every 30 seconds. If a contest lasts for X minutes, what is the maximum number of submissions 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.Ramesh loves sweet food. His favorite chocolate bar consists of pieces, each piece may contain a nut. Ramesh wants to break the bar 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 directed graph consisting of $n$ vertices. Each directed edge (or arc) labeled with a single character. Initially, 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.Frosh commencing their studies at Waterloo have diverse interests, as evidenced by their desire to take various combinations of course...
user: Generate an executable Python 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 N integers arr[ ], the task is to count the minimum number of operations to equalize the array i.e. to make all arra...
user: Generate an executable Python 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 N elements and Q queries. Each query containing an integer X. For each query print the X^th smallest number of the i...
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(0-based indexing), you have to find the max sum of i*A[i] where A[i] is the element at index i in the array. The only operation allowed is to rotate(clock-wise ...
user: Generate an executable Python 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 unsorted array and two elements num1 and num2. The task is to count the number of elements occurs between the given elements ...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Given a number num, our task is to find the closest Palindrome number whose absolute difference with given number is minimum. If 2 Pal...
user: Generate an executable Python 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 expression string x. Examine whether the pairs and the orders of {,},(,),[,] are correct in exp. For example, the function sh...
user: Generate an executable Python 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 array $a$ of size $n$ consisting only of zeroes and ones and an integer $k$. In one operation you can do one of 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.Daniel is watching a football team playing a game during their training session. They want to improve their passing skills during 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.Byteland has $N$ cities (numbered from $\mbox{1}$ to $N$) and $N-1$ bidirectional roads. It is guaranteed that there is a route from 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.SKIT's Language Department are studying an incredible string which is actually a palindrome. The students are trying to build all poss...
user: Generate an executable Python 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 positive integers of size N. Count the number of good pairs (i,j) such that: 1≤ i ≤ N, 1≤ j ≤ N and arr_{i} < arr...
user: Generate an executable Python 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 integer $\boldsymbol{d}$ is a divisor of an integer $n$ if the remainder of $n\div d=0$. Given an integer, for each digit that 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.dot The dot tool returns the dot product of two arrays. import numpy A = numpy.array([ 1, 2 ]) B = numpy.array([ 3, 4 ]) print 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.Nathan is preparing for the Dash marathon. He has N training plans. The i-th plan has an effectiveness of A_{i}, but requires that at ...
user: Generate an executable Python 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 range [m..n]. You task is to find the number of integers divisible by either a or b in the given range. Example 1: Input: 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.Your friend just bought a new programmable robot and has asked for your help. The robot operates in a 2D grid that may contain obstacl...
user: Generate an executable Python 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 grid of n rows and m columns each cell containing a robot. Rows are numbered 0 to n-1 and columns 0 to m-1. Every robot 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.Read problem statements in [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well. Chef's college is conducting an online...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Zombies have placed themselves at every junction in Bucharest. Each junction 'i' initially has a presence of ai number of zombies. Eve...
user: Generate an executable Python 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 arr of size N, the task is to modify values of this array in such a way that the sum of absolute differences between tw...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Rachel works at a big fashion organization. There is a big event coming up and she has to select dresses for an exhibition. She has 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.Read problems statements [Mandarin] , [Bengali] , [Hindi] , [Russian] and [Vietnamese] as well. Chef is participating in a pogo stick...
user: Generate an executable Python 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 the World Cup Finals. Chef only finds a match interesting if the skill difference of the competing teams is *less than or equal ...
user: Generate an executable Python 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 N, the task is to find the number of diagonals in N sided convex polygon. Example 1: Input: N = 5 Output: 5 Example 2: ...
user: Generate an executable Python 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 Russian here Polo, the Penguin, likes lucky strings - the strings that consist only of lucky digits 4 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 an N bit binary number, find the 1's complement of the number. The ones' complement of a binary number is defined as the value 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.Welcome back to our new town named Errorinous Town. The most characteristics of this town is that people of the town follow a very dif...