question large_stringlengths 265 13.2k |
|---|
Solve the programming task below in a Python markdown code block.
Recently, Petya learned about a new game "Slay the Dragon". As the name suggests, the player will have to fight with dragons. To defeat a dragon, you have to kill it and defend your castle. To do this, the player has a squad of $n$ heroes, the strength ... |
Solve the programming task below in a Python markdown code block.
You are given a special jigsaw puzzle consisting of $n\cdot m$ identical pieces. Every piece has three tabs and one blank, as pictured below. $\{3$
The jigsaw puzzle is considered solved if the following conditions hold: The pieces are arranged into ... |
Solve the programming task below in a Python markdown code block.
You have a given picture with size $w \times h$. Determine if the given picture has a single "+" shape or not. A "+" shape is described below:
A "+" shape has one center nonempty cell. There should be some (at least one) consecutive non-empty cells ... |
Solve the programming task below in a Python markdown code block.
You are given three strings A, B and C. Each of these is a string of length N consisting of lowercase English letters.
Our objective is to make all these three strings equal. For that, you can repeatedly perform the following operation:
* Operation: C... |
Solve the programming task below in a Python markdown code block.
Given a string, determine if it's a valid identifier.
## Here is the syntax for valid identifiers:
* Each identifier must have at least one character.
* The first character must be picked from: alpha, underscore, or dollar sign. The first character can... |
Solve the programming task below in a Python markdown code block.
Write
```python
function repeating_fractions(numerator, denominator)
```
that given two numbers representing the numerator and denominator of a fraction, return the fraction in string format. If the fractional part has repeated digits, replace those dig... |
Solve the programming task below in a Python markdown code block.
A traveler is planning a water hike along the river. He noted the suitable rest points for the night and wrote out their distances from the starting point. Each of these locations is further characterized by its picturesqueness, so for the i-th rest poi... |
Solve the programming task below in a Python markdown code block.
It is a simplified version of problem F2. The difference between them is the constraints (F1: $k \le 2$, F2: $k \le 10$).
You are given an integer $n$. Find the minimum integer $x$ such that $x \ge n$ and the number $x$ is $k$-beautiful.
A number is c... |
Solve the programming task below in a Python markdown code block.
You are given an undirected graph with N vertices and 0 edges. Process Q queries of the following types.
* `0 u v`: Add an edge (u, v).
* `1 u v`: Print 1 if u and v are in the same connected component, 0 otherwise.
Constraints
* 1 \leq N \leq 200,00... |
Solve the programming task below in a Python markdown code block.
There are n heaps of stone. The i-th heap has h_i stones. You want to change the number of stones in the heap by performing the following process once:
* You go through the heaps from the 3-rd heap to the n-th heap, in this order.
* Let i be the ... |
Solve the programming task below in a Python markdown code block.
Your task is to write function which takes string and list of delimiters as an input and returns list of strings/characters after splitting given string.
Example:
```python
multiple_split('Hi, how are you?', [' ']) => ['Hi,', 'how', 'are', 'you?']
mult... |
Solve the programming task below in a Python markdown code block.
Example
Input
3 2
R1
Output
3 1 2
4 5 6
7 8 9
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.
There are N islands and M bridges.
The i-th bridge connects the A_i-th and B_i-th islands bidirectionally.
Initially, we can travel between any two islands using some of these bridges.
However, the results of a survey show that these bridges will all co... |
Solve the programming task below in a Python markdown code block.
Niwango-kun is an employee of Dwango Co., Ltd.
One day, he is asked to generate a thumbnail from a video a user submitted.
To generate a thumbnail, he needs to select a frame of the video according to the following procedure:
* Get an integer N and N i... |
Solve the programming task below in a Python markdown code block.
Mike decided to teach programming to children in an elementary school. He knows that it is not an easy task to interest children in that age to code. That is why he decided to give each child two sweets.
Mike has $n$ sweets with sizes $a_1, a_2, \ldots... |
Solve the programming task below in a Python markdown code block.
The hero of the Cut the Rope game is a little monster named Om Nom. He loves candies. And what a coincidence! He also is the hero of today's problem. [Image]
One day, Om Nom visited his friend Evan. Evan has n candies of two types (fruit drops and car... |
Solve the programming task below in a Python markdown code block.
Example
Input
2
1 2
Output
2
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.
A chessboard n × m in size is given. During the zero minute we repaint all the black squares to the 0 color. During the i-th minute we repaint to the i color the initially black squares that have exactly four corner-adjacent squares painted i - 1 (all s... |
Solve the programming task below in a Python markdown code block.
Takahashi has a tower which is divided into N layers. Initially, all the layers are uncolored. Takahashi is going to paint some of the layers in red, green or blue to make a beautiful tower. He defines the beauty of the tower as follows:
* The beauty o... |
Solve the programming task below in a Python markdown code block.
Polycarp likes numbers that are divisible by 3.
He has a huge number $s$. Polycarp wants to cut from it the maximum number of numbers that are divisible by $3$. To do this, he makes an arbitrary number of vertical cuts between pairs of adjacent digits.... |
Solve the programming task below in a Python markdown code block.
Vasya the Great Magician and Conjurer loves all kinds of miracles and wizardry. In one wave of a magic wand he can turn an object into something else. But, as you all know, there is no better magic in the Universe than the magic of numbers. That's why V... |
Solve the programming task below in a Python markdown code block.
A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7.
Write a program which reads a list of N integers and prints the number of prime numbe... |
Solve the programming task below in a Python markdown code block.
Polycarp likes arithmetic progressions. A sequence $[a_1, a_2, \dots, a_n]$ is called an arithmetic progression if for each $i$ ($1 \le i < n$) the value $a_{i+1} - a_i$ is the same. For example, the sequences $[42]$, $[5, 5, 5]$, $[2, 11, 20, 29]$ and ... |
Solve the programming task below in a Python markdown code block.
Gennady owns a small hotel in the countryside where he lives a peaceful life. He loves to take long walks, watch sunsets and play cards with tourists staying in his hotel. His favorite game is called "Mau-Mau".
To play Mau-Mau, you need a pack of $52$ ... |
Solve the programming task below in a Python markdown code block.
You have an integer variable x.
Initially, x=0.
Some person gave you a string S of length N, and using the string you performed the following operation N times.
In the i-th operation, you incremented the value of x by 1 if S_i=I, and decremented the val... |
Solve the programming task below in a Python markdown code block.
Alice and Bob play 5-in-a-row game. They have a playing field of size 10 × 10. In turns they put either crosses or noughts, one at a time. Alice puts crosses and Bob puts noughts.
In current match they have made some turns and now it's Alice's turn. Sh... |
Solve the programming task below in a Python markdown code block.
Your friend won't stop texting his girlfriend. It's all he does. All day. Seriously. The texts are so mushy too! The whole situation just makes you feel ill.
Being the wonderful friend that you are, you hatch an evil plot. While he's sleeping, you ta... |
Solve the programming task below in a Python markdown code block.
prison
There are an infinite number of prisoners. Initially, the prisoners are numbered 0, 1, 2, ....
Do the following N times:
* Release the 0th prisoner and execute the k, 2k, 3k, ... th prisoners.
* Then renumber the remaining prisoners. At this t... |
Solve the programming task below in a Python markdown code block.
# Task
**_Given_** an *array/list [] of n integers* , *find maximum triplet sum in the array* **_Without duplications_** .
___
# Notes :
* **_Array/list_** size is *at least 3* .
* **_Array/list_** numbers could be a *mixture of positives , negati... |
Solve the programming task below in a Python markdown code block.
You might have remembered Theatre square from the problem 1A. Now it's finally getting repaved.
The square still has a rectangular shape of $n \times m$ meters. However, the picture is about to get more complicated now. Let $a_{i,j}$ be the $j$-th squa... |
Solve the programming task below in a Python markdown code block.
You are given an integer $n$. In one move, you can either multiply $n$ by two or divide $n$ by $6$ (if it is divisible by $6$ without the remainder).
Your task is to find the minimum number of moves needed to obtain $1$ from $n$ or determine if it's im... |
Solve the programming task below in a Python markdown code block.
There are two buttons, one of size A and one of size B.
When you press a button of size X, you get X coins and the size of that button decreases by 1.
You will press a button twice. Here, you can press the same button twice, or press both buttons once.
... |
Solve the programming task below in a Python markdown code block.
Create a function `isAlt()` that accepts a string as an argument and validates whether the vowels (a, e, i, o, u) and consonants are in alternate order.
```python
is_alt("amazon")
// true
is_alt("apple")
// false
is_alt("banana")
// true
```
Arguments... |
Solve the programming task below in a Python markdown code block.
There is a cube which consists of n × n × n small cubes. Small cubes have marks on their surfaces. An example where n = 4 is shown in the following figure.
<image>
Then, as shown in the figure above (right), make a hole that penetrates horizontally ... |
Solve the programming task below in a Python markdown code block.
Constraints
* 1 ≤ |V| ≤ 1000
* 0 ≤ |E| ≤ 2000
* -10000 ≤ di ≤ 10000
* There are no parallel edges
* There are no self-loops
Input
An edge-weighted graph G (V, E) and the source r.
|V| |E| r
s0 t0 d0
s1 t1 d1
:
s|E|-1 t|E|-1 d|E|-1
|V| is the numb... |
Solve the programming task below in a Python markdown code block.
As Valeric and Valerko were watching one of the last Euro Championship games in a sports bar, they broke a mug. Of course, the guys paid for it but the barman said that he will let them watch football in his bar only if they help his son complete a prog... |
Solve the programming task below in a Python markdown code block.
You are given a sequence $a$, initially consisting of $n$ integers.
You want to transform this sequence so that all elements in it are equal (i. e. it contains several occurrences of the same element).
To achieve this, you choose some integer $x$ that... |
Solve the programming task below in a Python markdown code block.
B: Hokkaido University Hard
Note
Please note that the question settings are the same as question A, except for the constraints.
story
Homura-chan, who passed Hokkaido University and is excited about the beginning of a new life. But in front of her, ... |
Solve the programming task below in a Python markdown code block.
Implement `String#whitespace?(str)` (Ruby), `String.prototype.whitespace(str)` (JavaScript), `String::whitespace(str)` (CoffeeScript), or `whitespace(str)` (Python), which should return `true/True` if given object consists exclusively of zero or more wh... |
Solve the programming task below in a Python markdown code block.
Takahashi is solving quizzes. He has easily solved all but the last one.
The last quiz has three choices: 1, 2, and 3.
With his supernatural power, Takahashi has found out that the choices A and B are both wrong.
Print the correct choice for this proble... |
Solve the programming task below in a Python markdown code block.
You are given an array $a[0 \ldots n-1]$ of length $n$ which consists of non-negative integers. Note that array indices start from zero.
An array is called good if the parity of each index matches the parity of the element at that index. More formally,... |
Solve the programming task below in a Python markdown code block.
The postal code in Atcoder Kingdom is A+B+1 characters long, its (A+1)-th character is a hyphen -, and the other characters are digits from 0 through 9.
You are given a string S. Determine whether it follows the postal code format in Atcoder Kingdom.
-... |
Solve the programming task below in a Python markdown code block.
CQXYM found a rectangle A of size n × m. There are n rows and m columns of blocks. Each block of the rectangle is an obsidian block or empty. CQXYM can change an obsidian block to an empty block or an empty block to an obsidian block in one operation.
... |
Solve the programming task below in a Python markdown code block.
Note that girls in Arpa’s land are really attractive.
Arpa loves overnight parties. In the middle of one of these parties Mehrdad suddenly appeared. He saw n pairs of friends sitting around a table. i-th pair consisted of a boy, sitting on the a_{i}-th... |
Solve the programming task below in a Python markdown code block.
Mash 2 arrays together so that the returning array has alternating elements of the 2 arrays . Both arrays will always be the same length.
eg. [1,2,3] + ['a','b','c'] = [1, 'a', 2, 'b', 3, 'c']
Read the inputs from stdin solve the problem and write th... |
Solve the programming task below in a Python markdown code block.
Polycarp wrote on the board a string $s$ containing only lowercase Latin letters ('a'-'z'). This string is known for you and given in the input.
After that, he erased some letters from the string $s$, and he rewrote the remaining letters in any order. ... |
Solve the programming task below in a Python markdown code block.
Just to remind, girls in Arpa's land are really nice.
Mehrdad wants to invite some Hoses to the palace for a dancing party. Each Hos has some weight wi and some beauty bi. Also each Hos may have some friends. Hoses are divided in some friendship groups... |
Solve the programming task below in a Python markdown code block.
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 and set your punishment in the form of correctional labor.
You must paint a fence which consists of $10^{100}$ planks ... |
Solve the programming task below in a Python markdown code block.
Write a program which reads an directed graph $G = (V, E)$, and finds the shortest distance from vertex $1$ to each vertex (the number of edges in the shortest path). Vertices are identified by IDs $1, 2, ... n$.
Constraints
* $1 \leq n \leq 100$
Inp... |
Solve the programming task below in a Python markdown code block.
The only difference between easy and hard versions is the length of the string. You can hack this problem only if you solve both problems.
Kirk has a binary string $s$ (a string which consists of zeroes and ones) of length $n$ and he is asking you to f... |
Solve the programming task below in a Python markdown code block.
A university student, Takahashi, has to take N examinations and pass all of them. Currently, his readiness for the i-th examination is A_{i}, and according to his investigation, it is known that he needs readiness of at least B_{i} in order to pass the ... |
Solve the programming task below in a Python markdown code block.
Snuke has an integer sequence A of length N.
He will freely choose an integer b. Here, he will get sad if A_i and b+i are far from each other. More specifically, the sadness of Snuke is calculated as follows:
* abs(A_1 - (b+1)) + abs(A_2 - (b+2)) + ..... |
Solve the programming task below in a Python markdown code block.
Stephen Queen wants to write a story. He is a very unusual writer, he uses only letters 'a', 'b', 'c', 'd' and 'e'!
To compose a story, Stephen wrote out $n$ words consisting of the first $5$ lowercase letters of the Latin alphabet. He wants to select ... |
Solve the programming task below in a Python markdown code block.
#### Task:
Your job here is to implement a method, `approx_root` in Ruby/Python/Crystal and `approxRoot` in JavaScript/CoffeeScript, that takes one argument, `n`, and returns the approximate square root of that number, rounded to the nearest hundredth ... |
Solve the programming task below in a Python markdown code block.
Kevin has just recevied his disappointing results on the USA Identification of Cows Olympiad (USAICO) in the form of a binary string of length n. Each character of Kevin's string represents Kevin's score on one of the n questions of the olympiad—'1' for... |
Solve the programming task below in a Python markdown code block.
You are given a connected undirected weighted graph consisting of $n$ vertices and $m$ edges.
You need to print the $k$-th smallest shortest path in this graph (paths from the vertex to itself are not counted, paths from $i$ to $j$ and from $j$ to $i$ ... |
Solve the programming task below in a Python markdown code block.
Karen has just arrived at school, and she has a math test today!
<image>
The test is about basic addition and subtraction. Unfortunately, the teachers were too busy writing tasks for Codeforces rounds, and had no time to make an actual test. So, they ... |
Solve the programming task below in a Python markdown code block.
Little Artem has invented a time machine! He could go anywhere in time, but all his thoughts of course are with computer science. He wants to apply this time machine to a well-known data structure: multiset.
Artem wants to create a basic multiset of in... |
Solve the programming task below in a Python markdown code block.
Moscow is hosting a major international conference, which is attended by n scientists from different countries. Each of the scientists knows exactly one language. For convenience, we enumerate all languages of the world with integers from 1 to 10^9.
In... |
Solve the programming task below in a Python markdown code block.
Problem
Alice and Bob are competing in the 50m dash.
However, in this world, the higher the AOJ rate is, the better, so the higher the AOJ rate wins.
If there is no AOJ rate on either side, there is no comparison, so there is no choice but to compete i... |
Solve the programming task below in a Python markdown code block.
Takahashi has two positive integers A and B.
It is known that A plus B equals N. Find the minimum possible value of "the sum of the digits of A" plus "the sum of the digits of B" (in base 10).
Constraints
* 2 ≤ N ≤ 10^5
* N is an integer.
Input
Inp... |
Solve the programming task below in a Python markdown code block.
Read problems statements in Mandarin Chinese and Russian as well.
A version control system(VCS) is a repository of files, often the files for the source code of computer programs, with monitored access. Every change made to the source is tracked, alo... |
Solve the programming task below in a Python markdown code block.
You are given a huge decimal number consisting of $n$ digits. It is guaranteed that this number has no leading zeros. Each digit of this number is either 0 or 1.
You may perform several (possibly zero) operations with this number. During each operation... |
Solve the programming task below in a Python markdown code block.
Maya writes weekly articles to a well known magazine, but she is missing one word each time she is about to send the article to the editor. The article is not complete without this word. Maya has a friend, Dan, and he is very good with words, but he doe... |
Solve the programming task below in a Python markdown code block.
If you draw a few infinitely long straight lines on an infinitely wide plane, this plane will be divided into several areas. For example, if you draw a straight line, the plane will be divided into two areas. Even if you draw the same number of straight... |
Solve the programming task below in a Python markdown code block.
Mr. E Ven only likes even length words.
Please create a translator so that he doesn't have to hear those pesky odd length words.
For some reason he also hates punctuation, he likes his sentences to flow.
Your translator should take in a string and outp... |
Solve the programming task below in a Python markdown code block.
At 17:00, special agent Jack starts to escape from the enemy camp. There is a cliff in between the camp and the nearest safety zone. Jack has to climb the almost vertical cliff by stepping his feet on the blocks that cover the cliff. The cliff has slipp... |
Solve the programming task below in a Python markdown code block.
There are n positive integers a_1, a_2, ..., a_n. For the one move you can choose any even value c and divide by two all elements that equal c.
For example, if a=[6,8,12,6,3,12] and you choose c=6, and a is transformed into a=[3,8,12,3,3,12] after the ... |
Solve the programming task below in a Python markdown code block.
This kata is from check py.checkio.org
You are given an array with positive numbers and a number N. You should find the N-th power of the element in the array with the index N. If N is outside of the array, then return -1. Don't forget that the first e... |
Solve the programming task below in a Python markdown code block.
We have an H \times W grid whose squares are painted black or white. The square at the i-th row from the top and the j-th column from the left is denoted as (i, j).
Snuke would like to play the following game on this grid. At the beginning of the game, ... |
Solve the programming task below in a Python markdown code block.
The official capital and the cultural capital of Berland are connected by a single road running through n regions. Each region has a unique climate, so the i-th (1 ≤ i ≤ n) region has a stable temperature of ti degrees in summer.
This summer a group of... |
Solve the programming task below in a Python markdown code block.
Nezzar has $n$ balls, numbered with integers $1, 2, \ldots, n$. Numbers $a_1, a_2, \ldots, a_n$ are written on them, respectively. Numbers on those balls form a non-decreasing sequence, which means that $a_i \leq a_{i+1}$ for all $1 \leq i < n$.
Nezzar... |
Solve the programming task below in a Python markdown code block.
We, the researchers who discovered and investigated the ancient nation Iwashiro, finally discovered the temple in the center of Iwashiro. A lithograph dedicated to the god of Iwashiro was stored in the temple. On the lithograph, two strings were written... |
Solve the programming task below in a Python markdown code block.
Boolean Expression Compressor
You are asked to build a compressor for Boolean expressions that transforms expressions to the shortest form keeping their meaning.
The grammar of the Boolean expressions has terminals `0` `1` `a` `b` `c` `d` `-` `^` `*` ... |
Solve the programming task below in a Python markdown code block.
Snuke is visiting a shop in Tokyo called 109 to buy some logs.
He wants n logs: one of length 1, one of length 2, ..., and one of length n.
The shop has n+1 logs in stock: one of length 1, one of length 2, \dots, and one of length n+1. Each of these log... |
Solve the programming task below in a Python markdown code block.
You are given a string $s$ consisting of $n$ lowercase Latin letters.
You have to remove at most one (i.e. zero or one) character of this string in such a way that the string you obtain will be lexicographically smallest among all strings that can be o... |
Solve the programming task below in a Python markdown code block.
Some positive integers can be represented by a sum of one or more consecutive prime numbers. How many such representations does a given positive integer have? For example, the integer 53 has two representations 5 + 7 + 11 + 13 + 17 and 53. The integer 4... |
Solve the programming task below in a Python markdown code block.
Omkar is playing his favorite pixelated video game, Bed Wars! In Bed Wars, there are $n$ players arranged in a circle, so that for all $j$ such that $2 \leq j \leq n$, player $j - 1$ is to the left of the player $j$, and player $j$ is to the right of pl... |
Solve the programming task below in a Python markdown code block.
Notice that the memory limit is non-standard.
Recently Arthur and Sasha have studied correct bracket sequences. Arthur understood this topic perfectly and become so amazed about correct bracket sequences, so he even got himself a favorite correct brack... |
Solve the programming task below in a Python markdown code block.
Wherever the destination is, whoever we meet, let's render this song together.
On a Cartesian coordinate plane lies a rectangular stage of size w × h, represented by a rectangle with corners (0, 0), (w, 0), (w, h) and (0, h). It can be seen that no col... |
Solve the programming task below in a Python markdown code block.
We ask you to select some number of positive integers, and calculate the sum of them.
It is allowed to select as many integers as you like, and as large integers as you wish.
You have to follow these, however: each selected integer needs to be a multipl... |
Solve the programming task below in a Python markdown code block.
Given an integer N, let us consider a triangle of numbers of N lines in which a number a_{11} appears in the first line, two numbers a_{21} and a_{22} appear in the second line, three numbers a_{31}, a_{32} and a_{33} appear in the third line, etc. In g... |
Solve the programming task below in a Python markdown code block.
Students Vasya and Petya are studying at the BSU (Byteland State University). At one of the breaks they decided to order a pizza. In this problem pizza is a circle of some radius. The pizza was delivered already cut into n pieces. The i-th piece is a se... |
Solve the programming task below in a Python markdown code block.
One day, the teacher came up with the following game.
The game uses n cards with one number from 1 to 10 and proceeds as follows.
1. The teacher pastes n cards on the blackboard in a horizontal row so that the numbers can be seen, and declares an inte... |
Solve the programming task below in a Python markdown code block.
You are visiting a large electronics store to buy a refrigerator and a microwave.
The store sells A kinds of refrigerators and B kinds of microwaves. The i-th refrigerator ( 1 \le i \le A ) is sold at a_i yen (the currency of Japan), and the j-th micro... |
Solve the programming task below in a Python markdown code block.
Hands that shed innocent blood!
There are n guilty people in a line, the i-th of them holds a claw with length L_{i}. The bell rings and every person kills some of people in front of him. All people kill others at the same time. Namely, the i-th person... |
Solve the programming task below in a Python markdown code block.
Snuke and Raccoon have a heap of N cards. The i-th card from the top has the integer a_i written on it.
They will share these cards.
First, Snuke will take some number of cards from the top of the heap, then Raccoon will take all the remaining cards.
He... |
Solve the programming task below in a Python markdown code block.
In Japan, temperature is usually expressed using the Celsius (℃) scale. In America, they used the Fahrenheit (℉) scale instead. $20$ degrees Celsius is roughly equal to $68$ degrees Fahrenheit. A phrase such as "Today’s temperature is $68$ degrees" is c... |
Solve the programming task below in a Python markdown code block.
You planned a trip using trains and buses.
The train fare will be A yen (the currency of Japan) if you buy ordinary tickets along the way, and B yen if you buy an unlimited ticket.
Similarly, the bus fare will be C yen if you buy ordinary tickets along ... |
Solve the programming task below in a Python markdown code block.
This time no story, no theory. The examples below show you how to write function `accum`:
**Examples:**
```
accum("abcd") -> "A-Bb-Ccc-Dddd"
accum("RqaEzty") -> "R-Qq-Aaa-Eeee-Zzzzz-Tttttt-Yyyyyyy"
accum("cwAt") -> "C-Ww-Aaa-Tttt"
```
The parameter of... |
Solve the programming task below in a Python markdown code block.
You have two friends. You want to present each of them several positive integers. You want to present cnt_1 numbers to the first friend and cnt_2 numbers to the second friend. Moreover, you want all presented numbers to be distinct, that also means that... |
Solve the programming task below in a Python markdown code block.
Little penguin Polo likes permutations. But most of all he likes permutations of integers from 0 to n, inclusive.
For permutation p = p_0, p_1, ..., p_{n}, Polo has defined its beauty — number $(0 \oplus p_{0}) +(1 \oplus p_{1}) + \cdots +(n \oplus p_{... |
Solve the programming task below in a Python markdown code block.
Limak is a little polar bear. He doesn't have many toys and thus he often plays with polynomials.
He considers a polynomial valid if its degree is n and its coefficients are integers not exceeding k by the absolute value. More formally:
Let a0, a1, ..... |
Solve the programming task below in a Python markdown code block.
It is winter now, and Max decided it's about time he watered the garden.
The garden can be represented as n consecutive garden beds, numbered from 1 to n. k beds contain water taps (i-th tap is located in the bed x_{i}), which, if turned on, start deli... |
Solve the programming task below in a Python markdown code block.
You are looking at the floor plan of the Summer Informatics School's new building. You were tasked with SIS logistics, so you really care about travel time between different locations: it is important to know how long it would take to get from the lectu... |
Solve the programming task below in a Python markdown code block.
We have a rectangular grid of squares with H horizontal rows and W vertical columns. Let (i,j) denote the square at the i-th row from the top and the j-th column from the left. On this grid, there is a piece, which is initially placed at square (s_r,s_c... |
Solve the programming task below in a Python markdown code block.
For an array $b$ of length $m$ we define the function $f$ as $ f(b) = \begin{cases} b[1] & \quad \text{if } m = 1 \\ f(b[1] \oplus b[2],b[2] \oplus b[3],\dots,b[m-1] \oplus b[m]) & \quad \text{otherwise,} \end{cases} $
where $\oplus$ is bitwise exclu... |
Solve the programming task below in a Python markdown code block.
At Akabeko Elementary School, all the students participate in a slightly unusual jogging. Students run their own lap courses at their own pace. After going around each of your courses, you will be returned to elementary school. How many laps do they all... |
Solve the programming task below in a Python markdown code block.
Now I have a card with n numbers on it. Consider arranging some or all of these appropriately to make numbers. Find the number obtained by adding all the numbers created at this time.
For example, if you have 1 and 2, you will get 4 numbers 1, 2, 12, 2... |
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 `... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.