Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import sys
from itertools import combinations
read = sys.stdin.read

N, K, *xy = map(int, read().split())
xy = list(zip(*[iter(xy)] * 2))
X = [x for x, y in xy]
Y = [y for x, y in xy]
answer = 10 ** 20

for i in combinations(X, 2):
    for j in combinations(Y, 2):
        top = max(j)
        bottom = min(j)
        left = min(i)
        right = max(i)
        cnt = 0
        for x, y in xy:
            if left <= x <= right and bottom <= y <= top:
                cnt += 1
        if cnt < K:
            continue

        S = (top - bottom) * (right - left)
        if S < answer:
            answer = S

print(answer)

Fixed submission:
import sys
from itertools import combinations
read = sys.stdin.read

N, K, *xy = map(int, read().split())
xy = sorted(zip(*[iter(xy)] * 2))
X, Y = zip(*xy)
answer = 10 ** 20

for left, right in combinations(range(N), 2):
    width = X[right] - X[left]
    tmp_Y = sorted(Y[left:right + 1])
    h = len(tmp_Y)
    for i in range(h):
        if i + K > h:
            break

        S = width * (tmp_Y[i + K - 1] - tmp_Y[i])
        if S < answer:
            answer = S

print(answer)
Buggy python submission (verdict: Runtime Error):
from collections import Counter

N = int(input())
D = int, input().split()
M = int(input())
T = input().split()

d = Counter(D)
t = Counter(T)
for key, value in t.items():
    if d.get(key, 0) < value:
        print('NO')
        exit()
else:
    print('YES')

Fixed submission:
from collections import Counter

N = int(input())
D = list(map(int, input().split()))
M = int(input())
T = list(map(int, input().split()))

d = Counter(D)
t = Counter(T)
for key, value in t.items():
    if d.get(key, 0) < value:
        print('NO')
        exit()
else:
    print('YES')
Buggy python submission (verdict: Time Limit Exceeded):
import sys
from itertools import product

read = sys.stdin.readline


def main():
    N = int(read())
    A = [list(map(int, read().split())) for _ in range(N)]

    answer = 0
    for i, j in product(range(N), repeat=2):
        if i < j:
            continue
        edge = A[i][j]
        for k in range(N):
            if i == k or j == k:
                continue

            tmp = A[i][k] + A[k][j]
            if tmp < edge:
                print(-1)
                exit()
            elif tmp == edge:
                break
        else:
            answer += edge

    print(answer)


if __name__ == '__main__':
    main()


Fixed submission:
import sys
import numpy as np

read = sys.stdin.read

N, *A = map(int, read().split())
A = np.array(A, np.int64).reshape(N, N)
'''
answer = 0
for i, j in product(range(N), repeat=2):
    if i < j:
        continue
    edge = A[i][j]
    for k in range(N):
        if i == k or j == k:
            continue

        tmp = A[i][k] + A[k][j]
        if tmp < edge:
            print(-1)
            exit()
        elif tmp == edge:
            break
    else:
        answer += edge
'''

useless = np.zeros_like(A)

for i in range(N):
    grid = A[i] + A[i, None].T
    if np.any(grid < A):
        print(-1)
        exit()
    grid[i] = np.inf
    grid[:, i] = np.inf

    useless |= (A == grid)

