Zaglol Contest - FCDS level 1 contest 2026
A. Zaglol welcoming
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

Welcome to FCDS contest. You are given a string $$$s$$$. Your task is to print $$$FCDS$$$ regardless of the input.

Input

The first line contains a string $$$s$$$.

Output

Print $$$FCDS$$$

Example
Input
baraa
Output
FCDS

B. Baby Baraa in ALBAIK
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

One day, $$$Baby$$$ $$$Baraa$$$ was in $$$Saudi$$$ $$$Arabia$$$. He went to his favourite restaurant $$$ALBAIK$$$.

$$$ALBAIK$$$ is a restaurant that sells $$$n$$$ chickens; the size of the $$$i$$$-th chicken is $$$a_i$$$.

Actually, $$$Baby$$$ $$$Baraa$$$ was not hungry, so he decided to play with these chickens.

For each chicken $$$i$$$, $$$Baby$$$ $$$Baraa$$$ will count how many chickens after this chicken, according to their order, have a smaller size than the $$$i$$$-th chicken.

More formally, for each $$$(1 ≤ i ≤ n)$$$, he will count how many $$$j$$$ such that $$$(j \gt i)$$$ and $$$a_i \gt a_j$$$.

As $$$Baby$$$ $$$Baraa$$$ became hungry, now he wants you to play this game.

Input

The first line contains one integer $$$n$$$ $$$(1≤n≤2⋅10^5)$$$.

The second line contains $$$n$$$ integers $$$a_1,a_2,…,a_n$$$ $$$(1≤a_i≤100)$$$ — the sizes of the $$$n$$$ chickens.

Output

Output a single integer — the answer to the game.

Example
Input
6
4 5 3 1 6 2
Output
9
Note

The $$$9$$$ pairs are $$$(4, 3), (4, 1), (4, 2), (5, 3), (5, 1), (5, 2), (3, 1), (3, 2), (6, 2)$$$

C. Kero ! Kero ! El3ab ya Kero !
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

$$$Mohamed$$$ and $$$Kero$$$ are playing a game during their spare time.

they are given an array $$$A$$$ of length $$$N$$$ and an integer $$$K$$$.

in the game, $$$Mohamed$$$ will play first then $$$Kero$$$.

$$$Mohamed$$$ will choose any index $$$i$$$ $$$(1 \leq i \leq N)$$$, and add to his score $$$(a_i \% K)$$$, and according to these steps each one of them tries to maximize his score.

Help us to find if $$$Mohamed$$$ will win the game or not.

Note : each $$$a_i$$$ is used once.

Input

First line , Given two integers $$$N$$$, $$$K$$$ . $$$(1 \leq N \leq 2*10^5)$$$ , $$$(1 \leq K \leq 10^9)$$$, $$$N$$$ is the length of array $$$A$$$ and $$$K$$$.

Second line, Given an array $$$A$$$ of $$$N$$$ integers , $$$(-10^9 \leq a_i \leq 10^9)$$$.

Output

if $$$Mohamed$$$ is the winner, print "YES", otherwise print "NO" in any form (Yes/yES/YeS)( No/nO/no).

Examples
Input
3 5
2 9 -7
Output
YES
Input
4 4
1 -3 7 -9
Output
NO
Note

A $$$\%$$$ K = ((A $$$\%$$$ K) + K) $$$\%$$$ K .

in the first test case :

step $$$1$$$ : $$$Mohamed$$$ will choose $$$(i=2)$$$ then $$$( 9 \% 5 = 4)$$$ then $$$Mohamed$$$ score $$$= 4.$$$

step $$$2$$$ : $$$Kero$$$ will choose $$$(i=3)$$$ then $$$( -7 \% 5 = 3)$$$ then $$$Kero$$$ score $$$= 3.$$$

step $$$3$$$ : $$$Mohamed$$$ will choose $$$(i=1)$$$ then $$$( 2 \% 5 = 2)$$$ then $$$Mohamed$$$ score $$$= 4 + 2 = 6.$$$

Since $$$Mohamed$$$ score $$$= 6$$$ and $$$Kero$$$ score $$$= 3$$$, then $$$Mohamed$$$ is the winner.

D. Sahla bas Sa7la
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

Fady was walking alone and his friend Omar asked for his help to solve a math problem.

He gave him two integers $$$A$$$ and $$$B$$$. He asked him to determine the number of pairs of integers $$$(a,b)$$$ such that $$$(1 \le a \le A)$$$ and $$$(1 \le b \le B)$$$, and the following equation is valid: $$$a \cdot b + a = a \cdot 10^{k}$$$, where $$$k$$$ is the number of digits of $$$b$$$ in decimal notation.

