Score : <var>400</var> points

Problem Statement

We have a tree with <var>N</var> vertices numbered <var>1</var> to <var>N</var>.
The <var>i</var>-th edge in the tree connects Vertex <var>u_i</var> and Vertex <var>v_i</var>, and its length is <var>w_i</var>.
Your objective is to paint each vertex in the tree white or black (it is fine to paint all vertices the same color) so that the following condition is satisfied:

For any two vertices painted in the same color, the distance between them is an even number.

Find a coloring of the vertices that satisfies the condition and print it. It can be proved that at least one such coloring exists under the constraints of this problem.

Constraints

All values in input are integers.

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

<var>1 \leq u_i < v_i \leq N</var>

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

Input

Input is given from Standard Input in the following format:

<var>N</var>
<var>u_1</var> <var>v_1</var> <var>w_1</var>
<var>u_2</var> <var>v_2</var> <var>w_2</var>
<var>.</var>
<var>.</var>
<var>.</var>
<var>u_{N - 1}</var> <var>v_{N - 1}</var> <var>w_{N - 1}</var>

Output

Print a coloring of the vertices that satisfies the condition, in <var>N</var> lines.
The <var>i</var>-th line should contain 0 if Vertex <var>i</var> is painted white and 1 if it is painted black.

If there are multiple colorings that satisfy the condition, any of them will be accepted.

Sample Input 1

3
1 2 2
2 3 1

Sample Output 1

0
0
1

Sample Input 2

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

Sample Output 2

1
0
1
0
1


Score: <var>300</var> points

Problem Statement

Takahashi has decided to hold fastest-finger-fast quiz games. Kizahashi, who is in charge of making the scoreboard, is struggling to write the program that manages the players' scores in a game, which proceeds as follows.

A game is played by <var>N</var> players, numbered <var>1</var> to <var>N</var>. At the beginning of a game, each player has <var>K</var> points.

When a player correctly answers a question, each of the other <var>N-1</var> players receives minus one (<var>-1</var>) point. There is no other factor that affects the players' scores.

At the end of a game, the players with <var>0</var> points or lower are eliminated, and the remaining players survive.

In the last game, the players gave a total of <var>Q</var> correct answers, the <var>i</var>-th of which was given by Player <var>A_i</var>.
For Kizahashi, write a program that determines whether each of the <var>N</var> players survived this game.

Constraints

All values in input are integers.

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

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

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

<var>1 \leq A_i \leq N\ (1 \leq i \leq Q)</var>

Input

Input is given from Standard Input in the following format:

<var>N</var> <var>K</var> <var>Q</var>
<var>A_1</var>
<var>A_2</var>
<var>.</var>
<var>.</var>
<var>.</var>
<var>A_Q</var>

Output

Print <var>N</var> lines. The <var>i</var>-th line should contain Yes if Player <var>i</var> survived the game, and No otherwise.

Sample Input 1

6 3 4
3
1
3
2

Sample Output 1

No
No
Yes
No
No
No

In the beginning, the players' scores are <var>(3, 3, 3, 3, 3, 3)</var>.

Player <var>3</var> correctly answers a question. The players' scores are now <var>(2, 2, 3, 2, 2, 2)</var>.

Player <var>1</var> correctly answers a question. The players' scores are now <var>(2, 1, 2, 1, 1, 1)</var>.

Player <var>3</var> correctly answers a question. The players' scores are now <var>(1, 0, 2, 0, 0, 0)</var>.

Player <var>2</var> correctly answers a question. The players' scores are now <var>(0, 0, 1, -1, -1, -1)</var>.

Players <var>1, 2, 4, 5</var> and <var>6</var>, who have <var>0</var> points or lower, are eliminated, and Player <var>3</var> survives this game.

Sample Input 2

6 5 4
3
1
3
2

Sample Output 2

Yes
Yes
Yes
Yes
Yes
Yes

Sample Input 3

10 13 15
3
1
4
1
5
9
2
6
5
3
5
8
9
7
9

Sample Output 3

No
No
No
No
Yes
No
No
No
Yes
No


Score : <var>100</var> points

Problem Statement

The window of Takahashi's room has a width of <var>A</var>. There are two curtains hung over the window, each of which has a horizontal length of <var>B</var>. (Vertically, the curtains are long enough to cover the whole window.)

We will close the window so as to minimize the total horizontal length of the uncovered part of the window.
Find the total horizontal length of the uncovered parts of the window then.

Constraints

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

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

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

Input

Input is given from Standard Input in the following format:

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

Output

Print the total horizontal length of the uncovered parts of the window.

Sample Input 1

12 4

Sample Output 1

4

We have a window with a horizontal length of <var>12</var>, and two curtains, each of length <var>4</var>, that cover both ends of the window, for example. The uncovered part has a horizontal length of <var>4</var>.

Sample Input 2

20 15

Sample Output 2

0

If the window is completely covered, print <var>0</var>.

Sample Input 3

20 30

Sample Output 3

0

Each curtain may be longer than the window.


Score : <var>100</var> points

Problem Statement

You are given three integers, <var>A</var>, <var>B</var> and <var>C</var>.

Among them, two are the same, but the remaining one is different from the rest.

For example, when <var>A=5,B=7,C=5</var>, <var>A</var> and <var>C</var> are the same, but <var>B</var> is different.

Find the one that is different from the rest among the given three integers.

Constraints

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

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

The input satisfies the condition in the statement.

Input

Input is given from Standard Input in the following format:

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

Output

Among <var>A</var>, <var>B</var> and <var>C</var>, print the integer that is different from the rest.

Sample Input 1

5 7 5

Sample Output 1

7

This is the same case as the one in the statement.

Sample Input 2

1 1 7

Sample Output 2

7

In this case, <var>C</var> is the one we seek.

Sample Input 3

-100 100 100

Sample Output 3

-100


Score : <var>200</var> points

Problem Statement

Snuke has come to a store that sells boxes containing balls. The store sells the following three kinds of boxes:

Red boxes, each containing <var>R</var> red balls

Green boxes, each containing <var>G</var> green balls

Blue boxes, each containing <var>B</var> blue balls

Snuke wants to get a total of exactly <var>N</var> balls by buying <var>r</var> red boxes, <var>g</var> green boxes and <var>b</var> blue boxes.
How many triples of non-negative integers <var>(r,g,b)</var> achieve this?

Constraints

All values in input are integers.

<var>1 \leq R,G,B,N \leq 3000</var>

Input

Input is given from Standard Input in the following format:

<var>R</var> <var>G</var> <var>B</var> <var>N</var>

Output

Print the answer.

Sample Input 1

1 2 3 4

Sample Output 1

4

Four triples achieve the objective, as follows:

<var>(4,0,0)</var>

<var>(2,1,0)</var>

<var>(1,0,1)</var>

<var>(0,2,0)</var>

Sample Input 2

13 1 4 3000

Sample Output 2

87058


Score : <var>100</var> points

Problem Statement

How many multiples of <var>d</var> are there among the integers between <var>L</var> and <var>R</var> (inclusive)?

Constraints

All values in input are integers.

<var>1 \leq L \leq R \leq 100</var>

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

Input

Input is given from Standard Input in the following format:

<var>L</var> <var>R</var> <var>d</var>

Output

Print the number of multiples of <var>d</var> among the integers between <var>L</var> and <var>R</var> (inclusive).

Sample Input 1

5 10 2

Sample Output 1

3

Among the integers between <var>5</var> and <var>10</var>, there are three multiples of <var>2</var>: <var>6</var>, <var>8</var>, and <var>10</var>.

Sample Input 2

6 20 7

Sample Output 2

2

Among the integers between <var>6</var> and <var>20</var>, there are two multiples of <var>7</var>: <var>7</var> and <var>14</var>.

Sample Input 3

1 100 1

Sample Output 3

100


Score : <var>100</var> points

Problem Statement

It is known that the area of a regular dodecagon inscribed in a circle of radius <var>a</var> is <var>3a^2</var>.

Given an integer <var>r</var>, find the area of a regular dodecagon inscribed in a circle of radius <var>r</var>.

Constraints

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

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

Input

Input is given from Standard Input in the following format:

<var>r</var>

Output

Print an integer representing the area of the regular dodecagon.

Sample Input 1

4

Sample Output 1

48

The area of the regular dodecagon is <var>3 \times 4^2 = 48</var>.

Sample Input 2

15

Sample Output 2

675

Sample Input 3

80

Sample Output 3

19200


Score : <var>300</var> points

Problem Statement

There are <var>N</var> balls in a two-dimensional plane. The <var>i</var>-th ball is at coordinates <var>(x_i, y_i)</var>.

We will collect all of these balls, by choosing two integers <var>p</var> and <var>q</var> such that <var>p \neq 0</var> or <var>q \neq 0</var> and then repeating the following operation:

Choose a ball remaining in the plane and collect it. Let <var>(a, b)</var> be the coordinates of this ball. If we collected a ball at coordinates <var>(a - p, b - q)</var> in the previous operation, the cost of this operation is <var>0</var>. Otherwise, including when this is the first time to do this operation, the cost of this operation is <var>1</var>.

Find the minimum total cost required to collect all the balls when we optimally choose <var>p</var> and <var>q</var>.

Constraints

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

<var>|x_i|, |y_i| \leq 10^9</var>

If <var>i \neq j</var>, <var>x_i \neq x_j</var> or <var>y_i \neq y_j</var>.

All values in input are integers.

Input

Input is given from Standard Input in the following format:

<var>N</var>
<var>x_1</var> <var>y_1</var>
<var>:</var>
<var>x_N</var> <var>y_N</var>

Output

Print the minimum total cost required to collect all the balls.

Sample Input 1

2
1 1
2 2

Sample Output 1

1

If we choose <var>p = 1, q = 1</var>, we can collect all the balls at a cost of <var>1</var> by collecting them in the order <var>(1, 1)</var>, <var>(2, 2)</var>.

Sample Input 2

3
1 4
4 6
7 8

Sample Output 2

1

If we choose <var>p = -3, q = -2</var>, we can collect all the balls at a cost of <var>1</var> by collecting them in the order <var>(7, 8)</var>, <var>(4, 6)</var>, <var>(1, 4)</var>.

Sample Input 3

4
1 1
1 2
2 1
2 2

Sample Output 3

2


Score : <var>200</var> points

Problem Statement

Given are integers <var>a,b,c</var> and <var>d</var>.
If <var>x</var> and <var>y</var> are integers and <var>a \leq x \leq b</var> and <var>c\leq y \leq d</var> hold, what is the maximum possible value of <var>x \times y</var>?

Constraints

<var>-10^9 \leq a \leq b \leq 10^9</var>

<var>-10^9 \leq c \leq d \leq 10^9</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>c</var> <var>d</var>

Output

Print the answer.

Sample Input 1

1 2 1 1

Sample Output 1

2

If <var>x = 1</var> and <var>y = 1</var> then <var>x \times y = 1</var>.
If <var>x = 2</var> and <var>y = 1</var> then <var>x \times y = 2</var>.
Therefore, the answer is <var>2</var>.

Sample Input 2

3 5 -4 -2

Sample Output 2

-6

The answer can be negative.

Sample Input 3

-1000000000 0 -1000000000 0

Sample Output 3

1000000000000000000


Score: <var>400</var> points

Problem Statement

Kizahashi, who was appointed as the administrator of ABC at National Problem Workshop in the Kingdom of AtCoder, got too excited and took on too many jobs.

Let the current time be time <var>0</var>. Kizahashi has <var>N</var> jobs numbered <var>1</var> to <var>N</var>.

It takes <var>A_i</var> units of time for Kizahashi to complete Job <var>i</var>. The deadline for Job <var>i</var> is time <var>B_i</var>, and he must complete the job before or at this time.

Kizahashi cannot work on two or more jobs simultaneously, but when he completes a job, he can start working on another immediately.

