Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
numbers=[]
for _ in range(N):
    X,L=map(int,input().split())
    left=X-L
    right=X+L
    numbers.append([right,left])
numbers=sorted(numbers)
answer=1
large=numbers[0][0]
for  _ in range(len(numbers)-1):
    if numbers[answer][0]>large and numbers[answer][1]>=large:
        large=numbers[answer][0]
        answer+=1
    else:
        del numbers[answer]
print(answer)


Fixed submission:
N=int(input())
numbers=[]
for _ in range(N):
    X,L=map(int,input().split())
    left=X-L
    right=X+L
    numbers.append([right,left])
numbers=sorted(numbers)
answer=1
large=numbers[0][0]
for  _ in range(len(numbers)-1):
    if numbers[answer][0]>large and numbers[answer][1]>=large:
        large=numbers[answer][0]
        answer+=1
    else:
        del numbers[answer]
print(answer)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
numbers=[]
for _ in range(N):
    X,L=map(int,input().split())
    left=X-L
    right=X+L
    numbers.append([right,left])
numbers=sorted(numbers)
answer=1
for  _ in range(len(numbers)-1):
    if numbers[answer][0]>numbers[answer-1][0] and numbers[answer][1]>=numbers[answer-1][0]:
        answer+=1
    else:
        del numbers[answer]
print(answer)


Fixed submission:
N=int(input())
numbers=[]
for _ in range(N):
    X,L=map(int,input().split())
    left=X-L
    right=X+L
    numbers.append([right,left])
numbers=sorted(numbers)
answer=1
large=numbers[0][0]
for  _ in range(len(numbers)-1):
    if numbers[answer][0]>large and numbers[answer][1]>=large:
        large=numbers[answer][0]
        answer+=1
    else:
        del numbers[answer]
print(answer)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
numbers=[]
for _ in range(N):
    X,L=map(int,input().split())
    left=X-L
    right=X+L
    numbers.append([right,left])
numbers=sorted(numbers)
answer=1
for  _ in range(len(numbers)-1):
    if numbers[answer][0]>numbers[answer-1][0] and numbers[answer][1]>=numbers[answer-1][0]:
        answer+=1
    else:
        del numbers[answer]
print(answer)


Fixed submission:
N=int(input())
numbers=[]
for _ in range(N):
    X,L=map(int,input().split())
    left=X-L
    right=X+L
    numbers.append([right,left])
numbers=sorted(numbers)
answer=1
large=numbers[0][0]
for  _ in range(len(numbers)-1):
    if numbers[answer][0]>large and numbers[answer][1]>=large:
        large=numbers[answer][0]
        answer+=1
    else:
        del numbers[answer]
print(answer)
Buggy python submission (verdict: Time Limit Exceeded):
N,K,S=map(int,input().split())
answers=[S]*K
answers_=[S+1]*(N-K)
answer=''
for k in range(K):
    answer+=str(answers[k])
    answer+=' '
for answer_ in answers_:
    answer+=str(answer_)
    answer+=' '
print(answer)


Fixed submission:
N,K,S=map(int,input().split())
answers=[str(S)]*K
answers_=[str(S+1)]*(N-K)
a=' '.join(answers)
b=' '.join(answers_)
if K==0:
    if S==pow(10,9):
        answers_ = ['1'] * (N - K)
        b = ' '.join(answers_)
        c=b
    else:
        c=b
elif S==pow(10,9):
    answers_=['1']*(N-K)
    b = ' '.join(answers_)
    c=a+' '+b
else:
    c = a + ' ' + b
print(c)

Buggy python submission (verdict: Time Limit Exceeded):
N,K,S=map(int,input().split())
answers=[S]*K
for _ in range(N-K):
    answers.append(S+1)
answer=''
for answer_ in answers:
    answer+=str(answer_)
    answer+=' '
print(answer)


