Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
n = input()
A = [input() for i in range(n)]

def insertionSort(A,n,g):
    cnt = 0
    for i in range(g,n):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j+g] = A[j]
            j -= g
            cnt += 1
        A[j+g] = v

    return cnt

def shellSort(A,n):
    cnt = 0
    m = int((n-1)/3)
    G = [1]
    for i in range(1,n):
        g = 3**i
        if g > n:
            break
        G.append(G[i-1]+g)
    m = len(G)
    for i in range(m):
        j = (m-1) - i
        cnt = insertionSort(A,n,G[j])

    return m, G, cnt

m, G, cnt = shellSort(A,n)

print m
for i in range(m-1):
    j = m - i
    print G[j],
print G[0]

for item in A:
    print item

Fixed submission:
n = input()
A = [input() for i in range(n)]

def insertionSort(A,n,g):
    cnt = 0
    for i in range(g,n):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j+g] = A[j]
            j -= g
            cnt += 1
        A[j+g] = v

    return cnt

def shellSort(A,n):
    cnt = 0
    m = int((n-1)/3)
    G = [1]
    for i in range(1,n):
        gn = G[i-1]+3**i
        if gn > n:
            break
        G.append(gn)
    m = len(G)
    for i in range(m):
        j = (m-1) - i
        cnt += insertionSort(A,n,G[j])

    return m, G, cnt

m, G, cnt = shellSort(A,n)

print m

for i in range(1,m):
    j = m - i
    print G[j],
print G[0]

print cnt

for item in A:
    print item
Buggy python submission (verdict: Runtime Error):
stack =[]
for item in raw_input().split():
    stack.append(item)


def Cal(sym,n1,n2):
    n1 = int(n1)
    n2 = int(n2)
    if sym == '+':
        ans = n1 + n2
    elif sym == '-':
        ans = n1 - n2
    else:
        ans = n1 * n2
        
    return ans

sym_stack = []
ans_stack = []

while len(stack)>0:
    m = stack.pop()
    if not m.isdigit():
        sym_stack.append(m)
    else:
        n2 = m
        n1 = stack.pop()
        sym = sym_stack.pop()
        ans = Cal(sym,n1,n2)
        ans_stack.append(ans)


n2 = ans_stack.pop()
n1 = ans_stack.pop()
sym = sym_stack.pop()
Ans = Cal(sym,n1,n2)

print Ans

Fixed submission:
def Cal(sym,n1,n2):
    n1 = int(n1)
    n2 = int(n2)
    if sym == '+':
        ans = n1 + n2
    elif sym == '-':
        ans = n1 - n2
    else:
        ans = n1 * n2
        
    return ans

stack = []

for item in raw_input().split():
    if item.isdigit():
        stack.append(item)
    else:
        n2 = stack.pop()
        n1 = stack.pop()
        sym = item
        ans = Cal(sym,n1,n2)
        stack.append(ans)

Ans = stack.pop()

print Ans

Buggy python submission (verdict: Runtime Error):
stack =[]
for item in raw_input().split():
    stack.append(item)


def Cal(sym,n1,n2):
    n1 = int(n1)
    n2 = int(n2)
    if sym == '+':
        ans = n1 + n2
    elif sym == '-':
        ans = n1 - n2
    else:
        ans = n1 * n2
        
    return ans

sym_stack = []
ans_stack = []

while len(stack)>0:
    m = stack.pop()
    if not m.isdigit():
        sym_stack.append(m)
    else:
        n2 = m
        n1 = stack.pop()
        sym = sym_stack.pop()
        ans = Cal(sym,n1,n2)
        ans_stack.append(ans)

while len(sym_stack)>0:
    n2 = ans_stack.pop()
    n1 = ans_stack.pop()
    sym = sym_stack.pop()
    ans = Cal(sym,n1,n2)
    ans_stack.append(ans)
Ans = ans_stack.pop()

print Ans

