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

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>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>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>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

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>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

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>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

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

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>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>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

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

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>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>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>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


Score: <var>400</var> points

Problem Statement

There is a cave.

The cave has <var>N</var> rooms and <var>M</var> passages. The rooms are numbered <var>1</var> to <var>N</var>, and the passages are numbered <var>1</var> to <var>M</var>. Passage <var>i</var> connects Room <var>A_i</var> and Room <var>B_i</var> bidirectionally. One can travel between any two rooms by traversing passages. Room <var>1</var> is a special room with an entrance from the outside.

It is dark in the cave, so we have decided to place a signpost in each room except Room <var>1</var>. The signpost in each room will point to one of the rooms directly connected to that room with a passage.

Since it is dangerous in the cave, our objective is to satisfy the condition below for each room except Room <var>1</var>.

If you start in that room and repeatedly move to the room indicated by the signpost in the room you are in, you will reach Room <var>1</var> after traversing the minimum number of passages possible.

Determine whether there is a way to place signposts satisfying our objective, and print one such way if it exists.

Constraints

All values in input are integers.

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

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

<var>1 \leq A_i, B_i \leq N\ (1 \leq i \leq M)</var>

<var>A_i \neq B_i\ (1 \leq i \leq M)</var>

One can travel between any two rooms by traversing passages.

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

If there is no way to place signposts satisfying the objective, print No.

Otherwise, print <var>N</var> lines. The first line should contain Yes, and the <var>i</var>-th line <var>(2 \leq i \leq N)</var> should contain the integer representing the room indicated by the signpost in Room <var>i</var>.

Sample Input 1

4 4
1 2
2 3
3 4
4 2

Sample Output 1

Yes
1
2
2

If we place the signposts as described in the sample output, the following happens:

Starting in Room <var>2</var>, you will reach Room <var>1</var> after traversing one passage: <var>(2) \to 1</var>. This is the minimum number of passages possible.

Starting in Room <var>3</var>, you will reach Room <var>1</var> after traversing two passages: <var>(3) \to 2 \to 1</var>. This is the minimum number of passages possible.

Starting in Room <var>4</var>, you will reach Room <var>1</var> after traversing two passages: <var>(4) \to 2 \to 1</var>. This is the minimum number of passages possible.

Thus, the objective is satisfied.

Sample Input 2

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

Sample Output 2

Yes
6
5
5
1
1

If there are multiple solutions, any of them will be accepted.


Score : <var>400</var> points

Problem Statement

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

Starting with this string, he will produce a new one in the procedure given as follows.

The procedure consists of <var>Q</var> operations. In Operation <var>i</var> <var>(1 \leq i \leq Q)</var>, an integer <var>T_i</var> is provided, which means the following:

If <var>T_i = 1</var>: reverse the string <var>S</var>.

If <var>T_i = 2</var>: An integer <var>F_i</var> and a lowercase English letter <var>C_i</var> are additionally provided.

If <var>F_i = 1</var> : Add <var>C_i</var> to the beginning of the string <var>S</var>.

If <var>F_i = 2</var> : Add <var>C_i</var> to the end of the string <var>S</var>.

Help Takahashi by finding the final string that results from the procedure.

Constraints

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

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

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

<var>T_i = 1</var> or <var>2</var>.

<var>F_i = 1</var> or <var>2</var>, if provided.

<var>C_i</var> is a lowercase English letter, if provided.

Input

Input is given from Standard Input in the following format:

<var>S</var>
<var>Q</var>
<var>Query_1</var>
<var>:</var>
<var>Query_Q</var>

In the <var>3</var>-rd through the <var>(Q+2)</var>-th lines, <var>Query_i</var> is one of the following:

<var>1</var>

which means <var>T_i = 1</var>, and:

<var>2</var> <var>F_i</var> <var>C_i</var>

which means <var>T_i = 2</var>.

Output

Print the resulting string.

Sample Input 1

a
4
2 1 p
1
2 2 c
1

Sample Output 1

cpa

There will be <var>Q = 4</var> operations. Initially, <var>S</var> is a.

