Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
a = sorted(list(map(int, input().split())))

import numpy as np
from scipy.misc import comb

i = 0
j = N//2

ans = (0, 0)
x = 0
for j in range(1, N):
    n = a[j]
    while j - i > 1:
        if abs(n/2 - a[i]) < abs(n/2 - a[i+1]):
            break
        i+=1
    p = a[i]
    y = comb(n, p)
    if y > x:
        x = y
        ans = (n, p)

print(str(ans[0]), str(ans[1]))


Fixed submission:
N = int(input())
a = sorted(list(map(int, input().split())))

def find_p(n, i):
    lo = 0
    hi = i
    mid = (hi-lo)//2
    xl = a[0]
    xh = a[i]
    while hi - lo > 1:
        mid = (hi+lo)//2
        if a[mid] > n//2:
            hi = mid
        else:
            lo = mid
    if abs(a[lo] - n/2) > abs(a[hi] - n/2):
        return a[hi]
    else:
        return a[lo]



print(str(a[-1]) + ' ' + str(find_p(a[-1], N-1)))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
a = sorted(list(map(int, input().split())))

import numpy as np
from scipy.misc import comb

i = 0
j = 1

ans = (0, 0)
x = 0
for j in range(1, N):
    n = a[j]
    while j - i > 1:
        if abs(n/2 - a[i]) < abs(n/2 - a[i+1]):
            break
        i+=1
    p = a[i]
    y = comb(n, p)
    if y > x:
        x = y
        ans = (n, p)

print(str(ans[0]), str(ans[1]))

Fixed submission:
N = int(input())
a = sorted(list(map(int, input().split())))

def find_p(n, i):
    lo = 0
    hi = i
    mid = (hi-lo)//2
    xl = a[0]
    xh = a[i]
    while hi - lo > 1:
        mid = (hi+lo)//2
        if a[mid] > n//2:
            hi = mid
        else:
            lo = mid
    if abs(a[lo] - n/2) > abs(a[hi] - n/2):
        return a[hi]
    else:
        return a[lo]



print(str(a[-1]) + ' ' + str(find_p(a[-1], N-1)))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
a = sorted(list(map(int, input().split())))
import numpy as np
from scipy.misc import comb

def find_p(n, i):
    lo = 0
    hi = i
    mid = (hi-lo)//2
    xl = a[0]
    xh = a[i]
    while hi - lo > 1:
        mid = (hi+lo)//2
        if a[mid] > n//2:
            hi = mid
        else:
            lo = mid
    if abs(a[lo] - n/2) > abs(a[hi] - n/2):
        return a[hi]
    else:
        return a[lo]

ans = (0, 0)
x = 0
for j in range(N):
    i = N-j-1
    if a[i] < ans[1]:
        break
    n = a[i]
    p = find_p(n, i)
    y = comb(n, p)
    if y > x:
        ans = (n, p)
        x = y

print(str(ans[0]) + ' ' + str(ans[1]))


Fixed submission:
N = int(input())
a = sorted(list(map(int, input().split())))

def find_p(n, i):
    lo = 0
    hi = i
    mid = (hi-lo)//2
    xl = a[0]
    xh = a[i]
    while hi - lo > 1:
        mid = (hi+lo)//2
        if a[mid] > n//2:
            hi = mid
        else:
            lo = mid
    if abs(a[lo] - n/2) > abs(a[hi] - n/2):
        return a[hi]
    else:
        return a[lo]



print(str(a[-1]) + ' ' + str(find_p(a[-1], N-1)))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
a = sorted(list(map(int, input().split())))
import numpy as np
from scipy.misc import comb

def find_p(n, i):
    lo = 0
    hi = i
    mid = (hi-lo)//2
    xl = a[0]
    xh = a[i]
    while hi - lo > 1:
        mid = (hi+lo)//2
        if a[mid] > n//2:
            hi = mid
        else:
            lo = mid
    if abs(a[lo] - n/2) > abs(a[hi] - n/2):
        return a[hi]
    else:
        return a[lo]

ans = (0, 0)
x = 0
for j in range(N):
    i = N-j-1
    n = a[i]
    p = find_p(n, i)
    y = comb(n, p)
    if y > x:
        ans = (n, p)
        x = y

print(str(ans[0]) + ' ' + str(ans[1]))

Fixed submission:
N = int(input())
a = sorted(list(map(int, input().split())))

def find_p(n, i):
    lo = 0
    hi = i
    mid = (hi-lo)//2
    xl = a[0]
    xh = a[i]
    while hi - lo > 1:
        mid = (hi+lo)//2
        if a[mid] > n//2:
            hi = mid
        else:
            lo = mid
    if abs(a[lo] - n/2) > abs(a[hi] - n/2):
        return a[hi]
    else:
        return a[lo]



print(str(a[-1]) + ' ' + str(find_p(a[-1], N-1)))