Score : <var>100</var> points

Problem Statement

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

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

Assume we use the minimum number of bills required.

Constraints

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

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

Input

Input is given from Standard Input in the following format:

<var>N</var>

Output

Print the amount of change as an integer.

Sample Input 1

1900

Sample Output 1

100

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

Sample Input 2

3000

Sample Output 2

0

We can pay the exact price.


Score : <var>100</var> points

Problem Statement

There is a grid with <var>H</var> horizontal rows and <var>W</var> vertical columns.
Let <var>(i, j)</var> denote the square at the <var>i</var>-th row from the top and the <var>j</var>-th column from the left.

For each <var>i</var> and <var>j</var> (<var>1 \leq i \leq H</var>, <var>1 \leq j \leq W</var>), Square <var>(i, j)</var> is described by a character <var>a_{i, j}</var>.
If <var>a_{i, j}</var> is ., Square <var>(i, j)</var> is an empty square; if <var>a_{i, j}</var> is #, Square <var>(i, j)</var> is a wall square.
It is guaranteed that Squares <var>(1, 1)</var> and <var>(H, W)</var> are empty squares.

Taro will start from Square <var>(1, 1)</var> and reach <var>(H, W)</var> by repeatedly moving right or down to an adjacent empty square.

Find the number of Taro's paths from Square <var>(1, 1)</var> to <var>(H, W)</var>.
As the answer can be extremely large, find the count modulo <var>10^9 + 7</var>.

Constraints

<var>H</var> and <var>W</var> are integers.

<var>2 \leq H, W \leq 1000</var>

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

Squares <var>(1, 1)</var> and <var>(H, W)</var> are empty squares.

Input

Input is given from Standard Input in the following format:

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

Output

Print the number of Taro's paths from Square <var>(1, 1)</var> to <var>(H, W)</var>, modulo <var>10^9 + 7</var>.

Sample Input 1

3 4
...#
.#..
....

Sample Output 1

3

There are three paths as follows:

Sample Input 2

5 2
..
#.
..
.#
..

Sample Output 2

0

There may be no paths.

Sample Input 3

5 5
..#..
.....
#...#
.....
..#..

Sample Output 3

24

Sample Input 4

20 20
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................

Sample Output 4

345263555

Be sure to print the count modulo <var>10^9 + 7</var>.


Score : <var>100</var> points

Problem Statement

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

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

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

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

Constraints

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

Input

Input is given from Standard Input in the following format:

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

Output

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

Sample Input 1

4 3 2

Sample Output 1

YES

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

Sample Input 2

2 3 4

Sample Output 2

NO

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


Score : <var>100</var> points

Problem Statement

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

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

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

Constraints

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

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

Input

Input is given from Standard Input in the following format:

<var>S</var>

Output

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

Sample Input 1

oxo

Sample Output 1

900

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

Sample Input 2

ooo

Sample Output 2

1000

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

Sample Input 3

xxx

Sample Output 3

700

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


Score : <var>100</var> points

Problem Statement

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

Constraints

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

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

Input

Input is given from Standard Input in the following format:

<var>a</var>

Output

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

Sample Input 1

2

Sample Output 1

14

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

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

Sample Input 2

10

Sample Output 2

1110


Score : <var>100</var> points

Problem Statement

A programming competition site AtCode regularly holds programming contests.

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

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

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

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

Constraints

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

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

Input

Input is given from Standard Input in the following format:

<var>R</var>

Output

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

Sample Input 1

1199

Sample Output 1

ABC

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

Sample Input 2

1200

Sample Output 2

ARC

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

Sample Input 3

4208

Sample Output 3

AGC


Score : <var>300</var> points

Problem Statement

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

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

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

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

Constraints

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

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

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

All values in input are integers.

Input

Input is given from Standard Input in the following format:

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

Output

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

Sample Input 1

6 2 4

Sample Output 1

2

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

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

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

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

Sample Input 2

7 4 3

Sample Output 2

1

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

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

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

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

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

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

Sample Input 3

10 1 2

Sample Output 3

8

Sample Input 4

1000000000000000 1000000000000000 1000000000000000

Sample Output 4

1000000000000000

The answer can be enormous.


Score: <var>400</var> points

Problem Statement

To become a millionaire, M-kun has decided to make money by trading in the next <var>N</var> days. Currently, he has <var>1000</var> yen and no stocks - only one kind of stock is issued in the country where he lives.

He is famous across the country for his ability to foresee the future. He already knows that the price of one stock in the next <var>N</var> days will be as follows:

<var>A_1</var> yen on the <var>1</var>-st day, <var>A_2</var> yen on the <var>2</var>-nd day, ..., <var>A_N</var> yen on the <var>N</var>-th day.

In the <var>i</var>-th day, M-kun can make the following trade any number of times (possibly zero), within the amount of money and stocks that he has at the time.

Buy stock: Pay <var>A_i</var> yen and receive one stock.

Sell stock: Sell one stock for <var>A_i</var> yen.

What is the maximum possible amount of money that M-kun can have in the end by trading optimally?

Constraints

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

<var>100 \leq A_i \leq 200</var>

All values in input are integers.

Input

Input is given from Standard Input in the following format:

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

Output

Print the maximum possible amount of money that M-kun can have in the end, as an integer.

Sample Input 1

7
100 130 130 130 115 115 150

Sample Output 1

1685

In this sample input, M-kun has seven days of trading. One way to have <var>1685</var> yen in the end is as follows:

Initially, he has <var>1000</var> yen and no stocks.

Day <var>1</var>: Buy <var>10</var> stocks for <var>1000</var> yen. Now he has <var>0</var> yen.

Day <var>2</var>: Sell <var>7</var> stocks for <var>910</var> yen. Now he has <var>910</var> yen.

Day <var>3</var>: Sell <var>3</var> stocks for <var>390</var> yen. Now he has <var>1300</var> yen.

Day <var>4</var>: Do nothing.

Day <var>5</var>: Buy <var>1</var> stock for <var>115</var> yen. Now he has <var>1185</var> yen.

Day <var>6</var>: Buy <var>10</var> stocks for <var>1150</var> yen. Now he has <var>35</var> yen.

Day <var>7</var>: Sell <var>11</var> stocks for <var>1650</var> yen. Now he has <var>1685</var> yen.

There is no way to have <var>1686</var> yen or more in the end, so the answer is <var>1685</var>.

Sample Input 2

6
200 180 160 140 120 100

Sample Output 2

1000

In this sample input, it is optimal to do nothing throughout the six days, after which we will have <var>1000</var> yen.

Sample Input 3

2
157 193

Sample Output 3

1216

In this sample input, it is optimal to buy <var>6</var> stocks in Day <var>1</var> and sell them in Day <var>2</var>, after which we will have <var>1216</var> yen.


Score : <var>200</var> points

Problem Statement

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

Constraints

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

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

All values in input are integers.

Input

Input is given from Standard Input in the following format:

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

Output

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

Sample Input 1

4
1 4 6 3

Sample Output 1

5

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

Sample Input 2

2
1000000000 1

Sample Output 2

999999999

Sample Input 3

