Score : <var>100</var> points

Problem Statement

Takahashi likes the sound when he buys a drink from a vending machine.

That sound can be heard by spending <var>A</var> yen (the currency of Japan) each time.

Takahashi has <var>B</var> yen. He will hear the sound as many times as he can with that money, but at most <var>C</var> times, as he would be satisfied at that time.

How many times will he hear the sound?

Constraints

All values in input are integers.

<var>1 \leq A, B, C \leq 100</var>

Input

Input is given from Standard Input in the following format:

<var>A</var> <var>B</var> <var>C</var>

Output

Print the number of times Takahashi will hear his favorite sound.

Sample Input 1

2 11 4

Sample Output 1

4

Since he has not less than <var>8</var> yen, he will hear the sound four times and be satisfied.

Sample Input 2

3 9 5

Sample Output 2

3

He may not be able to be satisfied.

Sample Input 3

100 1 10

Sample Output 3

0


Score : <var>300</var> points

Problem Statement

We have a <var>2 \times N</var> grid. We will denote the square at the <var>i</var>-th row and <var>j</var>-th column (<var>1 \leq i \leq 2</var>, <var>1 \leq j \leq N</var>) as <var>(i, j)</var>.

You are initially in the top-left square, <var>(1, 1)</var>.
You will travel to the bottom-right square, <var>(2, N)</var>, by repeatedly moving right or down.

The square <var>(i, j)</var> contains <var>A_{i, j}</var> candies.
You will collect all the candies you visit during the travel.
The top-left and bottom-right squares also contain candies, and you will also collect them.

At most how many candies can you collect when you choose the best way to travel?

Constraints

<var>1 \leq N \leq 100</var>

<var>1 \leq A_{i, j} \leq 100</var> (<var>1 \leq i \leq 2</var>, <var>1 \leq j \leq N</var>)

Input

Input is given from Standard Input in the following format:

<var>N</var>
<var>A_{1, 1}</var> <var>A_{1, 2}</var> <var>...</var> <var>A_{1, N}</var>
<var>A_{2, 1}</var> <var>A_{2, 2}</var> <var>...</var> <var>A_{2, N}</var>

Output

Print the maximum number of candies that can be collected.

Sample Input 1

5
3 2 2 4 1
1 2 2 2 1

Sample Output 1

14

The number of collected candies will be maximized when you:

move right three times, then move down once, then move right once.

Sample Input 2

4
1 1 1 1
1 1 1 1

Sample Output 2

5

You will always collect the same number of candies, regardless of how you travel.

Sample Input 3

7
3 3 4 5 4 5 3
5 3 4 4 2 3 2

Sample Output 3

29

Sample Input 4

1
2
3

Sample Output 4

5


Score : <var>100</var> points

Problem Statement

Takahashi is distributing <var>N</var> balls to <var>K</var> persons.

If each person has to receive at least one ball, what is the maximum possible difference in the number of balls received between the person with the most balls and the person with the fewest balls?

Constraints

<var>1 \leq K \leq N \leq 100</var>

All values in input are integers.

Input

Input is given from Standard Input in the following format:

<var>N</var> <var>K</var>

Output

Print the maximum possible difference in the number of balls received.

Sample Input 1

3 2

Sample Output 1

1

The only way to distribute three balls to two persons so that each of them receives at least one ball is to give one ball to one person and give two balls to the other person.

Thus, the maximum possible difference in the number of balls received is <var>1</var>.

Sample Input 2

3 1

Sample Output 2

0

We have no choice but to give three balls to the only person, in which case the difference in the number of balls received is <var>0</var>.

Sample Input 3

8 5

Sample Output 3

3

For example, if we give <var>1, 4, 1, 1, 1</var> balls to the five persons, the number of balls received between the person with the most balls and the person with the fewest balls would be <var>3</var>, which is the maximum result.


Score : <var>100</var> points

Problem Statement

We have <var>A</var> balls with the string <var>S</var> written on each of them and <var>B</var> balls with the string <var>T</var> written on each of them.

From these balls, Takahashi chooses one with the string <var>U</var> written on it and throws it away.

Find the number of balls with the string <var>S</var> and balls with the string <var>T</var> that we have now.

Constraints

<var>S</var>, <var>T</var>, and <var>U</var> are strings consisting of lowercase English letters.

The lengths of <var>S</var> and <var>T</var> are each between <var>1</var> and <var>10</var> (inclusive).

<var>S \not= T</var>

<var>S=U</var> or <var>T=U</var>.

<var>1 \leq A,B \leq 10</var>

<var>A</var> and <var>B</var> are integers.

Input

Input is given from Standard Input in the following format:

<var>S</var> <var>T</var>
<var>A</var> <var>B</var>
<var>U</var>

Output

Print the answer, with space in between.

Sample Input 1

red blue
3 4
red

Sample Output 1

2 4

Takahashi chose a ball with red written on it and threw it away.
Now we have two balls with the string <var>S</var> and four balls with the string <var>T</var>.

Sample Input 2

red blue
5 5
blue

Sample Output 2

5 4

Takahashi chose a ball with blue written on it and threw it away.
Now we have five balls with the string <var>S</var> and four balls with the string <var>T</var>.


Score: <var>300</var> points

Problem Statement

We have a <var>3 \times 3</var> grid. A number <var>c_{i, j}</var> is written in the square <var>(i, j)</var>, where <var>(i, j)</var> denotes the square at the <var>i</var>-th row from the top and the <var>j</var>-th column from the left.

According to Takahashi, there are six integers <var>a_1, a_2, a_3, b_1, b_2, b_3</var> whose values are fixed, and the number written in the square <var>(i, j)</var> is equal to <var>a_i + b_j</var>.

Determine if he is correct.

Constraints

<var>c_{i, j} \ (1 \leq i \leq 3, 1 \leq j \leq 3)</var> is an integer between <var>0</var> and <var>100</var> (inclusive).

Input

Input is given from Standard Input in the following format:

<var>c_{1,1}</var> <var>c_{1,2}</var> <var>c_{1,3}</var>
<var>c_{2,1}</var> <var>c_{2,2}</var> <var>c_{2,3}</var>
<var>c_{3,1}</var> <var>c_{3,2}</var> <var>c_{3,3}</var>

Output

If Takahashi's statement is correct, print Yes; otherwise, print No.

Sample Input 1

1 0 1
2 1 2
1 0 1

Sample Output 1

Yes

Takahashi is correct, since there are possible sets of integers such as: <var>a_1=0,a_2=1,a_3=0,b_1=1,b_2=0,b_3=1</var>.

Sample Input 2

2 2 2
2 1 2
2 2 2

Sample Output 2

No

Takahashi is incorrect in this case.

Sample Input 3

0 8 8
0 8 8
0 8 8

Sample Output 3

Yes

Sample Input 4

1 8 6
2 9 7
0 7 7

Sample Output 4

No


Score : <var>100</var> points

Problem Statement

On some day in January <var>2018</var>, Takaki is writing a document. The document has a column where the current date is written in yyyy/mm/dd format. For example, January <var>23</var>, <var>2018</var> should be written as 2018/01/23.

After finishing the document, she noticed that she had mistakenly wrote 2017 at the beginning of the date column. Write a program that, when the string that Takaki wrote in the date column, <var>S</var>, is given as input, modifies the first four characters in <var>S</var> to 2018 and prints it.

Constraints

<var>S</var> is a string of length <var>10</var>.

The first eight characters in <var>S</var> are 2017/01/.

The last two characters in <var>S</var> are digits and represent an integer between <var>1</var> and <var>31</var> (inclusive).

Input

Input is given from Standard Input in the following format:

<var>S</var>

Output

Replace the first four characters in <var>S</var> with 2018 and print it.

Sample Input 1

2017/01/07

Sample Output 1

2018/01/07

Sample Input 2

2017/01/31

Sample Output 2

2018/01/31


Score : <var>200</var> points

Problem Statement

Takahashi has <var>N</var> days of summer vacation.

His teacher gave him <var>M</var> summer assignments. It will take <var>A_i</var> days for him to do the <var>i</var>-th assignment.

He cannot do multiple assignments on the same day, or hang out on a day he does an assignment.

What is the maximum number of days Takahashi can hang out during the vacation if he finishes all the assignments during this vacation?

If Takahashi cannot finish all the assignments during the vacation, print -1 instead.

Constraints

<var>1 \leq N \leq 10^6</var>

<var>1 \leq M \leq 10^4</var>

<var>1 \leq A_i \leq 10^4</var>

Input

Input is given from Standard Input in the following format:

<var>N</var> <var>M</var>
<var>A_1</var> <var>...</var> <var>A_M</var>

Output

Print the maximum number of days Takahashi can hang out during the vacation, or -1.

Sample Input 1

41 2
5 6

Sample Output 1

30

For example, he can do the first assignment on the first <var>5</var> days, hang out on the next <var>30</var> days, and do the second assignment on the last <var>6</var> days of the vacation. In this way, he can safely spend <var>30</var> days hanging out.

Sample Input 2

10 2
5 6

Sample Output 2

-1

He cannot finish his assignments.

Sample Input 3

11 2
5 6

Sample Output 3

0

He can finish his assignments, but he will have no time to hang out.

Sample Input 4

314 15
9 26 5 35 8 9 79 3 23 8 46 2 6 43 3

Sample Output 4

9


Score : <var>300</var> points

Problem Statement

There is a sequence of length <var>N</var>: <var>A_1, A_2, ..., A_N</var>. Initially, this sequence is a permutation of <var>1, 2, ..., N</var>.

On this sequence, Snuke can perform the following operation:

Choose <var>K</var> consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements.

Snuke would like to make all the elements in this sequence equal by repeating the operation above some number of times.
Find the minimum number of operations required.
It can be proved that, Under the constraints of this problem, this objective is always achievable.

Constraints

<var>2 \leq K \leq N \leq 100000</var>

<var>A_1, A_2, ..., A_N</var> is a permutation of <var>1, 2, ..., N</var>.

Input

Input is given from Standard Input in the following format:

<var>N</var> <var>K</var>
<var>A_1</var> <var>A_2</var> <var>...</var> <var>A_N</var>

Output

Print the minimum number of operations required.

Sample Input 1

4 3
2 3 1 4

Sample Output 1

2

One optimal strategy is as follows:

In the first operation, choose the first, second and third elements. The sequence <var>A</var> becomes <var>1, 1, 1, 4</var>.

In the second operation, choose the second, third and fourth elements. The sequence <var>A</var> becomes <var>1, 1, 1, 1</var>.

Sample Input 2

3 3
1 2 3

Sample Output 2

1

Sample Input 3

8 3
7 3 1 8 4 6 2 5

Sample Output 3

4


Score : <var>300</var> points

Problem Statement

Sitting in a station waiting room, Joisino is gazing at her train ticket.

The ticket is numbered with four digits <var>A</var>, <var>B</var>, <var>C</var> and <var>D</var> in this order, each between <var>0</var> and <var>9</var> (inclusive).

In the formula <var>A</var> <var>op1</var> <var>B</var> <var>op2</var> <var>C</var> <var>op3</var> <var>D</var> <var>=</var> <var>7</var>, replace each of the symbols <var>op1</var>, <var>op2</var> and <var>op3</var> with + or - so that the formula holds.

The given input guarantees that there is a solution. If there are multiple solutions, any of them will be accepted.

Constraints

<var>0≤A,B,C,D≤9</var>

All input values are integers.

It is guaranteed that there is a solution.

Input

Input is given from Standard Input in the following format:

<var>ABCD</var>

Output

Print the formula you made, including the part =7.

Use the signs + and -.

Do not print a space between a digit and a sign.

Sample Input 1

1222

Sample Output 1

1+2+2+2=7

This is the only valid solution.

Sample Input 2

0290

Sample Output 2

0-2+9+0=7

<var>0 - 2 + 9 - 0 = 7</var> is also a valid solution.

Sample Input 3

3242

Sample Output 3

3+2+4-2=7


Score : <var>200</var> points

Problem Statement

Tak performed the following action <var>N</var> times: rolling two dice.
The result of the <var>i</var>-th roll is <var>D_{i,1}</var> and <var>D_{i,2}</var>.

Check if doublets occurred at least three times in a row.
Specifically, check if there exists at lease one <var>i</var> such that <var>D_{i,1}=D_{i,2}</var>, <var>D_{i+1,1}=D_{i+1,2}</var> and <var>D_{i+2,1}=D_{i+2,2}</var> hold.

Constraints

<var>3 \leq N \leq 100</var>

<var>1\leq D_{i,j} \leq 6</var>

All values in input are integers.

Input

Input is given from Standard Input in the following format:

<var>N</var>
<var>D_{1,1}</var> <var>D_{1,2}</var>
<var>\vdots</var>
<var>D_{N,1}</var> <var>D_{N,2}</var>

