p02661 AtCoder Beginner Contest 169 - Count Median_28731
There are N integers X_1, X_2, \cdots, X_N, and we know that A_i \leq X_i \leq B_i. Find the number of different values that the median of X_1, X_2, \cdots, X_N can take.

Constraints

* 2 \leq N \leq 2 \times 10^5
* 1 \leq A_i \leq B_i \leq 10^9
* All values in input are integers.

Input

Input is given from Standard Input in the following format:


N
A_1 B_1
A_2 B_2
:
A_N B_N


Output

Print the answer.

Examples

Input

2
1 2
2 3


Output

3


Input

3
100 100
10 10000
1 1000000000


Output

9991
#include <bits/stdc++.h>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,LL> PL;

int main(){
  LL n;
  cin>>n;
  LL a[200010],b[200010];
  for(LL i=0;i<n;i++){
    cin>>a[i]>>b[i];
  }
  sort(a,a+n);
  sort(b,b+n);
  if(n%2!=0){
    LL m=n/2;
    cout<<b[m]-a[m]+1<<endl;
   
  }
  else{
    LL m=n/2-1;
    cout<<b[m]+b[m+1]-a[m]-a[m+1]+1<<endl;
  }
  return 0;
}

3
100 100
10 10000
1 1000000000 2
1 2
2 3 3
100 100
8 10000
1 1000000000 2
1 2
2 4 3
100 100
8 11000
1 1000000000 2
1 1
2 4 2
1 1
1 7 2
0 1
1 7 2
0 1
0 7 3
000 010
8 11000
1 1001000000 2
0 1
0 8 3
000 010
8 11000
2 1001000000 3
000 010
8 01000
2 1001000000 2
0 0
0 14 3
010 010
8 01000
2 1001000000 2
0 0
-1 14 3
010 010
8 01010
2 1001000000 2
0 0
-1 23 3
010 010
2 01010
2 1001000000 2
0 1
-1 23 2
0 2
-1 23 2
-1 2
-1 23 3
010 000
4 00111
1 1001000000 2
0 1
-2 1 2
0 2
-2 1 3
001 001
4 00111
0 1001000000 2
1 2
0 0 2
1 2
0 -1 2
2 2
0 -1 3
000 001
2 00111
0 1001000000 2
2 2
1 -1 2
1 2
2 -2 3
100 001
0 00101
0 1001000000 3
111 100
0 00011
0 1001000000 2
0 2
6 0 3
111 100
1 00011
-1 1001010000 3
110 000
1 00011
-1 1001011000 2
0 6
10 -1 2
0 0
10 -1 2
0 0
10 0 2
0 0
6 0 2
1 0
6 0 2
1 0
16 1 2
1 0
19 1 2
2 0
19 1 2
2 0
9 2 3
001 000
1 00110
-1 1001100000 2
3 0
9 0 2
5 0
9 0 2
5 -1
9 0 2
1 -1
11 0 3
011 100
2 00001
-2 1001100010 3
001 100
2 10011
-2 1001000010 3
011 100
2 10011
-2 1001000010 3
000 100
2 10011
-3 1000010010 3
000 100
2 11011
-3 1000010010 3
100 100
2 11011
-3 0000010010 3
100 000
3 10011
-3 0000010010 3
101 000
4 10011
-3 0000010010 3
101 000
4 10001
-3 0000010010 3
111 000
6 10001
-5 0100110010 3
101 000
4 10000
-7 0100110000 3
110 010
2 10000
-12 0100111000 3
000 011
2 10000
-12 0100111000 3
001 110
4 11010
-7 0100111000 3
001 010
4 01010
-7 0100111000 3
101 010
3 01010
-8 0100111000 3
001 010
3 01000
-8 0100111000 3
100 000
8 10010
0 1110101000 2
-9 0
-1 1 2
-17 0
0 1 2
-14 -1
-1 2 2
-19 -2
-2 2 2
-19 -3
-2 2 3
000 110
7 10001
2 1011000010 3
000 100
7 11000
3 1011000010 3
000 100
7 01000
3 1011000010 3
000 101
7 01001
1 0011000010 2
-23 -1
4 1 2
-23 -1
0 1 3
000 101
7 01001
0 0011000010 2
-31 -1
0 1 3
100 101
7 01001
0 0011000010 2
-31 -1
1 1 3
100 101
7 00001
0 0011000010 2
-31 -1
2 1 2
-46 -1
2 1 3
100 101
9 00001
0 0011001010 2
-46 -1
2 0 2
-46 -2
2 0 3
100 101
10 01001
0 0011001010 3
100 101
18 01001
-1 0011001010 3
100 101
19 01001
-1 0011001010 3
100 101
36 01001
-1 0011001000 3
110 101
36 01101
-1 1111001010 3
110 101
66 01101
-2 1111001010 3
110 101
66 11101
-2 1111001010 3
110 111
66 11100
-2 1111001010 3
111 110
111 11100
-2 1111011010 3
011 110
111 11100
-2 1111011010 3
010 110
111 11100
-2 1111011010 3
000 010
010 11100
-2 0111011011
9991 3 9993
 4
 10993
 3
 7
 8
 9
 11000
 10
 10999
 999
 15
 993
 16
 1003
 25
 1009
 26
 27
 28
 108
 5
 6
 111
 2
 1
 0
 112
 -1
 -2
 102
 101
 -3
 100
 11
 -4
 -10
 -9
 -5
 -6
 -15
 -18
 -19
 -8
 110
 -11
 -13
 -14
 -12
 99
 10011
 10010
 10012
 11012
 10009
 10008
 10007
 9998
 9996
 9997
 9999
 10001
 11010
 1010
 1008
 1000
 10003
 12
 19
 17
 22
 21
 10000
 10998
 998
 1001
 20
 24
 1002
 32
 995
 31
 95
 30
 45
 93
 44
 43
 992
 984
 983
 966
 1066
 1036
 11036
 11035
 10990
 11090
 11091
 11101
