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.Kiyora has $n$ whiteboards numbered from $1$ to $n$. Initially, the $i$-th whiteboard has the integer $a_i$ written on it.
Koxia perf... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Given a non-negative number num in the form of string. The task is to apply at most one swap operation on the number num so that the 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.Read problems statements in Mandarin Chinese, Russian and Vietnamese as well.
Nim is a well-known combinatorial game, based on removi... |
user: Generate an executable Python 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 pattern string and a test string, If the pattern is preceded by a ^, the pattern(excluding the ^) will be matched with the sta... |
user: Generate an executable Python 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 many excellent strategy board games, and your favourite among them is called “Steel Age”. It offers many different paths 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.You are given two arrays of integers $a_1, a_2, \ldots, a_n$ and $b_1, b_2, \ldots, b_n$.
Let's define a transformation of the array ... |
user: Generate an executable Python 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 newly opened multinational brand has decided to base their company logo on the three most common characters in the company name. 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 a string $S$ consisting of lowercase English characters. Chef defined functions left shift $L(X)$ and right shift $R(X)$ 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.Fibonacci numbers have the following form:
$\begin{aligned}F_1&-1\\ F_2&=1\\ F_3&=2\\ \vdots\\ F_n&=F_{n-2}+F_{n-1}\end{aligned}$
... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Marin wants you to count number of permutations that are beautiful. A beautiful permutation of length $n$ is a permutation that has 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, Russian and Vietnamese as well.
You are given a structure of a water reservoir. The re... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Chef and his son Chefu want 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.Consider a sequence of $N$ integers where each integer between $1$ and $N$ appears exactly once.
A pair of numbers in the sequence 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 problem statements in [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
You are given an integer $C$. Let $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.Farmer Jon has recently bought $n$ tree seedlings that he wants to plant in his yard. It takes $1$ day for Jon to plant a seedling1, a... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Given an array $\boldsymbol{A\left[\right]}$ of $N$ distinct elements. Let $M_1$ and $M_2$ be the smallest and the next smallest 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.A strange grid has been recovered from an old book. It has $5$ columns and infinite number of rows. The bottom row is considered as 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 [Russian], [Mandarin Chinese], [Bengali], and [Vietnamese] as well.
It's the soccer match finals in Chefla... |
user: Generate an executable Python 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 is given an array A consisting 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.There are N cities and N directed roads in Steven's world. The cities are numbered from 0 to N - 1. Steven can travel from city i to 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 positive integer, $n$, find and print the number of pairs of positive integers $(a,b)$, where $a<b$, that exist such that 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.Polycarp is working on the implementation of displaying likes on the Codehorses social network. The number of likes should be displaye... |
user: Generate an executable Python 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 ticket is a string consisting of six digits. A ticket is considered lucky if the sum of the first three digits is equal to the sum 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.Subly went to meet the Chef. As the Chef gets a lot of problems from his friends, he wants Subly to help him find a good programmer.
... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Every day after school, you and your friends get together and play in a band. Over the past couple of months, the band has been rehear... |
user: Generate an executable Python 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 positive integer $x$. Multiply its nonzero digits and you get another integer $y$. Repeating this process, you eventually 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.Your favourite social media website is changing their policy on login password validation: a slight error when logging in is now accep... |
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 consisting of N positive integers, and an integer k .You have to find the maximum product of k contiguous elements in the array. Your task is to complete the fu... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Given a sorted array arr[ ] of N positive integers. Your task is to find an index i in the array from where the number of elements smaller than arr[i] in the left side of 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.Reduce a string of lowercase characters in range ascii[‘a’..’z’]by doing a series of operations. In each operation, select a pair 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.Read problems statements in Mandarin Chinese, Russian and Vietnamese as well.
Chef has recently got a broadband internet connection.... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Simone’s mother often complains about how Simone never helps with chores at home. In return, Simone often points out that many of 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.The evil emperor Cactus has in his possession the Magic Keg and has flooded the Enchanted Forest! The Painter and the three little hed... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Abhinav is master in game theory. He creates new games with a great logic and today he has created another one. He invites his best 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.Given an array of stick lengths, use $3$ of them to construct a non-degenerate triangle with the maximum possible perimeter. Return an... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Read problems statements in Mandarin chinese, Russian and Vietnamese as well.
Chef has fallen into the Labyrinth!
Fortunately, Chef... |
user: Generate an executable Python 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 developing a project to build a new data center. The data center will be a rectangle with an area of exactly n square meters. ... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Given two binary numbers A,B i.e., numbers containing only zero or one. Let the i th bit of A and i th bit of B differ by d. We need ... |
user: Generate an executable Python 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 Divan analyzed a sequence $a_1, a_2, \ldots, a_n$ consisting of $n$ non-negative integers as follows. He considered each non-empt... |
user: Generate an executable Python 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 family of $n$ gnomes likes to line up for a group picture. Each gnome can be uniquely identified by a number $1..n$ written on 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.Given N and M Dexter wants to know how many pairs a,b(1 ≤ a < b ≤N) are there such that (a+b) is divisible by M.
For example when 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.You’ve just come out of a theatre after watching X-Men, and you’re thinking of mutation. You cannot just move on. You’re stuck on muta... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Complete the function to find spiral order traversal of a tree. For below tree, function should return 1, 2, 3, 4, 5, 6, 7.
Example 1:
Input:
1
/ \
3 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 [Russian], [Mandarin Chinese], [Bengali], and [Vietnamese] as well.
You are given a string S consisting of... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.You are playing a game in which a group of players take turns saying animal names. The animal name you say when it is your turn must 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.In this problem, you have to analyze a particular sorting algorithm. The algorithm processes a sequence of $n$ distinct integers by sw... |
user: Generate an executable Python 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 always hope things in our lives will run smoothly, and having smooth arrays may help. An array $A$ of $N$ non-negative integers 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.You are given the equation $\tan\alpha=\frac{p}{q}$ and a positive integer, $n$. Calculate $\tan n\alpha$. There are $\mathbf{T}$ test... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Yi has moved to Sweden and now goes to school here. The first years of schooling she got in China, and the curricula do not match comp... |
user: Generate an executable Python 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 arrays $a$ and $b$ of $n$ positive integers each. You can apply the following operation to them any number of times:... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Driving through the Irish countryside, one frequently sees enigmatic small grey stones sitting by the wayside, spaced about a kilometr... |
user: Generate an executable Python 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 recent lab accident resulted in the creation of an extremely dangerous virus that replicates so rapidly it's hard to predict exactly... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.You are given an array of integer numbers. Calculate the sum of its elements.
Input
The first line of the input contains an integer ... |
user: Generate an executable Python 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 found the string $s$ and the permutation $p$. Their lengths turned out to be the same and equal to $n$.
A permutation 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.Arthur defines a function, $f(k)$, to be the number of $(p,q)$ pairs such that:
$1<p\leq q\leq k$
${p}$ and $q}$ are coprime.
$p\cdot... |
user: Generate an executable Python 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 $\mbox{A}$ and $n$ other sets.
Your job is to find whether set $\mbox{A}$ is a strict superset of each of the $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.Alice is driving from her home to her office which is A kilometers away and will take her X hours to reach.
Bob is driving from 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.Mirko’s ASCII street is made of $N$ lowercase letters of the English alphabet. The city government occasionally replaces the tiles 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.A sequence of brackets is called balanced if one can turn it into a valid math expression by adding characters «+» and «1». For exampl... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Given a sorted array with duplicate elements and we have to find the index of the last duplicate element and return the index of it and also return the duplicate element.
E... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Chef recently realized that he needs a haircut, and went to his favorite hair salon. At the salon, he found N customers waiting for 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.Alice buys a toy with a selling price of 100 rupees. There is a discount of x percent on the toy. Find the amount Alice needs to pay 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.You and Your friend play BADMINTON together. Each game of BADMINTON ends in one of two ways -- win, lose. you Both have been playing 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.Lexicographical order is often known as alphabetical order when dealing with strings. A string is greater than another string if it c... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Let F(S) denote the number of distinct elements in the array S. For example, F([1, 2, 3, 2]) = 3, F([1, 2]) = 2.
You are given an 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.You are given a square grid with $n$ rows and $n$ columns, where each cell has a non-negative integer written in it. There is a chip 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.For a [permutation] P of the integers 1 to N, we define a new array A_{P} of length N-2 as follows:
For 1 ≤ i ≤ N-2, (A_{P})_i denote... |
user: Generate an executable Python 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 has n employees numbered from 1 to n. Each employee either has no immediate manager or exactly one immediate manager, who 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.Bob is a dance teacher and he started dance classes recently. He observes a strange attendance pattern among his students. Initially, ... |
user: Generate an executable Python 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 an infinite two dimensional array $F$ using the following formula:
- $F_{0, 0} = 0$,
- $F_{0, 1} = F_{1, 0} = 1$,
- 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.Every (positive) rational number can be expressed as a ratio of two (positive) integers. However, in decimal form, rational numbers 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.Masha is going to participate in a talent show conducted by the university she studies at. She wants to impress the audience with lots... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Recall that a tree is an undirected, connected acyclic graph. We have a weighted tree, $\mathbf{T}$, with $n$ vertices; let $dist_{u,v... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Note: You can skip to BRIEF if you do not want to read the complete story.
Khaolin Temple is world's most famous algorithmic pilgrima... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.JJ has an array A of size N. He can perform the following operations on the array at most K times:
Set A_{i} := A_{i + 1} where 1 ≤ i... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Read problem statements in [Mandarin], [Bengali], [Russian], and [Vietnamese] as well.
Ujan is a software developer. He is developing... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.n pupils, who love to read books, study at school. It is known that each student has exactly one best friend, and each pupil is the be... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Chef has two arrays A and B of the same size N.
In one operation, Chef can:
Choose an index i (1 ≤ i ≤ N) and swap the elements A_{i}... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.There is a sheet of paper that can be represented with a grid of size $n \times m$: $n$ rows and $m$ columns of cells. All cells are 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.Gunnar and Emma play a lot of board games at home, so they own many dice that are not normal $6$-sided dice. For example they own a 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.sum
The sum tool returns the sum of array elements over a given axis.
import numpy
my_array = numpy.array([ [1, 2], [3, 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.The square-ten tree decomposition of an array is defined as follows:
The lowest (${0}^{t h}$) level of the square-ten tree consists 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.Ever wonder what will happen when you meet a person who uses a different base system to talk about numbers? For example, when you hear... |
user: Generate an executable Python 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, find the longest palindromic substring in S. Substring of string S: S[ i . . . . j ] where 0 ≤ i ≤ j < len(S). Palin... |
user: Generate an executable Python 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 teacher asks the class to open their books to a page number. A student can either start turning pages from the front of the book or ... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Vjekoslav the Wolf is running away from a bunch of blood hungry hunters. The hunters are smart and hide behind trees. Vjekoslav knows ... |
user: Generate an executable Python 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 queue is an abstract data type that maintains the order in which elements were added to it, allowing the oldest elements to be remov... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Everyone knows what a square looks like. Mathematically, a square is a regular quadrilateral. This means that it has four equal sides ... |
user: Generate an executable Python 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 invented 1-minute Instant Noodles. As the name suggests, each packet takes exactly 1 minute to cook.
Chef's restaurant has X... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.You are given integer N, and return the Fibonacci Series till the Nth term.
Example:
Input:
5
Output:
0 1 1 2 3 5
Explanation:
0 1 1 2... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.You are given a mysterious language (codenamed "UnknownX") available in "Custom Test" tab. Find out what this language is, and use 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.Chef's favorite game is chess. Today, he invented a new piece and wants to see its strengths.
From a cell (X, Y), the new piece can 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.The fight for the best number in the globe is going to finally come to an end.The top two contenders for the best number are number 2 ... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Read problems statements in [Mandarin Chinese], [Russian], [Vietnamese] and [Bengali] as well.
A circular binary string is called *go... |
user: Generate an executable Python 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.
Mike is fond of collecting stamps. He has a lot of rare and unusual ones ... |
user: Generate an executable Python 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, Russian and Vietnamese as well.
There are N sets of integers from 1 to K both inclusive. Find ... |
user: Generate an executable Python 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 waiter at a party. There is a pile of numbered plates. Create an empty $\textit{answers}$ array. At each iteration, $\bol... |
user: Generate an executable Python 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.
You are given a sequence a_{1}, a_{2}, ..., a_{N}. Count the number of tr... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Fredo has crush on a girl in his class. He went to ask her out for a date. She, being a coder, gave her a simple graph with N vertices... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Red John has committed another murder. This time, he doesn't leave a red smiley behind. Instead he leaves a puzzle for Patrick Jane to... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.