peterverebics/CodeNet_Python_118 huggingface dataset:
n = int(input())
a = []
b = []
ab = []
for i in range(n):
    ai,bi = map(int,input().split())
    a.append(ai)
    b.append(bi)
    ab.append((ai,bi))
a.sort()
b.sort()
x1 = a[(n-1)//2]
x2 = a[(n-1)//2+1]
y1 = b[n-1-(n-1)//2]
y2 = b[n-2-(n-1)//2]
if n % 2 == 1:
    print(y1-x1+1)
else:
    print(y2+y1-x2-x1+1)
N = int(input())
E = [list(map(int,input().split())) for _ in range(N)]

E = sorted(E,key=lambda x:x[0])

A=[v[0] for v in E]
B=[v[1] for v in E]

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


if N%2==0:
    A_mid = (A[N//2]+A[N//2-1])
    B_mid = (B[N//2]+B[N//2-1])
    print(B_mid-A_mid+1)
else:
    A_mid = A[N//2]
    B_mid=B[N//2]
    print(B_mid-A_mid+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 != 0 :
    print(b[n//2] - a[n//2] + 1)
    exit(0)

def m_r(c):
    return (c[n//2] + c[n//2 - 1])

z = m_r(b) - m_r(a) + 1
print(z)
from statistics import median

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

if n % 2 == 1:
    print(abs(median(b) - median(a)) + 1)
else:
    print(int(abs(median(b) - median(a)) * 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 == 0:
    start = (a[n//2-1] + a[n//2]) / 2
    end = (b[n//2-1] + b[n//2]) / 2
    print(int((end-start) * 2 + 1))
else:
    print(b[(n+1)//2-1] - a[(n+1)//2-1] + 1)
n = int(input())
a, b = [], []
lst = []
for i in range(1, n+1):
    ai, bi = map(int, input().split())
    a.append(ai)
    b.append(bi)
    lst.append([ai, bi, i])

if n % 2 == 1:
    a.sort()
    b.sort()
    idx = n//2
    print(b[idx]-a[idx]+1)
    exit()

a.sort()
b.sort()
mini = (a[n//2]+a[n//2-1])/2
maxi = (b[n//2]+b[n//2-1])/2
print(int((maxi-mini)*2+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()

#print(A)
#print(B)

if n%2:
    a = A[(n+1)//2-1]
    b = B[(n+1)//2-1]
    print(int(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)*2+1))
n = int(input())
left = []
right = []

for i in range(n):
    array = list(map(int, input().split()))
    left.append(array[0])
    right.append(array[1])

left.sort()
right.sort()

if n % 2 != 0:
    print(right[n//2] - left[n//2] + 1)
else:
    num1 = (right[n//2] + right[n//2-1])/2
    num2 = (left[n//2] + left[n//2-1])/2
    print(int((num1 - num2)*2 + 1))
import sys
input = sys.stdin.buffer.readline

N = int(input())
pairs = [tuple(map(int, input().split())) for _ in range(N)]
As, Bs = zip(*pairs)

if N % 2 == 0:
    sA = sorted(As)
    medA2 = sA[N//2-1] + sA[N//2]
    sB = sorted(Bs)
    medB2 = sB[N//2-1] + sB[N//2]
    print(medB2 - medA2 + 1)
else:
    sA = sorted(As)
    medA = sA[N//2]
    sB = sorted(Bs)
    medB = sB[N//2]
    print(medB - medA + 1)
import sys
input = lambda: sys.stdin.readline().rstrip()

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

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

if n%2 ==1:
    a.sort()
    b.sort()
    xmin= a[int((n-1)/2)]
    xmax= b[int((n - 1) / 2)]

    print(int(xmax-xmin+1))

if n%2 ==0:
    a.sort()
    b.sort()
    xmin = a[int(n/2-1)]+a[int(n/2)]
    xmax = b[int(n / 2 - 1)] + b[int(n / 2)]
    print(int((xmax-xmin)+1))
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))
import math


def median(array):
    if N % 2:
        return array[N // 2]
    else:
        return sum(array[N // 2 - 1: N // 2 + 1])


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()
x = median(A)
y = median(B)
print(y - x + 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:
  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 x in range(n):
    tmp = list(map(int, input().split()))
    a[x] = tmp[0]
    b[x] = tmp[1]

a.sort()
b.sort()
if n % 2 == 1:
    l = a[n // 2]
    r = b[n // 2]
    print(r - l + 1)
else:
    l1, l2 = a[n // 2 - 1], a[n // 2]
    r1, r2 = b[n // 2 - 1], b[n // 2]
    print((r1 + r2) - (l1 + l2) + 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, 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)
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)
N = int(input())

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

listXmin = []
listXmax = []
maxXi = 0
minXi = 10 ** 10
for i in range(N):
    listXmin.append(A[i])
    listXmax.append(B[i])

listXmin.sort()
listXmax.sort()
if N % 2 == 0:
    centrali = int(N / 2) - 1
    centralinext = int(N / 2)
    print(((listXmax[centrali] + listXmax[centralinext]) - (listXmin[centrali] + listXmin[centralinext])) + 1)
else:
    centrali = int((N + 1) / 2) - 1
    print(listXmax[centrali] - listXmin[centrali] + 1)
n = int(input())
x = [tuple(map(int, input().split())) for _ in range(n)]

if n % 2 == 1:
    x.sort()
    l = x[n // 2][0]
    x.sort(key=lambda x: -x[1])
    r = x[n // 2][1]
    print(r - l + 1)

else:
    x.sort()
    l1 = x[n // 2 - 1][0]
    l2 = x[n // 2][0]
    x.sort(key=lambda x: -x[1])
    r1 = x[n // 2 - 1][1]
    r2 = x[n // 2][1]
    print(r1 + r2 - l1 - l2 + 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:
    m = (A[n//2]+A[n//2-1])
    M = (B[n//2]+B[n//2-1])
    print(M-m+1)
N = int(input())
a = [0]*N
b = [0]*N
for i in range(N):
    a[i],b[i] = map(int, input().split())
import statistics
X = statistics.median(a)
Y = statistics.median(b)
if N%2==1:
    print(Y-X+1)
else:
    print(int((2*(Y-X)+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:
    print(int(((B[n//2]+B[n//2-1])/2-(A[n//2]+A[n//2-1])/2)*2+1))
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 == 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())
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)
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:
    x = A[n//2-1]+A[n//2]
    y = B[n//2-1]+B[n//2]
    ans = y-x+1
else:
    x = A[n//2]
    y = B[n//2]
    ans = y-x+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()
B.sort()

sorted_A = A
sorted_B = B

if N % 2 != 0:
  center_A = sorted_A[N//2]
  center_B = sorted_B[N//2]
  print(center_B - center_A + 1)
else:
  center_A = (sorted_A[N//2-1] + sorted_A[N//2]) / 2
  center_B = (sorted_B[N//2-1] + sorted_B[N//2]) / 2
  print(int((center_B - center_A)*2 + 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()
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())
li_a = []
li_b = []
for _ in range(n):
    a, b = map(int, input().split())
    li_a.append(a)
    li_b.append(b)
li_a.sort()
li_b.sort()
if n%2 == 1:
    min_c = li_a[(n-1)//2]
    max_c = li_b[(n-1)//2]
    print(max_c-min_c+1)
else:
    min_c = (li_a[(n//2)-1] + li_a[(n//2)])/2
    max_c = (li_b[(n//2)-1] + li_b[(n//2)])/2
    print(int((max_c-min_c)*2+1))
import statistics

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

low = statistics.median(AB[0])
high = statistics.median(AB[1])

if len(AB[0])%2 ==0:
    print(int(2*(high-low)+1))
else:
    print(high-low+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()
j = n//2
if n%2 == 0:
  print((B[j]+B[j-1])-(A[j]+A[j-1])+1)
else:
  print(B[j]-A[j]+1)
# coding: utf-8
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:
    print(B[N//2-1]-A[N//2-1]+B[N//2]-A[N//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=sorted(a)
b=sorted(b)
n-=1

if n%2==1:
  A=(a[n//2]+a[n//2+1])/2
  B=(b[n//2]+b[n//2+1])/2
  print(int(-(A-B)*2+1))
  #print(a)
  #print(b)
  #print(A,B)
else:
  A=a[(n+1)//2]
  B=b[(n+1)//2]
  print(-A+B+1)
  #print([a,b,A,B])
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:
    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 i in range(n):
	x,y = map(int,input().split())
	a.append(x)
	b.append(y)
a.sort()
b.sort()
if(n&1):
	l = a[n//2]
	r = b[n//2]
else:
	l = a[n//2]+a[n//2-1]
	r = b[n//2]+b[n//2-1]
print(r-l+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 == 0:
    min_a = a[n // 2 - 1] + a[n // 2]
    min_b = b[n // 2 - 1] + b[n // 2]
    print(min_b - min_a + 1)
else:
    min_a = a[n // 2]
    min_b = b[n // 2]
    print(min_b - min_a + 1)
def solve():
    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(reverse=True)

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

if n%2 == 1:
	print(b[(n+1)//2]-a[(n+1)//2]+1)
else:
	print(b[n//2]-a[n//2]+b[n//2+1]-a[n//2+1]+1)
n=int(input())
m,M=[],[]
for i in range(n):
  a,b=map(int,input().split())
  m+=[a]
  M+=[b]
m.sort()
M.sort()
d=n//2
print(M[d]-m[d]+1+(M[d-1]+-m[d-1])*(1-n%2))
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))
n = int(input())
la, lb = [], []
for _ in range(n):
    a, b = map(int, input().split())
    la.append(a)
    lb.append(b)

la.sort()
lb.sort(reverse=True)

if n % 2 == 1:
    i = n // 2 + 1
    md = la[i - 1]
    mu = lb[i - 1]
    answer = mu - md + 1
else:
    i = n // 2
    md2 = la[i - 1] + la[i]
    mu2 = lb[i - 1] + lb[i]
    answer = (mu2 - md2) + 1

print(answer)
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)

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

if N % 2 == 1:
    i = N // 2
    AB.sort()
    L = AB[i][0]
    AB.sort(key=lambda x: x[1])
    R = AB[i][1]
    ans = R - L + 1
else:
    i = N // 2 - 1
    j = i + 1
    AB.sort()
    L = AB[i][0] + AB[j][0]
    AB.sort(key=lambda x: x[1])
    R = AB[i][1] + AB[j][1]
    ans = R - L + 1

print(ans)
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=False)
down = sorted(ab,key=lambda a:a[0],reverse=False)
 
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())

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

s=sorted(s)
e=sorted(e,reverse=True)

x=n//2
if n%2==1:
  ans=(e[x]-s[x]+1)

else:
  ts=(s[x]+s[x-1])/2
  te=(e[x]+e[x-1])/2
  ans=(te-ts)//0.5+1

print(int(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()
b.sort()

if N % 2 == 1:
  mid = N // 2
  print(b[mid] - a[mid] + 1)
else:
  mid1 = N // 2
  mid2 = mid1 - 1
  print(b[mid1] + b[mid2] - a[mid1] - a[mid2] + 1)
import statistics
def main():
    N = int(input())
    A = []
    B = []
    for i in range(N):
        a, b = [int(_n) for _n in input().split()]
        A.append(a)
        B.append(b)
    a = statistics.median(A)
    b = statistics.median(B)
    # print(a,b)
    if N % 2 == 0:
        print(int(2 * (b-a))+1)
    else:
        print(int(b-a)+1)


main()
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==0:
    x=[a[n//2-1],a[n//2]]
    y=[b[n//2-1],b[n//2]]
    print(sum(y)-sum(x)+1)
else:
    x=a[n//2]
    y=b[n//2]
    print(y-x+1)
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()
if n%2:
  c=(n+1)//2-1
  print(B[c]-A[c]+1)
else:
  c=n//2
  print(B[c]+B[c-1]-A[c]-A[c-1]+1)
import numpy as np
(n,),*l = [[*map(int,i.split())]for i in open(0)]
a,b = np.median(l,axis=0)
if n%2>0:
    print(int(b-a+1))
else:
    print(int(b*2-a*2)+1)
n=int(input())
A=[list(map(int,input().split())) for i in range(n)]
B=[[A[i][1],A[i][0]] for i in range(n)]
A.sort()
B.sort(reverse=True)
if n%2==1:
  print(B[(n-1)//2][0]-A[(n-1)//2][0]+1)
else:
  print((B[n//2][0]+B[n//2-1][0])-(A[n//2][0]+A[n//2-1][0])+1)
# ABC169 E

N=int(input())
AB=[tuple(map(int,input().split())) for _ in [0]*N]

def med(A):
    N=len(A)
    if N%2:
        return A[(N+1)//2-1]
    else:
        return (A[N//2-1]+A[N//2])/2
    
A=[i[0] for i in AB]  
B=[i[1] for i in AB]
medA=med(sorted(A))
medB=med(sorted(B))

if N%2:
    print(medB-medA+1)
else:
    print(int(2*medB-2*medA+1))
from statistics import median

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

if n % 2 == 1:
    print(abs(median(b) - median(a)) + 1)
else:
    print(int(abs(median(b) - median(a)) * 2) + 1)
N, *AB = 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)
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:
    medi = N // 2
    ans = B[medi] - A[medi] + 1
else:
    medi1 = N // 2 - 1
    medi2 = medi1 + 1
    A_medi = (A[medi1] + A[medi2]) / 2
    B_medi = (B[medi1] + B[medi2]) / 2
    ans = (B_medi - A_medi) * 2 + 1
print(int(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(reverse=True)

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

# print(a)
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:
    j = N // 2
    i = j - 1
    med1_by_2 = A[i] + A[j]
    med2_by_2 = B[i] + B[j]
    ans = med2_by_2 - med1_by_2 + 1
else:
    i = N // 2
    med1 = A[i]
    med2 = B[i]
    ans = med2 - med1 + 1
print(ans)
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))
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()
M=N//2

if N%2:
    print(B[M]-A[M]+1)
else:
    print((B[M-1]+B[M]) - (A[M-1]+A[M]) + 1)
N = int(input())
A = []
B = []
for i in range(N):
  Anew, Bnew = map(int,input().split())
  A.append(Anew)
  B.append(Bnew)
A.sort()
B.sort()
if N % 2 == 0:
  min = (A[N//2-1] + A[N//2]) / 2
  max = (B[N//2-1] + B[N//2]) / 2
  print(int((max-min)*2+1))
else:
  min = (A[(N-1)//2])
  max = (B[(N-1)//2])
  print(max-min+1)
N = int(input())
X = [list(map(int, input().split())) for _ in range(N)]

lb = sorted(v for v, _ in X)
ub = sorted(v for _, v in X)

if N % 2 == 0:
    l = lb[N // 2 - 1] + lb[N // 2]
    u = ub[N // 2 - 1] + ub[N // 2]
    print(u - l + 1)
else:
    l = lb[N // 2]
    u = ub[N // 2]
    print(u - l + 1)
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:
    ans = B[N // 2] - A[N // 2] + 1
    print (ans)
else:
    a = (A[N // 2 - 1] + A[N // 2])
    b = (B[N // 2 - 1] + B[N // 2])
    print (b - a + 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, b = [], []
for _ in range(n):
    u, v = map(int, input().split())
    a.append(u)
    b.append(v)
a.sort()
b.sort(reverse = True)
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())
A = list()
B = list()
for _ in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)
A.sort()
B.sort(reverse=True)
if N%2 == 1:
    print(B[(N+1)//2 - 1] - A[(N+1)//2 - 1] + 1)
else:
    print((B[(N+1)//2 - 1] - A[(N+1)//2 - 1]) + (B[(N+1)//2] - A[(N+1)//2]) + 1)
n = int(input())
a_list = []
b_list = []

for _ in range(n):
    a, b = map(int,input().split())
    a_list.append(a)
    b_list.append(b)

a_list.sort()
b_list.sort()

if n%2==0:
    half = int(n/2)
    first = (a_list[half-1]+a_list[half])/2
    last = (b_list[half-1]+b_list[half])/2
    print(int((last-first)/0.5)+1)
else:
    half = int((n+1)/2)
    print(b_list[half-1]-a_list[half-1]+1)
def main():
  N = int(input())
  A = []
  B = []
  for i 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-1)//2]-A[(N-1)//2]+1)
  else:
    med_A = (A[N//2-1] + A[N//2])/2
    med_B = (B[N//2-1] + B[N//2])/2
    print(int((med_B-med_A)*2 + 1))
if __name__ == "__main__":
  main()
# coding: utf-8

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

print(ans)
n=int(input())
a=sorted([list(map(int,input().split())) for i in range(n)])
b=sorted(a,key=lambda x:x[1])
if n%2==1:
    print(b[n//2][1]-a[n//2][0]+1)
else:
    print((b[n//2-1][1]+b[n//2][1])-(a[n//2-1][0]+a[n//2][0])+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()
#print(A)
#print(B)
if N % 2 == 1:
    AA = A[(N+1)//2-1]
    BB = B[(N+1)//2-1] 
    print(BB-AA+1)
else:
    AA = (A[N//2-1]+A[N//2])/2
    BB = (B[N//2-1]+B[N//2])/2
    print(int((BB-AA)*2+1))
from math import sqrt
itl = lambda: list(map(float, input().strip().split()))


def median(N, C):
    if N % 2:
        return C[N // 2]
    else:
        return C[N // 2 - 1] + C[N // 2]


def solve():
    N = int(input())

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

    ma = median(N, A)
    mb = median(N, B)
    return mb - ma + 1


if __name__ == '__main__':
    print(solve())
#!/usr/bin/env python3
import sys

input = sys.stdin.readline


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


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


def MI():
    return 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)
n = int(input())

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



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



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



if n % 2 == 1:
    print(bm - am + 1)
else:
    print(int((bm - am) * 2 + 1))
def calc_median(X):
    #中央値計算
    Xl = len(X)
    if Xl % 2:
        ret = X[(Xl + 1) // 2 - 1]
    else:
        ret = (X[Xl // 2 - 1] + X[Xl // 2]) / 2

    return ret


N, *AB = map(int, open(0).read().split())

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

AM = calc_median(A)
BM = calc_median(B)

if N % 2:
    ans = BM - AM + 1
else:
    ans = int((BM - AM) * 2 + 1)

print(ans)
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())
d = []
u = []
for _ in range(n):
    a, b = map(int, input().split())
    d.append(a)
    u.append(b)

d = sorted(d)
u = sorted(u, reverse=True)
if n % 2 == 0:
    dl = (d[n//2] + d[n//2-1]) / 2
    ul = (u[n//2] + u[n//2-1]) / 2
    ans = int((ul-dl) / 0.5 + 1)
else:
    dl = d[n//2]
    ul = u[n//2]
    ans = ul-dl+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()
B.sort(reverse=True)
if N%2==1:
  mid = (N+1)//2-1
  ans = B[mid]-A[mid]+1
else:
  mid1 = N//2-1
  mid2 = N//2
  ans = (B[mid1]+B[mid2])-(A[mid1]+A[mid2])+1

print(ans)
n=int(input())
arr1=[]
arr2=[]
for _ in range(n):
  a,b=map(int,input().split())
  arr1.append(a)
  arr2.append(b)
arr1=sorted(arr1)
arr2=sorted(arr2)
if n%2==1:
  l=arr1[n//2]
  r=arr2[n//2]
else:
  l=arr1[n//2-1]+arr1[n//2]
  r=arr2[n//2-1]+arr2[n//2]
print(r-l+1)
N = int(input())
As = []
Bs = []
for i in range(N):
  A, B = map(int, input().split())
  As.append(A)
  Bs.append(B)
As.sort()
Bs.sort()
if N%2 == 1:
  A = As[N//2]
  B = Bs[N//2]
  r = B-A+1
else:
  A = As[(N-1)//2]+As[N//2]
  B = Bs[(N-1)//2]+Bs[N//2]
  r = B-A+1
print(r)
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)
        

if __name__ == "__main__":
    main()