Score : <var>300</var> points

Problem Statement

Find the price of a product before tax such that, when the consumption tax rate is <var>8</var> percent and <var>10</var> percent, the amount of consumption tax levied on it is <var>A</var> yen and <var>B</var> yen, respectively. (Yen is the currency of Japan.)

Here, the price before tax must be a positive integer, and the amount of consumption tax is rounded down to the nearest integer.

If multiple prices satisfy the condition, print the lowest such price; if no price satisfies the condition, print -1.

Constraints

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

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

Input

Input is given from Standard Input in the following format:

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

Output

If there is a price that satisfies the condition, print an integer representing the lowest such price; otherwise, print -1.

Sample Input 1

2 2

Sample Output 1

25

If the price of a product before tax is <var>25</var> yen, the amount of consumption tax levied on it is:

When the consumption tax rate is <var>8</var> percent: <var>\lfloor 25 \times 0.08 \rfloor = \lfloor 2 \rfloor = 2</var> yen.

When the consumption tax rate is <var>10</var> percent: <var>\lfloor 25 \times 0.1 \rfloor = \lfloor 2.5 \rfloor = 2</var> yen.

Thus, the price of <var>25</var> yen satisfies the condition. There are other possible prices, such as <var>26</var> yen, but print the minimum such price, <var>25</var>.

Sample Input 2

8 10

Sample Output 2

100

If the price of a product before tax is <var>100</var> yen, the amount of consumption tax levied on it is:

When the consumption tax rate is <var>8</var> percent: <var>\lfloor 100 \times 0.08 \rfloor = 8</var> yen.

When the consumption tax rate is <var>10</var> percent: <var>\lfloor 100 \times 0.1 \rfloor = 10</var> yen.

Sample Input 3

19 99

Sample Output 3

-1

There is no price before tax satisfying this condition, so print -1.


Score : <var>200</var> points

Problem Statement

There are <var>N</var> mountains ranging from east to west, and an ocean to the west.

At the top of each mountain, there is an inn. You have decided to choose where to stay from these inns.

The height of the <var>i</var>-th mountain from the west is <var>H_i</var>.

You can certainly see the ocean from the inn at the top of the westmost mountain.

For the inn at the top of the <var>i</var>-th mountain from the west <var>(i = 2, 3, ..., N)</var>, you can see the ocean if and only if <var>H_1 \leq H_i</var>, <var>H_2 \leq H_i</var>, <var>...</var>, and <var>H_{i-1} \leq H_i</var>.

From how many of these <var>N</var> inns can you see the ocean?

Constraints

All values in input are integers.

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

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

Input

Input is given from Standard Input in the following format:

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

Output

Print the number of inns from which you can see the ocean.

Sample Input 1

4
6 5 6 8

Sample Output 1

3

You can see the ocean from the first, third and fourth inns from the west.

Sample Input 2

5
4 5 3 5 4

Sample Output 2

3

Sample Input 3

5
9 5 6 8 4

Sample Output 3

1


Score : <var>400</var> points

Problem Statement

We have a string <var>S</var> of length <var>N</var> consisting of R, G, and B.

Find the number of triples <var>(i,~j,~k)~(1 \leq i < j < k \leq N)</var> that satisfy both of the following conditions:

<var>S_i \neq S_j</var>, <var>S_i \neq S_k</var>, and <var>S_j \neq S_k</var>.

<var>j - i \neq k - j</var>.

Constraints

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

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

Input

Input is given from Standard Input in the following format:

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

Output

Print the number of triplets in question.

Sample Input 1

4
RRGB

Sample Output 1

1

Only the triplet <var>(1,~3,~4)</var> satisfies both conditions. The triplet <var>(2,~3,~4)</var> satisfies the first condition but not the second, so it does not count.

Sample Input 2

39
RBRBGRBGGBBRRGBBRRRBGGBRBGBRBGBRBBBGBBB

Sample Output 2

1800


Score : <var>200</var> points

Problem Statement

You are given positive integers <var>A</var> and <var>B</var>.

Find the <var>K</var>-th largest positive integer that divides both <var>A</var> and <var>B</var>.

The input guarantees that there exists such a number.

Constraints

All values in input are integers.

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

The <var>K</var>-th largest positive integer that divides both <var>A</var> and <var>B</var> exists.

<var>K \geq 1</var>

Input

Input is given from Standard Input in the following format:

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

Output

Print the <var>K</var>-th largest positive integer that divides both <var>A</var> and <var>B</var>.

Sample Input 1

8 12 2

Sample Output 1

2

Three positive integers divides both <var>8</var> and <var>12</var>: <var>1, 2</var> and <var>4</var>.
Among them, the second largest is <var>2</var>.

Sample Input 2

100 50 4

Sample Output 2

5

Sample Input 3

1 1 1

Sample Output 3

1


Score : <var>100</var> points

Problem Statement

Based on some criterion, Snuke divided the integers from <var>1</var> through <var>12</var> into three groups as shown in the figure below.
Given two integers <var>x</var> and <var>y</var> (<var>1 ≤ x < y ≤ 12</var>), determine whether they belong to the same group.

Constraints

<var>x</var> and <var>y</var> are integers.

<var>1 ≤ x < y ≤ 12</var>

Input

Input is given from Standard Input in the following format:

<var>x</var> <var>y</var>

Output

If <var>x</var> and <var>y</var> belong to the same group, print Yes; otherwise, print No.

Sample Input 1

1 3

Sample Output 1

Yes

Sample Input 2

2 4

Sample Output 2

No


Score : <var>300</var> points

Problem Statement

There are <var>N</var> people standing in a row from west to east.
Each person is facing east or west.
The directions of the people is given as a string <var>S</var> of length <var>N</var>.
The <var>i</var>-th person from the west is facing east if <var>S_i =</var> E, and west if <var>S_i =</var> W.

You will appoint one of the <var>N</var> people as the leader, then command the rest of them to face in the direction of the leader.
Here, we do not care which direction the leader is facing.

The people in the row hate to change their directions, so you would like to select the leader so that the number of people who have to change their directions is minimized.
Find the minimum number of people who have to change their directions.

Constraints

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

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

<var>S_i</var> is E or W.

Input

Input is given from Standard Input in the following format:

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

Output

Print the minimum number of people who have to change their directions.

Sample Input 1

5
WEEWW

Sample Output 1

1

Assume that we appoint the third person from the west as the leader.
Then, the first person from the west needs to face east and has to turn around.
The other people do not need to change their directions, so the number of people who have to change their directions is <var>1</var> in this case.
It is not possible to have <var>0</var> people who have to change their directions, so the answer is <var>1</var>.

Sample Input 2

12
WEWEWEEEWWWE

Sample Output 2

4

Sample Input 3

8
WWWWWEEE

Sample Output 3

3


Score : <var>300</var> points

Problem Statement

<var>1000000000000001</var> dogs suddenly appeared under the roof of Roger's house, all of which he decided to keep. The dogs had been numbered <var>1</var> through <var>1000000000000001</var>, but he gave them new names, as follows:

the dogs numbered <var>1,2,\cdots,26</var> were respectively given the names a, b, ..., z;

the dogs numbered <var>27,28,29,\cdots,701,702 </var> were respectively given the names aa, ab, ac, ..., zy, zz;

the dogs numbered <var>703,704,705,\cdots,18277,18278 </var> were respectively given the names aaa, aab, aac, ..., zzy, zzz;

the dogs numbered <var>18279,18280,18281,\cdots,475253,475254 </var> were respectively given the names aaaa, aaab, aaac, ..., zzzy, zzzz;

the dogs numbered <var>475255,475256,\cdots </var> were respectively given the names aaaaa, aaaab, ...;

and so on.

To sum it up, the dogs numbered <var>1, 2, \cdots</var> were respectively given the following names:

a, b, ..., z, aa, ab, ..., az, ba, bb, ..., bz, ..., za, zb, ..., zz, aaa, aab, ..., aaz, aba, abb, ..., abz, ..., zzz, aaaa, ...

Now, Roger asks you:

"What is the name for the dog numbered <var>N</var>?"

Constraints

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

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

Input

Input is given from Standard Input in the following format:

<var>N</var>

Output

Print the answer to Roger's question as a string consisting of lowercase English letters.

Sample Input 1

2

Sample Output 1

b

Sample Input 2

27

Sample Output 2

aa

Sample Input 3

123456789

Sample Output 3

jjddja


Score : <var>200</var> points

Problem Statement

An integer <var>N</var> is a multiple of <var>9</var> if and only if the sum of the digits in the decimal representation of <var>N</var> is a multiple of <var>9</var>.

Determine whether <var>N</var> is a multiple of <var>9</var>.

Constraints

<var>0 \leq N < 10^{200000}</var>

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

Input

Input is given from Standard Input in the following format:

<var>N</var>

Output

If <var>N</var> is a multiple of <var>9</var>, print Yes; otherwise, print No.

Sample Input 1

123456789

Sample Output 1

Yes

The sum of these digits is <var>1+2+3+4+5+6+7+8+9=45</var>, which is a multiple of <var>9</var>, so <var>123456789</var> is a multiple of <var>9</var>.

Sample Input 2

0

Sample Output 2

Yes

Sample Input 3

31415926535897932384626433832795028841971693993751058209749445923078164062862089986280

Sample Output 3

No


Score : <var>100</var> points

Problem Statement

Shichi-Go-San (literally "Seven-Five-Three") is a traditional event in a certain country to celebrate the growth of seven-, five- and three-year-old children.

Takahashi is now <var>X</var> years old. Will his growth be celebrated in Shichi-Go-San this time?

Constraints

<var>1 ≤ X ≤ 9</var>

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

Input

Input is given from Standard Input in the following format:

<var>X</var>

Output

If Takahashi's growth will be celebrated, print YES; if it will not, print NO.

Sample Input 1

5

Sample Output 1

YES

The growth of a five-year-old child will be celebrated.

Sample Input 2

6

Sample Output 2

NO

See you next year.


Score : <var>100</var> points

Problem Statement

Joisino wants to evaluate the formula "<var>A</var> <var>op</var> <var>B</var>".
Here, <var>A</var> and <var>B</var> are integers, and the binary operator <var>op</var> is either + or -.
Your task is to evaluate the formula instead of her.

Constraints

<var>1≦A,B≦10^9</var>

<var>op</var> is either + or -.

Input

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

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

Output

Evaluate the formula and print the result.

Sample Input 1

1 + 2

Sample Output 1

3

Since <var>1 + 2 = 3</var>, the output should be <var>3</var>.

Sample Input 2

5 - 7

Sample Output 2

-2


Score : <var>100</var> points

Problem Statement

Compute <var>A \times B</var>.

Constraints

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

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

All values in input are integers.

Input

Input is given from Standard Input in the following format:

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

Output

Print the value <var>A \times B</var> as an integer.

Sample Input 1

2 5

Sample Output 1

10

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

Sample Input 2

100 100

Sample Output 2

10000


Score : <var>100</var> points

Problem Statement

Two deer, AtCoDeer and TopCoDeer, are playing a game called Honest or Dishonest.
In this game, an honest player always tells the truth, and an dishonest player always tell lies.
You are given two characters <var>a</var> and <var>b</var> as the input. Each of them is either H or D, and carries the following information:

If <var>a</var>=H, AtCoDeer is honest; if <var>a</var>=D, AtCoDeer is dishonest.
If <var>b</var>=H, AtCoDeer is saying that TopCoDeer is honest; if <var>b</var>=D, AtCoDeer is saying that TopCoDeer is dishonest.

Given this information, determine whether TopCoDeer is honest.

Constraints

<var>a</var>=H or <var>a</var>=D.

