formatted_conversations
stringlengths
1.13k
138k
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Given a English alphabet c, Write a program to check whether a character is a vowel or not. Example 1: Input: c = 'a' Output: YES Ex...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Chef is playing an easier variation of the board game ‘Risk’ with his friend Mike. There is an $N * M$ grid, depicting the world map. ...
user: Generate an executable Python 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 palindromic string $s$ of length $n$. You have to count the number of indices $i$ $(1 \le i \le n)$ such that the str...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.View Russian Translation The great Amu is the the special agent chosen directly from by the king. There are n cities in his country...
user: Generate an executable Python 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. The task is to complete the function convertFive() which replaces all zeros in the number with 5 and returns the 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.Alex, Bob, and, Chef are standing on the coordinate plane. Chef is standing at the origin (coordinates (0, 0)) while the location 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.You are given an array [A_{1}, \ldots, A_{N}]. You want to split it into several (≥ 2) [subarrays] so that the following condition hol...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.In this challenge, the task is to debug the existing code to successfully execute all provided test files. Given two strings consisti...
user: Generate an executable Python 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 linked lists consisting of N and M nodes respectively. The task is to merge both of the list (in-place) and return he...
user: Generate an executable Python 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. There are n villages in a line in an area. There are t...
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 and a number k, find the largest sum of the subarray containing at least k numbers. It may be assumed that the size of array is at-least k. Example 1: Input :...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Given a linked list and positions m and n. Reverse the linked list from position m to n. Example 1: Input : N = 10 Linked List = 1->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.A tournament is going on in the Society Park. One of the game people are playing is Rock Paper Scissors. We all know Rock Paper Scisso...
user: Generate an executable Python 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, both having length N. He can perform the following operation on A any number of times (possibly z...
user: Generate an executable Python 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 strings A and B consisting of lowercase alphabets, each of length N. Help Chef in finding the number of indices i (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.Given two integers, $m$ and ${k}}$, Alice loves to calculate their power sum using the following formula: $\textit{PowerSum}(m,k)\equi...
user: Generate an executable Python 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 that a mango weighs X kilograms and a truck weighs Y kilograms. You want to cross a bridge that can withstand a weight 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.Chef is planning to buy a new car for his birthday. After a long search, he is left with 2 choices: Car 1: Runs on diesel with a fuel...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Limak is a little bear who loves school. Today was his first lesson in cryptography, and the teacher assigned some difficult homework—...
user: Generate an executable Python 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 $p=[p_1,p_2,\dots, p_n]$ which contains every integer from $1$ to $n$ (inclusive) exactly 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.There is a horizontal row of $n$ cubes. The length of each cube is given. You need to create a new vertical pile of cubes. The new pil...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Fiona is an expert climber. She often brings some pegs with her, which she nails in some strategic places in the rock wall, so that 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.Luis has a sequence of $n+1$ integers $a_1, a_2, \ldots, a_{n+1}$. For each $i = 1, 2, \ldots, n+1$ it is guaranteed that $0\leq a_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.Little Matej is solving an OOP (Object-oriented programming) laboratory exercise and he’s having trouble with solving one subtask. He...
user: Generate an executable Python 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 semester, Chef took X courses. Each course has Y units and each unit has Z chapters in it. Find the total number of chapters Che...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.A number k is called a square number if for some value of d > 1, k % (d*d) = 0. Given a number N, find the total number of positive 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 size N. The array consists of a permutation of the set {1, 2, 3, … , N} for some positive integer N. Y...
user: Generate an executable Python 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 lowercase alphabets and an integer K. Find the count of all substrings of length K which have exactly...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition."Promises are meant to be broken." Chotu being desperately in love with her crush made N promises to her on Promise Day. Each promise ...
user: Generate an executable Python 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 series of numbers 3,10,21,36 …., and series starting from N = 1, find the pattern and output the N'th value of the above seri...
user: Generate an executable Python 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 hopper is a virtual creature that visits Java programs and explores their arrays. Scientists observed a hopper and came to the follo...
user: Generate an executable Python 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 binary string S of length N. You can perform the following operation on S: Select an index i \ (1 ≤ i < |S|) such 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.There are $n$ cities in Berland. The city numbered $1$ is the capital. Some pairs of cities are connected by a one-way road of length ...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Mr. Turtle loves drawing on his whiteboard at home. One day when he was drawing, his marker dried out! Mr. Turtle then noticed that 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.Sam lives in Awesomeburg, its downtown has a triangular shape. Also, the following is true about the triangle: its vertices have inte...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Like people, numbers are also friends with each other. Friendliness between any two numbers a and b is defined as the absolute differe...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Mr. Road Runner bought a piece of land in the middle of a desert for a nominal amount. It turns out that the piece of land is now wort...
user: Generate an executable Python 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 coordinate points A, B and C, find the missing point D such that ABCD can be a parallelogram. If there are multiple such 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.Chef has recently started playing chess, and wants to play as many games as possible. He calculated that playing one game of chess 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 problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well. You are given a tree with $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.An eccentric coach asks players on the team to line up alphabetically at the start of practice. The coach does not tell the players wh...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.CodeMart is a shopping platform and it is distributing gift vouchers to its esteemed users. The voucher can be redeemed by providing 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 problems statements in Mandarin Chinese and Russian as well. As every other little boy, Mike has a favorite toy to play with. 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.Mira is very fond of gifts, so this valentine-season, Krish is going to gift her a game Nice Quadrilaterals (Yeah! Krish is such a gee...
user: Generate an executable Python 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 just completed a brave journey to see The Wizard of Odds, who agrees to grant you any wish, so long as you can complete the f...
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 s. You need to reverse the string. Example 1: Input: s = Geeks Output: skeeG Example 2: Input: s = for Output: rof Your Task: You only need to complete ...
user: Generate an executable Python 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. You are given an array A of integers of size N. You will be given Q queri...
user: Generate an executable Python 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 participating in Yet Another Tournament. There are $n + 1$ participants: you and $n$ other opponents, numbered from $1$ to $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.------Read problems statements in Hindi, Mandarin chinese , Russian and Vietnamese as well. ------ Chef wants to set problems for 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.When Per was living in New York, he couldn’t use his debit card as often as in Sweden. He had to carry cash all the time and his walle...
user: Generate an executable Python 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], [Russian], and [Vietnamese] as well. Chef is busy preparing for the next lunchtime, so he has ...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.A couple of computer science students have decided to start a book circle, in which they will be able to share the passion of their li...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well. Alice just invited Bob to com...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Check Tutorial tab to know how to to solve. You are given a string $\mbox{S}$ and width $\boldsymbol{w}$. Your task is to wrap 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.The enemy and their massive army is approaching your fortress, and all you have to defend it is a legion of guardian gnomes. There 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.A (1-indexed) binary string S of length N is called a *xor palindrome* if the value of S_{i} \oplus S_{(N + 1 - i)} is the same for 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.A Fenwick Tree (also known as a Binary Indexed Tree) is a data structure on an array which enables fast ($O(\log n)$) updates and pref...
user: Generate an executable Python 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 playing hopscotch! You start at the origin and your goal is to hop to the lattice point $(N, N)$. A hop consists of going from ...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Mehta woke up after a long sleep, and decided to attend college class which is infact pretty much unusual. But, to somehow survive 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.Let's denote the $f(x)$ function for a string $x$ as the number of distinct characters that the string contains. For example $f({abc})...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.$m$ chairs are arranged in a circle sequentially. The chairs are numbered from $0$ to $m-1$. $n$ people want to sit in these chairs. 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.Yancy is designing a new board game called Colorland. The rules of Colorland are as follows: - Colorland’s board is a linear sequence...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Baxter Scott owns The Enlightened Dairy Co., a dairy company with magical cows. Early each morning, he brushes his teeth, strolls outs...
user: Generate an executable Python 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 positive integers with length $n$, determine if there exist three distinct indices $i$, $j$, $k$ such that $a_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.Tatyana is a big sports fan and she likes volleyball a lot! She writes down the final scores of the game after it has ended in her not...
user: Generate an executable Python 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. Your task is to identify the pattern from the Examples and print the pattern. Example 1: Input: N = 4 Output: 4...
user: Generate an executable Python 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 rope of length N meters, cut the rope into several ropes of varying lengths in a way that maximizes product of lengths of all ...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.HackerRank is starting a bus service in MountainView, California. The bus starts at time T = 0 at $station_{1}$and goes through $stati...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Kyle and Mike are bored on a rainy day and decide to pass the time by creating a new game having the following rules: The game starts...
user: Generate an executable Python 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 world is made up of $10$ kinds of people, those who understand binary and those who do not. These different kinds of people do not...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Areesha likes to play interesting games with her friend Adam. The game they played last evening is about building a number with n digi...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Given a square matrix of size N*N, print the sum of upper and lower triangular elements. Upper Triangle consists of elements on the di...
user: Generate an executable Python 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 wants to inspect the quality of vegetables at each shop in the vegetable market. There are N different vegetable sellers in a lin...
user: Generate an executable Python 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 of numbers. You can change any number from the sequence to any other number of your choice. Your task is to 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.Given Pointer/Reference to the head of the linked list, the task is to Sort the given linked list using Merge Sort. Note: If the lengt...
user: Generate an executable Python 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 tree is an undirected connected graph in which there are no cycles. This problem is about non-rooted trees. A leaf of a tree is a ve...
user: Generate an executable Python 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 provided code stub will read in a dictionary containing key/value pairs of name:[marks] for a list of students. Print the average...
user: Generate an executable Python 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 problem is to find the shortest distances between every pair of vertices in a given edge-weighted directed graph. The graph is rep...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Amanda has a string of lowercase letters that she wants to copy to a new string. She can perform the following operations with the gi...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Even before they leave the apartment, Joey drives Chandler crazy by forgetting everything useful, even his passport, but crying every ...
user: Generate an executable Python 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 Chef has reached the finals of the Annual Inter-school Declamation contest. For the finals, students were asked to prepare 10 top...
user: Generate an executable Python 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 101 citizens in Chefland. It is election time in Chefland and 3 parties, A, B, and C are contesting the elections. Party 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.You administer a large cluster of computers with hard drives that use various file system types to store data. You recently decided 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.The only difference between the easy and hard versions are the locations you can teleport to. Consider the points $0, 1, \dots, n$ 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.Read problems statements [Bengali] , [Mandarin chinese] , [Russian] and [Vietnamese] as well. ShareChat is a country where Chef lives...
user: Generate an executable Python 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 arrays X[] and Y[] of points where (X_{i}, Y_{i}) represents a point on the X-Y plane. Your task is to complete the function...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Jenna is playing a computer game involving a large map with $n$ cities numbered sequentially from $1$ to $n$ that are connected by $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.In the current semester, you have taken X RTP courses, Y Audit courses and Z Non-RTP courses. The credit distribution for the course...
user: Generate an executable Python 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 size N consisting of only 0's and 1's. The array is sorted in such a manner that all the 1's are placed first and th...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.You are given an integer N. Find the number of distinct XORs it is possible to make using two positive integers no larger than N. 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.Most people have heard of Julius Caesar, a Roman dictator who lived in the first century BC and who was famous, amongst other things, ...
user: Generate an executable Python 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 just graduated from programming school and nailed a Python programming job. The first day at work you realize that you have inheri...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Lauren has a chart of distinct projected prices for a house over the next several years. She must buy the house in one year and sell ...
user: Generate an executable Python 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. The Euler totient function $\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.You are programming an autonomous rocket powered hovercraft. The vehicle can travel very, very fast, but turning is difficult. Since 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 an array of integers a of length n and a value k. You have to find out the maximum possible numbers within 10^{9}whose sum does ...
user: Generate an executable Python 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 collection of rocks where each rock has various minerals embeded in it. Each type of mineral is designated by a lowercase ...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Along with some friends you formed the Band of Atonal Percussionists and Cellists. You have been playing for some years together, but ...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Rahul and his friends decided to play a game in a New Year Party and the winner will be given some cash prize as decided among them.Th...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Mr. Geek is a greedy seller. He has a stock of N laptops which comprises of both useful and useless laptops. Now, he wants to organize a sale to clear his stock of useless lap...