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 have a robot in a two-dimensional labyrinth which consists of N × M cells. Some pairs of cells adjacent by side are separated by 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.Rohan is downloading the movie Tiger Zinda Hai using a torrent website, but he is new to torrent, so he doesn't know the difference be... |
user: Generate an executable Python 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 recently started selling a special fruit.
He has been selling the fruit for X rupees (X is a multiple of 100). He earns a profi... |
user: Generate an executable Python 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 decided to go to a gold mine along with N of his friends (thus, total N+1 people including Chef go to the gold mine).
The go... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Read problems statements in [Mandarin Chinese], [Russian], [Vietnamese] and [Bengali] as well.
You are given N non-negative integers... |
user: Generate an executable Python 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 a harder version of 1A - Bear and Vowels.
There are 26 letters in the English alphabet and 6 of them are vowels: a,e,i,o,u,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 non-negative integer n. You are only allowed to make set bit unset. You have to find the maximum possible value of query so 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.Given an integer N. Your task is to find the number of binary strings of length N having no consecutive 1s.
As the number can be large... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Chef wants to buy a stock whose price was S rupees when the market opened. He will buy the stock if and only if its price is in the ra... |
user: Generate an executable Python 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 Byteland they have a very strange monetary system.
Each Bytelandian gold coin has an integer number written on it. A coin n
can be... |
user: Generate an executable Python 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 n elements. Find length of the largest sub-array having GCD equal to 1. If no such subarray exist with GCD 1, ret... |
user: Generate an executable Python 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 $2n$ integers $1, 2, \dots, 2n$. You have to redistribute these $2n$ elements into $n$ pairs. After that, you choose $x$ pair... |
user: Generate an executable Python 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 the problem. The difference in the constraints between both versions is colored below in red. You can make... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.We have three positive integers a, b and c. You don't know their values, but you know some information about them. Consider all three ... |
user: Generate an executable Python 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.combinations_with_replacement(iterable, r)
This tool returns $\textbf{r}$ length subsequences of elements from the input i... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese].
There are $N$ guests (numbered $1$ 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.Read problems statements in Mandarin Chinese, Russian and Vietnamese as well.
Chef has an array A consisting of N integers. He 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.Read problem statements in [Mandarin], [Russian], and [Vietnamese] as well.
You are given a sequence of integers A_{1}, A_{2}, \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.Let f(X) denote the number of set bits in X.
Given integers N and K, construct an array A of length N such that:
0 ≤ A_{i} ≤ K for al... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Given a sequence A of length N, the weight of this sequence is defined as
\text{weight}(A) = \sum_{i = 1}^{N} i\cdot A_{i}
Given an ... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Given two square Matrices A[][] and B[][]. Your task is to complete the function multiply which stores the multiplied matrices in a new matrix C[][].
Example 1:
Input:
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.You are given n numbers x1,x2,...,xn and a prime number P. Count the number of tuples (y1,...,yn) with 0 ≤ yi ≤ xi and
\displaystyle\... |
user: Generate an executable Python 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 person is said to be sleep deprived if he slept strictly less than 7 hours in a day.
Chef was only able to sleep X hours yesterday.... |
user: Generate an executable Python 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, the task is find the number of ways to represent this number as a sum of 2 or more consecutive natural numbers.
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 playing Ludo. According to the rules of Ludo, a player can enter a new token into the play only when he rolls a 6 on the die.
... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Real-time software in the Mars Pathfinder spacecraft suffered from an issue known as priority inversion. One technique to address this... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Little Mojo owns a match making company, which even to her surprise is an extreme hit. She says that her success rate cannot be matche... |
user: Generate an executable Python 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 teaching Bob maths via a game called N-guesser.
Alice has a positive integer N which Bob needs to guess. She gives him two 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.
Tic-Tac-Toe used to be Chef's favourite game during h... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.A space explorer's ship crashed on Mars! They send a series of SOS messages to Earth for help.
Letters in some of the SOS messages 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 problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Chef is playing a card game 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.There are N ninjas in a hidden ninja village. The main source of this village's income is the fees of the jobs completed by these N 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.In this problem, a String S is composed of lowercase alphabets and wildcard characters i.e. '?'. Here, '?' can be replaced by any of 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.There is a binary string S. Alice and Bob are playing a game on it.
Each turn, the following happens:
1. Alice selects a 01 subseque... |
user: Generate an executable Python 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 arr[] and a query integer q. Find the number X from the array such that it can be converted from q to X suc... |
user: Generate an executable Python 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 arcade game player wants to climb to the top of the leaderboard and track their ranking. The game uses Dense Ranking, so its 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.You are given $n$ integers $a_1, a_2, \ldots, a_n$. Find the maximum value of $max(a_l, a_{l + 1}, \ldots, a_r) \cdot min(a_l, a_{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.Read problems statements [Mandarin] , [Bengali] , [Hindi] , [Russian] and [Vietnamese] as well.
There are $N$ watchtowers built in 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 three numbers A,B and C. Find roots of quadratic equation Ax^{2} + Bx + C = 0. (A not equal to 0)
Example 1:
Input: A = 2, 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.You are given a string S that contains parentheses and letters. You have to remove the minimum number of invalid parentheses to make 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.You are given a hexagonal grid consisting of two rows, each row consisting of $n$ cells. The cells of the first row are labelled $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.Solve the query ,
given f(0)=0 , f(1)=1 , f(2)=1
f(n) = f(n-2) + f(n-3) + n*2
Input
First line denotes the number of test cases ... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Given an array Arr[] of N integers. Find the contiguous sub-array(containing at least one number) which has the maximum sum and return... |
user: Generate an executable Python 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.Jordan Belfort is a renowned stock broker who owns the Stock Brokerage firm,Starton Oakmount at Wall Street. He does a lot of "lega... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Recently, Anthony has really gotten into the battle royale games. His favorite game is PUBNite.
In PUBNite, many players fight agains... |
user: Generate an executable Python 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$ elements numbered from $1$ to $n$, the element $i$ has value $a_i$ and color $c_i$, initially, $c_i = 0$ for all $i$... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.In the game “Simon Says” one person plays the role of Simon, who gives instructions to everyone else playing the game. The tricky part... |
user: Generate an executable Python 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 BST(Binary Search Tree) with n number of nodes and value x. your task is to find the greatest value node of the BST wh... |
user: Generate an executable Python 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 eight planets and one planetoid in the Solar system. It is not a well known fact that there is a secret planet S4 inhabited ... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Dino loves ice cream. In case he ever run out of ice cream at his office, he keeps a stash of dry ice in order to quickly make new ice... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Hemose was shopping with his friends Samez, AhmedZ, AshrafEzz, TheSawan and O_E in Germany. As you know, Hemose and his friends are pr... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Given n and m, calculate 1^{1} + 2^{2} + 3^{3} + ... + n^{n} modulo m.
------ Input ------
The first line contains 1 ≤ t ≤ 10, 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.Count the numbers between 1 to N containing 4 as a digit.
Example 1:
Input:
N = 9
Output:
1
Explanation:
4 is the only number betwee... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Given an array A of n positive numbers. The task is to find the first index in the array such that the sum of elements before it is eq... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.After passing the final round of the Hunter Exam, Gon is now a Hunter! But before continuing his exciting journey, Gon decides to visi... |
user: Generate an executable Python 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. Krabs is a hardcore cryptocurrency and blockchain technology enthusiast. In a recent conference, he heard about a new cryptocurren... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.After attending the ProgNova contest, Peter walks out of the school to enjoy a weekend of shopping in Manhattan!
Peter has a shopping... |
user: Generate an executable Python 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 friend Ivan asked you to help him rearrange his desktop. The desktop can be represented as a rectangle matrix of size $n \times 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.Geek is very fond of patterns. Once, his teacher gave him a square pattern to solve. He gave Geek an integer n and asked him to build ... |
user: Generate an executable Python 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 decided to take a break, and go for a ride. He is currently in city 0, and he wants to get to city N.
The cities along the ro... |
user: Generate an executable Python 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 SRA company wants to hold a web search championship. There were n computers given for the competition, each of them is connected 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.Given the root of a binary tree. Check whether it is a BST or not.
Note: We are considering that BSTs can not contain duplicate Nodes.... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.A thief trying to escape from a jail has to cross N walls whose heights are given in arr[] each with varying heights. He climbs X feet... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Sarthak has a set S of N distinct prime numbers. He grew very fond of that set, and now he only likes a positive integer X if all of i... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Read problems statements in Mandarin Chinese and Russian.
Tuzik is a little dog. But despite the fact he is still a puppy he alread... |
user: Generate an executable Python 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 a polynomial of degree N with integer 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.You are given $n$ non-negative integers, $a_0,a_1,\ldots,a_{n-1}$. We define the score for some permutation ($\boldsymbol{p}$) 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.Given an array arr[ ] of n integers, for every element, find the closest element on it's right that has a greater frequency than its 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.For the first time, Polycarp's startup ended the year with a profit! Now he is about to distribute k burles as a bonus among n employe... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Bran was a prisoner in Azkaban. Though Bran was a witty and intelligent guy.He was confident of escaping prison.After few days of obse... |
user: Generate an executable Python 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
Jeffrey is the creator of the Fenêtres operating system, the most popular operating system in the world. Sale... |
user: Generate an executable Python 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 multiset of points on the plane with integer coordinates. Find the maximum distance between two points from this multi... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.In a native language, the increasing order of priority of characters is a, b, c, d, e, f, g, h, i, j, k, l, m, n, ng, o, p, q, r, s, t... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Read problem statements in [Mandarin], [Bengali], and [Russian] as well.
You are handed a binary string S, but not in any ordinary fo... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Your little sister has been a big help today: she went into town to do all the groceries! During this grand voyage, she was accompanie... |
user: Generate an executable Python 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 Swedes wanted to arrange a ping pong tournament among the $n$ high school students in the nation. Since Sweden is the fairest coun... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Watson likes to challenge Sherlock's math ability. He will provide a starting and ending value that describe a range of integers, inc... |
user: Generate an executable Python 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.
Sereja have an array that consist of n integers a[1], a[2], ..., a[n]. Now... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Given a Binary Search Tree. Find sum of all elements smaller than and equal to Kth smallest element.
Example 1:
Input:
20
... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.“Phew, that was the last one!” exclaimed the garden helper Tim as he threw the last tree plant to the ground. His employer, countess 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.Python has built-in string validation methods for basic data. It can check if a string is composed of alphabetical characters, alphanu... |
user: Generate an executable Python 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 wants to watch $n$ videos. Each video is only one minute long, but its size may be arbitrary. The $i$-th video has the size $... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Given an undirected graph and an integer M. The task is to determine if the graph can be colored with at most M colors such that no two adjacent vertices of the graph are colo... |
user: Generate an executable Python 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 and an integer x.Delete x^{th} node from the singly linked list.
Example 1:
Input: 1 -> 3 -> 4
x ... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.A Dice is a really great invention made in the history of the mankind. They try to capture the notion of randomness and one can experi... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Given an array arr[] of N positive integers. Select values from the array such that their sum is minimum. You must pick at least 1 val... |
user: Generate an executable Python 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 n elements, update all elements of given array to some minimum value x i.e, arr[i] = x (0 <= i < n), such that produ... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Anki started a new restaurant in Jalpaiguri. As a perfectionist, she wants no complaint from any of the customers.
So she decided 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.The color of a cat is primarily decided by three genes, coding for Black (Eumelanin), Red (Phaeomelanin) and Dilution (Melanophilin). ... |
user: Generate an executable Python 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 pairs of numbers. In every pair, the first number is always smaller than the second number. A pair (c, d) can follow 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.collections.Counter()
A counter is a container that stores elements as dictionary keys, and their counts are stored as dictionary v... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Geek is playing an array game. He is weak in the concepts of arrays. Geek is given two arrays arr[ ] and brr[ ] of the same size n. 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.You are given an array $a$ of $n$ integers. You are allowed to perform the following operation on it as many times as you want (0 or 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.Murgi is very generous. Today she is very happy as she got placed in her dream company. To celebrate this moment, she decided to dist... |
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 size N, a node, and a positive integer k., Your task is to complete the function kthAncestor(), the function should return the kth ancestor of the give... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Jaap, Jan, and Thijs are on a trip to the desert after having attended the ACM ICPC World Finals 2015 in Morocco. The trip included 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.View Russian Translation
You are given a tree T of n nodes. The nodes in the tree are numbered 1 through n. Let's consider some set 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.With the advent of touch-screen based interfaces, software designers have had to reinvent computer control for finger-based gestures. ... |
user: Generate an executable Python 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 points on X-Y plane with integer coordinates (xi, yi). You are given a set of polygons with all of its edges parallel to 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.A person is getting ready to leave and needs a pair of matching socks. If there are $n$ colors of socks in the drawer, how many socks... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.