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.You are given an integer $n$.
Your task is to find two positive (greater than $0$) integers $a$ and $b$ such that $a+b=n$ and the lea... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Haha, try to solve this, SelectorUnlimited!
— antontrygubO_o
Your friends Alice and Bob practice fortune telling.
Fortune telling 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.Chef gave you an infinite number of candies to sell. There are N customers, and the budget of the i^{th} customer is A_{i} rupees, whe... |
user: Generate an executable Python 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 Two Binary Trees, write a function that returns true if one is mirror of other, else returns false.
Example 1:
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.Let $length(A)$ denote the count of digits of a number $\mbox{A}$ in its decimal representation.
John is looking for new methods 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 two integers, $N$ and $\mbox{M}$. Count the number of strings of length $N$ (under the alphabet set of size $\mbox{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.Chef visited a grocery store for fresh supplies. There are N items in the store where the i^{th} item has a freshness value A_{i} and ... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Chef is trying to solve a problem having T test cases, where, for each test case he is given a single integer N.
Chef has an algorith... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Sherlock Holmes is bored to death as there aren't any interesting cases to solve. Dr Watson finding it impossible to be around Sherloc... |
user: Generate an executable Python 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 aliens living in outer space are very advanced in technology,
intelligence and everything, except one, and that is Cooking.
Each... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.You are given a string S of even length s1..s2n . Perform the following manipulations:
* divide it into two halves s1..sn and sn + ... |
user: Generate an executable Python 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 teacher has sent an e-mail to her students with the following task: “Write a program that will determine and output the value 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 the boss of ACM (Air Conditioned Minions), an upstanding company with a single goal of world domination.
The company has $N$ ... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Read problems statements [Bengali] , [Mandarin chinese] , [Russian] and [Vietnamese] as well.
You are given an integer sequence $A$ 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.
You are given a rooted tree 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 problems statements in Mandarin chinese, Russian and Vietnamese as well.
Katya has a sequence of integers $a_{1}, a_{2}, \dots,... |
user: Generate an executable Python 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 N candies. He has to distribute them to exactly M of his friends such that each friend gets equal number of candies and each ... |
user: Generate an executable Python 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 sequence $a$, initially consisting of $n$ integers.
You want to transform this sequence so that all elements in it 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.Initially, Chef had an array A of length N. Chef performs the following operation on A at most once:
Select L and R such that 1 ≤ L ≤ ... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Taboo is a popular party game. In this game one player, the Clue Giver, prompts his/her teammates to guess a keyword by giving clues. ... |
user: Generate an executable Python 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 learning data structures and is familiar with linked lists, but he's curious about how to access the previous element in a lin... |
user: Generate an executable Python 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 Professor is facing the North. Tokyo is in trouble, and she is facing the South. Professor being her guardian angel wants to help ... |
user: Generate an executable Python 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 lost the password of his super locker. He remembers the number of digits N as well as the sum S of all the digits of his password... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Gang members of unseen gang are trying to plant the bomb in the different sectors of the city, but they need approval from the leader ... |
user: Generate an executable Python 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 non-negative integers, and a value sum, determine if there is a subset of the given set with sum equal to given sum.... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Utkarsh has a [permutation] P of \{0, 1, 2, \dots, N-1\}.
He wants to find the number of pairs (L, R) (1 ≤ L < R ≤ N) such that swapp... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Alice and Bob are very good friends and they always distribute all the eatables equally among themselves.
Alice has A chocolates 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 a large positive number N having x digits, the task is to count all rotations of the given number which are divisible by 4.
Exam... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Given string str, transform it according to the following rules:
Delete all the vowels from the string.
Insert # in front of all the c... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Read problems statements in Mandarin Chinese, Russian and Vietnamese as well.
Chef likes problems on geometry a lot. Please help him... |
user: Generate an executable Python 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, find the sum of GCD(i, N) where i = 1 to N. GCD denotes the greatest common divisor. Provide the answer modulus 10... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Aayush has recently started teaching Latin Dance. Today, he will be teaching Salsa. For this, he needs to divide the people attending ... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Positive integer number x is called prime, if it has exactly two positive integer divisors. For example, 2, 3, 17, 97 are primes, 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.Shekhar and his friend Nilesh are playing some unusual game. Initially there are two stacks of nuts. The first stack contains A nuts a... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Given a number N find whether its a happy number or not.
A number is called happy if it leads to 1 after a sequence of steps wherein ... |
user: Generate an executable Python 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.
In Chefland the ChefSanta gets a list of what children... |
user: Generate an executable Python 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 as well.
Mahesh got a beautiful array named A as a birthday gift from his 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.Doremy's new city is under construction! The city can be regarded as a simple undirected graph with $n$ vertices. The $i$-th vertex 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.Nikita has a row of $N$ white tiles indexed from $\mbox{1}$ to $N$. This time, she's painting them green!
Find the number of ways Ni... |
user: Generate an executable Python 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 digits (values lie in range from 0 to 9). The task is to count all the sub sequences possible in array such that 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.You are given an array A = \{ a_0, a_1...a_{N-1} \} and an integer D. Find the total number of un-ordered pairs (i, j) where i \ne j 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.Professor Zac is trying to finish a collection of tasks during the first week at the start of the term. He knows precisely how long 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.One day Mehak and Meenal were having a fight between them To resolve the dispute a question was given to both of them.
Given an 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.Print numbers from N to 1 (space separated) without the help of loops.
Example 1:
Input:
N = 10
Output: 10 9 8 7 6 5 4 3 2 1
Your Task... |
user: Generate an executable Python 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 string S consisting only of English lowercase letters (a - z). However, Hitesh does not like it and wants it to be reversed... |
user: Generate an executable Python 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.Read problem statements in [Russian], [Mandarin Chinese], [Bengali], and [Vietnamese] as well.
Let's define a function F(X) as 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.Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
These days, Chef has been pla... |
user: Generate an executable Python 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 positive integers $a_1, a_2, \ldots, a_n$.
Make the product of all the numbers in the array (that is, $a_1 ... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Given a Sentence S of length N containing only english alphabet characters, your task is to write a program that converts the given 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.The gaming company Sandstorm is developing an online two player game. You have been asked to implement the ranking system. All players... |
user: Generate an executable Python 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 permutation of length $n$ is a sequence of integers from $1$ to $n$ such that each integer appears in it exactly once.
Let the fixe... |
user: Generate an executable Python 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 competition is being held between two teams: A and B. Team A has N players numbered from 1 to N. Team B has M players numbered 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.Ashi is interested in checking the algorithmic skills of her boyfriend. So, she sets up a special 2-D graph for him. The 2-D graph loo... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Given a BST and a key K. If K is not present in the BST, Insert a new Node with a value equal to K into the BST.
Note: If K is already present in the BST, don't modify the BS... |
user: Generate an executable Python 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$ pairs of hard disk drives (HDDs) in a cluster. Each HDD is located at an integer coordinate on an infinite straight line... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Nezzar has $n$ balls, numbered with integers $1, 2, \ldots, n$. Numbers $a_1, a_2, \ldots, a_n$ are written on them, respectively. 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.Pal like board games. One day Shark shows him a new board game.
This is different from other board games .It follows some rules .
It ... |
user: Generate an executable Python 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 [Bengali] and [Vietnamese] as well.
Ghayeeth is a math teacher. He likes playing games, so he invented a new... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Problem Statement:
Given a simple arithmetic expression you need to find the result in
least repersentable mixed format.
note:express... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Mansi is fond of solving mental ability questions. Today while solving some questions she came across a series which she was unable 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.You are given a directed graph. However some edges have lost the direction in which they were facing. Now, you as a magician, want 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.Read problems statements [Bengali] , [Mandarin chinese] , [Russian] and [Vietnamese] as well.
There are two sequences $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.We all know how to calculate $a^{b}$ using $\boldsymbol{b}$ operations by multiplying $1$ by $\boldsymbol{a}$ a total of $\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.At some point or another, most computer science students have written a standard Sudoku solving program. This is yet another “put 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 a singly linked list consisting of N nodes. The task is to remove duplicates (nodes with duplicate values) from the given list (... |
user: Generate an executable Python 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 M, N, and a 2D matrix Mat of dimensions MxN, clockwise rotate the elements in it.
Example 1:
Input:
M=3,N=3
Mat=[[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.itertools.product()
This tool computes the cartesian product of input iterables.
It is equivalent to nested for-loops.
For exampl... |
user: Generate an executable Python 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 warehouse with $\mbox{M}$ containers filled with an infinite number of candies. The containers are arranged in a single row... |
user: Generate an executable Python 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 really likes to compete on Codechef, and he has gained an impressive rating of X, where X > 0. There is also a parallel universe,... |
user: Generate an executable Python 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 two binary strings A and B, both of length N. You have to merge both the binary strings to form a new binary string C of leng... |
user: Generate an executable Python 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 Manhattan Positioning System (MPS) is a modern variant of GPS, optimized for use in large cities. MPS assumes all positions are di... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.The mythic world of Chess Land is a rectangular grid of squares with R rows and C columns, R being greater than or equal to C. Its row... |
user: Generate an executable Python 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 hostel has N rooms in a straight line. It has to accommodate X people. Unfortunately, out of these X people, Y of them are infected ... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Given two numbers N and K. Find out if ‘N’ can be written as a sum of ‘K’ prime numbers.
Input:
N = 10 and K = 2
Output: 1
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.Given a BST and an integer. Find the least absolute difference between any node value of the BST and the given integer.
Example 1:
Inp... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Mr. Vincent works in a door mat manufacturing company. One day, he designed a new door mat with the following specifications:
Mat si... |
user: Generate an executable Python 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], [Russian], [Mandarin] and [Vietnamese] as well.
Hulk has a set of distinct points P in the 2D 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 asked to ensure that the first and last names of people begin with a capital letter in their passports. For example, alison 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.Given a positive integer N, return the N^{th} row of pascal's triangle.
Pascal's triangle is a triangular array of the binomial coeffi... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Given a linked list of N nodes such that it may contain a loop.
A loop here means that the last node of the link list is connected 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.Read problems statements in Mandarin Chinese, Russian and Vietnamese as well.
Read problems statements in Mandarin Chinese, Russian 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.Most of us like playing video games. Benni prefers to play the video game Digbuild. Digbuild is primarily about surviving for as long ... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Ishaan is playing with strings these days. He has found a new string. He wants to modify it as per the following rules to make it vali... |
user: Generate an executable Python 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 n x n binary grid. A grid is said to be binary if every value in grid is either 1 or 0.
You can change at most one 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.Given a square grid of size N, each cell of which contains integer cost which represents a cost to traverse through that cell, we need... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Mr. Aggarwal is a HOD of a department in a local university. After the Sessional exams he got his hands on a group's marks.
Overall 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.Johnny has a pool in his garden. There are several islands in the pool. Some islands are connected by bridges. Any bridge can be remov... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Two kingdoms had been at war for a long time, until the emperor intervened to bring an end to the conflict. The territory in question ... |
user: Generate an executable Python 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 N elements.
Array elements have property :
adjacent elements of array differ by atmost '1'.
Now you have 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.Electoral systems across the world can vary widely. In some systems, such as winner-take-all, the winner is determined by the pluralit... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Given a number N. You can perform an operation on it multiple times, in which you can change digit 5 to 6 and vice versa.
You have to return the sum of the maximum number 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 integer N representing the number of pairs of parentheses, the task is to generate all combinations of well-formed(balanced) ... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Check Tutorial tab to know how to to solve.
Here is a sample line of code that can be executed in Python:
print("Hello, World!")... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Friday is the highlight of Børge and Åse’s life. They can meet up with their buddies in the ITU Friday bar and discuss anything they 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.Chef is fan of pairs and he likes all things that come in pairs. He even has a doll collection in which the dolls come in pairs. One 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.There is a pyramid which consists of $n$ floors. The floors are numbered from top to bottom in increasing order. In the pyramid, 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.You need to calculate the following sum over Q queries.:
Assume array to be 1-indexed.
Example 1:
Input: nums = {2, 3, 4, 5, 1, 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.Given an array $A$ of length $N$, we can define rotation as follows. If we rotate $A$ to the right, all elements move to the right 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.Zapray really loves the Algorithmic Problem Solving course, but he is struggling with it. Recently the class studied Longest Increasin... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.