TnT/CodeNet4Repair huggingface dataset:
Problem:
A string is called a KEYENCE string when it can be changed to `keyence` by removing its contiguous substring (possibly empty) only once.  Given a string S consisting of lowercase English letters, determine if S is a KEYENCE string.

Incorrect submission (verdict: Wrong Answer):
import sys
S = list(input())
Ans_list=['k','e','y','e','n','c','e']
Ans = 0
for i in range(len(S)):
    for j in range(i,len(S),+1):
        
        if (S[:i:]+S[j::]) == Ans_list:
           Ans = 1
           print(Ans)
           sys.exit()
print(Ans)

Fixed, accepted submission:
import sys
S = list(input())
Ans_list=['k','e','y','e','n','c','e']
Ans = 'NO'
for i in range(len(S)):
    for j in range(i,len(S),+1):
        
        if (S[:i:]+S[j::]) == Ans_list:
           Ans = 'YES'
           print(Ans)
           sys.exit()
print(Ans)
Problem:
Let f(n) be the number of triples of integers (x,y,z) that satisfy both of the following conditions:    * 1 \leq x,y,z   * x^2 + y^2 + z^2 + xy + yz + zx = n  Given an integer N, find each of f(1),f(2),f(3),\ldots,f(N).

Incorrect submission (verdict: Wrong Answer):
N = int(input())

F = [0]*(N+1)

for x in range(1, 101):
    for y in range(1, 101):
        for z in range(1, 101):
            c = x**2 + y**2 + z**2 + x*y + y*z + z*x
            if (c <= N):
                F[c] += 1
print(*F, sep='\n')

Fixed, accepted submission:
N = int(input())

F = [0]*(N+1)

for x in range(1, 101):
    for y in range(1, 101):
        for z in range(1, 101):
            c = x**2 + y**2 + z**2 + x*y + y*z + z*x
            if (c <= N):
                F[c] += 1
print(*F[1:], sep='\n')
Problem:
Snuke has decided to construct a string that starts with `A` and ends with `Z`, by taking out a substring of a string s (that is, a consecutive part of s).  Find the greatest length of the string Snuke can construct. Here, the test set guarantees that there always exists a substring of s that starts with `A` and ends with `Z`.

Incorrect submission (verdict: Wrong Answer):
s=input()
print(s.find('A')-s.rfind('Z'))

Fixed, accepted submission:
s=input()
print(s.rfind('Z')-s.find('A')+1)
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):
print('2018/01' + input()[-2:])

Fixed, accepted submission:
print('2018/01/' + input()[-2:])
Problem:
How many ways are there to choose two distinct positive integers totaling N, disregarding the order?

Incorrect submission (verdict: Wrong Answer):
def f(N):
  if N%2==0:
    return N//2-1
  else:
    return N//2
  N=int(input())
  print(f(N))

Fixed, accepted submission:
def f(N):
    if N%2==0:
        return N//2-1
    else:
        return N//2
N=int(input())
print(f(N))
Problem:
Given is a tree G with N vertices. The vertices are numbered 1 through N, and the i-th edge connects Vertex a_i and Vertex b_i.  Consider painting the edges in G with some number of colors. We want to paint them so that, for each vertex, the colors of the edges incident to that vertex are all different.  Among the colorings satisfying the condition above, construct one that uses the minimum number of colors.

Incorrect submission (verdict: Wrong Answer):

def top_sort_tree(g,root):
    n = len(g)
    parent = [-1]*n
    top_order = [-1]*n
    pos = 0
    
    from collections import deque
    q = deque([root])
    while q:
        v = q.pop()
        top_order[pos] = v
        pos += 1
        for c in g[v]:
            if c != parent[v]:
                parent[c] = v
                q.append(c)

    return top_order

#####################################

# coding: utf-8
# Your code here!
import sys
read = sys.stdin.read
readline = sys.stdin.readline 
readlines = sys.stdin.readlines

#n = int(input())
#ab = [[int(i) for i in readline().split()] for _ in range(n)]

n = int(input())
ab = map(int,read().split())