5
1 1 1 1 1

Sample Output 3

0


Score : <var>100</var> points

Problem Statement

Taro's summer vacation starts tomorrow, and he has decided to make plans for it now.

The vacation consists of <var>N</var> days.
For each <var>i</var> (<var>1 \leq i \leq N</var>), Taro will choose one of the following activities and do it on the <var>i</var>-th day:

A: Swim in the sea. Gain <var>a_i</var> points of happiness.

B: Catch bugs in the mountains. Gain <var>b_i</var> points of happiness.

C: Do homework at home. Gain <var>c_i</var> points of happiness.

As Taro gets bored easily, he cannot do the same activities for two or more consecutive days.

Find the maximum possible total points of happiness that Taro gains.

Constraints

All values in input are integers.

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

<var>1 \leq a_i, b_i, c_i \leq 10^4</var>

Input

Input is given from Standard Input in the following format:

<var>N</var>
<var>a_1</var> <var>b_1</var> <var>c_1</var>
<var>a_2</var> <var>b_2</var> <var>c_2</var>
<var>:</var>
<var>a_N</var> <var>b_N</var> <var>c_N</var>

Output

Print the maximum possible total points of happiness that Taro gains.

Sample Input 1

3
10 40 70
20 50 80
30 60 90

Sample Output 1

210

If Taro does activities in the order C, B, C, he will gain <var>70 + 50 + 90 = 210</var> points of happiness.

Sample Input 2

1
100 10 1

Sample Output 2

100

Sample Input 3

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

Sample Output 3

46

Taro should do activities in the order C, A, B, A, C, B, A.


Score : <var>200</var> points

Problem Statement

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

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

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

Constraints

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

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

Input

Input is given from Standard Input in the following format:

<var>X</var>

Output

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

Sample Input 1

1024

Sample Output 1

2020

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

Sample Input 2

0

Sample Output 2

0

He is penniless - or yenless.

Sample Input 3

1000000000

Sample Output 3

2000000000

He is a billionaire - in yen.


Score : <var>200</var> points

Problem Statement

Two children are playing tag on a number line. (In the game of tag, the child called "it" tries to catch the other child.) The child who is "it" is now at coordinate <var>A</var>, and he can travel the distance of <var>V</var> per second.
The other child is now at coordinate <var>B</var>, and she can travel the distance of <var>W</var> per second.

He can catch her when his coordinate is the same as hers.
Determine whether he can catch her within <var>T</var> seconds (including exactly <var>T</var> seconds later).
We assume that both children move optimally.

Constraints

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

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

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

<var>A \neq B</var>

All values in input are integers.

Input

Input is given from Standard Input in the following format:

<var>A</var> <var>V</var>
<var>B</var> <var>W</var>
<var>T</var>

Output

If "it" can catch the other child, print YES; otherwise, print NO.

Sample Input 1

1 2
3 1
3

Sample Output 1

YES

Sample Input 2

1 2
3 2
3

Sample Output 2

NO

Sample Input 3

1 2
3 3
3

Sample Output 3

NO


Score : <var>300</var> points

Problem Statement

There are <var>N</var> sightseeing spots on the <var>x</var>-axis, numbered <var>1, 2, ..., N</var>.
Spot <var>i</var> is at the point with coordinate <var>A_i</var>.
It costs <var>|a - b|</var> yen (the currency of Japan) to travel from a point with coordinate <var>a</var> to another point with coordinate <var>b</var> along the axis.

You planned a trip along the axis.
In this plan, you first depart from the point with coordinate <var>0</var>, then visit the <var>N</var> spots in the order they are numbered, and finally return to the point with coordinate <var>0</var>.

However, something came up just before the trip, and you no longer have enough time to visit all the <var>N</var> spots, so you decided to choose some <var>i</var> and cancel the visit to Spot <var>i</var>.
You will visit the remaining spots as planned in the order they are numbered.
You will also depart from and return to the point with coordinate <var>0</var> at the beginning and the end, as planned.

For each <var>i = 1, 2, ..., N</var>, find the total cost of travel during the trip when the visit to Spot <var>i</var> is canceled.

Constraints

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

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

Output

Print <var>N</var> lines.
In the <var>i</var>-th line, print the total cost of travel during the trip when the visit to Spot <var>i</var> is canceled.

Sample Input 1

3
3 5 -1

Sample Output 1

12
8
10

Spot <var>1</var>, <var>2</var> and <var>3</var> are at the points with coordinates <var>3</var>, <var>5</var> and <var>-1</var>, respectively.
For each <var>i</var>, the course of the trip and the total cost of travel when the visit to Spot <var>i</var> is canceled, are as follows:

For <var>i = 1</var>, the course of the trip is <var>0 \rightarrow 5 \rightarrow -1 \rightarrow 0</var> and the total cost of travel is <var>5 + 6 + 1 = 12</var> yen.

For <var>i = 2</var>, the course of the trip is <var>0 \rightarrow 3 \rightarrow -1 \rightarrow 0</var> and the total cost of travel is <var>3 + 4 + 1 = 8</var> yen.

For <var>i = 3</var>, the course of the trip is <var>0 \rightarrow 3 \rightarrow 5 \rightarrow 0</var> and the total cost of travel is <var>3 + 2 + 5 = 10</var> yen.

Sample Input 2

5
1 1 1 2 0

Sample Output 2

4
4
4
2
4

Sample Input 3

6
-679 -2409 -3258 3095 -3291 -4462

Sample Output 3

21630
21630
19932
8924
21630
19288


Score : <var>200</var> points

Problem Statement

Let <var>S(n)</var> denote the sum of the digits in the decimal notation of <var>n</var>.
For example, <var>S(101) = 1 + 0 + 1 = 2</var>.

Given an integer <var>N</var>, determine if <var>S(N)</var> divides <var>N</var>.

Constraints

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

Input

Input is given from Standard Input in the following format:

<var>N</var>

Output

If <var>S(N)</var> divides <var>N</var>, print Yes; if it does not, print No.

Sample Input 1

12

Sample Output 1

Yes

In this input, <var>N=12</var>.
As <var>S(12) = 1 + 2 = 3</var>, <var>S(N)</var> divides <var>N</var>.

Sample Input 2

101

Sample Output 2

No

As <var>S(101) = 1 + 0 + 1 = 2</var>, <var>S(N)</var> does not divide <var>N</var>.

Sample Input 3

999999999

Sample Output 3

Yes


Score : <var>100</var> points

Problem Statement

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

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

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

Constraints

All input values are integers.

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

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

Input

Input is given from Standard Input in the following format:

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

Output

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

Sample Input 1

50 100 120

Sample Output 1

Yes

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

Sample Input 2

500 100 1000

Sample Output 2

No

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

Sample Input 3

19 123 143

Sample Output 3

No

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

Sample Input 4

19 123 142

Sample Output 4

Yes


Score : <var>200</var> points

Problem Statement

Snuke has <var>N</var> sticks.
The length of the <var>i</var>-th stick is <var>l_i</var>.

Snuke is making a snake toy by joining <var>K</var> of the sticks together.