Fixed submission:
N,K,S=map(int,input().split())
answers=[str(S)]*K
answers_=[str(S+1)]*(N-K)
a=' '.join(answers)
b=' '.join(answers_)
if K==0:
    if S==pow(10,9):
        answers_ = ['1'] * (N - K)
        b = ' '.join(answers_)
        c=b
    else:
        c=b
elif S==pow(10,9):
    answers_=['1']*(N-K)
    b = ' '.join(answers_)
    c=a+' '+b
else:
    c = a + ' ' + b
print(c)
Buggy python submission (verdict: Time Limit Exceeded):
N,M=map(int,input().split())
words=[[] for _ in range(N)]
for _ in range(M):
    p,S=input().split()
    p=int(p)-1
    words[p].append(S)
AC=0
WA=0
for a in words:
    for b in a:
        if a.count('WA') != 0 and len(a) == a.count('WA'):
            break
        if b=='AC':
            AC+=1
            break
        elif b=='WA':
            WA+=1
print(AC,WA)


Fixed submission:
N,M=map(int,input().split())
words=[[] for _ in range(N)]
for _ in range(M):
    p,S=input().split()
    p=int(p)-1
    words[p].append(S)
AC=0
WA=0
for a in words:
    if a.count('WA') != 0 and len(a) == a.count('WA'):
        continue
    for b in a:
        if b=='AC':
            AC+=1
            break
        elif b=='WA':
            WA+=1
print(AC,WA)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
a=input().split()
A=[int(b) for b in a]
B=[format(a,'b').zfill(100) for a in A]
mod=pow(10,9)+7
answer=0
for i in range(100):
    zero=0
    one=0
    kotae=1
    for j in B:
        if j[i]=='0':
            zero+=1
        elif j[i]=='1':
            one+=1
    kotae=zero*one
    for _ in range(100-i-1):
        kotae*=2
    answer+=kotae
print(answer%mod)


Fixed submission:
N=int(input())
a=input().split()
A=[int(b) for b in a]
B=[format(a,'b').zfill(60) for a in A]
mod=pow(10,9)+7
answer=0
for i in range(60):
    zero=0
    one=0
    kotae=1
    for j in B:
        if j[i]=='0':
            zero+=1
        elif j[i]=='1':
            one+=1
    kotae=zero*one
    for _ in range(60-i-1):
        kotae*=2
    answer+=kotae
print(answer%mod)
Buggy python submission (verdict: Runtime Error):
def fl(x):
    digits = 8
    form = '%.'+str(digits-1)+'e'
    return float((form % x))
a,b,x=map(int,input().split())
import math
if x>=a*b/2:
    print(90 - math.degrees(math.atan(fl(a / 2 / (b - fl(x / a ** 2))))))
else:
    tate=fl(2*x/a/b)
    print(90-math.degrees(math.atan(fl(tate/b))))


Fixed submission:
import math
a,b,x=map(int,input().split())
S=x/a
if S<=a*b/2:
    h=2*S/b
    answer=math.degrees(math.atan(b/h))
    print(answer)
else:
    T=a*b-S
    h=2*T/a
    answer=math.degrees(math.atan(h/a))
    print(answer)

Buggy python submission (verdict: Runtime Error):
a,b,x=map(int,input().split())
import math
if x>=a*b/2:
    print(90 - math.degrees(math.atan(a / 2 / (b - x / a ** 2))))
else:
    tate=2*x/a/b
    print(90-math.degrees(math.atan(tate/b)))
    

Fixed submission:
import math
a,b,x=map(int,input().split())
S=x/a
if S<=a*b/2:
    h=2*S/b
    answer=math.degrees(math.atan(b/h))
    print(answer)
else:
    T=a*b-S
    h=2*T/a
    answer=math.degrees(math.atan(h/a))
    print(answer)

Buggy python submission (verdict: Runtime Error):
a,b,x=map(int,input().split())
import math
print(90-math.degrees(math.atan(a/2/(b-x/a**2))))


Fixed submission:
import math
a,b,x=map(int,input().split())
S=x/a
if S<=a*b/2:
    h=2*S/b
    answer=math.degrees(math.atan(b/h))
    print(answer)
