TnT/CodeNet4Repair huggingface dataset:
Problem:
Takahashi has a deposit of 100 yen (the currency of Japan) in AtCoder Bank.  The bank pays an annual interest rate of 1 % compounded annually. (A fraction of less than one yen is discarded.)  Assuming that nothing other than the interest affects Takahashi's balance, in how many years does the balance reach X yen or above for the first time?

Incorrect submission (verdict: Wrong Answer):
x=int(input())
a=100
cnt=0
while x>=a:
  a=int(a*1.01)
#  print(a)
  cnt+=1
  
print(cnt)

Fixed, accepted submission:
x=int(input())
a=100
cnt=0
while x>a:
  a=int(a*1.01)
  cnt+=1

print(cnt)
Problem:
There are a total of A + B cats and dogs. Among them, A are known to be cats, but the remaining B are not known to be either cats or dogs.  Determine if it is possible that there are exactly X cats among these A + B animals.

Incorrect submission (verdict: Wrong Answer):
A, B, X = [int(x) for x in input().split()]

def solve(A, B, X):
  if A + B < X:
    print("NO")
  elif A > X:
    print("NO")
  else:
    print("YES")

Fixed, accepted submission:
A, B, X = [int(x) for x in input().split()]
if A + B < X:
  print("NO")
elif A > X:
  print("NO")
else:
  print("YES")
Problem:
We ask you to select some number of positive integers, and calculate the sum of them.  It is allowed to select as many integers as you like, and as large integers as you wish. You have to follow these, however: each selected integer needs to be a multiple of A, and you need to select at least one integer.  Your objective is to make the sum congruent to C modulo B. Determine whether this is possible.  If the objective is achievable, print `YES`. Otherwise, print `NO`.

Incorrect submission (verdict: Wrong Answer):
# -*- coding: utf-8 -*-

a, b, c = map(int, input().split())

rest = a % b
num = a

while True:
    if num % b == c:
        print('Yes')
        exit()
    num+=a
    if num % b == rest:
        print('No')
        exit()

Fixed, accepted submission:
# -*- coding: utf-8 -*-

a, b, c = map(int, input().split())

rest = a % b
num = a

while True:
    if num % b == c:
        print('YES')
        exit()
    num+=a
    if num % b == rest:
        print('NO')
        exit()
Problem:
On some day in January 2018, Takaki is writing a document. The document has a column where the current date is written in `yyyy/mm/dd` format. For example, January 23, 2018 should be written as `2018/01/23`.  After finishing the document, she noticed that she had mistakenly wrote `2017` at the beginning of the date column. Write a program that, when the string that Takaki wrote in the date column, S, is given as input, modifies the first four characters in S to `2018` and prints it.

Incorrect submission (verdict: Wrong Answer):
s= input()
if s[4]=='2017':
  print('2018'+s[4:])
else:
  print(s)

Fixed, accepted submission:
s=  input()
print(s[:3] + '8' + s[4:])
Problem:
You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively.    An example of a trapezoid  Find the area of this trapezoid.

Incorrect submission (verdict: Wrong Answer):
a=int(input())
b=int(input())
h = int(input())
print((a+b)*h/2)

Fixed, accepted submission:
a=int(input())
b=int(input())
h = int(input())
print(int((a+b)*h/2))
Problem:
There are N empty boxes arranged in a row from left to right. The integer i is written on the i-th box from the left (1 \leq i \leq N).  For each of these boxes, Snuke can choose either to put a ball in it or to put nothing in it.  We say a set of choices to put a ball or not in the boxes is good when the following condition is satisfied:    * For every integer i between 1 and N (inclusive), the total number of balls contained in the boxes with multiples of i written on them is congruent to a_i modulo 2.  Does there exist a good set of choices? If the answer is yes, find one good set of choices.

Incorrect submission (verdict: Wrong Answer):
n=int(input())
a=list(map(int,input().split()))
b=[0]*n

for i in range(n,0,-1):
    m=n//i
    total=0
    for j in range(1,m+1):
        total+=a[i*j-1]
    b[i-1]=total%2
ans=sum(b)
print(ans)
print(*b)

Fixed, accepted submission:
n=int(input())
a=list(map(int,input().split()))
b=[0]*n

for i in range(n,0,-1):
    m=n//i
    total=0
    for j in range(1,m+1):
        if j==1:
            total+=a[i-1]
        else:
            total+=b[i*j-1]
    b[i-1]=total%2
