Məsələlər
Segments
Segments
\textbf{n} segments \[\textbf{a_i}, \textbf{b_i}\] are given on a coordinate line. Find the number of pairs (\textbf{i}, \textbf{j}) such that \textbf{i} < \textbf{j} and segments \[\textbf{a_i}, \textbf{b_i}\] and \[\textbf{a_j}, \textbf{b_j}\] have at least one common point.
\InputFile
The first line contains an integer \textbf{n} (\textbf{1} ≤ \textbf{n} ≤ \textbf{10^5}). Each of the next \textbf{n} lines contains numbers \textbf{a_i} and \textbf{b_i} - the end points of a corresponding segment (\textbf{-10^9} ≤ \textbf{a_i}, \textbf{b_i} ≤ \textbf{10^9}).
\OutputFile
Print the number of pairs of intersecting segments.
Giriş verilənləri #1
3 0 1 1 2 2 3
Çıxış verilənləri #1
2
Giriş verilənləri #2
4 0 6 2 3 1 4 5 7
Çıxış verilənləri #2
4