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.Write a program to obtain length (L) and breadth (B) of a rectangle and check whether its area is greater or perimeter is greater or b... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.There are M job applicants and N jobs. Each applicant has a subset of jobs that he/she is interested in. Each job opening can only ac... |
user: Generate an executable Python 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 $n\times n\times n$ cube, let $f(x,y,z)$ (where $1\leq x,y,z\leq n$) denote the value stored in cell $(x,y,z)$.
A $k\times ... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Two years ago, you helped install the nation’s very first Flubber pipe network in your hometown, to great success. Polls show that eve... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Given two integer numbers a and b, the task is to find count of all common divisors of given numbers.
Example 1:
Input: a = 12, b = 24... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Given a singly linked list of size N of integers. The task is to check if the given linked list is palindrome 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.Leonardo loves primes and created ${q}$ queries where each query takes the form of an integer, $n$. For each $n$, count the maximum 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.There is a circular track of length M consisting of M checkpoints and M bidirectional roads such that each road has a length of 1 unit... |
user: Generate an executable Python 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 think you can code?
This problem will test you on various basic programming techniques.
You are given two integers $N$ and $t$... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Given two linked lists, your task is to complete the function mergeList() which inserts nodes of second list into first list at alternate positions of first list. The lists 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.Given a Binary Tree of size N. The task is to complete the function sumLeaf(), that should return the sum of all the leaf nodes of the... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Eve is a beginner stand-up comedian. Her first show gathered a grand total of two spectators: Alice and Bob.
Eve prepared $a_1 + a_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.Manasa is a student in the department of Mathematics. She is pretty good at doing calculations involving small numbers, but large 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.Fluttershy has been put in charge of a high-end boutique in Manehattan, and she needs to deal with the customers that come in.
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.Given an Integer N and a list arr. Sort the array using bubble sort algorithm.
Example 1:
Input:
N = 5
arr[] = {4, 1, 3, 9, 7}
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.This is the easy version of this problem. The only difference between easy and hard versions is the constraints on $k$ and $m$ (in 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.You are given an array $a$ of length $n$ consisting of integers. You can apply the following operation, consisting of several steps, o... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Given a integer number n, find largest sum of digits in all divisors of n.
Example 1:
Input:
n = 12
Output:
6
Explanation:
The divis... |
user: Generate an executable Python 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 Burger Town new burger restaurants will be opened! Concretely, $N$ restaurants will open in $N$ days, while restaurant $\boldsymbol... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Binary search is a search algorithm usually used on a sorted sequence to quickly find an element with a given value. In this problem 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.Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Chef has $N$ items in his sho... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.“Drat!” cursed Charles. “This stupid carry bar is not working in my Engine! I just tried to calculate the square of a number, but it’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.Donald is a fence builder. He wants to build a fence that is $N - 1$ meters long. He needs a fence post every meter along the fence, 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.Ivica and Marica are attending astronomy classes and are observing two unusual stars. They noted the time when each of them flashed. T... |
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 of even size consisting of positive integers. Your task is to find the sum after sorting the array, such that the sum of product of alternate elements is minimu... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.A no is said to be k-Almost Prime Number if it has exactly k prime factors (not necessary distinct). Your task is to complete the function printKAlmostPrimes which takes two... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Given a list arr of N integers, print sums of all subsets in it.
Example 1:
Input:
N = 2
arr[] = {2, 3}
Output:
0 2 3 5
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.View Russian Translation
Limak is an old brown bear.
He often goes bowling with his friends.
You may know that usually the aim is to ... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Today while studying Omar reads many words in books and references. He feels bored enough to stop reading he has noticed something str... |
user: Generate an executable Python 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 is called powerful if it is a power of two or a factorial. In other words, the number $m$ is powerful if there exists a non-n... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Ishaan being curious as always was playing with numbers when he started to reverse the numbers. He invented something called the "inverting factor" of two numbers.
The inverti... |
user: Generate an executable Python 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 will find three types of people in an engineering college Maggu,Machau and Others. We all know how much hard Maggu people try to 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 a boolean 2D array, where each row is sorted. Find the row with the maximum number of 1s.
Example 1:
Input:
N = 3, M = 4
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.Chef has a sequence A of 2 \cdot N integers containing all natural numbers from 1 to N exactly twice.
Let a sequence B containing K 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.The only difference with E2 is the question of the problem..
Vlad built a maze out of $n$ rooms and $n-1$ bidirectional corridors. 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.You are given a string S, convert it into a magical string.
A string can be made into a magical string if the alphabets are swapped 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 integer N, recursively sum digits of N until we get a single digit. The process can be described below
If N < 10
dig... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.According to a recent survey, Biryani is the most ordered food. Chef wants to learn how to make world-class Biryani from a MasterChef.... |
user: Generate an executable Python 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 array $a$ composed of all the integers in the range $[l, r]$. For example, if $l = 3$ and $r = 7$, then $a = [3, 4, 5, 6,... |
user: Generate an executable Python 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 unique characters (in infinite supply), find the number of possible mapped strings of length N.
A mapped string follows follow... |
user: Generate an executable Python 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 with repeated elements, the task is to find the maximum distance between two occurrences of an element.
Example 1:
Inpu... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.This is the easy version of Problem F. The only difference between the easy version and the hard version is the constraints.
We will ... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.You are given an array of integers nums and an integer K, your task is to find the smallest positive integer divisor, such that upon 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.Monocarp has forgotten the password to his mobile phone. The password consists of $4$ digits from $0$ to $9$ (note that it can start 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 an array of positive integers. The task is to print the minimum product of any two numbers of the given array.
Example 1:
Inpu... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Given a number positive number N, find value of f_{0} + f_{1} + f_{2} + . + f_{N} where f_{i} indicates ith Fibonacci number.
Remember... |
user: Generate an executable Python 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 very large number $R$ in a compressed format. It is compressed as a binary string $s$, and an integer $k$. Start with the 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.Given an array arr[] of N integers and replace every element with the least greater element on its right side in the array. If there 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.Oh!! Mankind is in trouble again. This time, it's a deadly disease spreading at a rate never seen before. The need of the hour is to 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.Basin City is known for her incredibly high crime rates. The police see no option but to tighten security. They want to install traffi... |
user: Generate an executable Python 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[] consisting of N and M elements respectively. The task is to find minimum number of elements to remove fro... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Victor works for Alberta Chemicals Monitoring (ACM). ACM is a company that analyses raw environmental data related to chemicals used 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.Not so long ago, Vlad had a birthday, for which he was presented with a package of candies. There were $n$ types of candies, there 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.Geek is in a maze of size N * M. Each cell in the maze is made of either '.' or '#'. An empty cell is represented by '.' and an obstac... |
user: Generate an executable Python 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, calculate the ratios of its elements that are positive, negative, and zero. Print the decimal value of ea... |
user: Generate an executable Python 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 K. Find the kth permutation sequence of first N natural numbers.
Example 1:
Input: 4 3
Output: 1324
Explana... |
user: Generate an executable Python 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 doors and N persons. The doors are numbered from 1 to N and persons are given id’s numbered from 1 to N. Each door can have on... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.One day you wanted to read something, so you went to your bookshelf to grab some book. But when you saw how messy the bookshelf was 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.Tom Dwan has long been considered one of the most aggressive poker players in the world, and his mind-boggling swings are proof. Appar... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Professor X wants his students to help each other in the chemistry lab. He suggests that every student should help out a classmate who... |
user: Generate an executable Python 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 a tree (a connected graph without cycles) with N nodes, numbered 1 through N.
Each node has some weight Wi. Sonya 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.Chef has two arrays A and B of the same size N.
In one operation, Chef can:
Choose two integers i and j (1 ≤ i, j ≤ N) and swap the 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_1, a_2, \dots, a_n$ consisting of $n$ distinct integers. Count the number of pairs of indices $(i, j)$ such ... |
user: Generate an executable Python 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 and a target, find the number of node in the minimum sub-tree with the given sum equal to the target which is also... |
user: Generate an executable Python 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 all valid combinations of K numbers that sum upto to N such that the following conditions are true:
Only number 1 through 9 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 matrix mat of size N x M where every element is either O or X.
Replace all O with X that are surrounded by X.
A O (or a set 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.You are given a chessboard of size NxN. There is a white knight and several black pawns located on the board. The knight can move simi... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Read problems statements in Mandarin chinese, Russian and Vietnamese as well.
You are a poor person in ChocoLand. Here, people eat 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.Kamal is an amazing coder. He normally gets over excited during compilers lab, as compilers is his favorite subject.
One fine day, th... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Implement a Queue using 2 stacks s1 and s2 .
A Query Q is of 2 Types
(i) 1 x (a query of this type means pushing 'x' into the queue)
(ii) 2 (a query of this type means to 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 [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Chef has a sequence $A_{1}, 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 Vietnamese .
Chef likes to work with arrays a lot. Today he has an array A of length N consisting of pos... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.zeros
The zeros tool returns a new array with a given shape and type filled with $\mbox{o}$'s.
import numpy
print numpy.zeros((1,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.Abhishek Azad is quite skilled at fighting. People of IT-4,5,6 had a great time with Abhishek and Ms. Jasmine Bedi fighting over ever... |
user: Generate an executable Python 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 gives an array A with N elements to Babla. Babla's task is to find the maximum non-negative integer X such that:
No element in 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.Luca has a cypher made up of a sequence of $n$ wheels, each with a digit $a_i$ written on it. On the $i$-th wheel, he made $b_i$ moves... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Given a string A and a dictionary of n words B, find out if A can be segmented into a space-separated sequence of dictionary words.
Note: From the dictionary B each word can b... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.RSJ has a sequence $a$ of $n$ integers $a_1,a_2, \ldots, a_n$ and an integer $s$. For each of $a_2,a_3, \ldots, a_{n-1}$, he chose a 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.My dear friend Rahul was sad when nobody gave him anything important to do in URJA. So he decided to take out his anger by bringing do... |
user: Generate an executable Python 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 Golden Ring is the special tourist route in Berland. This route consists of n cities and the cyclic railway route. Cities are 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.When Farmer Oskar doesn’t watch his cows closely enough, they tend to wander off into the forest to hunt for horse spies. To catch 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.Chef has a large orchestra in his kitchen and he is preparing for a concert next week. He also has a music score, which is represented... |
user: Generate an executable Python 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 already know Basic Euclidean Algorithm. Now using the Extended Euclidean Algorithm, given a and b calculate the GCD and integer coe... |
user: Generate an executable Python 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 sumOfLongRootToLeafPath(), that find the sum of all nodes on 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 a 2D board of letters and a word. Check if the word exists in the board. The word can be constructed from letters of adjacent ce... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Use the counting sort to order a list of strings associated with integers. If two strings are associated with the same integer, they 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.Alice is feeling bored while sitting on the riverbank with her sister, when she notices a 2D White Rabbit with a 2D pocket watch run 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 problems statements in Mandarin chinese, Russian and Vietnamese as well.
You are given an integer $n$ and a string $s$ consisti... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.JJ has an array A of length N and an integer X. JJ can perform the following operation at most once:
Select a [subsequence] of A and 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 an array of integers, print all the pairs having positive and negative values of a number that exists in the array.
NOTE: If 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.Given a sorted array arr[] of size N and an integer K. The task is to check if K is present in the array or not using ternary search.
... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Spoilers Ahead!!!. Micro just saw the 9^{th} episode of the GoT season 6. When he saw Jon beat Ramsay on face, that moment, the episod... |
user: Generate an executable Python 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 which is basically a sentence without spaces between words. However the first letter of every word is in uppercase. 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.Given two integers L and R . Find the resultant after applying the series of Bitwise AND ( & ) operation on every natural number betwe... |
user: Generate an executable Python 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 value of n, we need to find the sum of the series where i-th term is sum of first i natural numbers.
NOTE: Sum of the series... |
user: Generate an executable Python 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 and his classmates are playing a prank on their Computer Science teacher. They change places every time the teacher turns to look... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Larry has been given a permutation of a sequence of natural numbers incrementing from $\mbox{1}$ as an array. He must determine wheth... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Jai and Veeru are best friends and are very fond of solving different problems. One day Jai decided to challenge Veeru by giving him 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.Hello from the future. I am a time traveller. You would think that in the future we have agreed to use a single scale for measuring te... |
user: Generate an executable Python 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 call the set of positive integers $S$ correct if the following two conditions are met:
$S \subseteq \{1, 2, \dots, n\}$;
if $a... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.