formatted_conversations
stringlengths
1.13k
138k
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Geek is given a task to select at most 10 employees for a company project. Each employee is represented by a single digit ID number which is unique for all the selected employ...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Celery — the legendary Pokenom has been spotted in Alexa Forest. To become the best Pokenom trainer, Bash has arrived at Alexa Forest...
user: Generate an executable Python 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 Chinese], [Russian], and [Vietnamese] as well. Chef has been studying the human sleep cycle 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.Tetris is a popular computer game played in a field consisting of $C$ columns and an unlimited number of rows. In one move, one of the...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Read problem statements in [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well. There are N breakfasts in the restaura...
user: Generate an executable Python 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 called A[] of sorted integers having no duplicates, find the length of the Longest Arithmetic Progression (LLAP) in it....
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Given a sorted and rotated array A of N distinct elements which are rotated at some point, and given an element K. The task is to find the index of the given element K in 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.In a planet far far away, an intelligence agency plans to send some spies to the Earth to investigate the life there. In order to ensu...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Note: This POTD is a part of Geek Summer Carnival. Solve all POTD consecutively from 5th to 10th April and get a chance to win exclusi...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Given an array of integers, find the longest subarray where the absolute difference between any two elements is less than or equal 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.Description Blithchron is the annual cultural festival of IIT Gandhinagar. A popular event in Blithchron is Adrenaline - a treasure hu...
user: Generate an executable Python 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 recent schoolboard elections were hotly contested: a proposal to swap school start times for elementary and high school students, ...
user: Generate an executable Python 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. Find the kth distinct element. Example 1: Input: n = 6, k = 2 arr = {1, 2, 1, 3, 4, 2} Output: 4 Explan...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.The mayor of Farzville is studying the city's road system to find ways of improving its traffic conditions. Farzville's road system 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 two sorted arrays(arr1[] and arr2[]) of size M and N of distinct elements. Given a value Sum. The problem is to count all pairs ...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.CQXYM is counting permutations length of $2n$. A permutation is an array consisting of $n$ distinct integers from $1$ to $n$ in arbit...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Asha is an aspiring mathematician. One day she discovered numbers that she calls prosperous numbers. A prosperous number is a positive...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Fillomino is a classic logic puzzle. (You do not need to know Fillomino in order to solve this problem.) In one classroom in Yunqi tow...
user: Generate an executable Python 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 of words where each word consists of lowercase English letters. word_{A} is a predecessor of word_{B} if and 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.Chef has three numbers A, B, and C. He can do the following type of operation: Select two numbers amongst A, B, and C; Add 1 to the 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.Suppose $a_1, a_2, \dots, a_n$ is a sorted integer sequence of length $n$ such that $a_1 \leq a_2 \leq \dots \leq a_n$. For every $1 ...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Given below is a binary tree. The task is to print the top view of binary tree. Top view of a binary tree is the set of nodes visible ...
user: Generate an executable Python 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. You are given two positive in...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Coach Chef has selected all the players and now he has to separate them into 2 teams, $A$ and $B$. Each player must be included in ex...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Read problems statements in Mandarin Chinese and Russian as well. John's barn has a fence consisting of N consecutive parts numbered...
user: Generate an executable Python 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 when Ravi studied in the first year at school, his teacher gave the class the following homework. She offered the students a 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.Read problems statements [Hindi] ,[Bengali] , [Mandarin chinese] , [Russian] and [Vietnamese] as well. There are $N$ circles in a pla...
user: Generate an executable Python 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. You are given two strings $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.Link to Russian translation of the problem. Kevin has a lot of permutations, but he doesn't like them. Therefore, he wants to give so...
user: Generate an executable Python 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 strings S, oldW and newW. Find all occurrences of the word oldW in S and replace them with word newW. Example 1: Input: 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.While debugging a program Mirko noticed that a bug in the program may be linked with the existence of so called square killers in the ...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Given an array arr[ ] of N elements, your task is to find the minimum number of increment operations required to make all the 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.Daisy loves playing games with words. Recently, she has been playing the following Deletive Editing word game with Daniel. Daisy pick...
user: Generate an executable Python 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, being a Chess fan, was thrilled after he read the following news: [Michael Simkin, a postdoctoral fellow at Harvard University’...
user: Generate an executable Python 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 bucket having a capacity of K liters. It is already filled with X liters of water. Find the maximum amount of extra water...
user: Generate an executable Python 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 say you are standing on the $XY$-plane at point $(0, 0)$ and you want to reach point $(n, n)$. You can move only in two directi...
user: Generate an executable Python 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 captain of your space ship you have never encountered a more fierce enemy than the one you have snuck upon now. You immediately bri...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Unfortunately Crookshanks(Laurent's cat) has eaten the problem statement. Are you good enough to solve it without the statement? Inpu...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.You are given a set of N types of rectangular 3-D boxes, where the ith box has height h, width w and length l. Your task is to create ...
user: Generate an executable Python 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 challenge is only forPython 2. input() In Python 2, the expression input() is equivalent to eval(raw _input(prompt)). Code >...
user: Generate an executable Python 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 Computer Science Engineer from SKIT has been assigned a problem by his Maths Lecturer to find the number of pairs (a,b) within a giv...
user: Generate an executable Python 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 N integers, the task is to find the number of pairs in the array whose XOR is odd. Example 1: Input: N = 3, ar...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.This is the easy version of the problem. The only difference is that in this version $n \leq 2000$. You can make hacks only if both ve...
user: Generate an executable Python 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 keypad as shown in the diagram, and an N digit number which is represented by array a[ ], the task is to list all words which ...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Chinnu plans a get together on her birthday. To avoid her buddies from getting bored, she asks Chinna to come up with some interesting...
user: Generate an executable Python 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, your task is to print the Nth non Fibonacci number. The Fibonacci numbers are defined as: Fib(0) = 0 Fib(...
user: Generate an executable Python 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 in the input, find its next sparse binary number.A sparse binary number is a number whose binary representation doe...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Sevenkplus was interested in contributing a challenge to hackerrank and he came up with this problem. You are given a linear congrue...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Jim is doing his discrete maths homework which requires him to repeatedly calculate ^{n}C_{r}(n choose r) for different values of n. 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.Today is the day of the CCDSAP exam. Chef is responsible for monitoring the exam. The hall in which the exam will be held contains $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.On every CodeChef user's profile page, the list of problems that they have set, tested, and written editorials for, is listed at the b...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Nathaniel collects rare gems and minerals, and has decided he has to protect his valuable collection from thieves. He is installing 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.Every modern car has an odometer. It measures how far the car has traveled, and is used, among other things, to decide when to service...
user: Generate an executable Python 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. Consider an array arr having N elements where arr[i] = 2*i+1. (The array is 0-indexed) You are allowed 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.Lea runs into a lot of words in her life. A lot of them she finds unpleasant. To compensate for that she started making up pleasant 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.Remember the busy boards for toddlers that have an array of holes into which to hammer pegs of various shapes? There’s a new, electron...
user: Generate an executable Python 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$ strings $s_1, s_2, \dots, s_n$ of length at most $\mathbf{8}$. For each string $s_i$, determine if there exist two ...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Hackerland is a one-dimensional city with houses aligned at integral locations along a road. The Mayor wants to install radio transmit...
user: Generate an executable Python 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 screen containing alphabets from a-z, we can go from one character to another character using a remote. The remote contains le...
user: Generate an executable Python 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 clique in a graph is set of nodes such that there is an edge between any two distinct nodes in the set. Finding the largest clique 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.Given two integer numbers, F and S. In binary form of the numbers, for every i^{th }set bit in F, negate the i ^{th }bit in S. Example...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Pero is a passionate lover of riddles. The newest type of riddles he has come across requires the solver to check whether the given wo...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Given two strings S1 and S2 in lowercase, the task is to make them anagram. The only allowed operation is to remove a character from any string. Find the minimum number of cha...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Pak Chanek has $n$ two-dimensional slices of cheese. The $i$-th slice of cheese can be represented as a rectangle of dimensions $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.As a new employee at the Northwestern Europe Routing Company (NWERC), you do a lot of thinking about wireless network architectures. 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.Tsetso likes to play with arrays. An Array A[1,2,\ldots,N] is said to be a Tsetso array if A[1] \cdot A[N] = max(A_{1},A_{2},\ldots,...
user: Generate an executable Python 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, find the sum of odd numbers and even numbers from 1 to N. Example 1: Input: 5 Output: 9 6 Explanation: Odd numbe...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.For any two given positive integers p and q, find (if present) the leftmost digit in the number obtained by computing the exponent 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 an unsorted array arr[] of n positive integers. Find the number of triangles that can be formed with three different array 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.Given a sentence containing several words and numbers. Find the largest number among them which does not contain 9. Example 1: Input:...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Given an array, rotate the array by one position in clock-wise direction. Example 1: Input: N = 5 A[] = {1, 2, 3, 4, 5} Output: 5 1 2 3 4 Example 2: Input: N = 8 A[] = {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.In computing, the collection of four bits is called a nibble. Chef defines a program as: Good, if it takes exactly X nibbles of memor...
user: Generate an executable Python 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 a contract to build towers in Chefland which are made by stacking blocks one above the other. Initially, there is only 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.Well, it’s time. Andrew has been accumulating file after file on his computer and could never bring himself to delete any single one 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 N, the number of plots on either sides of the road. Find the total ways to construct buildings in the plots such that there is 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.Simon Haples is a somewhat peculiar person. Not quite hip, not quite square, he is more of a triangular nature: ever since childhood, ...
user: Generate an executable Python 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 likes cooking. But more than that, he likes to give gifts. And now he wants to give his girlfriend an unforgettable gift. But unf...
user: Generate an executable Python 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 interesting theory in mathematics is that there is a sequence generator that, given any positive integer as the starting point, alw...
user: Generate an executable Python 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 undirected connected graph of n vertices and list of m edges in a graph and for each pair of vertices that are connected by 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 and his friends would like to attend a large New Year's party in Goa. However, their teacher has given them an assignment to comp...
user: Generate an executable Python 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 Singly Linked List of N and M nodes respectively. The task is to check whether two linked lists are identical or not. Two 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 two positive integers a and b, we define f(a, b) = \text{lcm}(a, b) - \gcd(a, b), where \text{lcm} denotes the [lowest common mu...
user: Generate an executable Python 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 Sam has a special liking for numbers as well as the famous Movie and TV-Series TRANSFORMERS. He has a weird perspective of seei...
user: Generate an executable Python 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 a number in form of its binary representation S, having length N. Determine if the number can be represented as a sum 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.When constructing electric circuits one has to connect pairs of points using wire, preferable as short as possible. In this problem we...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Ishaan has bought N lottery tickets each having an ID denoted by an array A. As a result comes out, Ishaan gets very lucky and gets to know that each one of his tickets has 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.You are the owner of a harvesting field which can be modeled as an infinite line, whose positions are identified by integers. It will...
user: Generate an executable Python 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 make a purchase. For this, he needs X gold coins, but he has none at the moment. Chef has N fixed deposits, the i^{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.There are n customers in the cafeteria. Each of them wants to buy a hamburger. The i-th customer has a_i coins, and they will buy a 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.There are n cities connected by some number of cars. You are given an array of cars where cars[i] =[from_{i},to_{i},cost_{i}] indicate...
user: Generate an executable Python 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 to work on a project for the next N hours. He is given a work plan to do this, which is given to you as a binary string S 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.Consider a rat placed at (0, 0) in a square matrix of order N * N. It has to reach the destination at (N - 1, N - 1). Find all possibl...
user: Generate an executable Python 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 of integers, find the distinct index of values that satisfy A + B = C + D where A,B,C & D are integers value...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.A number n can be broken into three parts n/2, n/3, and n/4 (consider only the integer part). Each number obtained in this process can...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Given an array of integer $a_1, a_2, \ldots, a_n$. In one operation you can make $a_i := a_i + 1$ if $i < n$ and $a_i \leq 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.Read problems statements in Mandarin Chinese, Russian and Vietnamese as well. Sereja has an undirected graph on N vertices. There ar...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Last summer, Feluda gifted Lalmohan-Babu a balanced bracket sequence $s$ of length $2 n$. Topshe was bored during his summer vacation...
user: Generate an executable Python 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 cards on a table, out of which X cards are face-up and the remaining are face-down. In one operation, we can do the follo...
user: Generate an executable Python 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 doubly linked list and a position. The task is to delete a node from given position in a doubly linked list. 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.The Vietnamese High School graduation exam is in progress! For most Vietnamese high school students, this is their most important exam...