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.Polycarp is the project manager in the IT-company. Right now, he needs to choose developers for his team to start a new project. 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.Chef has an array of N integers. Chef can rearrange this array in any manner. Chef doesn’t like the array if any two adjacent elemen...
user: Generate an executable Python 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. The following is an easy game that the setter of this problem played when...
user: Generate an executable Python 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. You have to find the number of digits that appear in its factorial, where factorial is defined as, factorial(N) = ...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Read problem statements in [Mandarin], [Vietnamese], and [Russian] as well. Chef has an array A of length N. Since Chef's favorite 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.There is an array $a$ of length $n$. You may perform the following operation any number of times: Choose two indices $l$ and $r$ wher...
user: Generate an executable Python 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 switching buildings, he loses height $\boldsymbol{I}$ while jumping. The second restriction is explained below with an 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.Read problems statements in mandarin chinese, russian and vietnamese as well. Though our Head Chef retired from sport programming lo...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Have you ever wished to be given a direct problem statement in the contest? Do you hate the boring stories that problem setters write....
user: Generate an executable Python 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 of length N, made up of only uppercase characters 'R' and 'G', where 'R' stands for Red and 'G' stands for Green.Find 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 Binary Search Tree and a target sum. Check whether there's a pair of Nodes in the BST with value summing up to the target 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.Given an unsorted array Arr[] of N integers and a Key which is present in this array. You need to write a program to find the start 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.The task is to find the smallest number with given sum of digits as S and number of digits as D. Example 1: Input: S = 9 D = 2 Outp...
user: Generate an executable Python 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. We have to find maximum sum of all permutations of numbers from 1 to N. The maximum sum will be sum of absolute diff...
user: Generate an executable Python 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 hiring team aims to find 3 candidates who are great collectively. Each candidate has his or her ability expressed as an integer. 3...
user: Generate an executable Python 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 A and B. Your task is to return their product. Example 1: Input: A = 1, B = 2 Output: 2 Explanation: Multiplicati...
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 integer array. We need to make array elements distinct by increasing values and keeping the array sum minimum possible. We need to print the minimum possible su...
user: Generate an executable Python 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 is playing a video game that contains N monsters having varying power denoted by power[i]. Geek will play total Q rounds and 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.The kingdom of Zion has cities connected by bidirectional roads. There is a unique path between any pair of cities. Morpheus has foun...
user: Generate an executable Python 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 is in a geekland which have a river and some stones in it. Initially geek can step on any stone. Each stone has a number on it 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.Chef loves problems about digits and he came up with an interesting one. Chef has given you two integers N and K. You should find 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.Providing wireless network coverage for a large office can be tricky. In this problem you are asked to set up wireless network coverag...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.In this problem you will be solving one of the most profound challenges of humans across the world since the beginning of time – how 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.Find the number of positive integral solutions for the equations $\dfrac{1}{x}+\dfrac{1}{y}=\dfrac{1}{N!}$ Input Format An integer...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Given an positive integer N and a list of N integers A[]. Each element in the array denotes the maximum length of jump you can cover. ...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Using seven segment display, you can write down any digit from 0 to 9 using at most seven segments. Given a positive number N and then...
user: Generate an executable Python 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 elements. The task is to calculate the cumulative frequency of each element of the array. Note :- Cumulative frequen...
user: Generate an executable Python 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 number n and d. The task is to find the number between 0 to n which contain the specific digit d. Example 1 - Input...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Given an array A of N length. We need to calculate the next smallest greater element for each element in a given array. If the next greater element is not available in a given...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.The task is to find the second smallest number with a given sum of digits as S and the number of digits as D. Example 1: Input: S = 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.Monocarp is playing a computer game. In this game, his character fights different monsters. A fight between a character and a monster...
user: Generate an executable Python 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 *fuel economy* of a car is the distance which it can travel on one litre of fuel. The base fuel economy (i.e, its fuel economy 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 a sorted array with possibly duplicate elements. The task is to find indexes of first and last occurrences of an element X in 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.In a two player card game, you have $n$ minions on the board and the opponent has $m$ minions. Each minion has a health between $1$ 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.Alice and Bob love playing Don’tminion, which typically involves a lot of shuffling of decks of different sizes. Because they play 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.It is so boring in the summer holiday, isn't it? So Alice and Bob have invented a new game to play. The rules are as follows. First, 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.Tira would like to join a multiplayer game with $n$ other players. Each player has a character with some features. There are a total 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.Read problems statements [Hindi] , [Vietnamese] , [Mandarin Chinese] , [Russian] and [Bengali] as well. Raja only participates in con...
user: Generate an executable Python 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 sorted integers. The task is to find the closest value to the given number in array. Array may contain duplicate val...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Tywin Lannister is facing a war. He has N troops of soldiers. Each troop has a certain number of soldiers denoted by an array A. Tywin thinks that a troop is lucky if it has 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 matrix of size n x m with 0’s and 1’s , you enter the matrix at cell (0,0) in left to right direction. whenever you encounter ...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Our Chef is catering for a big corporate office party and is busy preparing different mouth watering dishes. The host has insisted tha...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Your friend is an organizer of the International Chess Playing Championship. He is worried that some of the contestants may be cheatin...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Vasya decided to go to the grocery store. He found in his wallet $a$ coins of $1$ burle and $b$ coins of $2$ burles. He does not yet 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 a permutation $a$ of length $n$. Recall that permutation is an array consisting of $n$ distinct integers from $1$ to $n$...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Read problems statements in Mandarin Chinese and Russian. Rupsa recently started to intern under Chef. He gave her N type of ingred...
user: Generate an executable Python 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, find its minimum depth. Example 1: Input: 1 / \ 3 2 / 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.The final of Berland Chess Team Championship is going to be held soon. Two teams consisting of n chess players each will compete for 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.Due to the rise of covid-19 cases in India, this year BCCI decided to organize knock-out matches in IPL rather than a league. Today 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.Today is external viva of computer science subject and Bosky is not at all prepared for it. Adding to his problems, he hasn't reached ...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Thrilled about his new valid set of pieces, Mirko rushed over to Slavko’s, to find that Slavko too found a set of chess pieces in 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.As you might already know, space has always been a problem in ICPC Jakarta. To cope with this, ICPC Jakarta is planning to build two n...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Given an integer N, print all the N digit numbers in increasing order, such that their digits are in strictly increasing order(from 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.There are K travellers who want to travel through a country one after the other. The country is in the form of a 2-d grid and is divid...
user: Generate an executable Python 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 coins of distinct denominations and total amount of money. Find the minimum number of coins required to make up that 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.Years after the Ishval Civil War, the Ishvalan refugees have now found a safe place for themselves which is a rectangular piece of lan...
user: Generate an executable Python 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. Find if it can be expressed as sum of two prime numbers. Example 1: Input: N = 34 Output: "Yes" Explanation: 34 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 a binary tree. Find the preorder traversal of the tree without using recursion. Example 1: Input: 1 / \ ...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Given a string str of lowercase ASCII characters, Count the number of distinct continuous palindromic sub-strings which are present 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.Read problems statements in Mandarin chinese, Russian and Vietnamese as well. Sheokand loves strings. Chef has $N$ strings $S_{1}, 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.Given an array of n distinct elements. Find the length of shortest unordered (neither increasing nor decreasing) sub array in given 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.Your are given N students with some goodies to be distrubuted among them such that student at i^{th} index gets exactly i amount of go...
user: Generate an executable Python 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 matrix of size n x m. Your task is to make Zeroes, that means in whole matrix when you find a zero, convert its upper, lower,...
user: Generate an executable Python 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 water company is trying to provide water from its pumping station to a mansion. The company owns $n$ water stations, numbered $1 \ld...
user: Generate an executable Python 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 enmity between Logan and Donald Pierce never ceases to exist. However, once Logan and Donald came face to face. Donald got agit...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Read problem statements in [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well. Chef is trying to invent the light bul...
user: Generate an executable Python 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 single day, $N$ of Luka’s trucks travel a specific highway. The highway has a number of exits and entrances. An exit with a parti...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.The teacher gives a mental ability question to Raju. The question is as follows:- Raju is in an elevator. Given by his teacher is an array of size N which denotes the number 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 2D matrix g contains only 1 and 0, count the number of triangles in it. Take 3 index i,j,k (0<=i,j,k<n). {i,j}, {j,k}, {k,i} 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.This is the easy version of the problem. The only difference is that in this version there are no "remove" queries. Initially you hav...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Arthur and his sister Carol have been playing a game called Nim for some time now. Nim is played as follows: - The starting position ...
user: Generate an executable Python 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 arrays of equal size N and an integer K. The task is to check if after permuting both arrays, we get sum of their correspond...
user: Generate an executable Python 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 X. The task is to find the smallest even number E such that E > X and all digits in X and E are the same. Not...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Read problems statements in Mandarin chinese, Russian and Vietnamese as well. You are given a string $S$ of lowercase English letter...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.God's Blessing on This PermutationForces! A Random Pebble You are given a permutation $p_1,p_2,\ldots,p_n$ of length $n$ and a posit...
user: Generate an executable Python 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 of non negative integers. We can perform a swap operation on any two adjacent elements in the array. 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.Given a positive integer n. The problem is to check whether only the first and last bits are set in the binary representation of n. 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.You all must be familiar with the chess-board having 8*8 squares of alternate black and white cells. Well, here we have for you a simi...
user: Generate an executable Python 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 Dobby loves playing games, especially games relat...
user: Generate an executable Python 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 arrays arr[ ] and peanlty[ ], each of size n. All elements in arr[ ] are in the range of 1 to n. You have to traverse arr[ ]...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Given two numbers X and N, find the smallest value of (N*K) which is closest to X. Where K is any positive number greater than zero. 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 a sequence A consisting of N integer elements: A1, A2, .., AN. Your task is to answer Q queries. Each query requires to count 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.Ani and his Favourite Chemistry Teacher Lissa were performing an Experiment in the Chemistry Lab. Experiment involves a N step Chemica...
user: Generate an executable Python 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, find the minimum characters to be added at front of the string to make it a palindrome. Example 1: Input: str = AB...
user: Generate an executable Python 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 and a key, count the number of occurrences of given key in the linked list. Example 1: Input: N = 7 Link Li...
user: Generate an executable Python 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 cards placed in front of you on the table. The i^{th} card has the number A_{i} written on it. In one move, you can remov...
user: Generate an executable Python 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 a given value N, denoting the number of Characters starting from the A, print reverse character bridge pattern. Example 1: Input...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Given an array A of positive integers, sort the array in ascending order such that element at index K in unsorted array stays unmoved and all other elements are sorted. 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.Johanna knows mind reading magic, or so she says. Her new trick consists of lining up $N$ decks of cards, each deck having $K$ cards n...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Given a string S of lowercase english alphabetic characters and a substring range starting from q1 and ending at q2, the task is to find out the count of palindromic substring...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.*CodeChef recently revamped its [practice page] to make it easier for users to identify the next problems they should solve by introdu...
user: Generate an executable Python 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 versions is the constraints on $n$, $k$, $a_i$, and the 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.People are going to the movies in groups (or alone), but normally only care to socialize within that group. Being Scandinavian, each 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.Harry is doing magic practice on X axis.He found 4 points A,B,C,D. Now consider line AB and CD ( |AB|=|CD| ) , he guesses an angle alp...
user: Generate an executable Python 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 room there are N empty boxes in a row indexed from 1 to N. At a time, 2 people enter the room each having a chocolate bar with hi...
user: Generate an executable Python 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 tree consising of N vertices. What is the minimum number of vertices that should be removed that all the remaining par...
user: Generate an executable Python 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 and a node value X, find if the node with value X is present in the BST or not. Example 1: Input: 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.*Each contest - there are approximately 1500 - 2000 users who participate for the 1st time and get rated.* *The Chef wanted to tell 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.In this challenge, the task is to debug the existing code to successfully execute all provided test files. There are $n$ boxes in fro...
user: Generate an executable Python 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's Paint Shop is one of the famous shop in Geekland, but 2014 Earthquake caused disarrangement of the items in his shop. Each item...