question large_stringlengths 265 13.2k |
|---|
Solve the programming task below in a Python markdown code block.
Polycarpus is an amateur businessman. Recently he was surprised to find out that the market for paper scissors is completely free! Without further ado, Polycarpus decided to start producing and selling such scissors.
Polycaprus calculated that the opti... |
Solve the programming task below in a Python markdown code block.
Once upon a time, a CodeWarrior, after reading a [discussion on what can be the plural](http://www.codewars.com/kata/plural/discuss/javascript), took a look at [this page](http://en.wikipedia.org/wiki/Grammatical_number#Types_of_number
) and discovered ... |
Solve the programming task below in a Python markdown code block.
Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of Mysterious Light.
Three mirrors of length N are set so that they form an equilateral triangle. Let the vertices of the triangle be a, b and c.
Inside the trian... |
Solve the programming task below in a Python markdown code block.
Let us define the oddness of a permutation p = {p_1,\ p_2,\ ...,\ p_n} of {1,\ 2,\ ...,\ n} as \sum_{i = 1}^n |i - p_i|.
Find the number of permutations of {1,\ 2,\ ...,\ n} of oddness k, modulo 10^9+7.
-----Constraints-----
- All values in input are ... |
Solve the programming task below in a Python markdown code block.
Let w be a string consisting of lowercase letters.
We will call w beautiful if the following condition is satisfied:
- Each lowercase letter of the English alphabet occurs even number of times in w.
You are given the string w. Determine if w is beautif... |
Solve the programming task below in a Python markdown code block.
DLS and JLS are bored with a Math lesson. In order to entertain themselves, DLS took a sheet of paper and drew $n$ distinct lines, given by equations $y = x + p_i$ for some distinct $p_1, p_2, \ldots, p_n$.
Then JLS drew on the same paper sheet $m$ dis... |
Solve the programming task below in a Python markdown code block.
Dreamoon wants to climb up a stair of n steps. He can climb 1 or 2 steps at each move. Dreamoon wants the number of moves to be a multiple of an integer m.
What is the minimal number of moves making him climb to the top of the stairs that satisfies hi... |
Solve the programming task below in a Python markdown code block.
You are going to eat X red apples and Y green apples.
You have A red apples of deliciousness p_1,p_2, \dots, p_A, B green apples of deliciousness q_1,q_2, \dots, q_B, and C colorless apples of deliciousness r_1,r_2, \dots, r_C.
Before eating a colorle... |
Solve the programming task below in a Python markdown code block.
Once when Gerald studied in the first year at school, his teacher gave the class the following homework. She offered the students a string consisting of n small Latin letters; the task was to learn the way the letters that the string contains are writte... |
Solve the programming task below in a Python markdown code block.
Polycarp has a string $s[1 \dots n]$ of length $n$ consisting of decimal digits. Polycarp performs the following operation with the string $s$ no more than once (i.e. he can perform operation $0$ or $1$ time):
Polycarp selects two numbers $i$ and $j$ (... |
Solve the programming task below in a Python markdown code block.
Petya loves lucky numbers very much. Everybody knows that lucky numbers are positive integers whose decimal record contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Petya has sequence a consisting... |
Solve the programming task below in a Python markdown code block.
There are $n$ startups. Startups can be active or acquired. If a startup is acquired, then that means it has exactly one active startup that it is following. An active startup can have arbitrarily many acquired startups that are following it. An active ... |
Solve the programming task below in a Python markdown code block.
Little Johnny has recently learned about set theory. Now he is studying binary relations. You've probably heard the term "equivalence relation". These relations are very important in many areas of mathematics. For example, the equality of the two number... |
Solve the programming task below in a Python markdown code block.
Today is Wednesday, the third day of the week. What's more interesting is that tomorrow is the last day of the year 2015.
Limak is a little polar bear. He enjoyed this year a lot. Now, he is so eager to the coming year 2016.
Limak wants to prove how r... |
Solve the programming task below in a Python markdown code block.
There are N sightseeing spots on the x-axis, numbered 1, 2, ..., N. Spot i is at the point with coordinate A_i. It costs |a - b| yen (the currency of Japan) to travel from a point with coordinate a to another point with coordinate b along the axis.
You... |
Solve the programming task below in a Python markdown code block.
Andrewid the Android is a galaxy-famous detective. He is now investigating a case of frauds who make fake copies of the famous Stolp's gears, puzzles that are as famous as the Rubik's cube once was.
Its most important components are a button and a line... |
Solve the programming task below in a Python markdown code block.
Gerald is very particular to eight point sets. He thinks that any decent eight point set must consist of all pairwise intersections of three distinct integer vertical straight lines and three distinct integer horizontal straight lines, except for the av... |
Solve the programming task below in a Python markdown code block.
There are $n$ lamps on a line, numbered from $1$ to $n$. Each one has an initial state off ($0$) or on ($1$).
You're given $k$ subsets $A_1, \ldots, A_k$ of $\{1, 2, \dots, n\}$, such that the intersection of any three subsets is empty. In other words,... |
Solve the programming task below in a Python markdown code block.
Consider some square matrix A with side n consisting of zeros and ones. There are n rows numbered from 1 to n from top to bottom and n columns numbered from 1 to n from left to right in this matrix. We'll denote the element of the matrix which is locate... |
Solve the programming task below in a Python markdown code block.
You are given a binary matrix $A$ of size $n \times n$. Let's denote an $x$-compression of the given matrix as a matrix $B$ of size $\frac{n}{x} \times \frac{n}{x}$ such that for every $i \in [1, n], j \in [1, n]$ the condition $A[i][j] = B[\lceil \frac... |
Solve the programming task below in a Python markdown code block.
Masha works in an advertising agency. In order to promote the new brand, she wants to conclude contracts with some bloggers. In total, Masha has connections of $n$ different bloggers. Blogger numbered $i$ has $a_i$ followers.
Since Masha has a limited ... |
Solve the programming task below in a Python markdown code block.
For this exercise you will create a global flatten method. The method takes in any number of arguments and flattens them into a single array. If any of the arguments passed in are an array then the individual objects within the array will be flattened s... |
Solve the programming task below in a Python markdown code block.
Vasya and Petya are playing a simple game. Vasya thought of number x between 1 and n, and Petya tries to guess the number.
Petya can ask questions like: "Is the unknown number divisible by number y?".
The game is played by the following rules: first P... |
Solve the programming task below in a Python markdown code block.
The blinds are known to consist of opaque horizontal stripes that can be rotated thus regulating the amount of light flowing in the room. There are n blind stripes with the width of 1 in the factory warehouse for blind production. The problem is that al... |
Solve the programming task below in a Python markdown code block.
Related to MrZizoScream's Product Array kata. You might want to solve that one first :)
```if:javascript
**Note:** Node 10 has now been enabled, and you can now use its BigInt capabilities if you wish, though your resulting array must still contain str... |
Solve the programming task below in a Python markdown code block.
Solve the mystery.
Input:
String which consists of words(all the characters of any word are lower case letters) and punctuation marks(consists of {'.' , ',' , '?' , '!'}). Also every input string consists of one '*' in it.
It is guaranteed that string... |
Solve the programming task below in a Python markdown code block.
Write a program which reads a rectangle and a circle, and determines whether the circle is arranged inside the rectangle. As shown in the following figures, the upper right coordinate $(W, H)$ of the rectangle and the central coordinate $(x, y)$ and rad... |
Solve the programming task below in a Python markdown code block.
Let's consider one interesting word game. In this game you should transform one word into another through special operations.
Let's say we have word w, let's split this word into two non-empty parts x and y so, that w = xy. A split operation is transf... |
Solve the programming task below in a Python markdown code block.
You are to write a function to transpose a guitar tab up or down a number of semitones. The amount to transpose is a number, positive or negative. The tab is given as an array, with six elements for each guitar string (fittingly passed as strings). Outp... |
Solve the programming task below in a Python markdown code block.
In the computer network of the Berland State University there are n routers numbered from 1 to n. Some pairs of routers are connected by patch cords. Information can be transmitted over patch cords in both direction. The network is arranged in such a wa... |
Solve the programming task below in a Python markdown code block.
ZS the Coder and Chris the Baboon has arrived at Udayland! They walked in the park where n trees grow. They decided to be naughty and color the trees in the park. The trees are numbered with integers from 1 to n from left to right.
Initially, tree i ha... |
Solve the programming task below in a Python markdown code block.
Mashmokh works in a factory. At the end of each day he must turn off all of the lights.
The lights on the factory are indexed from 1 to n. There are n buttons in Mashmokh's room indexed from 1 to n as well. If Mashmokh pushes button with index i, then... |
Solve the programming task below in a Python markdown code block.
Vasily exited from a store and now he wants to recheck the total price of all purchases in his bill. The bill is a string in which the names of the purchases and their prices are printed in a row without any spaces. Check has the format "name_1price_1na... |
Solve the programming task below in a Python markdown code block.
Recenlty Luba got a credit card and started to use it. Let's consider n consecutive days Luba uses the card.
She starts with 0 money on her account.
In the evening of i-th day a transaction a_{i} occurs. If a_{i} > 0, then a_{i} bourles are deposited ... |
Solve the programming task below in a Python markdown code block.
This is the easy version of the problem. The difference between the versions is the constraints on a_i. You can make hacks only if all versions of the problem are solved.
Little Dormi has recently received a puzzle from his friend and needs your help t... |
Solve the programming task below in a Python markdown code block.
Some numbers have funny properties. For example:
> 89 --> 8¹ + 9² = 89 * 1
> 695 --> 6² + 9³ + 5⁴= 1390 = 695 * 2
> 46288 --> 4³ + 6⁴+ 2⁵ + 8⁶ + 8⁷ = 2360688 = 46288 * 51
Given a positive integer n written as abcd... (a, b, c, d... being digits) and... |
Solve the programming task below in a Python markdown code block.
Given two arrays of integers `m` and `n`, test if they contain *at least* one identical element. Return `true` if they do; `false` if not.
Your code must handle any value within the range of a 32-bit integer, and must be capable of handling either arra... |
Solve the programming task below in a Python markdown code block.
Vasya has a sequence $a$ consisting of $n$ integers $a_1, a_2, \dots, a_n$. Vasya may pefrom the following operation: choose some number from the sequence and swap any pair of bits in its binary representation. For example, Vasya can transform number $6... |
Solve the programming task below in a Python markdown code block.
E-training
Nene is writing a program to look up $ N $ integers $ V_1, V_2, V_3, \ cdots, V_N $ for programming training.
As told by his instructor, Umiko, Nene wrote a program to look up multiples of 2, 3, and 6.
Multiples of 2 were $ A $, multiples ... |
Solve the programming task below in a Python markdown code block.
You are given two arrays $a$ and $b$, each contains $n$ integers.
You want to create a new array $c$ as follows: choose some real (i.e. not necessarily integer) number $d$, and then for every $i \in [1, n]$ let $c_i := d \cdot a_i + b_i$.
Your goal is... |
Solve the programming task below in a Python markdown code block.
Deoxyribonucleic acid (DNA) is a chemical found in the nucleus of cells and carries the "instructions" for the development and functioning of living organisms.
If you want to know more http://en.wikipedia.org/wiki/DNA
In DNA strings, symbols "A" and "... |
Solve the programming task below in a Python markdown code block.
```if:javascript
`Array.prototype.length` will give you the number of top-level elements in an array.
```
```if:ruby
`Array#length` will give you the number of top-level elements in an array.
```
```if:csharp
The `Length` property of an array will give ... |
Solve the programming task below in a Python markdown code block.
You are given $n$ dominoes. Each domino has a left and a right cell. Each cell can be colored either black or white. Some cells are already colored, while some aren't yet.
The coloring is said to be valid if and only if it is possible to rearrange the ... |
Solve the programming task below in a Python markdown code block.
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 which are already booked and some are still free. The places are numbered in the following fashion:
The car is separated i... |
Solve the programming task below in a Python markdown code block.
Serge came to the school dining room and discovered that there is a big queue here. There are $m$ pupils in the queue. He's not sure now if he wants to wait until the queue will clear, so he wants to know which dish he will receive if he does. As Serge ... |
Solve the programming task below in a Python markdown code block.
There is a square in the xy-plane. The coordinates of its four vertices are (x_1,y_1),(x_2,y_2),(x_3,y_3) and (x_4,y_4) in counter-clockwise order.
(Assume that the positive x-axis points right, and the positive y-axis points up.)
Takahashi remembers (x... |
Solve the programming task below in a Python markdown code block.
A sequence a_1,a_2,... ,a_n is said to be /\/\/\/ when the following conditions are satisfied:
* For each i = 1,2,..., n-2, a_i = a_{i+2}.
* Exactly two different numbers appear in the sequence.
You are given a sequence v_1,v_2,...,v_n whose length ... |
Solve the programming task below in a Python markdown code block.
Write a function that takes an integer and returns an array `[A, B, C]`, where `A` is the number of multiples of 3 (but not 5) below the given integer, `B` is the number of multiples of 5 (but not 3) below the given integer and `C` is the number of mult... |
Solve the programming task below in a Python markdown code block.
The Patisserie AtCoder sells cakes with number-shaped candles.
There are X, Y and Z kinds of cakes with 1-shaped, 2-shaped and 3-shaped candles, respectively.
Each cake has an integer value called deliciousness, as follows:
- The deliciousness of the c... |
Solve the programming task below in a Python markdown code block.
Your favorite shop sells n Kinder Surprise chocolate eggs. You know that exactly s stickers and exactly t toys are placed in n eggs in total.
Each Kinder Surprise can be one of three types:
* it can contain a single sticker and no toy;
* it can c... |
Solve the programming task below in a Python markdown code block.
The Squareland national forest is divided into equal 1 × 1 square plots aligned with north-south and east-west directions. Each plot can be uniquely described by integer Cartesian coordinates (x, y) of its south-west corner.
Three friends, Alice, Bob, ... |
Solve the programming task below in a Python markdown code block.
Recall that the sequence $b$ is a a subsequence of the sequence $a$ if $b$ can be derived from $a$ by removing zero or more elements without changing the order of the remaining elements. For example, if $a=[1, 2, 1, 3, 1, 2, 1]$, then possible subsequen... |
Solve the programming task below in a Python markdown code block.
You are given a set of $n$ segments on the axis $Ox$, each segment has integer endpoints between $1$ and $m$ inclusive. Segments may intersect, overlap or even coincide with each other. Each segment is characterized by two integers $l_i$ and $r_i$ ($1 \... |
Solve the programming task below in a Python markdown code block.
There are N cubes stacked vertically on a desk.
You are given a string S of length N. The color of the i-th cube from the bottom is red if the i-th character in S is 0, and blue if that character is 1.
You can perform the following operation any number ... |
Solve the programming task below in a Python markdown code block.
Little boy Petya loves stairs very much. But he is bored from simple going up and down them — he loves jumping over several stairs at a time. As he stands on some stair, he can either jump to the next one or jump over one or two stairs at a time. But so... |
Solve the programming task below in a Python markdown code block.
Hiking club "Up the hill" just returned from a walk. Now they are trying to remember which hills they've just walked through.
It is known that there were N stops, all on different integer heights between 1 and N kilometers (inclusive) above the sea lev... |
Solve the programming task below in a Python markdown code block.
You've got a string $S$ consisting of $n$ lowercase English letters from your friend. It turned out that this is a number written in poman numerals. The poman numeral system is long forgotten. All that's left is the algorithm to transform number from po... |
Solve the programming task below in a Python markdown code block.
Given three distinct integers $a$, $b$, and $c$, find the medium number between all of them.
The medium number is the number that is neither the minimum nor the maximum of the given three numbers.
For example, the median of $5,2,6$ is $5$, since the m... |
Solve the programming task below in a Python markdown code block.
In the good old days, the Internet was free from fears and terrorism. People did not have to worry about any cyber criminals or mad computer scientists. Today, however, you are facing atrocious crackers wherever you are, unless being disconnected. You h... |
Solve the programming task below in a Python markdown code block.
As technologies develop, manufacturers are making the process of unlocking a phone as user-friendly as possible. To unlock its new phone, Arkady's pet dog Mu-mu has to bark the password once. The phone represents a password as a string of two lowercase ... |
Solve the programming task below in a Python markdown code block.
Polycarp plays "Game 23". Initially he has a number $n$ and his goal is to transform it to $m$. In one move, he can multiply $n$ by $2$ or multiply $n$ by $3$. He can perform any number of moves.
Print the number of moves needed to transform $n$ to $m$... |
Solve the programming task below in a Python markdown code block.
The year of 2012 is coming...
According to an ancient choradrican legend in this very year, in 2012, Diablo and his brothers Mephisto and Baal will escape from hell, and innumerable hordes of demons will enslave the human world. But seven brave heroes ... |
Solve the programming task below in a Python markdown code block.
Special Agent Smart Beaver works in a secret research department of ABBYY. He's been working there for a long time and is satisfied with his job, as it allows him to eat out in the best restaurants and order the most expensive and exotic wood types ther... |
Solve the programming task below in a Python markdown code block.
Takahashi throws N dice, each having K sides with all integers from 1 to K. The dice are NOT pairwise distinguishable.
For each i=2,3,...,2K, find the following value modulo 998244353:
- The number of combinations of N sides shown by the dice such that... |
Solve the programming task below in a Python markdown code block.
Are you fond of collecting some kind of stuff? Mike is crazy about collecting stamps. He is an active member of Stamp Collecting Сommunity(SCC).
SCC consists of N members which are fond of philately. A few days ago Mike argued with the others from SCC... |
Solve the programming task below in a Python markdown code block.
Gleb ordered pizza home. When the courier delivered the pizza, he was very upset, because several pieces of sausage lay on the crust, and he does not really like the crust.
The pizza is a circle of radius r and center at the origin. Pizza consists of t... |
Solve the programming task below in a Python markdown code block.
Example
Input
anagram
grandmother
Output
4
Read the inputs from stdin solve the problem and write the answer to stdout (do not directly test on the sample inputs). Enclose your code within ```python delimiters. |
Solve the programming task below in a Python markdown code block.
Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want any friend... |
Solve the programming task below in a Python markdown code block.
INTERCAL is the oldest of esoteric programming languages. One of its many weird features is the method of character-based output, known as Turing Tape method. It converts an array of unsigned 8-bit integers into a sequence of characters to print, using ... |
Solve the programming task below in a Python markdown code block.
Background
There is a message that is circulating via public media that claims a reader can easily read a message where the inner letters of each words is scrambled, as long as the first and last letters remain the same and the word contains all the let... |
Solve the programming task below in a Python markdown code block.
Vasya lives in a strange world. The year has n months and the i-th month has ai days. Vasya got a New Year present — the clock that shows not only the time, but also the date.
The clock's face can display any number from 1 to d. It is guaranteed that a... |
Solve the programming task below in a Python markdown code block.
Write a program which manipulates a disjoint set S = {S1, S2, . . . , Sk}.
First of all, the program should read an integer n, then make a disjoint set where each element consists of 0, 1, ... n−1 respectively.
Next, the program should read an integer... |
Solve the programming task below in a Python markdown code block.
Greg is a beginner bodybuilder. Today the gym coach gave him the training plan. All it had was n integers a_1, a_2, ..., a_{n}. These numbers mean that Greg needs to do exactly n exercises today. Besides, Greg should repeat the i-th in order exercise a_... |
Solve the programming task below in a Python markdown code block.
You are given two positive integer numbers a and b. Permute (change order) of the digits of a to construct maximal number not exceeding b. No number in input and/or output can start with the digit 0.
It is allowed to leave a as it is.
-----Input-----... |
Solve the programming task below in a Python markdown code block.
Little Elephant was fond of inventing new games. After a lot of research, Little Elephant came to know that most of the animals in the forest were showing less interest to play the multi-player games. Little Elephant had started to invent single player ... |
Solve the programming task below in a Python markdown code block.
Vova plays a computer game known as Mages and Monsters. Vova's character is a mage. Though as he has just started, his character knows no spells.
Vova's character can learn new spells during the game. Every spell is characterized by two values x_{i} an... |
Solve the programming task below in a Python markdown code block.
A certain type of steel is graded according to the following conditions.
1. Hardness of the steel must be greater than 50
2. Carbon content of the steel must be less than 0.7
3. Tensile strength must be greater than 5600
The grades awarded are as foll... |
Solve the programming task below in a Python markdown code block.
Ashish has an array $a$ of size $n$.
A subsequence of $a$ is defined as a sequence that can be obtained from $a$ by deleting some elements (possibly none), without changing the order of the remaining elements.
Consider a subsequence $s$ of $a$. He def... |
Solve the programming task below in a Python markdown code block.
In the school computer room there are n servers which are responsible for processing several computing tasks. You know the number of scheduled tasks for each server: there are m_{i} tasks assigned to the i-th server.
In order to balance the load for ea... |
Solve the programming task below in a Python markdown code block.
A permutation of length n is an integer sequence such that each integer from 0 to (n - 1) appears exactly once in it. For example, sequence [0, 2, 1] is a permutation of length 3 while both [0, 2, 2] and [1, 2, 3] are not.
A fixed point of a function i... |
Solve the programming task below in a Python markdown code block.
You have N items that you want to put them into a knapsack. Item i has value vi and weight wi.
You want to find a subset of items to put such that:
* The total value of the items is as large as possible.
* The items have combined weight at most W, tha... |
Solve the programming task below in a Python markdown code block.
You are running through a rectangular field. This field can be represented as a matrix with 3 rows and m columns. (i, j) denotes a cell belonging to i-th row and j-th column.
You start in (2, 1) and have to end your path in (2, m). From the cell (i, j)... |
Solve the programming task below in a Python markdown code block.
Eugeny loves listening to music. He has n songs in his play list. We know that song number i has the duration of t_{i} minutes. Eugeny listens to each song, perhaps more than once. He listens to song number i c_{i} times. Eugeny's play list is organized... |
Solve the programming task below in a Python markdown code block.
I need to save some money to buy a gift. I think I can do something like that:
First week (W0) I save nothing on Sunday, 1 on Monday, 2 on Tuesday... 6 on Saturday,
second week (W1) 2 on Monday... 7 on Saturday and so on according to the table below wh... |
Solve the programming task below in a Python markdown code block.
Snuke built an online judge to hold a programming contest.
When a program is submitted to the judge, the judge returns a verdict, which is a two-character string that appears in the string S as a contiguous substring. (The judge can return any two-char... |
Solve the programming task below in a Python markdown code block.
Today Vasya visited a widely known site and learned that the continuation of his favourite game Codecraft II will appear after exactly k months. He looked at the calendar and learned that at the moment is the month number s. Vasya immediately got intere... |
Solve the programming task below in a Python markdown code block.
For a set $S$ of integers, perform a sequence of the following operations. Note that multiple elements can have equivalent values in $S$.
* insert($x$): Insert $x$ to $S$ and report the number of elements in $S$ after the operation.
* find($x$): Report... |
Solve the programming task below in a Python markdown code block.
Given is a string S of length N consisting of lowercase English letters.
Snuke can do this operation any number of times: remove fox occurring as a substring from s and concatenate the remaining parts of s.
What is the minimum possible length of s after... |
Solve the programming task below in a Python markdown code block.
She does her utmost to flawlessly carry out a person's last rites and preserve the world's balance of yin and yang.
Hu Tao, being the little prankster she is, has tried to scare you with this graph problem! You are given a connected undirected graph of... |
Solve the programming task below in a Python markdown code block.
Madoka decided to entrust the organization of a major computer game tournament "OSU"!
In this tournament, matches are held according to the "Olympic system". In other words, there are $2^n$ participants in the tournament, numbered with integers from $1... |
Solve the programming task below in a Python markdown code block.
There are N gems. The value of the i-th gem is V_i.
You will choose some of these gems, possibly all or none, and get them.
However, you need to pay a cost of C_i to get the i-th gem.
Let X be the sum of the values of the gems obtained, and Y be the sum... |
Solve the programming task below in a Python markdown code block.
Do you know a story about the three musketeers? Anyway, you will learn about its origins now.
Richelimakieu is a cardinal in the city of Bearis. He is tired of dealing with crime by himself. He needs three brave warriors to help him to fight against ba... |
Solve the programming task below in a Python markdown code block.
There are $n$ models in the shop numbered from $1$ to $n$, with sizes $s_1, s_2, \ldots, s_n$.
Orac will buy some of the models and will arrange them in the order of increasing numbers (i.e. indices, but not sizes).
Orac thinks that the obtained arran... |
Solve the programming task below in a Python markdown code block.
Petya and Vasya are playing a game. Petya's got n non-transparent glasses, standing in a row. The glasses' positions are indexed with integers from 1 to n from left to right. Note that the positions are indexed but the glasses are not.
First Petya puts... |
Solve the programming task below in a Python markdown code block.
A permutation p of size n is the sequence p1, p2, ..., pn, consisting of n distinct integers, each of them is from 1 to n (1 ≤ pi ≤ n).
A lucky permutation is such permutation p, that any integer i (1 ≤ i ≤ n) meets this condition ppi = n - i + 1.
You... |
Solve the programming task below in a Python markdown code block.
You have $n$ students under your control and you have to compose exactly two teams consisting of some subset of your students. Each student had his own skill, the $i$-th student skill is denoted by an integer $a_i$ (different students can have the same ... |
Solve the programming task below in a Python markdown code block.
Natsuki and her friends were taken to the space by an alien and made friends with a lot of aliens. During the space travel, she discovered that aliens’ hands were often very different from humans’. Generally speaking, in a kind of aliens, there are N fi... |
Solve the programming task below in a Python markdown code block.
You are given an array of $n$ integers $a_1$, $a_2$, ..., $a_n$, and a set $b$ of $k$ distinct integers from $1$ to $n$.
In one operation, you may choose two integers $i$ and $x$ ($1 \le i \le n$, $x$ can be any integer) and assign $a_i := x$. This ope... |
Solve the programming task below in a Python markdown code block.
Pavel cooks barbecue. There are n skewers, they lay on a brazier in a row, each on one of n positions. Pavel wants each skewer to be cooked some time in every of n positions in two directions: in the one it was directed originally and in the reversed di... |
Solve the programming task below in a Python markdown code block.
In order to celebrate Twice's 5th anniversary, Tzuyu and Sana decided to play a game.
Tzuyu gave Sana two integers $a$ and $b$ and a really important quest.
In order to complete the quest, Sana has to output the smallest possible value of ($a \oplus x... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.