else:
    T=a*b-S
    h=2*T/a
    answer=math.degrees(math.atan(h/a))
    print(answer)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
L=input().split()
A=[int(a) for a in L]
B=sorted(A)
answer=0
for a in range(N-1):
    number=1
    while a+number<N-1:
        suuji = number + 1
        saisho=B[a]
        tonari=B[a+number]
        goukei=saisho+tonari
        while a+suuji<N:
            tar=B[a+suuji]
            if goukei>tar:
                answer+=1
            else:
                break
            suuji+=1
        number+=1
print(answer)


Fixed submission:
N=int(input())
L=list(map(int,input().split()))
sort_L=sorted(L,reverse=True)
ans=0
for n in range(N-2):
    for o in range(n+1,N-1):
        lar=sort_L[n]
        kouho=sort_L[o+1:]
        mid=sort_L[o]
        sa=lar-mid
        left=0
        right=N-o-2
        if kouho[-1]>sa:
            ans+=right+1
        else:
            while right > left + 1:
                half = (right + left) // 2
                if kouho[half] <= sa:
                    right = half
                else:
                    left = half
            if kouho[right]<=sa and kouho[left]<=sa:
                continue
            elif kouho[right]>sa:
                ans+=right+1
            else:
                ans+=left+1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import math
A,B=map(int,input().split())
#nの約数を全て求める
def divisor(n):
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table
answers=[]
a=divisor(A)
b=divisor(B)
for a_ in a:
    if a_ in b:
        answers.append(a_)
n = len(answers)
numbers=[]
for i in range(2 ** n):
    number = []
    for j in range(n):  # このループが一番のポイント
        if ((i >> j) & 1):  # 順に右にシフトさせ最下位bitのチェックを行う
            number.append(answers[j])  # フラグが立っていたら bag に果物を詰める
    numbers.append(number)
del numbers[0]
answer=0
for number in numbers:
    ans=0
    for m in range(len(number)-1):
        for n in range(m+1,len(number)):
            a=math.gcd(number[m],number[n])
            if a!=1:
                ans=1
                break
    if ans==0:
        answer=max(answer,len(number))
print(answer)


Fixed submission:
A,B=map(int,input().split())
def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]
a=make_divisors(A)
b=make_divisors(B)
kouyakusuu=set(a)&set(b)
out=[]
kouho=sorted(list(kouyakusuu))
del kouho[0]
for a in range(len(kouho)-1):
    for b in range(a+1,len(kouho)):
        if kouho[b]%kouho[a]==0:
            out.append(kouho[b])
