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.

-----Notes-----
The median of X_1, X_2, \cdots, X_N is defined as follows. Let x_1, x_2, \cdots, x_N be the result of sorting X_1, X_2, \cdots, X_N in ascending order.
 - If N is odd, the median is x_{(N+1)/2};
 - if N is even, the median is (x_{N/2} + x_{N/2+1}) / 2.

-----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.

-----Sample Input-----
2
1 2
2 3

-----Sample Output-----
3

 - If X_1 = 1 and X_2 = 2, the median is \frac{3}{2};
 - if X_1 = 1 and X_2 = 3, the median is 2;
 - if X_1 = 2 and X_2 = 2, the median is 2;
 - if X_1 = 2 and X_2 = 3, the median is \frac{5}{2}.
Thus, the median can take three values: \frac{3}{2}, 2, and \frac{5}{2}.

Difficulty: interview

Starter code:

Solutions:
import numpy as np

N, *AB = list(map(int, open(0).read().split()))
min_med = np.median([a for a in AB[::2]])
max_med = np.median([b for b in AB[1::2]])
if N % 2:
    print((int(max_med - min_med) + 1))
else:
    print((int(max_med * 2 - min_med * 2) + 1))


N=int(input())
A=[]
B=[]
for i in range(N):
  a,b=map(int,input().split())
  A.append(a)
  B.append(b)
A.sort()
B.sort()