The length of the toy is represented by the sum of the individual sticks that compose it.
Find the maximum possible length of the toy.

Constraints

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

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

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

Input

Input is given from Standard Input in the following format:

<var>N</var> <var>K</var>
<var>l_1</var> <var>l_2</var> <var>l_3</var> <var>...</var> <var>l_{N}</var>

Output

Print the answer.

Sample Input 1

5 3
1 2 3 4 5

Sample Output 1

12

You can make a toy of length <var>12</var> by joining the sticks of lengths <var>3</var>, <var>4</var> and <var>5</var>, which is the maximum possible length.

Sample Input 2

15 14
50 26 27 21 41 7 42 35 7 5 5 36 39 1 45

Sample Output 2

386


Score : <var>200</var> points

Problem Statement

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

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

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

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

Constraints

All values in input are integers.

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

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

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

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

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

Input

Input is given from Standard Input in the following format:

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

Output

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

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

Sample Input 1

3 70
7 60
1 80
4 50

Sample Output 1

4

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

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

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

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

Sample Input 2

4 3
1 1000
2 4
3 1000
4 500

Sample Output 2

TLE

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

Sample Input 3

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

Sample Output 3

5


Score : <var>100</var> points

Problem Statement

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

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

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

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

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

Constraints

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

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

Input

Input is given from Standard Input in the following format:

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

Output

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

Sample Input 1

CSS
CSR

Sample Output 1

2

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

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

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

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

Sample Input 2

SSR
SSR

Sample Output 2

3

Sample Input 3

RRR
SSS

Sample Output 3

0


Score : <var>100</var> points

Problem Statement

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

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

Constraints

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

All values in input are integers.

Input

Input is given from Standard Input in the following format:

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

Output

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

Sample Input 1

5 7 9

Sample Output 1

win

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

Sample Input 2

13 7 2

Sample Output 2

bust

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


Score : <var>400</var> points

Problem Statement

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

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

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

Constraints

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

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

All values in input are integers.

Input

Input is given from Standard Input in the following format:

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

Output

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

Sample Input 1

5
1 1 2 1 2

Sample Output 1

2
2
3
2
3

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

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

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

Sample Input 2

4
1 2 3 4

Sample Output 2

0
0
0
0

No two balls have equal numbers written on them.

Sample Input 3

5
3 3 3 3 3

Sample Output 3

6
6
6
6
6

Any two balls have equal numbers written on them.

Sample Input 4

8
1 2 1 4 2 1 4 1

Sample Output 4

5
7
5
7
7
5
7
5


Score : <var>200</var> points

Problem Statement

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

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

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

Constraints

All values in input are integers.

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

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

Input

Input is given from Standard Input in the following format:

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

Output

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

Sample Input 1

5
5 2 3 4 1

Sample Output 1

YES

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

Sample Input 2

5
2 4 3 5 1

Sample Output 2

NO

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

Sample Input 3

7
1 2 3 4 5 6 7

Sample Output 3

YES

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


Score : <var>500</var> points

Problem Statement

Ibis is fighting with a monster.

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

Ibis can cast <var>N</var> kinds of spells. Casting the <var>i</var>-th spell decreases the monster's health by <var>A_i</var>, at the cost of <var>B_i</var> Magic Points.

The same spell can be cast multiple times. There is no way other than spells to decrease the monster's health.

Ibis wins when the health of the monster becomes <var>0</var> or below.

Find the minimum total Magic Points that have to be consumed before winning.

Constraints

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

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

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

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

Output

Print the minimum total Magic Points that have to be consumed before winning.

Sample Input 1

9 3
8 3
4 2
2 1

Sample Output 1

4

First, let us cast the first spell to decrease the monster's health by <var>8</var>, at the cost of <var>3</var> Magic Points. The monster's health is now <var>1</var>.

Then, cast the third spell to decrease the monster's health by <var>2</var>, at the cost of <var>1</var> Magic Point. The monster's health is now <var>-1</var>.

In this way, we can win at the total cost of <var>4</var> Magic Points.

Sample Input 2

100 6
1 1
2 3
3 9
4 27
5 81
6 243

Sample Output 2

100

It is optimal to cast the first spell <var>100</var> times.

Sample Input 3

9999 10
540 7550
691 9680
700 9790
510 7150
415 5818
551 7712
587 8227
619 8671
588 8228
176 2461

Sample Output 3

139815


Score : <var>200</var> points

Problem Statement

Sig has built his own keyboard. Designed for ultimate simplicity, this keyboard only has <var>3</var> keys on it: the 0 key, the 1 key and the backspace key.

To begin with, he is using a plain text editor with this keyboard. This editor always displays one string (possibly empty). Just after the editor is launched, this string is empty. When each key on the keyboard is pressed, the following changes occur to the string:

The 0 key: a letter 0 will be inserted to the right of the string.

The 1 key: a letter 1 will be inserted to the right of the string.

The backspace key: if the string is empty, nothing happens. Otherwise, the rightmost letter of the string is deleted.

Sig has launched the editor, and pressed these keys several times. You are given a string <var>s</var>, which is a record of his keystrokes in order. In this string, the letter 0 stands for the 0 key, the letter 1 stands for the 1 key and the letter B stands for the backspace key. What string is displayed in the editor now?

Constraints

<var>1 ≦ |s| ≦ 10</var> (<var>|s|</var> denotes the length of <var>s</var>)

<var>s</var> consists of the letters 0, 1 and B.

The correct answer is not an empty string.

Input

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

<var>s</var>

Output

Print the string displayed in the editor in the end.

Sample Input 1

01B0

Sample Output 1

00

Each time the key is pressed, the string in the editor will change as follows: 0, 01, 0, 00.

Sample Input 2

0BB1

Sample Output 2

1

Each time the key is pressed, the string in the editor will change as follows: 0, (empty), (empty), 1.


Score : <var>200</var> points

Problem Statement

Niwango created a playlist of <var>N</var> songs.
The title and the duration of the <var>i</var>-th song are <var>s_i</var> and <var>t_i</var> seconds, respectively.
It is guaranteed that <var>s_1,\ldots,s_N</var> are all distinct.

Niwango was doing some work while playing this playlist. (That is, all the songs were played once, in the order they appear in the playlist, without any pause in between.)
However, he fell asleep during his work, and he woke up after all the songs were played.
According to his record, it turned out that he fell asleep at the very end of the song titled <var>X</var>.

Find the duration of time when some song was played while Niwango was asleep.

Constraints

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

<var>s_i</var> and <var>X</var> are strings of length between <var>1</var> and <var>100</var> (inclusive) consisting of lowercase English letters.

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

There exists an integer <var>i</var> such that <var>s_i = X</var>.

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

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

Input

Input is given from Standard Input in the following format:

<var>N</var>
<var>s_1</var> <var>t_1</var>
<var>\vdots</var>
<var>s_{N}</var> <var>t_N</var>
<var>X</var>

Output

Print the answer.

Sample Input 1

3
dwango 2
sixth 5
prelims 25
dwango

Sample Output 1

30

While Niwango was asleep, two songs were played: sixth and prelims.

