formatted_conversations stringlengths 1.13k 138k |
|---|
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Read problem statements in [Bengali], [Russian], [Mandarin] and [Vietnamese] as well.
Chef is given two integers N and M. Please help... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Given two integers, $\boldsymbol{l}$ and $\textbf{r}$, find the maximal value of $\boldsymbol{a}$ xor $\boldsymbol{b}$, written $a\opl... |
user: Generate an executable Python 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 of the nodes of a Binary Search Tree (BST) are swapped. Fix (or correct) the BST by swapping them back. Do not change the structur... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Given an array of N positive integers where all numbers occur even number of times except one number which occurs odd number of times.... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Nikolaj works at a company that sells a large number of products. Each product has a product ID, which is a large integer. For error 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.You have a binary string S. You can perform the following operation on S:
Select any substring S_{L \dots R} (1 ≤ L ≤ R ≤ |S|) which 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.Mirko has chosen four integers which form an arithmetic progression. In other words, when the four numbers are sorted, then the differ... |
user: Generate an executable Python 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.
There are S sine functions and C cosine functions as following:
a_{i} sin... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Black Friday is the Friday following Thanksgiving Day in the United States (the fourth Thursday of November). Since the early 2000s, 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 [Bengali], [Russian], [Mandarin] and [Vietnamese] as well.
A string S whose characters are one of the foll... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Spike is competing in the Gauntlet of Fire for the title of Dragon Lord. To succeed, he needs to traverse the labyrinthine volcanic tu... |
user: Generate an executable Python 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 searching for the pizza, baby Hosssam came across two permutations $a$ and $b$ of length $n$.
Recall that a permutation is an 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.We know that a sequence of N integers is called a permutation if it contains all integers from 1 to N exactly once.
A K- *beautiful 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.-----Input-----
The first line of input contains an integer $1 \le N \le 40$, the degree of the recurrence. The next line of input con... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Ashish has a string $s$ of length $n$ containing only characters 'a', 'b' and 'c'.
He wants to find the length of the smallest substr... |
user: Generate an executable Python 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.
The last time in Byteland, Ch... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Somewhere in an animal kingdom far from here there is a large forest. Inside the forest live a large number of frogs. Every year 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.Chef has two binary strings A and B, each of length N.
Chef can rearrange both the strings in any way. Find the maximum [bitwise XOR]... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Given a linked list of size N, your task is to complete the function isLengthEvenOrOdd() which contains head of the linked list and check whether the length of linked list 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.Let's define a good tree:It is a tree with k * n nodes labeled from 0 to k * n - 1
Node i and node j are not adjacent, for all 0 ≤ i, ... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Given a sorted array of positive integers. Your task is to rearrange the array elements alternatively i.e first element should be max ... |
user: Generate an executable Python 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 and a target value, determine the number of pairs of array elements that have a difference equal to the tar... |
user: Generate an executable Python 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 very hungry. So, Chef goes to a shop selling burgers. The shop has 2 types of burgers:
Normal burgers, which cost X rupees eac... |
user: Generate an executable Python 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 town with N people and initially, the i^{th} person has A_{i} coins. However, some people of the town decide to become *mon... |
user: Generate an executable Python 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 and his friend Bharat have decide... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Vlad found two positive numbers $a$ and $b$ ($a,b>0$). He discovered that $a \oplus b = \frac{a + b}{2}$, where $\oplus$ means the bit... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Yes! You’ve finally been chosen to participate in the "Great Geek Game-show 3000". This is the moment you’ve been waiting for, ever si... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Manasa loves the nim game, in which there are $n$ buckets, each having $A_i$ balls. Two players play alternately. Each turn consists 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.Wallace the Weightlifting Walrus is training for a contest where it will have to lift $1000$ kg. Wallace has some weight plates lying ... |
user: Generate an executable Python 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 distant country has $N$ cities in it. The elections were just held in this country, so the new prime minister was elected. Currently... |
user: Generate an executable Python 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 invested his money at an interest rate of X percent per annum while the current inflation rate is Y percent per annum.
An 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 problems statements in [Mandarin Chinese], [Russian], [Vietnamese] and [Bengali] as well.
Chef invented a new game named Quick B... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Ishaan is given N integers in the form of an array A. He is asked to select all of these integers in any order. For selecting every integer he gets some points. He needs to ma... |
user: Generate an executable Python 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.
Euler's phi function for a positive integer N is usually denoted ... |
user: Generate an executable Python 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 L-shape is a figure on gridded paper that looks like the first four pictures below. An L-shape contains exactly three shaded cells ... |
user: Generate an executable Python 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 like how hot dogs come in packs of ten, and buns come in packs of eight or twelve — you have to buy nine packs to make it come 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're creating a game level for some mobile game. The level should contain some number of cells aligned in a row from left to right 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.One day, Wet Shark was given an array $X=\{x_1,x_2,\ldots,x_m\}$. As always, he started playing with its subsequences.
When you came... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.JJ has an array A. He can perform the following operation on A:
Divide A into two subsequences P and Q such that each A_{i} belongs to... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Read problem statements in [Bengali], [Russian], [Mandarin] and [Vietnamese] as well.
Naveej is from a tribe that speaks some weird 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.Read problems statements [Hindi] ,[Bengali] , [Mandarin chinese] , [Russian] and [Vietnamese] as well.
In the magical land of Bytelan... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Akash got his money from CodeChef today, so he decided to have dinner outside.
He went to a restaurant having N items on the menu. T... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Read problems statements in Mandarin chinese, Russian and Vietnamese as well.
When the final results for the employement competition... |
user: Generate an executable Python 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 travelling in Italy. They are travelling by car and unfortunately they took a wrong turn. Now they are stuck in the ... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.You are attempting to climb up the roof to fix some leaks, and have to go buy a ladder. The ladder needs to reach to the top of the 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.Two players (numbered $\mbox{1}$ and $2$) are playing a game of Tower Breakers! The rules of the game are as follows:
Player $\mbox{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.Chef is given a binary string S of length N.
In one operation, Chef has to choose exactly K indices and flip their values.
Chef can ... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.As you might have heard, Gunnar is an old and forgetful researcher. Most of his research is in security and he cares a bit too much ab... |
user: Generate an executable Python 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.
For a given $N$, find the number of 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.Geek played three matches and he wants to represent his scores as an array and in the Concatenated string form.
Example 1:
Input:
2 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.Young Marin, now already a respectable star of Croatian cinematography, spends his free time looking out the window. Unfortunately for... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.The impossible has happened. Bear G. has fallen into his own trap. Lured by a delicious box of Domaćica, without even thinking, he rus... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Sorting arrays is traditionally associated with high-level languages. How hard can it be in Befunge? Sort the given array in non-desce... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Kiana thinks two integers are friends if and only if one of them divides the other one. For example, 12 and 4 are friends, also 6 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.Read problems statements in [Russian] and [Bengali].
There's a zebra crossing appearing in the middle of nowhere with N blocks in it.... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Given a Binary Search Tree (with all values unique) and two node values. Find the Lowest Common Ancestors of the two nodes in the BST.
Example 1:
Input:
5
... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.While Alice was drinking sugarcane juice, she started wondering about the following facts:
The juicer sells each glass of sugarcane ju... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Frodo was caught by Saruman. He tore a pouch from Frodo's neck, shook out its contents —there was a pile of different rings: gold 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.any()
This expression returns True if any element of the iterable is true.
If the iterable is empty, it will return False.
Code
... |
user: Generate an executable Python 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 research, it is tough to determine how good of a researcher you are. One way that people determine how good you are is by looking 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.Mirko buys a lot of candy in the candy shop. He cannot always pay the exact amount so the shopkeeper and he have an agreement. He tell... |
user: Generate an executable Python 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 integers written in base radix. Calculate their sum and output it written in the same base.
Input
The firs... |
user: Generate an executable Python 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 circular array of length N is defined as follows: N integers A_{1},A_{2},…,A_{N} are placed in a circle in such a way 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.Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Chef decided to write an infi... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Anyone knows that the best place to learn the art of espionage is at the Manhattan Academy of Private Spies (MAPS). Scattered across 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.Read problems statements in mandarin chinese, russian and vietnamese as well.
Ada has an array of N crayons, some crayons are point... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.A binary heap is a Binary Tree with the following properties:
1) Its a complete tree (All levels are completely filled except possibly the last level and the last level has 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.See Russian Translation
I often buy Coca-Cola from the vending machine at work. Usually, I buy several cokes at once, since my workin... |
user: Generate an executable Python 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 group of $n$ friends living in an $m$-dimensional hyperspace want to meet up at some central location. The hyperspace is in the form... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Meereen is famous for its fighting pits where fighters fight each other to the death.
Initially, there are $n$ fighters and each figh... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.You are given two arrays $a$ and $b$ of length $n$. Array $a$ contains each odd integer from $1$ to $2n$ in an arbitrary order, and ar... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Everyone’s favorite character and puppet-maker Geppetto has opened a new pizza place, the best in town. Geppetto is trying to make 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 string s consisting only lower case alphabets, find the minimum number of changes required to it so that all substrings 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.A permutation of length N is an array of N integers A = [A_{1}, A_{2}, \dots, A_{N}] such that every integer from 1 to N appears in 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.Alice, Bob, and Charlie have X, Y, and Z chocolates respectively.
Find whether you can redistribute the chocolates such that:
Each 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.Welcome to the exciting class of Professor Manasa. In each lecture she used to play some game while teaching a new concept. Today's to... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Given an array of bird sightings where every element represents a bird type id, determine the id of the most frequently sighted type. ... |
user: Generate an executable Python 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[0 \ldots n - 1] = [a_0, a_1, \ldots, a_{n - 1}]$ of zeroes and ones only. Note that in this problem, unlike ... |
user: Generate an executable Python 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 time for the annual 3-SAT competition, where the contestants compete to answer as many instances of 3-SAT as possible within 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.Recently Tanya had breakup with his boyfriend and now she is looking for someone who can understand her and take care of her.
So Tanya... |
user: Generate an executable Python 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 finally got the chance of his lifetime to drive in the F1 tournament. But, there is one problem. Chef did not know about 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.The Playfair cipher is a manual symmetric encryption technique and was the first digraph substitution cipher. The scheme was invented ... |
user: Generate an executable Python 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 that Balázs has the fanciest fence in the whole town. It's built up from N fancy sections. The sections are rectangles... |
user: Generate an executable Python 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 huge blanket on your bed but unfortunately it has N stains. You cover them using
a single, rectangular silk cloth. The sil... |
user: Generate an executable Python 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 scientist, E. Collie, is going to do some experiments with bacteria. Right now, she has one bacterium. She already knows that this 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.Given a single integer N, your task is to find the sum of the square of the first N even natural Numbers.
Example 1:
Input: 2
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.Given an array A consisting of N non-negative integers.
You need to perform the following operation (N - 1) times:
Sort the array A ... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.You are given two integers a and b (a ≤ b). How many prime numbers are there on the interval from a to b, inclusive?
Input
The 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.A chain letter is a kind of a message which urges the recipient to forward it to as many contacts as possible, usually with some kind ... |
user: Generate an executable Python 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's dog Snuffles has so many things to play with! 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.Recently Chef joined a new company. In this company, the employees have to work for X hours each day from Monday to Thursday. Also, 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.Chef has two ranges [A, B] and [C, D]. Chef needs to find the number of integers that belong to at least one of the ranges.
Note: A r... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Chef has started working at the candy store. The store has 100 chocolates in total.
Chef’s daily goal is to sell X chocolates. For ea... |
user: Generate an executable Python 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 entire world faces the greatest danger as Batman and Superman confront each other. Lex Luthor , inclined to destroy Superman allie... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Given a square grid of characters in the range ascii[a-z], rearrange elements of each row alphabetically, ascending. Determine 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.After the phenomenal success of the 36th Chamber of Shaolin, San Te has decided to start 37th Chamber of Shaolin. The aim this time 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.Given two long integers, $\text{min}$ and $\textit{max}$, find and print a common fraction, $\frac{n}{d}$, such that $min\leq d\leq ma... |
user: Generate an executable Python 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 been a hard time for Baahubali in mathematics. Yet another challenge from Kattappa.
Baahubali is given 5 integers in the range 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.Young Mirko is a smart, but mischievous boy who often wanders around parks looking for new ideas. This time he’s come across pensioner... |
user: Generate an executable Python 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 is a tree with N weighted vertices and N-1 weighted edges. The i-th vertex has a weight of A_{i}. The i-th edge has a weight of ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.