formatted_conversations
stringlengths
1.13k
138k
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.You are given n × m table. Each cell of the table is colored white or black. Find the number of non-empty sets of cells such 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.Two neighboring kingdoms decided to build a wall between them with some gates to enable the citizens to go from one kingdom to another...
user: Generate an executable Python 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 following process. There is a platform with n columns. 1 × 1 squares are appearing one after another in some columns...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Ambar is a gardener and have many water jugs in his garden. The shape of water jug is a cone placed on the top of a cylinder (the ra...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Students of Maharaja Agrasen Institute of Technology, are going for long trip. Along with one teacher who is programmer. In the middle...
user: Generate an executable Python 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 ladder which leads to the door of heaven. Each step of ladder has a card in it. The card is blue if the number printed on i...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.The Monk learned about priority queues recently and asked his teacher for an interesting problem. So his teacher came up with a simple...
user: Generate an executable Python 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 in a class of Computer Networks, little Roy learned to calculate Hamming Distance between two strings of equal length. Durin...
user: Generate an executable Python 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 is assigned a task by his fellow mates.He has to take a string from somewhere and first of all he has to calculate the weight 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.A number can be called v-number if the sum of the lower half of the array is equal to the sum of the upper half of the array. EXAMPLE...
user: Generate an executable Python 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 have N logs of lengths A_1,A_2,\cdots A_N. We can cut these logs at most K times in total. When a log of length L is cut at a poin...
user: Generate an executable Python 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 have N+M balls, each of which has an integer written on it. It is known that: * The numbers written on N of the balls are even. * ...
user: Generate an executable Python 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 knight - the chess piece - at the origin (0, 0) of a two-dimensional grid. When the knight is at the square (i, j), it 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.Kizahashi, who was appointed as the administrator of ABC at National Problem Workshop in the Kingdom of AtCoder, got too excited and 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.We will play a one-player game using a number line and N pieces. First, we place each of these pieces at some integer coordinate. 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.Mr. Infinity has a string S consisting of digits from `1` to `9`. Each time the date changes, this string changes as follows: * 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.Write a program which replace all the lower-case letters of a given text with the corresponding captital letters. Input A text inc...
user: Generate an executable Python 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 n × n grid D where each cell contains either 1 or 0. Your task is to create a program that takes the gird data as input 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.problem You are a traveler traveling on the JOI Highway. The JOI Highway is a road that extends straight from east to west, and there...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Cosmic market, commonly known as Kozumike, is the largest coterie spot sale in the universe. Doujin lovers of all genres gather at Koz...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Problem There are W white square tiles in the horizontal direction and H in the vertical direction, for a total of W x H tiles. On t...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.A positive integer is called a "prime-factor prime" when the number of its prime factors is prime. For example, $12$ is a prime-factor...
user: Generate an executable Python 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 goal of the 8 puzzle problem is to complete pieces on $3 \times 3$ cells where one of the cells is empty space. In this problem, ...
user: Generate an executable Python 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 was chatting with his friend who was a mathematician.Chef said "Hi !". His friend replied that '!' is the symbol of factorial...
user: Generate an executable Python 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 N subordinates. In order to complete a very important order he will choose exactly K of them. He can't choose less than K 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.Background Given a natural number n, find the summation of all its proper divisors. Definition: A proper divisor of a natural number ...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Points:10 The Indian Heights School believes that learning with the aid of technology is the fastest way to do so. It is a pioneer 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.Problem Statement  Given a number , find whether it is a power of 2 or not NOTE There is a limit in Source code. Input The first 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.Consider a set of points A, initially it is empty. There are three types of queries: 1. Insert a point (x_i, y_i) to A. It is guar...
user: Generate an executable Python 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 points on the plane, (x_1,y_1), (x_2,y_2), …, (x_n,y_n). You need to place an isosceles triangle with two sides on the 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.Polycarp took n videos, the duration of the i-th video is a_i seconds. The videos are listed in the chronological order, i.e. the 1-st...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.You are given a tree consisting exactly of n vertices. Tree is a connected undirected graph with n-1 edges. Each vertex v of this tree...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.An array of integers p_1, p_2, ..., p_n is called a permutation if it contains each number from 1 to n exactly once. For example, 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 have a given picture with size w × h. Determine if the given picture has a single "+" shape or not. A "+" shape is described below...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Jack is working on his jumping skills recently. Currently he's located at point zero of the number line. He would like to get to the 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.Let's define a balanced multiset the following way. Write down the sum of all elements of the multiset in its decimal representation. ...
user: Generate an executable Python 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 a rebel leader and you are planning to start a revolution in your country. But the evil Government found out about your plans ...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Petya has come to the math exam and wants to solve as many problems as possible. He prepared and carefully studied the rules by which ...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.You are given an array a[0 … n-1] of length n which consists of non-negative integers. Note that array indices start from zero. An 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.Captain Flint and his crew keep heading to a savage shore of Byteland for several months already, drinking rum and telling stories. 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.You are given a positive integer k and an array a_1, a_2, …, a_n of non-negative distinct integers not smaller than k and not greater ...
user: Generate an executable Python 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 Berland University is preparing to celebrate the 256-th anniversary of its founding! A specially appointed Vice Rector for the cel...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.It is known that there are k fish species in the polar ocean, numbered from 1 to k. They are sorted by non-decreasing order of their w...
user: Generate an executable Python 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 new TV game on BerTV. In this game two players get a number A consisting of 2n digits. Before each turn players determine w...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Sereja has an array a, consisting of n integers a1, a2, ..., an. The boy cannot sit and do nothing, he decided to study an array. Sere...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Inna loves sweets very much. She has n closed present boxes lines up in a row in front of her. Each of these boxes contains either a c...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.The R1 company wants to hold a web search championship. There were n computers given for the competition, each of them is connected 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.Devu and his brother love each other a lot. As they are super geeks, they only like to play with arrays. They are given two arrays a 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.Appleman and Toastman play a game. Initially Appleman gives one group of n numbers to the Toastman, then they start to complete the fo...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Bizon the Champion has recently finished painting his wood fence. The fence consists of a sequence of n panels of 1 meter width and 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.Amr lives in Lala Land. Lala Land is a very beautiful country that is located on a coordinate line. Lala Land is famous with its apple...
user: Generate an executable Python 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 walking down the street Vanya saw a label "Hide&Seek". Because he is a programmer, he used & as a bitwise AND for these two word...
user: Generate an executable Python 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 like games. And now they are ready to start a new game. They have placed n chocolate bars in a line. Alice starts to eat...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Mahmoud and Ehab live in a country with n cities numbered from 1 to n and connected by n - 1 undirected roads. It's guaranteed that yo...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.At regular competition Vladik and Valera won a and b candies respectively. Vladik offered 1 his candy to Valera. After that Valera gav...
user: Generate an executable Python 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 very important person has a piece of paper in the form of a rectangle a × b. Also, he has n seals. Each seal leaves an impression...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Polycarpus takes part in the "Field of Wonders" TV show. The participants of the show have to guess a hidden word as fast as possible....
user: Generate an executable Python 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 flower shop has got n bouquets, and the i-th bouquet consists of ai flowers. Vasya, the manager of the shop, decided to make large 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.Scooby is stuck in a cave in barren islands. Shaggy decided to play a prank on scooby. in his ghostly voice shaggy asks a question 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.Aarav has just graduated from the university. Now he is going to travel along his country. More precisely: there are N cities with int...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.There are many ways to order a list of integers from 1 to n. For example, if n = 3, the list could be : [3\; 1\; 2]. But there is 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.CodeswarBala found various ornaments in Btyeland. Each ornament is made up of various items, and each item is represented by a letter...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Rani works at sweet shop and is currently arranging sweets i.e. putting sweets in boxes. There are some boxes which contains sweets 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.Our smart travel agent, Mr. X's current assignment is to show a group of tourists a distant city. As in all countries, certain pairs 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.There was a power value associated with each soldier of Ram’s troop. It was a known belief that if two soldiers could be paired such 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 are N points on the 2D plane, i-th of which is located on (x_i, y_i). There can be multiple points that share the same coordinat...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.AtCoder Inc. holds a contest every Saturday. There are two types of contests called ABC and ARC, and just one of them is held at a ti...
user: Generate an executable Python 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 are two sequences a=\\{a_0,\ldots,a_{N-1}\\} and b=\\{b_0,\ldots,b_{N-1}\\} of N non-negative integers each. Snuke will choose ...
user: Generate an executable Python 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 an integer N. Find the number of positive integers less than or equal to N that have an odd number of digits (in base ten wit...
user: Generate an executable Python 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 have a long seat of width X centimeters. There are many people who wants to sit here. A person sitting on the seat will always occu...
user: Generate an executable Python 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 frequency operation in the conversion operation of a finite number sequence. The conversion result of the sequence $ 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.Mobile phones are equipped with a function that displays input candidates in order to efficiently input texts such as emails. This rec...
user: Generate an executable Python 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, A and B, play the game using cards with numbers from 0 to 9. First, the two arrange the given n cards face down in a hori...
user: Generate an executable Python 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 were the master craftsman in the stone age, and you devoted your life to carving many varieties of tools out of natural stones. Yo...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Kita_masa is planning a trip around the world. This world has N countries and the country i has M_i cities. Kita_masa wants to visit e...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Mysterious button You decide to earn coins in a dungeon on the outskirts of town. There are N rooms in this dungeon, numbered from 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.The range search problem consists of a set of attributed records S to determine which records from S intersect with a given range. Fo...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Nitesh recently discovered a new game CODATHON with the help of a very intelligent alien friend Jupiter. In this game a student had va...
user: Generate an executable Python 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 daily train consists of N cars. Let's consider one particular car. It has 54 places numbered consecutively from 1 to 54, some of whi...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Valentine's Day is coming and our friend Mr.IDC has fallen in love with a girl. He just could not control his feelings and went to pro...
user: Generate an executable Python 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 Ceil has some matchsticks in his kitchen. Detail of matchsticks: There are N matchsticks in total. They are numbered from to 0 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."I heard that you're settled down That you found a girl and you're married now. I heard that your dreams came true. Guess...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Vasya has got a magic matrix a of size n × m. The rows of the matrix are numbered from 1 to n from top to bottom, the columns are 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're given an array a. You should repeat the following operation k times: find the minimum non-zero element in the array, print 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.Today at the lesson of mathematics, Petya learns about the digital root. The digital root of a non-negative integer is the single dig...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Finished her homework, Nastya decided to play computer games. Passing levels one by one, Nastya eventually faced a problem. Her missio...
user: Generate an executable Python 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 shovels in the nearby shop. The i-th shovel costs a_i bourles. Misha has to buy exactly k shovels. Each shovel can be bou...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Finally, a basketball court has been opened in SIS, so Demid has decided to hold a basketball exercise session. 2 ⋅ n students have 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.Let's define p_i(n) as the following permutation: [i, 1, 2, ..., i - 1, i + 1, ..., n]. This means that the i-th permutation is almost...
user: Generate an executable Python 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 square of size 10^6 × 10^6 on the coordinate plane with four points (0, 0), (0, 10^6), (10^6, 0), and (10^6, 10^6) as its 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.This winter is so cold in Nvodsk! A group of n friends decided to buy k bottles of a soft drink called "Take-It-Light" to warm up a bi...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.There are three cells on an infinite 2-dimensional grid, labeled A, B, and F. Find the length of the shortest path from A to B if: ...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Petya and Vasya are tossing a coin. Their friend Valera is appointed as a judge. The game is very simple. First Vasya tosses a coin x ...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Special Agent Smart Beaver works in a secret research department of ABBYY. He's been working there for a long time and is satisfied wi...
user: Generate an executable Python 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 table G of size n × m such that G(i, j) = GCD(i, j) for all 1 ≤ i ≤ n, 1 ≤ j ≤ m. GCD(a, b) is the greatest common divisor ...
user: Generate an executable Python 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 string s = s1s2...s|s|, where |s| is the length of string s, and si its i-th character. Let's introduce several definitio...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.New Year is coming in Line World! In this world, there are n cells numbered by integers from 1 to n, as a 1 × n board. People live 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.Today, Wet Shark is given n bishops on a 1000 by 1000 grid. Both rows and columns of the grid are numbered from 1 to 1000. Rows are nu...
user: Generate an executable Python 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 Vasya's uncle is a postman. The post offices are located on one circular road. Besides, each post office has its own gas statio...
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.ZS the Coder loves to read the dictionary. He thinks that a word is nice if there exists a substring (contiguous segment of letters) o...