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.An array is beautiful if both of the following two conditions meet:
there are at least $l_1$ and at most $r_1$ elements in the array ... |
user: Generate an executable Python 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$ consisting of $n$ integers. Initially all elements of $a$ are either $0$ or $1$. You need to process $q$ qu... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.N light bulbs are connected by a wire. Each bulb has a switch associated with it, however due to faulty wiring, a switch also changes ... |
user: Generate an executable Python 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 eval() expression is a very powerful built-in function of Python. It helps in evaluating an expression. The expression can be a Py... |
user: Generate an executable Python 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 decided to go on a diet... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Mirko lives in a big enchanted forest where trees are very tall and grow really quickly. That forest can be represented as an $N\cdot ... |
user: Generate an executable Python 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 grid of size N, with rows numbered from 0 to N - 1 starting from the top and columns numbered from 0 to N - 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.See Russian Translation
David is playing a video game set in a dungeon. The dungeon has n interesting points and m one way tunnels co... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Your task is to calculate the sum (indicated by S) of all the k-balanced integers between [L, R]. An integer is called k-balanced 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.Read problem statements in [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
You are given a convex polygon with 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 a number S in the form of string, the task is to check whether the sum of digits at odd places is equal to the sum of digits at ... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Jimmy and his friends were all standing in a lineup for ice cream when a huge gust blew them all around. The friends want to keep thin... |
user: Generate an executable Python 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 integers a, b and c. The task is to check if it is possible to make right angled triangle with sides of length a, b and 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.Phoenix is playing with a new puzzle, which consists of $n$ identical puzzle pieces. Each puzzle piece is a right isosceles triangle 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 as integer s, find the sum of all the elements present in all possible subsequences of s.
Example 1:
Input: S = "123"... |
user: Generate an executable Python 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 and an integer X.
In one operation, Chef does the following:
Find the smallest element in the current... |
user: Generate an executable Python 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 3 numbers A, B and C. Find the greatest number among them.
Example 1:
Input: A = 10, B = 3, C = 2
Output: 10
Explanation:
10 is ... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.You are given string $\boldsymbol{\mathrm{~s~}}$ and number $\boldsymbol{\mbox{k}}$.
Consider a substring $\boldsymbol{p}$ of string... |
user: Generate an executable Python 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 Hackerrank number is a magic number that can be used to get sudo permissions on the site. We are going to generate a hackerrank 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.Bob decided to take a break from calculus homework and designed a game for himself.
The game is played on a sequence of piles of ston... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.John is taking a white paper and starting noted down the random numbers in ascending order in the list. John is briliant in mathematic... |
user: Generate an executable Python 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, Check if characters of the given string can be rearranged to form a palindrome.
Note: You have to return 1 if it is ... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Ram is very fond of patterns. Once, his teacher gave him a pattern to solve. He gave Ram an integer n and asked him to build a pattern... |
user: Generate an executable Python 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's your birthday today! So, you ask your dad to buy a brand new bicycle. But your dad knows you are weak in math. Hence he gives you... |
user: Generate an executable Python 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 age of the Terminators has ended but not all is destroyed.
Treasure Hunter Gagan has discovered a secret vault built by the Machi... |
user: Generate an executable Python 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 containing N words consisting of lowercase characters. Your task is to find the most frequent word in the array. 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.Andi and Bob are best friends. They both are good programmers as well. They love programming together because if one of them gets stuc... |
user: Generate an executable Python 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 was gifted an array $a$ of length $n$. Polycarp considers an array beautiful if there exists a number $C$, such that each num... |
user: Generate an executable Python 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 AVL tree and N values to be deleted from the tree. Write a function to delete a given value from the tree.
Example 1:
Tree =
... |
user: Generate an executable Python 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 matrix of $R$ rows and $C$ columns. All elements of the matrix have absolute value smaller than or equal to $10^4$. Y... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Given an array Arr of N integers that contains odd number of occurrences for all numbers except for a few elements which are present 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 undirected graph consisting of $n$ vertices and $n$ edges. It is guaranteed that the given graph is connected (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.Polycarpus has a complex electronic device. The core of this device is a circuit board. The board has 10^9 contact points which are 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.Polycarp has an integer $n$ that doesn't contain the digit 0. He can do the following operation with his number several (possibly zero... |
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, return length of the longest subarray of non- negative integers.
Note: Subarray here means a continuous part of the 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.It's the sale season again and Chef bought items worth a total of X rupees. The sale season offer is as follows:
if X ≤ 100, no disco... |
user: Generate an executable Python 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. He can replace any occurrence of -
- 01 with a
- 10 with b
- 010 with ab
- 101 with ba
While doing these... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.You are given N integers A_{1}, A_{2}, \ldots, A_{N}. Find *any* permutation B_{1}, B_{2}, \ldots, B_{N} of these integers, for which ... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Given a binary string (consists of only 0 and 1). If there is “100” as a sub-string in the string, then we can delete this sub-string.... |
user: Generate an executable Python 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 $n$ integers. Initially there is only one copy of the given array.
You can do operations of two types:
... |
user: Generate an executable Python 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 maximum occurrences of a, b, and c in a string. Your task is to make the string containing only a, b, and c such that no thr... |
user: Generate an executable Python 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 hard version of the problem. The only difference between the two versions is that the harder version asks additionally 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.Shik loves sorted intervals. But currently he does not have enough time to sort all the numbers. So he decided to use Almost sorted 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[] consisting of n integers, find the length of the longest subarray with positive (non zero) product.
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.Read problems statements in [Hindi], [Mandarin Chinese], [Russian], [Vietnamese], and [Bengali] as well.
You are given a sequence $A_... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.In the second round of the Hunter Exam, the candidates are faced with an even more challenging problem, requiring both agility and mat... |
user: Generate an executable Python 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 array of N numbers, we need to maximize the sum of selected numbers. At each step, you need to select a number A_{i}, delete o... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Given a Binary Tree of N nodes. Find the vertical width of the tree.
Example 1:
Input:
1
/ \
2 3
/ \ / \
4 5 6 7
\ ... |
user: Generate an executable Python 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 $n$ initial strings of lower case letters, where no initial string is a prefix of any other initial string. Now, consider cho... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Anthony has two multiple choice assignments to hand in today. The answer to each assignment is a string, where the $i^\textrm {th}$ 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.Arnabjan, The Picnic man of CSE batch 2013-17 organises a picnic for the
whole batch.During Picnic ,he found n numbers.As the batch ... |
user: Generate an executable Python 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 size N and a key. The task is to insert the key in the middle of the linked list.
Example 1:
Input:
LinkedList ... |
user: Generate an executable Python 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 playing a game with his brother Chefu. Before ... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Burenka and Tonya are playing an old Buryat game with a chip on a board of $n \times m$ cells.
At the beginning of the game, the chip... |
user: Generate an executable Python 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 Japanese game of Shiritori is the perfect 2-player game for a long car ride. The rules are simple: the first player picks any word... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Appu is now frustrated,because even after using the height doubling powder from the market, he is unable to normalize the heights of 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 arr[] of size N where every element is in the range from 0 to n-1. Rearrange the given array so that the transformed 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.*A Binod is a person who is very good with bitwise operations. Help Alice solve the following problem and become a Binod.*
You are gi... |
user: Generate an executable Python 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 of integers is called *good* if all its elements are perfect squares.
You are given an array A of N integers. In one move, ... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Given an array arr[] of size N, enqueue the elements of the array into a queue and then dequeue them.
Example 1:
Input:
N = 5
arr[] = 1 2 3 4 5
Output:
1 2 3 4 5
Example 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.For a given prime number p find all the number of pairs (m, n) of positive integers such that 1 ≤ m , n ≤ p(p-1)* and p divides nm - ... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Construct an N \times M matrix with entries having positive integers such that:
If M > 1, i^{th} row is strictly increasing from left... |
user: Generate an executable Python 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$ that contains $n$ integers. You can choose any proper subsegment $a_l, a_{l + 1}, \ldots, a_r$ of this arra... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Monocarp has just learned a new card trick, and can't wait to present it to you. He shows you the entire deck of $n$ cards. You see 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.A string consisting only of parentheses \verb+(+ and \verb+)+ is called a parentheses string. The balanced parentheses strings are def... |
user: Generate an executable Python 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 stack of water glasses in a form of pascal triangle and a person wants to pour the water at the topmost glass, but the capa... |
user: Generate an executable Python 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 N. Find the total count of set bits for all numbers from 1 to N(both inclusive).
Example 1:
Input: N = 4
Output... |
user: Generate an executable Python 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 decimal numbers represented by two linked lists of size N and M respectively. The task is to return a linked list that repre... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Timur initially had a binary string$^{\dagger}$ $s$ (possibly of length $0$). He performed the following operation several (possibly z... |
user: Generate an executable Python 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 city’s local subway service S.L., Super Lag, are currently being blamed that their displays, showing the expected wait time until ... |
user: Generate an executable Python 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 throwing a party for his N friends. There is a pizza store nearby and he wants to buy pizza for his friends. Each pizza has ex... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Chef is setting up a perfect bath for himself. He has X litres of hot water and Y litres of cold water.
The initial temperature of 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.For two given positive numbers a and b. Find a^{b}. Output your number modulus 10^{9}+7.
Example 1:
Input: a = 1, b = 1
Output: 1
Expl... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Topologically sorting the nodes of a directed graph (digraph) $G$ means putting the nodes in linear order\[ v_0, v_1, v_2, v_3, \ldots... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Given a row wise sorted matrix of size R*C where R and C are always odd, find the median of the matrix.
Example 1:
Input:
R = 3, C = 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.“Arrange” is a planetary popular Flash game. In “Arrange” the player is given a permutation of numbers $1$ to $N$ and a list of allowe... |
user: Generate an executable Python 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, the task is to count all palindromic sub-strings present in it. Length of palindrome sub-string must be greater than 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.Alice has an array A of length N which is initially a *permutation*. She dislikes K numbers which are B_{1}, B_{2}, \ldots, B_{K} all ... |
user: Generate an executable Python 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 was dismantling his attic and found an old floppy drive on it. A round disc was inserted into the drive with $n$ integers wri... |
user: Generate an executable Python 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.
Spring is interesting season of year. Chef is thinking about different thi... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Theofanis really likes sequences of positive integers, thus his teacher (Yeltsa Kcir) gave him a problem about a sequence that consist... |
user: Generate an executable Python 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 working a night shift at the university as a janitor, you absentmindedly erase a blackboard covered with equations, only to real... |
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 A of size N. You need to print elements of A in alternate order (starting from index 0).
Example 1:
Input:
N = 4
A[] = {1, 2, 3, 4}
Output:
1 3
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.There are N piles of coins each containing Ai (1<=i<=N) coins. Find the minimum number of coins to be removed such that the absolute ... |
user: Generate an executable Python 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], [Bengali], and [Mandarin Chinese] as well.
There are $N$ students standing in a canteen queue, ... |
user: Generate an executable Python 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[] sorted in ascending order of size N and an integer K. Check if K is present in the array or not.
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.Master Chief is in a very dangerous situation. He is trapped in a building full of Flood. Cortana analyses the situation and comes up ... |
user: Generate an executable Python 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 has got an internship at a well reputed company. But something started bothering him when he joined. It's been one month now 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.Given an array Arr of size N, print all its elements.
Example 1:
Input:
N = 5
Arr[] = {1, 2, 3, 4, 5}
Output: 1 2 3 4 5
Example 2:
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.The Government of Mars is not only interested in optimizing space flights, but also wants to improve the road system of the planet.
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.A typical strategy in the game Starcraft is to mass up large amounts of low-tier units such as Zerglings, then throw them at your oppo... |
user: Generate an executable Python 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 Bread Bucket Challenge
MIT Hostel is very famous for its Buttered toast it provides, during Sundays.
Navkrish loves the bread 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.In Chefland, a tennis game involves 4 referees.
Each referee has to point out whether he considers the ball to be inside limits or 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.Today, Fredo went for shopping. There are N shops in the market. Each shop has its number. The shop numbers are in random order and tw... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.In the game of Broken Blocks, the player is allowed to move on m x n blocks i.e. m levels and n stone blocks on each level such that 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.Dr. Chaz is hosting a programming contest wrap up dinner. Dr. Chaz has severe OCD and is very strict on rules during dinner, specifica... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Valentine's Day is approaching and thus Chef wants to buy some chocolates for someone special.
Chef has a total of X rupees and 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.This is an easy version of the problem. The difference between the versions is that the string can be longer than in the easy version.... |
user: Generate an executable Python 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 find the bracket numbers.
Example 1:
Input: S = "(aa(bdc))p(dee)"
Output: 1 2 2 1 3 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.Micah lives a peaceful life with his family in one of Canada’s most beautiful provinces. The vast wealth he has accumulated allows him... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.