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 may have heard of the “maximum subarray problem” from your university’s undergraduate algorithms course. The problem goes like 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.Now as I fest is on the way to start Coordinators of different events are busy in purchasing Goodies for the winners. But the coordina... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Ivana won the bet (Zvonko hadn’t foreseen this and suspects that it is due to outside interference) and now Zvonko is waiting for her ... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.John, a student who is taking the game development course, recently developed a mobile game called Fruit Slicer for his coursework. 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, russian and vietnamese as well.
Chef Ada loves trees, she thinks that the beauty 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.Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Сhef has assembled a football... |
user: Generate an executable Python 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 integers, sort the array (in descending order) according to count of set bits in binary representation of array elem... |
user: Generate an executable Python 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.
In a far away dystopian world, the measure of the quality of a person’s 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 number N, print all the composite numbers less than or equal to N. The number should be printed in ascending order.
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 an infinite number line. You start at 0 and can go either to the left or to the right. The condition is that in the i^{th} move,... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.You are given a tree with N nodes and each has a value associated with it. You are given Q queries, each of which is either an update ... |
user: Generate an executable Python 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 seminar of Artificial Intelligence is going on,and the number of participants from Foreign is N, while from India is M. All the part... |
user: Generate an executable Python 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 devotee wishing to give offerings to temples along a mountain range. The temples are located in a row at different heights.... |
user: Generate an executable Python 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 connected undirected tree with N nodes. In one move, you can merge any two adjacent nodes. Calculate the minimum number of mov... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Given the schedule of Chef for 30 days (A binary string of length 30 where '0' denotes that Chef was on leave and '1' denotes Chef was... |
user: Generate an executable Python 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 encoded string (s) is given, and the task is to decode it. The encoding pattern is that the occurrence of the string is given at 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.Given an odd number in the form of string, the task is to make largest even number possible from the given number provided one is allo... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Petra is learning how to add two positive integers in school, but thinks it is a bit too difficult. They are currently working with 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.Given a doubly linked list of n nodes sorted by values, the task is to remove duplicate nodes present in the linked list.
Example 1:
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 [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Consider the following functi... |
user: Generate an executable Python 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 string str of a constant length, print a triangle out of it. The triangle should start with the first character of the string 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.Professor Sahil is a master artist, he always finds creative ways to teach lessons to his students.
Today in Painting class he took al... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Rainfall is measured in millimeters. The rain is collected in a vertical transparent tube with millimeter markings, and once the rain ... |
user: Generate an executable Python 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$ positive integers $a_1, a_2, \ldots, a_n$. Your task is to calculate the number of arrays of $n$ positiv... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Images by John Fowler, Carol Highsmith, and Richard Woodland
You have decided to spend a day of your trip to Rapid City taking photog... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Read problems statements [Mandarin] , [Bengali] , [Hindi] , [Russian] and [Vietnamese] as well.
You are given a grid with $N$ rows 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.Given the adjacency list representation of an undirected graph
your task is to complete the function printGraph() that takes the numbe... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Richard and Daniel have been very naughty throughout the day. So their computer teacher gave them a problem and if they are able to so... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Implement a simple text editor. The editor initially contains an empty string, $\mbox{S}$. Perform $Q$ operations of the following $\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.Parsa has a humongous tree on $n$ vertices.
On each vertex $v$ he has written two integers $l_v$ and $r_v$.
To make Parsa's tree loo... |
user: Generate an executable Python 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.
Fedya and Alex are OI-ers. They live in different cities, but they 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.Better Documents Inc. is contemplating the next generation of word processors. Now, nearly every word processor includes a Spell Check... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.You are given an array $a$ consisting of $n$ integers.
Let's call a pair of indices $i$, $j$ good if $1 \le i < j \le n$ and $\gcd(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 problem is a complicated version of D1, but it has significant differences, so read the whole statement.
Polycarp has an array 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 are given two strings $s$, and $t$. Count the number of substrings of $s$ that contain $t$ as a subsequence at least once.
Note 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.There is a contest containing 2 problems A and B.
2 strong participants P and Q participated in the contest and solved both the prob... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Cady’s Chocolate Company just opened down the street! Cady’s chocolate is world famous, and her recipe is top secret. But the company ... |
user: Generate an executable Python 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 gardener Kazimir Kazimirovich has an array of $n$ integers $c_1, c_2, \dots, c_n$.
He wants to check if there are two different 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.Luka is slacking again during chemistry class, while the teacher is explaining Avogadro’s law.
Luka first drew a table consisting 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.Some viruses replicate by replacing a piece of DNA in a living cell with a piece of DNA that the virus carries with it. This makes 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.Parimal and VKC are playing a game. The scenerio is that 'N' balls are there in front of Parimal and VKC, also each ball has been giv... |
user: Generate an executable Python 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 with N elements and value of all the elements is zero. We can perform following operations on the array.
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.Let's define the cost of a simple undirected graph as the sum of the costs of its nodes. The cost of a node is defined as DK, where 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 problem statements in [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Chef has A units of solid and B units ... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Let's call a permutation $p$ of length $n$ anti-Fibonacci if the condition $p_{i-2} + p_{i-1} \ne p_i$ holds for all $i$ ($3 \le i \le... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Two people are playing game of Misère Nim. The basic rules for this game are as follows:
The game starts with $n$ piles of stones ind... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Given a number N. Check whether it is divisible by the sum of its digits or not.
Example 1:
Input:
N=18
Output:
1
Explanation:
The sum... |
user: Generate an executable Python 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 your town has been infested by swindlers who convince unknowing tourists to play a simple dice game with them for money. 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.Alice has just learned addition. However, she hasn't learned the concept of "carrying" fully — instead of carrying to the next column,... |
user: Generate an executable Python 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 permutation P of length 2 \cdot N. He can perform the following operation on P:
Select an index i (1 ≤ i < 2 \cdot N) 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.You are given an array, arr of length N, and also a single integer K . Your task is to split the array arr into K non-overlapping, 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.You are standing at the point $0$ on a coordinate line. Your goal is to reach the point $n$. In one minute, you can move by $2$ or by ... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Given a Directed Graph having V nodes numbered from 0 to V-1, and E directed edges. Given two nodes, source and destination, count 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.A company conducted a coding test to hire candidates. $N$ candidates appeared for the test, and each of them faced $M$ problems. 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.Read problems statements in Mandarin Chinese, Russian and Vietnamese as well.
Last week Penguin Charlie had a birthday. Chef present... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Note: This POTD is a part of Geek Summer Carnival. Solve all POTD consecutively from 5th to 10th April and get a chance to win exclusi... |
user: Generate an executable Python 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 as follow:
1,1,7,19,73....
Find the N^{th} term of the given sequence.
Example 1:
Input: N = 1
Output: 1
Example 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.There are N events (numbered from 1 to N) and M contestants (numbered from 1 to M). For each event i, contestant j receives a predeter... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Two players are playing a game on a $15\times15$ chessboard. The rules of the game are as follows:
The game starts with $\boldsymbol{... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Read problems statements in [Hindi], [Mandarin Chinese], [Vietnamese], and [Bengali] as well.
You are given two sets of segments on 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.In the greatest epic Mahabharata, Before the Kurukshetra war started both the Kauravas and the Pandavas were trying to get the support... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Hexagonal numbers are figurate numbers which can be calculated using the formula hn = 2n2 - n. You are given n; calculate n-th hexagon... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Shefin gives you a string S and you have to find a non-empty string P such that:
P is a substring of S.
No non-empty substring of 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.Josip is a strange painter. He wants to paint a picture consisting of $N \times N$ pixels, where $N$ is a power of two ($1, 2, 4, 8, 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.Alice gave Bob 3 integers N, K, and S. Help Bob find an S-good sequence.
A sequence B of length N is called S-good if the following c... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.The two countries of A and B are at war against each other. Both countries have N number of soldiers. The power of these soldiers are given by A[i]...A[N] and B[i]....B[N].
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.Björn likes the square root of two, $\sqrt {2} = 1.41421356\dots $ very much. He likes it so much that he has decided to write down 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.Given a sequence of N elements, Chef defines a function F(i) (1 ≤ i ≤ N) as the median of the first i elements of the sequence.
Chef ... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Tracy gives Charlie a [Directed Acyclic Graph] with N vertices. Among these N vertices, K vertices are *sources*, and L vertices 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.After dating for a long time, Akhil is finally going to propose to his girlfriend. She is very strong in mathematics, and will accept ... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Harry is a bright student. To prepare thoroughly for exams, he completes all the exercises in his book! Now that the exams are approac... |
user: Generate an executable Python 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 M of size n * n, the task is to find sum of the zigzag sequence with the largest sum. A zigzag sequence starts from the... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Given an array arr[] of N values, the task is to find the number which has the maximum number of zeroes. If there are no zeroes then print -1.
Note: If there are multiple 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.You are given an array A of length N.
You can perform the following operation on the array, as long as it has more than one element:... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Chan has decided to make a list of all possible combinations of letters of a given string S. If there are two strings with the same se... |
user: Generate an executable Python 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 an integer n, your task is to return the sum of all natural number less than or equal to n.
As the answer could be 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.Read problems statements in Mandarin chinese, Russian and Vietnamese as well.
Gritukan likes to take cyclic trips around the world. ... |
user: Generate an executable Python 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 India vs Pakistan and all the tickets of the match have been sold out.
Chotu being a die-hard fan participates in a lucky draw 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.Given an integer N, list all the divisors of N (excluding N) in sorted order. Find the number formed by performing the XOR operation 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.Alice is visiting New York City. To make the trip fun, Alice will take photos of the city skyline and give the set of photos as a 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.Given two sorted matrices mat1 and mat2 of size N x N of elements. Given a value x. The problem is to count all pairs from both matric... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Write a program to implement a Stack using Array. Your task is to use the class as shown in the comments in the code editor and comple... |
user: Generate an executable Python 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 three positive integers x, y and n, the task is to find count of all numbers from 1 to n that can be formed using x and y. A num... |
user: Generate an executable Python 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 defines a group of three friends as a *perfect* group if the age of one person is equal to the sum of the age of remaining two pe... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.You are the boss of ACM (Association for Cool Machineries), an upstanding company with a single goal of world domination.
Like all ot... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Given n arrays of size m each. Find maximum sum obtained by selecting a number from each array such that the element selected from the i-th array is more than the element sele... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Given a number N, find the total sum of digits of all the numbers from 1 to N.
Example 1:
Input:
N = 5
Output:
15
Explanation:
Sum 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 Mandarin Chinese, Russian and Vietnamese as well.
Chef likes problems involving arrays. Unfortunately, t... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Given a set of N integer points on the Cartesian plane. Your task is to find an integer point satisfying its sum of distances to N giv... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.DestinyLand is a really fun place for kids. It is composed of N islands, numbered from 1 to N. The company is planning to divide these... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Given a number N, find the total number of possible X such that (N XOR X) == (N OR X), where 0<=X<=N.
Example 1:
Input: N = 5
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.BAAS Inc. (Build Airplanes As-a-Service) has grand plans to build lots of airplanes. Naturally, the airplane construction process cons... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.------Read problems statements in Hindi,
Mandarin chinese
, Russian and Vietnamese as well. ------
During Eid, it's a tradition that... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Chef recently solved his first problem on CodeChef. The problem he solved has N test cases. He gets a score for his submission accordi... |
user: Generate an executable Python 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 known problem with some microphones is the “hissing s”. That is, sometimes the sound of the letter s is particularly pronounced; it ... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Liam is planning out his route for an upcoming nature hike. Unfortunately, the region that he plans on hiking through is notoriously 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 integers L and R, your task is to find the XOR of elements of the range [L, R].
Example:
Input:
L = 4, R = 8
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.Chef has an integer N. It is known that the largest [odd] [divisor] of N does not exceed 10^{5}.
Determine two non-negative integers... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Provided a String of length N, your task is to find out whether or not the given string is a prime string. A prime string is a 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.Everybody knows what an arithmetic progression is.
Sequences [1, 5], [10], [5, 4, 3] are arithmetic progressions and sequences [1, 3... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.