Problem: There are N integers X_1, X_2, \cdots, X_N, and we know that A_i \leq X_i \leq B_i. Find the number of different values that the median of X_1, X_2, \cdots, X_N can take.

Submission attempts (in order):
import numpy as np
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))

def do():
    n=INT()
	A=[]
    B=[]
    for i in range(n):
        a,b=INTM()
        A.append(a)
        B.append(b)
        B=sorted(B,reverse=True)
    if n%2==1:
        ta=A[n//2]
        tb=B[n//2]
        print(tb-ta+1)
    else:
        ta1=A[n//2]
        ta2=A[n//2+1]
        tb1=B[n//2]
        tb2=B[n//2+1]
        avea=(ta1+ta2)/2
        aveb=(tb1+tb2)/2
        print(int((aveb-avea)*2)+1)
        
        
    
if __name__ == '__main__':
    do()

import numpy as np
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))

def do():
    n=INT()
	A=[]
    B=[]
    for i in range(n):
        a,b=INTM()
        A.append(a)
        B.append(b)
        B=sorted(B,reverse=True9
    if n%2==1:
        ta=A[n//2]
        tb=B[n//2]
        print(tb-ta+1)
    else:
        ta1=A[n//2]
        ta2=A[n//2+1]
        tb1=B[n//2]
        tb2=B[n//2+1]
        avea=(ta1+ta2)/2
        aveb=(tb1+tb2)/2
        print(int((aveb-avea)*2)+1)
        
        
    
if __name__ == '__main__':
    do()

import numpy as np
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))

def do():
    imos1=np.array([0]*(10**9))
    imos2=np.array([0]*(10**9))
    n=INT()

    for i in range(n):
        a,b=INTM()
        b=10**9+1-b
        imos1[a-1:]+=1
        imos2[b-1:]+=1
        
    if n%2==1:
        for i in range(n//2+1,n+1):
            if (i in imos1) and (i in imos2): 
                ta=imos1.index(i)+1
                tb=10**9-imos2.index(i)
                break
            else:
                pass
        print(tb-ta+1)
    else:
        for i in range(n//2,n+1):
            if (i in imos1) and (i in imos2): 
                for k in range(i+1,n+1):
                    if (k in imos1) and (k in imos2):
                        ta1=imos1.index(i)+1
                        ta2=imos1.index(k)+1
                        tb1=10**9-imos2.index(i)
                        tb2=10**9-imos2.index(k)
                        avea=(ta1+ta2)/2
                        ave=b(tb1+tb2)/2
                        print(int((aveb-avea)*2)+1)
                        break
                        break
                    else:
                        pass
            else:
                pass
        
        
    
if __name__ == '__main__':
    do()

import numpy as np
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
 
def do():
    n=INT()
    A=[]
    B=[]
    for i in range(n):
        a,b=INTM()
        A.append(a)
        B.append(b)
        
    A=sorted(A)
    B=sorted(B,reverse=True)
    if n%2==1:
        ta=A[n//2]
        tb=B[n//2]
        print(tb-ta+1)
    else:
        ta1=A[n//2-1]
        ta2=A[n//2]
        tb1=B[n//2-1]
        tb2=B[n//2]
        avea=(ta1+ta2)/2
        aveb=(tb1+tb2)/2
        print(int((aveb-avea)*2)+1)
        
        
    
if __name__ == '__main__':
    do()

Verdicts: Runtime Error

Runtime Error

Runtime Error

Accepted