Operation <var>1</var>: Add p at the beginning of <var>S</var>. <var>S</var> becomes pa.

Operation <var>2</var>: Reverse <var>S</var>. <var>S</var> becomes ap.

Operation <var>3</var>: Add c at the end of <var>S</var>. <var>S</var> becomes apc.

Operation <var>4</var>: Reverse <var>S</var>. <var>S</var> becomes cpa.

Thus, the resulting string is cpa.

Sample Input 2

a
6
2 2 a
2 1 b
1
2 2 c
1
1

Sample Output 2

aabc

There will be <var>Q = 6</var> operations. Initially, <var>S</var> is a.

Operation <var>1</var>: <var>S</var> becomes aa.

Operation <var>2</var>: <var>S</var> becomes baa.

Operation <var>3</var>: <var>S</var> becomes aab.

Operation <var>4</var>: <var>S</var> becomes aabc.

Operation <var>5</var>: <var>S</var> becomes cbaa.

Operation <var>6</var>: <var>S</var> becomes aabc.

Thus, the resulting string is aabc.

Sample Input 3

y
1
2 1 x

Sample Output 3

xy


Score: <var>100</var> points

Problem Statement

The cat Snuke wants to play a popular Japanese game called ÅtCoder, so Iroha has decided to teach him Japanese.

When counting pencils in Japanese, the counter word "本" follows the number. The pronunciation of this word varies depending on the number. Specifically, the pronunciation of "本" in the phrase "<var>N</var> 本" for a positive integer <var>N</var> not exceeding <var>999</var> is as follows:

hon when the digit in the one's place of <var>N</var> is <var>2</var>, <var>4</var>, <var>5</var>, <var>7</var>, or <var>9</var>;

pon when the digit in the one's place of <var>N</var> is <var>0</var>, <var>1</var>, <var>6</var> or <var>8</var>;

bon when the digit in the one's place of <var>N</var> is <var>3</var>.

Given <var>N</var>, print the pronunciation of "本" in the phrase "<var>N</var> 本".

Constraints

<var>N</var> is a positive integer not exceeding <var>999</var>.

Input

Input is given from Standard Input in the following format:

<var>N</var>

Output

Print the answer.

Sample Input 1

16

Sample Output 1

pon

The digit in the one's place of <var>16</var> is <var>6</var>, so the "本" in "<var>16</var> 本" is pronounced pon.

Sample Input 2

2

Sample Output 2

hon

Sample Input 3

183

Sample Output 3

bon


Score : <var>300</var> points

Problem Statement

There are <var>N</var> people living on a number line.

The <var>i</var>-th person lives at coordinate <var>X_i</var>.

You are going to hold a meeting that all <var>N</var> people have to attend.

The meeting can be held at any integer coordinate. If you choose to hold the meeting at coordinate <var>P</var>, the <var>i</var>-th person will spend <var>(X_i - P)^2</var> points of stamina to attend the meeting.

Find the minimum total points of stamina the <var>N</var> people have to spend.

Constraints

All values in input are integers.

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

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

Input

Input is given from Standard Input in the following format:

<var>N</var>
<var>X_1</var> <var>X_2</var> <var>...</var> <var>X_N</var>

Output

Print the minimum total stamina the <var>N</var> people have to spend.

Sample Input 1

2
1 4

Sample Output 1

5

Assume the meeting is held at coordinate <var>2</var>. In this case, the first person will spend <var>(1 - 2)^2</var> points of stamina, and the second person will spend <var>(4 - 2)^2 = 4</var> points of stamina, for a total of <var>5</var> points of stamina. This is the minimum total stamina that the <var>2</var> people have to spend.

Note that you can hold the meeting only at an integer coordinate.

Sample Input 2

7
14 14 2 13 56 2 37

Sample Output 2

2354


Score : <var>300</var> points

Problem Statement

There is a staircase with <var>N</var> steps. Takahashi is now standing at the foot of the stairs, that is, on the <var>0</var>-th step.
He can climb up one or two steps at a time.

