Problem:
 Score : 500 points    Problem Statement 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 1 2
1 2
2 3      Sample Output 1 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} .       Sample Input 2 3
100 100
10 10000
1 1000000000      Sample Output 2 9991

Solution (Python):
import sys,bisect,string,math,time,functools,random,fractions
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
from itertools import permutations,combinations,groupby
rep=range
def Golf():n,*t=map(int,open(0).read().split())
def I():return int(input())
def S_():return input()
def IS():return input().split()
def LS():return [i for i in input().split()]
def LI():return [int(i) for i in input().split()]
def LI_():return [int(i)-1 for i in input().split()]
def NI(n):return [int(input()) for i in range(n)]
def NI_(n):return [int(input())-1 for i in range(n)]
def StoLI():return [ord(i)-97 for i in input()]
def ItoS(n):return chr(n+97)
def LtoS(ls):return ''.join([chr(i+97) for i in ls])
def RA():return map(int,open(0).read().split())
def GI(V,E,ls=None,Directed=False,index=1):
    org_inp=[];g=[[] for i in range(V)]
    FromStdin=True if ls==None else False
    for i in range(E):
        if FromStdin:
            inp=LI()
            org_inp.append(inp)
        else:
            inp=ls[i]
        if len(inp)==2:
            a,b=inp;c=1
        else:
            a,b,c=inp
        if index==1:a-=1;b-=1
        aa=(a,c);bb=(b,c);g[a].append(bb)
        if not Directed:g[b].append(aa)
    return g,org_inp
