Buggy python submission (verdict: Time Limit Exceeded):
from bisect import bisect_left
def comb(n,k):
    nCk = 1
    mod = 10**9+7
    for i in range(n-k+1, n+1):
        nCk *= i
        nCk %= mod
    for i in range(1, k+1):
        nCk *= pow(i, mod-2, mod)
        nCk %= mod
    return nCk

n = int(input())
A = list(map(int,input().split()))
A.sort()
y = max(A)
idx = bisect_left(A, y//2)
ans = -1
x = idx
for i in range(max(0, idx-1), min(n+1, idx+1)):
    if comb(y, A[i]) > ans:
        ans = comb(y,A[i])
        x = A[i]
print(y,x)

Fixed submission:
n = int(input())
lst = list(map(int,input().split()))
lst.sort()

m = lst[-1]
line = m / 2
r = 10**10

for i in range(n):
    if abs(r-line) > abs(lst[i]-line):
        r = lst[i]
print(m,r)

Buggy python submission (verdict: Time Limit Exceeded):
from math import factorial
import bisect

n = int(input())
lst = list(map(int,input().split()))

lst = sorted(lst)

def nCr(n,r):
    return factorial(n)/factorial(n-r) * factorial(r)

if n == 2:
    print(max(lst), min(lst))
else:
    num = max(lst)
    r1 = bisect.bisect_left(lst, num//2)
    r2 = bisect.bisect_right(lst, num//2)
    
    val1 = nCr(num, lst[r1])
    val2 = nCr(num, lst[r2])
    
    if val1 >= val2:
        ans = (max(num, lst[r1]), min(num, lst[r1]))
    else:
        ans = (max(num, lst[r2]), min(num, lst[r2]))
    
    print(*ans)

Fixed submission:
n = int(input())
lst = list(map(int,input().split()))
lst.sort()

m = lst[-1]
line = m / 2
r = 10**10

for i in range(n):
    if abs(r-line) > abs(lst[i]-line):
        r = lst[i]
print(m,r)

Buggy python submission (verdict: Runtime Error):
from math import factorial
import bisect

n = int(input())
lst = list(map(int,input().split()))

lst = sorted(lst)

ans = (-1,-1)
val = -1

def nCr(n,r):
    return factorial(n)/factorial(n-r) * factorial(r)

if n == 2:
    print(max(lst), min(lst))
else:
    for i in range(1, n):
        num = lst[i]
        pos = bisect.bisect_left(lst, num//2)
        r = lst[pos]
        
        tmp_val = nCr(num, r)
        if tmp_val > val:
            val = tmp_val
            ans = (num, r)
    
    print(max(ans), min(ans))

Fixed submission:
n = int(input())
lst = list(map(int,input().split()))
lst.sort()

m = lst[-1]
line = m / 2
r = 10**10

for i in range(n):
    if abs(r-line) > abs(lst[i]-line):
        r = lst[i]
print(m,r)

Buggy python submission (verdict: Runtime Error):
from math import factorial
import bisect

n = int(input())
lst = list(map(int,input().split()))

lst = sorted(lst)

ans = (-1,-1)
val = -1

def nCr(n,r):
    return factorial(n)/factorial(n-r) * factorial(r)

if n == 2:
    print(max(lst), min(lst))
else:
    for i in range(1, n):
        num = lst[i]
        pos = bisect.bisect_left(lst, num//2)
        r = lst[pos]
        
        tmp_val = nCr(num, r)
        if tmp_val > val:
            val = tmp_val
            ans = (num, r)
    
    print(max(ans), min(ans)

Fixed submission:
n = int(input())
lst = list(map(int,input().split()))
lst.sort()

m = lst[-1]
line = m / 2
r = 10**10

for i in range(n):
    if abs(r-line) > abs(lst[i]-line):
        r = lst[i]
print(m,r)

Buggy python submission (verdict: Runtime Error):

from math import factorial
import bisect

n = int(input())
lst = list(map(int,input().split()))

lst = sorted(lst)

ans = (-1,-1)
val = -1

def nCr(n,r):
    return factorial(n)/factorial(n-r) * factorial(r)

if n==2:
    print(*lst)
    exit()

for i in range(1, n):
    n = lst[i]
    r1 = bisect.bisect_left(lst, n//2)
    r2 = bisect.bisect_right(lst, n//2)
    
    v1 = nCr(n, lst[r1])
    v2 = nCr(n, lst[r2])
    
    if v1 > val and n!=lst[r1]:
        val = v1
        ans = (n, lst[r1])
    if v2 > val and n!=lst[r2]:
        val = v2
        ans = (n, lst[r2])
    
print(*ans)

Fixed submission:
n = int(input())
lst = list(map(int,input().split()))
lst.sort()

m = lst[-1]
line = m / 2
r = 10**10

for i in range(n):
    if abs(r-line) > abs(lst[i]-line):
        r = lst[i]
print(m,r)