Output

Print Yes if doublets occurred at least three times in a row. Print No otherwise.

Sample Input 1

5
1 2
6 6
4 4
3 3
3 2

Sample Output 1

Yes

From the second roll to the fourth roll, three doublets occurred in a row.

Sample Input 2

5
1 1
2 2
3 4
5 5
6 6

Sample Output 2

No

Sample Input 3

6
1 1
2 2
3 3
4 4
5 5
6 6

Sample Output 3

Yes


Score : <var>300</var> points

Problem Statement

Given is a positive integer <var>N</var>.
How many tuples <var>(A,B,C)</var> of positive integers satisfy <var>A \times B + C = N</var>?

Constraints

<var> 2 \leq N \leq 10^6</var>

All values in input are integers.

Input

Input is given from Standard Input in the following format:

<var>N</var>

Output

Print the answer.

Sample Input 1

3

Sample Output 1

3

There are <var>3</var> tuples of integers that satisfy <var>A \times B + C = 3</var>: <var>(A, B, C) = (1, 1, 2), (1, 2, 1), (2, 1, 1)</var>.

Sample Input 2

100

Sample Output 2

473

Sample Input 3

1000000

Sample Output 3

13969985


Score : <var>200</var> points

Problem Statement

There are <var>N + 1</var> squares arranged in a row, numbered <var>0, 1, ..., N</var> from left to right.

Initially, you are in Square <var>X</var>.
You can freely travel between adjacent squares. Your goal is to reach Square <var>0</var> or Square <var>N</var>.
However, for each <var>i = 1, 2, ..., M</var>, there is a toll gate in Square <var>A_i</var>, and traveling to Square <var>A_i</var> incurs a cost of <var>1</var>.
It is guaranteed that there is no toll gate in Square <var>0</var>, Square <var>X</var> and Square <var>N</var>.

Find the minimum cost incurred before reaching the goal.

Constraints

<var>1 \leq N \leq 100</var>

<var>1 \leq M \leq 100</var>

<var>1 \leq X \leq N - 1</var>

<var>1 \leq A_1 < A_2 < ... < A_M \leq N</var>

<var>A_i \neq X</var>

All values in input are integers.

Input

Input is given from Standard Input in the following format:

<var>N</var> <var>M</var> <var>X</var>
<var>A_1</var> <var>A_2</var> <var>...</var> <var>A_M</var>

Output

Print the minimum cost incurred before reaching the goal.

Sample Input 1

5 3 3
1 2 4

Sample Output 1

1

The optimal solution is as follows:

First, travel from Square <var>3</var> to Square <var>4</var>. Here, there is a toll gate in Square <var>4</var>, so the cost of <var>1</var> is incurred.

Then, travel from Square <var>4</var> to Square <var>5</var>. This time, no cost is incurred.

Now, we are in Square <var>5</var> and we have reached the goal.

In this case, the total cost incurred is <var>1</var>.

Sample Input 2

7 3 2
4 5 6

Sample Output 2

0

We may be able to reach the goal at no cost.

Sample Input 3

10 7 5
1 2 3 4 6 8 9

Sample Output 3

3


Score : <var>400</var> points

Problem Statement

For an integer <var>N</var>, we will choose a permutation <var>\{P_1, P_2, ..., P_N\}</var> of <var>\{1, 2, ..., N\}</var>.

Then, for each <var>i=1,2,...,N</var>, let <var>M_i</var> be the remainder when <var>i</var> is divided by <var>P_i</var>.

Find the maximum possible value of <var>M_1 + M_2 + \cdots + M_N</var>.

Constraints

<var>N</var> is an integer satisfying <var>1 \leq N \leq 10^9</var>.

Input

Input is given from Standard Input in the following format:

<var>N</var>

Output

Print the maximum possible value of <var>M_1 + M_2 + \cdots + M_N</var>.

Sample Input 1

2

Sample Output 1

1

When the permutation <var>\{P_1, P_2\} = \{2, 1\}</var> is chosen, <var>M_1 + M_2 = 1 + 0 = 1</var>.

Sample Input 2

13

Sample Output 2

78

Sample Input 3

1

Sample Output 3

0


Score : <var>200</var> points

Problem Statement

Katsusando loves omelette rice.

Besides, he loves crème brûlée, tenderloin steak and so on, and believes that these foods are all loved by everyone.

To prove that hypothesis, he conducted a survey on <var>M</var> kinds of foods and asked <var>N</var> people whether they like these foods or not.

The <var>i</var>-th person answered that he/she only likes the <var>A_{i1}</var>-th, <var>A_{i2}</var>-th, <var>...</var>, <var>A_{iK_i}</var>-th food.

Find the number of the foods liked by all the <var>N</var> people.

Constraints

All values in input are integers.

<var>1 \leq N, M \leq 30</var>

<var>1 \leq K_i \leq M</var>

<var>1 \leq A_{ij} \leq M</var>

For each <var>i</var> <var>(1 \leq i \leq N)</var>, <var>A_{i1}, A_{i2}, ..., A_{iK_i}</var> are distinct.

Constraints

Input is given from Standard Input in the following format:

<var>N</var> <var>M</var>
<var>K_1</var> <var>A_{11}</var> <var>A_{12}</var> <var>...</var> <var>A_{1K_1}</var>
<var>K_2</var> <var>A_{21}</var> <var>A_{22}</var> <var>...</var> <var>A_{2K_2}</var>
<var>:</var>
<var>K_N</var> <var>A_{N1}</var> <var>A_{N2}</var> <var>...</var> <var>A_{NK_N}</var>

Output

Print the number of the foods liked by all the <var>N</var> people.

Sample Input 1

3 4
2 1 3
3 1 2 3
2 3 2

Sample Output 1

1

As only the third food is liked by all the three people, <var>1</var> should be printed.

Sample Input 2

5 5
4 2 3 4 5
4 1 3 4 5
4 1 2 4 5
4 1 2 3 5
4 1 2 3 4

Sample Output 2

0

Katsusando's hypothesis turned out to be wrong.

Sample Input 3

1 30
3 5 10 30

Sample Output 3

3


Score : <var>300</var> points

Problem Statement

<var>N</var> persons are standing in a row. The height of the <var>i</var>-th person from the front is <var>A_i</var>.

We want to have each person stand on a stool of some heights - at least zero - so that the following condition is satisfied for every person:

Condition: Nobody in front of the person is taller than the person. Here, the height of a person includes the stool.

Find the minimum total height of the stools needed to meet this goal.

Constraints

<var>1 \leq N \leq 2\times 10^5</var>

<var>1 \leq A_i \leq 10^9</var>

All values in input are integers.

Input

Input is given from Standard Input in the following format:

<var>N</var>
<var>A_1</var> <var>\ldots</var> <var>A_N</var>

Output

Print the minimum total height of the stools needed to meet the goal.

Sample Input 1

5
2 1 5 4 3

Sample Output 1

4

If the persons stand on stools of heights <var>0</var>, <var>1</var>, <var>0</var>, <var>1</var>, and <var>2</var>, respectively, their heights will be <var>2</var>, <var>2</var>, <var>5</var>, <var>5</var>, and <var>5</var>, satisfying the condition.

We cannot meet the goal with a smaller total height of the stools.

Sample Input 2

5
3 3 3 3 3

Sample Output 2

0

Giving a stool of height <var>0</var> to everyone will work.


Score : <var>300</var> points

Problem Statement

There are <var>N</var> squares arranged in a row from left to right.

The height of the <var>i</var>-th square from the left is <var>H_i</var>.

You will land on a square of your choice, then repeat moving to the adjacent square on the right as long as the height of the next square is not greater than that of the current square.

Find the maximum number of times you can move.

Constraints

All values in input are integers.

<var>1 \leq N \leq 10^5</var>

<var>1 \leq H_i \leq 10^9</var>

Input

Input is given from Standard Input in the following format:

<var>N</var>
<var>H_1</var> <var>H_2</var> <var>...</var> <var>H_N</var>

Output

Print the maximum number of times you can move.

Sample Input 1

5
10 4 8 7 3

Sample Output 1

2

By landing on the third square from the left, you can move to the right twice.

Sample Input 2

7
4 4 5 6 6 5 5

Sample Output 2

3

By landing on the fourth square from the left, you can move to the right three times.

Sample Input 3

4
1 2 3 4

Sample Output 3

0


Score : <var>100</var> points

Problem Statement

You are given a string <var>S</var> of length <var>N</var> consisting of A, B and C, and an integer <var>K</var> which is between <var>1</var> and <var>N</var> (inclusive).
Print the string <var>S</var> after lowercasing the <var>K</var>-th character in it.

Constraints

<var>1 ≤ N ≤ 50</var>

<var>1 ≤ K ≤ N</var>

<var>S</var> is a string of length <var>N</var> consisting of A, B and C.

Input

Input is given from Standard Input in the following format:

<var>N</var> <var>K</var>
<var>S</var>

Output

Print the string <var>S</var> after lowercasing the <var>K</var>-th character in it.

Sample Input 1

3 1
ABC

Sample Output 1

aBC

Sample Input 2

4 3
CABA

Sample Output 2

CAbA


Score : <var>200</var> points

Problem Statement

Determine if an <var>N</var>-sided polygon (not necessarily convex) with sides of length <var>L_1, L_2, ..., L_N</var> can be drawn in a two-dimensional plane.

You can use the following theorem:

Theorem: an <var>N</var>-sided polygon satisfying the condition can be drawn if and only if the longest side is strictly shorter than the sum of the lengths of the other <var>N-1</var> sides.

Constraints

All values in input are integers.

<var>3 \leq N \leq 10</var>

<var>1 \leq L_i \leq 100</var>

Input

Input is given from Standard Input in the following format:

<var>N</var>
<var>L_1</var> <var>L_2</var> <var>...</var> <var>L_N</var>

Output

If an <var>N</var>-sided polygon satisfying the condition can be drawn, print Yes; otherwise, print No.

Sample Input 1

4
3 8 5 1

Sample Output 1

Yes

Since <var>8 < 9 = 3 + 5 + 1</var>, it follows from the theorem that such a polygon can be drawn on a plane.

Sample Input 2

4
3 8 4 1

Sample Output 2

No

Since <var>8 \geq 8 = 3 + 4 + 1</var>, it follows from the theorem that such a polygon cannot be drawn on a plane.

Sample Input 3

10
1 8 10 5 8 12 34 100 11 3

Sample Output 3

No


Score : <var>200</var> points

Problem Statement

You have decided to write a book introducing good restaurants.
There are <var>N</var> restaurants that you want to introduce: Restaurant <var>1</var>, Restaurant <var>2</var>, <var>...</var>, Restaurant <var>N</var>. Restaurant <var>i</var> is in city <var>S_i</var>, and your assessment score of that restaurant on a <var>100</var>-point scale is <var>P_i</var>.
No two restaurants have the same score.

You want to introduce the restaurants in the following order:

The restaurants are arranged in lexicographical order of the names of their cities.

If there are multiple restaurants in the same city, they are arranged in descending order of score.

Print the identification numbers of the restaurants in the order they are introduced in the book.

Constraints

<var>1 ≤ N ≤ 100</var>

<var>S</var> is a string of length between <var>1</var> and <var>10</var> (inclusive) consisting of lowercase English letters.

<var>0 ≤ P_i ≤ 100</var>

<var>P_i</var> is an integer.

<var>P_i ≠ P_j</var> <var>(1 ≤ i < j ≤ N)</var>

Input

Input is given from Standard Input in the following format:

<var>N</var>
<var>S_1</var> <var>P_1</var>
<var>:</var>
<var>S_N</var> <var>P_N</var>

Output

Print <var>N</var> lines. The <var>i</var>-th line (<var>1 ≤ i ≤ N</var>) should contain the identification number of the restaurant that is introduced <var>i</var>-th in the book.

Sample Input 1

6
khabarovsk 20
moscow 10
kazan 50
kazan 35
moscow 60
khabarovsk 40

Sample Output 1

3
4
6
1
5
2

The lexicographical order of the names of the three cities is kazan <var><</var> khabarovsk <var><</var> moscow. For each of these cities, the restaurants in it are introduced in descending order of score. Thus, the restaurants are introduced in the order <var>3,4,6,1,5,2</var>.

Sample Input 2

10
yakutsk 10
yakutsk 20
yakutsk 30
yakutsk 40
yakutsk 50
yakutsk 60
yakutsk 70
yakutsk 80
yakutsk 90
yakutsk 100

Sample Output 2

10
9
8
7
6
5
4
3
2
1


Score : <var>300</var> points

Problem Statement

There are <var>N</var> candles placed on a number line.
The <var>i</var>-th candle from the left is placed on coordinate <var>x_i</var>.
Here, <var>x_1 < x_2 < ... < x_N</var> holds.

