Score : <var>200</var> points

Problem Statement

Joisino is about to compete in the final round of a certain programming competition.
In this contest, there are <var>N</var> problems, numbered <var>1</var> through <var>N</var>.
Joisino knows that it takes her <var>T_i</var> seconds to solve problem <var>i(1≦i≦N)</var>.

Also, there are <var>M</var> kinds of drinks offered to the contestants, numbered <var>1</var> through <var>M</var>.
If Joisino takes drink <var>i(1≦i≦M)</var>, her brain will be stimulated and the time it takes for her to solve problem <var>P_i</var> will become <var>X_i</var> seconds.
It does not affect the time to solve the other problems.

A contestant is allowed to take exactly one of the drinks before the start of the contest.
For each drink, Joisino wants to know how many seconds it takes her to solve all the problems if she takes that drink.
Here, assume that the time it takes her to solve all the problems is equal to the sum of the time it takes for her to solve individual problems.
Your task is to write a program to calculate it instead of her.

Constraints

All input values are integers.

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

<var>1≦T_i≦10^5</var>

<var>1≦M≦100</var>

<var>1≦P_i≦N</var>

<var>1≦X_i≦10^5</var>

Input

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

<var>N</var>
<var>T_1</var> <var>T_2</var> <var>...</var> <var>T_N</var>
<var>M</var>
<var>P_1</var> <var>X_1</var>
<var>P_2</var> <var>X_2</var>
<var>:</var>
<var>P_M</var> <var>X_M</var>

Output

For each drink, calculate how many seconds it takes Joisino to solve all the problems if she takes that drink, and print the results, one per line.

Sample Input 1

3
2 1 4
2
1 1
2 3

Sample Output 1

6
9

If Joisino takes drink <var>1</var>, the time it takes her to solve each problem will be <var>1</var>, <var>1</var> and <var>4</var> seconds, respectively, totaling <var>6</var> seconds.

If Joisino takes drink <var>2</var>, the time it takes her to solve each problem will be <var>2</var>, <var>3</var> and <var>4</var> seconds, respectively, totaling <var>9</var> seconds.

Sample Input 2

5
7 2 3 8 5
3
4 2
1 7
4 13

Sample Output 2

19
25
30


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>100</var> points

Problem Statement

Decades have passed since the beginning of AtCoder Beginner Contest.

The contests are labeled as ABC001, ABC002, <var>...</var> from the first round, but after the <var>999</var>-th round ABC999, a problem occurred: how the future rounds should be labeled?

In the end, the labels for the rounds from the <var>1000</var>-th to the <var>1998</var>-th are decided: ABD001, ABD002, <var>...</var>, ABD999.

You are given an integer <var>N</var> between <var>1</var> and <var>1998</var> (inclusive). Print the first three characters of the label of the <var>N</var>-th round of AtCoder Beginner Contest.

Constraints

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

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

Input

Input is given from Standard Input in the following format:

<var>N</var>

Output

Print the first three characters of the label of the <var>N</var>-th round of AtCoder Beginner Contest.

Sample Input 1

999

Sample Output 1

ABC

The <var>999</var>-th round of AtCoder Beginner Contest is labeled as ABC999.

Sample Input 2

1000

Sample Output 2

ABD

The <var>1000</var>-th round of AtCoder Beginner Contest is labeled as ABD001.

Sample Input 3

1481

Sample Output 3

ABD

The <var>1481</var>-th round of AtCoder Beginner Contest is labeled as ABD482.


Score : <var>200</var> points

Problem Statement

An integer <var>X</var> is called a Harshad number if <var>X</var> is divisible by <var>f(X)</var>, where <var>f(X)</var> is the sum of the digits in <var>X</var> when written in base <var>10</var>.

Given an integer <var>N</var>, determine whether it is a Harshad number.

Constraints

<var>1?N?10^8</var>

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

Input

Input is given from Standard Input in the following format:

<var>N</var>

Output

Print Yes if <var>N</var> is a Harshad number; print No otherwise.

Sample Input 1

12

Sample Output 1

Yes

<var>f(12)=1+2=3</var>. Since <var>12</var> is divisible by <var>3</var>, <var>12</var> is a Harshad number.

Sample Input 2

57

Sample Output 2

No

<var>f(57)=5+7=12</var>. Since <var>57</var> is not divisible by <var>12</var>, <var>12</var> is not a Harshad number.

Sample Input 3

148

Sample Output 3

No


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>100</var> points

Problem Statement

How many hours do we have until New Year at <var>M</var> o'clock (24-hour notation) on <var>30</var>th, December?

Constraints

<var>1≤M≤23</var>

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

Input

Input is given from Standard Input in the following format:

<var>M</var>

Output

If we have <var>x</var> hours until New Year at <var>M</var> o'clock on <var>30</var>th, December, print <var>x</var>.

Sample Input 1

21

Sample Output 1

27

We have <var>27</var> hours until New Year at <var>21</var> o'clock on <var>30</var>th, December.

Sample Input 2

12

Sample Output 2

36


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

We have a long seat of width <var>X</var> centimeters.
There are many people who wants to sit here. A person sitting on the seat will always occupy an interval of length <var>Y</var> centimeters.

We would like to seat as many people as possible, but they are all very shy, and there must be a gap of length at least <var>Z</var> centimeters between two people, and between the end of the seat and a person.

At most how many people can sit on the seat?

Constraints

All input values are integers.

<var>1 \leq X, Y, Z \leq 10^5</var>

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

Input

Input is given from Standard Input in the following format:

<var>X</var> <var>Y</var> <var>Z</var>

Output

Print the answer.

Sample Input 1

13 3 1

Sample Output 1

3

There is just enough room for three, as shown below:

Figure

Sample Input 2

12 3 1

Sample Output 2

2

Sample Input 3

100000 1 1

Sample Output 3

49999

Sample Input 4

64146 123 456

Sample Output 4

110

Sample Input 5

64145 123 456

Sample Output 5

109


Score : <var>400</var> points

Problem Statement

There is a grid with <var>H</var> horizontal rows and <var>W</var> vertical columns, and there are obstacles on some of the squares.

Snuke is going to choose one of the squares not occupied by an obstacle and place a lamp on it.
The lamp placed on the square will emit straight beams of light in four cardinal directions: up, down, left, and right.
In each direction, the beam will continue traveling until it hits a square occupied by an obstacle or it hits the border of the grid. It will light all the squares on the way, including the square on which the lamp is placed, but not the square occupied by an obstacle.

Snuke wants to maximize the number of squares lighted by the lamp.

You are given <var>H</var> strings <var>S_i</var> (<var>1 \leq i \leq H</var>), each of length <var>W</var>. If the <var>j</var>-th character (<var>1 \leq j \leq W</var>) of <var>S_i</var> is #, there is an obstacle on the square at the <var>i</var>-th row from the top and the <var>j</var>-th column from the left; if that character is ., there is no obstacle on that square.

Find the maximum possible number of squares lighted by the lamp.

Constraints

<var>1 \leq H \leq 2,000</var>

<var>1 \leq W \leq 2,000</var>

<var>S_i</var> is a string of length <var>W</var> consisting of # and ..

. occurs at least once in one of the strings <var>S_i</var> (<var>1 \leq i \leq H</var>).

Input

Input is given from Standard Input in the following format:

<var>H</var> <var>W</var>
<var>S_1</var>
<var>:</var>
<var>S_H</var>

Output

Print the maximum possible number of squares lighted by the lamp.

Sample Input 1

4 6
#..#..
.....#
....#.
#.#...

Sample Output 1

8

If Snuke places the lamp on the square at the second row from the top and the second column from the left, it will light the following squares: the first through fifth squares from the left in the second row, and the first through fourth squares from the top in the second column, for a total of eight squares.

Sample Input 2

8 8
..#...#.
....#...
##......
..###..#
...#..#.
##....#.
#...#...
###.#..#

Sample Output 2

13


Score: <var>200</var> points

Problem Statement

Takahashi, who works at DISCO, is standing before an iron bar.
The bar has <var>N-1</var> notches, which divide the bar into <var>N</var> sections. The <var>i</var>-th section from the left has a length of <var>A_i</var> millimeters.

Takahashi wanted to choose a notch and cut the bar at that point into two parts with the same length.
However, this may not be possible as is, so he will do the following operations some number of times before he does the cut:

Choose one section and expand it, increasing its length by <var>1</var> millimeter. Doing this operation once costs <var>1</var> yen (the currency of Japan).

