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.Mark and Jane are very happy after having their first child. Their son loves toys, so Mark wants to buy some. There are a number of di...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Timur's grandfather gifted him a chessboard to practice his chess skills. This chessboard is a grid $a$ with $n$ rows and $m$ columns ...
user: Generate an executable Python 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 time in $12$-hour AM/PM format, convert it to military (24-hour) time. Note: - 12:00:00AM on a 12-hour clock is 00:00:00 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.Ronit is working on HackerEarth Profile. Right now he is working on User Statistics. One of the statistics data (Code Streak) is as 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.Mark has just purchased a rack of $n$ lightbulbs. The state of the lightbulbs can be described with binary string $s = s_1s_2\dots s_n...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Read problems statements in Mandarin Chinese here ------ Problem Statement ------ As we know, Fibonacci Number is defined as 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.Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well. Chef and his friend Chefu dec...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Check Tutorial tab to know how to to solve. You are given a string $N$. Your task is to verify that $N$ is a floating point numbe...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Jigar got a sequence of n positive integers as his birthday present! He likes consecutive subsequences whose sum is divisible by k. He...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given an array arr[], and you have to re-construct an array arr[]. The values in arr[] are obtained by doing Xor of consecutive elements in the array. Example 1: Input...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Read problems statements in Mandarin Chinese and Russian. Some chefs go for a tour lasting N days. They take packages of bread for 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.On a planet called Natoon, a person's wealth as well as health is measured by the amount of gold the person has. For example if a pers...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Simon: On the fountain, there should be 2 jugs - a 5 gallon and a 3 gallon. Do you see them? Fill one of the jugs with exactly 4 gallo...
user: Generate an executable Python 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 remembered the $2020$-th year, and he is happy with the arrival of the new $2021$-th year. To remember such a wonderful momen...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Manasa was sulking her way through a boring class when suddenly her teacher singled her out and asked her a question. He gave her a nu...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Given a set of n non-negative integers, and a value m, determine if there is a subset of the given set with sum divisible by m. 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.Given a registry of all houses in your state or province, you would like to know the minimum size of an axis-aligned square zone such ...
user: Generate an executable Python 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 number N, print sum of all of its digits. Input First Line of input contains integer T denoting number of test cases. Next 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 range L to R, the task is to find the highest occurring digit in prime numbers which lie between L and R (both inclusive). 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.Read problem statements in [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well. Chef has $N$ [6-sided standard dice]. ...
user: Generate an executable Python 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 student called Slon is very mischievous in school. He is always bored in class and he is always making a mess. The teacher wanted to...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Given two given numbers a and b where 1<=a<=b, find the number of perfect squares between a and b (a and b inclusive). 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.2) Krishna had just completed his class on trees. To make things worse , the teacher had asked them to draw all possible ‘Binary Tree...
user: Generate an executable Python 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 list intervals of n intervals, the ith element [s, e, p] denotes the starting point s, ending point e, and the profit p earned...
user: Generate an executable Python 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 United Federation of Planets is an alliance of N planets, they are indexed from 1 to N. Some planets are connected by space tunnel...
user: Generate an executable Python 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’s that time of the year when students head back to school, which will usually involve moving lots of stuff, and packing lots of tha...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.In a nearby village, the postman, milkman and garbage man face the same problem morning after morning: house 18. House 18 is guarded 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.Given a linked list of size N. The task is to complete the function countNodesinLoop() that checks whether a given Linked List contain...
user: Generate an executable Python 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. The apocalyptic demon Kali is on a rampage. The ground shudders under his...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Read problems statements in Mandarin Chinese and Russian as well. Chef wants to implement wildcard pattern matching supporting only ...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Given an array of integers Arr of size N and a number K. Return the maximum sum of a subarray of size K. NOTE*: A subarray is a contig...
user: Generate an executable Python 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. As everybody knows, Reza Shir...
user: Generate an executable Python 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 directed acyclic graph, consisting of $n$ vertices and $m$ edges. The vertices are numbered from $1$ to $n$. There 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.Given a set of distinct positive integers nums, return the largest subset answer such that every pair (answer[i], answer[j]) of elemen...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Doremy has $n$ buckets of paint which is represented by an array $a$ of length $n$. Bucket $i$ contains paint with color $a_i$. Let $...
user: Generate an executable Python 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. Let A be an N \times N grid such that A_{i, j} = i + N\cdot(j-1) for 1 ≤ i, j ≤ N. For example, if N = 4 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.Team Red and Team Blue competed in a competitive FPS. Their match was streamed around the world. They played a series of $n$ matches. ...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Lucifer is having a permutation of integers from 1 to N denoted by P. Let i^th element of P be denoted as Pi. For all pairs of distinc...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.You are given an array $a$ consisting of $n$ positive integers. You are allowed to perform this operation any number of times (possib...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Tom and Jerry are wonderful characters. They are always running and make us laugh. Right now, they are in a grid of houses and Jerry ...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Enter-View $\left({\mbox{EV}}\right)$ is a linear, street-like country. By linear, we mean all the cities of the country are placed on...
user: Generate an executable Python 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 if it is Disarium or not. A number is called Disarium if sum of its digits powered with their respective positi...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Sevenkplus has a regular polygon. Each vertex of the polygon has a color, either white or black. Sevenkplus wants to count the number ...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Berland Music is a music streaming service built specifically to support Berland local artist. Its developers are currently working on...
user: Generate an executable Python 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 length $n$, tell us whether it has a non-empty subsequence such that the product of its elements is not a perfec...
user: Generate an executable Python 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 loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the luck...
user: Generate an executable Python 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 Rumbling is a hypothetical cataclysmic event involving Karl Fritz's Wall Titans marching across the Earth, destroying all life upo...
user: Generate an executable Python 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 positive integers N and K. You have to perform the following operation exactly K times: - For the current value of 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 Hill Number is a positive integer, the digits of which possibly rise and then possibly fall, but never fall and then rise. For 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.Problem Statement Mark’s company Facebook employed n coders .Now Mark needs to build a tree hierarchy of supervisor - subordinate rel...
user: Generate an executable Python 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 coordinates of four points in a plane. Find if the four points form a square or not. Example 1: Input: points=(0,0),(0,1),(1,0),...
user: Generate an executable Python 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 link to the Russian translation. Enzo is trying to reach Bonnie in her dream. Bonnie's dreamland is so big. It has n cities 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.It's Galactik Football time! The Galactik Football Assosiation (GFA) has announced a football tournament between all the teams of all ...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Organising a group trip for the elderly can be a daunting task... Not least because of the fussy participants, each of whom will only ...
user: Generate an executable Python 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 positive integers Arr_{1}, Arr_{2} ............ Arr_{n}. The value of each contiguous subarray of given array 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.Fooland city has a special multi-lane running track. Lanes are numbered from 1 to Tracks. The lanes have N horizontal barriers lying o...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Given a string N representing a positive number. The task is to round N to the nearest multiple of 10. Note: If you are having two mu...
user: Generate an executable Python 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 was Fredo's birthday yesterday. He got a simple graph of N vertices and M edges as one of the birthday gifts. He has been bragging...
user: Generate an executable Python 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 buildings in Linear Land. They appear in a linear line one after the other and their heights are given in the array 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.There is an array A with N elements. Each element of A has a fixed *polarity*: either north or south. Chef is allowed to perform som...
user: Generate an executable Python 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 binary string str of length N. The task is to find the maximum count of consecutive substrings str can be divided into such that...
user: Generate an executable Python 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 a sequence $A$ of $N$ integers such that $|A_{i}| ≤ 1$. For each $x$ such that $-N ≤ x ≤ N$, find the number of non-empty su...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.You are given a string $s$. You need to find two non-empty strings $a$ and $b$ such that the following conditions are satisfied: Stri...
user: Generate an executable Python 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 B of equal length, find how many times the corresponding position in the two strings hold exactly the same cha...
user: Generate an executable Python 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 you look at photographs of watches and clocks, you'll find that they almost always show the time 10:10. There are lots of theorie...
user: Generate an executable Python 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. Peter decided to surprise his class by organizing a new lottery with a very peculiar system. He starts by announcing a small po...
user: Generate an executable Python 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 classroom with two rows of computers. There are $n$ computers in each row and each computer has its own grade. Computers 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.The postal service is interested in cutting costs as an alternative to raising the postage rates. One way to do this is by minimizing ...
user: Generate an executable Python 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.A pronic number is a number which is the product of two consecutive integers. Find all Pronic Numbers less than or equal to the given...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.You are given two integers $l$ and $r$, $l\le r$. Find the largest possible value of $a mod b$ over all pairs $(a, b)$ of integers for...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Bauua is very fond of fibonacci numbers so one day he thought of an AMAZing series of which each term can be expressed as f(n)=af(n-1...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Given two coordinates (x, y) and (a, b). Find if it is possible to reach (x,y) from (a,b). Only possible moves from any coordinate (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.Let's denote the Manhattan distance between two points $p_1$ (with coordinates $(x_1, y_1)$) and $p_2$ (with coordinates $(x_2, y_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.Cat Taro recently discovered how to reverse a number. He defines a function rev(x) that returns the reverse of the base-10 representat...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Given a positive number k, we need to find a minimum value of positive integer n, such that XOR of n and n+1 is equal to k. If no such...
user: Generate an executable Python 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 path in the form of a rectangular matrix having few landmines arbitrarily placed (marked as 0), calculate length of the shorte...
user: Generate an executable Python 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 5 integers K, L, R, X, Y. Find whether there exists two integers A and B such that A / B = K where L ≤ A ≤ R and X ≤ B ≤ Y. Exam...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Euler’s number (you may know it better as just $e$) has a special place in mathematics. You may have encountered $e$ in calculus or ec...
user: Generate an executable Python 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 fantasy hockey, there are $n$ team owners that each selects $k$ hockey players. To determine which owner gets which players, the ow...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Once upon a time, high up on Mount Olympus, it came to pass that the gods held a competition to see who among them was the best at sor...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Nikita just came up with a new array game. The rules are as follows: Initially, Nikita has an array of integers. In each move, Nikit...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.You are a member of the Senate of an ancient empire governed by a mighty dictator. You have joined a bipartisan secret committee of th...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Read problems statements in Mandarin Chinese and Vietnamese as well. It is well-known that ∑sqrt(a_{i}), a_{i} ∈ N is a root of some...
user: Generate an executable Python 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. Consider an integer sequence A = [A_{1}, A_{2}, \ldots, A_{N}]. Define another sequence S of length N, 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.Read problems statements in [Hindi], [Mandarin Chinese], [Russian], [Vietnamese], and [Bengali] as well. Teams $A$ and $B$ are having...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Biswa and Debu are playing a weird word game. Biswa has a set S of N strings. Debu makes Q turns. In each turn he gives Biswa a 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.Russian Translation Available You are given a weighted graph with N vertices and M edges. Find the total weight of its maximum spanni...
user: Generate an executable Python 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 company "Divan's Sofas" is planning to build $n + 1$ different buildings on a coordinate line so that: the coordinate of each bui...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well. Chef is playing a card game 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.Daenerys frequently invents games to help teach her second grade Computer Science class about various aspects of the discipline. 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.Write a program that, given a date in $2009$, determines the day of week on that date. -----Input----- The first line contains two po...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.The cost of stock on each day is given in an array price[] of size n. Find all the days on which you buy and sell the stock so that in between those days your profit is maximu...
user: Generate an executable Python 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 company manager gave projects to the employees of his company. The employees have to form a team of two for doing the project. The 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.You are given an array A of N integers . You want to convert the array A into a permutation of N integers. To do this, you can apply 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.Theta likes to bake cookies for the upcoming holidays. She has a selection of cookie cutters of different shapes and sizes. She thinks...
user: Generate an executable Python 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 and an integer X. In one operation, you can change the i^{th} element of the array to any integer va...
user: Generate an executable Python 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. Write a program to find the number of digits in the product of these two integers. Example 1: Input: 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.Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well. Chef is teaching a cooking co...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.We define the *goodness* of any array B of length M as: \sum_{i = 1}^{M - 1} |B_{i + 1} - B_{i}| (Here |X| denotes the absolute value ...