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.Given an integer n, the task is to find whether n can be written as sum of three consecutive integer. Example 1: Input: n = 6 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.Chef and Jhool went to a party, and both decided to play a game. The game is simple, both Chef and Jhool will eat the dishes served ...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Aditya can always be seen eating bananas. On his birthday he decides to give his friends a Banana treat. As we know Aditya is a miser...
user: Generate an executable Python 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 that contains only digits (0-9) and an integer target, return all possible strings to insert the binary operator ' + ...
user: Generate an executable Python 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 scientists discovered new field to research. They explore how to organize TV schedule to maximize happiness of viewers. They ...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Teja is extremely enthusiastic about competitive programming , but sometimes fails miserably even for easy problems. Utkarsh , his bes...
user: Generate an executable Python 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 number N and a number D. Find the count of positive numbers smaller or equal to N such that the difference between ...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Give a N*N square matrix, return an array of its anti-diagonals. Look at the example for more details. Example 1: Input: N = 2 matrix[...
user: Generate an executable Python 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 coding class is very famous in Chefland. This year X students joined his class and each student will require one chair to sit...
user: Generate an executable Python 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 consider some array A. The following algorithm calculates it's force: Find all the continuous blocks where all the elemens of A ...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.There are N office cubicles placed in a straight line, each with a bright bulb. Each light bulb can brighten K rooms on either side 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 an incomplete Sudoku configuration in terms of a 9x9 2-D square matrix(mat[][]) the task to check if the current configuration ...
user: Generate an executable Python 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 participated in a contest and got a rank X. Chef is trying to find his name in the ranklist but there are too many pages. Each ...
user: Generate an executable Python 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 have found a new chess character — pook. It has the qualities of both a rook and a pawn. Specifically, treating the chessboard to 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.A number n is said to be a Carmichael number if it satisfies the following modular arithmetic condition: power(b, n-1) MOD n = 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 value N. In how many ways you can construct a grid of size N x 4 using tiles of size 1 x 4. Example 1: Input: N = 1 Output: 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 an array Arr of size N and a positive integer K, find the sub-array of length K with the maximum average. Example 1: Input: 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.You are beta testing the new secret Terraria update. This update will add quests to the game! Simply, the world map can be represente...
user: Generate an executable Python 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 sequence of $n$ integers, $p(1),p(2),...,p(n)$ where each element is distinct and satisfies $1\leq p(x)\leq n$. For each $\bol...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Chef has a tree consisting of N nodes, rooted at node 1. Every node of this tree can be assigned a binary value (0 or 1). Initially, 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.While walking in grand malls little Elsa likes to play a game she calls “Lava”. This is a simple game using the different colors of 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.Find the Nth term of the following series : N Nth term 1 0 2 1 3 0 4 2 5 0 6 1 7 0 8 3 9 0 10 1 and s...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Read problems statements in Mandarin chinese, Russian and Vietnamese as well. Chef loves single-colored squares, so he got a recta...
user: Generate an executable Python 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 quadratic equation with integer coefficients A * X2 + B * X + C = 0. It is guaranteed that A ≠ 0 and that the equation...
user: Generate an executable Python 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 eular toitent function of N. Eular toitent function of N is total number of positive integers less than N 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.As an engineer and would like to improve the quality of duct tapes that your firm manufactures. An entire tape can be represented as 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 find its next greater or equal number whose binary representation must not contain consecutive ones. For 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.Captain Jack Sparrow was taken to the Davy Jones Locker along with The Black Pearl by the Kraken. Will and Elizabeth have set sail alo...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Define a cyclic sequence of size $n$ as an array $s$ of length $n$, in which $s_n$ is adjacent to $s_1$. Muxii has a ring represented...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Alf and Beata were two kids who lived long ago, during the time before you could spend Halloween participating in programming competit...
user: Generate an executable Python 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 if it can be expressed as x^{y} where y > 1 and x > 0 and x and y both are both integers. Example 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 N bags of candies where each bag contains Ai number of candies in it. Your task is to use minimum number of steps to make number...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.In ancient times, communication was not as swift as it is today. When a kingdom was at war, it could take months to muster all the arm...
user: Generate an executable Python 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 pet store on sale there are: $a$ packs of dog food; $b$ packs of cat food; $c$ packs of universal food (such food is suitabl...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.HiQ recently got an assignment from a client to create a clone of the immensely popular website https://IsItHalloween.com. The website...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.n athletes take part in the hammer throw. Each of them has his own unique identifier — the integer from 1 to n (all athletes have dist...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Xsquare is not good at Mathematics, but his Mathematics teacher considers him the most brilliant student of the class. How come ? Actu...
user: Generate an executable Python 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 length K. Find any permutation P of length N such that only the prefixes of length A_{i} (1 ≤ i ≤ K) form ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Charul has been given a task by Ishaan. He challenges him to fill a large container of capacity K liters. Charul has N vessels with him with different capacities. The capaciti...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Iskander the Baker is decorating a huge cake, covering the rectangular surface of the cake with frosting. For this purpose, he mixes f...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.itertools.combinations(iterable, r) This tool returns the $\textbf{r}$ length subsequences of elements from the input iterable. Com...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Anthony and Cora are playing Dominion, their favorite card game. In Dominion, there are $T$ different card types, and each player has ...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.In this challenge, you will be given an array $\mbox{B}$ and must determine an array $\mbox{A}$. There is a special rule: For all $\...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Given a string str and a pattern pat. You need to check whether the pattern is present or not in the given string. Example 1:- Input: 2 abcdefh bcd axzy xy Output: Present No...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Chloe is fascinated by prime numbers. She came across the number $283002$ on a sign and, though the number is not prime, found some pr...
user: Generate an executable Python 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 palindrome is a string that can be read the same way from left to right and from right to left. For example, strings "hanah", "233...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Mr. Modulo lives up to his name and is always busy taking modulo of numbers and making new problems. Now he comes up with another problem. He has an array of integers with n e...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Chef and his friend is standing on the X-axis at the points X_{1} and X_{2} respectively. Chef moves one step forward each second (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.SKITians are good with mensuration hence they like to play with geometric shapes like rectangles in the plane. You are given two recta...
user: Generate an executable Python 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 N and M. Find the longest common contiguous subset in binary representation of both the numbers and print its decim...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Our geek loves to play with strings, Currently, he is trying to reduce the size of a string by recursively removing all the consecutiv...
user: Generate an executable Python 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 0-indexed array S with N strings, numbered 0 through N-1, and Q queries to handle. All strings in this problem are non...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Problem Statement: Garfield the cat likes candies A LOT. He always keeps a huge stock of it at his home. Today John, his owner, broug...
user: Generate an executable Python 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 week Mister George visited Croatia. Since Mister George is a very important person, while he was in a street, the police disallow...
user: Generate an executable Python 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 and Martin retired from their jobs and became shepherds. After each winter they need to rebuild the sheep pen. Each year they ha...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Solve the mystery. INPUT : First line contains T No. of test cases. Each test case contains two lines. First line contains two spac...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Janmansh and Jay are playing a game. They start with a number X and they play a total of Y moves. Janmansh plays the first move of the...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Chef has an array A of length N. Chef forms a binary array B of length N using the parity of the sums of adjacent elements in A. 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 given an array Arr of size N. Replace every element with the next greatest element (greatest element on its right side) in 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.、Consider an inifite array, $a$, of positive numbers, $a_1,a_2,\ldots$, where each $a_i=i$. You can apply a permutation, ${p}$, of siz...
user: Generate an executable Python 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. You are given a strictly con...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.You and your friend Ilya are participating in an individual programming contest consisting of multiple stages. A contestant can get 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.You are in charge of a server that needs to run some submitted tasks on a first-come, first-served basis. Each day, you can dedicate 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.Xsquare has decided to win next Programming Marathon and started his preparation for the same. Xsquare's coach advised him to revise 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 war is going on between star world and dark world. The king of the starworld need to choose troops of soldiers and send them for 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.The management of the software company JunkCode has recently found, much to their surprise and disappointment, that productivity has g...
user: Generate an executable Python 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 NWERC 2018, the organisers have done something rather special with the balloons. Instead of buying balloons of equal size, they bo...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.During their New Year holidays, Alice and Bob play the following game using an array $a$ of $n$ integers: Players take turns, Alice m...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.You are given two positive integers a and b. You also have a number x, which is initially set to 0. At first, you can add a to x any 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 an unsorted array of integers, find the number of continuous subarrays having sum exactly equal to a given number k. Example 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 matrix of order nxm, composed of only 0's and 1's, find the number of 1's in the matrix that are surrounded by an even number ...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Given an array of n positive integers. Find the sum of the maximum sum subsequence of the given array such that the integers in the 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.Victoria has a tree, $\mathbf{T}$, consisting of $N$ nodes numbered from $1$ to $N$. Each edge from node $U_i$ to $V_i$ in tree $\math...
user: Generate an executable Python 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$-integer sequence, $A=\{a_0,a_1,\ldots,a_{n-1}\}$. We perform a query on $\mbox{A}$ by using an integer, $\boldsymbol{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.MyTunes, a new music application from Mapple, allows you to display and sort your music according to many different attributes. Attrib...
user: Generate an executable Python 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 square matrix of size n×n. Your task is to calculate the sum of its diagonals. Example 1: Input: matrix = {{1, 1, 1}, {1, 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.Read problem statements in [Mandarin], [Bengali], [Russian], and [Vietnamese] as well. Chef is a software developer, so he has to swi...
user: Generate an executable Python 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 had an array A of length N such that 1 ≤ A_{i} ≤ N for all 1 ≤ i ≤ N. Chef constructed another binary array B of length N in 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 integer N. You are asked to find total number of integer pairs (A,B) such that 1 ≤ A,B ≤ N A^{2}+B^{2}+gcd^{2}(A,B)...
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 n elements. Your task is to complete the Function num which returns an integer denoting the total number of times digit k appears in the whole array. 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.Given a positive integer N., The task is to find the value of where function F(i) for the number i be defined as the sum of all 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.Calculate the Nth digit in the representation of Pi. Example 1: Input: N = 1 Output: 3 Explanation: Value of Pi is 3.14... So, the ...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Chef is a big fan of Coldplay. Every Sunday, he will drive to a park taking M minutes to reach there, and during the ride he will play...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.\[ C_6H_{12}O_{6} + 6O2 \rightarrow 6CO_2 + 6 H_2O \] Professor Cesium has created a new process to transform some chemical product 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.Monocarp wrote down two numbers on a whiteboard. Both numbers follow a specific format: a positive integer $x$ with $p$ zeros appended...
user: Generate an executable Python 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 Dayne is the ruler of a huge country called Seven Kingdoms. He has two sisters, Arya and Sansa, and wants to give some cities of 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.Chef has a grid of size N \times M. In one move, Chef can move from his current cell to an adjacent cell. If the Chef is currently 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 sequences, one is increasing sequence a[] and another a normal sequence b[], find the K-th missing element in the increasing...
user: Generate an executable Python 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. A tuple $(a, b, c)$ is consi...
user: Generate an executable Python 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 can perform the following operations on the string, $a$: Capitalize zero or more of $a$'s lowercase letters. Delete all of the ...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well. "Out of 6 billion humans, 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.AquaMoon and Cirno are playing an interesting game with arrays. Cirno has prepared two arrays $a$ and $b$, both consist of $n$ non-neg...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Happy Ladybugs is a board game having the following properties: The board is represented by a string, $\boldsymbol{b}$, of length $n$...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Chef has an array A of length N. In one operation, Chef can choose any [subsequence] of the array and any integer X and then add X 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.Given an array A of size N. The contents of A are copied into another array B and numbers are shuffled. Also, one element is removed f...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.You are given a standard 8 \times 8 chessboard which has exactly 3 pieces placed on it - 2 black rooks and 1 white king. The rows 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.-----Input----- The first line of input contains a line contains a line with four non-negative integers, $2 \le n \le 250$, $0 \le m \...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.You are given an undirected graph consisting of n vertices and m edges. Recall that a cycle is a path that starts and ends in the sam...
user: Generate an executable Python 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. You are given two binary str...
user: Generate an executable Python 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 an $n\! \times \! m$ grid and a $2\! \times \! 2$ block. She would like to place her block in the grid. She must place it so...