<var>b</var>=H or <var>b</var>=D.

Input

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

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

Output

If TopCoDeer is honest, print H. If he is dishonest, print D.

Sample Input 1

H H

Sample Output 1

H

In this input, AtCoDeer is honest. Hence, as he says, TopCoDeer is honest.

Sample Input 2

D H

Sample Output 2

D

In this input, AtCoDeer is dishonest. Hence, contrary to what he says, TopCoDeer is dishonest.

Sample Input 3

D D

Sample Output 3

H


Score : <var>200</var> points

Problem Statement

Given are two strings <var>S</var> and <var>T</var>.

Let us change some of the characters in <var>S</var> so that <var>T</var> will be a substring of <var>S</var>.

At least how many characters do we need to change?

Here, a substring is a consecutive subsequence. For example, xxx is a substring of yxxxy, but not a substring of xxyxx.

Constraints

The lengths of <var>S</var> and <var>T</var> are each at least <var>1</var> and at most <var>1000</var>.

The length of <var>T</var> is at most that of <var>S</var>.

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

Input

Input is given from Standard Input in the following format:

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

Output

Print the minimum number of characters in <var>S</var> that need to be changed.

Sample Input 1

cabacc
abc

Sample Output 1

1

For example, changing the fourth character a in <var>S</var> to c will match the second through fourth characters in <var>S</var> to <var>T</var>.

Since <var>S</var> itself does not have <var>T</var> as its substring, this number of changes - one - is the minimum needed.

Sample Input 2

codeforces
atcoder

Sample Output 2

6


Score : <var>300</var> points

Problem Statement

You are given a string <var>S</var> of length <var>N</var> consisting of A, C, G and T. Answer the following <var>Q</var> queries:

Query <var>i</var> (<var>1 \leq i \leq Q</var>): You will be given integers <var>l_i</var> and <var>r_i</var> (<var>1 \leq l_i < r_i \leq N</var>). Consider the substring of <var>S</var> starting at index <var>l_i</var> and ending at index <var>r_i</var> (both inclusive). In this string, how many times does AC occurs as a substring?

Notes

A substring of a string <var>T</var> is a string obtained by removing zero or more characters from the beginning and the end of <var>T</var>.

For example, the substrings of ATCODER include TCO, AT, CODER, ATCODER and  (the empty string), but not AC.

Constraints

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

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

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

Each character in <var>S</var> is A, C, G or T.

<var>1 \leq l_i < r_i \leq N</var>

Input

Input is given from Standard Input in the following format:

<var>N</var> <var>Q</var>
<var>S</var>
<var>l_1</var> <var>r_1</var>
<var>:</var>
<var>l_Q</var> <var>r_Q</var>

Output

Print <var>Q</var> lines. The <var>i</var>-th line should contain the answer to the <var>i</var>-th query.

Sample Input 1

8 3
ACACTACG
3 7
2 3
1 8

Sample Output 1

2
0
3

Query <var>1</var>: the substring of <var>S</var> starting at index <var>3</var> and ending at index <var>7</var> is ACTAC. In this string, AC occurs twice as a substring.

Query <var>2</var>: the substring of <var>S</var> starting at index <var>2</var> and ending at index <var>3</var> is CA. In this string, AC occurs zero times as a substring.

Query <var>3</var>: the substring of <var>S</var> starting at index <var>1</var> and ending at index <var>8</var> is ACACTACG. In this string, AC occurs three times as a substring.


Score : <var>300</var> points

Problem Statement

Let <var>f(n)</var> be the number of triples of integers <var>(x,y,z)</var> that satisfy both of the following conditions:

<var>1 \leq x,y,z</var>

<var>x^2 + y^2 + z^2 + xy + yz + zx = n</var>

Given an integer <var>N</var>, find each of <var>f(1),f(2),f(3),\ldots,f(N)</var>.

Constraints

All values in input are integers.

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

Input

Input is given from Standard Input in the following format:

<var>N</var>

Output

Print <var>N</var> lines. The <var>i</var>-th line should contain the value <var>f(i)</var>.

Sample Input 1

20

Sample Output 1

0
0
0
0
0
1
0
0
0
0
3
0
0
0
0
0
3
3
0
0

For <var>n=6</var>, only <var>(1,1,1)</var> satisfies both of the conditions. Thus, <var>f(6) = 1</var>.

For <var>n=11</var>, three triples, <var>(1,1,2)</var>, <var>(1,2,1)</var>, and <var>(2,1,1)</var>, satisfy both of the conditions. Thus, <var>f(6) = 3</var>.

For <var>n=17</var>, three triples, <var>(1,2,2)</var>, <var>(2,1,2)</var>, and <var>(2,2,1)</var>, satisfy both of the conditions. Thus, <var>f(17) = 3</var>.

For <var>n=18</var>, three triples, <var>(1,1,3)</var>, <var>(1,3,1)</var>, and <var>(3,1,1)</var>, satisfy both of the conditions. Thus, <var>f(18) = 3</var>.


Score : <var>200</var> points

Problem Statement

You have a digit sequence <var>S</var> of length <var>4</var>. You are wondering which of the following formats <var>S</var> is in:

YYMM format: the last two digits of the year and the two-digit representation of the month (example: 01 for January), concatenated in this order

MMYY format: the two-digit representation of the month and the last two digits of the year, concatenated in this order

If <var>S</var> is valid in only YYMM format, print YYMM; if <var>S</var> is valid in only MMYY format, print MMYY; if <var>S</var> is valid in both formats, print AMBIGUOUS; if <var>S</var> is valid in neither format, print NA.

Constraints

<var>S</var> is a digit sequence of length <var>4</var>.

Input

Input is given from Standard Input in the following format:

<var>S</var>

Output

Print the specified string: YYMM, MMYY, AMBIGUOUS or NA.

Sample Input 1

1905

Sample Output 1

YYMM

May <var>XX19</var> is a valid date, but <var>19</var> is not valid as a month. Thus, this string is only valid in YYMM format.

Sample Input 2

0112

Sample Output 2

AMBIGUOUS

Both December <var>XX01</var> and January <var>XX12</var> are valid dates. Thus, this string is valid in both formats.

Sample Input 3

1700

Sample Output 3

NA

Neither <var>0</var> nor <var>17</var> is valid as a month. Thus, this string is valid in neither format.


Score : <var>200</var> points

Problem Statement

Some number of chocolate pieces were prepared for a training camp.
The camp had <var>N</var> participants and lasted for <var>D</var> days.
The <var>i</var>-th participant (<var>1 \leq i \leq N</var>) ate one chocolate piece on each of the following days in the camp: the <var>1</var>-st day, the <var>(A_i + 1)</var>-th day, the <var>(2A_i + 1)</var>-th day, and so on.
As a result, there were <var>X</var> chocolate pieces remaining at the end of the camp. During the camp, nobody except the participants ate chocolate pieces.

Find the number of chocolate pieces prepared at the beginning of the camp.

Constraints

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

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

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

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

All input values are integers.

Input

Input is given from Standard Input in the following format:

<var>N</var>
<var>D</var> <var>X</var>
<var>A_1</var>
<var>A_2</var>
<var>:</var>
<var>A_N</var>

Output

Find the number of chocolate pieces prepared at the beginning of the camp.

Sample Input 1

3
7 1
2
5
10

Sample Output 1

8

The camp has <var>3</var> participants and lasts for <var>7</var> days.
Each participant eats chocolate pieces as follows:

The first participant eats one chocolate piece on Day <var>1</var>, <var>3</var>, <var>5</var> and <var>7</var>, for a total of four.

The second participant eats one chocolate piece on Day <var>1</var> and <var>6</var>, for a total of two.

The third participant eats one chocolate piece only on Day <var>1</var>, for a total of one.

Since the number of pieces remaining at the end of the camp is one, the number of pieces prepared at the beginning of the camp is <var>1 + 4 + 2 + 1 = 8</var>.

Sample Input 2

2
8 20
1
10

Sample Output 2

29

Sample Input 3

5
30 44
26
18
81
18
6

Sample Output 3

56


Score : <var>300</var> points

Problem Statement

There are <var>N</var> cubes stacked vertically on a desk.

You are given a string <var>S</var> of length <var>N</var>. The color of the <var>i</var>-th cube from the bottom is red if the <var>i</var>-th character in <var>S</var> is 0, and blue if that character is 1.

You can perform the following operation any number of times: choose a red cube and a blue cube that are adjacent, and remove them. Here, the cubes that were stacked on the removed cubes will fall down onto the object below them.

At most how many cubes can be removed?

Constraints

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

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

Each character in <var>S</var> is 0 or 1.

Input

Input is given from Standard Input in the following format:

<var>S</var>

Output

Print the maximum number of cubes that can be removed.

Sample Input 1

0011

Sample Output 1

4

All four cubes can be removed, by performing the operation as follows:

Remove the second and third cubes from the bottom. Then, the fourth cube drops onto the first cube.

Remove the first and second cubes from the bottom.

Sample Input 2

11011010001011

Sample Output 2

12

Sample Input 3

0

Sample Output 3

0


Score : <var>100</var> points

Problem Statement

In order to pass the entrance examination tomorrow, Taro has to study for <var>T</var> more hours.

Fortunately, he can leap to World B where time passes <var>X</var> times as fast as it does in our world (World A).

While <var>(X \times t)</var> hours pass in World B, <var>t</var> hours pass in World A.

How many hours will pass in World A while Taro studies for <var>T</var> hours in World B?

Constraints

All values in input are integers.

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

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

Input

Input is given from Standard Input in the following format:

<var>T</var> <var>X</var>

Output

Print the number of hours that will pass in World A.

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

Sample Input 1

8 3

Sample Output 1

2.6666666667

While Taro studies for eight hours in World B where time passes three times as fast, <var>2.6666...</var> hours will pass in World A.

Note that an absolute or relative error of at most <var>10^{-3}</var> is allowed.

Sample Input 2

99 1

Sample Output 2

99.0000000000

Sample Input 3

1 100

Sample Output 3

0.0100000000


Score : <var>300</var> points

Problem Statement

You are given two non-negative integers <var>L</var> and <var>R</var>.
We will choose two integers <var>i</var> and <var>j</var> such that <var>L \leq i < j \leq R</var>.
Find the minimum possible value of <var>(i \times j) \mbox{ mod } 2019</var>.

Constraints

All values in input are integers.

<var>0 \leq L < R \leq 2 \times 10^9</var>

Input

Input is given from Standard Input in the following format:

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

Output

Print the minimum possible value of <var>(i \times j) \mbox{ mod } 2019</var> when <var>i</var> and <var>j</var> are chosen under the given condition.

Sample Input 1

2020 2040

Sample Output 1

2

When <var>(i, j) = (2020, 2021)</var>, <var>(i \times j) \mbox{ mod } 2019  = 2</var>.

Sample Input 2

4 5

Sample Output 2

20

We have only one choice: <var>(i, j) = (4, 5)</var>.


Score : <var>300</var> points

Problem Statement

There are <var>N</var> stones arranged in a row. Every stone is painted white or black.
A string <var>S</var> represents the color of the stones. The <var>i</var>-th stone from the left is white if the <var>i</var>-th character of <var>S</var> is ., and the stone is black if the character is #.

Takahashi wants to change the colors of some stones to black or white so that there will be no white stone immediately to the right of a black stone.
Find the minimum number of stones that needs to be recolored.

Constraints

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

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

Input

Input is given from Standard Input in the following format:

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

Output

Print the minimum number of stones that needs to be recolored.

Sample Input 1

3
#.#

Sample Output 1

1

It is enough to change the color of the first stone to white.