answer=set(out)
print(len(kouho)+1-len(answer))
Buggy python submission (verdict: Time Limit Exceeded):
import heapq
N,M=map(int,input().split())
a=list(map(int,input().split()))
heapq.heapify(a)
for _ in range(M):
    a = list(map(lambda x: x * (-1), a))  # 各要素を-1倍
    heapq.heapify(a)  # リストを優先度付きキューへ
    number=heapq.heappop(a) * (-1) # 最大値の取り出し
    a = list(map(lambda x: x * (-1), a))  # 各要素を-1倍
    heapq.heappush(a, number//2)  # 要素の挿入
print(sum(a))


Fixed submission:
import heapq
N,M=map(int,input().split())
a=list(map(int,input().split()))
a = list(map(lambda x: x * (-1), a))  # 各要素を-1倍
heapq.heapify(a)  # リストを優先度付きキューへ
for _ in range(M):
    number=heapq.heappop(a)  # 最大値の取り出し
    if number%2==0:
        number=number//2
    else:
        number=number//2+1
    heapq.heappush(a, number)  # 要素の挿入
print(-sum(a))
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
S=[a for a in range(1,N)]
print(sum(S))


Fixed submission:
N=int(input())
print((N*(N-1)//2))
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
S={}
SS=[]
answer=0
for _ in range(N):
    s=input()
    s=sorted(s)
    s=str(s)
    if s in SS:
        answer+=S[s]
        S[s] += 1
    else:
        SS.append(s)
        S[s]=1
print(answer)


Fixed submission:
import collections
N=int(input())
SS=[]
answer=0
for _ in range(N):
    s=input()
    s=sorted(s)
    S=''
    for a in s:
        S+=a
    SS.append(S)
a=collections.Counter(SS)
for n in a.values():
   answer+=(n-1)*n/2
print(int(answer))
Buggy python submission (verdict: Time Limit Exceeded):
import heapq
N,M=map(int,input().split())
A=list(map(int,input().split()))
numbers=[]
for _ in range(M):
    B,C=map(int,input().split())
    number=[C]*B
    numbers+=number
    numbers=sorted(numbers,reverse=True)
    numbers=numbers[:N]
numbers+=A
answer=sorted(numbers,reverse=True)
print(sum(answer[:N]))


Fixed submission:
import heapq
N,M=map(int,input().split())
A=list(map(int,input().split()))
heapq.heapify(A)
numbers=[]
for _ in range(M):
    B,C=map(int,input().split())
    numbers.append([C,B])
numbers=sorted(numbers,reverse=True)
for number in numbers:
    B=number[1]
    C=number[0]
    for _ in range(B):
        a = heapq.heappop(A)
        if C <= a:
            heapq.heappush(A, a)
            break
        else:
            heapq.heappush(A,C)
print(sum(A))

Buggy python submission (verdict: Time Limit Exceeded):
import heapq
N,M=map(int,input().split())
A=list(map(int,input().split()))
heapq.heapify(A)
for _ in range(M):
    B,C=map(int,input().split())
    for _ in range(B):
        a = heapq.heappop(A)
        if C <= a:
            heapq.heappush(A, a)
            break
        else:
            heapq.heappush(A,C)
print(sum(A))


Fixed submission:
import heapq
N,M=map(int,input().split())
A=list(map(int,input().split()))
heapq.heapify(A)
numbers=[]
for _ in range(M):
    B,C=map(int,input().split())
    numbers.append([C,B])
numbers=sorted(numbers,reverse=True)
for number in numbers:
    B=number[1]
    C=number[0]
    for _ in range(B):
        a = heapq.heappop(A)
        if C <= a:
            heapq.heappush(A, a)
            break
        else:
            heapq.heappush(A,C)
print(sum(A))
Buggy python submission (verdict: Runtime Error):
import math
N=int(input())
a=input().split()
A=[int(b) for b in a]
A=sorted(A,reverse=True)
numbers=[]
numbers.append(math.gcd(A[0],A[1]))
for a in range(1,N):
    answer=math.gcd(numbers[-1],A[a])
    numbers.append(answer)
print(numbers[-1])


Fixed submission:
import fractions
N=int(input())
a=input().split()
A=[int(b) for b in a]
A=sorted(A,reverse=True)
numbers=[]
numbers.append(fractions.gcd(A[0],A[1]))
for a in range(1,N):
    answer=fractions.gcd(numbers[-1],A[a])
    numbers.append(answer)
print(numbers[-1])

Buggy python submission (verdict: Runtime Error):
import math
N=int(input())
a=input().split()
A=[int(b) for b in a]
A=sorted(A,reverse=True)
numbers=[]
numbers.append(math.gcd(A[0],A[1]))
for a in range(1,N):
    answer=math.gcd(numbers[-1],A[a])
    numbers.append(answer)
print(numbers[-1])


Fixed submission:
import fractions
N=int(input())
a=input().split()
A=[int(b) for b in a]
A=sorted(A,reverse=True)
numbers=[]
numbers.append(fractions.gcd(A[0],A[1]))
for a in range(1,N):
    answer=fractions.gcd(numbers[-1],A[a])
    numbers.append(answer)
print(numbers[-1])

Buggy python submission (verdict: Runtime Error):
import math
N=int(input())
a=input().split()
A=[int(b) for b in a]
A=sorted(A,reverse=True)
numbers=[]
for n in range(N-1):
    answer=math.gcd(A[n],A[n+1])
    numbers.append(answer)
numbers.append(A[-1])
print(min(numbers))


Fixed submission:
import fractions
N=int(input())
a=input().split()
A=[int(b) for b in a]
A=sorted(A,reverse=True)
numbers=[]
numbers.append(fractions.gcd(A[0],A[1]))
for a in range(1,N):
    answer=fractions.gcd(numbers[-1],A[a])
    numbers.append(answer)
print(numbers[-1])

Buggy python submission (verdict: Runtime Error):
import math
N=int(input())
a=input().split()
A=[int(b) for b in a]
A=sorted(A,reverse=True)
numbers=[]
for n in range(N-1):
    answer=math.gcd(A[n],A[n+1])
    numbers.append(answer)
print(min(numbers))


Fixed submission:
import fractions
N=int(input())
a=input().split()
A=[int(b) for b in a]
A=sorted(A,reverse=True)
numbers=[]
numbers.append(fractions.gcd(A[0],A[1]))
for a in range(1,N):
    answer=fractions.gcd(numbers[-1],A[a])
    numbers.append(answer)
print(numbers[-1])
Buggy python submission (verdict: Time Limit Exceeded):
N,W=map(int,input().split())
numbers=[]
for _ in range(N):
    w,v=input().split()
    numbers.append([int(w),int(v)])
def chmax(a,b):
    if a>=b:
        return a
    else:
        return b
dp=[[0 for i in range(W+1)] for j in range(N+1)]
for a in range(N):
    for sum_w in range(W+1):
        if sum_w-numbers[a][0]>=0:
            dp[a+1][sum_w]=chmax(dp[a+1][sum_w],dp[a][sum_w-numbers[a][0]]+numbers[a][1])
        dp[a+1][sum_w]=chmax(dp[a+1][sum_w],dp[a][sum_w])
print(dp[N][W])


Fixed submission:
N,W=map(int,input().split())
numbers=[]
for _ in range(N):
    w,v=input().split()
    numbers.append([int(w),int(v)])
def chmax(a,b):
    if a>=b:
        return a
    else:
        return b
dp=[[0 for i in range(W+1)] for j in range(N+1)]
for a in range(N):
    for sum_w in range(W+1):
        if sum_w-numbers[a][0]>=0:
            dp[a+1][sum_w]=chmax(dp[a+1][sum_w],dp[a][sum_w-numbers[a][0]]+numbers[a][1])
        dp[a+1][sum_w]=chmax(dp[a+1][sum_w],dp[a][sum_w])
print(dp[N][W])
Buggy python submission (verdict: Runtime Error):
import math
from collections import Counter
N, P = map(int, input().split())
if P == 1:
    print(1)
elif N == 1:
    print(P)
else:
    Eratosthenes = [p for p in range(2, math.ceil(P ** 0.5))]
    number = Eratosthenes[0]
    sosuu = []
    while number < P ** 0.25:
        sosuu.append(number)
        n_Eratosthenes = []
        for n in Eratosthenes:
            if n % number == 0:
                pass
            else:
                n_Eratosthenes.append(n)
        if len(n_Eratosthenes) == 0:
            break
        number = n_Eratosthenes[0]
        Eratosthenes = n_Eratosthenes
    numbers=sosuu+Eratosthenes
    suuji=0
    answers=[]
    while P>1:
        number=numbers[suuji]
        if P%number==0:
            answers.append(number)
            P=P//number
        else:
            suuji+=1
    kotae=Counter(answers)
    answer=1
    for key,value in kotae.items():
        if value>=N:
            answer*=key
    print(answer)


Fixed submission:
import math
from collections import Counter
N, P = map(int, input().split())
if P == 1:
    print(1)
elif N == 1:
    print(P)
else:
    Eratosthenes = [p for p in range(2, math.ceil(P ** 0.5))]
    number = Eratosthenes[0]
    sosuu = []
    while number < P ** 0.25:
        sosuu.append(number)
        n_Eratosthenes = []
        for n in Eratosthenes:
            if n % number == 0:
                pass
            else:
                n_Eratosthenes.append(n)
        if len(n_Eratosthenes) == 0:
            break
        number = n_Eratosthenes[0]
        Eratosthenes = n_Eratosthenes
    numbers=sosuu+Eratosthenes
    suuji=0
    answers=[]
    while P>1 and suuji<len(numbers):
        number=numbers[suuji]
        if P%number==0:
            answers.append(number)
            P=P//number
        else:
            suuji+=1
    kotae=Counter(answers)
    answer=1
    for key,value in kotae.items():
        kazu=value//N
        if kazu==0:
            continue
        else:
            answer*=(key**kazu)
    print(answer)
Buggy python submission (verdict: Time Limit Exceeded):
N,M=map(int,input().split())
numbers=[]
for _ in range(M):
    a,b=input().split()
    numbers.append([int(b),int(a)])
new_numbers=sorted(numbers)
answers=[]


while new_numbers:
    large = new_numbers[0][0]
    if  not new_numbers[0] in answers:
        answers.append(new_numbers[0])
    new_numbers=[a for a in new_numbers if a[1]>=large]
print(len(answers))


Fixed submission:
N,M=map(int,input().split())
numbers=[]
for _ in range(M):
    a,b=input().split()
    numbers.append([int(b),int(a)])
new_numbers=sorted(numbers)
answers=[]
while new_numbers:
    large = new_numbers[0][0]
    if  not new_numbers[0] in answers:
        answers.append(new_numbers[0])
    new_numbers=[a for a in new_numbers if a[1]>=large]
print(len(answers))
Buggy python submission (verdict: Runtime Error):
s=input()
K=int(input())
answers=[]
S=[a for a in s]
N=len(S)
for a in range(N):
    number = 0
    while a + number <= N and number<=K:
        z = S[a:a + number]
        answers.append(z)
        number += 1
kotae = []
for a in answers:
    if a in kotae:
        pass
    else:
        kotae.append(a)
kotae = sorted(kotae)
answer=kotae[K]
moji=''
for a in answer:
    moji+=a
print(moji)


Fixed submission:
a,b,c,d=map(int,input().split())
if abs(c-a)<=d:
    print('Yes')
elif abs(a-b)<=d and abs(b-c)<=d:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Time Limit Exceeded):
import math
import statistics
N=int(input())
X=input().split()
Y=[int(a) for a in X]
Z=tuple(Y)
for a in range(N):
    b=Z[a]
    answer=list(Z)
    answer.remove(b)
    answer=sorted(answer)
    print(answer[int(N/2-1)])


Fixed submission:
N=int(input())
X=input().split()
Y=[int(a) for a in X]
Z=sorted(Y)
a=Z[int(N/2-1)]
b=Z[int(N/2)]
for c in range(N):
    if Y[c]<=a:
        print(b)
    else:
        print(a)

Buggy python submission (verdict: Time Limit Exceeded):
import math
import statistics
N=int(input())
X=input().split()
Y=[int(a) for a in X]
Z=tuple(Y)
for a in range(N):
    b=Z[a]
    answer=list(Z)
    answer.remove(b)
    print(statistics.median(answer))
    

Fixed submission:
N=int(input())
X=input().split()
Y=[int(a) for a in X]
Z=sorted(Y)
a=Z[int(N/2-1)]
b=Z[int(N/2)]
for c in range(N):
    if Y[c]<=a:
        print(b)
    else:
        print(a)
Buggy python submission (verdict: Runtime Error):
N=int(input())
A=list(map(int,input().split()))
if N==2:
    print(*A)
else:
    A=sorted(A)
    ans1=A[-1]
    del A[-1]
    saidai=ans1/2
    num=pow(10,9)
    for n in range(N-2):
        if abs(saidai-A[n])<=num:
            num=abs(saidai-A[n])
        else:
            ans2=n-1
    print(ans1,A[ans2])
    

Fixed submission:
N=int(input())
A=list(map(int,input().split()))
sort_A=sorted(A)
max_A=sort_A[-1]
answer=[]
half_A=max_A//2
number=pow(10,9)
answer=0
for n in range(N-1):
    if number>=abs(sort_A[n]-half_A):
        answer=n
        number=abs(sort_A[n]-half_A)
print(max_A,sort_A[answer])

Buggy python submission (verdict: Time Limit Exceeded):
import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
N=int(input())
A=list(map(int,input().split()))
if N==2:
    print(*A)
else:
    A=sorted(A)
    ans1=A[-1]
    del A[-1]
    saidai=ans1/2
    left=0
    right=N-2
    while right-left>1:
        mid=(left+right)//2
        if A[mid]>=saidai:
            right=mid
        else:
            left=mid
    r=combinations_count(ans1,A[right])
    l=combinations_count(ans1,A[left])
    if r>=l:
        print(ans1,A[right])
    else:
        print(ans1,A[left])
        

Fixed submission:
N=int(input())
A=list(map(int,input().split()))
sort_A=sorted(A)
max_A=sort_A[-1]
answer=[]
half_A=max_A//2
number=pow(10,9)
answer=0
for n in range(N-1):
    if number>=abs(sort_A[n]-half_A):
        answer=n
        number=abs(sort_A[n]-half_A)
print(max_A,sort_A[answer])

Buggy python submission (verdict: Time Limit Exceeded):
import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
N=int(input())
A=list(map(int,input().split()))
if N==2:
    print(*A)
else:
    A=sorted(A)
    ans1=A[-1]
    num=0
    flag=0
    for n in range(N-1):
        if combinations_count(ans1,A[n])>=num:
            num=combinations_count(ans1,A[n])
        else:
            flag=1
            break
    if flag==1:
        print(ans1,A[n-1])
    else:
        print(ans1,A[-2])
        

Fixed submission:
N=int(input())
A=list(map(int,input().split()))
sort_A=sorted(A)
max_A=sort_A[-1]
answer=[]
half_A=max_A//2
number=pow(10,9)
answer=0
for n in range(N-1):
    if number>=abs(sort_A[n]-half_A):
        answer=n
        number=abs(sort_A[n]-half_A)
print(max_A,sort_A[answer])
Buggy python submission (verdict: Runtime Error):
A,B=map(int,input().split())
S=input()
number=0
list=['0','1','2','3','4'.'5','6','7','8','9']
for a in range(A):
    if S[a] in list:
        number+=1
if S[A]=='-':
    number+=1
for a in range(B):
    if S[A+a+1] in list:
        number+=1
if number==A+B+1:
    print('Yes')
else:
    print('No')


Fixed submission:
A,B=map(int,input().split())
S=input()
number=0
list=['0','1','2','3','4','5','6','7','8','9']
for a in range(A):
    if S[a] in list:
        number+=1
if S[A]=='-':
    number+=1
for a in range(B):
    if S[A+a+1] in list:
        number+=1
if number==A+B+1:
    print('Yes')
else:
    print('No')

Buggy python submission (verdict: Runtime Error):
A,B=map(int,input().split())
S=input()
number=0
list=[0,1,2,3,4,5,6,7,8,9]
for a in range(A):
    if int(S[a]) in list:
        number+=1
if S[A]=='-':
    number+=1
for a in range(B):
    if int(S[A+a+1]) in list:
        number+=1
if number==A+B+1:
    print('Yes')
else:
    print('No')
    

Fixed submission:
A,B=map(int,input().split())
S=input()
number=0
list=['0','1','2','3','4','5','6','7','8','9']
for a in range(A):
    if S[a] in list:
        number+=1
if S[A]=='-':
    number+=1
for a in range(B):
    if S[A+a+1] in list:
        number+=1
if number==A+B+1:
    print('Yes')
else:
    print('No')