Merge every set of overlapping intervals and print the result in increasing order.
Input
- Line 1: n (
1 ≤ n ≤ 10^5)
- Next n lines: two integers
start end (start ≤ end)
Output
The merged intervals, one per line, as start end, sorted by start.
Hint
Sort by start first. After sorting, an interval either extends the previous one or begins a new one — there is no third case.
Read from standard input and write to standard output. 5 test cases in total (3 hidden). Tests for this language run inside your browser.