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.Read problems statements [Bengali] , [Mandarin chinese] , [Russian] and [Vietnamese] as well.
For her birthday, Rima got an integer s... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Given a string arr consisting of lowercase english letters, arrange all its letters in lexicographical order using Counting Sort.
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.Sam is playing with an array, $\mbox{A}$, of $N$ positive integers. Sam writes a list, $\mbox{S}$, containing all $\mbox{A}$'s contigu... |
user: Generate an executable Python 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, check if it can be rotated to form a palindrome.
Example 1:
Input:
s = aaaab
Output: 1
Explanation: "aaaab" can 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.Given a 2D binary matrix A(0-based index) of dimensions NxM. Find the minimum number of steps required to reach from (0,0) to (X, Y).
... |
user: Generate an executable Python 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 order to pass time during your vacation, you decided to go on a hike to visit a scenic lake up in the mountains. Hiking to the lake... |
user: Generate an executable Python 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 list of $N$ numbers $a_1,a_2,\ldots,a_n$. For each element at position $\boldsymbol{i}$ ($1\leq i\leq N$), we define $... |
user: Generate an executable Python 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 has just learned multiplying two integers. He wants to multiply two integers X and Y to form a number Z. To make the problem int... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.At the time when Pythagoreanism was prevalent, people were also focused on different ways to factorize a number. In one class, Pythago... |
user: Generate an executable Python 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 $n$ colored segments on the number line. Each segment is either colored red or blue. The $i$-th segment can be represent... |
user: Generate an executable Python 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 that contains n integers: A_{1}, A_{2}, ..., 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.Given two integers A and B, the task is to find an integer X such that (X XOR A) is minimum possible and the count of set bit in X 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 have given N cities numbered from 0 to N-1. The distance between each pair of cities is given by N * N matrix MAT where MAT[i][j] ... |
user: Generate an executable Python 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 balls . All of them are initially uncolored . You have to color the balls with two colors RED and BLUE such that there can 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.Given an array having both positive and negative integers. The task is to compute the length of the largest subarray with sum 0.
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.Pasijans, patience, or solitaire is the name for a group of single player card games. One new such game, so new it has no name, is pla... |
user: Generate an executable Python 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 needs random numbers for its operation. $N$ random numbers have been generated using $N$ numbers as seeds and the following ... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Given a string consisting of spaces,\t,\n and lower case alphabets.Your task is to count the number of words where spaces,\t and \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.Given a non-negative number N and two values L and R. The problem is to toggle the bits in the range L to R in the binary representati... |
user: Generate an executable Python 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$ elements, each element is either $0$ or $1$.
You can make operations of $2$ kinds.
Pick ... |
user: Generate an executable Python 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 five positive integers, find the minimum and maximum values that can be calculated by summing exactly four of the five integers.... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Read problems statements in Mandarin chinese, Russian and Vietnamese as well.
You are a citizen of Arrayland. Your President (Mr. P)... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.A Sumo wrestling championship is scheduled to be held this winter in the HackerCity where N wrestlers from different parts of the worl... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Given an array of n integers rearrange the values of the array so as to maximize the worth of the array.Worth of an array a is defined... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.You are given a number $n$ (divisible by $3$) and an array $a[1 \dots n]$. In one move, you can increase any of the array elements by ... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Alice and Bob play a game on an array of N integers. They alternate moves, with Alice making the first move.
The rules are as follows... |
user: Generate an executable Python 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 an owner of lemonade island, each lemonade costs $5. Customers are standing in a queue to buy from you and order one at a time... |
user: Generate an executable Python 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.
An equation is an equality containing one or more variables. Solvi... |
user: Generate an executable Python 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 of length N.
You can apply the following operation on the string any number of times:
Choose an index i (1≤ ... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Given a positive integer, N. Find the factorial of N.
Example 1:
Input:
N = 5
Output:
120
Explanation:
5*4*3*2*1 = 120
Example 2:
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.For each bill you pay using CRED, you earn X CRED coins.
At CodeChef store, each bag is worth 100 CRED coins.
Chef pays Y number o... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.After defeating a Blacklist Rival, you get a chance to draw $1$ reward slip out of $x$ hidden valid slips. Initially, $x=3$ and these ... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Welcome to Sevenkplus' perfect math class! In this class, you will learn about representation theory. And this class is in a different... |
user: Generate an executable Python 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 define Score of an array B of length M as \sum_{i=1}^{M} \sum_{j=i}^{M} f(i,j), where f(i,j) = B_{i} | B_{i+1} | \dots | B_{j} (... |
user: Generate an executable Python 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 reverse every k nodes (where k is an input to the function) in the linked list. If 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.A binary string S of length N is called *K-balanced string* if it holds the following property: For each index i\;(1 ≤ i ≤ N) such 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.Mirko and his older brother Slavko are playing a game. At the beginning of the game, they pick three numbers $K$, $L$, $M$. In the fir... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.The country of Byteland contains N cities and N - 1 bidirectional roads between them such that there is a path between any two cities.... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Professor Braino Mars is one of the top researchers in the field of solar system creation. He runs various simulations to test out his... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Given N non-negative integers a_{1},a_{2},....a_{n} where each represents a point at coordinate (i, a_{i}). N vertical lines are drawn such that the two endpoints of line i 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.Hitman have an array x1,x2...xN of n elements. You have to tell how many pairs (a,b)
exist such that 1 ≤ a < b ≤ N and x[a] XOR x[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 an array arr[] containing positive elements. A and B are two numbers defining a range. The task is to check if the array 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.A row of $n$ cells is given, all initially white. Using a stamp, you can stamp any two neighboring cells such that one becomes red and... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Given an array of positive integers and many queries for divisibility. In every query Q[i], we are given an integer K , we need to count all elements in the array which are pe... |
user: Generate an executable Python 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 $r\! \times \! c$ grid. Each cell of this grid is filled with a number between $1$ and $r{\cdot }c$ inclusive, and 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.There are $n$ block towers in a row, where tower $i$ has a height of $a_i$. You're part of a building crew, and you want to make the 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.Do you like summer? Residents of Tyago do. They especially love eating ice cream in the hot summer. So this summer day a large queue 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.Mersenne Prime is a prime number that is one less than a power of two. In other words, any prime is Mersenne Prime if it is of the 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.There are N candies in a room labelled from 1 to N and there are N - 1 directed path between these candies such that every candy has 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.Concentration is a not so popular 2 player card game of both skill and luck. The standard Concentration game is played with one or two... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Read problems statements in Mandarin Chinese here
------ Problem Statement ------
Maxim likes dividers of the numbers. Also Maxim ... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Given a string S consisting of opening and closing parenthesis '(' and ')'. Find length of the longest valid parenthesis substring.
A ... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Alice and Bob are playing a game on a simple connected graph with $N$ nodes and $M$ edges.
Alice colors each edge in the graph red 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.Recently, Pero has been into robotics, so he decided to make a robot that checks whether a deck of poker cards is complete.
He’s alre... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Geek wants to distribute gifts to N students. He buys N gifts and asks his students to make a list of gifts arranged in order of 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 a string S with repeated characters. The task is to rearrange characters in a string such that no two adjacent characters are 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.Given two positive integers A and B, find GCD of A and B.
Example 1:
Input: A = 3, B = 6
Output: 3
Explanation: GCD of 3 and 6 is 3
Ex... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Real stupidity beats artificial intelligence every time.
— Terry Pratchett, Hogfather, Discworld
You are given a string $s$ of lengt... |
user: Generate an executable Python 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 fair coin and two integers X and N.
You repeatedly flip the coin and perform the following operation based on the res... |
user: Generate an executable Python 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, find any 3 elements in it such that A[i] < A[j] < A[k] and i < j < k.
Example 1:
Input:
N = 5
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 two Arrays A[] and B[] of length N and M respectively. Find the minimum number of insertions and deletions on the array A[], req... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Given an array Arr[] of size N. For every element in the array, the task is to find the index of the farthest element in the array 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.Rajat eats a lot. Today he has been given N berries to eat. His mouth is so big that he can eat a lot of them together but quantity 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.Being a Pokenom trainer is very stressful. You always need to take good care of all your Pokenoms and always be prepared to battle oth... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Sarthak got an empty magic grid of size N \times N on his birthday. The grid can only be filled with positive integers 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.Kristen loves playing with and comparing numbers. She thinks that if she takes two different positive numbers, the one whose digits 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.Ross, being divorced for three times(yeah, and he is just 30!) had nothing to do so Chandler told him to paint his apartment.
Consider... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Polycarp has a favorite sequence $a[1 \dots n]$ consisting of $n$ integers. He wrote it out on the whiteboard as follows:
he wrote 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.Given n, a and r as the number of terms, first term and common ratio respectively of an Geometric Progression Series. Find the sum 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 in geekworld railway station. You are given train schedule as follows
arrival_time array contains arrival time of each train
... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.As a New Yorker you are always very busy. Apart from your long work day you tend to have a very long list of errands that need to be 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.For every positive integer we may obtain a non-negative integer by multiplying its digits. This defines a function $f$, e.g. $f(38) = ... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Löpkass is out running in the forest again. He loves running in the forest. However, there is a programming competition starting in 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 Mandarin chinese, Russian and Vietnamese as well.
Chef found a very useful open-source code for the curre... |
user: Generate an executable Python 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, rearrange it in such a way that it has no subsequence as cba. If there are multiple answers return the lexicographical... |
user: Generate an executable Python 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 of size N and a number K., You must modify array arr[] exactly K number of times. Here modify array means 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.Misha needs to send packages to his friend Nadia. Both of them often travel across Russia, which is very large. So they decide to hire... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Given an integer $n$, find the maximum value of integer $k$ such that the following condition holds:
$n$ & ($n-1$) & ($n-2$) & ($n-3$... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.OP Bro loves numbers.He is trying to solve the following problem.
Given A , B and K.Find the number of numbers between A
and B 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.Your working week consists of $n$ days numbered from $1$ to $n$, after day $n$ goes day $1$ again. And $3$ of them are days off. One 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 S. For each index i(1<=i<=N-1), erase it if s[i] is equal to s[i-1] in the string.
Example 1:
Input:
S = aabb
Output: ... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Riley is a very bad boy, but at the same time, he is a yo-yo master. So, he decided to use his yo-yo skills to annoy his friend Anton.... |
user: Generate an executable Python 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+2 people sitting in a line, numbered from 0 to n+1. Some K distinct people with numbers ranging between 1 and n (inclusive... |
user: Generate an executable Python 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 linked lists sorted in increasing order, create a new linked list representing the intersection of the two linked lists. 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.Alice wrote an exam containing N true or false questions (i.e. questions whose answer is either true or false). Each question is worth... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Apple considers any iPhone with a battery health of 80\% or above, to be in *optimal* condition.
Given that your iPhone has X\% batt... |
user: Generate an executable Python 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 decided to join a Gym in ChefLand and if possible, also hire a personal trainer at the gym. The monthly cost of the gym is 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.Read problems statements in Mandarin Chinese, Russian and Vietnamese as well.
Chef has a collection of N postage stamps. Each stamp ... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Theofanis has a string $s_1 s_2 \dots s_n$ and a character $c$. He wants to make all characters of the string equal to $c$ using 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.For a given non-negative integer N, find the next smallest Happy Number. A number is called happy if it leads to 1 after a sequence 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.Given a String S (in lowerCase only). Starting from letter 'a' which is the only source. for example:- "aaabcahd..." . Now you can onl... |
user: Generate an executable Python 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 having only one ‘1’ and all other ’0’s in its binary representation, find position of the only set bit. If 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 string consisting of lowercase english alphabets. Find the repeated character present first in the string.
Example 1:
Input:
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.Famous wizard Sumar moonji kumaru is stuck in a huge room and has to save Hermione Granger from a monster. Kumaru is at location P1 gi... |
user: Generate an executable Python 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.
Bitsetbaba Ashiq works in a p... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Given a permutation of first n natural numbers as an array and an integer k. Print the lexicographically largest permutation after at ... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Ali Koochooloo is going to buy new clothes since we're reaching Noruz, the ancient Persian festival and the beginning of new Persian y... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Given an array of N integers, the task is to find all pairs with an absolute difference less than K.
NOTE: Pair (i, j) is considered s... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Given a string and number of rows ‘n’. Print the string formed by concatenating n rows when the input string is written in row-wise Zi... |
user: Generate an executable Python 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 University of Lagado is organising events for the upcoming Fresher’s week and has been told — much to the surprise of its staff — ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.