B - Up and Down Editorial /

Time Limit: 2 sec / Memory Limit: 1024 MB

注意

この問題に対する言及は、2019年12月29日 05:00 JST まで禁止されています。言及がなされた場合、賠償が請求される可能性があります。

試験後に総合得点や認定級を公表するのは構いませんが、どの問題が解けたかなどの情報は発信しないようにお願いします。

問題文

ある商品の N 日間の売上が整数列 A_1, A_2, \ldots, A_N として与えられる。A_i (1 \leqq i \leqq N)i 日目の売上を表す。

あなたは、2 日目以降の各日について、その日の売上が前日の売上よりどれだけ高かったか (あるいは低かったか) を出力するプログラムを作成することにした。

より具体的には、プログラムは N-1 行を出力し、i 行目 (1 \leqq i \leqq N-1) の内容は次の通りである。

  • A_{i+1}A_i と等しい場合: stay
  • A_{i+1}A_i より小さい場合: down [減少量]、ここで [減少量] は整数値 A_i - A_{i+1}
  • A_{i+1}A_i より大きい場合: up [増加量]、ここで [増加量] は整数値 A_{i+1} - A_i

このプログラムを作成せよ。

制約

  • 2 \leqq N \leqq 100,000
  • 0 \leqq A_i \leqq 1,000,000,000
  • 入力中の値はすべて整数である。

入力

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

N
A_1
A_2
:
A_{N}

出力

問題文で指示された通りに N - 1 行を出力せよ。


入力例 1

10
9
10
3
100
100
90
80
10
30
10

出力例 1

up 1
down 7
up 97
stay
down 10
down 10
down 70
up 20
down 20

N = 10 日間の売上が与えられている。出力の最初の 4 行について説明する。

  • 1 行目: A_2 = 10A_1 = 9 より 1 大きいため up 1 と出力する。
  • 2 行目: A_3 = 3A_2 = 10 より 7 小さいため down 7 と出力する。
  • 3 行目: A_4 = 100A_3 = 3 より 97 大きいため up 97 と出力する。
  • 4 行目: A_5 = 100A_4 = 100 と等しいため stay と出力する。

Warning

Do not make any mention of this problem until December 29, 2019, 05:00 a.m. JST. In case of violation, compensation may be demanded.

After the examination, you can reveal your total score and grade to others, but nothing more (for example, which problems you solved).

Problem Statement

Given is a series of sales of a certain product for N days, as an integer sequence A_1, A_2, \ldots, A_N. A_i (1 \leq i \leq N) represents the sale for the i-th day.

You decide to write a program that, for each day starting with the second day, prints how much the sales increased (or decreased) compared to the previous day.

More specifically, your program should print N-1 lines. The i-th line (1 \leq i \leq N-1) should contain the following:

  • If A_{i+1} is equal to A_i: stay
  • If A_{i+1} is less than A_i: down [amount], where [amount] is the integer value A_i - A_{i+1}
  • If A_{i+1} is greater than A_i: up [amount], where [amount] is the integer value A_{i+1} - A_i

Write this program.

Constraints

  • 2 \leq N \leq 100000
  • 0 \leq A_i \leq 10^9
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

N
A_1
A_2
:
A_{N}

Output

Print N - 1 lines, as specified in Problem Statement.


Sample Input 1

10
9
10
3
100
100
90
80
10
30
10

Sample Output 1

up 1
down 7
up 97
stay
down 10
down 10
down 70
up 20
down 20

Given is a series of sales for N = 10 days. Let us explain the first four lines in the output:

  • Line 1: A_2 = 10 is greater than A_1 = 9 by 1, so print up 1.
  • Line 2: A_3 = 3 is smaller than A_2 = 10 by 7, so print down 7.
  • Line 3: A_4 = 100 is greater than A_3 = 3 by 97, so print up 97.
  • Line 4: A_5 = 100 is equal to A_4 = 100, so print stay.