print(A[useless != 1].sum() // 2)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
a = list(map(int, input().split()))
A = sum(a)
ans = 100 ** 100

for i in range(1, N):
    x = sum(a[:i])
    ans = min(ans, abs(A - 2 * x))

print(ans)

Fixed submission:
N = int(input())
a = list(map(int, input().split()))
A = sum(a)
ans = 100 ** 100
x = 0

for i in range(N - 1):
    x += a[i]
    ans = min(ans, abs(A - 2 * x))

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
a = list(map(int, input().split()))
A = sum(a)
ans_list = [0] * (N - 1)

for i in range(1, N):
    x = sum(a[:i])
    ans_list[i - 1] = abs(A - 2 * x)

print(min(ans_list))

Fixed submission:
N = int(input())
a = list(map(int, input().split()))
A = sum(a)
ans = 100 ** 100
x = 0

for i in range(N - 1):
    x += a[i]
    ans = min(ans, abs(A - 2 * x))

print(ans)
Buggy python submission (verdict: Runtime Error):
import sys
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import shortest_path
read = sys.stdin.read

N, *ab = map(int, read().split())

graph = csr_matrix(([1] * (N - 1), (ab[::2], ab[1::2])), shape=(N + 1, N + 1))
distance = shortest_path(graph, directed=False, indices=[1, N])
d1 = distance[0]
dn = distance[1]

Fennec = -1
for i, j in zip(d1, dn):
    if i <= j:
        Fennec += 1

if Fennec > N - Fennec:
    print('Fennec')
else:
    print('Sunuke')

Fixed submission:
import sys
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import dijkstra
read = sys.stdin.read

N, *ab = map(int, read().split())
a, b = zip(*zip(*[iter(ab)] * 2))

graph = csr_matrix(([1] * (N - 1), (a, b)), shape=(N + 1, N + 1))
distance = dijkstra(graph, directed=False, indices=[1, N])
d1 = distance[0]
dn = distance[1]

Fennec = -1
for i, j in zip(d1, dn):
    if i <= j:
        Fennec += 1

if Fennec > N - Fennec:
    print('Fennec')
else:
    print('Snuke')
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(str, input().split()))
b = []

for i in range(n):
    if i % 2 == 0:
        b.append(a[i])
    else:
        b = [a[i]] + b

if n % 2 == 1:
    b.reverse()

print(' '.join(map(str, b)))

Fixed submission:
n = int(input())
a = input().split()

print(' '.join(a[-1::-2] + a[(n % 2)::2]))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
b = []

for i in range(n):
    b.append(a[i])
    b.reverse()

print(' '.join(map(str, b)))

Fixed submission:
n = int(input())
a = input().split()

print(' '.join(a[-1::-2] + a[(n % 2)::2]))
Buggy python submission (verdict: Runtime Error):
import sys
import numpy as np
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import minimum_spanning_tree
read = sys.stdin.read

N, *xy = map(int, read().split())
xy = np.array(xy, np.int64).reshape(N, 2)
x = xy[:, 0]
y = xy[:, 1]

town = np.arange(N)
arg_x = np.argsort(x)
arg_y = np.argsort(y)

edges_x = x[arg_x[1:]] - x[arg_x[:-1]]
town_x = town[arg_x]

edges_y = y[arg_y[1:]] - y[arg_y[:-1]]
town_y = town[arg_y]

edges = np.concatenate([edges_x, edges_y])
towns_1 = np.concatenate([town_x[1:], town_y[1:]])
towns_2 = np.concatenate([town_x[:-1], town_y[:-1]])

graph = csr_matrix((edges, (towns_1, towns_2)), shape=(N, N))
tree = minimum_spanning_tree(graph, overwrite=True).astype(dtype='int')
answer = tree.sum()

print(answer)

Fixed submission:
import sys
import numpy as np
read = sys.stdin.read


class UnionFind():
    # 作りたい要素数nで初期化
    # 使用するインスタンス変数の初期化
    def __init__(self, n):
        self.n = n
        # root[x]<0ならそのノードが根かつその値が木の要素数
        # rootノードでその木の要素数を記録する
        self.root = [-1]*(n+1)
        # 木をくっつける時にアンバランスにならないように調整する
        self.rnk = [0]*(n+1)

    # ノードxのrootノードを見つける
    def Find_Root(self, x):
        if self.root[x] < 0:
            return x
        else:
            # ここで代入しておくことで、後の繰り返しを避ける
            self.root[x] = self.Find_Root(self.root[x])
            return self.root[x]

    # 木の併合、入力は併合したい各ノード
    def Unite(self, x, y):
        # 入力ノードのrootノードを見つける
        x = self.Find_Root(x)
        y = self.Find_Root(y)
        # すでに同じ木に属していた場合
        if x == y:
            return
        # 違う木に属していた場合rnkを見てくっつける方を決める
        elif self.rnk[x] > self.rnk[y]:
            self.root[x] += self.root[y]
            self.root[y] = x

        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            # rnkが同じ（深さに差がない場合）は1増やす
            if self.rnk[x] == self.rnk[y]:
                self.rnk[y] += 1

    # xとyが同じグループに属するか判断
    def isSameGroup(self, x, y):
        return self.Find_Root(x) == self.Find_Root(y)

    # ノードxが属する木のサイズを返す
    def Count(self, x):
        return -self.root[self.Find_Root(x)]