However, the treads of the <var>a_1</var>-th, <var>a_2</var>-th, <var>a_3</var>-th, <var>\ldots</var>, <var>a_M</var>-th steps are broken, so it is dangerous to set foot on those steps.

How many are there to climb up to the top step, that is, the <var>N</var>-th step, without setting foot on the broken steps?
Find the count modulo <var>1\ 000\ 000\ 007</var>.

Constraints

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

<var>0 \leq M \leq N-1</var>

<var>1 \leq a_1 < a_2 < </var> <var>...</var> <var> < a_M \leq N-1</var>

Input

Input is given from Standard Input in the following format:

<var>N</var> <var>M</var>
<var>a_1</var>
<var>a_2</var>
<var> .</var>
<var> .</var>
<var> .</var>
<var>a_M</var>

Output

Print the number of ways to climb up the stairs under the condition, modulo <var>1\ 000\ 000\ 007</var>.

Sample Input 1

6 1
3

Sample Output 1

4

There are four ways to climb up the stairs, as follows:

<var>0 \to 1 \to 2 \to 4 \to 5 \to 6</var>

<var>0 \to 1 \to 2 \to 4 \to 6</var>

<var>0 \to 2 \to 4 \to 5 \to 6</var>

<var>0 \to 2 \to 4 \to 6</var>

Sample Input 2

10 2
4
5

Sample Output 2

0

There may be no way to climb up the stairs without setting foot on the broken steps.

Sample Input 3

100 5
1
23
45
67
89

Sample Output 3

608200469

Be sure to print the count modulo <var>1\ 000\ 000\ 007</var>.


Score : <var>300</var> points

Problem Statement

Takahashi is organizing a party.

At the party, each guest will receive one or more snack pieces.

Takahashi predicts that the number of guests at this party will be <var>A</var> or <var>B</var>.

Find the minimum number of pieces that can be evenly distributed to the guests in both of the cases predicted.

We assume that a piece cannot be divided and distributed to multiple guests.

Constraints

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

<var>A \neq B</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

Print the minimum number of pieces that can be evenly distributed to the guests in both of the cases with <var>A</var> guests and <var>B</var> guests.

Sample Input 1

2 3

Sample Output 1

6

When we have six snack pieces, each guest can take three pieces if we have two guests, and each guest can take two if we have three guests.

Sample Input 2

123 456

Sample Output 2

18696

Sample Input 3

100000 99999

Sample Output 3

9999900000


Score : <var>100</var> points

Problem Statement

You will turn on the air conditioner if, and only if, the temperature of the room is <var>30</var> degrees Celsius or above.

The current temperature of the room is <var>X</var> degrees Celsius. Will you turn on the air conditioner?

Constraints

<var>-40 \leq X \leq 40</var>

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

Input

Input is given from Standard Input in the following format:

<var>X</var>

Output

Print Yes if you will turn on the air conditioner; print No otherwise.

Sample Input 1

25

Sample Output 1

No

Sample Input 2

30

Sample Output 2

Yes


Score : <var>100</var> points

Problem Statement

There are <var>N</var> stones, numbered <var>1, 2, \ldots, N</var>.
For each <var>i</var> (<var>1 \leq i \leq N</var>), the height of Stone <var>i</var> is <var>h_i</var>.

There is a frog who is initially on Stone <var>1</var>.
He will repeat the following action some number of times to reach Stone <var>N</var>:

If the frog is currently on Stone <var>i</var>, jump to one of the following: Stone <var>i + 1, i + 2, \ldots, i + K</var>. Here, a cost of <var>|h_i - h_j|</var> is incurred, where <var>j</var> is the stone to land on.

Find the minimum possible total cost incurred before the frog reaches Stone <var>N</var>.

Constraints

All values in input are integers.

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

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

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

Input

Input is given from Standard Input in the following format:

<var>N</var> <var>K</var>
<var>h_1</var> <var>h_2</var> <var>\ldots</var> <var>h_N</var>

Output

Print the minimum possible total cost incurred.

Sample Input 1

