A - Scoreboard

Time Limit: 2 sec / Memory Limit: 1024 MiB

配点 : 100

問題文

チーム高橋とチーム青木が N 回の試合を行いました。 i 回め (1\leq i\leq N) の試合ではチーム高橋が X _ i 点、チーム青木が Y _ i 点を獲得しました。

N 回の試合で獲得した得点の合計がより多いチームの勝ちです。

どちらのチームが勝ったか出力してください。 ただし、獲得した得点の合計が等しい場合は引き分けとなります。

制約

  • 1\leq N\leq 100
  • 0\leq X _ i\leq 100\ (1\leq i\leq N)
  • 0\leq Y _ i\leq 100\ (1\leq i\leq N)
  • 入力はすべて整数

入力

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

N
X _ 1 Y _ 1
X _ 2 Y _ 2
\vdots
X _ N Y _ N

出力

チーム高橋が勝った場合 Takahashi を、チーム青木が勝った場合 Aoki を、引き分けの場合 Draw を出力せよ。


入力例 1

4
10 2
10 1
10 2
3 2

出力例 1

Takahashi

4 回の試合で、チーム高橋は 33 点、チーム青木は 7 点を獲得しました。 チーム高橋が勝ったため、Takahashi を出力してください。


入力例 2

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

出力例 2

Draw

いずれのチームも 22 点を獲得しました。 引き分けなので、Draw を出力してください。


入力例 3

4
0 0
10 10
50 50
0 100

出力例 3

Aoki

一方もしくは両方のチームが、一試合のうちに 1 点も取れない場合もあります。

Score: 100 points

Problem Statement

Team Takahashi and Team Aoki played N matches. In the i-th match (1\leq i\leq N), Team Takahashi scored X _ i points, and Team Aoki scored Y _ i points.

The team with the higher total score from the N matches wins.

Print the winner. If the two teams have the same total score, it is a draw.

Constraints

  • 1\leq N\leq 100
  • 0\leq X _ i\leq 100\ (1\leq i\leq N)
  • 0\leq Y _ i\leq 100\ (1\leq i\leq N)
  • All input values are integers.

Input

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

N
X _ 1 Y _ 1
X _ 2 Y _ 2
\vdots
X _ N Y _ N

Output

If Team Takahashi wins, print Takahashi; if Team Aoki wins, print Aoki; if it is a draw, print Draw.


Sample Input 1

4
10 2
10 1
10 2
3 2

Sample Output 1

Takahashi

In four matches, Team Takahashi scored 33 points, and Team Aoki scored 7 points. Team Takahashi wins, so print Takahashi.


Sample Input 2

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

Sample Output 2

Draw

Both teams scored 22 points. It is a draw, so print Draw.


Sample Input 3

4
0 0
10 10
50 50
0 100

Sample Output 3

Aoki

One or both teams may score no points in a match.

B - CAPS LOCK

Time Limit: 2 sec / Memory Limit: 1024 MiB

配点 : 100

問題文

英小文字のみからなる文字列 S が与えられます。

S の各文字を英大文字に変換して得られる文字列 T を出力してください。

制約

  • S は英小文字のみからなる、長さが 1 以上 100 以下の文字列

入力

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

S

出力

T を出力せよ。


入力例 1

abc

出力例 1

ABC

abc の各文字を英大文字に変換すると ABC になります。


入力例 2

a

出力例 2

A

入力例 3

abcdefghjiklnmoqprstvuwxyz

出力例 3

ABCDEFGHJIKLNMOQPRSTVUWXYZ

Score : 100 points

Problem Statement

You are given a string S consisting of lowercase English letters.

Uppercase each character of S and print the resulting string T.

Constraints

  • S is a string consisting of lowercase English letters whose length is between 1 and 100, inclusive.

Input

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

S

Output

Print T.


Sample Input 1

abc

Sample Output 1

ABC

Uppercase each character of abc, and you have ABC.


Sample Input 2

a

Sample Output 2

A

Sample Input 3

abcdefghjiklnmoqprstvuwxyz

Sample Output 3

ABCDEFGHJIKLNMOQPRSTVUWXYZ
C - ABC-DEF

