Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
from itertools import product
n, *AB = map(int, open(0).read().split())
A, B = map(sorted, [AB[::2], AB[1::2]])
mid = n//2
if n % 2 == 0:
    a, b = A[mid-1], B[mid-1]
    X = range(a, b+1)
    a, b = A[mid], B[mid]
    Y = range(a, b+1)
    Z = {a+b for a, b in product(X, Y)}
    print(len(Z))
else:
    print(B[mid] - A[mid] + 1)


Fixed submission:
n, *AB = map(int, open(0).read().split())
A, B = map(sorted, [AB[::2], AB[1::2]])
mid = n//2
if n % 2 == 0:
    a0, a1 = A[mid-1], A[mid]
    b0, b1 = B[mid-1], B[mid]
    print(b0+b1 - (a0+a1) + 1)
else:
    print(B[mid] - A[mid] + 1)

Buggy python submission (verdict: Runtime Error):
from itertools import product
n, *AB = map(int, open(0).read().split())
A, B = AB[::2], AB[1::2]
A, B = map(sorted, [A, B])
mid = n//2
if n % 2 == 0:
    a, b = A[mid-1], B[mid-1]
    X = range(a, b+1)
    a, b = A[mid], B[mid]
    Y = range(a, b+1)
    Z = {(a+b)/2 for a, b in product(X, Y)}
    print(len(Z))
else:
    print(B[mid] - A[mid] + 1)


Fixed submission:
n, *AB = map(int, open(0).read().split())
A, B = map(sorted, [AB[::2], AB[1::2]])
mid = n//2
if n % 2 == 0:
    a0, a1 = A[mid-1], A[mid]
    b0, b1 = B[mid-1], B[mid]
    print(b0+b1 - (a0+a1) + 1)
else:
    print(B[mid] - A[mid] + 1)
Buggy python submission (verdict: Runtime Error):
d = {}
for i in range(1, 100):
    for j in range(i-1, -i-1, -1):
        if i ** 5 - j ** 5 > 10 ** 9:
            print(*d[int(input())])
            exit()
        d[i ** 5 - j ** 5] = (i, j)
    else:
        continue

Fixed submission:
d = {}
for i in range(1, 1000):
    if i ** 5 - (i-1) ** 5 > 10 ** 9:
        break
    for j in range(i-1, -i-1, -1):
        if i ** 5 - j ** 5 > 10 ** 9:
            break
        d[i ** 5 - j ** 5] = (i, j)
print(*d[int(input())])
Buggy python submission (verdict: Runtime Error):
n, *A = map(int, open(0).read().split())
ans = 0
for i, a in enumerate(A, 1):
    x, y = i+a, i-a
    d[x] = d.get(x, 0)+1
    ans += d.get(y, 0)
print(ans)

Fixed submission:
from collections import Counter
inputs = open(0).readlines()
n = int(inputs[0])
*A, = (map(int, inputs[1].split()))
B = Counter([a+i for i, a in enumerate(A, 1)])
C = Counter([i-a for i, a in enumerate(A, 1)])
ans = 0
for k, v in B.items():
    if k in C:
        ans += C[k]*v
print(ans)

Buggy python submission (verdict: Runtime Error):
from collections import Counter
n = int(inputs[0])
*A, = (map(int, inputs[1].split()))
B = Counter([a+i for i, a in enumerate(A, 1)])
C = Counter([i-a for i, a in enumerate(A, 1)])
ans = 0
for k, v in B.items():
    if k in C:
        ans += C[k]*v
print(ans)

Fixed submission:
from collections import Counter
inputs = open(0).readlines()
n = int(inputs[0])
*A, = (map(int, inputs[1].split()))
B = Counter([a+i for i, a in enumerate(A, 1)])
C = Counter([i-a for i, a in enumerate(A, 1)])
ans = 0
for k, v in B.items():
    if k in C:
        ans += C[k]*v
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
from itertools import combinations
inputs = open(0).readlines()
n = int(inputs[0])
*A, = (map(int, inputs[1].split()))
B = [a+i for i, a in enumerate(A, 1)]
C = [i-a for i, a in enumerate(A, 1)]
ans = 0
for k1, v1 in Counter(B).items():
    for k2, v2 in Counter(C).items():
        if k1 == k2:
            ans += v1*v2
