peterverebics/CodeNet_Python_118 huggingface dataset:
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)

min_x.sort()
max_x.sort()

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)
def median(q):
  l = len(q)
  q = sorted(q, reverse=True)
  if l%2 == 0:
    return (q[int(l/2)] + q[int(l/2)-1])/2
  else:
    return q[int((l+1)/2-1)]
n = int(input())

a = []
b = []
for i in range(n):
  x, y = map(int, input().split())
  a.append(x)
  b.append(y)
med_a = median(a)
med_b = median(b)

if n%2 == 0:
  print(int(2*(med_b - med_a) + 1))
else:
  print((med_b - med_a) + 1)
n = int(input())
a = []
b = []
for i in range(n):
	a_1, b_1 = input().split()
	a.append(int(a_1))
	b.append(int(b_1))
a.sort()
b.sort()
is_odds = n % 2 == 0
a_med = a[(n + 1) // 2 - 1] if not is_odds else a[n // 2 - 1] + a[n // 2]
b_med = b[(n + 1) // 2 - 1] if not is_odds else b[n // 2 - 1] + b[n // 2]
print(b_med - a_med + 1)
import sys
input = sys.stdin.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==1:
 print(B[int((N-1)/2)]-A[int((N-1)/2)]+1)
else:
 print(B[int(N/2)]+B[int(N/2)-1]-A[int(N/2)]-A[int(N/2)-1]+1)
n = int(input())

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

mins = sorted(mins)
maxs = sorted(maxs)

if n % 2 != 0:
    print(maxs[((n+1)//2) - 1] - mins[((n+1)//2) - 1] + 1)
else:
    print(int(2 * ((maxs[((n+1)//2) - 1] + maxs[n//2])/2 - (mins[((n+1)//2) - 1] + mins[n//2])/2) + 1))
# E - Count Median

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:
    A_median = A[(N+1)//2-1]
    B_median = B[(N+1)//2-1]
    print(B_median - A_median + 1)
else:
    A_median = (A[N//2-1] + A[N//2])
    B_median = (B[N//2-1] + B[N//2])
    print(B_median - A_median + 1)
N = int(input())
array1 = []
array2 = []
for i in range(N):
    a,b = map(int,input().split())
    array1.append(a)
    array2.append(b)

array1.sort()
array2.sort()

if N % 2 == 0:
    min = array1[N//2]+array1[N//2-1]
    max = array2[N//2]+array2[N//2-1]
    print(max-min+1)
else:
    min = array1[N//2]
    max = array2[N//2]
    print(max-min+1)
from statistics import median

la = []
lb = []
for _ in range(int(input())):
    a, b = map(int, input().split())
    la.append(a)
    lb.append(b)

ma = median(la)
mb = median(lb)
if len(la) % 2:
    print(int((mb - ma) + 1))
else:
    print(int(2 * (mb - ma) + 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()

i = N//2
if N%2 == 0:
    print(B[i]+B[i-1]-A[i]-A[i-1]+1)
else:
    print(B[i]-A[i]+1)
#!/usr/bin/env python3
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()
N = int(input())
A = [0]*N
B = [0]*N
for i in range(N):
    a, b = map(int, input().split())
    A[i], B[i] = a, b
mx, mn = 0, 0
B.sort()
A.sort()
if N%2 == 0:
    mx = (B[N//2-1]+B[N//2+1-1])/2
    mn = (A[N//2-1]+A[N//2+1-1])/2
else:
    mx = B[(N+1)//2-1]
    mn = A[(N+1)//2-1]
#print(B, A)
#print(mx, mn)
if N%2 == 0:
    print(int(2*(mx-mn)+1))
else:
    print(mx-mn+1)
n = int(input())
min_val, max_val = zip(*[map(int, input().split()) for _ in range(n)])
min_val = sorted(min_val)
max_val = sorted(max_val)

if n % 2:
    mid = n//2
    min_median = min_val[mid]
    max_median = max_val[mid]
    print(max_median-min_median+1)
else:
    midl = (n-1)//2
    midr = midl+1
    min_median = min_val[midl]+min_val[midr]
    max_median = max_val[midl]+max_val[midr]
    print(max_median-min_median+1)
import sys
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N = int(readline())
AB = np.array(read().split(), np.int64)

A = AB[::2]
B = AB[1::2]

A.sort()
B.sort()

if N % 2 == 0:
    n = N // 2
    med1 = A[n - 1] + A[n]
    med2 = B[n - 1] + B[n]
    x = med2 - med1 + 1
else:
    n = N // 2
    med1 = A[n]
    med2 = B[n]
    x = med2 - med1 + 1

print(x)
n=int(input())
l=[list(map(int,input().split())) for i in range(n)]
work1=sorted([x[0] for x in l])
work2=sorted([x[1] for x in l])
if n%2==1 : 
    mmin=work1[n//2]
    mmax=work2[n//2]
else:
    mmin=work1[n//2]+work1[n//2-1]
    mmax=work2[n//2]+work2[n//2-1]
print(mmax-mmin+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 == 0:
    print((B[N//2-1]+B[N//2])-(A[N//2-1]+A[N//2])+1)

else:
    print(B[N//2]-A[N//2]+1)
N = int(input())
X = [list(map(int,input().split())) for _ in range(N)]

Y = sorted(X, key=lambda x:x[0])
Z = sorted(X, key=lambda x:x[1])

ans = 0
if N % 2:
    ans = Z[N//2][1]-Y[N//2][0]+1

else:
    ans = Z[N//2][1]-Y[N//2][0]+1
    ans += Z[N//2-1][1]-Y[N//2-1][0]

print(ans)
n = int(input())
ab = [[int(i) for i in input().split()] for j in range(n)]

if n % 2 == 1:
    ab.sort(reverse=True,key=lambda x: x[1])
    max_ab = ab[n//2][1]
    ab.sort(reverse=True,key=lambda x: x[0])
    print(max_ab-ab[n//2][0]+1)
else:
    ab.sort(reverse=True,key=lambda x: x[1])
    ab1 = ab[n//2][1]
    ab2 = ab[n//2-1][1]
    ab.sort(key=lambda x: x[0])
    ab3 = ab[n//2][0]
    ab4 = ab[n//2-1][0]
    
    print(ab1+ab2-(ab3+ab4)+1)
n = int(input())
ab=[list(map(int,input().split())) for i in range(n)]

all_min=[]
all_max=[]
for itm in ab:
    a,b=itm
    all_min.append(a)
    all_max.append(b)

import statistics
med_min=statistics.median(all_min)
med_max=statistics.median(all_max)

diff = med_max - med_min

if n%2==0:
    print(int(diff*2+1))
else:
    print(diff+1)
n = int(input())
ab = [list(map(int, 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 n % 2 == 1:
    m = a[n // 2]
    M = b[n // 2]
    print(M - m + 1)
else:
    m = (a[n // 2 - 1] + a[n // 2]) / 2
    M = (b[n // 2 - 1] + b[n // 2]) / 2
    print(int((M - m) * 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 & 1:
  min_medium = a_list[n // 2]
  max_medium = b_list[n // 2]
  print(max_medium - min_medium + 1)
else:
  min_medium_x2 = a_list[n // 2 - 1] + a_list[n // 2]
  max_medium_x2 = b_list[n // 2 - 1] + b_list[n // 2]
  print(max_medium_x2 - min_medium_x2 + 1)
n,*ab=map(int,open(0).read().split())
a=ab[::2]
b=ab[1::2]
m=n//2
a.sort()
b.sort()
ans=0
if n&1==1:
  ans=b[m]-a[m]+1
else:
  ans=int(2*((b[m]+b[m-1])/2-(a[m]+a[m-1])/2))
  ans+=1
print(ans)
n = int(input())
A=[]
B=[]
for i in range(n):
    a,b=map(int,input().split())
    A.append(a)
    B.append(b)
A.sort()
B.sort()
if n%2==0:
    A_med=(A[int(n/2)-1]+A[int(n/2)])/2
    B_med=(B[int(n/2)-1]+B[int(n/2)])/2
    print(int((B_med-A_med)*2+1))
else:
    A_med=A[int((n+1)/2)-1]
    B_med=B[int((n+1)/2)-1]
    print(int(B_med-A_med+1))
n = int(input())

rs = []
aes = []
bs = []

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


aes.sort()
bs.sort(reverse=True)

if n % 2 == 1:
  p = aes[(n - 1) // 2]
  q = bs[(n - 1) // 2]
  ans = q - p + 1
else:
  p1 = aes[n // 2 - 1]
  p2 = bs[n // 2]
  q1 = aes[n // 2]
  q2 = bs[n // 2 - 1]
  ans = (p2 - p1 + 1) + (q2- q1 + 1) - 1
 
# print(p1, p2, q1, q2)
print(ans)
import sys
def input():
	return sys.stdin.readline()[:-1]
n = int(input())
seg = [list(map(int, input().split())) for _ in range(n)]
a = [x[0] for x in seg]
b = [x[1] for x in seg]
a.sort()
b.sort()

if n%2 == 1:
	print(b[n//2] - a[n//2] + 1)
else:
	print(b[n//2] - a[n//2] + b[n//2-1] - a[n//2-1] + 1)
from operator import itemgetter
n=int(input())
l=[list(map(int,input().split())) for i in range(n)]
l.sort()
if n%2==1:
  x=l[n//2][0]
  l=sorted(l,key=itemgetter(1))
  y=l[n//2][1]
  print(y-x+1)
else:
  x=(l[n//2][0]+l[(n//2)-1][0])/2
  l=sorted(l,key=itemgetter(1))
  y=(l[n//2][1]+l[(n//2)-1][1])/2
  print(int((y-x)*2)+1)
import sys
input = sys.stdin.readline
n = int(input())
a = []
b = []
for i in range(n):
    ai, bi = map(int, input().split())
    a.append(ai)
    b.append(bi)
a.sort()
b.sort()
if n % 2 == 1:
    am = a[n // 2]
    bm = b[n // 2]
    ans = abs(bm - am) + 1
else:
    am1 = a[n // 2 - 1]
    am2 = a[n//2]
    bm1 = b[n // 2 - 1]
    bm2 = b[n // 2]
    ans = bm1 + bm2 - (am1 + am2) + 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 % 2 == 1:
    print(abs(A[N//2]-B[N//2])+1)
else:
    a_median = (A[N//2] + A[(N//2)-1])/2
    b_median = (B[N//2] + B[(N//2)-1])/2
    print(int(abs(a_median-b_median)*2+1))
n = int(input())
ab = [map(int, input().split()) for _ in range(n)]
a, b = [list(i) for i in zip(*ab)]
c = sorted(a)
d = sorted(b)

ans = 0
if n % 2 == 1:
    ans = d[(n-1)//2] - c[(n-1)//2] + 1
else:
    ans = d[n//2] + d[n//2 - 1] - c[n//2] - c[n//2 - 1] + 1

print(ans)
import sys
import math
def input():
    return sys.stdin.readline()[:-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:
    ans = b[n//2]-a[n//2]+1
    print(ans)
if n%2==0:
    ans = b[n//2]+b[n//2-1]-a[n//2]-a[n//2-1]+1
    print(ans)
n = int(input())
list_AB = [ list(map(int,input().split(" "))) for _ in range(n)]
mins = []
maxs = []
for a, b in list_AB:
    mins.append(a)
    maxs.append(b)

mins.sort()
maxs.sort()

if n % 2 == 1:
    ans = maxs[n//2] - mins[n//2] + 1
else:
    small = mins[n//2] + mins[n//2-1]
    large = maxs[n//2] + maxs[n//2-1]
    ans = large - small +1

print(ans)
def median(A,N):
    A.sort()
    if N % 2 == 1:
        return A[N//2]
    else:
        return A[(N-1)//2] + A[(N-1)//2+1]

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

    A = [AB[i][0] for i in range(N)]
    B = [AB[i][1] for i in range(N)]

    ans = median(B,N) - median(A,N) + 1
    print(ans)

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

readline = sys.stdin.readline
readall = sys.stdin.read
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
prn = lambda x: print(*x, sep='\n')

n = ni()
a = list(map(int, readall().split()))
l = a[::2]
h = a[1::2]
l.sort()
h.sort()
ml = l[n//2] if n&1 else (l[n//2] + l[n//2-1])
mh = h[n//2] if n&1 else (h[n//2] + h[n//2-1])
print(mh - ml + 1)
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

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

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

if n%2==1:
  mn = smn[(n+1)//2-1]
  mx = smx[(n+1)//2-1]
  print(round((mx-mn)+1))
else:
  mn = (smn[n//2-1]+smn[n//2])/2.0
  mx = (smx[n//2-1]+smx[n//2])/2.0
  print(round((mx-mn)*2+1))
import statistics
N = int(input())
 
a = []
b = []
 
for i in range(N):
    m, n = map(int, input().split())
    a.append(m)
    b.append(n)
 
if N % 2 == 1:
    print(int(statistics.median(b)-statistics.median(a)+1))
else:
    print(int(statistics.median(b)*2-statistics.median(a)*2+1))
n = int(input())
A = []
B = []
for _ in range(n):
    a, b = tuple(map(int, input().split()))
    A.append(a)
    B.append(b)

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

if n%2==1:
    sa = A[n//2]
    lb = B[n//2]
    print(lb - sa + 1)
else:
    sal = A[n//2-1]
    sar = A[n//2]

    lbl = B[n//2-1]
    lbr = B[n//2]
    print((lbl + lbr) - (sal + sar) +1)
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)*2-statistics.median(min)*2)+1)
else:
    print(int(statistics.median(max)-statistics.median(min))+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:
    M = B[N // 2]
    m = A[N // 2]
    print(M - m + 1)

else:
    M = (B[N // 2 - 1] + B[N // 2]) / 2
    m = (A[N // 2 - 1] + A[N // 2]) / 2
    print(int((M - m + 0.5) * 2))
N = int(input())
A = [None] * N
B = [None] * 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:
    b = (B[N // 2] + B[(N - 1) // 2]) / 2
    a = (A[N // 2] + A[(N - 1) // 2]) / 2
    print(int((b - a) * 2 + 1))
else:
    print(B[N // 2] - A[N // 2] + 1)
import sys

sys.setrecursionlimit(500005)
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

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

if n % 2 == 1:
    a.sort()
    b.sort()
    print(b[n//2]-a[n//2]+1)
else:
    a.sort()
    b.sort()
    print((b[n//2]+b[n//2-1])-(a[n//2]+a[n//2-1])+1)
n=int(input())
ar=[list(map(int,input().split())) for i in range(n)]
low=[ar[i][0] for i in range(n)]
high=[ar[i][1] for i in range(n)]
low.sort()
high.sort()
if n%2==1:
    print(high[n//2]-low[n//2]+1)
else:
    l=(low[n//2]+low[n//2-1])/2
    h=(high[n//2]+high[n//2-1])/2
    print(int((h-l)*2)+1)
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-1][0], tr[t][1]
    a3, a4 = tl[t][0], tr[t-1][1]
    print(a4-a3+a2-a1+1)
n = int(input())
a = [0]*n
b = [0]*n

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

a.sort()
b.sort()

if n%2 == 1:
    print(b[n//2] - a[n//2] + 1)
else:
    print(b[n//2] + b[(n//2)-1] - a[n//2] - a[(n//2)-1] + 1)
import 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:
    ans = 0
    i = n//2-1
    j = n//2
    tmp = [[a[i], b[i]], [a[j], b[j]]]
    ans = (b[i] + b[j]) - (a[i] + a[j]) + 1
    print(ans)
else:
    mid_l = a[n//2]
    mid_r = b[n//2]
    print(mid_r - mid_l + 1)
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)
from statistics import median
 
X = []
X1 = []
N=int(input())
for i in range(N):
    a, b = map(int, input().split())
    X.append(a)
    X1.append(b)
 
m1 = median(X)
m2 = median(X1)
if len(X) % 2:
    print(int((m2 - m1) + 1))
else:
    print(int(2 * (m2 - m1) + 1))
N=int(input())

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

A.sort()
B.sort()
    
if N%2==1:
    mA=A[(N-1)//2]
    mB=B[(N-1)//2]
    print(mB-mA+1)
else:
    nA=A[N//2]+A[N//2-1]
    nB=B[N//2]+B[N//2-1]
    print(nB-nA+1)
n = int(input())

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

    minimum.append(a)
    maximum.append(b)

# 奇数の場合は？

minimum.sort()
maximum.sort()

if n % 2 == 1:
    print(maximum[(n+1)//2 - 1]- minimum[(n+1)//2 - 1] + 1)
else:
    upper = maximum[n//2-1] + maximum[n//2]
    lower = minimum[n//2-1] + minimum[n//2]
    print(upper - lower + 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)

m = median(A)
M = median(B)

if N % 2 == 0:
    m *= 2
    M *= 2

print(int(M-m+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==0:
    mid_min=(A[N//2-1]+A[N//2])
    mid_max=(B[N//2-1]+B[N//2])
else:
    mid_min=A[N//2]
    mid_max=B[N//2]

print(mid_max-mid_min+1)
n = int(input())
x = [list(map(int, input().split())) for _ in range(n)]
y = sorted(x)
z = sorted(x, key=lambda x: x[1])

if n % 2 == 1:
    print(z[n//2][1] - y[n//2][0] + 1)
else:
    a = y[n//2-1][0]
    b = y[n//2][0]
    c = z[n//2-1][1]
    d = z[n//2][1]
    e = (c + d) / 2
    f = (a + b) / 2
    print(int((e - f) * 2) + 1)
import statistics  # Pythonのみ
# import string
import sys
sys.setrecursionlimit(10 ** 5 + 10)


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


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

    M = statistics.median(B)
    m = statistics.median(A)

    if N % 2 == 0:
        print(int((M-m)//0.5+1))
    else:
        print(M-m+1)


resolve()
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()
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 = sorted(A)
B = sorted(B)
if N %2 ==1:
    M = (N+1)//2
    left = A[M-1]
    right = B[-M]
    ans = right - left +1
else:
    M1 = N//2
    M2 = M1+1
    left1 = A[M1-1]
    right1 =B[-M1]
    left2 = A[M2-1]
    right2  =B[-M2]
    ans = right2 + right1 -left1-left2+1
print(ans)
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)
import statistics

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

ma = statistics.median(a)
mb = statistics.median(b)

if n % 2 == 1:
    ans = mb - ma + 1
else:
    ma = int(ma * 2)
    mb = int(mb * 2)
    ans = mb - ma + 1

print(ans)
n = int(input())
a = []
b = []
for i in range(n):
	a_1, b_1 = input().split()
	a.append(int(a_1))
	b.append(int(b_1))
a.sort()
b.sort()
is_odds = n % 2 == 0
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 - 1] - a[(n + 1) // 2 - 1] + 1)
n = int(input())
p = []
q = []
for i in range(n):
    a,b = map(int,input().split())
    p.append(a)
    q.append(b)

sop = sorted(p)
soq = sorted(q)
ans = 0
if n % 2 == 1:
    ans = soq[(n+1)//2-1] - sop[(n+1)//2-1] + 1
elif n % 2 == 0:
    s = soq[n//2-1]+soq[n//2]
    t = sop[n//2-1]+sop[n//2]
    ans = (s*0.5-t*0.5+1)*2 - 1
print(int(ans))
N = int(input())
AB = [list(map(int, input().split())) for _ in range(N)]

X_l = sorted([Ai for Ai, Bi in AB])
X_r = sorted([Bi for Ai, Bi in AB])

if N % 2 == 0:
    ans_min = X_l[N // 2 - 1] + X_l[N // 2]
    ans_max = X_r[N // 2 - 1] + X_r[N // 2]
else:
    ans_min = X_l[N // 2]
    ans_max = X_r[N // 2]

ans = ans_max - ans_min + 1
print(ans)
# https://codeforces.com/blog/entry/78195: Geothermal editorial

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:
    medA, medB = A[n//2], B[n//2]
    
else:
    medA = A[n//2] + A[n//2 - 1]
    medB = B[n//2] + B[n//2 - 1]

print(medB - medA + 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)

mi = sorted(mi)
ma = sorted(ma)

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)
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))
from statistics import median

n=int(input())
l1=[]
l2=[]
for i in range(n):
  a,b=nii()
  l1.append(a)
  l2.append(b)

m1=median(l1)
m2=median(l2)
ans=m2-m1

if n%2==0:
  ans*=2

print(int(ans+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 == 1:
    mid = (n+1)//2-1
    res = b_list[mid] - a_list[mid] + 1
else:
    mid_f = n//2-1
    mid_s = n//2
    max_sum = b_list[mid_s] + b_list[mid_f]
    min_sum = a_list[mid_s] + a_list[mid_f]
    res = max_sum - min_sum + 1

print(res)
import sys
input = sys.stdin.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:
    m = A[N//2]; M = B[N//2]
    print(M-m+1)
else:
    m1 = A[N//2-1]; m2 = A[N//2]
    M1 = B[N//2-1]; M2 = B[N//2]
    ans = M1 + M2 - (m1+m2) + 1
    print(ans)
n = int(input())
ab = [list(map(int, input().split())) for i in range(n)]
left = sorted([i for i,j in ab])
right = sorted([j for i,j in ab])
if n%2 == 0:
    x = left[n//2] + left[n//2-1]
    y = right[n//2] + right[n//2-1]
    ans = y-x+1
else:
    x = left[n//2]
    y = right[n//2]
    ans = y-x+1
print(ans)
import statistics

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

a = [0]*N
b = [0]*N

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

if N % 2 == 1:
    print(int(f(b)-f(a)+1))
else:
    print(int(f(b)*2-f(a)*2+1))
import statistics
n=int(input())
a=list()
b=list()
for i in range(n):
    x,y=map(int,input().split())
    a.append(x)
    b.append(y)

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

N = int(input())
A_B = [[int(i) for i in input().split(' ')] for n in range(N)]

t = list(zip(*A_B))

A_sta = statistics.median(t[0])
B_sta = statistics.median(t[1])

if N % 2 == 0:
    count = int(2 * (B_sta - A_sta) + 1)
else:
    count = B_sta - A_sta + 1

print(count)
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:
    r = (B[N//2-1]+B[N//2])
    l = (A[N//2-1]+A[N//2])
    print(r-l+1)
#
import sys
import math
import numpy as np
import itertools

n = int(input())

# n行の複数列ある数値をそれぞれの配列へ
a, b = [0]*n, [0]*n
for i in range(n): a[i], b[i] = map(int, input().split())

#print(a,b)

a.sort()
b.sort()

if n % 2 == 0:
    t = a[n//2-1] + a[n//2]
    s = b[n//2-1] + b[n//2]
    print(s-t+1)
else:
    t = a[n//2]
    s = b[n//2]
    print(s-t+1)
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:
    mid = n // 2
    median_min = lower[mid]
    median_max = upper[mid]
else:
    mid = n // 2 - 1
    median_min = lower[mid] + lower[mid + 1]
    median_max = upper[mid] + upper[mid + 1]
print(median_max - median_min + 1)
n = int(input())
a = []
b = []
for _ in range(n):
    ae, be = map(int,input().split())
    a.append(ae)
    b.append(be)
a.sort()
b.sort()

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