Fixed submission:
def Cal(sym,n1,n2):
    n1 = int(n1)
    n2 = int(n2)
    if sym == '+':
        ans = n1 + n2
    elif sym == '-':
        ans = n1 - n2
    else:
        ans = n1 * n2
        
    return ans

stack = []

for item in raw_input().split():
    if item.isdigit():
        stack.append(item)
    else:
        n2 = stack.pop()
        n1 = stack.pop()
        sym = item
        ans = Cal(sym,n1,n2)
        stack.append(ans)

Ans = stack.pop()

print Ans
Buggy python submission (verdict: Runtime Error):
def main():
    n = input()
    D = []
    O = []
    for i in range(n):
        c, k = raw_input().split()
        if c == 'insert':
            D.append(k)
        else:
            O.append(search(D,k))

    for item in O:
        print item

    return 0


def search(D,k):
    Dc = D[:]
    o = 'no'
    while Dc != []:
        d = Dc.pop()
        if d == k:
            o = 'yes'
            break

    return o
            

if __name__ == "__main__":
    main()

Fixed submission:
def main():
    n = input()
    S = map(int,raw_input().split())
    q = input()
    T = map(int,raw_input().split())
    m = 0
    for i in range(q):
        t = T.pop()
        for j in range(n):
            s = S[j]
            if t == s:
                m += 1
                break
                
    print m

if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n,q = map(int,raw_input().split())

    ds = DisjointSet(n)

    for i in xrange(q):
        com,x,y = map(int,raw_input().split())
        if com:
            if ds.root[x] == ds.root[y]:
                print 1
            else:
                print 0
        else:
            ds.unite(x,y)

class DisjointSet():
    def __init__(self,n):
        self.n = n
        self.root = range(n)
        self.parent = [-1]*n
        self.rank = [0]*n

    def findSet(self,x):
        if self.parent[x] == -1:
            return x
        else:
            p = self.findSet(self.parent[x])
            self.parent[x] = p

    def unite(self,x,y):
        if self.rank[x] > self.rank[y]:
            for z in [u for u in xrange(self.n) if self.root[u] == self.root[y]]:
                self.parent[z] = self.root[x]
                self.root[z] = self.root[x]
                self.rank[z] = self.rank[x]
        elif self.rank[x] < self.rank[y]:
            for z in [u for u in xrange(self.n) if self.root[u] == self.root[x]]:
                self.parent[z] = self.root[y]
                self.root[z] = self.root[y]
                self.rank[z] = self.rank[y]
        else:
            for z in [u for u in xrange(self.n) if self.root[u] == self.root[x]]:
                self.parent[z] = self.root[y]
                self.root[z] = self.root[y]
                self.rank[z] = self.rank[y]+1

if __name__ == "__main__":
    main()

Fixed submission:
def main():
    n,q = map(int,raw_input().split())

    ds = DisjointSet(n)

    for i in xrange(q):
        com,x,y = map(int,raw_input().split())
        if com:
            ds.findSet(x)
            ds.findSet(y)
            if ds.parent[x] == ds.parent[y]:
                print 1
            else:
                print 0
        else:
            ds.findSet(x)
            ds.findSet(y)
            ds.unite(x,y)

class DisjointSet():
    def __init__(self,n):
        self.n = n
        self.parent = range(n)

    def findSet(self,x):
        if self.parent[x] == x:
            return x
        else:
            p = self.findSet(self.parent[x])
            self.parent[x] = p
            return p

    def unite(self,x,y):
        if self.parent[y] > self.parent[x]:
            self.parent[self.parent[y]] = self.parent[x]
        else:
            self.parent[self.parent[x]] = self.parent[y]

if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

for _ in range(N):
    x = input()
    y = input()
    m, n = len(x), len(y)
    dp = [[0 for i in range(n+1)] for j in range(m+1)]
    
    for i in range(1, m+1):
        for j in range(1, n+1):
            if x[i-1] == y[j-1]:
                dp[i][j] = dp[i-1][j-1] + 1
            else:
                dp[i][j] = max(dp[i][j-1], dp[i-1][j])
                
    print(dp[m][n])

