question large_stringlengths 265 13.2k |
|---|
Solve the programming task below in a Python markdown code block.
Integral numbers can be even or odd.
Even numbers satisfy `n = 2m` ( with `m` also integral ) and we will ( completely arbitrarily ) think of odd numbers as `n = 2m + 1`.
Now, some odd numbers can be more odd than others: when for some `n`, `m` is mo... |
Solve the programming task below in a Python markdown code block.
Quite recently, a very smart student named Jury decided that lectures are boring, so he downloaded a game called "Black Square" on his super cool touchscreen phone.
In this game, the phone's screen is divided into four vertical strips. Each second, a b... |
Solve the programming task below in a Python markdown code block.
Little Petya likes numbers a lot. He found that number 123 in base 16 consists of two digits: the first is 7 and the second is 11. So the sum of digits of 123 in base 16 is equal to 18.
Now he wonders what is an average value of sum of digits of the nu... |
Solve the programming task below in a Python markdown code block.
# Task
John is a programmer. He treasures his time very much. He lives on the `n` floor of a building. Every morning he will go downstairs as quickly as possible to begin his great work today.
There are two ways he goes downstairs: walking or taking t... |
Solve the programming task below in a Python markdown code block.
Ania has a large integer $S$. Its decimal representation has length $n$ and doesn't contain any leading zeroes. Ania is allowed to change at most $k$ digits of $S$. She wants to do it in such a way that $S$ still won't contain any leading zeroes and it'... |
Solve the programming task below in a Python markdown code block.
Difference of Big Integers
Given two integers $A$ and $B$, compute the difference, $A - B$.
Input
Two integers $A$ and $B$ separated by a space character are given in a line.
Output
Print the difference in a line.
Constraints
* $-1 \times 10^{100... |
Solve the programming task below in a Python markdown code block.
The weight of a sequence is defined as the number of unordered pairs of indexes $(i,j)$ (here $i \lt j$) with same value ($a_{i} = a_{j}$). For example, the weight of sequence $a = [1, 1, 2, 2, 1]$ is $4$. The set of unordered pairs of indexes with same... |
Solve the programming task below in a Python markdown code block.
For a permutation P[1... N] of integers from 1 to N, function f is defined as follows:
$f(i, j) = \left\{\begin{array}{ll}{P [ i ]} & {\text{if} j = 1} \\{f(P [ i ], j - 1)} & {\text{otherwise}} \end{array} \right.$
Let g(i) be the minimum positive ... |
Solve the programming task below in a Python markdown code block.
You'll be given a string, and have to return the total of all the unicode characters as an int. Should be able to handle any characters sent at it.
examples:
uniTotal("a") == 97
uniTotal("aaa") == 291
Write your solution by modifying this code:
```... |
Solve the programming task below in a Python markdown code block.
There are two bus stops denoted A and B, and there n buses that go from A to B every day. The shortest path from A to B takes t units of time but some buses might take longer paths. Moreover, buses are allowed to overtake each other during the route.
A... |
Solve the programming task below in a Python markdown code block.
##Task:
You have to write a function **pattern** which creates the following pattern upto n number of rows.
* If the Argument is 0 or a Negative Integer then it should return "" i.e. empty string.
* If any odd number is passed as argument then the p... |
Solve the programming task below in a Python markdown code block.
One day, Taro received a strange email with only the number "519345213244" in the text. The email was from my cousin, who was 10 years older than me, so when I called and asked, "Oh, I sent it with a pocket bell because I was in a hurry. It's convenient... |
Solve the programming task below in a Python markdown code block.
The only difference between easy and hard versions is that you should complete all the projects in easy version but this is not necessary in hard version.
Polycarp is a very famous freelancer. His current rating is $r$ units.
Some very rich customers ... |
Solve the programming task below in a Python markdown code block.
[3R2 as DJ Mashiro - Happiness Breeze](https://open.spotify.com/track/2qGqK8GRS65Wlf20qUBEak)
[Ice - DJ Mashiro is dead or alive](https://soundcloud.com/iceloki/dj-mashiro-is-dead-or-alive)
NEKO#ΦωΦ has just got a new maze game on her PC!
The game's ... |
Solve the programming task below in a Python markdown code block.
Complete the function that takes 3 numbers `x, y and k` (where `x ≤ y`), and returns the number of integers within the range `[x..y]` (both ends included) that are divisible by `k`.
More scientifically: `{ i : x ≤ i ≤ y, i mod k = 0 }`
## Example
G... |
Solve the programming task below in a Python markdown code block.
A newspaper is published in Walrusland. Its heading is s1, it consists of lowercase Latin letters. Fangy the little walrus wants to buy several such newspapers, cut out their headings, glue them one to another in order to get one big string. After that ... |
Solve the programming task below in a Python markdown code block.
Ksenia has ordinary pan scales and several weights of an equal mass. Ksenia has already put some weights on the scales, while other weights are untouched. Ksenia is now wondering whether it is possible to put all the remaining weights on the scales so t... |
Solve the programming task below in a Python markdown code block.
Mancala is a game famous in the Middle East. It is played on a board that consists of 14 holes. [Image]
Initially, each hole has $a_i$ stones. When a player makes a move, he chooses a hole which contains a positive number of stones. He takes all the ... |
Solve the programming task below in a Python markdown code block.
Roman and Denis are on the trip to the programming competition. Since the trip was long, they soon got bored, and hence decided to came up with something. Roman invented a pizza's recipe, while Denis invented a string multiplication. According to Denis,... |
Solve the programming task below in a Python markdown code block.
Several ages ago Berland was a kingdom. The King of Berland adored math. That's why, when he first visited one of his many palaces, he first of all paid attention to the floor in one hall. The floor was tiled with hexagonal tiles.
The hall also turned ... |
Solve the programming task below in a Python markdown code block.
$n$ people gathered to hold a jury meeting of the upcoming competition, the $i$-th member of the jury came up with $a_i$ tasks, which they want to share with each other.
First, the jury decides on the order which they will follow while describing the t... |
Solve the programming task below in a Python markdown code block.
You are a paparazzi working in Manhattan.
Manhattan has r south-to-north streets, denoted by numbers 1, 2,…, r in order from west to east, and r west-to-east streets, denoted by numbers 1,2,…,r in order from south to north. Each of the r south-to-north... |
Solve the programming task below in a Python markdown code block.
Given a permutation $p$ of length $n$, find its subsequence $s_1$, $s_2$, $\ldots$, $s_k$ of length at least $2$ such that: $|s_1-s_2|+|s_2-s_3|+\ldots+|s_{k-1}-s_k|$ is as big as possible over all subsequences of $p$ with length at least $2$. Among a... |
Solve the programming task below in a Python markdown code block.
We have N sticks with negligible thickness.
The length of the i-th stick is A_i.
Snuke wants to select four different sticks from these sticks and form a rectangle (including a square), using the sticks as its sides.
Find the maximum possible area of th... |
Solve the programming task below in a Python markdown code block.
Consider the following series:
`1, 2, 4, 8, 16, 22, 26, 38, 62, 74, 102, 104, 108, 116, 122`
It is generated as follows:
* For single digit integers, add the number to itself to get the next element.
* For other integers, multiply all the non-zero di... |
Solve the programming task below in a Python markdown code block.
You take your son to the forest to see the monkeys. You know that there are a certain number there (n), but your son is too young to just appreciate the full number, he has to start counting them from 1.
As a good parent, you will sit and count with hi... |
Solve the programming task below in a Python markdown code block.
Galois is one of the strongest chess players of Byteforces. He has even invented a new variant of chess, which he named «PawnChess».
This new game is played on a board consisting of 8 rows and 8 columns. At the beginning of every game some black and wh... |
Solve the programming task below in a Python markdown code block.
Write a program which finds a pattern $p$ in a ring shaped text $s$.
<image>
Constraints
* $1 \leq $ length of $p \leq $ length of $s \leq 100$
* $s$ and $p$ consists of lower-case letters
Input
In the first line, the text $s$ is given.
In the sec... |
Solve the programming task below in a Python markdown code block.
Let $f(i)$ denote the minimum positive integer $x$ such that $x$ is not a divisor of $i$.
Compute $\sum_{i=1}^n f(i)$ modulo $10^9+7$. In other words, compute $f(1)+f(2)+\dots+f(n)$ modulo $10^9+7$.
-----Input-----
The first line contains a single i... |
Solve the programming task below in a Python markdown code block.
The Third Doctor Who once correctly said that travel between parallel universes is "like travelling sideways". However, he incorrectly thought that there were infinite parallel universes, whereas in fact, as we now all know, there will never be more tha... |
Solve the programming task below in a Python markdown code block.
Notes
Template in C
Constraints
2 ≤ the number of operands in the expression ≤ 100
1 ≤ the number of operators in the expression ≤ 99
-1 × 109 ≤ values in the stack ≤ 109
Input
An expression is given in a line. Two consequtive symbols (operand or o... |
Solve the programming task below in a Python markdown code block.
Santa Claus decided to disassemble his keyboard to clean it. After he returned all the keys back, he suddenly realized that some pairs of keys took each other's place! That is, Santa suspects that each key is either on its place, or on the place of anot... |
Solve the programming task below in a Python markdown code block.
Petya works as a PR manager for a successful Berland company BerSoft. He needs to prepare a presentation on the company income growth since 2001 (the year of its founding) till now. Petya knows that in 2001 the company income amounted to a1 billion bour... |
Solve the programming task below in a Python markdown code block.
Problem Statement
Mr. Takatsuki, who is planning to participate in the Aizu training camp, is enthusiastic about studying and has been studying English recently. She tries to learn as many English words as possible by playing the following games on her... |
Solve the programming task below in a Python markdown code block.
You have a robot that can move along a number line. At time moment $0$ it stands at point $0$.
You give $n$ commands to the robot: at time $t_i$ seconds you command the robot to go to point $x_i$. Whenever the robot receives a command, it starts moving... |
Solve the programming task below in a Python markdown code block.
Arkadiy has lots square photos with size a × a. He wants to put some of them on a rectangular wall with size h × w.
The photos which Arkadiy will put on the wall must form a rectangular grid and the distances between neighboring vertically and horizon... |
Solve the programming task below in a Python markdown code block.
Misha was interested in water delivery from childhood. That's why his mother sent him to the annual Innovative Olympiad in Irrigation (IOI). Pupils from all Berland compete there demonstrating their skills in watering. It is extremely expensive to host ... |
Solve the programming task below in a Python markdown code block.
You are given a sequence $a=[a_1,a_2,\dots,a_n]$ consisting of $n$ positive integers.
Let's call a group of consecutive elements a segment. Each segment is characterized by two indices: the index of its left end and the index of its right end. Denote b... |
Solve the programming task below in a Python markdown code block.
1000000000000001 dogs suddenly appeared under the roof of Roger's house, all of which he decided to keep. The dogs had been numbered 1 through 1000000000000001, but he gave them new names, as follows:
- the dogs numbered 1,2,\cdots,26 were respectively... |
Solve the programming task below in a Python markdown code block.
Move every letter in the provided string forward 10 letters through the alphabet.
If it goes past 'z', start again at 'a'.
Input will be a string with length > 0.
Write your solution by modifying this code:
```python
def move_ten(st):
```
Your so... |
Solve the programming task below in a Python markdown code block.
Little Bolek has found a picture with n mountain peaks painted on it. The n painted peaks are represented by a non-closed polyline, consisting of 2n segments. The segments go through 2n + 1 points with coordinates (1, y1), (2, y2), ..., (2n + 1, y2n + 1... |
Solve the programming task below in a Python markdown code block.
## Task:
You have to write a function `pattern` which returns the following Pattern(See Pattern & Examples) upto `n` number of rows.
* Note:`Returning` the pattern is not the same as `Printing` the pattern.
#### Rules/Note:
* If `n < 1` then it shoul... |
Solve the programming task below in a Python markdown code block.
As it's the first of April, Heidi is suspecting that the news she reads today are fake, and she does not want to look silly in front of all the contestants. She knows that a newspiece is fake if it contains heidi as a subsequence. Help Heidi assess whet... |
Solve the programming task below in a Python markdown code block.
In your garden, there is a long and narrow flowerbed that stretches infinitely to the east. You have decided to plant N kinds of flowers in this empty flowerbed. For convenience, we will call these N kinds of flowers Flower 1, 2, …, N. Also, we will cal... |
Solve the programming task below in a Python markdown code block.
C --Misawa's rooted tree
Problem Statement
You noticed that your best friend Misawa's birthday was near, and decided to give him a rooted binary tree as a gift. Here, the rooted binary tree has the following graph structure. (Figure 1)
* Each vertex ... |
Solve the programming task below in a Python markdown code block.
The fundamental idea in the JPEG compression algorithm is to sort coeffi- cient of given image by zigzag path and encode it. In this problem, we don’t discuss about details of the algorithm, but you are asked to make simple pro- gram. You are given sing... |
Solve the programming task below in a Python markdown code block.
The bear decided to store some raspberry for the winter. He cunningly found out the price for a barrel of honey in kilos of raspberry for each of the following n days. According to the bear's data, on the i-th (1 ≤ i ≤ n) day, the price for one barrel o... |
Solve the programming task below in a Python markdown code block.
In this kata you will have to modify a sentence so it meets the following rules:
convert every word backwards that is:
longer than 6 characters
OR
has 2 or more 'T' or 't' in it
convert every word uppercase that is:
exactly 2 charact... |
Solve the programming task below in a Python markdown code block.
You are an all-powerful being and you have created a rectangular world. In fact, your world is so bland that it could be represented by a r × c grid. Each cell on the grid represents a country. Each country has a dominant religion. There are only two re... |
Solve the programming task below in a Python markdown code block.
The number 105 is quite special - it is odd but still it has eight divisors.
Now, your task is this: how many odd numbers with exactly eight positive divisors are there between 1 and N (inclusive)?
-----Constraints-----
- N is an integer between 1 and... |
Solve the programming task below in a Python markdown code block.
You are given a positive integer N. Find the number of the pairs of integers u and v (0≦u,v≦N) such that there exist two non-negative integers a and b satisfying a xor b=u and a+b=v. Here, xor denotes the bitwise exclusive OR. Since it can be extremely ... |
Solve the programming task below in a Python markdown code block.
You are given an array $a_1, a_2, \dots , a_n$ consisting of integers from $0$ to $9$. A subarray $a_l, a_{l+1}, a_{l+2}, \dots , a_{r-1}, a_r$ is good if the sum of elements of this subarray is equal to the length of this subarray ($\sum\limits_{i=l}^{... |
Solve the programming task below in a Python markdown code block.
Once again Tavas started eating coffee mix without water! Keione told him that it smells awful, but he didn't stop doing that. That's why Keione told his smart friend, SaDDas to punish him! SaDDas took Tavas' headphones and told him: "If you solve the f... |
Solve the programming task below in a Python markdown code block.
*This kata is based on [Project Euler Problem #349](https://projecteuler.net/problem=349). You may want to start with solving [this kata](https://www.codewars.com/kata/langtons-ant) first.*
---
[Langton's ant](https://en.wikipedia.org/wiki/Langton%27s... |
Solve the programming task below in a Python markdown code block.
You are given a string $s$, consisting of $n$ letters, each letter is either 'a' or 'b'. The letters in the string are numbered from $1$ to $n$.
$s[l; r]$ is a continuous substring of letters from index $l$ to $r$ of the string inclusive.
A string is ... |
Solve the programming task below in a Python markdown code block.
Wabbit is trying to move a box containing food for the rest of the zoo in the coordinate plane from the point $(x_1,y_1)$ to the point $(x_2,y_2)$.
He has a rope, which he can use to pull the box. He can only pull the box if he stands exactly $1$ unit ... |
Solve the programming task below in a Python markdown code block.
You have a permutation: an array $a = [a_1, a_2, \ldots, a_n]$ of distinct integers from $1$ to $n$. The length of the permutation $n$ is odd.
Consider the following algorithm of sorting the permutation in increasing order.
A helper procedure of the a... |
Solve the programming task below in a Python markdown code block.
JAG-channel
Nathan O. Davis operates an electronic bulletin board called JAG-channel. He is currently working on adding a new feature called Thread View.
Like many other electronic bulletin boards, JAG-channel is thread-based. Here, a thread refers to... |
Solve the programming task below in a Python markdown code block.
Rudolf is on his way to the castle. Before getting into the castle, the security staff asked him a question:
Given two binary numbers $a$ and $b$ of length $n$. How many different ways of swapping two digits in $a$ (only in $a$, not $b$) so that bitwis... |
Solve the programming task below in a Python markdown code block.
Ivan wants to make a necklace as a present to his beloved girl. A necklace is a cyclic sequence of beads of different colors. Ivan says that necklace is beautiful relative to the cut point between two adjacent beads, if the chain of beads remaining afte... |
Solve the programming task below in a Python markdown code block.
One day Dima and Alex had an argument about the price and quality of laptops. Dima thinks that the more expensive a laptop is, the better it is. Alex disagrees. Alex thinks that there are two laptops, such that the price of the first laptop is less (str... |
Solve the programming task below in a Python markdown code block.
The new PIN is hard to remember. I was told that I shouldn't take notes, but I don't think I can remember them. Therefore, I decided to embed a numerical value in the text and make a note of the PIN. Here, the sum of all the numbers is the PIN.
Create ... |
Solve the programming task below in a Python markdown code block.
An array is called beautiful if all the elements in the array are equal.
You can transform an array using the following steps any number of times:
1. Choose two indices i and j (1 ≤ i,j ≤ n), and an integer x (1 ≤ x ≤ a_i). Let i be the source inde... |
Solve the programming task below in a Python markdown code block.
Complete the method which returns the number which is most frequent in the given input array. If there is a tie for most frequent number, return the largest number among them.
Note: no empty arrays will be given.
## Examples
```
[12, 10, 8, 12, 7, 6... |
Solve the programming task below in a Python markdown code block.
According to rules of the Berland fashion, a jacket should be fastened by all the buttons except only one, but not necessarily it should be the last one. Also if the jacket has only one button, it should be fastened, so the jacket will not swinging open... |
Solve the programming task below in a Python markdown code block.
You have a sequence $a$ with $n$ elements $1, 2, 3, \dots, k - 1, k, k - 1, k - 2, \dots, k - (n - k)$ ($k \le n < 2k$).
Let's call as inversion in $a$ a pair of indices $i < j$ such that $a[i] > a[j]$.
Suppose, you have some permutation $p$ of size $... |
Solve the programming task below in a Python markdown code block.
Snuke is interested in strings that satisfy the following conditions:
* The length of the string is at least N.
* The first N characters equal to the string s.
* The last N characters equal to the string t.
Find the length of the shortest string tha... |
Solve the programming task below in a Python markdown code block.
There are two sisters Alice and Betty. You have $n$ candies. You want to distribute these $n$ candies between two sisters in such a way that: Alice will get $a$ ($a > 0$) candies; Betty will get $b$ ($b > 0$) candies; each sister will get some intege... |
Solve the programming task below in a Python markdown code block.
You are given two sorted arrays that contain only integers. Your task is to find a way to merge them into a single one, sorted in **ascending order**. Complete the function `mergeArrays(arr1, arr2)`, where `arr1` and `arr2` are the original sorted array... |
Solve the programming task below in a Python markdown code block.
Mayor of city S just hates trees and lawns. They take so much space and there could be a road on the place they occupy!
The Mayor thinks that one of the main city streets could be considerably widened on account of lawn nobody needs anyway. Moreover, t... |
Solve the programming task below in a Python markdown code block.
There are N boxes arranged in a row from left to right. The i-th box from the left contains A_i candies.
You will take out the candies from some consecutive boxes and distribute them evenly to M children.
Such being the case, find the number of the pair... |
Solve the programming task below in a Python markdown code block.
In his publication Liber Abaci Leonardo Bonacci, aka Fibonacci, posed a problem involving a population of idealized rabbits. These rabbits bred at a fixed rate, matured over the course of one month, had unlimited resources, and were immortal.
Beginning... |
Solve the programming task below in a Python markdown code block.
Some time ago Lesha found an entertaining string $s$ consisting of lowercase English letters. Lesha immediately developed an unique algorithm for this string and shared it with you. The algorithm is as follows.
Lesha chooses an arbitrary (possibly zero... |
Solve the programming task below in a Python markdown code block.
Unlucky year in Berland is such a year that its number n can be represented as n = x^{a} + y^{b}, where a and b are non-negative integer numbers.
For example, if x = 2 and y = 3 then the years 4 and 17 are unlucky (4 = 2^0 + 3^1, 17 = 2^3 + 3^2 = 2^4 ... |
Solve the programming task below in a Python markdown code block.
A restaurant received n orders for the rental. Each rental order reserve the restaurant for a continuous period of time, the i-th order is characterized by two time values — the start time l_{i} and the finish time r_{i} (l_{i} ≤ r_{i}).
Restaurant man... |
Solve the programming task below in a Python markdown code block.
You have a set of four (4) balls labeled with different numbers: ball_1 (1), ball_2 (2), ball_3 (3) and ball(4) and we have 3 equal boxes for distribute them. The possible combinations of the balls, without having empty boxes, are:
```
(1) ... |
Solve the programming task below in a Python markdown code block.
You are standing on top of an amazing Himalayan mountain. The view is absolutely breathtaking! you want to take a picture on your phone, but... your memory is full again! ok, time to sort through your shuffled photos and make some space...
Given a gall... |
Solve the programming task below in a Python markdown code block.
You are given an n × m table, consisting of characters «A», «G», «C», «T». Let's call a table nice, if every 2 × 2 square contains all four distinct characters. Your task is to find a nice table (also consisting of «A», «G», «C», «T»), that differs from... |
Solve the programming task below in a Python markdown code block.
The new ITone 6 has been released recently and George got really keen to buy it. Unfortunately, he didn't have enough money, so George was going to work as a programmer. Now he faced the following problem at the work.
Given a sequence of n integers p_1... |
Solve the programming task below in a Python markdown code block.
# Task
A robot is standing at the `(0, 0)` point of the Cartesian plane and is oriented towards the vertical (y) axis in the direction of increasing y values (in other words, he's facing up, or north). The robot executes several commands each of which ... |
Solve the programming task below in a Python markdown code block.
How much bigger is a 16-inch pizza compared to an 8-inch pizza? A more pragmatic question is: How many 8-inch pizzas "fit" in a 16-incher?
The answer, as it turns out, is exactly four 8-inch pizzas. For sizes that don't correspond to a round number of ... |
Solve the programming task below in a Python markdown code block.
Let's define `increasing` numbers as the numbers whose digits, read from left to right, are never less than the previous ones: 234559 is an example of increasing number.
Conversely, `decreasing` numbers have all the digits read from left to right so th... |
Solve the programming task below in a Python markdown code block.
Two players decided to play one interesting card game.
There is a deck of $n$ cards, with values from $1$ to $n$. The values of cards are pairwise different (this means that no two different cards have equal values). At the beginning of the game, the d... |
Solve the programming task below in a Python markdown code block.
Problem
Given a permutation of length $ N $ $ P = \\ {P_1, P_2, \ ldots, P_N \\} $ and the integer $ K $.
Determine if the permutation $ P $ can be monotonically increased by repeating the following operation any number of times $ 0 $ or more.
* Choos... |
Solve the programming task below in a Python markdown code block.
Read problems statements in Mandarin Chinese and Russian.
Recently Chef has decided to make some changes in our beloved Codechef. As you know, each problem at Codechef has its memory and time limits. To make problems even more challenging, he decided... |
Solve the programming task below in a Python markdown code block.
Example
Input
3
aab
czc
baa
Output
aac
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.
Let's call an array consisting of n integer numbers a_1, a_2, ..., a_{n}, beautiful if it has the following property:
consider all pairs of numbers x, y (x ≠ y), such that number x occurs in the array a and number y occurs in the array a; for each p... |
Solve the programming task below in a Python markdown code block.
A string S of an odd length is said to be a strong palindrome if and only if all of the following conditions are satisfied:
- S is a palindrome.
- Let N be the length of S. The string formed by the 1-st through ((N-1)/2)-th characters of S is a palind... |
Solve the programming task below in a Python markdown code block.
Everyone loves a freebie. Especially students.
It is well-known that if in the night before exam a student opens window, opens the student's record-book and shouts loudly three times "Fly, freebie, fly!" — then flown freebie helps him to pass the upcom... |
Solve the programming task below in a Python markdown code block.
Write a program which print coordinates $(x_i, y_i)$ of given $n$ points on the plane by the following criteria.
1. first by $x$-coordinate
2. in case of a tie, by $y$-coordinate
Constraints
* $1 \leq n \leq 100,000$
* $-1,000,000,000 \leq x_i, y_i \... |
Solve the programming task below in a Python markdown code block.
Motorist Kojiro spent 10 years saving up for his favorite car brand, Furrari. Finally Kojiro's dream came true! Kojiro now wants to get to his girlfriend Johanna to show off his car to her.
Kojiro wants to get to his girlfriend, so he will go to her al... |
Solve the programming task below in a Python markdown code block.
There are N cities. There are also K roads and L railways, extending between the cities. The i-th road bidirectionally connects the p_i-th and q_i-th cities, and the i-th railway bidirectionally connects the r_i-th and s_i-th cities. No two roads connec... |
Solve the programming task below in a Python markdown code block.
Vasily the bear has got a sequence of positive integers a_1, a_2, ..., a_{n}. Vasily the Bear wants to write out several numbers on a piece of paper so that the beauty of the numbers he wrote out was maximum.
The beauty of the written out numbers b_1,... |
Solve the programming task below in a Python markdown code block.
A string t is called an anagram of the string s, if it is possible to rearrange letters in t so that it is identical to the string s. For example, the string "aab" is an anagram of the string "aba" and the string "aaa" is not.
The string t is called a ... |
Solve the programming task below in a Python markdown code block.
Scheme? - Too loudly said. Just a new idea. Now Chef is expanding his business. He wants to make some new restaurants in the big city of Lviv. To make his business competitive he should interest customers. Now he knows how. But don't tell anyone - it i... |
Solve the programming task below in a Python markdown code block.
In the world of birding there are four-letter codes for the common names of birds. These codes are created by some simple rules:
* If the bird's name has only one word, the code takes the first four letters of that word.
* If the name is made up of tw... |
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.
You are given an array consisting of $n$ integers $a_1$, $a_2$, ..., $a_n$. Initially $a_x = 1$, all other elements are equal to $0$.
You have to perform $m$ operations. During the $i$-th operation, you choose two indices $c$ and $d$ such that $l_i \le... |
Solve the programming task below in a Python markdown code block.
Hardutta is planning an inter college football league. He has invited n teams, including our own team from BPHC. Now, one of the organizers Ramehta was hell bent on knowing one thing : How many matches will all the teams play in their home kit and how m... |
Solve the programming task below in a Python markdown code block.
Luba thinks about watering her garden. The garden can be represented as a segment of length k. Luba has got n buckets, the i-th bucket allows her to water some continuous subsegment of garden of length exactly a_{i} each hour. Luba can't water any parts... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.