N, *xy = map(int, read().split())
xy = np.array(xy, np.int64).reshape(N, 2)

town = np.arange(N)
arg_x = np.argsort(xy[:, 0])
arg_y = np.argsort(xy[:, 1])

edges_x = xy[arg_x[1:], 0] - xy[arg_x[:-1], 0]
town_x = zip(town[arg_x[1:]], town[arg_x[:-1]])
edges_y = xy[arg_y[1:], 1] - xy[arg_y[:-1], 1]
town_y = zip(town[arg_y[1:]], town[arg_y[:-1]])

edges = list(zip(edges_x, town_x)) + list(zip(edges_y, town_y))
edges.sort()

tree = UnionFind(N)
answer = 0

for d, (t1, t2) in edges:
    if tree.isSameGroup(t1, t2):
        continue

    tree.Unite(t1, t2)
    answer += d

print(answer)
Buggy python submission (verdict: Runtime Error):
A, B, C = map(int, input().split())

if A[-1] == B[0] and B[-1] == C[0]:
    print('YES')
else:
    print('NO')

Fixed submission:
A, B, C = input().split()

if A[-1] == B[0] and B[-1] == C[0]:
    print('YES')
else:
    print('NO')

Buggy python submission (verdict: Runtime Error):
A, B , C = map(int, input().split())

if A[-1] == B[0] and B[-1] == C[0]:
    print('YES')
else:
    print('NO')

Fixed submission:
A, B, C = input().split()

if A[-1] == B[0] and B[-1] == C[0]:
    print('YES')
else:
    print('NO')
Buggy python submission (verdict: Runtime Error):
a, b, c = input().split()

if b - a == c - b:
    print('YES')
else:
    print('NO')

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

if b - a == c - b:
    print('YES')
else:
    print('NO')
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())

if a == b:
    print('H')
else:
    print('D')

Fixed submission:
a, b = map(str, input().split())

if a == b:
    print('H')
else:
    print('D')
Buggy python submission (verdict: Time Limit Exceeded):
import sys
from bisect import bisect_right
input = sys.stdin.readline

N, C, K = map(int, input().split())
T = [int(input()) for i in range(N)]
T.sort()
answer = 0

while T:
    n = min(C - 1, len(T) - 1)
    if T[n] <= T[0] + K:
        n = C
    else:
        n = bisect_right(T, T[0] + K)
    T = T[n:]
    answer += 1

print(answer)

Fixed submission:
import sys
input = sys.stdin.readline

N, C, K = map(int, input().split())
T = [int(input()) for i in range(N)]
T.sort()
answer = 1
limit = T[0] + K
n = 0

for i in T:
    if i <= limit and n < C:
        n += 1
    else:
        answer += 1
        n = 1
        limit = i + K

print(answer)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
from bisect import bisect_right
input = sys.stdin.readline

N, C, K = map(int, input().split())
T = [int(input()) for i in range(N)]
T.sort()
answer = 0

while T:
    n = min(C, bisect_right(T, T[0] + K))
    T = T[n:]
    answer += 1

print(answer)

Fixed submission:
import sys
input = sys.stdin.readline