5 3
10 30 40 50 20

Sample Output 1

30

If we follow the path <var>1</var> → <var>2</var> → <var>5</var>, the total cost incurred would be <var>|10 - 30| + |30 - 20| = 30</var>.

Sample Input 2

3 1
10 20 10

Sample Output 2

20

If we follow the path <var>1</var> → <var>2</var> → <var>3</var>, the total cost incurred would be <var>|10 - 20| + |20 - 10| = 20</var>.

Sample Input 3

2 100
10 10

Sample Output 3

0

If we follow the path <var>1</var> → <var>2</var>, the total cost incurred would be <var>|10 - 10| = 0</var>.

Sample Input 4

10 4
40 10 20 70 80 10 20 70 80 60

Sample Output 4

40

If we follow the path <var>1</var> → <var>4</var> → <var>8</var> → <var>10</var>, the total cost incurred would be <var>|40 - 70| + |70 - 70| + |70 - 60| = 40</var>.


Score : <var>100</var> points

Problem Statement

<var>N</var> of us are going on a trip, by train or taxi.

The train will cost each of us <var>A</var> yen (the currency of Japan).

The taxi will cost us a total of <var>B</var> yen.

How much is our minimum total travel expense?

Constraints

All values in input are integers.

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

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

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

Input

Input is given from Standard Input in the following format:

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

Output

Print an integer representing the minimum total travel expense.

Sample Input 1

4 2 9

Sample Output 1

8

The train will cost us <var>4 \times 2 = 8</var> yen, and the taxi will cost us <var>9</var> yen, so the minimum total travel expense is <var>8</var> yen.

Sample Input 2

4 2 7

Sample Output 2

7

Sample Input 3

4 2 8

Sample Output 3

8


Score : <var>100</var> points

Problem Statement

Snuke is going to open a contest named "AtCoder <var>s</var> Contest".
Here, <var>s</var> is a string of length <var>1</var> or greater, where the first character is an uppercase English letter, and the second and subsequent characters are lowercase English letters.

Snuke has decided to abbreviate the name of the contest as "A<var>x</var>C".
Here, <var>x</var> is the uppercase English letter at the beginning of <var>s</var>.

Given the name of the contest, print the abbreviation of the name.

Constraints

The length of <var>s</var> is between <var>1</var> and <var>100</var>, inclusive.

The first character in <var>s</var> is an uppercase English letter.

The second and subsequent characters in <var>s</var> are lowercase English letters.

Input

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

AtCoder <var>s</var> Contest

Output

Print the abbreviation of the name of the contest.

Sample Input 1

AtCoder Beginner Contest

Sample Output 1

ABC

The contest in which you are participating now.

Sample Input 2

AtCoder Snuke Contest

Sample Output 2

ASC

This contest does not actually exist.

Sample Input 3

AtCoder X Contest

Sample Output 3

AXC


Score : <var>300</var> points

Problem Statement

You are given an integer <var>N</var>.

For two positive integers <var>A</var> and <var>B</var>, we will define <var>F(A,B)</var> as the larger of the following: the number of digits in the decimal notation of <var>A</var>, and the number of digits in the decimal notation of <var>B</var>.

For example, <var>F(3,11) = 2</var> since <var>3</var> has one digit and <var>11</var> has two digits.

Find the minimum value of <var>F(A,B)</var> as <var>(A,B)</var> ranges over all pairs of positive integers such that <var>N = A \times B</var>.

Constraints

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

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

Input

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

<var>N</var>

Output

Print the minimum value of <var>F(A,B)</var> as <var>(A,B)</var> ranges over all pairs of positive integers such that <var>N = A \times B</var>.

Sample Input 1

10000

Sample Output 1

3

<var>F(A,B)</var> has a minimum value of <var>3</var> at <var>(A,B)=(100,100)</var>.

Sample Input 2

1000003

Sample Output 2

7

There are two pairs <var>(A,B)</var> that satisfy the condition: <var>(1,1000003)</var> and <var>(1000003,1)</var>. For these pairs, <var>F(1,1000003)=F(1000003,1)=7</var>.

