peterverebics/CodeNet_Python_118 huggingface dataset:
N = int(input())
A = [0] * (N + 1)
B = [0] * (N + 1)

count = 0

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

if N % 2 == 1:
  centerA = int(A[(N + 1) // 2])
  centerB = int(B[(N + 1) // 2])
else:
  centerA = (A[N // 2] + A[N // 2 + 1]) / 2
  centerB = (B[N // 2] + B[N // 2 + 1]) / 2

#print(centerA, centerB)  

if N % 2 == 1:
  count = int(centerB) - int(centerA) + 1
else:
  count = int(centerB * 2) - int(centerA * 2) + 1

print(int(count))
import statistics
n=int(input())
r=set([])
x=[[]]*n
for i in range(n):
  a,b=list(map(int,input().split()))
  x[i]=[a,b]
r0=statistics.median([x[z][0] for z in range(n)])
r1=statistics.median([x[z][1] for z in range(n)])
if ((r0*2) % 2)>0 or ((r1*2) % 2)>0:
  mult=2
else:
  mult=1
mult=int((r1-r0)*mult+1)
print(mult)
N = int(input())
ab = [list(map(int, input().split())) for _ in range(N)]


if N % 2 == 0:
    maxab = ab[(N // 2) - 1][1]
    minab = ab[N // 2][0]
    x1 = (ab[(N // 2) - 1][0] + ab[N // 2][0])
    x2 = (ab[(N // 2) - 1][1] + ab[N // 2][1])
    print(x2 - x1 + 1)

else:
    print(ab[N // 2][1] - ab[N // 2][0] + 1)
from sys import stdin
from decimal import Decimal
N = int(stdin.readline().rstrip())
A = []
B = []
for i in range(N):
    a,b = [int(x) for x in stdin.readline().rstrip().split()]
    A.append(a)
    B.append(b)
    
A.sort()
B.sort()
if N % 2 == 0:
    ans = Decimal(sum(B))/Decimal(2) - Decimal(sum(A))/Decimal(2)
    ans /= Decimal(0.5)
    print(int(ans))
else:
    ans = B[N//2] - A[N//2] + 1
    print(ans)
from collections import defaultdict
from fractions import Fraction
N = int(input())
A = [0 for  _ in range(N)]
B = [0 for  _ in range(N)]
for i in range(N):
    A[i], B[i] = [int(i) for i in input().split()]
A.sort()
B.sort()

if N%2 == 1:
    target = ((N+1)//2)-1
    print(B[target]-A[target]+1)
else:
    target1 = ((N)//2)-1
    target2 = (N)//2
    print((B[target2]-A[target1]) * 2-1)
N = int(input())
AA = [0]*N
BB = [0]*N
for i in range(N):
  AA[i], BB[i] = map(int,input().split())
AA_sorted = sorted(AA)
BB_sorted = sorted(BB,reverse=True)
if N%2 == 1:
  idx = int(N/2)
  N_Max = BB_sorted[idx]
  N_Min = AA_sorted[idx]
  print(N_Max-N_Min+1)
else:
  idx = int(N/2)
  N_Max = BB_sorted[idx-1]
  N_Min = AA_sorted[idx-1]
  print((N_Max-N_Min)*2-1)
import statistics
N = int(input())
arr = [list(map(int, input().split())) for _ in range(N)]
arr.sort()
if N % 2 == 1:
    print(arr[N//2][1]-arr[N//2][0]+1)
else:
    print(arr[N//2][1]-arr[(N//2)-1][0]+1)
n = int(input())

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

if n % 2 == 1:
    print(rs[len(rs)//2] - ls[len(ls)//2] + 1)
else:
    a = (rs[len(rs)//2-1] * 10 + rs[len(rs)//2] * 10) / 2
    b = (ls[len(ls)//2-1] * 10 + ls[len(ls)//2] * 10) / 2
    print((a - b) // 5 + 1)
import sys, math
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 10**9 + 7

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

A.sort()
B.sort(reverse=True)

i = (N-1)//2

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

ab = [list(map(int, input().split())) for _ in range(n)]
ab = sorted(ab, key=lambda x:int(x[1]))

c = [ab[i][1]-ab[i][0] for i in range(n)]

if n%2 == 1:
    center = n//2
    answer = ab[center][1]-ab[center][0]
else:
    center = [n//2-1,n//2]
    answer1 = ab[center[0]][1] - ab[center[0]][0]+1
    answer2 = ab[center[1]][1] - ab[center[1]][0]+1
    answer = answer1*answer2 - max(0,ab[center[0]][1]-min(ab[center[0]][0],ab[center[1]][1]))

print(answer)
from itertools import product

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(len(set(a + b for a, b in product(range(A[N // 2 - 1], A[N // 2] + 1), range(B[N // 2 - 1], B[N // 2] + 1)))))
else:
    print(B[N // 2] - A[N // 2] + 1)
N = int(input())
A = [0] * (N + 1)
B = [0] * (N + 1)

count = 0

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

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

#print(centerA, centerB)  

if N % 2 == 1:
  count = centerB - centerA + 1
else:
  count = int(centerB * 2) - int(centerA * 2) + 1

print(int(count))
import numpy as np

N = int(input())

AB = []

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

index = [AB[i][0] for i in range(len(AB))]
index = np.argsort(index)
AB = list(np.array(AB)[index])

if len(AB)%2==0:
  A = AB[len(AB)//2-1]
  B = AB[len(AB)//2]
  middle = max(B) - min(A)
  print(middle+1)
else:
  C = AB[len(AB)//2]
  print(C[-1]-C[0])
n,*ab = map(int,open(0).read().split())
a = ab[::2]
b = ab[1::2]
a.sort()
b.sort(reverse=True)

if n%2 == 1:
    med_min = a[(n-1)//2]
    med_max = b[(n-1)//2]
    ans = med_max - med_min + 1
else:
    med_min = (a[n//2-1] + a[n//2] ) /2
    med_max = (b[n//2-1] + b[n//2] ) /2
    ans = (med_max - med_min)*2 + 1

print(ans)
n = int(input())
AB = [tuple(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 = [(AB[i][0], i) for i in range(n)]
# B = [(AB[i][1], i) for i in range(n)]

A.sort()
B.sort()

if n % 2 == 1:
    print(B[n % 2] - A[n % 2] + 1)

if n % 2 == 0:
    print(B[n % 2 + 1] - A[n % 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, B)
if N % 2 == 0:
    n1 = N // 2 - 1
    n2 = N // 2
    ans = B[n1] - A[n1] + B[n2] - A[n2] + 1
    print(ans)

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

# AB = [[int(x) for x in input().split()] for _ in range(N)]

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

else:
    ans += 1
print(ans)
N = int(input())
l = []
for _ in range(N):
    A, B = 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][0], tr[t][1]
    a3, a4 = tl[t-1][0], tr[t-1][1]
    print((a4-a3+1)*(a4-a3)//2)
N=int(input())

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

if N%2==0:
    center=N//2
    min_tmp=(min_x[center]+min_x[center-1])
    max_tmp=(max_x[center]+max_x[center-1])
    print(max_tmp-min_tmp+1)
else:
    center=N//2
    print(max_x[center]-min_x[center]+1)
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n = int(readline())
aa = []
bb = []
for _ in range(n):
    a, b = map(int, readline().split())
    aa.append(a)
    bb.append(b)
aa.sort()
bb.sort(reverse=True)
if n == 2:
    print(bb[0] - aa[0] + 1)
else:
    print(bb[1] - aa[1] + 1)
n = int(input())
info = [list(map(int, input().split())) for i in range(n)]

if n % 2 == 1:
    info = sorted(info)
    l = info[n // 2][0]
    info = sorted(info)[::-1]
    r = info[n // 2][1]
    print(r - l + 1)

else:
    info = sorted(info)
    l, lmax = info[n // 2 - 1]
    del info[n // 2 - 1]
    info = sorted(info)[::-1]
    rmin, r = info[n // 2 - 1]
    print((lmax - l + 1) + (r - rmin + 1) - 1)
import sys

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

n = N // 2 if N % 2 != 0 else N // 2 - 1
left = AB[n][0]

AB.sort(key=lambda x: x[1])
right = AB[n][1]

print(max(0, right - left + 1))
N = int(input())
AB = []
for i in range(N):
  AB.append(list(map(int, input().split())))

l = 0
r = 0

AB.sort()
if N % 2 == 0:
  l = AB[N//2][0] + AB[N//2 - 1][0]
else:
  l = AB[N//2][0]
AB.sort(key = lambda x: x[1])
if N % 2 == 0:
  r = AB[N//2][1] + AB[N//2 - 1][0]
else:
  r = AB[N//2][1]
  
if N % 2 == 0:
  print((r - l) * 2 + 1)
else:
  print(r - l + 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(2*medB-2*medA+1)
# Count median
N=int(input())
m=[]
M=[]
for i in range(N):
    x,y=map(int,input().split())
    m.append(x)
    M.append(y)
m.sort()
M.sort(reverse=True)
if N%2!=0:
    mini=m[N//2]
    maxi=M[-N//2]
    print(maxi-mini+1)
else:
    mini=m[N//2-1]
    maxi=M[-N//2]
    print((maxi-mini)*2+1)
n=int(input())
c=[list(map(int,input().split())) for _ in range(n)]
a=[i[0] for i in c]
b=[i[1] for i in c]
a.sort()
b.sort()
print(b[n//2]-a[n//2-1]-b[n//2-1]+a[n//2]+1)
N = int(input())
AB = [list(map(int, input().split())) for _ in range(N)]
A, B = zip(*AB)

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())
x =[]
y =[]
for i in range(n):
    a, b = map(int,input().split())
    x.append(a)
    y.append(b)
x =sorted(x)
y =sorted(y,reverse = True)

ans = 0
if n %2 == 0:
    m = n //2 -1
    ans = y[m]-x[m] +1
    print(ans)
    exit()
else:
    m = n//2
    ans = y[m] - x[m] + 1
    print(ans)
    exit()
n = int(input())
ab = [list(map(int, input().split())) for _ in range(n)]
ab.sort()
l = ab[(n+1)//2-1][0]
ab.sort(key=lambda x:x[1], reverse=True)
r = ab[(n+1)//2-1][1]

if n % 2 == 0:
    print((r-l)*2-1)
else:
    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()


mini=A[(N-1)//2]
maxi=B[(N-1)//2]
if N//2==0:
  print((maxi-mini)*2+1)
else:
  print(maxi-mini+1)
N = int(input())
ans = 0
ma = []
mi = []
for i in range(N):
    x1, x2 = map(int, input().split())
    mi.append(x1)
    ma.append(x2)

L = 0
R = 0

if N % 2 == 0:
    L = (mi[N//2-1]+mi[N//2]) / 2
    R = (ma[N//2-1]+ma[N//2]) / 2
    ans = int((R-L)/0.5)+1
else:
    L = mi[N//2]
    R = ma[N//2]
    ans = R - L + 1


print(ans)
N = int(input())
A = [0 for _ in range(N)]

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

A.sort()
if N%2 == 0:
    print((A[N//2-1]+A[N//2])//2+1)
else:
    print(A[N//2])
import sys
input = sys.stdin.readline
from bisect import bisect_left, bisect_right

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()

ng, ok = 0, 10 ** 9 + 10
while ok - ng > 1 :
  mid = (ok + ng) // 2
  if N - bisect_right(A, mid) >= N // 2 + 1 :
    ng = mid
  else :
    ok = mid

ret = -ok

ok, ng = 0, 10 ** 9 + 10
while ng - ok > 1 :
  mid = (ok + ng) // 2
  if bisect_left(B, mid) >= N // 2 + 1 :
    ng = mid
  else :
    ok = mid
    
ret += ok + 1

print(max(0, ret))
import sys
readline=sys.stdin.readline
 
N=int(readline())
A = [None] * N
B = [None] * N
for i in range(N):
  A[i],B[i] = map(int,readline().split())

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

if N % 2 == 1:
  minval = A[N // 2]
  maxval = B[N // 2]
  print(max(maxval - minval + 1,0))
else:
  minval = A[(N - 1) // 2]
  maxval = B[(N) // 2]
  ran = maxval - minval + 1
  print((ran * (ran - 1)) // 2)
N=int(input())
A=[]
B=[]
for _ in range(N):
  a,b=map(int,input().split())
  A.append(a)
  B.append(b)
if N%2==0:
  A.sort()
  B.sort()
  c=int(N/2)
  d=A[c-1]+B[c-1]
  e=A[c]+B[c]
  f=e-d
  print(f+1)
else:
  A.sort()
  B.sort()
  c=int(N/2)
  print(B[c]-A[c]+1)
def main():
    n = int(input())
    al = []
    bl = []
    for _ in range(n):
        a, b = map(int, input().split())
        al.append(a)
        bl.append(b)
    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)

if __name__ == "__main__":
    main()
import statistics

n=int(input())
a = [[int(i) for i in input().split()] for j in range(n)]
min=[i[0] for i in a]
max=[i[1] for i in a]
if n%2==0:
    print(int(statistics.median(max)-statistics.median(min))*2+1)
else:
    print(int(statistics.median(max)-statistics.median(min))+1)
n = int(input())
info = [list(map(int, input().split())) for i in range(n)]

if n % 2 == 1:
    info = sorted(info)
    l = info[n // 2][0]
    info = sorted(info)[::-1]
    r = info[n // 2][1]
    print(r - l + 1)

else:
    info = sorted(info)
    l, lmax = info[n // 2 - 1]
    info = sorted(info)[::-1]
    rmin, r = info[n // 2 - 1]
    length = []
    for i in range(n):
        length.append(min(r, info[i][1]) - max(l, info[i][0]) + 1)

    length = sorted(length, reverse=True)
    print(length[0] + length[1] - 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==0:
    p = n//2
    right = (a[p]+a[p-1])/2 -1
    left = (b[p]+b[p-1])/2
else:
    p = n//2
    right = a[p]
    left = b[p]
print(int(left-right)+1)
import statistics
import math
N = int(input())

n =[]
m =[]

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

nmean = statistics.median(n)
mmean =statistics.median(m)

if N%2 == 1:
    print(mmean - nmean + 1)
else:
    print(int(mmean - nmean)*2 +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)

ans = int(median(B)-median(A))
if N%2==0:
    ans = ans*2
print(ans+1)
n = int(input())
x = [list(map(int,input().split())) for i in range(n)]

if n%2==0:
    print(int((x[(n//2)][-1]-x[(n//2)-1][0])//0.5)-1)
else:
    tmp = x[n//2]
    print(len(range(tmp[0], tmp[-1]+1)))
N=int(input())
A=[]
B=[]
for i in range(N):
  a,b=map(int,input().split())
  A+=[a]
  B+=[b]
A.sort()
B.sort()
if N%2==1:
  ans=B[N//2]-A[N//2]+1
else:
  Am=A[N//2]+A[N//2-1]
  Bm=B[N//2]+B[N//2-1]
  if (Bm-Am)%2==0:
    ans=(Bm-Am)+1
  else:
    ans=(Bm-Am-1)*2
print(ans)
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 != 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)
n = int(input())
ab =[list(map(int,input().split())) for _ in range(n)]

a = []
b =[]
for x in ab:
  a.append(x[0])
  b.append(x[1])

a.sort()
b.sort()
ca,cb =0,0
if n % 2 == 0:
  ca = (a[n//2-1] + a[n//2])//2
  cb = (b[n//2-1] + b[n//2])//2
  ans = (cb-ca) / 0.5 +1
else:
  ca = a[(n+1)//2-1]
  cb = b[(n+1)//2-1]
  ans = (cb-ca) +1

print(int(ans))
import bisect

def Z(): return int(input())
def ZZ(): return [int(_) for _ in input().split()]

def main():
    N = Z()
    A, B = [], []
    for _ in range(N):
        a, b = ZZ()
        A.append(a)
        B.append(b)
    A.sort()
    B.sort()
    midA = A[N//2] if N%2 == 1 else (A[N//2-1] + A[N//2])//2
    midB = B[N//2] if N%2 == 1 else (B[N//2-1] + B[N//2] + 1)//2
    print(max(0, midB-midA+1))

    return

if __name__ == '__main__':
    main()
import heapq as hp
n = int(input())
if n%2 ==0:
    m = n//2 + 1
else:
    m = (n+1) //2
a,b = [],[]
for i in (0,n):
    c = list(map(int, input().split()))
    a.append(c[0])
    b.append(c[1])
la = hp.nlargest(m,a)
lb = hp.nlargest(m,b)
if n%2 == 0:
    c = la[-1] + la[-2] 
    d = lb[-1] + lb[-2] 
    print(d-c+1)
else:
    print(lb[-1]//2-la[-1]//2+1)
N = int(input())
A,B,X = [0]*N,[0]*N,[0]*N
for i in range(N):
    A[i],B[i] = map(int,input().split())
if N%2 == 1:
    ans = B[int((N-1)/2)] - A[int((N-1)/2)] + 1
elif N%2 == 0:
    ans = B[int(N/2)] + B[int(N/2)-1] - A[int(N/2)] - A[int(N/2)-1] + 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()

right = 0
left = 0

ans = 0

if n%2 == 0:
    right = b[n//2 + 1 -1]
    left = a[n//2 -1]
    ans = 2*(right-left)-1
else:
    right = b[(n+1)//2 -1 ]
    left = a[(n+1)//2 -1]
    ans = right -left +1

print(ans)
N = int(input())
import numpy as np
A = [0]*N
B = [0]*N
for i in range(N):
    A[i], B[i] = map(int,input().split())
na = np.median(A)
nb = np.median(B)
if N%2 == 1:
    ans = int(nb - na + 1)
    print(ans)
    exit()
else:
    ans = 2*int(nb - na) + 1
    print(ans)
    exit()
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n = int(readline())
aa = []
bb = []
for _ in range(n):
    a, b = map(int, readline().split())
    aa.append(a)
    bb.append(b)
aa.sort()
bb.sort()
print(bb[n // 2] - aa[n // 2] + 1 + n // 2)
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])//2
    b=(M[z]+M[z-1])//2
    print(2*(b-a)+1)
n = int(input())
a = []
b = []
for _ in range(n):
    atmp, btmp = map(int, input().split())
    a.append(atmp)
    b.append(btmp)
a.sort()
b.sort()
if n % 2 == 1:
    pos = n // 2
    print(b[pos] - a[pos] + 1)
else:
    pos = n // 2 - 1
    a1 = a[pos]
    a2 = a[pos + 1]
    b1 = b[pos]
    b2 = b[pos + 1]
    medmin = b1 + a1
    medmax = b2 + a2
    print(medmax - medmin + 1)
n = int(input())
x = [list(map(int,input().split())) for i in range(n)]

if n%2==0:
    min_sum = x[(n//2)-1][0]+x[(n//2)][0]/2
    max_sum = x[(n//2)-1][1]+x[(n//2)][1]/2
    print(int((max_sum-min_sum)*2))
else:
    tmp = x[n//2]
    print(tmp[1]-tmp[0]+1)
def main():
    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 == 0:
        m1 = (A[n//2-1]+A[n//2])//2
        m2 = (B[n//2-1]+B[n//2])//2
        print(2*(m2-m1)+1)
    else:
        print(B[(n+1)//2-1]-A[(n+1)//2-1]+1)    
main()
N = int(input())
AB = [list(map(int, input().split())) for _ in range(N)]

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

if N % 2 == 1:
    print(b[N // 2] - a[N // 2] + 1)
elif N % 2 == 0:
    print((b[(N + 1) // 2] + b[N // 2]) - (a[(N + 1) // 2] + a[N // 2]) + 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==0:
        print(B[n//2]-A[n//2-1]+1)
    else:
        print(B[n-(n+1)//2]-A[(n+1)//2-1]+1)
if __name__ == "__main__":
    main()
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==0:
    p = n//2
    right = (a[p]+a[p-1])/2 -1
    left = (b[p]+b[p-1])/2
    r = left-right
    if int(r)==r:
        print(int(r)*2)
    else:
        print(int(r)*2 +1)
else:
    p = n//2
    right = a[p]
    left = b[p]
    print(int(left-right)+1)
n = int(input())
ab = [tuple(map(int, input().split())) for _ in range(n)]
ab.sort()
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]
ans = b1 - a1 + 1 if b1 >= a1 else 0
if n % 2 == 0:
    ans += int((b1+b2)/2 - (a1+a2)/2)
    if (b1+b2)%2 or (a1+a2)%2: ans += 1

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

count = 0

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

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

#print(centerA, centerB)  

if N % 2 == 1:
  count = centerB - centerA + 1
else:
  count = (centerB - centerA) * 2 + 1

print(int(count))
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==1:
    print(B[(N-1)//2] - A[(N-1)//2]+1)
else:
    b1 = B[(N-2)//2]
    b2 = B[N//2]
    a1 = A[(N-2)//2]
    a2 = A[N//2]
    print(a2 + b2 - (a1 + b1) + 1)
N = int(input())
AB = []
for _ in range(N):
    AB.append(list(map(int, input().split())))
if N % 2 == 1:
    idx = N // 2
    ans = AB[idx][1] - AB[idx][0] + 1
else:
    idx1 = (N-1) // 2
    idx2 = (N-1) //2 + 1
    lower_bound = AB[idx1][0] + AB[idx2][0]
    upper_bbound = AB[idx1][1] + AB[idx2][1]
    diff = upper_bbound - lower_bound + 1
    ans = diff
print(ans)
import sys
input = lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(20000000)
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:
    tmp = [a[n//2-1], a[n//2], b[n//2-1], b[n//2]]
    tmp.sort()
    print((tmp[1] + tmp[3]) - (tmp[0] + tmp[2]) + 1)
else:
    mid_l = a[n//2]
    mid_r = b[n//2]
    print(mid_r - mid_l + 1)
N = int(input())

A = []
B = []
for _ in range(N):
    a, b = [int(_) for _ in 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:
    sa, ea = A[N//2 - 1], A[N//2]
    sb, eb = B[N//2 - 1], B[N//2]
    print(eb+ea - (sa+sb) + 1)
from itertools import product

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()

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

if N%2==0:
    sca=scb=N//2-1
    lca=lcb=N//2
    x=A[lca]+A[sca]
    y=B[lcb]+B[lcb]
    print(x-y+1)
    
    
else:
    ca=cb=N//2
    ans=B[cb]-A[ca]+1
    print(ans)
N = int(input())
AB = [list(map(int, input().split())) for n in range(N)]

if N % 2 == 0:
  k1 = int(N/2-1)
  k2 = int(N/2)
  pattern = set()
  for i in range(AB[k1][0], AB[k1][1]+1):
    for j in range(AB[k2][0], AB[k2][1]+1):
      pattern.add(i+j)
  
  print(len(pattern))
else:
  k = int((N+1)/2)-1
  A = AB[k][0]
  B = AB[k][1]
  print(B-A+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!=0:
    ans=b[(n-1)//2]-a[(n-1)//2]+1
else:
    ans=(b[(n)//2-1]-a[(n)//2-1])*2+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())

def f(n):
  AB = list(zip(A, B))
  AB.sort()
  return AB[n]

if N%2==0:
  a1, b1 = f(N//2-1)
  a2, b2 = f(N//2)
  print((b1+b2)-(a1+a2)+1)
else:
  a, b = f(N//2)
  print(b-a+1)
import heapq as hp
n = int(input())
if n%2 ==0:
    m = n//2 + 1
else:
    m = (n+1) //2
a,b = [],[]
for i in (0,n):
    c = list(map(int, input().split()))
    a.append(c[0])
    b.append(c[1])
print(a,b)
la = hp.nlargest(m,a)
lb = hp.nlargest(m,b)
if n%2 == 0:
    c = la[-1] + la[-2] 
    d = lb[-1] + lb[-2] 
    print(d-c+1)
else:
    print(lb[-1]//2-la[-1]//2+1)
n = int(input())
min_s = []
max_s = []
for i in range(n):
    a, b = map(int, input().split())
    min_s.append(a)
    max_s.append(b)

min_s.sort()
max_s.sort()
if n % 2 == 0:
    min_med = (min_s[n//2-1] + min_s[n//2])/2
    max_med = (max_s[n//2-1] + max_s[n//2])/2
    print(int(max_med-min_med)*2+1)

else:
    min_med = min_s[(n+1)//2-1]
    max_med = max_s[(n+1)//2-1]
    print(int((max_med-min_med)+1))
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:
    a_m = a[n // 2]
    b_m = b[n // 2]
    print(b_m - a_m + 1)
else:
    a_m = (a[n // 2 - 1] + a[n // 2]) / 2
    b_m = (b[n // 2 - 1] + b[n // 2]) / 2
    print(int(b_m - a_m) * 2 + 1)