Can Kizahashi complete all the jobs in time? If he can, print Yes; if he cannot, print No.

Constraints

All values in input are integers.

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

<var>1 \leq A_i, B_i \leq 10^9 (1 \leq i \leq N)</var>

Input

Input is given from Standard Input in the following format:

<var>N</var>
<var>A_1</var> <var>B_1</var>
<var>.</var>
<var>.</var>
<var>.</var>
<var>A_N</var> <var>B_N</var>

Output

If Kizahashi can complete all the jobs in time, print Yes; if he cannot, print No.

Sample Input 1

5
2 4
1 9
1 8
4 9
3 12

Sample Output 1

Yes

He can complete all the jobs in time by, for example, doing them in the following order:

Do Job <var>2</var> from time <var>0</var> to <var>1</var>.

Do Job <var>1</var> from time <var>1</var> to <var>3</var>.

Do Job <var>4</var> from time <var>3</var> to <var>7</var>.

Do Job <var>3</var> from time <var>7</var> to <var>8</var>.

Do Job <var>5</var> from time <var>8</var> to <var>11</var>.

Note that it is fine to complete Job <var>3</var> exactly at the deadline, time <var>8</var>.

Sample Input 2

3
334 1000
334 1000
334 1000

Sample Output 2

No

He cannot complete all the jobs in time, no matter what order he does them in.

Sample Input 3

30
384 8895
1725 9791
170 1024
4 11105
2 6
578 1815
702 3352
143 5141
1420 6980
24 1602
849 999
76 7586
85 5570
444 4991
719 11090
470 10708
1137 4547
455 9003
110 9901
15 8578
368 3692
104 1286
3 4
366 12143
7 6649
610 2374
152 7324
4 7042
292 11386
334 5720

Sample Output 3

Yes


Score : <var>100</var> points

Problem Statement

You are given three words <var>s_1</var>, <var>s_2</var> and <var>s_3</var>, each composed of lowercase English letters, with spaces in between.
Print the acronym formed from the uppercased initial letters of the words.

Constraints

<var>s_1</var>, <var>s_2</var> and <var>s_3</var> are composed of lowercase English letters.

<var>1 ≤ |s_i| ≤ 10 (1≤i≤3)</var>

Input

Input is given from Standard Input in the following format:

<var>s_1</var> <var>s_2</var> <var>s_3</var>

Output

Print the answer.

Sample Input 1

atcoder beginner contest

Sample Output 1

ABC

The initial letters of atcoder, beginner and contest are a, b and c. Uppercase and concatenate them to obtain ABC.

Sample Input 2

resident register number

Sample Output 2

RRN

Sample Input 3

k nearest neighbor

Sample Output 3

KNN

Sample Input 4

async layered coding

Sample Output 4

ALC


Score : <var>100</var> points

Problem Statement

We will buy a product for <var>N</var> yen (the currency of Japan) at a shop.

If we use only <var>1000</var>-yen bills to pay the price, how much change will we receive?

Assume we use the minimum number of bills required.

Constraints

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

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

Input

Input is given from Standard Input in the following format:

<var>N</var>

Output

Print the amount of change as an integer.

Sample Input 1

1900

Sample Output 1

100

We will use two <var>1000</var>-yen bills to pay the price and receive <var>100</var> yen in change.

Sample Input 2

3000

Sample Output 2

0

We can pay the exact price.


Score : <var>100</var> points

Problem Statement

AtCoDeer has three cards, one red, one green and one blue.

An integer between <var>1</var> and <var>9</var> (inclusive) is written on each card: <var>r</var> on the red card, <var>g</var> on the green card and <var>b</var> on the blue card.

We will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer.

Is this integer a multiple of <var>4</var>?

Constraints

<var>1 ≤ r, g, b ≤ 9</var>

Input

Input is given from Standard Input in the following format:

<var>r</var> <var>g</var> <var>b</var>

Output

If the three-digit integer is a multiple of <var>4</var>, print YES (case-sensitive); otherwise, print NO.

Sample Input 1

4 3 2

Sample Output 1

YES

<var>432</var> is a multiple of <var>4</var>, and thus YES should be printed.

Sample Input 2

2 3 4

Sample Output 2

NO

<var>234</var> is not a multiple of <var>4</var>, and thus NO should be printed.


Score : <var>100</var> points

Problem Statement

In "Takahashi-ya", a ramen restaurant, a bowl of ramen costs <var>700</var> yen (the currency of Japan), plus <var>100</var> yen for each kind of topping (boiled egg, sliced pork, green onions).

A customer ordered a bowl of ramen and told which toppings to put on his ramen to a clerk. The clerk took a memo of the order as a string <var>S</var>. <var>S</var> is three characters long, and if the first character in <var>S</var> is o, it means the ramen should be topped with boiled egg; if that character is x, it means the ramen should not be topped with boiled egg. Similarly, the second and third characters in <var>S</var> mean the presence or absence of sliced pork and green onions on top of the ramen.

Write a program that, when <var>S</var> is given, prints the price of the corresponding bowl of ramen.

Constraints

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

Each character in <var>S</var> is o or x.

Input

Input is given from Standard Input in the following format:

<var>S</var>

Output

Print the price of the bowl of ramen corresponding to <var>S</var>.

Sample Input 1

oxo

Sample Output 1

900

The price of a ramen topped with two kinds of toppings, boiled egg and green onions, is <var>700 + 100 \times 2 = 900</var> yen.

Sample Input 2

ooo

Sample Output 2

1000

The price of a ramen topped with all three kinds of toppings is <var>700 + 100 \times 3 = 1000</var> yen.

Sample Input 3

xxx

Sample Output 3

700

The price of a ramen without any toppings is <var>700</var> yen.


Score : <var>100</var> points

Problem Statement

Given an integer <var>a</var> as input, print the value <var>a + a^2 + a^3</var>.

Constraints

<var>1 \leq a \leq 10</var>

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

Input

Input is given from Standard Input in the following format:

<var>a</var>

Output

Print the value <var>a + a^2 + a^3</var> as an integer.

Sample Input 1

2

Sample Output 1

14

When <var>a = 2</var>, we have <var>a + a^2 + a^3 = 2 + 2^2 + 2^3 = 2 + 4 + 8 = 14</var>.

Print the answer as an input. Outputs such as 14.0 will be judged as incorrect.

Sample Input 2

10

Sample Output 2

1110


Score : <var>100</var> points

Problem Statement

A programming competition site AtCode regularly holds programming contests.

The next contest on AtCode is called ABC, which is rated for contestants with ratings less than <var>1200</var>.

The contest after the ABC is called ARC, which is rated for contestants with ratings less than <var>2800</var>.

The contest after the ARC is called AGC, which is rated for all contestants.

Takahashi's rating on AtCode is <var>R</var>. What is the next contest rated for him?

Constraints

<var>0 ≤ R ≤ 4208</var>

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

Input

Input is given from Standard Input in the following format:

<var>R</var>

Output

Print the name of the next contest rated for Takahashi (ABC, ARC or AGC).

Sample Input 1

1199

Sample Output 1

ABC

<var>1199</var> is less than <var>1200</var>, so ABC will be rated.

Sample Input 2

1200

Sample Output 2

ARC

<var>1200</var> is not less than <var>1200</var> and ABC will be unrated, but it is less than <var>2800</var> and ARC will be rated.

Sample Input 3

4208

Sample Output 3

AGC


Score : <var>300</var> points

Problem Statement

Takahashi, who lives on the number line, is now at coordinate <var>X</var>. He will make exactly <var>K</var> moves of distance <var>D</var> in the positive or negative direction.

More specifically, in one move, he can go from coordinate <var>x</var> to <var>x + D</var> or <var>x - D</var>.

He wants to make <var>K</var> moves so that the absolute value of the coordinate of the destination will be the smallest possible.

Find the minimum possible absolute value of the coordinate of the destination.

Constraints

<var>-10^{15} \leq X \leq 10^{15}</var>

<var>1 \leq K \leq 10^{15}</var>

<var>1 \leq D \leq 10^{15}</var>

All values in input are integers.

Input

Input is given from Standard Input in the following format:

<var>X</var> <var>K</var> <var>D</var>

Output

Print the minimum possible absolute value of the coordinate of the destination.

Sample Input 1

6 2 4

Sample Output 1

2

Takahashi is now at coordinate <var>6</var>. It is optimal to make the following moves:

Move from coordinate <var>6</var> to (<var>6 - 4 =</var>) <var>2</var>.

Move from coordinate <var>2</var> to (<var>2 - 4 =</var>) <var>-2</var>.

Here, the absolute value of the coordinate of the destination is <var>2</var>, and we cannot make it smaller.

Sample Input 2

7 4 3

Sample Output 2

1

Takahashi is now at coordinate <var>7</var>. It is optimal to make, for example, the following moves:

Move from coordinate <var>7</var> to <var>4</var>.

Move from coordinate <var>4</var> to <var>7</var>.

Move from coordinate <var>7</var> to <var>4</var>.

Move from coordinate <var>4</var> to <var>1</var>.

Here, the absolute value of the coordinate of the destination is <var>1</var>, and we cannot make it smaller.

Sample Input 3

10 1 2

Sample Output 3

8

Sample Input 4

1000000000000000 1000000000000000 1000000000000000

Sample Output 4

1000000000000000

The answer can be enormous.


Score : <var>200</var> points

Problem Statement

You are given an integer sequence <var>A</var> of length <var>N</var>.
Find the maximum absolute difference of two elements (with different indices) in <var>A</var>.

Constraints

<var>2 \leq N \leq 100</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>A_2</var> <var>...</var> <var>A_N</var>

Output

Print the maximum absolute difference of two elements (with different indices) in <var>A</var>.

Sample Input 1

4
1 4 6 3

Sample Output 1

5

The maximum absolute difference of two elements is <var>A_3-A_1=6-1=5</var>.

Sample Input 2

2
1000000000 1

Sample Output 2

999999999

Sample Input 3

5
1 1 1 1 1

Sample Output 3

0


Score : <var>200</var> points

Problem Statement

Takahashi loves gold coins. He gains <var>1000</var> happiness points for each <var>500</var>-yen coin he has and gains <var>5</var> happiness points for each <var>5</var>-yen coin he has. (Yen is the currency of Japan.)

Takahashi has <var>X</var> yen. If he exchanges his money so that he will gain the most happiness points, how many happiness points will he earn?

(We assume that there are six kinds of coins available: <var>500</var>-yen, <var>100</var>-yen, <var>50</var>-yen, <var>10</var>-yen, <var>5</var>-yen, and <var>1</var>-yen coins.)

Constraints

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

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

Input

Input is given from Standard Input in the following format:

<var>X</var>

Output

Print the maximum number of happiness points that can be earned.

Sample Input 1

1024

Sample Output 1

2020

By exchanging his money so that he gets two <var>500</var>-yen coins and four <var>5</var>-yen coins, he gains <var>2020</var> happiness points, which is the maximum number of happiness points that can be earned.

Sample Input 2

0

Sample Output 2

0

He is penniless - or yenless.

Sample Input 3

1000000000

Sample Output 3

2000000000

He is a billionaire - in yen.


Score : <var>100</var> points

Problem Statement

An elementary school student Takahashi has come to a variety store.

He has two coins, <var>A</var>-yen and <var>B</var>-yen coins (yen is the currency of Japan), and wants to buy a toy that costs <var>C</var> yen. Can he buy it?

Note that he lives in Takahashi Kingdom, and may have coins that do not exist in Japan.

Constraints

All input values are integers.

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

<var>1 \leq C \leq 1000</var>

Input

Input is given from Standard Input in the following format:

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

Output

If Takahashi can buy the toy, print Yes; if he cannot, print No.

Sample Input 1

50 100 120

Sample Output 1

Yes

He has <var>50 + 100 = 150</var> yen, so he can buy the <var>120</var>-yen toy.

