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 an array $a$ consisting of $n$ integers. The array is sorted if $a_1 \le a_2 \le \dots \le a_n$.
You want to make the 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.Kriti and Me were getting bored, so we finally came up with an idea of a cool game.
The game is described as follows.
1. Initially, we... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Transpose
We can generate the transposition of an array using the tool numpy.transpose.
It will not affect the original array, bu... |
user: Generate an executable Python 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 head, the head of a singly linked list, find if the linked list is circular or not. A linked list is called circular if it not 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.All the players of Juventus Football Club live on a straight street. Their houses are numbered
0,1,2....N-1. One day, their coach 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.You are given two integers N and K. Find number of ordered triplets (A, B, C) that satisfy the following conditions:
0 ≤ A, B, C < 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.Given a sorted array of size N and an integer K, find the position(0-based indexing) at which K is present in the array using binary 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 an array of positive integers. Find the maximum sum of strictly increasing subarrays.
Example 1:
Input :
arr[] = {1, 2, 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.Given two numbers M and N. The task is to find the position of the rightmost different bit in the binary representation of numbers.
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.Suppose you have a binary array B of length N.
A sequence x_{1}, x_{2}, \ldots, x_{k} is called *good* with respect to B if it satis... |
user: Generate an executable Python 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.
Consider an ordered tree with N vertices. Your task is... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.The knight is standing in front of a long and narrow hallway. A princess is waiting at the end of it.
In a hallway there are three do... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Jimmy and his friends like to visit large theme parks. In the current theme park there are many roller coasters which then are categor... |
user: Generate an executable Python 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 and Vietnamese as well. ------
Sheokand is good at mathematics. ... |
user: Generate an executable Python 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.Kox enjoys her job, but she does not like to waste extra time traveling to and from her office. After working for many years, she k... |
user: Generate an executable Python 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 the following game. Alice has a set $S$ of disjoint ranges of integers, initially containing only one range $[1, 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.There are 10 problems in a contest. You know that the score of each problem is either 1 or 100 points.
Chef came to know the total sc... |
user: Generate an executable Python 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 with $N$ nodes (numbered $1$ through $N$). There are $K$ special nodes $f_{1},f_{2},\ldots,f_{K}$ in this tree.
... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Given a binary tree. The task is to find the Node with maximum GCD of the siblings of this tree. You have to return the value 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.Flatland is a country with a number of cities, some of which have space stations. Cities are numbered consecutively and each has a ro... |
user: Generate an executable Python 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. Write a program to check whether an arithmetic progression can be formed using all the given elements.
... |
user: Generate an executable Python 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 numbers in an array. Your task is to keep at-most K numbers at the top (According to their frequency). We basically need to 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.Dothraki are planning an attack to usurp King Robert's throne. King Robert learns of this conspiracy from Raven and plans to lock 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.Given a binary tree, connect the nodes that are at the same level. The structure of the tree Node contains an addition nextRight point... |
user: Generate an executable Python 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 consider two strings to be anagrams of each other if the first string's letters can be rearranged to form the second string. In 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.Given an array, the task is to find the difference between highest occurrence and lowest occurrence of any number in an array.
Note: 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 problems statements in [Hindi], [Mandarin Chinese], [Russian], [Vietnamese], and [Bengali] as well.
In a *red-blue tree*, each 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.Given a string with brackets ('[' and ']') and the index of an opening bracket. Find the index of the corresponding closing bracket.
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.Given a number N, swap the two nibbles in it and find the resulting number.
Example 1:
Input:
N = 100
Output:
70
Explanation:
100 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 array A[] of N integers, where A[i] denotes the height of i^{th} tree.
Geek needs to cut down M meters of wood. He has a woo... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Levenshtein distance between two strings of letters is calculated as the minimal total cost of a sequence of edit actions that convert... |
user: Generate an executable Python 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 four 3-dimensional points to Sherlock and asks him if they all lie in the same plane. Your task here is to help Sherlock.... |
user: Generate an executable Python 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 decided to teach some ad... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Given binary string str consisting of only 0's and 1's, Check if all the 0's are together or not.
Example 1:
Input:
str = "000"
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.There is a table on which N balls are kept starting from index 1 to N in horizontal direction. Each ball is either of red (denoted 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 are playing a game. They have an array of positive integers $a$ of size $n$.
Before starting the game, Alice chooses 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.Geek is the founder of Geek Constructions. He always maintains a black-list of potential employees which can be fired at any moment.
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.MTR (subway) stations are common meetup locations in Hong Kong. Alice and Bob are going to meet up at one of the MTR stations. They 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.Read problems statements in Mandarin Chinese and Russian as well.
In every contest there should be an easy problem about matrices. 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.Princess Artapoelc greeted her guests by either kissing on the cheek (K) or hugging (H). From the first guest
she kisses, she 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.Lisa just got a new math workbook. A workbook contains exercise problems, grouped into chapters. Lisa believes a problem to be speci... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.You are given an integer n. Output its prime factorization.
If n = a1b1a2b2 ... akbk, where ak are prime numbers, the output of your ... |
user: Generate an executable Python 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 stumbled upon B black nodes and W white nodes and now wants to construct a tree using them.
Chef is bamboozled by the total 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 problems statements in Mandarin Chinese, Russian and Vietnamese as well.
Chef likes solving problems involving a lot of queries... |
user: Generate an executable Python 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 very popular computer game. The next level consists of $n$ consecutive locations, numbered from $1$ to $n$, each 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.Laurel and Hardy have $n$ piles of chocolates with each pile containing some number of chocolates. The piles are arranged from left 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 a string ‘str’, the task is to check that reverses of all possible substrings of ‘str’ are present in ‘str’. If yes then... |
user: Generate an executable Python 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 stones in a pond, each having a value A_{i} written on it. A frog is at stone 1 and wants to reach stone N. The frog can 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.Ewan is a park ranger, and part of his duty is to observe how the ecosystem changes over time. He has just detected that a group of pi... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Given two strings 'str1' and 'str2', check if these two strings are isomorphic to each other.
Two strings str1 and str2 are called iso... |
user: Generate an executable Python 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 rented a car for a day.
Usually, the cost of the car is Rs 10 per km. However, since Chef has booked the car for the whole day,... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Let's call a sequence $b_1, b_2, b_3 \dots, b_{k - 1}, b_k$ almost increasing if $$\min(b_1, b_2) \le \min(b_2, b_3) \le \dots \le \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.Read problems statements in [Russian] and [Bengali].
Chef opened a company which manufactures cars and bikes. Each car requires 4 tyr... |
user: Generate an executable Python 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 numbers written on a blackboard.
In one operation, Chef can:
Choose any 3 integers A, B, and C written on the blackboar... |
user: Generate an executable Python 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], [Vietnamese], and [Bengali] as well.
You are given a grid with $N$ rows and ... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Oh, no. Atli has just painted himself into a corner. He has been playing the video game Planetaris and decided to start a war against ... |
user: Generate an executable Python 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 decided to open a new business—bank vaults. A branch of the bank can be visualized in a plane, vaults being points in the plane.... |
user: Generate an executable Python 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 the coordinates of the centres of two circles (X1, Y1) and (X2, Y2) as well as the radii of the respective circles R1 and R2.Fin... |
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 A of size N, construct a Sum Array S(of same size) such that S is equal to the sum of all the elements of A except A[i]. Your task is to complete the function 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.Imagine you have a special keyboard with the following keys:
Key 1: Prints 'A' on screen
Key 2: (Ctrl-A): Select screen
Key 3: (Ctrl... |
user: Generate an executable Python 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 grid of size n*n filled with 0, 1, 2, 3. Check whether there is a path possible from the source to destination. You can traver... |
user: Generate an executable Python 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 arrived in The Big City but your journey is not yet complete. You must still navigate the subway and get to your final destin... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Rookie Bunny is helping the motor vehicle department to renew licenses for its customers. She works at the ticket machine and gives ti... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Given a range of numbers starting with integer L and ending at R, the task is to count the numbers which have same first and last digi... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Russian version of the problem can be read here.
There are two cats playing, and each of them has a set of strings consisted of lower... |
user: Generate an executable Python 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 tree and a sum S, print all the paths, starting from root, that sums upto the given sum. Path maynot end on a leaf node... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Old Farmer Ranjan works on the farm of landlord Mittal Sahab. On the occasion of Diwali, Mittal Sahab decided to give some bonus to 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.Chef has scored A, B, and C marks in 3 different subjects respectively.
Chef will fail if the average score of any two subjects is 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.We call a non-negative number x good if its binary representation is palindromic. For example, 107 is good because its binary represen... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Sorting arrays is traditionally associated with high-level languages. How hard can it be in FALSE? Sort the given array in non-descend... |
user: Generate an executable Python 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.
Kekocity's population consist of N gnomes numbered wit... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Jimmy loves playing with strings. He thinks string $\mbox{A}$ is similar to string $\mbox{B}$ if the following conditions are satisfie... |
user: Generate an executable Python 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 n x n integer matrix grid where each value grid[i][j] represents height of the cell (i, j).
You can travel from a cel... |
user: Generate an executable Python 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 the names and grades for each student in a class of $N$ students, store them in a nested list and print the name(s) of any stude... |
user: Generate an executable Python 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[] denoting heights of N towers and a positive integer K.
For each tower, you must perform exactly one of the follo... |
user: Generate an executable Python 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 nums[] of size n, where nums[i] denotes the number of characters in one word. Let K be the limit on the number of chara... |
user: Generate an executable Python 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 all pairs (sets) of prime numbers (p,q) such that p*q <= n, where n is given number.
Example 1:
Input: n = 4
Output: 2 2
Expla... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.A rectangular swamp is inhabited by 10 species of frogs. Frogs of species i can jump from hillocks to hillock exactly i units along 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.Geek Land has a population of N people and each person's ability to rule the town is measured by a numeric value arr[i]. The two peopl... |
user: Generate an executable Python 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 gives Bob a board composed of $1\times1$ wooden squares and asks him to find the minimum cost of breaking the board back down 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.Andy wants to play a game with his little brother, Bob. The game starts with an array of distinct integers and the rules are as follo... |
user: Generate an executable Python 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 [Mandarin] , [Bengali] , [Hindi] , [Russian] and [Vietnamese] as well.
Consider a seven-segment display, whi... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Given a matrix of size N x M. You have to find the K^{th} element which will obtain while traversing the matrix spirally starting from... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.You are given a binary tree. Your task is pretty straightforward. You have to find the sum of the product of each node and its mirror ... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Keko has $N$ dots in a 2-D coordinate plane. He wants to measure the gap between the most distant two dots. To make the problem easier... |
user: Generate an executable Python 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 scientists Mildra and Gloisa have been responsible for exploring Luyten 726-8, but have ended up with an issue: Their fusion react... |
user: Generate an executable Python 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 containing N integers and an integer K., Your task is to find the length of the longest Sub-Array with the sum of the 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.The other day Bjarki was playing one of his many video games, $\sim $s. In $\sim $s you build a house, start a family, and slowly, but... |
user: Generate an executable Python 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 playlist contains 3 songs named A, B, and C, each of duration exactly X minutes. Chef generally plays these 3 songs in loop, i.... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.A number of regional Internet Service Providers (ISPs), both big and small have recently been forced into a merger by the government, ... |
user: Generate an executable Python 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 are well known with the two personalities Gabbar Singh & Phoolan Devi. Gabbar Singh , the most iconic villain of Hindi Film Industr... |
user: Generate an executable Python 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 G and an array arr[] of size N, find the length of the minimum subarray whose Greatest Common Divisor equals to G.
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.Mathematics wrapped in English is not that Easy
Love stories that happened in college life stays for longer , even for a life-time. 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.
Rahul and Rashi are off to the wedding of a close rela... |
user: Generate an executable Python 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 doorman Bruno at the popular night club Heaven is having a hard time fulfilling his duties. He was told by the owner that when 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.You are given an array arr[] of numbers of size N. You need to multiply these numbers and find the remainder when the product of 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.Read problems statements in Mandarin Chinese, Russian and Vietnamese as well.
Andrash study in Uzhland National University. Now is 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.Read problems statements in Mandarin Chinese, Russian and Vietnamese as well.
Arrays have fallen out of Chef's good books, and he pl... |
user: Generate an executable Python 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 2 integers a and b. Let a number be defined as
$a+b\sqrt{5}$
. As we know
$a+b\sqrt{5}$
will be an irrational number 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.Xorq has invented an encryption algorithm which uses bitwise XOR operations extensively. This encryption algorithm uses a sequence of ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.