formatted_conversations stringlengths 1.13k 138k |
|---|
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Given an integer array arr of size N. The Range of a subarray of arr is the difference between the largest and smaller element 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.Chef and Chefina are at positions X and Y on a number line.
They both love badminton.
It is known that badminton courts are located ... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Read problems statements in [Mandarin Chinese], [Russian], [Vietnamese] and [Bengali] as well.
Chefland is holding a virtual marathon... |
user: Generate an executable Python 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 Chef is stuck on an island and currently he has $x$ units of food supply and $y$ units of water supply in total that he could ... |
user: Generate an executable Python 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, the task is to count number of subsequences of the form a^{i}b^{j}c^{k}, where i >= 1, j >=1 and k >= 1.
Note:
1. 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 problems statements in Mandarin Chinese and Russian.
Yesterday Chef had a great party and doesn't remember the way he celebrea... |
user: Generate an executable Python 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 Tower of Hanoi is a famous game consisting of $3$ rods and a number of discs of incrementally different diameters. The puzzle star... |
user: Generate an executable Python 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, Ahmed_Hossam went to Hemose and said "Let's solve a gym contest!". Hemose didn't want to do that, as he was playing Valorant,... |
user: Generate an executable Python 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 new semester at Hogwarts has just started, but something is not quite right – the staircases are not cooperating with the school a... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.There are N marbles in a line, numbered 1 through N from left to right. Count numbers of ways to remove exactly M marbles such that t... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Chef wants to cross a hallway of N doors. These N doors are represented as a string. Each door is initially either open or close, 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.Read problems statements in [Hindi], [Mandarin Chinese], [Russian], [Vietnamese] and [Bengali] as well.
Recently, Chef has moved to a... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Read problems statements in Mandarin Chinese, Russian and Vietnamese as well.
Limak is a little polar bear, who loves eating cookies... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Along the railroad there are stations indexed from $1$ to $10^9$. An express train always travels along a route consisting of $n$ stat... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Arjit loved his family.He enjoyed spending time with them.And it was no different on the New Year.
He took his family on a picnic.Mad... |
user: Generate an executable Python 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. ------
Tumut, the best programmer in his villag... |
user: Generate an executable Python 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 and a number k, write a function that returns true if given array can be divided into pairs such that 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.Eugene must do his homework, but he is struggling.
He has three integer numbers: A, N, M. He writes number A on the board N times 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 problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
For an array $B$, while it 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.Given three arrays sorted in increasing order. Find the elements that are common in all three arrays.
Note: can you take care of the 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.Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Ari and Rich are playing a pr... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Ross, Monica, Rachel and Chandler are playing a game of pyramids in which they have to arrange n smaller pyramids each of diameter ri ... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Consider the sequence of numbers 1, 1, 2, 1, 2, 3, 1, 2, 3, 4, 1, 2, 3, 4, 5, ... In this sequence first we have the number 1, then 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.Consider the following function $f(X)$, which takes a single positive integer as argument, and returns an integer.
function f(X): ite... |
user: Generate an executable Python 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 link list of size N, modify the list such that all the even numbers appear before all the odd numbers in the modified list. 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 integers ${b}$ and $a$, find the smallest integer ${h}$, such that there exists a triangle of height ${h}$, base ${b}$, having 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.Jaggu is a little kid and he likes playing with water balloons. He took 1 million ( $10^{6} $) empty buckets and he filled the bucket ... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.You are given an array $a$ of length $n$. The array is called 3SUM-closed if for all distinct indices $i$, $j$, $k$, the sum $a_i + a_... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Given two integers N and M and a matrix of dimensions N*M. Count all the rows in a matrix that are sorted either in strictly increasin... |
user: Generate an executable Python 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 prime $\boldsymbol{p}$, define $\text{ord}_p(k)$ as the multiplicity of $\boldsymbol{p}$ in $\boldsymbol{\mbox{k}}$, i.e. ... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.A palindrome is a string that reads the same from left to right as it does from right to left.
Given a string, $\mbox{S}$, of $N$ low... |
user: Generate an executable Python 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 A of size N that contains only positive integers, find a continuous sub-array that adds to a given number S 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.You recently received a bag of chocolate sticks for Halloween. To prevent you from compulsively eating all the chocolate sticks in one... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Lukáš loves skiing. One morning, the sun was shining like no other sun had ever shone before, and he wanted to do something exciting. ... |
user: Generate an executable Python 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 strings C and D and you have to find how many times you can form string D from string C. You are only allow ed to 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.A poor old man works in a palace for a living. One day the old man's wife met with an accident. She needed an immediate operation but ... |
user: Generate an executable Python 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 Akshat's Birthday and he has invited some of the employees of his company which he has recently started. Every employee 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 positive number n. You need to write a program to find the maximum sum of distinct numbers such that the LCM of all these numb... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Given two linked lists of size N and M, which are sorted in non-decreasing order. The task is to merge them in such a way that the res... |
user: Generate an executable Python 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 dealt with most of the kingdoms on mainland Westeros, Daenerys turns to the Kingdom of Iron Islands.
The ruler, Balon Greyjoy 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.You are an employee at Micah’s Airlift Payload Services (MAPS), which is a local crane company. On this particular day, you receive 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 Binary Search Tree, modify the given BST such that it is balanced and has minimum possible height.
Examples :
Input:
30... |
user: Generate an executable Python 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.Find the sum of values of even and odd index positions separately.
Example 1:
Input:
N=5
Arr={1,2,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.Chef and Chefina are residing in a hotel.
There are 10 floors in the hotel and each floor consists of 10 rooms.
Floor 1 consists 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.When simulating x-ray imaging different energy photons interact differently and therefore needs to be simulated separetly. Often one h... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.A number N is represented in Linked List such that each digit corresponds to a node in linked list. You need to add 1 to it.
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.You are given a string $s$ consisting of lowercase letters of the English alphabet. You must perform the following algorithm on $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.You are given a program that consists of $n$ instructions. Initially a single variable $x$ is assigned to $0$. Afterwards, the instruc... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Ved started playing a new mobile game called Fighting Clans. An army of N enemies is approaching his base. The i^{th} enemy has H_{i} ... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.You are given the head of a doubly Linked List and a Key. Your task is to delete all occurrences of the given key and return the new 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.You are given an array $a$ of length $n$. Let $cnt_x$ be the number of elements from the array which are equal to $x$. Let's also defi... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Mike received an array $a$ of length $n$ as a birthday present and decided to test how pretty it is.
An array would pass the $i$-th 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.There is a large pile of socks that must be paired by color. Given an array of integers representing the color of each sock, determine... |
user: Generate an executable Python 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 dive into the interesting topic of regular expressions! You are given some input, and you are required to check whether they are... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Given a one/two-digit timing, calculate the possibilities of occurrence of other timings(including the glowing one) with relevant to g... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Given two arrays a[] and b[] respectively of size n and m, the task is to print the count of elements in the intersection (or common e... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.You are given an array A = [A_{1}, A_{2}, \ldots, A_{N}].
Is it possible to partition A into two non-empty [subsequences] S_{1} and 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 a string S containing lowercase English alphabets. Initially, you are at index 1. You can only jump to some other location j (j>... |
user: Generate an executable Python 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 K sorted arrays arranged in the form of a matrix of size K*K. The task is to merge them into one sorted array.
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.Given an array arr[] of N integers, Geek wants to assign a value to each of the array elements. The minimum value that can be assigned... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.An array A is called *weird* if it can be sorted in non-decreasing order by applying the given operation any number of times:
Select 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.After their pool burst, Mirko and Slavko started collecting cards. In their neighbourhood, card collection is taken seriously and ther... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Leo has started a job in a travel agency. His first task is to organize a summer trip to an exotic overseas city. During the summer se... |
user: Generate an executable Python 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 binary trees, the task is to find if both of them are identical or not.
Example 2:
Input:
1 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 problem statements in [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
You are given a tree with $N$ nodes nu... |
user: Generate an executable Python 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.
Kerim is an environment-friendly guy. ... |
user: Generate an executable Python 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 is playing a noob version of the game Flappy... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Neil has a [perfect binary tree] with N nodes, and an integer M. He can assign values to nodes. He calls the tree good if the followin... |
user: Generate an executable Python 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 test files to this problem were wrong during the contest. To make up for this mistake, the solutions submitted during the contest ... |
user: Generate an executable Python 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 graph with n vertices and connections between them. Your task is to find whether you can come to same vertex X if ... |
user: Generate an executable Python 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, write a function to check whether the given Binary Tree is a prefect Binary Tree or not. A Binary tree is Perfect... |
user: Generate an executable Python 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 boss of ACM (Association for Convex Main Office), an upstanding company with a single goal of world domination.
Today, yo... |
user: Generate an executable Python 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 you have two points $p = (x_p, y_p)$ and $q = (x_q, y_q)$. Let's denote the Manhattan distance between them as $d(p, q) = |x_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.Read problem statements in [Russian], [Mandarin Chinese], [Bengali], and [Vietnamese] as well.
You are given an array A consisting 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.Given an integer N and an integer D, rotate the binary representation of the integer N by D digits to the left as well as right and pr... |
user: Generate an executable Python 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 S consisting of strings separated by a space. Hash the list using the hash rule and a long string X given below and retur... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Shil is very bad at greedy algorithms. So he decided to practice a lot of greedy problems. He came across a very good problem.Problem ... |
user: Generate an executable Python 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, Vasya has decided to go to the Shopping Centre to buy some stuff for the upcoming College Farewell. On reaching the place, he ... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.NVWLS, or “No Vowels” puzzles are popular among puzzle enthusiasts. For example, consider the following no-vowels message:
BTWNSBTLSH... |
user: Generate an executable Python 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 itertools module standardizes a core set of fast, memory efficient tools that are useful by themselves or in combination. Together... |
user: Generate an executable Python 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.
Consider the following algorit... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Given the coordinates (x, y) of a point in 2-D plane. Find if it is possible to reach (x, y) from (0, 0). The only possible moves from... |
user: Generate an executable Python 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 and Chhotu are best friends. Chef knows that Chho... |
user: Generate an executable Python 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$ integers in the range $[-50000, 50000]$, how many ways are there to pick three integers $a_ i$, $a_ j$, $a_ k$, such that $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.In a coding contest, there are two types of problems:
Easy problems, which are worth 1 point each
Hard problems, which are worth 2 po... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Staircase detail
This is a staircase of size $n=4$:
#
##
###
####
Its base and height are both equal to $n$. It is drawn usi... |
user: Generate an executable Python 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 num1 and num2, the task is to find the product of the two numbers on a 12 hour clock rather than a number ... |
user: Generate an executable Python 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 obstacle on a 2D plane in the form of a simple polygon with vertices at points $(x_1,y_1),(x_2,y_2),...,(x_n,y_n)$. Vertex... |
user: Generate an executable Python 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 series of numbers composed of only digits 4 and 7. First few numbers in the series are 4, 7, 44, 47, 74, 77, 444, .. etc. 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.Chef is the financial incharge of Chefland and one of his duties is identifying if any company has gained a monopolistic advantage 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.Given an array arr[] of N distinct numbers, the task is to sort all even-placed numbers in increasing and odd-place numbers in decreas... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.You are given an array arr of N integers representing a min Heap. The task is to convert it to max Heap.
A max-heap is a complete bina... |
user: Generate an executable Python 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's son wants to go on a roller coaster ride. The height of Chef's son is X inches while the minimum height required to go on the r... |
user: Generate an executable Python 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 expression of the form $a{+}b$, where $a$ and $b$ are integers from $0$ to $9$. You have to evaluate it and print 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 [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Let's call a positive 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 a non-negative integer S represented as a string, remove K digits from the number so that the new number is the smallest 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.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 are given an array A containing N integers. A [subsequence] of this array is called *good* if all the elements of this 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.You have a sequence of $n$ colored blocks. The color of the $i$-th block is $c_i$, an integer between $1$ and $n$.
You will place 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 A of n positive numbers. The task is to find the first Equilibrium Point in an array.
Equilibrium Point in an array is... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.