The ornament has a square shape and consists of equal square pixels. Each pixel can be either red or white. An ornament is considered to be balanced if any square 2 $$$\times$$$ 2 contains both white and red pixels, but their amounts are not equal to each other. Give an example of any balanced ornament.
The input contains a single integer $$$n, (2 \leq n \leq 5000)$$$ - the width and height of the ornament in pixels.
Output $$$n$$$ lines of $$$n$$$ characters $$$R$$$ or $$$W$$$ that show the color of the pixels in the ornament (red and white respectively). From the entire set of possible answers, you can print any.
3
RRR WRW WWW
The well-known JoyTube video site is hosting an event called Streamer Night. On this night, which lasts $$$n$$$ seconds, every self-respecting channel organizes a stream. You are subscribed to $$$k$$$ channels, each of which will start its stream at $$$a_i$$$-th second and end it at $$$b_i$$$-th second $$$(i\in[1;k])$$$. What is the maximum number of streams you can watch that night from start to the end? If any stream ends, then you can switch to another starting stream at the same second.
The first line contains two integers $$$n$$$ and $$$k$$$ $$$(2 \leq n \leq 200 000, 1 \leq k \leq 200 000)$$$. The next $$$k$$$ lines contain pairs of numbers $$$a_i, b_i (1 \leq a_i \lt b_i \leq n)$$$.
Print one number - the answer to the problem.
5 3 1 3 2 5 3 4
2
6 4 2 3 2 3 2 3 2 3
1
You work for a publishing house. Recently you have received $$$n$$$ stories from different authors. The $$$i$$$th story has a length of $$$a_i$$$ pages. In the near future you have planned to publish $$$k$$$ books, $$$i$$$-th book contains $$$b_i$$$ pages. Each book can contain any number of different available stories. Each story can be published in any number of books, just like in none of them. For each book, determine the maximum number of stories that it can contain.
The first line contains two space-separated numbers $$$n$$$ and $$$k$$$ ($$$1 \leq n,k \leq 200000$$$). The second line contains $$$n$$$ space-separated numbers $$$a_i$$$ $$$(1 \leq a_i \leq 10^9)$$$. The third line contains $$$k$$$ space-separated numbers $$$b_i$$$ $$$(1 \leq b_i \leq 10^{18})$$$.
Print $$$k$$$ space-separated numbers - the maximum number of stories for each book.
4 3 8 2 3 30 5 29 1
2 3 0
You are given a string of characters '(' and ')'. Check if a given sequence of brackets can be obtained from some mathematical expression by removing all numbers and operation symbols.
The first input line contains one natural number $$$n$$$, $$$1 \leq n \leq 200000$$$. The second line contains a sequence of $$$n$$$ characters '(' and ')'.
Print $$$YES$$$ or $$$NO$$$ - the answer to the problem question.
6 (())()
YES
3 ())
NO
4 )(()
NO
$$$n$$$ teams train at the sports school. The $$$i$$$th team has the strength $$$a_i$$$. A month later, a tournament will take place, during which each team will play a match with every other team. The match ends with the victory of one of the teams if it is stronger than the other, or a draw if the strengths of the teams are equal. At the end of the tournament, each team will receive a certain number of points for the matches played: 3 points for each win and 1 point for each draw.
Mr. Yaruta can train with any team, and then its strength will increase by 1. He is interested in the maximum total amount of points of all teams together. What is the minimum number of training session he need to provide to do this?
The first line contains the number of teams $$$n$$$, $$$(2 \leq n \leq 200000)$$$. The second line contains $$$n$$$ space-separated integers $$$a_i$$$, $$$(1 \leq a_i \leq 10^9)$$$.
Output one integer - the answer to the problem.
3 6 5 6
1
It is known that any star cannot be simultaneously visible both from the south pole and from the north pole. Using this, the Penguin and the Bear decided to count all the stars in space. They stood at the poles at the same time, and each counted the stars that are visible to him. You know these two numbers. Using these data, answer the question: how many stars are there in space?
The two input lines contain the numbers $$$A$$$ and $$$B$$$ $$$(1 \leq A,B \lt 10^{10^5})$$$ - the number of stars counted by the Penguin and the Bear. These integers don't contain leading zeros.
Output one number - the answer to the problem. This number must not contain leading zeros.
705 33
738
Two ants live at points $$$a_1$$$ and $$$a_2$$$ of the coordinate axis. At the same time and at a constant speed, they begin to run in a certain direction. The first ant knows that after $$$t_1$$$ seconds he will be at the point $$$p_1$$$. The second one knows that in $$$t_2$$$ seconds he will be at the point $$$p_2$$$. Determine if the ants will ever meet at the same point. If so, how soon will they meet?
The first line contains 3 integers $$$a_1$$$, $$$t_1$$$, $$$p_1$$$, $$$(-10^4 \leq a_1 \leq 10^4,$$$ $$$1 \leq t_1 \leq 10^4,$$$ $$$-10^4 \leq p_1 \leq 10^4,$$$ $$$a_1 \neq p_1)$$$. The second line contains 3 integers $$$a_2$$$, $$$t_2$$$, $$$p_2$$$, $$$(-10^4 \leq a_2 \leq 10^4,$$$ $$$1 \leq t_2 \leq 10^4,$$$ $$$-10^4 \leq p_2 \leq 10^4,$$$ $$$a_2 \neq p_2)$$$. Also $$$a_1 \neq a_2$$$.
Print -1 if the ants never meet. Otherwise, print a single number - the time until the meeting. It must differ from the correct answer by no more than $$$10^{-6}$$$.
-3 2 5 12 1 10
2.50000000
If the person to your right and the person to your left have the same name, then you can make a wish. Your task is to arrange $$$n$$$ Andrews, $$$n$$$ Bens and $$$n$$$ Charlies in a row so that there are exactly $$$k$$$ people among them who can make a wish.
The input contains two numbers $$$n$$$ and $$$k$$$, $$$(1 \leq n \leq 20000$$$, $$$0 \leq k \leq 3*n)$$$.
If the necessary arrangement is impossible, print -1. Otherwise, output a string of $$$3*n$$$ characters. It must contain exactly $$$n$$$ characters $$$A$$$, $$$B$$$, $$$C$$$, each of which represents a person with the corresponding name. If there are more than one correct answers, print any of them.
2 1
CAABCB
6 17
-1
Robbers led by Robin Hood live in Sherwood Forest. They are extremely resentful that other people's incomes are distributed unevenly. Therefore, any of the robbers can approach two people and do the following actions:
1) Calculate how much money they have. Let these quantities be equal to $$$a_1$$$ and $$$a_2$$$.
2) Choose $$$i, j \in \{1;2\}$$$ $$$(i \neq j)$$$, also choose a prime number $$$p$$$ such that $$$a_i$$$ is divisible by $$$p$$$.
3) Redistribute the money so that one person has $$$\frac{a_i}{p}$$$ of money, and the other has $$$a_j*p$$$. If extra money remains from such a redistribution, then the robber will take it for himself. If, on the contrary, there is not enough money for such amounts, then the robber will pay them out of his own pocket.
Today two people will walk through Sherwood Forest with amounts of money equal to 1 and $$$n$$$. They can meet any non-negative number of robbers. The robbers, of course, plan to act together in order to take as much money as possible in total. How much richer can the robbers get?
The input contains one number $$$n$$$, $$$(1 \leq n \leq 10^9)$$$.
Print a single number - the amount of money the robbers can get if they act optimally.
8
3
29
0
Cats are predators, so they know how to camouflage well and disperse throughout the area. Everything you see can be represented as a string $$$s$$$ of lowercase latin letters. There's a cat hiding there if you can choose three indices $$$i \lt j \lt k$$$ such that the string $$$\overline{s_i s_j s_k}$$$ differs from the string $$$'cat'$$$ by no more than a character in one position.
For example, in the string $$$'cpython'$$$ there is a cat hidden, because you can select indices 1, 2, 4, and then the resulting string $$$'cpt'$$$ differs from the string $$$'cat'$$$ only in the second character.
Your task is to determine whether the cat is hiding in a given line, and if so, find it.
The input is a string $$$s$$$ of lowercase latin letters. The length of the string $$$|s|$$$ is such that $$$3 \leq |s| \leq 2*10^5$$$.
If the cat is hiding in this string, then print any of the possible places where it could hide. Namely, print three space-separated indices $$$i, j, k$$$ such that $$$1 \leq i \lt j \lt k \leq |s|$$$.
If the cat could not hide in this string, then print -1.
cpython
1 3 4
codeforces
-1
thecatishere
4 5 6