A - Three-letter acronym

Time Limit: 2 sec / Memory Limit: 256 MB

配点 : 100

問題文

英小文字からなる 3 つの単語 s_1, s_2, s_3 が空白区切りで与えられるので、単語の先頭の文字をつなげ、大文字にした略語を出力してください。

制約

  • s_1, s_2, s_3 は英小文字からなる。
  • 1 ≦|s_i|≦ 10 (1≦i≦3)

入力

入力は以下の形式で標準入力から与えられる。

s_1 s_2 s_3

出力

答えを出力せよ。


入力例 1

atcoder beginner contest

出力例 1

ABC

atcoder beginner contest の先頭の文字はそれぞれa b cなので、ABCが答えになります。


入力例 2

resident register number

出力例 2

RRN

入力例 3

k nearest neighbor

出力例 3

KNN

入力例 4

async layered coding

出力例 4

ALC

Score : 100 points

Problem Statement

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

Constraints

  • s_1, s_2 and s_3 are composed of lowercase English letters.
  • 1 ≤ |s_i| ≤ 10 (1≤i≤3)

Input

Input is given from Standard Input in the following format:

s_1 s_2 s_3

Output

Print the answer.


Sample Input 1

atcoder beginner contest

Sample Output 1

ABC

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


Sample Input 2

resident register number

Sample Output 2

RRN

Sample Input 3

k nearest neighbor

Sample Output 3

KNN

Sample Input 4

async layered coding

Sample Output 4

ALC
B - Comparison

Time Limit: 2 sec / Memory Limit: 256 MB

配点 : 200

問題文

2 つの正整数 A, B が与えられるので、その大小を比較してください。

制約

  • 1≦A, B ≦ 10^{100}
  • 入力の A, B の先頭は0でない。

入力

入力は以下の形式で標準入力から与えられる。

A
B

出力

A>B のときGREATERA<B のときLESSA=B のときEQUALと出力せよ。


入力例 1

36
24

出力例 1

GREATER

36>24 なので、答えはGREATERです。


入力例 2

850
3777

出力例 2

LESS

入力例 3

9720246
22516266

出力例 3

LESS

入力例 4

123456789012345678901234567890
234567890123456789012345678901

出力例 4

LESS

Score : 200 points

Problem Statement

You are given two positive integers A and B. Compare the magnitudes of these numbers.

Constraints

  • 1 ≤ A, B ≤ 10^{100}
  • Neither A nor B begins with a 0.

Input

Input is given from Standard Input in the following format:

A
B

Output

Print GREATER if A>B, LESS if A<B and EQUAL if A=B.


Sample Input 1

36
24

Sample Output 1

GREATER

Since 36>24, print GREATER.


Sample Input 2

850
3777

Sample Output 2

LESS

Sample Input 3

9720246
22516266

Sample Output 3

LESS

Sample Input 4

123456789012345678901234567890
234567890123456789012345678901

Sample Output 4

LESS
C - Sequence

Time Limit: 2 sec / Memory Limit: 256 MB

配点 : 300

問題文

長さ N の数列があり、i 番目の数は a_i です。 あなたは 1 回の操作でどれか 1 つの項の値を 1 だけ増やすか減らすことができます。

以下の条件を満たすために必要な操作回数の最小値を求めてください。

  • すべてのi (1≦i≦n) に対し、第 1 項から第 i 項までの和は 0 でない
  • すべてのi (1≦i≦n-1) に対し、i 項までの和と i+1 項までの和の符号が異なる

制約

  • 2≦ n ≦ 10^5
  • |a_i| ≦ 10^9
  • a_i は整数

入力

入力は以下の形式で標準入力から与えられる。

n
a_1 a_2 ... a_n

出力

必要な操作回数の最小値を出力せよ。


入力例 1

4
1 -3 1 0

出力例 1

4

例えば、数列を 1, -2, 2, -24 回の操作で変更することができます。この数列は 1, 2, 3, 4 項までの和がそれぞれ 1, -1, 1, -1 であるため、条件を満たしています。


入力例 2

5
3 -6 4 -5 7

