qyliang/CodeNanoFix huggingface dataset:
Buggy code:
import math
n = int(input())
a = list(map(int, input().split()))
a.sort()

def comb(n, r):
    return math.factorial(n) // math.factorial(n - r)

maxi = 0
i = -1
key = a[i] // 2
for j in range(n):
    if a[j] > key:
        break
# print(j, n-1)
if abs(a[j-1] - key) > abs(a[j] - (key+1)) or not(j < n-1):
    ans = [a[i], a[j-1]]
else:
    ans = [a[i], a[j]]
# ok = n
# ng = -1
# while abs(ok - ng) > 1:
#     mid = (ok + ng) // 2
#     if key <= a[mid]: ok = mid
#     else: ng = mid
# if ok < i: 
#     if comb(a[i], a[ok]) > maxi:
#         maxi = comb(a[i], a[ok])
#         ans = [a[i], a[ok]]
# if ng >= 0: 
#     if comb(a[i], a[ng]) > maxi:
#         maxi = comb(a[i], a[ng])
#         ans = [a[i], a[ng]]
print("{} {}". format(ans[0], ans[1]))

Fixed code:
import math
n = int(input())
a = list(map(int, input().split()))
a.sort()

def comb(n, r):
    return math.factorial(n) // math.factorial(n - r)

maxi = 0
i = -1
key = a[i] // 2
for j in range(n):
    if a[j] > key:
        break
# print(j, n-1)
# print(j, key, a)
if abs(a[j-1] - key) >= abs(a[j] - key) and j < n-1:
    ans = [a[i], a[j]]
else:
    ans = [a[i], a[j-1]]
