[ABC377D] 避开所有区间 (Many Segments 2)
Score : points
Problem Statement
You are given two sequences of positive integers of length , and , and an integer .
Find the number of pairs of integers that satisfy both of the following conditions:
-
-
For every , the interval does not completely contain the interval .
Constraints
-
-
-
All input values are integers.
Input
The input is given from Standard Input in the following format:
$N$ $M$
$L_1$ $R_1$
$L_2$ $R_2$
$\vdots$
$L_N$ $R_N$
Output
Print the answer.
Sample Input 1
2 4
1 2
3 4
Sample Output 1
5
The five pairs satisfy the conditions.
For example, does not satisfy the conditions because the interval completely contains the interval .
Sample Input 2
6 5
1 1
2 2
3 3
4 4
5 5
1 5
Sample Output 2
0
There may be cases where no pairs of integers satisfy the conditions.
Sample Input 3
6 20
8 12
14 20
11 13
5 19
4 11
1 6
Sample Output 3
102