出力例 2

0

はじめから条件を満たしています。


入力例 3

6
-1 4 3 2 -5 4

出力例 3

8

Score : 300 points

Problem Statement

You are given an integer sequence of length N. The i-th term in the sequence is a_i. In one operation, you can select a term and either increment or decrement it by one.

At least how many operations are necessary to satisfy the following conditions?

  • For every i (1≤i≤n), the sum of the terms from the 1-st through i-th term is not zero.
  • For every i (1≤i≤n-1), the sign of the sum of the terms from the 1-st through i-th term, is different from the sign of the sum of the terms from the 1-st through (i+1)-th term.

Constraints

  • 2 ≤ n ≤ 10^5
  • |a_i| ≤ 10^9
  • Each a_i is an integer.

Input

Input is given from Standard Input in the following format:

n
a_1 a_2 ... a_n

Output

Print the minimum necessary count of operations.


Sample Input 1

4
1 -3 1 0

Sample Output 1

4

For example, the given sequence can be transformed into 1, -2, 2, -2 by four operations. The sums of the first one, two, three and four terms are 1, -1, 1 and -1, respectively, which satisfy the conditions.


Sample Input 2

5
3 -6 4 -5 7

Sample Output 2

0

The given sequence already satisfies the conditions.


Sample Input 3

6
-1 4 3 2 -5 4

Sample Output 3

8
D - Alice&Brown

Time Limit: 2 sec / Memory Limit: 256 MB

配点 : 500

問題文

AliceとBrownはゲームをするのが好きです。今日は以下のゲームを思いつきました。

2つの山があり、はじめにX, Y個の石が置かれています。 AliceとBrownは毎ターン以下の操作を交互に行い、操作を行えなくなったプレイヤーは負けとなります。

  • 片方の山から 2i 個の石を取り、そのうち i 個の石を捨て、残りの i 個の石をもう片方の山に置く。ここで、整数 i (1≦i) の値は山に十分な個数の石がある範囲で自由に選ぶことができる。

Aliceが先手で、二人とも最適にプレイすると仮定したとき、与えられた X, Y に対しどちらのプレイヤーが勝つか求めてください。

制約

  • 0≦ X, Y ≦ 10^{18}

入力

入力は以下の形式で標準入力から与えられる。

X Y

出力

Aliceが勝つときAliceと、Brownが勝つときBrownと出力せよ。


入力例 1

2 1

出力例 1

Brown

Aliceは 2 個石のある山から 2 個取るしかありません。その結果、山の石の数はそれぞれ 0, 2 個となり、Brownは 2 個の石を取り、山の石の数はそれぞれ 1, 0 個となります。 Aliceはこれ以上操作を行うことができないので、Brownの勝ちです。


入力例 2

5 0

出力例 2

Alice

入力例 3

0 0

出力例 3

Brown

入力例 4

4 8

出力例 4

Alice

Score : 500 points

Problem Statement

Alice and Brown loves games. Today, they will play the following game.

In this game, there are two piles initially consisting of X and Y stones, respectively. Alice and Bob alternately perform the following operation, starting from Alice:

  • Take 2i stones from one of the piles. Then, throw away i of them, and put the remaining i in the other pile. Here, the integer i (1≤i) can be freely chosen as long as there is a sufficient number of stones in the pile.

The player who becomes unable to perform the operation, loses the game.

Given X and Y, determine the winner of the game, assuming that both players play optimally.

Constraints

  • 0 ≤ X, Y ≤ 10^{18}

Input

Input is given from Standard Input in the following format:

X Y

Output

Print the winner: either Alice or Brown.


Sample Input 1

2 1

Sample Output 1

Brown

Alice can do nothing but taking two stones from the pile containing two stones. As a result, the piles consist of zero and two stones, respectively. Then, Brown will take the two stones, and the piles will consist of one and zero stones, respectively. Alice will be unable to perform the operation anymore, which means Brown's victory.


Sample Input 2

5 0

Sample Output 2

Alice

Sample Input 3

0 0

Sample Output 3

Brown

Sample Input 4

4 8

Sample Output 4

Alice