Sample Input 2

5
#.##.

Sample Output 2

2

Sample Input 3

9
.........

Sample Output 3

0


Score : <var>100</var> points

Problem Statement

Serval is fighting with a monster.

The health of the monster is <var>H</var>.

In one attack, Serval can decrease the monster's health by <var>A</var>.
There is no other way to decrease the monster's health.

Serval wins when the monster's health becomes <var>0</var> or below.

Find the number of attacks Serval needs to make before winning.

Constraints

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

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

All values in input are integers.

Input

Input is given from Standard Input in the following format:

<var>H</var> <var>A</var>

Output

Print the number of attacks Serval needs to make before winning.

Sample Input 1

10 4

Sample Output 1

3

After one attack, the monster's health will be <var>6</var>.

After two attacks, the monster's health will be <var>2</var>.

After three attacks, the monster's health will be <var>-2</var>.

Thus, Serval needs to make three attacks to win.

Sample Input 2

1 10000

Sample Output 2

1

Sample Input 3

10000 1

Sample Output 3

10000


Score : <var>300</var> points

Problem Statement

Given is a sequence of integers <var>A_1, A_2, ..., A_N</var>.
If its elements are pairwise distinct, print YES; otherwise, print NO.

Constraints

<var>2 ≤ N ≤ 200000</var>

<var>1 ≤ A_i ≤ 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

If the elements of the sequence are pairwise distinct, print YES; otherwise, print NO.

Sample Input 1

5
2 6 1 4 5

Sample Output 1

YES

The elements are pairwise distinct.

Sample Input 2

6
4 1 3 1 6 2

Sample Output 2

NO

The second and fourth elements are identical.

Sample Input 3

2
10000000 10000000

Sample Output 3

NO


Score : <var>200</var> points

Problem Statement

There is a string <var>S</var> consisting of digits 1, 2, <var>...</var>, 9.
Lunlun, the Dachshund, will take out three consecutive digits from <var>S</var>, treat them as a single integer <var>X</var> and bring it to her master. (She cannot rearrange the digits.)

The master's favorite number is <var>753</var>. The closer to this number, the better.
What is the minimum possible (absolute) difference between <var>X</var> and <var>753</var>?

Constraints

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

Each character in <var>S</var> is 1, 2, <var>...</var>, or 9.

Input

Input is given from Standard Input in the following format:

<var>S</var>

Output

Print the minimum possible difference between <var>X</var> and <var>753</var>.

Sample Input 1

1234567876

Sample Output 1

34

Taking out the seventh to ninth characters results in <var>X = 787</var>, and the difference between this and <var>753</var> is <var>787 - 753 = 34</var>. The difference cannot be made smaller, no matter where <var>X</var> is taken from.

Note that the digits cannot be rearranged. For example, taking out 567 and rearranging it to 765 is not allowed.

We cannot take out three digits that are not consecutive from <var>S</var>, either. For example, taking out the seventh digit 7, the ninth digit 7 and the tenth digit 6 to obtain 776 is not allowed.

Sample Input 2

35753

Sample Output 2

0

If 753 itself can be taken out, the answer is <var>0</var>.

Sample Input 3

1111111111

Sample Output 3

642

No matter where <var>X</var> is taken from, <var>X = 111</var>, with the difference <var>753 - 111 = 642</var>.


Score : <var>200</var> points

Problem Statement

Given is an integer <var>N</var>. Find the number of positive integers less than or equal to <var>N</var> that have an odd number of digits (in base ten without leading zeros).

Constraints

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

Input

Input is given from Standard Input in the following format:

<var>N</var>

Output

Print the number of positive integers less than or equal to <var>N</var> that have an odd number of digits.

Sample Input 1

11

Sample Output 1

9

Among the positive integers less than or equal to <var>11</var>, nine integers have an odd number of digits: <var>1, 2, \ldots, 9</var>.

Sample Input 2

136

Sample Output 2

46

In addition to <var>1, 2, \ldots, 9</var>, another <var>37</var> integers also have an odd number of digits: <var>100, 101, \ldots, 136</var>.

Sample Input 3

100000

Sample Output 3

90909


Score : <var>200</var> points

Problem Statement

Takahashi has a deposit of <var>100</var> yen (the currency of Japan) in AtCoder Bank.

The bank pays an annual interest rate of <var>1</var> % compounded annually. (A fraction of less than one yen is discarded.)

Assuming that nothing other than the interest affects Takahashi's balance, in how many years does the balance reach <var>X</var> yen or above for the first time?

Constraints

<var> 101 \le X \le 10^{18} </var>

All values in input are integers.

Input

Input is given from Standard Input in the following format:

<var>X</var>

Output

Print the number of years it takes for Takahashi's balance to reach <var>X</var> yen or above for the first time.

Sample Input 1

103

Sample Output 1

3

The balance after one year is <var>101</var> yen.

The balance after two years is <var>102</var> yen.

The balance after three years is <var>103</var> yen.

Thus, it takes three years for the balance to reach <var>103</var> yen or above.

Sample Input 2

1000000000000000000

Sample Output 2

3760

Sample Input 3

1333333333

Sample Output 3

1706


Score : <var>100</var> points

Problem Statement

Takahashi loves takoyaki - a ball-shaped snack.

With a takoyaki machine, he can make at most <var>X</var> pieces of takoyaki at a time, taking <var>T</var> minutes regardless of the number of pieces to make.

How long does it take to make <var>N</var> takoyaki?

Constraints

<var>1 \leq N,X,T \leq 1000</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>T</var>

Output

Print an integer representing the minimum number of minutes needed to make <var>N</var> pieces of takoyaki.

Sample Input 1

20 12 6

Sample Output 1

12

He can make <var>12</var> pieces of takoyaki in the first <var>6</var> minutes and <var>8</var> more in the next <var>6</var> minutes, so he can make <var>20</var> in a total of <var>12</var> minutes.

Note that being able to make <var>12</var> in <var>6</var> minutes does not mean he can make <var>2</var> in <var>1</var> minute.

Sample Input 2

1000 1 1000

Sample Output 2

1000000

It seems to take a long time to make this kind of takoyaki.


Score : <var>300</var> points

Problem Statement

A sequence <var>a_1,a_2,... ,a_n</var> is said to be /\/\/\/ when the following conditions are satisfied:

For each <var>i = 1,2,..., n-2</var>, <var>a_i = a_{i+2}</var>.

Exactly two different numbers appear in the sequence.

You are given a sequence <var>v_1,v_2,...,v_n</var> whose length is even.
We would like to make this sequence /\/\/\/ by replacing some of its elements.
Find the minimum number of elements that needs to be replaced.

Constraints

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

<var>n</var> is even.

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

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

Input

Input is given from Standard Input in the following format:

<var>n</var>
<var>v_1</var> <var>v_2</var> <var>...</var> <var>v_n</var>

Output

Print the minimum number of elements that needs to be replaced.

Sample Input 1

4
3 1 3 2

Sample Output 1

1

The sequence <var>3,1,3,2</var> is not /\/\/\/, but we can make it /\/\/\/ by replacing one of its elements: for example, replace the fourth element to make it <var>3,1,3,1</var>.

Sample Input 2

6
105 119 105 119 105 119

Sample Output 2

0

The sequence <var>105,119,105,119,105,119</var> is /\/\/\/.

Sample Input 3

4
1 1 1 1

Sample Output 3

2

The elements of the sequence <var>1,1,1,1</var> are all the same, so it is not /\/\/\/.


Score : <var>200</var> points

Problem Statement

There are <var>N</var> apple trees in a row. People say that one of them will bear golden apples.

We want to deploy some number of inspectors so that each of these trees will be inspected.

Each inspector will be deployed under one of the trees. For convenience, we will assign numbers from <var>1</var> through <var>N</var> to the trees. An inspector deployed under the <var>i</var>-th tree <var>(1 \leq i \leq N)</var> will inspect the trees with numbers between <var>i-D</var> and <var>i+D</var> (inclusive).

Find the minimum number of inspectors that we need to deploy to achieve the objective.

Constraints

All values in input are integers.

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

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

Input

Input is given from Standard Input in the following format:

<var>N</var> <var>D</var>

Output

Print the minimum number of inspectors that we need to deploy to achieve the objective.

Sample Input 1

6 2

Sample Output 1

2

We can achieve the objective by, for example, placing an inspector under Tree <var>3</var> and Tree <var>4</var>.

Sample Input 2

14 3

Sample Output 2

2

Sample Input 3

20 4

Sample Output 3

3


Score : <var>200</var> points

Problem Statement

Takahashi and Aoki will have a battle using their monsters.

The health and strength of Takahashi's monster are <var>A</var> and <var>B</var>, respectively, and those of Aoki's monster are <var>C</var> and <var>D</var>, respectively.

The two monsters will take turns attacking, in the order Takahashi's, Aoki's, Takahashi's, Aoki's, ...
Here, an attack decreases the opponent's health by the value equal to the attacker's strength.
The monsters keep attacking until the health of one monster becomes <var>0</var> or below. The person with the monster whose health becomes <var>0</var> or below loses, and the other person wins.

If Takahashi will win, print Yes; if he will lose, print No.

Constraints

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

All values in input are integers.

Input

Input is given from Standard Input in the following format:

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

Output

If Takahashi will win, print Yes; if he will lose, print No.

Sample Input 1

10 9 10 10

Sample Output 1

No

First, Takahashi's monster attacks Aoki's monster, whose health is now <var>10-9=1</var>.

Next, Aoki's monster attacks Takahashi's monster, whose health is now <var>10-10=0</var>.

Takahashi's monster is the first to have <var>0</var> or less health, so Takahashi loses.

Sample Input 2

46 4 40 5

Sample Output 2

Yes


Score : <var>200</var> points

Problem Statement

Takahashi's house has only one socket.

Takahashi wants to extend it with some number of power strips, each with <var>A</var> sockets, into <var>B</var> or more empty sockets.

One power strip with <var>A</var> sockets can extend one empty socket into <var>A</var> empty sockets.

Find the minimum number of power strips required.

Constraints

All values in input are integers.

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

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

Input

Input is given from Standard Input in the following format:

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

Output

Print the minimum number of power strips required.

Sample Input 1

4 10

Sample Output 1

3

<var>3</var> power strips, each with <var>4</var> sockets, extend the socket into <var>10</var> empty sockets.

Sample Input 2

8 9

Sample Output 2

2

<var>2</var> power strips, each with <var>8</var> sockets, extend the socket into <var>15</var> empty sockets.

Sample Input 3

8 8

Sample Output 3

1


Score : <var>200</var> points

Problem Statement

It is November <var>18</var> now in Japan. By the way, <var>11</var> and <var>18</var> are adjacent Lucas numbers.

You are given an integer <var>N</var>. Find the <var>N</var>-th Lucas number.

Here, the <var>i</var>-th Lucas number <var>L_i</var> is defined as follows:

<var>L_0=2</var>

<var>L_1=1</var>

<var>L_i=L_{i-1}+L_{i-2} (i≥2)</var>

Constraints

<var>1≤N≤86</var>

It is guaranteed that the answer is less than <var>10^{18}</var>.

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

Input

Input is given from Standard Input in the following format:

<var>N</var>

Output

Print the <var>N</var>-th Lucas number.

Sample Input 1

5

Sample Output 1

11

<var>L_0=2</var>

<var>L_1=1</var>

<var>L_2=L_0+L_1=3</var>

<var>L_3=L_1+L_2=4</var>

<var>L_4=L_2+L_3=7</var>

<var>L_5=L_3+L_4=11</var>

Thus, the <var>5</var>-th Lucas number is <var>11</var>.

Sample Input 2

