Buggy python submission (verdict: Time Limit Exceeded):
def sq(a, b, mod):  # aのb乗を剰余,kは初期値#20191116-D-Knight
    if b == 0:
        return 1
    elif b % 2 == 0:
        return sq(a, b // 2, mod)**2 % mod
    else:
        return sq(a, b - 1, mod) * a % mod


def nCk(n, k, mod=10 ** 9 + 7):
    x = max(k, n - k)
    y = min(k, n - k)
    kkai = 1
    for i in range(2, y + 1):
        kkai = (kkai * i) % mod
    nkkai = 1
    for i in range(x + 1, n + 1):
        nkkai = (nkkai * i) % mod
    answer = sq(kkai, mod - 2, mod) * nkkai % mod
    return answer

n = int(input())
alist = list(map(int, input().split()))
m = max(alist)
ans = 0
ans_ = (0, 0)
sbn = 10**10
for a in alist:
    if a == m:
        continue
    sbn_ = abs(m//2-a)
    if sbn_ < sbn :
        sbn = sbn_
        nck = nCk(m, a)
        # print(nck)
        ans = nck
        ans_ = (m, a)
print(ans_[0], ans_[1])


Fixed submission:
n = map(int, input().split())
alist = list(map(int, input().split()))
m = max(alist)
sbn = 10**10
for a in alist:
    if abs(m/2 - a) < sbn and a != m:
        ans = a
        sbn = abs(m/2 - a)
print(m, ans)

Buggy python submission (verdict: Runtime Error):
def sq(a, b, mod):  # aのb乗を剰余,kは初期値#20191116-D-Knight
    if b == 0:
        return 1
    elif b % 2 == 0:
        return sq(a, b // 2, mod)**2 % mod
    else:
        return sq(a, b - 1, mod) * a % mod


def nCk(n, k, mod=10 ** 9 + 7):
    x = max(k, n - k)
    y = min(k, n - k)
    kkai = 1
    for i in range(2, y + 1):
        kkai = (kkai * i) % mod
    nkkai = 1
    for i in range(x + 1, n + 1):
        nkkai = (nkkai * i) % mod
    answer = sq(kkai, mod - 2, mod) * nkkai % mod
    return answer

n = int(input())
alist = list(map(int, input().split()))
m = max(alist)
ans = 0
ans_ = (0, 0)
sbn = 10**10
for a in alist:
    if a == b:
        continue
    sbn_ = abs(m//2-a)
    if sbn_ < sbn :
        sbn = sbn_
        nck = nCk(m, a)
        # print(nck)
        ans = nck
        ans_ = (m, a)
print(ans_[0], ans_[1])


Fixed submission:
n = map(int, input().split())
alist = list(map(int, input().split()))
m = max(alist)
sbn = 10**10
for a in alist:
    if abs(m/2 - a) < sbn and a != m:
        ans = a
        sbn = abs(m/2 - a)
print(m, ans)

Buggy python submission (verdict: Runtime Error):
def sq(a, b, mod):  # aのb乗を剰余,kは初期値#20191116-D-Knight
    if b == 0:
        return 1
    elif b % 2 == 0:
        return sq(a, b // 2, mod)**2 % mod
    else:
        return sq(a, b - 1, mod) * a % mod


def nCk(n, k, mod=10 ** 9 + 7):
    x = max(k, n - k)
    y = min(k, n - k)
    kkai = 1
    for i in range(2, y + 1):
        kkai = (kkai * i) % mod
    nkkai = 1
    for i in range(x + 1, n + 1):
        nkkai = (nkkai * i) % mod
    answer = sq(kkai, mod - 2, mod) * nkkai % mod
    return answer

n = int(input())
alist = list(map(int, input().split()))
m = max(alist)
ans = 0
ans_ = (0, 0)
sbn = 10**10
for a in alist:
    if a == b:
        continue
    sbn_ = abs(m//2-a)
    if sbn_ < sbn :
        sbn = sbn_
        nck = nCk(m, a)
        # print(nck)
        ans = nck
        ans_ = (m, a)
print(ans_[0], ans_[1])


Fixed submission:
n = map(int, input().split())
alist = list(map(int, input().split()))
m = max(alist)
sbn = 10**10
for a in alist:
    if abs(m/2 - a) < sbn and a != m:
        ans = a
        sbn = abs(m/2 - a)
print(m, ans)

Buggy python submission (verdict: Time Limit Exceeded):
def sq(a, b, mod):  # aのb乗を剰余,kは初期値#20191116-D-Knight
    if b == 0:
        return 1
    elif b % 2 == 0:
        return sq(a, b // 2, mod)**2 % mod
    else:
        return sq(a, b - 1, mod) * a % mod


def nCk(n, k, mod=10 ** 9 + 7):
    x = max(k, n - k)
    y = min(k, n - k)
    kkai = 1
    for i in range(2, y + 1):
        kkai = (kkai * i) % mod
    nkkai = 1
    for i in range(x + 1, n + 1):
        nkkai = (nkkai * i) % mod
    answer = sq(kkai, mod - 2, mod) * nkkai % mod
    return answer

n = int(input())
alist = list(map(int, input().split()))
m = max(alist)
ans = 0
ans_ = (0, 0)
for a in alist:
    nck = nCk(m, a)
    if nck >= ans:
        # print(nck)
        ans = nck
        ans_ = (m, a)
print(ans_[0], ans_[1])


Fixed submission:
n = map(int, input().split())
alist = list(map(int, input().split()))
m = max(alist)
sbn = 10**10
for a in alist:
    if abs(m/2 - a) < sbn and a != m:
        ans = a
        sbn = abs(m/2 - a)
print(m, ans)

Buggy python submission (verdict: Time Limit Exceeded):
def sq(a, b, mod):  # aのb乗を剰余,kは初期値#20191116-D-Knight
    if b == 0:
        return 1
    elif b % 2 == 0:
        return sq(a, b // 2, mod)**2 % mod
    else:
        return sq(a, b - 1, mod) * a % mod


def nCk(n, k, mod=10 ** 9 + 7):
    x = max(k, n - k)
    y = min(k, n - k)
    kkai = 1
    for i in range(2, y + 1):
        kkai = (kkai * i) % mod
    nkkai = 1
    for i in range(x + 1, n + 1):
        nkkai = (nkkai * i) % mod
    answer = sq(kkai, mod - 2, mod) * nkkai % mod
    return answer


n = int(input())
alist = sorted(list(set(map(int, input().split()))))[::-1]
a, b = 0, 0
ans = 0
for i in range(n - 1):
    ai = alist[i]
    for j in range(i + 1, n):
        com = nCk(ai, alist[j])
        if com > ans:
            ans = com
            a, b = ai, alist[j]
print(a, b)


Fixed submission:
n = map(int, input().split())
alist = list(map(int, input().split()))
m = max(alist)
sbn = 10**10
for a in alist:
    if abs(m/2 - a) < sbn and a != m:
        ans = a
        sbn = abs(m/2 - a)
print(m, ans)