Both $$$a$$$ and $$$b$$$ must be written without leading zeroes.

Input

The first line contains an integer $$$t$$$ $$$(1 \le t \le 100)$$$ — the number of test cases.

Each of the next $$$t$$$ lines contains two integers $$$A$$$ and $$$B$$$ $$$(1 \le A,B \le 10^{9})$$$.

Output

For each test case, output a single integer — the number of pairs $$$(a,b)$$$ satisfying the given conditions.

Example
Input
3
1 9
5 20
50 500
Output
1
5
100
Note

The 5 valid pairs $$$(a, b)$$$ for the second testcase are:

$$$(1, 9), (2, 9), (3, 9), (4, 9), (5, 9)$$$

$$$(5, 9)$$$ is valid because $$$5 \cdot 9 + 5 = 5 \cdot 10^1$$$

E. Zeyad's Symmetric Functions
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

This problem is about the function $$$\textbf{f(x)=1/x}$$$. Given $$$l$$$ and $$$r (-10^{18} \le l \le r \le 10^{18})$$$. For each $$$\textbf{non-zero integer}$$$ $$$x_i (l \le x_i \le r)(x \neq 0)$$$,consider the triangle formed by:

1) The $$$X$$$-Axis

2) The $$$Y$$$-Axis

3) The tangent line to the curve $$$f(x) = 1/x$$$ at the point $$$(x_i , f(x_i))$$$

Find the sum of the areas of all such triangles.

Input

The only line of input contains two integers $$$l$$$ and $$$r (-10^{18} \le l \le r \le 10^{18})$$$.

(It's guaranteed that at least one of them doesn't equal 0)

Output

Print a single integer — the sum of the areas of the triangles.

Example
Input
1 1
Output
2
Note

The answer of the testcase, as in the image, is $$$(1/2) * 2 * 2 = 2$$$.

F. Franco Haters Club
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

After $$$Baby Baraa$$$ has qualified to DAR, he knew that some people made TEENS CHALLENGE marathon for Ramadan. As he is a $$$master$$$ on codeforces, he ordered them to be a tester and problemsetter.

$$$Baby Baraa$$$ forgot that he has a hashing sheet that must be finished tomorrow, but there is no time to make a problem, so he made a nice small problem for you.

Given a string $$$s$$$ and its size $$$n$$$. Your task is to sort this string according to Franco Teens Language.

As $$$Baby Baraa$$$ was busy solving the hashing sheet, solve this problem for him.

Input

The first line of input contains one integer $$$n$$$ $$$(1≤n≤10^5)$$$ — the size of the string.

The second line of input contains string $$$s$$$ — the string to be sorted.

Output

Print $$$s$$$ sorted according to Franco Teens Language.

Examples
Input
22
WISH0BARAA0TO0REACH0CM
Output
AAAABCCEHHIMORRST0000W
Input
23
WELCOMETOTEENSCHALLENGE
Output
ACCEEEEEEGHLLLMNNOOSTTW
Input
3
YAY
Output
AYY
Note

Franco Teens Language consists of characters from 0 to 9 and A to Z by this order : 7AB5CDE6FGHI3JKL1MNO9PQR2ST0UV4WXYZ8.

This means that "YAY" is sorted to "AYY" because A is before Y in this language.

G. No story, No ACs, Many WAs, just an unsolvable problem
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

I've run out of stories, so here is the problem directly. You are given an integer $$$n$$$ and $$$n$$$ strings $$$$$$s_1, s_2, \ldots, s_n.$$$$$$ You may reorder the strings in any way and concatenate them into a single string. Your task is to determine an order of the strings such that the resulting concatenated string is lexicographically smallest.

A string $$$x$$$ is lexicographically smaller than a string $$$y$$$ if, at the first position where they differ, the character in $$$x$$$ comes earlier in the alphabet than the character in $$$y$$$. If one string is a prefix of the other, the shorter string is considered smaller.

Input

The first line contains an integer $$$n$$$ $$$(1 \le n \le 5 \times 10^4)$$$. Each of the next $$$n$$$ lines contains one string $$$s_i$$$ consisting of lowercase English letters, where $$$(1 \le |s_i| \le 50)$$$. The total length of all strings does not exceed $$$5 \times 10^4$$$.

Output

Output the lexicographically smallest possible concatenation of all strings.

Examples
Input
3
fcds
alex
icpc
Output
alexfcdsicpc
Input
6
a
ab
aba
b
ba
bb
Output
aabaabbabbb