Fixed submission:
def lcs(s1, s2):
    dp = []
    for s2_k in s2:
        bgn_idx = 0
        for i, cur_idx in enumerate(dp):
            chr_idx = s1.find(s2_k, bgn_idx) + 1
            if not chr_idx:
                break
            dp[i] = min(cur_idx, chr_idx)
            bgn_idx = cur_idx
        else:
            chr_idx = s1.find(s2_k, bgn_idx) + 1
            if chr_idx:
                dp.append(chr_idx)
    return len(dp)

def solve():
    N = int(input())
    for _ in range(N):
        x = input()
        y = input()
        print(lcs(x, y))

if __name__ == '__main__':
    solve()
Buggy python submission (verdict: Runtime Error):
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()

from collections import defaultdict, deque, Counter
from sys import exit
import heapq
import math
import fractions
import copy
from itertools import permutations
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

from itertools import permutations
from math import factorial, hypot

N = getN()
A = getList()

course = []
x1 = A[0]
for i in A:
    x2 = i
    opt = math.gcd(x1, x2)
    course.append(opt)
    x1 = opt

reverse = []
y1 = A[-1]
for i in A[::-1]:
    y2 = i
    opt = math.gcd(y1, y2)
    reverse.append(opt)
    y1 = opt
reverse.sort()

ans = 0
for i in range(N):
    res = 0
    if i == 0:
        res = reverse[1]
    elif i == N - 1:
        res = course[-2]
    else:
        res = math.gcd(course[i - 1], reverse[i + 1])
    ans = max(ans, res)
print(ans)

Fixed submission:
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()

from collections import defaultdict, deque, Counter
from sys import exit
import heapq
import math
from fractions import gcd
import copy
from itertools import permutations
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

from itertools import permutations
from math import factorial, hypot

N = getN()
A = getList()

course = []
x1 = A[0]
for i in A:
    x2 = i
    opt = gcd(x1, x2)
    course.append(opt)
    x1 = opt

reverse = []
y1 = A[-1]
for i in A[::-1]:
    y2 = i
    opt = gcd(y1, y2)
    reverse.append(opt)
    y1 = opt
reverse.sort()

ans = 0
for i in range(N):
    res = 0
    if i == 0:
        res = reverse[1]
    elif i == N - 1:
        res = course[-2]
    else:
        res = gcd(course[i - 1], reverse[i + 1])
    ans = max(ans, res)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n, q = map(int, input().split())
s = input()
ans = []
for i in range(q):
    counter = 0
    l, r = map(int,input().split())
    for i in range(r - l):
        if s[i + l - 1] + s[i + l] == "AC":
            counter += 1
    ans.append(counter)
for i in ans:
    print(i)

Fixed submission:
N,Q=map(int,input().split())
S=input()
count=[0]*N
for i in range(1,N):
    count[i]+=count[i-1]
    if S[i-1:i+1]=="AC":count[i]+=1
