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.YOLO is a simple card game played between two players with a normal deck of 52 WWE cards, each having a rank, forming a sequence of 52...
user: Generate an executable Python 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 n-ary trees. Check if they are mirror images of each other or not. You are also given e denoting the number of edges in both...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Smith numbers were named by Albert Wilansky of Lehigh University. He noticed the property in the phone number (493-7775) of his brothe...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.A step array is an array of integers where each element has a difference of at most k with its neighbor. Given a key x, we need to find the index value of x if multiple elemen...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.One of the SWERC judges has a dog named Boy. Besides being a good competitive programmer, Boy loves fresh air, so she wants to be walk...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.You are given a number N, you have to represent this number as the sum of the minimum number of possible pseudo-binary numbers. A 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.Employees of JebTrains are on their way to celebrate the 256-th day of the year! There are n employees and k teams in JebTrains. 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.There is a heavy rainfall over the Antique Cultural Museum, and the roof has sprung a leak! All the beautiful paintings risk destructi...
user: Generate an executable Python 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 which consists of only lowercase English alphabets, you have to perform the below operations: If the string S contain...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Alice and Bob are playing a game. Alice goes first. They have a binary circular array A with N elements. In one move, a player can: 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.It's Sparsh (techno-cultural fest of SVNIT) time and that means a week long holidays for SVNITians!! Almost all students get their ful...
user: Generate an executable Python 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 The great Charzeh is playing a game with Joffrey Baratheon. There are n knights in seven kingdoms. i-th knig...
user: Generate an executable Python 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, check if all leaves are at same level or not. Example 1: Input: 1 / \ 2 3 O...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Given a binary matrix mat[][] of dimensions NxM such that 1 denotes land and 0 denotes water. Find the number of closed islands 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.Given a dictionary of words and an M x N board where every cell has one character. Find all possible different words from the dictiona...
user: Generate an executable Python 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 Oz is playing with colorful balls. He has A red balls, B blue balls, C green balls and D yellow balls. Using the balls, he wa...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Koga and Ryuho, new generation Athena's saints, are training to improve their control over the cosmos. According to the ancient Master...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Chef has two non negative integers N and X. He now wants to find the number of integers K such that 0 ≤ K < N, and (N \oplus K) \And X...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Read problems statements in Mandarin Chinese, Russian and Vietnamese as well. Chef has a two-dimensional matrix A of dimensions 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 stairs, and a person standing at the bottom wants to reach the top. The person can climb either 1 stair or 2 stairs at a 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.You have $N$ objects, each with $M$ copies. How many ways are there to take exactly $K$ of them? -----Input----- The first line of 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.Given an array arr of size n containing non-negative integers, the task is to divide it into two sets S1 and S2 such that the absolute...
user: Generate an executable Python 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 bored technician whose job requires inspecting each of $10$ equipment stations on a regular basis has tried to inject a little varie...
user: Generate an executable Python 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 length n. Find all possible unique permutations of the array. Example 1: Input: n = 3 arr[] = {1, 2, 1} Outpu...
user: Generate an executable Python 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 2D integer array ranges whose length is n where ranges[i]=[start_{i}, end,coins_{i}] means all integers from start_{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 problem statements in [Russian] Chef has a sequence $A_{1}, A_{2}, \ldots, A_{N}$. In one operation, Chef can choose one index $...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Chinese Fedor is a research scientist, who has recently found a road map of Ancient Berland. Ancient Berland consisted of N cities...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Calculate the angle between the hour hand and minute hand. Note: There can be two angles between hands; we need to print a minimum 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.It is the hard version of the problem. The only difference is that in this version $3 \le k \le n$. You are given a positive integer ...
user: Generate an executable Python 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 define the diameter of a strongly-connected oriented graph, $G=(V,E)$, as the minimum integer $\boldsymbol{d}$ such that for 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.Munnabhai desires to become a very famous doctor. So he just enrolled in a famous university. University offers N different courses. 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.A matrix is constructed of size n*n. such that M_{i}_{,j}= i+j. Count the number of cells having value q. Note: Assume, the array is 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.The Hogwarts School of Witchcraft and Wizardry is the home of many students during the school year. The school has many rooms connecte...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.An array is said to be good if all its elements are distinct, i.e. no two elements of the array are equal to each other. You are give...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Zapray recently did not have much time to finish his homework due to his addiction to Pokemon. What is even worse, this week’s algorit...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.You are given a number n. Print n lines, i-th line should consist of i characters "*". Lines' indices are 1-based. Input The only li...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Read problems statements in Mandarin chinese, Russian and Vietnamese as well. Chef has a sequence $A$ consisting of $N$ positive int...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Chef has a rectangular plate of length N cm and width M cm. He wants to make a wireframe around the plate. The wireframe costs X rup...
user: Generate an executable Python 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$ ($n \ge 3$) positive integers. It is known that in this array, all the numbers except one...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Rachit, one of the best programmers of Geekland university is busy in his research on prime numbers these days. Once, while roaming in...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Read problems statements in Mandarin Chinese and Russian. Chef has N simple polygons (non self intersecting polygons) in which no tw...
user: Generate an executable Python 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 [Hindi] , [Vietnamese] , [Mandarin Chinese] , [Russian] and [Bengali] as well. Chef loves prime numbers 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.Isaac has to buy a new HackerPhone for his girlfriend Amy. He is exploring the shops in the town to compare the prices whereupon he fi...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.You and your friends have gathered at your house to prepare for the Big Game, which you all plan to attend in the afternoon at the foo...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.This time around, Baby Ehab will play with permutations. He has $n$ cubes arranged in a row, with numbers from $1$ to $n$ written 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.A palindrome is a word that reads the same forward and backward. Given a string s, you need to make it a palindrome by adding 0 or mor...
user: Generate an executable Python 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 big international retailer is setting up shop in India and plans to open stores in N towns (3 ≤ N ≤ 1000), denoted by 1, 2, . . . , ...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.You have recently started playing a brand new computer game called "Mr. President". The game is about ruling a country, building infra...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.For a given number N check if it is prime or not. A prime number is a number which is only divisible by 1 and itself. Example 1: Inp...
user: Generate an executable Python 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 with a value associated with each node, we need to choose a subset of these nodes such that sum of chosen nodes is...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.You are given two arrays $A$ = $A_{1}, A_{2}, \ldots, A_{N}$ and $B$ = $B_{1}, B_{2}, \ldots, B_{N}$. We want to make these two arrays...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Frank N. Stein is a very conservative high-school teacher. He wants to take some of his students on an excursion, but he is afraid tha...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.You are given an array A of N positive integers. In one operation, you can do the following: Choose an index i (1 ≤ i ≤ N), and chan...
user: Generate an executable Python 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 rooted tree of N vertices rooted at vertex 1. Each vertex v has a value A_{v} associated with it. You choose a vertex v (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.You are given a positive integer $N$. Your task is to print a palindromic triangle of size $N$. For example, a palindromic triang...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Young Mr. Potato is opening two new stores where he will, you guessed it, sell potatoes. Mr. Potato gets his potatoes from $N$ farmers...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Sheila is a student and she drives a typical student car: it is old, slow, rusty, and falling apart. Recently, the needle on the speed...
user: Generate an executable Python 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 pattern containing only I's and D's. I for increasing and D for decreasing. Devise an algorithm to print the minimum number 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 lowercase Latin character (letter), check if it appears in the string ${codeforces}$. -----Input----- The first line 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.There is a grid with $n$ rows and $m$ columns. Some cells are colored black, and the rest of the cells are colored white. In one oper...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Read problems statements in Mandarin Chinese, Russian and Vietnamese as well. Chef is a private detective. He was asked to investiga...
user: Generate an executable Python 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 lowercase letters in the range ascii[a-z], determine the index of a character that can be removed to make the string...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Tokitsukaze has a sequence $a$ of length $n$. For each operation, she selects two numbers $a_i$ and $a_j$ ($i \ne j$; $1 \leq i,j \leq...
user: Generate an executable Python 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 boys and N girls attend a dance class, where N is odd. For today's practice session, they need to form N boy-girl pairs. The i-th 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.Last winter, an avalanche swept away all the ski lifts from the ski resort Valen. Instead of rebuilding the lifts like they were befor...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Arithmetic coding is a method to represent a message as a real number $x$ such that $0 \leq x < 1$. We will assume that the message co...
user: Generate an executable Python 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 binary matrix A i.e. it contains only 0 and 1.Now you are at A[1][1] and you want to go to an ending point A[k...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Given a square matrix[][] of size N x N. The task is to rotate it by 90 degrees in an anti-clockwise direction without using any extra space. Example 1: Input: N = 3 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.Many phones use a nine-pivot unlock pattern. The nine pivots are arranged as a $3 \times 3$ grid, and numbered from $1$ to $9$ as show...
user: Generate an executable Python 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 positive integer number fair if it is divisible by each of its nonzero digits. For example, $102$ is fair (because it is div...
user: Generate an executable Python 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 only 2 type of denominations in Chefland: Coins worth 1 rupee each Notes worth 10 rupees each Chef wants to pay his friend...
user: Generate an executable Python 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 simple .Given a positive integer N . Let X be the factorial of N. You have to calculate pf , sum and div where , pf=tot...
user: Generate an executable Python 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 has a string $S$. He als...
user: Generate an executable Python 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, construct an array A of length N such that: 1 ≤ A_{i} ≤ 10^{18} for all (1 ≤ i ≤ N); There exists a [subsequence] ...
user: Generate an executable Python 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 array. The task is to find the maximum of the minimum of every window size in the array. Note: Window size varies fro...
user: Generate an executable Python 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(duplicates allowed). Print “Yes” if it is a set of contiguous integers else print “No”. 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.Everybody loves big numbers (if you do not, you might want to stop reading at this point). There are many ways of constructing really ...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Baby Ehab is known for his love for a certain operation. He has an array $a$ of length $n$, and he decided to keep doing the following...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.You are given a polynom in form p(x) = (x + a1)·(x + a2)·... (x + an). Write Pike program to print it in a standard form p(x) = xn + 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.You have two arrays A and B of size N and M respectively. You have to merge both the arrays to form a new array C of size N + M (the 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.Allen, a government secret service, has been assigned to infiltrate a mafia secret base to uncover crucial information regarding the m...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.You are given an array A = [A_{1}, A_{2}, \ldots, A_{N}], consisting of N integers. In one move, you can take two adjacent numbers 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’s a new art installation in town, and it inspires you…to play a childish game. The art installation consists of a floor with 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.Read problem statements in [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well. Chef has 3 boxes of sizes A, B, and 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.You are given an array A of length N. An element X is said to be *dominant* if the frequency of X in A is strictly greater than the fr...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Ravi a team member of Abhinav’s ACM ICPC team akatsuki11 is also a good friend of Abhinav. Ravi is a chess-freak who keeps on defeatin...
user: Generate an executable Python 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[], its starting position l and its ending position r. Sort the array using merge sort algorithm. 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.Developed in the 1940s in the United Kingdom, the game of Cluedo is one of the most popular board games in the world. The object 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.You are given an infinite 2-d grid with the bottom left cell referenced as (1,1). All the cells contain a value of zero initially. Let...
user: Generate an executable Python 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, you need to find the number of all root to leaf paths along with their path lengths. Example 1: Input: 3 ...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Given a matrix with n rows and m columns. Your task is to find the kth element which is obtained while traversing the matrix spirally....
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.King loves to go on tours with his friends. King has N cars that can seat 5 people each and M cars that can seat 7 people each. Deter...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Sevenkplus has a rooted tree with $N$ vertices. The vertices are labeled from $1$ to $N$. $1$ is the root of the tree. Each vertex $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.Your slightly pointy-bearded boss has assigned you to write software to find the best songs from different music albums. And the softw...
user: Generate an executable Python 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 Math department has challenged the Computer Science department at your University to solve a difficult puzzle in Discrete Mathemat...
user: Generate an executable Python 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 strings of digits, try to find the occurrence of a given pattern of digits. In the grid and pattern arrays, each 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.Neo has a complex matrix script. The matrix script is a $N$ X $\mbox{M}$ grid of strings. It consists of alphanumeric characters, 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.Chef is playing a mobile game. In the game, Chef's character *Chefario* can perform special attacks. However, one special attack costs...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.An input string S of length N is transferred through the network using a special protocol. The protocol can send the string through 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.This is the easy version of this problem. In this version, we do not have queries. Note that we have multiple test cases in this versi...