question
large_stringlengths
265
13.2k
Solve the programming task below in a Python markdown code block. Cheesy Cheeseman just got a new monitor! He is happy with it, but he just discovered that his old desktop wallpaper no longer fits. He wants to find a new wallpaper, but does not know which size wallpaper he should be looking for, and alas, he just thre...
Solve the programming task below in a Python markdown code block. Given is an integer x that is greater than or equal to 0, and less than or equal to 1. Output 1 if x is equal to 0, or 0 if x is equal to 1. -----Constraints----- - 0 \leq x \leq 1 - x is an integer -----Input----- Input is given from Standard Input...
Solve the programming task below in a Python markdown code block. Consider the number `1176` and its square (`1176 * 1176) = 1382976`. Notice that: * the first two digits of `1176` form a prime. * the first two digits of the square `1382976` also form a prime. * the last two digits of `1176` and `1382976` are the sam...
Solve the programming task below in a Python markdown code block. Phoenix has $n$ coins with weights $2^1, 2^2, \dots, 2^n$. He knows that $n$ is even. He wants to split the coins into two piles such that each pile has exactly $\frac{n}{2}$ coins and the difference of weights between the two piles is minimized. Forma...
Solve the programming task below in a Python markdown code block. # 'Magic' recursion call depth number This Kata was designed as a Fork to the one from donaldsebleung Roboscript series with a reference to: https://www.codewars.com/collections/roboscript It is not more than an extension of Roboscript infinite "sing...
Solve the programming task below in a Python markdown code block. Given is a string S. Replace every character in S with x and print the result. -----Constraints----- - S is a string consisting of lowercase English letters. - The length of S is between 1 and 100 (inclusive). -----Input----- Input is given from Sta...
Solve the programming task below in a Python markdown code block. You are given an integer N. Find the number of the positive divisors of N!, modulo 10^9+7. -----Constraints----- - 1≤N≤10^3 -----Input----- The input is given from Standard Input in the following format: N -----Output----- Print the number of the po...
Solve the programming task below in a Python markdown code block. You are given two positive integers $x$ and $y$. You can perform the following operation with $x$: write it in its binary form without leading zeros, add $0$ or $1$ to the right of it, reverse the binary form and turn it into a decimal number which is a...
Solve the programming task below in a Python markdown code block. Snuke is buying a bicycle. The bicycle of his choice does not come with a bell, so he has to buy one separately. He has very high awareness of safety, and decides to buy two bells, one for each hand. The store sells three kinds of bells for the price of...
Solve the programming task below in a Python markdown code block. Square Route Square root English text is not available in this practice contest. Millionaire Shinada, who has decided to build a new mansion, is wondering in which city to build the new mansion. To tell the truth, Mr. Shinada is a strange person who ...
Solve the programming task below in a Python markdown code block. A `bouncy number` is a positive integer whose digits neither increase nor decrease. For example, 1235 is an increasing number, 5321 is a decreasing number, and 2351 is a bouncy number. By definition, all numbers under 100 are non-bouncy, and 101 is the ...
Solve the programming task below in a Python markdown code block. Read problems statements in Mandarin Chinese . Given an array of n non-negative integers: A_{1}, A_{2}, …, A_{N}. Your mission is finding a pair of integers A_{u}, A_{v} (1 ≤ u < v ≤ N) such that (A_{u} and A_{v}) is as large as possible. And is a bi...
Solve the programming task below in a Python markdown code block. For a given sequence of distinct non-negative integers $(b_1, b_2, \dots, b_k)$ we determine if it is good in the following way: Consider a graph on $k$ nodes, with numbers from $b_1$ to $b_k$ written on them. For every $i$ from $1$ to $k$: find such ...
Solve the programming task below in a Python markdown code block. Bomboslav likes to look out of the window in his room and watch lads outside playing famous shell game. The game is played by two persons: operator and player. Operator takes three similar opaque shells and places a ball beneath one of them. Then he shu...
Solve the programming task below in a Python markdown code block. You have an array of integers (initially empty). You have to perform $q$ queries. Each query is of one of two types: "$1$ $x$" — add the element $x$ to the end of the array; "$2$ $x$ $y$" — replace all occurrences of $x$ in the array with $y$. Find ...
Solve the programming task below in a Python markdown code block. > I would, if I could, > If I couldn't how could I? > I couldn't, without I could, could I? > Could you, without you could, could ye? > Could ye? could ye? > Could you, without you could, could ye? It is true, as this old rhyme says, that we can o...
Solve the programming task below in a Python markdown code block. In this kata, you will write a function that returns the positions and the values of the "peaks" (or local maxima) of a numeric array. For example, the array `arr = [0, 1, 2, 5, 1, 0]` has a peak at position `3` with a value of `5` (since `arr[3]` equa...
Solve the programming task below in a Python markdown code block. In an attempt to escape the Mischievous Mess Makers' antics, Farmer John has abandoned his farm and is traveling to the other side of Bovinia. During the journey, he and his k cows have decided to stay at the luxurious Grand Moo-dapest Hotel. The hotel ...
Solve the programming task below in a Python markdown code block. E869120 is initially standing at the origin (0, 0) in a two-dimensional plane. He has N engines, which can be used as follows: - When E869120 uses the i-th engine, his X- and Y-coordinate change by x_i and y_i, respectively. In other words, if E869120 ...
Solve the programming task below in a Python markdown code block. At Aizu Riverside Hospital, inpatients walk twice a day for rehabilitation and health promotion. As the number of people trying to recover their physical strength by walking is increasing day by day in order to leave the hospital energetically, the dire...
Solve the programming task below in a Python markdown code block. Expression Mining Consider an arithmetic expression built by combining single-digit positive integers with addition symbols `+`, multiplication symbols `*`, and parentheses `(` `)`, defined by the following grammar rules with the start symbol `E`. E ...
Solve the programming task below in a Python markdown code block. There are n shovels in Polycarp's shop. The i-th shovel costs i burles, that is, the first shovel costs 1 burle, the second shovel costs 2 burles, the third shovel costs 3 burles, and so on. Polycarps wants to sell shovels in pairs. Visitors are more l...
Solve the programming task below in a Python markdown code block. As you may know, MemSQL has American offices in both San Francisco and Seattle. Being a manager in the company, you travel a lot between the two cities, always by plane. You prefer flying from Seattle to San Francisco than in the other direction, becau...
Solve the programming task below in a Python markdown code block. N contestants participated in a competition. The total of N-1 matches were played in a knockout tournament. For some reasons, the tournament may not be "fair" for all the contestants. That is, the number of the matches that must be played in order to wi...
Solve the programming task below in a Python markdown code block. Eugene likes working with arrays. And today he needs your help in solving one challenging task. An array $c$ is a subarray of an array $b$ if $c$ can be obtained from $b$ by deletion of several (possibly, zero or all) elements from the beginning and se...
Solve the programming task below in a Python markdown code block. We have a rectangular parallelepiped of size A×B×C, built with blocks of size 1×1×1. Snuke will paint each of the A×B×C blocks either red or blue, so that: * There is at least one red block and at least one blue block. * The union of all red blocks for...
Solve the programming task below in a Python markdown code block. Greg has an array a = a1, a2, ..., an and m operations. Each operation looks as: li, ri, di, (1 ≤ li ≤ ri ≤ n). To apply operation i to the array means to increase all array elements with numbers li, li + 1, ..., ri by value di. Greg wrote down k queri...
Solve the programming task below in a Python markdown code block. Simon has an array a_1, a_2, ..., a_{n}, consisting of n positive integers. Today Simon asked you to find a pair of integers l, r (1 ≤ l ≤ r ≤ n), such that the following conditions hold: there is integer j (l ≤ j ≤ r), such that all integers a_{l}, a_...
Solve the programming task below in a Python markdown code block. In number theory, an **[abundant](https://en.wikipedia.org/wiki/Abundant_number)** number or an **[excessive](https://en.wikipedia.org/wiki/Abundant_number)** number is one for which the sum of it's **[proper divisors](http://mathworld.wolfram.com/Prop...
Solve the programming task below in a Python markdown code block. Problem Statement Let's consider operations on monochrome images that consist of hexagonal pixels, each of which is colored in either black or white. Because of the shape of pixels, each of them has exactly six neighbors (e.g. pixels that share an edge...
Solve the programming task below in a Python markdown code block. F: Multiplication is fun --Multiplication Is Interesting - story Namba, a high school boy, is thinking of giving her a few lines on her birthday. She is a girl who loves multiplication, so Namba wants to give her a sequence that will allow her to enjo...
Solve the programming task below in a Python markdown code block. This kata generalizes [Twice Linear](https://www.codewars.com/kata/5672682212c8ecf83e000050). You may want to attempt that kata first. ## Sequence Consider an integer sequence `U(m)` defined as: 1. `m` is a given non-empty set of positive integers. 2...
Solve the programming task below in a Python markdown code block. You are given an array $a$ consisting of $n$ integer numbers. Let instability of the array be the following value: $\max\limits_{i = 1}^{n} a_i - \min\limits_{i = 1}^{n} a_i$. You have to remove exactly one element from this array to minimize instabil...
Solve the programming task below in a Python markdown code block. ## Overview Resistors are electrical components marked with colorful stripes/bands to indicate both their resistance value in ohms and how tight a tolerance that value has. If you did my Resistor Color Codes kata, you wrote a function which took a strin...
Solve the programming task below in a Python markdown code block. There are a total of n x n squares, n rows vertically and n columns horizontally. Some squares are marked. Create a program that reads the marked state of each square and displays the length of the side of the largest square consisting of only the unmar...
Solve the programming task below in a Python markdown code block. A bus moves along the coordinate line Ox from the point x = 0 to the point x = a. After starting from the point x = 0, it reaches the point x = a, immediately turns back and then moves to the point x = 0. After returning to the point x = 0 it immediatel...
Solve the programming task below in a Python markdown code block. # Task Given two integers `a` and `b`, return the sum of the numerator and the denominator of the reduced fraction `a/b`. # Example For `a = 2, b = 4`, the result should be `3` Since `2/4 = 1/2 => 1 + 2 = 3`. For `a = 10, b = 100`, the result should...
Solve the programming task below in a Python markdown code block. Dr. Evil is interested in math and functions, so he gave Mahmoud and Ehab array a of length n and array b of length m. He introduced a function f(j) which is defined for integers j, which satisfy 0 ≤ j ≤ m - n. Suppose, c_{i} = a_{i} - b_{i} + j. Then f...
Solve the programming task below in a Python markdown code block. Print all combinations which can be made by $k$ different elements from $0, 1, ..., n-1$. Note that we represent $0, 1, ... n-1$ as 00...0001, 00...0010, 00...0100, ..., 10...0000 in binary respectively and the integer representation of a combination is...
Solve the programming task below in a Python markdown code block. Basic regex tasks. Write a function that takes in a numeric code of any length. The function should check if the code begins with 1, 2, or 3 and return `true` if so. Return `false` otherwise. You can assume the input will always be a number. Write yo...
Solve the programming task below in a Python markdown code block. Wilson primes satisfy the following condition. Let ```P``` represent a prime number. Then ```((P-1)! + 1) / (P * P)``` should give a whole number. Your task is to create a function that returns ```true``` if the given number is a Wilson prime. Write...
Solve the programming task below in a Python markdown code block. There is a function f(x), which is initially a constant function f(x) = 0. We will ask you to process Q queries in order. There are two kinds of queries, update queries and evaluation queries, as follows: - An update query 1 a b: Given two integers a a...
Solve the programming task below in a Python markdown code block. Our old friend Alexey has finally entered the University of City N — the Berland capital. Alexey expected his father to get him a place to live in but his father said it was high time for Alexey to practice some financial independence. So, Alexey is liv...
Solve the programming task below in a Python markdown code block. Given are a sequence of N positive integers A_1, A_2, \ldots, A_N and another positive integer S. For a non-empty subset T of the set \{1, 2, \ldots , N \}, let us define f(T) as follows: - f(T) is the number of different non-empty subsets \{x_1, x_2...
Solve the programming task below in a Python markdown code block. A [sequence or a series](http://world.mathigon.org/Sequences), in mathematics, is a string of objects, like numbers, that follow a particular pattern. The individual elements in a sequence are called terms. A simple example is `3, 6, 9, 12, 15, 18, 21, ...
Solve the programming task below in a Python markdown code block. N cells are arranged in a row. Some of them may contain tokens. You are given a string s that consists of `0`s and `1`s. If the i-th character of s is `1`, the i-th cell (from left) contains a token. Otherwise, it doesn't contain a token. Snuke wants t...
Solve the programming task below in a Python markdown code block. There are $n$ cities and $m$ bidirectional roads in Berland. The $i$-th road connects the cities $x_i$ and $y_i$, and has the speed limit $s_i$. The road network allows everyone to get from any city to any other city. The Berland Transport Ministry is ...
Solve the programming task below in a Python markdown code block. Once n people simultaneously signed in to the reception at the recently opened, but already thoroughly bureaucratic organization (abbreviated TBO). As the organization is thoroughly bureaucratic, it can accept and cater for exactly one person per day. A...
Solve the programming task below in a Python markdown code block. Write a code that receives an array of numbers or strings, goes one by one through it while taking one value out, leaving one value in, taking, leaving, and back again to the beginning until all values are out. It's like a circle of people who decide ...
Solve the programming task below in a Python markdown code block. Read problems statements in Mandarin Chinese and Russian. Chef likes trees a lot. Today he has an infinte full binary tree (each node has exactly two childs) with special properties. Chef's tree has the following special properties : Each node of the...
Solve the programming task below in a Python markdown code block. We have two permutations P and Q of size N (that is, P and Q are both rearrangements of (1,~2,~...,~N)). There are N! possible permutations of size N. Among them, let P and Q be the a-th and b-th lexicographically smallest permutations, respectively. Fi...
Solve the programming task below in a Python markdown code block. # Task You are a magician. You're going to perform a trick. You have `b` black marbles and `w` white marbles in your magic hat, and an infinite supply of black and white marbles that you can pull out of nowhere. You ask your audience to repeatedl...
Solve the programming task below in a Python markdown code block. Today Tavas got his test result as an integer score and he wants to share it with his girlfriend, Nafas. His phone operating system is Tavdroid, and its keyboard doesn't have any digits! He wants to share his score with Nafas via text, so he has no cho...
Solve the programming task below in a Python markdown code block. Given a certain integer ```n```, we need a function ```big_primefac_div()```, that give an array with the highest prime factor and the highest divisor (not equal to n). Let's see some cases: ```python big_primefac_div(100) == [5, 50] big_primefac_div(1...
Solve the programming task below in a Python markdown code block. Asterix, Obelix and their temporary buddies Suffix and Prefix has finally found the Harmony temple. However, its doors were firmly locked and even Obelix had no luck opening them. A little later they found a string s, carved on a rock below the temple'...
Solve the programming task below in a Python markdown code block. An English booklet has been created for publicizing Aizu to the world. When you read it carefully, you found a misnomer (an error in writing) on the last name of Masayuki Hoshina, the lord of the Aizu domain. The booklet says "Hoshino" not "Hoshina". Y...
Solve the programming task below in a Python markdown code block. When Mr. X is away from home, he has decided to use his smartwatch to search the best route to go back home, to participate in ABC. You, the smartwatch, has found N routes to his home. If Mr. X uses the i-th of these routes, he will get home in time t_i...
Solve the programming task below in a Python markdown code block. A newspaper is published in Walrusland. Its heading is s1, it consists of lowercase Latin letters. Fangy the little walrus wants to buy several such newspapers, cut out their headings, glue them one to another in order to get one big string. After that ...
Solve the programming task below in a Python markdown code block. Recently Bob invented a new game with a tree (we should remind you, that a tree is a connected graph without cycles): he deletes any (possibly, zero) amount of edges of the tree, and counts the product of sizes of the connected components left after the...
Solve the programming task below in a Python markdown code block. You are given an integer sequence A of length N and an integer K. You will perform the following operation on this sequence Q times: - Choose a contiguous subsequence of length K, then remove the smallest element among the K elements contained in the c...
Solve the programming task below in a Python markdown code block. Dima, Inna and Seryozha have gathered in a room. That's right, someone's got to go. To cheer Seryozha up and inspire him to have a walk, Inna decided to cook something. Dima and Seryozha have n fruits in the fridge. Each fruit has two parameters: the ...
Solve the programming task below in a Python markdown code block. Berland SU holds yet another training contest for its students today. n students came, each of them brought his laptop. However, it turned out that everyone has forgot their chargers! Let students be numbered from 1 to n. Laptop of the i-th student has...
Solve the programming task below in a Python markdown code block. Let's call an array of non-negative integers $a_1, a_2, \ldots, a_n$ a $k$-extension for some non-negative integer $k$ if for all possible pairs of indices $1 \leq i, j \leq n$ the inequality $k \cdot |i - j| \leq min(a_i, a_j)$ is satisfied. The expans...
Solve the programming task below in a Python markdown code block. We have a board with a 2 \times N grid. Snuke covered the board with N dominoes without overlaps. Here, a domino can cover a 1 \times 2 or 2 \times 1 square. Then, Snuke decided to paint these dominoes using three colors: red, cyan and green. Two domin...
Solve the programming task below in a Python markdown code block. Wilbur the pig is tinkering with arrays again. He has the array a_1, a_2, ..., a_{n} initially consisting of n zeros. At one step, he can choose any index i and either add 1 to all elements a_{i}, a_{i} + 1, ... , a_{n} or subtract 1 from all elements a...
Solve the programming task below in a Python markdown code block. You are given a simple code of a function and you would like to know what it will return. F(N, K, Answer, Operator, A[N]) returns int; begin for i=1..K do for j=1..N do Answer=(Answer operator A_{j}) return Answer end Here N, K, Answer and the value ...
Solve the programming task below in a Python markdown code block. Dr. Bruce Banner hates his enemies (like others don't). As we all know, he can barely talk when he turns into the incredible Hulk. That's why he asked you to help him to express his feelings. Hulk likes the Inception so much, and like that his feelings...
Solve the programming task below in a Python markdown code block. The Fire Lord attacked the Frost Kingdom. He has already got to the Ice Fortress, where the Snow Queen dwells. He arranged his army on a segment n in length not far from the city walls. And only the frost magician Solomon can save the Frost Kingdom. <i...
Solve the programming task below in a Python markdown code block. The World Programming Olympics Medal is a metal disk, consisting of two parts: the first part is a ring with outer radius of r1 cm, inner radius of r2 cm, (0 < r2 < r1) made of metal with density p1 g/cm3. The second part is an inner disk with radius r2...
Solve the programming task below in a Python markdown code block. The Ohgas are a prestigious family based on Hachioji. The head of the family, Mr. Nemochi Ohga, a famous wealthy man, wishes to increase his fortune by depositing his money to an operation company. You are asked to help Mr. Ohga maximize his profit by o...
Solve the programming task below in a Python markdown code block. Comrade Dujikov is busy choosing artists for Timofey's birthday and is recieving calls from Taymyr from Ilia-alpinist. Ilia-alpinist calls every n minutes, i.e. in minutes n, 2n, 3n and so on. Artists come to the comrade every m minutes, i.e. in minute...
Solve the programming task below in a Python markdown code block. You are given a string S. Takahashi can insert the character `A` at any position in this string any number of times. Can he change S into `AKIHABARA`? Constraints * 1 \leq |S| \leq 50 * S consists of uppercase English letters. Input Input is given...
Solve the programming task below in a Python markdown code block. Coffee Vending Machine Problems [Part 1] You have a vending machine, but it can not give the change back. You decide to implement this functionality. First of all, you need to know the minimum number of coins for this operation (i'm sure you don't want...
Solve the programming task below in a Python markdown code block. Bash wants to become a Pokemon master one day. Although he liked a lot of Pokemon, he has always been fascinated by Bulbasaur the most. Soon, things started getting serious and his fascination turned into an obsession. Since he is too young to go out an...
Solve the programming task below in a Python markdown code block. Pari has a friend who loves palindrome numbers. A palindrome number is a number that reads the same forward or backward. For example 12321, 100001 and 1 are palindrome numbers, while 112 and 1021 are not. Pari is trying to love them too, but only very ...
Solve the programming task below in a Python markdown code block. Problem Statement You want to compete in ICPC (Internet Contest of Point Collection). In this contest, we move around in $N$ websites, numbered $1$ through $N$, within a time limit and collect points as many as possible. We can start and end on any web...
Solve the programming task below in a Python markdown code block. Petya has recently started working as a programmer in the IT city company that develops computer games. Besides game mechanics implementation to create a game it is necessary to create tool programs that can be used by game designers to create game lev...
Solve the programming task below in a Python markdown code block. ## Task **_Given_** *an array of integers* , **_Find_** **_the maximum product_** *obtained from multiplying 2 adjacent numbers in the array*. ____ # Notes * **_Array/list_** size is *at least 2*. * **_Array/list_** numbers could be a *mixture of po...
Solve the programming task below in a Python markdown code block. In some country there are exactly n cities and m bidirectional roads connecting the cities. Cities are numbered with integers from 1 to n. If cities a and b are connected by a road, then in an hour you can go along this road either from city a to city b...
Solve the programming task below in a Python markdown code block. You are given an infinite checkered field. You should get from a square (x1; y1) to a square (x2; y2). Using the shortest path is not necessary. You can move on the field squares in four directions. That is, when you are positioned in any square, you ca...
Solve the programming task below in a Python markdown code block. After a successful year of milk production, Farmer John is rewarding his cows with their favorite treat: tasty grass! On the field, there is a row of n units of grass, each with a sweetness s_i. Farmer John has m cows, each with a favorite sweetness f_...
Solve the programming task below in a Python markdown code block. There are N people, conveniently numbered 1 through N. They were standing in a row yesterday, but now they are unsure of the order in which they were standing. However, each person remembered the following fact: the absolute difference of the number of ...
Solve the programming task below in a Python markdown code block. Chef loves research! Now he is looking for subarray of maximal length with non-zero product. Chef has an array A with N elements: A1, A2, ..., AN. Subarray Aij of array A is elements from index i to index j: Ai, Ai+1, ..., Aj. Product of subarray Aij...
Solve the programming task below in a Python markdown code block. Formula One championship consists of series of races called Grand Prix. After every race drivers receive points according to their final position. Only the top 10 drivers receive points in the following order 25, 18, 15, 12, 10, 8, 6, 4, 2, 1. At the co...
Solve the programming task below in a Python markdown code block. Shubham has a binary string $s$. A binary string is a string containing only characters "0" and "1". He can perform the following operation on the string any amount of times: Select an index of the string, and flip the character at that index. This m...
Solve the programming task below in a Python markdown code block. You are given a string $s$ consisting of the characters '0', '1', and '?'. You need to replace all the characters with '?' in the string $s$ by '0' or '1' so that the string becomes a palindrome and has exactly $a$ characters '0' and exactly $b$ charact...
Solve the programming task below in a Python markdown code block. Cucumber boy is fan of Kyubeat, a famous music game. Kyubeat has 16 panels for playing arranged in 4 × 4 table. When a panel lights up, he has to press that panel. Each panel has a timing to press (the preffered time when a player should press it), an...
Solve the programming task below in a Python markdown code block. Read problems statements in Mandarin Chinese and Russian as well. Mike is given an undirected graph G of N vertices and M edges. A non-negative integer X_{i} is assigned to the i'th vertex of G, for 1 ≤ i ≤ N. Mike was asked to assign labels to eac...
Solve the programming task below in a Python markdown code block. There are $n$ persons located on a plane. The $i$-th person is located at the point $(x_i, y_i)$ and initially looks at the point $(u_i, v_i)$. At the same moment of time, all persons will start to rotate clockwise synchronously with the same angular s...
Solve the programming task below in a Python markdown code block. Selection of Participants of an Experiment Dr. Tsukuba has devised a new method of programming training. In order to evaluate the effectiveness of this method, he plans to carry out a control experiment. Having two students as the participants of the e...
Solve the programming task below in a Python markdown code block. Takahashi is a teacher responsible for a class of N students. The students are given distinct student numbers from 1 to N. Today, all the students entered the classroom at different times. According to Takahashi's record, there were A_i students in the ...
Solve the programming task below in a Python markdown code block. You are given an integer $n$. You can perform any of the following operations with this number an arbitrary (possibly, zero) number of times: Replace $n$ with $\frac{n}{2}$ if $n$ is divisible by $2$; Replace $n$ with $\frac{2n}{3}$ if $n$ is divisi...
Solve the programming task below in a Python markdown code block. After a long day, Alice and Bob decided to play a little game. The game board consists of $n$ cells in a straight line, numbered from $1$ to $n$, where each cell contains a number $a_i$ between $1$ and $n$. Furthermore, no two cells contain the same num...
Solve the programming task below in a Python markdown code block. Factorize a given integer n. Constraints * 2 ≤ n ≤ 109 Input n An integer n is given in a line. Output Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime f...
Solve the programming task below in a Python markdown code block. There are n people taking part in auction today. The rules of auction are classical. There were n bids made, though it's not guaranteed they were from different people. It might happen that some people made no bids at all. Each bid is define by two int...
Solve the programming task below in a Python markdown code block. You are given an array $a$ consisting of $n$ non-negative integers. You have to choose a non-negative integer $x$ and form a new array $b$ of size $n$ according to the following rule: for all $i$ from $1$ to $n$, $b_i = a_i \oplus x$ ($\oplus$ denotes t...
Solve the programming task below in a Python markdown code block. A schoolboy named Vasya loves reading books on programming and mathematics. He has recently read an encyclopedia article that described the method of median smoothing (or median filter) and its many applications in science and engineering. Vasya liked t...
Solve the programming task below in a Python markdown code block. In Arcady's garden there grows a peculiar apple-tree that fruits one time per year. Its peculiarity can be explained in following way: there are n inflorescences, numbered from 1 to n. Inflorescence number 1 is situated near base of tree and any other i...
Solve the programming task below in a Python markdown code block. In Takahashi Kingdom, which once existed, there are N cities, and some pairs of cities are connected bidirectionally by roads. The following are known about the road network: - People traveled between cities only through roads. It was possible to reach...
Solve the programming task below in a Python markdown code block. Now that Chef has finished baking and frosting his cupcakes, it's time to package them. Chef has N cupcakes, and needs to decide how many cupcakes to place in each package. Each package must contain the same number of cupcakes. Chef will choose an integ...