for i in range(Q):
    l,r=map(int,input().split())
    print(count[r-1]-count[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
n, q = map(int, input().split())
s = input()
count = [0]*q
for i in range(q):
    l, r = map(int,input().split())
    str = s[l - 1: r]
    counter = 0
    for n in range(len(str) - 1):
        if str[n] + str[n + 1] == "AC":
            count[i] += 1
for i in count:
    print(i)

Fixed submission:
N,Q=map(int,input().split())
S=input()
count=[0]*N
for i in range(1,N):
    count[i]+=count[i-1]
    if S[i-1:i+1]=="AC":count[i]+=1
for i in range(Q):
    l,r=map(int,input().split())
    print(count[r-1]-count[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
n, q = map(int, input().split())
s = input()
ans = []
for i in range(q):
    l, r = map(int,input().split())
    str = s[l - 1: r]
    counter = 0
    for n in range(len(str) - 1):
        if str[n] + str[n + 1] == "AC":
            counter += 1
    ans.append(counter)
for i in ans:
    print(i)

Fixed submission:
N,Q=map(int,input().split())
S=input()
count=[0]*N
for i in range(1,N):
    count[i]+=count[i-1]
    if S[i-1:i+1]=="AC":count[i]+=1
for i in range(Q):
    l,r=map(int,input().split())
    print(count[r-1]-count[l-1])
Buggy python submission (verdict: Runtime Error):
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()

from collections import defaultdict, deque, Counter
from sys import exit
import heapq
import math
import copy
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

A, B = getNM()
# bit1桁目のフラグの個数
# 周期は2 ** 1
# 0と1が交互に
# bit2桁目のフラグの個数
# 周期は2 ** 2
flags1 = [0] * 40
flags2 = [0] * 40
# 1 ~ nまでに各桁のフラグが何本立つか計算する関数
def bitflag(n, flaglist):
    if n > 0:
        for i in range(1, 40):
            split = 2 ** i
            flag1 = (n // split) * (split // 2)
            flag2 = max(n % split + 1 - (split // 2), 0)
            flaglist[i] += flag1 + flag2
# 1 ~ A - 1について（Aは範囲に入っているため）
bitflag(A - 1, flags1)
bitflag(B, flags2)

for i in range()
for i in range(40):
    flags2[i] -= flags1[i]
ans = 0
# 奇数ならフラグが立つ
for i in range(40):
    if flags2[i] % 2 != 0:
        ans += 2 ** (i - 1)
print(ans)

Fixed submission:
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()

from collections import defaultdict, deque, Counter
from sys import exit
import heapq
import math
import copy
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

A, B = getNM()
# bit1桁目のフラグの個数
# 周期は2 ** 1
# 0と1が交互に
# bit2桁目のフラグの個数
# 周期は2 ** 2
flags1 = [0] * 61
flags2 = [0] * 61
# 1 ~ nまでに各桁のフラグが何本立つか計算する関数
def bitflag(n, flaglist):
    if n > 0:
        for i in range(1, 61):
            split = 2 ** i
            flag1 = (n // split) * (split // 2)
            flag2 = max(n % split + 1 - (split // 2), 0)
            flaglist[i] += flag1 + flag2
# 1 ~ A - 1について（Aは範囲に入っているため）
bitflag(A - 1, flags1)
bitflag(B, flags2)
for i in range(61):
    flags2[i] -= flags1[i]
ans = 0
# 奇数ならフラグが立つ
for i in range(61):
    if flags2[i] % 2 != 0:
        ans += 2 ** (i - 1)
print(ans)
Buggy python submission (verdict: Runtime Error):
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()

from collections import defaultdict, deque, Counter
from sys import exit
import heapq
import math
import copy
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

N = getN()
A = getList()

ans = A[0]
for i in range(1, N):
    ans = math.gcd(ans, A[i])
print(ans)

Fixed submission:
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()

from collections import defaultdict, deque, Counter
from sys import exit
import heapq
import math
import fractions
import copy
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

N = getN()
A = getList()

ans = A[0]
for i in range(1, N):
    ans = fractions.gcd(ans, A[i])
print(ans)

Buggy python submission (verdict: Runtime Error):
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()

from collections import defaultdict, deque, Counter
from sys import exit
import heapq
import math
import copy
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

N = getN()
A = getList()

ans = A[0]
for i in range(1, N - 1):
    ans = math.gcd(ans, A[i])
print(ans)

Fixed submission:
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()

from collections import defaultdict, deque, Counter
from sys import exit
import heapq
import math
import fractions
import copy
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

N = getN()
A = getList()

ans = A[0]
for i in range(1, N):
    ans = fractions.gcd(ans, A[i])
print(ans)
Buggy python submission (verdict: Runtime Error):
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()

from collections import defaultdict, deque, Counter
from sys import exit
import heapq
import math
import copy
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

N = getN()
info = []
for i in range(N):
    x, y, h = getNM()
    info.append([x, y, h])

ans = []
for i in range(101):
    for j in range(101):
        X = i
        Y = j
        height = []
        flag = True
        for k in range(N):
            minusx = abs(X - info[k][0])
            minusy = abs(Y - info[k][1])
            if info[k][2] != 0:
                h = info[k][2] + minusx + minusy
                if k != 0 and h != height[-1]:
                    flag = False
                    break
                height.append(h)
        if flag:
            ans = [i, j, height[0]]
print(*ans)

Fixed submission:
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()

from collections import defaultdict, deque, Counter
from sys import exit
import heapq
import math
import copy
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

N = getN()
info = []
for i in range(N):
    x, y, h = getNM()
    info.append([x, y, h])
info.sort(reverse = True,key = lambda info:info[2])

ans = []
for i in range(101):
    for j in range(101):
        height = -1
        flag = True
        for k in range(N):
            minusx = abs(i - info[k][0])
            minusy = abs(j - info[k][1])
            if height == -1:
                # 上で逆順にソートしてるので確実に１以上の高さがでる
                height = info[k][2] + minusx + minusy
            else:
                # 問題の式に沿うように
                if info[k][2] != max(height - minusx - minusy, 0):
                    flag = False
                    break
        if flag:
            ans = [i, j, height]
print(*ans)
Buggy python submission (verdict: Runtime Error):
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()

from collections import defaultdict, deque, Counter
from sys import exit
import heapq
import math
import copy
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

N = getN()
V = getList()

# 条件を満たすもののうちで最も多く現れる多い２数を採用する方針
even = [0] * (200 + 1)
odd = [0] * (200 + 1)
for i in range(N):
    if i % 2 == 0:
        even[V[i]] += 1
    else:
        odd[V[i]] += 1
# 偶数列、奇数列に現れる数字の中で一番多かったもの
topeven = even.index(max(even))
topodd = odd.index(max(odd))
even.sort()
odd.sort()

ans = 0
if topeven == topodd:
    # 偶数列で一番多かった数、奇数列で２番目に多かった数
    opt1 = N - even[-1] - odd[-2]
    # 偶数列で２番目に多かった数、奇数列で一番多かった数
    opt2 = N - even[-2] - odd[-1]
    # どちらか小さい方
    ans = min(opt1, opt2)
else:
    ans = N - even[-1] - odd[-1]
print(ans)

Fixed submission:
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()

from collections import defaultdict, deque, Counter
from sys import exit
import heapq
import math
import copy
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

N = getN()
V = getList()

# 条件を満たすもののうちで最も多く現れる多い２数を採用する方針
even = [0] * (10 ** 5 + 1)
odd = [0] * (10 ** 5 + 1)
for i in range(N):
    if i % 2 == 0:
        even[V[i]] += 1
    else:
        odd[V[i]] += 1
# 偶数列、奇数列に現れる数字の中で一番多かったもの
topeven = even.index(max(even))
topodd = odd.index(max(odd))
even.sort()
odd.sort()

ans = 0
if topeven == topodd:
    # 偶数列で一番多かった数、奇数列で２番目に多かった数
    opt1 = N - even[-1] - odd[-2]
    # 偶数列で２番目に多かった数、奇数列で一番多かった数
    opt2 = N - even[-2] - odd[-1]
    # どちらか小さい方
    ans = min(opt1, opt2)
else:
    ans = N - even[-1] - odd[-1]
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()

from collections import defaultdict, deque, Counter
from sys import exit
import heapq
import math
import copy
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

N = getN()
A = getList()
A.sort()

def cmb(n, r):
    r = min(n - r, r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1, r + 1))
    return over // under

max = max(A)
index = bisect_left(A, max / 2)
if cmb(max, A[index]) > cmb(max, A[index - 1]):
    ans = [max, A[index]]
else:
    ans = [max, A[index - 1]]
print(*ans)

Fixed submission:
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()

from collections import defaultdict, deque, Counter
from sys import exit
import heapq
import math
import copy
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

N = getN()
A = getList()
A.sort()

max = max(A)
index = bisect_left(A, max / 2)
if abs((max / 2) - A[index]) < abs((max / 2) - A[index - 1]):
    ans = [max, A[index]]
else:
    ans = [max, A[index - 1]]
print(*ans)