peterverebics/CodeNet_Python_118 huggingface dataset:
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:
    print(ran[N // 2] * 2 - 1)

else:
    print(ran[N // 2])
n=int(input())
AB=[list(map(int,input().split())) for _ in range(n)]

if n % 2 == 1:
  mid=(n+1)//2
  print(AB[mid-1][1]-AB[mid-1][0]+1)
else:
  mid=n//2
  print(AB[mid][1]+AB[mid-1][1]-AB[mid][0]-AB[mid-1][0]+1)
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(int((xb - xa) * 2 + 1))
else:
    xa, xb = ab[N // 2]
    print("hoge")
    print(xb - xa + 1)
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
    print(B[-id] - A[id-1] + 1)
from math import ceil, floor

N = int(input())

A, B = [], []
for i in range(N):
    _a, _b = [int(x) for x in input().split()]
    A.append(_a)
    B.append(_b)

A.sort()
B.sort()

min_mid, max_mid = 0, 0
if N % 2 != 0:
    mid = int((N-1)/2)
    min_mid, max_mid = A[mid], B[mid]
else:
    mid = int(N / 2)
    min_mid = floor((A[mid-1] + A[mid]) / 2)
    max_mid = ceil((B[mid-1] + B[mid]) / 2)

res = str(max_mid - min_mid + 1)
print(res)
N = int(input())

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

list = []

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

list.sort()


if(N%2 == 1):
    ans = list[N+1] - list[N-2] + 1

else:
    temp = list[N+1] - list[N-2] + 1
    ans = temp*(temp - 1)//2

print(ans)
from statistics import median

t=int(input())
n=t
low=list()
high=list()
while t!=0:
     t-=1
     L,H=list(map(int,input().split()))
     low.append(L)
     high.append(H)
diff=int(median(high)-median(low))
if n%2 == 0:
     ans=(diff*2)+1
     print(ans)
else:
     ans=diff+1
     print(ans)
N = int(input())
A = []
B = []

for i in range(N):
  hoge = input().split()
  A.append(int(hoge[0]))
  B.append(int(hoge[1]))

sorted_A = sorted(A)
sorted_B = sorted(B)

if N % 2 != 0:
  center_A = sorted_A[N//2]
  center_B = sorted_B[N//2]
  print(abs(center_B - center_A) + 1)
else:
  center_A = (sorted_A[N//2-1] + sorted_A[N//2]) //2
  center_B = (sorted_B[N//2-1] + sorted_B[N//2]) //2
  print(abs(center_B - center_A)*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]) / 2

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]) / 2

if n & 1:
    print(mid_max - mid_min + 1)
else:
    print(int(mid_max - mid_min) * 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)
  
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)
def median(array):
    L = len(array)
    if L%2==0:
        return (array[L//2-1]+array[L//2])/2
    else:
        return array[L//2]



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

if N%2==1:
    print(median(B) - median(A) + 1)
else:
    print(int((median(B) - median(A) +0.5)*2))
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 = y - x + 1
    print(int(y - x) + int(y - x + 1))
N = int(input())
A = []
B = []
for i in range (0,N):
	a, b = map(int, input().split())
	A.append(a)
	B.append(b)
    
A = sorted(A)
B = sorted(B)

if N%2 ==1:
	print(B[int((N+1)/2)-1]-A[int((N+1)/2)-1]+1)
else:
	print(B[int(N/2)]+A[int(N/2)]-B[int(N/2)-1]-A[int(N/2)-1]+1)
n=int(input())
a=[]
b=[]
for _ in range(n):
  A,B=map(int,input().split())
  a.append(A)
  b.append(B)
q=sorted(a)
w=sorted(b)
w=list(reversed(w))
p=n//2
if n%2==1:
  e=q[p]
  r=w[p]
  t=r-e+1
else:
  e=q[p-1]
  r=w[p-1]
  t=r-e
  print(2*t-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])
down = sorted(ab,key=lambda a:a[1])
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 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(reverse=True)
right = AB[n][1]

print(right - left + 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])
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 sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    N,*ab = map(int, read().split())

    AB = []
    for a, b in zip(*[iter(ab)]*2):
        AB.append((a, b))

    AB.sort()
    a, _ = AB[N // 2]
    
    AB.sort(key=lambda x: x[1])
    _, b = AB[N // 2]

    if N % 2 == 0:
        ans = (b - a + 1) * 2 - 1
    else:
        ans = b - a + 1
    
    print(ans)


if __name__ == "__main__":
    main()
n=int(input())
AB=[]
A=[]
B=[]
for _ in range(n):
    a,b = map(int,input().split())
    AB.append((a,b))
    A.append(a)
    B.append(b)
#AB = sorted(AB,key=lambda x: x[1])
med = n//2
if n%2 != 0:
    print(B[n//2]-A[n//2]+1)
else:
    p = (A[n//2] + A[n//2-1])/2
    q = (B[n//2] + B[n//2-1])/2
    print(int((q-p)*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(reverse=True)
mid1 = A[(N + 1) // 2 - 1]
mid2 = B[(N + 1) // 2 - 1]

if N % 2 == 1:
    print(mid2 - mid1 + 1)
else:
    print((mid2 - mid1) * 2 - 1)
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(xa, xb)
    print(int((xb - xa) * 2 + 1))
else:
    xa, xb = ab[N // 2]
    print(xb - xa + 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&1:
    print(b[n//2]-a[n//2]+1)
else:
    print(1+(b[n//2]+a[n//2])-(b[(n-1)//2]+a[(n-1)//2]))
N = int(input())
A = []
B = []
for n in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)
#AB = sorted(AB, key=lambda x: x[0])
#print(AB)
A.sort()
B.sort()

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

elif N % 2 == 0:
    print(int((B[N//2] - A[N//2])/(1/2) + 1))
    
else:
    print('RE')
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 + 1)
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 statistics

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

if N % 2 == 0:
    print(2 * round(Bm - Am) + 1)
else:
    print(Bm - Am + 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(int((b[n//2-1][1]+b[n//2][1])/2-(a[n//2-1][0]-a[n//2][0])/2))
import statistics
n=int(input())
r=set([])
x=[[]]*n
for i in range(n):
  a,b=list(map(int,input().split()))
  x[i]=[a,b]
r0=statistics.median([x[z][0] for z in range(n)])
r1=statistics.median([x[z][1] for z in range(n)])
if ((r0*2) % 2)>0 or ((r1*2) % 2)>0:
  mult=2
else:
  mult=1
mult=int((r1-r0)+mult)
print(mult)
n = int(input())
X=[]
X1=[]
for i in range(n):
    a,b = map(int, input().split())
    X.append(a)
    X1.append(b)
X.sort()
X1.sort(reverse=True)
if n % 2: 
    print(X1[n//2] - X[n//2] + 1)
else: 
    print((X1[n//2]+X1[n//2-1]) - (X[n//2]+X1[n//2-1]) + 1)
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(max(0,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+=[a]
  B+=[b]
A.sort()
B.sort()
if N%2==1:
  ans=B[N//2]-A[N//2]+1
else:
  ans=(B[N//2]-A[N//2])*2+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 = 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())
numbers = []
for _ in range(N):
    a, b = map(int, input().split())
    numbers.append(b-a+1)
numbers.sort()  # 左を昇順ソート


if N % 2 == 1:
    print(numbers[N%2])
else:
    print(numbers[N%2] + numbers[N%2]-numbers[N%2-1] + 1)
n = int(input())
a = []
b = []
for i in range(n):
    x,y = map(int, input().split())
    a.append(x)
    b.append(y)
a.sort()
b.sort()
if n%2:
    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=[0]*n
b=[0]*n
for i in range(n):
  a[i],b[i] = map(int,input().split())
m = n-1
if n % 2 == 0:
  a_c = int((a[int(m/2)]+a[int(m/2)+1])/2)
  b_c = int((b[int(m/2)]+b[int(m/2)+1])/2)
  print(int((b_c-a_c)*2)+1)
else:
  a_c = a[int((m+1)/2)]
  b_c = b[int((m+1)/2)]
  print(b_c-a_c+1)
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()

print(int(statistics.median(b)+0.5)- int(statistics.median(a)) + 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)
n = int(input())
AB = [tuple(map(int, input().split())) for i in range(n)]
X = sorted(AB, key=lambda x: x[0])
Y = sorted(AB, key=lambda x: x[1])
if n % 2 == 0:
    print((Y[n // 2][1] - X[n // 2 - 1][0] - 1) * 2 + 1)
else:
    print(Y[n // 2][1] - X[n // 2][0] + 1)
N = int(input())

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

left = sorted(left)
right = sorted(right)

i = 0
while True:
    l = left[i]
    r = right[-1-i]
    if l>r:
        break
    i += 1
    if (i+1)==N:
        break

print(r-l+1)
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:
    print(int(int(b_med-a_med)/0.5+1))
else:
    print(int(b_med-a_med+1))
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(int((xb - xa) * 2 + 1))
else:
    xa, xb = ab[N // 2]
    print(xb - xa + 1)
#!/usr/bin/env python3


def main():
    N = int(input())
    A = [None] * N
    B = [None] * 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-1)//2] - A[(N-1)//2] + 1)
    else:
        print(B[N//2]+A[N//2] - B[N//2-1] - A[N//2-1] + 1)
    

if __name__ == "__main__":
    main()
import math
import statistics
N = int(input())
# a_min = 10**10
# a_max = -1
# b_min = 10**10
# b_max = -1
A = []
B = []
for _ in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)
    # a_min = min(a, a_min)
    # a_max = max(a, a_max)
    # b_min = min(b, b_min)
    # b_max = max(b, b_max)

# print([a_min, a_max], [b_min, b_max])
a_median = statistics.median(A)
b_median = statistics.median(B)
print(math.ceil(b_median) - int(a_median)+1)
n = int(input())

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

al = []
bl = []

for a,b in abl:
    al.append(a)
    bl.append(b)

if n % 2 == 0:
    min_a = (al[n//2-1] + al[n//2]) / 2
    max_a = (bl[n//2-1] + bl[n//2]) / 2
else:
    min_a = al[(n-1)//2]
    max_a = bl[(n-1)//2]

if n % 2 == 0:
    print(int(max_a - min_a) * 2 + 1)
else:
    print(max_a - min_a + 1)
n = int(input())
al = []
bl = []
for _ in range(n):
  a, b = map(int, input().split())
  al.append(a)
  bl.append(b)

if n % 2 == 0:
  a_mid = al[n//2-1]
  b_mid = bl[n//2]
  print((b_mid - a_mid) * 2 - 1)  
else:
  a_mid = al[(n+1)//2-1]
  b_mid = bl[(n+1)//2-1]
  print(b_mid - a_mid + 1)
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:
  i1 = n // 2 - 1
  i2 = n // 2
  print( (( B[ i2 ] + A[ i2 ] ) - ( B[ i1 ] + A[ i1 ] )) // 2 + 1 )
else:
  i = ( n + 1 ) // 2 - 1
  print( B[ i ] - A[ i ] + 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)

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)
N = int(input())
List = []

A = []
B = []

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

if N%2 == 1:
  A.sort()
  B.sort()
  ans = B[N//2] - A[N//2] + 1
  print(int(ans))
else:
  A.sort()
  B.sort()
  c = B[N//2] - A[N//2] + 1
  d = B[N//2-1] - A[N//2-1] + 1
  print(int(c+d-min(c,d)+1))
n = int(input())
a = []
b = []
for i in range(n):
   ai,bi = [int(j) for j in input().split()]
   a.append(ai)
   b.append(bi)
a.sort()
b.sort()
if n == 1:
   ans = b[0] - a[0] + 1
elif n % 2 == 1:
   tg = (n+1) // 2
   ans = b[-tg] + a[tg-1] + 1
else:
   tg = n//2
   ans = b[-tg] + b[-tg-1] - a[tg-1] - a[tg] +1
print(ans)
n = int(input())
info = [list(map(int, input().split())) for i in range(n)]

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

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

    length = sorted(length, reverse=True)
    print(length[0] + length[1] - 1)
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 = m_b - m_a
if n%2 == 0:
    m += 2
else:
    m += 1

print(int(m))
N = int(input())
AB = [list(map(int, input().split())) for i in range(N)]
AB.sort()

if N % 2 == 1:
  n = N // 2
  a, b = AB[n]
  print(b - a + 1)
else:
  n = N // 2
  a0, b0 = AB[n-1]
  a1, b1 = AB[n]
  left = a0 + a1; right = b0 + b1
  print(right - left + 1)
import numpy as np
import math
import collections
import bisect
from decimal import *


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


A.sort()
B.sort()
if N % 2 == 1:
    print(B[(N - 1) // 2] - A[(N - 1) // 2] + 1)
else:
    print(B[(N - 1) // 2] - A[(N - 1) // 2])
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()
from statistics import median
Am = median(A)
Bm = median(B)
if N%2==1:
    ans = Bm-Am+1
else:
    ans = int(Bm-Am)*2+1
n = int(input())
ab = [tuple(map(int, input().split())) for _ in range(n)]
a, b = map(list, zip(*ab))
a.sort()
b.sort(reverse=True)
a1, b1 = a[n//2], b[n//2]
a2, b2 = a[n//2-1], b[n//2-1]
ans = b1 - a1 + 1
if n % 2 == 0:
    ans += int((b1+b2)/2 - (a1+a2)/2 + 1)
    if a1 == a2 and b1 == b2: ans -= 1

print(ans)
n = int(input())
ab = []
for _ in range(n):
    a, b = map(int, input().split())
    ab.append((a, b))
ab1 = sorted(ab, key=lambda x:x[0])
ab2 = sorted(ab, key=lambda x:-x[1])
if n%2==1:
    print(ab2[n//2][1]-ab1[n//2][0]+1)
else:
    rmax = 0
    lmin = 10**9
    for i in range(n//2):
        rmax = max(rmax, ab1[i][1])
        lmin = min(lmin, ab2[i][0])
    print(ab2[n//2-1][1]+rmax-ab1[n//2-1][0]-lmin+1)
N=int(input())
P = [list(map(int,input().split())) for i in range(N)]
Q=[]
R=[]

for i in range(N):
    Q.append(P[i][1])
    R.append(P[i][0])

Q.sort()
R.sort()

if N%2==1:
    print(int(int(Q[-2])-int(R[1]))+1)
else:
    print(int(((((int(Q[-1])-int(Q[-2]))/2)-((int(R[0])-int(R[1]))/2))*2)+1))
from sys import stdin
from decimal import Decimal
N = int(stdin.readline().rstrip())
A = []
B = []
for i in range(N):
    a,b = [int(x) for x in stdin.readline().rstrip().split()]
    A.append(a)
    B.append(b)
    
A.sort()
B.sort()
if N % 2 == 0:
    ans = Decimal(sum(A))/Decimal(N) - Decimal(sum(B))/Decimal(N)
    ans /= Decimal(0.5)
    print(int(ans))
else:
    ans = B[N//2] - A[N//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)
a=sorted(a)
b=sorted(b)
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)
N=int(input())

alist,blist=[],[]
for _ in range(N):
  a,b=map(int,input().split())
  alist.append(a)
  blist.append(b)
alist.sort()
blist.sort()
#print(ablist,alist,blist)

if N%2==1:
  left=alist[N//2]
  right=blist[-N//2]
  #print(left,right)
  print(right-left+1)
else:
  left1=alist[N//2-1]
  left2=alist[N//2]
  right1=blist[-N//2+1]
  right2=blist[-N//2]
  #print(left,right)
  print(right1+right2-left1-left2+1)
n = int(input())
l = []
for _ in range(n):
    a,b = map(int,input().split())
    l.append(a)
    l.append(b)
l2 = sorted(list(set(l)))
length = len(l2)
if length == 1:
  print(l2[0])
  exit()
if length%2==0:
  print(l2[length//2]-l2[length//2-1]+1)
  exit()
print(l2[length//2 + 1] - l2[length//2 - 1] + 1)
def main():
    n = int(input())
    t = [[int(t)for t in input().split()]for _ in [0]*n]

    t_1 = sorted(t,key=lambda a: a[0])
    t_2 = sorted(t,key=lambda b:b[1],reverse=True)

    if n%2==1:
        ans = t_2[n//2][1]-t_1[n//2][0]+1
        print(ans)
    else:
        b = t_2[n//2]
        a = t_1[n//2]

        ans = a[1]-a[0]+b[1]-b[0] + 1
        print(ans)







if __name__ == "__main__":
    main()
N = int(input())
A = []
B = []
ans = 0
min_a = 10**10
max_b = 0
for _ in range(N):
    a, b = map(int, input().split())
    min_a = min(a, min_a)
    max_b = max(b, max_b)
    A.append(a)
    B.append(b)

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

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

else:
    A.sort()
    B.sort()
    ans = B[N//2] - A[N//2 - 1]
    ans *= 2
    ans -= 1
print(ans)
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:
  x=A[N//2-1]
  y=B[N//2]
else:
  x=A[N//2]
  y=B[N//2]
print(y-x+1)
# E
N = int(input())
AandB = [list(map(int, input().split())) for _ in range(N)]
A = [AandB[i][0] for i in range(N)]
B = [AandB[i][1] for i in range(N)]

A_sorted = sorted(A)
B_sorted = sorted(B)

if N % 2 != 0:
    n = N // 2
    a = A_sorted[n]
    b = B_sorted[-(n+1)]
    print(b-a+1)
else:
    n = N // 2
    a = A_sorted[n-1]
    b = B_sorted[-n]
N=int(input())
L=[]
for i in range(N):
    A, B=list(map(int,input().split()))
    L.append((A,B))
L1=sorted(L,key=lambda x: x[0])
L2=sorted(L,key=lambda x: x[1])
if N%2==1:
    n=N//2
    print(min(L2[n][1],L1[n][1]) -L1[n][0]+1)
else:
    n=N//2
    m=(L1[n-1][1]+L1[n][1])/2
    print(min(L2[n-1][1]+L2[n][1],L1[n-1][1]+L1[n][1])-L1[n-1][0]-L1[n][0]+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:
    ans = B[N//2] - A[N//2]+1
    print(ans)
else:
    ans = B[N//2] - A[N//2]+2
    print(ans)
N = int(input())
l = []
for _ in range(N):
    A, B = map(int, input().split())
    l.append((A, B))

t = N//2
tl = sorted(l)
tr = sorted(l, key=lambda x:-x[1])

if N%2:
    print(tr[t][1]-tl[t][0]+1)
else:
    a1, a2 = tl[t][0], tr[t][1]
    a3, a4 = tl[t-1][0], tr[t-1][1]
    print((a2-a1+1)*(a4-a3+1))
n = int(input())
ab = sorted([list(map(int,input().split())) for i in range(n)])
ab_b = sorted(ab,key=lambda x:x[1])
if n==2:
    x1 = ab_b[-1][1]+ab[0][1]/2
    x2 = ab_b[-1][0]+ab[0][0]/2
    ans = int((x1-x2)*2)
elif n%2==1:
    ans = ab_b[-2][1]-ab[1][0]+1
else:
    x1 = ab_b[-2][1]+ab[1][1]/2
    x2 = ab_b[-2][0]+ab[1][0]/2
    ans = int((x1-x2)*2)
print(ans)
# Count median
N=int(input())
m=[]
M=[]
for i in range(N):
    x,y=map(int,input().split())
    m.append(x)
    M.append(y)
m.sort()
M.sort(reverse=True)

if N%2!=0:
    mini=m[N//2]
    maxi=M[-N//2]
    print(maxi-mini+1)
else:
    mini=m[N//2-1]
    maxi=M[-N//2-1]
    if maxi>=mini:
        print((maxi-mini)*2+1)
    else:
        print(0)
from sys import stdin, setrecursionlimit


def main():
    input = stdin.buffer.readline
    n = int(input())
    ab = [list(map(int, input().split())) for _ in range(n)]
    if n % 2 != 0:
        a, b = ab[n // 2]
        print(b - a + 1)
    else:
        a1, b1 = ab[(n - 1) // 2]
        a2, b2 = ab[(n + 1) // 2]
        print(b1 + b2 - a1 - a2 + 1)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()
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])
 
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


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 = math.floor((a[N // 2 - 1] + a[N // 2]) / 2)
        ma = math.ceil((b[N // 2 - 1] + b[N // 2]) / 2)
        print(a, b, mi, ma)
        print(int(ma - mi + 1))


N = int(input())
lines = []
for i in range(N):
    lines.append(list(map(int, input().split())))
main(N, lines)
from sys import stdin, setrecursionlimit


def main():
    input = stdin.buffer.readline
    n = int(input())
    ab = [list(map(int, input().split())) for _ in range(n)]
    if n % 2 != 0:
        a, b = ab[n // 2]
        print(b - a + 1)
    else:
        a1, b1 = ab[(n - 1) // 2]
        a2, b2 = ab[(n + 1) // 2]
        print(b1 + b2 - a1 - a2)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()