peterverebics/CodeNet_Python_118 huggingface dataset:
import statistics

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

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

if n%2==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())
ab = [list(map(int, input().split())) for _ in range(N)]

l = sorted(ab, key=lambda x: x[0])
r = sorted(ab, key=lambda x: x[1])

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

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

A.sort()
B.sort()

if N%2==1:
    mi = N//2
    lmed = A[mi]
    rmed = B[mi]
    print(rmed-lmed+1)

if N%2==0:
    mir = N//2
    mil = mir-1
    lmed = (A[mir]+A[mil]) / 2
    rmed = (B[mir]+B[mil]) / 2
    print(int(2*(rmed-lmed)+1))
n=int(input())
a=[];b=[]
for _ in range(n):
    ai,bi=map(int, input().split())
    a.append(ai);b.append(bi)
a.sort()
b.sort()
ma=0;mb=0
if n%2:
    ma=a[n//2]
    mb=b[n//2]
    
else:
    ma=a[n//2]+a[n//2-1]
    mb=b[n//2]+b[n//2-1]
print(mb-ma+1)
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:
        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
    return ans
print(solve())
N = int(input())

AB = []

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

A_idx = [(AB[i][0], i) for i in range(N)]
B_idx = [(AB[i][1], i) for i in range(N)]

A_idx.sort(key=lambda e:e[0])
B_idx.sort(key=lambda e:e[0])

if N % 2 == 1:
    diff = B_idx[N//2][0]-A_idx[N//2][0]
    print(diff+1)
else:
    l = N//2-1
    u = N//2
    diff = (B_idx[l][0]+B_idx[u][0])-(A_idx[l][0]+A_idx[u][0])
    print(diff+1)
N = int(input())
A = [0]*N
B = [0]*N
for i in range(N):
    A_in, B_in = map(int, input().split())
    A[i] = A_in
    B[i] = B_in


A.sort()
B.sort()
if N % 2 == 1:
    print(B[(N+1)//2 - 1] - A[(N+1)//2 - 1] + 1)
else:
    d_B_med = (B[N//2 - 1] + B[N//2])
    d_A_med = (A[N//2 - 1] + A[N//2])
    print(d_B_med - d_A_med + 1)
from sys import stdin
input = stdin.readline
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:
    temp = N//2
    m = (A[temp]+A[temp-1])/2
    M = (B[temp]+B[temp-1])/2
    print(int((M-m+1/2)//(1/2)))
else:
    temp = N//2
    print(B[temp]-A[temp]+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_)
am, bm = median(a), median(b)
print(int(max(0, bm - am) * 2) + 1 if n % 2 == 0 else int(max(0, bm - am)) + 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 - 1) // 2] - A[(N - 1) // 2] + 1)
else:
    print(((B[N // 2] + B[N // 2 - 1]) - (A[N // 2] + A[N // 2 - 1])) + 1)
n = int(input())
al = []
bl = []
for _ in range(n):
    a,b= map(int, input().split())
    al.append(a)
    bl.append(b)

al.sort()
bl.sort()

if n%2 == 1:
    minv = al[n//2]
    maxv = bl[n//2]
    print(maxv-minv+1)

else:
    minv2 = al[n//2] + al[n//2-1]
    maxv2 = bl[n//2] + bl[n//2-1]
    print(maxv2-minv2+1)
n = int(input())
listA = []
listB = []
for i in range(n):
    a, b = map(int, input().split())
    listA.append(a)
    listB.append(b)
listA.sort()
listB.sort()

if n%2 == 0:
    ta = (listA[n//2]+listA[n//2-1])
    tb = (listB[n//2]+listB[n//2-1])
else:
    ta = listA[n//2]
    tb = listB[n//2]

print(tb-ta+1)
def resolve():
	from statistics import median
	import sys
	input = sys.stdin.readline
	n = int(input())
	ab = [list(map(int, input().split())) for i in range(n)]
	mina = median(i[0] for i in ab)
	maxb = median(i[1] for i in ab)
	abrange = maxb - mina
	if n%2 == 0:
		print(int(abrange/0.5 + 1))
	else:
		print(int(abrange/1 + 1))
resolve()
import sys
input = sys.stdin.readline
N = int(input())
AB = [tuple(map(int,input().split())) for i in range(N)]
A = []
B = []
for a,b in AB:
    A.append(a)
    B.append(b)
A.sort()
B.sort()

if N%2==0:
    m = N//2
    b = B[m] + B[m-1]
    a = A[m] + A[m-1]
    print(b - a + 1)
else:
    m = N//2
    print(B[m] - A[m] + 1)
n = int(input())
A = [[int(i) for i in input().split(" ")] for j in range(n)]
a = sorted([i[0] for i in A])
b = sorted([i[1] for i in A], reverse=True)
if n%2 == 1:
    print(b[n//2]-a[n//2]+1)
else:
    l = (a[n//2-1] + a[n//2]) / 2
    r = (b[n//2-1] + b[n//2]) / 2
    print(int((r-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)
a.sort()
b.sort(reverse=True)
ans=0
if n%2==1:
    s=a[n//2]
    g=b[n//2]
    ans=g-s+1
else:
    s1,s2=a[n//2-1],a[n//2]
    g2,g1=b[n//2-1],b[n//2]
    ans=(g2+g1)-(s2+s1)+1
print(ans)
def main():

    import statistics

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

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

    meda = statistics.median(a)
    medb = statistics.median(b)

    if n % 2:
        print(int(medb - meda + 1))
    else:
        print(int((medb - meda) * 2 + 1))


if __name__ == '__main__':
    main()
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
n = int(readline())
import numpy as np
kx = np.array(read().split(),np.int32)
a = kx[::2]
b = kx[1::2]
a.sort()
b.sort()
if n%2 == 1:
  L = a[n//2]
  R = b[n//2]
  ans = R-L+1
else:
  LL = a[n//2-1]
  LR = b[n//2-1]
  RL = a[n//2]
  RR = b[n//2]
  ans = RR+LR-LL-RL+1
print(ans)
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] + y[m+1]-x[m]-x[m+1] +1
    print(ans)
    exit()
else:
    m = n//2
    ans = y[m] - x[m] + 1
    print(ans)
    exit()
n=int(input())
a= [list(map(int, input().split())) for i in range(n)]

# 奇数の時
if n%2==1:
    # 下限
    a.sort()
    l=a[n//2][0]

    a.sort(key=lambda x:x[1])

    r=a[n//2][1]
    print(r-l+1)

else:
    a.sort()
    l=a[n//2-1][0]+a[n//2][0]
    a.sort(key=lambda x:x[1])
    r=a[n//2-1][1]+a[n//2][1]
    print(r-l+1)
n = int(input())
A = []
B = []

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

A.sort()
B.sort()

if n % 2 == 0:
    print(B[n//2] + B[n//2-1] - A[n//2] - A[n//2-1] + 1)
else:
    print(B[(n-1)//2] - A[(n-1)//2] + 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
if n%2:
  print(M[d]-m[d]+1)
else:
  print(M[d-1]+M[d]-m[d-1]-m[d]+1)
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
    num1 = (A[target1]+A[target2])/2
    num2 = (B[target1]+B[target2])/2
    print(int(((num2-num1)/0.5)+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]) / 2
b_med = b[(n + 1) // 2 - 1] if not is_odds else (b[n // 2 - 1] + b[n // 2]) / 2
from_a = a_med if not is_odds else int(a_med * 2)
to_b = b_med if not is_odds else int(b_med * 2)
print(to_b - from_a + 1)
#!/usr/bin/python
# -*- coding: utf-8 -*-

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

A = []
B = []

for i in range(N):
    A.append(AB[i][0])
    B.append(AB[i][1])

A.sort()
B.sort()

if N%2 == 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)
n = int(input())

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

ab.sort()

if n % 2 == 1:
    m = (n-1) // 2
    l = ab[m][0]

    ab.sort(key = lambda x: x[1], reverse = True)

    m = (n-1) // 2
    r = ab[m][1]
    print(r - l + 1)
else:

    m = n // 2
    l1 = ab[m-1][0]
    l2 = ab[m][0]

    ab.sort(key = lambda x: x[1], reverse = True)

    m = n // 2
    r1 = ab[m][1]
    r2 = ab[m-1][1]
    print((r1+r2)-(l1+l2)+1)
n = int(input())
a = []
b = []
for i in range(n):
    a1,b1 = map(int, input().split())
    a.append(a1)
    b.append(b1)
a.sort()
b.sort()
if n%2 == 1:
    print(b[(n+1)//2-1]-a[(n+1)//2-1]+1)
else:
	print(b[n//2-1]-a[n//2-1]+b[n//2]-a[n//2]+1)
n, *AB = map(int, open(0).read().split())
A, B = map(sorted, [AB[::2], AB[1::2]])
mid = n//2
if n % 2 == 0:
    a0, a1 = A[mid-1], A[mid]
    b0, b1 = B[mid-1], B[mid]
    print(b0+b1 - (a0+a1) + 1)
else:
    print(B[mid] - A[mid] + 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:
    M = (b[n//2]+b[n//2-1])/2
    m = (a[n//2]+a[n//2-1])/2
    print(int((M-m)*2+1))
n = int(input())
arr_a = []
arr_b = []
for i in range(n):
    a, b = map(int, input().split())
    arr_a.append(a)
    arr_b.append(b)
arr_a.sort()
arr_b.sort()
if n % 2 == 1:
    print(arr_b[n//2] - arr_a[n//2] + 1)
else:
    median_a = (arr_a[int(n/2 -1)] + arr_a[int(n/2)])
    median_b = (arr_b[int(n/2 -1)] + arr_b[int(n/2)])
    print(median_b - median_a + 1)
n = int(input())
num = []


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

a = []
b = []
for i in range(n):
    a.append(num[i][0])
    b.append(num[i][1])

a.sort()
b.sort()

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

else:
    right = b[n//2]
    left = a[n//2]
    print(right - left + 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()

s, t = 0, 0
if n % 2 == 0:
    s = (A[n//2-1] + A[n//2])
    t = (B[n//2-1] + B[n//2])
else:
    s = A[n//2]
    t = B[n//2]

print(t-s+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:
  A_median = A[N // 2]
  B_median = B[N // 2]
  print(abs(B_median - A_median) + 1)
else:
  A_median = (A[N // 2 - 1] + A[N // 2]) / 2
  B_median = (B[N // 2 - 1] + B[N // 2]) / 2
  print(int(abs(B_median - A_median) * 2) + 1)
import sys
input = sys.stdin.readline
n = int(input())
ab = [list(map(int,input().split())) for i in range(n)]
l,r = list(zip(*ab))
l = list(l)
r = list(r)
l.sort()
r.sort()
if n%2:
  print((r[n//2]-l[n//2])+1)
else:
  print(((r[n//2-1]+r[n//2])-(l[n//2-1]+l[n//2]))+1)
import statistics
n=int(input())
 
la, lb = [], []
for _ in range(n):
  a, b = map(int, input().split())
  la.append(a)
  lb.append(b)
c=statistics.median(la)
d=statistics.median(lb)
if n%2==1:
  print(d-c+1)
else:
  print(int(2*d-2*c+1))
n=int(input())
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==1):
    target=(n+1)//2
    print(b[target-1]-a[target-1]+1)
if (n%2==0):
    target=(n)//2
    left=a[target]+a[target-1]
    right=b[target]+b[target-1]
    ans=right-left+1
    print(ans)
n = int(input())
ab =[list(map(int,input().split())) for _ in range(n)]

ab.sort()
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 = int((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))
N = int(input())
A = [0]*N
B = [0]*N

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

A.sort()
B.sort()
if N % 2 == 1:
    print(B[N//2]-A[N//2]+1)
else:
    Am = (A[N//2]+A[N//2-1])/2
    Bm = (B[N//2]+B[N//2-1])/2
    print(int((Bm-Am)*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 = sorted(A)
B = sorted(B)

if N % 2 == 1:
    print(B[(N+1)//2-1] - A[(N+1)//2-1] + 1)
else:
    b = B[N//2-1] + B[N//2]
    a = A[N//2-1] + A[N//2]
    print(b-a+1)
N=int(input())

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

A.sort()
B.sort()

I=~-N//2
print(B[I]-A[I]+1 + (B[I+1]-A[I+1] if N%2==0 else 0))
n=int(input())
aa=[]
bb=[]
for i in range(n):
    a,b=map(int,input().split())
    aa.append(a)
    bb.append(b)
aa.sort()
bb.sort()
if(n%2==0):
    print(bb[n//2-1]+bb[n//2]-aa[n//2]-aa[n//2-1]+1)
else:
    print(bb[n//2]-aa[n//2]+1)
n = int(input())
minnums = [[] for _ in range(n)]
maxnums = [[] for _ in range(n)]

for i in range(n):
  minnums[i], maxnums[i] = map(int, input().split())
  
minnums.sort()
maxnums.sort()

if n % 2:
  minmedian = minnums[n // 2]
  maxmedian = maxnums[n // 2]
  print(maxmedian - minmedian + 1)
else:
  minmedian = (minnums[n // 2 - 1] + minnums[n // 2]) / 2
  maxmedian = (maxnums[n // 2 - 1] + maxnums[n // 2]) / 2
  print(int((maxmedian - minmedian) * 2 + 1))
import math
import fractions
import collections
import itertools
import pprint
N=int(input())
l=[list(map(int,input().split())) for _ in range(N)]
l1=[]
l2=[]
for i in range(N):
    l1.append(l[i][0])
    l2.append(l[i][1])
l1.sort()
l2.sort()
if N%2==0:
    minmed=(l1[N//2]+l1[N//2-1])/2
    maxmed=(l2[N//2]+l2[N//2-1])/2
    print(int(2*(maxmed-minmed)+1))
else:
    minmed=l1[N//2]
    maxmed=l2[N//2]
    print(maxmed-minmed+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:
    min_X = A[(N+1)//2-1]
    max_X = B[(N+1)//2-1]
    print(max_X - min_X + 1)
else:
    min_X = (A[N//2-1] + A[N//2])/2
    max_X = (B[N//2-1] + B[N//2])/2
    print(int((max_X - min_X)*2) + 1)
def resolve():
    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()
    if n%2==0:
        k=int(n/2)
        print(int(2*((b[k]+b[k-1])/2-(a[k]+a[k-1])/2)+1))
    else:
        k=n//2
        print(b[k]-a[k]+1)
resolve()
N = int(input())
AB = [tuple(map(int, input().split())) for _ in range(N)]

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

if N % 2:
    lb = a[(N - 1) // 2]
    ub = b[(N - 1) // 2]
    ans = ub - lb + 1
else:
    lb = (a[(N - 2) // 2] + a[N // 2]) / 2
    ub = (b[(N - 2) // 2] + b[N // 2]) / 2
    ans = int((ub - lb) * 2) + 1

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

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

med_a = median(A)
med_b = median(B)
if N % 2 == 1:
    ans = int(med_b) - int(med_a) + 1
else:
    ans = med_b * 2 - med_a * 2 + 1
    ans = int(ans)

print(ans)
n = int(input())
A = []
B = []
for i in range(n):
    x = [int(i) for i in input().split()]
    A.append(x[0])
    B.append(x[1])
A = sorted(A)
B = sorted(B)
if n % 2:
    med_A = A[n//2]
    med_B = B[n//2]
    print(abs(med_A - med_B) + 1)
else:
    med_A  = A[(n-1)//2]+A[n//2] # this is double of median
    med_B = B[(n-1)//2]+B[n//2]
    print(abs(med_A - med_B) + 1) # we want gap of 1/2
# coding: utf-8
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
AB = np.array([lr() for _ in range(N)])
A = AB[:, 0]
B = AB[:, 1]
me_A = np.median(A)
me_B = np.median(B)
if N&1:
    answer = int(me_B - me_A) + 1
else:
    answer = int((me_B - me_A) / 0.5) + 1

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

A.sort()
B.sort()

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

else:
    x = a[N//2]
    y = b[N//2]
    print(y-x+1)
n = int(input().strip())
lower=[0]*n
upper=[0]*n
for i in range(n):
    A, B = map(int, input().strip().split())
    lower[i]=A
    upper[i]=B
lower.sort()
upper.sort()

if n%2:
    ans=upper[n//2]-lower[n//2]+1
else:
    ans=upper[n//2]+upper[n//2-1]-(lower[n//2]+lower[n//2-1])+1
print(ans)
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))


n = ii()
A = []
B = []

for _ in range(n):
    a,b = iim()
    A.append(a)
    B.append(b)
A.sort()
B.sort()

if n%2 == 1:
    ans = B[n//2]-A[n//2]+1
else:
    lmin = A[n//2-1]
    lmax = B[n//2-1]
    rmin = A[n//2]
    rmax = B[n//2]
    ans = (rmax+lmax) - (rmin+lmin) + 1
print(ans)
import numpy as np

N = int(input())

AB = []
for i in range(N):
    ab = list( map(int,input().split()) )
    AB.append(ab)

AB = np.array(AB)

A = AB[:,0]
B = AB[:,1]

m_min = np.median(A)
m_max = np.median(B)

if N%2==0:
    ans = (int(m_max*10) - int(m_min*10)) //5 +1
else:
    ans = int(m_max) - int(m_min) + 1

print(ans)
import statistics
import math

N = int(input())

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

AM = statistics.median(A)
BM = statistics.median(B)
if N % 2 == 1:
    ANS = (BM - AM) + 1
else:
    ANS = int((BM - AM) * 2 + 1)
print(ANS)
N = int(input())
from  statistics import median


MIN = [0] * N
MAX = [0] * N

for i in range(N):
  A, B = map(int, input().split())
  
  MIN[i] = A
  MAX[i] = B
  
min_ = median(MIN)
max_ = median(MAX)
d = max_ - min_

if N % 2 == 0:
  print(int(d * 2) + 1)
else:
  print(int(d)+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:
    n = N // 2
    m2 = A[n - 1] + A[n]
    M2 = B[n - 1] + B[n]
    ans = M2 - m2 + 1
    print(ans)
else:
    n = N // 2
    m2 = A[n]
    M2 = B[n]
    ans = M2 - m2 + 1
    print(ans)
from statistics import median


def main():
    n = int(input())
    a = [0] * n
    b = [0] * n
    for i in range(n):
        a[i], b[i] = map(int, input().split())
    ans = median(b) - median(a)
    if n % 2 == 0:
        ans *= 2
    ans = int(ans)
    ans += 1
    print(ans)


if __name__ == '__main__':
    main()
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n = int(readline())
ab = list(map(int,read().split()))
a = ab[::2]
b = ab[1::2]
a.sort()
b.sort()

if(n%2==1):
    n_min = a[n//2]
    n_max = b[n//2]
    ans = n_max-n_min+1
else:
    n_min = a[n//2 -1] + a[n//2]
    n_max = b[n//2 -1] + b[n//2]
    ans = n_max-n_min+1

print(ans)
import statistics
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:
  print(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):
    aa, bb = [int(i) for i in input().split()]
    a.append(aa)
    b.append(bb)
a.sort()
b.sort()

if n % 2 == 0:
    mi = a[n // 2] + a[n // 2 - 1]
    ma = b[n // 2] + b[n // 2 - 1]
else:
    mi = a[n // 2]
    ma = b[n // 2]
print(ma - mi + 1)
n = int(input())

low = [0]*n
high = [0]*n

for i in range(n):
    a, b = [int(x) for x in input().split(" ")]
    low[i] = a
    high[i] = b

low.sort()
high.sort()

if n%2 == 1:
    print(high[n//2]-low[n//2]+1)
else:
    x = (low[(n-1)//2] + low[n//2])/2
    y = (high[(n-1)//2] + high[n//2])/2
    print(int(2*y - 2*x + 1))
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(b[n//2]-a[n//2]+1)
else:
  print((b[n//2]+b[n//2-1])-(a[n//2]+a[n//2-1])+1)
def main():
    n = int(input())
    al = []
    bl = []
    for _ in range(n):
        a, b = map(int, input().split())
        al.append(a)
        bl.append(b)
    als = list(sorted(al))
    bls = list(sorted(bl))
    if n%2:
        print(bls[n//2]-als[n//2]+1)
    else:
        print(bls[n//2-1]+bls[n//2]-als[n//2]-als[n//2-1]+1)

if __name__ == "__main__":
    main()
from operator import itemgetter

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

sortA = sorted(AB, key=itemgetter(0))
sortB = sorted(AB, key=itemgetter(1))

if n%2==1:
    print(sortB[n//2][1] - sortA[-n//2][0] + 1)

else:
    print(int(((sortB[n//2][1]+sortB[n//2-1][1])/2 - (sortA[n//2][0]+sortA[n//2-1][0])/2) / (1/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 == 0:
    l = A[N // 2 - 1] + A[N // 2]
    u = B[N // 2 - 1] + B[N // 2]
    print(u - l + 1)
else:
    l = A[N // 2]
    u = B[N // 2]
    print(u - l + 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:
    mid_min = a[n//2]
    mid_max = b[n//2]
    print(mid_max-mid_min+1)
else:
    mid_min = (a[n//2-1]+a[n//2])/2
    mid_max = (b[n//2-1]+b[n//2])/2
    print(int((mid_max-mid_min)*2)+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()

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(b1 + b2 - (a1 + a2) + 1)
    #print(a1,a2,b1,b2)
import statistics
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:
  med_min = A[N // 2]
  med_max = B[N // 2]
  print(med_max - med_min + 1)  
else:
  med_min_db = A[N // 2] + A[N // 2 - 1]
  med_max_db = B[N // 2] + B[N // 2 - 1]
  print(med_max_db - med_min_db + 1)
n=int(input())
a=[]
b=[]
for i in range(n):
  tmpa,tmpb=map(int,input().split())
  a.append(tmpa)
  b.append(tmpb)
if n%2==1:
  a.sort()
  b.sort()
  print(b[n//2]-a[n//2]+1)
else:
  a.sort()
  b.sort()
  tmp=(b[n//2-1]+b[n//2])/2 - (a[n//2-1]+a[n//2])/2
  if tmp.is_integer():
    print(int(tmp)*2+1)
  else:
    print(int(tmp+0.5)*2)
import numpy as np
import itertools
import statistics
import math

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

arr = np.array(l)

arr1 = arr[:,:1].tolist()
arr2 = arr[:,1:].tolist()

l1 = list(itertools.chain.from_iterable(arr1))
l2 = list(itertools.chain.from_iterable(arr2))

a = statistics.median(l1)
b = statistics.median(l2)

if n%2 ==1:
    print(b-a+1)
else:
    print(int((b-a)//0.5) + 1)
import numpy as np
N = int(input())
A = []
B = []
for i in range(N):
    in1, in2 = list(map(int,input().split()))
    A.append(in1)
    B.append(in2)
temp1 = np.median(A)
temp2 = np.median(B)
if N % 2 == 0:
    ans = (temp2 - temp1) * 2 + 1
else:
    ans = (temp2 - temp1) + 1
print(int(ans))
import numpy as np
N = int(input())
table = np.array([list(map(int, input().split())) for _ in range(N)])

inf, sup = np.median(table, axis=0)
diff = int(sup - inf)
if N % 2 == 0:
    diff *= 2
print(diff + 1)