Buggy python submission (verdict: Runtime Error):
import sys

sys.setrecursionlimit(10000)

def search(a, b, left, right):
    mid = int(left + (left - right) / 2)
    if(b[mid] == a):
        return b[mid]
    if(b[mid] >= a and a >= b[mid+1]):
        if(b[mid]- a >= a - b[mid+1]):
            return  b[mid+1]
        else:
            return b[mid]
    if(b[mid] >= a):
        return search(a, b, 0, mid)
    else:
        return search(a, b, mid, right)

n = int(input())
a = list(map(int, input().split(" ")))

b = sorted(a, reverse=True)
for i in b:
    m = i/2
    j = search(m, b, 0, len(b))
    print("%d %d" %(i, j))
    break

Fixed submission:
import sys

sys.setrecursionlimit(10000)

def search(a, b, left, right):
    mid = int(left + (right - left) / 2)
    if(b[mid] == a):
        return b[mid]
    if(len(b) <= mid + 1):
        return b[mid]
    if(b[mid] >= a and a >= b[mid+1]):
        if(b[mid]- a >= a - b[mid+1]):
            return b[mid+1]
        else:
            return b[mid]
    if(b[mid] <= a):
        return search(a, b, left, mid)
    else:
        return search(a, b, mid, right)

n = int(input())
a = list(map(int, input().split(" ")))

b = sorted(a, reverse=True)
for i in b:
    m = i/2
    j = search(m, b, 0, len(b))
    print("%d %d" %(i, j))
    break

Buggy python submission (verdict: Runtime Error):
import scipy.misc as scm

def search(a, b, left, right):
    mid = int(left + (left - right) / 2)
    if(b[mid] == a):
        return b[mid]
    if(b[mid] >= a and a >= b[mid+1]):
        if(b[mid]- a >= a - b[mid+1]):
            return  b[mid+1]
        else:
            return b[mid]
    if(b[mid] >= a):
        return search(a, b, 0, mid)
    else:
        return search(a, b, mid, right)

n = int(input())
a = list(map(int, input().split(" ")))

b = sorted(a, reverse=True)
for i in b:
    m = i/2
    j = search(m, b, 0, len(b))
    print("%d %d" %(i, j))
    break

Fixed submission:
import sys

sys.setrecursionlimit(10000)

def search(a, b, left, right):
    mid = int(left + (right - left) / 2)
    if(b[mid] == a):
        return b[mid]
    if(len(b) <= mid + 1):
        return b[mid]
    if(b[mid] >= a and a >= b[mid+1]):
        if(b[mid]- a >= a - b[mid+1]):
            return b[mid+1]
        else:
            return b[mid]
    if(b[mid] <= a):
        return search(a, b, left, mid)
    else:
        return search(a, b, mid, right)

n = int(input())
a = list(map(int, input().split(" ")))

b = sorted(a, reverse=True)
for i in b:
    m = i/2
    j = search(m, b, 0, len(b))
    print("%d %d" %(i, j))
    break

Buggy python submission (verdict: Time Limit Exceeded):
import scipy.misc as scm

n = int(input())
a = list(map(int, input().split(" ")))

b = sorted(a, reverse=True)

for i in b:
    j = 0
    if(i % 2 == 0):
        m = int(i/2)
    else:
        m = int((i+1)/2)
    while(True):
        if(int(m - j) in b):
            print("%d %d" %(i, int(m - j)))
            break
        if (int(m + j) in b):
            print("%d %d" %(i, int(m + j)))
            break
        j += 1
    break

Fixed submission:
import sys

sys.setrecursionlimit(10000)

def search(a, b, left, right):
    mid = int(left + (right - left) / 2)
    if(b[mid] == a):
        return b[mid]
    if(len(b) <= mid + 1):
        return b[mid]
    if(b[mid] >= a and a >= b[mid+1]):
        if(b[mid]- a >= a - b[mid+1]):
            return b[mid+1]
        else:
            return b[mid]
    if(b[mid] <= a):
        return search(a, b, left, mid)
    else:
        return search(a, b, mid, right)

n = int(input())
a = list(map(int, input().split(" ")))

b = sorted(a, reverse=True)
for i in b:
    m = i/2
    j = search(m, b, 0, len(b))
    print("%d %d" %(i, j))
    break