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 in Mandarin Chinese and Russian. Grapes of Coderpur are very famous. Devu went to the market and saw that ...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Daenerys Targaryen is now targetting the Kingdom of Rock, ruled by House Lannister. Tywin Lannister is a shrewd man and hence sends 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.David is looking to book some travel over the world. There are $n$ countries that he can visit, and $m$ flights that are available. 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.Two good friends were trying to make a new programming language called Perse-script. The most important part of this language is stri...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.There are n cities in Wisdom, numbered from 1 to n, connected by m bidirectional roads. The j-th road connects city aj and bj. For t...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well. Chef decided to exercise by 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.Berland Gardeners United Inc. hired you for the project called "SmartGarden". The main feature of this project is automatic garden wat...
user: Generate an executable Python 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 B of length 2N . You have an unknown array A which is sorted and contains *distinct* elements. You need to find...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Your task is to implement 2 stacks in one array efficiently. You need to implement 4 methods. push1 : pushes element into first stack...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Circular land is an $2n \times 2n$ grid. Rows of this grid are numbered by integers from $1$ to $2n$ from top to bottom and columns 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.Barry and Bruce are twin brothers. Bruce likes keeping his parenthetical sequences balanced. Barry would like to mess with Bruce by 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.The ZOO management had been wondering for a long time how to increase the number of children visitors to the ZOO. The solution was sur...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Excitement is rapidly increasing in anticipation of the concluding debate at the 0x7E4 Undemocratic Inclinational Unconvention, where ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Given a Binary Search Tree of size N, find the Median of its Node values. Example 1: Input: 6 / \ 3 8 / \ / \ 1 4 7 9 Output: 6 Explanati...
user: Generate an executable Python 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 L and a number N, you need to write a program to find if there exists a pair of elements in the array who...
user: Generate an executable Python 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 numbers $1, \, 2, \, \dots, \, n \cdot k$ are colored with $n$ colors. These colors are indexed by $1, \, 2, \, \dots, \, n$. 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.Let f be a function, such that, for an array A of size M, f(A) is defined as f(A) = \sum_{i=1}^{M}\sum_{j=1, j \ne i}^{j=M} (A_{i}\cd...
user: Generate an executable Python 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, both of length N. You would like to choose exactly K distinct indices i_{1},i_{2}, \ldots, i_{K} 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.View Russian Translation Mary is about to get married! She has already bought an extremely beautiful wedding dress, a wonderful chape...
user: Generate an executable Python 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 singly linked list, the task is to rearrange it in a way that all odd position nodes are together and all even positions 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.You're given a string S of length N and an integer K. Let C denote the set of all characters in S. The string S is called *good* 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.Given a binary tree, find the largest value in each level. Example 1: Input : 1 / \ 2 3 Output : 1 3 Explanati...
user: Generate an executable Python 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, find the first repeating element. The element should occur more than once and the index of its first 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.Rushitote went to a programming contest to distribute apples and oranges to the contestants. He has N apples and M oranges, which 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.Theta has been learning about powers of $2$ in school. She notices that some numbers when written out contain powers of $2$ in their 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.Given two numbers A and B which define a range, where A <= B. Find the count of total numbers in the given range [A … B] divisible 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.Today the Intergalactic Council of Pebble Coins (ICPC) conducted an intergalactic auction of the Neutronium Chaos Pebble Coin (NCPC). ...
user: Generate an executable Python 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 encoded binary string and a Huffman MinHeap tree, your task is to complete the function decodeHuffmanData(), which decodes 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.Geek is organising a bike race with N bikers. The initial speed of the ith biker is denoted by H_{i} Km/hr and the acceleration of ith...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Two strings are anagrams of each other if the letters of one string can be rearranged to form the other string. Given a string, find 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.Let $\mathsf{AND}$ denote the bitwise AND operation , and $\mathsf{OR}$ denote the bitwise OR operation . You are given an array $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.Team RCB has earned X points in the games it has played so far in this year's IPL. To qualify for the playoffs they must earn at least...
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 N integers. A subsequence of arr[] is called Bitonic if it is first increasing then decreasing. Print the max sum bitonic subsequence. Example 1: Input...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Last weekend you and your friends went to visit the local farmer’s market at the town square. As you were standing around in a circle ...
user: Generate an executable Python 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. You are given an undirected 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.Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet ...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Buckbeak was a Hippogriff. He lived with Rubeus Hagrid and many other Hippogriff, but was later sentenced to death as he attacked Drac...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Akku likes binary numbers and she likes playing with these numbers. Her teacher once gave her a question.For given value of L and 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.Chef is given two integers N, S. Consider an array A of size N such that A[i]=i for every 1 ≤ i ≤ N. You are required to find any 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.Xenny and his friends came to know about a mobile phone product called NplusN, which could be bought if a person sent invitations to 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 an integer N print total number of divisors of N. It is guaranteed that N is a multiple of prime numbers less than 10^6. Input ...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.You are given N balls numbered from 1 to N and there are N baskets numbered from 1 to N in front of you, the i^{th} basket is meant fo...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.As we all know cultural fest of IIT-Delhi is one of the biggest youth festival of north india and this year too it was very special 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.Let's learn about list comprehensions! You are given three integers $x,y$ and $z$ representing the dimensions of a cuboid along with 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 a string of digits, the task is to check if it is a ‘sum-string’. A string S is called a sum-string if a rightmost substring can...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Sarah and Patricia are young, very gifted sisters. Ever since they learned arithmetic in preschool, they have been bothering their mot...
user: Generate an executable Python 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 set S containing N distinct integers. Chef wants to gift Chefina an array A of any finite length such that the following c...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Read problems statements in Mandarin Chinese, Russian and Vietnamese as well. A recent glut in Chefland's markets has caused the loc...
user: Generate an executable Python 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 provided with marks of N students in Physics, Chemistry and Maths. Perform the following 3 operations: Sort the students 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.There is an array of N distinct elements. Array elements are some permutation of first N natural numbers.(hence they are distinct ) 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 N cards on the table and each has a number between 0 and N. Let us denote the number on the i^{th} card by c_{i}. You want t...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Roughly speaking, this problem asks you to create the checker of [*the problem used in December CookOff*]. You are given a tree 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.Given a directed graph, find out if a vertex j is reachable from another vertex i for all vertex pairs (i, j) in the given graph. Here...
user: Generate an executable Python 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 exists a cursed city known as District B12. It consists of N people upon which an ancient curse prevails and due to which they h...
user: Generate an executable Python 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 numbered from 1 to N such that: Exactly one of these people is a thief and always lies; All the others are honest 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 numbers A and B and task is to check whether A is greater than or less than or equals to B. Example 1: Input: A = 2, B = 5...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Vishesh has gone to watch the new Spider-Man movie, but he is having troubles choosing which Popcorn-and-Coke combo to buy. 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.You are given a spreadsheet that contains a list of $N$ athletes and their details (such as age, height, weight and so on). You are re...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Jessica wants to become a javelin thrower, moreover she wants to become a famous one. However, she doesn’t want to train $40$ hours 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.The story of Harry Potter begins when Lord Voldemort arrives at his house at Privet Drive. Harry's house has N rooms placed in one lin...
user: Generate an executable Python 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*m. Every cell of matrix contains either 'A' or 'B'. Exchange is defined as swaping the characters between 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.Chef's dog *binary* hears frequencies starting from 67 Hertz to 45000 Hertz (both inclusive). If Chef's commands have a frequency 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.Chef is given two binary strings A and B, each having length N. Chef wants to find the number of binary strings C, of length N, 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.You are given an array A of size N, and you are also given a sum. You need to find if two numbers in A exist that have sum equal 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.The positive odd numbers are sorted in ascending order as $1,3,5,7,9,11,13,15,17,19\ldots$, and grouped as $(1),(3,5),(7,9,11),(13,15,...
user: Generate an executable Python 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 rectangle sheetof NxM. Make C cuts parallel to edges such that area of the smallest piece after cutting is maximised i.e. After cutt...
user: Generate an executable Python 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 took an examination two times. In the first attempt, he scored X marks while in the second attempt he scored Y marks. According 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.Bob is completing a true/false worksheet, consisting of a list of $n$ problems where each answer is either “true” or “false”. The prob...
user: Generate an executable Python 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 ChefLand, human brain speed is measured in bits per second (bps). Chef has a threshold limit of X bits per second above which his c...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Little Marin spent all his day generating test data for COCI. He simply couldn’t make it work, so he had a nervous breakdown and can’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.In the middle of a nightmare, Maxine suddenly finds herself in a mysterious room with the following items: A piece of paper with 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 single linked list of size M, your task is to complete the function sumOfLastN_Nodes(), which should return the sum of last 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 is given two strings A and B of length N containing lowercase English letters. Chef can rearrange both the strings in any way 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.Given an array of size N, find the number of distinct pairs {i, j} (i != j) in the array such that the sum of a[i] and a[j] is greater...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Consider a 2d plane and a Robot which is located at (0,0) who can move only one unit step at a time in any direction i.e. if its initi...
user: Generate an executable Python 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 known that in regular dice, the sum of opposite faces is 7. A regular dice is rolled and you are given the value X showing on 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 an integer N, print all the divisors of N in the ascending order. Example 1: Input : 20 Output: 1 2 4 5 10 20 Explanation: 20 ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Aditya has arranged some of his building blocks in N columns. Each column has a certain number of blocks given by an array A. Each element of A(i.e. Ai) is the height of the 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 unsorted linked list of N nodes. The task is to remove duplicate elements from this unsorted Linked List. When a value appear...
user: Generate an executable Python 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 enchanted forest got its name from the magical mushrooms growing here. They may cause illusions and generally should not be approa...
user: Generate an executable Python 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. What is the maximum number of squares of size 2x2 that can be fit ...
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 S consisting of N numbers, find the sum of difference between last and first element of each subset. Example 1: Input: S = [5,8] Output: 3 Explanation: There 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 integer N. Your task is to generate a permutation P of size N, such that: For all (1< i≤ N), \sum_{j = 1}^{i} P_{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.A sequence of $n$ numbers is called permutation if it contains all numbers from $1$ to $n$ exactly once. For example, the sequences [$...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Ashish and Chandu were travelling to Japan. Chandu gave Ashish a weird lottery ticket which had a string S of length N containing lowe...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.People in Chefland have three different eye colors, namely brown, blue, and green. green is the rarest of the eye colors whereas brown...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Yraglac has just finished building a robot! It’s fancy: two wheels, with an auto-balancing system, several cameras, wireless connectiv...
user: Generate an executable Python 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 a grid of dimensions N \times M. You are allowed to perform two types of operations: Go down, left, up, or right each 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.You are studying a swarm of N fireflies. Each firefly is moving in a straight line at a constant speed. You are standing at the center...
user: Generate an executable Python 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 chocolate bar has a rectangular shape and consists of n × m slices. In other words, a bar consists of n rows with m slices of chocol...
user: Generate an executable Python 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 $n \times m$ matrix of ones and zeros. For example, this $4 \times 4$:$\begin{matrix} 1 & 1 & 1 & 1 \\ 0 & 1 & 1 & 1 \\ 0 ...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Given an array arr of size N consisting of non-negative integers. You are also given Q queries represented by 2D integer array 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.Given 2 integers L, R as input, and find the bitwise OR of all the integers in the range [L, R] (both inclusive). Example 1: Input: 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.Jon Marius shouted too much at the recent Justin Bieber concert, and now needs to go to the doctor because of his sore throat. The doc...
user: Generate an executable Python 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. Your task is to check if there exists a permutation of the digits of this number which is divisible by 4. ^{ }...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Given a singly linked list L_{0} -> L_{1} -> … -> L_{n-1} -> L_{n}. Rearrange the nodes in the list so that the new formed list is: L_{0} -> L_{n} -> L_{1} -> L_{n-1} -> L_{2}...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.------Read problems statements in Mandarin chinese , Russian and Vietnamese as well. ------ Professor GukiZ decided to distribute al...
user: Generate an executable Python 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 points of the form (x_{i}, y_{i}) on a 2-D plane. From each point, you draw 2 lines one horizontal and one vertical. Now some...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Read problems statements in Mandarin Chinese and Russian as well. After IOI Ilya decided to make a business. He found a social netw...
user: Generate an executable Python 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 and an integer k, the task is to reduce the string by applying the following operation: Choose a group of k consecuti...