Kyrgyzstan has been taking part in ICPC competitions since 1996, when the North-Eastern European Regional Contest (NEERC) was organized.
In the 2003-2004 season, the team from Kyrgyzstan reached the ICPC World Finals for the first time, and in 2005 the first ICPC regional championship was held in Kyrgyzstan.
Since then, the regional championship has been held every year.
In 2019, due to the increase in the number of participants, an additional qualification stage was introduced — but due to COVID restrictions, it was not held in 2020 and 2021.
However, all of this is true for student teams — school teams from Kyrgyzstan that wanted to participate in the VKOSHP finals had to qualify every year through the general online selection.
And now, in 2026, the situation for school teams has finally changed — now, in parallel with the student team championship in Kyrgyzstan, which is a qualifier for the NERC Finals, a school team championship is also held, which is a qualifier for VKOSHP.
As in the case of student teams, school teams first need to pass a qualification stage, and based on its results the best teams will advance to the main stage of the championship.
The author of this problem decided that this event is a good basis for a problem.
For a given year $$$Y$$$, output all team competitions that were held or will be held in Kyrgyzstan in that year.
The only line contains an integer $$$Y$$$ $$$(2005 \le Y \le 2026)$$$ — the year of the competitions.
In the first line, output an integer $$$k$$$ — the number of team competitions held (or to be held) in year $$$Y$$$ in Kyrgyzstan.
In the next $$$k$$$ lines, output one competition per line (in any order):
The lines may be output in any order.
2026
4 School Qual School Regional ICPC Qual ICPC Regional
2019
2 ICPC Qual ICPC Regional
2021
1 ICPC Regional
2007
1 ICPC Regional
In the first example ($$$Y = 2026$$$), for the first time in history, all four competitions are held in the same year at once: the ICPC student championship, its qualification, as well as the newly introduced school championship and its qualification.
In the second example ($$$Y = 2019$$$), this is the first year when, in addition to the ICPC student regional championship, its qualification was also held.
In the third example ($$$Y = 2021$$$), due to COVID restrictions, the qualification stage for the student championship was not held again (as in 2020), so only the ICPC regional championship itself took place.
In the fourth example ($$$Y = 2007$$$), we go back to 2007, when only the ICPC student regional championship was held, without any qualifications.
One of the features of adult life is the proper approach to washing clothes:
Many examples can be invented, but here we will fix several basic rules of a "responsible washer":
Your wardrobe contains $$$N$$$ clothing items, each described by its color and type.
Determine the minimum number of washes required according to the rules described above.
The first line contains one integer $$$N$$$ $$$(1 \le N \le 10^4)$$$ — the number of clothing items available.
Each of the next $$$N$$$ lines contains the description of one clothing item in the wardrobe: two words separated by a space $$$c_i$$$ $$$t_i$$$ — the color and the type of the clothing item, respectively.
$$$c_i$$$ can be one of the following words:
$$$t_i$$$ can be one of the following words:
Print one integer — the minimum number of washes taking into account all the rules described above.
10Red SocksBlack JeansWhite T-shirtYellow T-shirtRed HoodieGreen SocksBlue T-shirtWhite T-shirtBlue HoodieGray Trousers
7
8Yellow T-shirtBlack T-shirtRed T-shirtGray T-shirtRed T-shirtBlue T-shirtGreen T-shirtBlue T-shirt
4
6Red SocksBlack SocksBlack SocksWhite SocksBlue SocksWhite Socks
1
9Blue HoodieBlack JeansWhite TrousersGreen HoodieRed HoodieBlue JeansBlue JeansWhite JeansWhite Hoodie
6
Example 1.
In total, there are $$$7$$$ washes: $$$1$$$ for socks, $$$3$$$ for T-shirts, $$$1$$$ for the bright sweater, and $$$2$$$ for the dark sweaters and trousers.
Example 2.
In total, there are $$$4$$$ washes: one each for red, yellow, green, and dark T-shirts, regardless of the number of items of each color.
Example 3.
All socks are washed in one wash, regardless of their number and color.
Example 4.
In total, there are $$$6$$$ washes.
You have probably heard the legend of Sisyphus — as punishment for various offenses against the gods, he is forced to push a heavy stone up a mountain.
But when the stone reaches the top — it immediately rolls back down, and Sisyphus is forced to start all over again.
This has been going on for more than one century already — and Hades (the ruler of the underworld) decided to somehow make this action more interesting.
Now Sisyphus is forced to drag the stone along an infinite straight line.
During the day, Sisyphus can drag the stone by at most $$$A$$$ meters to the right (in the positive direction).
But at night, a strong wind starts blowing, which blows Sisyphus together with the stone to the left (in the negative direction).
To make things more interesting, the wind gets stronger every night — on the $$$i$$$-th night, the wind will blow Sisyphus $$$i \cdot B$$$ meters to the left.
Hades is interested in watching Sisyphus as long as he makes at least some progress to the right. Otherwise, Hades changes the parameters $$$A$$$ and $$$B$$$ and starts Sisyphus's punishment from the beginning.
For each pair $$$A$$$ and $$$B$$$, determine the maximum distance to the right Sisyphus can advance.
The first line contains an integer $$$Q$$$ $$$(1 \le Q \le 10^4)$$$ — the number of different punishment variants.
Each of the next $$$Q$$$ lines contains two integers $$$A_i$$$ and $$$B_i$$$ $$$(1 \le A_i, B_i \le 10^9)$$$ separated by a space — the distance Sisyphus can drag the stone to the right in one day, and the initial wind strength for the $$$i$$$-th punishment variant.
Print $$$Q$$$ lines.
In the $$$i$$$-th line, print one integer $$$D_i$$$ — the maximum positive distance Sisyphus can advance in the $$$i$$$-th punishment.
510 33 1042 4212345 876987654321 1
22 3 42 93195 487730529388812681
The first punishment.
Let us consider Sisyphus's coordinate on the line after each day and night:
It can be seen that Sisyphus advanced maximally to $$$22$$$ — after that, the wind will keep pushing him further and further to the left.
The second punishment.
Hades realized that he had overcomplicated things — and ended this trial.
The third punishment.
It was pointless to continue any further.
The fourth punishment.
This example is intended for additional verification of the correctness of your calculations.
The fifth punishment.
This example is intended for additional verification of the efficiency of your calculations.
Did you know that in the past, even calculators were programmed in computer science classes?
The author of this problem personally learned about this from their parents, who did something similar in the late 1980s.
In 2026, the main trend is communicating with various LLM models in chat mode (and not only that).
But is it possible to communicate in a similar way with a chatbot programmed on a calculator?
It is possible if we consider some digits to be similar to letters of the Latin alphabet:
And if you turn the calculator upside down, you can see two more correspondences:
We will call a number $$$X$$$ a "word" if all of its digits are similar to letters:
Your task is to determine the number of word-like numbers in the interval $$$[0; N]$$$.
The only line contains one integer $$$N$$$ $$$(0 \le N \le 123456)$$$ — the upper bound of the interval $$$[0; N]$$$.
Print two integers $$$C_1$$$ and $$$C_2$$$ separated by a space:
34
8 15
8051
202 1100
123456
1536 10368
Example 1.
In the normal orientation, the following numbers look like words:
In the turned upside down orientation, the following numbers look like words:
Example 2.
This test is an additional opportunity to check that your counting is performed correctly.
Example 3.
This test checks that your counting is performed efficiently enough (the bound $$$N$$$ takes its maximum possible value).
Autumn has come — which means everyone starts thinking about how quickly summer flew by...
It seems that a lot happened over these three months — but at the same time, it feels like there could have been even more.
This time you prepared thoroughly — and documented all your activities, dividing them into four categories:
You are interested in the total time spent on each of the four categories of activities.
The first line contains an integer $$$N$$$ ($$$1 \le N \le 2 \cdot 10^5$$$) — the number of records in the log.
Each of the next $$$N$$$ lines contains one log record in the format $$$D$$$ $$$A$$$ (two strings separated by a space), where:
It is guaranteed that:
Note — consecutive records may contain the same activities.
Output $$$4$$$ lines, each containing the total time spent on the corresponding activity type.
The order of the output lines is S, W, T, R (sleep; study / work; time on the road; entertainment, respectively).
Each line must be printed in the format DD hh:mm:ss — the number of days, hours, minutes, and seconds spent on that activity type over the whole summer.
Assume that summer ends exactly at 09.01 00:00:00 (that is, the last activity in the log continues until that moment).
1006.01 00:00:00 S06.01 09:12:34 W06.02 00:59:47 S06.02 08:00:00 W07.16 07:45:00 T07.16 12:58:27 R08.01 20:21:53 R08.25 18:00:07 T08.25 23:57:59 S08.26 08:00:00 W
S 1 00:14:48 W 50 07:32:13 T 0 11:11:19 R 40 05:01:40
206.01 00:00:00 T08.29 09:12:34 W
S 0 00:00:00 W 2 14:47:26 T 89 09:12:34 R 0 00:00:00
Example 1.
Let us consider the given log step by step:
Example 2.
Let us consider the given log step by step:
Note that although there are no records of type S and R in the log — you still need to output the total time for them as well (in this case it will be zero, that is, 00 00:00:00).
A cashier has an infinite number of banknotes with denominations $$$1, 2, \ldots, K$$$.
The cashier prefers the stacks of banknotes to end uniformly:
Help the cashier — find any way to give $$$N$$$ units of change uniformly.
The only line contains two integers $$$N$$$ and $$$K$$$ separated by a space ($$$1 \le N \le 10^{18}$$$; $$$1 \le K \le 2 \cdot 10^5$$$) — the amount of change and the number of different available denominations.
Print $$$K$$$ integers $$$C_1, C_2, \ldots, C_K$$$ ($$$0 \le C_i \le N$$$) separated by spaces — the number of banknotes of denomination $$$i$$$ in a uniform change of $$$N$$$.
The answer must satisfy the following conditions:
If there are multiple answers satisfying the conditions, print any of them.
10 3
2 1 2
61 7
1 3 3 3 3 3 0
In the first example, the cashier gave:
In total, the cashier gave $$$C_1 \cdot 1 + C_2 \cdot 2 + C_3 \cdot 3 = 10$$$ units.
In the second example, the cashier gave:
In total, the cashier gave $$$1 \cdot 1 + 3 \cdot (2 + 3 + 4 + 5 + 6) + 0 \cdot 7 = 61$$$ units.
Note that this is only one possible answer with $$$\max(C_1, \ldots, C_7) = 3$$$. It can be shown that there is no answer where $$$\max(C_1, \ldots, C_7)$$$ is less than $$$3$$$.
You are given a permutation $$$P$$$ of length $$$N$$$.
For each prefix of this permutation, you need to compute its median.
The first line contains one integer $$$N$$$ $$$(1 \le N \le 2 \cdot 10^5)$$$ — the length of the permutation.
The second line contains $$$N$$$ integers $$$P_1, P_2, \ldots, P_N$$$ $$$(1 \le P_i \le N)$$$ separated by spaces — the elements of the permutation.
It is guaranteed that all values $$$P_i$$$ are distinct.
Print $$$N$$$ integers $$$M_1, M_2, \ldots, M_N$$$ separated by spaces, where $$$M_i$$$ is the doubled median of the elements $$$P_1, \ldots, P_i$$$ (that is, the median of the first $$$i$$$ elements of the permutation multiplied by $$$2$$$).
75 2 1 4 7 6 3
10 7 4 6 8 9 8
The median of a set of $$$k$$$ numbers sorted in nondecreasing order as $$$a_1 \le a_2 \le \ldots \le a_k$$$ is defined as:
Since the median for even $$$k$$$ may not be an integer, you should output its doubled value — it is always an integer.
Let us consider the first example step by step. At each step $$$i$$$, we consider the prefix of the first $$$i$$$ elements of the permutation sorted in nondecreasing order, and compute its doubled median $$$M_i$$$: