peterverebics/CodeNet_Python_118 huggingface dataset:
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)
#print(A,B)
if N % 2 == 1:
    x = (N+1) // 2
    ans = B[x-1] - A[x-1] + 1
else:
    x = N // 2
    ans = (B[x-1] + B[x]) - (A[x] + A[x-1]) + 1
print(ans)
n = int(input())
a = [0] * n
b = [0] * n
for i in range(n):
    a[i], b[i] = [int(j) for j in 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 median(q):
    l=len(q)
    q=sorted(q,reverse=True)
    if l%2==0:
        return (q[int(l/2)]+q[int(l/2)-1])/2
    else:
        return q[int((l+1)/2-1)]

n=int(input())

a=[]
b=[]

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

if n%2==0:
    print(int(2*(med_b-med_a)+1))
    
else:
    print((med_b-med_a)+1)
#!/usr/bin/env python
import sys
sys.setrecursionlimit(10**9)
from collections import deque,defaultdict
import heapq
from itertools import combinations
import bisect

n=int(input())
l=[]
p=[]
q=[]
for i in range(n):
    a,b=map(int,input().split())
    l.append([2*a,2*b])
    p.append(2*a)
    q.append(2*b)
p.sort()
q.sort()
if n%2==0:
    al=(p[n//2]+p[n//2-1])//2
    ar=(q[n//2]+q[n//2-1])//2
else:
    al=p[n//2]//2
    ar=q[n//2]//2
print(ar-al+1)
n = int(input())
ab = [list(map(int, input().split())) for _ in range(n)]

a, b = map(list, zip(*ab))
a.sort()
b.sort()

if n % 2:
    i = (n + 1) // 2 - 1
    mn = a[i]
    mx = b[i]

else:
    i1, i2 = n // 2 - 1, n // 2
    mn = a[i1] + a[i2]
    mx = b[i1] + b[i2]

ans = mx - mn + 1
print(ans)
n = int(input())
a = [0] * n
b = [0] * n
for i in range(n):
    atmp,btmp = (int(num) for num in input().split())
    a[i] = atmp
    b[i] = btmp
    
a.sort()
b.sort()
minval = 0
maxval = 0
ans = 0
if n % 2 == 0:
    minval = (a[n//2-1] + a[n//2]) / 2
    maxval = (b[n//2-1] + b[n//2]) / 2
    ans = int((maxval - minval) * 2 + 0.00001) + 1
else:
    minval = a[n//2]
    maxval = b[n//2]
    ans = maxval - minval + 1
    
print(ans)
n=int(input())
a=[]
b=[]
for i in range(n):
  c,d=map(int,input().split())
  a.append(c)
  b.append(d)
a=sorted(a)
b=sorted(b)
if n%2==0:
  x=(a[n//2-1]+a[n//2])
  y=(b[n//2-1]+b[n//2])
  print(y-x+1)
else:
  print(b[n//2]-a[n//2]+1)
import sys
input = lambda:sys.stdin.readline().strip()
n = int(input())
a = [0]
b = [0]
for i in range(n):
    ai,bi = map(int,input().split())
    a.append(ai)
    b.append(bi)
a.sort()
b.sort()
if n&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())
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:
    ma = A[N//2]
    mb = B[N//2]
    print(max(0, mb - ma + 1))
else:
    ma = A[N//2] + A[N//2-1]
    mb = B[N//2] + B[N//2-1]
    print(max(0, mb - ma + 1))
from statistics import median

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

a = [ab[i][0] for i in range(n)]
b = [ab[i][1] for i in range(n)]

if n % 2 == 0:
    ma, mb = median(a), median(b)
    print(int(2 * mb - 2 * ma + 1))
if n % 2 == 1:
    ma, mb = median(a), median(b)
    print(int(mb - ma + 1))
from operator import itemgetter, attrgetter
N, *A = map(int, open(0).read().split())
*A, = zip(*[iter(A)]*2)

if N % 2 == 0:
    A.sort()
    mid_l = A[N//2-1][0]+A[N//2][0]
    A.sort(key=itemgetter(1))
    mid_r = A[N//2-1][1]+A[N//2][1]
    print(mid_r - mid_l+1)
else:
    A.sort()
    mid_l = A[N//2][0]
    A.sort(key=itemgetter(1))

    mid_r = A[N//2][1]
    print(mid_r - mid_l+1)
import statistics
N = int(input())
AB = [map(int, input().split()) for _ in range(N)]
A,B = [list(i) for i in zip(*AB)]
if N%2 == 1:
    low_med = statistics.median(A)
    high_med = statistics.median(B)
    print(high_med - low_med +1)
else:
    low_med = statistics.median(A)
    high_med = statistics.median(B)
    print(int(2 * (high_med - low_med) +1))
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
#  print(ts,te)
  ans=(te-ts)//0.5+1


print(int(ans))
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(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())
A = [[] for _ in range(N)]
B = [[] for _ in range(N)]
for i in range(N):
    A[i], B[i] = map(int, input().split())

A.sort()
B.sort()
if N%2 == 1:
    m_min = A[N//2]
    m_max = B[N//2]
    diff = m_max - m_min
    print(diff +1)
else:
    m_min = (A[N//2-1] +A[N//2])/2
    m_max = (B[N//2-1] +B[N//2])/2
    diff = m_max - m_min
    print(int(diff//0.5)+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:
    am = A[N//2]
    bm = B[N//2]

    print (bm-am+1)

else:
    am = (A[N//2] + A[N//2-1])/2
    bm = (B[N//2] + B[N//2-1])/2

    print ( int((bm-am)/0.5) + 1)
N = int(input())
AB = []
for i 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==0:
    A1 = A[N//2-1]
    A2 = A[N//2]
    B1 = B[N//2-1]
    B2 = B[N//2]
    print((B1+B2)-(A1+A2)+1)
else:
    A1 = A[N//2]
    B1 = B[N//2]
    print((B1-A1)+1)
N = int(input())
L, H = [0] * N, [0] * N

for i in range(N):
    L[i], H[i] = list(map(int, input().split()))

L.sort()
H.sort(reverse=True)
if N%2 == 1:
    i = (N-1)//2
    l, h = L[i], H[i]
    print(h-l+1)
else:
    i = N//2
    ll, lh = L[i-1], L[i]
    hl, hh = H[i-1], H[i]
    print((hh+hl) - (lh+ll) + 1)
from operator import itemgetter

n = int(input())
info = [list(map(int, input().split())) for i in range(n)]
a = [info[i][0] for i in range(n)]
b = [info[i][1] for i in range(n)]

a = sorted(a)
b = sorted(b)
if n % 2 == 1:
    l = a[n // 2]
    r = b[n // 2]
    print(r - l + 1)
else:
    l1, l2 = a[n // 2 - 1], a[n // 2]
    r1, r2 = b[n // 2 - 1], b[n // 2]
    print((r1 + r2) - (l1 + l2) + 1)
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(c+d-1)
n=int(input())
alist=[]
blist=[]
for i in range(n):
    a, b = map(int,input().split())
    alist.append(a)
    blist.append(b)

alist=sorted(alist)
blist=sorted(blist)

if n%2==1:
    center=(n-1)//2
    answer=blist[center]-alist[center]+1
    print(answer)
else:
    #print(alist, blist)
    mae=(alist[(n//2)-1]+alist[(n//2)])/2
    ato=(blist[(n//2)-1]+blist[(n//2)])/2
    #print(mae, ato)
    print(int((ato-mae)*2+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()
ans = 0
if n % 2 == 1:
    ans = B[n // 2] - A[n // 2] + 1
else:
    large = B[n // 2] + B[n // 2 - 1]
    small = A[n // 2] + A[n // 2 - 1]
    ans = large - small + 1

print(ans)
n = int(input())
list_a = []
list_b = []
for i in range(n):
    a,b = (int(x) for x in input().split())
    list_a.append(a)
    list_b.append(b)
list_a.sort()
list_b.sort()

if n%2==0:
    mi = (list_a[int(n/2)]+list_a[int(n/2)-1])/2
    ma = (list_b[int(n/2)]+list_b[int(n/2)-1])/2
    print(int((ma-mi)*2+1))
else:
    mi = list_a[int((n-1)/2)]
    ma = list_b[int((n-1)/2)]
    print(int(ma-mi+1))
n = int(input())
al = [0] * n
bl = [0] * n
for i in range(n):
    al[i], bl[i] = map(int, input().split())

al.sort()
bl.sort(reverse=True)

if n % 2 == 0:
    print((bl[n//2-1] - al[n//2-1])+((bl[n//2] - al[n//2])+1))
else:
    print(bl[n//2] - al[n//2]+1)
def Z(): return int(input())
def ZZ(): return [int(_) for _ in input().split()]

def main():
    N = Z()
    A, B = [], []
    for _ in range(N):
        a, b = ZZ()
        A.append(a)
        B.append(b)
    A.sort()
    B.sort()
    midA = A[N//2] if N%2 == 1 else (A[N//2-1] + A[N//2])
    midB = B[N//2] if N%2 == 1 else (B[N//2-1] + B[N//2])
    print(midB-midA+1)

    return

if __name__ == '__main__':
    main()
N = int(input())
L = list()
As, Bs= list(),list()
for i in range(N):
    A,B = map(int,input().split())
    L.append([A,B])
    As.append(A)
    Bs.append(B)

As.sort()
Bs.sort()
if N % 2 == 0:
    mins = (As[N//2] + As[N//2-1]) / 2.0
    maxs = (Bs[N//2] + Bs[N//2-1]) / 2.0
    print(int((maxs-mins)/0.5)+1)
else:
    mins,maxs = As[N//2], Bs[N//2]

    print(int(maxs-mins)+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()
if n % 2 == 1:
    print(b[n//2] - a[n//2] + 1)
else:
    front = n//2
    back = (n-1)//2
    print((b[front] + b[back] - (a[front] + a[back]) + 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:
    sca=scb=N//2-1
    lca=lcb=N//2
    x=A[lca]+A[sca]
    y=B[lcb]+B[scb]
    print(y-x+1)
    
    
else:
    ca=cb=N//2
    ans=B[cb]-A[ca]+1
    print(ans)
n=int(input())

minl=[]
maxl=[]
for i in range(n):
  k=input().split()
  minl.append(int(k[0]))
  maxl.append(int(k[1]))
  
minl.sort()
maxl.sort()

if n%2==1:
  c=int((n+1)/2)-1
  re=maxl[c]-minl[c]+1
else:
  c2=int(n/2)
  c1=c2-1
  re=(maxl[c1]+maxl[c2])-(minl[c1]+minl[c2])+1
  
print(re)
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n = int(readline())
aa = []
bb = []
for _ in range(n):
    a, b = map(int, readline().split())
    aa.append(a)
    bb.append(b)
aa.sort()
bb.sort()
if n % 2 == 1:
    print(bb[n // 2] - aa[n // 2] + 1)
else:
    print(bb[n // 2] + bb[n // 2 - 1] - aa[n // 2] - aa[n // 2 - 1] + 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
    print(B[n] + B[n - 1] - A[n] - A[n - 1] + 1)
else:
    n = N // 2
    print((B[n] - A[n] + 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()

ans = 0

if n % 2 == 1:
    l1 = A[int(n/2)]
    r1 = B[int(n/2)]
    ans = r1 - l1 + 1
else:
    l2 = A[int(n/2)-1] + A[int((n/2))]
    r2 = B[int(n/2)-1] + B[int((n/2))]
    ans = r2 - l2 + 1

print(ans)
import sys
import math

N = int(sys.stdin.readline().strip())
ABlist = []
for _ in range(N):
    a, b = map(int, sys.stdin.readline().strip().split())
    ABlist.append((a, b))

Asorted = sorted(ABlist)
Bsorted = sorted(ABlist, key=lambda x: x[1])
if N % 2 == 1:
    left = Asorted[N//2][0]
    right = Bsorted[N//2][1]
    # print(left, right)
    print(right - left + 1)
else:
    left = (Asorted[N//2 - 1][0] + Asorted[N//2][0]) / 2
    right = (Bsorted[N//2 - 1][1] + Bsorted[N//2][1]) / 2
    print(int((right - left) * 2 + 1))
import statistics
import math

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:
    ans = statistics.median(b) - statistics.median(a) + 1
else:
    ans = (statistics.median(b) - statistics.median(a))*2 + 1
print(int(ans))
N=int(input())

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

if N%2==1:
    print(M[N//2]-m[N//2]+1)
else:
    M1=(M[N//2-1]+M[N//2])/2
    m1=(m[N//2-1]+m[N//2])/2
    print(int((M1-m1)*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:
    l = A[N // 2]
    r = B[N // 2]
    print(r - l + 1)
else:
    l2 = A[N // 2 - 1] + A[N // 2]
    r2 = B[N // 2 - 1] + B[N // 2]
    print(r2 - l2 + 1)
n=int(input())
alist=[]
blist=[]
for i in range(n):
    a,b=map(int,input().split())
    alist.append(a)
    blist.append(b)
alist.sort()
blist.sort()
if n%2==1:
    num1=-1*(n//-2)-1
    print(blist[num1]-alist[num1]+1)
else:
    num1=n//2-1
    num2=num1+1
    print((blist[num2]+blist[num1])-(alist[num2]+alist[num1])+1)
N = int(input())
AB = [list(map(int,input().split())) for _ in [0]*N]

c = [0]*N
d = [0]*N
for i,ab in enumerate(AB):
    a,b = ab
    c[i] = a
    d[i] = b
c.sort()
d.sort(reverse=True)

if N%2:
    L = c[N//2]
    R = d[N//2]
    print(R-L+1)
else:
    L1 = c[N//2-1]
    R1 = d[N//2]
    L2 = c[N//2]
    R2 = d[N//2-1]
    print((R1+R2)-(L1+L2)+1)
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = int(input())
As = []
Bs = []
for _ in range(N):
    A, B = mapint()
    As.append(A)
    Bs.append(B)
As.sort()
Bs.sort()

if N%2==1:
    left = As[N//2]
    right = Bs[N//2]
else:
    left = (As[N//2]+As[N//2-1])
    right = (Bs[N//2]+Bs[N//2-1])

print(right-left+1)
from math import *
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)
A.sort();B.sort()
if N%2:
    ans=median(B)-median(A)+1
else:
    ans=(median(B)-median(A))*2+1
print(int(ans))
#!/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()
n = int(input())
a = []
b = []

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

a.sort()
b.sort()

if n%2 == 1:
    p = a[n//2]
    q = b[n//2]
    ans = q - p + 1

else:
    p1 = a[n//2 -1]
    p2 = a[n//2]
    q1 = b[n//2]
    q2 = b[n//2 - 1]
    p = (p1+p2)*5
    q = (q1+q2)*5 
    ans = (q-p)//5 + 1

print(ans)
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 == 0:
    leftA, leftB = As[N // 2 - 1], Bs[N // 2 - 1]
    rightA, rightB = As[N // 2], Bs[N // 2]
    minM = leftA + rightA
    maxM = leftB + rightB
    print(maxM-minM+1)
else:
    midA, midB = As[N // 2], Bs[N // 2]
    print(midB-midA+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:
  M = B[n//2 - 1] + B[n//2]
  m = A[n//2 - 1] + A[n//2]
  ans = M-m+1
  print(ans)
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(reverse=True)
if n%2 == 1:
    ans = B[(n+1)//2-1]-A[(n+1)//2-1]+1
    print(ans)
else:
    y = A[n//2-1] + A[n//2]
    x = B[n//2-1] + B[n//2]
    ans = x-y+1
    print(ans)
from numpy import*
(n,),*d=[[*map(int,i.split())]for i in open(0)]
a,b=median(d,0)
print(int((b-a)*(2-n%2))+1)
N = int(input())
AB = [list(map(int,input().split())) for _ in range(N)]

A = [i[0] for i in AB]
B = [i[1] for i in AB]
from statistics import median

a_med = median(A)
b_med = median(B)

if N%2==1:
  print(b_med - a_med + 1)
  
else:
  print(int((b_med - a_med) * 2) + 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)

from statistics import median

if N%2 ==1:
	print(median(B)-median(A)+1)
else:
	print(int((median(B)-median(A))*2+1))
# -*- coding: utf-8 -*-
import sys

N, *AB = map(int, sys.stdin.buffer.read().split())

A = sorted(AB[::2])
B = sorted(AB[1::2])

center = N//2

if N%2==1:
  print(B[center]-A[center]+1)
else:
  print((B[center]+B[center-1])-(A[center]+A[center-1])+1)
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]) / 2
    max_med = (max_s[n // 2 - 1] + max_s[n // 2]) / 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())
ls = [list(map(int, input().split())) for i in range(n)]
ls1=list()
ls2=list()
for i in range(n):
    ls1.append(ls[i][0])
    ls2.append(ls[i][1])
ls1.sort()
ls2.sort()

if n%2:
    print(ls2[n//2]-ls1[n//2]+1)
else:
    a=ls2[n//2-1]+ls2[n//2]
    b=ls1[n//2-1]+ls1[n//2]
    print(a-b+1)
import sys
def input():
    return sys.stdin.readline()[:-1]
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:
    print(B[N//2]-A[N//2]+1)
else:
    a=A[N//2-1]+A[N//2]
    b=B[N//2-1]+B[N//2]
    print(b-a+1)
n, *AB = map(int, open(0).read().split())
A, B = map(sorted, [AB[::2], AB[1::2]])
mid = n//2
a = A[mid]
b = B[mid]
if n % 2 == 0:
    a += A[mid-1]
    b += B[mid-1]
print(b-a+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()

if N % 2 == 1:
    mid_a = A[(N + 1) // 2 - 1]
    mid_b = B[(N + 1) // 2 - 1]
    print(mid_b - mid_a + 1)
else:
    mid_a = (A[N // 2 - 1] + A[N // 2]) / 2
    mid_b = (B[N // 2 - 1] + B[N // 2]) / 2
    print(int((mid_b - mid_a) * 2) + 1)
import numpy as np

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

if N % 2 == 1:
    a = np.sort(arr[:, 0])
    b = np.sort(arr[:, 1])
    print(b[N // 2] - a[N // 2] + 1)

else:
    a = np.sort(arr[:, 0])
    b = np.sort(arr[:, 1])
    print((b[N // 2] + b[N // 2 - 1]) - (a[N // 2 - 1] + a[N // 2]) + 1)
N = int(input())

A = [0 for i in range(N)]
B = [0 for i in range(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:
    print(B[N//2]-A[N//2]+1)
else:
    print(B[N//2]+B[(N-1)//2]-A[N//2]-A[(N-1)//2]+1)
n=int(input())
a,b=[],[]
for _ in range(n):
    i,j=map(int,input().split())
    a+=[i]
    b+=[j]
a.sort()
b.sort()
c=n//2
if n%2==1:
    print(b[c]-a[c]+1)
else:
    print(b[c]-a[c]+b[c-1]-a[c-1]+1)
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(round(2 * (Bm - Am) + 1))
else:
    print(Bm - Am + 1)
n = int(input())

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

aList.sort()
bList.sort()


if not n % 2 == 0:
    half = (n+1) // 2 - 1
    print(bList[half] - aList[half] + 1)
else:
    half = (n) // 2 - 1
    print(bList[half] + bList[half+1] - (aList[half] + aList[half+1]) + 1)
n = int(input())

ls = []
rs = []
for _ in range(n):
    x, y = map(int, input().split())
    ls.append(x)
    rs.append(y)

ls = sorted(ls)
rs = sorted(rs)

if n % 2 == 1:
    print(rs[len(rs)//2] - ls[len(ls)//2] + 1)
else:
    a = (rs[len(rs)//2-1] * 10 + rs[len(rs)//2] * 10) // 2
    b = (ls[len(ls)//2-1] * 10 + ls[len(ls)//2] * 10) // 2
    print((a - b) // 5 + 1)
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)
A.sort()
B.sort()
#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 i in range(n):
    aa,bb=list(map(int,input().split()))
    a.append(aa*2)
    b.append(bb*2)

a.sort()
b.sort()

if n%2==1:
    amed=a[(n-1)//2]
    bmed=b[(n-1)//2]

    ans=(bmed-amed)//2+1
else:
    amed=(a[n//2-1]+a[n//2])/2
    bmed = (b[n // 2 - 1] + b[n // 2]) / 2

    ans=bmed-amed+1

print(int(ans))
n=int(input())
A=[]
B=[]
for i in range(n):
    a,b=map(int,input().split())
    A.append(a)
    B.append(b)
A.sort()
B.sort()
if n%2==0:
    a_min=(A[n//2-1]+A[n//2])/2
    b_max=(B[n//2-1]+B[n//2])/2
    print(int(1+(b_max-a_min)/0.5))
else:
    a_min=A[n//2]
    b_max=B[n//2]
    print(int(b_max-a_min)+1)
n=int(input(""))
a=[]
b=[]
for i in range(n):
    cc=input("").split(" ")
    a+=[int(cc[0])]
    b+=[int(cc[1])]
s=0
a.sort()
b.sort()
if (n%2==0):
    s=(a[int(n/2)]+a[int(n/2)-1]-b[int(n/2)]-b[int(n/2)-1])
else:
    s=a[int((n-1)/2)]-b[int((n-1)/2)]
print(int(-s+1))
import numpy as np
def resolve():
    N = int(input())
    A = np.zeros(N)
    B = np.zeros(N)
    for i in range(N):
        A[i],B[i] = map(int,input().split())
    Amed = np.median(A)
    Bmed = np.median(B)
    if N % 2 == 0:
        print(int((Bmed - Amed) * 2 + 1))
    else:
        print(int(Bmed - Amed +1))
resolve()
n = int(input())
AB = []
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:
  l = A[n//2]
  r = B[n//2]
  print(r-l + 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):
    s,t = map(int,input().split())
    a.append(s)
    b.append(t)
a.sort()
b.sort()
if n%2 == 0:
    am = (a[n//2-1]+a[n//2])/2
    bm = (b[n//2-1]+b[n//2])/2
    print(int((bm-am)*2+1))
else:
    am = a[(n-1)//2]
    bm = b[(n-1)//2]
    print(bm-am+1)
N=int(input())
A=[0]*N
B=[0]*N
x,y=0,0
for i in range(N):
  x,y=map(int,input().split())
  A[i]=x
  B[i]=y
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)
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:
    m = n//2
    ans = b[m] - a[m] + 1
else:
    ml = n//2-1
    mr = n//2
    ma = (a[ml] + a[mr])/2 
    mb = (b[ml] + b[mr])/2
    ans = int((mb - ma)*2 + 1)
print(ans)
N = int(input())
AB = [list(map(int,input().split())) for _ in range(N)]
 
A = []
B = []
for i in range(N):
  A.append(AB[i][0])
  B.append(AB[i][1])
A.sort()
B.sort()
if N % 2 == 0:
    n = N // 2
    med1 = A[n-1] + A[n]
    med2 = B[n-1] + B[n]
    x = med2 - med1 + 1
else:
    n = N // 2
    med1 = A[n]
    med2 = B[n]
    x = med2 - med1 + 1
    
print(x)
import numpy as np
(n,), *d = [[*map(int, i.split())] for i in open(0)]
a, b = np.median(d, axis=0)
if n%2:print(int(b - a + 1))
else:print(int(b*2 - a*2 + 1))
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 == 1:
    ans = B[n//2]-A[n//2]+1
else:
    ans = B[n//2-1]+B[n//2]-(A[n//2-1]+A[n//2])+1
print(ans)
N = int(input())
ab = [list(map(int, input().split())) for _ in range(N)]

ba = []
for i, j in ab:
    ba.append([j, i])

ab.sort()
ba.sort(reverse = True)

if N % 2 == 1:
    n = (N+1) // 2 - 1
    ans = ba[n][0] - ab[n][0] + 1
    
else:
    n = N // 2 - 1
    ans = (ba[n][0] + ba[n+1][0]) - (ab[n][0] + ab[n+1][0]) + 1

print(ans)
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:
        mn = A[N//2-1] + A[N//2]
        mx = B[N//2-1] + B[N//2]
    else:
        mn = A[N//2]
        mx = B[N//2]
    ans = (mx-mn) + 1
    print(ans)


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.sort()
B.sort()
if N%2!=0:
    n=(N+1)//2
    ans=B[n-1]-A[n-1]+1
else:
    n=N//2
    ans1=(A[n-1]+A[n])/2
    ans2=(B[n-1]+B[n])/2
    ans=(ans2-ans1)*2+1
print(int(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()

res = 0

if n % 2 == 1:
    midA = A[n // 2]
    midB = B[n // 2]
    if midB >= midA:
        res = midB - midA + 1
    else:
        res = 0
else:
    midA = A[n // 2 - 1] + A[n // 2] 
    midB = B[n // 2 - 1] + B[n // 2]
    if midB >= midA:
        res = midB - midA + 1
    else:
        res = 0
print(res)