#CCBCHBON0000041. Bỏ dòng rỗng liên tiếp (Collapse Consecutive Newlines)

Bỏ dòng rỗng liên tiếp (Collapse Consecutive Newlines)

Collapse Consecutive Newlines

Source: Phước Hưng OJ

Version: Phuoc Hung OJ Extended

Problem Statement

Replace every contiguous run of at least two LF newline characters with exactly one LF. Preserve every other character, including spaces and tabs. At stream boundaries, retain one LF from a run. A line containing spaces is not empty. Do not append a newline at EOF.

Input

A UTF-8 stream of at most 100000 bytes without CR, possibly empty or unterminated.

Output

Print the stream with LF runs collapsed, adding nothing else.

Subtasks

  • Subtask 1 (20%): UTF-8 stream length at most 100 bytes, no CR.

  • Subtask 2 (30%): UTF-8 stream length at most 2000 bytes, no CR.

  • Subtask 3 (50%): UTF-8 stream length at most 100000 bytes, no CR.

Examples

Example 1

Input:

A


B

C

Output:

A
B
C

Explanation:

Keep only the first LF from any consecutive run; spaces remain untouched. Actual escaped input: "A\n\n\nB\n\nC"; escaped output: "A\nB\nC".

Example 2

Input:


Output:


Explanation:

Keep only the first LF from any consecutive run; spaces remain untouched. Actual escaped input: "\n\n\n"; escaped output: "\n".

Example 3

Input:

A 

B

Output:

A 
B

Explanation:

Keep only the first LF from any consecutive run; spaces remain untouched. Actual escaped input: "A \n\nB"; escaped output: "A \nB".

Example 4

Input:


Output:


Explanation:

Keep only the first LF from any consecutive run; spaces remain untouched. Actual escaped input: ""; escaped output: "".

The quoted forms below use \t for a literal tab, \n for an LF, and \ for a literal backslash; they describe the actual byte stream, not additional characters in input.