Sample Input 3

9876543210

Sample Output 3

6


Score : <var>300</var> points

Problem Statement

Takahashi has <var>N</var> balls. Initially, an integer <var>A_i</var> is written on the <var>i</var>-th ball.

He would like to rewrite the integer on some balls so that there are at most <var>K</var> different integers written on the <var>N</var> balls.

Find the minimum number of balls that Takahashi needs to rewrite the integers on them.

Constraints

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

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

All input values are integers.

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>A_N</var>

Output

Print the minimum number of balls that Takahashi needs to rewrite the integers on them.

Sample Input 1

5 2
1 1 2 2 5

Sample Output 1

1

For example, if we rewrite the integer on the fifth ball to <var>2</var>, there are two different integers written on the balls: <var>1</var> and <var>2</var>.
On the other hand, it is not possible to rewrite the integers on zero balls so that there are at most two different integers written on the balls, so we should print <var>1</var>.

Sample Input 2

4 4
1 1 2 2

Sample Output 2

0

Already in the beginning, there are two different integers written on the balls, so we do not need to rewrite anything.

Sample Input 3

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

Sample Output 3

3


Score : <var>500</var> points

Problem Statement

There are <var>N</var> Snuke Cats numbered <var>1, 2, \ldots, N</var>, where <var>N</var> is even.

Each Snuke Cat wears a red scarf, on which his favorite non-negative integer is written.

Recently, they learned the operation called xor (exclusive OR).

What is xor?

For <var>n</var> non-negative integers <var>x_1, x_2, \ldots, x_n</var>, their xor, <var>x_1~\textrm{xor}~x_2~\textrm{xor}~\ldots~\textrm{xor}~x_n</var> is defined as follows:

 When <var>x_1~\textrm{xor}~x_2~\textrm{xor}~\ldots~\textrm{xor}~x_n</var> is written in base two, the digit in the <var>2^k</var>'s place (<var>k \geq 0</var>) is <var>1</var> if the number of integers among <var>x_1, x_2, \ldots, x_n</var> whose binary representations have <var>1</var> in the <var>2^k</var>'s place is odd, and <var>0</var> if that count is even.

For example, <var>3~\textrm{xor}~5 = 6</var>.

They wanted to use this operation quickly, so each of them calculated the xor of the integers written on their scarfs except his scarf.

We know that the xor calculated by Snuke Cat <var>i</var>, that is, the xor of the integers written on the scarfs except the scarf of Snuke Cat <var>i</var> is <var>a_i</var>.
Using this information, restore the integer written on the scarf of each Snuke Cat.

Constraints

All values in input are integers.

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

<var>N</var> is even.

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

There exists a combination of integers on the scarfs that is consistent with the given information.

Input

Input is given from Standard Input in the following format:

<var>N</var>
<var>a_1</var> <var>a_2</var> <var>\ldots</var> <var>a_N</var>

Output

Print a line containing <var>N</var> integers separated with space.

The <var>i</var>-th of the integers from the left should represent the integer written on the scarf of Snuke Cat <var>i</var>.

If there are multiple possible solutions, you may print any of them.

Sample Input 1

4
20 11 9 24

Sample Output 1

26 5 7 22

<var>5~\textrm{xor}~7~\textrm{xor}~22 = 20</var>

<var>26~\textrm{xor}~7~\textrm{xor}~22 = 11</var>

<var>26~\textrm{xor}~5~\textrm{xor}~22 = 9</var>

<var>26~\textrm{xor}~5~\textrm{xor}~7 = 24</var>

Thus, this output is consistent with the given information.


Score : <var>100</var> points

Problem Statement

There are <var>N</var> children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give <var>1</var> candy to the first child in the line, <var>2</var> candies to the second child, ..., <var>N</var> candies to the <var>N</var>-th child. How many candies will be necessary in total?

Constraints

<var>1≦N≦100</var>

Input

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

<var>N</var>

Output

Print the necessary number of candies in total.

Sample Input 1

3

Sample Output 1

