formatted_conversations stringlengths 1.13k 138k |
|---|
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.You are given an integer $k$. Find the largest integer $x$, where $1 \le x < k$, such that $x! + (x - 1)!^\dagger$ is a multiple 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.Mirko has $N$ items (labeled with numbers from $1$ to $N$) and $L$ drawers (labeled with numbers from $1$ to $L$). All items are curre... |
user: Generate an executable Python 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 N edges. The task is to convert this to a Circular Doubly Linked List(CDLL) in-place. The left and right pointe... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Iceland is famous for its geothermal activity, which supplies the country with much of its electricity and heating. It is also a sourc... |
user: Generate an executable Python 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 length N.
Let f(i) denote the sum A_{1} + A_{2} + \dots + A_{i} \, and let g(i) denote the sum A_{i} + A_{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.Given an undirected graph (not necessarily connected) with V vertices and adjacency list adj. You are required to find all the vertice... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Sparsh(techno-cultural fest of SVNIT) fever is spread all over SVNIT and now the core-committee of Sparsh wants to propagate it all ov... |
user: Generate an executable Python 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, check if it can be partitioned into two parts such that the sum of elements in both parts is 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.You are given a two dimensional chess board of size $N \times N$ ($1$-based indexing). Some of the cells on this board are ‘.’ denotin... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Chef is given a binary string A of length N. He can perform the following operation on A any number of times:
Choose L and R (1 ≤ L ≤ ... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.One day while playing with GCD (Greatest Common Divisor), Panda got struck in a problem, so help Panda to solve his problem. His probl... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Given a BST and a value k, the task is to delete the nodes having values greater than or equal to k.
Example 1:
Input:
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.Garry is looking at the sky. Such a beautiful day! He notices that the clouds are particularly beautiful today, and wishes to record 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 a number, the task is to set all odd bits of a number.
NOTE: Position of Least Significant Bit is considered as 1.
Example 1:
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.Read problems statements [Mandarin] , [Bengali] , [Hindi] , [Russian] and [Vietnamese] as well.
You are given an integer sequence $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 a tree with N vertices, where the i^{th} vertex has color A_{i}.
We say that an edge of this tree *separates* color C 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.Hattori is very much inspired by the way GMAIL works. He decides to build his own simple version of GMAIL. He divides the mails into 3... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Jack is very fond of reading. He reads a lot many pages of books in a day. Since he is obsessed with reading, he reads K times more pa... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Given a BST and an integer K. Find the Kth Smallest element in the BST using O(1) extra space.
Example 1:
Input:
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.You are given an array of N elements and num queries, In each query you are given three numbers L,R and K and you have to tell, how 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.Given a string S of digits(0-9).Find the maximum value that can be obtained from the string by putting either '*' or '+' operators 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.Christmas comes sooner every year. In fact, in one oft-forgotten corner of the world, gift-giving has already started in the form of a... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Given A binary Tree. Your task is to remove all the half nodes (which has only one child).
Example 1:
Input:
7
/ \
7 8
/
2
Output: 2 7 8 ... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Watson asks Sherlock:
Given a string S of N 0's and M 1's, how many unique permutations of this string start with 1?
Help Sherlock ... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Geek is very fond of patterns. Once, his teacher gave him a pattern to solve. He gave Ram an integer n and asked him to build a patte... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Miss DD is the most beautiful girl of NITJ.
While working on her final year project, Miss DD found some interesting numbers known as 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.One day, little Mirko came across a funny looking machine! It consisted of a very very large screen and a single button. When he found... |
user: Generate an executable Python 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 str1 and str2. The task is to remove or insert the minimum number of characters from/in str1 so as to transform it 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.Alice and Bob are playing a game.
They start with a positive integer $n$ and take alternating turns doing operations on it. Each turn... |
user: Generate an executable Python 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, and you have to validate whether it's a valid Roman numeral. If it is valid, print True. Otherwise, print Fals... |
user: Generate an executable Python 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 goes to the supermarket to buy some items. Luckily there's a sale going on under which Chef gets the following offer:
If Chef b... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.You have an infinitely long digital panel. Using various combinations of 7 segments, we can represent each digit. The picture shows 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.Given an ascending sorted rotated array Arr of distinct integers of size N. The array is right rotated K times. Find the value of K.
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 two linked lists, your task is to complete the function makeUnion(), that returns the union list of two linked lists. This union... |
user: Generate an executable Python 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$ two-dimensional points in space, determine whether they lie on some vertical or horizontal line. If yes, print YES; otherwis... |
user: Generate an executable Python 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 subsequence as any subset of an array. We define a subarray as a contiguous subsequence in an array.
Given an array, 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.Monocarp plays a computer game. There are $n$ different sets of armor and $m$ different weapons in this game. If a character equips 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.A terrible monster is rampaging through Neo Tokyo 5! The Earth Defense Force (EDF) has sent a mech unit1 to defeat the monster. Becaus... |
user: Generate an executable Python 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 lamps in a line. The lamps are numbered 1 to n from left to right. There are also n keys. When key number i is pressed, al... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.During a game of Minesweeper you have arrived in the situation shown in the image, with an $n\times n$ square surrounded by $1$s, them... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Bwahahahahaha!!! Your nemesis, the dashingly handsome spy Waco Powers, has at last fallen to your secret volcano base’s deathtraps (or... |
user: Generate an executable Python 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 Hindi,
Mandarin chinese
, Russian and Vietnamese as well. ------
The structure of the company Shar... |
user: Generate an executable Python 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
Eugene has a sequence of upper hemispheres and another of lower hemispher... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Chef wants to become fit for which he decided to walk to the office and return home by walking. It is known that Chef's office is X km... |
user: Generate an executable Python 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 elements. For any ordered triplet (i, j, k) such that i, j, and k are pairwise distinct and 1 ≤ i, j, 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.You are given an integer 'n' which denote the number of elements in an array a[ ] and an integer 'x'. You have to calculate the averag... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Pak Chanek has a prime number$^\dagger$ $n$. Find a prime number $m$ such that $n + m$ is not prime.
$^\dagger$ A prime number is 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.A brokerage firm is interested in detecting automatic trading. They believe that a particular algorithm repeats itself; that is, it 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.Given a string s which contains only lower alphabetic characters, check if it is possible to remove at most one character from this st... |
user: Generate an executable Python 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're given a sequence of N distinct integers. You need to find a subsequence of length K with the maximum possible median.
The 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.Penelope is part of the admin team of the newly built supercomputer. Her job is to assign workstations to the researchers who come her... |
user: Generate an executable Python 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 Bureau for Artificial Problems in Competitions wants you to solve the following problem: Given $n$ positive integers $a_1, \dots ,... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.George has won the lottery and, being a nice guy, has decided to spread the wealth around. However, monetary gifts can be taxed once 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 arr[] of positive integers of size N. Reverse every sub-array group of size K.
Note: If at any instance, there are no 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.Given an array A[] of N positive integers which can contain integers from 1 to P where elements can be repeated or can be absent 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.Given an integer N, the task is to find out the count of numbers M that satisfy the condition M + sum(M) + sum (sum(M)) = N, where sum... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Read problems statements [Mandarin] , [Bengali] , [Hindi] , [Russian] and [Vietnamese] as well.
Chef has bought a new robot, which 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.Given a Binary Tree of size N, You have to count leaves in it. For example, there are two leaves in following tree
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.Read problems statements in Mandarin Chinese, Russian and Vietnamese as well.
Chef's team is going to participate at the legendary 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.There are N children and Chef wants to give them 1 candy each. Chef already has X candies with him. To buy the rest, he visits a candy... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.When it comes to trams, a lot of people are civilized individuals who know how to behave in one. However, there are always those few 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.Minion's approach is Correct, if number of the positive integers less than or equal to N that are relatively prime to N, is prime or 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 a straight line, $a\cdot x+b\cdot y=c$. Find the point closest to the origin that also satisfies the following propertie... |
user: Generate an executable Python 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 one cat, $k$ mice, and one hole on a coordinate line. The cat is located at the point $0$, the hole is located at the point ... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Raaju and Ankit went on an adventurous trip to the Old Ruins of Al Kharid. There they somehow ran into an old precious pot of gems. No... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.You are given an array of $n$ integers $a_1, a_2, \ldots, a_n$. The integers are either $1$ or $-1$. You have to perform 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.Chef wants to gift his girlfriend a necklace made of beads. The beads can be made of either Stone, Glass, Quartz, Ruby or Diamond (he ... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Given an integer, check whether it is Bleak or not.
A number n is called Bleak if it can be represented as sum of a positive number x... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Given an NxN chessboard and a Knight at position (x, y). The Knight has to take exactly K steps, where at each step it chooses any 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.Alice and Bob are playing a game on a binary string S of length N.
Alice and Bob alternate turns, with Alice going first. On their tu... |
user: Generate an executable Python 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 went to Australia and sa... |
user: Generate an executable Python 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 integer N. Check whether the Binary Representation of the number is Palindrome or not.
Note: No leading 0’s are ... |
user: Generate an executable Python 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. In this version, all cards have the same color.
Alice has $n$ cards, each card is white, 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.Watson gives Sherlock an array $\mbox{A}$ of $N$ elements and two arrays $\mbox{B}$ and $\mbox{C}$, of $\mbox{M}$ elements each. Then ... |
user: Generate an executable Python 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 matrix your task is to find all unique rows of the given matrix in the order of their appearance in the matrix.
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.Read problems statements in Mandarin Chinese, Russian and Vietnamese as well.
Chef is playing a video game. In a video game, there'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.Given two Binary Search Trees. Find the nodes that are common in both of them, ie- find the intersection of the two BSTs.
Example 1:
I... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Convert a given string to its cross string (i.e Diagonal from left-right and from right-left).
See examples for better understanding... |
user: Generate an executable Python 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$ sticks with positive integral length $a_1, a_2, \ldots, a_n$.
You can perform the following operation any 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.A long time ago in a galaxy far, far away, there were $N$ planets. There were also $N - 1$ interplanetary paths that connected all 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.In olden days finding square roots seemed to be difficult but nowadays it can be easily done using in-built functions available across... |
user: Generate an executable Python 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 arr of n elements. In one operation you can pick two indices i and j, such that arr[i] >= arr[j] and replace th... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.You are given a positive integer N. You have to split each digit of N into either of two non-empty subsequences A or B.
For 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.You own and manage an office building. One of the tenants, a regional paper supply company, is complaining about the lack of security ... |
user: Generate an executable Python 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$ one-dimensional segments (each segment is denoted by two integers — its endpoints).
Let's define the function $f(x)... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Roger the Lion wants to help all his friends with passing exams. They need to solve the following problem to pass the IT exam.
You've... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Morse Code is an assignment of sequences of dots and dashes to alphabet characters. You are to create a Morse-like code that yields 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.Xenia is a girl being born a noble. Due to the inflexibility and harshness of her family, Xenia has to find some ways to amuse herself... |
user: Generate an executable Python 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 has just finished writing down the lecture on elvish languages. The language this week was "VwV" (pronounced as "uwu"). The w... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Read problems statements in Mandarin Chinese, Russian and Vietnamese as well.
Sebi likes solving Rubik's cube a lot. He spends a lot... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Read problems statements in Mandarin Chinese, Russian and Vietnamese as well.
You are given two integer arrays A and B each of size ... |
user: Generate an executable Python 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 will be two arrays of integers. Determine all integers that satisfy the following two conditions:
The elements of the first ... |
user: Generate an executable Python 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 of lowercase alphabets, check if it is isogram or not. An Isogram is a string in which no letter occurs more than onc... |
user: Generate an executable Python 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 thieves (who strongly “recommended” us not to reveal their names) has broken into the central bank of Logland, where the country’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.During a daily walk Alina noticed a long number written on the ground. Now Alina wants to find some positive number of same length wit... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Chef is given a rooted tree with N nodes numbered 1 to N where 1 is the root node.
Each node is assigned a lowercase english alphabe... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Chef is fond of burgers and decided to make as many burgers as possible.
Chef has A patties and B buns. To make 1 burger, Chef needs ... |
user: Generate an executable Python 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 $A$ and $B$, $A$ modulo $B$ is the remainder when dividing $A$ by $B$. For example, the numbers $7$, $14$, $27$ 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 two strings 'str' and a wildcard pattern 'pattern' of length N and M respectively, You have to print '1' if the wildcard patter... |
user: Generate an executable Python 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 A and B, find the count of integers X \in [L, R] such that at least one of the following is true:
X and A are [copr... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.