N, C, K = map(int, input().split())
T = [int(input()) for i in range(N)]
T.sort()
answer = 1
limit = T[0] + K
n = 0

for i in T:
    if i <= limit and n < C:
        n += 1
    else:
        answer += 1
        n = 1
        limit = i + K

print(answer)
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())

while 2 * N + 1 < M:
    N += 1
    M -= 2

print(min(N, M // 2))

Fixed submission:
N, M = map(int, input().split())

x = max(0, (M - 2 * N) // 4)
N += x
M -= 2 * x

print(min(N, M // 2))
Buggy python submission (verdict: Time Limit Exceeded):
K, S = map(int, input().split())
ans = 0

for i in range(K + 1):
    s = i
    if s > S:
        break
    for j in range(K + 1):
        s = i + j
        if s > S:
            break
        for k in range(K + 1):
            s = i + j + k
            if S == s:
                ans += 1
                break

print(ans)

Fixed submission:
K, S = map(int, input().split())
ans = 0

for i in range(K + 1):
    s = i
    if s > S:
        break
    for j in range(K + 1):
        s = i + j
        if s > S:
            break
        Z = S - s
        if 0 <= Z <= K:
            ans += 1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
K, S = map(int, input().split())
ans = 0

for i in range(K + 1):
    for j in range(K + 1):
        for k in range(K + 1):
            s = i + j + k
            if S < s:
                break
            elif S == s:
                ans += 1

print(ans)

Fixed submission:
K, S = map(int, input().split())
ans = 0

for i in range(K + 1):
    s = i
    if s > S:
        break
    for j in range(K + 1):
        s = i + j
        if s > S:
            break
        Z = S - s
        if 0 <= Z <= K:
            ans += 1

print(ans)
Buggy python submission (verdict: Runtime Error):
import sys
from scipy.sparse.csgraph import shortest_path
from scipy.sparse import csr_matrix
from itertools import combinations
read = sys.stdin.read

N, M, *abc = map(int, read().split())
a, b, c = zip(*zip(*[iter(abc)] * 3))

graph = csr_matrix((c, (a, b)), shape=(N + 1, N + 1))
distance = shortest_path(graph, directed=False)

answer = 0

for i, j in zip(a, b):
    for s in range(1, N + 1):
        if distance[i][j] + distance[j][s] == distance[i][s]:
            continue

        if distance[j][i] + distance[i][s] == distance[j][s]:
            continue

        answer += 1

print(answer)

Fixed submission:
import sys
from scipy.sparse.csgraph import dijkstra
from scipy.sparse import csr_matrix
read = sys.stdin.read

N, M, *abc = map(int, read().split())
a, b, c = zip(*zip(*[iter(abc)] * 3))

graph = csr_matrix((c, (a, b)), shape=(N + 1, N + 1))
distance = dijkstra(graph, directed=False)

answer = 0

for i, j, k in zip(a, b, c):
    k = float(k)
    if k == distance[i][j]:
        continue

    for s in range(1, N + 1):
        if i == s or j == s:
            continue

        if k + distance[j][s] == distance[i][s]:
            break

        if k + distance[i][s] == distance[j][s]:
            break

    else:
        answer += 1

print(answer)
Buggy python submission (verdict: Runtime Error):
from itertools import accumulate
from math import sqrt, floor
from bisect import bisect_left

N = int(input())
n = list(accumulate(range(floor(sqrt(2 * N)) + 1)))

r = bisect_left(n, N)

if n[r] == N:
    print('\n'.join(map(str, range(1, r + 1))))
    exit()

d = n[r] - N
for i in range(1, r + 1):
    if i != d:
        print(i)

Fixed submission:
from itertools import accumulate
from math import sqrt
from bisect import bisect_left

N = int(input())
n = list(accumulate(range(int(sqrt(2 * N)) + 2)))

r = bisect_left(n, N)

if n[r] == N:
    print('\n'.join(map(str, range(1, r + 1))))
    exit()

d = n[r] - N
for i in range(1, r + 1):
    if i != d:
        print(i)

Buggy python submission (verdict: Runtime Error):
from itertools import accumulate
from math import sqrt
from bisect import bisect_left

N = int(input())
n = list(accumulate(range(int(sqrt(N)) + 5)))

r = bisect_left(n, N)

if n[r] == N:
    print('\n'.join(map(str, range(1, r + 1))))
    exit()

d = n[r] - N
for i in range(1, r + 1):
    if i != d:
        print(i)

Fixed submission:
from itertools import accumulate
from math import sqrt
from bisect import bisect_left

N = int(input())
n = list(accumulate(range(int(sqrt(2 * N)) + 2)))

r = bisect_left(n, N)

if n[r] == N:
    print('\n'.join(map(str, range(1, r + 1))))
    exit()

d = n[r] - N
for i in range(1, r + 1):
    if i != d:
        print(i)

Buggy python submission (verdict: Runtime Error):
from itertools import accumulate
from math import sqrt
from bisect import bisect_left

N = int(input())
n = list(accumulate(range(int(sqrt(N)) + 3)))

r = bisect_left(n, N)

if n[r] == N:
    print('\n'.join(map(str, range(1, r + 1))))
    exit()

d = n[r] - N
for i in range(1, r + 1):
    if i != d:
        print(i)

Fixed submission:
from itertools import accumulate
from math import sqrt
from bisect import bisect_left

N = int(input())
n = list(accumulate(range(int(sqrt(2 * N)) + 2)))

r = bisect_left(n, N)

if n[r] == N:
    print('\n'.join(map(str, range(1, r + 1))))
    exit()

d = n[r] - N
for i in range(1, r + 1):
    if i != d:
        print(i)
Buggy python submission (verdict: Runtime Error):
import numpy as np

s = input()
N = len(s)

# 縦：じゃんけんの回数(0回含む）、横：パーを出した回数 そのときの最大スコア
# 1回目のじゃんけんではパーは出せない
scores = np.zeros((N + 1, N + 1), np.int64)

for i in range(2, N + 1):
    if s[i - 1] == 'g':
        scores[i, 0] = scores[i - 1, 0]
        scores[i, 1:i // 2 + 1] = np.maximum(scores[i - 1, :i // 2] + 1, scores[i - 1, 1:i // 2 + 1])
    else:
        scores[i, 0] = scores[i - 1, 0] - 1
        scores[i, 1:i // 2 + 1] = np.maximum(scores[i - 1, :i // 2], scores[i - 1, 1:i // 2 + 1] - 1)

print(scores[-1].max())

Fixed submission:
s = input()

print(-s.count('p') + len(s) // 2)

Buggy python submission (verdict: Runtime Error):
import numpy as np

s = input()
N = len(s)

# 縦：じゃんけんの回数(0回含む）、横：パーを出した回数 そのときの最大スコア
# 1回目のじゃんけんではパーは出せない
scores = np.zeros((N + 1, N // 2 + 1), np.int64)

for i in range(2, N + 1):
    if s[i - 1] == 'g':
        scores[i, 0] = scores[i - 1, 0]
        scores[i, 1:i // 2 + 1] = np.maximum(scores[i - 1, :i // 2] + 1, scores[i - 1, 1:i // 2 + 1])
    else:
        scores[i, 0] = scores[i - 1, 0] - 1
        scores[i, 1:i // 2 + 1] = np.maximum(scores[i - 1, :i // 2], scores[i - 1, 1:i // 2 + 1] - 1)

print(scores[-1].max())

Fixed submission:
s = input()

print(-s.count('p') + len(s) // 2)

Buggy python submission (verdict: Runtime Error):
import numpy as np

s = input()
N = len(s)

# 縦：じゃんけんの回数、横：パーを出した回数 そのときの最大スコア
# 1回目のじゃんけんではパーは出せない
scores = np.zeros((N, N // 2 + 1), np.int64)

for i in range(1, N):
    if s[i] == 'g':
        scores[i, 0] = scores[i - 1, 0]
        scores[i, 1:i // 2 + 2] = np.maximum(scores[i - 1, :i // 2 + 1] + 1, scores[i - 1, 1:i // 2 + 2])
    else:
        scores[i, 0] = scores[i - 1, 0] - 1
        scores[i, 1:i // 2 + 2] = np.maximum(scores[i - 1, :i // 2 + 1], scores[i - 1, 1:i // 2 + 2] - 1)

print(scores[-1].max())

Fixed submission:
s = input()

print(-s.count('p') + len(s) // 2)
Buggy python submission (verdict: Time Limit Exceeded):
X = input()

while X.find('ST') != -1:
    X = ''.join(X.split('ST'))

print(len(X))

Fixed submission:
from collections import deque

X = input()
stack = deque([X[0]])

for i in X[1:]:
    if stack:
        if stack[-1] == 'S' and i == 'T':
            stack.pop()
        else:
            stack.append(i)
    else:
        stack.append(i)

print(len(stack))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))

answer = 0
for i in range(N - 1):
    for j in range(i + 1, N):
        if A[i] == j + 1 and A[j] == i + 1:
            answer += 1

print(answer)

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

answer = 0
for i in range(N):
    if a[a[i] - 1] - 1 == i:
        answer += 1

print(answer // 2)
Buggy python submission (verdict: Runtime Error):
s = input()
n = len(s)

if n == 2 and s[0] == s[1]:
    print(1, 2)
    exit()

for i in range(n):
    if s[i] == s[i + 1] or s[i] == s[i + 2] or s[i + 1] == s[i + 2]:
        print(i + 1, i + 3)
        exit()

print(-1, -1)

Fixed submission:
s = input()
n = len(s)

if n == 2 and s[0] == s[1]:
    print(1, 2)
    exit()

for i in range(n - 2):
    if s[i] == s[i + 1] or s[i] == s[i + 2] or s[i + 1] == s[i + 2]:
        print(i + 1, i + 3)
        exit()

print(-1, -1)
Buggy python submission (verdict: Time Limit Exceeded):
a,b,c,k = map(int,input().split())
b = b + a
c = c + b
ans = 0
if k <= a:
    for _ in range(k):
        ans += 1
elif k <= b:
    ans = a
else:
    ans = a
    for _ in range(k-b):
        ans -= 1
print(ans)

Fixed submission:
a,b,c,k = map(int,input().split())
ans = 0
if k <= a:
    ans = k
elif k <= b+a:
    ans = a
else:
    ans = a - (k-(a+b))
print(ans)
Buggy python submission (verdict: Runtime Error):
PD = input()
print(PD.replase("?", "D"))

Fixed submission:
PD = input()
print(PD.replace("?", "D"))
Buggy python submission (verdict: Runtime Error):
data = input()
name = ['pon','pon','hon', 'bon','hon','hon','pon','hon','pon','hon']
print(name[int(data[-1])]

Fixed submission:
data = input()
name = ['pon','pon','hon', 'bon','hon','hon','pon','hon','pon','hon']
print(name[int(data[-1])])
Buggy python submission (verdict: Runtime Error):
A, B = list(map(int, input().split()))

def sum_tap_num(tap_num, A, B):
  if tap_num + A >= B:
    tam_num += 1
  	return tap_num
  
  return sum_tap_num(tap_num+1, A, B)

print(sum_tap_num(0, A, B))

Fixed submission:
A, B = list(map(int, input().split()))

def sum_tap_num(tap_num, A, B):
	tap_sum = (tap_num-1)*(A-1)+A
	if tap_sum >= B:
		return tap_num
  	
	return sum_tap_num(tap_num+1, A, B)
if B==1:
	print(0)
else:
	print(sum_tap_num(1, A, B))
Buggy python submission (verdict: Runtime Error):
"""
H1時M1分起床
H2時M2分就寝
K分勉強
"""

H1, M1, H2, M2, K = input().split(" ")

awake_time = H1 *60 + M1
sleep_time = H2 *60 + M1
start_limit_time = sleep_time - K

can_study_time = start_limit_time - awake_time

print(can_study_time)


Fixed submission:
import sys

"""
H1時M1分起床
H2時M2分就寝
K分勉強
"""
 
H1, M1, H2, M2, K = map(int, sys.stdin.read().split())
 
awake_time = H1 *60 + M1
sleep_time = H2 *60 + M2
start_limit_time = sleep_time - K
can_study_time = start_limit_time - awake_time
 
print(can_study_time)
Buggy python submission (verdict: Time Limit Exceeded):
import fractions
from functools import reduce

N = int(input())
A = [int(i) for i in input().split(" ")]

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

ans = 1
for i in range(N):
    cand = gcd_list(A[:i] + A[i+1:])
    if cand > ans:
        ans = cand
print(ans)

Fixed submission:
from fractions import gcd

N = int(input())
A = [int(i) for i in input().split(" ")]

if N == 2:
    print(max(A))
    import sys
    sys.exit()

g = gcd(A[0], A[1])
lmax = 1
num = 0
for i in range(2,N):
    cand = gcd(g, A[i])
    if cand < g:
        l = int(g / cand)
        g = cand
        if lmax < l:
            lmax = l
            num = A[i]
A = A[1:] + [A[0]]
g = gcd(A[0], A[1])
for i in range(2,N):
    cand = gcd(g, A[i])
    if cand < g:
        l = int(g / cand)
        g = cand
        if lmax < l:
            lmax = l
            num = A[i]
A = A[1:] + [A[0]]
g = gcd(A[0], A[1])
for i in range(2,N):
    cand = gcd(g, A[i])
    if cand < g:
        l = int(g / cand)
        g = cand
        if lmax < l:
            lmax = l
            num = A[i]
if num == A[0]:
    A = A[1:]
    flag = False
    N -= 1
elif num == A[1]:
    A = [A[0]] + A[2:]
    flag = False
    N -= 1
else:
    flag = True
g = gcd(A[0], A[1])
for i in range(2,N):
    if A[i] == num and flag:
        flag = False
    else:
        g = gcd(g, A[i])
print(g)

Buggy python submission (verdict: Runtime Error):
import math
from functools import reduce

N = int(input())
A = [int(i) for i in input().split(" ")]

def gcd_list(numbers):
    return reduce(math.gcd, numbers)

ans = 1
for i in range(N):
    cand = gcd_list(A[:i] + A[i+1:])
    if cand > ans:
        ans = cand
print(ans)

Fixed submission:
from fractions import gcd

N = int(input())
A = [int(i) for i in input().split(" ")]

if N == 2:
    print(max(A))
    import sys
    sys.exit()

g = gcd(A[0], A[1])
lmax = 1
num = 0
for i in range(2,N):
    cand = gcd(g, A[i])
    if cand < g:
        l = int(g / cand)
        g = cand
        if lmax < l:
            lmax = l
            num = A[i]
A = A[1:] + [A[0]]
g = gcd(A[0], A[1])
for i in range(2,N):
    cand = gcd(g, A[i])
    if cand < g:
        l = int(g / cand)
        g = cand
        if lmax < l:
            lmax = l
            num = A[i]
A = A[1:] + [A[0]]
g = gcd(A[0], A[1])
for i in range(2,N):
    cand = gcd(g, A[i])
    if cand < g:
        l = int(g / cand)
        g = cand
        if lmax < l:
            lmax = l
            num = A[i]
if num == A[0]:
    A = A[1:]
    flag = False
    N -= 1
elif num == A[1]:
    A = [A[0]] + A[2:]
    flag = False
    N -= 1
else:
    flag = True
g = gcd(A[0], A[1])
for i in range(2,N):
    if A[i] == num and flag:
        flag = False
    else:
        g = gcd(g, A[i])
print(g)