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.Tim is visiting his grandma for two days and is bored due to the lack of the electricity over there. That's why he starts to play with... |
user: Generate an executable Python 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 binary string S of length N. Chef can perform the following operation on S:
Insert any character (0 or 1) at any position i... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given an array arr of size N. You need to push the elements of the array into a stack and then print them while popping.
Example 1:
Input:
n = 5
arr = {1 2 3 4 5}
Ou... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Mario's bullet moves at X pixels per frame. He wishes to shoot a goomba standing Y pixels away from him. The goomba does not move.
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.Given two integer array A and B of size N each.
A sum combination is made by adding one element from array A and another element of 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.For 3 distinct prime integers A, B, and C (1 < A,B,C < 2^{30}), we define positive integers X, Y, and Z as:
X = A\oplus B, Y = B\opl... |
user: Generate an executable Python 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 mapping a faraway planet using a satellite. The planet’s surface can be modeled as a grid. The satellite has captured an image... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.New Year is just around the corner, which means that in School 179, preparations for the concert are in full swing.
There are $n$ cla... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Johnny is playing with a large binary number, $\mbox{B}$. The number is so large that it needs to be compressed into an array of integ... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Given an array A[] of size N and a positive integer K, find the first negative integer for each and every window(contiguous subarray) of size K.
Example 1:
Input :
N = 5
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 number N, find the most occurring digit in it. If two or more digits occur same number of times, then return the highest of 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 piles where the i^{th} pile consists of A_{i} stones.
Chef and Chefina are playing a game taking alternate turns with Che... |
user: Generate an executable Python 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 moved to Colorland. Currency System here consists of various type of coins.
Each coin in Colorland has exactly one color. 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.The weekend is coming soon and you want to spend some time without worrying about your younger son Tommy. He is 6 years old and likes ... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Given a Binary Tree of size N, your task is to complete the function rightLeafSum(), which should return the sum of all the leaf nodes... |
user: Generate an executable Python 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] and [Russian].
Chef opted for Bio-Statistics as an Open-Elective course in his universi... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Tony is going on a road trip. Because gas is so expensive, Tony wants to carefully choose the gas stations he refuels at to save as 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.Micro is working on a product in his internship. Name of the product is "Product". It takes an array A having N integers as input and ... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Chef considers the climate HOT if the temperature is above 20, otherwise he considers it COLD. You are given the temperature C, find 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.Given a Directed Graph with V vertices and E edges, Find the members of strongly connected components in the graph.
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.You are given integers N and D. Find N positive integers x1...xN such that the difference of their product and their sum equals D.
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.> "Even a broken clock is right twice a day"
For those unfamiliar with the above proverb, the statement refers to a stopped 12 hour 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.Kim’s current obsession is to build towers from ordered sequences of Lego bricks. The towers are built one at a time, brick by brick. ... |
user: Generate an executable Python 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 number str(in string format) in hexadecimal. A new number can be made from the number str by selecting any subsequence... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.We define f(x)=\begin{cases} f(x \oplus reverse(x))+1 & \text{if } x \neq 0 \\ 0 & \text{otherwise} \end{cases}
Here, \oplus denote... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Given a directed flow network where each edge has a capacity of flow it could allow, find the maximum flow over the network from sourc... |
user: Generate an executable Python 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 3rd round of COCI is already here! In order to bet on predict the scores, we have assumed the following:
- If contestant $A$ scor... |
user: Generate an executable Python 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 A of length N. He can perform the following operation on A:
1) Select an index i (1 ≤ i ≤ N - 1) and select an int... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Having passed the Hunter Exam, Gon is now officially a Hunter! Gon is now saying goodbye to his best friend, Killua, as Gon wants to v... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.William is a huge fan of planning ahead. That is why he starts his morning routine by creating a nested list of upcoming errands.
A v... |
user: Generate an executable Python 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.
Chef likes sequences of inte... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.We have an array a[] of N stones of various heights laid out in a row. By taking some consecutive section of the stones, we wish to fo... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Positive integer $x$ is called divisor of positive integer $y$, if $y$ is divisible by $x$ without remainder. For example, $1$ is a 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.For the New Year, Polycarp decided to send postcards to all his $n$ friends. He wants to make postcards with his own hands. For this 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.The non-negative integer a is a divisor of the non-negative integer b if and only if there exists a positive integer c such that a × 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.Chances are that you have probably already heard of the travelling salesman problem. If you have, then you are aware that it is an NP-... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Gregor is learning about RSA cryptography, and although he doesn't understand how RSA works, he is now fascinated with prime numbers 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 number N, if the number is between 1 and 10 both inclusive then return the number in words (Lower case English Alphabets) othe... |
user: Generate an executable Python 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_1, a_2, \ldots, a_n$, find the minimum number of elements to remove from the sequence such that after the removal,... |
user: Generate an executable Python 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 wants to send an encrypted message in the form of string S to his friend Keeg along with instructions on how to decipher the mess... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Read problems statements in Mandarin chinese, Russian and Vietnamese as well.
Chef is tired of solving boring math problems by hand.... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Given a linked list of n nodes and a key , the task is to check if the key is present in the linked list or not.
Example:
Input:
n = 4... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Chef wants to impress Chefina by giving her the maximum number of gifts possible.
Chef is in a gift shop having N items where the cos... |
user: Generate an executable Python 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 A[] of size N, delete all the duplicated elements from A[]. Modify the array such that if there are X distinct el... |
user: Generate an executable Python 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 a lot of rumors in the media these days. One day Aida decided to find out how rumors are made.
She asked n of her friends 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.Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Chefina likes prefix and suff... |
user: Generate an executable Python 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 following are musical notes in “increasing order”:$A$, $A\sharp $, $B$, $C$, $C\sharp $, $D$, $D\sharp $, $E$, $F$, $F\sharp $, $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.Tom the Straight Builder has finally finished building his Great Wall. Being a Straight Builder he has of course built a wall with no ... |
user: Generate an executable Python 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 types of medicines and M types of diseases where medicine types are numbered from 1 to N and disease types are numbered fr... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Read problem statements in [Mandarin], [Bengali], [Russian], and [Vietnamese] as well.
Finally a monsoon has come. According to the M... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Given a positive integer N, the task is to find all the N bit binary numbers having more than or equal 1’s than 0’s for any prefix 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.A string is called *boring* if all the characters of the string are same.
You are given a string S of length N, consisting of lowerca... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Berland State University has received a new update for the operating system. Initially it is installed only on the $1$-st computer.
U... |
user: Generate an executable Python 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 optimist believes in the optimal usage of all options available.*
Chef gives you a sequence A_{1}, A_{2}, \ldots, A_{N} consistin... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Madoka's father just reached $1$ million subscribers on Mathub! So the website decided to send him a personalized award — The Mathhub'... |
user: Generate an executable Python 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 strings, return all groups of strings that are anagrams. The groups must be created in order of their appearance 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.Multiset —is a set of numbers in which there can be equal elements, and the order of the numbers does not matter. Two multisets are eq... |
user: Generate an executable Python 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.
There are $N$ mountains in Ch... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.You are given two arrays A and B of unique elements of size N. Check if array B is a stack permutation of the array A or not.
Stack pe... |
user: Generate an executable Python 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 day Jim came across array arr[] of N numbers. He decided to divide these N numbers into different groups. Each group contains 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.The Kingdom of Gridland contains $\mbox{P}$ provinces. Each province is defined as a $2\times N$ grid where each cell in the grid repr... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.David has several containers, each with a number of balls in it. He has just enough containers to sort each type of ball he has into ... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.The Transit Authority of Greater Podunk is planning its holiday decorations. They want to create an illuminated display of their light... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Pussycat Sonya has N blocks consisting of integers. You may assume that block is a one-dimensional array. She wants to put them all 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.Chef has his lunch only between 1 pm and 4 pm (both inclusive).
Given that the current time is X pm, find out whether it is *lunchti... |
user: Generate an executable Python 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 largest value in each level.
Example 1:
Input:
1
/ \
2 3
Output:
1 3
Explanation... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Geek has a string Sof size Nconsisting of characters from '0'to '9'. He wants to minimise the length of the string. In each minimising... |
user: Generate an executable Python 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. The task is to find the minimum valued element in this given BST.
Example 1:
Input:
5
... |
user: Generate an executable Python 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 K. Find the number of ordered pairs of positive integers (a,b) where 1≤a<b<K such that a+b ≤ K.
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.On the competitive programming platform CodeCook, every person has a rating graph described by an array of integers $a$ of length $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 a test, there are N problems, each carrying X marks.
In each problem, Chef either received X marks or 0 marks.
Determine whether... |
user: Generate an executable Python 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 very fond of patterns. Once, his teacher gave him a pattern to solve. He gave Geek an integer n and asked him to build a patte... |
user: Generate an executable Python 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 and Abhishek are two friends. Abh... |
user: Generate an executable Python 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.
Let P denote a sequence of N [prime numbers] such that the sum of the sequence is A.
Let Q denote a seque... |
user: Generate an executable Python 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 positive integers. Find an integer denoting the maximum XOR subset value in the given array arr[].
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.Your task is to implement the function atoi. The function takes a string(str) as argument and converts it to an integer and returns 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 temperature in celsius C. You have to convert it in Fahrenheit.
Example 1:
Input:
C = 32
Output:
89.60
Explanation:
For 32 d... |
user: Generate an executable Python 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 operating systems that use paging for memory management, page replacement algorithm is needed to decide which page needs to be repl... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Mila and Gila are sisters, Mila being the younger one. They both have some number of coins of different denominations with them. Mila ... |
user: Generate an executable Python 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 the prices of stock for n number of days. every ith day tell the price of the stock on that day. find the maximum profit... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Convex Hull of a set of points, in 2D plane, is a convex polygon with minimum area such that each point lies either on the boundary 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.The country of Chefland is a group of N cities having M directed roads between its cities. It takes 1 second to travel on any road.
... |
user: Generate an executable Python 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 state has just purchased a large, unspoiled tract of land, and wishes to turn it into a nature park with hiking trails. The land ... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Read problems statements in [Russian] and [Bengali].
An array is called *lovely* if the sum of absolute differences of each adjacent ... |
user: Generate an executable Python 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 total number of Rectangles (excluding squares) in a N*N chessboard.7
Example 1:
Input:
N = 1
Output:
0
Explanation:
There is only... |
user: Generate an executable Python 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$ of lowercase Latin letters.
The following operation can be used:
select one character (from 'a' to 'z') 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.On a faraway planet, strange plants with two stems can be found. Every plant on the planet can be described by three numbers: the $x$-... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.A string is a valid parentheses string (denoted VPS ) if is meets any one of the following:
It is an empty string "", or a single 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.Given an array a[] of size N which contains elements from 0 to N-1, you need to find all the elements occurring more than once 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.Liam (angryneeson52) is playing his favorite tower defense game! This game involves destroying minions of his opponent while defending... |
user: Generate an executable Python 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 new computer game you need to help the hero to get out of the maze, which is a rectangular field of size n × m. The hero is locat... |
user: Generate an executable Python 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 size N having no duplicate elements. The array can be categorized into the following:
1. Ascending
2. Desc... |
user: Generate an executable Python 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 height.
Example 1:
Input:
1
/ \
2 3
Output: 2
Example 2:
Input:
2
\
1
/
3
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.The store sells $n$ items, the price of the $i$-th item is $p_i$. The store's management is going to hold a promotion: if a customer 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 two sequences, find the length of longest subsequence present in both of them. Both the strings are of uppercase.
Example 1:
Inp... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.You are given a rooted tree with $n$ nodes. The nodes are labeled $1$ to $n$, and node $1$ is the root. Each node has a value $v_ i$.
... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Read problems statements in Mandarin Chinese, Russian and Vietnamese as well.
Little Egor is a huge movie fan. He likes watching dif... |
user: Generate an executable Python 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 square matrix of integer numbers. Rotate it 90 degrees clockwise (see examples for clarification of rotation).
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.Given a string, S find the rank of the string amongst all its permutations sorted lexicographically.The rank can be big. So print it m... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Lily is fascinated by numbers. She believes the whole world revolves around them, and that everything is connected by numbers. Her fri... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.