Sample Input 2

500 100 1000

Sample Output 2

No

He has <var>500 + 100 = 600</var> yen, but he cannot buy the <var>1000</var>-yen toy.

Sample Input 3

19 123 143

Sample Output 3

No

There are <var>19</var>-yen and <var>123</var>-yen coins in Takahashi Kingdom, which are rather hard to use.

Sample Input 4

19 123 142

Sample Output 4

Yes


Score : <var>200</var> points

Problem Statement

When Mr. X is away from home, he has decided to use his smartwatch to search the best route to go back home, to participate in ABC.

You, the smartwatch, has found <var>N</var> routes to his home.

If Mr. X uses the <var>i</var>-th of these routes, he will get home in time <var>t_i</var> at cost <var>c_i</var>.

Find the smallest cost of a route that takes not longer than time <var>T</var>.

Constraints

All values in input are integers.

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

<var>1 \leq T \leq 1000</var>

<var>1 \leq c_i \leq 1000</var>

<var>1 \leq t_i \leq 1000</var>

The pairs <var>(c_i, t_i)</var> are distinct.

Input

Input is given from Standard Input in the following format:

<var>N</var> <var>T</var>
<var>c_1</var> <var>t_1</var>
<var>c_2</var> <var>t_2</var>
<var>:</var>
<var>c_N</var> <var>t_N</var>

Output

Print the smallest cost of a route that takes not longer than time <var>T</var>.

If there is no route that takes not longer than time <var>T</var>, print TLE instead.

Sample Input 1

3 70
7 60
1 80
4 50

Sample Output 1

4

The first route gets him home at cost <var>7</var>.

The second route takes longer than time <var>T = 70</var>.

The third route gets him home at cost <var>4</var>.

Thus, the cost <var>4</var> of the third route is the minimum.

Sample Input 2

4 3
1 1000
2 4
3 1000
4 500

Sample Output 2

TLE

There is no route that takes not longer than time <var>T = 3</var>.

Sample Input 3

5 9
25 8
5 9
4 10
1000 1000
6 1

Sample Output 3

5


Score : <var>100</var> points

Problem Statement

You will be given a string <var>S</var> of length <var>3</var> representing the weather forecast for three days in the past.

The <var>i</var>-th character <var>(1 \leq i \leq 3)</var> of <var>S</var> represents the forecast for the <var>i</var>-th day. S, C, and R stand for sunny, cloudy, and rainy, respectively.

You will also be given a string <var>T</var> of length <var>3</var> representing the actual weather on those three days.

The <var>i</var>-th character <var>(1 \leq i \leq 3)</var> of <var>S</var> represents the actual weather on the <var>i</var>-th day. S, C, and R stand for sunny, cloudy, and rainy, respectively.

Print the number of days for which the forecast was correct.

Constraints

<var>S</var> and <var>T</var> are strings of length <var>3</var> each.

<var>S</var> and <var>T</var> consist of S, C, and R.

Input

Input is given from Standard Input in the following format:

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

Output

Print the number of days for which the forecast was correct.

Sample Input 1

CSS
CSR

Sample Output 1

2

For the first day, it was forecast to be cloudy, and it was indeed cloudy.

For the second day, it was forecast to be sunny, and it was indeed sunny.

For the third day, it was forecast to be sunny, but it was rainy.

Thus, the forecast was correct for two days in this case.

Sample Input 2

SSR
SSR

Sample Output 2

3

Sample Input 3

RRR
SSS

Sample Output 3

0


Score : <var>100</var> points

Problem Statement

Given are three integers <var>A_1</var>, <var>A_2</var>, and <var>A_3</var>.

If <var>A_1+A_2+A_3</var> is greater than or equal to <var>22</var>, print bust; otherwise, print win.

Constraints

<var>1 \leq A_i \leq 13 \ \ (i=1,2,3)</var>

All values in input are integers.

Input

Input is given from Standard Input in the following format:

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

Output

If <var>A_1+A_2+A_3</var> is greater than or equal to <var>22</var>, print bust; otherwise, print win.

Sample Input 1

5 7 9

Sample Output 1

win

<var>5+7+9=21</var>, so print win.

Sample Input 2

13 7 2

Sample Output 2

bust

<var>13+7+2=22</var>, so print bust.


Score : <var>400</var> points

Problem Statement

We have <var>N</var> balls. The <var>i</var>-th ball has an integer <var>A_i</var> written on it.

For each <var>k=1, 2, ..., N</var>, solve the following problem and print the answer.

Find the number of ways to choose two distinct balls (disregarding order) from the <var>N-1</var> balls other than the <var>k</var>-th ball so that the integers written on them are equal.

Constraints

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

<var>1 \leq A_i \leq N</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>A_2</var> <var>...</var> <var>A_N</var>

Output

For each <var>k=1,2,...,N</var>, print a line containing the answer.

Sample Input 1

5
1 1 2 1 2

Sample Output 1

2
2
3
2
3

Consider the case <var>k=1</var> for example. The numbers written on the remaining balls are <var>1,2,1,2</var>.

From these balls, there are two ways to choose two distinct balls so that the integers written on them are equal.

Thus, the answer for <var>k=1</var> is <var>2</var>.

Sample Input 2

4
1 2 3 4

Sample Output 2

0
0
0
0

No two balls have equal numbers written on them.

Sample Input 3

5
3 3 3 3 3

Sample Output 3

6
6
6
6
6

Any two balls have equal numbers written on them.

Sample Input 4

8
1 2 1 4 2 1 4 1

Sample Output 4

5
7
5
7
7
5
7
5


Score : <var>200</var> points

Problem Statement

We have a sequence <var>p</var> = {<var>p_1,\ p_2,\ ...,\ p_N</var>} which is a permutation of {<var>1,\ 2,\ ...,\ N</var>}.

You can perform the following operation at most once: choose integers <var>i</var> and <var>j</var> <var>(1 \leq i < j \leq N)</var>, and swap <var>p_i</var> and <var>p_j</var>. Note that you can also choose not to perform it.

Print YES if you can sort <var>p</var> in ascending order in this way, and NO otherwise.

Constraints

All values in input are integers.

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

<var>p</var> is a permutation of {<var>1,\ 2,\ ...,\ N</var>}.

Input

Input is given from Standard Input in the following format:

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

Output

Print YES if you can sort <var>p</var> in ascending order in the way stated in the problem statement, and NO otherwise.

Sample Input 1

5
5 2 3 4 1

Sample Output 1

YES

You can sort <var>p</var> in ascending order by swapping <var>p_1</var> and <var>p_5</var>.

Sample Input 2

5
2 4 3 5 1

Sample Output 2

NO

In this case, swapping any two elements does not sort <var>p</var> in ascending order.

Sample Input 3

7
1 2 3 4 5 6 7

Sample Output 3

YES

<var>p</var> is already sorted in ascending order, so no operation is needed.


Score : <var>200</var> points

Problem Statement

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

Snuke has decided to distribute <var>x</var> sweets among them.
He needs to give out all the <var>x</var> sweets, but some of the children may get zero sweets.

For each <var>i</var> (<var>1 \leq i \leq N</var>), Child <var>i</var> will be happy if he/she gets exactly <var>a_i</var> sweets.
Snuke is trying to maximize the number of happy children by optimally distributing the sweets.
Find the maximum possible number of happy children.

Constraints

All values in input are integers.

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

<var>1 \leq x \leq 10^9</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>x</var>
<var>a_1</var> <var>a_2</var> <var>...</var> <var>a_N</var>

Output

Print the maximum possible number of happy children.

Sample Input 1

3 70
20 30 10

Sample Output 1

2

One optimal way to distribute sweets is <var>(20, 30, 20)</var>.

Sample Input 2

3 10
20 30 10

Sample Output 2

1

The optimal way to distribute sweets is <var>(0, 0, 10)</var>.

Sample Input 3

4 1111
1 10 100 1000

Sample Output 3

4

The optimal way to distribute sweets is <var>(1, 10, 100, 1000)</var>.

Sample Input 4

2 10
20 20

Sample Output 4

0

No children will be happy, no matter how the sweets are distributed.


Score : <var>300</var> points

Problem Statement

There is a circular pond with a perimeter of <var>K</var> meters, and <var>N</var> houses around them.

The <var>i</var>-th house is built at a distance of <var>A_i</var> meters from the northmost point of the pond, measured clockwise around the pond.

When traveling between these houses, you can only go around the pond.

Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the <var>N</var> houses.

Constraints

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

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

<var>0 \leq A_1 < ... < A_N < K</var>

All values in input are integers.

Input

Input is given from Standard Input in the following format:

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

Output

Print the minimum distance that needs to be traveled when you start at one of the houses and visit all the <var>N</var> houses.

Sample Input 1

20 3
5 10 15

Sample Output 1

10

If you start at the <var>1</var>-st house and go to the <var>2</var>-nd and <var>3</var>-rd houses in this order, the total distance traveled will be <var>10</var>.

Sample Input 2

20 3
0 5 15

Sample Output 2

10

If you start at the <var>2</var>-nd house and go to the <var>1</var>-st and <var>3</var>-rd houses in this order, the total distance traveled will be <var>10</var>.


Score : <var>200</var> points

Problem Statement

You have an integer variable <var>x</var>.
Initially, <var>x=0</var>.

Some person gave you a string <var>S</var> of length <var>N</var>, and using the string you performed the following operation <var>N</var> times.
In the <var>i</var>-th operation, you incremented the value of <var>x</var> by <var>1</var> if <var>S_i=</var>I, and decremented the value of <var>x</var> by <var>1</var> if <var>S_i=</var>D.

Find the maximum value taken by <var>x</var> during the operations (including before the first operation, and after the last operation).

Constraints

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

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

No characters except I and D occur in <var>S</var>.

Input

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

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

Output

Print the maximum value taken by <var>x</var> during the operations.

Sample Input 1

5
IIDID

Sample Output 1

2

After each operation, the value of <var>x</var> becomes <var>1</var>, <var>2</var>, <var>1</var>, <var>2</var> and <var>1</var>, respectively. Thus, the output should be <var>2</var>, the maximum value.

Sample Input 2

7
DDIDDII

Sample Output 2

0

The initial value <var>x=0</var> is the maximum value taken by <var>x</var>, thus the output should be <var>0</var>.


Score : <var>200</var> points

Problem Statement

You are given a string <var>S</var> of length <var>N</var> consisting of lowercase English letters.
We will cut this string at one position into two strings <var>X</var> and <var>Y</var>.
Here, we would like to maximize the number of different letters contained in both <var>X</var> and <var>Y</var>.
Find the largest possible number of different letters contained in both <var>X</var> and <var>Y</var> when we cut the string at the optimal position.

Constraints

<var>2 \leq N \leq 100</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 largest possible number of different letters contained in both <var>X</var> and <var>Y</var>.

Sample Input 1

6
aabbca

Sample Output 1

2

If we cut the string between the third and fourth letters into <var>X =</var> aab and <var>Y =</var> bca, the letters contained in both <var>X</var> and <var>Y</var> are a and b.
There will never be three or more different letters contained in both <var>X</var> and <var>Y</var>, so the answer is <var>2</var>.

Sample Input 2

10
aaaaaaaaaa

Sample Output 2

1

However we divide <var>S</var>, only a will be contained in both <var>X</var> and <var>Y</var>.

Sample Input 3

45
tgxgdqkyjzhyputjjtllptdfxocrylqfqjynmfbfucbir

Sample Output 3

9


Score : <var>200</var> points

Problem Statement

A shop sells <var>N</var> kinds of fruits, Fruit <var>1, \ldots, N</var>, at prices of <var>p_1, \ldots, p_N</var> yen per item, respectively. (Yen is the currency of Japan.)

Here, we will choose <var>K</var> kinds of fruits and buy one of each chosen kind. Find the minimum possible total price of those fruits.

Constraints

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