The answer is the total duration of these songs, <var>30</var>.

Sample Input 2

1
abcde 1000
abcde

Sample Output 2

0

No songs were played while Niwango was asleep.

In such a case, the total duration of songs is <var>0</var>.

Sample Input 3

15
ypnxn 279
kgjgwx 464
qquhuwq 327
rxing 549
pmuduhznoaqu 832
dagktgdarveusju 595
wunfagppcoi 200
dhavrncwfw 720
jpcmigg 658
wrczqxycivdqn 639
mcmkkbnjfeod 992
htqvkgkbhtytsz 130
twflegsjz 467
dswxxrxuzzfhkp 989
szfwtzfpnscgue 958
pmuduhznoaqu

Sample Output 3

6348


Score : <var>200</var> points

Problem Statement

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

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

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

Constraints

All values in input are integers.

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

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

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

Input

Input is given from Standard Input in the following format:

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

Output

Print the maximum possible number of happy children.

Sample Input 1

3 70
20 30 10

Sample Output 1

2

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

Sample Input 2

3 10
20 30 10

Sample Output 2

1

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

Sample Input 3

4 1111
1 10 100 1000

Sample Output 3

4

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

Sample Input 4

2 10
20 20

Sample Output 4

0

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


Score : <var>300</var> points

Problem Statement

There is an empty array.
The following <var>N</var> operations will be performed to insert integers into the array.
In the <var>i</var>-th operation <var>(1≤i≤N)</var>, <var>b_i</var> copies of an integer <var>a_i</var> are inserted into the array.
Find the <var>K</var>-th smallest integer in the array after the <var>N</var> operations.
For example, the <var>4</var>-th smallest integer in the array <var>\{1,2,2,3,3,3\}</var> is <var>3</var>.

Constraints

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

<var>1≤a_i,b_i≤10^5</var>

<var>1≤K≤b_1…+…b_n</var>

All input values are integers.

Input

Input is given from Standard Input in the following format:

<var>N</var> <var>K</var>
<var>a_1</var> <var>b_1</var>
<var>:</var>
<var>a_N</var> <var>b_N</var>

Output

Print the <var>K</var>-th smallest integer in the array after the <var>N</var> operations.

Sample Input 1

3 4
1 1
2 2
3 3

Sample Output 1

3

The resulting array is the same as the one in the problem statement.

Sample Input 2

10 500000
1 100000
1 100000
1 100000
1 100000
1 100000
100000 100000
100000 100000
100000 100000
100000 100000
100000 100000

Sample Output 2

1


Score : <var>300</var> points

Problem Statement

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

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

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

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

Constraints

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

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

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

All values in input are integers.

Input

Input is given from Standard Input in the following format:

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

Output

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

Sample Input 1

20 3
5 10 15

Sample Output 1

10

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

Sample Input 2

20 3
0 5 15

Sample Output 2

10

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


Score : <var>200</var> points

Problem Statement

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

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

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

Constraints

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

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

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

Input

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

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

Output

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

Sample Input 1

5
IIDID

Sample Output 1

2

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

Sample Input 2

7
DDIDDII

Sample Output 2

0

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


Score : <var>200</var> points

Problem Statement

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

Constraints

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

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

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

Input

Input is given from Standard Input in the following format:

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

Output

Print the largest possible number of different letters contained in both <var>X</var> and <var>Y</var>.

Sample Input 1

6
aabbca

Sample Output 1

2

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

Sample Input 2

10
aaaaaaaaaa

Sample Output 2

1

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

Sample Input 3

45
tgxgdqkyjzhyputjjtllptdfxocrylqfqjynmfbfucbir

Sample Output 3

9


Score : <var>200</var> points

Problem Statement

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

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

Constraints

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

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

All values in input are integers.

Input

Input is given from Standard Input in the following format:

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

Output

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

Sample Input 1

5 3
50 100 80 120 80

Sample Output 1

210

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

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

Sample Input 2

1 1
1000

Sample Output 2

1000


Score : <var>100</var> points

Problem Statement

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

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

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

Constraints

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

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

Input

Input is given from Standard Input in the following format:

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

Output

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

Sample Input 1

4 5

Sample Output 1

unsafe

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

Sample Input 2

100 2

Sample Output 2

safe

Many a sheep drive away two wolves.

Sample Input 3

10 10

Sample Output 3

unsafe


Score : <var>100</var> points

Problem Statement

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

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

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

Constraints

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

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

Input

Input is given from Standard Input in the following format:

<var>S</var>

Output

If <var>S</var> is a Hitachi string, print Yes; otherwise, print No.

Sample Input 1

hihi

Sample Output 1

Yes

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

Sample Input 2

hi

Sample Output 2

Yes

Sample Input 3

ha

Sample Output 3

No


Score : <var>100</var> points

Problem Statement

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

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

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

Constraints

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

All input values are integers.

Input

Input is given from Standard Input in the following format:

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

Output

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

Sample Input 1

3 8 7 1

Sample Output 1

Left

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

Sample Input 2

3 4 5 2

Sample Output 2

Balanced

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

Sample Input 3

1 7 6 4

Sample Output 3

Right

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


Score : <var>400</var> points

Problem Statement

For a positive integer <var>X</var>, let <var>f(X)</var> be the number of positive divisors of <var>X</var>.

Given a positive integer <var>N</var>, find <var>\sum_{K=1}^N K\times f(K)</var>.

Constraints

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

Input

Input is given from Standard Input in the following format:

<var>N</var>

Output

Print the value <var>\sum_{K=1}^N K\times f(K)</var>.

Sample Input 1

4

Sample Output 1

23

We have <var>f(1)=1</var>, <var>f(2)=2</var>, <var>f(3)=2</var>, and <var>f(4)=3</var>, so the answer is <var>1\times 1 + 2\times 2 + 3\times 2 + 4\times 3 =23</var>.

Sample Input 2

100

Sample Output 2

26879

Sample Input 3

10000000

Sample Output 3

838627288460105

Watch out for overflows.


Score : <var>500</var> points

Problem Statement

Consider sequences <var>\{A_1,...,A_N\}</var> of length <var>N</var> consisting of integers between <var>1</var> and <var>K</var> (inclusive).

There are <var>K^N</var> such sequences. Find the sum of <var>\gcd(A_1, ..., A_N)</var> over all of them.

Since this sum can be enormous, print the value modulo <var>(10^9+7)</var>.

Here <var>\gcd(A_1, ..., A_N)</var> denotes the greatest common divisor of <var>A_1, ..., A_N</var>.

Constraints

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

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

All values in input are integers.

Input

Input is given from Standard Input in the following format:

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

Output

Print the sum of <var>\gcd(A_1, ..., A_N)</var> over all <var>K^N</var> sequences, modulo <var>(10^9+7)</var>.

Sample Input 1

3 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

3 200

Sample Output 2

10813692

Sample Input 3

100000 100000

Sample Output 3

742202979

Be sure to print the sum modulo <var>(10^9+7)</var>.


Score : <var>200</var> points

Problem Statement

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

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

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

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

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

We can prove that this value is uniquely determined.

