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 a string str containing alphanumeric characters. The task is to calculate the sum of all the numbers present in the string. Exam...
user: Generate an executable Python 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 famous Jurassic park biologist Dean O’Saur has discovered new samples of what he expects to be the DNA of a dinosaur. With the hel...
user: Generate an executable Python 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 containing positive integers. Count number of smaller elements on right side of each array element. Examp...
user: Generate an executable Python 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 Tree of size N. Find the sum of all the leaf nodes that are left child of their parent of the given binary tree. Exampl...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Roy has taken a liking to the Binary Search Trees(BST). He is interested in knowing the number of ways an array $\mbox{A}$ of $N$ 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.Given a linked list of N nodes where nodes can contain values 0s, 1s, and 2s only. The task is to segregate 0s, 1s, and 2s linked list...
user: Generate an executable Python 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’s time to find out which player is consistent in cricket. You need to calculate the average of a player based on his score. Player ...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Janmansh is at the fruit market to buy fruits for Chingari. There is an infinite supply of three different kinds of fruits with prices...
user: Generate an executable Python 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 last worker in a production line at the factory of Automated Composed Machinery is worried. She knows that her job hangs in the ba...
user: Generate an executable Python 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, denoting the number of people who needs to be seated, and a list of m integers seats, where 0 represents 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.Chef is deriving weird ways to sort his array. Currently he is trying to sort his arrays in increasing order by reversing some of his ...
user: Generate an executable Python 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 only difference between the two versions is that the harder version asks additionally 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.As usual Alice and bob are playing a game. Alice will always take the first turn, after which they will take alternate turns and playe...
user: Generate an executable Python 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 Chessboard Distance for any two points (X_{1}, Y_{1}) and (X_{2}, Y_{2}) on a Cartesian plane is defined as max(|X_{1} - X_{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.Now Mr. MAZ is running short on sleeping pills, so he is searching them from planets to planets. Finally he reaches the planet where 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.Given a string s, extract all the integers from s. Example 1: Input: s = "1: Prakhar Agrawal, 2: Manish Kumar Rai, 3: Rishabh 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.Given a binary array A[] of size N. The task is to arrange the array in increasing order. Note: The binary array contains only 0 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.Every day, Danny buys one sweet from the candy store and eats it. The store has $m$ types of sweets, numbered from $1$ to $m$. Danny k...
user: Generate an executable Python 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. Construct a permutation P of length N such that For all i (1 ≤ i ≤ N-1), i divides abs(P_{i+1}-P_{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.Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well. Daanish as always is busy cre...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.You have a knapsack with the capacity of $W$. There are also $n$ items, the $i$-th one has weight $w_i$. You want to put some of thes...
user: Generate an executable Python 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 where each element (arr[i]) represents the height of the tower. Find for each tower, the nearest possible tower that 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.Young Mislav loves spending time in nature and, most of all, he loves spending time in forests. The fresh air and lovely sounds make 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 rooted tree with $n$ nodes. The nodes are numbered $1..n$. The root is node $1$, and $m$ of the nodes are colored red,...
user: Generate an executable Python 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 maximum possible area of the right angle triangle for a fixed length of hypotenuse. The task is to find the length of hypote...
user: Generate an executable Python 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. Find if it is possible to represent N as the sum of several(possibly zero) 2's and several(possibly zero) ...
user: Generate an executable Python 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, starting from 1 to N. At each iteration, you remove all elements at odd positions, until only one element ...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.View Russian Translation Probably, you have already read some problems but you still have not met any problems with queries on segmen...
user: Generate an executable Python 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 sorted array arr[] of size N and a number X, find a pair in array whose sum is closest to X. Example 1: Input: N = 6, X = 54 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 n integer ranges, the task is to find the maximum occurring integer in these ranges. If more than one such integer exists, 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.Given a Undirected Graph with V vertices and E edges, Find the level of node X. if X does not exist in the graph then print -1. Note: ...
user: Generate an executable Python 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 asked to write a program that takes an array A of length N and two integers X, Y as input and modifies it as follows: 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.You have a set of birthday cake candles. Each of such candles represents a digit between 0 and 9, inclusive. <image> Example of birth...
user: Generate an executable Python 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 very fond of ice-creams. He bought himself N ice-creams of two types which are represented in the form of string of 0'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.Read problems statements in [Mandarin Chinese], [Russian], [Vietnamese] and [Bengali] as well. Suppose the population is divided into...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Chandler has a set of N numbers and his company has given him a task to find a number P which has its proper factors as the given numb...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Given a directed graph with V nodes and E edges. If there is an edge from u to v then u depends on v. Find out the sum of dependencies...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Ehsan loves geometry! Especially he likes to rotate points! Given a point in the plane, Ehsan likes to rotate it by k degrees (counte...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Recently, Polycarp has been a fan of cinema novelties and is trying not to miss them! In the near future, n new movies will be releas...
user: Generate an executable Python 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 lives in Chefcity. Chefcity can be represented as...
user: Generate an executable Python 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 sum of length, breadth and height of a cuboid. The task is to find the maximum volume that can be achieved such that the sum...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.You have a 2D rectangular grid. Each grid cell contains either an apple, an obstacle, or is empty. Empty cells are denoted as ’.’, app...
user: Generate an executable Python 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 X and Y, and two values costX and costY, the task is to find the minimum cost required to make the given two strings...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Rhezo calls a number good if the number is divisible by all numbers from 1 to 9. His father also likes good numbers, and has promised ...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.There is an old adage about opening a can of worms. A lesser known adage is one about shooting a can of exploding worms with a BB gun....
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Archana is very fond of strings. Help her to solve a problem. The problem is as follows:- Given is a string of length L. Her task 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.The link to the Russian translation. Alex has opened the evil vault and is looking for her sister. The vault is evil and has an unsta...
user: Generate an executable Python 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 is very fond of balloons. Once he visited an amusement park with his mother. The mother told Bob that she would buy him a balloon ...
user: Generate an executable Python 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 section assumes that you understand the basics discussed in HTML Parser - Part 1 .handle_comment(data) This method is called ...
user: Generate an executable Python 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 and Chefina are playing a game. There are two piles numbered 1 and 2. Pile 1 contains X stones while Pile 2 contains Y stones. ...
user: Generate an executable Python 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 minimum number which is divisible by all numbers from 1 to n. Print the answer modulo (10^{9}...
user: Generate an executable Python 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 Birthday Paradox is the name given to the surprising fact that if there are just $23$ people in a group, there is a greater than $...
user: Generate an executable Python 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 BST, transform it into greater sum tree where each node contains sum of all nodes greater than that node. Example 1: Input: ...
user: Generate an executable Python 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 a chessboard with $N$ rows and just three columns. Slavica has written an integer on each field. Mirko has $K$ dominoes at 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.Read problems statements in Mandarin Chinese and Russian as well. Given n words w[1..n], which originate from the same stem (e.g. gr...
user: Generate an executable Python 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 integers X and Y. Chef wants to perform some operations to make X and Y equal. In one operation, Chef can either: set 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 full-board residents of the famous but misnamed Adephagia School For Boys feel hard done by. Recent savings have seen dinnertime 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.Given N people standing in a circle where 1^{st} is having a sword, find the luckiest person in the circle, if, from 1^{st} soldier 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.Given binary string s consisting of 0s and 1s only. You are allowed to do exactly one move that is you have to choose two indices i 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 loader works in a warehouse, which is a rectangular field with size n × m. Some cells of this field are free, others are occupied 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.The game of Memory is played with $N$ pairs of cards where each pair has the same picture, i.e. there are $N$ different pictures, 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 a singly linked list. The task is to find the length of the linked list, where length is defined as the number of nodes in the l...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Given N, check whether it is a Narcissistic number or not. Note: Narcissistic Number is a number that is the sum of its own digits 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.You are given two arrays A and B of equal length N. Your task is to pair each element of array A to an element in array B, such that 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.Given an integer N, print an inverted isosceles triangle of stars such that the height of the triangle is N. Example 1: Input: N = 4...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Polycarp was given a row of tiles. Each tile contains one lowercase letter of the Latin alphabet. The entire sequence of tiles forms 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.As summer vacations are going on and as usual Chintu and Pintu are in village at their maternal grand-parent's home to spend their sum...
user: Generate an executable Python 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 coins and K people. Each of them can propose a method of distribution of the coins amongst themselves when their chance co...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Given three integers N, M, and K. Lets Sum(N) be a function that calculates twice the sum of first N natural numbers. Calculate Sum(K+...
user: Generate an executable Python 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 Lists of strings s1 and s2, you have to count the number of strings in s2 which is either a suffix or prefix of at least 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.A nice part of the Roman Catholic Mass is the rite of peace when people shake hands with their neighbours and say “peace be with 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.It was time for the 7th Nordic Cinema Popcorn Convention, and this year the manager Ian had a brilliant idea. In addition to the tradi...
user: Generate an executable Python 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 classic video game “Prince of Python” comprises $n$ levels, numbered from $1$ to $n$. You are going to speedrun this game by finis...
user: Generate an executable Python 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, there are a lot of unusual people. We won’t go into details, but instead focus on a certain type, to us personally the most ...
user: Generate an executable Python 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 as a string S. Calculate difficulty of a given sentence. Difficulty of sentence is defined as 5*(number of hard word...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.2048 is a single-player puzzle game created by Gabriele Cirulli1. It is played on a $4 \times 4$ grid that contains integers $\geq 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.- Percent sign sand dollar sign! And colon semicolon, too! - You Asterisk-mouth! – Sam & Max: Hit the Road When typing SMS message...
user: Generate an executable Python 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. "But I’m no longer the troubl...
user: Generate an executable Python 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 developing software to stream music to users over the Interwebs. In order to reduce network traffic for your servers, you plan...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Grey Worm has learnt that Daario Naharis's Second Sons have combined with his Unsullied to improve Daenerys's strength. The combined 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 particular month has 30 days, numbered from 1 to 30. Day 1 is a Monday, and the usual 7-day week is followed (so day 2 is Tuesday, ...
user: Generate an executable Python 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 Duck number is a positive number which has zeroes present in it, For example, 3210, 8050896, 70709 are all Duck numbers. A number wi...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Sandra recently bought her first smart phone. One of her friends suggested a long list of applications (more commonly known as “apps”)...
user: Generate an executable Python 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 close friend of yours, a duck with financial problems, has requested your help with a matter that will help him pay off his debts. 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.Geek has an array of N non-overlapping intervals intervals where intervals[i] = [start_{i}, end_{i}] represent the start and the end 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.There is a string $s$ of length $3$, consisting of uppercase and lowercase English letters. Check if it is equal to "YES" (without quo...
user: Generate an executable Python 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 $n$ chains, the $i$-th chain consists of $c_i$ vertices. Vertices in each chain are numbered independently from $1$ to $c_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.Naruto has recently joined the Ninja Academy for higher education, while filling the admission form he is required to choose minimum $...
user: Generate an executable Python 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 table, $a$, with $n$ rows and $m$ columns. The top-left corner of the table has coordinates $(0,0)$, and the bottom-ri...
user: Generate an executable Python 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 with N positive elements A_{1}, A_{2}, \dots, A_{N}. You are also given a function S on any array C with leng...
user: Generate an executable Python 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 search tree. Your task is to complete the function which will return the Kth largest element without doing any modifica...
user: Generate an executable Python 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 s whose length is n and array queries of length q where each elements of queries is either of type 1 query or type 2 qu...
user: Generate an executable Python 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 been invited to host a famous radio show to tell your fascinating life story and play some of your favorite songs. However, 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 a string check if it is Pangram or not. A pangram is a sentence containing every letter in the English Alphabet (either lowercas...
user: Generate an executable Python 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 table $a$ of size $n \times m$. We will consider the table rows numbered from top to bottom from $1$ to $n$, and the 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 a number N, write a program to find a maximum number that can be formed using all of the digits of this number. Note: The 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.You’re one of the king’s spies sent on a secret mission to retrieve an item of incredible value, an ancient scroll from the throne 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 array A of size N, your task is to do some operations, i.e., search an element x, insert an element y at index yi, and delete an element z by completing the functions...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Sherlock is given an array of $N$ integers ($A_0,A_1...A_{N-1}$ by Watson. Now Watson asks Sherlock how many different pairs of indice...
user: Generate an executable Python 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 got a maze, which is a n*n Grid. Every cell of the maze contains these numbers 1, 2 or 3. If it contains 1 : means we can go...