peterverebics/CodeNet_Python_118 huggingface dataset:
N = int(input())
A = [0]*N
B = [0]*N 
for i in range(N):
    s,t = map(int,input().split())
    A[i] = s
    B[i] = t
A.sort()
B.sort()
if N%2 == 1:
    a = A[(N-1)//2]
    b = B[(N-1)//2]
    print(b-a+1)
if N%2 == 0:
    a = A[N//2 - 1] + A[N//2]
    b = B[N//2 - 1] + B[N//2]
    print(b-a+1)
n = int(input())
ab = [tuple(map(int, input().split())) for _ in range(n)]
a, b = map(list, zip(*ab))
a.sort()
b.sort(reverse=True)
a1, b1 = a[n//2], b[n//2]
a2, b2 = a[n//2-1], b[n//2-1]
if n % 2: print(b1 - a1 + 1)
else: print((b1+b2) - (a1+a2) + 1)
N = int(input())

ranges = [tuple(map(int,input().split())) for _ in range(N)]
A = sorted(a for a,b in ranges)
B = sorted(b for a,b in ranges)
if N % 2 == 0:
    a = A[N//2-1]+A[N//2]
    b = B[N//2-1]+B[N//2]
    print(b-a+1)
else:
    a = A[N//2]
    b = B[N//2]
    print(b-a+1)
N=int(input())
a=[]
b=[]
for _ in range(N):
    A,B=map(int,input().split())
    a.append(A)
    b.append(B)
a=sorted(a)
b=sorted(b)
if N%2==1:
    print(b[N//2]-a[N//2]+1)
else:
    print(int(((b[N//2-1]+b[N//2])/2-(a[N//2-1]+a[N//2])/2)*2+1))
import sys
read = sys.stdin.buffer.read
N, *AB = map(int, read().split())
A,B=AB[::2],AB[1::2]
A.sort()
B.sort(reverse=True)
pos=(N+1)//2-1
if N%2==1:
    ans = B[pos]-A[pos]+1
else:
    ans = (B[pos]+B[pos+1])-(A[pos]+A[pos+1])+1
print(ans)
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)
from statistics import median as m
n=int(input())
a=[0]*n
b=[0]*n
for i in range(n):
  x,y=map(int,input().split())
  a[i]=x
  b[i]=y
x=m(a)
y=m(b)
if n%2==0:
  x*=2
  y*=2
print(int(y-x+1))
n=int(input())
al=list()
bl=list()
for i in range(n):
    a,b=map(int,input().split())
    al.append(a)
    bl.append(b)
al.sort()
bl.sort()
l=n//2
if n%2==0:
    print(bl[l-1]+bl[l]-al[l-1]-al[l]+1)
else:
    print(bl[l]-al[l]+1)
N=int(input())
part=[list(map(int,input().split())) for _ in range(N)]

minlst=[0]*N
maxlst=[0]*N

for i in range(N):
    minlst[i]=part[i][0]
    maxlst[i]=part[i][1]
minlst.sort()
maxlst.sort()

if N%2==1:
    left=minlst[(N+1)//2-1]
    right=maxlst[(N+1)//2-1]
else:
    left=minlst[N//2-1]+minlst[N//2]
    right=maxlst[N//2-1]+maxlst[N//2]

print(right-left+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)
n = int(input())
aList = []
bList = []
for i in range(n):
  a, b = map(int, input().split())
  aList.append(a)
  bList.append(b)

aList.sort()
bList.sort()

if n % 2 == 0:
  middle = n // 2
  print(bList[middle] + bList[middle-1] - aList[middle] - aList[middle-1] + 1)
else:
  middle = (n-1) // 2
  print(bList[middle] - aList[middle] + 1)
def resolve():
	from statistics import median
	import sys
	input = sys.stdin.readline
	n = int(input())
	ab = [list(map(int, input().split())) for i in range(n)]
	mina = median(i[0] for i in ab)
	maxb = median(i[1] for i in ab)
	abrange = maxb - mina
	if n%2 == 0:
		print(int(abrange*2 + 1))
	else:
		print(int(abrange + 1))
resolve()
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:
    x = A[n//2]
    y = B[n//2]
else:
    x = A[n//2 - 1]+A[n//2]
    y = B[n//2 - 1]+B[n//2]
print(y-x+1)
N=int(input())
A=[0 for _ in range(N)]
B=[0 for _ in range(N)]
for i in range(N):
  a,b=[int(s) for s in input().split()]
  A[i]=a
  B[i]=b
A.sort()
B.sort()
def doublemed(ls,num):
  if num%2==0:
    return(ls[num//2-1]+ls[num//2])
  else:
    return(ls[num//2])
meda=doublemed(A,N)
medb=doublemed(B,N)
print(medb-meda+1)
N = int(input())
AB = [list(map(int, input().split())) for _ in range(N)]
A = sorted([ab[0]*(2-N%2) for ab in AB])
B = sorted([ab[1]*(2-N%2) for ab in AB])
if N%2 == 1:
  print(B[N//2]-A[N//2]+1)
else:
  print((B[N//2]+B[N//2-1])//2-(A[N//2]+A[N//2-1])//2+1)
import statistics

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

def median(arr):
    if len(arr) % 2 == 0:
        return (arr[n // 2 - 1] + arr[n // 2]) / 2
    else:
        return arr[n // 2]

m = n
if n % 2 == 0:
    m *= 2
medmin = median(sorted(map(lambda x: x * m, aa)))
medmax = median(sorted(map(lambda x: x * m, bb)))

print(int((medmax - medmin) / n) + 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:
    mid = N // 2
    print(B[mid] - A[mid] +1)
else:
    mid1 = N // 2
    mid2 = mid1 -1
    smallest = A[mid1] + A[mid2]
    largest = B[mid1] + B[mid2]
    print(largest - smallest + 1)
import statistics

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

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

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

print(ans)
def main():
    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)
    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)

if __name__ == "__main__":
    main()
N = int(input())
ab = []
for i in range(N):
    ab.append(tuple(map(int,input().split())))
 
up = sorted(ab,key=lambda a:a[1])
down = sorted(ab,key=lambda a:a[0])
 
if N%2 == 1:
    print(up[N//2][1]-down[N//2][0]+1)
else:
    up2 = sorted(ab,key=lambda a:a[1],reverse=True)
    down2 = sorted(ab,key=lambda a:a[0],reverse=True)
    r = (up[N//2][1]+up2[N//2][1])
    l = (down[N//2][0]+down2[N//2][0])
    print(r-l+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)
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:ans=b[n//2]-a[n//2]+1
else:ans=b[(n-1)//2+1]-a[(n-1)//2+1]+b[(n-1)//2]-a[(n-1)//2]+1
print(ans)
n = int(input())
a, b = [], []
for _ in range(n):
    tmp = list(map(int, input().split()))
    a.append(tmp[0])
    b.append(tmp[1])

a.sort()
b.sort()

if n%2:
    print(b[(n+1)//2-1]-a[(n+1)//2-1]+1)
else:
    print(b[n//2-1]+b[n//2]-a[n//2-1]-a[n//2]+1)
import numpy as np
N = int(input())
X = []
for i in range(N):
    X.append(list(map(int,input().split())))
temp = np.median(X,axis=0)
if N % 2 == 1:
    print(int(temp[1]-temp[0]+1))
else:
    print(int(2*temp[1]-2*temp[0]+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()

def median(li):
    if n%2==1:
        return li[n//2]
    else:
        return sum(li[n//2-1:n//2+1])
print(median(B)-median(A)+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 = sorted(A)
B = sorted(B)

if N % 2:
    ans = B[N//2] - A[N//2] + 1
else:
    l = A[N//2-1] + A[N//2]
    r = B[N//2-1] + B[N//2]
    ans = r-l+1
print(ans)
N = int(input())
a_list = []
b_list = []
for i in range(N):
    A, B = map(int, input().split())
    a_list.append(A)
    b_list.append(B)

a_list.sort()
b_list.sort()

a_m = a_list[N // 2 - 1] + a_list[N // 2] if N % 2 == 0 else a_list[(N + 1) // 2 - 1]
b_m = b_list[N // 2 - 1] + b_list[N // 2] if N % 2 == 0 else b_list[(N + 1) // 2 - 1]
a_m /= 2
b_m /= 2

print(int((b_m - a_m) / 0.5) + 1)
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)
N = int(input())
I = []

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

L = sorted(I)
R = sorted(I, key = lambda x: x[1])

if N%2 == 1:
  x = N//2
  print(R[x][1] - L[x][0] + 1)
else:
  x = N//2
  M = R[x][1] - L[x][0] + 1
  m = R[x-1][1] - L[x-1][0] + 1
  print(M + m - 1)
import statistics
import math

n = int(input())
aa,bb = [],[]

for i in range(n):
    a,b = map(int,input().split())
    
    aa.append(a)
    bb.append(b)
    
aa.sort()
bb.sort()
    
if n % 2 == 1:
    am = aa[n//2]
    bm = bb[n//2]
    
    ans = bm - am + 1
    
else:
    am = (aa[n//2] + aa[n//2-1]) / 2
    bm = (bb[n//2] + bb[n//2-1]) / 2
    
    ans = (bm - am)*2 + 1
    
print(int(ans))
import numpy as np

N = int(input())
A, B = [], []
for i in range(N):
    a, b = map(int, input().split())
    A.append(a if N & 1 else 2 * a)
    B.append(b if N & 1 else 2 * b)

a, b = int(np.median(A)), int(np.median(B))
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==1:
    ans = b[n//2]-a[n//2]+1
else:
    x1 = a[n//2]+a[n//2-1]
    x2 = b[n//2]+b[n//2-1]
    ans = x2-x1+1
print(ans)
import numpy as np

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

medA = np.median(Aarray)
medB = np.median(Barray)

if N%2 == 1:
    ans = medB-medA+1
else:
    ans = 2*(medB-medA)+1
    

print(str(int(ans)))
n = int(input())
a = []
b = []
for i in range(n):
    at, bt = map(int, input().split())
    a.append(at)
    b.append(bt)
if(n % 2 == 1):
    a.sort()
    b.sort()
    min_med = a[(n-1)//2]
    max_med = b[(n-1)//2]
    result = max_med - min_med + 1
else:
    a.sort()
    b.sort()
    min_med = (a[n//2-1] + a[n//2])/2
    max_med = (b[n//2-1] + b[n//2])/2
    result = (max_med - min_med)*2 + 1
print(int(result))
N = int(input())
ab = []
for i in range(N):
    ab.append(tuple(map(int,input().split())))
 
up = sorted(ab,key=lambda a:a[1],reverse=True)
down = sorted(ab,key=lambda a:a[0],reverse=True)
 
if N%2 == 1:
    print(up[N//2][1]-down[N//2][0]+1)
else:
    r = (up[N//2][1]+up[N//2-1][1])
    l = (down[N//2][0]+down[N//2-1][0])
    print(r-l+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:
  al=A[(N-1)//2]
  ar=A[N//2]
  bl=B[(N-1)//2]
  br=B[N//2]
  print(int(((br+bl)/2-(ar+al)/2)*2+1))
else:
  mini=A[(N-1)//2]
  maxi=B[(N-1)//2]
  print(maxi-mini+1)
import numpy as np
n = int(input())
A, B = [], []
for _ in range(n):
    a,b = map(int,input().split())
    A.append(a)
    B.append(b)

x = np.median(A)
y = np.median(B)
if n%2==0:
    print(int((y-x)/0.5+1))
else:
    print(int(y-x+1))
N = int(input())
X = [list(map(int,input().split())) for _ in range(N)]
A = sorted([X[i][0] for i in range(N)])
B = sorted([X[i][1] for i in range(N)])
if N%2==1:
    k = (N+1)//2
    a = A[k-1]
    b = B[k-1]
    print(b-a+1)
else:
    a2 = A[N//2-1]+A[N//2]
    b2 = B[N//2-1]+B[N//2]
    print(b2-a2+1)
n = int(input())
ab = []

for i in range(n):
    a, b = map(int, input().split())
    ab.append((a, b))

if n % 2 == 1:
    ab.sort()
    min_val = ab[n//2][0]
    ab.sort(key=lambda x: -x[1])
    max_val = ab[n//2][1]
    print(max_val - min_val + 1)
else:
    ab.sort()
    min_val = ab[n//2][0] + ab[n//2 - 1][0]
    ab.sort(key=lambda x: -x[1])
    max_val = ab[n//2][1] + ab[n//2 - 1][1]
    print(max_val - min_val + 1)
N = int(input())
AB = [[int(i) for i in input().split()] for _ in range(N)]

A = sorted([a for a,_ in AB])
B = sorted([b for _,b in AB])

if N % 2 == 1: # 奇数
    MIN = A[(N + 1) // 2 - 1]
    MAX = B[(N + 1) // 2 - 1]

else: # 偶数
    MIN = A[N // 2 - 1] + A[N // 2]
    MAX = B[N // 2 - 1] + B[N // 2]

print(MAX - MIN + 1)
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 sys
input = sys.stdin.readline

def main():
    n = int(input())
    low = []
    high = []

    for i in range(n):
        a, b = map(int, input().split())
        low.append(a)
        high.append(b)

    low.sort()
    high.sort()

    if n%2 == 1:
        l = low[n//2]
        h = high[n//2]
    else:
        l = low[n//2 - 1] + low[n//2]
        h = high[n//2 - 1] + high[n//2]

    ans = h - l + 1

    print(ans)

main()
import statistics
import math

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

A_m = statistics.median(A)
B_m = statistics.median(B)
if n%2 == 1:
    num = B_m - A_m +1
elif n %2 ==0:
    num = 2*B_m - 2*A_m +1
print(int(num))
import sys

readline = sys.stdin.readline
N = int(readline())
A = []
B = []
for _ in range(N):
    a, b = map(int, readline().split())
    A.append(a)
    B.append(b)
A.sort()
B.sort()
if N % 2 == 0:
    mi = A[N//2-1]+A[N//2]
    ma = B[N//2-1]+B[N//2]
else:
    mi = A[N//2]
    ma = B[N//2]
print(ma-mi+1)
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)
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:
    print(B[N//2]-A[N//2]+1)
else:
    A_chu=(A[N//2-1]+A[N//2])/2
    B_chu=(B[N//2-1]+B[N//2])/2
    ans=(B_chu-A_chu)*2+1
    print(int(ans))
import bisect
n = int(input())
a = []
b = []

for i in range(n):
    m, p = map(int, input().split())
    a.append(m)
    b.append(p)
a.sort()
b.sort()
middle = n // 2
if n % 2:
    print(b[middle] - a[middle] + 1)
else: 
    a_m = ( a[middle] + a[middle - 1] ) / 2
    b_m = ( b[middle] + b[middle - 1] ) / 2
    print(int((b_m - a_m) * 2 + 1))
N = int(input())
AB = [[int(i) for i in input().split()] for _ in range(N)]

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

if N % 2 == 0 :
  print(B[N//2] + B[N//2-1] - A[N//2] - A[N//2-1] + 1)
else :
  print(B[N//2] - A[N//2] + 1)
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:
    print(B[N//2] - A[N//2] + 1)
else:
    a0 = A[N//2 - 1]
    b0 = B[N//2 - 1]
    a1 = A[N//2]
    b1 = B[N//2]

    print((b1 + b0) - (a1 + a0) + 1)
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)
N = int(input())
As = []
Bs = []

for _ in range(N):
  a,b = map(int,input().split())
  As.append(a)
  Bs.append(b)
  
As.sort()
Bs.sort()

if N%2 == 1:
  ma = As[N//2]
  mb = Bs[N//2]
  print(mb-ma+1)
else:
  ma = (As[N//2-1] + As[N//2])/2
  mb = (Bs[N//2-1] + Bs[N//2])/2
  print(int((mb-ma)*2)+1)
N = int(input())

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

if N % 2 == 0:
    Amed = A[N//2-1]+A[N//2]
    Bmed = B[N//2-1]+B[N//2]
    print(Bmed-Amed+1)
else:
    Amed = A[N//2]
    Bmed = B[N//2]
    print(Bmed-Amed+1)
N, *AB = map(int, open(0).read().split())

A = sorted(zip(*[iter(AB)] * 2), key=lambda t: t[0])
B = sorted(zip(*[iter(AB)] * 2), key=lambda t: t[1])

if N % 2 == 1:
    L = A[N // 2][0]
    R = B[N // 2][1]
else:
    L = A[N // 2 - 1][0] + A[N // 2][0]
    R = B[N // 2 - 1][1] + B[N // 2][1]

print(R - L + 1)
n=int(input())
alis=[]
blis=[]
for i in range(n):
  a,b=map(int,input().split())
  alis.append(a)
  blis.append(b)
  
  
alis=sorted(alis)
blis=sorted(blis)
if n%2!=0:
  print(blis[int((n-1)/2)]-alis[int((n-1)/2)]+1)
else:
  bb=(blis[int(n/2)-1]+blis[int(n/2)])
  aa=(alis[int(n/2)-1]+alis[int(n/2)])
  print(bb-aa+1)
import math

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

A=[]
B=[]
for i in range(x):
    A.append(ab[i][0])
    B.append(ab[i][1])

A.sort()
B.sort()

if x%2==1:
    min=A[x//2]
    max=B[x//2]
    ans=max-min+1
else:
    min=(A[x//2-1]+A[x//2])/2
    max=(B[x//2-1]+B[x//2])/2
    ans=(max-min)*2+1

print(int(ans))
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

import statistics as st

n = ii()
a = []
b = []
for i in range(n):
    aa,bb = mi()
    a.append(aa)
    b.append(bb)

a.sort()
b.sort()

minmed = st.median(a)
maxmed = st.median(b)

if len(a) %2 == 0:
    ans = maxmed*2 - minmed*2 + 1
else:
    ans = maxmed-minmed+1
print(int(ans) )
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==0:
    print(B[N//2-1] + B[N//2] - (A[N//2-1] + A[N//2]) + 1)
else:
    print(B[(N-1)//2] - A[(N-1)//2] + 1)
def read_int():
    return int(input())


def read_ints():
    return map(int, input().split(' '))


n = read_int()
a = []
b = []
for i in range(n):
    ai, bi = read_ints()
    a.append(ai)
    b.append(bi)
a.sort()
b.sort()
if n % 2 == 0:
    ma = a[n // 2 - 1] + a[n // 2]
    mb = b[n // 2 - 1] + b[n // 2]
    print(mb - ma + 1)
else:
    ma = a[n // 2]
    mb = b[n // 2]
    print(mb - ma + 1)
from statistics import median

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

mn = median(A)
mx = median(B)

if N % 2 == 1:
    print(int(mx - mn + 1))        # mn, mn + 1, mn + 2, ..., mx
else:
    print(int((mx - mn) * 2 + 1))    # mn, mn + 0.5, mn + 1, ..., mx
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)
def e_count_median():
    N = int(input())
    Min, Max = [], []
    for _ in range(N):
        a, b = [int(i) for i in input().split()]
        Min.append(a)
        Max.append(b)
    Min.sort()
    Max.sort()

    mid = N // 2
    median_min, median_max = ((Min[mid], Max[mid]) if N % 2 == 1
                              else (Min[mid] + Min[mid - 1], Max[mid] + Max[mid - 1]))
    return median_max - median_min + 1

print(e_count_median())
n=int(input())
l1=[]
l2=[]
for i in range(n):
    a,b=map(int,input().split())
    l1.append(a)
    l2.append(b)
l1.sort()
l2.sort()
if n%2==0:
    low=l1[n//2]+l1[n//2-1]
    high=l2[n//2]+l2[n//2-1]
    print(high-low+1)
else:
    low=l1[n//2]
    high=l2[n//2]
    print(high-low+1)
n = int(input())
al=[]
bl=[]
for i in range(n):
    a , b = map(int, input().split())
    al.append(a)
    bl.append(b)
al.sort()
bl.sort()
if n%2==1:
    mi = al[n//2]
    ma = bl[n//2]
    print(int(ma-mi)+1)
else:
    mi = (al[n//2-1]+al[n//2])/2
    ma = (bl[n//2-1]+bl[n//2])/2
    print(int((ma-mi)*2+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))
N = int(input())
aa = []
bb = []
for i in range(N):
    a,b = [int(x) for x in input().split()]
    aa.append(a)
    bb.append(b)
aa.sort()
bb.sort()
if N % 2 != 0:
    print(bb[N//2]-aa[N//2]+1)
else:
    print(bb[N//2]+bb[N//2-1]-aa[N//2]-aa[N//2-1]+1)
import numpy as np
i4 = np.int32

nin = np.fromstring(open(0).read(), i4, sep=' ')
N = nin[0]
ab = nin[1:].reshape(-1, 2).T
a = np.sort(ab[0])
b = np.sort(ab[1])
i = N // 2
if N % 2:
    print(b[i] - a[i] + 1)
else:
    nmin = a[i - 1] + a[i]
    nmax = b[i - 1] + b[i]
    print(nmax - nmin + 1)
import itertools
import copy
from collections import deque
import heapq
n = int(input())
ma = []
mi = []
for i in range(n):
    a,b = map(int,input().split())
    mi.append(a)
    ma.append(b)
mi.sort()
ma.sort()
if n % 2 == 1:
    ans = ma[(n+1)//2-1]-mi[(n+1)//2-1] + 1
else:
    ans = (ma[n//2]+ma[n//2-1]-mi[n//2]-mi[n//2-1])+1
print(ans)
n=int(input())
a,b=[0]*n,[0]*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(1+(b[n//2]+b[(n-1)//2])-(a[n//2]+a[(n-1)//2]))
n = int(input())
a = []
b = []
for _ in range(n):
    aa, bb = list(map(int, input().split()))
    a.append(aa)
    b.append(bb)


import numpy as np

if n%2 == 0:
    print(int((np.median(b) - np.median(a)) / 0.5) + 1)
else:
    print(int((np.median(b) - np.median(a))) + 1)
N, *AB = map(int, open(0).read().split())
A = sorted(AB[::2])
B = sorted(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)
N = int(input())
low = [0] * N;  up = [0] * N;
for i in range(N):
    low[i], up[i] = [int(x) for x in input().split()]

low.sort()
up.sort(reverse = True)

if N % 2 == 0:
    k = N // 2
    ans = 0
    l1 = low[k - 1]
    l2 = low[k]
    u1 = up[k - 1]
    u2 = up[k]
    ans = u1 + u2 - l1 - l2 + 1
else:
    k = (N - 1) // 2
    l = low[k]
    u = up[k]
    ans = u - l + 1

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

al = []
bl = []
for a,b in ab:
  al.append(a)
  bl.append(b)
al.sort()
bl.sort()

if N%2 == 0:
  ans = (bl[N//2] + bl[N//2 -1]) - (al[N//2] + al[N//2 -1]) +1
else:
  ans = bl[N//2] - al[N//2] +1
print(ans)
n=int(input())
l=[]
r=[]
ans=0
for i in range(n):
    a,b=map(int,input().split())
    l.append(a)
    r.append(b)
l.sort()
r.sort()
if n%2==0:
    ans=int(((r[n//2]+r[n//2-1])/2-(l[n//2]+l[n//2-1])/2)*2+1)
else:
    ans=r[n//2]-l[n//2]+1
print(ans)
N = int(input())
AB = [list(map(int, input().split())) for _ in range(N)]
AB = list(map(list, (zip(*AB))))
A = sorted(AB[0])
B = sorted(AB[1])
if N % 2 == 0:
    m = N // 2
    left = (A[m] + A[m-1])
    right = (B[m] + B[m-1])
    print(right - left + 1)
else :
    m = N // 2
    print((B[m] - A[m]) + 1)
N = int(input())

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

XA.sort()
XB.sort()

if N % 2 == 1:
    aa = XA[ (N - 1) // 2] 
    bb = XB[ (N - 1) // 2]
    print(bb - aa + 1)
else:
    aa1 = XA[N // 2]
    bb1 = XB[N // 2]
    aa = XA[N // 2 - 1]
    bb = XB[N // 2 - 1]
    print((bb1 + bb) - (aa1 + aa) + 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 = 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 = []
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:
    b = (B[N//2-1]+B[N//2])/2
    a = (A[N//2-1]+A[N//2])/2
    ans = (b-a)//0.5 +1
else:
    b = B[(N+1)//2-1]
    a = A[(N+1)//2-1]
    ans = b-a+1
print(int(ans))
N = int(input())
AB = [list(map(int, input().split())) for i in range(N)]

def mid(AB, idx):
    if N % 2 == 0:
        return (AB[N//2-1][idx] + AB[N//2][idx]) / 2
    else:
        return AB[(N+1)//2-1][idx]

AB.sort()
amid = mid(AB, 0)
AB.sort(key=lambda x: x[1])
bmid = mid(AB, 1)
tmp = 1 if N % 2 == 1 else 2
print(int(tmp * (bmid - amid) + 1))
n = int(input())
a = []
b = []
for i in range(n):
  aa, bb = map(int, input().split())
  a.append(aa)
  b.append(bb)
a.sort()
b.sort()
ans = 0
if n%2 == 1:
  ans = b[n//2]-a[n//2]+1
else:
  ans = (b[n//2]-a[n//2])+(b[n//2-1]-a[n//2-1])+1
print (ans)