question large_stringlengths 265 13.2k |
|---|
Solve the programming task below in a Python markdown code block.
In the spirit of the holidays, Saitama has given Genos two grid paths of length n (a weird gift even by Saitama's standards). A grid path is an ordered sequence of neighbouring squares in an infinite grid. Two squares are neighbouring if they share a si... |
Solve the programming task below in a Python markdown code block.
Beroffice text editor has a wide range of features that help working with text. One of the features is an automatic search for typos and suggestions of how to fix them.
Beroffice works only with small English letters (i.e. with 26 letters from a to z).... |
Solve the programming task below in a Python markdown code block.
A string a of length m is called antipalindromic iff m is even, and for each i (1 ≤ i ≤ m) a_{i} ≠ a_{m} - i + 1.
Ivan has a string s consisting of n lowercase Latin letters; n is even. He wants to form some string t that will be an antipalindromic per... |
Solve the programming task below in a Python markdown code block.
Permutation p is an ordered set of integers p_1, p_2, ..., p_{n}, consisting of n distinct positive integers, each of them doesn't exceed n. We'll denote the i-th element of permutation p as p_{i}. We'll call number n the size or the length of permut... |
Solve the programming task below in a Python markdown code block.
A permutation is a sequence of integers p_1, p_2, ..., p_{n}, consisting of n distinct positive integers, each of them doesn't exceed n. Let's denote the i-th element of permutation p as p_{i}. We'll call number n the size of permutation p_1, p_2, ..., ... |
Solve the programming task below in a Python markdown code block.
N friends of Takahashi has come to a theme park.
To ride the most popular roller coaster in the park, you must be at least K centimeters tall.
The i-th friend is h_i centimeters tall.
How many of the Takahashi's friends can ride the roller coaster?
---... |
Solve the programming task below in a Python markdown code block.
Vasya is choosing a laptop. The shop has n laptops to all tastes.
Vasya is interested in the following properties: processor speed, ram and hdd. Vasya is a programmer and not a gamer which is why he is not interested in all other properties.
If all th... |
Solve the programming task below in a Python markdown code block.
A programming competition site AtCode regularly holds programming contests.
The next contest on AtCode is called ABC, which is rated for contestants with ratings less than 1200.
The contest after the ABC is called ARC, which is rated for contestants wit... |
Solve the programming task below in a Python markdown code block.
You are given integers N and K. Find the number of triples (a,b,c) of positive integers not greater than N such that a+b,b+c and c+a are all multiples of K. The order of a,b,c does matter, and some of them can be the same.
Constraints
* 1 \leq N,K \le... |
Solve the programming task below in a Python markdown code block.
Square1001 has seen an electric bulletin board displaying the integer 1.
He can perform the following operations A and B to change this value:
- Operation A: The displayed value is doubled.
- Operation B: The displayed value increases by K.
Square1001... |
Solve the programming task below in a Python markdown code block.
You have two positive integers w and h. Your task is to count the number of rhombi which have the following properties:
* Have positive area.
* With vertices at integer points.
* All vertices of the rhombi are located inside or on the border o... |
Solve the programming task below in a Python markdown code block.
You are given a binary string of length $n$ (i. e. a string consisting of $n$ characters '0' and '1').
In one move you can swap two adjacent characters of the string. What is the lexicographically minimum possible string you can obtain from the given o... |
Solve the programming task below in a Python markdown code block.
You are given n integers a_1, a_2, ..., a_n, where n is odd. You are allowed to flip the sign of some (possibly all or none) of them. You wish to perform these flips in such a way that the following conditions hold:
1. At least (n - 1)/(2) of the adj... |
Solve the programming task below in a Python markdown code block.
After Fox Ciel got off a bus, she found that the bus she was on was a wrong bus and she lost her way in a strange town. However, she fortunately met her friend Beaver Taro and asked which way to go to her castle. Taro's response to her was a string s, a... |
Solve the programming task below in a Python markdown code block.
You are given a non-empty string s consisting of lowercase English letters. You have to pick exactly one non-empty substring of s and shift all its letters 'z' $\rightarrow$ 'y' $\rightarrow$ 'x' $\rightarrow \ldots \rightarrow$ 'b' $\rightarrow$ 'a' $\... |
Solve the programming task below in a Python markdown code block.
Today, Chef woke up to find that he had no clean socks. Doing laundry is such a turn-off for Chef, that in such a situation, he always buys new socks instead of cleaning the old dirty ones. He arrived at the fashion store with money rupees in his pocket... |
Solve the programming task below in a Python markdown code block.
Given an D-dimension array, where each axis is of length N, your goal is to find the sum of every index in the array starting from 0.
For Example if D=1 and N=10 then the answer would be 45 ([0,1,2,3,4,5,6,7,8,9])
If D=2 and N = 3 the answer is 18 whic... |
Solve the programming task below in a Python markdown code block.
Little Petya often travels to his grandmother in the countryside. The grandmother has a large garden, which can be represented as a rectangle 1 × n in size, when viewed from above. This rectangle is divided into n equal square sections. The garden is ve... |
Solve the programming task below in a Python markdown code block.
Write a function that accepts a string, and returns true if it is in the form of a phone number. Assume that any integer from 0-9 in any of the spots will produce a valid phone number.
Only worry about the following format:
(123) 456-7890 (don't forg... |
Solve the programming task below in a Python markdown code block.
The Happy Farm 5 creators decided to invent the mechanism of cow grazing. The cows in the game are very slow and they move very slowly, it can even be considered that they stand still. However, carnivores should always be chased off them.
For that a y... |
Solve the programming task below in a Python markdown code block.
The ship crashed into a reef and is sinking. Now the entire crew must be evacuated. All n crew members have already lined up in a row (for convenience let's label them all from left to right with positive integers from 1 to n) and await further instruct... |
Solve the programming task below in a Python markdown code block.
When you asked some guy in your class his name, he called himself S, where S is a string of length between 3 and 20 (inclusive) consisting of lowercase English letters. You have decided to choose some three consecutive characters from S and make it his ... |
Solve the programming task below in a Python markdown code block.
Given a string as input, move all of its vowels to the end of the string, in the same order as they were before.
Vowels are (in this kata): `a, e, i, o, u`
Note: all provided input strings are lowercase.
## Examples
```python
"day" ==> "dya"
"app... |
Solve the programming task below in a Python markdown code block.
The Fair Nut found a string $s$. The string consists of lowercase Latin letters. The Nut is a curious guy, so he wants to find the number of strictly increasing sequences $p_1, p_2, \ldots, p_k$, such that: For each $i$ ($1 \leq i \leq k$), $s_{p_i} =... |
Solve the programming task below in a Python markdown code block.
$N$ persons visited a restaurant. The restaurant is open from 0 to $T$. The $i$-th person entered the restaurant at $l_i$ and left at $r_i$. Find the maximum number of persons during the business hours.
Constraints
* $ 1 \leq N \leq 10^5 $
* $ 1 \leq ... |
Solve the programming task below in a Python markdown code block.
When Darth Vader gets bored, he sits down on the sofa, closes his eyes and thinks of an infinite rooted tree where each node has exactly n sons, at that for each node, the distance between it an its i-th left child equals to d_{i}. The Sith Lord loves c... |
Solve the programming task below in a Python markdown code block.
Levko loves tables that consist of n rows and n columns very much. He especially loves beautiful tables. A table is beautiful to Levko if the sum of elements in each row and column of the table equals k.
Unfortunately, he doesn't know any such table. Y... |
Solve the programming task below in a Python markdown code block.
You are given a permutation of 1,2,...,N: p_1,p_2,...,p_N. Determine if the state where p_i=i for every i can be reached by performing the following operation any number of times:
- Choose three elements p_{i-1},p_{i},p_{i+1} (2\leq i\leq N-1) such tha... |
Solve the programming task below in a Python markdown code block.
Alice and Bob are playing a fun game of tree tag.
The game is played on a tree of $n$ vertices numbered from $1$ to $n$. Recall that a tree on $n$ vertices is an undirected, connected graph with $n-1$ edges.
Initially, Alice is located at vertex $a$, ... |
Solve the programming task below in a Python markdown code block.
Polycarp is making a quest for his friends. He has already made n tasks, for each task the boy evaluated how interesting it is as an integer q_{i}, and the time t_{i} in minutes needed to complete the task.
An interesting feature of his quest is: each... |
Solve the programming task below in a Python markdown code block.
Please write a function that sums a list, but ignores any duplicate items in the list.
For instance, for the list [3, 4, 3, 6] , the function should return 10.
Read the inputs from stdin solve the problem and write the answer to stdout (do not directl... |
Solve the programming task below in a Python markdown code block.
This is an easy version of the problem. The actual problems are different, but the easy version is almost a subtask of the hard version. Note that the constraints and the output format are different.
You are given a string $s$ consisting of $n$ lowerca... |
Solve the programming task below in a Python markdown code block.
Let's write a program related to an unsolved math problem called "Happy End Problem". Create a program to find the smallest convex polygon formed by connecting exactly k points from the N points given on the plane. However, after being given the coordin... |
Solve the programming task below in a Python markdown code block.
Bizon the Champion is called the Champion for a reason.
Bizon the Champion has recently got a present — a new glass cupboard with n shelves and he decided to put all his presents there. All the presents can be divided into two types: medals and cups. ... |
Solve the programming task below in a Python markdown code block.
Two foxes Jiro and Saburo are playing a game called 1D Reversi. This game is played on a board, using black and white stones. On the board, stones are placed in a row, and each player places a new stone to either end of the row. Similarly to the origina... |
Solve the programming task below in a Python markdown code block.
Find the minimum prime number greater than or equal to X.
-----Notes-----
A prime number is an integer greater than 1 that cannot be evenly divided by any positive integer except 1 and itself.
For example, 2, 3, and 5 are prime numbers, while 4 and 6 a... |
Solve the programming task below in a Python markdown code block.
Calculate the value of the sum: n mod 1 + n mod 2 + n mod 3 + ... + n mod m. As the result can be very large, you should print the value modulo 10^9 + 7 (the remainder when divided by 10^9 + 7).
The modulo operator a mod b stands for the remainder afte... |
Solve the programming task below in a Python markdown code block.
You are given an array $a$ of length $n$.
You are also given a set of distinct positions $p_1, p_2, \dots, p_m$, where $1 \le p_i < n$. The position $p_i$ means that you can swap elements $a[p_i]$ and $a[p_i + 1]$. You can apply this operation any numb... |
Solve the programming task below in a Python markdown code block.
Little Lesha loves listening to music via his smartphone. But the smartphone doesn't have much memory, so Lesha listens to his favorite songs in a well-known social network InTalk.
Unfortunately, internet is not that fast in the city of Ekaterinozavods... |
Solve the programming task below in a Python markdown code block.
There are two popular keyboard layouts in Berland, they differ only in letters positions. All the other keys are the same. In Berland they use alphabet with 26 letters which coincides with English alphabet.
You are given two strings consisting of 26 di... |
Solve the programming task below in a Python markdown code block.
Many students live in a dormitory. A dormitory is a whole new world of funny amusements and possibilities but it does have its drawbacks.
There is only one shower and there are multiple students who wish to have a shower in the morning. That's why eve... |
Solve the programming task below in a Python markdown code block.
Let's solve the puzzle by programming.
The numbers n x n are arranged in a grid pattern. Some of the numbers are circled and we will call them the starting point. The rules of the puzzle are as follows:
* Draw one line that goes vertically and horizon... |
Solve the programming task below in a Python markdown code block.
In this Kata, you will check if it is possible to convert a string to a palindrome by changing one character.
For instance:
```Haskell
solve ("abbx") = True, because we can convert 'x' to 'a' and get a palindrome.
solve ("abba") = False, because we c... |
Solve the programming task below in a Python markdown code block.
Sasha and Ira are two best friends. But they aren’t just friends, they are software engineers and experts in artificial intelligence. They are developing an algorithm for two bots playing a two-player game. The game is cooperative and turn based. In eac... |
Solve the programming task below in a Python markdown code block.
You are given two arrays $a$ and $b$, both of length $n$.
Let's define a function $f(l, r) = \sum\limits_{l \le i \le r} a_i \cdot b_i$.
Your task is to reorder the elements (choose an arbitrary order of elements) of the array $b$ to minimize the valu... |
Solve the programming task below in a Python markdown code block.
# Let's watch a parade!
## Brief
You're going to watch a parade, but you only care about one of the groups marching. The parade passes through the street where your house is. Your house is at number `location` of the street. Write a function `parade_tim... |
Solve the programming task below in a Python markdown code block.
Transpose means is to interchange rows and columns of a two-dimensional array matrix.
[A^(T)]ij=[A]ji
ie:
Formally, the i th row, j th column element of AT is the j th row, i th column element of A:
Example :
```
[[1,2,3],[4,5,6]].transpose() //sh... |
Solve the programming task below in a Python markdown code block.
Alexandra has an even-length array $a$, consisting of $0$s and $1$s. The elements of the array are enumerated from $1$ to $n$. She wants to remove at most $\frac{n}{2}$ elements (where $n$ — length of array) in the way that alternating sum of the array ... |
Solve the programming task below in a Python markdown code block.
You are given an array a_1, a_2, ..., a_{n} consisting of n integers, and an integer k. You have to split the array into exactly k non-empty subsegments. You'll then compute the minimum integer on each subsegment, and take the maximum integer over the k... |
Solve the programming task below in a Python markdown code block.
As most of you might know already, a prime number is an integer `n` with the following properties:
* it must be greater than 1
* it must be divisible only by itself and 1
And that's it: -15 or 8 are not primes, 5 or 97 are; pretty easy, isn't it?
Wel... |
Solve the programming task below in a Python markdown code block.
In this Kata, you will count the number of times the first string occurs in the second.
```Haskell
solve("zaz","zazapulz") = 4 because they are ZAZapulz, ZAzapulZ, ZazApulZ, zaZApulZ
```
More examples in test cases.
Good luck!
Please also try [Sim... |
Solve the programming task below in a Python markdown code block.
It's finally summer in Chefland! So our chef is looking forward to prepare some of the best "beat-the-heat" dishes to attract more customers. He summons the Wizard of Dessert to help him with one such dish.
The wizard provides the chef with a sequence o... |
Solve the programming task below in a Python markdown code block.
There is an Amidakuji that consists of w vertical bars and has a height (the number of steps to which horizontal bars can be added) of h. w is an even number. Of the candidates for the place to add the horizontal bar of this Amidakuji, the ath from the ... |
Solve the programming task below in a Python markdown code block.
You are given two arithmetic progressions: a_1k + b_1 and a_2l + b_2. Find the number of integers x such that L ≤ x ≤ R and x = a_1k' + b_1 = a_2l' + b_2, for some integers k', l' ≥ 0.
-----Input-----
The only line contains six integers a_1, b_1, a_2... |
Solve the programming task below in a Python markdown code block.
You are given a sequence $a_1, a_2, \dots, a_n$, consisting of integers.
You can apply the following operation to this sequence: choose some integer $x$ and move all elements equal to $x$ either to the beginning, or to the end of $a$. Note that you hav... |
Solve the programming task below in a Python markdown code block.
Suppose you are given a string s of length n consisting of lowercase English letters. You need to compress it using the smallest possible number of coins.
To compress the string, you have to represent s as a concatenation of several non-empty strings: ... |
Solve the programming task below in a Python markdown code block.
Screen resolution of Polycarp's monitor is $a \times b$ pixels. Unfortunately, there is one dead pixel at his screen. It has coordinates $(x, y)$ ($0 \le x < a, 0 \le y < b$). You can consider columns of pixels to be numbered from $0$ to $a-1$, and rows... |
Solve the programming task below in a Python markdown code block.
You have a long stick, consisting of $m$ segments enumerated from $1$ to $m$. Each segment is $1$ centimeter long. Sadly, some segments are broken and need to be repaired.
You have an infinitely long repair tape. You want to cut some pieces from the ta... |
Solve the programming task below in a Python markdown code block.
Little Johnny Bubbles enjoys spending hours in front of his computer playing video games. His favorite game is Bubble Strike, fast-paced bubble shooting online game for two players.
Each game is set in one of the N maps, each having different terrain c... |
Solve the programming task below in a Python markdown code block.
Brief
=====
Sometimes we need information about the list/arrays we're dealing with. You'll have to write such a function in this kata. Your function must provide the following informations:
* Length of the array
* Number of integer items in the array... |
Solve the programming task below in a Python markdown code block.
You are given a tree (an undirected connected acyclic graph) consisting of $n$ vertices and $n - 1$ edges. A number is written on each edge, each number is either $0$ (let's call such edges $0$-edges) or $1$ (those are $1$-edges).
Let's call an ordered... |
Solve the programming task below in a Python markdown code block.
We have a weighted directed graph with N vertices numbered 0 to N-1.
The graph initially has N-1 edges. The i-th edge (0 \leq i \leq N-2) is directed from Vertex i to Vertex i+1 and has a weight of 0.
Snuke will now add a new edge (i → j) for every pa... |
Solve the programming task below in a Python markdown code block.
You are given an array of unique numbers. The numbers represent points. The higher the number the higher the points.
In the array [1,3,2] 3 is the highest point value so it gets 1st place. 2 is the second highest so it gets second place. 1 is the 3rd ... |
Solve the programming task below in a Python markdown code block.
You are given a prime number p, n integers a_1, a_2, …, a_n, and an integer k.
Find the number of pairs of indexes (i, j) (1 ≤ i < j ≤ n) for which (a_i + a_j)(a_i^2 + a_j^2) ≡ k mod p.
Input
The first line contains integers n, p, k (2 ≤ n ≤ 3 ⋅ 10^... |
Solve the programming task below in a Python markdown code block.
The goal is to write a pair of functions the first of which will take a string of binary along with a specification of bits, which will return a numeric, signed complement in two's complement format. The second will do the reverse. It will take in an in... |
Solve the programming task below in a Python markdown code block.
You and your friend are participating in a TV show "Run For Your Prize".
At the start of the show n prizes are located on a straight line. i-th prize is located at position a_{i}. Positions of all prizes are distinct. You start at position 1, your frie... |
Solve the programming task below in a Python markdown code block.
The fearless Ikta has finally hunted down the infamous Count Big Bridge! Count Bigbridge is now trapped in a rectangular room w meters wide and h meters deep, waiting for his end.
If you select a corner of the room and take the coordinate system so tha... |
Solve the programming task below in a Python markdown code block.
# Background
My TV remote control has arrow buttons and an `OK` button.
I can use these to move a "cursor" on a logical screen keyboard to type "words"...
The screen "keyboard" layout looks like this
#tvkb {
width : 300px;
border: 5px sol... |
Solve the programming task below in a Python markdown code block.
The circle line of the Roflanpolis subway has $n$ stations.
There are two parallel routes in the subway. The first one visits stations in order $1 \to 2 \to \ldots \to n \to 1 \to 2 \to \ldots$ (so the next stop after station $x$ is equal to $(x+1)$ if... |
Solve the programming task below in a Python markdown code block.
Orac is studying number theory, and he is interested in the properties of divisors.
For two positive integers $a$ and $b$, $a$ is a divisor of $b$ if and only if there exists an integer $c$, such that $a\cdot c=b$.
For $n \ge 2$, we will denote as $f(... |
Solve the programming task below in a Python markdown code block.
<image>
You can preview the image in better quality by the link: [http://assets.codeforces.com/files/656/without-text.png](//assets.codeforces.com/files/656/without-text.png)
Input
The only line of the input is a string (between 1 and 50 characters l... |
Solve the programming task below in a Python markdown code block.
Grigoriy, like the hero of one famous comedy film, found a job as a night security guard at the museum. At first night he received embosser and was to take stock of the whole exposition.
Embosser is a special devise that allows to "print" the text of a... |
Solve the programming task below in a Python markdown code block.
Nastya received one more array on her birthday, this array can be used to play a traditional Byteland game on it. However, to play the game the players should first select such a subsegment of the array that $\frac{p}{s} = k$, where p is the product of ... |
Solve the programming task below in a Python markdown code block.
Tonight is brain dinner night and all zombies will gather together to scarf down some delicious brains. The artful Heidi plans to crash the party, incognito, disguised as one of them. Her objective is to get away with at least one brain, so she can anal... |
Solve the programming task below in a Python markdown code block.
Takahashi and Aoki will take N exams numbered 1 to N. They have decided to compete in these exams. The winner will be determined as follows:
* For each exam i, Takahashi decides its importance c_i, which must be an integer between l_i and u_i (inclusiv... |
Solve the programming task below in a Python markdown code block.
Takahashi has decided to give a string to his mother.
The value of a string T is the length of the longest common subsequence of T and T', where T' is the string obtained by reversing T. That is, the value is the longest length of the following two str... |
Solve the programming task below in a Python markdown code block.
Since most contestants do not read this part, I have to repeat that Bitlandians are quite weird. They have their own jobs, their own working method, their own lives, their own sausages and their own games!
Since you are so curious about Bitland, I'll g... |
Solve the programming task below in a Python markdown code block.
Lеt's create function to play cards. Our rules:
We have the preloaded `deck`:
```
deck = ['joker','2♣','3♣','4♣','5♣','6♣','7♣','8♣','9♣','10♣','J♣','Q♣','K♣','A♣',
'2♦','3♦','4♦','5♦','6♦','7♦','8♦','9♦','10♦','J♦','Q♦','K♦','A♦',
... |
Solve the programming task below in a Python markdown code block.
A non-empty string is called palindrome, if it reads the same from the left to the right and from the right to the left. For example, "abcba", "a", and "abba" are palindromes, while "abab" and "xy" are not.
A string is called a substring of another str... |
Solve the programming task below in a Python markdown code block.
This is the performance version of [this kata](https://www.codewars.com/kata/59afff65f1c8274f270020f5).
---
Imagine two rings with numbers on them. The inner ring spins clockwise and the outer ring spins anti-clockwise. We start with both rings aligne... |
Solve the programming task below in a Python markdown code block.
Consider a 32-bit real type with 7 bits from the right as the decimal part, the following 24 bits as the integer part, and the leftmost 1 bit as the sign part as shown below (b1, ..., b32). Represents 0 or 1).
<image>
To translate this format into a ... |
Solve the programming task below in a Python markdown code block.
You are given an integer N. Consider an infinite N-ary tree as shown below:
<image>
Figure: an infinite N-ary tree for the case N = 3
As shown in the figure, each vertex is indexed with a unique positive integer, and for every positive integer there ... |
Solve the programming task below in a Python markdown code block.
You are given a number $n$ (divisible by $3$) and an array $a[1 \dots n]$. In one move, you can increase any of the array elements by one. Formally, you choose the index $i$ ($1 \le i \le n$) and replace $a_i$ with $a_i + 1$. You can choose the same ind... |
Solve the programming task below in a Python markdown code block.
Have a look at the following numbers.
```
n | score
---+-------
1 | 50
2 | 150
3 | 300
4 | 500
5 | 750
```
Can you find a pattern in it? If so, then write a function `getScore(n)`/`get_score(n)`/`GetScore(n)` which returns the score for any... |
Solve the programming task below in a Python markdown code block.
There is a very long bench. The bench is divided into M sections, where M is a very large integer.
Initially, the bench is vacant. Then, M people come to the bench one by one, and perform the following action:
* We call a section comfortable if the se... |
Solve the programming task below in a Python markdown code block.
[Chopsticks (singular: chopstick) are short, frequently tapered sticks used in pairs of equal length, which are used as the traditional eating utensils of China, Japan, Korea and Vietnam. Originated in ancient China, they can also be found in some areas... |
Solve the programming task below in a Python markdown code block.
It is nighttime and Joe the Elusive got into the country's main bank's safe. The safe has n cells positioned in a row, each of them contains some amount of diamonds. Let's make the problem more comfortable to work with and mark the cells with positive n... |
Solve the programming task below in a Python markdown code block.
Problem statement
There is a tree consisting of $ N $ vertices $ N-1 $ edges, and the $ i $ th edge connects the $ u_i $ and $ v_i $ vertices.
Each vertex has a button, and the button at the $ i $ th vertex is called the button $ i $.
First, the beau... |
Solve the programming task below in a Python markdown code block.
You are given an integer x of n digits a_1, a_2, …, a_n, which make up its decimal notation in order from left to right.
Also, you are given a positive integer k < n.
Let's call integer b_1, b_2, …, b_m beautiful if b_i = b_{i+k} for each i, such that... |
Solve the programming task below in a Python markdown code block.
You are given array a with n elements and the number m. Consider some subsequence of a and the value of least common multiple (LCM) of its elements. Denote LCM as l. Find any longest subsequence of a with the value l ≤ m.
A subsequence of a is an array... |
Solve the programming task below in a Python markdown code block.
Denis, after buying flowers and sweets (you will learn about this story in the next task), went to a date with Nastya to ask her to become a couple. Now, they are sitting in the cafe and finally... Denis asks her to be together, but ... Nastya doesn't g... |
Solve the programming task below in a Python markdown code block.
n children are standing in a circle and playing a game. Children's numbers in clockwise order form a permutation a_1, a_2, ..., a_{n} of length n. It is an integer sequence such that each integer from 1 to n appears exactly once in it.
The game consist... |
Solve the programming task below in a Python markdown code block.
Consider a long corridor which can be divided into $n$ square cells of size $1 \times 1$. These cells are numbered from $1$ to $n$ from left to right.
There are two people in this corridor, a hooligan and a security guard. Initially, the hooligan is in... |
Solve the programming task below in a Python markdown code block.
It is well known that Berland has n cities, which form the Silver ring — cities i and i + 1 (1 ≤ i < n) are connected by a road, as well as the cities n and 1. The goverment have decided to build m new roads. The list of the roads to build was prepared.... |
Solve the programming task below in a Python markdown code block.
There are two rectangles whose bases are parallel to the x-axis. Read the lower left coordinates (xa1, ya1) and upper right coordinates (xa2, ya2) of rectangle A, the lower left coordinates (xb1, yb1) and upper right coordinates (xb2, yb2) of rectangle ... |
Solve the programming task below in a Python markdown code block.
Let us call a pair of integer numbers m-perfect, if at least one number in the pair is greater than or equal to m. Thus, the pairs (3, 3) and (0, 2) are 2-perfect while the pair (-1, 1) is not.
Two integers x, y are written on the blackboard. It is all... |
Solve the programming task below in a Python markdown code block.
На тренировку по подготовке к соревнованиям по программированию пришли n команд. Тренер для каждой команды подобрал тренировку, комплект задач для i-й команды занимает a_{i} страниц. В распоряжении тренера есть x листов бумаги, у которых обе стороны чис... |
Solve the programming task below in a Python markdown code block.
Takahashi is playing with N cards.
The i-th card has an integer X_i on it.
Takahashi is trying to create as many pairs of cards as possible satisfying one of the following conditions:
* The integers on the two cards are the same.
* The sum of the int... |
Solve the programming task below in a Python markdown code block.
There are N squares arranged in a row from left to right. The height of the i-th square from the left is H_i.
For each square, you will perform either of the following operations once:
- Decrease the height of the square by 1.
- Do nothing.
Determine ... |
Solve the programming task below in a Python markdown code block.
Given are an N \times N matrix and an integer K. The entry in the i-th row and j-th column of this matrix is denoted as a_{i, j}. This matrix contains each of 1, 2, \dots, N^2 exactly once.
Sigma can repeat the following two kinds of operation arbitrari... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.