Time Limit: 2 sec / Memory Limit: 1024 MiB

配点 : 200

問題文

非負整数 A,B,C,D,E,F があり、A\times B\times C\geq D\times E\times F をみたしています。
(A\times B\times C)-(D\times E\times F) の値を 998244353 で割った余りを求めてください。

制約

  • 0\leq A,B,C,D,E,F\leq 10^{18}
  • A\times B\times C\geq D\times E\times F
  • A,B,C,D,E,F は整数

入力

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

A B C D E F

出力

(A\times B\times C)-(D\times E\times F)998244353 で割った余りを整数で出力せよ。


入力例 1

2 3 5 1 2 4

出力例 1

22

A\times B\times C=2\times 3\times 5=30, D\times E\times F=1\times 2\times 4=8 より、
(A\times B\times C)-(D\times E\times F)=22 であり、これを 998244353 で割った余りである 22 を出力します。


入力例 2

1 1 1000000000 0 0 0

出力例 2

1755647

A\times B\times C=1000000000, D\times E\times F=0 より、
(A\times B\times C)-(D\times E\times F)=1000000000 であり、これを 998244353 で割った余りである 1755647 を出力します。


入力例 3

1000000000000000000 1000000000000000000 1000000000000000000 1000000000000000000 1000000000000000000 1000000000000000000

出力例 3

0

(A\times B\times C)-(D\times E\times F)=0 であり、これを 998244353 で割った余りである 0 を出力します。

Score : 200 points

Problem Statement

There are non-negative integers A, B, C, D, E, and F, which satisfy A\times B\times C\geq D\times E\times F.
Find the remainder when (A\times B\times C)-(D\times E\times F) is divided by 998244353.

Constraints

  • 0\leq A,B,C,D,E,F\leq 10^{18}
  • A\times B\times C\geq D\times E\times F
  • A, B, C, D, E, and F are integers.

Input

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

A B C D E F

Output

Print the remainder when (A\times B\times C)-(D\times E\times F) is divided by 998244353, as an integer.


Sample Input 1

2 3 5 1 2 4

Sample Output 1

22

Since A\times B\times C=2\times 3\times 5=30 and D\times E\times F=1\times 2\times 4=8,
we have (A\times B\times C)-(D\times E\times F)=22. Divide this by 998244353 and print the remainder, which is 22.


Sample Input 2

1 1 1000000000 0 0 0

Sample Output 2

1755647

Since A\times B\times C=1000000000 and D\times E\times F=0,
we have (A\times B\times C)-(D\times E\times F)=1000000000. Divide this by 998244353 and print the remainder, which is 1755647.


Sample Input 3

1000000000000000000 1000000000000000000 1000000000000000000 1000000000000000000 1000000000000000000 1000000000000000000

Sample Output 3

0

We have (A\times B\times C)-(D\times E\times F)=0. Divide this by 998244353 and print the remainder, which is 0.

D - Delimiter

Time Limit: 2 sec / Memory Limit: 1024 MiB

配点 : 150

問題文

N 個の整数 A_1,A_2,\dots,A_N が、 1 行に 1 つずつ、 N 行にわたって与えられます。但し、 N は入力では与えられません。
さらに、以下が保証されます。

  • A_i \neq 0 ( 1 \le i \le N-1 )
  • A_N = 0

A_N, A_{N-1},\dots,A_1 をこの順に出力してください。

制約

  • 入力は全て整数
  • 1 \le N \le 100
  • 1 \le A_i \le 10^9 ( 1 \le i \le N-1 )
  • A_N = 0

入力

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

A_1
A_2
\vdots
A_N

出力

A_N, A_{N-1},\dots,A_1 をこの順に、改行区切りで整数として出力せよ。


入力例 1

3
2
1
0

出力例 1

0
1
2
3

繰り返しになりますが、 N は入力では与えられないことに注意してください。
この入力においては N=4 で、 A=(3,2,1,0) です。


入力例 2

0

出力例 2

0

A=(0) です。


入力例 3

123
456
789
987
654
321
0

出力例 3

0
321
654
987
789
456
123

Score: 150 points

Problem Statement