Constraints

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

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

All values in input are integers.

Input

Input is given from Standard Input in the following format:

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

Output

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

Sample Input 1

5 2

Sample Output 1

18

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

Sample Input 2

3 -1

Sample Output 2

0

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

Sample Input 3

30 -50

Sample Output 3

-1044


Score : <var>200</var> points

Problem Statement

The development of algae in a pond is as follows.

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

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

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

Constraints

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

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

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

All values in input are integers.

Input

Input is given from Standard Input in the following format:

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

Output

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

Sample Input 1

2 10 20

Sample Output 1

30
50
90
170
330
650
1290
2570
5130
10250

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

Sample Input 2

4 40 60

Sample Output 2

200
760
3000
11960
47800
191160
764600
3058360
12233400
48933560


Problem Statement

AtCoder currently hosts three types of contests: ABC, ARC, and AGC. As the number of users has grown, in order to meet the needs of more users, AtCoder has decided to increase the number of contests to 26 types, from AAC to AZC. For convenience, we number these 26 types as type 1 through type 26. AtCoder wants to schedule contests for <var>D</var> days so that user satisfaction is as high as possible. For every day, AtCoder will hold exactly one contest, and each contest will end on that day. The satisfaction is calculated as follows.

The satisfaction at the beginning of day 1 is 0. Satisfaction can be negative.

Holding contests increases satisfaction. The amount of increase will vary depending on a variety of factors. Specifically, we know in advance that holding a contest of type <var>i</var> on day <var>d</var> will increase the satisfaction by <var>s_{d,i}</var>.

If a particular type of contest is not held for a while, the satisfaction decreases. Each contest type <var>i</var> has an integer <var>c_i</var>, and at the end of each day <var>d=1,2,...,D</var>, the satisfaction decreases as follows. Let <var>\mathrm{last}(d,i)</var> be the last day before day <var>d</var> (including <var>d</var>) on which a contest of type <var>i</var> was held. If contests of type <var>i</var> have never been held yet, we define <var>\mathrm{last}(d,i)=0</var>. At the end of day <var>d</var>, the satisfaction decreases by <var>\sum _{i=1}^{26}c_i \times (d-\mathrm{last}(d,i))</var>.

Please schedule contests on behalf of AtCoder.
If the satisfaction at the end of day <var>D</var> is <var>S</var>, you will get a score of <var>\max(10^6 + S, 0)</var>.
There are 50 test cases, and the score of a submission is the total scores for each test case.
You can make submissions multiple times, and the highest score among your submissions will be your score.

Constraints

<var>D = 365</var>

Each <var>c_i</var> is an integer satisfying <var>0\leq c_i \leq 100</var>.

Each <var>s_{d,i}</var> is an integer satisfying <var>0\leq s_{d,i} \leq 20000</var>.

Input

Input is given from Standard Input in the following format:

<var>D</var>
<var>c_1</var> <var>c_2</var> <var>\cdots</var> <var>c_{26}</var>
<var>s_{1,1}</var> <var>s_{1,2}</var> <var>\cdots</var> <var>s_{1,26}</var>
<var>\vdots</var>
<var>s_{D,1}</var> <var>s_{D,2}</var> <var>\cdots</var> <var>s_{D,26}</var>

Output

Let <var>t_d</var> (<var>1\leq t_d \leq 26</var>) be the type of the contest that will be held at day <var>d</var>.
Print <var>D</var> integers <var>t_d</var> to Standard Output in the following format:

<var>t_1</var>
<var>t_2</var>
<var>\vdots</var>
<var>t_D</var>

Any output that does not follow the above format may result in <s>0 points</s>WA for that test case.

Input Generation

Each integer <var>c_i</var> and <var>s_{d,i}</var> is generated independently and uniformly at random from the integers in the range described in the problem statement.

Sample Input 1

5
86 90 69 51 2 96 71 47 88 34 45 46 89 34 31 38 97 84 41 80 14 4 50 83 7 82
19771 12979 18912 10432 10544 12928 13403 3047 10527 9740 8100 92 2856 14730 1396 15905 6534 4650 11469 3628 8433 2994 10899 16396 18355 11424
6674 17707 13855 16407 12232 2886 11908 1705 5000 1537 10440 10711 4917 10770 17272 15364 19277 18094 3929 3705 7169 6159 18683 15410 9092 4570
6878 4239 19925 1799 375 9563 3445 5658 19857 11401 6997 6498 19933 3848 2426 2146 19745 16880 17773 18359 3921 14172 16730 11157 5439 256
8633 15862 15303 10749 18499 7792 10317 5901 9395 11433 3514 3959 5202 19850 19469 9790 5653 784 18500 10552 17975 16615 7852 197 8471 7452
19855 17918 7990 10572 4333 438 9140 9104 12622 4985 12319 4028 19922 12132 16259 17476 2976 547 19195 19830 16285 4806 4471 9457 2864 2192

Sample Output 1

1
17
13
14
13

Note that this example is a small one for checking the problem specification. It does not satisfy the constraint <var>D=365</var> and is never actually given as a test case. The final satisfaction with this output is 79325, so the score is 1079325.

Input generator, score calculator, and visualizer

Beginner's Guide

If you don't know what to do, proceed to problem B or C.


Score : <var>200</var> points

Problem Statement

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

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

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

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

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

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

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

Determine if war will break out.

Constraints

All values in input are integers.

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

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

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

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

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

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

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

Input

Input is given from Standard Input in the following format:

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

Output

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

Sample Input 1

3 2 10 20
8 15 13
16 22

Sample Output 1

No War

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

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

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

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

Sample Input 2

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

Sample Output 2

War

Sample Input 3

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

Sample Output 3

War


Score : <var>300</var> points

Problem Statement

Hearing that energy drinks increase rating in those sites, Takahashi decides to buy up <var>M</var> cans of energy drinks.

There are <var>N</var> stores that sell energy drinks. In the <var>i</var>-th store, he can buy at most <var>B_i</var> cans of energy drinks for <var>A_i</var> yen (the currency of Japan) each.

What is the minimum amount of money with which he can buy <var>M</var> cans of energy drinks?

It is guaranteed that, in the given inputs, a sufficient amount of money can always buy <var>M</var> cans of energy drinks.

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>

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

<var>B_1 + ... + B_N \geq M</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 minimum amount of money with which Takahashi can buy <var>M</var> cans of energy drinks.

Sample Input 1

2 5
4 9
2 4

Sample Output 1

12

With <var>12</var> yen, we can buy one drink at the first store and four drinks at the second store, for the total of five drinks. However, we cannot buy <var>5</var> drinks with <var>11</var> yen or less.

Sample Input 2

4 30
6 18
2 5
3 10
7 9

Sample Output 2

130

Sample Input 3

1 100000
1000000000 100000

Sample Output 3

100000000000000

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


Score : <var>100</var> points

Problem Statement

It has been decided that a programming contest sponsored by company A will be held, so we will post the notice on a bulletin board.

The bulletin board is in the form of a grid with <var>N</var> rows and <var>N</var> columns, and the notice will occupy a rectangular region with <var>H</var> rows and <var>W</var> columns.

