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.Chef has infinite coins in denominations of rupees 5 and rupees 10.
Find the minimum number of coins Chef needs, to pay exactly X rup... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Bureaucrats love bureaucracy. This assertion seems fairly obvious but a less obvious observation is the amount of paperwork this means... |
user: Generate an executable Python 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 hit new RPG mobile game Curveknights was recently released and Yraglac has been absolutely obsessed with it. Yraglac has been tryi... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Stack likes the number 3 a lot.
He has two non-negative integers A and B.
In one operation, Stack can do either of the following:
... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Micro just learned about prime numbers. But he quickly got bored of them, so he defined a new kind of numbers and called them Prime 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.You are given two integers N \ ( N ≥ 2) and S. You have to construct an array A containing N integers such that:
0 ≤ A_{i} ≤ S for eac... |
user: Generate an executable Python 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 elements in the following format {a1, a2, a3, a4, .., an/2, b1, b2, b3, b4, ., bn/2}, the task is shuffle 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.start() & end()
These expressions return the indices of the start and end of the substring matched by the group.
Code
>>> import ... |
user: Generate an executable Python 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 to strings B and G. String B represents a binary code and string G represents a Gray Code. You need to write a program which con... |
user: Generate an executable Python 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 array of N integers, find sum of bit differences in all pairs that can be formed from array elements. Bit difference ... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.You will be provided with a passage (no special characters, no punctuations). Your task is to find the frequency of the words occurrin... |
user: Generate an executable Python 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 elementary school class is going on a road trip by bus to a computer factory. However, the driver is really tired of having to driv... |
user: Generate an executable Python 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 Wolf town there are 2 big markets S and T. The distance between these markets is D. Chef Ciel would like to run 2 restaurants in Wo... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Chess is a very popular game played by hundreds of millions of people. Nowadays, we have chess engines such as Stockfish and Komodo 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 regular N-gon with vertices at (cos(2πi / N), sin(2πi / N)), ∀ i ∈ [0,N-1]. Some of these vertices are blocked and all... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.A startup company tries to develop software for self-driving cars. One of the surprisingly difficult problems turns out to be right-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 a Circular Linked List of size N. The task is to delete the given node (excluding the first and last node) in the circular linke... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.This is the hard version of this problem. The only difference between the easy and hard versions is the constraints on $k$ and $m$. 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 consisting of N positive integers.
Suppose F(B,X) gives the minimum positive integer Y such that:
X divides ... |
user: Generate an executable Python 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 a given an array $a$ of length $n$. Find a subarray $a[l..r]$ with length at least $k$ with the largest median.
A median 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.Consider a string of $N$ letters, where $N$ is an even number. Rearrange the letters such that all $N/2+1$ substrings of length $N/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.Read problem statements in [Mandarin], [Bengali], [Russian], and [Vietnamese] as well.
Chef has a sequence A_{1}, A_{2}, \ldots, A_{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 in mandarin chinese, russian and vietnamese as well.
Today is the final round of La Liga, the most popular ... |
user: Generate an executable Python 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 and a prime p, the task is to print the largest power of prime p that divides N!. Here N! means the factori... |
user: Generate an executable Python 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, determine if they share a common substring. A substring may be as small as one character.
Example
$s1=\text{'... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Adam is standing at point $(a,b)$ in an infinite 2D grid. He wants to know if he can reach point $(x,y)$ or not. The only operation 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.Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Chef is experimenting in his ... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Peter returned from the recently held ACM ICPC World Finals only to find that his return flight was overbooked and he was bumped 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.Due to the frantical usage of the racket to kill flies, Marin has sustained a serious bodily injury known to the medical community as ... |
user: Generate an executable Python 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 each created one problem for HackerRank. A reviewer rates the two challenges, awarding points on a scale from 1 to 100 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.In the gym, Chef prefers to lift at least $W$ grams during a bench press and if that's impossible, Chef considers his workout to be 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.While performing complex market analysis William encountered the following problem:
For a given array $a$ of size $n$ and a natural 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.Harry, Ron and Hermonie are in their third year at Hogwarts School of
Witchcraft and Wizadry. Hermonie has been given a time turner 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.Let's call an array $a$ consisting of $n$ positive (greater than $0$) integers beautiful if the following condition is held for every ... |
user: Generate an executable Python 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. The problem is to set the rightmost unset bit in the binary representation of N. If there are no unset ... |
user: Generate an executable Python 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’ve been put in charge of an art exhibit from the famous minimalist sculptor J (even his name is minimalist!). J’s work involves 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.There is a mysterious castle in Earthland. In this castle there are 'n' rooms and each room contains "saviour soul" which need to be 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.You are given n segments on the Ox axis. The i-th segment is given as a pair l_i, r_i, where l_i is the position of the left end of 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.Given a binary tree of size N, find its reverse level order traversal. ie- the traversal must begin from the last level.
Example 1:
I... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Given a array, write a program to construct a triangle where last row contains elements of given array, every element of second last row contains sum of below two elements 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.Polycarp got an array of integers $a[1 \dots n]$ as a gift. Now he wants to perform a certain number of operations (possibly zero) so ... |
user: Generate an executable Python 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 BSTs containing N1 and N2 distinct nodes respectively and given a value x. Your task is to complete the function countPairs(... |
user: Generate an executable Python 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 positive integers. Your task is to sort them in such a way that the first part of the array contains odd numbers 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.There has been a Galaxy war started between Deo system and Sprite system . Mountain named planet is leader from Deo system and want 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 array of N integers and another array R containing Q queries(of l and r). Answer all Q queries asking the number of primes 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.A sequence of $n$ numbers is called permutation if it contains all integers from $1$ to $n$ exactly once. For example, the sequences [... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Given a function that takes a binary string. The task is to return the longest size of contiguous substring containing only ‘1’.
Input:
The first line of input contains an int... |
user: Generate an executable Python 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 out the nearest number which is a perfect square and also the absolute difference between them.
Example 1:
Inpu... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Often, when a list is sorted, the elements being sorted are just keys to other values. For example, if you are sorting files by their ... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.How many non-attacking knights K(n) can be placed on an n x n chessboard.
Recall that a knight can attack another knight if their ver... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Tom hates mathematical sequences, his friend gave him an integer sequence and asked him to
find the nth term of the sequence. As you 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.Implement the recursive function given by the following rules and print the last 3 digits:
F(x, y) = {
y + 1 when x = 0,
F(x - 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 Bucket having a capacity of N litres and the task is to determine that by how many ways you can fill it using two bottles of 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.We take a line segment of length $\textbf{C}$ on a one-dimensional plane and bend it to create a circle with circumference $\textbf{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.While breaking ground for the Obama Presidential Center, which will be located just a few blocks from campus in Jackson Park, archeolo... |
user: Generate an executable Python 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 three integers $a$, $b$, and $c$. Determine if one of them is the sum of the other two.
-----Input-----
The first 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.Given an array of integers of size n and an integer k, find all the pairs in the array whose absolute difference is divisible by k.
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.The All-Berland Team Programming Contest will take place very soon. This year, teams of four are allowed to participate.
There are $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.Problem Statement
Olivia, another cyborg with crafted legs is a very dear friend of Geneo. On the eve of valentines day, Olivia decide... |
user: Generate an executable Python 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 order to build a staircase to a famous pagoda on top of a mountain, the local authority has identified $N$ positions along the moun... |
user: Generate an executable Python 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's current age is 20 years, while Chefina's current age is 10 years.
Determine Chefina's age when Chef will be X years old.
Not... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Vikrant and Sarthak are roommates and this morning they had a fight over who is smarter.As we all know Sarthak is a geek so he gave Vi... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Arild just turned $1$ year old, and is currently learning how to count. His favorite thing to count is how many mouthfuls he has 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.The game Pokenom Go has just been released. Pokenom trainers can now travel the world, capture Pokenom in the wild and battle each oth... |
user: Generate an executable Python 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 and a number K where K is used as a threshold value to divide each element of the array into... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Even if it's a really easy question, she won't be able to answer it
— Perfect Memento in Strict Sense
Cirno's perfect bitmasks class... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Chef has an array A of size N. He can perform the following operation on A:
Select an i (1 ≤ i ≤ N) and for all 1 ≤ j ≤ i, set A_{j} :... |
user: Generate an executable Python 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's professor is planning to give his class a group assignment. There are 2N students in the class, with distinct roll numbers rang... |
user: Generate an executable Python 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 to find the sum of all the elements from all possible subsets of a set formed by first N natural numbers... |
user: Generate an executable Python 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$. You have to determine whether it is possible to build the string $s$ out of strings aa, aaa, bb and/or bbb... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Rishi likes to play with strings.Strings have been his passion since his childhood.One day in college,Rishi came to know about the con... |
user: Generate an executable Python 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$ consisting of $n$ integers $a_1, a_2, \dots, a_n$, and an integer $x$. Your task is to make the sequence ... |
user: Generate an executable Python 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 and Nastya live in a city consisting of $n$ houses and $n-1$ road. From each house, you can get to the other by moving only along... |
user: Generate an executable Python 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 distinct integers and a range from L to R, the task is to count the number of triplets having a sum in the r... |
user: Generate an executable Python 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 very fond of traveling. There are n cities, labeled from 1 to n. You are also given flights, a list of travel flights as dire... |
user: Generate an executable Python 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.
As usual, I went to work in 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.Given a palindromic number N in the form of string. The task is to find the smallest palindromic number greater than N using the same ... |
user: Generate an executable Python 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 positive integers of size N, where each value represents the number of chocolates in a packet. Each packet can ... |
user: Generate an executable Python 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 circular linked list, your task is to complete the method printList() that prints the linked list.
Input:
The printList functi... |
user: Generate an executable Python 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
Utkarsh has recently put on some weight. In order to lose weight, he has to run on boundary of gardens.
But he lives... |
user: Generate an executable Python 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 of size N. Find the maximum possible XOR between two numbers present in the array.
Example 1:... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Given a string containing multiple words, count the characters in each word and display them.
Example 1:
Input:
S = "the quick brown 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.Given an interger array arr[] of size n and an interger k.In one operation, you can choose an index i where 0<i Return the maximum fre... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Gotham city is in danger. All the people from Gotham were airlifted and they are going to be dropped at different districts of a new 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.Bitville is a seaside city that has a number of shopping centers connected by bidirectional roads, each of which has a travel time ass... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.KK has a crush on a girl in his class. In this valentines day he planned to propose her.
KK's crush will accept his proposal if KK 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.You are given a two-dimensional table (grid) A of N rows and M columns.
Every cell contains a lowercase letter, one of 'a' - 'z'.
Le... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Given two integers N and K, the task is to find the count of palindromic strings of length lesser than or equal to N, with first K cha... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Implement a Stack using two queues q1 and q2.
Example 1:
Input:
push(2)
push(3)
pop()
push(4)
pop()
Output: 3 4
Explanation:
push(2) the stack will be {2}
push(3) the stack wi... |
user: Generate an executable Python 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 employee's wallet can contain no more than M notes or coins. A boss pays his salary by the minimum notes possible. However the empl... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Sid is a superior salesperson. So he gets a task from his boss. The task is that he will be given some number of products say k (All 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.Ricky has N different balls and John has R different bags. Their teacher Ms.Samara wants them to distribute these N balls into R bags... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Alexa has two stacks of non-negative integers, stack $a[n]$ and stack $b[m]$ where index $0$ denotes the top of the stack. Alexa chall... |
user: Generate an executable Python 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}\}. Determine whether they can be reordered such that each pair of consecutive 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 was a game organised in the college for recreation.
The condition was that there were N number of locks in a room .
Wi... |
user: Generate an executable Python 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 Python, a string of text can be aligned left, right and center.
.ljust(width)
This method returns a left aligned string of length... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.You are given an array of integers $a_1, a_2, \ldots, a_n$ and an integer $x$.
You need to select the maximum number of elements in t... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.A number is called faithful if you can write it as the sum of distinct powers of 7.
e.g., 2457 = 7 + 7^{2} + 7^{4 . }If we order all... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Given an array Arr of size N, print second largest distinct element from an array.
Example 1:
Input:
N = 6
Arr[] = {12, 35, 1, 10, 34... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Xenny, the traveller, was in AlgoLand for vacation. He wanted to travel from city U to city V. Being quite an explorer, he wanted to t... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.