if N%2==1:
  Amed=A[N//2]
  Bmed=B[N//2]
  print(Bmed-Amed+1)
else:
  Amed=(A[N//2]+A[N//2-1])/2
  Bmed=(B[N//2]+B[N//2-1])/2
  print(round((Bmed-Amed)*2+1))

# -*- coding:utf-8 -*-

def solve():
    N = int(input())
    Ls, Rs = [], []
    for i in range(N):
        a, b = list(map(int, input().split()))
        Ls.append(a), Rs.append(b)
    Ls.sort(), Rs.sort()

    ans = 0
    if N%2 == 1:
        # Nが奇数なら
        l = Ls[N//2]
        r = Rs[N//2]
        ans = r-l+1
    else:
        # Nが偶数なら
        l2 = Ls[N//2-1]+Ls[N//2]
        r2 = Rs[N//2-1]+Rs[N//2]
        ans = r2-l2+1

    print(ans)


def __starting_point():
    solve()

__starting_point()

n = int(input())
arr_a = []
arr_b = []
for i in range(n):
    a, b = map(int, input().split())
    arr_a.append(a)
    arr_b.append(b)
arr_a.sort()
arr_b.sort()
if n % 2 == 1:
    print(arr_b[n//2] - arr_a[n//2] + 1)
else:
    median_a = (arr_a[int(n/2 -1)] + arr_a[int(n/2)])
    median_b = (arr_b[int(n/2 -1)] + arr_b[int(n/2)])
    print(median_b - median_a + 1)

n=int(input())
a,b=[],[]
for i in range(n):
    c,d=map(int,input().split())
    a.append(c)
    b.append(d)
a.sort()
b.sort(reverse=True)
if n%2==1:
    ac=a[(n+1)//2-1]
    bc=b[(n+1)//2-1]
    ans=bc-ac
else:
    ac=(a[n//2-1]+a[n//2])
    bc=(b[n//2-1]+b[n//2])
    ans=bc-ac
print(ans+1)

n = int(input())
l = []
r = []
for _ in range(n):
  a, b = list(map(int, input().split()))
  l.append(a)
  r.append(b)
l.sort()
r.sort()
if n % 2 == 1:
  l_mid = l[n // 2]
  r_mid = r[n // 2]
  print((r_mid - l_mid + 1))
else:
  l_mid = (l[n // 2] + l[n // 2 - 1]) / 2
  r_mid = (r[n // 2] + r[n // 2 - 1]) / 2
  print((int((r_mid - l_mid) * 2) + 1))


import collections
N = int(input())
A = [0] * N
B = [0] * N
for i in range(N):
    a, b = map(int, input().split())
    A[i] = a
    B[i] = b
A.sort()
B.sort()
N_q, N_mod = divmod(N, 2)
if N_mod == 1:
    ans = B[N_q] - A[N_q] + 1
else:
    ans = B[N_q - 1] - A[N_q - 1] + B[N_q] - A[N_q] + 1
print(ans)

from statistics import median

N = int(input())
A = [0] * N
B = [0] * N
for c in range(N):
    A[c], B[c] = list(map(int, input().split()))

A_med = median(A)
B_med = median(B)

if N % 2 == 0:
    print((round(2 * (B_med - A_med) + 1)))
else:
    print((B_med - A_med + 1))


#!/usr/bin/env python3
import sys
from itertools import chain
import numpy as np

# from itertools import combinations as comb
# form bisect import bisect_left, bisect_right, insort_left, insort_right
# from collections import Counter


def solve(N: int, A: "List[int]", B: "List[int]"):
    A = sorted(A)
    B = sorted(B)
    if N % 2 == 1:
        l = A[N // 2]
        r = B[N // 2]
        return r - l + 1
    else:
        l2 = A[N // 2 - 1] + A[N // 2]
        r2 = B[N // 2 - 1] + B[N // 2]
        return r2 - l2 + 1


def main():
    tokens = chain(*(line.split() for line in sys.stdin))
    # N, A, B = map(int, line.split())
    N = int(next(tokens))  # type: int
    AB = np.array(list(map(int, tokens)), dtype=np.int32)
    A = AB[0::2]
    B = AB[1::2]
    answer = solve(N, A, B)
    print(answer)


def __starting_point():
    main()

__starting_point()

import statistics
N = int(input())
AB = [map(int, input().split()) for _ in range(N)]
A,B = [list(i) for i in zip(*AB)]
if N%2 == 1:
    low_med = statistics.median(A)
    high_med = statistics.median(B)
    print(high_med - low_med +1)
else:
    low_med = statistics.median(A)
    high_med = statistics.median(B)
    print(int(2 * (high_med - low_med) +1))

N = int(input())
AB = [list(map(int, input().split())) for _ in range(N)]
A, B = map(list, zip(*AB))

A.sort()
B.sort()

def median(a):
    n = N
    return a[(n+1)//2-1] if n%2 else (a[n//2-1]+a[n//2])/2

A_mid = median(A)
B_mid = median(B)

r = int((B_mid-A_mid) * [2, 1][N%2]) + 1

print(r)

ni = lambda: int(input())
nm = lambda: list(map(int, input().split()))
nl = lambda: list(map(int, input().split()))

n=ni()
mins=[]
maxs=[]
for i in range(n):
  a,b=nm()
  mins.append(a)
  maxs.append(b)

smn = sorted(mins)
smx = sorted(maxs)

if n%2==1:
  mn = smn[(n+1)//2-1]
  mx = smx[(n+1)//2-1]
  print((round((mx-mn)+1)))
else:
  mn = (smn[n//2-1]+smn[n//2])/2.0
  mx = (smx[n//2-1]+smx[n//2])/2.0
  print((round((mx-mn)*2+1)))


n = int(input())
a = []
b = []
for i in range(n):
    s,t = map(int,input().split())
    a.append(s)
    b.append(t)
a.sort()
b.sort()
if n%2 == 0:
    am = (a[n//2-1]+a[n//2])/2
    bm = (b[n//2-1]+b[n//2])/2
    print(int((bm-am)*2+1))
else:
    am = a[(n-1)//2]
    bm = b[(n-1)//2]
    print(bm-am+1)

import sys
input = sys.stdin.readline
N = int(input())
AB = [tuple(map(int,input().split())) for i in range(N)]
A = []
B = []
for a,b in AB:
    A.append(a)
    B.append(b)
A.sort()
B.sort()

if N%2==0:
    m = N//2
    b = B[m] + B[m-1]
    a = A[m] + A[m-1]
    print(b - a + 1)
else:
    m = N//2
    print(B[m] - A[m] + 1)

from statistics import median
 
X = []
X1 = []
N=int(input())
for i in range(N):
    a, b = map(int, input().split())
    X.append(a)
    X1.append(b)
 
m1 = median(X)
m2 = median(X1)
if len(X) % 2:
    print(int((m2 - m1) + 1))
else:
    print(int(2 * (m2 - m1) + 1))

import sys

import bisect


def input():
    return sys.stdin.readline().rstrip()


def main():
    N = int(input())
    A = []
    B = []
    for i in range(N):
        a, b = list(map(int, input().split()))
        A.append(a)
        B.append(b)
    pass
    A.sort()
    B.sort()
    if N % 2 == 0:
        n = N // 2
        mini = (A[n]+A[n-1]) /2
        maxi = (B[n]+B[n-1]) /2
        print((int((maxi-mini)*2)+1))
    else:
        n = N//2
        mini = A[n]
        maxi = B[n]
        print((maxi-mini+1))



def __starting_point():
    main()

__starting_point()

#!/usr/bin/env python3
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

N = int(input())
A = [0 for i in range(N)]
B = [0 for i in range(N)]
for i in range(N):
    a,b = LI()
    A[i] = a
    B[i] = b

A.sort()
B.sort()

if N % 2 == 1:
    min_mid = A[(N - 1) // 2]
else:
    min_mid = (A[N //2 - 1] + A[N//2]) / 2

if N % 2 == 1:
    max_mid = B[(N - 1) // 2]
else:
    max_mid = (B[N //2 - 1] + B[N//2]) / 2 

if N % 2 == 0:
    print((int((max_mid - min_mid) / 0.5 + 1)))
else:
    print((math.ceil(max_mid) - math.floor(min_mid) + 1))




N, *AB = list(map(int, open(0).read().split()))
A = sorted(a for a in AB[::2])
B = sorted(b for b in AB[1::2])
if N % 2:
    print((B[N // 2] - A[N // 2] + 1))
else:
    print((B[N // 2 - 1] + B[N // 2] - A[N // 2 - 1] - A[N // 2] + 1))


def main(N, lines):
    a = sorted([line[0] for line in lines])
    b = sorted([line[1] for line in lines])

    if N % 2 == 1:
        mi = a[N // 2]
        ma = b[N // 2]
        print((int(ma - mi + 1)))
    else:
        mi = (a[N // 2 - 1] + a[N // 2])
        ma = (b[N // 2 - 1] + b[N // 2])
        print((int(ma - mi + 1)))


N = int(input())
lines = []
for i in range(N):
    lines.append(list(map(int, input().split())))
main(N, lines)


def main():
    import sys
    input = sys.stdin.readline

    N = int(input())
    A = []
    B = []
    for _ in range(N):
        a, b = list(map(int, input().split()))
        A.append(a)
        B.append(b)
    A.sort()
    B.sort()

    if N & 1:
        j = (N - 1) // 2
        ans = B[j] - A[j] + 1
        print(ans)
        return

    j = N // 2 - 1
    k = N // 2
    ans = (B[j] + B[k]) - (A[j] + A[k]) + 1
    print(ans)
    return


def __starting_point():
    main()

__starting_point()

N = int(input())
t = N // 2
a_list = []
b_list = []
for i in range(N):
    ab = list(map(int, input().split()))
    a_list.append(ab[0])
    b_list.append(ab[1])

a_list = sorted(a_list)
b_list = sorted(b_list)

if N%2 == 1:
    a_median = a_list[t]
    b_median = b_list[t]
    print(b_median-a_median+1)
elif N%2 == 0:
    a_median = (a_list[t-1]+a_list[t])/2
    b_median = (b_list[t-1]+b_list[t])/2
    print(int(2*(b_median-a_median)+1))

#!/usr/bin/env python3
import sys
from itertools import chain
import numpy as np

# from itertools import combinations as comb
# form bisect import bisect_left, bisect_right, insort_left, insort_right
# from collections import Counter


def solve(N: int, A: "List[int]", B: "List[int]"):
    A = np.sort(A)
    B = np.sort(B)
    if N % 2 == 1:
        l = A[N // 2]
        r = B[N // 2]
        return r - l + 1
    else:
        l2 = A[N // 2 - 1] + A[N // 2]
        r2 = B[N // 2 - 1] + B[N // 2]
        return r2 - l2 + 1


def main():
    tokens = chain(*(line.split() for line in sys.stdin))
    # N, A, B = map(int, line.split())
    N = int(next(tokens))  # type: int
    AB = np.array(list(map(int, tokens)), dtype=np.int32)
    A = AB[0::2]
    B = AB[1::2]
    answer = solve(N, A, B)
    print(answer)


def __starting_point():
    main()

__starting_point()

n=int(input())
s,t=[],[]
for i in range(n):
    a,b=map(int,input().split())
    s.append(a)
    t.append(b)
s=sorted(s)
t=sorted(t)
if n%2==0:
    print(t[n//2-1]+t[n//2]-s[n//2-1]-s[n//2]+1)
else:
    print(t[n//2]-s[n//2]+1)

def main():
    n = int(input())
    a = [None]*n
    b = [None]*n
    for i in range(n):
        a[i], b[i] = map(int, input().split())
    a.sort()
    b.sort()
    if n&1:
        print(b[n//2]-a[n//2]+1)
    else:
        print(b[n//2-1]+b[n//2]-a[n//2-1]-a[n//2]+1)
        

def __starting_point():
    main()
__starting_point()

N=int(input())
A,B=[],[]
for i in range(N):
  a,b=map(int,input().split())
  A.append(a)
  B.append(b)
  
A,B=map(sorted,(A,B))

if N % 2 == 1:
  mA, mB = A[N//2],B[N//2]
  print(mB-mA+1)
else:
  mA, mB = (A[N//2-1]+A[N//2])/2,(B[N//2-1]+B[N//2])/2
  print(int((mB-mA)/0.5+0.5)+1)

from numpy import*
t=loadtxt(open(0),skiprows=1)
a,b=median(t,0)
print(int((b-a)*(2-len(t)%2))+1)

# -*- coding: utf-8 -*-

N = int(input().strip())
AB_list = [list(map(int, input().rstrip().split())) for i in range(N)]
#-----

A_list,B_list = list(map(list, list(zip(*AB_list))))

A_list.sort()
B_list.sort()


if N%2 == 0:
    Med_A = A_list[ (N-1)//2 ] + A_list[ (N-1)//2 + 1 ]
    Med_B = B_list[ (N-1)//2 ] + B_list[ (N-1)//2 + 1 ]
    
else:
    Med_A = A_list[ (N-1)//2 ]
    Med_B = B_list[ (N-1)//2 ]


Med_range = Med_B - Med_A + 1
print(Med_range)


import statistics
n=int(input())
 
la, lb = [], []
for _ in range(n):
  a, b = map(int, input().split())
  la.append(a)
  lb.append(b)
c=statistics.median(la)
d=statistics.median(lb)
if n%2==1:
  print(d-c+1)
else:
  print(int(2*d-2*c+1))

n = int(input())
l = []
r = []
for _ in range(n):
    a, b = map(int, input().split())
    l.append(a)
    r.append(b)
l.sort()
r.sort()
if n % 2 == 1:
    l_mid = l[n // 2]
    r_mid = r[n // 2]
    print(r_mid - l_mid + 1)
else:
    l_mid = (l[n // 2] + l[n // 2 - 1]) / 2
    r_mid = (r[n // 2] + r[n // 2 - 1]) / 2
    print(int(r_mid * 2 - l_mid * 2) + 1)

import statistics
N = int(input())
A = [0] * N
B = [0] * N
for i in range(N):
    A[i], B[i] = map(int, input().split())
A.sort()
B.sort()
if N%2==1:
  print(statistics.median(B)-statistics.median(A)+1)
else:
  print(int(statistics.median(B)*2-statistics.median(A)*2+1))

import statistics
N= int(input())
min_all=[]
max_all = []
for _ in range(N):
    a,b=list(map(int,input().split()))
    min_all.append(a)
    max_all.append(b)
min_median = statistics.median(min_all)
max_median = statistics.median(max_all)
if N%2:
    ans = max_median - min_median+1
else:
    ans = int((max_median - min_median +0.5)*2)
print(ans)


N = int(input())
A = [0 for _ in range(N)]
B = [0 for _ in range(N)]
import statistics
for k in range(N):
  A[k], B[k] = map(int, input().split())

if N%2 == 1:
  print(statistics.median(B) - statistics.median(A) +1)
else:
  print(int((statistics.median(B) - statistics.median(A))*2 +1))

import numpy as np

N = int(input())
A = []
B = []

for i in range(N):
    a, b = [int(x) for x in input().split()]
    A.append(a)
    B.append(b)

C = np.array(A)
D = np.array(B)

m_inf = np.median(C)
m_sup = np.median(D)

if N % 2 == 0:
    ans = 2 * m_sup - 2 * m_inf + 1
else:
    ans = m_sup - m_inf + 1

print(int(ans))

def solve(n, a, b):
    l = (n+1)//2 - 1
    r = l + 1 + (n%2==0)
    lb = sum(sorted(a)[l:r])
    ub = sum(sorted(b)[l:r])
    return (ub - lb) + 1

n = int(input())
a = [0] * n
b = [0] * n
for i in range(n):
    a[i], b[i] = map(int, input().split())
print(solve(n, a, b))

N = int(input())
t = N//2
la, lb = [], []
for _ in range(N):
    A, B = list(map(int, input().split()))
    la.append(A)
    lb.append(B)
la.sort()
lb.sort()
print((lb[t]-la[t]+1 if N%2 else lb[t-1]-la[t]+lb[t]-la[t-1]+1))


import statistics
n=int(input())
la, lb = [], []
for _ in range(n):
  a, b =list(map(int, input().split()))
  la.append(a)
  lb.append(b)
c=statistics.median(la)
d=statistics.median(lb)
if n%2==1:
  print((d-c+1))
else:
  print((int(2*d-2*c+1)))









N = int(input())

AB = []

for _ in range(N):
    AB.append(list(map(int, input().split())))

A_idx = [(AB[i][0], i) for i in range(N)]
B_idx = [(AB[i][1], i) for i in range(N)]

A_idx.sort(key=lambda e:e[0])
B_idx.sort(key=lambda e:e[0])

if N % 2 == 1:
    diff = B_idx[N//2][0]-A_idx[N//2][0]
    print(diff+1)
else:
    l = N//2-1
    u = N//2
    diff = (B_idx[l][0]+B_idx[u][0])-(A_idx[l][0]+A_idx[u][0])
    print(diff+1)

import statistics

N = int(input())
A = []
B = []
for i in range(N):
    a, b = list(map(int, input().split()))
    A.append(a)
    B.append(b)
Am = statistics.median(A)
Bm = statistics.median(B)

if N % 2 == 0:
    print(round(2 * (Bm - Am) + 1))
else:
    print(Bm - Am + 1)

from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
from functools import reduce
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def MAP1()  : return map(lambda x:int(x)-1,input().split())
def LIST()  : return list(MAP())
def LIST1() : return list(MAP1())

def solve():
    N = INT()
    a = []
    b = []
    for i in range(N):
        A, B = MAP()
        a.append(A)
        b.append(B)
    a.sort()
    b.sort()

    if N % 2 == 1:
        am = a[(N+1)//2-1]
        bm = b[(N+1)//2-1]
        ans = bm - am + 1
    else:
        am = ( a[N//2-1]+a[N//2] ) / 2
        bm = ( b[N//2-1]+b[N//2] ) / 2
        ans = int( ( bm - am ) * 2 + 1 )
    print(ans)

def __starting_point():
    solve()
__starting_point()

import sys
from collections import deque, defaultdict, Counter
from itertools import accumulate, product, permutations, combinations
from operator import itemgetter
from bisect import bisect_left, bisect_right
from heapq import heappop, heappush
from math import ceil, floor, sqrt, gcd, inf
from copy import deepcopy
import numpy as np
import scipy as sp

INF = inf
MOD = 1000000007

n = int(input())
A = [[int(i) for i in input().split()]for j in range(n)]    # nは行数

tmp = 0
res = 0

x = np.median(np.array(A), axis=0)
if n % 2 == 0:
    res = int((x[1] - x[0]) * 2 + 1)
else:
    res = int(x[1] - x[0] + 1)

print(res)


N = int(input())

A = []
B = []
for i in range(N):
  a, b = list(map(int, input().split()))
  A.append(a)
  B.append(b)
A.sort()
B.sort()

if N%2:
  ma = A[N//2]
  mb = B[N//2]
  print((max(0, mb-ma+1)))
else:
  ma = A[N//2] + A[N//2-1]
  mb = B[N//2] + B[N//2-1]
  print((max(0, mb-ma+1)))


N=int(input())
A=[]
B=[]
for i in range(N):
  a,b=map(int,input().split())
  A.append(a)
  B.append(b)
A.sort()
B.sort()
def median(x):
  l=len(x)
  if l%2==0:
    return (x[l//2-1]+x[l//2])/2
  else:
    return x[l//2]
if N%2==1:
  print(median(B)-median(A)+1)
else:
  print(int((median(B)-median(A))*2+1))

a = []
b = []
n = int(input())
for _ in range(n):
    x, y = map(int, input().split())
    a.append(x)
    b.append(y)
a.sort()
b.sort()
if n % 2 == 1:
    print(b[(n-1)//2] - a[(n-1)//2]+1)
    return
print(b[n//2] + b[n//2-1] - a[n//2] - a[n//2-1] + 1)

N = int(input())

A,B = [], []
for i in range(N):
    a,b = list(map(int, input().split()))
    A.append(a)
    B.append(b)

A.sort()
B.sort()

cnt = 0
if(N % 2 == 1):
    l = A[N//2]
    r = B[N//2]
    cnt = r - l + 1
else:
    l = A[N//2-1] + A[N//2]
    r = B[N//2-1] + B[N//2]
    cnt = r - l + 1
print(cnt)


import statistics
import math

N = int(input())

min_x = []
max_x = []

for i in range(N):
    A, B = list(map(int, input().split()))
    min_x.append(A)
    max_x.append(B)

min_x.sort()
max_x.sort()

result = []

if len(min_x) % 2 == 0:
    min_median = (min_x[len(min_x)//2-1] + min_x[len(min_x)//2])
    max_median = (max_x[len(min_x)//2-1] + max_x[len(min_x)//2])
    print((len(list(range(math.floor(min_median), math.ceil(max_median) + 1)))))

else:
    min_median = min_x[len(min_x)//2]
    max_median = max_x[len(min_x)//2]
    print((max_median - min_median + 1))


N=int(input())
A=[0]*N
B=[0]*N
for i in range(N):
    A[i], B[i]=map(int, input().split())
    
A.sort()
B.sort()

if N%2==1:
    print(B[N//2]-A[N//2]+1)
else:
    print(B[N//2]+B[N//2-1]-A[N//2]-A[N//2-1]+1)

def main():
    n = int(input())
    A,B = [],[]
    for _ in range(n):
        a,b = list(map(int,input().split()))
        A.append(a)
        B.append(b)
    A,B = sorted(A),sorted(B)
    if n%2==0:
        a_m,b_m = (A[n//2]+A[n//2-1]),(B[n//2]+B[n//2-1])
        print((b_m-a_m+1))
    else:
        a_m,b_m = A[n//2],B[n//2]
        print((b_m-a_m+1))

def __starting_point():
    main()

__starting_point()

N = int(input())

A = []
B = []
for i in range(N):
  a, b = map(int, input().split())
  A.append(a)
  B.append(b)
A.sort()
B.sort()

if N%2:
  ma = A[N//2]
  mb = B[N//2]
  print(max(0, mb-ma+1))
else:
  ma = A[N//2] + A[N//2-1]
  mb = B[N//2] + B[N//2-1]
  print(max(0, mb-ma+1))

N = int(input())
A = [0]*N
B = [0]*N

for i in range(N):
    A[i], B[i] = map(int, input().split())

A = sorted(A)
B = sorted(B)

if N % 2 == 1:
    print(B[(N+1)//2-1] - A[(N+1)//2-1] + 1)
else:
    b = B[N//2-1] + B[N//2]
    a = A[N//2-1] + A[N//2]
    print(b-a+1)

N = int(input())
A = []; B = []
for i in range(N):
  a,b = map(int,input().split())
  A.append(a);B.append(b)

A.sort();B.sort()
if N%2 == 0:
  MIN = A[N//2-1]+A[N//2] #Medianの二倍
  MAX = B[N//2-1]+B[N//2]
  ans = MAX-MIN+1
else:
  MIN = A[N//2] #Medianの二倍
  MAX = B[N//2]
  ans = MAX-MIN+1
print(ans)

N = int(input())
A = []
B = []
for i in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)
A.sort()
B.sort()
if N % 2 == 0:
    n = N // 2
    print(B[n] + B[n - 1] - A[n] - A[n - 1] + 1)
else:
    n = N // 2
    print((B[n] - A[n] + 1))

from numpy import*
a,b=median(t:=loadtxt(open(0),skiprows=1),0)
print(int((a-b)*~(~len(t)%2))+1)

def main():
    n = int(input())
    al = []
    bl = []
    for _ in range(n):
        a, b = map(int, input().split())
        al.append(a)
        bl.append(b)
    al.sort()
    bl.sort()
    if n%2:
        print(bl[n//2]-al[n//2]+1)
    else:
        print(bl[n//2]+bl[n//2-1]-al[n//2]-al[n//2-1]+1)
 
def __starting_point():
    main()
__starting_point()

def main():
    n = int(input())
    a = [None]*n
    b = [None]*n
    for i in range(n):
        a[i],b[i] = map(int, input().split())
    a.sort()
    b.sort()    
    if n&1:
        print(b[n//2]-a[n//2]+1)
    else:
        print(b[n//2-1]+b[n//2]-a[n//2]+1-a[n//2-1])
            
def __starting_point():
    main()
__starting_point()

N = int(input())
A = [list(map(int, input().split())) for i in range(N)]

# N = 3
# A = [[1, 3], [2, 5], [1, 7]]

if N % 2 == 1:
    minA = sorted([row[0] for row in A])
    maxA = sorted([row[1] for row in A])
    medA = minA[int(N/2)]
    medB = maxA[int(N/2)]
    print(medB-medA+1)
else:
    minA = sorted([row[0] for row in A])
    maxA = sorted([row[1] for row in A])
    medA = (minA[int(N/2-1)]+minA[int(N/2)])/2
    medB = (maxA[int(N/2-1)]+maxA[int(N/2)])/2
    print(int((medB-medA)*2+1))

N = int(input())
AB = [[int(_) for _ in input().split()] for _ in range(N)]
A = sorted([a for a, b in AB])
B = sorted([b for a, b in AB])

ans = B[N // 2] + B[(N - 1) // 2] - (A[N // 2] + A[(N - 1) // 2])
if N % 2:
    ans //= 2
ans += 1
print(ans)


n=int(input())
a=[0]*n
b=[0]*n
for i in range(n):
  a[i],b[i] = map(int,input().split())
a.sort(reverse=True)
b.sort()
if n%2:
  a_med = a[n//2]
  b_med = b[n//2]
  print(b_med - a_med + 1)
else:
  a_med = (a[n//2-1] + a[n//2])/2
  b_med = (b[n//2-1] + b[n//2])/2
  print(int((b_med - a_med)*2)+1)

from operator import itemgetter

n = int(input())
AB = [list(map(int, input().split())) for _ in range(n)]

sortA = sorted(AB, key=itemgetter(0))
sortB = sorted(AB, key=itemgetter(1))

if n%2==1:
    print(sortB[n//2][1] - sortA[-n//2][0] + 1)

else:
    print(int(((sortB[n//2][1]+sortB[n//2-1][1])/2 - (sortA[n//2][0]+sortA[n//2-1][0])/2) / (1/2) + 1))

import sys

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inm = lambda: map(int, sys.stdin.readline().split())
inl = lambda: list(inm())
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))

N = ini()
A, B = [], []
for i in range(N):
    a, b = inm()
    A.append(a)
    B.append(b)


def solve():
    sa = sorted(A)
    sb = sorted(B)
    if N % 2 == 1:
        return sb[N // 2] - sa[N // 2] + 1
    else:
        return (sb[N // 2] + sb[N // 2 - 1]) - (sa[N // 2] + sa[N // 2 - 1]) + 1


print(solve())


#float型を許すな
#numpyはpythonで
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

n=I()
lis1=[]
lis2=[]
for i in range(n):
    a,b=MI()
    lis1.append(a)
    lis2.append(b)
lis1.sort()
lis2.sort()
if n%2==1:
    med1=lis1[n//2]
    med2=lis2[n//2]
    print(med2-med1+1)
if n%2==0:
    med1=lis1[n//2-1]+lis1[n//2]
    med2=lis2[n//2-1]+lis2[n//2]
    print(med2-med1+1)

n=int(input())
import bisect as bi
A=[] ; B=[]
for i in range(n):
    a,b=list(map(int,input().split()))
    A.append(a)
    B.append(b)

A.sort() ; B.sort()
if n%2==1:
    a=A[(n-1)//2] ; b=B[(n-1)//2]
  
    print((b-a+1))
else:
    a=(A[n//2-1]+A[n//2])/2 ; b=(B[n//2-1]+B[n//2])/2
  
    print((int((b-a)/0.5)+1))


N=int(input())
l,r=[],[]
for i in range(N):
  a,b=map(int,input().split())
  l.append(a)
  r.append(b)
l.sort()
r.sort()
if N%2:
  print(r[N//2]-l[N//2]+1)
else:
  a=(l[N//2]+l[N//2-1])/2
  b=(r[N//2]+r[N//2-1])/2
  print(int((b-a)*2)+1)

N = int(input())
A = []
B = []
for i in range (0,N):
	a, b = map(int, input().split())
	A.append(a)
	B.append(b)
    
A = sorted(A)
B = sorted(B)

from statistics import median

if N%2 ==1:
	print(median(B)-median(A)+1)
else:
	print(int((median(B)-median(A))*2+1))

from statistics import*
(n,),*t=[map(int,t.split())for t in open(0)]
a,b=map(median,zip(*t))
print(int((b-a)*(2-n%2))+1)

import sys
import numpy as np
input = sys.stdin.readline
read = sys.stdin.read


def log(*args):
    print(*args, file=sys.stderr)


def main():
    np.set_printoptions(threshold=20)
    N = int(input())
    AB = np.array(read().split(), dtype=np.int)
    A = AB[0::2]
    B = AB[1::2]
    A.sort()
    B.sort()
    if N % 2 == 1:
        n = N // 2
        print(B[n] - A[n] + 1)
    else:
        n = N // 2
        print((B[n] + B[n - 1]) - (A[n] + A[n - 1]) + 1)



def __starting_point():
    main()

__starting_point()

import math
n = int(input())
a = [0]*n
b = [0]*n
for i in range(n):
  a[i], b[i] = list(map(int, input().split()))
a.sort()
b.sort()
ans = 0
h = int(n/2)
if n % 2 == 0:
  a_harf = a[h-1] + a[h]
  b_harf = b[h-1] + b[h]
  ans = b_harf - a_harf + 1
else:
  ans = b[h] - a[h] + 1
  
print(ans)

from numpy import*
(n,),*d=[int_(i.split())for i in open(0)]
a,b=median(d,0)
print(int((b-a)*(2-n%2))+1)

N=int(input())
L=[]
for i in range(N):
    A, B=list(map(int,input().split()))
    L.append((A,B))
L1=sorted(L,key=lambda x: x[0])
L2=sorted(L,key=lambda x: x[1])
if N%2==1:
    n=N//2
    print(L2[n][1] -L1[n][0]+1)
else:
    n=N//2
    m=(L1[n-1][1]+L1[n][1])/2
    print(L2[n-1][1]+L2[n][1]-L1[n-1][0]-L1[n][0]+1)

def med(l):
	t = len(l)
	if t%2:
		return l[t//2]
	else: return (l[t//2]+l[t//2-1])/2

n = int(input())
a = []
b = []
for i in range(n):
	x,y = list(map(int,input().split()))
	a+=[x]
	b+=[y]
a.sort()
b.sort()

if n%2==0:
	print((int((med(b)-med(a))*2)+1))
else:
	print((med(b)-med(a)+1))


n = int(input())
a = [0]*n
b = [0]*n

for i in range(n):
    aa,bb = list(map(int, input().split()))
    a[i] = aa
    b[i] = bb

a.sort()
b.sort()

if n%2 == 1:
    print((b[n//2] - a[n//2] + 1))
else:
    print((b[n//2] + b[(n//2)-1] - a[n//2] - a[(n//2)-1] + 1))


import statistics
n = int(input())

a=[0]*n
b=[0]*n

for i in range(n):
    a[i],b[i] = list(map(int,input().split()))

cen_a=statistics.median(a)
cen_b=statistics.median(b)

if n%2==1:
    print((cen_b-cen_a+1))
else:
    print((int((cen_b-cen_a)*2+1)))


n=int(input(""))
a=[]
b=[]
for i in range(n):
    cc=input("").split(" ")
    a+=[int(cc[0])]
    b+=[int(cc[1])]
s=0
a.sort()
b.sort()
if (n%2==0):
    s=(a[int(n/2)]+a[int(n/2)-1]-b[int(n/2)]-b[int(n/2)-1])
else:
    s=a[int((n-1)/2)]-b[int((n-1)/2)]
print((int(-s+1)))


from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter
from operator import mul
import copy
# ! /usr/bin/env python
# -*- coding: utf-8 -*-

import heapq

n = int(input())

aa = []
bb = []
for i in range(n):
    a , b = list(map(int, input().split()))

    aa.append(a)
    bb.append(b)

aa.sort()
bb.sort()

if n % 2 == 0:
    m_a = (aa[n // 2 - 1] + aa[n // 2])
    m_b = (bb[n // 2 - 1] + bb[n // 2])

    print(m_b - m_a+1)
    return

else:
    median_a = aa[n // 2]
    median_b = bb[n // 2]

    print(median_b-median_a+1)
    return

import statistics
N = int(input())
A = []
B = []
for _ in range(N):
  a, b = list(map(int, input().split()))
  A.append(a)
  B.append(b)

A.sort()
B.sort()

if N % 2 == 1:
  med_min = A[N // 2]
  med_max = B[N // 2]
  print((med_max - med_min + 1))  
else:
  med_min_db = A[N // 2] + A[N // 2 - 1]
  med_max_db = B[N // 2] + B[N // 2 - 1]
  print((med_max_db - med_min_db + 1))





n = int(input())
A, B = map(list,zip(*[map(int,input().split()) for i in range(n)]))
A.sort()
B.sort()
if n&1:
	print(B[n//2]-A[n//2]+1)
else:
	print(B[n//2]+B[n//2-1]-(A[n//2]+A[n//2-1])+1)

from statistics import median


def main():
    n = int(input())
    a = [0] * n
    b = [0] * n
    for i in range(n):
        a[i], b[i] = list(map(int, input().split()))
    ans = median(b) - median(a)
    if n % 2 == 0:
        ans *= 2
    ans = int(ans)
    ans += 1
    print(ans)


def __starting_point():
    main()

__starting_point()

n=int(input())
m=[]
M=[]
for _ in range(n):
    x,y=map(int,input().split())
    m.append(x)
    M.append(y)
m=sorted(m)
M=sorted(M)

z=n//2
if n%2==1:
    a=m[z]
    b=M[z]
    print(b-a+1)
else:
    a=m[z]+m[z-1]
    b=M[z]+M[z-1]
    print(b-a+1)

import statistics
n=int(input())

la, lb = [], []
for _ in range(n):
  a, b = map(int, input().split())
  la.append(a)
  lb.append(b)
c=statistics.median(la)
d=statistics.median(lb)
if n%2==1:
  print(d-c+1)
else:
  print(int(2*d-2*c+1))

def main():
    n = int(input())
    a, b = [None]*n, [None]*n
    for i in range(n):
        a[i], b[i] = map(int, input().split())
    a.sort()
    b.sort()
    if n & 1:
        print(b[n//2]-a[n//2]+1)
    else:
        print(b[n//2-1]+b[n//2]-a[n//2-1]-a[n//2]+1)

def __starting_point():
    main()
__starting_point()

from statistics import median

N = int(input())
A = [0] * N
B = [0] * N
max=0
min =0
for c in range(N):
    A[c], B[c] = map(int, input().split())

med_A = median(A)
med_B = median(B)

if N%2==0:
    print(int((med_B-med_A)*2+1))
else:
    print(med_B-med_A+1)

import numpy as np

N = int(input())
AB = np.vstack([list(map(int, input().split())) for _ in range(N)])
meds = np.median(AB, axis=0)

if N%2 == 0:
    print((int((meds[1]-meds[0])*2+1)))
else:
    print((int(meds[1]-meds[0] +1)))


#!/usr/bin/env python3
import sys

input = sys.stdin.readline


def S():
    return input().rstrip()


def I():
    return int(input())


def MI():
    return list(map(int, input().split()))


n = I()
ab = list(map(int, sys.stdin.read().split()))
a = ab[::2]
b = ab[1::2]
a.sort()
b.sort()

if n % 2 == 0:
    m1 = (a[n // 2 - 1] + a[n // 2]) / 2
    m2 = (b[n // 2 - 1] + b[n // 2]) / 2
    print((int((m2 - m1) * 2 + 1)))
else:
    m1 = a[n // 2]
    m2 = b[n // 2]
    print((m2 - m1 + 1))


import statistics
from collections import Counter
N = int(input())
A = [list(map(int, input().split(" "))) for i in range(N)]
xMIN = []
xMAX = []



for i in range(N):
    xMIN.append(A[i][0])

for j in range(N):
    xMAX.append(A[j][1])


if N % 2 != 0:
    medianMIN = statistics.median(xMIN)
    medianMAX = statistics.median(xMAX)
    print((int(medianMAX-medianMIN+1)))
else:
    medianMIN_LOW = statistics.median_low(xMIN)
    medianMIN_HIGH = statistics.median_high(xMIN)
    medianMAX_LOW = statistics.median_low(xMAX)
    medianMAX_HIGH = statistics.median_high(xMAX)
    print(((medianMAX_LOW+medianMAX_HIGH)-(medianMIN_LOW+medianMIN_HIGH)+1))


N = int(input())
A = list()
B = list()
for i in range(N):
  a, b = map(int, input().split())
  A.append(a)
  B.append(b)
  
A.sort()
B.sort()

if(N%2==1):
  x = A[(N-1)//2]
  y = B[(N-1)//2]
  print(y-x+1)
else:
  x = A[(N//2)-1] + A[N//2]
  y = B[(N//2)-1] + B[N//2]
  print(y-x+1)

def solve():
  N = int(input())
  A = [0]*N
  B = [0]*N
  for i in range(N):
    A[i],B[i] = map(int, input().split())
  A.sort()
  B.sort(reverse=True)
  if N%2==1:
    b = A[N//2]
    u = B[N//2]
    return u-b+1
  b1 = A[N//2-1]
  b2 = A[N//2]
  u1 = B[N//2-1]
  u2 = B[N//2]
  return u1+u2-b1-b2+1
print(solve())

n=int(input())
a,b=[],[]
for i in range(n):
  inp=list(map(int,input().split()))
  a.append(inp[0])
  b.append(inp[1])
a.sort()
b.sort()
am=sum(a[(n-1)//2:n//2+1])
bm=sum(b[(n-1)//2:n//2+1])
print(bm-am+1)

# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from collections import deque
from functools import lru_cache
import bisect
import re
import queue
import decimal


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [Scanner.string() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [Scanner.int() for i in range(n)]


MOD = int(1e09) + 7
INF = int(1e15)


def solve():
    N = Scanner.int()
    A = [0 for _ in range(N)]
    B = [0 for _ in range(N)]
    for i in range(N):
        A[i], B[i] = Scanner.map_int()
    A.sort()
    B.sort()
    if N % 2 == 0:
        mA = A[N // 2] + A[N // 2 - 1]
        mB = B[N // 2] + B[N // 2 - 1]
        print((mB - mA + 1))
    else:
        mA = A[N // 2]
        mB = B[N // 2]
        print((mB - mA + 1))


def main():
    # sys.setrecursionlimit(1000000)
    # sys.stdin = open("sample.txt")
    # T = Scanner.int()
    # for _ in range(T):
    #     solve()
    # print('YNeos'[not solve()::2])
    solve()


def __starting_point():
    main()

__starting_point()

import statistics

N = int(input())
AB = [map(int, input().split()) for _ in range(N)]
A, B = [list(i) for i in zip(*AB)]


A_median = statistics.median(A)
B_median = statistics.median(B)
if N%2==0:
    print(int((B_median-A_median)*2)+1)
else:
    print(B_median-A_median+1)

n = int(input())
a = [0] * n
b = [0] * n
for i in range(n):
    a[i], b[i] = [int(j) for j in input().split()]
a.sort()
b.sort()
if n % 2 == 1:
    print(b[n//2] - a[n//2] + 1)
else:
    print(b[n//2] + b[n//2-1] - a[n//2] - a[n//2-1] + 1)

N = int(input())
l = []
for _ in range(N):
    A, B = list(map(int, input().split()))
    l.append((A, B))

t = N//2
tl = sorted(l)
tr = sorted(l, key=lambda x:-x[1])

if N%2:
    print((tr[t][1]-tl[t][0]+1))
else:
    a1, a2 = tl[t-1][0], tr[t][1]
    a3, a4 = tl[t][0], tr[t-1][1]
    print((a4-a3+a2-a1+1))


N = int(input())
a, b = [], []
for i in range(N):
    c, d = map(int, input().split())
    a.append(c)
    b.append(d)
a.sort()
b.sort()
if N%2 == 1:
    print(b[N//2] - a[N//2] + 1)
else:
    print((b[N//2]+b[N//2-1]) - (a[N//2]+a[N//2-1]) + 1)

N = int(input())

Alist = []
Blist = []

for _ in range(N):
    a, b = map(int, input().split())
    Alist.append(a)
    Blist.append(b)

Alist.sort()
Blist.sort()

if N%2==1:
    center_A = Alist[(N-1)//2]
    center_B = Blist[(N-1)//2]
    print(int(center_B - center_A + 1))

else:
    center_A = (Alist[N//2 - 1] + Alist[N//2]) / 2
    center_B = (Blist[N//2 - 1] + Blist[N//2]) / 2
    print(int(center_B * 2 - center_A * 2 + 1))

from statistics import median
N = int(input())
A = []
B = []
for n in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)
#AB = sorted(AB, key=lambda x: x[0])
#print(AB)
cenA = median(A)
cenB = median(B)


if N % 2 == 1:
    print(int(cenB - cenA + 1))

elif N % 2 == 0:
    print(int((cenB - cenA)*2 + 1))
    
else:
    print('RE')

3
# -*- coding:utf-8 -*-

import numpy

def main():
  n = int(input())
  la, lb = [], []
  for _ in range(n):
    a, b = list(map(int, input().split()))
    la.append(a)
    lb.append(b)
  la.sort(), lb.sort()
  
  if n % 2 == 0:
    s = (n-1)//2
    e = s + 2
    ma = sum(la[s:e]) / 2.0
    mb = sum(lb[s:e]) / 2.0
    print((int(2 * (mb - ma) + 1)))
  if n % 2 == 1:
    ma = la[n//2]
    mb = lb[n//2]
    print((mb - ma + 1))
    
def __starting_point():
  main()


__starting_point()

n = int(input())
A = []
B = []
for i in range(n):
    x = [int(i) for i in input().split()]
    A.append(x[0])
    B.append(x[1])
A = sorted(A)
B = sorted(B)
if n % 2:
    med_A = A[n//2]
    med_B = B[n//2]
    print(abs(med_A - med_B) + 1)
else:
    med_A  = A[(n-1)//2]+A[n//2] # this is double of median
    med_B = B[(n-1)//2]+B[n//2]
    print(abs(med_A - med_B) + 1) # we want gap of 1/2