6

The answer is <var>1+2+3=6</var>.

Sample Input 2

10

Sample Output 2

55

The sum of the integers from <var>1</var> to <var>10</var> is <var>55</var>.

Sample Input 3

1

Sample Output 3

1

Only one child. The answer is <var>1</var> in this case.


Score : <var>200</var> points

Problem Statement

We have <var>N</var> weights indexed <var>1</var> to <var>N</var>. The mass of the weight indexed <var>i</var> is <var>W_i</var>.

We will divide these weights into two groups: the weights with indices not greater than <var>T</var>, and those with indices greater than <var>T</var>, for some integer <var>1 \leq T < N</var>. Let <var>S_1</var> be the sum of the masses of the weights in the former group, and <var>S_2</var> be the sum of the masses of the weights in the latter group.

Consider all possible such divisions and find the minimum possible absolute difference of <var>S_1</var> and <var>S_2</var>.

Constraints

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

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

All values in input are integers.

Input

Input is given from Standard Input in the following format:

<var>N</var>
<var>W_1</var> <var>W_2</var> <var>...</var> <var>W_{N-1}</var> <var>W_N</var>

Output

Print the minimum possible absolute difference of <var>S_1</var> and <var>S_2</var>.

Sample Input 1

3
1 2 3

Sample Output 1

0

If <var>T = 2</var>, <var>S_1 = 1 + 2 = 3</var> and <var>S_2 = 3</var>, with the absolute difference of <var>0</var>.

Sample Input 2

4
1 3 1 1

Sample Output 2

2

If <var>T = 2</var>, <var>S_1 = 1 + 3 = 4</var> and <var>S_2 = 1 + 1 = 2</var>, with the absolute difference of <var>2</var>. We cannot have a smaller absolute difference.

Sample Input 3

8
27 23 76 2 3 5 62 52

Sample Output 3

2


Score : <var>200</var> points

Problem Statement

You are given string <var>S</var> and <var>T</var> consisting of lowercase English letters.

Determine if <var>S</var> equals <var>T</var> after rotation.

That is, determine if <var>S</var> equals <var>T</var> after the following operation is performed some number of times:

Operation: Let <var>S = S_1 S_2 ... S_{|S|}</var>. Change <var>S</var> to <var>S_{|S|} S_1 S_2 ... S_{|S|-1}</var>.

Here, <var>|X|</var> denotes the length of the string <var>X</var>.

Constraints

<var>2 \leq |S| \leq 100</var>

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

<var>S</var> and <var>T</var> consist of lowercase English letters.

Input

Input is given from Standard Input in the following format:

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

Output

If <var>S</var> equals <var>T</var> after rotation, print Yes; if it does not, print No.

Sample Input 1

kyoto
tokyo

Sample Output 1

Yes

In the first operation, kyoto becomes okyot.

In the second operation, okyot becomes tokyo.

Sample Input 2

abc
arc

Sample Output 2

No

abc does not equal arc after any number of operations.

Sample Input 3

aaaaaaaaaaaaaaab
aaaaaaaaaaaaaaab

Sample Output 3

Yes


Score : <var>200</var> points

Problem Statement

Find the sum of the integers between <var>1</var> and <var>N</var> (inclusive), whose sum of digits written in base <var>10</var> is between <var>A</var> and <var>B</var> (inclusive).

Constraints

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

<var>1 \leq A \leq B \leq 36</var>

All input values 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 sum of the integers between <var>1</var> and <var>N</var> (inclusive), whose sum of digits written in base <var>10</var> is between <var>A</var> and <var>B</var> (inclusive).

Sample Input 1

20 2 5

Sample Output 1

84

Among the integers not greater than <var>20</var>, the ones whose sums of digits are between <var>2</var> and <var>5</var>, are: <var>2,3,4,5,11,12,13,14</var> and <var>20</var>. We should print the sum of these, <var>84</var>.

Sample Input 2

10 1 2

Sample Output 2

13

Sample Input 3

100 4 16

Sample Output 3

4554


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^5</var>

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