How many ways are there to choose where to put the notice so that it completely covers exactly <var>HW</var> squares?

Constraints

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

All values in input are integers.

Input

Input is given from Standard Input in the following format:

<var>N</var>
<var>H</var>
<var>W</var>

Output

Print the answer.

Sample Input 1

3
2
3

Sample Output 1

2

There are two ways to put the notice, as follows:

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

Here, # represents a square covered by the notice, and . represents a square not covered.

Sample Input 2

100
1
1

Sample Output 2

10000

Sample Input 3

5
4
2

Sample Output 3

8


Score: <var>300</var> points

Problem Statement

In Republic of Atcoder, there are <var>N</var> prefectures, and a total of <var>M</var> cities that belong to those prefectures.

City <var>i</var> is established in year <var>Y_i</var> and belongs to Prefecture <var>P_i</var>.

You can assume that there are no multiple cities that are established in the same year.

It is decided to allocate a <var>12</var>-digit ID number to each city.

If City <var>i</var> is the <var>x</var>-th established city among the cities that belong to Prefecture <var>i</var>, the first six digits of the ID number of City <var>i</var> is <var>P_i</var>, and the last six digits of the ID number is <var>x</var>.

Here, if <var>P_i</var> or <var>x</var> (or both) has less than six digits, zeros are added to the left until it has six digits.

Find the ID numbers for all the cities.

Note that there can be a prefecture with no cities.

Constraints

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

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

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

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

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

All values in input are integers.

Input

Input is given from Standard Input in the following format:

<var>N</var> <var>M</var>
<var>P_1</var> <var>Y_1</var>
<var>:</var>
<var>P_M</var> <var>Y_M</var>

Output

Print the ID numbers for all the cities, in ascending order of indices (City <var>1</var>, City <var>2</var>, <var>...</var>).

Sample Input 1

2 3
1 32
2 63
1 12

Sample Output 1

000001000002
000002000001
000001000001

As City <var>1</var> is the second established city among the cities that belong to Prefecture <var>1</var>, its ID number is <var>000001000002</var>.

As City <var>2</var> is the first established city among the cities that belong to Prefecture <var>2</var>, its ID number is <var>000002000001</var>.

As City <var>3</var> is the first established city among the cities that belong to Prefecture <var>1</var>, its ID number is <var>000001000001</var>.

Sample Input 2

2 3
2 55
2 77
2 99

Sample Output 2

000002000001
000002000002
000002000003


Score : <var>100</var> points

Problem Statement

You are given an array <var>a_0, a_1, ..., a_{N-1}</var> of length <var>N</var>. Process <var>Q</var> queries of the following types.

0 p x: <var>a_p \gets a_p + x</var>

1 l r: Print <var>\sum_{i = l}^{r - 1}{a_i}</var>.

Constraints

<var>1 \leq N, Q \leq 500,000</var>

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

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

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

All values in Input are integer.

Input

Input is given from Standard Input in the following format:

<var>N</var> <var>Q</var>
<var>a_0</var> <var>a_1</var> ... <var>a_{N - 1}</var>
<var>\textrm{Query}_0</var>
<var>\textrm{Query}_1</var>
:
<var>\textrm{Query}_{Q - 1}</var>

Output

For each query of the latter type, print the answer.

Sample Input 1

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

Sample Output 1

15
7
25
6


Score : <var>300</var> points

Problem Statement

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

Consider doing the following operation:

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

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

Constraints

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

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

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

Input

Input is given from Standard Input in the following format:

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

Output

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

Sample Input 1

2 3 2
..#
###

Sample Output 1

5

Five choices below satisfy the condition.

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

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

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

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

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

Sample Input 2

2 3 4
..#
###

Sample Output 2

1

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

Sample Input 3

2 2 3
##
##

Sample Output 3

0

Sample Input 4

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

Sample Output 4

208


Score : <var>300</var> points

Problem Statement

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

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

Constraints

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

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

Input

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

<var>S</var>

Output

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

Sample Input 1

erasedream

Sample Output 1

YES

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

Sample Input 2

dreameraser

Sample Output 2

YES

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

Sample Input 3

dreamerer

Sample Output 3

NO


Score : <var>200</var> points

Problem Statement

There are <var>N</var> students and <var>M</var> checkpoints on the <var>xy</var>-plane.

The coordinates of the <var>i</var>-th student <var>(1 \leq i \leq N)</var> is <var>(a_i,b_i)</var>, and the coordinates of the checkpoint numbered <var>j</var> <var>(1 \leq j \leq M)</var> is <var>(c_j,d_j)</var>.

When the teacher gives a signal, each student has to go to the nearest checkpoint measured in Manhattan distance.

The Manhattan distance between two points <var>(x_1,y_1)</var> and <var>(x_2,y_2)</var> is <var>|x_1-x_2|+|y_1-y_2|</var>.

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

If there are multiple nearest checkpoints for a student, he/she will select the checkpoint with the smallest index.

Which checkpoint will each student go to?

Constraints

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

<var>-10^8 \leq a_i,b_i,c_j,d_j \leq 10^8</var>

All input values are integers.

Input

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

<var>N</var> <var>M</var>
<var>a_1</var> <var>b_1</var>
<var>:</var>
<var>a_N</var> <var>b_N</var>
<var>c_1</var> <var>d_1</var>
<var>:</var>
<var>c_M</var> <var>d_M</var>

Output

Print <var>N</var> lines.

The <var>i</var>-th line <var>(1 \leq i \leq N)</var> should contain the index of the checkpoint for the <var>i</var>-th student to go.

Sample Input 1

2 2
2 0
0 0
-1 0
1 0

Sample Output 1

2
1

The Manhattan distance between the first student and each checkpoint is:

For checkpoint <var>1</var>: <var>|2-(-1)|+|0-0|=3</var>

For checkpoint <var>2</var>: <var>|2-1|+|0-0|=1</var>

The nearest checkpoint is checkpoint <var>2</var>. Thus, the first line in the output should contain <var>2</var>.

The Manhattan distance between the second student and each checkpoint is:

For checkpoint <var>1</var>: <var>|0-(-1)|+|0-0|=1</var>

For checkpoint <var>2</var>: <var>|0-1|+|0-0|=1</var>

When there are multiple nearest checkpoints, the student will go to the checkpoint with the smallest index. Thus, the second line in the output should contain <var>1</var>.

Sample Input 2

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

Sample Output 2

3
1
2

There can be multiple checkpoints at the same coordinates.

Sample Input 3

5 5
-100000000 -100000000
-100000000 100000000
100000000 -100000000
100000000 100000000
0 0
0 0
100000000 100000000
100000000 -100000000
-100000000 100000000
-100000000 -100000000

Sample Output 3

5
4
3
2
1


Score : <var>100</var> points

Problem Statement

Takahashi is meeting up with Aoki.

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

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

Will he arrive in time?

Constraints

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

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

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

All values in input are integers.

Input

Input is given from Standard Input in the following format:

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

Output

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

Sample Input 1

1000 15 80

Sample Output 1

Yes

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

Sample Input 2

