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.You start with an array A of size N. Initially all elements of the array A are zero. You will be given K positive integers. Let j be 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.Anthony recently started watching YouTube videos with the title “$X$ but every time $Y$ happens it speeds up by $Z$”. He likes watchin...
user: Generate an executable Python 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 Gridnavia, three languages are spoken: Arwegian, Banish, and Cwedish. Gridnavia consists of an $n \times m$ grid, where at least 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.Given a number N in the form of string, the task is to check if the number is divisible by 5. Example 1: Input: N = "5" Output: 1 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 a Binary Tree (BT), convert it to a Doubly Linked List(DLL) In-Place. The left and right pointers in nodes are to be used as pre...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Frida is a writer for Cosmopolitan who writes restaurant reviews. She enjoys it a lot, but it seems that, throughout the years, she 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.Alice initially has a string S of length N, and she decides to modify it! Her modification consists of K steps numbered from 1 to K. 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.Taum is planning to celebrate the birthday of his friend, Diksha. There are two types of gifts that Diksha wants from Taum: one is bla...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Queen of westeros is known for her dragons and magic. To control her dragons she speaks random but powerful words. The strength of her...
user: Generate an executable Python 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 three integers $A$, $B$ and $C$. The numbers will not be given in that exact order, but we do know that $A$ is less ...
user: Generate an executable Python 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 a and b. Check whether they contain any common subsequence (non empty) or not. Example 1: Input: a = "ABEF" b = "CAD...
user: Generate an executable Python 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 a string S with him. Chef is happy if the string contains a contiguous substring of length strictly greater than 2 in which 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 two integers m & n, find the number of possible sequences of length n such that each of the next element is greater than or equa...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Priyanka works for an international toy company that ships by container. Her task is to the determine the lowest cost way to combine ...
user: Generate an executable Python 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 school morning Mirko is woken up by the sound of his alarm clock. Since he is a bit forgetful, quite often he leaves the alarm 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 number N , calculate total number of permutations of it and also the sum of all permutations including that number itself. 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.Wabbit is playing a game with $n$ bosses numbered from $1$ to $n$. The bosses can be fought in any order. Each boss needs to be defeat...
user: Generate an executable Python 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$ be a string of lowercase Latin letters. Its price is the sum of the indices of letters (an integer between 1 and 26) that 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.Read problems statements in Mandarin Chinese, Russian and Vietnamese as well. Chef has a standard chocolate of n by m pieces. More f...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Mary has an $n\times m$ piece of paper that she wants to cut into $1\times1$ pieces according to the following rules: She can only cu...
user: Generate an executable Python 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 smallest number that can be framed using the series created by the digits obtained by raising the given number ( "a" ) 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.\textit {Life is change, change is stability.} Chef calls a sequence of integers A_{1}, A_{2}, \ldots, A_{N} stable if all the eleme...
user: Generate an executable Python 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: an array $a$ consisting of $n$ zeros and an array $b$ consisting of $n$ integers. You can apply the followi...
user: Generate an executable Python 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 dots that form a triangle such that i^{th }line contains i number of dots. . . . . . . . . . . Find the minimum hieg...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Recall that a subsequence of a string is any string obtained by removing some subset of characters from the string, for instance “stri...
user: Generate an executable Python 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 large-scale conference on unnatural sciences is going to be held soon in Berland! In total, n scientists from all around the world 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.Once upon a time in a land far far away, inhabited only by math students, Iva and Vedran were discussing self-explanatory sentences. 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 Undirected Graph having unit weight, Find the shortest path from src to all the vertex and if it is unreachable to re...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Petar is throwing a birthday party and he decided to invite some of the employees of his company where he is the CEO. Each employee, ...
user: Generate an executable Python 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 users registered on a website CuteKittens.com. Each of them has a unique password represented by pass[1], pass[2], ..., pa...
user: Generate an executable Python 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 infinite number of cities in Geekland numbered from 1 onward. Some of them are connected via bidirectional railway tracks. 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 a floor of size n x m and tiles of size 1 x m. The problem is to count the number of ways to tile the given floor using 1 x m ti...
user: Generate an executable Python 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, the task is to complete the function maxPalindrome() which returns an integer denoting the length of the longest...
user: Generate an executable Python 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 set, $\mbox{S}$, consisting of $\boldsymbol{\mbox{k}}$ integers. The set is beautiful if at least one of the following cond...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Deepankar loves to play with the arrays a lot. Today, he has an array A of N integers. He has to fulfill M operations. Each 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.Given a binary tree, print the bottom view from left to right. A node is included in bottom view if it can be seen when we look at 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.HTML Generator Sample Page Yesterday night while walking under the street lights, We saw a drunk man. ...
user: Generate an executable Python 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 positive integer N, return its corresponding column title as it would appear in an Excel sheet. For N =1 we have column A, 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.Jay runs a small carnival that has various rides and attractions. Unfortunately, times are tough. A recent roller coaster accident, fl...
user: Generate an executable Python 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 of lowercase english characters, find out whether the summation of X and Y is even or odd, where X is the count of di...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Monica decides that she would like to get to know the neighbours in the apartment better. She makes a batch of wonderful chocolates 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.Utkarsh is forced to play yet another game with Ashish. In this game there are N piles, i^{th} pile contains A_{i} stones. Utkarsh mo...
user: Generate an executable Python 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 distinct integers, find all the pairs having both negative and positive values of a number in the array. Example 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.The absolute difference is the positive difference between two values $\boldsymbol{a}$ and $\boldsymbol{b}$, is written $\left|a-b\rig...
user: Generate an executable Python 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 $n$-queens problem is popular among computer science students. Its task is to place a maximum number of queens on an $n\times n$ 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.Read problems statements in [Hindi], [Mandarin Chinese], [Russian], [Vietnamese] and [Bengali] as well. The UEFA Champions League 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.$n$ people live on the coordinate line, the $i$-th one lives at the point $x_i$ ($1 \le i \le n$). They want to choose a position $x_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.Given two string, represented as linked lists (every character is a node->data in the linked list). Write a function compare() that wo...
user: Generate an executable Python 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 integer numbers from 1 to nm was put into rectangular table having n rows and m columns. The numbers was put from left to right, f...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.You are given a string $s$, consisting of lowercase Latin letters. Every letter appears in it no more than twice. Your task is to rea...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.To access CRED programs, one needs to have a credit score of 750 or more. Given that the present credit score is X, determine if 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.One of the most difficult things about going on a holiday is making sure your luggage does not exceed the maximum weight. You, chairma...
user: Generate an executable Python 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, sort it in the following manner. Sorted string must contain a vowel as first letter and a consonant as next letter 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 a N*M matrix of ones and zeros, return how many square submatrices have all ones. Example 1: Input: N = 3 M = 4 matrix [ ][ ] = ...
user: Generate an executable Python 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 x N matrix, mat[N][N] of integers. The task is to find the maximum value of mat(c, d) mat(a, b) over all choices of indexes...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Alex is attending a Halloween party with his girlfriend, Silvia. At the party, Silvia spots the corner of an infinite chocolate bar (t...
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 arr consisting of integers of size n and 2 additional integers k and x, you need to find the number of subsets of this array of size k, where Absolute differenc...
user: Generate an executable Python 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 N * N matrix, U. You have to choose 2 sub-matrices A and B made of only 1s of U, such that, they have at least 1 cell ...
user: Generate an executable Python 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 wants to gift C chocolates to Botswal on his birthday. However, he has only X chocolates with him. The cost of 1 chocolate is Y...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Given a list of names, display the longest name. Example: Input: N = 5 names[] = { "Geek", "Geeks", "Geeksfor", "GeeksforGeek", "Gee...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Robot Turtles is one of Theta’s favorite games. In this game, kindergarteners learn how to “code” by creating programs that move a tur...
user: Generate an executable Python 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 only difference between the two versions is that this version asks the maximal possible answer. Homer likes arrays a lot. Today 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 [Mandarin] , [Bengali] , [Hindi] , [Russian] and [Vietnamese] as well. There are three friends; let's call 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.Chef wants to give a burger party to all his N friends i.e. he wants to buy one burger for each of his friends. The cost of each bur...
user: Generate an executable Python 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 word pat and a text txt. Return the count of the occurrences of anagrams of the word in the text. Example 1: Input: txt = forx...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Himanshu is quite a lucky person, or atleast he claims to be. Recently, he has started some research work in college and guess 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.Your factory has $N$ junctions (numbered from $1$ to $N$) connected by $M$ conveyor belts. Each conveyor belt transports any product a...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.There are $n$ boxes with different quantities of candies in each of them. The $i$-th box has $a_i$ candies inside. You also have $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.Teja likes cricket very much and likes to watch it all the time, but he is bored of watching the matches alone and asks his friend 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.Ram has a candy bar that he really wants to eat. However, there is a polynomial written on the wrapper which he has to solve. If he do...
user: Generate an executable Python 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 test for allergy is conducted over the course of several days, and consists of exposing you to different substances (so called aller...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Thore is a fashionable man. Every time he meets up with his programming team, he wears his hot pink team hoodie over a salmon colored ...
user: Generate an executable Python 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 of N integers. Two players play a game with the array in turns. The game aims to make the array equal. Players add 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 an experienced investor who is investing in multiple companies. At the end of the year you are expected to file your taxes, 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.Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well. Chef is playing a card game 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.You are given a N \times N grid. You need to fill each cell of the grid with 1 or -1. You need to fill the grid in a way such that 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.Given a binary string S. The task is to count the number of substrings that start and end with 1. For example, if the input string 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.You are given an array A of size N. Output the maximum value of A[i]%A[j] (ie. A[i] mod A[j]) over all 1 ≤ i, j ≤ N. ------ 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.On a circle lie $2n$ distinct points, with the following property: however you choose $3$ chords that connect $3$ disjoint pairs of 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.Given a number N, check if a number is perfect or not. A number is said to be perfect if sum of all its factors excluding the number 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.You are given an array Arr of size N. You have to find the K-th largest sum of contiguous subarray within the array elements. 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.A large network of criminals is working under JOKER to destroy and demolish Gotham city. Captain Gordon is quite tensed about what the...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Adobe wants to play a game. He is given a number N. He has to create a alphabetical string in lower case from that number and tell whether the string is palindrome or not. 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.In fact, the problems E1 and E2 do not have much in common. You should probably think of them as two separate problems. You are 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.Markov takes out his Snakes and Ladders game, stares at the board and wonders: "If I can always roll the die to whatever number I wa...
user: Generate an executable Python 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 array is a type of data structure that stores elements of the same type in a contiguous block of memory. In an array, $A$, of size ...
user: Generate an executable Python 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 the stock market, a person buys a stock and sells it on some future date. Given the stock prices of N days in an array A[ ] and a p...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Let's define the function F(l,r) : F(l,r) = \sum x, \forall x , where x is a prime number between l and r inclusive. In Short,...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.N teams have come to participate in a competitive coding event called “Binary Battles”. It is a [single-elimination tournament] consis...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.NIT, the cleaver, is new in town! Thousands of people line up to orz him. To keep his orzers entertained, NIT decided to let them solv...
user: Generate an executable Python 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. There's an array A consisting of N non-zero integers 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 have a sequence 2,5,16,65,........Given an integer n as input. You have to find the value at the nth position in the sequence. 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.Read problems statements in [Hindi], [Mandarin Chinese], [Russian], [Vietnamese], and [Bengali] as well. You are given a string $S$ 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.Little chief has his own restaurant in the city. There are N workers there. Each worker has his own salary. The salary of the i-th wor...
user: Generate an executable Python 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 grid of n*m. Find the distance of the nearest 1 in the grid for each cell. The distance is calculated as |i_{1} - i_{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.You are batting at the pitch and all eyes are on you, the best player in all of IPL! The opposing team will relentlessly bowl at you 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.Read problems statements in Mandarin Chinese, Russian and Vietnamese as well. Little Egor likes to play with positive integers and th...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Ellen is teaching elementary math to her students and the time for the final exam has come. The exam consists of $n$ questions. In 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 have a string $s$ consisting of digits from $0$ to $9$ inclusive. You can perform the following operation any (possibly zero) 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.You are provided an unlimited collection of red, green and blue balls. Now your task is to arrange N balls taken from this collection ...