print(ans)

Fixed submission:
from collections import Counter
inputs = open(0).readlines()
n = int(inputs[0])
*A, = (map(int, inputs[1].split()))
B = Counter([a+i for i, a in enumerate(A, 1)])
C = Counter([i-a for i, a in enumerate(A, 1)])
ans = 0
for k, v in B.items():
    if k in C:
        ans += C[k]*v
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
from itertools import combinations
inputs = open(0).readlines()
n = int(inputs[0])
*A, = (map(int, inputs[1].split()))
B = [a+i for i, a in enumerate(A, 1)]
C = [i-a for i, a in enumerate(A, 1)]
ans = 0
for k1, v1 in Counter(B).items():
    for k2, v2 in Counter(C).items():
        if k1 == k2:
            ans += v1*v2
print(ans)

Fixed submission:
from collections import Counter
inputs = open(0).readlines()
n = int(inputs[0])
*A, = (map(int, inputs[1].split()))
B = Counter([a+i for i, a in enumerate(A, 1)])
C = Counter([i-a for i, a in enumerate(A, 1)])
ans = 0
for k, v in B.items():
    if k in C:
        ans += C[k]*v
print(ans)
Buggy python submission (verdict: Runtime Error):
bun = inputs[0]
nub = list(reversed(bun))
n = int(len(bun) / 2)

i = hug = 0
while i < n:
    if bun[i] != nub[i]:
        hug += 1
    i += 1
print(hug)

Fixed submission:
S = input()
RS = reversed(S)
n = int(len(S) / 2)

ans = 0
for c1, c2 in zip(S[:n], RS):
    if c1 != c2:
        ans += 1
print(ans)

Buggy python submission (verdict: Runtime Error):
bun = input()
nub = reversed(S)
n = int(len(S) / 2)

i = hug = 0
while i < n:
    if bun[i] != nub[i]:
        hug += 1
    i += 1
print(hug)

Fixed submission:
S = input()
RS = reversed(S)
n = int(len(S) / 2)

ans = 0
for c1, c2 in zip(S[:n], RS):
    if c1 != c2:
        ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
import sys
inputs = sys.stdin.readlines()
from functools import reduce
from operator import mul

n = int(inputs[0])
A = list(map(int, inputs[1].split()))
B = []
C = []
mod = 1000000007
for i in range(n):
    nb_rgb = [
        len([x for x in B if x == 0]),
        len([x for x in B if x == 1]),
        len([x for x in B if x == 2])
    ]
    tmp = [int(nb == A[i]) for nb in nb_rgb]
    if sum(tmp) == 1:
        B.append(tmp.index(1))
    elif sum(tmp) == 2:
        B.append(tmp.index(1))
        C.append(2)
    elif sum(tmp) == 3:
        B.append(tmp.index(1))
        C.append(3)

print(reduce(mul, C) % mod)

Fixed submission:
import sys
inputs = sys.stdin.readlines()
from functools import reduce
from operator import mul

n = int(inputs[0])
A = list(map(int, inputs[1].split()))
B = {0:0, 1:0, 2:0}
C = []
mod = 1000000007
for i in range(n):
    matches = [int(nb == A[i]) for nb in B.values()]
    if sum(matches) == 1:
        B[matches.index(1)] += 1
    elif sum(matches) == 2:
        B[matches.index(1)] += 1
        C.append(2)
    elif sum(matches) == 3:
        B[matches.index(1)] += 1
        C.append(3)
    else:
        print(0)
        break
else:
    print(reduce(mul, C) % mod)