def GGI(h,w,search=None,replacement_of_found='.',mp_def={'

    mp=[boundary]*(w+2);found={}
    for i in range(h):
        s=input()
        for char in search:
            if char in s:
                found[char]=((i+1)*(w+2)+s.index(char)+1)
                mp_def[char]=mp_def[replacement_of_found]
        mp+=[boundary]+[mp_def[j] for j in s]+[boundary]
    mp+=[boundary]*(w+2)
    return h+2,w+2,mp,found
def TI(n):return GI(n,n-1)
def accum(ls):
    rt=[0]
    for i in ls:rt+=[rt[-1]+i]
    return rt
def bit_combination(n,base=2):
    rt=[]
    for tb in range(base**n):s=[tb//(base**bt)%base for bt in range(n)];rt+=[s]
    return rt
def gcd(x,y):
    if y==0:return x
    if x%y==0:return y
    while x%y!=0:x,y=y,x%y
    return y
def show(*inp,end='\n'):
    if show_flg:print(*inp,end=end)
 
YN=['YES','NO'];Yn=['Yes','No']
mo=10**9+7
inf=float('inf')
FourNb=[(-1,0),(1,0),(0,1),(0,-1)];EightNb=[(-1,0),(1,0),(0,1),(0,-1),(1,1),(-1,-1),(1,-1),(-1,1)];compas=dict(zip('WENS',FourNb));cursol=dict(zip('LRUD',FourNb))
l_alp=string.ascii_lowercase

read=sys.stdin.buffer.read
readline=sys.stdin.buffer.readline
input=lambda: sys.stdin.readline().rstrip()


class Tree:
    def __init__(self,inp_size=None,ls=None,init=True,index=0):
        self.LCA_init_stat=False
        self.ETtable=[]
        if init:
            if ls==None:
                self.stdin(inp_size,index=index)
            else:
                self.size=len(ls)+1
                self.edges,_=GI(self.size,self.size-1,ls,index=index)
        return
 
    def stdin(self,inp_size=None,index=1):
        if inp_size==None:
            self.size=int(input())
        else:
            self.size=inp_size
        self.edges,_=GI(self.size,self.size-1,index=index)
        return
    
    def listin(self,ls,index=0):
        self.size=len(ls)+1
        self.edges,_=GI(self.size,self.size-1,ls,index=index)
        return
 
    def __str__(self):
        return  str(self.edges)
 
    def dfs(self,x,func=lambda prv,nx,dist:prv+dist,root_v=0):
        q=deque()
        q.append(x)
        v=[-1]*self.size
        v[x]=root_v
        while q:
            c=q.pop()
            for nb,d in self.edges[c]:
                if v[nb]==-1:
                    q.append(nb)
                    v[nb]=func(v[c],nb,d)
        return v
 
    def EulerTour(self,x):
        q=deque()
        q.append(x)
        self.depth=[None]*self.size
        self.depth[x]=0
        self.ETtable=[]
        self.ETdepth=[]
        self.ETin=[-1]*self.size
        self.ETout=[-1]*self.size
        cnt=0
        while q:
            c=q.pop()
            if c<0:
                ce=~c
            else:
                ce=c
                for nb,d in self.edges[ce]:
                    if self.depth[nb]==None:
                        q.append(~ce)
                        q.append(nb)
                        self.depth[nb]=self.depth[ce]+1
            self.ETtable.append(ce)
            self.ETdepth.append(self.depth[ce])
            if self.ETin[ce]==-1:
                self.ETin[ce]=cnt
            else:
                self.ETout[ce]=cnt
            cnt+=1
        return
    
    def LCA_init(self,root):
        self.EulerTour(root)
        self.st=SparseTable(self.ETdepth,init_func=min,init_idl=inf)
        
        self.LCA_init_stat=True
        return
    
    def LCA(self,root,x,y):
        if self.LCA_init_stat==False:
            self.LCA_init(root)
        xin,xout=self.ETin[x],self.ETout[x]
        yin,yout=self.ETin[y],self.ETout[y]
        a=min(xin,yin)
        b=max(xout,yout,xin,yin)
        id_of_min_dep_in_et=self.st.query_id(a,b+1)
        return self.ETtable[id_of_min_dep_in_et]




class SparseTable: 
    def __init__(self,ls,init_func=min,init_idl=float('inf')):
        self.func=init_func
        self.idl=init_idl
        self.size=len(ls)
        self.N0=self.size.bit_length()
        self.table=[ls[:]]
        self.index=[list(range(self.size))]
        self.lg=[0]*(self.size+1)
        
        for i in range(2,self.size+1):
            self.lg[i]=self.lg[i>>1]+1
 
        for i in range(self.N0):
            tmp=[self.func(self.table[i][j],self.table[i][min(j+(1<<i),self.size-1)]) for j in range(self.size)]
            tmp_id=[self.index[i][j] if self.table[i][j]==self.func(self.table[i][j],self.table[i][min(j+(1<<i),self.size-1)]) else self.index[i][min(j+(1<<i),self.size-1)] for j in range(self.size)]
            self.table+=[tmp]
            self.index+=[tmp_id]
    
    
    def query(self,l,r):
        if r>self.size:r=self.size
        
        N=self.lg[r-l]
        return self.func(self.table[N][l],self.table[N][max(0,r-(1<<N))])
    
    
    def query_id(self,l,r):
        if r>self.size:r=self.size
        
        N=self.lg[r-l]
        a,b=self.index[N][l],self.index[N][max(0,r-(1<<N))]
        if self.table[0][a]==self.func(self.table[N][l],self.table[N][max(0,r-(1<<N))]):
            b=a
        return b
    
    
    def right_bound(self,pos,x):
        k=(self.size-pos).bit_length()
        for j in range(k)[::-1]:
            nx=pos+(1<<j)
            if nx<n and self.query(pos,nx+1)<=x:
                pos+=(1<<j)
        return pos
    
    
    def left_bound(self,pos,x):
        k=pos.bit_length()
        for j in range(k)[::-1]:
            nx=pos-(1<<j)
            if 0<=nx and self.query(nx,pos+1)<=x:
                pos-=(1<<j)
        return pos

    def __str__(self):
        return str(self.table[0])
 
    def print(self):
        for i in self.table:
            print(*i)
 



def primeFactor(N):
    i,n=2,N
    ret={}
    d,sq=2,99
    while i<=sq:
        k=0
        while n%i==0:
            n,k,ret[i]=n//i,k+1,k+1
        if k>0 or i==97:
            sq=int(n**(1/2)+0.5)
        if i<4:
            i=i*2-1
        else:
            i,d=i+d,d^6
    if n>1:
        ret[n]=1
    return ret




def PrimeNumSet(N):
    Max = int(N**0.5)
    seachList = [i for i in range(2,N+1)]
    primeNum = []
    while seachList:
        if seachList[0] <= Max:
            break
        primeNum.append(seachList[0])
        tmp = seachList[0]
        seachList = [i for i in seachList if i % tmp != 0]
    primeNum.extend(seachList)
    return primeNum



def LCM(b,mo=10**9+7):
    prs=PrimeNumSet(max(b))
    M=dict(zip(prs,[0]*len(prs)))
    for i in b:
        dc=primeFactor(i)
        for j,k in dc.items():
            M[j]=max(M[j],k)
    
    r=1
    for j,k in M.items():
        if k!=0:
            r*=pow(j,k,mo)
            r%=mo
    return r

 
show_flg=False
show_flg=True
ans=0


n=I()
A=[]
B=[]

for i in rep(n):
    a,b=LI()
    A+=[a]
    B+=[b]

A.sort()
B.sort()
if n%2==0:
    kl=n//2-1
    kr=n//2
else:
    kl=n//2
    kr=n//2
lm,lM=A[kl],A[kr]
rm,rM=B[kl],B[kr]
L,R=0,0
if n%2==0:
    
    L=lm+lM
    R=rm+rM
    ans=R-L+1
else:
    ans=rm-lm+1


print(ans)

Solution (Python):

import sys
input = sys.stdin.readline

n = int(input())
lower = []
upper = []
for _ in range(n):
    a, b = map(int, input().split())
    lower.append(a)
    upper.append(b)

lower.sort()
upper.sort()

if n % 2 == 1:
    l_mid = lower[n // 2]
    u_mid = upper[n // 2]
    print(u_mid - l_mid + 1)
else:
    l_mid = (lower[n // 2] + lower[n // 2 - 1])
    u_mid = (upper[n // 2] + upper[n // 2 - 1])
    ans = u_mid - l_mid + 1
    print(ans)

Solution (Python):
def resolve():
    import sys
    import statistics
    input = sys.stdin.readline
    n = int(input())
    a = [None] * n
    b = [None] * n
    for i in range(n):
        ai, bi = map(int, input().split())
        a[i] = ai
        b[i] = bi
    if n % 2 == 0:
        minmed = statistics.median_high(a) + statistics.median_low(a)
        maxmed = statistics.median_high(b) + statistics.median_low(b)
        print(maxmed - minmed + 1)
    else:
        print(statistics.median(b) - statistics.median(a) + 1)


if __name__ == '__main__':
    resolve()

Solution (Python):
import sys
sys.setrecursionlimit(10**6)
input = sys.stdin.readline

n = int(input())
AB = [[0,0] for _ in range(n)]
A = [0]*n
B = [0]*n
for i in range(n):
    a,b = map(int,input().split())
    AB[i] = [a,b]
    A[i] = a
    B[i] = b
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)

Solution (Python):
import sys
input = sys.stdin.buffer.readline

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:     
    ans = B[N//2] - A[N//2] + 1
else:       
    ans = (B[N//2] + B[N//2-1]) - (A[N//2] + A[N//2-1]) + 1
print(ans)

Solution (Python):
def main():
    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 == 0:
        mn = A[N//2-1] + A[N//2]
        mx = B[N//2-1] + B[N//2]
    else:
        mn = A[N//2]
        mx = B[N//2]
    ans = (mx-mn) + 1
    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):

import sys

N, *AB = map(int, sys.stdin.buffer.read().split())

A = sorted(AB[::2])
B = sorted(AB[1::2])

center = N//2

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

Solution (Python):
n=int(input())
ab=[list(map(int,input().split())) for _ in range(n)]
ab.sort(key=lambda x:x[0])

if n%2==0:
    min=ab[n//2-1][0]+ab[n//2][0]
else:
    min=ab[n//2][0]
ab.sort(key=lambda x:-x[1])
if n%2==0:
    max=ab[n//2-1][1]+ab[n//2][1]
else:
    max=ab[n//2][1]
print(max-min+1)

Solution (Python):

import sys
from statistics import median
sys.setrecursionlimit(10**8)
INF = float("inf")


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

    return


if __name__ == '__main__':
    main()

Solution (Python):
import sys
input=lambda: sys.stdin.readline().rstrip()
n=int(input())
A,B=[],[]
for _ in range(n):
  a,b=map(int,input().split())
  A.append(a)
  B.append(b)
A.sort()
B.sort()
if n%2==1:
  l=A[n//2]
  r=B[n//2]
  print(r-l+1)
else:
  l=A[n//2-1]+A[n//2]
  r=B[n//2-1]+B[n//2]
  print(r-l+1)

Solution (Python):
N = int(input())
AB = []
for i in range(N):
    AB.append(list(map(int,input().split())))

A = []
B = []
for i in range(N):
    A.append(AB[i][0])
    B.append(AB[i][1])
A.sort()
B.sort()
if N%2==0:
    A1 = A[N//2-1]
    A2 = A[N//2]
    B1 = B[N//2-1]
    B2 = B[N//2]
    print((B1+B2)-(A1+A2)+1)
else:
    A1 = A[N//2]
    B1 = B[N//2]
    print((B1-A1)+1)

Solution (Python):
import sys


def solve_even(n, aaa, bbb):
    li = n // 2 - 1
    ri = n // 2
    aaa.sort()
    bbb.sort()
    ll = aaa[li]
    lr = aaa[ri]
    rl = bbb[li]
    rr = bbb[ri]
    return (rl + rr) - (lr + ll) + 1


def solve_odd(n, aaa, bbb):
    k = n // 2
    aaa.sort()
    bbb.sort()
    return bbb[k] - aaa[k] + 1


n, *ab = map(int, sys.stdin.buffer.read().split())
if n % 2 == 0:
    ans = solve_even(n, ab[0::2], ab[1::2])
else:
    ans = solve_odd(n, ab[0::2], ab[1::2])
print(ans)

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

Solution (Python):

n = int(input())
l=[]
r=[]
for i in range(n):
    temp = list(map(int, input().split()))
    l.append(temp[0])
    r.append(temp[1])

l.sort()
r.sort()

if(n%2==1):
    dif = r[n//2] - l[n//2]
    
    print(dif+1)
else:
    dif2 = (r[n//2]+r[n//2-1]) - (l[n//2]+l[n//2-1])
    
    print(dif2+1)

Solution (Python):
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n = ni()
mn = []
mx = []
for i in range(n):
    a,b = na()
    mn.append(a)
    mx.append(b)

mn.sort()
mx.sort()

if n%2 == 0:
    p = mn[n//2-1]+mn[n//2]
    q = mx[n//2-1]+mx[n//2]
    print(q-p+1)
else:
    p = mn[n//2]
    q = mx[n//2]
    print(q-p+1)

Solution (Python):
N = int(input())
if N % 2 == 1:
    odd = 1
else:
    odd = 0
L = [list(map(int, input().split())) for _ in range(N)]

L.sort()
A = [L[i][0] for i in range(N)]
if odd:
    minres = A[(N - 1) // 2]
else:
    minres = A[(N - 2) // 2] + A[N // 2]

L.sort(key=lambda x: x[1])
B = [L[i][1] for i in range(N)]
if odd:
    maxres = B[(N - 1) // 2]
else:
    maxres = B[(N - 2) // 2] + B[N // 2]

print(maxres - minres + 1)

Solution (Python):
n = int(input())
a = [0] * n
b = [0] * n
for i in range(n):
    atmp,btmp = (int(num) for num in input().split())
    a[i] = atmp
    b[i] = btmp
    
a.sort()
b.sort()
minval = 0
maxval = 0
ans = 0
if n % 2 == 0:
    minval = (a[n//2-1] + a[n//2]) / 2
    maxval = (b[n//2-1] + b[n//2]) / 2
    ans = int((maxval - minval) * 2 + 0.00001) + 1
else:
    minval = a[n//2]
    maxval = b[n//2]
    ans = maxval - minval + 1
    
print(ans)

Solution (Python):
N = int(input())
AB = []
for i in range(N):
  ab = tuple(map(int,input().split()))
  AB += [ab]

AB_on_A = sorted(AB)
AB_on_B = sorted(AB,key=lambda x:x[1])
if N%2==0:
  min_num = AB_on_A[N//2-1][0]+AB_on_A[N//2][0]
  max_num = AB_on_B[N//2-1][1]+AB_on_B[N//2][1]
  print(max_num-min_num+1)
else:
  min_num = AB_on_A[N//2][0]
  max_num = AB_on_B[N//2][1]
  print(max_num-min_num+1)

Solution (Python):
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))

Solution (Python):
def examA():
    A, B = LI()
    ans = A*B
    print(ans)
    return

def examB():
    N = I()
    A = LI()
    for a in A:
        if a==0:
            print(0)
            return
    ans = 1
    for a in A:
        ans *= a
        if ans>10**18:
            print(-1)
            return
    print(ans)
    return

def examC():
    A, B = list(map(float,input().split()))
    ans = (int(A*B*100))//100
    print(ans)
    return

def examD():
    def factorization(n):
        arr = defaultdict(int)
        temp = n
        for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
            if temp % i == 0:
                cnt = 0
                while temp % i == 0:
                    cnt += 1
                    temp //= i
                arr[i] = cnt
        if temp != 1:
            arr[temp] = 1
        if arr == []:
            arr[n] = 1
        return arr
    C = [0,1,3,6,10,15,21,28,36,45]
    N = I()
    F = factorization(N)
    ans = 0
    
    for f in F.values():
        for i in range(10):
            if C[i]>f:
                ans += i-1
                break
    print(ans)
    return

def examE():
    N = I()
    A = [0]*N
    B = [0]*N
    for i in range(N):
        A[i],B[i] = LI()
    A.sort()
    B.sort()
    if N%2==0:
        L = (A[N//2-1] + A[N//2])/2
        R = (B[N//2-1] + B[N//2])/2
        ans = int((R-L)*2) +1
    else:
        L = A[N//2]
        R = B[N//2]
        ans = (R-L)+1

    print(ans)
    return

def examF():
    N, S = LI()
    A = LI()

    ans = 0
    print(ans)
    return

import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def I(): return int(input())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 1<<60
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

sys.setrecursionlimit(10**7)

if __name__ == '__main__':
    examE()

"""
142
12 9 1445 0 1
asd dfg hj o o
aidn
"""

Solution (Python):
N = int(input())
AB = [tuple(map(int, input().split())) for _ in range(N)]

A, B = zip(*AB)
a = list(A)
b = list(B)
a.sort()
b.sort()

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

print(ans)

Solution (Python):
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:
  k1 = a[n//2]
  k2 = b[n//2]
else:
  k1 = a[n//2-1]+a[n//2]
  k2 = b[n//2-1]+b[n//2]

ans = k2-k1+1
print(ans)

Solution (Python):
import sys
input=sys.stdin.readline
n=int(input())
ab=[]
for _ in range(n):
	a,b=map(int,input().split())
	ab.append((a,b))
ab.sort()
if n%2==1:
	m=ab[n//2][0]
else:
	m=(ab[n//2-1][0]+ab[n//2][0])
ab.sort(key=lambda x:x[1])
if n%2==1:
	M=ab[n//2][1]
else:
	M=(ab[n//2-1][1]+ab[n//2][1])
print(M-m+1)

Solution (Python):


import os
import sys
from io import BytesIO, IOBase

"""
    for _ in range(int(input())):
    n,m=map(int,input().split())
    n=int(input())
    a = [int(x) for x in input().split()]
"""

def main():
    n=int(input())
    l,r=[],[]
    for _ in range(n):
        u,v=map(int,input().split())
        l.append(u)
        r.append(v)
    l.sort()
    r.sort()
    u,v=0,0
    if n%2:
        u,v=l[n//2],r[n//2]
    else:
        u,v=l[n//2]+l[n//2-1],r[n//2]+r[n//2-1]
    print(v-u+1)




BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")



if __name__ == "__main__":
    main()

Solution (Python):

from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n = I()
    g = LIR(n)
    if n&1:
        g.sort()
        l = g[n>>1][0]
        g.sort(key = lambda x:x[1])
        r = g[n>>1][1]
        print(r-l+1)
    else:
        g.sort()
        l = g[(n>>1)-1][0]+g[(n>>1)][0]
        g.sort(key = lambda x:x[1])
        r = g[n>>1][1]+g[(n>>1)-1][1]
        print(r-l+1)
    
    
    
    
    
    
    
    
    
    
    
    
    
    return


if __name__ == "__main__":
    solve()

Solution (Python):
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n = int(input())
AB = [tuple(map(int,input().split())) for i in range(n)]
A = [ai for ai,bi in AB]
B = [bi for ai,bi in AB]
A.sort()
B.sort()
if n % 2 == 0:
  aa = (A[n//2-1]+A[n//2]) 
  bb = (B[n//2-1]+B[n//2])
  print(bb-aa+1)

else:
  aa = (A[n//2]) 
  bb = (B[n//2])
  print(bb-aa+1)

Solution (Python):
n = int(input())
a, b = [], []
for _ in range(n):
    ai, bi = map(int, input().split())
    a.append(ai)
    b.append(bi)
a.sort()
b.sort()
if n & 1:
    print(b[n // 2] - a[n // 2] + 1)
else:
    a = list(map(lambda x: x * 2, a))
    b = list(map(lambda x: x * 2, b))
    print((b[n // 2 - 1] + b[n // 2]) // 2 
            - (a[n // 2 - 1] + a[n // 2]) // 2 + 1)

Solution (Python):


import sys
sys.setrecursionlimit(300000)


def solve(N: int, A: "List[int]", B: "List[int]"):
    a = A
    b = B
    a.sort()
    b.sort()
    if N % 2 == 0:
        ma = (a[N // 2 - 1] + a[N // 2]) / 2
        mb = (b[N // 2 - 1] + b[N // 2]) / 2
        ret = mb * 2 - ma * 2 + 1
    else:
        ma = (a[N // 2]) / 2
        mb = (b[N // 2]) / 2
        ret = mb * 2 - ma * 2 + 1
    print(int(ret))
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    A = [int()] * (N)  
    B = [int()] * (N)  
    for i in range(N):
        A[i] = int(next(tokens))
        B[i] = int(next(tokens))
    solve(N, A, B)

if __name__ == '__main__':
    main()

Solution (Python):
N = int(input())
AB = [list(map(int,input().split())) for i in range(N)]
A = [AB[i][0] for i in range(N)]
B = [AB[i][1] for i in range(N)]

A.sort()
B.sort()

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

Solution (Python):
n = int(input())
a = []
b = []
for _ in range(n):
    ai, bi = map(int, input().split())
    a.append(ai)
    b.append(bi)
a.sort()
b.sort()

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

Solution (Python):
import sys
input = sys.stdin.readline
def main():
    N = int( input())
    t = 1
    if N%2 == 0:
        t = 2
    AB = [ tuple( map( lambda x: int(x)*t, input().split())) for _ in range(N)]
    A = [ab[0] for ab in AB]
    B = [ab[1] for ab in AB]
    A.sort()
    B.sort()
    if t == 1:
        m = A[N//2]
        M = B[N//2]
    else:
        m = (A[N//2-1]+A[N//2])//2
        M = (B[N//2-1]+B[N//2])//2
    print(M-m+1)
if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())
a = []
b = []
for i in range(n):
    x,y = map(int, input().split())
    a.append(x)
    b.append(y)
a.sort()
b.sort()
if n%2:
    mid_min = a[n//2]
    mid_max = b[n//2]
    print(mid_max-mid_min+1)
else:
    mid_min = (a[n//2-1]+a[n//2])/2
    mid_max = (b[n//2-1]+b[n//2])/2
    print(int((mid_max-mid_min)*2)+1)

Solution (Python):
n = int(input())

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

al = []
bl = []

for a,b in abl:
    al.append(a)
    bl.append(b)

al = sorted(al)
bl = sorted(bl)
if n % 2 == 0:
    min_a = (al[n//2-1] + al[n//2]) / 2
    max_a = (bl[n//2-1] + bl[n//2]) / 2
else:
    min_a = al[(n-1)//2]
    max_a = bl[(n-1)//2]

if n % 2 == 0:
    print(int((max_a - min_a) * 2 + 1))
else:
    print(max_a - min_a + 1)

Solution (Python):
mod = 1000000007
eps = 10**-9


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

    N = int(input())
    A = []
    B = []
    for _ in range(N):
        a, b = map(int, input().split())
        A.append(a)
        B.append(b)
    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)


if __name__ == '__main__':
    main()

Solution (Python):
import sys
input = sys.stdin.readline
def ii(): return int(input())
def mi(): return map(int, input().rstrip().split())
def lmi(): return list(map(int, input().rstrip().split()))
def li(): return list(input().rstrip())
def debug(*args, sep=" ", end="\n"): print("debug:", *args, file=sys.stderr, sep=sep, end=end) if not __debug__ else None
def exit(*arg): print(*arg); sys.exit()


def main():
    n = ii()
    l = []
    r = []
    for i in range(n):
        a, b = mi()
        l.append(2 * a)
        r.append(2 * b)
    
    l.sort()
    r.sort()
    if n % 2 == 0:
        ll = (l[n // 2] + l[n // 2 - 1]) // 2
        rr = (r[n // 2] + r[n // 2 - 1]) // 2
    else:
        ll = l[n // 2]
        rr = r[n // 2]
    
    if n % 2 == 0:
        print(rr - ll + 1)
    else:
        print(rr // 2 - ll // 2 + 1)
    return

if __name__ == "__main__":
    main()

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

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

Solution (Python):
N = int(input())
A, B = [], []
for _ in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)
if N%2==1:
    n = N//2
    print(sorted(B, reverse=True)[n]-sorted(A)[n]+1)
    exit()
l, r = (N-2)//2, N//2
A.sort()
B.sort()
print(-A[r]-A[l]+B[r]+B[l]+1)

Solution (Python):

import bisect
import collections
import sys

sys.setrecursionlimit(1000000)
ACMOD = 1000000007
INF = 1 << 62


def solve(N: int, A: "List[int]", B: "List[int]"):
    for i, a in enumerate(A):
        b = B[i]
    ca = sorted(A)

    def get_middle(arr):
        if len(arr) % 2 == 1:
            return arr[(len(arr)) // 2]
        return (arr[len(arr) // 2 - 1] + arr[len(arr) // 2]) / 2

    cb = sorted(B)
    min_ = (get_middle(ca))
    max_ = (get_middle(cb))
    if N % 2:
        print(max_ - min_ + 1)
    else:
        print(int(2 * max_ - 2 * min_ + 1))

    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    N = int(next(tokens))  
    A = [int()] * (N)  
    B = [int()] * (N)  
    for i in range(N):
        A[i] = int(next(tokens))
        B[i] = int(next(tokens))
    solve(N, A, B)


if __name__ == '__main__':
    main()

Solution (Python):
n=int(input())
alist=[]
blist=[]
for i in range(n):
    a, b = map(int,input().split())
    alist.append(a)
    blist.append(b)

alist=sorted(alist)
blist=sorted(blist)

if n%2==1:
    center=(n-1)//2
    answer=blist[center]-alist[center]+1
    print(answer)
else:
    
    mae=(alist[(n//2)-1]+alist[(n//2)])/2
    ato=(blist[(n//2)-1]+blist[(n//2)])/2
    
    print(int((ato-mae)*2+1))

Solution (Python):
import statistics
n=int(input())
a=[0 for _ in range(n)]
b=[0 for _ in range(n)]
for i in range(n):
	a[i],b[i] = map(int,input().split())







ans = 0
if n % 2 == 1:
	ans = statistics.median(b)-statistics.median(a)+1
else:
	ans = int(statistics.median(b)*2-statistics.median(a)*2+1)
print(ans)

Solution (Python):

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:
    am = A[N//2]
    bm = B[N//2]

    print (bm-am+1)

else:
    am = (A[N//2] + A[N//2-1])/2
    bm = (B[N//2] + B[N//2-1])/2

    print ( int((bm-am)/0.5) + 1)

Solution (Python):
N = int(input())
A, B = [], []
for _ in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)
A, B = sorted(A), sorted(B)
m1 = A[N//2] + A[(N-1)//2]
m2 = B[N//2] + B[(N-1)//2]
print((m2 - m1) // (N % 2 + 1) + 1)

Solution (Python):
def main():
    N = int(input())
    AB = [tuple(map(int, input().split())) for _ in range(N)]
    A = [a for a, _ in AB]
    B = [b for _, b in AB]
    A.sort()
    B.sort()
    if N & 1:
        return B[N // 2] - A[N // 2] + 1
    return (B[N // 2] + B[N // 2 - 1]) - (A[N // 2] + A[N // 2 - 1]) + 1

print(main())

Solution (Python):
import sys
input = sys.stdin.readline
N = int(input())
a = []
for _ in range(N):
  l, r = map(int, input().split())
  a.append((l, r))
a.sort()
X = 0
if N % 2: X = a[N // 2][0]
else: X = (a[N // 2 - 1][0] + a[N // 2][0]) / 2
a.sort(key = lambda x: x[1])
Y = 0
if N % 2: Y = a[N // 2][1]
else: Y = (a[N // 2 - 1][1] + a[N // 2][1]) / 2

if N % 2: print(Y - X + 1)
else: print(int(Y * 2 - X * 2 + 1))