86

Sample Output 2

939587134549734843


Score : <var>200</var> points

Problem Statement

There is a grid of squares with <var>H</var> horizontal rows and <var>W</var> vertical columns.
The square at the <var>i</var>-th row from the top and the <var>j</var>-th column from the left is represented as <var>(i, j)</var>.
Each square is black or white.
The color of the square is given as an <var>H</var>-by-<var>W</var> matrix <var>(a_{i, j})</var>.
If <var>a_{i, j}</var> is ., the square <var>(i, j)</var> is white; if <var>a_{i, j}</var> is #, the square <var>(i, j)</var> is black.

Snuke is compressing this grid.
He will do so by repeatedly performing the following operation while there is a row or column that consists only of white squares:

Operation: choose any one row or column that consists only of white squares, remove it and delete the space between the rows or columns.

It can be shown that the final state of the grid is uniquely determined regardless of what row or column is chosen in each operation.
Find the final state of the grid.

Constraints

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

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

There is at least one black square in the whole grid.

Input

Input is given from Standard Input in the following format:

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

Output

Print the final state of the grid in the same format as input (without the numbers of rows and columns); see the samples for clarity.

Sample Input 1

4 4
##.#
....
##.#
.#.#

Sample Output 1

###
###
.##

The second row and the third column in the original grid will be removed.

Sample Input 2

3 3
#..
.#.
..#

Sample Output 2

#..
.#.
..#

As there is no row or column that consists only of white squares, no operation will be performed.

Sample Input 3

4 5
.....
.....
..#..
.....

Sample Output 3

#

Sample Input 4

7 6
......
....#.
.#....
..#...
..#...
......
.#..#.

Sample Output 4

..#
#..
.#.
.#.
#.#


Score: <var>100</var> points

Problem Statement

Takahashi the Jumbo will practice golf.

His objective is to get a carry distance that is a multiple of <var>K</var>, while he can only make a carry distance of between <var>A</var> and <var>B</var> (inclusive).

If he can achieve the objective, print OK; if he cannot, print NG.

Constraints

All values in input are integers.

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

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

Input

Input is given from Standard Input in the following format:

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

Output

If he can achieve the objective, print OK; if he cannot, print NG.

Sample Input 1

7
500 600

Sample Output 1

OK

Among the multiples of <var>7</var>, for example, <var>567</var> lies between <var>500</var> and <var>600</var>.

Sample Input 2

4
5 7

Sample Output 2

NG

No multiple of <var>4</var> lies between <var>5</var> and <var>7</var>.

Sample Input 3

1
11 11

Sample Output 3

OK


Score : <var>100</var> points

Problem Statement

You are given two integers <var>A</var> and <var>B</var> as the input. Output the value of <var>A + B</var>.

However, if <var>A + B</var> is <var>10</var> or greater, output error instead.

Constraints

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

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

Input

Input is given from Standard Input in the following format:

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

Output

If <var>A + B</var> is <var>10</var> or greater, print the string error (case-sensitive); otherwise, print the value of <var>A + B</var>.

Sample Input 1

6 3

Sample Output 1

9

Sample Input 2

6 4

Sample Output 2

error


Score : <var>300</var> points

Problem Statement

Takahashi, Nakahashi and Hikuhashi have integers <var>A</var>, <var>B</var> and <var>C</var>, respectively.
After repeating the following operation <var>K</var> times, find the integer Takahashi will get minus the integer Nakahashi will get:

Each of them simultaneously calculate the sum of the integers that the other two people have, then replace his own integer with the result.

However, if the absolute value of the answer exceeds <var>10^{18}</var>, print Unfair instead.

Constraints

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

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

All values in input are integers.

Input

Input is given from Standard Input in the following format:

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

Output

Print the integer Takahashi will get minus the integer Nakahashi will get, after repeating the following operation <var>K</var> times.
If the absolute value of the answer exceeds <var>10^{18}</var>, print Unfair instead.

Sample Input 1

1 2 3 1

Sample Output 1

1

After one operation, Takahashi, Nakahashi and Hikuhashi have <var>5</var>, <var>4</var> and <var>3</var>, respectively. We should print <var>5-4=1</var>.

Sample Input 2

2 3 2 0

Sample Output 2

-1

Sample Input 3

1000000000 1000000000 1000000000 1000000000000000000

Sample Output 3

0


Score : <var>200</var> points

Problem Statement

We have held a popularity poll for <var>N</var> items on sale. Item <var>i</var> received <var>A_i</var> votes.

From these <var>N</var> items, we will select <var>M</var> as popular items. However, we cannot select an item with less than <var>\dfrac{1}{4M}</var> of the total number of votes.

If <var>M</var> popular items can be selected, print Yes; otherwise, print No.

Constraints

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

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

<var>A_i</var> are distinct.

All values in input are integers.

Input

Input is given from Standard Input in the following format:

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

Output

If <var>M</var> popular items can be selected, print Yes; otherwise, print No.

Sample Input 1

4 1
5 4 2 1

Sample Output 1

Yes

There were <var>12</var> votes in total. The most popular item received <var>5</var> votes, and we can select it.

Sample Input 2

3 2
380 19 1

Sample Output 2

No

There were <var>400</var> votes in total. The second and third most popular items received less than <var>\dfrac{1}{4\times 2}</var> of the total number of votes, so we cannot select them. Thus, we cannot select two popular items.

Sample Input 3

12 3
4 56 78 901 2 345 67 890 123 45 6 789

Sample Output 3

Yes


Score : <var>200</var> points

Problem Statement

Takahashi is practicing shiritori alone again today.

Shiritori is a game as follows:

In the first turn, a player announces any one word.

In the subsequent turns, a player announces a word that satisfies the following conditions:

That word is not announced before.

The first character of that word is the same as the last character of the last word announced.

In this game, he is practicing to announce as many words as possible in ten seconds.

You are given the number of words Takahashi announced, <var>N</var>, and the <var>i</var>-th word he announced, <var>W_i</var>, for each <var>i</var>. Determine if the rules of shiritori was observed, that is, every word announced by him satisfied the conditions.

Constraints

<var>N</var> is an integer satisfying <var>2 \leq N \leq 100</var>.

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

Input

Input is given from Standard Input in the following format:

<var>N</var>
<var>W_1</var>
<var>W_2</var>
<var>:</var>
<var>W_N</var>

Output

If every word announced by Takahashi satisfied the conditions, print Yes; otherwise, print No.

Sample Input 1

4
hoge
english
hoge
enigma

Sample Output 1

No

As hoge is announced multiple times, the rules of shiritori was not observed.

Sample Input 2

9
basic
c
cpp
php
python
nadesico
ocaml
lua
assembly

Sample Output 2

Yes

Sample Input 3

8
a
aa
aaa
aaaa
aaaaa
aaaaaa
aaa
aaaaaaa

Sample Output 3

No

Sample Input 4

3
abc
arc
agc

Sample Output 4

No


Score: <var>100</var> points

Problem Statement

In AtCoder Kingdom, Gregorian calendar is used, and dates are written in the "year-month-day" order, or the "month-day" order without the year.

For example, May <var>3</var>, <var>2018</var> is written as <var>2018</var>-<var>5</var>-<var>3</var>, or <var>5</var>-<var>3</var> without the year.

In this country, a date is called Takahashi when the month and the day are equal as numbers. For example, <var>5</var>-<var>5</var> is Takahashi.

How many days from <var>2018</var>-<var>1</var>-<var>1</var> through <var>2018</var>-<var>a</var>-<var>b</var> are Takahashi?

Constraints

<var>a</var> is an integer between <var>1</var> and <var>12</var> (inclusive).

<var>b</var> is an integer between <var>1</var> and <var>31</var> (inclusive).

<var>2018</var>-<var>a</var>-<var>b</var> is a valid date in Gregorian calendar.

Input

Input is given from Standard Input in the following format:

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

Output

Print the number of days from <var>2018</var>-<var>1</var>-<var>1</var> through <var>2018</var>-<var>a</var>-<var>b</var> that are Takahashi.

Sample Input 1

5 5

Sample Output 1

5

There are five days that are Takahashi: <var>1</var>-<var>1</var>, <var>2</var>-<var>2</var>, <var>3</var>-<var>3</var>, <var>4</var>-<var>4</var> and <var>5</var>-<var>5</var>.

Sample Input 2

2 1

Sample Output 2

1

There is only one day that is Takahashi: <var>1</var>-<var>1</var>.

Sample Input 3

11 30

Sample Output 3

11

There are eleven days that are Takahashi: <var>1</var>-<var>1</var>, <var>2</var>-<var>2</var>, <var>3</var>-<var>3</var>, <var>4</var>-<var>4</var>, <var>5</var>-<var>5</var>, <var>6</var>-<var>6</var>, <var>7</var>-<var>7</var>, <var>8</var>-<var>8</var>, <var>9</var>-<var>9</var>, <var>10</var>-<var>10</var> and <var>11</var>-<var>11</var>.


Score : <var>300</var> points

Problem Statement

There is a rectangle in a coordinate plane. The coordinates of the four vertices are <var>(0,0)</var>, <var>(W,0)</var>, <var>(W,H)</var>, and <var>(0,H)</var>.
You are given a point <var>(x,y)</var> which is within the rectangle or on its border. We will draw a straight line passing through <var>(x,y)</var> to cut the rectangle into two parts. Find the maximum possible area of the part whose area is not larger than that of the other. Additionally, determine if there are multiple ways to cut the rectangle and achieve that maximum.

Constraints

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

<var>0\leq x\leq W</var>

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

All values in input are integers.

Input

Input is given from Standard Input in the following format:

<var>W</var> <var>H</var> <var>x</var> <var>y</var>

Output

Print the maximum possible area of the part whose area is not larger than that of the other, followed by 1 if there are multiple ways to cut the rectangle and achieve that maximum, and 0 otherwise.

The area printed will be judged correct when its absolute or relative error is at most <var>10^{-9}</var>.

Sample Input 1

2 3 1 2

Sample Output 1

3.000000 0

The line <var>x=1</var> gives the optimal cut, and no other line does.

Sample Input 2

2 2 1 1

Sample Output 2

2.000000 1


Score : <var>300</var> points

Problem Statement

You are given three integers <var>A</var>, <var>B</var> and <var>C</var>. Find the minimum number of operations required to make <var>A</var>, <var>B</var> and <var>C</var> all equal by repeatedly performing the following two kinds of operations in any order:

Choose two among <var>A</var>, <var>B</var> and <var>C</var>, then increase both by <var>1</var>.

Choose one among <var>A</var>, <var>B</var> and <var>C</var>, then increase it by <var>2</var>.

It can be proved that we can always make <var>A</var>, <var>B</var> and <var>C</var> all equal by repeatedly performing these operations.

Constraints

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

All values in input are integers.

Input

Input is given from Standard Input in the following format:

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

Output

Print the minimum number of operations required to make <var>A</var>, <var>B</var> and <var>C</var> all equal.

Sample Input 1

2 5 4

Sample Output 1

2

We can make <var>A</var>, <var>B</var> and <var>C</var> all equal by the following operations:

Increase <var>A</var> and <var>C</var> by <var>1</var>. Now, <var>A</var>, <var>B</var>, <var>C</var> are <var>3</var>, <var>5</var>, <var>5</var>, respectively.

Increase <var>A</var> by <var>2</var>. Now, <var>A</var>, <var>B</var>, <var>C</var> are <var>5</var>, <var>5</var>, <var>5</var>, respectively.

Sample Input 2

2 6 3

Sample Output 2

5

Sample Input 3

31 41 5

Sample Output 3

23


Score : <var>100</var> points

