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.Murphy wants her brother Tom to leave their house as she need to do some serious work inside the house to save the earth!
But Tom is ... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.The city where Mocha lives in is called Zhijiang. There are $n+1$ villages and $2n-1$ directed roads in this city.
There are two kind... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Many airports have moving conveyor belts in the corridors between halls and terminals. Instead of walking on the floor, passengers 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.Tribonacci numbers are a sequence of numbers, defined as follows:
* t0 = t1 = 0,
* t2 = 1,
* ti = ti - 1 + ti - 2 + ti - 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.A number is algebraic if it is a root of some nonzero polynomial with integer coefficients. A number is transcendental if it is not 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.RK and RG are best friends. They are very particular in maintaining their Swag Level. Now, RK and RG travel to a mysterious place. 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.Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
You are given a 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.Anatoly Cheng McDougal is a typical student in many ways. Whenever possible he tries to cut and paste code instead of writing it 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.Nastia has received an array of $n$ positive integers as a gift.
She calls such an array $a$ good that for all $i$ ($2 \le i \le 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 string S which contains only small letters. The task is to make a square matrix from string S. Then perform the following oper... |
user: Generate an executable Python 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 coronation of King Berl XXII is soon! The whole royal family, including n daughters of Berl XXII, will be present.
The King has 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.There are p balls of type P, q balls of type Q and r balls of type R. Using the balls we want to create a straight line such that no 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.Charles is traveling to the fantastic Fibonacci City. The city has $n$ mansions of various heights and $m$ bi-directional roads connec... |
user: Generate an executable Python 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 distinct elements. Find the minimum number of swaps required to sort the array in strictly increasing order.
Examp... |
user: Generate an executable Python 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 triangle of numbers where each number is equal to the sum of the three numbers on top of it, find the first even number in a 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.As punishment for attacking Sunland, Wet Shark is now forced to walk on a line of numbered squares, starting from $\mbox{1}$ and going... |
user: Generate an executable Python 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, a subarray S of A is called good if XOR(S) ≥ K, where XOR(S) denotes the [bitwise XOR] of 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.Chef has 2 strings A and B of equal length N. Both strings contain lowercase english alphabets only.
Chef can perform several moves o... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.A deque is a double-ended queue that allows enqueue and dequeue operations from both the ends.
Given a deque and Q queries. The task is to perform some operation on dequeue ac... |
user: Generate an executable Python 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 A of length N, let F(A) denote the sum of the product of all the subarrays of A. Formally,
F(A) = \sum_{L=1}^N \sum_{R=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.In a previous challenge you implemented the Insertion Sort algorithm. It is a simple sorting algorithm that works well with small or 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 three distinct numbers A, B and C. Find the number with value in middle (Try to do it with minimum comparisons).
Example 1:
Inpu... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Last year iElectro has given a circuit deigning problem , in which participants will have to prepare a grid of bulbs such that ,if you... |
user: Generate an executable Python 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 Greg’s birthday! To celebrate, his friend Sam invites Greg and two other friends for a small party. Of course, every birthday pa... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.A string is k palindrome if it can be transformed into a palindrome on removing at most k characters from it. Your task is to complete the function is_k_palin which takes 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.Announcement
************Second Round will be ONLINE instead of ONSITE*************
Problem Statement
It’s 18th Century and the king ... |
user: Generate an executable Python 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(A) denote the maximum frequency of any element present in the array.
For example:
If 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.You read scientific research regarding popularity of most famous superstitions across various countries, and you want to analyze their... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.The Imitation Game is a 2014 film based in 1939 during World War II. It follows the newly created British intelligence agency MI6 as 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.The home office of Labyrinthian Inc. has installed a new system of security badges and electronic door locks. Each badge is assigned 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.All of you are probably very familiar with the problem of finding the longest monotone subsequence. You probably think you know all ab... |
user: Generate an executable Python 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 daily train consists of N cars. Let's consider one particular car. It has 54 places numbered consecutively from 1 to 54, some of whi... |
user: Generate an executable Python 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.
Having already mastered cooki... |
user: Generate an executable Python 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.
In one operation, Chef can remove any one element from the array.
Determine the minimum 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.Nick is a bird watcher and often visits the forum “CrowFinders” to discuss his hobby with like-minded people. CrowFinders has a voting... |
user: Generate an executable Python 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 problem is to implement disjoint set union. There will be 2 incomplete functions namely union and find. You have to complete thes... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Read problem statements in [Mandarin], [Bengali], [Russian], and [Vietnamese] as well.
Chef aims to be the richest person in Chefland... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.You've got a string $S$ consisting of $n$ lowercase English letters from your friend. It turned out that this is a number written in 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.Given three distinct integers $a$, $b$, and $c$, find the medium number between all of them.
The medium number is the number that is ... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Read problems statements in Mandarin chinese, Russian and Vietnamese as well.
You work as an engineer. You were given an empty board... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Ancay youyay eakspay igpay atinlay? (Can you speak pig latin?) If you can’t, here are the rules:
- If a word begins with a consonant,... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Bowling is a sport in which a player rolls a bowling ball towards a group of pins, the target being to knock down the pins at the end ... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Bees are one of the most industrious insects. Since they collect nectar and pollen from flowers, they have to rely on the trees in 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.Consider a long alley with a N number of doors on one side. All the doors are closed initially. You move to and fro in the alley chang... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.As we know, Ishaan has a love for chocolates. He has bought a huge chocolate bar that contains N chocolate squares. Each of the square... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Geeks Island is represented by an N * M matrix mat. The island is touched by the Indian Ocean from the top and left edges and the Arab... |
user: Generate an executable Python 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 an array A of N integers. You need to find the minimum cost of creating another array B of N integers with 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.You are given a permutation $p_1, p_2, \dots, p_n$. Then, an undirected graph is constructed in the following way: add an edge between... |
user: Generate an executable Python 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 chocolates. But he can't reach the kitchen shelf which has 'N' chocolates. His family has K members and he can 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.Ricky gives a number 'n' to John. Now Ricky wants John to generate Z with symbol "*" such that it spans n rows.
Example:
Input : n=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.To destroy humanity, The Monster Association sent $n$ monsters to Earth's surface. The $i$-th monster has health $h_i$ and power $p_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.A certain type of steel is graded according to the following conditions.
1. Hardness of the steel must be greater than 50
2. Carbon 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.The country of BitLand is divided into N districts, and these districts are arranged in a circle: 1, 2, 3, ..., N, where i and i+1 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.The followers of Psycho-Helmet religion follow a peculiar calendar – a normal year contains N days. Every K-th year is a “MOB” year. F... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Least common multiple (LCM) of two numbers is the smallest positive integer which is divisible by both of them. You are given integers... |
user: Generate an executable Python 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], [Vietnamese] and [Bengali] as well.
Ada has two matrices $A$ and ... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Having just moved to Transylvania, one of the first orders of business is to get a transit card for the public transportation. The tra... |
user: Generate an executable Python 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$ block towers, numbered from $1$ to $n$. The $i$-th tower consists of $a_i$ blocks.
In one move, you can move one block ... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Did you know you can download more RAM? There is a shop with $n$ different pieces of software that increase your RAM. The $i$-th RAM 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.You have recently made a grid traversing robot that can find its way from the top left corner of a grid to the bottom right corner. Ho... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Given an array of integers, your task is to find the smallest and second smallest element in the array. If smallest and second smallest do not exist, print -1.
Example 1:
Inpu... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Ishika got stuck on an island. There is only one shop on this island and it is open on all days of the week except for Sunday. Conside... |
user: Generate an executable Python 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 year is 2312, and Humanity’s Rush to the Stars is now $200$ years old. The problem of real-time communication between star systems... |
user: Generate an executable Python 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 [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
You are given an array A of size N. 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.One day Bob drew a tree, $\mathbf{T}$, with $n$ nodes and $n-1$ edges on a piece of paper. He soon discovered that parent of a node de... |
user: Generate an executable Python 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 strange counter. At the first second, it displays the number $3$. Each second, the number displayed by decrements by $\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.Pathfinding is a task of finding a route between two points. It often appears in many problems. For example, in a GPS navigation softw... |
user: Generate an executable Python 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 integers from 1 to N. Count the interesting pairs of (A, B) that satisfy the following conditions:
A and B 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.A permutation is a sequence of $n$ integers from $1$ to $n$, in which all numbers occur exactly once. For example, $[1]$, $[3, 5, 2, 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 new student dorm has been opened! It consists of $M$ buildings, labeled with integers from $1$ to $M$. The dorm is initially empty, ... |
user: Generate an executable Python 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 digits (values are from 0 to 9), find the minimum possible sum of two numbers formed from digits of the array. All d... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.You are given three positive integers N, x, and y.
Count the number of arrays P of length N such that:
P_{1} = P_{N} = 1
There are ex... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Alice likes digits very much. She thinks some digits are lucky digits. She also calls numbers consisting ALL the lucky digits at least... |
user: Generate an executable Python 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 reason to leave this place, but I don't."*
In the fourth game, Sang-Woo and Ali are competing against each other. Sang-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.Given a 2d list that represents the nodes of a Binary tree with N nodes, the task is to find the maximum GCD of the siblings of this 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 string without spaces, the task is to remove duplicates from it.
Note: The original order of characters must be kept the same... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Given a string S consisting of upper/lower-case alphabets and empty space characters ‘ ‘. The string may contain spaces at the end. Yo... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Mehta is a very lazy boy. He always sleeps in Maths class. One day his teacher catches him sleeping and tells him that she would mark ... |
user: Generate an executable Python 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's apartment consists 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.Phoebe enjoys playing music. She especially enjoys playing it for her friends.
Phoebe has made a new musical instrument. The instrume... |
user: Generate an executable Python 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, $a$ and $\boldsymbol{b}$, find and print the total number of ways to insert a character at any position in 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.Professor McGonagall teaches transfiguration at Hogwarts. She has given Harry the task of changing himself into a cat. She explains 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.Watson gives Sherlock an array of integers. Given the endpoints of an integer range, for all $M$ in that inclusive range, determine t... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Given a singly linked list, your task is to remove every k^{th} node from the linked list.
Input:
The first line of input contains number of test cases T. Then T test cases 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.-----Input-----
The first line of input contains a line with four non-negative integers, $2 \le n \le 500$, $0 \le m \le 10000$, $0 \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.Mount Snowdon, the tallest place in Wales, is a major attraction for mountain bikers far and wide. To take advantage of the popularity... |
user: Generate an executable Python 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 integer array $a_1, a_2, \dots, a_n$ good if $a_i \neq i$ for each $i$.
Let $F(a)$ be the number of pairs $(i, j)$ ($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.Bob has just learned number theory and is very excited about it. Unlike everytime, Bob is not in trouble this time, but being kind hea... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Prof. Twotwo as the name suggests is very fond powers of 2. Moreover he also has special affinity to number 800. He is known for carry... |
user: Generate an executable Python 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 pyramid of the following form with an infinite number of rows:
1
2\ 3
4\ 5\ 6
7\ 8\ 9\ 10
...........
From a cell, ... |
user: Generate an executable Python 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 positive numbers X and Y, check if Y is a power of X or not.
Example 1:
Input:
X = 2, Y = 8
Output:
1
Explanation:
2^{3} 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..remove(x)
This operation removes element $\boldsymbol{x}$ from the set.
If element $\boldsymbol{x}$ does not exist, it raises 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.Alice and Bob were playing a game yet again but this time, Bob already lost the game. Now he wants to take revenge.
Bob saw a jigsaw ... |
user: Generate an executable Python 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 positive integers num1 and num2, subtract num2 from num1 on a 12 hour clock rather than a number line.
Note: Assume the 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.Given a number N.Find the nearest number which is a power of 2 and greater than or equal to N.
Example 1:
Input:
N = 1
Output:
1
Expla... |
user: Generate an executable Python 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 many people, the word “Peru” conjures up images of the Inca temple Machu Picchu and llamas. But for some visitors to the country, ... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Mr. Lucky has a store that sells numbers. These numbers have an interesting property: each number formed by its first $k$ digits is ev... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.While diving in ancient river of Egypt, Shil came across an oblivion treasure of algorithms and data structures.This treasure has powe... |
user: Generate an executable Python 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 integers. The task is to find if there are two pairs (a, b) and (c, d) such that a+b = c+d.
Example 1:
Input:N=7... |
user: Generate an executable Python 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 basketball competition is held where the number of players in a team does not have a maximum or minimum limit (not necessarily $5$ p... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.