Initially, no candles are burning.
Snuke decides to light <var>K</var> of the <var>N</var> candles.

Now, he is at coordinate <var>0</var>.
He can move left and right along the line with speed <var>1</var>.
He can also light a candle when he is at the same position as the candle, in negligible time.

Find the minimum time required to light <var>K</var> candles.

Constraints

<var>1 \leq N \leq 10^5</var>

<var>1 \leq K \leq N</var>

<var>x_i</var> is an integer.

<var>|x_i| \leq 10^8</var>

<var>x_1 < x_2 < ... < x_N</var>

Input

Input is given from Standard Input in the following format:

<var>N</var> <var>K</var>
<var>x_1</var> <var>x_2</var> <var>...</var> <var>x_N</var>

Output

Print the minimum time required to light <var>K</var> candles.

Sample Input 1

5 3
-30 -10 10 20 50

Sample Output 1

40

He should move and light candles as follows:

Move from coordinate <var>0</var> to <var>-10</var>.

Light the second candle from the left.

Move from coordinate <var>-10</var> to <var>10</var>.

Light the third candle from the left.

Move from coordinate <var>10</var> to <var>20</var>.

Light the fourth candle from the left.

Sample Input 2

3 2
10 20 30

Sample Output 2

20

Sample Input 3

1 1
0

Sample Output 3

0

There may be a candle placed at coordinate <var>0</var>.

Sample Input 4

8 5
-9 -7 -4 -3 1 2 3 4

Sample Output 4

10


Score : <var>300</var> points

Problem Statement

There are <var>N</var> observatories in AtCoder Hill, called Obs. <var>1</var>, Obs. <var>2</var>, <var>...</var>, Obs. <var>N</var>. The elevation of Obs. <var>i</var> is <var>H_i</var>.
There are also <var>M</var> roads, each connecting two different observatories. Road <var>j</var> connects Obs. <var>A_j</var> and Obs. <var>B_j</var>.

Obs. <var>i</var> is said to be good when its elevation is higher than those of all observatories that can be reached from Obs. <var>i</var> using just one road.
Note that Obs. <var>i</var> is also good when no observatory can be reached from Obs. <var>i</var> using just one road.

How many good observatories are there?

Constraints

<var>2 \leq N \leq 10^5</var>

<var>1 \leq M \leq 10^5</var>

<var>1 \leq H_i \leq 10^9</var>

<var>1 \leq A_i,B_i \leq N</var>

<var>A_i \neq B_i</var>

Multiple roads may connect the same pair of observatories.

All values in input are integers.

Input

Input is given from Standard Input in the following format:

<var>N</var> <var>M</var>
<var>H_1</var> <var>H_2</var> <var>...</var> <var>H_N</var>
<var>A_1</var> <var>B_1</var>
<var>A_2</var> <var>B_2</var>
<var>:</var>
<var>A_M</var> <var>B_M</var>

Output

Print the number of good observatories.

Sample Input 1

4 3
1 2 3 4
1 3
2 3
2 4

Sample Output 1

2

From Obs. <var>1</var>, you can reach Obs. <var>3</var> using just one road. The elevation of Obs. <var>1</var> is not higher than that of Obs. <var>3</var>, so Obs. <var>1</var> is not good.

From Obs. <var>2</var>, you can reach Obs. <var>3</var> and <var>4</var> using just one road. The elevation of Obs. <var>2</var> is not higher than that of Obs. <var>3</var>, so Obs. <var>2</var> is not good.

From Obs. <var>3</var>, you can reach Obs. <var>1</var> and <var>2</var> using just one road. The elevation of Obs. <var>3</var> is higher than those of Obs. <var>1</var> and <var>2</var>, so Obs. <var>3</var> is good.

From Obs. <var>4</var>, you can reach Obs. <var>2</var> using just one road. The elevation of Obs. <var>4</var> is higher than that of Obs. <var>2</var>, so Obs. <var>4</var> is good.

Thus, the good observatories are Obs. <var>3</var> and <var>4</var>, so there are two good observatories.

Sample Input 2

6 5
8 6 9 1 2 1
1 3
4 2
4 3
4 6
4 6

Sample Output 2

3


Score : <var>300</var> points

Problem Statement

There are <var>N</var> monsters, numbered <var>1, 2, ..., N</var>.

Initially, the health of Monster <var>i</var> is <var>A_i</var>.

Below, a monster with at least <var>1</var> health is called alive.

Until there is only one alive monster, the following is repeated:

A random alive monster attacks another random alive monster.

As a result, the health of the monster attacked is reduced by the amount equal to the current health of the monster attacking.

Find the minimum possible final health of the last monster alive.

Constraints

All values in input are integers.

<var>2 \leq N \leq 10^5</var>

<var>1 \leq A_i \leq 10^9</var>

Input

Input is given from Standard Input in the following format:

<var>N</var>
<var>A_1</var> <var>A_2</var> <var>...</var> <var>A_N</var>

Output

Print the minimum possible final health of the last monster alive.

Sample Input 1

4
2 10 8 40

Sample Output 1

2

When only the first monster keeps on attacking, the final health of the last monster will be <var>2</var>, which is minimum.

Sample Input 2

4
5 13 8 1000000000

Sample Output 2

1

Sample Input 3

3
1000000000 1000000000 1000000000

Sample Output 3

1000000000


Score : <var>300</var> points

Problem Statement

There are <var>N</var> Reversi pieces arranged in a row. (A Reversi piece is a disc with a black side and a white side.)
The state of each piece is represented by a string <var>S</var> of length <var>N</var>.
If <var>S_i=</var>B, the <var>i</var>-th piece from the left is showing black;
If <var>S_i=</var>W, the <var>i</var>-th piece from the left is showing white.

Consider performing the following operation:

Choose <var>i</var> (<var>1 \leq i < N</var>) such that the <var>i</var>-th piece from the left is showing black and the <var>(i+1)</var>-th piece from the left is showing white, then flip both of those pieces. That is, the <var>i</var>-th piece from the left is now showing white and the <var>(i+1)</var>-th piece from the left is now showing black.

Find the maximum possible number of times this operation can be performed.

Constraints

<var>1 \leq |S| \leq 2\times 10^5</var>

<var>S_i=</var>B or W

Input

Input is given from Standard Input in the following format:

<var>S</var>

Output

Print the maximum possible number of times the operation can be performed.

Sample Input 1

BBW

Sample Output 1

2

The operation can be performed twice, as follows:

Flip the second and third pieces from the left.

Flip the first and second pieces from the left.

Sample Input 2

BWBWBW

Sample Output 2

6


Score : <var>300</var> points

Problem

Takahashi, who is a novice in competitive programming, wants to learn <var>M</var> algorithms.
Initially, his understanding level of each of the <var>M</var> algorithms is <var>0</var>.

Takahashi is visiting a bookstore, where he finds <var>N</var> books on algorithms.
The <var>i</var>-th book (<var>1\leq i\leq N</var>) is sold for <var>C_i</var> yen (the currency of Japan). If he buys and reads it, his understanding level of the <var>j</var>-th algorithm will increase by <var>A_{i,j}</var> for each <var>j</var> (<var>1\leq j\leq M</var>).
There is no other way to increase the understanding levels of the algorithms.

Takahashi's objective is to make his understanding levels of all the <var>M</var> algorithms <var>X</var> or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it.

Constraints

All values in input are integers.

<var>1\leq N, M\leq 12</var>

<var>1\leq X\leq 10^5</var>

<var>1\leq C_i \leq 10^5</var>

<var>0\leq A_{i, j} \leq 10^5</var>

Input

Input is given from Standard Input in the following format:

<var>N</var> <var>M</var> <var>X</var>
<var>C_1</var> <var>A_{1,1}</var> <var>A_{1,2}</var> <var>\cdots</var> <var>A_{1,M}</var>
<var>C_2</var> <var>A_{2,1}</var> <var>A_{2,2}</var> <var>\cdots</var> <var>A_{2,M}</var>
<var>\vdots</var>
<var>C_N</var> <var>A_{N,1}</var> <var>A_{N,2}</var> <var>\cdots</var> <var>A_{N,M}</var>

Output

If the objective is not achievable, print -1; otherwise, print the minimum amount of money needed to achieve it.

Sample Input 1

3 3 10
60 2 2 4
70 8 7 9
50 2 3 9

Sample Output 1

120

Buying the second and third books makes his understanding levels of all the algorithms <var>10</var> or higher, at the minimum cost possible.

Sample Input 2

3 3 10
100 3 1 4
100 1 5 9
100 2 6 5

Sample Output 2

-1

Buying all the books is still not enough to make his understanding levels of all the algorithms <var>10</var> or higher.

Sample Input 3

8 5 22
100 3 7 5 3 1
164 4 5 2 7 8
334 7 2 7 2 9
234 4 7 2 8 2
541 5 4 3 3 6
235 4 8 6 9 7
394 3 6 1 6 2
872 8 4 3 7 2

Sample Output 3

1067


Score : <var>200</var> points

Problem Statement

We have <var>N</var> points in the two-dimensional plane. The coordinates of the <var>i</var>-th point are <var>(X_i,Y_i)</var>.

Among them, we are looking for the points such that the distance from the origin is at most <var>D</var>. How many such points are there?

We remind you that the distance between the origin and the point <var>(p, q)</var> can be represented as <var>\sqrt{p^2+q^2}</var>.

Constraints

<var>1 \leq N \leq 2\times 10^5</var>

<var>0 \leq D \leq 2\times 10^5</var>

<var>|X_i|,|Y_i| \leq 2\times 10^5</var>

All values in input are integers.

Input

Input is given from Standard Input in the following format:

<var>N</var> <var>D</var>
<var>X_1</var> <var>Y_1</var>
<var>\vdots</var>
<var>X_N</var> <var>Y_N</var>

Output

Print an integer representing the number of points such that the distance from the origin is at most <var>D</var>.

Sample Input 1

4 5
0 5
-2 4
3 4
4 -4

Sample Output 1

3

The distance between the origin and each of the given points is as follows:

<var>\sqrt{0^2+5^2}=5</var>

<var>\sqrt{(-2)^2+4^2}=4.472\ldots</var>

<var>\sqrt{3^2+4^2}=5</var>

<var>\sqrt{4^2+(-4)^2}=5.656\ldots</var>

Thus, we have three points such that the distance from the origin is at most <var>5</var>.

Sample Input 2

12 3
1 1
1 1
1 1
1 1
1 2
1 3
2 1
2 2
2 3
3 1
3 2
3 3

Sample Output 2

7

Multiple points may exist at the same coordinates.

Sample Input 3

20 100000
14309 -32939
-56855 100340
151364 25430
103789 -113141
147404 -136977
-37006 -30929
188810 -49557
13419 70401
-88280 165170
-196399 137941
-176527 -61904
46659 115261
-153551 114185
98784 -6820
94111 -86268
-30401 61477
-55056 7872
5901 -163796
138819 -185986
-69848 -96669

Sample Output 3

6


Score : <var>200</var> points

Problem Statement

You are given a string <var>s</var> consisting of lowercase English letters. Extract all the characters in the odd-indexed positions and print the string obtained by concatenating them. Here, the leftmost character is assigned the index <var>1</var>.

Constraints

Each character in <var>s</var> is a lowercase English letter.

<var>1≤|s|≤10^5</var>

Input

The input is given from Standard Input in the following format:

<var>s</var>

Output

Print the string obtained by concatenating all the characters in the odd-numbered positions.

Sample Input 1

atcoder

Sample Output 1

acdr

Extract the first character a, the third character c, the fifth character d and the seventh character r to obtain acdr.

Sample Input 2

aaaa

Sample Output 2

aa

Sample Input 3

z

Sample Output 3

z

Sample Input 4

fukuokayamaguchi

Sample Output 4

fkoaaauh


Score : <var>400</var> points

Problem Statement

Given are integers <var>A</var>, <var>B</var>, and <var>N</var>.

Find the maximum possible value of <var>floor(Ax/B) - A × floor(x/B)</var> for a non-negative integer <var>x</var> not greater than <var>N</var>.

Here <var>floor(t)</var> denotes the greatest integer not greater than the real number <var>t</var>.

Constraints

<var>1 ≤ A ≤ 10^{6}</var>

<var>1 ≤ B ≤ 10^{12}</var>

<var>1 ≤ N ≤ 10^{12}</var>

All values in input are integers.

Input

Input is given from Standard Input in the following format:

<var>A</var> <var>B</var> <var>N</var>

Output

Print the maximum possible value of <var>floor(Ax/B) - A × floor(x/B)</var> for a non-negative integer <var>x</var> not greater than <var>N</var>, as an integer.

Sample Input 1

5 7 4

Sample Output 1

2

