A meeting room receives n reservations, each a half-open interval [start, end) with start < end. Two reservations overlap if they share at least one instant — formally, if max(start_i, start_j) < min(end_i, end_j). Reservations that merely touch (one ends exactly where another begins) do not overlap. Count the number of unordered pairs of reservations that overlap.
Input format
Line 1: an integer n.
Next n lines: two integers start and end describing one reservation (start < end).
Output format
A single integer: the number of overlapping unordered pairs.
Constraints
- 1 ≤ n ≤ 100000
- 0 ≤ start < end ≤ 1000000000