formatted_conversations stringlengths 1.13k 138k |
|---|
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.You have a connected undirected graph made of $n$ nodes and $m$ edges. The $i$-th node has a value $v_i$ and a target value $t_i$.
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 problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
You are given a rooted tree 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.You are given an unordered array of unique integers incrementing from $\mbox{1}$. You can swap any two elements a limited number of t... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Given an array arr of n integers, sort the first half of the array in ascending order and second half in descending order.
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.A group of $n$ friends decide to go to a restaurant. Each of the friends plans to order meals for $x_i$ burles and has a total of $y_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.The n-queens puzzle is the problem of placing n queens on a (n×n) chessboard such that no two queens can attack each other.
Given an 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 array A[] of N elements, You'd like to know how many triangles can be formed with side lengths equal to adjacent elements fro... |
user: Generate an executable Python 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 annual meeting of Board of Directors of Acme Inc. If everyone attending shakes hands exactly one time with every other attende... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.The median of $\mbox{M}$ numbers is defined as the middle number after sorting them in order if $\mbox{M}$ is odd. Or it is 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.Given an array nums[] of N positive integers. Find the minimum number of operations required to modify the array such that array eleme... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Given a string S. The task is to find the first repeated character in it. We need to find the character that occurs more than once 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.Madoka decided to entrust the organization of a major computer game tournament "OSU"!
In this tournament, matches are held according ... |
user: Generate an executable Python 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 artist who wanted to create an installation where his works appeared to be floating in midair has cast a large cube of clear acryli... |
user: Generate an executable Python 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$ of $m$ integers $a_1, a_2, \ldots, a_m$ Decinc if $a$ can be made increasing by removing a decreasing subseque... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.My birthday is coming up. Alas, I am getting old and would like to feel young again. Fortunately, I have come up with an excellent way... |
user: Generate an executable Python 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 words are anagrams of one another if their letters can be rearranged to form the other word.
Given a string, split it into two ... |
user: Generate an executable Python 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 arr[] where each element represents the maximum length of the jump that can be made forward from that 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 singly linked list with N nodes and a number X. The task is to find the node at the given index (X)(1 based index) of linked 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.Given N in Gray Code, find its binary equivalent. Return the decimal representation of the binary equivalent.
Example 1:
Input: N = 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.Find the Nth term of the Mysterious series.
N Nth term
1 5
2 10
3 26
4 50
5 122
.
.
.
10 842
Example 1:
Input: N ... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.There are n psychos standing in a line. Each psycho is assigned a unique integer from 1 to n. At each step every psycho who has an id ... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Write a program that receives a number n as input and prints it in the following format as shown below.
Like for n = 2 the pattern wil... |
user: Generate an executable Python 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 using a string S of length N. They both have their individual strings which are initially empty.
Bot... |
user: Generate an executable Python 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, find it's parity.
Parity of a number refers to the number of 1 bits it contains. The number has “odd parity”, if ... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.For an array of non-negative integers $a$ of size $n$, we construct another array $d$ as follows: $d_1 = a_1$, $d_i = |a_i - a_{i - 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.In the rhythm game Arcaea, the player can play songs with various partners. Every partner has two skill levels: Frag, and Step. A larg... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Your competitors are in possession of a mysterious apparatus which gives them an advantage over you. The apparatus has $n$ on/off swit... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Ashton appeared for a job interview and is asked the following question. Arrange all the distinct substrings of a given string in lex... |
user: Generate an executable Python 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 3 numbers a, b and x. You need to output the multiple of x which is closest to a^{b}. If more than one answer exists , 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.Michael and Joe are playing a game. The game is played on a grid with $n$ rows and $m$ columns, filled with distinct integers. We deno... |
user: Generate an executable Python 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$.
Consider all pairs of integer arrays $a$ and $p$ of the same length such that $n = \prod a_i^{p_i}$ (i.e. $a_1^... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.There are 3 hidden numbers A, B, C.
You somehow found out the values of \min(A, B), \min(B, C), and \min(C, A).
Determine whether th... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
$N$ integers $A_{1}, A_{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.Mafia is a social game played frequently by high school competitors in informatics on summer and winter camps and national competition... |
user: Generate an executable Python 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 keep the problem statement easy, shall we?
How many integers of length N are such that sum of square of digits in exactly K 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 has $x$ of red and $y$ of blue candies. Using them, he wants to make gift sets. Each gift set contains either $a$ red candies... |
user: Generate an executable Python 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 numbers, and another number target, find three integers in the array such that the sum is closest to the targ... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.A person wants to determine the most expensive computer keyboard and USB drive that can be purchased with a give budget. Given price 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.Trapped at home in quarantine, Johan tries to keep madness at bay and fend off isolation by playing Critter Junction, a social simulat... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Maggu is very serious about his work. He is so bossy that everyone fears him.
One day he gave his assistant N records with a number 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.Anmol and Biswa have got a water gun with colored pellets to hit Anurag as they have too much free time this semester. The pellets 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.You are given an array consisting of all integers from $[l, r]$ inclusive. For example, if $l = 2$ and $r = 5$, the array would be $[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 [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
You are given an integer $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.Ezio can manipulate at most X number of guards with the apple of eden.
Given that there are Y number of guards, predict if he can saf... |
user: Generate an executable Python 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 size $N$. You are asked to answer ${Q}$ queries.
Each query is of the form :
${ij x}$
You need 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 new type of chocolate arrived in the local shop. The chocolate comes in bars, each bar consisting of $N$ squares. Bars are factory 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 arr[] of size N and an integer K, the task is to left rotate the array K indexes
Example 1:
Input: N = 7, K = 2
arr[] =... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Its world war Z and you are a member of the secret crypto-society. Your team has intercepted an important piece of cryptic document fr... |
user: Generate an executable Python 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 valid postal code $\mbox{P}$ have to fullfil both below requirements:
$\mbox{P}$ must be a number in the range from 100000 to 9999... |
user: Generate an executable Python 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 path in some Unix-similar file system is given. The path consists of elements separated with characters "/". For example: "/usr/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.You are given a number $n$ and an array $b_1, b_2, \ldots, b_{n+2}$, obtained according to the following algorithm:
some array $a_1, ... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Little Mirko wrote into his math notebook an equation containing three positive integers, the equals sign and one of the four basic ar... |
user: Generate an executable Python 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 consisting of only lowercase characters whose anagrams are almost equal. The task is to count the number 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.Mirko has assembled an excellent crossword puzzle and now he wants to frame it. Mirko’s crossword puzzle consists of $M \times N$ lett... |
user: Generate an executable Python 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 having N elements, Chef wonders how many pairs (i, j) exists such that 1 ≤ i < j ≤ N, and A_{i} \cdot A_{j} is divisi... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Palindrome is a string that reads the same backward as forward, e.g., madam.
You are given a string whose length is even, and 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.Given a string S, remove all consonants and print the modified string that contains vowels only.
Example 1:
Input
S = "abEkipo"
Output... |
user: Generate an executable Python 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 integer is considered handsome if every two of its consecutive digits are of different parity. For a given integer $N$, what is its... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.HackerRank-city is an acyclic connected graph (or tree). Its not an ordinary place, the construction of the whole tree takes place 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.There are $n$ people at the railway station, and each one wants to buy a ticket to go to one of $\boldsymbol{\mbox{k}}$ different dest... |
user: Generate an executable Python 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 [Bengali] , [Mandarin chinese] , [Russian] and [Vietnamese] as well.
There is an ATM machine. Initially, 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.The re.sub() tool (sub stands for substitution) evaluates a pattern and, for each valid match, it calls a method (or lambda).
The me... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Summer is at its peak in Chefland. Chef is planning to purchase a water cooler to keep his room cool. He has two options available:
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.Tanya and Nina are very close friends, still Tanya is jealous of Nina's problem solving skills. To prove Nina that she is even better ... |
user: Generate an executable Python 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 Directed Graph, find a Mother Vertex in the Graph (if present).
A Mother Vertex is a vertex through which we can reach all 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.Please find the number of N-length strings that are made of only letters 'a, 'b', 'c' and 'd' and do not contain any of the restricted... |
user: Generate an executable Python 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 Deepak is the most popular cartographer in the entire realm of Game of Thrones. But, he has a simple problem: he's an alcohol a... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Vaibhav likes to play with numbers and he has N numbers. One day he was placing the numbers on the playing board just to count that how many numbers he has. He was placing the... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Given a number N. Check whether it is divisble by 4.
Example 1:
Input:
N = 1124
Output: 1
Explanation: The number is divisible by 4
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.Given an integer array and a non-negative integer k, count all distinct pairs with difference equal to k, i.e., A[ i ] - A[ 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.Given a graph which represents a flow network with N vertices numbered 1 to N and M edges.Find the maximum flow from vertex numbered 1... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.A tree of $\mbox{P}$ nodes is an un-directed connected graph having $P-1$ edges. Let us denote $\mbox{R}$ as the root node. If $\mbox{... |
user: Generate an executable Python 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], [Vietnamese], and [Bengali] as well.
A semester in Chef's University has $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.Each resident of a particular town is a member of zero or more clubs and also a member of exactly one political party. Each club is 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.Thalia is a Legendary Grandmaster in chess. She has $n$ trophies in a line numbered from $1$ to $n$ (from left to right) and a lamp 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 are given a string $\mbox{S}$.
$\mbox{S}$ contains alphanumeric characters only.
Your task is to sort the string $\mbox{S}$ 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 playing a racing game. Your character starts at the X-axis line ($y=0$) and proceeds up the racetrack, which has a boundary at... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Read problem statements in [Russian], [Mandarin] and [Vietnamese] as well.
You are given a permutation P of integers from 1 to N, 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.Aujasvit just came up with a new game to play with his friends. N people stand in a circle, each assigned an index from 1 to N in cloc... |
user: Generate an executable Python 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’s favorite season is winter. Caught up in the festivities, Peter would like to decorate his city.
The city has many areas for 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 Cirular Linked List of size N, split it into two halves circular lists. If there are odd number of nodes in the given circular... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Your friend Nick needs your help with a hard problem that he came across in real life. Nick has a loo roll of length $\ell $ centimetr... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.A set is an unordered collection of elements without duplicate entries.
When printed, iterated or converted into a sequence, its 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.You are given a positive integer X. Your task is to tell whether there exist two positive integers a and b (a > 0, b > 0) such that
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.Given a 32 bit unsigned integer num and an integer i. Perform following operations on the number -
1. Get ith bit
2. Set ith bit
3. 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 natural number N, find the count of numbers from 1 to N that have an odd number of divisors.
Example 1:
Input:
N = 1
Outpu... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.You are given an array A consisting of N integers.
From array A, we create a new array B containing all pairwise bitwise ANDs of elem... |
user: Generate an executable Python 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 positive number $x$ of length $n$ in base $p$ ($2 \le p \le 10^9$) is written on the blackboard. The number $x$ is given as a sequen... |
user: Generate an executable Python 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 Q queries of indices, print the number of next greater elements(NGEs) to the right of the given index... |
user: Generate an executable Python 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 spend this summer planning next year’s summer vacation. They want to travel from the old city of A-town to the popular 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 string str of length N. The task is to find the minimum characters to be added at the front to make string palindrome.
Note: A p... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Sean’s Swathers makes custom swathers (equipment used to harvest grain). All swathers go through the same basic stages in their constr... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Jonas is developing the JUxtaPhone and is tasked with animating the compass needle. The API is simple: the compass needle is currently... |
user: Generate an executable Python 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 might be familiar with the binomial coefficient ${m \choose k}$ defined as ${m \choose k} = \frac{m!}{k!(m-k)!}$, where $m$ and $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 competing in a ski slalom, and you need to select the best skis for the race. The format of the race is that there are $N$ pai... |
user: Generate an executable Python 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 convex polygons $A$ and $B$. It is guaranteed that $B$ is strictly contained inside of $A$.
You would like to make ... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Read problem statements in [Mandarin], [Vietnamese], and [Russian] as well.
Miana and Serdenopis have guests for dinner tonight and 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 infinite supply of each denomination of Indian currency { 1, 2, 5, 10, 20, 50, 100, 200, 500, 2000 } and a target value N.
Fi... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.There's a chip in the point $(0, 0)$ of the coordinate plane. In one operation, you can move the chip from some point $(x_1, y_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.Read problems statements in Mandarin Chinese and Russian.
Chef is judging a game called "Broken telephone". There are total N playe... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.