Choose one section of length at least <var>2</var> millimeters and shrink it, decreasing its length by <var>1</var> millimeter. Doing this operation once costs <var>1</var> yen.

Find the minimum amount of money needed before cutting the bar into two parts with the same length.

Constraints

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

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

Output

Print an integer representing the minimum amount of money needed before cutting the bar into two parts with the same length.

Sample Input 1

3
2 4 3

Sample Output 1

3

The initial lengths of the sections are <var>[2, 4, 3]</var> (in millimeters). Takahashi can cut the bar equally after doing the following operations for <var>3</var> yen:

Shrink the second section from the left. The lengths of the sections are now <var>[2, 3, 3]</var>.

Shrink the first section from the left. The lengths of the sections are now <var>[1, 3, 3]</var>.

Shrink the second section from the left. The lengths of the sections are now <var>[1, 2, 3]</var>, and we can cut the bar at the second notch from the left into two parts of length <var>3</var> each.

Sample Input 2

12
100 104 102 105 103 103 101 105 104 102 104 101

Sample Output 2

0


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>400</var> points

Problem Statement

We have <var>N</var> bricks arranged in a row from left to right.

The <var>i</var>-th brick from the left <var>(1 \leq i \leq N)</var> has an integer <var>a_i</var> written on it.

Among them, you can break at most <var>N-1</var> bricks of your choice.

Let us say there are <var>K</var> bricks remaining. Snuke will be satisfied if, for each integer <var>i</var> <var>(1 \leq i \leq K)</var>, the <var>i</var>-th of those brick from the left has the integer <var>i</var> written on it.

Find the minimum number of bricks you need to break to satisfy Snuke's desire. If his desire is unsatisfiable, print -1 instead.

Constraints

All values in input are integers.

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

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

Input

Input is given from Standard Input in the following format:

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

Output

Print the minimum number of bricks that need to be broken to satisfy Snuke's desire, or print -1 if his desire is unsatisfiable.

Sample Input 1

3
2 1 2

Sample Output 1

1

If we break the leftmost brick, the remaining bricks have integers <var>1</var> and <var>2</var> written on them from left to right, in which case Snuke will be satisfied.

Sample Input 2

3
2 2 2

Sample Output 2

-1

In this case, there is no way to break some of the bricks to satisfy Snuke's desire.

Sample Input 3

10
3 1 4 1 5 9 2 6 5 3

Sample Output 3

7

Sample Input 4

1
1

Sample Output 4

0

There may be no need to break the bricks at all.


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>100</var> points

Problem Statement

Given a lowercase English letter <var>c</var>, determine whether it is a vowel. Here, there are five vowels in the English alphabet: a, e, i, o and u.

Constraints

<var>c</var> is a lowercase English letter.

Input

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

<var>c</var>

Output

If <var>c</var> is a vowel, print vowel. Otherwise, print consonant.

Sample Input 1

a

Sample Output 1

vowel

Since a is a vowel, print vowel.

Sample Input 2

z

Sample Output 2

consonant

Sample Input 3

s

Sample Output 3

consonant


Score : <var>200</var> points

Problem Statement