H. Zaglol vs. the British Occupation
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

Zaglol has a fight against a row of $$$n$$$ members of the British Occupation; the $$$i$$$-th person has power $$$a_i$$$. Zaglol has a magic sword with power $$$x$$$.

Zaglol can kill a person only if the sword's current power is at least that person's power. However, each time he kills a person with power $$$a_i$$$, the sword's power decreases by $$$a_i$$$.

For each query (a given sword power $$$x$$$) determine the maximum number of members of the British Occupation Zaglol can kill.

Each query is independent (Zaglol starts fresh for every query).

Input

The first line contains a single integer $$$n (1 ≤ n ≤ 10^5)$$$ — the number of people.

The second line contains $$$n$$$ integers $$$a₁, a₂, ..., aₙ$$$ $$$(1 ≤ aᵢ ≤ 10^9)$$$ — the power of each person.

The third line contains a single integer $$$q (1 ≤ q ≤ 10^5)$$$ — the number of queries.

The next $$$q$$$ lines each contain a single integer $$$x (0 ≤ x ≤ 10^9)$$$ — the sword power for that query.

Output

For each query, print a single integer on its own line: the maximum number of members of the British Occupation Zaglol can kill with a sword of power $$$x$$$.

Example
Input
7
5 1 3 7 2 3 10
5
0
2
3
6
10
Output
0
1
2
3
4

I. Swap(Mohamed, !Mohamed)
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

You have $$$n$$$ boxes. You are given a binary string $$$boxes$$$ of length $$$n$$$, where $$$boxes_i$$$ is '$$$0$$$' if the $$$i_{th}$$$ box is empty, and '$$$1$$$' if it contains one ball.

In one operation, you can move one ball from a box to an adjacent box. $$$Box_i$$$ is adjacent to $$$box_j$$$ if $$$abs(i - j) = 1$$$.

Note that after doing so, there may be more than one ball in some boxes.

Print an array $$$answer$$$ of size $$$n$$$, where $$$answer_i$$$ is the minimum number of operations needed to move all the balls to the $$$i_{th}$$$ box.

Each $$$answer_i$$$ is calculated considering the initial state of the boxes.

Input

The first line contains a single integer $$$n$$$ $$$(1 \leq n \leq 2×10^5)$$$ — the number of boxes.

The second line contains a single string $$$boxes$$$.

Output

Print an array $$$answer$$$ of size $$$n$$$, where $$$answer_i$$$ is the minimum number of operations needed to move all the balls to the $$$i_{th}$$$ box.

Examples
Input
3
110
Output
1 1 3
Input
6
001011
Output
11 8 5 4 3 4

K. Wahban and brackets
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

Wahban is known for his admiration for bracket sequences, especially regular bracket sequences $$$\dagger$$$ One day, while playing ping-pong with his friend, Zaghloul, he found a weird piece of paper with the title "REVERSE" and below it a sequence of brackets, and after an intensive moment of thinking, his friend, Zaghloul, asked him if he could obtain a Reversed regular bracket sequence $$$\ast$$$ from the given sequence, Wahban took the problem personally and decided not only to solve the problem, but to print the maximum reversed regular brackets subsequence$$$\top$$$ size, help Wahabn solve the problem or report it's impossible.

$$$\dagger$$$A regular bracket sequence is a bracket sequence that can be transformed into a correct arithmetic expression by inserting the characters 1 and + between the original characters of the sequence, for example: () and ()(()) are valid, while ()) and )( are invalid

$$$\ast$$$ A sequence is called reverse bracket sequence if and only if when we reverse the whole string, it gives us Regular bracket sequence, )( is valid, while () and ()() are invalid

$$$\top$$$ Subsequence is bunch of indices that can be obtained from deleting zero or more indices from the start, end or even middle of any sequence, for example: given this sequence 1,2,3,4,5 one valid subsequence is 1,3,5. }

Input

The only input is string $$$S$$$ $$$(1 \le |S| \le 10^6)$$$

Output

if it's impossible to obtain any valid subsequence, output $$$-1$$$.

otherwise, output the maximum size of a such valid subsequence.

Examples
Input
()
Output
-1
Input
()()()
Output
4
Note

In test case 1, if we reverse the string () we get )(, which's not valid, so there's no valid answer.

In test case 2, looking at the string at indices 2,3 ")(", if we reversed we get a valid sequence () of size = 2, also string formed from indices 2,5 ")(" gives us the same answer, the maximum answer is obtained from the string with indices 2,3,4,5 ")()("