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.Polycarp calls an array dense if the greater of any two adjacent elements is not more than twice bigger than the smaller. More formall... |
user: Generate an executable Python 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 and rotated array A of N distinct elements which is rotated at some point, and given an element key. The task is to fin... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Jim's Burgers has a line of hungry customers. Orders vary in the time it takes to prepare them. Determine the order the customers re... |
user: Generate an executable Python 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 S represented as a string, the task is to get the sum of all possible sub-strings of this string.
As the answer will ... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.The farmer decided to build a barn on his farm. But on his farm there are trees and other buildings, which he does not want to remove.... |
user: Generate an executable Python 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 function $f(X)=X^2$. You are also given $\mbox{K}$ lists. The $i^{\mbox{th}}$ list consists of $N_i$ elements.
You ha... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Saurabh and Pranav play the popular game of Hungry Birds on windows and android phones respectively.
The game goal is to destroy bird... |
user: Generate an executable Python 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 x, y, z, the task is to compute the value of GCD(LCM(x,y), LCM(x,z)) and return the value.
Where, GCD = Greatest ... |
user: Generate an executable Python 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 likes all the numbers which are divisible by A. Bob does not like the numbers which are divisible by B and likes all the remaini... |
user: Generate an executable Python 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.
Leha is a bright mathematician. Today he is investigati... |
user: Generate an executable Python 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 str of length N, you have to find number of palindromic subsequence (need not necessarily be distinct) present in the 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.Sorting
One common task for computers is to sort data. For example, people might want to see all their files on a computer sorted by... |
user: Generate an executable Python 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 recently learned in her economics class that the market is said to be in equilibrium when the supply is equal to the demand.... |
user: Generate an executable Python 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 of integers. Find an element such that all the elements to its left are smaller and to its right are 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.You are given some text $t$ and a set of $n$ strings $s_1, s_2, \dots, s_n$.
In one step, you can choose any occurrence of any string... |
user: Generate an executable Python 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 is now far into the future and human civilization is ancient history. Archaeologists from a distant planet have recently discovered... |
user: Generate an executable Python 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 farmer has a rectangular land of size m×n. There are swamps in the land where the fencing is not possible. You need to find the peri... |
user: Generate an executable Python 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 define the following:
A subsequence of an array is an ordered subset of the array's elements having the same sequential ordering a... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Given a string, check if all its characters are the same or not.
Example 1:
Input:
s = "geeks"
Output: False
Explanation: The string 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 singly linked list of size N, and an integer K. You need to swap the K^{th} node from the beginning and K^{th} node from the e... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Given a Binary Search Tree. Convert a given BST into a Special Max Heap with the condition that all the values in the left subtree of ... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.You are given a number N. You can perform the following operation on it:-
Change any digit of N to a different digit. The cost of 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.At the store, the salespeople want to make all prices round.
In this problem, a number that is a power of $10$ is called a round numb... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Consider a rooted binary tree with $n$ vertices containing numbers. Each vertex of the tree either has two sons (left son and right 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.One thing almost all computers have in common, whether it is a simple stack-based calculator, a 6502 powered BBC Micro, or a brand new... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Read problems statements in Mandarin Chinese, Russian and Vietnamese as well.
Chef has two piles of stones with him, one has n_{1} 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.SHIN-CHAN and KAZAMA grew up to become very good friends. They went to high school together and shared the same bench in class. In one... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Given a linked list of N nodes. The task is to reverse this list.
Example 1:
Input:
LinkedList: 1->2->3->4->5->6
Output: 6 5 4 3 2 1
E... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.You are given the sequence: 0123456789101112131415...
The 0th digit of this sequence is 0, the 1st digit of this sequence is 1, the 2n... |
user: Generate an executable Python 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 programming contest circles, one of the most important roles is that of the Chief Equality Officer (CEO). This person is responsibl... |
user: Generate an executable Python 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 f(n)= [((1^2)x(nC1)^2) + ((2^2)x(nC2)^2) + ((3^2)x(nC3)^2) + ...... + ((n^2)x(nCn)^2)]%MOD.
Let there are k primes between 1 an... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Given an array of n integers. We need to count all values of ‘k’ such that
arr[0] % k = arr[1] % k = ....... = arr[n-1] % k
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 two strings denoting non-negative numbers X and Y. Calculate the sum of X and Y.
Example 1:
Input:
X = "25", Y = "23"
Output:
4... |
user: Generate an executable Python 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, find the number of factors in N! ( N factorial).
Example :
Input:
N = 5
Output:
16
Explanation:
5! is 120 ... |
user: Generate an executable Python 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 Panda has a thing for powers and modulus and he likes challenges. His friend Lucy, however, is impractical and challenges Panda... |
user: Generate an executable Python 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 str, convert the first letter of each word in the string to uppercase.
Example 1:
Input:
str = "i love programming"
Ou... |
user: Generate an executable Python 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 an integer K, find the number of pairs of elements in the array whose sum is equal to K.
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.The JoyFest at SVNIT comes to end. In the closing ceremony, a joyful cake is distributed among all visitors and volunteers. There is 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.
Bob and Alice are playing a 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 will be given N strings. You need to add them. String contains {[a-z][A-Z][0-9]}.
Order of value of each character is 0 < 1 < 2 < ... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Read problems statements in Mandarin Chinese and Russian.
Roman has no idea, why this problem is called Stone. He also has no idea 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.Consider a sequence $A$ of integers, containing $N$ integers between $1$ and $N$. Each integer appears exactly once in 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.King Arthur has a large kingdom that can be represented as a tree, where nodes correspond to cities and edges correspond to the roads ... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Tokitsukaze has a permutation $p$. She performed the following operation to $p$ exactly $k$ times: in one operation, for each $i$ 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.*"Stick with the strongest team, that's the only way."*
Gi-Hun and his mates have survived the deadly night, but now it’s time for th... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Equilibrium index of an array is an index such that the sum of elements at lower indexes is equal to the sum of elements at higher indexes.
Given an array, your task is to fin... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Given a boolean 2D array of n x m dimensions where each row is sorted. Find the 0-based index of the first row that has the maximum nu... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Small Pizza has an area of 'S' units. Medium Pizza has an area of 'M' units. Large Pizza has an area of 'L' units.
Cost of Small, medi... |
user: Generate an executable Python 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 completing her final semester, Savita is back home. She is excited to meet all her friends. Her $N$ friends live in different ho... |
user: Generate an executable Python 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 mayor has decided that it is high time to implement a new system of television transmitters. The city can be represented as a segm... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Hey buddy,
How are you? Last night I saw you programming on Hackerrank in my burger restauraunt. So I wonder if you can help me out o... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Given an array of penalties fine[], an array of car numbers car[], and also the date. The task is to find the total fine which will 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.Read problem statements in [Mandarin], [Bengali], [Russian], and [Vietnamese] as well.
For a positive, \textbf{even} integer N, we ca... |
user: Generate an executable Python 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 round and square brackets is given. You can change the sequence by performing the following operations:
change the 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.Some people(n) are standing in a queue. A selection process follows a rule where people standing on even positions are selected. 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.There are N people standing in a line from left to right. The i-th person from the left has a height H_{i}. H is a permutation of 1 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.Given two strings S1 and S2 . Print "1" if both strings are anagrams otherwise print "0" .
Note: An anagram of a string is another str... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.A professor teaches Computer Science in his University. After the End Semester Examination, he checks all the papers and keeps them in... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Given a matrix mat[][] of n rows and m columns, consisting of 0’s and 1’s. The task is to complete the function findPerimeter which returns an integer denoting the perimeter 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.Li and Lu have $n$ integers, $a_1,a_2,\ldots,a_n$, that they want to divide fairly between the two of them. They decide that if Li get... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Define the score of some binary string $T$ as the absolute difference between the number of zeroes and ones in it. (for example, $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.“Never attribute to malice that which is adequately explained by stupidity.” –Robert Hanlon.
A well-known trendsetter from a faraway... |
user: Generate an executable Python 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 positive integers.
In one operation, you can do the following:
Choose integers i and j (1 ≤ i < j ≤ 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 positive integers N and K.
You have to construct an array A of length N such that :
1 ≤ A_{i} ≤ 10^{18}
\sum_{i=1}^{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.Given a number n, find count of all binary sequences of length 2n such that sum of first n bits is same as sum of last n bits.
The anw... |
user: Generate an executable Python 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 set of N distinct points P_{1}, P_{2}, P_{3}, \ldots, P_{N} on a 2-D plane.
A triplet (i, j, k) is called a holy trip... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Rookie Pirate Captain Jack Albatross has secretly laid anchor in a hidden bay not far from Port Wine, the local meeting point for griz... |
user: Generate an executable Python 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_1, a_2, \ldots, a_n$. Each element of $a$ is $1$ or $2$.
Find out if an integer $k$ exists so that the 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.On a weekend, Qingshan suggests that she and her friend Daniel go hiking. Unfortunately, they are busy high school students, so they 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 two lists V1 and V2 of sizes n and m respectively. Return the list of elements common to both the lists and return the list in 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.Luke likes to eat. There are $n$ piles of food aligned in a straight line in front of him. The $i$-th pile contains $a_i$ units of foo... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.HackerEarth has decided to give exciting gifts to the contingents that have come.
They have decided to pack gifts for each member in 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.Let's dive into decorators! You are given $N$ mobile numbers. Sort them in ascending order then print them in the standard format show... |
user: Generate an executable Python 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 input string composed solely of lowercase English letters, find the longest substring that occurs more than once in the 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.We define a function F, on a array , P ,as follows:
F(P) = ( length(P)^
distinct(P))%(10^9+7)
where:
length(P) denotes the number of... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.You are given a string S. Find the length of its the longest substring which occurs at least two times. Occurences can intersect.
Inp... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Given N find all Sophie Germain Prime numbers less than N . A prime number p is called a sophie prime number if 2p+1 is also a prime 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.Given a binary tree, find the Postorder Traversal of it.
For Example, the postorder traversal of the following tree is:
5 10 39 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.Alice and Bob recently got into running, and decided to compare how much they ran on different days.
They each ran for N days — on 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.HackerLand National Bank has a simple policy for warning clients about possible fraudulent account activity. If the amount spent 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.The growth of Computer Science has forced the scientific community to award Nobel Prize in CS starting from this year.
Chef knows tha... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Vacations have arrived and Chef wants to go to his home in ChefLand. There are two types of routes he can take:
Take a flight from hi... |
user: Generate an executable Python 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 buckets and infinite number of balls. The maximum capacity of each bucket is given in an array capacity[]. Find the number 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.Tuco Salamanca has N distributors in New Mexico. He has to distribute methamphetamine in N districts. Each distributor has some probab... |
user: Generate an executable Python 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 string S and an integer K, the task is to count the number of substrings that contain exactly K ones.
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.In Doraland, people have unique Identity Numbers called D-id. Doraemon owns the most popular gadget shop in Doraland. Since his gadget... |
user: Generate an executable Python 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 all the nodes at odd levels.Root is considered at level 1.
Example 1:
Input:
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.You are in a game of laser tag, where the goal is to shoot and hit other players with the laser gun you are carrying. Running up to 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 planet named “Ruizland” having $N$ cities, These cities are connected in the form of a tree by a bidirectional path of spec... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.You have two strings $s_1$ and $s_2$ of length $n$, consisting of lowercase English letters. You can perform the following operation 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.You are given $\mbox{Q}$ queries. Each query consists of a single number $N$. You can perform any of the $2$ operations on $N$ in each... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Sophia has discovered several alien languages. Suprisingly, all of these languages have an alphabet, and each of them may contain thou... |
user: Generate an executable Python 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 tree T with N vertices. Recall that a tree is a connected graph with N-1 edges.
Determine the minimum number of edges... |
user: Generate an executable Python 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.
Aditi recently discovered a new magic trick. First, she gives you an inte... |
user: Generate an executable Python 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 easy version of the problem. The only difference between an easy and a hard version is in the number of queries.
Polycarp ... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Ishaan has been given a task by his teacher. He needs to find the Nth term of a series. His teacher gives him some examples to help hi... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Punctual City is well known for the punctuality of its citizens and its public transportation system. It is particularly famous for it... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.You are given an array A of length N.
The *interesting value* of a subarray is defined as the product of the maximum and minimum ele... |
user: Generate an executable Python 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 special Binary Tree whose leaf nodes are connected to form a circular doubly linked list. Find the height of this special 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.HackerLand is a country with $n$ beautiful cities and $m$ undirected roads. Like every other beautiful country, HackerLand has traffic... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.