Problem Statement

Given is an integer <var>x</var> that is greater than or equal to <var>0</var>, and less than or equal to <var>1</var>.
Output <var>1</var> if <var>x</var> is equal to <var>0</var>, or <var>0</var> if <var>x</var> is equal to <var>1</var>.

Constraints

<var>0 \leq x \leq 1</var>

<var>x</var> is an integer

Input

Input is given from Standard Input in the following format:

<var>x</var>

Output

Print <var>1</var> if <var>x</var> is equal to <var>0</var>, or <var>0</var> if <var>x</var> is equal to <var>1</var>.

Sample Input 1

1

Sample Output 1

0

Sample Input 2

0

Sample Output 2

1


Score : <var>200</var> points

Problem Statement

We have a permutation <var>p</var> = {<var>p_1,\ p_2,\ ...,\ p_n</var>} of {<var>1,\ 2,\ ...,\ n</var>}.

Print the number of elements <var>p_i</var> (<var>1 < i < n</var>) that satisfy the following condition:

<var>p_i</var> is the second smallest number among the three numbers <var>p_{i - 1}</var>, <var>p_i</var>, and <var>p_{i + 1}</var>.

Constraints

All values in input are integers.

<var>3 \leq n \leq 20</var>

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

Input

Input is given from Standard Input in the following format:

<var>n</var>
<var>p_1</var> <var>p_2</var> <var>...</var> <var>p_n</var>

Output

Print the number of elements <var>p_i</var> (<var>1 < i < n</var>) that satisfy the condition.

Sample Input 1

5
1 3 5 4 2

Sample Output 1

2

<var>p_2 = 3</var> is the second smallest number among <var>p_1 = 1</var>, <var>p_2 = 3</var>, and <var>p_3 = 5</var>. Also, <var>p_4 = 4</var> is the second smallest number among <var>p_3 = 5</var>, <var>p_4 = 4</var>, and <var>p_5 = 2</var>. These two elements satisfy the condition.

Sample Input 2

9
9 6 3 2 5 8 7 4 1

Sample Output 2

5


Score : <var>200</var> points

Problem Statement

There are some animals in a garden. Each of them is a crane with two legs or a turtle with four legs.

Takahashi says: "there are <var>X</var> animals in total in the garden, and they have <var>Y</var> legs in total." Determine whether there is a combination of numbers of cranes and turtles in which this statement is correct.

Constraints

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

<var>1 \leq Y \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>

Output

If there is a combination of numbers of cranes and turtles in which the statement is correct, print Yes; otherwise, print No.

Sample Input 1

3 8

Sample Output 1

Yes

The statement "there are <var>3</var> animals in total in the garden, and they have <var>8</var> legs in total" is correct if there are two cranes and one turtle. Thus, there is a combination of numbers of cranes and turtles in which the statement is correct.

Sample Input 2

2 100

Sample Output 2

No

There is no combination of numbers of cranes and turtles in which this statement is correct.

Sample Input 3

1 2

Sample Output 3

Yes

We also consider the case in which there are only cranes or only turtles.


Score : <var>200</var> points

Problem Statement

Given is a string <var>S</var>. Replace every character in <var>S</var> with x and print the result.

Constraints

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

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

Input

Input is given from Standard Input in the following format:

<var>S</var>

Output

Replace every character in <var>S</var> with x and print the result.

Sample Input 1

sardine

Sample Output 1

xxxxxxx

Replacing every character in <var>S</var> with x results in xxxxxxx.

Sample Input 2

xxxx

Sample Output 2

xxxx

Sample Input 3

gone

Sample Output 3

xxxx


Score : <var>300</var> points

Problem Statement

How many integer sequences <var>A_1,A_2,\ldots,A_N</var> of length <var>N</var> satisfy all of the following conditions?

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

There exists some <var>i</var> such that <var>A_i=0</var> holds.

There exists some <var>i</var> such that <var>A_i=9</var> holds.

The answer can be very large, so output it modulo <var>10^9 + 7</var>.

Constraints

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

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

Input

Input is given from Standard Input in the following format:

<var>N</var>

Output

Print the answer modulo <var>10^9 + 7</var>.

Sample Input 1

2

Sample Output 1

2

Two sequences <var>\{0,9\}</var> and <var>\{9,0\}</var> satisfy all conditions.

Sample Input 2

1

Sample Output 2

0

Sample Input 3

869121

Sample Output 3

2511445


Score : <var>100</var> points

Problem Statement

There are a total of <var>A + B</var> cats and dogs.
Among them, <var>A</var> are known to be cats, but the remaining <var>B</var> are not known to be either cats or dogs.

Determine if it is possible that there are exactly <var>X</var> cats among these <var>A + B</var> animals.

Constraints

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

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

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

Output

If it is possible that there are exactly <var>X</var> cats, print YES; if it is impossible, print NO.

Sample Input 1

3 5 4

Sample Output 1

YES

If there are one cat and four dogs among the <var>B = 5</var> animals, there are <var>X = 4</var> cats in total.

Sample Input 2

2 2 6

Sample Output 2

NO

Even if all of the <var>B = 2</var> animals are cats, there are less than <var>X = 6</var> cats in total.

Sample Input 3

5 3 2

Sample Output 3

NO

Even if all of the <var>B = 3</var> animals are dogs, there are more than <var>X = 2</var> cats in total.


Score : <var>100</var> points

Problem Statement

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

Takahashi chooses an integer <var>a</var> from the positive integers not greater than <var>N</var> with equal probability.

Find the probability that <var>a</var> is odd.

Constraints

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

Input

Input is given from Standard Input in the following format:

<var>N</var>

Output

Print the probability that <var>a</var> is odd.
Your output will be considered correct when its absolute or relative error from the judge's output is at most <var>10^{-6}</var>.

Sample Input 1

4

Sample Output 1

0.5000000000

There are four positive integers not greater than <var>4</var>: <var>1</var>, <var>2</var>, <var>3</var>, and <var>4</var>. Among them, we have two odd numbers: <var>1</var> and <var>3</var>. Thus, the answer is <var>\frac{2}{4} = 0.5</var>.

Sample Input 2

5

Sample Output 2

0.6000000000

Sample Input 3

1

Sample Output 3

1.0000000000


Score : <var>400</var> points

Problem Statement

Takahashi is going to buy <var>N</var> items one by one.

The price of the <var>i</var>-th item he buys is <var>A_i</var> yen (the currency of Japan).

He has <var>M</var> discount tickets, and he can use any number of them when buying an item.

If <var>Y</var> tickets are used when buying an item priced <var>X</var> yen, he can get the item for <var>\frac{X}{2^Y}</var> (rounded down to the nearest integer) yen.

What is the minimum amount of money required to buy all the items?

Constraints

All values in input are integers.

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

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

Input

Input is given from Standard Input in the following format:

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

Output

Print the minimum amount of money required to buy all the items.

Sample Input 1

3 3
2 13 8

Sample Output 1

9

We can buy all the items for <var>9</var> yen, as follows:

Buy the <var>1</var>-st item for <var>2</var> yen without tickets.

Buy the <var>2</var>-nd item for <var>3</var> yen with <var>2</var> tickets.

Buy the <var>3</var>-rd item for <var>4</var> yen with <var>1</var> ticket.

Sample Input 2

4 4
1 9 3 5

Sample Output 2

6

Sample Input 3

1 100000
1000000000

Sample Output 3

0

We can buy the item priced <var>1000000000</var> yen for <var>0</var> yen with <var>100000</var> tickets.

Sample Input 4

10 1
1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000

Sample Output 4

9500000000


Score : <var>300</var> points

Problem Statement

When <var>l</var> is an odd number, the median of <var>l</var> numbers <var>a_1, a_2, ..., a_l</var> is the <var>(\frac{l+1}{2})</var>-th largest value among <var>a_1, a_2, ..., a_l</var>.

You are given <var>N</var> numbers <var>X_1, X_2, ..., X_N</var>, where <var>N</var> is an even number.
For each <var>i = 1, 2, ..., N</var>, let the median of <var>X_1, X_2, ..., X_N</var> excluding <var>X_i</var>, that is, the median of <var>X_1, X_2, ..., X_{i-1}, X_{i+1}, ..., X_N</var> be <var>B_i</var>.

Find <var>B_i</var> for each <var>i = 1, 2, ..., N</var>.

Constraints

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

<var>N</var> is even.

<var>1 \leq X_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>X_1</var> <var>X_2</var> ... <var>X_N</var>

Output

Print <var>N</var> lines.
The <var>i</var>-th line should contain <var>B_i</var>.

Sample Input 1

4
2 4 4 3

Sample Output 1

4
3
3
4

Since the median of <var>X_2, X_3, X_4</var> is <var>4</var>, <var>B_1 = 4</var>.

Since the median of <var>X_1, X_3, X_4</var> is <var>3</var>, <var>B_2 = 3</var>.

Since the median of <var>X_1, X_2, X_4</var> is <var>3</var>, <var>B_3 = 3</var>.

Since the median of <var>X_1, X_2, X_3</var> is <var>4</var>, <var>B_4 = 4</var>.

Sample Input 2

2
1 2

Sample Output 2

2
1

Sample Input 3

6
5 5 4 4 3 3

Sample Output 3

4
4
4
4
4
4


Score : <var>200</var> points

Problem Statement

There are <var>N</var> participants in the CODE FESTIVAL 2016 Qualification contests. The participants are either students in Japan, students from overseas, or neither of these.

Only Japanese students or overseas students can pass the Qualification contests. The students pass when they satisfy the conditions listed below, from the top rank down. Participants who are not students cannot pass the Qualification contests.

A Japanese student passes the Qualification contests if the number of the participants who have already definitively passed is currently fewer than <var>A+B</var>.

An overseas student passes the Qualification contests if the number of the participants who have already definitively passed is currently fewer than <var>A+B</var> and the student ranks <var>B</var>-th or above among all overseas students.

A string <var>S</var> is assigned indicating attributes of all participants. If the <var>i</var>-th character of string <var>S</var> is a, this means the participant ranked <var>i</var>-th in the Qualification contests is a Japanese student; b means the participant ranked <var>i</var>-th is an overseas student; and c means the participant ranked <var>i</var>-th is neither of these.

Write a program that outputs for all the participants in descending rank either Yes if they passed the Qualification contests or No if they did not pass.

Constraints

<var>1≦N,A,B≦100000</var>

<var>A+B≦N</var>

<var>S</var> is <var>N</var> characters long.

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

Input

Inputs are provided from Standard Input in the following form.

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

Output

Output <var>N</var> lines. On the <var>i</var>-th line, output Yes if the <var>i</var>-th participant passed the Qualification contests or No if that participant did not pass.

Sample Input 1

10 2 3
abccabaabb

Sample Output 1

Yes
Yes
No
No
Yes
Yes
Yes
No
No
No

The first, second, fifth, sixth, and seventh participants pass the Qualification contests.

Sample Input 2

12 5 2
cabbabaacaba

Sample Output 2

No
Yes
Yes
Yes
Yes
No
Yes
Yes
No
Yes
No
No

The sixth participant is third among overseas students and thus does not pass the Qualification contests.

Sample Input 3

5 2 2
ccccc

Sample Output 3

No
No
No
No
No


Problem Statement

You are given two integers <var>a</var> and <var>b</var> (<var>a≤b</var>). Determine if the product of the integers <var>a</var>, <var>a+1</var>, <var>…</var>, <var>b</var> is positive, negative or zero.

Constraints

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

<var>-10^9≤a≤b≤10^9</var>

Partial Score

In test cases worth <var>100</var> points, <var>-10≤a≤b≤10</var>.

