peterverebics/CodeNet_Python_118 huggingface dataset:
n=int(input())
a,b=[],[]
for i in range(n):
  inp=list(map(int,input().split()))
  a.append(inp[0])
  b.append(inp[1])
am=sum(a[(n-1)//2:n//2+1])
bm=sum(b[(n-1)//2:n//2+1])
print(bm-am+1)
import statistics

n = int(input())
# ab = [list(map(int, input().split())) for _ in range(n)]
a, b = list(), list()
for _ in range(n):
    a_, b_ = map(int, input().split())
    a.append(a_)
    b.append(b_)

a_med = statistics.median(a)
b_med = statistics.median(b)
if len(a) % 2 == 0:
    print(int(b_med - a_med + 2))
else:
    print(b_med - a_med + 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((max_X - min_X)*2 + 1)
N = int(input())
ab = []
for i in range(N):
    ab.append(tuple(map(int,input().split())))

up = sorted(ab,key=lambda a:a[0],reverse=True)
down = sorted(ab,key=lambda a:a[1],reverse=True)
if N%2 == 1:
    print(up[N//2][1]-down[N//2][0]+1)
else:
    r = (up[N//2-1][1]+up[N//2][1])
    l = (down[N//2-1][0]+down[N//2][0])

    print(r-l+1)
N = int(input())
a = [0]*N
b = [0]*N
for i in range(N):
    a[i],b[i] = map(int, input().split())
import statistics
X = statistics.median(a)
Y = statistics.median(b)
print(Y-X+1)
#from collections import deque,defaultdict
from sys import stdin
input = stdin.readline
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

n = inn()
a = []
b = []
for i in range(n):
    aa,bb = inm()
    a.append(aa)
    b.append(bb)
a.sort()
b.sort(reverse=True)
m = n//2 - (0 if n%2==1 else 1)
print(b[m]-a[m]+1)
import statistics
import math

n = int(input())
aa,bb = [],[]

for i in range(n):
    a,b = map(int,input().split())
    
    aa.append(a)
    bb.append(b)
    
if n % 2 == 1:
    am = aa[n//2]
    bm = bb[n//2]
    
    ans = bm - am + 1
    
else:
    am = (aa[n//2] + aa[n//2-1]) / 2
    bm = (bb[n//2] + bb[n//2-1]) / 2
    
    ans = (bm - am)*2 + 1
    
print(int(ans))
N = int(input())
ans = []
pts = []
for i in range(N):
    x1, x2 = map(int, input().split())
    pts.append(x1)
    pts.append(x2)
pts = sorted(pts)

l = N // 2

if N % 2 == 0:
    L = (pts[l-1] + pts[l]) / 2
    R = (pts[-l] + pts[-l-1]) / 2
    ans = int((R-L)/(0.5)) + 1
else:
    ans = pts[-1-l] - pts[l] + 1
print(ans)
from operator import itemgetter
import copy

n = int(input())
ab = sorted([list(map(int, input().split())) for i in range(n)])
abr = copy.copy(ab)
abr.sort(key=itemgetter(1))
if n % 2:
    a1,b1 = ab[n//2]
    a2,b2 = abr[n//2]
    ans = b2 - a1 + 1
else:
    a1,b1 = ab[n//2-1]
    a2,b2 = abr[n//2-1]
    a3,b3 = ab[n//2]
    a4,b4 = ab[n//2]
    ans = b4 - a3 + b2 - a1 + 1
    if a3 > b2:
        ans += 1
print(ans)
N = int(input())
ab = [list(map(int, input().split())) for i in range(N)]

al = []
bl = []
for a,b in ab:
  al.append(a)
  bl.append(b)
al.sort()
bl.sort()

if N%2 == 0:
  ans = ((bl[N//2] + bl[N//2 -1])//2 - (al[N//2] + al[N//2 -1])//2) *2 +1
else:
  ans = bl[N//2] - al[N//2] +1
print(ans)
import statistics
import math

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

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

x = statistics.median(b[0])
y = statistics.median(b[1])

if n % 2 != 0:
    ans = y - x + 1

else:
    ans = round(y - x) * 2 + 1

print(ans)
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-1])/2
    max_med = (max_s[n//2-1] + max_s[n//2-1])/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))
n = int(input())
l = []
for i in range(n):
    a, b = map(int, input().split())
    l.append([a, b])
l.sort()
if n % 2:
    tmp = l[n // 2]
    print(tmp[1] - tmp[0] + 1)
else:
    tmp1 = l[(n - 1) // 2]
    tmp2 = l[n // 2]
    print(tmp2[1] - tmp2[0] + 1 + tmp1[1] - tmp1[0])
n=int(input())

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


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

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

else:
  x=n//2
#  ts=(s[x]+s[x-1])//2
#  te=(e[x]+e[x-1])//2
  ans=(e[x-1]-s[x-1]+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-1][0], tr[t][1]
    a3, a4 = tl[t][0], tr[t-1][1]
    v1 = (a2-a1+1)*(a4-a3+1)
    v2 = (a2-a3+1)*(a2-a3+1) if a3<=a2 else 0
    print(v1-v2)
# E

N = int(input())

ab = []

for i in range(N):
  ab.append(tuple(map(int,input().split())))
  
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==1:
  print(bm-am+1)
else:
  print(int(bm-am+2))
import math


def main(N, lines):
    a = sorted(map(lambda line: line[0], lines))
    b = sorted(map(lambda line: line[1], lines))

    if N % 2 == 1:
        mi = a[N // 2]
        ma = b[N // 2]
        print(int(ma - mi + 1))
    else:
        mi = math.floor((a[N // 2 - 1] + a[N // 2]) / 2)
        ma = math.ceil((b[N // 2 - 1] + b[N // 2]) / 2)
        print(int(ma - mi + 1))


N = int(input())
lines = []
for i in range(N):
    lines.append(list(map(int, input().split())))
main(N, lines)
n=int(input())
import bisect as bi
A=[] ; B=[]
for i in range(n):
    a,b=map(int,input().split())
    A.append(a)
    B.append(b)

if n%2==1:
    a=A[(n-1)//2] ; b=B[(n-1)//2]
    print(b-a+1)
else:
    a=(A[n//2-1]+A[n//2])/2 ; b=(B[n//2-1]+B[n//2])/2
    print(int((b-a)/0.5)+1)
import math

N = int(input())
list_A, list_B = list(), list()
for _ in range(N):
    A, B = map(int, input().split())
    list_A.append(A)
    list_B.append(B)

list_A.sort()
list_B.sort()

if N%2==0:
    tmp, tmp1 = N//2-1, N//2
    _min = math.floor(max(list_A[tmp], list_A[tmp1]))
    _max = math.ceil(min(list_B[tmp], list_B[tmp1]))
else:
    tmp = N//2
    _min = math.floor(list_A[tmp])
    _max = math.ceil(list_B[tmp])

print(_max-_min+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()

youso = int(n/2)

if n % 2 != 0:
    print(b[youso]-a[youso]+1)
else:
    print((b[youso]+b[youso-1])//2-(a[youso]+a[youso-1])//2+2)
import statistics
import math

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 == 0:
    print(int(statistics.median(b)+0.5)- int(statistics.median(a)))
else:
    print(int(statistics.median(b)+0.5)- int(statistics.median(a)) + 1)
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(len(C))
import math


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


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:
    print(y - x + 1)
else:
    print(int(y - x) + int(y - x + 1))
n = int(input())
lister = []
for i in range(n):
    lister.append([int(i) for i in input().split()])
 
if n % 2 == 1:
    lister.sort(key=lambda x:x[0])
    miner = lister[n//2][0]
    lister.sort(key=lambda x:x[1])
    maxer = lister[n//2][1]
    print(maxer- miner)
else:
    lister.sort(key=lambda x:x[0])
    miner = lister[n//2][0]
    lister.sort(key=lambda x:x[1])
    maxer = lister[n//2][1]
    print(1 + (maxer- miner)*2)
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    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(int((B[n//2-1]+B[n//2])/2-(A[n//2-1]+A[n//2])/2)*2+1)

if __name__=='__main__':
    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:
  i = n // 2
  print(( B[ i ] + B[ i - 1 ] ) - ( A[ i ] - A [ i - 1 ] ) + 1 )
else:
  i = ( n + 1 ) // 2
  print( B[ i ] - A[ i ] + 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)


if n%2==0:
    half = int(n/2)
    first = (a_list[half]+a_list[half])/2
    last = (b_list[half]+b_list[half])/2
    print(int((last-first)/0.5)+1)
else:
    half = int((n+1)/2)
    print(b_list[half-1]-a_list[half-1]+1)
def main(N, lines):
    a = sorted(map(lambda line: line[0], lines))
    b = sorted(map(lambda line: line[1], lines))

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


N = int(input())
lines = []
for i in range(N):
    lines.append(list(map(int, input().split())))
main(N, lines)
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[-2]-A[1]+1)
else:
    print(B[-2]-A[1]+3)
import sys

N = int(input())

min = []
max = []

for i in range(N):
    A,B = list(map(int, input().split()))
    min.append(A)
    max.append(B)

min = sorted(min)
max = sorted(max)

if N % 2 == 0:
    min_m = min[N // 2]
    max_m = max[N // 2]
    ans = (max_m - min_m) * 2 + 1
else:
    min_m = min[N // 2]
    max_m = max[N // 2]
    ans = max_m - min_m + 1
print(ans)
import math


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


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:
    print(y - x + 1)
else:
    temp = math.ceil(y) - math.floor(x)
    print(2 * temp + 1)
n = int(input())
mn = []
mx = []
for _ in range(n):
    a,b = map(int,input().split())
    mn.append(a)
    mx.append(b)
if n % 2 != 0:
    m = (n-1)//2
    p,q = mn[m],mx[m]
    print(q-p+1)
else:
    m1,m2 = (n//2)-1,n//2
    p,q = mn[m1]+mn[m2],mx[m1]+mx[m2]
    print(q-p+1)
n=int(input())
ab,ba=[],[]
for i in range(n):
    a,b=map(int,input().split())
    ab.append([a,b])
ab.sort()
ans=0
if n%2==1:
    s=ab[n//2][0]
    g=ab[n//2][1]
    ans=g-s+1
else:
    s1,s2=ab[n//2-1][0],ab[n//2][0]
    g1,g2=ab[n//2-1][1],ab[n//2][1]
    ans=(g2+g1)-(s2+s1)+1
print(ans)
import statistics
N = int(input())
A = [list(map(int, input().split(" "))) for i in range(N)]
xMIN = []
xMAX = []


for i in range(N):
    xMIN.append(A[i][0])

for j in range(N):
    xMAX.append(A[j][1])


medianMIN = statistics.median(xMIN)
medianMAX = statistics.median(xMAX)

if N%2==0:
    print(int(medianMAX-medianMIN+2))
else:
    print(int(medianMAX-medianMIN+1))
from copy import deepcopy
N = int(input())
ABs = [list(map(int,input().split())) for i in range(N)]
ABs_desc = deepcopy(ABs)
ABs.sort() #Aでソート
ABs_desc.sort(key=lambda x: x[1])
if N%2:
    A1,B1 = ABs[N//2]
    A2,B2 = ABs_desc[N//2]
    if B1 < A2:
        print(B1-A1+1 + B2-A2+1)
    else:
        print(B2-A1+1)
else:
    A1,B1 = ABs[(N-1)//2]
    A2,B2 = ABs_desc[(N-1)//2]
    print(B1+B2-A1-A2+1)
N = int(input())
X = [tuple(map(int, input().split())) for _ in range(N)]
if N == 2:
    ans = sorted(X, key=lambda x: x[1], reverse=True)[0][1] - sorted(X, key=lambda x: x[0])[0][0] + 1
else:
    ans = sorted(X, key=lambda x: x[1], reverse=True)[1][1] - sorted(X, key=lambda x: x[0])[1][0] + 1
print(ans)
n=int(input())
import bisect as bi
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:
    a=A[(n-1)//2] ; b=B[(n-1)//2]
    print(a,b)
    print(b-a+1)
else:
    a=(A[n//2-1]+A[n//2])/2 ; b=(B[n//2-1]+B[n//2])/2
    print(a,b)
    print(int((b-a)/0.5)+1)
n=int(input())
a=[]
b=[]
for _ in range(n):
    tmp_a,tmp_b=map(int,input().split())
    a.append(tmp_a)
    b.append(tmp_b)

if n%2!=0:
    index=(n+1)//2-1
    print(b[index]-a[index]+1)
else:
    index_min=n//2-1
    index_max=n//2
    print(b[index_min]+b[index_max]-a[index_min]-a[index_max]+1)
N = int(input())
L = list()
for _ in range(N):
    A, B = map(int, input().split())
    L.append((A, B))
L = sorted(L, key=lambda x: x[0])

if N%2 == 1:
    W = L[N//2]
    print(W[1] - W[0] + 1)
else:
    W = L[N//2 - 1]
    V = L[N//2]
    ans = max(W[1] - W[0] + 1, V[1] - V[0] + 1)
    print(ans + 1)
N = int(input())
As = []
Bs = []

for _ in range(N):
  a,b = map(int,input().split())
  As.append(a)
  Bs.append(b)
  
As.sort()
Bs.sort()

if N%2 == 1:
  ma = As[N//2]
  mb = Bs[N//2]
  print(mb-ma+1)
else:
  ma = (As[N//2-1] + As[N//2])//2
  mb = (Bs[N//2-1] + Bs[N//2])//2
  print(int((mb-ma)*2)+1)
n=int(input())
a=[0]*n
b=[0]*n
for i in range(n):
    a[i],b[i]=map(int,input().split())
    

if n%2==1:
    a_m = a[n//2]
    b_m = b[n//2]
    ans=max(b_m-a_m+1,0)
    print(ans)
else:
    a_m = (a[n//2]+a[n//2-1])
    b_m = (b[n//2]+b[n//2-1])
    ans = max(b_m-a_m+1,0)
    print(ans)
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], reverse=True)
right = AB[n][1]

if N % 2 != 0:
    print(max(0, right - left + 1))
else:
    print(max(0, (right - left) * 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))
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:
    mid_l = [a[n//2-1], a[n//2]]
    mid_r = [b[n//2-1], b[n//2]]
    l = mid_l[0] + mid_r[0]
    r = mid_r[1] + mid_r[1]
    print(r - l)
else:
    mid_l = a[n//2]
    mid_r = b[n//2]
    print(mid_r - mid_l + 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])/2
    B_median = (B[N//2 - 1] + B[N//2])/2
    print(int(B_median - A_median)*2 + 1)
N = int(input())
start = list()
end = list()

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[int(N/2)] - start[int(N/2)] + 1)
else:
  print((end[int(N/2)] - start[int(N/2)-1])*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[0]][1] - ab[center[0]][0]+1
    answer = answer1*answer2
    
print(answer)
N = int(input())
A,B = [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)

m = int(((n * 2) - 2) / 2)

A.sort()
p = A[m - 1]
B.sort(reverse=True)
q = B[m-1]
# print(p, q)

print(q - p + 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(((maxs[n//2] - mins[(n//2) - 1] + 1) * (maxs[n//2] - mins[(n//2) - 1])) // 2)
def main(N, lines):
    a = sorted(map(lambda line: line[0], lines))
    b = sorted(map(lambda line: line[1], lines))

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


N = int(input())
lines = []
for i in range(N):
    lines.append(list(map(int, input().split())))
main(N, lines)
N=int(input())
A=[]
B=[]
for i in range(N):
  a,b=map(int,input().split())
  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 = []
for i in range(N):
    ab.append(tuple(map(int,input().split())))

up = sorted(ab,key=lambda a:a[0],reverse=True)
down = sorted(ab,key=lambda a:a[1],reverse=True)

if N%2 == 1:
    print(up[N//2][1]-down[N//2][0]+1)
else:
    r = (up[N//2-1][1]+up[N//2][1])
    l = (down[N//2-1][0]+down[N//2][0])
    print(r-l+1)
import math
n=int(input())
a=sorted([list(map(int,input().split())) for i in range(n)])
b=sorted(a,key=lambda x:x[1])
if n%2==1:
    print(b[n//2][1]-a[n//2][0]+1)
else:
    print(math.ceil((b[n//2-1][1]+b[n//2][1])/2-(a[n//2-1][0]-a[n//2][0])/2))
import sys

readline = sys.stdin.readline
N = int(readline())
A = []
B = []
for _ in range(N):
    a, b = map(int, readline().split())
    A.append(a)
    B.append(b)
A.sort()
B.sort()
if N % 2 == 0:
    mi = (A[N//2-1]+A[N//2])//2
    ma = (B[N//2-1]+B[N//2])//2
    ans = (ma-mi)*2+1
else:
    mi = A[N//2]
    ma = B[N//2]
    ans = (ma-mi)+1
print(ans)
def main():
    n = int(input())
    a = [None]*n
    b = [None]*n
    for i in range(n):
        a[i], b[i] = map(int, input().split())
    if n&1:
        print(b[n//2]-a[n//2]+1)
    else:
        print(b[n//2-1]+b[n//2]-a[n//2-1]-a[n//2]+1)
        

if __name__ == "__main__":
    main()
import bisect
n = int(input())
a = []
b = []

for i in range(n):
    m, p = map(int, input().split())
    a.append(m)
    b.append(p)
a.sort()
b.sort()
middle = n // 2
if n % 2:
    print(b[middle] - a[middle] + 1)
else: 
    a_m = ( a[middle] + a[middle - 1] ) // 2
    b_m = ( b[middle] + b[middle - 1] ) // 2
    print((b_m - a_m) * 2 + 1)
import sys

input = sys.stdin.readline


def 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()
    
    if N % 2 == 0:
        a = A[N // 2 - 1]
        b = B[N // 2]
        ans = 2 * (b - a) - 1
    else:
        a = A[N // 2]
        b = B[N // 2]
        ans = b - a + 1

    print(ans)


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


def main():
    N = int(input())
    A = [None] * N
    B = [None] * N
    for i in range(N):
        A[i], B[i] = map(int, input().split())
    min_median = median(A)
    max_median = median(B)
    if N % 2 == 1:
        print(max_median - min_median + 1)
    else:
        print(max_median, min_median)
        print(round((max_median-min_median)*2)+1)


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

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

if n%2 == 1:
    print(ab_b[n//2][1]-ab_a[n//2][0]+1)
else:
    print(int(((ab_b[n//2][1]+ab_b[n//2-1][1])/2.0-(ab_a[n//2][0]+ab_a[n//2-1][0])/2.0)*2+1))
def main():
    n = int(input())
    a, b = [], []
    for _ in range(n):
        A, B = map(int, input().split())
        a.append(A)
        b.append(B)
    from statistics import median
    import math
    i = int(median(a))
    j = math.ceil(median(b))
    if n % 2 == 1:
        print(j - i + 1)
    else:
        print((j - i) * 2-1)
main()
from sys import stdin
input = stdin.readline

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

ab.sort()

ran = []

for a, b in ab:
    ran.append(b - a + 1)

ran.sort()

if N % 2 == 0:
    a1, b1 = ab[N // 2 - 1]
    a2, b2 = ab[N // 2]
    xa = (a2 - a1) / 2
    xb = (b2 - b1) / 2
    print((xb - xa) * 2 - 1)
else:
    xa, xb = ab[N // 2]
    print(xb - xa + 1)
from heapq import heappush
n=int(input())
A=[]
B=[]
for i in range(n):
  a,b=map(int,input().split())
  heappush(A,a)
  heappush(B,b)
if n%2:
  c=(n+1)//2-1
  print(B[c]-A[c]+1)
else:
  c=n//2
  print(int(((B[c]+B[c-1])/2-(A[c]+A[c-1])/2)//0.5+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 = sum(A)
right = sum(B)
if N%2 == 0:
  print(right-left+1)
else: 
  print(statistics.median(B)-statistics.median(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()

a = (A[(N-1)//2] + A[N//2])//2
b = (B[(N-1)//2] + B[N//2])//2
print(b-a+1)
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((b - a) * 2 - 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_a = median(A)
m_b = median(B)
m = int(m_b - m_a)
for tmp in [m_a, m_b]:
    if type(tmp) is float:
        m += 1

if n%2 == 1:
    print(m + 1)
else:
    print(m)
from statistics import median
import numpy as np
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_arr = np.array(A_list)
B_arr = np.array(B_list)

sort_index = np.argsort(A_arr)
A = A_arr[sort_index]
B = B_arr[sort_index]
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/2

ans = median(L2) - median(L1) + 1
ans = int(ans//1)
if N%2==0:
    ans += 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 = sorted(A)
B = sorted(B)
num = int(n/2)

if n%2 == 0:
  A_c = (A[num]+A[num-1])/2
  B_c = (B[num]+B[num-1])/2
  print(int((A_c-B_c)*2+1))

else:
  A_c = A[num]
  B_c = B[num]
  print(B_c - A_c+1)
N = int(input())
A, B = [], []
for i in range(N):
    tm, p = map(int, input().split())
    A.append(tm), B.append(p)
A.sort(), B.sort()

a = A[N // 2] * 2 if N % 2 == 1 else A[N // 2 - 1] + A[N // 2]
b = B[N // 2] * 2 if N % 2 == 1 else B[N // 2 - 1] + B[N // 2]
print(b - a + 1 if N % 2 == 1 else 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)
if N%2==1:
    print(B[N//2]-A[N//2]+1)
else:
    A_chu=(A[N//2-1]+A[N//2])/2
    B_chu=(B[N//2-1]+B[N//2])/2
    ans=(B_chu-A_chu)*2+1
    print(int(ans))
n = int(input())
x = []
for i in range(n):
    x.append([int(each) for each in input().split()])

# print(x)
if n%2 == 1:
    line = x[(n-1)//2]
    print(line[1] - line[0] +1)
else:
    l1 = x[n//2-1]
    l2 = x[n//2]
    print((max(l1)+max(l2)) - (min(l1)+min(l2)) +1)
n=int(input())
for i in range(n):
  a,b=map(int,input().split())
print(134)