<var>1 \leq p_i \leq 1000</var>

All values in input are integers.

Input

Input is given from Standard Input in the following format:

<var>N</var> <var>K</var>
<var>p_1</var> <var>p_2</var> <var>\ldots</var> <var>p_N</var>

Output

Print an integer representing the minimum possible total price of fruits.

Sample Input 1

5 3
50 100 80 120 80

Sample Output 1

210

This shop sells Fruit <var>1</var>, <var>2</var>, <var>3</var>, <var>4</var>, and <var>5</var> for <var>50</var> yen, <var>100</var> yen, <var>80</var> yen, <var>120</var> yen, and <var>80</var> yen, respectively.

The minimum total price for three kinds of fruits is <var>50 + 80 + 80 = 210</var> yen when choosing Fruit <var>1</var>, <var>3</var>, and <var>5</var>.

Sample Input 2

1 1
1000

Sample Output 2

1000


Score : <var>100</var> points

Problem Statement

There are <var>S</var> sheep and <var>W</var> wolves.

If the number of wolves is greater than or equal to that of sheep, the wolves will attack the sheep.

If the wolves will attack the sheep, print unsafe; otherwise, print safe.

Constraints

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

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

Input

Input is given from Standard Input in the following format:

<var>S</var> <var>W</var>

Output

If the wolves will attack the sheep, print unsafe; otherwise, print safe.

Sample Input 1

4 5

Sample Output 1

unsafe

There are four sheep and five wolves. The number of wolves is not less than that of sheep, so they will attack them.

Sample Input 2

100 2

Sample Output 2

safe

Many a sheep drive away two wolves.

Sample Input 3

10 10

Sample Output 3

unsafe


Score : <var>100</var> points

Problem Statement

A Hitachi string is a concatenation of one or more copies of the string hi.

For example, hi and hihi are Hitachi strings, while ha and hii are not.

Given a string <var>S</var>, determine whether <var>S</var> is a Hitachi string.

Constraints

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

<var>S</var> is a string 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 a Hitachi string, print Yes; otherwise, print No.

Sample Input 1

hihi

Sample Output 1

Yes

hihi is the concatenation of two copies of hi, so it is a Hitachi string.

Sample Input 2

hi

Sample Output 2

Yes

Sample Input 3

ha

Sample Output 3

No


Score : <var>100</var> points

Problem Statement

A balance scale tips to the left if <var>L>R</var>, where <var>L</var> is the total weight of the masses on the left pan and <var>R</var> is the total weight of the masses on the right pan. Similarly, it balances if <var>L=R</var>, and tips to the right if <var>L<R</var>.

Takahashi placed a mass of weight <var>A</var> and a mass of weight <var>B</var> on the left pan of a balance scale, and placed a mass of weight <var>C</var> and a mass of weight <var>D</var> on the right pan.

Print Left if the balance scale tips to the left; print Balanced if it balances; print Right if it tips to the right.

Constraints

<var>1\leq A,B,C,D \leq 10</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 Left if the balance scale tips to the left; print Balanced if it balances; print Right if it tips to the right.

Sample Input 1

3 8 7 1

Sample Output 1

Left

The total weight of the masses on the left pan is <var>11</var>, and the total weight of the masses on the right pan is <var>8</var>. Since <var>11>8</var>, we should print Left.

Sample Input 2

3 4 5 2

Sample Output 2

Balanced

The total weight of the masses on the left pan is <var>7</var>, and the total weight of the masses on the right pan is <var>7</var>. Since <var>7=7</var>, we should print Balanced.

Sample Input 3

1 7 6 4

Sample Output 3

Right

The total weight of the masses on the left pan is <var>8</var>, and the total weight of the masses on the right pan is <var>10</var>. Since <var>8<10</var>, we should print Right.


Score : <var>200</var> points

Problem Statement

You have <var>N</var> apples, called Apple <var>1</var>, Apple <var>2</var>, Apple <var>3</var>, ..., Apple <var>N</var>. The flavor of Apple <var>i</var> is <var>L+i-1</var>, which can be negative.

You can make an apple pie using one or more of the apples. The flavor of the apple pie will be the sum of the flavors of the apples used.

You planned to make an apple pie using all of the apples, but being hungry tempts you to eat one of them, which can no longer be used to make the apple pie.

You want to make an apple pie that is as similar as possible to the one that you planned to make. Thus, you will choose the apple to eat so that the flavor of the apple pie made of the remaining <var>N-1</var> apples will have the smallest possible absolute difference from the flavor of the apple pie made of all the <var>N</var> apples.

Find the flavor of the apple pie made of the remaining <var>N-1</var> apples when you choose the apple to eat as above.

We can prove that this value is uniquely determined.

Constraints

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

<var>-100 \leq L \leq 100</var>

All values in input are integers.

Input

Input is given from Standard Input in the following format:

<var>N</var> <var>L</var>

Output

Find the flavor of the apple pie made of the remaining <var>N-1</var> apples when you optimally choose the apple to eat.

Sample Input 1

5 2

Sample Output 1

18

The flavors of Apple <var>1</var>, <var>2</var>, <var>3</var>, <var>4</var>, and <var>5</var> are <var>2</var>, <var>3</var>, <var>4</var>, <var>5</var>, and <var>6</var>, respectively. The optimal choice is to eat Apple <var>1</var>, so the answer is <var>3+4+5+6=18</var>.

Sample Input 2

3 -1

Sample Output 2

0

The flavors of Apple <var>1</var>, <var>2</var>, and <var>3</var> are <var>-1</var>, <var>0</var>, and <var>1</var>, respectively. The optimal choice is to eat Apple <var>2</var>, so the answer is <var>(-1)+1=0</var>.

Sample Input 3

30 -50

Sample Output 3

-1044


Score : <var>200</var> points

Problem Statement

The development of algae in a pond is as follows.

Let the total weight of the algae at the beginning of the year <var>i</var> be <var>x_i</var> gram. For <var>i≥2000</var>, the following formula holds:

<var>x_{i+1} = rx_i - D</var>

You are given <var>r</var>, <var>D</var> and <var>x_{2000}</var>. Calculate <var>x_{2001}</var>, <var>...</var>, <var>x_{2010}</var> and print them in order.

Constraints

<var>2 ≤ r ≤ 5</var>

<var>1 ≤ D ≤ 100</var>

<var>D < x_{2000} ≤ 200</var>

All values in input are integers.

Input

Input is given from Standard Input in the following format:

<var>r</var> <var>D</var> <var>x_{2000}</var>

Output

Print <var>10</var> lines. The <var>i</var>-th line (<var>1 ≤ i ≤ 10</var>) should contain <var>x_{2000+i}</var> as an integer.

Sample Input 1

2 10 20

Sample Output 1

30
50
90
170
330
650
1290
2570
5130
10250

For example, <var>x_{2001} = rx_{2000} - D = 2 \times 20 - 10 = 30</var> and <var>x_{2002} = rx_{2001} - D = 2 \times 30 - 10 = 50</var>.

Sample Input 2

4 40 60

Sample Output 2

200
760
3000
11960
47800
191160
764600
3058360
12233400
48933560


Score : <var>200</var> points

Problem Statement

Our world is one-dimensional, and ruled by two empires called Empire A and Empire B.

The capital of Empire A is located at coordinate <var>X</var>, and that of Empire B is located at coordinate <var>Y</var>.

One day, Empire A becomes inclined to put the cities at coordinates <var>x_1, x_2, ..., x_N</var> under its control, and Empire B becomes inclined to put the cities at coordinates <var>y_1, y_2, ..., y_M</var> under its control.

If there exists an integer <var>Z</var> that satisfies all of the following three conditions, they will come to an agreement, but otherwise war will break out.

<var>X < Z \leq Y</var>

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

<var>y_1, y_2, ..., y_M \geq Z</var>

Determine if war will break out.

Constraints

All values in input are integers.

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

<var>-100 \leq X < Y \leq 100</var>

<var>-100 \leq x_i, y_i \leq 100</var>

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

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

<var>y_1, y_2, ..., y_M \neq Y</var>

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

Input

Input is given from Standard Input in the following format:

<var>N</var> <var>M</var> <var>X</var> <var>Y</var>
<var>x_1</var> <var>x_2</var> <var>...</var> <var>x_N</var>
<var>y_1</var> <var>y_2</var> <var>...</var> <var>y_M</var>

Output

If war will break out, print War; otherwise, print No War.

Sample Input 1

3 2 10 20
8 15 13
16 22

Sample Output 1

No War

The choice <var>Z = 16</var> satisfies all of the three conditions as follows, thus they will come to an agreement.

<var>X = 10 < 16 \leq 20 = Y</var>

<var>8, 15, 13 < 16</var>

<var>16, 22 \geq 16</var>

Sample Input 2

4 2 -48 -1
-20 -35 -91 -23
-22 66

Sample Output 2

War

Sample Input 3

5 3 6 8
-10 3 1 5 -100
100 6 14

Sample Output 3

War


Score : <var>300</var> points

Problem Statement

We have a grid of <var>H</var> rows and <var>W</var> columns of squares. The color of the square at the <var>i</var>-th row from the top and the <var>j</var>-th column from the left <var>(1 \leq i \leq H, 1 \leq j \leq W)</var> is given to you as a character <var>c_{i,j}</var>: the square is white if <var>c_{i,j}</var> is ., and black if <var>c_{i,j}</var> is #.

Consider doing the following operation:

Choose some number of rows (possibly zero), and some number of columns (possibly zero). Then, paint red all squares in the chosen rows and all squares in the chosen columns.

You are given a positive integer <var>K</var>. How many choices of rows and columns result in exactly <var>K</var> black squares remaining after the operation? Here, we consider two choices different when there is a row or column chosen in only one of those choices.

Constraints

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

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

<var>c_{i,j}</var> is . or #.

Input

Input is given from Standard Input in the following format:

<var>H</var> <var>W</var> <var>K</var>
<var>c_{1,1}c_{1,2}...c_{1,W}</var>
<var>c_{2,1}c_{2,2}...c_{2,W}</var>
<var>:</var>
<var>c_{H,1}c_{H,2}...c_{H,W}</var>

Output

Print an integer representing the number of choices of rows and columns satisfying the condition.

Sample Input 1

2 3 2
..#
###

Sample Output 1

5

Five choices below satisfy the condition.

The <var>1</var>-st row and <var>1</var>-st column

The <var>1</var>-st row and <var>2</var>-nd column

The <var>1</var>-st row and <var>3</var>-rd column

The <var>1</var>-st and <var>2</var>-nd column

The <var>3</var>-rd column

Sample Input 2

2 3 4
..#
###

Sample Output 2

1

One choice, which is choosing nothing, satisfies the condition.

Sample Input 3

2 2 3
##
##

Sample Output 3

0

Sample Input 4

6 6 8
..##..
.#..#.
#....#
######
#....#
#....#

Sample Output 4

208


Score : <var>300</var> points

Problem Statement

You are given a string <var>S</var> consisting of lowercase English letters.
Another string <var>T</var> is initially empty.
Determine whether it is possible to obtain <var>S = T</var> by performing the following operation an arbitrary number of times:

Append one of the following at the end of <var>T</var>: dream, dreamer, erase and eraser.

Constraints

<var>1≦|S|≦10^5</var>

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

Input

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

<var>S</var>

Output

If it is possible to obtain <var>S = T</var>, print YES. Otherwise, print NO.

Sample Input 1

erasedream

Sample Output 1

YES

Append erase and dream at the end of <var>T</var> in this order, to obtain <var>S = T</var>.

Sample Input 2

dreameraser

Sample Output 2

YES

Append dream and eraser at the end of <var>T</var> in this order, to obtain <var>S = T</var>.

Sample Input 3

dreamerer

Sample Output 3

NO


Score : <var>100</var> points

Problem Statement

Takahashi is meeting up with Aoki.