Input

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

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

Output

If the product is positive, print Positive. If it is negative, print Negative. If it is zero, print Zero.

Sample Input 1

1 3

Sample Output 1

Positive

<var>1×2×3=6</var> is positive.

Sample Input 2

-3 -1

Sample Output 2

Negative

<var>(-3)×(-2)×(-1)=-6</var> is negative.

Sample Input 3

-1 1

Sample Output 3

Zero

<var>(-1)×0×1=0</var>.


Score : <var>300</var> points

Problem Statement

AtCoDeer the deer is going on a trip in a two-dimensional plane.
In his plan, he will depart from point <var>(0, 0)</var> at time <var>0</var>, then for each <var>i</var> between <var>1</var> and <var>N</var> (inclusive), he will visit point <var>(x_i,y_i)</var> at time <var>t_i</var>.

If AtCoDeer is at point <var>(x, y)</var> at time <var>t</var>, he can be at one of the following points at time <var>t+1</var>: <var>(x+1,y)</var>, <var>(x-1,y)</var>, <var>(x,y+1)</var> and <var>(x,y-1)</var>.
Note that he cannot stay at his place.
Determine whether he can carry out his plan.

Constraints

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

<var>0</var> <var>≤</var> <var>x_i</var> <var>≤</var> <var>10^5</var>

<var>0</var> <var>≤</var> <var>y_i</var> <var>≤</var> <var>10^5</var>

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

<var>t_i</var> <var><</var> <var>t_{i+1}</var> (<var>1</var> <var>≤</var> <var>i</var> <var>≤</var> <var>N-1</var>)

All input values are integers.

Input

Input is given from Standard Input in the following format:

<var>N</var>
<var>t_1</var> <var>x_1</var> <var>y_1</var>
<var>t_2</var> <var>x_2</var> <var>y_2</var>
<var>:</var>
<var>t_N</var> <var>x_N</var> <var>y_N</var>

Output

If AtCoDeer can carry out his plan, print Yes; if he cannot, print No.

Sample Input 1

2
3 1 2
6 1 1

Sample Output 1

Yes

For example, he can travel as follows: <var>(0,0)</var>, <var>(0,1)</var>, <var>(1,1)</var>, <var>(1,2)</var>, <var>(1,1)</var>, <var>(1,0)</var>, then <var>(1,1)</var>.

Sample Input 2

1
2 100 100

Sample Output 2

No

It is impossible to be at <var>(100,100)</var> two seconds after being at <var>(0,0)</var>.

Sample Input 3

2
5 1 1
100 1 1

Sample Output 3

No


Score: <var>200</var> points

Problem Statement

Today, the memorable AtCoder Beginner Contest 100 takes place. On this occasion, Takahashi would like to give an integer to Ringo.

As the name of the contest is AtCoder Beginner Contest 100, Ringo would be happy if he is given a positive integer that can be divided by <var>100</var> exactly <var>D</var> times.

Find the <var>N</var>-th smallest integer that would make Ringo happy.

Constraints

<var>D</var> is <var>0</var>, <var>1</var> or <var>2</var>.

<var>N</var> is an integer between <var>1</var> and <var>100</var> (inclusive).

Input

Input is given from Standard Input in the following format:

<var>D</var> <var>N</var>

Output

Print the <var>N</var>-th smallest integer that can be divided by <var>100</var> exactly <var>D</var> times.

Sample Input 1

0 5

Sample Output 1

5

The integers that can be divided by <var>100</var> exactly <var>0</var> times (that is, not divisible by <var>100</var>) are as follows: <var>1</var>, <var>2</var>, <var>3</var>, <var>4</var>, <var>5</var>, <var>6</var>, <var>7</var>, ...

Thus, the <var>5</var>-th smallest integer that would make Ringo happy is <var>5</var>.

Sample Input 2

1 11

Sample Output 2

1100

The integers that can be divided by <var>100</var> exactly once are as follows: <var>100</var>, <var>200</var>, <var>300</var>, <var>400</var>, <var>500</var>, <var>600</var>, <var>700</var>, <var>800</var>, <var>900</var>, <var>1 \ 000</var>, <var>1 \ 100</var>, ...

Thus, the integer we are seeking is <var>1 \ 100</var>.

Sample Input 3

2 85

Sample Output 3

850000

The integers that can be divided by <var>100</var> exactly twice are as follows: <var>10 \ 000</var>, <var>20 \ 000</var>, <var>30 \ 000</var>, ...

Thus, the integer we are seeking is <var>850 \ 000</var>.


Score : <var>100</var> points

Problem Statement

We have two bottles for holding water.

Bottle <var>1</var> can hold up to <var>A</var> milliliters of water, and now it contains <var>B</var> milliliters of water.

Bottle <var>2</var> contains <var>C</var> milliliters of water.

We will transfer water from Bottle <var>2</var> to Bottle <var>1</var> as much as possible.

How much amount of water will remain in Bottle <var>2</var>?

Constraints

All values in input are integers.

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

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

Input

Input is given from Standard Input in the following format:

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

Output

Print the integer representing the amount of water, in milliliters, that will remain in Bottle <var>2</var>.

Sample Input 1

6 4 3

Sample Output 1

1

We will transfer two milliliters of water from Bottle <var>2</var> to Bottle <var>1</var>, and one milliliter of water will remain in Bottle <var>2</var>.

Sample Input 2

8 3 9

Sample Output 2

4

Sample Input 3

12 3 7

Sample Output 3

0


Score: <var>300</var> points

Problem Statement

Mr. Infinity has a string <var>S</var> consisting of digits from 1 to 9. Each time the date changes, this string changes as follows:

Each occurrence of 2 in <var>S</var> is replaced with 22. Similarly, each 3 becomes 333, 4 becomes 4444, 5 becomes 55555, 6 becomes 666666, 7 becomes 7777777, 8 becomes 88888888 and 9 becomes 999999999. 1 remains as 1.

For example, if <var>S</var> is 1324, it becomes 1333224444 the next day, and it becomes 133333333322224444444444444444 the day after next.
You are interested in what the string looks like after <var>5 \times 10^{15}</var> days. What is the <var>K</var>-th character from the left in the string after <var>5 \times 10^{15}</var> days?

Constraints

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

<var>K</var> is an integer between <var>1</var> and <var>10^{18}</var> (inclusive).

The length of the string after <var>5 \times 10^{15}</var> days is at least <var>K</var>.

Input

Input is given from Standard Input in the following format:

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

Output

Print the <var>K</var>-th character from the left in Mr. Infinity's string after <var>5 \times 10^{15}</var> days.

Sample Input 1

1214
4

Sample Output 1

2

The string <var>S</var> changes as follows:

Now: 1214

After one day: 12214444

After two days: 1222214444444444444444

After three days: 12222222214444444444444444444444444444444444444444444444444444444444444444

The first five characters in the string after <var>5 \times 10^{15}</var> days is 12222. As <var>K=4</var>, we should print the fourth character, 2.

Sample Input 2

3
157

Sample Output 2

3

The initial string is 3. The string after <var>5 \times 10^{15}</var> days consists only of 3.

Sample Input 3

299792458
9460730472580800

Sample Output 3

2


Score : <var>100</var> points

Problem Statement

This contest, AtCoder Beginner Contest, is abbreviated as ABC.

When we refer to a specific round of ABC, a three-digit number is appended after ABC. For example, ABC680 is the 680th round of ABC.

What is the abbreviation for the <var>N</var>-th round of ABC? Write a program to output the answer.

Constraints

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

Input

Input is given from Standard Input in the following format:

<var>N</var>

Output

Print the abbreviation for the <var>N</var>-th round of ABC.

Sample Input 1

100

Sample Output 1

ABC100

The 100th round of ABC is ABC100.

Sample Input 2

425

Sample Output 2

ABC425

Sample Input 3

999

Sample Output 3

ABC999


Score : <var>200</var> points

Problem Statement

We have sticks numbered <var>1, \cdots, N</var>. The length of Stick <var>i</var> <var>(1 \leq i \leq N)</var> is <var>L_i</var>.

In how many ways can we choose three of the sticks with different lengths that can form a triangle?

That is, find the number of triples of integers <var>(i, j, k)</var> <var>(1 \leq i < j < k \leq N)</var> that satisfy both of the following conditions:

<var>L_i</var>, <var>L_j</var>, and <var>L_k</var> are all different.

There exists a triangle whose sides have lengths <var>L_i</var>, <var>L_j</var>, and <var>L_k</var>.

Constraints

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

<var>1 \leq L_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>L_1</var> <var>L_2</var> <var>\cdots</var> <var>L_N</var>

Output

Print the number of ways to choose three of the sticks with different lengths that can form a triangle.

Sample Input 1

5
4 4 9 7 5

Sample Output 1

5

The following five triples <var>(i, j, k)</var> satisfy the conditions: <var>(1, 3, 4)</var>, <var>(1, 4, 5)</var>, <var>(2, 3, 4)</var>, <var>(2, 4, 5)</var>, and <var>(3, 4, 5)</var>.

Sample Input 2

6
4 5 4 3 3 5

Sample Output 2

8

We have two sticks for each of the lengths <var>3</var>, <var>4</var>, and <var>5</var>. To satisfy the first condition, we have to choose one from each length.

There is a triangle whose sides have lengths <var>3</var>, <var>4</var>, and <var>5</var>, so we have <var>2 ^ 3 = 8</var> triples <var>(i, j, k)</var> that satisfy the conditions.

Sample Input 3

10
9 4 6 1 9 6 10 6 6 8

Sample Output 3

39

Sample Input 4

2
1 1

Sample Output 4

0

No triple <var>(i, j, k)</var> satisfies <var>1 \leq i < j < k \leq N</var>, so we should print <var>0</var>.


Score : <var>300</var> points

Problem Statement

We have two desks: A and B. Desk A has a vertical stack of <var>N</var> books on it, and Desk B similarly has <var>M</var> books on it.

It takes us <var>A_i</var> minutes to read the <var>i</var>-th book from the top on Desk A <var>(1 \leq i \leq N)</var>, and <var>B_i</var> minutes to read the <var>i</var>-th book from the top on Desk B <var>(1 \leq i \leq M)</var>.

Consider the following action:

Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk.

How many books can we read at most by repeating this action so that it takes us at most <var>K</var> minutes in total? We ignore the time it takes to do anything other than reading.

Constraints

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

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

<var>1 \leq A_i, 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>M</var> <var>K</var>
<var>A_1</var> <var>A_2</var> <var>\ldots</var> <var>A_N</var>
<var>B_1</var> <var>B_2</var> <var>\ldots</var> <var>B_M</var>

Output

Print an integer representing the maximum number of books that can be read.

Sample Input 1

3 4 240
60 90 120
80 150 80 150

Sample Output 1

3

In this case, it takes us <var>60</var>, <var>90</var>, <var>120</var> minutes to read the <var>1</var>-st, <var>2</var>-nd, <var>3</var>-rd books from the top on Desk A, and <var>80</var>, <var>150</var>, <var>80</var>, <var>150</var> minutes to read the <var>1</var>-st, <var>2</var>-nd, <var>3</var>-rd, <var>4</var>-th books from the top on Desk B, respectively.

We can read three books in <var>230</var> minutes, as shown below, and this is the maximum number of books we can read within <var>240</var> minutes.

Read the topmost book on Desk A in <var>60</var> minutes, and remove that book from the desk.

Read the topmost book on Desk B in <var>80</var> minutes, and remove that book from the desk.

Read the topmost book on Desk A in <var>90</var> minutes, and remove that book from the desk.

Sample Input 2

3 4 730
60 90 120
80 150 80 150