# ok = n
# ng = -1
# while abs(ok - ng) > 1:
#     mid = (ok + ng) // 2
#     if key <= a[mid]: ok = mid
#     else: ng = mid
# if ok < i: 
#     if comb(a[i], a[ok]) > maxi:
#         maxi = comb(a[i], a[ok])
#         ans = [a[i], a[ok]]
# if ng >= 0: 
#     if comb(a[i], a[ng]) > maxi:
#         maxi = comb(a[i], a[ng])
#         ans = [a[i], a[ng]]
print("{} {}". format(ans[0], ans[1]))
Buggy code:
from bisect import bisect_left
N = int(input())
A = list(map(int,input().split()))
A.sort()
n = A.pop()
index = bisect_left(A, n//2+1)
if index == 0:
    r = A[0]
elif index == N-2:
    r = A[N-2]
else:
    if abs(n//2+1-A[index]) <= abs(n//2+1-A[index-1]):
        r = A[index]
    else:
        r = A[index - 1]
print(*[n,r])

Fixed code:
from bisect import bisect_left
N = int(input())
A = list(map(int,input().split()))
A.sort()
n = A.pop()
index = bisect_left(A, n//2)
if index == 0:
    r = A[0]
elif index == N-1:
    r = A[N-2]
else:
    if abs(n//2-A[index]) <= abs(n//2-A[index-1]):
        r = A[index]
    else:
        r = A[index - 1]
print(*[n,r])
Buggy code:
n = int(input())
a = list(map(int,input().split()))
a.sort()
M = max(a)
m = M//2
tmp = 1e9
for i in range(n-1):
    if tmp > abs(a[i]-m):
        tmp = abs(a[i]-m)
        ans = i

print(M,a[ans])

Fixed code:
n = int(input())
a = list(map(int,input().split()))
a.sort()
M = max(a)
m = M/2
tmp = 1e9
for i in range(n-1):
    if tmp > abs(a[i]-m):
        tmp = abs(a[i]-m)
        ans = i

print(M,a[ans])
Buggy code:
def pow(x, n , mod):
    res = 1
    while n > 0:
        if  bin(n & 1) == bin(1) :
            res = res * x % mod
        x = x*x % mod
        n = n >>1
    return res   

def combination(n,a):
    x = 1
    for i in range(a):
        x = x * (n-i) % mod
    y = 1
    for i in range(a):
        y = y * (a-i) % mod
    y = pow(y, mod-2, mod)
    return (x*y % mod)

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

m = max(a)
a = sorted(a)

ans = 0

for i in a:
    if abs(m//2-i) < abs(m//2-ans):
        ans = i

print(m, ans)

Fixed code:
def pow(x, n , mod):
    res = 1
    while n > 0:
        if  bin(n & 1) == bin(1) :
            res = res * x % mod
        x = x*x % mod
        n = n >>1
    return res   

def combination(n,a):
    x = 1
    for i in range(a):
        x = x * (n-i) % mod
    y = 1
    for i in range(a):
        y = y * (a-i) % mod
    y = pow(y, mod-2, mod)
    return (x*y % mod)

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

m = max(a)
a = sorted(a)

ans = 0

for i in a:
    if abs(m/2-i) < abs(m/2-ans):
        ans = i

print(m, ans)
Buggy code:
n = int(input())
an = [int(i) for i in input().split()]
ai = max(an)
print("%d %d"%(ai, min(an, key=lambda i:abs(ai-i**2))))

Fixed code:
n = int(input())
an = [int(i) for i in input().split()]
an.sort()
ai = an[-1]
print("%d %d"%(ai, min(an, key=lambda i:abs(ai-i*2))))
Buggy code:
import sys
from bisect import bisect_left

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


def main():
    N = int(input())
    A = list(map(int, input().split()))
    A.sort()
    MAX = max(A)
    A = A[:-1]
    target = MAX // 2
    idx = bisect_left(A, target)

    if idx == 0:
        print(MAX, A[0])
    else:
        if abs(target - A[idx]) < abs(target - A[idx - 1]):
            print(MAX, A[idx])
        else:
            print(MAX, A[idx - 1])


if __name__ == "__main__":
    main()


Fixed code:
import sys
from bisect import bisect_left

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


def main():
    N = int(input())
    A = list(map(int, input().split()))
    A.sort()
    MAX = max(A)
    A = A[:-1]
    target = MAX / 2
    idx = bisect_left(A, target)

    if idx == 0:
        print(MAX, A[0])
    elif idx == N - 1:
        print(MAX, A[-1])
    else:
        if abs(target - A[idx]) < abs(target - A[idx - 1]):
            print(MAX, A[idx])
        else:
            print(MAX, A[idx - 1])


if __name__ == "__main__":
    main()
Buggy code:
n=int(input())
a=list(map(int,input().split()))
a.sort()
max_a=a[n-1]
N=int(n/2)
max_b=a[N]
resu=[0,N,n-1]
while resu[2]-resu[0]<=1:
    if max_b-max_a/2>0:
        resu[2]=N
        N=int((resu[0]+resu[1]+1)/2)
        resu[1]=N
        max_b=a[N]
    elif max_b==max_a/2:
        break
    else:
        resu[0]=N
        N=int((resu[1]+resu[2]+1)/2)
        resu[1]=N
        max_b=a[N]
        
print(max_a,a[resu[1]])

Fixed code:
n=int(input())
a=list(map(int,input().split()))
a.sort()
max_a=a[n-1]
N=int(n/2)-1


mid=a[N]
resu=[0,N,n-2]
while resu[2]-resu[0]>1:
    if mid-max_a/2>0:
        resu[2]=N
        N=int((resu[0]+resu[1])/2)
        resu[1]=N
        mid=a[N]
    elif mid==max_a/2:
        break
    else:
        resu[0]=N
        N=int((resu[1]+resu[2])/2)
        resu[1]=N
        mid=a[N]
if resu[2]-resu[0]==1:
    if a[resu[0]]+a[resu[2]]-max_a>0:
        resu[1]=resu[0]
    else:
        resu[1]=resu[2]
       
print(max_a,a[resu[1]])
Buggy code:
n=int(input())
a=list(map(int,input().split()))
a=sorted(a)

max_num=max(a)
middle_num=max_num/2

for i in range(n):
    if a[i]> middle_num:
        num=i
        break

if middle_num-a[i-1]>=middle_num-a[i]:
    print("{} {}".format(max_num,a[i-1]))
else:
    print("{} {}".format(max_num,a[i]))
    

Fixed code:
n=int(input())
a=list(map(int,input().split()))
a=sorted(a)

max_num=max(a)
middle_num=max_num/2
num=0

for i in range(n):
    if a[i]> middle_num:
        num=i
        break

if middle_num-a[num-1]<=-middle_num+a[num]:
    print("{} {}".format(max_num,a[num-1]))
else:
    print("{} {}".format(max_num,a[num]))
Buggy code:
n=int(input())
a=sorted(list(map(int,input().split())),reverse=True)
#print(a)
h=a[0]/2
dif=10**18
tmp=None
for i in range(n):
    if dif>abs(a[i]-h):
        dif=abs(a[i]-h)
        tmp=a[i]
print(a[0],tmp)

Fixed code:
n=int(input())
a=sorted(list(map(int,input().split())),reverse=True)
#print(a)
h=a[0]/2
dif=10**18
tmp=None
for i in range(1,n):
    if dif>abs(a[i]-h):
        dif=abs(a[i]-h)
        tmp=a[i]
print(a[0],tmp)
Buggy code:
def main():
    N = int(input())
    A = list(map(int, input().split()))
    aj = max(A)
    A.sort(key=lambda x: abs(aj / 2 - x))
    print(aj, A[0]) 
main()


Fixed code:
def main():
    N = int(input())
    A = list(map(int, input().split()))
    A.sort()
    aj = A.pop()
    A.sort(key=lambda x: abs(aj / 2 - x))
    print(aj, A[0]) 
main()
Buggy code:
n = int(input())
a = list(map(int,input().split()))
ans_bigger = max(a)
ans_half = a / 2
dif = float("inf")
for i in range(n):
  x = abs(a[i]-ans_half)
  if dif > x:
    dif = x
    ans_smaller = a[i]
print(ans_bigger,ans_smaller)

Fixed code:
n = int(input())
a = sorted(list(map(int,input().split())))
ans_bigger = max(a)
ans_half = ans_bigger / 2
dif = float("inf")
for i in range(n-1):
  x = abs(a[i]-ans_half)
  if dif > x:
    dif = x
    ans_smaller = a[i]
print(ans_bigger,ans_smaller)
Buggy code:
import bisect

N=int(input())
a=list(map(int,input().split()))
b=sorted(a)
M=b[N-1]
i=bisect.bisect_left(b,M/2)

if i==0: print(M,b[0])
elif abs(M/2-b[i-1])<abs(M/2-b[i]): print(M,b[i-1])
else: print(M,b[i])

Fixed code:
import bisect

N=int(input())
a=list(map(int,input().split()))
b=sorted(a)
M=b[N-1]
i=bisect.bisect_left(b,M/2)

if i==0: print(M,b[0])
elif abs(M/2-b[i-1])<=abs(M/2-b[i]): print(M,b[i-1])
else: print(M,b[i])
Buggy code:
n = int(input())
a = sorted(list(map(int, input().split())))

m = a[-1]

r = 10**10
for i in range(n):
    if abs(a[i]-(m//2-a[i])) < r:
        r = abs(a[i]-(m//2-a[i]))
        idx = i

print(m, a[idx])


Fixed code:
n = int(input())
a = sorted(list(map(int, input().split())))

m = a[-1]

r = 10**10
for i in range(n):
    if abs(a[i]-(m-a[i])) < r:
        r = abs(a[i]-(m-a[i]))
        idx = i

print(m, a[idx])
Buggy code:
N = int(input())
A = list(map(int, input().split()))

n = max(A)
A.sort(key=lambda a: abs(a - n // 2))
r = A[0]
print(n, r)


Fixed code:
N = int(input())
A = list(map(int, input().split()))
A.sort()

n = A.pop()
A.sort(key=lambda a: abs(a - n / 2))
r = A[0]
print(n, r)
Buggy code:
n=int(input())
 
t = list(map(int,input().split()))
 
a1 = max(t)
 
ans = 100000000000000
 
memo = 0

for i in t:
    if ans > abs(a1//2-i):
        ans = abs(a1//2-i)
        memo = i
print(a1, memo)

Fixed code:
n=int(input())
 
t = list(map(int,input().split()))
t.sort()
a1 = max(t)
 
ans = 100000000000000
 
memo = 0

for i in t:
    if ans > abs(a1/2-i):
        ans = abs(a1/2-i)
        memo = i
print(a1, memo)
Buggy code:
N=int(input())
s=list(map(int,input().split()))
n=max(s)
s.remove(n)
q=n
for i in s:
    t=n//2-i
    if q>=t:
        q=t
        w=str(n)+" "+str(i)
print(w)        
    

Fixed code:
N=int(input())
s=list(map(int,input().split()))
n=max(s)
s.remove(n)
q=n
for i in s:
    t=abs(n/2-i)
    if q>=t:
        q=t
        w=str(n)+" "+str(i)
print(w)
Buggy code:
n = int(input())
A = list(map(int, input().split()))
m = max(A) 
min = float("inf")
for i in range(n):
  if min > abs(A[i] - m/2): 
    min = abs(A[i] - m/2)
    r = A[i]
print(m,r)


Fixed code:
n = int(input())
A = list(map(int, input().split()))
m = max(A) 
min = float("inf")
for i in range(n):
  if min > abs(A[i] - m/2) and A[i] != m: 
    min = abs(A[i] - m/2)
    r = A[i]
print(m,r)
Buggy code:
n=int(input())
a=list(map(int,input().split()))
ans1=max(a)
m=10**9+1
temp=ans1/2
i=0
for index,val in enumerate(a):
    if abs(val-temp)<m:
        m=abs(val-temp)
        i=index
ans2=a[i]
print(ans1,ans2)

Fixed code:
n=int(input())
a=list(map(int,input().split()))
ans1=max(a)
m=10**9+1
temp=ans1/2
i=0
for index,val in enumerate(a):
    if val==ans1: continue
    if abs(val-temp)<m:
        m=abs(val-temp)
        i=index
ans2=a[i]
print(ans1,ans2)
Buggy code:
n = int(input())
A = [int(a) for a in input().split()]

A.sort()

ans_a = A[n-1]

left = 0
right = n-1
while True:
    if left == right:
        ans_b = A[left]
        break
    elif left + 1 == right:
        if abs(A[left]-ans_a/2) < abs(A[right]-ans_a/2):
            ans_b = A[left]
        else:
            ans_b = A[right]
        break
    elif ans_a//2 < A[(left+right)//2]:
        right = (left+right)//2
    else:
        left = (left+right)//2

print(ans_a,ans_b)

Fixed code:
n = int(input())
A = [int(a) for a in input().split()]

A.sort()
if n == 2:
    print(A[1],A[0])
else:
    ans_a = A[n-1]

    left = 0
    right = n-1
    while True:
        if left == right:
            ans_b = A[left]
            break
        elif left + 1 == right:
            if abs(A[left]-ans_a/2) < abs(A[right]-ans_a/2):
                ans_b = A[left]
            else:
                ans_b = A[right]
            break
        elif ans_a//2 < A[(left+right)//2]:
            right = (left+right)//2
        else:
            left = (left+right)//2

    print(ans_a,ans_b)
Buggy code:
n = int(input())
arr = [int(a) for a in input().split()]

i = max(arr)
j = min(arr, key=lambda a: min(abs(i//2-a), abs((i+1)//2-a)))

print(i, j)


Fixed code:
n = int(input())
arr = [int(a) for a in input().split()]

i = max(arr)
arr.remove(i)
j = min(arr, key=lambda a: min(abs(i//2-a), abs((i+1)//2-a)))

print(i, j)
Buggy code:
n = int(input())
a_list = list(map(int, input().split()))

max_a = max(a_list)
half_max = max_a / 2
near = max_a
near_ori = max_a
for a in a_list:
    tmp = abs(a - half_max)
    if tmp < near:
        near = tmp
        near_ori = a
        
print(max_a, near_ori)

Fixed code:
n = int(input())
a_list = list(map(int, input().split()))

max_a = max(a_list)
half_max = max_a / 2

near = max_a
near_ori = max_a
for a in a_list:
    if a == max_a:
        continue
    tmp = abs(a - half_max)
    if tmp < near:
        near = tmp
        near_ori = a
        
print(max_a, near_ori)
Buggy code:
n=int(input())
a=list(map(int,input().split()))
m=max(a)
h=m/2
d=abs(a[0]-h)
x=0
for i in range(1,n):
  if abs(a[i]-h)<d:
    x=i
print(m,a[x])

Fixed code:
n=int(input())
a=sorted(list(map(int,input().split())))
m=a[n-1]
a=a[:n]
h=m/2
d=abs(a[0]-h)
x=0
for i in range(1,n-1):
  if abs(a[i]-h)<d:
    x=i
    d=abs(a[i]-h)
print(m,a[x])
Buggy code:
import sys
import numpy
import math

N=int(input())

A=list(map(int,input().split()))

dekaiyatu=numpy.argmax(A)
kati=A[dekaiyatu]

A.pop(dekaiyatu)
iikanjinoyatu= numpy.argmin(list(map((lambda x: abs((dekaiyatu/2)-x) ), A)))

string=str(kati)+" "+str(A[iikanjinoyatu])

print(string)


Fixed code:
import sys
import numpy
import math

N=int(input())

A=list(map(int,input().split()))

dekaiyatu=numpy.argmax(A)
kati=A[dekaiyatu]

A.pop(dekaiyatu)
iikanjinoyatu= numpy.argmin(list(map((lambda x: abs((kati/2)-x)), A)))
string=str(kati)+" "+str(A[iikanjinoyatu])

print(string)
Buggy code:
n=int(input())
l=list(map(int,input().split()))
m=max(l)
if m%2!=0:
  med=(m+1)//2
else:
  med=m//2
mi=m
for ll in l:
  mi=min(mi,abs(ll-med))
print(m,mi)

Fixed code:
n=int(input())
l=list(map(int,input().split()))
m=max(l)
l.remove(m)
if m%2!=0:
  med=(m+1)//2
else:
  med=m//2
mi=m
for ll in l:
  mi=min(mi,abs(ll-med))
if med+mi in l:
  print(m,med+mi)
else:
  print(m,med-mi)
Buggy code:
n=int(input())
a=list(map(int,input().split()))
a.sort()

b=len(a)
Z=a[-1]
X=0
for i in range(1,N-1):
  if abs((Z/2)-A[X])>abs((Z/2)-A[i]):
    X=i



print(a[-1],a[l])

Fixed code:
n=int(input())
a=list(map(int,input().split()))
a.sort()

b=len(a)
Z=a[-1]
X=0
for i in range(1,n-1):
  if abs((Z/2)-a[X])>abs((Z/2)-a[i]):
    X=i



print(a[-1],a[X])
Buggy code:
N = int(input())
A = list(map(int,input().split()))

A.sort()

ai = A[-1]

M = min(ai-A[0], A[0])
aj = A[0]

for i in range(N):
    m = min(ai-A[i], A[i])
    if M < m:
        aj = A[i]
        M = m
    else:
        break

print(ai,aj)

Fixed code:
N = int(input())
A = list(map(int,input().split()))

A.sort()

ai = A[-1]

M = min(ai-A[0], A[0])
aj = A[0]

for i in range(N):
    m = min(ai-A[i], A[i])
    if M < m:
        aj = A[i]
        M = m

print(ai,aj)
Buggy code:
import bisect
n = int(input())
a = list(map(int,input().split()))

a.sort()

ai = a[-1]

ind = bisect.bisect_left(a,ai//2+1)

if a[ind-1] <= ai-a[ind]:
    aj = a[ind]
else:
    aj = a[ind-1]

print(ai,aj)


Fixed code:
import bisect
n = int(input())
a = list(map(int,input().split()))

a.sort()

ai = a[-1]

ind = bisect.bisect_left(a,ai//2+1)

if a[ind-1] < ai-a[ind]:
    aj = a[ind]
else:
    aj = a[ind-1]

print(ai,aj)
Buggy code:
import math
 
def comb(n,r):
    return int(math.factorial(n)/(math.factorial(r)*math.factorial(n-r)))

def deff_half(l, h):
    d = abs(h - l[0])
    r = 0
    for i in range(1, len(l)):
        if d > abs(h - l[i]):
            d = abs(h - l[i])
            r = i
    return l[r]
    
n = int(input())
x = list(map(int, input().split(" ")))
 
a = max(x)
result = deff_half(x, a/2)

print(a , result)

Fixed code:
import math
 
def comb(n,r):
    return int(math.factorial(n)/(math.factorial(r)*math.factorial(n-r)))

def deff_half(l, h):
    d = abs(h/2 - l[0])
    r = 0
    for i in range(1, len(l)):
        if l[i] == h:
            continue
        if d >= abs(h/2 - l[i]):
            d = abs(h/2 - l[i])
            r = i
    return l[r]
    
n = int(input())
x = list(map(int, input().split(" ")))
 
a = max(x)
result = deff_half(x, a)

print(a , result)
Buggy code:
n = int(input())
an = list(map(int, input().split()))

maxi = max(an)
v = maxi
for a in an:
  if a == maxi:
    continue
  if abs(a-maxi/2) < abs(v-maxi/2):
    v = a
print(' '.join( map(str, [maxi, v]) ))

Fixed code:
n = int(input())
an = list(map(int, input().split()))
if n == 2:
  print(' '.join( map(str, [max(an), min(an)]) ))
  exit()

maxi = max(an)
v = maxi
for a in an:
  if a == maxi:
    continue
  if abs(a-maxi/2) < abs(v-maxi/2):
    v = a
print(' '.join( map(str, [maxi, v]) ))
Buggy code:
n = int(input())
a = sorted([int(_) for _ in input().split()])[::-1]
m = a[0]
half = m/2
r = m
for i in a:
    if abs(half-i) < abs(half-r):
        r = i

print(m, r)

Fixed code:
n = int(input())
a = sorted([int(_) for _ in input().split()])[::-1]
m = a[0]
half = m/2
r = a[1]
for i in range(1, n):
    if abs(half-a[i]) < abs(half-r):
        r = a[i]

print(m, r)
Buggy code:
N = int(input())
A = list(map(int,input().split()))
maxA = max(A)
B = [abs(i-maxA/2) for i in A]
mid_pA = int(min(B) + maxA/2)
mid_mA = int(-min(B) + maxA/2)
for i in A:
    if i == mid_pA:
        print(maxA,mid_pA)
        break
    elif i == mid_mA:
        print(maxA,mid_mA)
        break

Fixed code:
N = int(input())
A = list(map(int,input().split()))
maxA = max(A)
B = [abs(i-maxA/2) for i in A]
mid_pA = int(min(B) + maxA/2)
mid_mA = int(-min(B) + maxA/2)
A.sort()
for i in A[:N]:
    if i == mid_pA:
        print(maxA,mid_pA)
        break
    elif i == mid_mA:
        print(maxA,mid_mA)
        break
Buggy code:
import math
n = int(input())
a = list(map(int,input().split()))

a = sorted(a, reverse = True)
mid = a[0]//2
diff = abs(mid - a[0])

if n == 2:
    print(max(a[0],a[1]),min(a[0],a[1]))
else:
    for i in range(n):
        if abs(a[i] - mid) <= diff:
            diff = abs(a[i] - mid)
            ans = i
    print(a[0], a[ans])

Fixed code:
import math
n = int(input())
a = list(map(int,input().split()))

a = sorted(a, reverse = True)
mid = a[0]//2
diff = abs(mid - a[0])

if n == 2:
    print(max(a[0],a[1]),min(a[0],a[1]))
else:
    for i in range(n):
        if abs(a[i] - mid) < diff:
            diff = abs(a[i] - mid)
            ans = i
    print(a[0], a[ans])
Buggy code:
n = int(input())
a = list(map(int,input().split()))
a = sorted(a, reverse = True)

ai = a[0] // 2
aj = 0
comb = 10 ** 10
for i in range(n):
    temp = abs(a[i] - ai)
    if comb >= temp:
        comb = temp
        aj = a[i]
print(a[0], aj)

Fixed code:
n = int(input())
a = list(map(int,input().split()))
a = sorted(a, reverse = True)

ai = a[0] / 2
aj = 0
comb = 10 ** 10
for i in range(n):
    temp = abs(a[i] - ai)
    if comb >= temp:
        comb = temp
        aj = a[i]
print(a[0], aj)
Buggy code:
n = int(input())
A = list(map(int,input().split()))
ai = max(A)
dif = list(map(lambda a:abs(ai/2-a),A))
print(ai,A[dif.index(min(dif))])

Fixed code:
n = int(input())
A = list(map(int,input().split()))
ai = max(A)
A.pop(A.index(ai))
dif = list(map(lambda a:abs(ai/2-a),A))
print(ai,A[dif.index(min(dif))])
Buggy code:
n = int(input())
a = [int(x) for x in input().split()]

t = max(a)
b = []

for i in range(n):
  u = abs(n / 2 - a[i])
  b.append(u)

v = a[u.index(min(b))]
print(t, v)

Fixed code:
n = int(input())
a = [int(x) for x in input().split()]

t = max(a)
b = []

for i in range(n):
  if t != a[i]:
    u = abs(t / 2 - a[i])
    b.append(u)
  else:
    b.append(t)

v = a[b.index(min(b))]
print(t, v)
Buggy code:
N=int(input())
A=[int(i) for i in input().split()]
M=max(A)
S=0
j=0
for i in range(N):
  if S>abs(2*A[i]-M):
    j=i
    S=abs(2*A[j]-M)
print(M,A[j])


Fixed code:
N=int(input())
A=[int(i) for i in input().split()]
M=max(A)
S=10**9
j=0
for i in range(N):
  if S>=abs(2*A[i]-M):
    j=i
    S=abs(2*A[j]-M)
print(M,A[j])
Buggy code:
n = int(input())
A = map(int, input().split())
 
ai = max(A)
A.remove(ai)
 
Asub = [abs(ai/2 -a) for a in A]
aj = A[Asub.index(min(Asub))]
 
print('{} {}'.format(ai, aj))

Fixed code:
n = int(input())
A = list(map(int, input().split()))

ai = max(A)
A.remove(ai)

Asub = [abs(ai/2 -a) for a in A]
aj = A[Asub.index(min(Asub))]

print('{} {}'.format(ai, aj))
Buggy code:
# coding : utf-8

import numpy as np

N = int(input())
X = np.array([int(i) for i in input().split()])

maxl = np.max(X)
Xed = X - int(maxl/2)
com = X[np.where(np.min(Xed))]

print(maxl,com[0])


Fixed code:
# coding : utf-8

import numpy as np

N = int(input())
X = np.array([int(i) for i in input().split()])

X = np.sort(X)
maxl = np.max(X)
Xed = (X - maxl/2)**2
com = X[np.where(Xed == np.min(Xed))]

print(maxl,com[0])
Buggy code:
#import numpy as np
#import math
import sys

read = lambda: sys.stdin.readline().rstrip()

class Solution(object):
    def binomial_coefficients(self, n, A):

        n0 = max(A)
        mid, r, cur = n0 / 2, -1, float("inf")
        for i in A:
            if i != n0:
                x = abs(mid - i)
                if x < cur:
                    r, cur = i, x
        return n, r

def main():
    n0 = int(read())
    A0 = tuple(map(int, read().split()))

    res0, res1 = Solution().binomial_coefficients(n0, A0)

    print(res0, res1)
 
if __name__ == "__main__":
    main()

Fixed code:
#import numpy as np
#import math
import sys

read = lambda: sys.stdin.readline().rstrip()

class Solution(object):
    def binomial_coefficients(self, n, A):

        n0 = max(A)

        mid, r, cur = n0 / 2, -1, float("inf")
        for i in A:
            if i != n0:
                x = abs(mid - i)
                if x < cur:
                    r, cur = i, x
        return n0, r

def main():
    n0 = int(read())
    A0 = tuple(map(int, read().split()))

    res0, res1 = Solution().binomial_coefficients(n0, A0)

    print(res0, res1)
 
if __name__ == "__main__":
    main()
Buggy code:
n = int(input())
x = [int(i) for i in input().split()]

x.sort()
mx = x[n-1]
print(mx," ",sep="",end="")
i = 1
while True:
    if x[i] - mx/2 >= 0:
        break
    i += 1
if mx/2 - x[i-1] < x[i] - mx/2:
    print(x[i-1])
else:
    print(x[i])


Fixed code:
n = int(input())
x = [int(i) for i in input().split()]

x.sort()
mx = x[n-1]
print(mx," ",sep="",end="")
i = 1
while True:
    if x[i] - mx/2 >= 0:
        break
    i += 1
if mx/2 - x[i-1] <= x[i] - mx/2:
    print(x[i-1])
else:
    print(x[i])
Buggy code:
n = int(input())
a = list(map(int, input().split()))

max_a = max(a)

ans = max_a
for i in range(n):
    if abs(ans - max_a/2) > abs(a[i] - max_a/2):
        ans = a[i]

print(max_a, ans)

Fixed code:
n = int(input())
a = list(map(int, input().split()))

max_a = max(a)

ans = 0
for i in range(n):
    if abs(ans - max_a/2) > abs(a[i] - max_a/2):
        ans = a[i]

print(max_a, ans)