ans=sum(b)
print(ans)
if ans != 0:
    l=[]
    for i in range(n):
        if b[i]==1:
            l.append(i+1)
    print(*l)
Problem:
Write a program which reads two integers x and y, and prints them in ascending order.

Incorrect submission (verdict: Wrong Answer):
print( " ".join( sorted( input().split())))

Fixed, accepted submission:
while True :
    a, b = [int(i) for i in input().split()]
    if a == b == 0 : break
    elif a >= b :
        print(b, a)
    else : print(a,b)
Problem:
Let's arrange a deck of cards. There are totally 36 cards of 4 suits(S, H, C, D) and 9 values (1, 2, ... 9). For example, 'eight of heart' is represented by H8 and 'one of diamonds' is represented by D1.  Your task is to write a program which sorts a given set of cards in ascending order by their values using the Bubble Sort algorithms and the Selection Sort algorithm respectively. These algorithms should be based on the following pseudocode:                 BubbleSort(C) 1 for i = 0 to C.length-1 2     for j = C.length-1 downto i+1 3         if C[j].value < C[j-1].value 4             swap C[j] and C[j-1]                 SelectionSort(C) 1 for i = 0 to C.length-1 2     mini = i 3     for j = i to C.length-1 4         if C[j].value < C[mini].value 5             mini = j 6     swap C[i] and C[mini]   Note that, indices for array elements are based on 0-origin.  For each algorithm, report the stability of the output for the given input (instance). Here, 'stability of the output' means that: cards with the same value appear in the output in the same order as they do in the input (instance).

Incorrect submission (verdict: Wrong Answer):
n=int(input())
c=input().split();d=c[:]
for i in range(n-1):
 for j in range(0,n-i-1):
  if c[j][1]>c[j+1][1]:c[j],c[j+1]=c[j+1],c[j]
 m=d.index(min(d[i:]),i)
 if d[i][1]>=d[m][1]:d[i],d[m]=d[m],d[i]
print(*c);print("Stable")
print(*d)
b={i[1]for i in c}
print(["Stable","Not stable"][len(b)<len(c)])


Fixed, accepted submission:
n=int(input())
c=input().split();d=c[:]
for i in range(n-1):
 for j in range(n-i-1):
  if c[j][1]>c[j+1][1]:c[j:j+2]=c[j+1],c[j]
 m=i
 for j in range(i,n):
  if d[m][1]>d[j][1]:m=j
 d[i],d[m]=d[m],d[i]
print(*c);print("Stable")
print(*d);print(['Not s','S'][c==d]+'table')
Problem:
For given three points p1, p2, p, find the projection point x of p onto p1p2.  

Incorrect submission (verdict: Wrong Answer):
def dot(a, b):
  return a.real * b.real + a.imag * b.imag

def projection(a, b):
  return a * dot(a, b) / (abs(a) ** 2)


def solve(p0,p1,p2):
  a=p1-p0
  b=p2-p0
  pro=projection(a,b)
  t=p0+pro
  return t

def main():
  x0,y0,x1,y1=map(float,input().split())
  p0=complex(x0,y0)
  p1=complex(x1,y1)
  q=int(input())
  for i in range(q):
    p2=complex(*map(float,input().split()))
    t=solve(p0,p1,p2)
    print('{:.10f}{:.10f}'.format(t.real,t.imag))

main()



Fixed, accepted submission:
def dot(a, b):
  return a.real * b.real + a.imag * b.imag

def projection(a, b):
  return a * dot(a, b) / (abs(a) ** 2)


def solve(p0,p1,p2):
  a=p1-p0
  b=p2-p0
  pro=projection(a,b)
  t=p0+pro
  return t

def main():
  x0,y0,x1,y1=map(float,input().split())
  p0=complex(x0,y0)
  p1=complex(x1,y1)
  q=int(input())
  for i in range(q):
    p2=complex(*map(float,input().split()))
    t=solve(p0,p1,p2)
    print("{:.10f} {:.10f}".format(t.real,t.imag))

main()
Problem:
You are given three integers A, B and C. Find the minimum number of operations required to make A, B and C all equal by repeatedly performing the following two kinds of operations in any order:    * Choose two among A, B and C, then increase both by 1.   * Choose one among A, B and C, then increase it by 2.  It can be proved that we can always make A, B and C all equal by repeatedly performing these operations.