When <var>x=3</var>, <var>floor(Ax/B)-A×floor(x/B) = floor(15/7) - 5×floor(3/7) = 2</var>. This is the maximum value possible.

Sample Input 2

11 10 9

Sample Output 2

9


Score : <var>100</var> points

Problem Statement

There is an <var>N</var>-car train.

You are given an integer <var>i</var>. Find the value of <var>j</var> such that the following statement is true: "the <var>i</var>-th car from the front of the train is the <var>j</var>-th car from the back."

Constraints

<var>1 \leq N \leq 100</var>

<var>1 \leq i \leq N</var>

Input

Input is given from Standard Input in the following format:

<var>N</var> <var>i</var>

Output

Print the answer.

Sample Input 1

4 2

Sample Output 1

3

The second car from the front of a <var>4</var>-car train is the third car from the back.

Sample Input 2

1 1

Sample Output 2

1

Sample Input 3

15 11

Sample Output 3

5


Score : <var>200</var> points

Problem Statement

We ask you to select some number of positive integers, and calculate the sum of them.

It is allowed to select as many integers as you like, and as large integers as you wish.
You have to follow these, however: each selected integer needs to be a multiple of <var>A</var>, and you need to select at least one integer.

Your objective is to make the sum congruent to <var>C</var> modulo <var>B</var>.
Determine whether this is possible.

If the objective is achievable, print YES. Otherwise, print NO.

Constraints

<var>1 ≤ A ≤ 100</var>

<var>1 ≤ B ≤ 100</var>

<var>0 ≤ C < B</var>

Input

Input is given from Standard Input in the following format:

<var>A</var> <var>B</var> <var>C</var>

Output

Print YES or NO.

Sample Input 1

7 5 1

Sample Output 1

YES

For example, if you select <var>7</var> and <var>14</var>, the sum <var>21</var> is congruent to <var>1</var> modulo <var>5</var>.

Sample Input 2

2 2 1

Sample Output 2

NO

The sum of even numbers, no matter how many, is never odd.

Sample Input 3

1 100 97

Sample Output 3

YES

You can select <var>97</var>, since you may select multiples of <var>1</var>, that is, all integers.

Sample Input 4

40 98 58

Sample Output 4

YES

Sample Input 5

77 42 36

Sample Output 5

NO


Score : <var>200</var> points

Problem Statement

Takahashi has many red balls and blue balls. Now, he will place them in a row.

Initially, there is no ball placed.

Takahashi, who is very patient, will do the following operation <var>10^{100}</var> times:

Place <var>A</var> blue balls at the end of the row of balls already placed. Then, place <var>B</var> red balls at the end of the row.

How many blue balls will be there among the first <var>N</var> balls in the row of balls made this way?

Constraints

<var>1 \leq N \leq 10^{18}</var>

<var>A, B \geq 0</var>

<var>0 < A + B \leq 10^{18}</var>

All values in input are integers.

Input

Input is given from Standard Input in the following format:

<var>N</var> <var>A</var> <var>B</var>

Output

Print the number of blue balls that will be there among the first <var>N</var> balls in the row of balls.

Sample Input 1

8 3 4

Sample Output 1

4

Let b denote a blue ball, and r denote a red ball. The first eight balls in the row will be bbbrrrrb, among which there are four blue balls.

Sample Input 2

8 0 4

Sample Output 2

0

He placed only red balls from the beginning.

Sample Input 3

6 2 4

Sample Output 3

2

Among bbrrrr, there are two blue balls.


Score: <var>200</var> points

Problem Statement

The restaurant AtCoder serves the following five dishes:

ABC Don (rice bowl): takes <var>A</var> minutes to serve.

ARC Curry: takes <var>B</var> minutes to serve.

AGC Pasta: takes <var>C</var> minutes to serve.

APC Ramen: takes <var>D</var> minutes to serve.

ATC Hanbagu (hamburger patty): takes <var>E</var> minutes to serve.

Here, the time to serve a dish is the time between when an order is placed and when the dish is delivered.

This restaurant has the following rules on orders:

An order can only be placed at a time that is a multiple of <var>10</var> (time <var>0</var>, <var>10</var>, <var>20</var>, <var>...</var>).

Only one dish can be ordered at a time.

No new order can be placed when an order is already placed and the dish is still not delivered, but a new order can be placed at the exact time when the dish is delivered.

E869120 arrives at this restaurant at time <var>0</var>. He will order all five dishes. Find the earliest possible time for the last dish to be delivered.

Here, he can order the dishes in any order he likes, and he can place an order already at time <var>0</var>.

Constraints

<var>A, B, C, D</var> and <var>E</var> are integers between <var>1</var> and <var>123</var> (inclusive).

Input

Input is given from Standard Input in the following format:

<var>A</var>
<var>B</var>
<var>C</var>
<var>D</var>
<var>E</var>

Output

Print the earliest possible time for the last dish to be delivered, as an integer.

Sample Input 1

29
20
7
35
120

Sample Output 1

215

If we decide to order the dishes in the order ABC Don, ARC Curry, AGC Pasta, ATC Hanbagu, APC Ramen, the earliest possible time for each order is as follows:

Order ABC Don at time <var>0</var>, which will be delivered at time <var>29</var>.

Order ARC Curry at time <var>30</var>, which will be delivered at time <var>50</var>.

Order AGC Pasta at time <var>50</var>, which will be delivered at time <var>57</var>.

Order ATC Hanbagu at time <var>60</var>, which will be delivered at time <var>180</var>.

Order APC Ramen at time <var>180</var>, which will be delivered at time <var>215</var>.

There is no way to order the dishes in which the last dish will be delivered earlier than this.

Sample Input 2

101
86
119
108
57

Sample Output 2

481

If we decide to order the dishes in the order AGC Pasta, ARC Curry, ATC Hanbagu, APC Ramen, ABC Don, the earliest possible time for each order is as follows:

Order AGC Pasta at time <var>0</var>, which will be delivered at time <var>119</var>.

Order ARC Curry at time <var>120</var>, which will be delivered at time <var>206</var>.

Order ATC Hanbagu at time <var>210</var>, which will be delivered at time <var>267</var>.

Order APC Ramen at time <var>270</var>, which will be delivered at time <var>378</var>.

Order ABC Don at time <var>380</var>, which will be delivered at time <var>481</var>.

There is no way to order the dishes in which the last dish will be delivered earlier than this.

Sample Input 3

123
123
123
123
123

Sample Output 3

643

This is the largest valid case.


Score : <var>200</var> points

Problem Statement

The postal code in Atcoder Kingdom is <var>A+B+1</var> characters long, its <var>(A+1)</var>-th character is a hyphen -, and the other characters are digits from 0 through 9.

You are given a string <var>S</var>. Determine whether it follows the postal code format in Atcoder Kingdom.

Constraints

<var>1≤A,B≤5</var>

<var>|S|=A+B+1</var>

<var>S</var> consists of - and digits from 0 through 9.

Input

Input is given from Standard Input in the following format:

<var>A</var> <var>B</var>
<var>S</var>

Output

Print Yes if <var>S</var> follows the postal code format in AtCoder Kingdom; print No otherwise.

Sample Input 1

3 4
269-6650

Sample Output 1

Yes

The <var>(A+1)</var>-th character of <var>S</var> is -, and the other characters are digits from 0 through 9, so it follows the format.

Sample Input 2

1 1
---

Sample Output 2

No

<var>S</var> contains unnecessary -s other than the <var>(A+1)</var>-th character, so it does not follow the format.

Sample Input 3

1 2
7444

Sample Output 3

No


Score : <var>100</var> points

Problem Statement

Takahashi has decided to distribute <var>N</var> AtCoder Crackers to <var>K</var> users of as evenly as possible.
When all the crackers are distributed, find the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user.

Constraints

<var>1 \leq N,K \leq 100</var>

All values in input are integers.

Input

Input is given from Standard Input in the following format:

<var>N</var> <var>K</var>

Output

Print the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user.

Sample Input 1

7 3

Sample Output 1

1

