formatted_conversations
stringlengths
1.13k
138k
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.You are the founder of the Bruce Arden Programming Collective, which is a tutoring programme that matches experienced programmers 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.Chandler wants to give Joey money as Joey is going through some financial struggles. He believes 1500 will be enough to pay off the bi...
user: Generate an executable Python 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 browsing a math book, Mirko found a strange equation of the form $A=S$. What makes the equation strange is that $A$ and $S$ 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.When dealt cards in the card game Plump it is a good idea to start by sorting the cards in hand by suit and rank. The different suits ...
user: Generate an executable Python 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 balls in a bag. Initially, the i^{th} ball has a number A_{i} on it. In one second, a ball with number k (k>1), dissoci...
user: Generate an executable Python 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. Given an array consisting of N integers, you have to do the follow...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Harasees has an array A of size N containing non-negative integers. He starts at the index 1 of A and wants to reach the index N. In 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.You have a matrix $2 \times 2$ filled with distinct integers. You want your matrix to become beautiful. The matrix is beautiful if 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.Suppose there is a circle. There are $N$ petrol pumps on that circle. Petrol pumps are numbered $\mbox{0}$ to $(N-1)$ (both inclusive)...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.You are given an array of $n$ integers $a_1, a_2, \ldots, a_n$. After you watched the amazing film "Everything Everywhere All At Once"...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Doremy is asked to test $n$ contests. Contest $i$ can only be tested on day $i$. The difficulty of contest $i$ is $a_i$. Initially, Do...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Lukáš really likes orienteering, a sport that requires locating control points in rough terrain. To entertain the NWERC participants 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.Given a binary string S. The task is to count the number of substrings that starts and end with 1. Note: The starting and the ending 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.“Sabotage!” exclaimed J.R. Diddly, president and founder of Diddly Widgets Inc. “Vandalism, perhaps. Nothing’s actually been damaged...
user: Generate an executable Python 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 all know how to alphabetize a list of distinct words when you know the alphabet: One word may be a prefix of another longer word, 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.In Gregorian calendar a typical year consists of 365 days and 12 months. The numbers of days in the months are: 31, 28, 31, 30, 31, 30...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Judging from the previous problem, Friday the 13th really doesn't treat you well, so you start thinking about how to minimize its impa...
user: Generate an executable Python 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 finished his freshman year in college. As a p...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.There are $n$ logs, the $i$-th log has a length of $a_i$ meters. Since chopping logs is tiring work, errorgorn and maomao90 have decid...
user: Generate an executable Python 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 2 numbers A and B (A < B). Chef will perform some operations on A. In the i^{th} operation: Chef will add 1 to A if i is 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.Read problems statements in [Hindi], [Mandarin Chinese], [Russian], [Vietnamese], and [Bengali] as well. Chefland is a big city which...
user: Generate an executable Python 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 weighted tree with $n$ vertices. Recall that a tree is a connected graph without any cycles. A weighted tree is a tree...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Chef has with him an array A of length N. In one move, he can delete any element from A. Find the minimum number of deletions Chef mu...
user: Generate an executable Python 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 of n integers. For each element output the sum of itself and the previous element. For the first element, 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.The score of an array $v_1,v_2,\ldots,v_n$ is defined as the number of indices $i$ ($1 \le i \le n$) such that $v_1+v_2+\ldots+v_i = 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.A left rotation operation on an array of size $n$ shifts each of the array's elements $1$ unit to the left. Given an integer, $\boldsy...
user: Generate an executable Python 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 $\mbox{P}$ to be a permutation of the first $n$ natural numbers in the range $[1,n]$. Let $p o s[i]$ denote the value at pos...
user: Generate an executable Python 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 HTML code snippet of $N$ lines. Your task is to detect and print all the HTML tags, attributes and attribute values....
user: Generate an executable Python 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 class recently got a maths assignment with 5 questions. There are N (≤ 20) students in the class and at most 2 people can collabo...
user: Generate an executable Python 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 length $n$ and an integer $k$, you are tasked to find any two numbers $l$ and $r$ ($l \leq r$) such that: 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.The only difference between the easy and hard versions is that the given string $s$ in the easy version is initially a palindrome, thi...
user: Generate an executable Python 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 bracket sequence consisting of $n$ characters '(' and/or )'. You perform several operations with it. During one opera...
user: Generate an executable Python 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 Queue Q containing N elements. The task is to reverse the Queue. Your task is to complete the function rev(), that reverses 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.In this problem you will be doing some funny operations. These operations are basically a mixture of bitwise operations. You will be g...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Given an array of 0 and 1. In how many iterations it is possible that the whole array can be filled with 1's, if in a single iteration immediate neighbours of 1's can be fille...
user: Generate an executable Python 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 sorted arrays and a number x, find the pair whose sum is closest to x and the pair has an element from each array. In the ca...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Given an array of size N containing level order traversal of a BST. The task is to complete the function constructBst(), that construct the BST (Binary Search Tree) from its 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.Given an array Arr[] of N elements. Perform K right circular rotations on given ranges [L...R]. After performing these rotations, we 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.Yraglac really hates early winter. So he was greatly annoyed when it snowed early this year. His friend however claimed that summer 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.Magnus is the youngest chess grandmaster ever. He loves chess so much that he decided to decorate his home with chess pieces. To decor...
user: Generate an executable Python 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 a number of people who will be attending ACM-ICPC World Finals. Each of them may be well versed in a number of topics. Given...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Polycarp likes squares and cubes of positive integers. Here is the beginning of the sequence of numbers he likes: $1$, $4$, $8$, $9$, ...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Not so long ago, Vlad came up with an interesting function: $f_a(x)=\left\lfloor\frac{x}{a}\right\rfloor + x mod a$, where $\left\lfl...
user: Generate an executable Python 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. Princess Rupsa saw one of her friends playing a specia...
user: Generate an executable Python 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 size N and an integer K. He can perform the following operation on A any number of times: Select any K distinct...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Lazy caterer sequence is defined as the maximum number of pieces formed when slicing a convex pancake with n cuts (each cut is a strai...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.You are given a string that represents the postfix form of a valid mathematical expression. Convert it to its prefix form. Example: 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.Recently, the students of School 179 have developed a unique algorithm, which takes in a binary string $s$ as input. However, they soo...
user: Generate an executable Python 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 array A consisting of N integers. He calls 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.Long time ago there was a symmetric array $a_1,a_2,\ldots,a_{2n}$ consisting of $2n$ distinct integers. Array $a_1,a_2,\ldots,a_{2n}$ ...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Read problems statements [Bengali] , [Mandarin chinese] , [Russian] and [Vietnamese] as well. Chef is a cook and he has recently open...
user: Generate an executable Python 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 current programming club president, Norbit, gives speeches at the weekly club meetings. Casual viewers are underwhelmed with the q...
user: Generate an executable Python 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 exam time! You have, of course, been spending too much time participating in various programming contests and have not done much...
user: Generate an executable Python 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 string S of 0 and 1, check if the given string is valid or not. The given string is valid when there is no zero is pres...
user: Generate an executable Python 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 wants to rent a car to travel to his restaurant which is N kilometers away. He can either rent a petrol car or a diesel car. 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.Pumpkin Pete is trying out a new type of “rapid-growth” pumpkin seed that he bought from the farmer’s market. Without looking at the 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.Read problems statements in Mandarin Chinese and Russian. Chef likes to write poetry. Today, he has decided to write a X pages long...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Bill Gates is on one of his philanthropic journeys to a village in Utopia. He has brought a box of packets of candies and would like 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.After acquiring a new integer and showing it off to other couples at a cocktail party, Alice and Bob headed home for a good night 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.Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well. There are $N$ people on a str...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Given N distinct digits in an array A (from 1 to 9), Your task is to complete the function getSum which finds sum of all n digit numbers that can be formed using these digits....
user: Generate an executable Python 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 grid consisting of $N$ rows and $M$ columns, where each cell is either air, stone, or water. Each second, the water spreads...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Devendra just had a million-dollar idea and he needs funds to startup. He was recently invited to Sasta Shark Tank (A TV show where en...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Anton loves creating strings! Anton now wants to create a string S following some specific rules. They are as follows: Initially, 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.There are 100 questions in a paper. Each question carries +3 marks for correct answer, -1 marks for incorrect answer and 0 marks for u...
user: Generate an executable Python 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 us call two integers $x$ and $y$ adjacent if $\frac{lcm(x, y)}{gcd(x, y)}$ is a perfect square. For example, $3$ and $12$ are adja...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.You are given a string containing characters $\mbox{A}$ and $\mbox{B}$ only. Your task is to change it into a string such that there ...
user: Generate an executable Python 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 of length $n$: $a_1, a_2, \dots, a_n$ and $b_1, b_2, \dots, b_n$. You can perform the following operation 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.Nim is a famous game in which two players take turns removing items from $n$ distinct piles. During each turn, a player must remove on...
user: Generate an executable Python 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 array of numeric strings where each string is a positive number with anywhere from $\mbox{I}$ to $10^{6}$ digits. Sort 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 [Mandarin], [Vietnamese], and [Russian] as well. You are given a positive integer K and an array A consist...
user: Generate an executable Python 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 will be given a square chess board with one queen and a number of obstacles placed on it. Determine how many squares the queen ca...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Let's define $S(x)$ to be the sum of digits of number $x$ written in decimal system. For example, $S(5) = 5$, $S(10) = 1$, $S(322) = 7...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Chefland is a $1D$ city where each of the $N$ houses is located at a distinct positive integer coordinate $A_{1}, A_{2}, \ldots A_{N}$...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.This is year 2050 and your school is hosting IOI 2050 this time. To organize the contest a lot of LAN cables will be laid down. N stud...
user: Generate an executable Python 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. It’s Chef's birthday. He and his twin ...
user: Generate an executable Python 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 been assigned to develop a filter for bad messages in the in-game chat. A message is a string $S$ of length $n$, consisting 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.A pair of positive integers $(a,b)$ is called special if $\lfloor \frac{a}{b} \rfloor = a mod b$. Here, $\lfloor \frac{a}{b} \rfloor$ ...
user: Generate an executable Python 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. A competition with $N$ parti...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Illiteracy is a simple puzzle game created by Le Sio. 1 The game consists of a sequence of eight icons; the actual icons are very arti...
user: Generate an executable Python 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 sequence of integers is beautiful if each element 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.Read problems statements in Mandarin Chinese and Russian as well. Andrii is a great programmer. He recently managed to enter Ukraini...
user: Generate an executable Python 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. The staff of one of the most famous ChefLand's restaurants have just recei...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Mirko got his driver’s license! To celebrate that joyous occasion, his parents bought him his first car: a monster truck! Mirko found ...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Zara, an aspiring architect and urban planner, has drawn out what she considers to be the perfect skyline. As Zara is still aspiring 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.Most of you have played card games (and if you haven’t, why not???) in which the deck of cards is randomized by shuffling it one or mo...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Read problems statements in Mandarin Chinese, Russian and Vietnamese as well. Chef likes problems related to numbers a lot. He is gen...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Jesse loves cookies and wants the sweetness of some cookies to be greater than value $\boldsymbol{\mbox{k}}$. To do this, two cookies ...
user: Generate an executable Python 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 is your birthday. You have decided to give away candies to your friends. You have N friends and M candies. Suppose the 1^{st} ...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Timur likes his name. As a spelling of his name, he allows any permutation of the letters of the name. For example, the following 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.The “eight queens puzzle” is a classic puzzle where you have to place eight queens on a chess board in such a way that no queen can at...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.You are given an array $a$ of length $n$, and an integer $x$. You can perform the following operation as many times as you would like ...
user: Generate an executable Python 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 had $n$ positive integers $a_1, a_2, \dots, a_n$ arranged in a circle. For each pair of neighboring numbers ($a_1$ and $a_2$, $a_2...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given a string that is made up of words separated by spaces. Your task is to find the word with highest frequency, i.e. it appears maximum times in the sentence. If mu...
user: Generate an executable Python 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 final day of La Liga. Chef has a certain criteria for assessing football matches. In particular, he only likes a match 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.Samba has annoyed gabbar once again. But this time gabbar has all the six bullets in his pistol. the only way for samba to escape is t...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Chhota Bheem wants to eat the maximum number of ladoos in Dholakpur on Independence Day. The houses in Dholakpur are arranged in the 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.Žofka invented a new word puzzle. She gives you two strings $s_1$ and $s_2$ of the same length. You need to modify $s_1$ into $s_2$ 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.Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well. Chef has invested his savings...
user: Generate an executable Python 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 sequence whose $n^{\text{th}}$ term is $T_{n}=n^{K}$ You have to evaluate the series $S_n=T_1+T_2+T_3+\cdots+T_n$ Fi...