<var>1 \leq v_i \leq 10^9</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

5 5
1 1000000000
1 1000000000
1 1000000000
1 1000000000
1 1000000000

Sample Output 2

5000000000

The answer may not fit into a 32-bit integer type.

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

Takahashi went to an all-you-can-eat buffet with <var>N</var> kinds of dishes and ate all of them (Dish <var>1</var>, Dish <var>2</var>, <var>\ldots</var>, Dish <var>N</var>) once.

The <var>i</var>-th dish <var>(1 \leq i \leq N)</var> he ate was Dish <var>A_i</var>.

When he eats Dish <var>i</var> <var>(1 \leq i \leq N)</var>, he gains <var>B_i</var> satisfaction points.

Additionally, when he eats Dish <var>i+1</var> just after eating Dish <var>i</var> <var>(1 \leq i \leq N - 1)</var>, he gains <var>C_i</var> more satisfaction points.

Find the sum of the satisfaction points he gained.

Constraints

All values in input are integers.

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

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

<var>A_1, A_2, ..., A_N</var> are all different.

<var>1 \leq B_i \leq 50</var>

<var>1 \leq C_i \leq 50</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>
<var>B_1</var> <var>B_2</var> <var>...</var> <var>B_N</var>
<var>C_1</var> <var>C_2</var> <var>...</var> <var>C_{N-1}</var>

Output

Print the sum of the satisfaction points Takahashi gained, as an integer.

Sample Input 1

3
3 1 2
2 5 4
3 6

Sample Output 1

14

Takahashi gained <var>14</var> satisfaction points in total, as follows:

First, he ate Dish <var>3</var> and gained <var>4</var> satisfaction points.

Next, he ate Dish <var>1</var> and gained <var>2</var> satisfaction points.

Lastly, he ate Dish <var>2</var> and gained <var>5 + 3 = 8</var> satisfaction points.

Sample Input 2

4
2 3 4 1
13 5 8 24
45 9 15

Sample Output 2

74

Sample Input 3

2
1 2
50 50
50

Sample Output 3

150


Score : <var>300</var> points

Problem Statement

<var>N</var> tiles are arranged in a row from left to right. The initial color of each tile is represented by a string <var>S</var> of length <var>N</var>.

The <var>i</var>-th tile from the left is painted black if the <var>i</var>-th character of <var>S</var> is 0, and painted white if that character is 1.

You want to repaint some of the tiles black or white, so that any two adjacent tiles have different colors.

At least how many tiles need to be repainted to satisfy the condition?

Constraints

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

<var>S_i</var> is 0 or 1.

Input

Input is given from Standard Input in the following format:

<var>S</var>

Output

Print the minimum number of tiles that need to be repainted to satisfy the condition.

Sample Input 1

000

Sample Output 1

1

The condition can be satisfied by repainting the middle tile white.

Sample Input 2

10010010

Sample Output 2

3

Sample Input 3

0

Sample Output 3

0


Score : <var>400</var> points

Problem Statement

Given is a string <var>S</var> consisting of digits from 1 through 9.

Find the number of pairs of integers <var>(i,j)</var> (<var>1 ≤ i ≤ j ≤ |S|</var>) that satisfy the following condition:

Condition: In base ten, the <var>i</var>-th through <var>j</var>-th characters of <var>S</var> form an integer that is a multiple of <var>2019</var>.

Constraints

<var>1 ≤ |S| ≤ 200000</var>

<var>S</var> is a string consisting of digits from 1 through 9.

Input

Input is given from Standard Input in the following format:

<var>S</var>

Output

Print the number of pairs of integers <var>(i,j)</var> (<var>1 ≤ i ≤ j ≤ |S|</var>) that satisfy the condition.

Sample Input 1

1817181712114

Sample Output 1

3

Three pairs - <var>(1,5)</var>, <var>(5,9)</var>, and <var>(9,13)</var> - satisfy the condition.

Sample Input 2

14282668646

Sample Output 2

2

Sample Input 3

2119

Sample Output 3

0

No pairs satisfy the condition.