When the users receive two, two and three crackers, respectively, the (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user, is <var>1</var>.

Sample Input 2

100 10

Sample Output 2

0

The crackers can be distributed evenly.

Sample Input 3

1 1

Sample Output 3

0


Score : <var>100</var> points

Problem Statement

Ringo is giving a present to Snuke.

Ringo has found out that Snuke loves yakiniku (a Japanese term meaning grilled meat. yaki: grilled, niku: meat). He supposes that Snuke likes grilled things starting with YAKI in Japanese, and does not like other things.

You are given a string <var>S</var> representing the Japanese name of Ringo's present to Snuke. Determine whether <var>S</var> starts with YAKI.

Constraints

<var>1 \leq |S| \leq 10</var>

<var>S</var> consists of uppercase English letters.

Input

Input is given from Standard Input in the following format:

<var>S</var>

Output

If <var>S</var> starts with YAKI, print Yes; otherwise, print No.

Sample Input 1

YAKINIKU

Sample Output 1

Yes

YAKINIKU starts with YAKI.

Sample Input 2

TAKOYAKI

Sample Output 2

No

TAKOYAKI (a Japanese snack. tako: octopus) does not start with YAKI.

Sample Input 3

YAK

Sample Output 3

No


Score : <var>100</var> points

Problem Statement

There are <var>N</var> items, numbered <var>1, 2, \ldots, N</var>.
For each <var>i</var> (<var>1 \leq i \leq N</var>), Item <var>i</var> has a weight of <var>w_i</var> and a value of <var>v_i</var>.

Taro has decided to choose some of the <var>N</var> items and carry them home in a knapsack.
The capacity of the knapsack is <var>W</var>, which means that the sum of the weights of items taken must be at most <var>W</var>.

Find the maximum possible sum of the values of items that Taro takes home.

Constraints

All values in input are integers.

<var>1 \leq N \leq 100</var>

<var>1 \leq W \leq 10^9</var>

<var>1 \leq w_i \leq W</var>

<var>1 \leq v_i \leq 10^3</var>

Input

Input is given from Standard Input in the following format:

<var>N</var> <var>W</var>
<var>w_1</var> <var>v_1</var>
<var>w_2</var> <var>v_2</var>
<var>:</var>
<var>w_N</var> <var>v_N</var>

Output

Print the maximum possible sum of the values of items that Taro takes home.

Sample Input 1

3 8
3 30
4 50
5 60

Sample Output 1

90

Items <var>1</var> and <var>3</var> should be taken.
Then, the sum of the weights is <var>3 + 5 = 8</var>, and the sum of the values is <var>30 + 60 = 90</var>.

Sample Input 2

1 1000000000
1000000000 10

Sample Output 2

10

Sample Input 3

6 15
6 5
5 6
6 4
6 6
3 5
7 2

Sample Output 3

17

Items <var>2, 4</var> and <var>5</var> should be taken.
Then, the sum of the weights is <var>5 + 6 + 3 = 14</var>, and the sum of the values is <var>6 + 6 + 5 = 17</var>.


Score : <var>200</var> points

Problem Statement

You are given two positive integers <var>A</var> and <var>B</var>. Compare the magnitudes of these numbers.

Constraints

<var>1 ≤ A, B ≤ 10^{100}</var>

Neither <var>A</var> nor <var>B</var> begins with a 0.

Input

Input is given from Standard Input in the following format:

<var>A</var>
<var>B</var>

Output

Print GREATER if <var>A>B</var>, LESS if <var>A<B</var> and EQUAL if <var>A=B</var>.

Sample Input 1

36
24

Sample Output 1

GREATER

Since <var>36>24</var>, print GREATER.

Sample Input 2

850
3777

Sample Output 2

LESS

Sample Input 3

9720246
22516266

Sample Output 3

LESS

Sample Input 4

123456789012345678901234567890
234567890123456789012345678901

Sample Output 4

LESS


Score : <var>100</var> points

Problem Statement

You are given a string <var>S</var> as input. This represents a valid date in the year <var>2019</var> in the yyyy/mm/dd format. (For example, April <var>30</var>, <var>2019</var> is represented as 2019/04/30.)

Write a program that prints Heisei if the date represented by <var>S</var> is not later than April <var>30</var>, <var>2019</var>, and prints TBD otherwise.

Constraints

<var>S</var> is a string that represents a valid date in the year <var>2019</var> in the yyyy/mm/dd format.

Input

Input is given from Standard Input in the following format:

<var>S</var>

Output

Print Heisei if the date represented by <var>S</var> is not later than April <var>30</var>, <var>2019</var>, and print TBD otherwise.

Sample Input 1

2019/04/30

Sample Output 1

Heisei

Sample Input 2

2019/11/01

Sample Output 2

TBD


Score : <var>400</var> points

Problem Statement

Give a pair of integers <var>(A, B)</var> such that <var>A^5-B^5 = X</var>.
It is guaranteed that there exists such a pair for the given integer <var>X</var>.

Constraints

<var>1 \leq X \leq 10^9</var>

<var>X</var> is an integer.

There exists a pair of integers <var>(A, B)</var> satisfying the condition in Problem Statement.

Input

Input is given from Standard Input in the following format:

<var>X</var>

Output

Print <var>A</var> and <var>B</var>, with space in between.
If there are multiple pairs of integers <var>(A, B)</var> satisfying the condition, you may print any of them.

<var>A</var> <var>B</var>

Sample Input 1

33

Sample Output 1

2 -1

For <var>A=2</var> and <var>B=-1</var>, <var>A^5-B^5 = 33</var>.

Sample Input 2

1

Sample Output 2

0 -1


Score : <var>300</var> points

Problem Statement

Given are <var>N</var> integers <var>A_1,\ldots,A_N</var>.

Find the sum of <var>A_i \times A_j</var> over all pairs <var>(i,j)</var> such that <var>1\leq i < j \leq N</var>, modulo <var>(10^9+7)</var>.

Constraints

<var>2 \leq N \leq 2\times 10^5</var>

<var>0 \leq A_i \leq 10^9</var>

All values in input are integers.

Input

Input is given from Standard Input in the following format:

<var>N</var>
<var>A_1</var> <var>\ldots</var> <var>A_N</var>

Output

Print <var>\sum_{i=1}^{N-1}\sum_{j=i+1}^{N} A_i A_j</var>, modulo <var>(10^9+7)</var>.

Sample Input 1

3
1 2 3

Sample Output 1

11

We have <var>1 \times 2 + 1 \times 3 + 2 \times 3 = 11</var>.

Sample Input 2

4
141421356 17320508 22360679 244949

Sample Output 2

437235829


Score : <var>200</var> points

Problem Statement

Alice and Bob are controlling a robot. They each have one switch that controls the robot.

Alice started holding down her button <var>A</var> second after the start-up of the robot, and released her button <var>B</var> second after the start-up.

Bob started holding down his button <var>C</var> second after the start-up, and released his button <var>D</var> second after the start-up.

For how many seconds both Alice and Bob were holding down their buttons?

Constraints

<var>0≤A<B≤100</var>

<var>0≤C<D≤100</var>

All input values are integers.

Input

Input is given from Standard Input in the following format:

<var>A</var> <var>B</var> <var>C</var> <var>D</var>

Output

Print the length of the duration (in seconds) in which both Alice and Bob were holding down their buttons.

Sample Input 1

0 75 25 100

Sample Output 1

50

Alice started holding down her button <var>0</var> second after the start-up of the robot, and released her button <var>75</var> second after the start-up.

Bob started holding down his button <var>25</var> second after the start-up, and released his button <var>100</var> second after the start-up.

Therefore, the time when both of them were holding down their buttons, is the <var>50</var> seconds from <var>25</var> seconds after the start-up to <var>75</var> seconds after the start-up.

Sample Input 2

0 33 66 99

Sample Output 2

0

Alice and Bob were not holding their buttons at the same time, so the answer is zero seconds.

Sample Input 3

10 90 20 80

Sample Output 3

60


Score : <var>300</var> points

Problem Statement

Given any integer <var>x</var>, Aoki can do the operation below.

Operation: Replace <var>x</var> with the absolute difference of <var>x</var> and <var>K</var>.

You are given the initial value of an integer <var>N</var>. Find the minimum possible value taken by <var>N</var> after Aoki does the operation zero or more times.

Constraints

<var>0 ≤ N ≤ 10^{18}</var>

<var>1 ≤ K ≤ 10^{18}</var>

All values in input are integers.

Input

Input is given from Standard Input in the following format:

<var>N</var> <var>K</var>

Output

Print the minimum possible value taken by <var>N</var> after Aoki does the operation zero or more times.

Sample Input 1

7 4

Sample Output 1

1

Initially, <var>N=7</var>.

After one operation, <var>N</var> becomes <var>|7-4| = 3</var>.

After two operations, <var>N</var> becomes <var>|3-4| = 1</var>, which is the minimum value taken by <var>N</var>.

Sample Input 2

2 6

Sample Output 2

2

<var>N=2</var> after zero operations is the minimum.

Sample Input 3

1000000000000000000 1

Sample Output 3

0


Score : <var>200</var> points

Problem Statement

Takahashi loves palindromes. Non-palindromic strings are unacceptable to him. Each time he hugs a string, he can change one of its characters to any character of his choice.

Given is a string <var>S</var>. Find the minimum number of hugs needed to make <var>S</var> palindromic.

Constraints

<var>S</var> is a string consisting of lowercase English letters.

The length of <var>S</var> is between <var>1</var> and <var>100</var> (inclusive).

Input

Input is given from Standard Input in the following format:

<var>S</var>

Output

Print the minimum number of hugs needed to make <var>S</var> palindromic.

Sample Input 1

redcoder

Sample Output 1

1

For example, we can change the fourth character to o and get a palindrome redooder.

Sample Input 2

vvvvvv

Sample Output 2

0

We might need no hugs at all.

Sample Input 3

abcdabc

Sample Output 3

2


Score : <var>200</var> points

Problem Statement

Given are strings <var>s</var> and <var>t</var> of length <var>N</var> each, both consisting of lowercase English letters.

Let us form a new string by alternating the characters of <var>S</var> and the characters of <var>T</var>, as follows: the first character of <var>S</var>, the first character of <var>T</var>, the second character of <var>S</var>, the second character of <var>T</var>, <var>...</var>, the <var>N</var>-th character of <var>S</var>, the <var>N</var>-th character of <var>T</var>. Print this new string.

Constraints

<var>1 \leq N \leq 100</var>

<var>|S| = |T| = N</var>

<var>S</var> and <var>T</var> are strings consisting of lowercase English letters.

Input

Input is given from Standard Input in the following format:

<var>N</var>
<var>S</var> <var>T</var>

Output

Print the string formed.

Sample Input 1

2
ip cc

Sample Output 1

icpc

Sample Input 2

8
hmhmnknk uuuuuuuu

Sample Output 2

humuhumunukunuku

Sample Input 3

5
aaaaa aaaaa

Sample Output 3

aaaaaaaaaa


Score : <var>200</var> points

Problem Statement

There is an image with a height of <var>H</var> pixels and a width of <var>W</var> pixels. Each of the pixels is represented by either . or *. The character representing the pixel at the <var>i</var>-th row from the top and the <var>j</var>-th column from the left, is denoted by <var>C_{i,j}</var>.

Extend this image vertically so that its height is doubled. That is, print a image with a height of <var>2H</var> pixels and a width of <var>W</var> pixels where the pixel at the <var>i</var>-th row and <var>j</var>-th column is equal to <var>C_{(i+1)/2,j}</var> (the result of division is rounded down).

Constraints

<var>1≦H, W≦100</var>

<var>C_{i,j}</var> is either . or *.

Input

The input is given from Standard Input in the following format:

<var>H</var> <var>W</var>
<var>C_{1,1}...C_{1,W}</var>
:
<var>C_{H,1}...C_{H,W}</var>

Output

Print the extended image.

Sample Input 1

2 2
*.
.*

Sample Output 1

*.
*.
.*
.*

Sample Input 2

1 4
***.

Sample Output 2

***.
***.

Sample Input 3

9 20
.....***....***.....
....*...*..*...*....
...*.....**.....*...
...*.....*......*...
....*.....*....*....
.....**..*...**.....
.......*..*.*.......
........**.*........
.........**.........

Sample Output 3

.....***....***.....
.....***....***.....
....*...*..*...*....
....*...*..*...*....
...*.....**.....*...
...*.....**.....*...
...*.....*......*...
...*.....*......*...
....*.....*....*....
....*.....*....*....
.....**..*...**.....
.....**..*...**.....
.......*..*.*.......
.......*..*.*.......
........**.*........
........**.*........
.........**.........
.........**.........


Score : <var>200</var> points

Problem Statement

We have a board with <var>H</var> horizontal rows and <var>W</var> vertical columns of squares.
There is a bishop at the top-left square on this board.
How many squares can this bishop reach by zero or more movements?

Here the bishop can only move diagonally.
More formally, the bishop can move from the square at the <var>r_1</var>-th row (from the top) and the <var>c_1</var>-th column (from the left) to the square at the <var>r_2</var>-th row and the <var>c_2</var>-th column if and only if exactly one of the following holds:

<var>r_1 + c_1 = r_2 + c_2</var>

<var>r_1 - c_1 = r_2 - c_2</var>

For example, in the following figure, the bishop can move to any of the red squares in one move:

Constraints

<var>1 \leq H, W \leq 10^9</var>

All values in input are integers.

Input

Input is given from Standard Input in the following format:

<var>H \ W</var>

Output

Print the number of squares the bishop can reach.

Sample Input 1

4 5

Sample Output 1

10

The bishop can reach the cyan squares in the following figure:

Sample Input 2

7 3

Sample Output 2

11

The bishop can reach the cyan squares in the following figure:

Sample Input 3

1000000000 1000000000

Sample Output 3

500000000000000000


Score : <var>100</var> points

Problem Statement

Given is a lowercase English letter <var>C</var> that is not z. Print the letter that follows <var>C</var> in alphabetical order.

Constraints

<var>C</var> is a lowercase English letter that is not z.

Input

Input is given from Standard Input in the following format:

<var>C</var>

Output

Print the letter that follows <var>C</var> in alphabetical order.

Sample Input 1

a

Sample Output 1

b

a is followed by b.

Sample Input 2

y

Sample Output 2

z

y is followed by z.


Score : <var>100</var> points

Problem Statement

There are <var>H</var> rows and <var>W</var> columns of white square cells.

You will choose <var>h</var> of the rows and <var>w</var> of the columns, and paint all of the cells contained in those rows or columns.

How many white cells will remain?

It can be proved that this count does not depend on what rows and columns are chosen.

Constraints

All values in input are integers.

<var>1 \leq H, W \leq 20</var>

<var>1 \leq h \leq H</var>

<var>1 \leq w \leq W</var>

Input

Input is given from Standard Input in the following format:

<var>H</var> <var>W</var>
<var>h</var> <var>w</var>

Output

Print the number of white cells that will remain.

Sample Input 1

3 2
2 1

Sample Output 1

1

There are <var>3</var> rows and <var>2</var> columns of cells. When two rows and one column are chosen and painted in black, there is always one white cell that remains.

Sample Input 2

5 5
2 3

Sample Output 2

6

Sample Input 3

2 4
2 4

Sample Output 3

0


Score : <var>100</var> points

Problem Statement

Having learned the multiplication table, Takahashi can multiply two integers between <var>1</var> and <var>9</var> (inclusive) together. He cannot do any other calculation.

Given are two integers <var>A</var> and <var>B</var>.

If Takahashi can calculate <var>A \times B</var>, print the result; if he cannot, print -1 instead.

Constraints

<var>1 \leq A \leq 20</var>

<var>1 \leq B \leq 20</var>

All values in input are integers.

Input

Input is given from Standard Input in the following format:

<var>A</var> <var>B</var>

Output

If Takahashi can calculate <var>A \times B</var>, print the result; if he cannot, print -1.

Sample Input 1

2 5

Sample Output 1

10

<var>2 \times 5 = 10</var>.

Sample Input 2

5 10

Sample Output 2

-1

<var>5\times 10 = 50</var>, but Takahashi cannot do this calculation, so print -1 instead.

Sample Input 3

9 9

Sample Output 3

81


Score : <var>300</var> points

Problem Statement

There are <var>N</var> slimes lining up from left to right. The colors of these slimes will be given as a string <var>S</var> of length <var>N</var> consisting of lowercase English letters. The <var>i</var>-th slime from the left has the color that corresponds to the <var>i</var>-th character of <var>S</var>.

Adjacent slimes with the same color will fuse into one larger slime without changing the color. If there were a slime adjacent to this group of slimes before fusion, that slime is now adjacent to the new larger slime.

Ultimately, how many slimes will be there?

Constraints

<var>1 \leq N \leq 10^5</var>

<var>|S| = N</var>

<var>S</var> consists of lowercase English letters.

Input

Input is given from Standard Input in the following format:

<var>N</var>
<var>S</var>

Output

Print the final number of slimes.

Sample Input 1

10
aabbbbaaca

Sample Output 1

5

Ultimately, these slimes will fuse into abaca.

Sample Input 2

5
aaaaa

Sample Output 2

1

All the slimes will fuse into one.

Sample Input 3

20
xxzaffeeeeddfkkkkllq

Sample Output 3

10


Score : <var>200</var> points

Problem Statement

There is a square in the <var>xy</var>-plane. The coordinates of its four vertices are <var>(x_1,y_1),(x_2,y_2),(x_3,y_3)</var> and <var>(x_4,y_4)</var> in counter-clockwise order.
(Assume that the positive <var>x</var>-axis points right, and the positive <var>y</var>-axis points up.)

Takahashi remembers <var>(x_1,y_1)</var> and <var>(x_2,y_2)</var>, but he has forgot <var>(x_3,y_3)</var> and <var>(x_4,y_4)</var>.

Given <var>x_1,x_2,y_1,y_2</var>, restore <var>x_3,y_3,x_4,y_4</var>. It can be shown that <var>x_3,y_3,x_4</var> and <var>y_4</var> uniquely exist and have integer values.

Constraints

<var>|x_1|,|y_1|,|x_2|,|y_2| \leq 100</var>

<var>(x_1,y_1)</var> ≠ <var>(x_2,y_2)</var>

All values in input are integers.

Input

Input is given from Standard Input in the following format:

<var>x_1</var> <var>y_1</var> <var>x_2</var> <var>y_2</var>

Output

Print <var>x_3,y_3,x_4</var> and <var>y_4</var> as integers, in this order.

Sample Input 1

0 0 0 1

Sample Output 1

-1 1 -1 0

<var>(0,0),(0,1),(-1,1),(-1,0)</var> is the four vertices of a square in counter-clockwise order.
Note that <var>(x_3,y_3)=(1,1),(x_4,y_4)=(1,0)</var> is not accepted, as the vertices are in clockwise order.

Sample Input 2

2 3 6 6

Sample Output 2

3 10 -1 7

Sample Input 3

31 -41 -59 26

Sample Output 3

-126 -64 -36 -131


Score : <var>200</var> points

Problem Statement

In some village, there are <var>999</var> towers that are <var>1,(1+2),(1+2+3),...,(1+2+3+...+999)</var> meters high from west to east, at intervals of <var>1</var> meter.

It had been snowing for a while before it finally stopped. For some two adjacent towers located <var>1</var> meter apart, we measured the lengths of the parts of those towers that are not covered with snow, and the results are <var>a</var> meters for the west tower, and <var>b</var> meters for the east tower.

Assuming that the depth of snow cover and the altitude are the same everywhere in the village, find the amount of the snow cover.

Assume also that the depth of the snow cover is always at least <var>1</var> meter.

Constraints

<var>1 \leq a < b < 499500(=1+2+3+...+999)</var>

All values in input are integers.

There is no input that contradicts the assumption.

Input

Input is given from Standard Input in the following format:

<var>a</var> <var>b</var>

Output

If the depth of the snow cover is <var>x</var> meters, print <var>x</var> as an integer.

Sample Input 1

8 13

Sample Output 1

2

The heights of the two towers are <var>10</var> meters and <var>15</var> meters, respectively.
Thus, we can see that the depth of the snow cover is <var>2</var> meters.

Sample Input 2

54 65

Sample Output 2

1


Score : <var>200</var> points

Problem Statement

Find the largest square number not exceeding <var>N</var>. Here, a square number is an integer that can be represented as the square of an integer.

Constraints

<var>1 \leq N \leq 10^9</var>

<var>N</var> is an integer.

Input

Input is given from Standard Input in the following format:

<var>N</var>

Output

Print the largest square number not exceeding <var>N</var>.

Sample Input 1

10

Sample Output 1

9

<var>10</var> is not square, but <var>9 = 3 × 3</var> is. Thus, we print <var>9</var>.

Sample Input 2

81

Sample Output 2

81

Sample Input 3

271828182

Sample Output 3

271821169


Score : <var>100</var> points

Problem Statement

You are given a trapezoid. The lengths of its upper base, lower base, and height are <var>a</var>, <var>b</var>, and <var>h</var>, respectively.

An example of a trapezoid

Find the area of this trapezoid.

Constraints

<var>1≦a≦100</var>

<var>1≦b≦100</var>

<var>1≦h≦100</var>

All input values are integers.

<var>h</var> is even.

Input

The input is given from Standard Input in the following format:

<var>a</var>
<var>b</var>
<var>h</var>

Output

Print the area of the given trapezoid. It is guaranteed that the area is an integer.

Sample Input 1

3
4
2

Sample Output 1

7

When the lengths of the upper base, lower base, and height are <var>3</var>, <var>4</var>, and <var>2</var>, respectively, the area of the trapezoid is <var>(3+4)×2/2 = 7</var>.

Sample Input 2

4
4
4

Sample Output 2

16

In this case, a parallelogram is given, which is also a trapezoid.


Score : <var>400</var> points

Problem Statement

There are <var>N</var> people standing in a queue from west to east.

Given is a string <var>S</var> of length <var>N</var> representing the directions of the people.
The <var>i</var>-th person from the west is facing west if the <var>i</var>-th character of <var>S</var> is L, and east if that character of <var>S</var> is R.

A person is happy if the person in front of him/her is facing the same direction.
If no person is standing in front of a person, however, he/she is not happy.

You can perform the following operation any number of times between <var>0</var> and <var>K</var> (inclusive):

Operation: Choose integers <var>l</var> and <var>r</var> such that <var>1 \leq l \leq r \leq N</var>, and rotate by <var>180</var> degrees the part of the queue: the <var>l</var>-th, <var>(l+1)</var>-th, <var>...</var>, <var>r</var>-th persons. That is, for each <var>i = 0, 1, ..., r-l</var>, the <var>(l + i)</var>-th person from the west will stand the <var>(r - i)</var>-th from the west after the operation, facing east if he/she is facing west now, and vice versa.

What is the maximum possible number of happy people you can have?

Constraints

<var>N</var> is an integer satisfying <var>1 \leq N \leq 10^5</var>.

<var>K</var> is an integer satisfying <var>1 \leq K \leq 10^5</var>.

<var>|S| = N</var>

Each character of <var>S</var> is L or R.

Input

Input is given from Standard Input in the following format:

<var>N</var> <var>K</var>
<var>S</var>

Output

Print the maximum possible number of happy people after at most <var>K</var> operations.

Sample Input 1

6 1
LRLRRL

Sample Output 1

3

If we choose <var>(l, r) = (2, 5)</var>, we have LLLRLL, where the <var>2</var>-nd, <var>3</var>-rd, and <var>6</var>-th persons from the west are happy.

Sample Input 2

13 3
LRRLRLRRLRLLR

Sample Output 2

9

Sample Input 3

10 1
LLLLLRRRRR

Sample Output 3

9

Sample Input 4

9 2
RRRLRLRLL

Sample Output 4

7


Score : <var>300</var> points

Problem Statement

You are given an integer sequence of length <var>N</var>, <var>a_1,a_2,...,a_N</var>.

For each <var>1≤i≤N</var>, you have three choices: add <var>1</var> to <var>a_i</var>, subtract <var>1</var> from <var>a_i</var> or do nothing.

After these operations, you select an integer <var>X</var> and count the number of <var>i</var> such that <var>a_i=X</var>.

Maximize this count by making optimal choices.

Constraints

<var>1≤N≤10^5</var>

<var>0≤a_i<10^5 (1≤i≤N)</var>

<var>a_i</var> is an integer.

Input

The input is given from Standard Input in the following format:

<var>N</var>
<var>a_1</var> <var>a_2</var> .. <var>a_N</var>

Output

Print the maximum possible number of <var>i</var> such that <var>a_i=X</var>.

Sample Input 1

7
3 1 4 1 5 9 2

Sample Output 1

4

For example, turn the sequence into <var>2,2,3,2,6,9,2</var> and select <var>X=2</var> to obtain <var>4</var>, the maximum possible count.

Sample Input 2

10
0 1 2 3 4 5 6 7 8 9

Sample Output 2

3

Sample Input 3

1
99999

Sample Output 3

1


Score : <var>100</var> points

Problem Statement

You have three tasks, all of which need to be completed.

First, you can complete any one task at cost <var>0</var>.

Then, just after completing the <var>i</var>-th task, you can complete the <var>j</var>-th task at cost <var>|A_j - A_i|</var>.

Here, <var>|x|</var> denotes the absolute value of <var>x</var>.

Find the minimum total cost required to complete all the task.

Constraints

All values in input are integers.

<var>1 \leq A_1, A_2, A_3 \leq 100</var>

Input

Input is given from Standard Input in the following format:

<var>A_1</var> <var>A_2</var> <var>A_3</var>

Output

Print the minimum total cost required to complete all the task.

Sample Input 1

1 6 3

Sample Output 1

5

When the tasks are completed in the following order, the total cost will be <var>5</var>, which is the minimum:

Complete the first task at cost <var>0</var>.

Complete the third task at cost <var>2</var>.

Complete the second task at cost <var>3</var>.

Sample Input 2

11 5 5

Sample Output 2

6

Sample Input 3

100 100 100

Sample Output 3

0


Score : <var>100</var> points

Problem Statement

There is a right triangle <var>ABC</var> with <var>∠ABC=90°</var>.

Given the lengths of the three sides, <var>|AB|,|BC|</var> and <var>|CA|</var>, find the area of the right triangle <var>ABC</var>.

It is guaranteed that the area of the triangle <var>ABC</var> is an integer.

Constraints

<var>1 \leq |AB|,|BC|,|CA| \leq 100</var>

All values in input are integers.

The area of the triangle <var>ABC</var> is an integer.

Input

Input is given from Standard Input in the following format:

<var>|AB|</var> <var>|BC|</var> <var>|CA|</var>

Output

Print the area of the triangle <var>ABC</var>.

Sample Input 1

3 4 5

Sample Output 1

6

This triangle has an area of <var>6</var>.

Sample Input 2

5 12 13

Sample Output 2

30

This triangle has an area of <var>30</var>.

Sample Input 3

45 28 53

Sample Output 3

630

This triangle has an area of <var>630</var>.


Score : <var>500</var> points

Problem Statement

We have <var>N</var> bulbs arranged on a number line, numbered <var>1</var> to <var>N</var> from left to right.
Bulb <var>i</var> is at coordinate <var>i</var>.

Each bulb has a non-negative integer parameter called intensity.
When there is a bulb of intensity <var>d</var> at coordinate <var>x</var>, the bulb illuminates the segment from coordinate <var>x-d-0.5</var> to <var>x+d+0.5</var>.
Initially, the intensity of Bulb <var>i</var> is <var>A_i</var>. We will now do the following operation <var>K</var> times in a row:

For each integer <var>i</var> between <var>1</var> and <var>N</var> (inclusive), let <var>B_i</var> be the number of bulbs illuminating coordinate <var>i</var>. Then, change the intensity of each bulb <var>i</var> to <var>B_i</var>.

Find the intensity of each bulb after the <var>K</var> operations.

Constraints

<var>1 \leq N \leq 2 \times 10^5</var>

<var>1 \leq K \leq 2 \times 10^5</var>

<var>0 \leq A_i \leq N</var>

Input

Input is given from Standard Input in the following format:

<var>N</var> <var>K</var>
<var>A_1</var> <var>A_2</var> <var>\ldots</var> <var>A_N</var>

Output

Print the intensity <var>A{'}_i</var> of each bulb <var>i</var> after the <var>K</var> operations to Standard Output in the following format:

<var>A{'}_1</var> <var>A{'}_2</var> <var>\ldots</var> <var>A{'}_N</var>

Sample Input 1

5 1
1 0 0 1 0

Sample Output 1

1 2 2 1 2

Initially, only Bulb <var>1</var> illuminates coordinate <var>1</var>, so the intensity of Bulb <var>1</var> becomes <var>1</var> after the operation.
Similarly, the bulbs initially illuminating coordinate <var>2</var> are Bulb <var>1</var> and <var>2</var>, so the intensity of Bulb <var>2</var> becomes <var>2</var>.

Sample Input 2

5 2
1 0 0 1 0

Sample Output 2

3 3 4 4 3


Score : <var>200</var> points

Problem Statement

Snuke signed up for a new website which holds programming competitions.
He worried that he might forget his password, and he took notes of it.
Since directly recording his password would cause him trouble if stolen,
he took two notes: one contains the characters at the odd-numbered positions, and the other contains the characters at the even-numbered positions.

You are given two strings <var>O</var> and <var>E</var>. <var>O</var> contains the characters at the odd-numbered positions retaining their relative order, and <var>E</var> contains the characters at the even-numbered positions retaining their relative order.
Restore the original password.

Constraints

<var>O</var> and <var>E</var> consists of lowercase English letters (a - z).

<var>1 \leq |O|,|E| \leq 50</var>

<var>|O| - |E|</var> is either <var>0</var> or <var>1</var>.

Input

Input is given from Standard Input in the following format:

<var>O</var>
<var>E</var>

Output

Print the original password.

Sample Input 1

xyz
abc

Sample Output 1

xaybzc

The original password is xaybzc. Extracting the characters at the odd-numbered positions results in xyz, and extracting the characters at the even-numbered positions results in abc.

Sample Input 2

atcoderbeginnercontest
atcoderregularcontest

Sample Output 2

aattccooddeerrbreeggiunlnaerrccoonntteesstt


Score : <var>200</var> points

Problem Statement

In some other world, today is the day before Christmas Eve.

Mr. Takaha is buying <var>N</var> items at a department store. The regular price of the <var>i</var>-th item <var>(1 \leq i \leq N)</var> is <var>p_i</var> yen (the currency of Japan).

He has a discount coupon, and can buy one item with the highest price for half the regular price. The remaining <var>N-1</var> items cost their regular prices. What is the total amount he will pay?

Constraints

<var>2 \leq N \leq 10</var>

<var>100 \leq p_i \leq 10000</var>

<var>p_i</var> is an even number.

Input

Input is given from Standard Input in the following format:

<var>N</var>
<var>p_1</var>
<var>p_2</var>
<var>:</var>
<var>p_N</var>

Output

Print the total amount Mr. Takaha will pay.

Sample Input 1

3
4980
7980
6980

Sample Output 1

15950

The <var>7980</var>-yen item gets the discount and the total is <var>4980 + 7980 / 2 + 6980 = 15950</var> yen.

Note that outputs such as 15950.0 will be judged as Wrong Answer.

Sample Input 2

4
4320
4320
4320
4320

Sample Output 2

15120

Only one of the four items gets the discount and the total is <var>4320 / 2 + 4320 + 4320 + 4320 = 15120</var> yen.


Score : <var>200</var> points

Problem Statement

You are given nonnegative integers <var>a</var> and <var>b</var> (<var>a ≤ b</var>), and a positive integer <var>x</var>.
Among the integers between <var>a</var> and <var>b</var>, inclusive, how many are divisible by <var>x</var>?

Constraints

<var>0 ≤ a ≤ b ≤ 10^{18}</var>

<var>1 ≤ x ≤ 10^{18}</var>

Input

The input is given from Standard Input in the following format:

<var>a</var> <var>b</var> <var>x</var>

Output

Print the number of the integers between <var>a</var> and <var>b</var>, inclusive, that are divisible by <var>x</var>.

Sample Input 1

4 8 2

Sample Output 1

3

There are three integers between <var>4</var> and <var>8</var>, inclusive, that are divisible by <var>2</var>: <var>4</var>, <var>6</var> and <var>8</var>.

Sample Input 2

0 5 1

Sample Output 2

6

There are six integers between <var>0</var> and <var>5</var>, inclusive, that are divisible by <var>1</var>: <var>0</var>, <var>1</var>, <var>2</var>, <var>3</var>, <var>4</var> and <var>5</var>.

Sample Input 3

9 9 2

Sample Output 3

0

There are no integer between <var>9</var> and <var>9</var>, inclusive, that is divisible by <var>2</var>.

Sample Input 4

1 1000000000000000000 3

Sample Output 4

333333333333333333

Watch out for integer overflows.


Score : <var>300</var> points

Problem Statement

There is an integer sequence <var>A</var> of length <var>N</var> whose values are unknown.

Given is an integer sequence <var>B</var> of length <var>N-1</var> which is known to satisfy the following:

<var> B_i \geq \max(A_i, A_{i+1}) </var>

Find the maximum possible sum of the elements of <var>A</var>.

Constraints

All values in input are integers.

<var>2 \leq N \leq 100</var>

<var>0 \leq B_i \leq 10^5</var>

Input

Input is given from Standard Input in the following format:

<var>N</var>
<var>B_1</var> <var>B_2</var> <var>...</var> <var>B_{N-1}</var>

Output

Print the maximum possible sum of the elements of <var>A</var>.

Sample Input 1

3
2 5

Sample Output 1

9

<var>A</var> can be, for example, ( <var>2</var> , <var>1</var> , <var>5</var> ), ( <var>-1</var> , <var>-2</var> , <var>-3</var> ), or ( <var>2</var> , <var>2</var> , <var>5</var> ). Among those candidates, <var>A</var> = ( <var>2</var> , <var>2</var> , <var>5</var> ) has the maximum possible sum.

Sample Input 2

2
3

Sample Output 2

6

Sample Input 3

6
0 153 10 10 23

Sample Output 3

53


Score : <var>100</var> points

Problem Statement

There are three houses on a number line: House <var>1</var>, <var>2</var> and <var>3</var>, with coordinates <var>A</var>, <var>B</var> and <var>C</var>, respectively.
Print Yes if we pass the coordinate of House <var>3</var> on the straight way from House <var>1</var> to House <var>2</var> without making a detour, and print No otherwise.

Constraints

<var>0\leq A,B,C\leq 100</var>

<var>A</var>, <var>B</var> and <var>C</var> are distinct integers.

Input

Input is given from Standard Input in the following format:

<var>A</var> <var>B</var> <var>C</var>

Output

Print Yes if we pass the coordinate of House <var>3</var> on the straight way from House <var>1</var> to House <var>2</var> without making a detour, and print No otherwise.

Sample Input 1

3 8 5

Sample Output 1

Yes

We pass the coordinate <var>5</var> on the straight way from the house at coordinate <var>3</var> to the house at coordinate <var>8</var>.

Sample Input 2

7 3 1

Sample Output 2

No

Sample Input 3

10 2 4

Sample Output 3

Yes

Sample Input 4

31 41 59

Sample Output 4

No


Score : <var>100</var> points

Problem Statement

When you asked some guy in your class his name, he called himself <var>S</var>, where <var>S</var> is a string of length between <var>3</var> and <var>20</var> (inclusive) consisting of lowercase English letters.
You have decided to choose some three consecutive characters from <var>S</var> and make it his nickname. Print a string that is a valid nickname for him.

Constraints

<var>3 \leq |S| \leq 20</var>

<var>S</var> consists of lowercase English letters.

Input

Input is given from Standard Input in the following format:

<var>S</var>

Output

Print your answer.

Sample Input 1

takahashi

Sample Output 1

tak

Sample Input 2

naohiro

Sample Output 2

nao


Score : <var>100</var> points

Problem Statement

You are given an integer <var>K</var>.
Print the string obtained by repeating the string ACL <var>K</var> times and concatenating them.

For example, if <var>K = 3</var>, print ACLACLACL.

Constraints

<var>1 \leq K \leq 5</var>

All values in input are integers.

Input

Input is given from Standard Input in the following format:

<var>K</var>

Output

Print the string obtained by repeating the string ACL <var>K</var> times and concatenating them.

Sample Input 1

3

Sample Output 1

ACLACLACL


Score : <var>100</var> points

Problem Statement

Print the <var>K</var>-th element of the following sequence of length <var>32</var>:

1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51

Constraints

<var>1 \leq K \leq 32</var>

All values in input are integers.

Input

Input is given from Standard Input in the following format:

<var>K</var>

Output

Print the <var>K</var>-th element.

Sample Input 1

6

Sample Output 1

2

The <var>6</var>-th element is <var>2</var>.

Sample Input 2

27

Sample Output 2

5

The <var>27</var>-th element is <var>5</var>.


Score : <var>100</var> points

Problem Statement

You are given a grid with <var>2</var> rows and <var>3</var> columns of squares.
The color of the square at the <var>i</var>-th row and <var>j</var>-th column is represented by the character <var>C_{ij}</var>.

Write a program that prints YES if this grid remains the same when rotated <var>180</var> degrees, and prints NO otherwise.

Constraints

<var>C_{i,j}(1 \leq i \leq 2, 1 \leq j \leq 3)</var> is a lowercase English letter.

Input

Input is given from Standard Input in the following format:

<var>C_{11}C_{12}C_{13}</var>
<var>C_{21}C_{22}C_{23}</var>

Output

Print YES if this grid remains the same when rotated <var>180</var> degrees; print NO otherwise.

Sample Input 1

pot
top

Sample Output 1

YES

This grid remains the same when rotated <var>180</var> degrees.

Sample Input 2

tab
bet

Sample Output 2

NO

This grid does not remain the same when rotated <var>180</var> degrees.

Sample Input 3

eye
eel

Sample Output 3

NO


Score : <var>200</var> points

Problem Statement

Today is August <var>24</var>, one of the five Product Days in a year.

A date <var>m</var>-<var>d</var> (<var>m</var> is the month, <var>d</var> is the date) is called a Product Day when <var>d</var> is a two-digit number, and all of the following conditions are satisfied (here <var>d_{10}</var> is the tens digit of the day and <var>d_1</var> is the ones digit of the day):

<var>d_1 \geq 2</var>

<var>d_{10} \geq 2</var>

<var>d_1 \times d_{10} = m</var>

Takahashi wants more Product Days, and he made a new calendar called Takahashi Calendar where a year consists of <var>M</var> month from Month <var>1</var> to Month <var>M</var>, and each month consists of <var>D</var> days from Day <var>1</var> to Day <var>D</var>.

In Takahashi Calendar, how many Product Days does a year have?

Constraints

All values in input are integers.

<var>1 \leq M \leq 100</var>

<var>1 \leq D \leq 99</var>

Input

Input is given from Standard Input in the following format:

<var>M</var> <var>D</var>

Output

Print the number of Product Days in a year in Takahashi Calender.

Sample Input 1

15 40

Sample Output 1

10

There are <var>10</var> Product Days in a year, as follows (<var>m</var>-<var>d</var> denotes Month <var>m</var>, Day <var>d</var>):

<var>4</var>-<var>22</var>

<var>6</var>-<var>23</var>

<var>6</var>-<var>32</var>

<var>8</var>-<var>24</var>

<var>9</var>-<var>33</var>

<var>10</var>-<var>25</var>

<var>12</var>-<var>26</var>

<var>12</var>-<var>34</var>

<var>14</var>-<var>27</var>

<var>15</var>-<var>35</var>

Sample Input 2

12 31

Sample Output 2

5

Sample Input 3

1 1

Sample Output 3

0


Score : <var>100</var> points

Problem Statement

You have decided to give an allowance to your child depending on the outcome of the game that he will play now.

The game is played as follows:

There are three "integer panels", each with a digit between <var>1</var> and <var>9</var> (inclusive) printed on it, and one "operator panel" with a + printed on it.

The player should construct a formula of the form <var>X + Y</var>, by arranging the four panels from left to right. (The operator panel should not be placed at either end of the formula.)

Then, the amount of the allowance will be equal to the resulting value of the formula.

Given the values <var>A, B</var> and <var>C</var> printed on the integer panels used in the game, find the maximum possible amount of the allowance.

Constraints

All values in input are integers.

<var>1 \leq A, B, C \leq 9</var>

Input

Input is given from Standard Input in the following format:

<var>A</var> <var>B</var> <var>C</var>

Output

Print the maximum possible amount of the allowance.

Sample Input 1

1 5 2

Sample Output 1

53

The amount of the allowance will be <var>53</var> when the panels are arranged as 52+1, and this is the maximum possible amount.

Sample Input 2

9 9 9

Sample Output 2

108

Sample Input 3

6 6 7

Sample Output 3

82


Score : <var>300</var> points

Problem Statement

There are <var>N</var> squares arranged in a row from left to right. The height of the <var>i</var>-th square from the left is <var>H_i</var>.

For each square, you will perform either of the following operations once:

Decrease the height of the square by <var>1</var>.

Do nothing.

Determine if it is possible to perform the operations so that the heights of the squares are non-decreasing from left to right.

Constraints

All values in input are integers.

<var>1 \leq N \leq 10^5</var>

<var>1 \leq H_i \leq 10^9</var>

Input

Input is given from Standard Input in the following format:

<var>N</var>
<var>H_1</var> <var>H_2</var> <var>...</var> <var>H_N</var>

Output

If it is possible to perform the operations so that the heights of the squares are non-decreasing from left to right, print Yes; otherwise, print No.

Sample Input 1

5
1 2 1 1 3

Sample Output 1

Yes

You can achieve the objective by decreasing the height of only the second square from the left by <var>1</var>.

Sample Input 2

4
1 3 2 1

Sample Output 2

No

Sample Input 3

5
1 2 3 4 5

Sample Output 3

Yes

Sample Input 4

1
1000000000

Sample Output 4

Yes


Score : <var>200</var> points

Problem Statement

Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A.

The problem has <var>N</var> test cases.

For each test case <var>i</var> (<var>1\leq i \leq N</var>), you are given a string <var>S_i</var> representing the verdict for that test case. Find the numbers of test cases for which the verdict is AC, WA, TLE, and RE, respectively.

See the Output section for the output format.

Constraints

<var>1 \leq N \leq 10^5</var>

<var>S_i</var> is AC, WA, TLE, or RE.

Input

Input is given from Standard Input in the following format:

<var>N</var>
<var>S_1</var>
<var>\vdots</var>
<var>S_N</var>

Output

Let <var>C_0</var>, <var>C_1</var>, <var>C_2</var>, and <var>C_3</var> be the numbers of test cases for which the verdict is AC, WA, TLE, and RE, respectively. Print the following:

AC x <var>C_0</var>
WA x <var>C_1</var>
TLE x <var>C_2</var>
RE x <var>C_3</var>

Sample Input 1

6
AC
TLE
AC
AC
WA
TLE

Sample Output 1

AC x 3
WA x 1
TLE x 2
RE x 0

We have <var>3</var>, <var>1</var>, <var>2</var>, and <var>0</var> test case(s) for which the verdict is AC, WA, TLE, and RE, respectively.

Sample Input 2

10
AC
AC
AC
AC
AC
AC
AC
AC
AC
AC

Sample Output 2

AC x 10
WA x 0
TLE x 0
RE x 0


Score : <var>200</var> points

Problem Statement

There are <var>N</var> cities and <var>M</var> roads.
The <var>i</var>-th road <var>(1≤i≤M)</var> connects two cities <var>a_i</var> and <var>b_i</var> <var>(1≤a_i,b_i≤N)</var> bidirectionally.
There may be more than one road that connects the same pair of two cities.
For each city, how many roads are connected to the city?

Constraints

<var>2≤N,M≤50</var>

<var>1≤a_i,b_i≤N</var>

<var>a_i ≠ b_i</var>

All input values are integers.

Input

Input is given from Standard Input in the following format:

<var>N</var> <var>M</var>
<var>a_1</var> <var>b_1</var>
<var>:</var>
<var>a_M</var> <var>b_M</var>

Output

Print the answer in <var>N</var> lines.
In the <var>i</var>-th line <var>(1≤i≤N)</var>, print the number of roads connected to city <var>i</var>.

Sample Input 1

4 3
1 2
2 3
1 4

Sample Output 1

2
2
1
1

City <var>1</var> is connected to the <var>1</var>-st and <var>3</var>-rd roads.

City <var>2</var> is connected to the <var>1</var>-st and <var>2</var>-nd roads.

City <var>3</var> is connected to the <var>2</var>-nd road.

City <var>4</var> is connected to the <var>3</var>-rd road.

Sample Input 2

2 5
1 2
2 1
1 2
2 1
1 2

Sample Output 2

5
5

Sample Input 3

8 8
1 2
3 4
1 5
2 8
3 7
5 2
4 1
6 8

Sample Output 3

3
3
2
2
2
1
1
2


Score : <var>300</var> points

Problem Statement

There are <var>N</var> cities on a number line. The <var>i</var>-th city is located at coordinate <var>x_i</var>.

Your objective is to visit all these cities at least once.

In order to do so, you will first set a positive integer <var>D</var>.

Then, you will depart from coordinate <var>X</var> and perform Move <var>1</var> and Move <var>2</var> below, as many times as you like:

Move <var>1</var>: travel from coordinate <var>y</var> to coordinate <var>y + D</var>.

Move <var>2</var>: travel from coordinate <var>y</var> to coordinate <var>y - D</var>.

Find the maximum value of <var>D</var> that enables you to visit all the cities.

Here, to visit a city is to travel to the coordinate where that city is located.

Constraints

All values in input are integers.

<var>1 \leq N \leq 10^5</var>

<var>1 \leq X \leq 10^9</var>

<var>1 \leq x_i \leq 10^9</var>

<var>x_i</var> are all different.

<var>x_1, x_2, ..., x_N \neq X</var>

Input

Input is given from Standard Input in the following format:

<var>N</var> <var>X</var>
<var>x_1</var> <var>x_2</var> <var>...</var> <var>x_N</var>

Output

Print the maximum value of <var>D</var> that enables you to visit all the cities.

Sample Input 1

3 3
1 7 11

Sample Output 1

2

Setting <var>D = 2</var> enables you to visit all the cities as follows, and this is the maximum value of such <var>D</var>.

Perform Move <var>2</var> to travel to coordinate <var>1</var>.

Perform Move <var>1</var> to travel to coordinate <var>3</var>.

Perform Move <var>1</var> to travel to coordinate <var>5</var>.

Perform Move <var>1</var> to travel to coordinate <var>7</var>.

Perform Move <var>1</var> to travel to coordinate <var>9</var>.

Perform Move <var>1</var> to travel to coordinate <var>11</var>.

Sample Input 2

3 81
33 105 57

Sample Output 2

24

Sample Input 3

1 1
1000000000

Sample Output 3

999999999


Score : <var>300</var> points

Problem Statement

The commonly used bills in Japan are <var>10000</var>-yen, <var>5000</var>-yen and <var>1000</var>-yen bills. Below, the word "bill" refers to only these.

According to Aohashi, he received an otoshidama (New Year money gift) envelope from his grandfather that contained <var>N</var> bills for a total of <var>Y</var> yen, but he may be lying. Determine whether such a situation is possible, and if it is, find a possible set of bills contained in the envelope. Assume that his grandfather is rich enough, and the envelope was large enough.

Constraints

<var>1 ≤ N ≤ 2000</var>

<var>1000 ≤ Y ≤ 2 × 10^7</var>

<var>N</var> is an integer.

<var>Y</var> is a multiple of <var>1000</var>.

Input

Input is given from Standard Input in the following format:

<var>N</var> <var>Y</var>

Output

If the total value of <var>N</var> bills cannot be <var>Y</var> yen, print -1 -1 -1.

If the total value of <var>N</var> bills can be <var>Y</var> yen, let one such set of bills be "<var>x</var> <var>10000</var>-yen bills, <var>y</var> <var>5000</var>-yen bills and <var>z</var> <var>1000</var>-yen bills", and print <var>x</var>, <var>y</var>, <var>z</var> with spaces in between. If there are multiple possibilities, any of them may be printed.

Sample Input 1

9 45000

Sample Output 1

4 0 5

If the envelope contained <var>4</var> <var>10000</var>-yen bills and <var>5</var> <var>1000</var>-yen bills, he had <var>9</var> bills and <var>45000</var> yen in total. It is also possible that the envelope contained <var>9</var> <var>5000</var>-yen bills, so the output 0 9 0 is also correct.

Sample Input 2

20 196000

Sample Output 2

-1 -1 -1

When the envelope contained <var>20</var> bills in total, the total value would be <var>200000</var> yen if all the bills were <var>10000</var>-yen bills, and would be at most <var>195000</var> yen otherwise, so it would never be <var>196000</var> yen.

Sample Input 3

1000 1234000

Sample Output 3

14 27 959

There are also many other possibilities.

Sample Input 4

2000 20000000

Sample Output 4

2000 0 0


Score: <var>100</var> points

Problem Statement

Takahashi is solving quizzes. He has easily solved all but the last one.

The last quiz has three choices: <var>1</var>, <var>2</var>, and <var>3</var>.

With his supernatural power, Takahashi has found out that the choices <var>A</var> and <var>B</var> are both wrong.

Print the correct choice for this problem.

Constraints

Each of the numbers <var>A</var> and <var>B</var> is <var>1</var>, <var>2</var>, or <var>3</var>.

<var>A</var> and <var>B</var> are different.

Input

Input is given from Standard Input in the following format:

<var>A</var>
<var>B</var>

Output

Print the correct choice.

Sample Input 1

3
1

Sample Output 1

2

When we know <var>3</var> and <var>1</var> are both wrong, the correct choice is <var>2</var>.

Sample Input 2

1
2

Sample Output 2

3


Score : <var>200</var> points

Problem Statement

Takahashi has two positive integers <var>A</var> and <var>B</var>.

It is known that <var>A</var> plus <var>B</var> equals <var>N</var>.
Find the minimum possible value of "the sum of the digits of <var>A</var>" plus "the sum of the digits of <var>B</var>" (in base <var>10</var>).

Constraints

<var>2 ≤ N ≤ 10^5</var>

<var>N</var> is an integer.

Input

Input is given from Standard Input in the following format:

<var>N</var>

Output

Print the minimum possible value of "the sum of the digits of <var>A</var>" plus "the sum of the digits of <var>B</var>".

Sample Input 1

15

Sample Output 1

6

When <var>A=2</var> and <var>B=13</var>, the sums of their digits are <var>2</var> and <var>4</var>, which minimizes the value in question.

Sample Input 2

100000

Sample Output 2

10


Score : <var>300</var> points

Problem Statement

You are given <var>N</var> positive integers <var>a_1, a_2, ..., a_N</var>.

For a non-negative integer <var>m</var>, let <var>f(m) = (m\ mod\ a_1) + (m\ mod\ a_2) + ... + (m\ mod\ a_N)</var>.

Here, <var>X\ mod\ Y</var> denotes the remainder of the division of <var>X</var> by <var>Y</var>.

Find the maximum value of <var>f</var>.

Constraints

All values in input are integers.

<var>2 \leq N \leq 3000</var>

<var>2 \leq a_i \leq 10^5</var>

Input

Input is given from Standard Input in the following format:

<var>N</var>
<var>a_1</var> <var>a_2</var> <var>...</var> <var>a_N</var>

Output

Print the maximum value of <var>f</var>.

Sample Input 1

3
3 4 6

Sample Output 1

10

<var>f(11) = (11\ mod\ 3) + (11\ mod\ 4) + (11\ mod\ 6) = 10</var> is the maximum value of <var>f</var>.

Sample Input 2

5
7 46 11 20 11

Sample Output 2

90

Sample Input 3

7
994 518 941 851 647 2 581

Sample Output 3

4527


Score: <var>100</var> points

Problem Statement

In <var>2020</var>, AtCoder Inc. with an annual sales of more than one billion yen (the currency of Japan) has started a business in programming education.

One day, there was an exam where a one-year-old child must write a program that prints Hello World, and a two-year-old child must write a program that receives integers <var>A, B</var> and prints <var>A+B</var>.

Takahashi, who is taking this exam, suddenly forgets his age.

He decides to write a program that first receives his age <var>N</var> (<var>1</var> or <var>2</var>) as input, then prints Hello World if <var>N=1</var>, and additionally receives integers <var>A, B</var> and prints <var>A+B</var> if <var>N=2</var>.

Write this program for him.

Constraints

<var>N</var> is <var>1</var> or <var>2</var>.

<var>A</var> is an integer between <var>1</var> and <var>9</var> (inclusive).

<var>B</var> is an integer between <var>1</var> and <var>9</var> (inclusive).

Input

Input is given from Standard Input in one of the following formats:

1

2
<var>A</var>
<var>B</var>

Output

If <var>N=1</var>, print Hello World; if <var>N=2</var>, print <var>A+B</var>.

Sample Input 1

1

Sample Output 1

Hello World

As <var>N=1</var>, Takahashi is one year old. Thus, we should print Hello World.

Sample Input 2

2
3
5

Sample Output 2

8

As <var>N=2</var>, Takahashi is two years old. Thus, we should print <var>A+B</var>, which is <var>8</var> since <var>A=3</var> and <var>B=5</var>.


Score : <var>100</var> points

Problem Statement

Cat Snuke is learning to write characters.
Today, he practiced writing digits 1 and 9, but he did it the other way around.

You are given a three-digit integer <var>n</var> written by Snuke.
Print the integer obtained by replacing each digit 1 with 9 and each digit 9 with 1 in <var>n</var>.

Constraints

<var>111 \leq n \leq 999</var>

<var>n</var> is an integer consisting of digits 1 and 9.

Input

Input is given from Standard Input in the following format:

<var>n</var>

Output

Print the integer obtained by replacing each occurrence of 1 with 9 and each occurrence of 9 with 1 in <var>n</var>.

Sample Input 1

119

Sample Output 1

991

Replace the 9 in the ones place with 1, the 1 in the tens place with 9 and the 1 in the hundreds place with 9. The answer is 991.

Sample Input 2

999

Sample Output 2

111


Score : <var>100</var> points

Problem Statement

A string of length <var>6</var> consisting of lowercase English letters is said to be coffee-like if and only if its <var>3</var>-rd and <var>4</var>-th characters are equal and its <var>5</var>-th and <var>6</var>-th characters are also equal.

Given a string <var>S</var>, determine whether it is coffee-like.

Constraints

<var>S</var> is a string of length <var>6</var> consisting of lowercase English letters.

Input

Input is given from Standard Input in the following format:

<var>S</var>

Output

If <var>S</var> is coffee-like, print Yes; otherwise, print No.

Sample Input 1

sippuu

Sample Output 1

Yes

In sippuu, the <var>3</var>-rd and <var>4</var>-th characters are equal, and the <var>5</var>-th and <var>6</var>-th characters are also equal.

Sample Input 2

iphone

Sample Output 2

No

Sample Input 3

coffee

Sample Output 3

Yes