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

def main():
    N = int(input())
    A = list(map(int, input().split()))

    A.sort()
    n = A[-1]
    maxc = 0
    fn = factorial(n)
    i = bisect.bisect_left(A, n // 2)
    for r in [A[i-1], A[i]]:
        comb = (fn // factorial(n - r)) // factorial(r)
        if maxc < comb:
            ans = r
            maxc = comb
    print(n, ans)

main()


Fixed submission:
import bisect

def main():
    N = int(input())
    A = list(map(int, input().split()))

    A.sort()
    n = A[-1]
    i = bisect.bisect_left(A, n / 2)
    if n / 2 - A[i-1] <= A[i] - n / 2:
        r = A[i-1]
    else:
        r = A[i]
    print(n, r)

main()

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

def main():
    N = int(input())
    A = list(map(int, input().split()))

    A.sort()
    n = A[-1]
    maxc = 0
    fn = factorial(n)
    for r in A[:-1]:
        comb = (fn // factorial(n - r)) // factorial(r)
        if maxc < comb:
            ans = r
            maxc = comb
    print(n, ans)

main()


Fixed submission:
import bisect

def main():
    N = int(input())
    A = list(map(int, input().split()))

    A.sort()
    n = A[-1]
    i = bisect.bisect_left(A, n / 2)
    if n / 2 - A[i-1] <= A[i] - n / 2:
        r = A[i-1]
    else:
        r = A[i]
    print(n, r)

main()

Buggy python submission (verdict: Runtime Error):
from scipy.special import comb

def main():
    N = int(input())
    A = list(map(int, input().split()))

    A.sort()
    n = A[-1]
    maxc = 0
    for r in A[:-1]:
        cmb = comb(n, r)
        if maxc < cmb:
            ans = r
            maxc = cmb
    print(n, ans)

main()


Fixed submission:
import bisect

def main():
    N = int(input())
    A = list(map(int, input().split()))

    A.sort()
    n = A[-1]
    i = bisect.bisect_left(A, n / 2)
    if n / 2 - A[i-1] <= A[i] - n / 2:
        r = A[i-1]
    else:
        r = A[i]
    print(n, r)

main()

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

def main():
    N = int(input())
    A = list(map(int, input().split()))

    A.sort()
    n = A[-1]
    maxc = 0
    for r in A[:-1]:
        comb = factorial(n) // (factorial(r) * factorial(n - r))
        if maxc < comb:
            ans = r
            maxc = comb
    print(n, ans)

main()


Fixed submission:
import bisect

def main():
    N = int(input())
    A = list(map(int, input().split()))

    A.sort()
    n = A[-1]
    i = bisect.bisect_left(A, n / 2)
    if n / 2 - A[i-1] <= A[i] - n / 2:
        r = A[i-1]
    else:
        r = A[i]
    print(n, r)

main()

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

def main():
    N = int(input())
    A = list(map(int, input().split()))

    A.sort()
    n = A[-1]
    maxc = 0
    for r in A[:-1]:
        comb = (factorial(n) // factorial(n - r)) // factorial(r)
        if maxc < comb:
            ans = r
            maxc = comb
    print(n, ans)

main()


Fixed submission:
import bisect

def main():
    N = int(input())
    A = list(map(int, input().split()))

    A.sort()
    n = A[-1]
    i = bisect.bisect_left(A, n / 2)
    if n / 2 - A[i-1] <= A[i] - n / 2:
        r = A[i-1]
    else:
        r = A[i]
    print(n, r)

main()