Problem p03061 (python)

Fixed submission:
import sys
if sys.version_info.minor >= 5:
    from math import gcd
else:
    from fractions import gcd



N = int(input())
As = list(map(int, input().split()))

left_gcds = [gcd(As[0], As[0])]
for i in range(1, len(As)):
    left_gcds.append(gcd(left_gcds[i-1], As[i]))

right_gcds = [gcd(As[-1], As[-1])]
for i in range(1, len(As)):
    right_gcds.append(gcd(right_gcds[i-1], As[-(i+1)]))
right_gcds.reverse()

gcds = []
for i in range(N):
    if i == 0:
        gcds.append(right_gcds[1])
    elif i == N-1:
        gcds.append(left_gcds[-2])
    else:
        gcds.append(gcd(left_gcds[i-1], right_gcds[i+1]))
print(max(gcds))

Buggy submission (verdict: Runtime Error):
import sys
if sys.version_info.minor >= 5:
    from math import gcd
else:
    from fractions import gcd

N = int(input())
As = list(map(int, input().split()))

left_gcds = [gcd(As[0], As[0])]
for i in range(1, len(As)):
    left_gcds.append(gcd(left_gcds[i-1], As[i]))

right_gcds = [gcd(As[-1], As[-1])]
for i in reversed(range(len(As)-1)):
    right_gcds.append(gcd(right_gcds[i-1], As[i]))
right_gcds.reverse()

gcds = []
for i in range(N):
    if i == 0:
        gcds.append(right_gcds[1])
    elif i == N-1:
        gcds.append(left_gcds[-2])
    else:
        gcds.append(gcd(left_gcds[i-1], right_gcds[i+1]))
print(max(gcds))

Buggy submission (verdict: Runtime Error):
import sys
if sys.version_info.minor >= 5:
    from math import gcd
else:
    from fractions import gcd

N = int(input())
As = list(map(int, input().split()))

left_gcds = [gcd(As[0], As[0])]
for i in range(1, len(As)):
    left_gcds.append(gcd(left_gcds[i-1], As[i]))

right_gcds = [gcd(As[-1], As[-1])]
for i in reversed(range(len(As)-1)):
    right_gcds.append(gcd(right_gcds[i-1], As[i]))
right_gcds.reverse()

gcds = []
for i in range(N):
    if i == 0:
        gcds.append(right_gcds[1])
    elif i == N-1:
        gcds.append(left_gcds[-2])
    else:
        gcds.append(gcd(left_gcds[i-1], right_gcds[i+1]))
print(max(gcds))

Buggy submission (verdict: Runtime Error):
import fractions

N = int(input())
As = list(map(int, input().split()))

left_gcds = [fractions.gcd(As[0], As[0])]
for i in range(1, len(As)):
    left_gcds.append(fractions.gcd(left_gcds[i-1], As[i]))

right_gcds = [fractions.gcd(As[-1], As[-1])]
for i in reversed(range(len(As)-1)):
    right_gcds.append(fractions.gcd(right_gcds[i-1], As[i]))
right_gcds.reverse()

gcds = []
for i in range(N):
    if i == 0:
        gcds.append(right_gcds[1])
    elif i == N-1:
        gcds.append(left_gcds[-2])
    else:
        gcds.append(fractions.gcd(left_gcds[i-1], right_gcds[i+1]))
print(max(gcds))

Buggy submission (verdict: Runtime Error):
import math

N = int(input())
As = list(map(int, input().split()))

left_gcds = [math.gcd(As[0], As[0])]
for i in range(1, len(As)):
    left_gcds.append(math.gcd(left_gcds[i-1], As[i]))

right_gcds = [math.gcd(As[-1], As[-1])]
for i in reversed(range(len(As)-1)):
    right_gcds.append(math.gcd(right_gcds[i-1], As[i]))
right_gcds.reverse()

gcds = []
for i in range(N):
    if i == 0:
        gcds.append(right_gcds[1])
    elif i == N-1:
        gcds.append(left_gcds[-2])
    else:
        gcds.append(math.gcd(left_gcds[i-1], right_gcds[i+1]))
print(max(gcds))