Takahashi received otoshidama (New Year's money gifts) from <var>N</var> of his relatives.

You are given <var>N</var> values <var>x_1, x_2, ..., x_N</var> and <var>N</var> strings <var>u_1, u_2, ..., u_N</var> as input. Each string <var>u_i</var> is either JPY or BTC, and <var>x_i</var> and <var>u_i</var> represent the content of the otoshidama from the <var>i</var>-th relative.

For example, if <var>x_1 =</var> 10000 and <var>u_1 =</var> JPY, the otoshidama from the first relative is <var>10000</var> Japanese yen; if <var>x_2 =</var> 0.10000000 and <var>u_2 =</var> BTC, the otoshidama from the second relative is <var>0.1</var> bitcoins.

If we convert the bitcoins into yen at the rate of <var>380000.0</var> JPY per <var>1.0</var> BTC, how much are the gifts worth in total?

Constraints

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

<var>u_i =</var> JPY or BTC.

If <var>u_i =</var> JPY, <var>x_i</var> is an integer such that <var>1 \leq x_i \leq 10^8</var>.

If <var>u_i =</var> BTC, <var>x_i</var> is a decimal with <var>8</var> decimal digits, such that <var>0.00000001 \leq x_i \leq 100.00000000</var>.

Input

Input is given from Standard Input in the following format:

<var>N</var>
<var>x_1</var> <var>u_1</var>
<var>x_2</var> <var>u_2</var>
<var>:</var>
<var>x_N</var> <var>u_N</var>

Output

If the gifts are worth <var>Y</var> yen in total, print the value <var>Y</var> (not necessarily an integer).

Output will be judged correct when the absolute or relative error from the judge's output is at most <var>10^{-5}</var>.

Sample Input 1

2
10000 JPY
0.10000000 BTC

Sample Output 1

48000.0

The otoshidama from the first relative is <var>10000</var> yen. The otoshidama from the second relative is <var>0.1</var> bitcoins, which is worth <var>38000.0</var> yen if converted at the rate of <var>380000.0</var> JPY per <var>1.0</var> BTC. The sum of these is <var>48000.0</var> yen.

Outputs such as 48000 and 48000.1 will also be judged correct.

Sample Input 2

3
100000000 JPY
100.00000000 BTC
0.00000001 BTC

Sample Output 2

138000000.0038

In this case, outputs such as 138001000 and 1.38e8 will also be judged correct.


Score : <var>100</var> points

Problem Statement

Takahashi has a strong stomach. He never gets a stomachache from eating something whose "best-by" date is at most <var>X</var> days earlier.
He gets a stomachache if the "best-by" date of the food is <var>X+1</var> or more days earlier, though.

Other than that, he finds the food delicious if he eats it not later than the "best-by" date. Otherwise, he does not find it delicious.

Takahashi bought some food <var>A</var> days before the "best-by" date, and ate it <var>B</var> days after he bought it.

Write a program that outputs delicious if he found it delicious, safe if he did not found it delicious but did not get a stomachache either, and dangerous if he got a stomachache.

Constraints

<var>1 ≤ X,A,B ≤ 10^9</var>

Input

Input is given from Standard Input in the following format:

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

Output

Print delicious if Takahashi found the food delicious; print safe if he neither found it delicious nor got a stomachache; print dangerous if he got a stomachache.

Sample Input 1

4 3 6

Sample Output 1

safe

He ate the food three days after the "best-by" date. It was not delicious or harmful for him.

Sample Input 2

6 5 1

Sample Output 2

delicious

He ate the food by the "best-by" date. It was delicious for him.

Sample Input 3

3 7 12

Sample Output 3

dangerous

He ate the food five days after the "best-by" date. It was harmful for him.


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>200</var> points

Problem Statement

Takahashi bought a piece of apple pie at ABC Confiserie. According to his memory, he paid <var>N</var> yen (the currency of Japan) for it.

The consumption tax rate for foods in this shop is <var>8</var> percent. That is, to buy an apple pie priced at <var>X</var> yen before tax, you have to pay <var>X \times 1.08</var> yen (rounded down to the nearest integer).

Takahashi forgot the price of his apple pie before tax, <var>X</var>, and wants to know it again. Write a program that takes <var>N</var> as input and finds <var>X</var>. We assume <var>X</var> is an integer.

If there are multiple possible values for <var>X</var>, find any one of them. Also, Takahashi's memory of <var>N</var>, the amount he paid, may be incorrect. If no value could be <var>X</var>, report that fact.

Constraints

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

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

Input

Input is given from Standard Input in the following format:

<var>N</var>

Output

If there are values that could be <var>X</var>, the price of the apple pie before tax, print any one of them.

If there are multiple such values, printing any one of them will be accepted.

If no value could be <var>X</var>, print :(.

Sample Input 1

432

Sample Output 1

400

If the apple pie is priced at <var>400</var> yen before tax, you have to pay <var>400 \times 1.08 = 432</var> yen to buy one.

Otherwise, the amount you have to pay will not be <var>432</var> yen.

Sample Input 2

1079

Sample Output 2

:(

There is no possible price before tax for which you have to pay <var>1079</var> yen with tax.

Sample Input 3

1001

Sample Output 3

927

If the apple pie is priced <var>927</var> yen before tax, by rounding down <var>927 \times 1.08 = 1001.16</var>, you have to pay <var>1001</var> yen.


Score : <var>200</var> points

Problem Statement

Evi has <var>N</var> integers <var>a_1,a_2,..,a_N</var>. His objective is to have <var>N</var> equal integers by transforming some of them.

He may transform each integer at most once. Transforming an integer <var>x</var> into another integer <var>y</var> costs him <var>(x-y)^2</var> dollars. Even if <var>a_i=a_j (i≠j)</var>, he has to pay the cost separately for transforming each of them (See Sample 2).

Find the minimum total cost to achieve his objective.

Constraints

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

<var>-100≦a_i≦100</var>

Input

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

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

Output

Print the minimum total cost to achieve Evi's objective.

Sample Input 1

2
4 8

Sample Output 1

8

Transforming the both into <var>6</var>s will cost <var>(4-6)^2+(8-6)^2=8</var> dollars, which is the minimum.

Sample Input 2

3
1 1 3

Sample Output 2

3

Transforming the all into <var>2</var>s will cost <var>(1-2)^2+(1-2)^2+(3-2)^2=3</var> dollars. Note that Evi has to pay <var>(1-2)^2</var> dollar separately for transforming each of the two <var>1</var>s.

Sample Input 3

3
4 2 5

Sample Output 3

5

Leaving the <var>4</var> as it is and transforming the <var>2</var> and the <var>5</var> into <var>4</var>s will achieve the total cost of <var>(2-4)^2+(5-4)^2=5</var> dollars, which is the minimum.

Sample Input 4

4
-100 -100 -100 -100

Sample Output 4

0

Without transforming anything, Evi's objective is already achieved. Thus, the necessary cost is <var>0</var>.


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

There are <var>N</var> dishes of cuisine placed in front of Takahashi and Aoki.
For convenience, we call these dishes Dish <var>1</var>, Dish <var>2</var>, ..., Dish <var>N</var>.

When Takahashi eats Dish <var>i</var>, he earns <var>A_i</var> points of happiness; when Aoki eats Dish <var>i</var>, she earns <var>B_i</var> points of happiness.

Starting from Takahashi, they alternately choose one dish and eat it, until there is no more dish to eat.
Here, both of them choose dishes so that the following value is maximized: "the sum of the happiness he/she will earn in the end" minus "the sum of the happiness the other person will earn in the end".

Find the value: "the sum of the happiness Takahashi earns in the end" minus "the sum of the happiness Aoki earns in the end".

Constraints

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

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

<var>1 \leq B_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>B_1</var>
<var>:</var>
<var>A_N</var> <var>B_N</var>

Output

Print the value: "the sum of the happiness Takahashi earns in the end" minus "the sum of the happiness Aoki earns in the end".

Sample Input 1

3
10 10
20 20
30 30

Sample Output 1

20

In this sample, both of them earns <var>10</var> points of happiness by eating Dish <var>1</var>, <var>20</var> points by eating Dish <var>2</var>, and <var>30</var> points by eating Dish <var>3</var>.

In this case, since Takahashi and Aoki have the same "taste", each time they will choose the dish with which they can earn the greatest happiness. Thus, first Takahashi will choose Dish <var>3</var>, then Aoki will choose Dish <var>2</var>, and finally Takahashi will choose Dish <var>1</var>, so the answer is <var>(30 + 10) - 20 = 20</var>.

Sample Input 2

3
20 10
20 20
20 30

Sample Output 2

20

In this sample, Takahashi earns <var>20</var> points of happiness by eating any one of the dishes <var>1, 2</var> and <var>3</var>, but Aoki earns <var>10</var> points of happiness by eating Dish <var>1</var>, <var>20</var> points by eating Dish <var>2</var>, and <var>30</var> points by eating Dish <var>3</var>.

In this case, since only Aoki has likes and dislikes, each time they will choose the dish with which Aoki can earn the greatest happiness. Thus, first Takahashi will choose Dish <var>3</var>, then Aoki will choose Dish <var>2</var>, and finally Takahashi will choose Dish <var>1</var>, so the answer is <var>(20 + 20) - 20 = 20</var>.

Sample Input 3

6
1 1000000000
1 1000000000
1 1000000000
1 1000000000
1 1000000000
1 1000000000

Sample Output 3

-2999999997

Note that the answer may not fit into a <var>32</var>-bit integer.


Score : <var>200</var> points

Problem Statement

There are <var>2000001</var> stones placed on a number line. The coordinates of these stones are <var>-1000000, -999999, -999998, \ldots, 999999, 1000000</var>.

Among them, some <var>K</var> consecutive stones are painted black, and the others are painted white.

Additionally, we know that the stone at coordinate <var>X</var> is painted black.

Print all coordinates that potentially contain a stone painted black, in ascending order.

Constraints

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

<var>0 \leq X \leq 100</var>

All values in input are integers.

Input

Input is given from Standard Input in the following format:

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

Output

Print all coordinates that potentially contain a stone painted black, in ascending order, with spaces in between.

Sample Input 1

3 7

Sample Output 1

5 6 7 8 9

We know that there are three stones painted black, and the stone at coordinate <var>7</var> is painted black. There are three possible cases:

The three stones painted black are placed at coordinates <var>5</var>, <var>6</var>, and <var>7</var>.

The three stones painted black are placed at coordinates <var>6</var>, <var>7</var>, and <var>8</var>.

The three stones painted black are placed at coordinates <var>7</var>, <var>8</var>, and <var>9</var>.

Thus, five coordinates potentially contain a stone painted black: <var>5</var>, <var>6</var>, <var>7</var>, <var>8</var>, and <var>9</var>.

Sample Input 2

4 0

Sample Output 2

-3 -2 -1 0 1 2 3

Negative coordinates can also contain a stone painted black.

Sample Input 3

1 100

Sample Output 3

100


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


Score : <var>100</var> points

Problem Statement

Takahashi wants to print a document with <var>N</var> pages double-sided, where two pages of data can be printed on one sheet of paper.

At least how many sheets of paper does he need?

Constraints

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

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

Input

Input is given from Standard Input in the following format:

<var>N</var>

Output

Print the answer.

Sample Input 1

5

Sample Output 1

3

By printing the <var>1</var>-st, <var>2</var>-nd pages on the <var>1</var>-st sheet, <var>3</var>-rd and <var>4</var>-th pages on the <var>2</var>-nd sheet, and <var>5</var>-th page on the <var>3</var>-rd sheet, we can print all the data on <var>3</var> sheets of paper.

Sample Input 2

2

Sample Output 2

1

Sample Input 3

100

Sample Output 3

50


Score : <var>200</var> points

Problem Statement

AtCoDeer the deer found two rectangles lying on the table, each with height <var>1</var> and width <var>W</var>.
If we consider the surface of the desk as a two-dimensional plane, the first rectangle covers the vertical range of <var>[0,1]</var> and the horizontal range of <var>[a,a+W]</var>, and the second rectangle covers the vertical range of <var>[1,2]</var> and the horizontal range of <var>[b,b+W]</var>, as shown in the following figure:

AtCoDeer will move the second rectangle horizontally so that it connects with the first rectangle.
Find the minimum distance it needs to be moved.

Constraints

All input values are integers.

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

<var>1≤a,b≤10^5</var>

Input

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

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

Output

Print the minimum distance the second rectangle needs to be moved.

Sample Input 1

3 2 6

Sample Output 1

1

This input corresponds to the figure in the statement. In this case, the second rectangle should be moved to the left by a distance of <var>1</var>.

Sample Input 2

3 1 3

Sample Output 2

0

The rectangles are already connected, and thus no move is needed.

Sample Input 3

5 10 1

Sample Output 3

4


Score : <var>200</var> points

Problem Statement

Kurohashi has never participated in AtCoder Beginner Contest (ABC).

The next ABC to be held is ABC <var>N</var> (the <var>N</var>-th ABC ever held).
Kurohashi wants to make his debut in some ABC <var>x</var> such that all the digits of <var>x</var> in base ten are the same.

What is the earliest ABC where Kurohashi can make his debut?

Constraints

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

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

Input

Input is given from Standard Input in the following format:

<var>N</var>

Output

If the earliest ABC where Kurohashi can make his debut is ABC <var>n</var>, print <var>n</var>.

Sample Input 1

111

Sample Output 1

111

The next ABC to be held is ABC <var>111</var>, where Kurohashi can make his debut.

Sample Input 2

112

Sample Output 2

222

The next ABC to be held is ABC <var>112</var>, which means Kurohashi can no longer participate in ABC <var>111</var>.
Among the ABCs where Kurohashi can make his debut, the earliest one is ABC <var>222</var>.

Sample Input 3

750

Sample Output 3

777


Score : <var>200</var> points

Problem Statement

Given is an integer <var>N</var>. Find the number of digits that <var>N</var> has in base <var>K</var>.

Notes

For information on base-<var>K</var> representation, see Positional notation - Wikipedia.

Constraints

All values in input are integers.

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

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

Input

Input is given from Standard Input in the following format:

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

Output

Print the number of digits that <var>N</var> has in base <var>K</var>.

Sample Input 1

11 2

Sample Output 1

4

In binary, <var>11</var> is represented as 1011.

Sample Input 2

1010101 10

Sample Output 2

7

Sample Input 3

314159265 3

Sample Output 3

18


Score : <var>300</var> points

Problem Statement

You have a pot and <var>N</var> ingredients. Each ingredient has a real number parameter called value, and the value of the <var>i</var>-th ingredient <var>(1 \leq i \leq N)</var> is <var>v_i</var>.

When you put two ingredients in the pot, they will vanish and result in the formation of a new ingredient. The value of the new ingredient will be <var>(x + y) / 2</var> where <var>x</var> and <var>y</var> are the values of the ingredients consumed, and you can put this ingredient again in the pot.

After you compose ingredients in this way <var>N-1</var> times, you will end up with one ingredient. Find the maximum possible value of this ingredient.

Constraints

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

<var>1 \leq v_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>v_1</var> <var>v_2</var> <var>\ldots</var> <var>v_N</var>

Output

Print a decimal number (or an integer) representing the maximum possible value of the last ingredient remaining.

Your output will be judged correct when its absolute or relative error from the judge's output is at most <var>10^{-5}</var>.

Sample Input 1

2
3 4

Sample Output 1

3.5

If you start with two ingredients, the only choice is to put both of them in the pot. The value of the ingredient resulting from the ingredients of values <var>3</var> and <var>4</var> is <var>(3 + 4) / 2 = 3.5</var>.

Printing 3.50001, 3.49999, and so on will also be accepted.

Sample Input 2

3
500 300 200

Sample Output 2

375

You start with three ingredients this time, and you can choose what to use in the first composition. There are three possible choices:

Use the ingredients of values <var>500</var> and <var>300</var> to produce an ingredient of value <var>(500 + 300) / 2 = 400</var>. The next composition will use this ingredient and the ingredient of value <var>200</var>, resulting in an ingredient of value <var>(400 + 200) / 2 = 300</var>.

Use the ingredients of values <var>500</var> and <var>200</var> to produce an ingredient of value <var>(500 + 200) / 2 = 350</var>. The next composition will use this ingredient and the ingredient of value <var>300</var>, resulting in an ingredient of value <var>(350 + 300) / 2 = 325</var>.

Use the ingredients of values <var>300</var> and <var>200</var> to produce an ingredient of value <var>(300 + 200) / 2 = 250</var>. The next composition will use this ingredient and the ingredient of value <var>500</var>, resulting in an ingredient of value <var>(250 + 500) / 2 = 375</var>.

Thus, the maximum possible value of the last ingredient remaining is <var>375</var>.

Printing 375.0 and so on will also be accepted.

Sample Input 3

5
138 138 138 138 138

Sample Output 3

138


Score : <var>200</var> points

Problem Statement

Find the number of palindromic numbers among the integers between <var>A</var> and <var>B</var> (inclusive).
Here, a palindromic number is a positive integer whose string representation in base <var>10</var> (without leading zeros) reads the same forward and backward.

Constraints

<var>10000 \leq A \leq B \leq 99999</var>

All input values are integers.

Input

Input is given from Standard Input in the following format:

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

Output

Print the number of palindromic numbers among the integers between <var>A</var> and <var>B</var> (inclusive).

Sample Input 1

11009 11332

Sample Output 1

4

There are four integers that satisfy the conditions: <var>11011</var>, <var>11111</var>, <var>11211</var> and <var>11311</var>.

Sample Input 2

31415 92653

Sample Output 2

612


Score : <var>200</var> points

Problem Statement

Takahashi has <var>A</var> cookies, and Aoki has <var>B</var> cookies.
Takahashi will do the following action <var>K</var> times:

If Takahashi has one or more cookies, eat one of his cookies.

Otherwise, if Aoki has one or more cookies, eat one of Aoki's cookies.

If they both have no cookies, do nothing.

In the end, how many cookies will Takahashi and Aoki have, respectively?

Constraints

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

<var>0 \leq B \leq 10^{12}</var>

<var>0 \leq K \leq 10^{12}</var>

All values in input are integers.

Input

Input is given from Standard Input in the following format:

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

Output

Print the numbers of Takahashi's and Aoki's cookies after <var>K</var> actions.

Sample Input 1

2 3 3

Sample Output 1

0 2

Takahashi will do the following:

He has two cookies, so he eats one of them.

Now he has one cookie left, and he eats it.

Now he has no cookies left, but Aoki has three, so Takahashi eats one of them.

Thus, in the end, Takahashi will have <var>0</var> cookies, and Aoki will have <var>2</var>.

Sample Input 2

500000000000 500000000000 1000000000000

Sample Output 2

0 0

Watch out for overflows.


Score : <var>200</var> points

Problem Statement

You are given a string <var>S</var> consisting of lowercase English letters.
Find the lexicographically (alphabetically) smallest lowercase English letter that does not occur in <var>S</var>.
If every lowercase English letter occurs in <var>S</var>, print None instead.

Constraints

<var>1 \leq |S| \leq 10^5</var> (<var>|S|</var> is the length of string <var>S</var>.)

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

Input

Input is given from Standard Input in the following format:

<var>S</var>

Output

Print the lexicographically smallest lowercase English letter that does not occur in <var>S</var>.
If every lowercase English letter occurs in <var>S</var>, print None instead.

Sample Input 1

atcoderregularcontest

Sample Output 1

b

The string atcoderregularcontest contains a, but does not contain b.

Sample Input 2

abcdefghijklmnopqrstuvwxyz

Sample Output 2

None

This string contains every lowercase English letter.

Sample Input 3

fajsonlslfepbjtsaayxbymeskptcumtwrmkkinjxnnucagfrg

Sample Output 3

d


Score : <var>200</var> points

Problem Statement

Given <var>N</var> integers <var>A_1, ..., A_N</var>, compute <var>A_1 \times ... \times A_N</var>.

However, if the result exceeds <var>10^{18}</var>, print -1 instead.

Constraints

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

<var>0 \leq A_i \leq 10^{18}</var>

All values in input are integers.

Input

Input is given from Standard Input in the following format:

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

Output

Print the value <var>A_1 \times ... \times A_N</var> as an integer, or -1 if the value exceeds <var>10^{18}</var>.

Sample Input 1

2
1000000000 1000000000

Sample Output 1

1000000000000000000

We have <var>1000000000 \times 1000000000 = 1000000000000000000</var>.

Sample Input 2

3
101 9901 999999000001

Sample Output 2

-1

We have <var>101 \times 9901 \times 999999000001 = 1000000000000000001</var>, which exceeds <var>10^{18}</var>, so we should print -1 instead.

Sample Input 3

31
4 1 5 9 2 6 5 3 5 8 9 7 9 3 2 3 8 4 6 2 6 4 3 3 8 3 2 7 9 5 0

Sample Output 3

0


Score : <var>300</var> points

Problem Statement

There are <var>N</var> towns in a coordinate plane. Town <var>i</var> is located at coordinates (<var>x_i</var>, <var>y_i</var>). The distance between Town <var>i</var> and Town <var>j</var> is <var>\sqrt{\left(x_i-x_j\right)^2+\left(y_i-y_j\right)^2}</var>.

There are <var>N!</var> possible paths to visit all of these towns once. Let the length of a path be the distance covered when we start at the first town in the path, visit the second, third, <var>\dots</var>, towns, and arrive at the last town (assume that we travel in a straight line from a town to another). Compute the average length of these <var>N!</var> paths.

Constraints

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

<var>-1000 \leq x_i \leq 1000</var>

<var>-1000 \leq y_i \leq 1000</var>

<var>\left(x_i, y_i\right) \neq \left(x_j, y_j\right)</var> (if <var>i \neq j</var>)

(Added 21:12 JST) 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 average length of the paths.
Your output will be judges as correct when the absolute difference from the judge's output is at most <var>10^{-6}</var>.

Sample Input 1

3
0 0
1 0
0 1

Sample Output 1

2.2761423749

There are six paths to visit the towns: <var>1</var> → <var>2</var> → <var>3</var>, <var>1</var> → <var>3</var> → <var>2</var>, <var>2</var> → <var>1</var> → <var>3</var>, <var>2</var> → <var>3</var> → <var>1</var>, <var>3</var> → <var>1</var> → <var>2</var>, and <var>3</var> → <var>2</var> → <var>1</var>.

The length of the path <var>1</var> → <var>2</var> → <var>3</var> is <var>\sqrt{\left(0-1\right)^2+\left(0-0\right)^2} + \sqrt{\left(1-0\right)^2+\left(0-1\right)^2} = 1+\sqrt{2}</var>.

By calculating the lengths of the other paths in this way, we see that the average length of all routes is:

<var>\frac{\left(1+\sqrt{2}\right)+\left(1+\sqrt{2}\right)+\left(2\right)+\left(1+\sqrt{2}\right)+\left(2\right)+\left(1+\sqrt{2}\right)}{6} = 2.276142...</var>

Sample Input 2

2
-879 981
-866 890

Sample Output 2

91.9238815543

There are two paths to visit the towns: <var>1</var> → <var>2</var> and <var>2</var> → <var>1</var>. These paths have the same length.

Sample Input 3

8
-406 10
512 859
494 362
-955 -475
128 553
-986 -885
763 77
449 310

Sample Output 3

7641.9817824387


Score : <var>200</var> points

Problem Statement

The word internationalization is sometimes abbreviated to i18n.
This comes from the fact that there are <var>18</var> letters between the first i and the last n.

You are given a string <var>s</var> of length at least <var>3</var> consisting of lowercase English letters.
Abbreviate <var>s</var> in the same way.

Constraints

<var>3 ≤ |s| ≤ 100</var> (<var>|s|</var> denotes the length of <var>s</var>.)

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

Input

Input is given from Standard Input in the following format:

<var>s</var>

Output

Print the abbreviation of <var>s</var>.

Sample Input 1

internationalization

Sample Output 1

i18n

Sample Input 2

smiles

Sample Output 2

s4s

Sample Input 3

xyz

Sample Output 3

x1z


Score : <var>100</var> points

Problem Statement

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

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

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

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

Constraints

All values in input are integers.

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

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

Input

Input is given from Standard Input in the following format:

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

Output

Print the minimum possible total cost incurred.

Sample Input 1

4
10 30 40 20

Sample Output 1

30

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

Sample Input 2

2
10 10

Sample Output 2

0

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

Sample Input 3

6
30 10 60 10 60 50

Sample Output 3

40

If we follow the path <var>1</var> → <var>3</var> → <var>5</var> → <var>6</var>, the total cost incurred would be <var>|30 - 60| + |60 - 60| + |60 - 50| = 40</var>.


Score : <var>400</var> points

Problem Statement

There are <var>N</var> persons called Person <var>1</var> through Person <var>N</var>.

You are given <var>M</var> facts that "Person <var>A_i</var> and Person <var>B_i</var> are friends." The same fact may be given multiple times.

If <var>X</var> and <var>Y</var> are friends, and <var>Y</var> and <var>Z</var> are friends, then <var>X</var> and <var>Z</var> are also friends. There is no friendship that cannot be derived from the <var>M</var> given facts.

Takahashi the evil wants to divide the <var>N</var> persons into some number of groups so that every person has no friend in his/her group.

At least how many groups does he need to make?

Constraints

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

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

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

<var>A_i \neq B_i</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>\vdots</var>
<var>A_M</var> <var>B_M</var>

Output

Print the answer.

Sample Input 1

5 3
1 2
3 4
5 1

Sample Output 1

3

Dividing them into three groups such as <var>\{1,3\}</var>, <var>\{2,4\}</var>, and <var>\{5\}</var> achieves the goal.

Sample Input 2

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

Sample Output 2

4

Sample Input 3

10 4
3 1
4 1
5 9
2 6

Sample Output 3

3


Score : <var>400</var> points

Problem Statement

We have <var>N</var> dice arranged in a line from left to right. The <var>i</var>-th die from the left shows <var>p_i</var> numbers from <var>1</var> to <var>p_i</var> with equal probability when thrown.

We will choose <var>K</var> adjacent dice, throw each of them independently, and compute the sum of the numbers shown. Find the maximum possible value of the expected value of this sum.

Constraints

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

<var>1 ≤ p_i ≤ 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_N</var>

Output

Print the maximum possible value of the expected value of the sum of the numbers shown.

Your output will be considered correct when its absolute or relative error from our answer is at most <var>10^{-6}</var>.

Sample Input 1

5 3
1 2 2 4 5

Sample Output 1

7.000000000000

When we throw the third, fourth, and fifth dice from the left, the expected value of the sum of the numbers shown is <var>7</var>. This is the maximum value we can achieve.

Sample Input 2

4 1
6 6 6 6

Sample Output 2

3.500000000000

Regardless of which die we choose, the expected value of the number shown is <var>3.5</var>.

Sample Input 3

10 4
17 13 13 12 15 20 10 13 17 11

Sample Output 3

32.000000000000


Score : <var>200</var> points

Problem Statement

There are <var>N</var> balls placed in a row.
AtCoDeer the deer is painting each of these in one of the <var>K</var> colors of his paint cans.
For aesthetic reasons, any two adjacent balls must be painted in different colors.

Find the number of the possible ways to paint the balls.

Constraints

<var>1≦N≦1000</var>

<var>2≦K≦1000</var>

The correct answer is at most <var>2^{31}-1</var>.

Input

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

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

Output

Print the number of the possible ways to paint the balls.

Sample Input 1

2 2

Sample Output 1

2

We will denote the colors by <var>0</var> and <var>1</var>. There are two possible ways: we can either paint the left ball in color <var>0</var> and the right ball in color <var>1</var>, or paint the left in color <var>1</var> and the right in color <var>0</var>.

Sample Input 2

1 10

Sample Output 2

10

Since there is only one ball, we can use any of the ten colors to paint it. Thus, the answer is ten.


Score : <var>100</var> points

Problem Statement

We have weather records at AtCoder Town for some consecutive three days. A string of length <var>3</var>, <var>S</var>, represents the records - if the <var>i</var>-th character is S, it means it was sunny on the <var>i</var>-th day; if that character is R, it means it was rainy on that day.

Find the maximum number of consecutive rainy days in this period.

Constraints

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

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

Input

Input is given from Standard Input in the following format:

<var>S</var>

Output

Print the maximum number of consecutive rainy days in the period.

Sample Input 1

RRS

Sample Output 1

2

We had rain on the <var>1</var>-st and <var>2</var>-nd days in the period. Here, the maximum number of consecutive rainy days is <var>2</var>, so we should print <var>2</var>.

Sample Input 2

SSS

Sample Output 2

0

It was sunny throughout the period. We had no rainy days, so we should print <var>0</var>.

Sample Input 3

RSR

Sample Output 3

1

We had rain on the <var>1</var>-st and <var>3</var>-rd days - two "streaks" of one rainy day, so we should print <var>1</var>.


Score : <var>100</var> points

Problem Statement

You will be given an integer <var>a</var> and a string <var>s</var> consisting of lowercase English letters as input.

Write a program that prints <var>s</var> if <var>a</var> is not less than <var>3200</var> and prints red if <var>a</var> is less than <var>3200</var>.

Constraints

<var>2800 \leq a < 5000</var>

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

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

Input

Input is given from Standard Input in the following format:

<var>a</var>
<var>s</var>

Output

If <var>a</var> is not less than <var>3200</var>, print <var>s</var>; if <var>a</var> is less than <var>3200</var>, print red.

Sample Input 1

3200
pink

Sample Output 1

pink

<var>a = 3200</var> is not less than <var>3200</var>, so we print <var>s =</var> pink.

Sample Input 2

3199
pink

Sample Output 2

red

<var>a = 3199</var> is less than <var>3200</var>, so we print red.

Sample Input 3

4049
red

Sample Output 3

red

<var>a = 4049</var> is not less than <var>3200</var>, so we print <var>s =</var> red.


Score : <var>100</var> points

Problem Statement

You are given two positive integers <var>a</var> and <var>b</var>.
Let <var>x</var> be the average of <var>a</var> and <var>b</var>.
Print <var>x</var> rounded up to the nearest integer.

Constraints

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

<var>1 \leq a, b \leq 100</var>

Input

Input is given from Standard Input in the following format:

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

Output

Print <var>x</var> rounded up to the nearest integer.

Sample Input 1

1 3

Sample Output 1

2

The average of <var>1</var> and <var>3</var> is <var>2.0</var>, and it will be rounded up to the nearest integer, <var>2</var>.

Sample Input 2

7 4

Sample Output 2

6

The average of <var>7</var> and <var>4</var> is <var>5.5</var>, and it will be rounded up to the nearest integer, <var>6</var>.

Sample Input 3

5 5

Sample Output 3

5


Score : <var>100</var> points

Problem Statement

We have three boxes <var>A</var>, <var>B</var>, and <var>C</var>, each of which contains an integer.

Currently, the boxes <var>A</var>, <var>B</var>, and <var>C</var> contain the integers <var>X</var>, <var>Y</var>, and <var>Z</var>, respectively.

We will now do the operations below in order. Find the content of each box afterward.

Swap the contents of the boxes <var>A</var> and <var>B</var>

Swap the contents of the boxes <var>A</var> and <var>C</var>

Constraints

<var>1 \leq X,Y,Z \leq 100</var>

All values in input are integers.

Input

Input is given from Standard Input in the following format:

<var>X</var> <var>Y</var> <var>Z</var>

Output

Print the integers contained in the boxes <var>A</var>, <var>B</var>, and <var>C</var>, in this order, with space in between.

Sample Input 1

1 2 3

Sample Output 1

3 1 2

After the contents of the boxes <var>A</var> and <var>B</var> are swapped, <var>A</var>, <var>B</var>, and <var>C</var> contain <var>2</var>, <var>1</var>, and <var>3</var>, respectively.

Then, after the contents of <var>A</var> and <var>C</var> are swapped, <var>A</var>, <var>B</var>, and <var>C</var> contain <var>3</var>, <var>1</var>, and <var>2</var>, respectively.

Sample Input 2

100 100 100

Sample Output 2

100 100 100

Sample Input 3

41 59 31

Sample Output 3

31 41 59


Score : <var>200</var> points

Problem Statement

You are given three strings <var>A, B</var> and <var>C</var>. Each of these is a string of length <var>N</var> consisting of lowercase English letters.

Our objective is to make all these three strings equal. For that, you can repeatedly perform the following operation:

Operation: Choose one of the strings <var>A, B</var> and <var>C</var>, and specify an integer <var>i</var> between <var>1</var> and <var>N</var> (inclusive). Change the <var>i</var>-th character from the beginning of the chosen string to some other lowercase English letter.

What is the minimum number of operations required to achieve the objective?

Constraints

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

Each of the strings <var>A, B</var> and <var>C</var> is a string of length <var>N</var>.

Each character in each of the strings <var>A, B</var> and <var>C</var> is a lowercase English letter.

Input

Input is given from Standard Input in the following format:

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

Output

Print the minimum number of operations required.

Sample Input 1

4
west
east
wait

Sample Output 1

3

In this sample, initially <var>A =</var> west、<var>B =</var> east、<var>C =</var> wait. We can achieve the objective in the minimum number of operations by performing three operations as follows:

Change the second character in <var>A</var> to a. <var>A</var> is now wast.

Change the first character in <var>B</var> to w. <var>B</var> is now wast.

Change the third character in <var>C</var> to s. <var>C</var> is now wast.

Sample Input 2

9
different
different
different

Sample Output 2

0

If <var>A, B</var> and <var>C</var> are already equal in the beginning, the number of operations required is <var>0</var>.

Sample Input 3

7
zenkoku
touitsu
program

Sample Output 3

13


Score : <var>200</var> points

Problem Statement

Snuke has decided to construct a string that starts with A and ends with Z, by taking out a substring of a string <var>s</var> (that is, a consecutive part of <var>s</var>).

Find the greatest length of the string Snuke can construct. Here, the test set guarantees that there always exists a substring of <var>s</var> that starts with A and ends with Z.

Constraints

<var>1 ≦ |s| ≦ 200{,}000</var>

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

There exists a substring of <var>s</var> that starts with A and ends with Z.

Input

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

<var>s</var>

Output

Print the answer.

Sample Input 1

QWERTYASDFZXCV

Sample Output 1

5

By taking out the seventh through eleventh characters, it is possible to construct ASDFZ, which starts with A and ends with Z.

Sample Input 2

ZABCZ

Sample Output 2

4

Sample Input 3

HASFJGHOGAKZZFEGA

Sample Output 3

12


Score: <var>100</var> points

Problem Statement

M-kun is a competitor in AtCoder, whose highest rating is <var>X</var>.

In this site, a competitor is given a kyu (class) according to his/her highest rating. For ratings from <var>400</var> through <var>1999</var>, the following kyus are given:

From <var>400</var> through <var>599</var>: <var>8</var>-kyu

From <var>600</var> through <var>799</var>: <var>7</var>-kyu

From <var>800</var> through <var>999</var>: <var>6</var>-kyu

From <var>1000</var> through <var>1199</var>: <var>5</var>-kyu

From <var>1200</var> through <var>1399</var>: <var>4</var>-kyu

From <var>1400</var> through <var>1599</var>: <var>3</var>-kyu

From <var>1600</var> through <var>1799</var>: <var>2</var>-kyu

From <var>1800</var> through <var>1999</var>: <var>1</var>-kyu

What kyu does M-kun have?

Constraints

<var>400 \leq X \leq 1999</var>

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

Input

Input is given from Standard Input in the following format:

<var>X</var>

Output

Print the kyu M-kun has, as an integer.
For example, if he has <var>8</var>-kyu, print 8.

Sample Input 1

725

Sample Output 1

7

M-kun's highest rating is <var>725</var>, which corresponds to <var>7</var>-kyu.

Thus, 7 is the correct output.

Sample Input 2

1600

Sample Output 2

2

M-kun's highest rating is <var>1600</var>, which corresponds to <var>2</var>-kyu.

Thus, 2 is the correct output.


Score : <var>100</var> points

Problem Statement

We have <var>A</var> apples and <var>P</var> pieces of apple.

We can cut an apple into three pieces of apple, and make one apple pie by simmering two pieces of apple in a pan.

Find the maximum number of apple pies we can make with what we have now.

Constraints

All values in input are integers.

<var>0 \leq A, P \leq 100</var>

Input

Input is given from Standard Input in the following format:

<var>A</var> <var>P</var>

Output

Print the maximum number of apple pies we can make with what we have.

Sample Input 1

1 3

Sample Output 1

3

We can first make one apple pie by simmering two of the three pieces of apple. Then, we can make two more by simmering the remaining piece and three more pieces obtained by cutting the whole apple.

Sample Input 2

0 1

Sample Output 2

0

We cannot make an apple pie in this case, unfortunately.

Sample Input 3

32 21

Sample Output 3

58


Score : <var>100</var> points

Problem Statement

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

How many times is the area of a circle of radius <var>r</var> larger than the area of a circle of radius <var>1</var>?

It can be proved that the answer is always an integer under the constraints given.

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 area of a circle of radius <var>r</var>, divided by the area of a circle of radius <var>1</var>, as an integer.

Sample Input 1

2

Sample Output 1

4

The area of a circle of radius <var>2</var> is <var>4</var> times larger than the area of a circle of radius <var>1</var>.

Note that output must be an integer - for example, 4.0 will not be accepted.

Sample Input 2

100

Sample Output 2

10000


Score : <var>300</var> points

Problem Statement

Takahashi is a teacher responsible for a class of <var>N</var> students.

The students are given distinct student numbers from <var>1</var> to <var>N</var>.

Today, all the students entered the classroom at different times.

According to Takahashi's record, there were <var>A_i</var> students in the classroom when student number <var>i</var> entered the classroom (including student number <var>i</var>).

From these records, reconstruct the order in which the students entered the classroom.

Constraints

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

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

<var> A_i \neq A_j </var> <var>(i \neq j)</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>\ldots</var> <var>A_N</var>

Output

Print the student numbers of the students in the order the students entered the classroom.

Sample Input 1

3
2 3 1

Sample Output 1

3 1 2

First, student number <var>3</var> entered the classroom.

Then, student number <var>1</var> entered the classroom.

Finally, student number <var>2</var> entered the classroom.

Sample Input 2

5
1 2 3 4 5

Sample Output 2

1 2 3 4 5

Sample Input 3

8
8 2 7 3 4 5 6 1

Sample Output 3

8 2 4 5 6 7 3 1


Score : <var>200</var> points

Problem Statement

There are <var>N</var> positive integers written on a blackboard: <var>A_1, ..., A_N</var>.

Snuke can perform the following operation when all integers on the blackboard are even:

Replace each integer <var>X</var> on the blackboard by <var>X</var> divided by <var>2</var>.

Find the maximum possible number of operations that Snuke can perform.

Constraints

<var>1 \leq N \leq 200</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>A_N</var>

Output

Print the maximum possible number of operations that Snuke can perform.

Sample Input 1

3
8 12 40

Sample Output 1

2

Initially, <var>[8, 12, 40]</var> are written on the blackboard.
Since all those integers are even, Snuke can perform the operation.

After the operation is performed once, <var>[4, 6, 20]</var> are written on the blackboard.
Since all those integers are again even, he can perform the operation.

After the operation is performed twice, <var>[2, 3, 10]</var> are written on the blackboard.
Now, there is an odd number <var>3</var> on the blackboard, so he cannot perform the operation any more.

Thus, Snuke can perform the operation at most twice.

Sample Input 2

4
5 6 8 10

Sample Output 2

0

Since there is an odd number <var>5</var> on the blackboard already in the beginning, Snuke cannot perform the operation at all.

Sample Input 3

6
382253568 723152896 37802240 379425024 404894720 471526144

Sample Output 3

8


Score : <var>300</var> points

Problem Statement

Takahashi is standing on a multiplication table with infinitely many rows and columns.

The square <var>(i,j)</var> contains the integer <var>i \times j</var>. Initially, Takahashi is standing at <var>(1,1)</var>.

In one move, he can move from <var>(i,j)</var> to either <var>(i+1,j)</var> or <var>(i,j+1)</var>.

Given an integer <var>N</var>, find the minimum number of moves needed to reach a square that contains <var>N</var>.

Constraints

<var>2 \leq N \leq 10^{12}</var>

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

Input

Input is given from Standard Input in the following format:

<var>N</var>

Output

Print the minimum number of moves needed to reach a square that contains the integer <var>N</var>.

Sample Input 1

10

Sample Output 1

5

<var>(2,5)</var> can be reached in five moves. We cannot reach a square that contains <var>10</var> in less than five moves.

Sample Input 2

50

Sample Output 2

13

<var>(5, 10)</var> can be reached in <var>13</var> moves.

Sample Input 3

10000000019

Sample Output 3

10000000018

Both input and output may be enormous.


Score : <var>200</var> points

Problem Statement

Let <var>w</var> be a string consisting of lowercase letters.
We will call <var>w</var> beautiful if the following condition is satisfied:

Each lowercase letter of the English alphabet occurs even number of times in <var>w</var>.

You are given the string <var>w</var>. Determine if <var>w</var> is beautiful.

Constraints

<var>1 \leq |w| \leq 100</var>

<var>w</var> consists of lowercase letters (a-z).

Input

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

<var>w</var>

Output

Print Yes if <var>w</var> is beautiful. Print No otherwise.

Sample Input 1

abaccaba

Sample Output 1

Yes

a occurs four times, b occurs twice, c occurs twice and the other letters occur zero times.

Sample Input 2

hthth

Sample Output 2

No


Score : <var>100</var> points

Problem Statement

You are given a positive integer <var>N</var>.
Find the minimum positive integer divisible by both <var>2</var> and <var>N</var>.

Constraints

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

All values in input are integers.

Input

Input is given from Standard Input in the following format:

<var>N</var>

Output

Print the minimum positive integer divisible by both <var>2</var> and <var>N</var>.

Sample Input 1

3

Sample Output 1

6

<var>6</var> is divisible by both <var>2</var> and <var>3</var>.
Also, there is no positive integer less than <var>6</var> that is divisible by both <var>2</var> and <var>3</var>.
Thus, the answer is <var>6</var>.

Sample Input 2

10

Sample Output 2

10

Sample Input 3

999999999

Sample Output 3

1999999998


Score : <var>200</var> points

Problem Statement

You are visiting a large electronics store to buy a refrigerator and a microwave.

The store sells <var>A</var> kinds of refrigerators and <var>B</var> kinds of microwaves. The <var>i</var>-th refrigerator ( <var>1 \le i \le A</var> ) is sold at <var>a_i</var> yen (the currency of Japan), and the <var>j</var>-th microwave ( <var>1 \le j \le B</var> ) is sold at <var>b_j</var> yen.

You have <var>M</var> discount tickets. With the <var>i</var>-th ticket ( <var>1 \le i \le M</var> ), you can get a discount of <var>c_i</var> yen from the total price when buying the <var>x_i</var>-th refrigerator and the <var>y_i</var>-th microwave together. Only one ticket can be used at a time.

You are planning to buy one refrigerator and one microwave. Find the minimum amount of money required.

Constraints

All values in input are integers.

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

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

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

<var> 1 \le a_i , b_i , c_i \le 10^5 </var>

<var> 1 \le x_i \le A </var>

<var> 1 \le y_i \le B </var>

<var> c_i \le a_{x_i} + b_{y_i} </var>

Input

Input is given from Standard Input in the following format:

<var>A</var> <var>B</var> <var>M</var>
<var>a_1</var> <var>a_2</var> <var>...</var> <var>a_A</var>
<var>b_1</var> <var>b_2</var> <var>...</var> <var>b_B</var>
<var>x_1</var> <var>y_1</var> <var>c_1</var>
<var>\vdots</var>
<var>x_M</var> <var>y_M</var> <var>c_M</var>

Output

Print the answer.

Sample Input 1

2 3 1
3 3
3 3 3
1 2 1

Sample Output 1

5

With the ticket, you can get the <var>1</var>-st refrigerator and the <var>2</var>-nd microwave for <var>3+3-1=5</var> yen.

Sample Input 2

1 1 2
10
10
1 1 5
1 1 10

Sample Output 2

10

Note that you cannot use more than one ticket at a time.

Sample Input 3

2 2 1
3 5
3 5
2 2 2

Sample Output 3

6

You can get the <var>1</var>-st refrigerator and the <var>1</var>-st microwave for <var>6</var> yen, which is the minimum amount to pay in this case.
Note that using a ticket is optional.


Score : <var>200</var> points

Problem Statement

A ball will bounce along a number line, making <var>N + 1</var> bounces. It will make the first bounce at coordinate <var>D_1 = 0</var>, and the <var>i</var>-th bounce <var>(2 \leq i \leq N+1)</var> at coordinate <var>D_i = D_{i-1} + L_{i-1}</var>.

How many times will the ball make a bounce where the coordinate is at most <var>X</var>?

Constraints

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

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

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

All values in input are integers.

Input

Input is given from Standard Input in the following format:

<var>N</var> <var>X</var>
<var>L_1</var> <var>L_2</var> <var>...</var> <var>L_{N-1}</var> <var>L_N</var>

Output

Print the number of times the ball will make a bounce where the coordinate is at most <var>X</var>.

Sample Input 1

3 6
3 4 5

Sample Output 1

2

The ball will make a bounce at the coordinates <var>0</var>, <var>3</var>, <var>7</var> and <var>12</var>, among which two are less than or equal to <var>6</var>.

Sample Input 2

4 9
3 3 3 3

Sample Output 2

4

The ball will make a bounce at the coordinates <var>0</var>, <var>3</var>, <var>6</var>, <var>9</var> and <var>12</var>, among which four are less than or equal to <var>9</var>.


Score: <var>300</var> points

Problem Statement

As AtCoder Beginner Contest 100 is taking place, the office of AtCoder, Inc. is decorated with a sequence of length <var>N</var>, <var>a = </var>{<var>a_1, a_2, a_3, ..., a_N</var>}.

Snuke, an employee, would like to play with this sequence.

Specifically, he would like to repeat the following operation as many times as possible:

For every <var>i</var> satisfying <var>1 \leq i \leq N</var>, perform one of the following: "divide <var>a_i</var> by <var>2</var>" and "multiply <var>a_i</var> by <var>3</var>".
Here, choosing "multiply <var>a_i</var> by <var>3</var>" for every <var>i</var> is not allowed, and the value of <var>a_i</var> after the operation must be an integer.

At most how many operations can be performed?

Constraints

<var>N</var> is an integer between <var>1</var> and <var>10 \ 000</var> (inclusive).

<var>a_i</var> is an integer between <var>1</var> and <var>1 \ 000 \ 000 \ 000</var> (inclusive).

Input

Input is given from Standard Input in the following format:

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

Output

Print the maximum number of operations that Snuke can perform.

Sample Input 1

3
5 2 4

Sample Output 1

3

The sequence is initially <var>{5, 2, 4}</var>. Three operations can be performed as follows:

First, multiply <var>a_1</var> by <var>3</var>, multiply <var>a_2</var> by <var>3</var> and divide <var>a_3</var> by <var>2</var>. The sequence is now <var>{15, 6, 2}</var>.

Next, multiply <var>a_1</var> by <var>3</var>, divide <var>a_2</var> by <var>2</var> and multiply <var>a_3</var> by <var>3</var>. The sequence is now <var>{45, 3, 6}</var>.

Finally, multiply <var>a_1</var> by <var>3</var>, multiply <var>a_2</var> by <var>3</var> and divide <var>a_3</var> by <var>2</var>. The sequence is now <var>{135, 9, 3}</var>.

Sample Input 2

4
631 577 243 199

Sample Output 2

0

No operation can be performed since all the elements are odd. Thus, the answer is <var>0</var>.

Sample Input 3

10
2184 2126 1721 1800 1024 2528 3360 1945 1280 1776

Sample Output 3

39


Score : <var>100</var> points

Problem Statement

You are given an integer <var>N</var> that has exactly four digits in base ten.
How many times does 2 occur in the base-ten representation of <var>N</var>?

Constraints

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

Input

Input is given from Standard Input in the following format:

<var>N</var>

Output

Print the answer.

Sample Input 1

1222

Sample Output 1

3

2 occurs three times in 1222. By the way, this contest is held on December <var>22</var> (JST).

Sample Input 2

3456

Sample Output 2

0

Sample Input 3

9592

Sample Output 3

1


Score : <var>100</var> points

Problem Statement

In AtCoder City, there are three stations numbered <var>1</var>, <var>2</var>, and <var>3</var>.

Each of these stations is operated by one of the two railway companies, A and B. A string <var>S</var> of length <var>3</var> represents which company operates each station. If <var>S_i</var> is A, Company A operates Station <var>i</var>; if <var>S_i</var> is B, Company B operates Station <var>i</var>.

To improve the transportation condition, for each pair of a station operated by Company A and one operated by Company B, there will be a bus service connecting them.

Determine if there is a pair of stations that will be connected by a bus service.

Constraints

Each character of <var>S</var> is A or B.

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

Input

Input is given from Standard Input in the following format:

<var>S</var>

Output

If there is a pair of stations that will be connected by a bus service, print Yes; otherwise, print No.

Sample Input 1

ABA

Sample Output 1

Yes

Company A operates Station <var>1</var> and <var>3</var>, while Company B operates Station <var>2</var>.

There will be a bus service between Station <var>1</var> and <var>2</var>, and between Station <var>2</var> and <var>3</var>, so print Yes.

Sample Input 2

BBA

Sample Output 2

Yes

Company B operates Station <var>1</var> and <var>2</var>, while Company A operates Station <var>3</var>.

There will be a bus service between Station <var>1</var> and <var>3</var>, and between Station <var>2</var> and <var>3</var>, so print Yes.

Sample Input 3

BBB

Sample Output 3

No

Company B operates all the stations. Thus, there will be no bus service, so print No.


Score : <var>300</var> points

Problem Statement

Given is a string <var>S</var>. Let <var>T</var> be the concatenation of <var>K</var> copies of <var>S</var>.
We can repeatedly perform the following operation: choose a character in <var>T</var> and replace it with a different character.
Find the minimum number of operations required to satisfy the following condition: any two adjacent characters in <var>T</var> are different.

Constraints

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

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

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

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

Input

Input is given from Standard Input in the following format:

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

Output

Print the minimum number of operations required.

Sample Input 1

issii
2

Sample Output 1

4

<var>T</var> is issiiissii.  For example, we can rewrite it into ispiqisyhi, and now any two adjacent characters are different.

Sample Input 2

qq
81

Sample Output 2

81

Sample Input 3

cooooooooonteeeeeeeeeest
999993333

Sample Output 3

8999939997


Score : <var>100</var> points

Problem Statement

Takahashi is a user of a site that hosts programming contests.

When a user competes in a contest, the rating of the user (not necessarily an integer) changes according to the performance of the user, as follows:

Let the current rating of the user be <var>a</var>.

Suppose that the performance of the user in the contest is <var>b</var>.

Then, the new rating of the user will be the avarage of <var>a</var> and <var>b</var>.

For example, if a user with rating <var>1</var> competes in a contest and gives performance <var>1000</var>, his/her new rating will be <var>500.5</var>, the average of <var>1</var> and <var>1000</var>.

Takahashi's current rating is <var>R</var>, and he wants his rating to be exactly <var>G</var> after the next contest.

Find the performance required to achieve it.

Constraints

<var>0 \leq R, G \leq 4500</var>

All input values are integers.

Input

Input is given from Standard Input in the following format:

<var>R</var>
<var>G</var>

Output

Print the performance required to achieve the objective.

Sample Input 1

2002
2017

Sample Output 1

2032

Takahashi's current rating is <var>2002</var>.

If his performance in the contest is <var>2032</var>, his rating will be the average of <var>2002</var> and <var>2032</var>, which is equal to the desired rating, <var>2017</var>.

Sample Input 2

4500
0

Sample Output 2

-4500

Although the current and desired ratings are between <var>0</var> and <var>4500</var>, the performance of a user can be below <var>0</var>.


Score : <var>200</var> points

Problem Statement

There are <var>N</var> people numbered <var>1</var> to <var>N</var>. Each person wears a red hat or a blue hat.

You are given a string <var>s</var> representing the colors of the people. Person <var>i</var> wears a red hat if <var>s_i</var> is R, and a blue hat if <var>s_i</var> is B.

Determine if there are more people wearing a red hat than people wearing a blue hat.

Constraints

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

<var>|s| = N</var>

<var>s_i</var> is R or B.

Input

Input is given from Standard Input in the following format:

<var>N</var>
<var>s</var>

Output

If there are more people wearing a red hat than there are people wearing a blue hat, print Yes; otherwise, print No.

Sample Input 1

4
RRBR

Sample Output 1

Yes

There are three people wearing a red hat, and one person wearing a blue hat.

Since there are more people wearing a red hat than people wearing a blue hat, the answer is Yes.

Sample Input 2

4
BRBR

Sample Output 2

No

There are two people wearing a red hat, and two people wearing a blue hat.

Since there are as many people wearing a red hat as people wearing a blue hat, the answer is No.


Score : <var>600</var> points

Problem Statement

Given is an integer sequence <var>A_1, ..., A_N</var> of length <var>N</var>.

We will choose exactly <var>\left\lfloor \frac{N}{2} \right\rfloor</var> elements from this sequence so that no two adjacent elements are chosen.

Find the maximum possible sum of the chosen elements.

Here <var>\lfloor x \rfloor</var> denotes the greatest integer not greater than <var>x</var>.

Constraints

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

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

Output

Print the maximum possible sum of the chosen elements.

Sample Input 1

6
1 2 3 4 5 6

Sample Output 1

12

Choosing <var>2</var>, <var>4</var>, and <var>6</var> makes the sum <var>12</var>, which is the maximum possible value.

Sample Input 2

5
-1000 -100 -10 0 10

Sample Output 2

0

Choosing <var>-10</var> and <var>10</var> makes the sum <var>0</var>, which is the maximum possible value.

Sample Input 3

10
1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000

Sample Output 3

5000000000

Watch out for overflow.

Sample Input 4

27
18 -28 18 28 -45 90 -45 23 -53 60 28 -74 -71 35 -26 -62 49 -77 57 24 -70 -93 69 -99 59 57 -49

Sample Output 4

295


Score: <var>300</var> points

Problem Statement

Find the minimum prime number greater than or equal to <var>X</var>.

Notes

A prime number is an integer greater than <var>1</var> that cannot be evenly divided by any positive integer except <var>1</var> and itself.

For example, <var>2</var>, <var>3</var>, and <var>5</var> are prime numbers, while <var>4</var> and <var>6</var> are not.

Constraints

<var> 2 \le X \le 10^5 </var>

All values in input are integers.

Input

Input is given from Standard Input in the following format:

<var>X</var>

Output

Print the minimum prime number greater than or equal to <var>X</var>.

Sample Input 1

20

Sample Output 1

23

The minimum prime number greater than or equal to <var>20</var> is <var>23</var>.

Sample Input 2

2

Sample Output 2

2

<var>X</var> itself can be a prime number.

Sample Input 3

99992

Sample Output 3

100003