Incorrect submission (verdict: Wrong Answer):
A, B, C = map(int, input().split())
sta = max(A, B, C)
ans = 0
if (B-A) >= 2:
    kake = (B-A)//2
    A = A*kake
    ans += kake

if (B-C) >= 2:
    kake = (B-C)//2
    C = C*kake
    ans += kake


if A == B == C:
    print(ans)
elif A == C:
    print(ans+1)
else:
    print(ans+2)

Fixed, accepted submission:
A, B, C = map(int, input().split())
ans = 0
max_ABC = max(A, B, C)

if max_ABC != A:
    ans += (max_ABC - A) // 2
    A += 2 * ((max_ABC-A) // 2)

if max_ABC != B:
    ans += (max_ABC - B) // 2
    B +=  2 * ((max_ABC-B) // 2)

if max_ABC != C:
    ans += (max_ABC - C) // 2
    C += 2 * ((max_ABC-C) // 2)

if 3 * max_ABC - (A+B+C) == 2:
    ans += 1
elif 3 * max_ABC - (A+B+C) == 1:
    ans += 2
print(ans)
Problem:
There are N boxes arranged in a row. Initially, the i-th box from the left contains a_i candies.  Snuke can perform the following operation any number of times:    * Choose a box containing at least one candy, and eat one of the candies in the chosen box.  His objective is as follows:    * Any two neighboring boxes contain at most x candies in total.  Find the minimum number of operations required to achieve the objective.

Incorrect submission (verdict: Wrong Answer):
def main():
    n, x = map(int, input().split())
    A = list(map(int, input().split()))
    ans = 0
    if A[0] > x:
        ans += A[0] - x
        A[0] = x
    print(ans)

    for i in range(n - 1):
        j = i + 1
        if j < n and A[i] + A[j] > x:
            diff = A[i] + A[j] - x
            ans += diff
            A[j] -= diff
    print(ans)


if __name__ == '__main__':
    main()

Fixed, accepted submission:
def main():
    n, x = map(int, input().split())
    A = list(map(int, input().split()))
    ans = 0
    if A[0] > x:
        ans += A[0] - x
        A[0] = x

    for i in range(n - 1):
        j = i + 1
        if j < n and A[i] + A[j] > x:
            diff = A[i] + A[j] - x
            ans += diff
            A[j] -= diff
    print(ans)


if __name__ == '__main__':
    main()
Problem:
The postal code in Atcoder Kingdom is A+B+1 characters long, its (A+1)-th character is a hyphen `-`, and the other characters are digits from `0` through `9`.  You are given a string S. Determine whether it follows the postal code format in Atcoder Kingdom.

Incorrect submission (verdict: Wrong Answer):
import re

A, B = map(int, input().split())
S = input()

result = re.match('[0-9]{A}-[0-9]{B}', S)

if result:
  print('Yes')
else:
  print('No')

Fixed, accepted submission:
import re

A, B = map(int, input().split())
S = input()

pattern = '[0-9]{' + str(A) + '}-[0-9]{' + str(B) + '}'
result = re.match(pattern, S)


if result:
  print('Yes')
else:
  print('No')
Problem:
Sig has built his own keyboard. Designed for ultimate simplicity, this keyboard only has 3 keys on it: the `0` key, the `1` key and the backspace key.  To begin with, he is using a plain text editor with this keyboard. This editor always displays one string (possibly empty). Just after the editor is launched, this string is empty. When each key on the keyboard is pressed, the following changes occur to the string:    * The `0` key: a letter `0` will be inserted to the right of the string.   * The `1` key: a letter `1` will be inserted to the right of the string.   * The backspace key: if the string is empty, nothing happens. Otherwise, the rightmost letter of the string is deleted.  Sig has launched the editor, and pressed these keys several times. You are given a string s, which is a record of his keystrokes in order. In this string, the letter `0` stands for the `0` key, the letter `1` stands for the `1` key and the letter `B` stands for the backspace key. What string is displayed in the editor now?

Incorrect submission (verdict: Wrong Answer):
S = input()
ansS = ""
ansL = 0
for i in range(len(S)):
  if S[i] == 'B':
    if len(ansS) != 0 :
      ansL = len(ansS)
      ansS = ansS[:ansL-1]
  else:
    ansS += S[i]

print(int(ansS))

Fixed, accepted submission:
S = input()
ans =''
for x in S:
  if x == '0':
    ans += x
  elif x == '1':
    ans += x
  else:
    if ans!='':
      ans = ans[:-1]
print(ans)
Problem:
You are given a string S consisting of lowercase English letters. Another string T is initially empty. Determine whether it is possible to obtain S = T by performing the following operation an arbitrary number of times:    * Append one of the following at the end of T: `dream`, `dreamer`, `erase` and `eraser`.

Incorrect submission (verdict: Wrong Answer):
s = input()
n = 0
while n == 0:
  if s[len(s)-5:len(s)] == "dream":
    s = s.rstrip("ream")
    s = s.rstrip("d")
  elif s[len(s)-5:len(s)] == "erase":
    s = s.rstrip("rase")
    s = s.rstrip("e")
  elif s[len(s)-7:len(s)] == "dreamer":
    s = s.rstrip("reamer")
    s = s.rstrip("d")
  elif s[len(s)-6:len(s)] == "eraser":
    s = s.rstrip("raser")
    s = s.rstrip("e")
  else:
    if len(s) == 0:
      n = 1
      print("Yes")
    else:
      n = -1
      print("No")

Fixed, accepted submission:
s = input()
n = 0
while n == 0:
  if s[len(s)-5:len(s)] == "dream":
    s = s[:len(s)-5]
  elif s[len(s)-5:len(s)] == "erase":
    s = s[:len(s)-5]
  elif s[len(s)-7:len(s)] == "dreamer":
    s = s[:len(s)-7]
  elif s[len(s)-6:len(s)] == "eraser":
    s = s[:len(s)-6]
  else:
    if len(s) == 0:
      n = 1
      print("YES")
    else:
      n = -1
      print("NO")
Problem:
The postal code in Atcoder Kingdom is A+B+1 characters long, its (A+1)-th character is a hyphen `-`, and the other characters are digits from `0` through `9`.  You are given a string S. Determine whether it follows the postal code format in Atcoder Kingdom.

Incorrect submission (verdict: Wrong Answer):
a,b=map(int,input().split())
s=input()
f=1
for i in range(a):
   if s[i]=='-':
      f=0
if[a]!='-':
   f=0
for j in range(b):
   if s[a+1+j]=='-':
      f=0
if f:
   print('Yes')
else:
   print('No')

Fixed, accepted submission:
a,b=map(int,input().split())
s=input()
f=1
for i in range(a):
   if s[i]=='-':
      f=0
if s[a]!='-':
   f=0
for j in range(b):
   if s[a+1+j]=='-':
      f=0
if f:
   print('Yes')
else:
   print('No')
Problem:
There are N cards. The i-th card has an integer A_i written on it. For any two cards, the integers on those cards are different.  Using these cards, Takahashi and Aoki will play the following game:    * Aoki chooses an integer x.   * Starting from Takahashi, the two players alternately take a card. The card should be chosen in the following manner:     * Takahashi should take the card with the largest integer among the remaining card.     * Aoki should take the card with the integer closest to x among the remaining card. If there are multiple such cards, he should take the card with the smallest integer among those cards.   * The game ends when there is no card remaining.  You are given Q candidates for the value of x: X_1, X_2, ..., X_Q. For each i (1 \leq i \leq Q), find the sum of the integers written on the cards that Takahashi will take if Aoki chooses x = X_i.

Incorrect submission (verdict: Wrong Answer):
n,q = map(int,input().split())
a = list(map(int,input().split()))
g = [0]*(n+1)
h = [0] + a[1-n%2::2]
m = len(h)-1
for i in range(n):
  g[i+1] = g[i] + a[i]
for i in range(m):
  h[i+1] += h[i]
d = {10**10:h[-1]}
for j in range(1,(n+1)//2+1):
  tak = g[n] - g[n-j] + h[(n-2*j)//2+n%2]
  key = (a[n-j]+a[n-2*j])//2 + 1
  d[key] = tak
l = list(d.keys())
l.sort()
m = len(l)
l.append(0)
d[0] = g[n]-g[n-(n+1)//2]

for _ in range(q):
  x = int(input())
  ok,ng = m,-1
  while ok-ng>1:
    mid = (ng+ok)//2
    if l[mid] >= x:
      ok = mid
    else:
      ng = mid
  print(d[l[ok]])
  

Fixed, accepted submission:
import bisect

n, q = map(int,input().split())
a = list(map(int,input().split()))
a.reverse()
 
cums = [0]*(n+1)
cume = [0]*(n+1)
for i in range(n):
  cums[i+1] = cums[i] + a[i]
  cume[i+1] = cume[i] + a[i]*(1 - i%2)

bo = list()
sc = list()
for i in range(1,(n+1)//2):
    b = (a[i] + a[2*i])//2 + 1
    bo.append(b)
    s = cums[i] + cume[-1] - cume[2*i]
    sc.append(s)
sc.append(cums[(n+1)//2])

bo.reverse()
sc.reverse()
 
for _ in range(q):
    i = bisect.bisect(bo, int(input()))
    print(sc[i])
Problem:
You are given an integer N. Find the number of the positive divisors of N!, modulo 10^9+7.

Incorrect submission (verdict: Wrong Answer):

import math
from collections import Counter
from collections import defaultdict
mod = 10**9+7 

def prime(n):
  for i in range(2, math.ceil(math.sqrt(n))+1):
    while n % i == 0:
      n /= i
      prime_count[i] += 1
  if n > 1:
    prime_count[int(n)] += 1

n = int(input())
a = 1
prime_count = defaultdict(int)
for i in range(1, n+1):
  prime(i)

print(prime_count)
ans = 1
for v in prime_count.values():
  ans *= (v+1)
  ans %= mod 
print(ans)





Fixed, accepted submission:

import math
from collections import Counter
from collections import defaultdict
mod = 10**9+7 

def prime(n):
  for i in range(2, math.ceil(math.sqrt(n))+1):
    while n % i == 0:
      n /= i
      prime_count[i] += 1
  if n > 1:
    prime_count[int(n)] += 1

n = int(input())
a = 1
prime_count = defaultdict(int)
for i in range(1, n+1):
  prime(i)

ans = 1
for v in prime_count.values():
  ans *= (v+1)
  ans %= mod 
print(ans)
Problem:
You are given strings s and t, consisting of lowercase English letters. You will create a string s' by freely rearranging the characters in s. You will also create a string t' by freely rearranging the characters in t. Determine whether it is possible to satisfy s' < t' for the lexicographic order.

Incorrect submission (verdict: Wrong Answer):
s = input()
t = input()
Ls= []
Lt= []
for i in s:
    Ls.append(i)
Ls = "".join(Ls)
for i in t:
    Lt.append(i)
Lt = "".join(Lt)
L = [Ls,Lt]
L = sorted(L)
if L[0]==Ls:
    print("Yes")
else:
    print("No")


Fixed, accepted submission:
s = sorted(input())
t = sorted(input())[::-1]
Ls= []
Lt= []

if len(s)<len(t) and set(s) == set(s)&set(t):
    print("Yes")
else:
    for i in s:
        Ls.append(i)
    Ls = "".join(Ls)
    for i in t:
        Lt.append(i)
    Lt = "".join(Lt)
    L = [Ls,Lt]
    L = sorted(L)
    if L[0]==L[1]:
        print("No")
    elif L[0]==Ls:
        print("Yes")
    else:
        print("No")
Problem:
In AtCoder, a person who has participated in a contest receives a _color_ , which corresponds to the person's rating as follows:    * Rating 1-399 : gray   * Rating 400-799 : brown   * Rating 800-1199 : green   * Rating 1200-1599 : cyan   * Rating 1600-1999 : blue   * Rating 2000-2399 : yellow   * Rating 2400-2799 : orange   * Rating 2800-3199 : red  Other than the above, a person whose rating is 3200 or higher can freely pick his/her color, which can be one of the eight colors above or not.   Currently, there are N users who have participated in a contest in AtCoder, and the i-th user has a rating of a_i.   Find the minimum and maximum possible numbers of different colors of the users.

Incorrect submission (verdict: Wrong Answer):
N,*A=map(int,open(0).read().split());l=[0]*9
for a in A:l[min(8,a//400)]+=1
m=sum([0<l[i]for i in range(8)]);print(min(m,1),m+l[8])

Fixed, accepted submission:
N,*A=map(int,open(0).read().split());l=[0]*9
for a in A:l[min(8,a//400)]+=1
m=sum([0<l[i]for i in range(8)]);print(max(m,1),m+l[8])
Problem:
You are given two integers A and B as the input. Output the value of A + B.  However, if A + B is 10 or greater, output `error` instead.

Incorrect submission (verdict: Wrong Answer):
a,b = map(int, input().split())
print(a+b if a+b >= 10 else 'error')

Fixed, accepted submission:
a,b = map(int, input().split())
print(a+b if a+b < 10 else 'error')
Problem:
You are given a string S of length 2 or 3 consisting of lowercase English letters. If the length of the string is 2, print it as is; if the length is 3, print the string after reversing it.

Incorrect submission (verdict: Wrong Answer):
S = input()

print(S if len(S) == 2 else S[-1])

Fixed, accepted submission:
S = input()

print(S if len(S) == 2 else S[::-1])
Problem:
Iroha loves _Haiku_. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order.  To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order.

Incorrect submission (verdict: Wrong Answer):
arr = list(map(int,input().split()))
if arr[0]==5 and arr[1]==7 and arr[2]==5:
  print('YES')
else:
  print('NO')

Fixed, accepted submission:
arr = list(map(int,input().split()))
if arr.count(5)==2 and arr.count(7)==1:
  print('YES')
else:
  print('NO')
Problem:
You are going out for a walk, when you suddenly encounter a monster. Fortunately, you have N katana (swords), Katana 1, Katana 2, …, Katana N, and can perform the following two kinds of attacks in any order:    * Wield one of the katana you have. When you wield Katana i (1 ≤ i ≤ N), the monster receives a_i points of damage. The same katana can be wielded any number of times.   * Throw one of the katana you have. When you throw Katana i (1 ≤ i ≤ N) at the monster, it receives b_i points of damage, and you lose the katana. That is, you can no longer wield or throw that katana.  The monster will vanish when the total damage it has received is H points or more. At least how many attacks do you need in order to vanish it in total?

Incorrect submission (verdict: Time Limit Exceeded):
n, h = map(int, input().split())
list_w = []
max_a = [-1, -1, 10**9]
for i in range(n):
  a, b = list(map(int, input().split()))
  list_w.append([a, b])
  if max_a[1] < a:
    max_a = [i, a, b]
  elif max_a[1] == a and max_a[2] > b:
    max_a = [i, a, b]  
list_w.pop(max_a[0])
list_w.sort(key=lambda x:x[1], reverse=True)

count = 0
while h > 0:
  if h > max_a[2]:
    if len(list_w) > 0 and list_w[0][1] > max_a[1]:
      h -= list_w[0][1]
      list_w.pop(0)
      count += 1
    else:
      if max_a[2] > max_a[1]:
        num = (h - max_a[2]) // max_a[1]
        h -= max_a[1] * num
        count += num
      else:
        num = h // max_a[1]
        h -= max_a[1] * num
        count += num
  else:
    h -= max_a[2]
    count += 1
print(count)

Fixed, accepted submission:
import math
n, h = map(int, input().split())
list_a = []
list_b = []
for i in range(n):
  a, b = list(map(int, input().split()))
  list_a.append(a)
  list_b.append(b)
max_a = max(list_a)
use_b = [b for b in list_b if b > max_a]
use_b.sort(reverse=True)

count = 0
while h > 0:
  if len(use_b) > 0:
    h -= use_b.pop(0)
    count += 1
  else:
    count += math.ceil(h / max_a)
    break
print(count)
Problem:
Let {\rm comb}(n,r) be the number of ways to choose r objects from among n objects, disregarding order. From n non-negative integers a_1, a_2, ..., a_n, select two numbers a_i > a_j so that {\rm comb}(a_i,a_j) is maximized. If there are multiple pairs that maximize the value, any of them is accepted.

Incorrect submission (verdict: Wrong Answer):
import math
import itertools
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()))
b = list(itertools.combinations(a,2))
ans = [0,(0,0)]
#print(b)
for i in range(len(b)):
    tmpans = combinations_count(max(b[i][0], b[i][1]),min(b[i][0], b[i][1]))
    if tmpans >= ans[0]:
        ans = [tmpans,(b[i][0], b[i][1])]
        
print(ans[1][0],ans[1][1])

Fixed, accepted submission:
n = int(input())
a = list(map(int,input().split()))
m = max(a)
del a[a.index(m)]
dis = [abs(m/2 - a[i]) for i in range(n-1)]
r = a[dis.index(min(dis))]
print(m,r)