They have planned to meet at a place that is <var>D</var> meters away from Takahashi's house in <var>T</var> minutes from now.

Takahashi will leave his house now and go straight to the place at a speed of <var>S</var> meters per minute.

Will he arrive in time?

Constraints

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

<var>1 \leq T \leq 10000</var>

<var>1 \leq S \leq 10000</var>

All values in input are integers.

Input

Input is given from Standard Input in the following format:

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

Output

If Takahashi will reach the place in time, print Yes; otherwise, print No.

Sample Input 1

1000 15 80

Sample Output 1

Yes

It takes <var>12.5</var> minutes to go <var>1000</var> meters to the place at a speed of <var>80</var> meters per minute. They have planned to meet in <var>15</var> minutes so he will arrive in time.

Sample Input 2

2000 20 100

Sample Output 2

Yes

It takes <var>20</var> minutes to go <var>2000</var> meters to the place at a speed of <var>100</var> meters per minute. They have planned to meet in <var>20</var> minutes so he will arrive just on time.

Sample Input 3

10000 1 1

Sample Output 3

No

He will be late.


Score : <var>100</var> points

Problem Statement

You are given a string <var>S</var> of length <var>3</var> consisting of a, b and c. Determine if <var>S</var> can be obtained by permuting abc.

Constraints

<var>|S|=3</var>

<var>S</var> consists of a, b and c.

Input

Input is given from Standard Input in the following format:

<var>S</var>

Output

If <var>S</var> can be obtained by permuting abc, print Yes; otherwise, print No.

Sample Input 1

bac

Sample Output 1

Yes

Swapping the first and second characters in bac results in abc.

Sample Input 2

bab

Sample Output 2

No

Sample Input 3

abc

Sample Output 3

Yes

Sample Input 4

aaa

Sample Output 4

No


Score : <var>100</var> points

Problem Statement

You went shopping to buy cakes and donuts with <var>X</var> yen (the currency of Japan).

First, you bought one cake for <var>A</var> yen at a cake shop.
Then, you bought as many donuts as possible for <var>B</var> yen each, at a donut shop.

How much do you have left after shopping?

Constraints

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

<var>A + B \leq X \leq 10</var> <var>000</var>

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

Input

Input is given from Standard Input in the following format:

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

Output

Print the amount you have left after shopping.

Sample Input 1

1234
150
100

Sample Output 1

84

You have <var>1234 - 150 = 1084</var> yen left after buying a cake.
With this amount, you can buy <var>10</var> donuts, after which you have <var>84</var> yen left.

Sample Input 2

1000
108
108

Sample Output 2

28

Sample Input 3

579
123
456

Sample Output 3

0

Sample Input 4

7477
549
593

Sample Output 4

405


Score : <var>200</var> points

Problem Statement

You are given a positive integer <var>X</var>.
Find the largest perfect power that is at most <var>X</var>.
Here, a perfect power is an integer that can be represented as <var>b^p</var>, where <var>b</var> is an integer not less than <var>1</var> and <var>p</var> is an integer not less than <var>2</var>.

Constraints

<var>1</var> <var>≤</var> <var>X</var> <var>≤</var> <var>1000</var>

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

Input

Input is given from Standard Input in the following format:

<var>X</var>

Output

Print the largest perfect power that is at most <var>X</var>.

Sample Input 1

10

Sample Output 1

9

There are four perfect powers that are at most <var>10</var>: <var>1</var>, <var>4</var>, <var>8</var> and <var>9</var>.
We should print the largest among them, <var>9</var>.

Sample Input 2

1

Sample Output 2

1

Sample Input 3

999

Sample Output 3

961


Score : <var>200</var> points

Problem Statement

You are given a string <var>S</var> of length <var>N</var> consisting of lowercase English letters, and an integer <var>K</var>.
Print the string obtained by replacing every character in <var>S</var> that differs from the <var>K</var>-th character of <var>S</var>, with *.

Constraints

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

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

<var>N</var> and <var>K</var> are integers.

Input

Input is given from Standard Input in the following format:

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

Output

Print the string obtained by replacing every character in <var>S</var> that differs from the <var>K</var>-th character of <var>S</var>, with *.

Sample Input 1

5
error
2

Sample Output 1

*rr*r

The second character of <var>S</var> is r. When we replace every character in error that differs from r with *, we get the string *rr*r.

Sample Input 2

6
eleven
5

Sample Output 2

e*e*e*

Sample Input 3

9
education
7

Sample Output 3

******i**


Score : <var>100</var> points

Problem Statement

There are <var>N</var> students in a school.

We will divide these students into some groups, and in each group they will discuss some themes.

You think that groups consisting of two or less students cannot have an effective discussion, so you want to have as many groups consisting of three or more students as possible.

Divide the students so that the number of groups consisting of three or more students is maximized.

Constraints

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

All input values are integers.

Input

Input is given from Standard Input in the following format:

<var>N</var>

Output

If you can form at most <var>x</var> groups consisting of three or more students, print <var>x</var>.

Sample Input 1

8

Sample Output 1

2

For example, you can form a group of three students and another of five students.

Sample Input 2

2

Sample Output 2

0

Sometimes you cannot form any group consisting of three or more students, regardless of how you divide the students.

Sample Input 3

9

Sample Output 3

3


Score : <var>100</var> points

Problem Statement

Determine if we can choose <var>K</var> different integers between <var>1</var> and <var>N</var> (inclusive) so that no two of them differ by <var>1</var>.

Constraints

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

<var>N</var> and <var>K</var> are integers.

Input

Input is given from Standard Input in the following format:

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

Output

If we can choose <var>K</var> integers as above, print YES; otherwise, print NO.

Sample Input 1

3 2

Sample Output 1

YES

We can choose <var>1</var> and <var>3</var>.

Sample Input 2

5 5

Sample Output 2

NO

Sample Input 3

31 10

Sample Output 3

YES

Sample Input 4

10 90

Sample Output 4

NO


Score : <var>100</var> points

Problem Statement

Takahashi wants to be a member of some web service.

He tried to register himself with the ID <var>S</var>, which turned out to be already used by another user.

Thus, he decides to register using a string obtained by appending one character at the end of <var>S</var> as his ID.

He is now trying to register with the ID <var>T</var>. Determine whether this string satisfies the property above.

Constraints

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

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

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

Input

Input is given from Standard Input in the following format:

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

Output

If <var>T</var> satisfies the property in Problem Statement, print Yes; otherwise, print No.

Sample Input 1

chokudai
chokudaiz

Sample Output 1

Yes

chokudaiz can be obtained by appending z at the end of chokudai.

Sample Input 2

snuke
snekee

Sample Output 2

No

snekee cannot be obtained by appending one character at the end of snuke.

Sample Input 3

a
aa

Sample Output 3

Yes


Score : <var>300</var> points

Problem Statement

We will play a one-player game using a number line and <var>N</var> pieces.

First, we place each of these pieces at some integer coordinate.

Here, multiple pieces can be placed at the same coordinate.

Our objective is to visit all of the <var>M</var> coordinates <var>X_1, X_2, ..., X_M</var> with these pieces, by repeating the following move:

Move: Choose a piece and let <var>x</var> be its coordinate. Put that piece at coordinate <var>x+1</var> or <var>x-1</var>.

Note that the coordinates where we initially place the pieces are already regarded as visited.

Find the minimum number of moves required to achieve the objective.

Constraints

All values in input are integers.

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

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

<var>-10^5 \leq X_i \leq 10^5</var>

<var>X_1, X_2, ..., X_M</var> are all different.

Input

Input is given from Standard Input in the following format:

<var>N</var> <var>M</var>
<var>X_1</var> <var>X_2</var> <var>...</var> <var>X_M</var>

Output

Find the minimum number of moves required to achieve the objective.

Sample Input 1

2 5
10 12 1 2 14

Sample Output 1

5

The objective can be achieved in five moves as follows, and this is the minimum number of moves required.

Initially, put the two pieces at coordinates <var>1</var> and <var>10</var>.

Move the piece at coordinate <var>1</var> to <var>2</var>.

Move the piece at coordinate <var>10</var> to <var>11</var>.

Move the piece at coordinate <var>11</var> to <var>12</var>.

Move the piece at coordinate <var>12</var> to <var>13</var>.

Move the piece at coordinate <var>13</var> to <var>14</var>.

Sample Input 2

3 7
-10 -3 0 9 -100 2 17

Sample Output 2

19

Sample Input 3

100 1
-100000

Sample Output 3

0


Score : <var>100</var> points

Problem Statement

We have a <var>3×3</var> square grid, where each square contains a lowercase English letters.
The letter in the square at the <var>i</var>-th row from the top and <var>j</var>-th column from the left is <var>c_{ij}</var>.

Print the string of length <var>3</var> that can be obtained by concatenating the letters in the squares on the diagonal connecting the top-left and bottom-right corner of the grid, from the top-left to bottom-right.

Constraints

Input consists of lowercase English letters.

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>
<var>c_{31}c_{32}c_{33}</var>

Output

Print the string of length <var>3</var> that can be obtained by concatenating the letters on the diagonal connecting the top-left and bottom-right corner of the grid, from the top-left to bottom-right.

Sample Input 1

ant
obe
rec

Sample Output 1

abc

The letters in the squares on the diagonal connecting the top-left and bottom-right corner of the grid are a, b and c from top-right to bottom-left. Concatenate these letters and print abc.

Sample Input 2

edu
cat
ion

Sample Output 2

ean


Score : <var>100</var> points

Problem Statement

You are given a three-digit positive integer <var>N</var>.

Determine whether <var>N</var> is a palindromic number.

Here, a palindromic number is an integer that reads the same backward as forward in decimal notation.

Constraints

<var>100≤N≤999</var>

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

Input

Input is given from Standard Input in the following format:

<var>N</var>

Output

If <var>N</var> is a palindromic number, print Yes; otherwise, print No.

Sample Input 1

575

Sample Output 1

Yes

<var>N=575</var> is also <var>575</var> when read backward, so it is a palindromic number. You should print Yes.

Sample Input 2

123

Sample Output 2

No

<var>N=123</var> becomes <var>321</var> when read backward, so it is not a palindromic number. You should print No.

Sample Input 3

812

Sample Output 3

No


Score : <var>100</var> points

Problem Statement

Given is a three-digit integer <var>N</var>. Does <var>N</var> contain the digit <var>7</var>?

If so, print Yes; otherwise, print No.

Constraints

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

Input

Input is given from Standard Input in the following format:

<var>N</var>

Output

If <var>N</var> contains the digit <var>7</var>, print Yes; otherwise, print No.

Sample Input 1

117

Sample Output 1

Yes

<var>117</var> contains <var>7</var> as its last digit.

Sample Input 2

123

Sample Output 2

No

<var>123</var> does not contain the digit <var>7</var>.

Sample Input 3

777

Sample Output 3

Yes


Score : <var>100</var> points

Problem Statement

There are two rectangles.
The lengths of the vertical sides of the first rectangle are <var>A</var>, and the lengths of the horizontal sides of the first rectangle are <var>B</var>.
The lengths of the vertical sides of the second rectangle are <var>C</var>, and the lengths of the horizontal sides of the second rectangle are <var>D</var>.

Print the area of the rectangle with the larger area.
If the two rectangles have equal areas, print that area.

Constraints

All input values are integers.

<var>1≤A≤10^4</var>

<var>1≤B≤10^4</var>

<var>1≤C≤10^4</var>

<var>1≤D≤10^4</var>

Input

The 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 area of the rectangle with the larger area.
If the two rectangles have equal areas, print that area.

Sample Input 1

3 5 2 7

Sample Output 1

15

The first rectangle has an area of <var>3×5=15</var>, and the second rectangle has an area of <var>2×7=14</var>.
Thus, the output should be <var>15</var>, the larger area.

Sample Input 2

100 600 200 300

Sample Output 2

60000


Score : <var>200</var> points

