peterverebics/CodeNet_Python_118 huggingface dataset:
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:
    x = A[N//2-1]+A[N//2]
    y = B[N//2-1]+B[N//2]
    print(y-x+1)
n = int(input())
#a = [list(map(int, input().split())) for _ in range(n)]
start = []
end = []
for i in range(n):
    a,b = map(int, input().split())
    start.append(a)
    end.append(b)
start.sort()
end.sort()
if (n%2==1):
    print(end[n//2]-start[n//2]+1)
else:
    s = start[n//2-1]+start[n//2]
    e = end[n//2-1]+end[n//2]
    print(e-s+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:
  med_minimum = A[(N-1)//2]
  med_maximum = B[(N-1)//2]
else:
  med_minimum = (A[(N-2)//2] + A[(N-2)//2+1])
  med_maximum = (B[(N-2)//2] + B[(N-2)//2+1])
print(med_maximum - med_minimum + 1)
n = int(input())

mins = []
maxs = []

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

if n % 2 == 1:
  mid = n // 2
  print(maxs[mid] - mins[mid] + 1)
else:
  mid1 = n//2
  mid2 = mid1 - 1
  smallest = mins[mid1] + mins[mid2]
  largest = maxs[mid1] + maxs[mid2]
  print(largest - smallest + 1)
from statistics import median

n = int(input())
a_list = [0] * n
b_list = [0] * n

for i in range(n):
     a, b = map(int, input().split())
     a_list[i] = a
     b_list[i] = b
    
min_median = median(a_list)
max_median = median(b_list)

median_range = max_median - min_median

if n%2 == 0:
    print(int(median_range/0.5 + 1))
else:
    print(int(median_range/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==0:
        print(int(((B[n//2-1]+B[n//2])/2-(A[n//2-1]+A[n//2])/2)*2)+1)
    else:
        print(B[(n+1)//2-1]-A[(n+1)//2-1]+1)
if __name__ == "__main__":
    main()
n=int(input())

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

a.sort()
b.sort()

youso = int(n/2)

if n % 2 != 0:
    print(b[youso]-a[youso]+1)
else:
    print((b[youso]+b[youso-1])-(a[youso]+a[youso-1])+1)
n = int(input())
lows, highs = [], []
for i in range(n):
    a, b = map(int, input().split())
    lows.append(a)
    highs.append(b)
lows.sort()
highs.sort()

if n % 2 == 0:
    low = lows[n // 2 - 1] + lows[n // 2]
    high = highs[n // 2 - 1] + highs[n // 2]
    print(high - low + 1)
else:
    low = lows[(n - 1) // 2]
    high = highs[(n - 1) // 2]
    print(high - low + 1)
from numpy import*
(n,),*d=[[*map(int,i.split())]for i in open(0)]
a,b=median(d,axis=0)
c=[2,1][n%2]
print(int(b*c-a*c+1))
import math
n = int(input())
a = []
b = []
for i in range(n):
    x, y = map(int, input().split())
    a.append(x)
    b.append(y)
a = sorted(a)
b = sorted(b)
res = 0
if n % 2 == 1:
    m = n // 2
    m1 = a[m]
    m2 = b[m]
    res = m2 - m1 + 1
else:
    ml = n // 2 - 1
    m1 = a[ml] + a[ml + 1]
    m2 = b[ml] + b[ml + 1]
    res = m2 - m1 + 1

print(res)
import sys
input = sys.stdin.readline
import statistics

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

A = [C[i][0] for i in range(n)]
B = [C[i][1] for i in range(n)]

ans = 0
if n%2==1:
    ans = statistics.median(B)-statistics.median(A)+1
    print(ans)
else:
    a = statistics.median(A)
    b = statistics.median(B)
    eps = 10**-3
    print(int(b*2+eps)-int(a*2+eps)+1)
n = int(input())
A, B = map(list,zip(*[map(int,input().split()) for i in range(n)]))
A.sort()
B.sort()
if n&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 statistics as st
import math
N = int(input())
A = [0]*N
B = [0]*N
for i in range(N):
  A[i] , B[i] = map(int,input().split())
mA = st.median(A)
mB = st.median(B)
if N % 2 == 0:
  ans = (mB - mA)*2 + 1
else:
  ans = mB - mA + 1
print(int(ans))
import statistics
N=int(input())
A=[]
B=[]
for i in range(N):
    a,b=map(int, input().split())
    A.append(a)
    B.append(b)
ma=statistics.median(A)
mb=statistics.median(B)
if N%2==0:
    print(int((mb-ma)*2+1))
else:
    print(int((mb-ma)+1))
def main():
    n = int(input())
    a, b = [None]*n, [None]*n
    for i in range(n):
        a[i], b[i] = map(int, input().split())
    a.sort()
    b.sort()
    if n%2:
        print(b[n//2]-a[n//2]+1)
    else:
        bm = b[n//2]+b[n//2-1]
        am = a[n//2]+a[n//2-1]
        print(bm-am+1)
        

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

n = int(input())
ab = [list(map(int, input().split())) for _ in range(n)]
a = [i for i, j in ab]
b = [j for i, j in ab]

if n % 2 == 1:
    print(abs(median(b) - median(a)) + 1)
else:
    print(int(abs(median(b) - median(a)) * 2) + 1)
def main():
    n = int(input())
    ab = [list(map(int, input().split())) for _ in [0]*n]
    if n % 2 == 1:
        min_a = sorted([a for a, b in ab])[n//2]
        max_a = sorted([b for a, b in ab])[n//2]
        print(max_a-min_a+1)
    else:
        min_a = sum(sorted([a for a, b in ab])[n//2-1:n//2+1])*2
        max_a = sum(sorted([b for a, b in ab])[n//2-1:n//2+1])*2
        print((max_a-min_a+2)//2)


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

A.sort()
B.sort()
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))
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)
x = median(A)
y = median(B)

if n % 2 == 0:
    print(int((y - x) * 2 + 1))
else:
    print(y - x + 1)
n = int(input())

a = []
b = []
for i in range(n):
  ab = input().split()
  a.append(int(ab[0]))
  b.append(int(ab[1]))
import statistics
a = statistics.median(a)
b = statistics.median(b)
if n % 2 != 0:
  print(int(b-a+1))
else:
  print(int(2*(b-a)+1))
def E():
    N = int(input())
    pairs = []
    lefts = []
    rights = []
    for _ in range(N):
        pairs.append(list(map(int, input().split())))
        lefts.append(pairs[-1][0])
        rights.append(pairs[-1][1])
    lefts.sort()
    rights.sort()
    if N%2==0:
        print(int(((rights[N//2]+rights[N//2-1])/2+1 - (lefts[N//2]+lefts[N//2-1])/2)*2-1))
        return
    print(rights[(N+1)//2-1] - lefts[(N+1)//2-1] + 1)
E()
import statistics


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

    amed = statistics.median(a)
    bmed = statistics.median(b)

    if n % 2:
        print(int(bmed - amed + 1))
    else:
        print(int((bmed - amed) * 2 + 1))


if __name__ == '__main__':
    main()
n = int(input())

mins = []
maxs = []

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

mins.sort()
maxs.sort()


if n % 2 == 1:
    mid = n // 2
    print(maxs[mid] - mins[mid] + 1)

else:
    mid1 = n//2
    mid2 = mid1-1
    smallest = mins[mid1] + mins[mid2]
    largest = maxs[mid1] + maxs[mid2]
    print(largest - smallest + 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()
m=int(n//2)
if n%2==0:
  a_av=(a[m]+a[m-1])/2
  b_av=(b[m]+b[m-1])/2
  ans=int(b_av*2-a_av*2+1)
else:
  ans=int(b[m]-a[m]+1)
print(ans)
N = int(input())
L = []
H = []
for _ in range(N):
    a, b = map(int, input().split())
    L.append(a)
    H.append(b)
L.sort()
H.sort()

if N % 2 == 0:
    h = H[N // 2 - 1] + H[N // 2]
    l = L[N // 2 - 1] + L[N // 2]
    ans = h - l + 1
else:
    h = H[N//2]
    l = L[N//2]
    ans = h - l + 1

print(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 == 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 = sys.stdin.readline

def m(l):
    l.sort()
    n = len(l)
    
    if n%2==0:
        return (l[n//2-1]+l[n//2])/2
    else:
        return l[n//2]

N = int(input())
A, B = [], []

for _ in range(N):
    Ai, Bi = map(int, input().split())
    A.append(Ai)
    B.append(Bi)
    
l, h = m(A), m(B)

if N%2==0:
    print(int((h-l)*2+1))
else:
    print(h-l+1)
n = int(input())
min = []
max = []
for i in range(n):
  a, b = map(int, input().split())
  min.append(a)
  max.append(b)
min.sort()
max.sort()
if n%2 == 0:
  print((max[n//2] + max[n//2 - 1]) -(min[n//2] + min[n//2 - 1])+ 1)
else:
  print(max[n//2]-min[n//2]+1)
from statistics import*
(n,),*t=[map(int,t.split())for t in open(0)]
a,b=map(median,zip(*t))
print(int((b-a)*(2-n%2))+1)
from bisect import *
from collections import *

N = int(input())
# AB = [list(map(int, input().split())) for i in range(N)]
A, B = [None]*N, [None]*N
for i in range(N):
    A[i], B[i] = map(int, input().split())
A.sort()
B.sort()
if N % 2:
    a = A[N//2]
    b = B[N//2]
    ans = b-a+1
else:
    a = A[N//2-1] + A[N//2] 
    b = B[N//2-1] + B[N//2]
    ans = b-a+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:
  MIN = A[N//2-1]+A[N//2] #Medianの二倍
  MAX = B[N//2-1]+B[N//2]
  ans = MAX-MIN+1
else:
  MIN = A[N//2] #Medianの二倍
  MAX = B[N//2]
  ans = MAX-MIN+1
print(ans)
n=int(input())
ab=[list(map(int, input().split())) for _ in range(n)]
a=[]
b=[]
for a_i, b_i in ab:
    a.append(a_i)
    b.append(b_i)
a.sort()
b.sort()

import statistics
a_med=statistics.median(a)
b_med=statistics.median(b)

if n%2==0:
    ans=2*b_med-2*a_med+1
else:
    ans=b_med-a_med+1
print(int(ans))
N = int(input())
ab = [list(map(int, input().split())) for _ in range(N)]
mnl = [ab[i][0] for i in range(N)]
mxl = [ab[i][1] for i in range(N)]
mnl.sort()
mxl.sort()

if N % 2:
  mn = mnl[N//2]
  mx = mxl[N//2]
  print(mx-mn+1)
else:
  mn = (mnl[N//2-1]+mnl[N//2])/2
  mx = (mxl[N//2-1]+mxl[N//2])/2
  d = mx-mn
  print(int(mx-mn+1+d))
n = int(input())

a = []
b = []

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

a.sort()
b.sort()

x, y = 0, 0

if n % 2 == 1:
    x = b[n//2]
    y = a[n//2]
else:
    x = b[n//2] + b[n//2-1]
    y = a[n//2] + a[n//2-1]

print(x-y+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(int(2*(m2-m1))+1)
    else:
        print(B[(n+1)//2-1]-A[(n+1)//2-1]+1)    
main()
# E - Count Median
def main():
    N, *AB = map(int, open(0).read().split())
    A, B = AB[::2], AB[1::2]
    A.sort(), B.sort()
    mid = N // 2
    if N % 2:
        print(B[mid] - A[mid] + 1)
    else:
        print((B[mid] + B[mid - 1]) - (A[mid] + A[mid - 1]) + 1)


if __name__ == "__main__":
    main()
def mp(): return map(int, input().split())
def lmp(): return list(map(int, input().split()))

n = int(input())
a_ar = []
b_ar = []
for i in range(n):
    a, b = mp()
    a_ar.append(a)
    b_ar.append(b)
a_ar.sort()
b_ar.sort()

if n % 2 == 1:
    print(b_ar[n//2]-a_ar[n//2]+1)
else:
    l = (a_ar[n//2-1] + a_ar[n//2])/2
    r = (b_ar[n//2-1] + b_ar[n//2])/2
    print(int((r-l)*2+1))
n = int(input())
AB = [tuple(map(int, input().split())) for i in range(n)]
A = sorted([a for a, b in AB])
B = sorted([b for a, b in AB])
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)]
A = sorted([X[i][0] for i in range(N)])
B = sorted([X[i][1] for i in range(N)])
if N%2==1:
    a = A[N//2]
    b = B[N//2]
    print(b-a+1)
else:
    a = (A[N//2]+A[N//2-1])
    b = (B[N//2]+B[N//2-1])
    print(b-a+1)
from sys import stdin
from sys import setrecursionlimit
import bisect
setrecursionlimit(10 ** 7)

n = int(input())
li = []
lin = []

for _ in range(n):
    a,b = map(int,stdin.readline().rstrip().split())
    li.append([a,b])
    lin.append([b,a])

li.sort()
lin.sort()

if n%2 == 1:
    print(lin[n//2][0]-li[n//2][0]+1)
else:
    print((lin[n//2][0]+lin[(n-1)//2][0])-(li[n//2][0]+li[(n-1)//2][0])+1)
n = int(input())

start = []
end = []

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

start.sort()
end.sort()

if n % 2 == 1:
    print(end[n // 2] - start[n // 2] + 1)
else:
    print(end[n // 2 - 1] + end[n // 2] - start[n // 2 - 1] - start[n // 2] + 1)
n = int(input())
A = []
B = []
for _ in range(n):
    v1, v2 = list(map(int, input().split(' ')))
    A.append(v1)
    B.append(v2)

A.sort()
B.sort()

if n % 2:
    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)
#!/usr/bin/env python3
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:
    ans = 0
    ans += b[n // 2 - 1] + b[n // 2]
    ans -= a[n // 2 - 1] + a[n // 2]
    print(ans + 1)
else:
    print(b[n // 2] - a[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()

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

else:
  ans = (B[n // 2] + B[n // 2 - 1]) - (A[n // 2] + A[n // 2 - 1]) + 1

print(ans)
from numpy import*
t=loadtxt(open(0),skiprows=1)
a,b=median(t,0)
print(int((b-a)*(2-len(t)%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))
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)

l1.sort()
l2.sort()

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

if n%2==1:
  ans=m2-m1
else:
  ans=(m2-m1)*2

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

A.sort()
B.sort()

if N % 2 == 1:
    index = int((N-1)/2)
    minX = A[index]
    maxX = B[index]
    ans = maxX - minX + 1
else:
    index = int(N/2)
    minX1 = A[index-1]
    minX2 = A[index]
    maxX1 = B[index-1]
    maxX2 = B[index]
    minX = minX1 + minX2
    maxX = maxX1 + maxX2
    ans = maxX - minX + 1

print(ans)
N = int(input())

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

mi = sorted([A[i][0] for i in range(N)])
ma = sorted([A[i][1] for i in range(N)])

if N % 2 == 0:
    mi2 = mi[N//2-1] + mi[N//2]
    ma2 = ma[N//2-1] + ma[N//2]
else:
    mi2 = mi[N//2]
    ma2 = ma[N//2]

print(ma2 - mi2 + 1)
n = int(input())
bounds = [list(map(int, input().split())) for _ in range(n)]
upper = sorted([b[1] for b in bounds])
lower = sorted([b[0] for b in bounds])

if n % 2 == 0:
	u_mid2 = upper[n // 2 - 1] + upper[n // 2]
	l_mid2 = lower[n // 2 - 1] + lower[n // 2]
	print(u_mid2 - l_mid2 + 1)
else:
	print(upper[n // 2] - lower[n // 2] + 1)
import statistics
N = int(input())
A = []
B = []
for _ in range(N):
  a, b = map(int, input().split())
  A.append(a)
  B.append(b)
left = statistics.median(A)
right = statistics.median(B)
if N%2 == 0:
  print(int(right*2 - left*2 + 1))
else: 
  print(right-left+1)
n = int(input())

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

if n & 1:
    m = n // 2
    print(v2[m] - v1[m] + 1)
else:
    m = n // 2
    print(v2[m-1]-v1[m-1] + v2[m]-v1[m] + 1)
n=int(input())
a=[]
b=[]
for i in range(n):
    tmp = input().split()
    a.append(int(tmp[0]))
    b.append(int(tmp[1]))
a_sorted = sorted(a)
b_sorted = sorted(b)

if n % 2 == 1:
    ans = b_sorted[(n-1)//2] - a_sorted[(n-1)//2] + 1
else:
    ans = (b_sorted[n//2-1] + b_sorted[n//2]) - (a_sorted[n//2-1] + a_sorted[n//2]) + 1
print(ans)
n = int(input())
AB = [list(map(int, input().split())) for _ in range(n)]
A, B = zip(*AB)
A = sorted(A)
B = sorted(B)
if n%2:
    a_m = A[(n-1)//2]
    b_m = B[(n-1)//2]
else:
    a_m = A[n//2] + A[n//2 - 1]
    b_m = B[n//2] + B[n//2 - 1]
ans = b_m - a_m + 1
print(ans)
N=int(input())
ls=[list(map(int,input().split())) for i in range(N)]
ls_a=sorted([ls[i][0] for i in range(N)])
ls_b=sorted([ls[i][1] for i in range(N)])
ls_b.reverse()

if N%2==1:
  print(ls_b[(N-1)//2]-ls_a[(N-1)//2]+1)
else:
  p=(ls_a[N//2-1]+ls_a[N//2])/2
  q=(ls_b[N//2-1]+ls_b[N//2])/2
  print(int((q-p)*2+1))
N = int(input())
A = []
B = []
for i in range(N):
  temp = list(map(int, input().split()))
  A.append(temp[0])
  B.append(temp[1])
As = sorted(A)
Bs = sorted(B)

if(N%2==1):
  print(Bs[N//2] - As[N//2] + 1)
else:
  ans = ( (Bs[N//2-1]+Bs[N//2])/2 - (As[N//2-1]+As[N//2])/2 ) * 2 + 1
  print(int(ans))
N = int(input())
I = [tuple(map(int, input().split())) for _ in range(N)]
As = []
Bs = []
for a, b in I:
	As.append(a)
	Bs.append(b)
As.sort()
Bs.sort()

if N % 2 == 0:
	lows = As[N//2] + As[N//2-1]
	his = Bs[N//2] + Bs[N//2-1]
else:
	lows = As[N//2]
	his = Bs[N//2]

print(his - lows + 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) + 1)
# E

N = int(input())

ab = []

for i in range(N):
  ab.append(tuple(map(int,input().split())))

ab.sort()
  
import statistics
import math

am = statistics.median([i[0] for i in ab])
bm = statistics.median([i[1] for i in ab])

if N%2 != 0:
  print(bm-am+1)
else:
  print(int((bm-am)*2+1))
n = int(input())
a = []
b = []
for i in range(n):
    x, y = map(int, input().split())
    a.append([x, y])
    b.append([y, x])
a = sorted(a)
b = sorted(b, reverse = True)

if n % 2 ==0:
    s = a[n//2 -1][0]
    e = b[n//2 -1][0]
    s2 = a[n//2][0]
    e2 = b[n//2][0]
    ans = e+ e2 -s-s2+1   
else:
    s = a[(n+1)//2 -1][0]
    e = b[(n+1)//2 -1][0]
    ans = e-s+1
print(ans)
import statistics
N= int(input())
min_all=[]
max_all = []
for _ in range(N):
    a,b=map(int,input().split())
    min_all.append(a)
    max_all.append(b)
min_median = statistics.median(min_all)
max_median = statistics.median(max_all)
if N%2:
    ans = max_median - min_median+1
else:
    ans = int((max_median - min_median +0.5)*2)
print(ans)
n = int(input())
a, b = [], []
for _ in range(n):
    i, j = map(int, input().split())
    a.append(i)
    b.append(j)

a.sort()
b.sort()

if n % 2 == 1:
    mi = a[n // 2]
    ma = b[n // 2]
    print(ma - mi + 1)
    exit()

mi = a[n // 2 - 1] + a[n // 2]
ma = b[n // 2 - 1] + b[n // 2]
print(ma - mi + 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 - 0.5
    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())
A = list()
B = list()
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-1)//2]
  y = B[(N-1)//2]
  print(y-x+1)
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 = []
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:
  mA = (A[N//2-1]+A[N//2])/2
  mB = (B[N//2-1]+B[N//2])/2
  print(int((mB - mA)*2 + 1))
else:
  mA = A[N//2]
  mB = B[N//2]
  print(mB-mA+1)
N = int(input())
AB = [tuple(map(int, input().split())) for _ in range(N)]
A = [a for a, _ in AB]
B = [b for _, b in AB]
A.sort()
B.sort()

if N % 2 == 1:
    mi = A[N // 2]
    mx = B[N // 2]
    print(mx - mi + 1)
else:
    mi = A[N // 2] + A[N // 2 - 1]
    mx = B[N // 2] + B[N // 2 - 1]
    print(mx - mi + 1)
import statistics
import math
from decimal import *
N = int(input())

n =[]
m =[]

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

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

if N%2 == 1:
    print(mmean - nmean + 1)
else:
    print(int((mmean - nmean)*2) +1 )
n = int(input().strip())
ab = [tuple(map(int, input().split())) for _ in range(n)]

mid_min = 0
mid_max = 0

ab.sort(key=lambda x: x[0])
if n & 1:
    mid_min = ab[n // 2][0]
else:
    mid_min = (ab[(n - 1) // 2][0] + ab[n // 2][0])

ab.sort(key=lambda x: x[1])
if n & 1:
    mid_max = ab[n // 2][1]
else:
    mid_max = (ab[(n - 1) // 2][1] + ab[n // 2][1])

print(mid_max - mid_min + 1)
n = int(input())
a,b = [], []
for _ in range(n):
  i = input().split()
  a.append(int(i[0]))
  b.append(int(i[1]))
a.sort()
b.sort()
if n%2:
  l = a[n//2]
  h = b[n//2]
  print(h-l+1)
else :
  l = (a[n//2-1]+a[n//2]) / 2
  h = (b[n//2-1]+b[n//2]) / 2
  print(int((h-l)*2) +1)
N=int(input())
A=[]
B=[]

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

l=[]
r=[]
A.sort()
B.sort()

if N%2==1:
    n=N//2
    ans=B[n]-A[n]+1
else:
    n1=N//2-1
    n2=N//2
    ans=B[n1]-A[n1]+B[n2]-A[n2]+1

print(ans)
import sys
sys.setrecursionlimit(10**8)
input = sys.stdin.readline

N = int(input())
L1 = []
L2 = []

for _ in range(N):
    a,b = map(int,input().split())
    L1.append(a)
    L2.append(b)

L1.sort()
L2.sort()

def median(L):
    if N&1:
        return L[(N)//2]
    else:
        ret = L[N//2-1] + L[N//2]
        return ret

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

ans = 0
if n % 2 == 0:
    l = a[n//2-1] + a[n//2]
    h = b[n//2-1] + b[n//2]

    ans += h - l + 1
else:
    l = a[n//2]
    h = b[n//2]

    ans += h - l + 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.sort()
B.sort()
if N % 2 == 1:
    id = (N+1)//2
    print(B[-id] - A[id-1] + 1)
else:
    id = N // 2
    ans = (B[-id-1]-A[id])*2 + 1
    ans += B[-id] - B[-id-1]

    ans += A[id] - A[id-1]

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

if N%2==1:
    k=N//2
    A.sort()
    B.sort()
    small=A[k]
    large=B[k]
    print(large-small+1)

else:
    k=N//2
    A.sort()
    B.sort()
    small=A[k-1]+A[k]
    large=B[k-1]+B[k]
    print(large-small+1)
n=int(input())
l=[]
r=[]
m=[]
for i in range(n):
  a,b=map(int,input().split())
  l.append(a)
  r.append(b)
l.sort()
r.sort()
if n%2==1:
  print(r[(n-1)//2]-l[(n-1)//2]+1)
else:
  print(r[(n//2-1)]+r[n//2]-l[n//2]-l[n//2-1]+1)
how_many = int(input())
least, biggest = [],[]
for i in range(how_many):
    nums = input().split()
    nums = [int(num) for num in nums]
    least.append(nums[0])
    biggest.append(nums[1])
least.sort()
biggest.sort()
if how_many % 2 == 1:
    print(biggest[int((how_many-1) / 2)] - least[int((how_many-1) / 2)] + 1)
else:
    l = (least[int(how_many / 2)] + least[int(how_many / 2 - 1)]) / 2
    b = (biggest[int(how_many / 2)] + biggest[int(how_many / 2 - 1)]) / 2
    print(int((b-l) / 0.5 + 1))