Sample Output 2

7

Sample Input 3

5 4 1
1000000000 1000000000 1000000000 1000000000 1000000000
1000000000 1000000000 1000000000 1000000000

Sample Output 3

0

Watch out for integer overflows.


Score : <var>300</var> points

Problem Statement

You are given four integers <var>A</var>, <var>B</var>, <var>C</var>, and <var>D</var>. Find the number of integers between <var>A</var> and <var>B</var> (inclusive) that can be evenly divided by neither <var>C</var> nor <var>D</var>.

Constraints

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

<var>1\leq C,D\leq 10^9</var>

All values in input are integers.

Input

Input is given from Standard Input in the following format:

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

Output

Print the number of integers between <var>A</var> and <var>B</var> (inclusive) that can be evenly divided by neither <var>C</var> nor <var>D</var>.

Sample Input 1

4 9 2 3

Sample Output 1

2

<var>5</var> and <var>7</var> satisfy the condition.

Sample Input 2

10 40 6 8

Sample Output 2

23

Sample Input 3

314159265358979323 846264338327950288 419716939 937510582

Sample Output 3

532105071133627368


Score : <var>200</var> points

Problem Statement

Takahashi has <var>N</var> blue cards and <var>M</var> red cards.
A string is written on each card. The string written on the <var>i</var>-th blue card is <var>s_i</var>, and the string written on the <var>i</var>-th red card is <var>t_i</var>.

Takahashi will now announce a string, and then check every card. Each time he finds a blue card with the string announced by him, he will earn <var>1</var> yen (the currency of Japan); each time he finds a red card with that string, he will lose <var>1</var> yen.

Here, we only consider the case where the string announced by Takahashi and the string on the card are exactly the same. For example, if he announces atcoder, he will not earn money even if there are blue cards with atcoderr, atcode, btcoder, and so on. (On the other hand, he will not lose money even if there are red cards with such strings, either.)

At most how much can he earn on balance?

Note that the same string may be written on multiple cards.

Constraints

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

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

<var>s_1, s_2, ..., s_N, t_1, t_2, ..., t_M</var> are all strings of lengths between <var>1</var> and <var>10</var> (inclusive) consisting of lowercase English letters.

Input

Input is given from Standard Input in the following format:

<var>N</var>
<var>s_1</var>
<var>s_2</var>
<var>:</var>
<var>s_N</var>
<var>M</var>
<var>t_1</var>
<var>t_2</var>
<var>:</var>
<var>t_M</var>

Output

If Takahashi can earn at most <var>X</var> yen on balance, print <var>X</var>.

Sample Input 1

3
apple
orange
apple
1
grape

Sample Output 1

2

He can earn <var>2</var> yen by announcing apple.

Sample Input 2

3
apple
orange
apple
5
apple
apple
apple
apple
apple

Sample Output 2

1

If he announces apple, he will lose <var>3</var> yen. If he announces orange, he can earn <var>1</var> yen.

Sample Input 3

1
voldemort
10
voldemort
voldemort
voldemort
voldemort
voldemort
voldemort
voldemort
voldemort
voldemort
voldemort

Sample Output 3

0

If he announces voldemort, he will lose <var>9</var> yen. If he announces orange, for example, he can avoid losing a yen.

Sample Input 4

6
red
red
blue
yellow
yellow
red
5
red
red
yellow
green
blue

Sample Output 4

1


Score : <var>100</var> points

Problem Statement

You are given two integers <var>A</var> and <var>B</var>.
Find the largest value among <var>A+B</var>, <var>A-B</var> and <var>A \times B</var>.

Constraints

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

All values in input are integers.

Input

Input is given from Standard Input in the following format:

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

Output

Print the largest value among <var>A+B</var>, <var>A-B</var> and <var>A \times B</var>.

Sample Input 1

3 1

Sample Output 1

4

<var>3+1=4</var>, <var>3-1=2</var> and <var>3 \times 1=3</var>. The largest among them is <var>4</var>.

Sample Input 2

4 -2

Sample Output 2

6

The largest is <var>4 - (-2) = 6</var>.

Sample Input 3

0 0

Sample Output 3

0


Score : <var>100</var> points

Problem Statement

Takahashi has <var>K</var> <var>500</var>-yen coins. (Yen is the currency of Japan.)
If these coins add up to <var>X</var> yen or more, print Yes; otherwise, print No.

Constraints

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

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

Input

Input is given from Standard Input in the following format:

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

Output

If the coins add up to <var>X</var> yen or more, print Yes; otherwise, print No.

Sample Input 1

2 900

Sample Output 1

Yes

Two <var>500</var>-yen coins add up to <var>1000</var> yen, which is not less than <var>X = 900</var> yen.

Sample Input 2

1 501

Sample Output 2

No

One <var>500</var>-yen coin is worth <var>500</var> yen, which is less than <var>X = 501</var> yen.

Sample Input 3

4 2000

Sample Output 3

Yes

Four <var>500</var>-yen coins add up to <var>2000</var> yen, which is not less than <var>X = 2000</var> yen.


Score : <var>100</var> points

Problem Statement

Snuke lives at position <var>x</var> on a number line.
On this line, there are two stores <var>A</var> and <var>B</var>, respectively at position <var>a</var> and <var>b</var>, that offer food for delivery.

Snuke decided to get food delivery from the closer of stores <var>A</var> and <var>B</var>.
Find out which store is closer to Snuke's residence.

Here, the distance between two points <var>s</var> and <var>t</var> on a number line is represented by <var>|s-t|</var>.

Constraints

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

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

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

<var>x, a</var> and <var>b</var> are pairwise distinct.

The distances between Snuke's residence and stores <var>A</var> and <var>B</var> are different.

Input

Input is given from Standard Input in the following format:

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

Output

If store <var>A</var> is closer, print A; if store <var>B</var> is closer, print B.

Sample Input 1

5 2 7

Sample Output 1

B

The distances between Snuke's residence and stores <var>A</var> and <var>B</var> are <var>3</var> and <var>2</var>, respectively.
Since store <var>B</var> is closer, print B.

Sample Input 2

1 999 1000

Sample Output 2

A


Score : <var>400</var> points

Problem Statement

There are <var>N</var> one-off jobs available. If you take the <var>i</var>-th job and complete it, you will earn the reward of <var>B_i</var> after <var>A_i</var> days from the day you do it.

You can take and complete at most one of these jobs in a day.

However, you cannot retake a job that you have already done.

Find the maximum total reward that you can earn no later than <var>M</var> days from today.

You can already start working today.

Constraints

All values in input are integers.

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

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

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

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

Input

Input is given from Standard Input in the following format:

<var>N</var> <var>M</var>
<var>A_1</var> <var>B_1</var>
<var>A_2</var> <var>B_2</var>
<var>\vdots</var>
<var>A_N</var> <var>B_N</var>

Output

Print the maximum total reward that you can earn no later than <var>M</var> days from today.

Sample Input 1

3 4
4 3
4 1
2 2

Sample Output 1

5

You can earn the total reward of <var>5</var> by taking the jobs as follows:

Take and complete the first job today. You will earn the reward of <var>3</var> after four days from today.

Take and complete the third job tomorrow. You will earn the reward of <var>2</var> after two days from tomorrow, that is, after three days from today.

Sample Input 2

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

Sample Output 2

10

Sample Input 3

1 1
2 1

Sample Output 3

0


Score: <var>200</var> points

Problem Statement

A country decides to build a palace.

In this country, the average temperature of a point at an elevation of <var>x</var> meters is <var>T-x \times 0.006</var> degrees Celsius.

There are <var>N</var> places proposed for the place. The elevation of Place <var>i</var> is <var>H_i</var> meters.

Among them, Princess Joisino orders you to select the place whose average temperature is the closest to <var>A</var> degrees Celsius, and build the palace there.

Print the index of the place where the palace should be built.

It is guaranteed that the solution is unique.

Constraints

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

<var>0 \leq T \leq 50</var>

<var>-60 \leq A \leq T</var>

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

All values in input are integers.

The solution is unique.

Input

Input is given from Standard Input in the following format:

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

Output

Print the index of the place where the palace should be built.

Sample Input 1

2
12 5
1000 2000

Sample Output 1

1

The average temperature of Place <var>1</var> is <var>12-1000 \times 0.006=6</var> degrees Celsius.

The average temperature of Place <var>2</var> is <var>12-2000 \times 0.006=0</var> degrees Celsius.

Thus, the palace should be built at Place <var>1</var>.

Sample Input 2

3
21 -11
81234 94124 52141

Sample Output 2

3


Score : <var>300</var> points

Problem Statement

Given is a positive integer <var>L</var>.
Find the maximum possible volume of a rectangular cuboid whose sum of the dimensions (not necessarily integers) is <var>L</var>.

Constraints

<var>1 ≤ L ≤ 1000</var>

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

Input

Input is given from Standard Input in the following format:

<var>L</var>

Output

Print the maximum possible volume of a rectangular cuboid whose sum of the dimensions (not necessarily integers) is <var>L</var>.
Your output is considered correct if its absolute or relative error from our answer is at most <var>10^{-6}</var>.

Sample Input 1

3

Sample Output 1

1.000000000000

For example, a rectangular cuboid whose dimensions are <var>0.8</var>, <var>1</var>, and <var>1.2</var> has a volume of <var>0.96</var>.

On the other hand, if the dimensions are <var>1</var>, <var>1</var>, and <var>1</var>, the volume of the rectangular cuboid is <var>1</var>, which is greater.

Sample Input 2

999

Sample Output 2

36926037.000000000000


Score : <var>300</var> points

Problem Statement

We will call a string obtained by arranging the characters contained in a string <var>a</var> in some order, an anagram of <var>a</var>.

For example, greenbin is an anagram of beginner. As seen here, when the same character occurs multiple times, that character must be used that number of times.

Given are <var>N</var> strings <var>s_1, s_2, \ldots, s_N</var>. Each of these strings has a length of <var>10</var> and consists of lowercase English characters. Additionally, all of these strings are distinct. Find the number of pairs of integers <var>i, j</var> <var>(1 \leq i < j \leq N)</var> such that <var>s_i</var> is an anagram of <var>s_j</var>.

Constraints

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

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

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

<var>s_1, s_2, \ldots, s_N</var> are all distinct.

Input

Input is given from Standard Input in the following format:

<var>N</var>
<var>s_1</var>
<var>s_2</var>
<var>:</var>
<var>s_N</var>

Output

Print the number of pairs of integers <var>i, j</var> <var>(1 \leq i < j \leq N)</var> such that <var>s_i</var> is an anagram of <var>s_j</var>.

Sample Input 1

3
acornistnt
peanutbomb
constraint

Sample Output 1

1

<var>s_1 =</var> acornistnt is an anagram of <var>s_3 =</var> constraint. There are no other pairs <var>i, j</var> such that <var>s_i</var> is an anagram of <var>s_j</var>, so the answer is <var>1</var>.

Sample Input 2

2
oneplustwo
ninemodsix

Sample Output 2

0

If there is no pair <var>i, j</var> such that <var>s_i</var> is an anagram of <var>s_j</var>, print <var>0</var>.

Sample Input 3

5
abaaaaaaaa
oneplustwo
aaaaaaaaba
twoplusone
aaaabaaaaa

Sample Output 3

4

Note that the answer may not fit into a <var>32</var>-bit integer type, though we cannot put such a case here.


Score : <var>100</var> points

Problem Statement

Takahashi, who is <var>A</var> years old, is riding a Ferris wheel.