Problem Statement

Let us define the FizzBuzz sequence <var>a_1,a_2,...</var> as follows:

If both <var>3</var> and <var>5</var> divides <var>i</var>, <var>a_i=\mbox{FizzBuzz}</var>.

If the above does not hold but <var>3</var> divides <var>i</var>, <var>a_i=\mbox{Fizz}</var>.

If none of the above holds but <var>5</var> divides <var>i</var>, <var>a_i=\mbox{Buzz}</var>.

If none of the above holds, <var>a_i=i</var>.

Find the sum of all numbers among the first <var>N</var> terms of the FizzBuzz sequence.

Constraints

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

Input

Input is given from Standard Input in the following format:

<var>N</var>

Output

Print the sum of all numbers among the first <var>N</var> terms of the FizzBuzz sequence.

Sample Input 1

15

Sample Output 1

60

The first <var>15</var> terms of the FizzBuzz sequence are:

<var>1,2,\mbox{Fizz},4,\mbox{Buzz},\mbox{Fizz},7,8,\mbox{Fizz},\mbox{Buzz},11,\mbox{Fizz},13,14,\mbox{FizzBuzz}</var>

Among them, numbers are <var>1,2,4,7,8,11,13,14</var>, and the sum of them is <var>60</var>.

Sample Input 2

1000000

Sample Output 2

266666333332

Watch out for overflow.


Score : <var>100</var> points

Problem Statement

AtCoDeer the deer found two positive integers, <var>a</var> and <var>b</var>.
Determine whether the product of <var>a</var> and <var>b</var> is even or odd.

Constraints

<var>1</var> <var>≤</var> <var>a,b</var> <var>≤</var> <var>10000</var>

<var>a</var> and <var>b</var> are integers.

Input

Input is given from Standard Input in the following format:

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

Output

If the product is odd, print Odd; if it is even, print Even.

Sample Input 1

3 4

Sample Output 1

Even

As <var>3 × 4 = 12</var> is even, print Even.

Sample Input 2

1 21

Sample Output 2

Odd

As <var>1 × 21 = 21</var> is odd, print Odd.


Score : <var>300</var> points

Problem Statement

Compute <var>A \times B</var>, truncate its fractional part, and print the result as an integer.

Constraints

<var>0 \leq A \leq 10^{15}</var>

<var>0 \leq B < 10</var>

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

<var>B</var> is a number with two digits after the decimal point.

Input

Input is given from Standard Input in the following format:

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

Output

Print the answer as an integer.

Sample Input 1

198 1.10

Sample Output 1

217

We have <var>198 \times 1.10 = 217.8</var>. After truncating the fractional part, we have the answer: <var>217</var>.

Sample Input 2

1 0.01

Sample Output 2

0

Sample Input 3

1000000000000000 9.99

Sample Output 3

9990000000000000


Score : <var>200</var> points

Problem Statement

You are given an image <var>A</var> composed of <var>N</var> rows and <var>N</var> columns of pixels, and a template image <var>B</var> composed of <var>M</var> rows and <var>M</var> columns of pixels.

A pixel is the smallest element of an image, and in this problem it is a square of size <var>1×1</var>.

Also, the given images are binary images, and the color of each pixel is either white or black.

In the input, every pixel is represented by a character: . corresponds to a white pixel, and # corresponds to a black pixel.

The image <var>A</var> is given as <var>N</var> strings <var>A_1,...,A_N</var>.

The <var>j</var>-th character in the string <var>A_i</var> corresponds to the pixel at the <var>i</var>-th row and <var>j</var>-th column of the image <var>A</var> <var>(1≦i,j≦N)</var>.

Similarly, the template image <var>B</var> is given as <var>M</var> strings <var>B_1,...,B_M</var>.

The <var>j</var>-th character in the string <var>B_i</var> corresponds to the pixel at the <var>i</var>-th row and <var>j</var>-th column of the template image <var>B</var> <var>(1≦i,j≦M)</var>.

Determine whether the template image <var>B</var> is contained in the image <var>A</var> when only parallel shifts can be applied to the images.

Constraints

<var>1≦M≦N≦50</var>

<var>A_i</var> is a string of length <var>N</var> consisting of # and ..

<var>B_i</var> is a string of length <var>M</var> consisting of # and ..

Input

The 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>A_N</var>
<var>B_1</var>
<var>B_2</var>
<var>:</var>
<var>B_M</var>

Output

Print Yes if the template image <var>B</var> is contained in the image <var>A</var>. Print No otherwise.

Sample Input 1

3 2
#.#
.#.
#.#
#.
.#

Sample Output 1

Yes

The template image <var>B</var> is identical to the upper-left <var>2 × 2</var> subimage and the lower-right <var>2 × 2</var> subimage of <var>A</var>. Thus, the output should be Yes.

Sample Input 2

4 1
....
....
....
....
#

Sample Output 2

No

The template image <var>B</var>, composed of a black pixel, is not contained in the image <var>A</var> composed of white pixels.


Score : <var>200</var> points

Problem Statement

Takahashi loves numbers divisible by <var>2</var>.

You are given a positive integer <var>N</var>. Among the integers between <var>1</var> and <var>N</var> (inclusive), find the one that can be divisible by <var>2</var> for the most number of times. The solution is always unique.

Here, the number of times an integer can be divisible by <var>2</var>, is how many times the integer can be divided by <var>2</var> without remainder.

For example,

<var>6</var> can be divided by <var>2</var> once: <var>6</var> -> <var>3</var>.

<var>8</var> can be divided by <var>2</var> three times: <var>8</var> -> <var>4</var> -> <var>2</var> -> <var>1</var>.

<var>3</var> can be divided by <var>2</var> zero times.

Constraints

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

Input

Input is given from Standard Input in the following format:

<var>N</var>

Output

Print the answer.

Sample Input 1

7

Sample Output 1

4

<var>4</var> can be divided by <var>2</var> twice, which is the most number of times among <var>1</var>, <var>2</var>, ..., <var>7</var>.

Sample Input 2

32

Sample Output 2

32

Sample Input 3

1

Sample Output 3

1

Sample Input 4

100

Sample Output 4

64


Score : <var>500</var> points

Problem Statement

You are given a sequence with <var>N</var> integers: <var>A = \{ A_1, A_2, \cdots, A_N \}</var>.
For each of these <var>N</var> integers, we will choose a color and paint the integer with that color. Here the following condition must be satisfied:

If <var>A_i</var> and <var>A_j</var> <var>(i < j)</var> are painted with the same color, <var>A_i < A_j</var>.

Find the minimum number of colors required to satisfy the condition.

Constraints

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

<var>0 \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>:</var>
<var>A_N</var>

Output

Print the minimum number of colors required to satisfy the condition.

Sample Input 1

5
2
1
4
5
3

Sample Output 1

2

We can satisfy the condition with two colors by, for example, painting <var>2</var> and <var>3</var> red and painting <var>1</var>, <var>4</var>, and <var>5</var> blue.

Sample Input 2

4
0
0
0
0

Sample Output 2

4

We have to paint all the integers with distinct colors.


Score : <var>300</var> points

Problem Statement

Dolphin resides in two-dimensional Cartesian plane, with the positive <var>x</var>-axis pointing right and the positive <var>y</var>-axis pointing up.

Currently, he is located at the point <var>(sx,sy)</var>. In each second, he can move up, down, left or right by a distance of <var>1</var>.

Here, both the <var>x</var>- and <var>y</var>-coordinates before and after each movement must be integers.

He will first visit the point <var>(tx,ty)</var> where <var>sx < tx</var> and <var>sy < ty</var>, then go back to the point <var>(sx,sy)</var>, then visit the point <var>(tx,ty)</var> again, and lastly go back to the point <var>(sx,sy)</var>.

Here, during the whole travel, he is not allowed to pass through the same point more than once, except the points <var>(sx,sy)</var> and <var>(tx,ty)</var>.

Under this condition, find a shortest path for him.

Constraints

<var>-1000 ≤ sx < tx ≤ 1000</var>

<var>-1000 ≤ sy < ty ≤ 1000</var>

<var>sx,sy,tx</var> and <var>ty</var> are integers.

Input

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

<var>sx</var> <var>sy</var> <var>tx</var> <var>ty</var>

Output

Print a string <var>S</var> that represents a shortest path for Dolphin.

The <var>i</var>-th character in <var>S</var> should correspond to his <var>i</var>-th movement.

The directions of the movements should be indicated by the following characters:

U: Up

D: Down

L: Left

R: Right

If there exist multiple shortest paths under the condition, print any of them.

Sample Input 1

0 0 1 2

Sample Output 1

UURDDLLUUURRDRDDDLLU

One possible shortest path is:

Going from <var>(sx,sy)</var> to <var>(tx,ty)</var> for the first time: <var>(0,0)</var> → <var>(0,1)</var> → <var>(0,2)</var> → <var>(1,2)</var>

Going from <var>(tx,ty)</var> to <var>(sx,sy)</var> for the first time: <var>(1,2)</var> → <var>(1,1)</var> → <var>(1,0)</var> → <var>(0,0)</var>

Going from <var>(sx,sy)</var> to <var>(tx,ty)</var> for the second time: <var>(0,0)</var> → <var>(-1,0)</var> → <var>(-1,1)</var> → <var>(-1,2)</var> → <var>(-1,3)</var> → <var>(0,3)</var> → <var>(1,3)</var> → <var>(1,2)</var>

Going from <var>(tx,ty)</var> to <var>(sx,sy)</var> for the second time: <var>(1,2)</var> → <var>(2,2)</var> → <var>(2,1)</var> → <var>(2,0)</var> → <var>(2,-1)</var> → <var>(1,-1)</var> → <var>(0,-1)</var> → <var>(0,0)</var>

Sample Input 2

-2 -2 1 1

Sample Output 2

UURRURRDDDLLDLLULUUURRURRDDDLLDL


Score : <var>400</var> points

Problem Statement

You have <var>N</var> cards. On the <var>i</var>-th card, an integer <var>A_i</var> is written.

For each <var>j = 1, 2, ..., M</var> in this order, you will perform the following operation once:

Operation: Choose at most <var>B_j</var> cards (possibly zero). Replace the integer written on each chosen card with <var>C_j</var>.

Find the maximum possible sum of the integers written on the <var>N</var> cards after the <var>M</var> operations.

Constraints

All values in input are integers.

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

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

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

<var>1 \leq B_i \leq N</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>A_N</var>
<var>B_1</var> <var>C_1</var>
<var>B_2</var> <var>C_2</var>
<var>\vdots</var>
<var>B_M</var> <var>C_M</var>

Output

Print the maximum possible sum of the integers written on the <var>N</var> cards after the <var>M</var> operations.

Sample Input 1

3 2
5 1 4
2 3
1 5

Sample Output 1

14

By replacing the integer on the second card with <var>5</var>, the sum of the integers written on the three cards becomes <var>5 + 5 + 4 = 14</var>, which is the maximum result.

Sample Input 2

10 3
1 8 5 7 100 4 52 33 13 5
3 10
4 30
1 4

Sample Output 2

338

Sample Input 3

3 2
100 100 100
3 99
3 99

Sample Output 3

300

Sample Input 4

11 3
1 1 1 1 1 1 1 1 1 1 1
3 1000000000
4 1000000000
3 1000000000

Sample Output 4

10000000001

The output may not fit into a <var>32</var>-bit integer type.


Score: <var>400</var> points

Problem Statement

Quickly after finishing the tutorial of the online game ATChat, you have decided to visit a particular place with <var>N-1</var> players who happen to be there. These <var>N</var> players, including you, are numbered <var>1</var> through <var>N</var>, and the friendliness of Player <var>i</var> is <var>A_i</var>.

The <var>N</var> players will arrive at the place one by one in some order. To make sure nobody gets lost, you have set the following rule: players who have already arrived there should form a circle, and a player who has just arrived there should cut into the circle somewhere.