g = [[] for _ in range(n)]
for a,b in zip(ab,ab):
    g[a-1].append(b-1)
    g[b-1].append(a-1)
    
#print(g)
print(top_sort_tree(g,0)[0])






Fixed, accepted submission:
# coding: utf-8
# Your code here!
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
 
n = int(input())

g = [[] for _ in range(n)]
d = {}
for i in range(n-1):
    a,b = [int(i) for i in readline().split()]
    d[(a-1,b-1)] = i
    g[a-1].append(b-1)
    g[b-1].append(a-1)
 

def dfs(v,p,j): #p: parent of v
    
    num = -1
    for c in g[v]:
        if c == p: continue
        num += 1
        col = (j+num)%m+1
        if c > v: ans[d[(v,c)]] = col
        else: ans[d[(c,v)]] = col
        dfs(c,v,col)

m = max(len(i) for i in g)
ans = [0]*(n-1)

dfs(0,-1,0)

#print(g,m,ans)
print(m)
print(*ans,sep = "\n")
Problem:
An _X -layered kagami mochi_ (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you have a 3-layered kagami mochi; if you put just one mochi, you have a 1-layered kagami mochi.  Lunlun the dachshund has N round mochi, and the diameter of the i-th mochi is d_i centimeters. When we make a kagami mochi using some or all of them, at most how many layers can our kagami mochi have?

Incorrect submission (verdict: Wrong Answer):
N=int(input())
list=[int(input()) for i in range(N)]
print(len(list))

Fixed, accepted submission:
N = int(input())
list=[]
for i in range(N):
    list.append(int(input()))
print(len(set(list)))
Problem:
There are N people standing in a row from west to east. Each person is facing east or west. The directions of the people is given as a string S of length N. The i-th person from the west is facing east if S_i = `E`, and west if S_i = `W`.  You will appoint one of the N people as the leader, then command the rest of them to face in the direction of the leader. Here, we do not care which direction the leader is facing.  The people in the row hate to change their directions, so you would like to select the leader so that the number of people who have to change their directions is minimized. Find the minimum number of people who have to change their directions.

Incorrect submission (verdict: Wrong Answer):
import sys
read = sys.stdin.read
from itertools import accumulate
def main():
    n = int(input())
    s = list(input())
    e = [0] * n
    w = [0] * n
    for i1 in range(n):
        e[i1] = s[i1] == 'E'
        w[i1] = s[i1] == 'W'
    e.insert(0, 0)
    e.append(0)
    w.insert(0, 0)
    w.append(0)

    ea = list(accumulate(e))
    wa = list(accumulate(w))
    rt = 0
    for j1 in range(1, n):
        rt = max(rt, ea[j1 - 1] + (wa[-1] - wa[j1]))
        print(j1, rt)
    r = n - rt - 1
    print(r)

if __name__ == '__main__':
    main()

Fixed, accepted submission:
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
from itertools import accumulate
def main():
    n = int(input())
    s = list(input())
    enum = [1 if c == 'E' else 0 for c in s]
    wnum = [1 if c == 'W' else 0 for c in s]
    enuma = tuple(accumulate(enum))
    wnuma = tuple(accumulate(wnum))
    wnumm = wnuma[-1]
    wnuma2 = [wnumm - wn for wn in wnuma]
    num = max(wnuma2[0], enuma[-2])
    for i1 in range(1, n - 1):
        num = max(num, enuma[i1 - 1] + wnuma2[i1])
    r = n - num - 1
    print(r)

if __name__ == '__main__':
    main()
Problem:
There are N participants in the CODE FESTIVAL 2016 Qualification contests. The participants are either students in Japan, students from overseas, or neither of these.  Only Japanese students or overseas students can pass the Qualification contests. The students pass when they satisfy the conditions listed below, from the top rank down. Participants who are not students cannot pass the Qualification contests.    * A Japanese student passes the Qualification contests if the number of the participants who have already definitively passed is currently fewer than A+B.   * An overseas student passes the Qualification contests if the number of the participants who have already definitively passed is currently fewer than A+B and the student ranks B-th or above among all overseas students.  A string S is assigned indicating attributes of all participants. If the i-th character of string S is `a`, this means the participant ranked i-th in the Qualification contests is a Japanese student; `b` means the participant ranked i-th is an overseas student; and `c` means the participant ranked i-th is neither of these.  Write a program that outputs for all the participants in descending rank either `Yes` if they passed the Qualification contests or `No` if they did not pass.

Incorrect submission (verdict: Wrong Answer):
x = list(map(int, input().split()))
s = list(input())
y = len(s)
rank = 0
frank = 0

for i in (0,y - 1):
    if s[i] == "c":
        print("NO")
        
    elif s[i] == "b":
        if rank < x[1] + x[2] and frank < x[2]:
            rank += 1
            frank += 1
            print("YES")
            
        else:
            print("NO")
            
    else:
            if rank < x[1] + x[2]:
                rank += 1 
                print("YES")
            
            else:
                print("NO")

Fixed, accepted submission:
li = list(map(int,input().split()))
s=list(input())
cnt = 0
b = 0
for i in s:
    if i == "a":
        if cnt < li[1] + li[2]:
            cnt += 1
            print("Yes")
        else:
            print("No")
    elif i == "b":
        b += 1
        if cnt < li[1] + li[2]:
            if b <= li[2]:
                cnt += 1
                print("Yes")
            else:
                print("No")
        else:
            print("No")
    else:
        #cnt -= 1
        print("No")
Problem:
JOI 君は妹のJOI 子ちゃんとJOI 美ちゃんと一緒におやつを食べようとしている．今日のおやつは3 人の大好物のバームクーヘンだ．  バームクーヘンは下図のような円筒形のお菓子である．3 人に分けるために，JOI 君は半径方向に刃を3回入れて，これを3 つのピースに切り分けなければならない．ただしこのバームクーヘンは本物の木材のように固いので，刃を入れるのは簡単ではない．そのためこのバームクーヘンにはあらかじめ $N$ 個の切れ込みが入っており，JOI 君は切れ込みのある位置でのみ切ることができる．切れ込みに1 から $N$ まで時計回りに番号をふったとき，$1 \leq i \leq N - 1$ に対し， $i$ 番目の切れ込みと$i + 1$ 番目の切れ込みの間の部分の大きさは $A_i$ である．また $N$ 番目の切れ込みと1 番目の切れ込みの間の部分の大きさは $A_N$ である．        図1: バームクーヘンの例 $N = 6, A_1 = 1, A_2 = 5, A_3 = 4, A_4 = 5, A_5 = 2, A_6 = 4$

Incorrect submission (verdict: Wrong Answer):

# Python3 2018.7.3 bal4u

import sys
from sys import stdin
input = stdin.readline

n = int(input())
a = [int(input()) for i in range(n)]
su = sum(a)
p = [0]*(n+1)
s = [0]*(n+1)
print("a=",a)
l, r = 0, su+1
while l + 1 < r:
	m = (l+r) >> 1
	for i in range(0, n):
		if i == 0: s[i] = p[i] = 0
		else:
			p[i] = p[i-1] - 1
			s[i] = s[i-1] - a[i-1]
			
		while s[i] < m:
			ii = i + p[i];
			if ii >= n: ii -= n
			s[i] += a[ii]
			p[i] += 1

	f = 0	
	for i in range(n):
		ii = i + p[i];
		if ii >= n: ii -= n
		if su-s[i]-s[ii] >= m:
			f = 1
			break
	if f: l = m
	else: r = m
print(l)


Fixed, accepted submission:

# Python3 2018.7.3 bal4u

import sys
from sys import stdin
input = stdin.readline

n = int(input())
a = [int(input()) for i in range(n)]
su = sum(a)
p = [0]*(n+1)
s = [0]*(n+1)
l, r = 0, su+1
while l + 1 < r:
	m = (l+r) >> 1
	for i in range(0, n):
		if i == 0: s[i] = p[i] = 0
		else:
			p[i] = p[i-1] - 1
			s[i] = s[i-1] - a[i-1]
			
		while s[i] < m:
			ii = i + p[i];
			if ii >= n: ii -= n
			s[i] += a[ii]
			p[i] += 1

	f = 0	
	for i in range(n):
		ii = i + p[i];
		if ii >= n: ii -= n
		if su-s[i]-s[ii] >= m:
			f = 1
			break
	if f: l = m
	else: r = m
print(l)
Problem:
You are given three strings A, B and C. Check whether they form a _word chain_.  More formally, determine whether both of the following are true:    * The last character in A and the initial character in B are the same.   * The last character in B and the initial character in C are the same.  If both are true, print `YES`. Otherwise, print `NO`.

Incorrect submission (verdict: Wrong Answer):
A, B, C = input().split()

if list(A[-1])==list(B[0]) and list(B[-1])==list(C[0]):
    print("Yes")
else:
    print("No")

Fixed, accepted submission:

A, B, C = input().split()

if A[-1]==B[0] and B[-1]==C[0]:
    print("YES")
else:
    print("NO")
Problem:
You have an integer variable x. Initially, x=0.  Some person gave you a string S of length N, and using the string you performed the following operation N times. In the i-th operation, you incremented the value of x by 1 if S_i=`I`, and decremented the value of x by 1 if S_i=`D`.  Find the maximum value taken by x during the operations (including before the first operation, and after the last operation).

Incorrect submission (verdict: Wrong Answer):
n = int(input())
s = input()
x = 0
y = 0
for i in range(n):
    if s[i] == 'I':
        y += 1
    else:
        y -= 1
    if y > 0:
        x = y
print(x)

Fixed, accepted submission:
n = int(input())
s = input()
x = 0
y = 0
for i in range(n):
    if s[i] == 'I':
        y += 1
    else:
        y -= 1
    if y > x:
        x = y
print(x)
Problem:
There is an empty array. The following N operations will be performed to insert integers into the array. In the i-th operation (1≤i≤N), b_i copies of an integer a_i are inserted into the array. Find the K-th smallest integer in the array after the N operations. For example, the 4-th smallest integer in the array \\{1,2,2,3,3,3\\} is 3.

Incorrect submission (verdict: Wrong Answer):
#ABC061
n,k = (int(i) for i in input().split())
a = []
b = []
for i in range(n):
    tmp = list(int(i) for i in input().split())
    a.append(tmp[0])
    b.append(tmp[1])

tmp = 0
tmp_i = 0
for i in range(n):
    tmp += b[i]
    if tmp>=n:
        tmp_i = i
        break
print(a[i])

Fixed, accepted submission:
#ABC061
N,K = (int(i) for i in input().split())
a = {}
for i in range(N):
    tmp = list(int(i) for i in input().split())
    if not tmp[0] in a.keys():
        a[tmp[0]] = tmp[1]
    else:
        a[tmp[0]] += tmp[1]


ans_array = []
for k,v in a.items():
    ans_array.append((k,v))
ans_array = sorted(ans_array)

count = 0
for i in range(N):
    count += ans_array[i][1]
    if count>=K:
        print(ans_array[i][0])
        break
Problem:
Takahashi bought a piece of apple pie at ABC Confiserie. According to his memory, he paid N yen (the currency of Japan) for it.  The consumption tax rate for foods in this shop is 8 percent. That is, to buy an apple pie priced at X yen before tax, you have to pay X \times 1.08 yen (rounded down to the nearest integer).  Takahashi forgot the price of his apple pie before tax, X, and wants to know it again. Write a program that takes N as input and finds X. We assume X is an integer.  If there are multiple possible values for X, find any one of them. Also, Takahashi's memory of N, the amount he paid, may be incorrect. If no value could be X, report that fact.

Incorrect submission (verdict: Wrong Answer):
import math


def inputs():
    return [int(s) for s in input().split()]


def main():
    N = int(input())

    v = math.ceil(N / 1.08)
    print(v)
    print(math.floor(v * 1.08))
    if math.floor(v * 1.08) == N:
        return v
    else:
        return ':('


if __name__ == '__main__':
    print(main())


Fixed, accepted submission:
import math


def inputs():
    return [int(s) for s in input().split()]


def main():
    N = int(input())

    v = math.ceil(N / 1.08)

    if math.floor(v * 1.08) == N:
        return v
    else:
        return ':('


if __name__ == '__main__':
    print(main())
Problem:
Write a program which reads three integers, and prints them in ascending order.

Incorrect submission (verdict: Wrong Answer):
A=list(map(int, input().split()))
A.sort()
print(A)

Fixed, accepted submission:
A=list(map(int, input().split()))
A.sort()
print(A[0],A[1],A[2])
Problem:
Find the sum of the integers between 1 and N (inclusive), whose sum of digits written in base 10 is between A and B (inclusive).

Incorrect submission (verdict: Wrong Answer):
def main():
    N, A, B = map(int, input().split())
    list = []
    for i in range(N + 1):
        if 10 < i:
            temp = str(i)
            ai = int(temp[0])
            bi = int(temp[1])
            if A - 1 < ai + bi < B + 1:
                print(i)
                list.append(i)
        else:
            if A - 1 < i < B + 1:
              print(i)
              list.append(i)
    print(sum(list))
main()

Fixed, accepted submission:
def main():
    N, A, B = map(int, input().split())
    ans = 0
    for i in range(N+1):
        tw = str(i)
        tn = 0
        for j in range(len(tw)):
            tn += int(tw[j])
        if A <= tn <= B:
            ans += i
    print(ans)
main()
Problem:
Joisino is planning to record N TV programs with recorders.  The TV can receive C channels numbered 1 through C.  The i-th program that she wants to record will be broadcast from time s_i to time t_i (including time s_i but not t_i) on Channel c_i.  Here, there will never be more than one program that are broadcast on the same channel at the same time.  When the recorder is recording a channel from time S to time T (including time S but not T), it cannot record other channels from time S-0.5 to time T (including time S-0.5 but not T).  Find the minimum number of recorders required to record the channels so that all the N programs are completely recorded.

Incorrect submission (verdict: Wrong Answer):
n,c=map(int,input().split())
time=[0]*(10**5)
for i in range(n):
	s,t,c=map(int,input().split())
	time[s-1]+=1
	time[t-1]-=1
for i in range(10**5-1):
	time[i+1]+=time[i]
print(max(time))

Fixed, accepted submission:
from itertools import accumulate
n,c=map(int,input().split())
time=[0]*(10**5+2)
stc=[]
for i in range(n):
	s,t,c=map(int,input().split())
	stc.append([s,t,c])
stc.sort(key=lambda x:(x[2],x[0]))
for i in range(n-1):
	if stc[i][2]==stc[i+1][2]:
		if stc[i][1]==stc[i+1][0]:
			stc[i+1][0]=stc[i][0]
			stc[i]=[-1]
lis=[]
for i in range(n):
	if stc[i]!=[-1]:
		lis.append(stc[i])
for i in range(len(lis)):
	time[lis[i][0]-1]+=1
	time[lis[i][1]]-=1
print(max(accumulate(time)))
Problem:
There are N + 1 squares arranged in a row, numbered 0, 1, ..., N from left to right.  Initially, you are in Square X. You can freely travel between adjacent squares. Your goal is to reach Square 0 or Square N. However, for each i = 1, 2, ..., M, there is a toll gate in Square A_i, and traveling to Square A_i incurs a cost of 1. It is guaranteed that there is no toll gate in Square 0, Square X and Square N.  Find the minimum cost incurred before reaching the goal.

Incorrect submission (verdict: Wrong Answer):
import bisect

n,m,x = map(int,input().split())
l = list(map(int,input().split()))
index = bisect.bisect_left(l,x)
print(min(index,n-index))

Fixed, accepted submission:
import bisect

n,m,x = map(int,input().split())
l = list(map(int,input().split()))
index = bisect.bisect_left(l,x)
print(min(index,m-index))
Problem:
We will buy a product for N yen (the currency of Japan) at a shop.  If we use only 1000-yen bills to pay the price, how much change will we receive?  Assume we use the minimum number of bills required.

Incorrect submission (verdict: Wrong Answer):
print(int(input()) % 1000)

Fixed, accepted submission:
ans = int(input()) % 1000
if ans == 0:
    print(0)
    exit(0)
print(1000 - ans)
Problem:
You are given nonnegative integers a and b (a ≤ b), and a positive integer x. Among the integers between a and b, inclusive, how many are divisible by x?

Incorrect submission (verdict: Wrong Answer):
x = list(map(int,input().split()))
a = 0
for i in range(x[0],x[1]):
    if i % x[2]==0:
        a = a+1
print(a)

Fixed, accepted submission:
x = list(map(int,input().split()))
a = 0
if x[0]%x[2]==0:
    b = x[0]
else:
     b = ((x[0] // x[2])+1)*x[2]
c = (x[1]-b)//x[2] + 1

print(c)
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, b, h = map(int,open(0).read().split())
print((a+b)* h / 2)

Fixed, accepted submission:
a, b, h = map(int,open(0).read().split())
print(round(((a+b)* h / 2)))
Problem:
You are given three integers, A, B and C.   Among them, two are the same, but the remaining one is different from the rest.   For example, when A=5,B=7,C=5, A and C are the same, but B is different.   Find the one that is different from the rest among the given three integers.

Incorrect submission (verdict: Wrong Answer):
num = input().split()
print(num)
for i in num:
    if num.count(i) == 1:
        print(i)


Fixed, accepted submission:
numbers = list(map(int, input().split()))
for i in numbers:
    if numbers.count(i) == 1:
        print(i)
Problem:
You are playing the following game with Joisino.    * Initially, you have a blank sheet of paper.   * Joisino announces a number. If that number is written on the sheet, erase the number from the sheet; if not, write the number on the sheet. This process is repeated N times.   * Then, you are asked a question: How many numbers are written on the sheet now?  The numbers announced by Joisino are given as A_1, ... ,A_N in the order she announces them. How many numbers will be written on the sheet at the end of the game?

Incorrect submission (verdict: Time Limit Exceeded):
n = int(input())
a = [int(input()) for i in range(n)]
lis = []

for i in a:
  if i in lis:
    a.remove(i)
  else:
    a.append(i)
    
print(len(lis))

Fixed, accepted submission:
n = int(input())
a = [int(input()) for i in range(n)]
dict = {}
count = 0
for i in a:
  if i not in dict:
    dict[i] = 1
  elif i in dict:
    dict[i]+= 1

for i in set(a):
  if dict[i]%2!=0:
    count += 1
    
    
print(count)
Problem:
AtCoDeer has three cards, one red, one green and one blue.   An integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card.   We will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer.   Is this integer a multiple of 4?

Incorrect submission (verdict: Wrong Answer):
l=[int(x) for x in input().split()]

if (l[0]+l[1]+l[2])%4 == 0:
  print("Yes")
else:
  print("No")

Fixed, accepted submission:
r,g,b=map(int,input().split())
if (10*g+b)%4==0:
  print('YES')
else:
  print('NO')
Problem:
Takahashi is competing in a sumo tournament. The tournament lasts for 15 days, during which he performs in one match per day. If he wins 8 or more matches, he can also participate in the next tournament.  The matches for the first k days have finished. You are given the results of Takahashi's matches as a string S consisting of `o` and `x`. If the i-th character in S is `o`, it means that Takahashi won the match on the i-th day; if that character is `x`, it means that Takahashi lost the match on the i-th day.  Print `YES` if there is a possibility that Takahashi can participate in the next tournament, and print `NO` if there is no such possibility.

Incorrect submission (verdict: Wrong Answer):
s=input()
if s.count("x") >= 8:
    print("No")
else:
    print("Yes")

Fixed, accepted submission:
s=input()
if s.count("x") >= 8:
    print("NO")
else:
    print("YES")
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):
n = int(input())
a = list(map(int, input().split()))

half = max(a) / 2
sa = float("inf")
ans = 0
for i in a:
    if i != max(a):
        if abs(half - i) < sa:
            ans = i
            sa = abs(half - i)

print(a[0], ans)

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

m = max(a)
half = m / 2
sa = float("inf")
ans = 0
for i in a:
    if i != m:
        if abs(half - i) < sa:
            ans = i
            sa = abs(half - i)

print(m, ans)