2000 20 100

Sample Output 2

Yes

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

Sample Input 3

10000 1 1

Sample Output 3

No

He will be late.


Score : <var>100</var> points

Problem Statement

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

Constraints

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

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

Input

Input is given from Standard Input in the following format:

<var>S</var>

Output

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

Sample Input 1

bac

Sample Output 1

Yes

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

Sample Input 2

bab

Sample Output 2

No

Sample Input 3

abc

Sample Output 3

Yes

Sample Input 4

aaa

Sample Output 4

No


Score : <var>100</var> points

Problem Statement

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

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

How much do you have left after shopping?

Constraints

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

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

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

Input

Input is given from Standard Input in the following format:

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

Output

Print the amount you have left after shopping.

Sample Input 1

1234
150
100

Sample Output 1

84

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

Sample Input 2

1000
108
108

Sample Output 2

28

Sample Input 3

579
123
456

Sample Output 3

0

Sample Input 4

7477
549
593

Sample Output 4

405


Score : <var>200</var> points

Problem Statement

It is only six months until Christmas, and AtCoDeer the reindeer is now planning his travel to deliver gifts.

There are <var>N</var> houses along TopCoDeer street. The <var>i</var>-th house is located at coordinate <var>a_i</var>. He has decided to deliver gifts to all these houses.

Find the minimum distance to be traveled when AtCoDeer can start and end his travel at any positions.

Constraints

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

<var>0 ≤ a_i ≤ 1000</var>

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

Input

Input is given from Standard Input in the following format:

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

Output

Print the minimum distance to be traveled.

Sample Input 1

4
2 3 7 9

Sample Output 1

7

The travel distance of <var>7</var> can be achieved by starting at coordinate <var>9</var> and traveling straight to coordinate <var>2</var>.

It is not possible to do with a travel distance of less than <var>7</var>, and thus <var>7</var> is the minimum distance to be traveled.

Sample Input 2

8
3 1 4 1 5 9 2 6

Sample Output 2

8

There may be more than one house at a position.


Score : <var>200</var> points

Problem Statement

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

Constraints

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

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

Input

Input is given from Standard Input in the following format:

<var>X</var>

Output

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

Sample Input 1

10

Sample Output 1

9

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

Sample Input 2

1

Sample Output 2

1

Sample Input 3

999

Sample Output 3

961


Score : <var>200</var> points

Problem Statement

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

Constraints

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

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

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

Input

Input is given from Standard Input in the following format:

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

Output

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

Sample Input 1

5
error
2

Sample Output 1

*rr*r

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

Sample Input 2

6
eleven
5

Sample Output 2

e*e*e*

Sample Input 3

9
education
7

Sample Output 3

******i**


Score : <var>100</var> points

Problem Statement

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

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

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

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

Constraints

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

All input values are integers.

Input

Input is given from Standard Input in the following format:

<var>N</var>

Output

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

Sample Input 1

8

Sample Output 1

2

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

Sample Input 2

2

Sample Output 2

0

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

Sample Input 3

9

Sample Output 3

3


Score : <var>200</var> points

Problem Statement

We have <var>N</var> squares assigned the numbers <var>1,2,3,\ldots,N</var>. Each square has an integer written on it, and the integer written on Square <var>i</var> is <var>a_i</var>.

How many squares <var>i</var> satisfy both of the following conditions?

The assigned number, <var>i</var>, is odd.

The written integer is odd.

Constraints

All values in input are integers.

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

Input

Input is given from Standard Input in the following format:

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

Output

Print the number of squares that satisfy both of the conditions.

Sample Input 1

5
1 3 4 5 7

Sample Output 1

2

Two squares, Square <var>1</var> and <var>5</var>, satisfy both of the conditions.

For Square <var>2</var> and <var>4</var>, the assigned numbers are not odd.

For Square <var>3</var>, the written integer is not odd.

Sample Input 2

15
13 76 46 15 50 98 93 77 31 43 84 90 6 24 14

Sample Output 2

3


Score : <var>100</var> points

Problem Statement

Snuke has a favorite restaurant.

The price of any meal served at the restaurant is <var>800</var> yen (the currency of Japan), and each time a customer orders <var>15</var> meals, the restaurant pays <var>200</var> yen back to the customer.

So far, Snuke has ordered <var>N</var> meals at the restaurant.
Let the amount of money Snuke has paid to the restaurant be <var>x</var> yen, and let the amount of money the restaurant has paid back to Snuke be <var>y</var> yen.
Find <var>x-y</var>.

Constraints

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

Input

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

<var>N</var>

Output

Print the answer.

Sample Input 1

20

Sample Output 1

15800

So far, Snuke has paid <var>16000</var> yen, and the restaurant has paid back <var>200</var> yen. Thus, the answer is <var>15800</var>.

Sample Input 2

60

Sample Output 2

47200

Snuke has paid <var>48000</var> yen for <var>60</var> meals, and the restaurant has paid back <var>800</var> yen.


Score : <var>100</var> points

Problem Statement

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

Constraints

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

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

Input

Input is given from Standard Input in the following format:

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

Output

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

Sample Input 1

3 2

Sample Output 1

YES

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

Sample Input 2

5 5

Sample Output 2

NO

Sample Input 3

31 10

Sample Output 3

YES

Sample Input 4

10 90

Sample Output 4

NO


Score : <var>100</var> points

Problem Statement

Takahashi wants to be a member of some web service.

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

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

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

Constraints

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

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

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

Input

Input is given from Standard Input in the following format:

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

Output

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

Sample Input 1

chokudai
chokudaiz

Sample Output 1

Yes

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

Sample Input 2

snuke
snekee

Sample Output 2

No

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

Sample Input 3

a
aa

Sample Output 3

Yes


Score : <var>300</var> points

Problem Statement

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

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

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

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

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

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

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

Constraints

All values in input are integers.

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

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

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

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

Input

Input is given from Standard Input in the following format:

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

Output

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

Sample Input 1

2 5
10 12 1 2 14

Sample Output 1

5

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

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

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

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

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

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

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

Sample Input 2

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

Sample Output 2

19

Sample Input 3

100 1
-100000

Sample Output 3

0


Score : <var>100</var> points

Problem Statement

AtCoDeer the deer recently bought three paint cans.
The color of the one he bought two days ago is <var>a</var>, the color of the one he bought yesterday is <var>b</var>, and the color of the one he bought today is <var>c</var>.
Here, the color of each paint can is represented by an integer between <var>1</var> and <var>100</var>, inclusive.

Since he is forgetful, he might have bought more than one paint can in the same color.
Count the number of different kinds of colors of these paint cans and tell him.

Constraints

<var>1≦a,b,c≦100</var>

Input

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

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

Output

Print the number of different kinds of colors of the paint cans.

Sample Input 1

3 1 4

Sample Output 1

3

Three different colors: <var>1</var>, <var>3</var>, and <var>4</var>.

Sample Input 2

3 3 33

Sample Output 2

2

Two different colors: <var>3</var> and <var>33</var>.


Score : <var>100</var> points

Problem Statement

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

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

Constraints