When each player, except the first one to arrive, arrives at the place, the player gets comfort equal to the smaller of the friendliness of the clockwise adjacent player and that of the counter-clockwise adjacent player. The first player to arrive there gets the comfort of <var>0</var>.

What is the maximum total comfort the <var>N</var> players can get by optimally choosing the order of arrivals and the positions in the circle to cut into?

Constraints

All values in input are integers.

<var>2 \leq N \leq 2 \times 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>\dots</var> <var>A_N</var>

Output

Print the maximum total comfort the <var>N</var> players can get.

Sample Input 1

4
2 2 1 3

Sample Output 1

7

By arriving at the place in the order Player <var>4, 2, 1, 3</var>, and cutting into the circle as shown in the figure, they can get the total comfort of <var>7</var>.

They cannot get the total comfort greater than <var>7</var>, so the answer is <var>7</var>.

Sample Input 2

7
1 1 1 1 1 1 1

Sample Output 2

6


Score: <var>200</var> points

Problem Statement

Takahashi will do a tap dance. The dance is described by a string <var>S</var> where each character is L, R, U, or D. These characters indicate the positions on which Takahashi should step. He will follow these instructions one by one in order, starting with the first character.

<var>S</var> is said to be easily playable if and only if it satisfies both of the following conditions:

Every character in an odd position (<var>1</var>-st, <var>3</var>-rd, <var>5</var>-th, <var>\ldots</var>) is R, U, or D.

Every character in an even position (<var>2</var>-nd, <var>4</var>-th, <var>6</var>-th, <var>\ldots</var>) is L, U, or D.

Your task is to print Yes if <var>S</var> is easily playable, and No otherwise.

Constraints

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

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

Input

Input is given from Standard Input in the following format:

<var>S</var>

Output

Print Yes if <var>S</var> is easily playable, and No otherwise.

Sample Input 1

RUDLUDR

Sample Output 1

Yes

Every character in an odd position (<var>1</var>-st, <var>3</var>-rd, <var>5</var>-th, <var>7</var>-th) is R, U, or D.

Every character in an even position (<var>2</var>-nd, <var>4</var>-th, <var>6</var>-th) is L, U, or D.

Thus, <var>S</var> is easily playable.

Sample Input 2

DULL

Sample Output 2

No

The <var>3</var>-rd character is not R, U, nor D, so <var>S</var> is not easily playable.

Sample Input 3

UUUUUUUUUUUUUUU

Sample Output 3

Yes

Sample Input 4

ULURU

Sample Output 4

No

Sample Input 5

RDULULDURURLRDULRLR

Sample Output 5

Yes


Score: <var>300</var> points

Problem Statement

Consider an analog clock whose hour and minute hands are <var>A</var> and <var>B</var> centimeters long, respectively.

An endpoint of the hour hand and an endpoint of the minute hand are fixed at the same point, around which each hand rotates clockwise at constant angular velocity. It takes the hour and minute hands <var>12</var> hours and <var>1</var> hour to make one full rotation, respectively.

At <var>0</var> o'clock, the two hands overlap each other. <var>H</var> hours and <var>M</var> minutes later, what is the distance in centimeters between the unfixed endpoints of the hands?

Constraints

All values in input are integers.

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

<var>0 \leq H \leq 11</var>

<var>0 \leq M \leq 59</var>

Input

Input is given from Standard Input in the following format:

<var>A</var> <var>B</var> <var>H</var> <var>M</var>

Output

Print the answer without units. Your output will be accepted when its absolute or relative error from the correct value is at most <var>10^{-9}</var>.

Sample Input 1

3 4 9 0

Sample Output 1

5.00000000000000000000

The two hands will be in the positions shown in the figure below, so the answer is <var>5</var> centimeters.

Sample Input 2

3 4 10 40

Sample Output 2

4.56425719433005567605

The two hands will be in the positions shown in the figure below. Note that each hand always rotates at constant angular velocity.


Score : <var>100</var> points

Problem Statement

We call a <var>4</var>-digit integer with three or more consecutive same digits, such as <var>1118</var>, good.

You are given a <var>4</var>-digit integer <var>N</var>. Answer the question: Is <var>N</var> good?

Constraints

<var>1000 ≤ N ≤ 9999</var>

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

Input

Input is given from Standard Input in the following format:

<var>N</var>

Output

If <var>N</var> is good, print Yes; otherwise, print No.

Sample Input 1

1118

Sample Output 1

Yes

<var>N</var> is good, since it contains three consecutive <var>1</var>.

Sample Input 2

7777

Sample Output 2

Yes

An integer is also good when all the digits are the same.

Sample Input 3

1234

Sample Output 3

No


Score : <var>300</var> points

Problem Statement

In a flower bed, there are <var>N</var> flowers, numbered <var>1,2,......,N</var>. Initially, the heights of all flowers are <var>0</var>.
You are given a sequence <var>h=\{h_1,h_2,h_3,......\}</var> as input. You would like to change the height of Flower <var>k</var> to <var>h_k</var> for all <var>k</var> <var>(1 \leq  k \leq N)</var>, by repeating the following "watering" operation:

Specify integers <var>l</var> and <var>r</var>. Increase the height of Flower <var>x</var> by <var>1</var> for all <var>x</var> such that <var>l \leq x \leq r</var>.

Find the minimum number of watering operations required to satisfy the condition.

Constraints

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

<var>0 \leq h_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>h_1</var> <var>h_2</var> <var>h_3</var> <var>......</var> <var>h_N</var>

Output

Print the minimum number of watering operations required to satisfy the condition.

Sample Input 1

4
1 2 2 1

Sample Output 1

2

The minimum number of watering operations required is <var>2</var>.
One way to achieve it is:

Perform the operation with <var>(l,r)=(1,3)</var>.

Perform the operation with <var>(l,r)=(2,4)</var>.

Sample Input 2

5
3 1 2 3 1

Sample Output 2

5

Sample Input 3

8
4 23 75 0 23 96 50 100

Sample Output 3

221


Score : <var>300</var> points

Problem Statement

Fennec is fighting with <var>N</var> monsters.

The health of the <var>i</var>-th monster is <var>H_i</var>.

Fennec can do the following two actions:

Attack: Fennec chooses one monster. That monster's health will decrease by <var>1</var>.

Special Move: Fennec chooses one monster. That monster's health will become <var>0</var>.

There is no way other than Attack and Special Move to decrease the monsters' health.

Fennec wins when all the monsters' healths become <var>0</var> or below.

Find the minimum number of times Fennec needs to do Attack (not counting Special Move) before winning when she can use Special Move at most <var>K</var> times.

Constraints

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

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

<var>1 \leq H_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>K</var>
<var>H_1</var> <var>...</var> <var>H_N</var>

Output

Print the minimum number of times Fennec needs to do Attack (not counting Special Move) before winning.

Sample Input 1

3 1
4 1 5

Sample Output 1

5

By using Special Move on the third monster, and doing Attack four times on the first monster and once on the second monster, Fennec can win with five Attacks.

Sample Input 2

8 9
7 9 3 2 3 8 4 6

Sample Output 2

0

She can use Special Move on all the monsters.

Sample Input 3

3 0
1000000000 1000000000 1000000000

Sample Output 3

3000000000

Watch out for overflow.


Score : <var>200</var> points

Problem Statement

<var>N</var> friends of Takahashi has come to a theme park.

To ride the most popular roller coaster in the park, you must be at least <var>K</var> centimeters tall.

The <var>i</var>-th friend is <var>h_i</var> centimeters tall.

How many of the Takahashi's friends can ride the roller coaster?

Constraints

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

<var> 1 \le K \le 500 </var>

<var> 1 \le h_i \le 500</var>

All values in input are integers.

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 number of people among the Takahashi's friends who can ride the roller coaster.

Sample Input 1

4 150
150 140 100 200

Sample Output 1

2

Two of them can ride the roller coaster: the first and fourth friends.

Sample Input 2

1 500
499

Sample Output 2

0

Sample Input 3

5 1
100 200 300 400 500

Sample Output 3

5


Score : <var>300</var> points

Problem Statement

You are playing the following game with Joisino.

Initially, you have a blank sheet of paper.

Joisino announces a number. If that number is written on the sheet, erase the number from the sheet; if not, write the number on the sheet. This process is repeated <var>N</var> times.

Then, you are asked a question: How many numbers are written on the sheet now?

The numbers announced by Joisino are given as <var>A_1, ... ,A_N</var> in the order she announces them. How many numbers will be written on the sheet at the end of the game?

Constraints

<var>1≤N≤100000</var>

<var>1≤A_i≤1000000000(=10^9)</var>

All input values are integers.

Input

Input is given from Standard Input in the following format:

<var>N</var>
<var>A_1</var>
<var>:</var>
<var>A_N</var>

Output

Print how many numbers will be written on the sheet at the end of the game.

Sample Input 1

3
6
2
6

Sample Output 1

1

The game proceeds as follows:

<var>6</var> is not written on the sheet, so write <var>6</var>.

<var>2</var> is not written on the sheet, so write <var>2</var>.

<var>6</var> is written on the sheet, so erase <var>6</var>.

Thus, the sheet contains only <var>2</var> in the end. The answer is <var>1</var>.

Sample Input 2

4
2
5
5
2

Sample Output 2

0

It is possible that no number is written on the sheet in the end.

Sample Input 3

6
12
22
16
22
18
12

Sample Output 3

2


Score: <var>500</var> points

Problem Statement

We have caught <var>N</var> sardines. The deliciousness and fragrantness of the <var>i</var>-th sardine is <var>A_i</var> and <var>B_i</var>, respectively.

We will choose one or more of these sardines and put them into a cooler. However, two sardines on bad terms cannot be chosen at the same time.

The <var>i</var>-th and <var>j</var>-th sardines <var>(i \neq j)</var> are on bad terms if and only if <var>A_i \cdot A_j + B_i \cdot B_j = 0</var>.

In how many ways can we choose the set of sardines to put into the cooler? Since the count can be enormous, print it modulo <var>1000000007</var>.

Constraints

All values in input are integers.

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

<var>-10^{18} \leq A_i, B_i \leq 10^{18}</var>

Input

Input is given from Standard Input in the following format:

<var>N</var>
<var>A_1</var> <var>B_1</var>
<var>:</var>
<var>A_N</var> <var>B_N</var>

Output

Print the count modulo <var>1000000007</var>.

Sample Input 1

3
1 2
-1 1
2 -1

Sample Output 1

5

There are five ways to choose the set of sardines, as follows:

The <var>1</var>-st

The <var>1</var>-st and <var>2</var>-nd

The <var>2</var>-nd

The <var>2</var>-nd and <var>3</var>-rd

The <var>3</var>-rd

Sample Input 2

10
3 2
3 2
-1 1
2 -1
-3 -9
-8 12
7 7
8 1
8 2
8 4

Sample Output 2

479


Score : <var>100</var> points

Problem Statement

You are given four digits <var>N_1, N_2, N_3</var> and <var>N_4</var>. Determine if these can be arranged into the sequence of digits "<var>1974</var>".

Constraints

<var>0 \leq N_1, N_2, N_3, N_4 \leq 9</var>

<var>N_1, N_2, N_3</var> and <var>N_4</var> are integers.

Input

Input is given from Standard Input in the following format:

<var>N_1</var> <var>N_2</var> <var>N_3</var> <var>N_4</var>

Output

If <var>N_1, N_2, N_3</var> and <var>N_4</var> can be arranged into the sequence of digits "<var>1974</var>", print YES; if they cannot, print NO.

Sample Input 1

1 7 9 4

Sample Output 1

YES

We can get <var>1974</var> by swapping <var>N_2</var> and <var>N_3</var>.

Sample Input 2

1 9 7 4

Sample Output 2

YES

We already have <var>1974</var> before doing anything.

Sample Input 3

