peterverebics/CodeNet_Python_118 huggingface dataset:
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(((b[n//2-1][1]+b[n//2][1])-(a[n//2-1][0]-a[n//2][0]))//2)
import sys
input = sys.stdin.readline
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 == 1:
    am = a[n // 2]
    bm = b[n // 2]
    ans = abs(bm - am) + 1
else:
    am1 = a[n // 2 - 1]
    am2 = a[n//2]
    bm1 = b[n // 2 - 1]
    bm2 = b[n // 2]
    ans = am2 + bm2 - (am1 + bm1) + 1
print(ans)
n = int(input())
AB = [tuple(map(int, input().split())) for i in range(n)]
A = [AB[i][0] for i in range(n)]
B = [AB[i][1] for i in range(n)]
# A = [(AB[i][0], i) for i in range(n)]
# B = [(AB[i][1], i) for i in range(n)]

A.sort()
B.sort()

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

if n % 2 == 0:
    print(B[n // 2] - A[n // 2 - 1] + 1)
import numpy as np
n = int(input())
A, B = [], []
for _ in range(n):
    a,b = map(int,input().split())
    A.append(a)
    B.append(b)

x = np.median(A)
y = np.median(B)
if n%2==0:
    print(int((y-x)/0.5+1))
else:
    print(y-x+1)
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 and ((r1*2) % 2)>0:
  mult=2
else:
  mult=1
#print(r0)
#print(r1)
mult=int((r1-r0)*mult+1)
print(mult)
  #r=r|
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)
if N%2:
    ans=B[(N+1)//2-1]-A[(N+1)//2-1]+1
else:
    ans=1+((B[N//2-1]+B[N//2]))-((A[N//2-1]+A[N//2]))
print(ans)
n = int(input())
A, B = [], []
for _ in range(n):
  a, b = map(int, input().split())
  A.append(a)
  B.append(b)

A.sort()
B.sort()

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

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

  if A[n // 2] != A[n // 2 - 1]:
    ans += 1

  if B[n // 2] != B[n // 2 - 1]:
    ans -= 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)
A.sort()
B.sort()
x = median(A)
y = median(B)
if N % 2:
    print(y - x + 1)
else:
    temp = math.floor(y) - math.floor(x)
    print(2 * temp + 1)
N = int(input())
AB = [list(map(int,input().split())) for _ in range(N)]

lab = len(AB)

if lab%2 != 0:
  ans = AB[N//2][1]-AB[N//2][0]+1
else:
  ans = max(AB[N//2][1],AB[N//2-1][1])-min(AB[N//2][0],AB[N//2-1][0])+1

print(ans)
N = int(input())
A = [0] * N
B = [0] * N
for i in range(N):
  a, b = list(map(int, input().split()))
  A[i] = a
  B[i] = b
  
A = sorted(A)
B = sorted(B)

if N % 2 == 1:
  x = int((N + 1)// 2)
  ans = abs(B[x - 1] - A[x - 1]) + 1
else:
  x = int(N // 2)
  a = max(A[x], B[x])
  b = min(A[x - 1], B[x - 1])
  ans = abs(b - a) + 1
  
print(ans)
n = int(input())
X = []
for i in range(n):
    X.append(list(map(int, input().split())))

ans = 0
if n % 2 == 0:
    a = X[n // 2 - 1][1] - X[n // 2 - 1][0] + 1
    b = X[n // 2][1] - X[n // 2][0] + 1
    ans = a * b - 1
else:
    ans = X[(n + 1) // 2 - 1][1] - X[(n + 1) // 2 - 1][0] + 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)
    
if(N % 2 == 1):
    k = int( (N-1) / 2 )
    print(B[k] - A[k] + 1)
else:
    k = int( N / 2 ) - 1
    print( B[k+1] - A[k+1] + 1 + B[k] - A[k] )
import sys
# sys.setrecursionlimit(200010)
def input():
    return sys.stdin.readline()[:-1]
def main():
    N = int(input())
    L = [list(map(int,input().split())) for _ in range(N)]
    if N%2 == 1:
        print(L[N//2][1]-L[N//2][0]+1)
    else:
        a = L[N//2-1][0]+L[N//2][0]
        b = L[N//2-1][1]+L[N//2][1]
        print(b-a+1)
if __name__ == '__main__':
    main()
import numpy as np
from statistics import median
n = int(input())
a = [list(map(int,input().split())) for i in range(n)]
b = np.array(a)
c = list(b[:,0])
d = list(b[:,1])
x = median(c)
y = median(d)
print(int(2*(y-x)+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)
mA=median(A);mB=median(B)
ans=int(mB-mA)
print(ans+1 if N%2 else ans+2)
N = int(input())
A = [0]*N
B = [0]*N
for i in range(N):
    A[i],B[i] = map(int,input().split()) 
    
Bs = sorted(B)
if N%2==1:
    maxlist = Bs[int(N-(N+1)/2):N]
    premax = min(maxlist)
    minlist = sorted(A)[:int((N+1)/2)]
    premin = max(minlist)
    print(premax-premin+1)
    
else:
    maxlist = Bs[int(N/2):N]
    premax = min(maxlist)
    minlist = sorted(A)[:int(N/2)]
    premin = max(minlist)
    num = premax-premin+1
    print(num*2-3)
import statistics
N=int(input())
A=[None]*N
B=[None]*N
for i in range(N):
  A[i],B[i] = map(int,input().split())
mini = statistics.median(A)
maxi = statistics.median(B)
if N % 2 == 1:
  print(maxi - mini +1)
else:
  print((maxi-mini)*2+1)
n = int(input())
la = []
lb = []
for i in range(n):
    a,b = map(int,input().split())
    la.append(a)
    lb.append(b)
la.sort()
lb.sort()

if n % 2 != 0:
    left = la[n//2]
    right = lb[n//2]
    print(right-left+1)
else:
    left = (la[n//2]+la[n//2-1])/2
    right = (lb[n//2]+lb[n//2-1])/2
    print(int(right-left)*2+1)
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)

if N % 2 == 0:
    ans = 2*(pts[-2] - pts[1] + 1) + 1
else:
    ans = pts[-2] - pts[1] + 1
print(ans)
n=int(input())
l=[]
r=[]
ans=0
for i in range(n):
    a,b=map(int,input().split())
    l.append(a)
    r.append(b)
l.sort()
r.sort()
if n%2==0:
    ans=r[n//2]-l[n//2-1]+1
else:
    ans=r[n//2]-l[n//2]+1
print(ans)
N = int(input())
left = []
right = []
for _ in range(N):
    l, r = map(int, input().split())
    left.append(l)
    right.append(r)
left.sort()
right.sort()
if N%2==0:
    for i, (l, r) in enumerate(zip(left, right[1:]), 1):
        if i==N//2:
            print((r-l)*2-1)
else:
    for i, (l, r) in enumerate(zip(left, right), 1):
        if i==N//2+1:
            print(r-l+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(ma,mb)
    print(int(mb - ma) * 2 + 1)
if n % 2 == 1:
    ma, mb = median(a), median(b)
    print(int(mb - ma + 1))
N = int(input())
A, B = [], []
for _ in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)

m1 = A[N//2] + A[(N-1)//2]
m2 = B[N//2] + B[(N-1)//2]
print((m2 - m1) // (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)
A.sort()
B.sort()
l = A[1]
r = B[-2]
if n % 2:
    print(r - l + 1)
else:
    print((r - l + 1) * 2 + 1)
n = int(input())
a_list = []
b_list = []
a_list.sort()
b_list.sort()
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)
import copy
n = int(input())
ab = [list(map(int,input().split())) for _ in range(n)]
ab2 = copy.deepcopy(ab)
ab = sorted(ab, key=lambda x:x[0])
ab2 = sorted(ab2, key=lambda x:x[1])
print(ab,ab2)
if n % 2 == 1:
    m = ab[n//2][0]
    M = ab2[n//2][1]
    print(M-m+1)
else:
    m = (ab[n//2][0]+ab[n//2-1][0])
    M = (ab[n//2][1]+ab[n//2-1][1])
    print(int(M-m+1))
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])

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 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(2*(maxmed-minmed)+1)
else:
    minmed=l1[N//2]
    maxmed=l2[N//2]
    print(maxmed-minmed+1)
N = int(input())
A = []
B = []
for _ in range(N):
  a, b = map(int,input().split())
  A.append(a)
  B.append(b)

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

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

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

if n % 2 == 1:
    print(q - p + 1)
else:
    print((q - p) * 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(abs(up[N//2][1]-down[N//2][0])+1)
else:
    up2 = sorted(ab,key=lambda a:a[0],reverse=True)
    down2 = sorted(ab,key=lambda a:a[1],reverse=True)
    r = (up[N//2][1]+up2[N//2][1])
    l = (down[N//2][0]+down2[N//2][0])
    print(abs(r-l)+1)
N = int(input(""))

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

  medians = []
for a in A:
  for b in B:
    n = (b - a) + 1
    if n % 2 == 0:
      indx = n//2
      med = (a+indx-1+a+indx) / 2
    else:
      indx = (n+1)//2
      med = a + indx-1

    medians.append(med)

medians = set(medians)
print(len(medians))
n=int(input())
ab=[list(map(int, input().split())) for _ in range(n)]
a=[]
b=[]
for a_i, b_i in ab:
    a.append(a_i)
    b.append(b_i)
a.sort()
b.sort()

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

if n%2==0:
    ans=2*b_med-2*a_med+1
else:
    ans=b_med-a_med+1
print(ans)
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)
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
    if n % 2 == 1:
        i = median(a)
        j = median(b)
        print(j - i + 1)
    else:
        i = int(median(a))
        j = math.ceil(median(b))
        print((j - i) * 2)
main()
import statistics
import math
from decimal import *
N = int(input())

n =[]
m =[]

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

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

if N%2 == 1:
    print(mmean - nmean + 1)
else:
    print(int(mmean - nmean)*2 +1 )
N = int(input())

A = [None] * N
B = [None] * N

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

medians = []

if N % 2 == 0:
    a_median = (A[N // 2 - 1] + A[N // 2]) // 2
    b_median = (B[N // 2 - 1] + B[N // 2]) // 2
    ans = abs(a_median - b_median) * 2 + 1
else:
    a_median = A[(N + 1) // 2 - 1]
    b_median = B[(N + 1) // 2 - 1]
    ans = abs(a_median - b_median) + 1

print(ans)
n = int(input())
ab = [list(map(int, input().split())) for _ in range(n)]
ab.sort()
l = ab[(n+1)//2-1][0]
ab.sort(key=lambda x:x[1], reverse=True)
r = ab[(n+1)//2-1][1]

print(l,r)
print(r-l+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 = 2 * sum(B) - 2 * sum(A)
    print(ans//2+1)
else:
    ans = B[N//2] - A[N//2] + 1
    print(ans)
N = int(input())
ab = [list(map(int, input().split())) for _ in range(N)]


if N % 2 == 0:
    maxab = ab[(N // 2) - 1][1]
    minab = ab[N // 2][0]
    x1 = ab[(N // 2) - 1][1] - ab[(N // 2) - 1][0] + 1
    x2 = ab[N // 2][1] - ab[N // 2][0] + 1
    if maxab < minab:
        print(x1 * x2)
    else:
        print(x1 * x2 - (abs(maxab - minab) + 1))
else:
    print(ab[N // 2][1] - ab[N // 2][0] + 1)
n = int(input())
ab = [list(map(int, input().split())) for _i in range(n)]
x, y = [], []
for i, j in ab:
    x.append(i)
    y.append(j)
x.sort()
y.sort()
p = n//2
if n%2==0:
    p -= 1
    result = (x[p+1]-x[p]+1)*(y[p+1]-y[p]+1)
else:
    result = x[p+1]-x[p]+y[p]-y[p-1]
    if x[p+1]==y[p-1]:
        result += 1
    else:
        result += 2
print(result)
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()
    ans=0
    if n%2==0:
        k=int(n/2)
        print(max(b[k],b[k-1])-min(a[k],a[k-1])+1)
    else:
        k=n//2
        print(b[k]-a[k]+1)
resolve()
import sys
sys.setrecursionlimit(10**9)

def main():
    N = int(input())
    rg = []

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

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

    a,b = rg[N//2-1]
    c,d  =rg[N//2]

    print(b+d-a-c+1)


if __name__ == "__main__":
  main()
N=int(input())
ans=0
if N%2==0:
    for i in range(1,N+1):
        A,B=map(int,input().split())
        if i==N//2:
            A0=A
        if i==N//2+1:
            B0=B
            ans=B0-A0+1
else:
    for i in range(1,N+1):
        A,B=map(int,input().split())
        if i==(N+1)//2:
            ans=B-A+1
print(ans)
from copy import deepcopy
n = int(input())
X = []
As = []
Bs = []
for i in range(n):
    A, B = list(map(int, input().split()))
    As.append(A)
    Bs.append(B)
As.sort()
Bs.sort()

if n % 2 == 1:
    m = (n-1) // 2
    print(Bs[m] - As[m] + 1)
else:
    b_m = n // 2 - 1
    a_m = b_m 
    min_mid =  (As[b_m] + As[a_m])
    max_mid =  Bs[b_m] + Bs[a_m]
    print(max_mid - min_mid + 1)
N=int(input())
from statistics import median
A=[0]*N
B=[0]*N
for i in range(N):
    a,b=map(int,input().split())
    A[i]=a
    B[i]=b
if N%2:
    print(median(B)- median(A)+1)
else:
    a=A[N//2-1]+A[N//2]
    b=B[N//2-1]+B[N//2]
    print(b-a+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)
#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-1]-A[x]) + 1
print(ans)
from statistics import median
N=int(input())
a,b=[],[]
#print(map(int,input().split())
for i in range(N):
  i,j=map(int,input().split())
  a.append(i)
  b.append(j)
amed,bmed=median(a),median(b)
  
if N%2==1:
  print(bmed-amed+1)
else:
  print(2*(bmed-amed)+1)
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
print(ans)
import statistics

N = int(input())
P = [[int(i) for i in input().split()] for _ in range(N)]


left = []
right = []

for i in range(N):
    left.append(P[i][0])
    right.append(P[i][1])

lmed = statistics.median(left)
rmed = statistics.median(right)

if N % 2 == 0:
    print(int(rmed - lmed) * 2 + 1)
else:
    print(rmed - lmed+1)
n = int(input())
ab =[list(map(int,input().split())) for _ in range(n)]

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 = (cb-ca) / 0.5 +1
else:
  ca = a[(n+1)//2-1]
  cb = b[(n+1)//2-1]
  ans = (cb-ca)//0.5 +1

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


pool = []
for a,b in ab:
    af = sum([1 for a1,b1 in list(ab) if a1 <= a <= b1])
    bf = sum([1 for a1,b1 in list(ab) if a1 <= b <= b1])
    pool.append((a,af))
    pool.append((b, bf))

# print(pool)

max_pool = max([p[1] for p in pool])
pool = [p[0] for p in pool if p[1] >= max_pool-1]
# print(pool)

if max_pool%2 == 1:
    print(max(pool) - min(pool) + 1)
else:
    print(max(pool) - min(pool) + 1)
from statistics import median

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

A_med = median(A)
B_med = median(B)

if N % 2 == 0:
    print(2 * (B_med - A_med) + 1)
else:
    print(B_med - A_med + 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:
  i = (N+1) // 2
  print(Bs[i-1] - As[i-1] + 1)
else:
  lower = N // 2
  upper = lower + 1
  print(Bs[upper - 1] - As[lower - 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):    
    print(B[N//2+1]-A[N//2+1]+1)
else:
    print(B[N//2]+B[N//2-1] - A[N//2]-A[N//2-1] + 1)
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(y, x)
    print(math.ceil(y) - math.floor(x) + 1)
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+1)//2-1]
  center_B = sorted_B[(N+1)//2-1]
  print(abs(center_A - center_B) + 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_A - center_B)*2 + 1)
import sys
import numpy as np
read = sys.stdin.read


n = int(input())
ab = np.array(read().split(), dtype=np.int64).reshape([n,2]).T
a = ab[0]
b = ab[1]
if n%2 ==1:
    a.sort()
    b.sort()
    N = n//2+1
    ans = b[-N]-a[N]+1
else:
    a.sort()
    b.sort()
    N = n//2
    ans= (b[-N]-a[N])*2+1
print(ans)
import math

N = int(input())
A = []
B = []
for i in range(N):
    in1, in2 = list(map(int,input().split()))
    A.append(in1)
    B.append(in2)
AA = sorted(A)
BB = sorted(B)

if N%2==1:
    low = AA[N//2  ]
    high = BB[N//2  ]
    print(high - low +1)

else:
    low = (AA[N//2-1] + AA[N//2]) / 2
    high = (BB[N//2-1] + BB[N//2]) / 2
    low = math.floor(low)
    high = math.ceil(high)
    print(high - low +1)
N=int(input())
ls=[list(map(int,input().split())) for i in range(N)]
ls_a=sorted([ls[i][0] for i in range(N)])
ls_b=[ls[i][1] for i in range(N)][::-1]

if N%2==1:
  print(ls_b[(N-1)//2]-ls_a[(N-1)//2]+1)
else:
  p=(ls_a[N//2-1]+ls_a[N//2])/2
  q=(ls_b[N//2-1]+ls_b[N//2])/2
  print(int((q-p)*2+1))
N=int(input())
a=[]
b=[]
for _ 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((b[N//2]-a[N//2])*2+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)

print(int(median(B) - median(A)) + 1)
import sys
input = sys.stdin.readline

def med(s: list):
    n = len(s)
    s = sorted(s, reverse = True)
    return s[(n + 1) // 2 - 1] if n & 1 else (s[n // 2] + s[n // 2 - 1]) // 2

n = int(input())
a, b = [], []
for i in range(n):
    aa, bb = map(int, input().split())
    a.append(aa), b.append(bb)
ma, mb = med(a), med(b)
print((mb - ma) + 1 if n & 1 else (mb - ma) * 2 + 1)
N = int(input())
A = [0 for _ in range(N)]
B = [0 for _ in range(N)]
import statistics
for k in range(N):
  A[k], B[k] = map(int, input().split())

if N%2 == 1:
  print(statistics.median(B) - statistics.median(A) +1)
else:
  print((statistics.median(B) - statistics.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:
    up2 = sorted(ab,key=lambda a:a[0],reverse=True)
    down2 = sorted(ab,key=lambda a:a[1],reverse=True)
    r = (up[N//2][1]+up2[N//2][1])
    l = (down[N//2][0]+down2[N//2][0])
    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)
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+1)*2-1
    print(int(ans))
N=int(input())
A=[list(map(int,input().split())) for i in range(N)]
if N%2==1:
    flat=[j for i in A for j in i]
    flat=sorted(flat)
    if flat[-2]==flat[1]:
        print(1)
    else:
        print(flat[-2]-flat[1]+1)
else:
    flat=[j for i in A for j in i]
    flat=sorted(flat)
    if flat[-2]==flat[1]:
        print(3)
    else:
        print((flat[-2]-flat[1])*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)

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

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

A.sort()
B.sort()

if N%2==0:
    sca=scb=N//2-1
    lca=lcb=N//2
    x=A[lca]+A[sca]
    y=B[lcb]+B[scb]
    print(x-y+1)
    
    
else:
    ca=cb=N//2
    ans=B[cb]-A[ca]+1
    print(ans)
N = int(input())
A_list = [0]*N
B_list = [0]*N
for i in range(N):
    A_list[i],B_list[i] = map(int,input().split())

A_list.sort()
B_list.sort()

if N%2 == 1:
    print(B_list[(N+1)//2] - A_list[(N+1)//2] + 1)
else:
    big = (B_list[N//2] + B_list[N//2-1])/2
    small = (A_list[N//2] + A_list[N//2-1])/2
    print(int((big-small)*2 + 1))
import numpy as np

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

if N%2 == 1:
    a_median = np.median(a_list).astype('int')
    b_median = np.median(b_list).astype('int')
    print(b_median-a_median+1)
elif N%2 == 0:
    a_median = np.median(a_list).astype('int')
    b_median = np.median(b_list).astype('int')
    print(2*(b_median-a_median)+1)
import numpy as np
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 = np.array(A)
B = np.array(B)
print(int(np.median(B) - np.median(A))  + 1)
n = int(input())
ab = [list(map(int, input().split())) for _ in range(n)]
a = [i for i, j in ab]
b = [j for i, j in ab]
a.sort()
b.sort()

if n % 2 == 1:
    print(abs(b[n//2] - a[n//2]) + 1)
else:
    tmp = [a[n // 2], a[n // 2 - 1], b[n // 2], b[n // 2 - 1]]
    tmp.sort()
    print(int(abs((tmp[0] + tmp[1]) / 2 - (tmp[2] + tmp[3]) / 2) / 0.5) + 1)