formatted_conversations stringlengths 1.13k 138k |
|---|
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.You are given array nums of n length and an integer k .return the maximum number of consecutive 1's in the array if you can flip at mo... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Like any good boss, the Chef has delegated all cooking jobs to his employees so he can take care of other tasks. Occasionally, one 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.Find the largest basin size in a given matrix.
9 9 9 8 8 8
8 8 8 7 7 7
7 7 7 7 7 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.You are given a set S of N elements. You are supposed to form an array A such as:
S = {1,2,3}
then we have its subsets as {},{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 tree that is built in a following way: initially there is single vertex 1. All the other vertices are added one by one... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Ms. Thomas is managing her class of $n$ students.
She placed all her students in a line, and gave the $i$-th student from the left a ... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.You are given an array A consisting of N integers.
In one operation, you can:
Choose any two indices i and j (i \neq j);
Subtract min... |
user: Generate an executable Python 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 $\textit{q}$ queries where each query consists of a set of $n$ points on a two-dimensional plane (i.e., $(x,y)$). For ea... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.*Words that contain many consecutive consonants, like "schtschurowskia", are generally considered somewhat hard to pronounce.*
We say... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Given a binary heap implementation of Priority Queue. Extract the maximum element from the queue i.e. remove it from the Queue and ret... |
user: Generate an executable Python 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 matrix Grid[][] of size NxN. Calculate the absolute difference between the sums of its diagonals.
Example 1:
Input:
N=3
Grid=[... |
user: Generate an executable Python 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 positive integers. Your task is to find the leaders in the array. An element of array is leader if it is greater 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 two numbers A and B. Your task is to return the sum of A and B.
Example 1:
Input:
A = 1, B = 2
Output:
3
Explanation:
Addition... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Lia is fascinated by anything she considers to be a twin. She calls a pairs of positive integers, $\boldsymbol{i}$ and $j$, twins 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.Pak Chanek, a renowned scholar, invented a card puzzle using his knowledge. In the puzzle, you are given a board with $n$ rows and $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.Chef's college is starting next week. There are $S$ subjects in total, and he needs to choose $K$ of them to attend each day, to fulfi... |
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 arr[ ] of size n such that elements of arr[ ] in range [0, 1, ..n-1]. Our task is to divide the array into the maximum number of partitions that can be sorted i... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Given an integer, $n$, print the following values for each integer $\boldsymbol{i}$ from $\mbox{1}$ to $n$:
Decimal
Octal
Hexadecimal... |
user: Generate an executable Python 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 game development studio, Ad Hoc Entertainment, is currently working on a billiards-based app they’re calling Pool Shark. Players ... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Optimistan is a strange country. It is situated on an island with a huge desert in the middle, so most people live in port towns along... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.You are given an array $A$ consisting of $N$ Integers which are initially all $0$. You are also given an array $B$ consisting of $N$ 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.Grimmjow is not dead. He comes back to take revenge from Ichigo. This time, Grimmjow has a new release which gives a difficult mathema... |
user: Generate an executable Python 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 an array A = \{a_{1}, a_{2},...,a_{n}\} of size n ≥ 1. If a_{k} = 2^{x} -1 for all 1≤ k ≤ n, for some integer x (1 ≤ x ≤ 60... |
user: Generate an executable Python 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 grid with $n$ rows and $m$ columns. We denote the square on the $i$-th ($1\le i\le n$) row and $j$-th ($1\le j\le 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.IPL 2021 final is yet again between MI and CSK. It's already been two super overs
and the last bowl of the third super over is left. 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 a string and your task is to swap cases. In other words, convert all lowercase letters to uppercase letters and vice ver... |
user: Generate an executable Python 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. Find the number of pairs $(i, j)$ ($1 \le i < j \le n$) where the sum of $a_i + a_j$ is gr... |
user: Generate an executable Python 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.
As a health expert, Vinay 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.Chef has a garden of size N \times N. The garden is divided into N^{2} squares of size 1\times 1 each.
Chef has plants in some unit 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 Mandarin Chinese and Russian.
Recently Chef become very much interested in perfect squares. We all kno... |
user: Generate an executable Python 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 regular $n$-gon. Each vertex of the $n$-gon was randomly colored with one of $n$ colors. Your task is to find 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.Little Kevin had never heard the word 'Infinitum'. So he asked his mentor to explain the word to him. His mentor knew that 'Infinitum'... |
user: Generate an executable Python 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 a square of side length 1 to Sherlock. Now, after each second, each square of some arbitrary side $\boldsymbol{\mbox{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 are given an array of numbers. Let us denote the array with $\boldsymbol{A\left[\right]}$. Your task is very simple. You need to 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 may have solved a lot of problems related to XOR and we are sure that you liked them, so here is one more problem for you.
You ar... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Read problem statements in [Mandarin], [Bengali], and [Russian] as well.
There are N students in a class, where the i-th student has ... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Rahul and Tina are looking forward to starting their new year at college. As they enter their new classroom, they observe the seats 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 [Hindi], [Spanish], [Mandarin chinese], [Russian], [Vietnamese] and [Bengali] as well.
Ada is one 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.Slavic has an array of length $n$ consisting only of zeroes and ones. In one operation, he removes either the first or the last 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.Read problem statements in [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Given an array C of M integers and a 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.For a sequence of integers $[x_1, x_2, \dots, x_k]$, let's define its decomposition as follows:
Process the sequence from the first 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.Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
You are given a rooted tree w... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Given an array of integers $Y=[y_1,y_2,\ldots,y_n]$, we have $n$ line segments, such that, the endpoints of $i^{\mbox{th}}$ segment 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.There are no heroes in this problem. I guess we should have named it "To Zero".
You are given two arrays $a$ and $b$, each of these 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.Read problems statements in Russian and Vietnamese as well.
Chef and Hasan went for skiing in a rectangular field, the field can be 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.You are given an array $a_1, a_2, \ldots, a_n$ consisting of $n$ positive integers and a positive integer $m$.
You should divide elem... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Read problems statements in Mandarin Chinese, Russian and Vietnamese as well.
Donald Drumpf has spent the entire summer lobbying 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.There are N people participating in a race. The N^{th} participant is your friend, so you want him to win. You are not a man of ethics... |
user: Generate an executable Python 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.
Alice and Bob have got an integer N. They deci... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Inflation has occurred in Berlandia, so the store needs to change the price of goods.
The current price of good $n$ is given. It is 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.Dexter and Debra are playing a game. They have N containers each having one or more chocolates. Containers are numbered from 1 to N, w... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.You are given two positive integer sequences $a_1, \ldots, a_n$ and $b_1, \ldots, b_m$. For each $j = 1, \ldots, m$ find the greatest ... |
user: Generate an executable Python 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 friends live in $n$ houses. Each house is located on a 2D plane, in a point with integer coordinates. There might be diff... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Kulyash has given you a bag with (N + M) balls having distinct colours. Among these, N balls have the number 2 printed on them and M 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.Read problems statements in Mandarin Chinese, Russian and Vietnamese as well.
Chef is working with the development of a new city Kre... |
user: Generate an executable Python 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 $n$ non-negative integers ($n \ge 2$) $a_1, a_2, \dots, a_n$ is called good if for all $i$ from $1$ to $n-1$ the followi... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.The median of a list of numbers is essentially its middle element after sorting. The same number of elements occur after it as before... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.This is the easy version of the problem. The only difference between the easy version and the hard version is the constraints on $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.Chef has 3 numbers P, Q and R. Chef wants to find the number of triples (A, B, C) such that:
(A \mid B) = P, (B \mid C) = Q and (C \mi... |
user: Generate an executable Python 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 grid with $n$ rows and $m$ columns, and three types of cells:
An empty cell, denoted with '.'.
A stone, denoted with '*'.... |
user: Generate an executable Python 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.
Probably everyone has experienced an awkward situation... |
user: Generate an executable Python 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.
Tuzik and his master Vanka are playing some unusual game. Initially there... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Hossam makes a big party, and he will invite his friends to the party.
He has $n$ friends numbered from $1$ to $n$. They will be arra... |
user: Generate an executable Python 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 [Vietnamese],
[Bengali], [Mandarin Chinese], and [Russian] as well.
Chef has two numbers $N$ and $M$. Hel... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Little Gaurav is very fond of numbers and sequences. One day his teacher tells him to find a strange sequence.
$S=\sum_{i=0,2^i\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.Chef is playing a game, which he starts with a score of S = 0. He also has an integer N.
In one move, Chef does the following:
Unifor... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Martians are actively engaged in interplanetary trade. Olymp City, the Martian city known for its spaceport, has become a place where ... |
user: Generate an executable Python 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$ consisting of characters 0 and/or 1.
You have to remove several (possibly zero) characters from the beginn... |
user: Generate an executable Python 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 numbers N and M. He calls a pair of numbers (A, B) *good* if it satisfies the following conditions:
1 ≤ A, B ≤ M
\gcd(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.Waiter: Good day, sir! What would you like to order?
Lucas: One Cheese & Random Toppings (CRT) pizza for me, please.
Waiter: Very ... |
user: Generate an executable Python 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 $n \times n$ chessboard. Rows and columns of the board are numbered from $1$ to $n$. Cell $(x, y)$ lies on the interse... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
You are given a rooted tree w... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Given an array A of size N, construct a simple (i.e, without self-loops and multiedges) strongly connected directed graph with N nodes... |
user: Generate an executable Python 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 alternating sum of an array A = [A_{1}, A_{2}, \ldots, A_{N}] is defined to be
A_{1} - A_{2} + A_{3} - \ldots + (-1)^{N-1}A_{N}
... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Read problems statements in [Mandarin Chinese], [Russian], [Vietnamese] and [Bengali] as well.
Chef is stuck in the wavey world of 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.Given two numbers $N$ and $\mbox{M}$. $N$ indicates the number of elements in the array $A[](1-indexed)$ and $\mbox{M}$ indicates numb... |
user: Generate an executable Python 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], and [Russian] as well.
Chef is a wanted criminal, and N police officers are up 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.Read problems statements in Mandarin Chinese and Russian.
Sereja has an array A of N positive integers : A[1], A[2], A[3], ... , A[N... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Read problems statements in Mandarin Chinese, Russian and Vietnamese as well.
Chef is the head of commercial logging industry that 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 and Russian.
A number is called as a lucky number if its decimal representation 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, Russian and Vietnamese as well.
Chef taught his brother Chefu about right angled trian... |
user: Generate an executable Python 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 $x$. Can you make $x$ by summing up some number of $11, 111, 1111, 11111, \ldots$? (You can use any number am... |
user: Generate an executable Python 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.
------ Problem description ------
Chef loves circular cakes. He ... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Sherry likes matrices a lot, but her favorite ones are humble matrices. An $N\times M$ matrix (we'll call it $\mbox{A}$) is humble 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.There is an infinite integer grid where N people live in N different houses. They decide to create a meeting point at one person's ho... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
There are $N$ caves in a row,... |
user: Generate an executable Python 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.
There are N integers X_{1}, X_{2}, ..., X_{N}.
Let'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.Arkady has a playlist that initially consists of $n$ songs, numerated from $1$ to $n$ in the order they appear in the playlist. Arkady... |
user: Generate an executable Python 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.
Consider an infinite full binary tree (each node has two children except ... |
user: Generate an executable Python 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 can perform operations on it.
In one operation you can replace 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.It is the easy version of the problem. The only difference is that in this version $n = 1$.
In the cinema seats can be represented as... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
You are given one positive in... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Read problem statements in [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Chef knows about two languages spoken ... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Sabya is writing code to output a random number between $1$ and $N$ inclusive. The code can output different integers in the interval ... |
user: Generate an executable Python 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 Datta likes betting in Indian Premier League very much.
He has 10000 rupees. Today the match is between team A and team B. The wi... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
You have become good friends ... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Mocha is a young girl from high school. She has learned so much interesting knowledge from her teachers, especially her math teacher. ... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Akash is interested in a new function F such that,
F(x) = GCD(1, x) + GCD(2, x) + ... + GCD(x, x)
where GCD is the Greatest Common 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.Ivan is playing yet another roguelike computer game. He controls a single hero in the game. The hero has $n$ equipment slots. There 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.Suppose you have an integer array $a_1, a_2, \dots, a_n$.
Let $\operatorname{lsl}(i)$ be the number of indices $j$ ($1 \le j < i$) su... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.