1 2 9 1

Sample Output 3

NO

Sample Input 4

4 9 0 8

Sample Output 4

NO


Score : <var>300</var> points

Problem Statement

There are <var>N</var> integers, <var>A_1, A_2, ..., A_N</var>, written on the blackboard.

You will choose one of them and replace it with an integer of your choice between <var>1</var> and <var>10^9</var> (inclusive), possibly the same as the integer originally written.

Find the maximum possible greatest common divisor of the <var>N</var> integers on the blackboard after your move.

Constraints

All values in input are integers.

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

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

Output

Input is given from Standard Input in the following format:

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

Output

Print the maximum possible greatest common divisor of the <var>N</var> integers on the blackboard after your move.

Sample Input 1

3
7 6 8

Sample Output 1

2

If we replace <var>7</var> with <var>4</var>, the greatest common divisor of the three integers on the blackboard will be <var>2</var>, which is the maximum possible value.

Sample Input 2

3
12 15 18

Sample Output 2

6

Sample Input 3

2
1000000000 1000000000

Sample Output 3

1000000000

We can replace an integer with itself.


Score : <var>100</var> points

Problem Statement

A biscuit making machine produces <var>B</var> biscuits at the following moments: <var>A</var> seconds, <var>2A</var> seconds, <var>3A</var> seconds and each subsequent multiple of <var>A</var> seconds after activation.

Find the total number of biscuits produced within <var>T + 0.5</var> seconds after activation.

Constraints

All values in input are integers.

<var>1 \leq A, B, T \leq 20</var>

Input

Input is given from Standard Input in the following format:

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

Output

Print the total number of biscuits produced within <var>T + 0.5</var> seconds after activation.

Sample Input 1

3 5 7

Sample Output 1

10

Five biscuits will be produced three seconds after activation.

Another five biscuits will be produced six seconds after activation.

Thus, a total of ten biscuits will be produced within <var>7.5</var> seconds after activation.

Sample Input 2

3 2 9

Sample Output 2

6

Sample Input 3

20 20 19

Sample Output 3

0


Score : <var>300</var> points

Problem Statement

Takahashi loves the number <var>7</var> and multiples of <var>K</var>.

Where is the first occurrence of a multiple of <var>K</var> in the sequence <var>7,77,777,\ldots</var>? (Also see Output and Sample Input/Output below.)

If the sequence contains no multiples of <var>K</var>, print -1 instead.

Constraints

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

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

Input

Input is given from Standard Input in the following format:

<var>K</var>

Output

Print an integer representing the position of the first occurrence of a multiple of <var>K</var>. (For example, if the first occurrence is the fourth element of the sequence, print 4.)

Sample Input 1

101

Sample Output 1

4

None of <var>7</var>, <var>77</var>, and <var>777</var> is a multiple of <var>101</var>, but <var>7777</var> is.

Sample Input 2

2

Sample Output 2

-1

All elements in the sequence are odd numbers; there are no multiples of <var>2</var>.

Sample Input 3

999983

Sample Output 3

999982


Score : <var>100</var> points

Problem Statement

Smeke has decided to participate in AtCoder Beginner Contest (ABC) if his current rating is less than <var>1200</var>, and participate in AtCoder Regular Contest (ARC) otherwise.

You are given Smeke's current rating, <var>x</var>. Print ABC if Smeke will participate in ABC, and print ARC otherwise.

Constraints

<var>1 ≦ x ≦ 3{,}000</var>

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

Input

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

<var>x</var>

Output

Print the answer.

Sample Input 1

1000

Sample Output 1

ABC

Smeke's current rating is less than <var>1200</var>, thus the output should be ABC.

Sample Input 2

2000

Sample Output 2

ARC

Smeke's current rating is not less than <var>1200</var>, thus the output should be ARC.


Score : <var>100</var> points

Problem Statement

Print the circumference of a circle of radius <var>R</var>.

Constraints

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

All values in input are integers.

Input

Input is given from Standard Input in the following format:

<var>R</var>

Output

Print the circumference of the circle.
Your output is considered correct if and only if its absolute or relative error from our answer is at most <var>10^{-2}</var>.

Sample Input 1

1

Sample Output 1

6.28318530717958623200

Since we accept an absolute or relative error of at most <var>10^{-2}</var>, <var>6.28</var> is also an acceptable output, but <var>6</var> is not.

Sample Input 2

73

Sample Output 2

458.67252742410977361942


Score : <var>100</var> points

Problem Statement

Iroha loves Haiku. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with <var>5</var>, <var>7</var> and <var>5</var> syllables, in this order.

To create a Haiku, Iroha has come up with three different phrases. These phrases have <var>A</var>, <var>B</var> and <var>C</var> syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order.

Constraints

<var>1≦A,B,C≦10</var>

Input

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

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

Output

If it is possible to construct a Haiku by using each of the phrases once, print YES (case-sensitive). Otherwise, print NO.

Sample Input 1

5 5 7

Sample Output 1

YES

Using three phrases of length <var>5</var>, <var>5</var> and <var>7</var>, it is possible to construct a Haiku.

Sample Input 2

7 7 5

Sample Output 2

NO


Score : <var>100</var> points

Problem Statement

There are two buttons, one of size <var>A</var> and one of size <var>B</var>.

When you press a button of size <var>X</var>, you get <var>X</var> coins and the size of that button decreases by <var>1</var>.

You will press a button twice. Here, you can press the same button twice, or press both buttons once.

At most how many coins can you get?

Constraints

All values in input are integers.

<var>3 \leq A, B \leq 20</var>

Input

Input is given from Standard Input in the following format:

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

Output

Print the maximum number of coins you can get.

Sample Input 1

5 3

Sample Output 1

9

You can get <var>5 + 4 = 9</var> coins by pressing the button of size <var>5</var> twice, and this is the maximum result.

Sample Input 2

3 4

Sample Output 2

7

Sample Input 3

6 6

Sample Output 3

12


Score : <var>100</var> points

Problem Statement

This contest is CODE FESTIVAL.
However, Mr. Takahashi always writes it CODEFESTIVAL, omitting the single space between CODE and FESTIVAL.

So he has decided to make a program that puts the single space he omitted.

You are given a string <var>s</var> with <var>12</var> letters.
Output the string putting a single space between the first <var>4</var> letters and last <var>8</var> letters in the string <var>s</var>.

Constraints

<var>s</var> contains exactly <var>12</var> letters.

All letters in <var>s</var> are uppercase English letters.

Input

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

<var>s</var>

Output

Print the string putting a single space between the first <var>4</var> letters and last <var>8</var> letters in the string <var>s</var>.
Put a line break at the end.

Sample Input 1

CODEFESTIVAL

Sample Output 1

CODE FESTIVAL

Putting a single space between the first <var>4</var> letters and last <var>8</var> letters in CODEFESTIVAL makes it CODE FESTIVAL.

Sample Input 2

POSTGRADUATE

Sample Output 2

POST GRADUATE

Sample Input 3

ABCDEFGHIJKL

Sample Output 3

ABCD EFGHIJKL


Score : <var>100</var> points

Problem Statement

In K-city, there are <var>n</var> streets running east-west, and <var>m</var> streets running north-south. Each street running east-west and each street running north-south cross each other. We will call the smallest area that is surrounded by four streets a block. How many blocks there are in K-city?

Constraints

<var>2 ≤ n, m ≤ 100</var>

Input

Input is given from Standard Input in the following format:

<var>n</var> <var>m</var>

Output

Print the number of blocks in K-city.

Sample Input 1

3 4

Sample Output 1

6

There are six blocks, as shown below:

Sample Input 2

2 2

Sample Output 2

1

There are one block, as shown below:


Score : <var>100</var> points

Problem Statement

Alice and Bob are playing One Card Poker.

One Card Poker is a two-player game using playing cards.

Each card in this game shows an integer between 1 and 13, inclusive.

The strength of a card is determined by the number written on it, as follows:

Weak 2 <var><</var> 3 <var><</var> 4 <var><</var> 5 <var><</var> 6 <var><</var> 7 <var><</var> 8 <var><</var> 9 <var><</var> 10 <var><</var> 11 <var><</var> 12 <var><</var> 13 <var><</var> 1 Strong

One Card Poker is played as follows:

Each player picks one card from the deck. The chosen card becomes the player's hand.

The players reveal their hands to each other. The player with the stronger card wins the game.

If their cards are equally strong, the game is drawn.

You are watching Alice and Bob playing the game, and can see their hands.

The number written on Alice's card is <var>A</var>, and the number written on Bob's card is <var>B</var>.

Write a program to determine the outcome of the game.

Constraints

<var>1≦A≦13</var>

<var>1≦B≦13</var>

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

Input

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

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

Output

Print Alice if Alice will win. Print Bob if Bob will win. Print Draw if the game will be drawn.

Sample Input 1

8 6

Sample Output 1

Alice

8 is written on Alice's card, and 6 is written on Bob's card.
Alice has the stronger card, and thus the output should be Alice.

Sample Input 2

1 1

Sample Output 2

Draw

Since their cards have the same number, the game will be drawn.

Sample Input 3

13 1

Sample Output 3

Bob


Score : <var>300</var> points

Problem Statement

In Takahashi Kingdom, there is an archipelago of <var>N</var> islands, called Takahashi Islands.
For convenience, we will call them Island <var>1</var>, Island <var>2</var>, ..., Island <var>N</var>.

There are <var>M</var> kinds of regular boat services between these islands.
Each service connects two islands. The <var>i</var>-th service connects Island <var>a_i</var> and Island <var>b_i</var>.

Cat Snuke is on Island <var>1</var> now, and wants to go to Island <var>N</var>.
However, it turned out that there is no boat service from Island <var>1</var> to Island <var>N</var>, so he wants to know whether it is possible to go to Island <var>N</var> by using two boat services.

Help him.

Constraints

<var>3 ≤ N ≤ 200</var> <var>000</var>

<var>1 ≤ M ≤ 200</var> <var>000</var>

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

<var>(a_i, b_i) \neq (1, N)</var>

If <var>i \neq j</var>, <var>(a_i, b_i) \neq (a_j, b_j)</var>.

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>a_2</var> <var>b_2</var>
:
<var>a_M</var> <var>b_M</var>

Output

If it is possible to go to Island <var>N</var> by using two boat services, print POSSIBLE; otherwise, print IMPOSSIBLE.

Sample Input 1

3 2
1 2
2 3

Sample Output 1

POSSIBLE

Sample Input 2

4 3
1 2
2 3
3 4

Sample Output 2

IMPOSSIBLE

You have to use three boat services to get to Island <var>4</var>.

Sample Input 3

100000 1
1 99999

Sample Output 3

IMPOSSIBLE

Sample Input 4

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

Sample Output 4

POSSIBLE

You can get to Island <var>5</var> by using two boat services: Island <var>1</var> -> Island <var>4</var> -> Island <var>5</var>.


Score : <var>400</var> points

Problem Statement

Given is a number sequence <var>A</var> of length <var>N</var>.

Find the number of integers <var>i</var> <var>\left(1 \leq i \leq N\right)</var> with the following property:

For every integer <var>j</var> <var>\left(1 \leq j \leq N\right)</var> such that <var>i \neq j </var>, <var>A_j</var> does not divide <var>A_i</var>.

Constraints

All values in input are integers.

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

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

Input

Input is given from Standard Input in the following format:

<var>N</var>
<var>A_1</var> <var>A_2</var> <var>\cdots</var> <var>A_N</var>

Output

Print the answer.

Sample Input 1

5
24 11 8 3 16

Sample Output 1

3

The integers with the property are <var>2</var>, <var>3</var>, and <var>4</var>.

Sample Input 2

4
5 5 5 5

Sample Output 2

0

Note that there can be multiple equal numbers.

Sample Input 3

10
33 18 45 28 8 19 89 86 2 4

Sample Output 3

5