It costs <var>B</var> yen (<var>B</var> is an even number) to ride the Ferris wheel if you are <var>13</var> years old or older, but children between <var>6</var> and <var>12</var> years old (inclusive) can ride it for half the cost, and children who are <var>5</var> years old or younger are free of charge. (Yen is the currency of Japan.)

Find the cost of the Ferris wheel for Takahashi.

Constraints

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

<var>2 ≤ B ≤ 1000</var>

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

Input

Input is given from Standard Input in the following format:

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

Output

Print the cost of the Ferris wheel for Takahashi.

Sample Input 1

30 100

Sample Output 1

100

Takahashi is <var>30</var> years old now, and the cost of the Ferris wheel is <var>100</var> yen.

Sample Input 2

12 100

Sample Output 2

50

Takahashi is <var>12</var> years old, and the cost of the Ferris wheel is the half of <var>100</var> yen, that is, <var>50</var> yen.

Sample Input 3

0 100

Sample Output 3

0

Takahashi is <var>0</var> years old, and he can ride the Ferris wheel for free.


Score : <var>400</var> points

Problem Statement

Given is a positive integer <var>N</var>. Consider repeatedly applying the operation below on <var>N</var>:

First, choose a positive integer <var>z</var> satisfying all of the conditions below:

<var>z</var> can be represented as <var>z=p^e</var>, where <var>p</var> is a prime number and <var>e</var> is a positive integer;

<var>z</var> divides <var>N</var>;

<var>z</var> is different from all integers chosen in previous operations.

Then, replace <var>N</var> with <var>N/z</var>.

Find the maximum number of times the operation can be applied.

Constraints

All values in input are integers.

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

Input

Input is given from Standard Input in the following format:

<var>N</var>

Output

Print the maximum number of times the operation can be applied.

Sample Input 1

24

Sample Output 1

3

We can apply the operation three times by, for example, making the following choices:

Choose <var>z=2 (=2^1)</var>. (Now we have <var>N=12</var>.)

Choose <var>z=3 (=3^1)</var>. (Now we have <var>N=4</var>.)

Choose <var>z=4 (=2^2)</var>. (Now we have <var>N=1</var>.)

Sample Input 2

1

Sample Output 2

0

We cannot apply the operation at all.

Sample Input 3

64

Sample Output 3

3

We can apply the operation three times by, for example, making the following choices:

Choose <var>z=2 (=2^1)</var>. (Now we have <var>N=32</var>.)

Choose <var>z=4 (=2^2)</var>. (Now we have <var>N=8</var>.)

Choose <var>z=8 (=2^3)</var>. (Now we have <var>N=1</var>.)

Sample Input 4

1000000007

Sample Output 4

1

We can apply the operation once by, for example, making the following choice:

<var>z=1000000007 (=1000000007^1)</var>. (Now we have <var>N=1</var>.)

Sample Input 5

997764507000

Sample Output 5

7


Score : <var>300</var> points

Problem Statement

Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.

She is shopping, and now paying at the cashier.
Her total is <var>N</var> yen (the currency of Japan), thus she has to hand at least <var>N</var> yen to the cashier (and possibly receive the change).

However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.

Find the amount of money that she will hand to the cashier.

Constraints

<var> 1 ≦ N < 10000</var>

<var> 1 ≦ K < 10</var>

<var> 0 ≦ D_1 < D_2 < … < D_K≦9</var>

<var>\{D_1,D_2,...,D_K\} ≠ \{1,2,3,4,5,6,7,8,9\}</var>

Input

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

<var>N</var> <var>K</var>
<var>D_1</var> <var>D_2</var> … <var>D_K</var>

Output

Print the amount of money that Iroha will hand to the cashier.

Sample Input 1

1000 8
1 3 4 5 6 7 8 9

Sample Output 1

2000

She dislikes all digits except <var>0</var> and <var>2</var>.

The smallest integer equal to or greater than <var>N=1000</var> whose decimal notation contains only <var>0</var> and <var>2</var>, is <var>2000</var>.

Sample Input 2

9999 1
0

Sample Output 2

9999


Score : <var>300</var> points

Problem Statement

Find <var>\displaystyle{\sum_{a=1}^{K}\sum_{b=1}^{K}\sum_{c=1}^{K} \gcd(a,b,c)}</var>.

Here <var>\gcd(a,b,c)</var> denotes the greatest common divisor of <var>a</var>, <var>b</var>, and <var>c</var>.

Constraints

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

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

Input

Input is given from Standard Input in the following format:

<var>K</var>

Output

Print the value of <var>\displaystyle{\sum_{a=1}^{K}\sum_{b=1}^{K}\sum_{c=1}^{K} \gcd(a,b,c)}</var>.

Sample Input 1

2

Sample Output 1

9

<var>\gcd(1,1,1)+\gcd(1,1,2)+\gcd(1,2,1)+\gcd(1,2,2)</var>
<var>+\gcd(2,1,1)+\gcd(2,1,2)+\gcd(2,2,1)+\gcd(2,2,2)</var>
<var>=1+1+1+1+1+1+1+2=9</var>

Thus, the answer is <var>9</var>.

Sample Input 2

200

Sample Output 2

10813692


Score : <var>300</var> points

Problem Statement

A company has <var>N</var> members, who are assigned ID numbers <var>1, ..., N</var>.

Every member, except the member numbered <var>1</var>, has exactly one immediate boss with a smaller ID number.

When a person <var>X</var> is the immediate boss of a person <var>Y</var>, the person <var>Y</var> is said to be an immediate subordinate of the person <var>X</var>.

You are given the information that the immediate boss of the member numbered <var>i</var> is the member numbered <var>A_i</var>. For each member, find how many immediate subordinates it has.

Constraints

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

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

Input

Input is given from Standard Input in the following format:

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

Output

For each of the members numbered <var>1, 2, ..., N</var>, print the number of immediate subordinates it has, in its own line.

Sample Input 1

5
1 1 2 2

Sample Output 1

2
2
0
0
0

The member numbered <var>1</var> has two immediate subordinates: the members numbered <var>2</var> and <var>3</var>.

The member numbered <var>2</var> has two immediate subordinates: the members numbered <var>4</var> and <var>5</var>.

The members numbered <var>3</var>, <var>4</var>, and <var>5</var> do not have immediate subordinates.

Sample Input 2

10
1 1 1 1 1 1 1 1 1

Sample Output 2

9
0
0
0
0
0
0
0
0
0

Sample Input 3

7
1 2 3 4 5 6

Sample Output 3

1
1
1
1
1
1
0


Score : <var>100</var> points

Problem Statement

In some other world, today is December <var>D</var>-th.

Write a program that prints Christmas if <var>D = 25</var>, Christmas Eve if <var>D = 24</var>, Christmas Eve Eve if <var>D = 23</var> and Christmas Eve Eve Eve if <var>D = 22</var>.

Constraints

<var>22 \leq D \leq 25</var>

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

Input

Input is given from Standard Input in the following format:

<var>D</var>

Output

Print the specified string (case-sensitive).

Sample Input 1

25

Sample Output 1

Christmas

Sample Input 2

22

Sample Output 2

Christmas Eve Eve Eve

Be sure to print spaces between the words.


Score : <var>100</var> points

Problem Statement

You are given three integers <var>A</var>, <var>B</var> and <var>C</var>.
Determine whether <var>C</var> is not less than <var>A</var> and not greater than <var>B</var>.

Constraints

<var>-100≤A,B,C≤100</var>

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

Input

Input is given from Standard Input in the following format:

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

Output

If the condition is satisfied, print Yes; otherwise, print No.

Sample Input 1

1 3 2

Sample Output 1

Yes

<var>C=2</var> is not less than <var>A=1</var> and not greater than <var>B=3</var>, and thus the output should be Yes.

Sample Input 2

6 5 4

Sample Output 2

No

<var>C=4</var> is less than <var>A=6</var>, and thus the output should be No.

Sample Input 3

2 2 2

Sample Output 3

Yes


Score : <var>100</var> points

Problem Statement

We have <var>N+M</var> balls, each of which has an integer written on it.

It is known that:

The numbers written on <var>N</var> of the balls are even.

The numbers written on <var>M</var> of the balls are odd.

Find the number of ways to choose two of the <var>N+M</var> balls (disregarding order) so that the sum of the numbers written on them is even.

It can be shown that this count does not depend on the actual values written on the balls.

Constraints

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

<var>2 \leq N+M</var>

All values in input are integers.

Input

Input is given from Standard Input in the following format:

<var>N</var> <var>M</var>

Output

Print the answer.

Sample Input 1

2 1

Sample Output 1

1

For example, let us assume that the numbers written on the three balls are <var>1,2,4</var>.

If we choose the two balls with <var>1</var> and <var>2</var>, the sum is odd;

If we choose the two balls with <var>1</var> and <var>4</var>, the sum is odd;

If we choose the two balls with <var>2</var> and <var>4</var>, the sum is even.

Thus, the answer is <var>1</var>.

Sample Input 2

4 3

Sample Output 2

9

Sample Input 3

1 1

Sample Output 3

0

Sample Input 4

13 3

Sample Output 4

81

Sample Input 5

0 3

Sample Output 5

3


Score: <var>300</var> points

Problem Statement

In 2028 and after a continuous growth, AtCoder Inc. finally built an empire with six cities (City <var>1, 2, 3, 4, 5, 6</var>)!

There are five means of transport in this empire:

Train: travels from City <var>1</var> to <var>2</var> in one minute. A train can occupy at most <var>A</var> people.

Bus: travels from City <var>2</var> to <var>3</var> in one minute. A bus can occupy at most <var>B</var> people.

Taxi: travels from City <var>3</var> to <var>4</var> in one minute. A taxi can occupy at most <var>C</var> people.

Airplane: travels from City <var>4</var> to <var>5</var> in one minute. An airplane can occupy at most <var>D</var> people.

Ship: travels from City <var>5</var> to <var>6</var> in one minute. A ship can occupy at most <var>E</var> people.

For each of them, one vehicle leaves the city at each integer time (time <var>0</var>, <var>1</var>, <var>2</var>, <var>...</var>).

There is a group of <var>N</var> people at City <var>1</var>, and they all want to go to City <var>6</var>.

At least how long does it take for all of them to reach there?
You can ignore the time needed to transfer.

Constraints

<var>1 \leq N, A, B, C, D, E \leq 10^{15}</var>

All values in input are integers.

Input

Input is given from Standard Input in the following format:

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

Output

Print the minimum time required for all of the people to reach City <var>6</var>, in minutes.

Sample Input 1

5
3
2
4
3
5

Sample Output 1

7

One possible way to travel is as follows.
First, there are <var>N = 5</var> people at City <var>1</var>, as shown in the following image:

In the first minute, three people travels from City <var>1</var> to City <var>2</var> by train. Note that a train can only occupy at most three people.

In the second minute, the remaining two people travels from City <var>1</var> to City <var>2</var> by train, and two of the three people who were already at City <var>2</var> travels to City <var>3</var> by bus. Note that a bus can only occupy at most two people.

In the third minute, two people travels from City <var>2</var> to City <var>3</var> by train, and another two people travels from City <var>3</var> to City <var>4</var> by taxi.

From then on, if they continue traveling without stopping until they reach City <var>6</var>, all of them can reach there in seven minutes.

There is no way for them to reach City <var>6</var> in <var>6</var> minutes or less.

Sample Input 2

10
123
123
123
123
123

Sample Output 2

5

All kinds of vehicles can occupy <var>N = 10</var> people at a time.
Thus, if they continue traveling without stopping until they reach City <var>6</var>, all of them can reach there in five minutes.

Sample Input 3

10000000007
2
3
5
7
11

Sample Output 3

5000000008

Note that the input or output may not fit into a <var>32</var>-bit integer type.