You are given N integers A_1,A_2,\dots,A_N, one per line, over N lines. However, N is not given in the input.
Furthermore, the following is guaranteed:

  • A_i \neq 0 ( 1 \le i \le N-1 )
  • A_N = 0

Print A_N, A_{N-1},\dots,A_1 in this order.

Constraints

  • All input values are integers.
  • 1 \le N \le 100
  • 1 \le A_i \le 10^9 ( 1 \le i \le N-1 )
  • A_N = 0

Input

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

A_1
A_2
\vdots
A_N

Output

Print A_N, A_{N-1}, \dots, A_1 in this order, as integers, separated by newlines.


Sample Input 1

3
2
1
0

Sample Output 1

0
1
2
3

Note again that N is not given in the input. Here, N=4 and A=(3,2,1,0).


Sample Input 2

0

Sample Output 2

0

A=(0).


Sample Input 3

123
456
789
987
654
321
0

Sample Output 3

0
321
654
987
789
456
123
E - Connect 6

Time Limit: 3 sec / Memory Limit: 1024 MiB

配点 : 300

問題文

NN 列のマス目があり、それぞれのマスは白または黒で塗られています。
マス目の状態は N 個の文字列 S_i で表され、 S_ij 文字目が # であることはマス目の上から i 行目、左から j 列目のマスが黒く塗られていることを、 . であることは白く塗られていることをさします。

高橋君はこのマス目のうち高々 2 つの白く塗られているマスを選び、黒く塗ることができます。
マス目の中に、黒く塗られたマスが縦、横、ななめのいずれかの向きに 6 つ以上連続するようにできるか判定してください。
ただし、黒く塗られたマスがななめに 6 つ以上連続するとは、NN 列のマス目に完全に含まれる 66 列のマス目であって、その少なくとも一方の対角線上のマスがすべて黒く塗られているようなものが存在する事をさします。

制約

  • 6 \leq N \leq 1000
  • \lvert S_i\rvert =N
  • S_i#. のみからなる。

入力

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

N
S_1
S_2
\vdots
S_N

出力

高々 2 つのマス目を黒く塗ることで条件をみたすようにできるなら Yes を、そうでないならば No を出力せよ。


入力例 1

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

出力例 1

Yes

上から 3 行目の左から 3, 6 番目のマスを塗ることで横方向に 6 つの黒く塗られたマスを連続させることができます。


入力例 2

6
######
######
######
######
######
######

出力例 2

Yes

高橋君はマス目を新たに黒く塗ることはできませんが、すでにこのマス目は条件をみたしています。


入力例 3

10
..........
#..##.....
..........
..........
....#.....
....#.....
.#...#..#.
..........
..........
..........

出力例 3

No

Score : 300 points

Problem Statement

There is a grid with N horizontal rows and N vertical columns, where each square is painted white or black.
The state of the grid is represented by N strings, S_i. If the j-th character of S_i is #, the square at the i-th row from the top and the j-th column from the left is painted black. If the character is ., then the square is painted white.

Takahashi can choose at most two of these squares that are painted white, and paint them black.
Determine if it is possible to make the grid contain 6 or more consecutive squares painted black aligned either vertically, horizontally, or diagonally.
Here, the grid is said to be containing 6 or more consecutive squares painted black aligned diagonally if the grid with N rows and N columns completely contains a subgrid with 6 rows and 6 columns such that all the squares on at least one of its diagonals are painted black.

Constraints

  • 6 \leq N \leq 1000
  • \lvert S_i\rvert =N
  • S_i consists of # and ..

Input

Input is given from Standard Input in the following format:

N
S_1
S_2
\vdots
S_N

Output

If it is possible to fulfill the condition by painting at most two squares, then print Yes; otherwise, print No.


Sample Input 1

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

Sample Output 1

Yes

By painting the 3-rd and the 6-th squares from the left in the 3-rd row from the top, there will be 6 squares painted black aligned horizontally.


Sample Input 2

6
######
######
######
######
######
######

Sample Output 2

Yes

While Takahashi cannot choose a square to paint black, the grid already satisfies the condition.


Sample Input 3

10
..........
#..##.....
..........
..........
....#.....
....#.....
.#...#..#.
..........
..........
..........

Sample Output 3

No