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.In the year 2120 there is a vast subway network under all of Lund, consisting of $N$ stations and $M$ tunnels. Each tunnel connects tw... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Two friends, A and B, are playing the game of matchsticks. In this game, a group of N matchsticks is placed on the table. The 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.Given a non-negative number n and two values l and r. The problem is to count the number of unset bits in the range l to r in the bina... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.There is an integer array $\boldsymbol{d}$ which does not contain more than two elements of the same value. How many distinct ascendin... |
user: Generate an executable Python 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 bowls containing cookies. In one operation, you can take one cookie from any of the non-empty bowls and put it into anothe... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Mirko and Slavko are USKOK agents tracking the movements of an unnamed corrupt government official. Anonymous sources have tipped them... |
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 S consisting of only opening and closing curly brackets '{' and '}', find out the minimum number of reversals required to convert the string into a balanced exp... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Read problems statements [Hindi] ,[Bengali] , [Mandarin chinese] , [Russian] and [Vietnamese] as well.
Appy loves balloons! She wants... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
For positive integers $a$ 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 singly linked list and a number k. Write a function to find the (N/k)^{th} element, where N is the number of elements in the 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.A function f is defined as follows F(N)= (1) +(2*3) + (4*5*6) ... N. Given an integer N the task is to print the F(N)th term.
Example ... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Given a graph with n vertices, e edges and an array arr[] denoting the edges connected to each other, check whether it is Biconnected ... |
user: Generate an executable Python 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 valid expression containing only binary operators '+', '-', '*', '/' and operands, remove all the redundant parenthesis.
A set... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.You are given the sequence a_1, a_2, ..., a_n. You can choose any subset of elements and then reorder them to create a "saw".
The seq... |
user: Generate an executable Python 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 strings check whether first string could be converted to the second string but the conditions are:
1.If the character is at ... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Monocarp is playing a game "Assimilation IV". In this game he manages a great empire: builds cities and conquers new lands.
Monocarp'... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Everybody knows that the capital of Bergeria is connected to banson by a direct road. To improve the road's traffic capacity, there wa... |
user: Generate an executable Python 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 message string S consisting of lowercase English alphabet letters. "ada" is a noise word and all the words that 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.The European Space Agency has $N$ telescopes observing distant planets. They have classified $M$ different types of events. They notic... |
user: Generate an executable Python 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, find the sum of all the leaf nodes that are at minimum level of the given binary tree.
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.You are given two arrays A and B, each of size N. You can perform the following types of operations on array A.
Type 1: Select any 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.Mirko found a wooden board and $N$ nails in his attic. Mirko hammered the nails into the board as fast as possible. The board can be 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.Consider a zero-indexed matrix with $m$ rows and $n$ columns, where each row is filled gradually. Given the first row of the matrix, 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.Krishnakant is standing at $(0,0)$ in the Cartesian plane. He wants to go to the point $(x,y)$ in the same plane using only horizontal... |
user: Generate an executable Python 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 India vs South Africa Match , Ananth and Arpit got bored and started playing a Game.
The Game goes as follows.
The Game cons... |
user: Generate an executable Python 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 consider a random permutation p_{1}, p_{2}, ..., p_{N} of numbers 1, 2, ..., N and calculate the value F=(X_{2}+...+X_{N-1})^{K}... |
user: Generate an executable Python 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 factorial $n!$ of a positive integer $n$ is defined as the product of all positive integers smaller than or equal to $n$. 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.In this challenge, the task is to debug the existing code to successfully execute all provided test files.
A number is called a smart... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.It's almost summertime, so Big Cat and Little Cat are getting in shape. They decide the core of their fitness plan is to start jogging... |
user: Generate an executable Python 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 calculate _{n}P^{r}. _{n}P^{r} represents n permutation r and value of _{n}P^{r }is (n!) / (n-r)!.
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.Note the unusual time limit in this problem.
You are given an array A of N positive integers.
The *power* of a subarray A[L, R] (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.A Hamiltonian path, is a path in an undirected graph that visits each vertex exactly once. Given an undirected graph, the task is to 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.Given a string S consisting only of opening and closing parenthesis 'ie '(' and ')', find out the length of the longest valid(well-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.Given a sorted array, arr[] of N integers, and a value X. Find the K closest elements to X in arr[].
Keep the following points in mind... |
user: Generate an executable Python 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 an array of length $n$. Initially, each element is equal to $0$ and there is a pointer located on the first element.
We can d... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.You are given an equation of the form x_{1}+x_{2}+...+x_{N}=K. You need to find the total number of positive integral solutions of 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 may be under the impression that treasure maps originate from pirates, who create maps after burying their treasure so that 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.There are $n$ workers and $m$ tasks. The workers are numbered from $1$ to $n$. Each task $i$ has a value $a_i$ — the index of worker 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.A set of gears is installed on the plane. You are given the center coordinate and radius of each gear, which are all integer-valued. F... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Objective
Today, we're learning about a new data type: sets.
Concept
If the inputs are given on one line separated by a character... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Graphical calculators have become popular among high school students. They allow functions to be plotted on screen with minimal effort... |
user: Generate an executable Python 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 size N. Rearrange the given array in-place such that all the negative numbers occur before all non-negative ... |
user: Generate an executable Python 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 summer is at its peak in Chefland. Chef is planning to purchase a water cooler to keep his room cool. He has two options available... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Pixels in a digital picture can be represented with three integers in the range $0$ to $255$ that indicate the intensity of the red, g... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.You are given a hexagonal grid with $n$ rows, where $n$ is an odd integer. The rows are numbered $1$ to $n$ from top to bottom. The od... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Alex is the most famous ringmaster(circus) of the Great Indian Circus from the movie Dhoom3 who has just come to your city to demonstr... |
user: Generate an executable Python 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 needs to make a rectangular box for his physics class project. He has bought P cm of wire and S cm^{2} of special paper. He wou... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.This is an easier version of the problem with smaller constraints.
Korney Korneevich dag up an array $a$ of length $n$. Korney Kornee... |
user: Generate an executable Python 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, Devendra went to Goa with his friends. Devendra is well known for not following a budget.
He had Rs. Z at the start 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.You are given a middle game situation of the game Tic Tac Toe. It is given that it is player "X's" turn and you need to give to most 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.The link to the Russian translation.
On the way to kill one of vampires Reyna addressed, Damon and Enzo arrive at a mysterious town. ... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Given three integers N, x and y, a number A is formed by repeating N x times and another number B is formed by repeating N y times. 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.Poker Nim is another $2$-player game that's a simple variation on a Nim game. The rules of the games are as follows:
The game starts ... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Rahul and Rohit are playing a game. Initially, two positive integers A and B are written on a blackboard. The players take turns, star... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.In the dangerous wild west, robbers are attacking a long train with many coaches. Chaos erupts, and the robbers realize that the amoun... |
user: Generate an executable Python 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.
Today is Chef's birthday. His mom gifted him a truly lovable gift, a perm... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Ashima is moody, and like most girlfriend suffers from serious mood swings. Currently, looking at Pankaj's interest in numbers, she 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.Given an unsorted array, find the minimum difference between any pair in given array.
Example 1:
Input: nums = [2, 4, 5, 9, 7]
Outpu... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Borussia Dortmund are a famous football ( soccer ) club from Germany. Apart from their fast-paced style of playing, the thing that mak... |
user: Generate an executable Python 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 the minimum sum of its factors.
Example 1:
Input:
N=10
Output:
7
Explanation:
There are two ways to factories 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.Description
IIT Gandhinagar has a strong policy against plagiarism. The institute decides to develop a program that measures how diffe... |
user: Generate an executable Python 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.
Mike and his friend Tom are playing a very interesting game right ... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Bob has X rupees and goes to a market. The cost of apples is Rs. A per kg and the cost of oranges is Rs. B per kg.
Determine whether ... |
user: Generate an executable Python 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 Nerd are strikers playing football with their friend the Goalie. Their energies are denoted by X,Y and Z respectively.
Strik... |
user: Generate an executable Python 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 favorite uncle has passed away, leaving you a large estate. Bank account numbers, locations of safe deposit boxes, and GPS coordi... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Understanding $2$'s complement representation is fundamental to learning about Computer Science. It allows us to write negative number... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Given a weighted graph of N vertices numbered from 0 to N-1 in the form of adjacency matrix A[ ][ ] and two integers S denoting the nu... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Read problems statements in [Mandarin Chinese], [Russian], [Vietnamese] and [Bengali] as well.
A permutation is an array consisting 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.David was given a red checkered rectangle of size $n \times m$. But he doesn't like it. So David cuts the original or any other rectan... |
user: Generate an executable Python 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 Barbara played some friendly games of one-on-one basketball after work, and you agreed to help them keep score. The rules of... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Given an array of integers (A[]) and a number x, find the smallest subarray with sum greater than the given value. If such a subarray... |
user: Generate an executable Python 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 distinct positive numbers, the task is to calculate the minimum number of subsets (or subsequences) from the array 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.In the previous challenge, you wrote code to perform an Insertion Sort on an unsorted array. But how would you prove that the code 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.There are N bikes and each can cover 100 km when fully fueled. What is the maximum amount of distance you can go using N bikes? You ma... |
user: Generate an executable Python 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 permutation $... |
user: Generate an executable Python 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 market of mangoes, there are N sellers numbered from 1 to N. The i-th seller initially charges a price of A_{i} coins for each 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.Byteland is in the midst of a political crisis. The city is in almost a state of civil war among the two factions, "Coders", who rule ... |
user: Generate an executable Python 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 row of N walls in Geeksland. The king of Geeksland ordered Alexa to color all the walls on the occasion of New Year. Alexa ... |
user: Generate an executable Python 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 playing hide-and-go-seek in a forest with Belle. The forest has one tree at each of the positive integer lattice points. That ... |
user: Generate an executable Python 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 Russian also.
Chef likes playing with strings. The most interesting game are named "CHEF in string". 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 string S, check if it is palindrome or not.
Example 1:
Input: S = "abba"
Output: 1
Explanation: S is a palindrome
Example 2:
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.If we want to add a single element to an existing set, we can use the .add() operation.
It adds the element to the set and returns '... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Given a string S, the task is to check if a string is a non-repetitive or not. A non-repetitive string is defined as a string that 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.Given a string w, integer array b, character array x and an integer n. n is the size of array b and array x. Find a substring which 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.Given two numbers L and R(L<R). Count all the prime numbers in the range [L, R].
Example 1:
Input:
L=1,R=10
Output:
4
Explanation:
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.Tieu owns a pizza restaurant and he manages it in his own way. While in a normal restaurant, a customer is served by following the fi... |
user: Generate an executable Python 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.
Recently, Chef hosted a stran... |
user: Generate an executable Python 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 grid on XY plane with dimensions r x c, the two players (say JON and ARYA ) can move the coin over the grid satisfying the fol... |
user: Generate an executable Python 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 floating point number N, the task is to find the smallest integer k, such that when we multiply k with N, we get a na... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Alice has a positive integer N. She is wondering how many ordered pairs of positive integers (i, j) exist such that i + j = N.
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.You are planning the next FIFA World Cup and you are counting the number of highways that need to be built to connect the cities with ... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Vlad has $n$ friends, for each of whom he wants to buy one gift for the New Year.
There are $m$ shops in the city, in each of which 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.An array $b$ of $m$ positive integers is good if for all pairs $i$ and $j$ ($1 \leq i,j \leq m$), $\max(b_i,b_j)$ is divisible by $\mi... |
user: Generate an executable Python 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 while playing with parentheses '{' and '}' , Panda came across an interesting question , given a string A consisting of parent... |
user: Generate an executable Python 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 certain political party with $N$ members wants to develop some brand new politics. In order to do so, the party plans to make a comm... |
user: Generate an executable Python 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 X find the total numbers A such that A XOR X >= X, and 1<=A<=X.
Example 1:
Input: 10
Output: 5
Explanation: Calculat... |
user: Generate an executable Python 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 median of a set of integers is the midpoint value of the data set for which an equal number of integers are less than and greater ... |
user: Generate an executable Python 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 about Arvind BR and his amazing skills. He now works in a company. As it is the duty of the seniors to take us out for tre... |
user: Generate an executable Python 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 grid of size M X N. Each point of the grid could be free, occupied by a black marble or by a white marble. If a black marb... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Mirko is a huge fan of chess and programming, but typical chess soon became boring for him, so he started having fun with rook pieces.... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.