Buggy python submission (verdict: Runtime Error):
import sys
inputs = sys.stdin.readlines()
n = int(inputs[0])
L = list(map(int, inputs[1].split())
A = sorted(L)

ans = 0
for i in range(n-1, 0, -1):
    l, r = 0, i-1
    while l < r:
        if A[i] < A[l] + A[r]:
            ans += r-l
            r -= 1
        else:
            l += 1

print(ans)

Fixed submission:
import sys
inputs = sys.stdin.readlines()
n = int(inputs[0])
L = list(map(int, inputs[1].split()))
A = sorted(L)
 
ans = 0
for i in range(n-1, 0, -1):
    l, r = 0, i-1
    while l < r:
        if A[i] < A[l] + A[r]:
            ans += r-l
            r -= 1
        else:
            l += 1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
inputs = sys.stdin.readlines()
n = int(inputs[0])
L = list(map(int, inputs[1].split()))

sort_L = sorted(L)
ans = 0
for i in range(n-2):
    a = sort_L[i]
    for j in range(i+1, n-1):
        b = sort_L[j]
        d = a+b
        for k in range(j+1, n):
            c = sort_L[k]
            if c < d:
                ans += 1
            else:
                break
print(ans)

Fixed submission:
import sys
inputs = sys.stdin.readlines()
n = int(inputs[0])
L = list(map(int, inputs[1].split()))
A = sorted(L)
 
ans = 0
for i in range(n-1, 0, -1):
    l, r = 0, i-1
    while l < r:
        if A[i] < A[l] + A[r]:
            ans += r-l
            r -= 1
        else:
            l += 1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
inputs = sys.stdin.readlines()
n = int(inputs[0])
L = list(map(int, inputs[1].split()))

sort_L = sorted(L)
ans = 0
for i in range(n-2):
    a = sort_L[i]
    for j in range(i+1, n-1):
        b = sort_L[j]
        d, e = b-a, a+b
        for k in range(j+1, n):
            c = sort_L[k]
            if d < c:
                if c < e:
                    ans += 1
                else:
                    break
print(ans)

Fixed submission:
import sys
inputs = sys.stdin.readlines()
n = int(inputs[0])
L = list(map(int, inputs[1].split()))
A = sorted(L)
 
ans = 0
for i in range(n-1, 0, -1):
    l, r = 0, i-1
    while l < r:
        if A[i] < A[l] + A[r]:
            ans += r-l
            r -= 1
        else:
            l += 1

print(ans)
Buggy python submission (verdict: Runtime Error):
def is_prime(n):
    assert n >= 1,  'Argument Error! n is "1 <= n".'
    for i in range(2, n + 1):
        if i ** 2 > n:
            break
        if n % i == 0:
            return False
    return n != 1

def divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    return divisors

a, b = sorted(list(map(int, inputs[0].split())))
divisors_ = set(divisors(a)) & set(divisors(b))

prime_divisors = [x for x in divisors_ if is_prime(x)]
print(len(prime_divisors) + 1)

Fixed submission:
def is_prime(n):
    assert n >= 1,  'Argument Error! n is "1 <= n".'
    for i in range(2, n + 1):
        if i ** 2 > n:
            break
        if n % i == 0:
            return False
    return n != 1

def divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    return divisors

a, b = sorted(list(map(int, input().split())))
divisors_ = set(divisors(a)) & set(divisors(b))

prime_divisors = [x for x in divisors_ if is_prime(x)]
print(len(prime_divisors) + 1)

Buggy python submission (verdict: Runtime Error):
def divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    return divisors

a, b = sorted(list(map(int, input().split())))
divisors_ = set(divisors(a)) & set(divisors(b))

prime_divisors = [x for x in divisors_ if is_prime(x)]
print(len(prime_divisors) + 1)

Fixed submission:
def is_prime(n):
    assert n >= 1,  'Argument Error! n is "1 <= n".'
    for i in range(2, n + 1):
        if i ** 2 > n:
            break
        if n % i == 0:
            return False
    return n != 1

def divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    return divisors

a, b = sorted(list(map(int, input().split())))
divisors_ = set(divisors(a)) & set(divisors(b))

prime_divisors = [x for x in divisors_ if is_prime(x)]
print(len(prime_divisors) + 1)
Buggy python submission (verdict: Runtime Error):
from heapq import heappush, heappop
N, M = map(int, inputs[0].split())
A = list(map(int, inputs[1].split()))

queue = []
for a in A:
    heappush(queue, -a)

for _ in range(M):
    heappush(queue, -(-heappop(queue) // 2))
print(-sum(queue))

Fixed submission:
import sys
inputs = sys.stdin.readlines()

from heapq import heappush, heappop
N, M = map(int, inputs[0].split())
A = list(map(int, inputs[1].split()))

queue = []
for a in A:
    heappush(queue, -a)

for _ in range(M):
    heappush(queue, -(-heappop(queue) // 2))
print(-sum(queue))

Buggy python submission (verdict: Time Limit Exceeded):
import sys
import bisect
inputs = sys.stdin.readlines()

N, M = map(int, inputs[0].split())
A = sorted(list(map(int, inputs[1].split())))

for _ in range(M):
    tmp = A.pop() // 2
    A.insert(bisect.bisect_left(A, tmp), tmp)
print(sum(A))

Fixed submission:
import sys
inputs = sys.stdin.readlines()

from heapq import heappush, heappop
N, M = map(int, inputs[0].split())
A = list(map(int, inputs[1].split()))

queue = []
for a in A:
    heappush(queue, -a)

for _ in range(M):
    heappush(queue, -(-heappop(queue) // 2))
print(-sum(queue))

Buggy python submission (verdict: Time Limit Exceeded):
import sys
import bisect
inputs = sys.stdin.readlines()

N, M = map(int, inputs[0].split())
A = sorted(list(map(int, inputs[1].split())))

for _ in range(M):
    tmp = A.pop() // 2
    A.insert(bisect.bisect_left(A, tmp), tmp)
print(sum(A))

Fixed submission:
import sys
inputs = sys.stdin.readlines()

from heapq import heappush, heappop
N, M = map(int, inputs[0].split())
A = list(map(int, inputs[1].split()))

queue = []
for a in A:
    heappush(queue, -a)

for _ in range(M):
    heappush(queue, -(-heappop(queue) // 2))
print(-sum(queue))
Buggy python submission (verdict: Runtime Error):
M, D = map(int, inputs[0].split())
good_dates = []
for date in range(D):
    d10 = (date+1) // 10
    d1 = (date+1) % 10
    if d1 >= 2 and d10 >= 2:
        if d1*d10 <= M:
            good_dates.append((d1*d10, date))
print(len(good_dates))

Fixed submission:
import sys
inputs = sys.stdin.readlines()

M, D = map(int, inputs[0].split())

good_dates = []
for date in range(D):
    d10 = (date+1) // 10
    d1 = (date+1) % 10
    if d1 >= 2 and d10 >= 2:
        if d1*d10 <= M:
            good_dates.append((d1*d10, date))
print(len(good_dates))

Buggy python submission (verdict: Runtime Error):
import sys
inputs = sys.stdin.readlines()

M, D = map(int, inputs[0].split())

good_dates = []
for date in range(D):
	d10 = (date+1) // 10
    d1 = (date+1) % 10
    if d1 >= 2 and d10 >= 2:
        if d1*d10 <= M:
            good_dates.append((d1*d10, date))
print(len(good_dates))

d10 = (date+1) // 10
    d1 = (date+1) % 10

Fixed submission:
import sys
inputs = sys.stdin.readlines()

M, D = map(int, inputs[0].split())

good_dates = []
for date in range(D):
    d10 = (date+1) // 10
    d1 = (date+1) % 10
    if d1 >= 2 and d10 >= 2:
        if d1*d10 <= M:
            good_dates.append((d1*d10, date))
print(len(good_dates))
Buggy python submission (verdict: Runtime Error):
n = int(input())
H = list(map(int, input().split()))

H[0] -= 1
for i in range(1, n):
    if H[i] < H[i-1]:
        H[i] -= 1
print('Yes' if reduce(lambda x, y: x <= y, H) else 'No')

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

H[0] -= 1
for i in range(1, n):
    if H[i-1] < H[i]:
        H[i] -= 1

if all(H[i-1] <= H[i] for i in range(1, n)):
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Time Limit Exceeded):
S = input().strip()
mod = 10**9 + 7
d = [i*10%13 for i in range(13)]
dp = [[0]*13 for _ in range(len(S)+1)]
dp[0][0] = 1
for i, c in enumerate(S, 1):
    if c != '?':
        c = int(c)
        for j in range(13):
            dp[i][(d[j] + c) % 13] = dp[i-1][j]
    else:
        for c in range(10):
            for j in range(13):
                k = (d[j] + c) % 13
                dp[i][k] += dp[i-1][j]
        for j in range(13):
            dp[i][j] %= mod
print(dp[-1][5])

Fixed submission:
S = input().strip()
mod = 10**9 + 7
d = {i:i*10%13 for i in range(13)}
dp = [[0]*13 for _ in range(len(S)+1)]
dp[0][0] = 1
for i, c in enumerate(S, 1):
    if c != '?':
        c = int(c)
        for j in range(13):
            dp[i][(d[j] + c) % 13] = dp[i-1][j] % mod
    else:
        for c in range(10):
            for j in range(13):
                k = (d[j] + c) % 13
                dp[i][k] = (dp[i][k] + dp[i-1][j]) % mod
print(dp[-1][5])

Buggy python submission (verdict: Time Limit Exceeded):
S = input().strip()
mod = 10**9 + 7
d = {i:i*10%13 for i in range(13)}
dp = [[0]*13 for _ in range(len(S)+1)]
dp[0][0] = 1
for i, c in enumerate(S, 1):
    if c != '?':
        c = int(c)
        for j in range(13):
            dp[i][(d[j] + c) % 13] = dp[i-1][j] % mod
    else:
        for c in range(10):
            for j in range(13):
                k = (d[j] + c) % 13
                dp[i][k] = (dp[i][k] + dp[i-1][j]) % mod
print(dp[-1][5])

Fixed submission:
S = input().strip()
mod = 10**9 + 7
d = {i:i*10%13 for i in range(13)}
dp = [[0]*13 for _ in range(len(S)+1)]
dp[0][0] = 1
for i, c in enumerate(S, 1):
    if c != '?':
        c = int(c)
        for j in range(13):
            dp[i][(d[j] + c) % 13] = dp[i-1][j] % mod
    else:
        for c in range(10):
            for j in range(13):
                k = (d[j] + c) % 13
                dp[i][k] = (dp[i][k] + dp[i-1][j]) % mod
print(dp[-1][5])
Buggy python submission (verdict: Runtime Error):
from collections import Counter

N = int(inputs[0])
a_list = list(map(int, inputs[1].split()))

def check(N, a_list):
    mc = Counter(a_list).most_common()
    n = len(mc)
    if n == 1:
        if mc[0][0] == 0:
            print('Yes')
            return
    elif n == 2:
        if mc[0][1] == 2*N // 3 and mc[1][0] == 0:
            print('Yes')
            return
    elif n == 3:
        if mc[0][1] == mc[1][1] == mc[2][1] and mc[0][0] ^ mc[1][0] ^ mc[2][0] == 0:
            print('Yes')
            return
    print('No')

check(N, a_list)

Fixed submission:
import sys
inputs = sys.stdin.readlines()

N = int(inputs[0])
a_list = list(map(int, inputs[1].split()))

from collections import Counter

def all_zeros(a_list):
    return sum(a_list) == 0

def check(N, a_list):
    if all_zeros(a_list):
        print('Yes')
        return
    elif N % 3 == 0:
        x = N // 3
        if not all([v % x == 0 for v in Counter(a_list).values()]):
            print('No')
            return
        while not all_zeros(a_list):
            counter = Counter([a & 1 for a in a_list])
            if counter[0] == x or counter[0] == N:
                a_list = [a >> 1 for a in a_list]
            else:
                print('No')
                return
        print('Yes')
    else:
        print('No')

check(N, a_list)

Buggy python submission (verdict: Runtime Error):
import sys
inputs = sys.stdin.readlines()

from collections import Counter

N = int(inputs[0])
a_list = list(map(int, inputs[1].split()))

def check(N, a_list):
    mc = Counter(a_list).most_common()
    n = len(mc)
    if n == 1:
        if mc[0][0] == 0:
            print('Yes')
            return
    elif n == 2:
        if mc[0][1] == 2*N // 3 and most_common[1][0] == 0:
            print('Yes')
            return
    elif n == 3:
        if mc[0][1] == mc[1][1] == mc[2][1] and mc[0][0] ^ mc[1][0] ^ mc[2][0] == 0:
            print('Yes')
            return
    print('No')

check(N, a_list)

Fixed submission:
import sys
inputs = sys.stdin.readlines()

N = int(inputs[0])
a_list = list(map(int, inputs[1].split()))

from collections import Counter

def all_zeros(a_list):
    return sum(a_list) == 0

def check(N, a_list):
    if all_zeros(a_list):
        print('Yes')
        return
    elif N % 3 == 0:
        x = N // 3
        if not all([v % x == 0 for v in Counter(a_list).values()]):
            print('No')
            return
        while not all_zeros(a_list):
            counter = Counter([a & 1 for a in a_list])
            if counter[0] == x or counter[0] == N:
                a_list = [a >> 1 for a in a_list]
            else:
                print('No')
                return
        print('Yes')
    else:
        print('No')

check(N, a_list)
Buggy python submission (verdict: Runtime Error):
L, R = map(int, input().split())
from itertools import combinations

mod = 2019
l, r = L % mod, R % mod
if l > r:
    l, r = r, l

mini = l*r % mod
for i, j in combinations(range(l, r+1), 2):
    mini = min(mini, i*j % mod)
    if mini == 0:
        break
print(mini)

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

if N*A <= B:
    print(N*A)
else:
    print(B)
Buggy python submission (verdict: Runtime Error):
import sys
from numpy.linalg import solve
import numpy as np
inputs = sys.stdin.readlines()

n = int(inputs[0])
A = np.array(list(map(int, inputs[1].split())))
I = np.eye(n, dtype=np.int)
B = np.empty((n, n), dtype=np.int)
for i in range(n):
    B[i, :] = I[i] + I[(i+1)%n]
print(*(map(lambda x: int(2*x), solve(B, A))))

Fixed submission:
import sys
import numpy as np
inputs = sys.stdin.readlines()

n = int(inputs[0])
A = np.array(list(map(int, inputs[1].split())))
B = np.empty((n,), dtype=np.int)
B[0] = (sum(A[::2])-sum(A[1::2])) // 2
for i in range(1, n):
    B[i] = A[i-1] - B[i-1]
print(*(B*2))
Buggy python submission (verdict: Runtime Error):
# 2
import sys
sys.setrecursionlimit(10000)
args = sys.stdin.readlines()
N = int(args[0])
xy_list = [[int(y) for y in x.split(' ')] for x in args[1:]]

from collections import Counter, defaultdict

delta_dict = defaultdict(int)

for i in range(N):
    for j in range(N):
        if i != j:
            delta_dict[(xy_list[i][0] - xy_list[j][0], xy_list[i][1] - xy_list[j][1])] += 1

print(N - Counter(delta_dict).most_common()[0][1])

Fixed submission:
# 2
import sys
sys.setrecursionlimit(10000)
args = sys.stdin.readlines()
N = int(args[0])
xy_list = [[int(y) for y in x.split(' ')] for x in args[1:]]

from collections import Counter, defaultdict

delta_dict = defaultdict(int)

if N == 1:
    print(1)
    exit()
for i in range(N):
    for j in range(N):
        if i != j:
            delta_dict[(xy_list[i][0] - xy_list[j][0], xy_list[i][1] - xy_list[j][1])] += 1
    
print(N - Counter(delta_dict).most_common()[0][1])
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import chain
chain_from_iterable = chain.from_iterable
from collections import Counter

def divisors(n):
    divisors = {1, n}
    for i in range(2, int(n**0.5)+1):
        q, r = divmod(n, i)
        if not r:
            divisors.add(i)
            divisors.add(q)
    return divisors

n = int(input())
A = map(int, input().split())
B = (divisors(a) for a in A)
c = Counter(chain_from_iterable(B))
print(max(k for k, v in c.items() if v >= n-1))

Fixed submission:
from fractions import gcd

n = int(input())
*A, = map(int, input().split())
B = A[::-1]
L, R = [0]*(n+1), [0]*(n+1)
for i in range(n):
    L[i+1] = gcd(L[i], A[i])
    R[i+1] = gcd(R[i], B[i])
L, R = L[:n], R[:n][::-1]
print(max(gcd(l, r) for l, r in zip(L, R)))

Buggy python submission (verdict: Runtime Error):
def divisors(n):
    divisors = set({1, n})
    for i in range(2, int(n**0.5)+1):
        q, r = divmod(n, i)
        if not r:
            divisors.add(i)
            divisors.add(q)
    return divisors

n = int(input())
A = map(int, input().split())
B = (divisors(a) for a in A)
c = Counter(chain_from_iterable(B))
print(max(k for k, v in c.items() if v >= n-1))

Fixed submission:
from fractions import gcd

n = int(input())
*A, = map(int, input().split())
B = A[::-1]
L, R = [0]*(n+1), [0]*(n+1)
for i in range(n):
    L[i+1] = gcd(L[i], A[i])
    R[i+1] = gcd(R[i], B[i])
L, R = L[:n], R[:n][::-1]
print(max(gcd(l, r) for l, r in zip(L, R)))

Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict
def divisors(n):
    divisors = set()
    for i in range(1, int(n**0.5)+1):
        q, r = divmod(n, i)
        if not r:
            divisors.add(i)
            divisors.add(q)
    return divisors

n = int(input())
*A, = map(int, input().split())
B = [divisors(a) for a in A]
d = defaultdict(int)
for b in B:
    for c in b:
        d[c] += 1
print(max(k for k, v in d.items() if v >= n-1))

Fixed submission:
from fractions import gcd

n = int(input())
*A, = map(int, input().split())
B = A[::-1]
L, R = [0]*(n+1), [0]*(n+1)
for i in range(n):
    L[i+1] = gcd(L[i], A[i])
    R[i+1] = gcd(R[i], B[i])
L, R = L[:n], R[:n][::-1]
print(max(gcd(l, r) for l, r in zip(L, R)))

Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict
def divisors(n):
    divisors = set()
    for i in range(1, int(n**0.5)+1):
        q, r = divmod(n, i)
        if not r:
            divisors.add(i)
            divisors.add(q)
    return divisors

n = int(input())
*A, = map(int, input().split())
B = [divisors(a) for a in A]
d = defaultdict(int)
for b in B:
    for c in b:
        d[c] += 1
print(max(k for k, v in d.items() if v >= n-1))

Fixed submission:
from fractions import gcd

n = int(input())
*A, = map(int, input().split())
B = A[::-1]
L, R = [0]*(n+1), [0]*(n+1)
for i in range(n):
    L[i+1] = gcd(L[i], A[i])
    R[i+1] = gcd(R[i], B[i])
L, R = L[:n], R[:n][::-1]
print(max(gcd(l, r) for l, r in zip(L, R)))