Input consists of lowercase English letters.

Input

Input is given from Standard Input in the following format:

<var>c_{11}c_{12}c_{13}</var>
<var>c_{21}c_{22}c_{23}</var>
<var>c_{31}c_{32}c_{33}</var>

Output

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

Sample Input 1

ant
obe
rec

Sample Output 1

abc

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

Sample Input 2

edu
cat
ion

Sample Output 2

ean


Score : <var>100</var> points

Problem Statement

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

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

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

Constraints

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

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

Input

Input is given from Standard Input in the following format:

<var>N</var>

Output

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

Sample Input 1

575

Sample Output 1

Yes

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

Sample Input 2

123

Sample Output 2

No

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

Sample Input 3

812

Sample Output 3

No


Score : <var>100</var> points

Problem Statement

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

If so, print Yes; otherwise, print No.

Constraints

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

Input

Input is given from Standard Input in the following format:

<var>N</var>

Output

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

Sample Input 1

117

Sample Output 1

Yes

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

Sample Input 2

123

Sample Output 2

No

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

Sample Input 3

777

Sample Output 3

Yes


Score : <var>100</var> points

Problem Statement

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

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

Constraints

All input values are integers.

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

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

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

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

Input

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

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

Output

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

Sample Input 1

3 5 2 7

Sample Output 1

15

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

Sample Input 2

100 600 200 300

Sample Output 2

60000


Score : <var>200</var> points

Problem Statement

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

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

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

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

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

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

Constraints

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

Input

Input is given from Standard Input in the following format:

<var>N</var>

Output

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

Sample Input 1

15

Sample Output 1

60

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

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

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

Sample Input 2

1000000

Sample Output 2

266666333332

Watch out for overflow.


Score : <var>100</var> points

Problem Statement

You planned a trip using trains and buses.
The train fare will be <var>A</var> yen (the currency of Japan) if you buy ordinary tickets along the way, and <var>B</var> yen if you buy an unlimited ticket.
Similarly, the bus fare will be <var>C</var> yen if you buy ordinary tickets along the way, and <var>D</var> yen if you buy an unlimited ticket.

Find the minimum total fare when the optimal choices are made for trains and buses.

Constraints

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

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

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

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

All input values are integers.

Input

Input is given from Standard Input in the following format:

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

Output

Print the minimum total fare.

Sample Input 1

600
300
220
420

Sample Output 1

520

The train fare will be <var>600</var> yen if you buy ordinary tickets, and <var>300</var> yen if you buy an unlimited ticket.
Thus, the optimal choice for trains is to buy an unlimited ticket for <var>300</var> yen.
On the other hand, the optimal choice for buses is to buy ordinary tickets for <var>220</var> yen.

Therefore, the minimum total fare is <var>300 + 220 = 520</var> yen.

Sample Input 2

555
555
400
200

Sample Output 2

755

Sample Input 3

549
817
715
603

Sample Output 3

1152


Score : <var>100</var> points

Problem Statement

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

Constraints

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

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

Input

Input is given from Standard Input in the following format:

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

Output

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

Sample Input 1

3 4

Sample Output 1

Even

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

Sample Input 2

1 21

Sample Output 2

Odd

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


Score : <var>300</var> points

Problem Statement

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

Constraints

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

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

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

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

Input

Input is given from Standard Input in the following format:

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

Output

Print the answer as an integer.

Sample Input 1

198 1.10

Sample Output 1

217

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

Sample Input 2

1 0.01

Sample Output 2

0

Sample Input 3

1000000000000000 9.99

Sample Output 3

9990000000000000


Score : <var>200</var> points

Problem Statement

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

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

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

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

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

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

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

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

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

Constraints

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

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

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

Input

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

<var>N</var> <var>M</var>
<var>A_1</var>
<var>A_2</var>
<var>:</var>
<var>A_N</var>
<var>B_1</var>
<var>B_2</var>
<var>:</var>
<var>B_M</var>

Output

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

Sample Input 1

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

Sample Output 1

Yes

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

Sample Input 2

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

Sample Output 2

No

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


Score : <var>200</var> points

Problem Statement

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

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

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

For example,

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

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

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

Constraints

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

Input

Input is given from Standard Input in the following format:

<var>N</var>

Output

Print the answer.

Sample Input 1

7

Sample Output 1

4

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

Sample Input 2

32

Sample Output 2

32

Sample Input 3

1

Sample Output 3

1

Sample Input 4

100

Sample Output 4

64


Score : <var>500</var> points

Problem Statement

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

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

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

Constraints

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

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

Input

Input is given from Standard Input in the following format:

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

Output

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

Sample Input 1

5
2
1
4
5
3

Sample Output 1

2

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

Sample Input 2

4
0
0
0
0

Sample Output 2

4

We have to paint all the integers with distinct colors.


Score : <var>300</var> points

Problem Statement

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

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

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

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

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

Under this condition, find a shortest path for him.

Constraints

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

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

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

Input

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

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

Output

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

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

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

U: Up

D: Down

L: Left

R: Right

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

Sample Input 1

0 0 1 2

Sample Output 1

UURDDLLUUURRDRDDDLLU

One possible shortest path is:

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

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

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

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

Sample Input 2

-2 -2 1 1

Sample Output 2

UURRURRDDDLLDLLULUUURRURRDDDLLDL


Score : <var>400</var> points

Problem Statement

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

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

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

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

Constraints

All values in input are integers.

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

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

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

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

Input

Input is given from Standard Input in the following format:

<var>N</var> <var>M</var>
<var>A_1</var> <var>A_2</var> <var>...</var> <var>A_N</var>
<var>B_1</var> <var>C_1</var>
<var>B_2</var> <var>C_2</var>
<var>\vdots</var>
<var>B_M</var> <var>C_M</var>

Output

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

Sample Input 1

3 2
5 1 4
2 3
1 5

Sample Output 1

14

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

Sample Input 2

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

Sample Output 2

338

Sample Input 3

3 2
100 100 100
3 99
3 99

Sample Output 3

300

Sample Input 4

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

Sample Output 4

10000000001

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


Score : <var>200</var> points

Problem Statement

Joisino is working as a receptionist at a theater.

The theater has <var>100000</var> seats, numbered from <var>1</var> to <var>100000</var>.

According to her memo, <var>N</var> groups of audiences have come so far, and the <var>i</var>-th group occupies the consecutive seats from Seat <var>l_i</var> to Seat <var>r_i</var> (inclusive).

How many people are sitting at the theater now?

Constraints

<var>1≤N≤1000</var>

<var>1≤l_i≤r_i≤100000</var>

No seat is occupied by more than one person.

All input values are integers.

Input

Input is given from Standard Input in the following format:

<var>N</var>
<var>l_1</var> <var>r_1</var>
<var>:</var>
<var>l_N</var> <var>r_N</var>

Output

Print the number of people sitting at the theater.

Sample Input 1

1
24 30

Sample Output 1

7

There are <var>7</var> people, sitting at Seat <var>24,25,26,27,28,29</var> and <var>30</var>.

Sample Input 2

2
6 8
3 3

Sample Output 2

4