Problem p03061 (python)

Fixed submission:
from fractions import gcd
N = int(input())
Alist = [0]+list(map(int, input().split()))+[0]
Rlist = [0]*(N+2)
Llist = [0]*(N+1)
for i in range(N):
    Llist[i+1] = gcd(Llist[i], Alist[i])
    Rlist[N-i] = gcd(Rlist[N-i+1], Alist[N-i+1])
print(max([gcd(Rlist[i], Llist[i]) for i in range(1,N+1)]))

Buggy submission (verdict: Runtime Error):
from fractions import gcd
from functools import reduce
N = int(input())
Alist = list(map(int, input().split()))
Alist = AList+[Alist[0]]
def gcd_list(numbers):
  return reduce(gcd, numbers)
if len(Alist) == 2:
    print(max(Alist))
else:
    gcdlist=[gcd_list(Alist[i:i+2]) for i in range(N)]
    ind = gcdlist.index(min(gcdlist))
    if ind == N:
      print(max([gcd_list(Alist[:N]), gcd_list(Alist[1:])]))
    else:
      print(max([gcd_list(Alist[:ind]+Alist[ind+1:]), gcd_list(Alist[:ind+1]+Alist[ind+2:])]))

Buggy submission (verdict: Runtime Error):
from fractions import gcd
N = int(input())
Alist = list(map(int, input().split()))
Rlist = [0]*(N+2)
Llist = [0]*(N+1)
for i in range(N):
    Llist[i+1] = gcd(Llist[i], Alist[i])
    Rlist[N-i] = gcd(Rlist[N-i+1], Alist[N-i+1])
print(max([gcd(Rlist[i], Llist[i]) for i in range(N)]))

Buggy submission (verdict: Runtime Error):
from fractions import gcd
N = int(input())
Alist = list(map(int, input().split()))
Rlist = [0]*(N+2)
Llist = [0]*(N+1)
for i in range(N):
    Llist[i+1] = gcd(Llist[i], Alist[i])
    Rlist[N-i] = gcd(Rlist[N-i+1], Alist[N-i+1])
print(max([gcd(Rlist[i], Llist[i]) for i in range(N)])

Buggy submission (verdict: Runtime Error):
N = int(input())
Alist = list(map(int, input().split()))
def gcd(a,b):
    while b!=0:
        a,b = b, a%b
    return a
def gcds(numbers):
    if len(numbers) == 2:
        return gcd(*numbers)
    else:
        n1 = gcd(numbers[0], numbers[1])
        return gcds(*[n1]+numbers[2:])
if len(Alist)>2:
    gcdlist = [gcds(Alist[:i]+Alist[i+1:]) for i in range(N)]
    print(max(gcdlist))
else:
    print(gcds(Alist))

Buggy submission (verdict: Runtime Error):
import math
N = int(input())
Alist = list(map(int, input().split()))
def gcds(numbers):
    if len(numbers) == 2:
        return math.gcd(*numbers)
    else:
        n1 = math.gcd(numbers[0], numbers[1])
        return gcds(* [n1]+numbers[2:])
if len(Alist)>2:
    gcdlist = [gcds(Alist[:i]+Alist[i+1:]) for i in range(N)]
    print(max(gcdlist))
else:
    gcds(Alist)

Buggy submission (verdict: Runtime Error):
import math
N = int(input())
Alist = list(map(int, input().split()))
def gcds(numbers):
    if len(numbers) == 2:
        return math.gcd(*numbers)
    else:
        n1 = math.gcd(numbers[0], numbers[1])
        return gcds(* [n1]+numbers[2:])
print(max([gcds(Alist[:i]+Alist[i+1:]) for i in range(N)]) if len(Alist)>2 else gcds(Alist))

Buggy submission (verdict: Runtime Error):
import math
from functools import reduce
N = int(input())
Alist = list(map(int, input().split()))
def gcd(numbers):
    return reduce(math.gcd, numbers)
print(max([gcd(Alist[:i]+Alist[i+1:]) for i in range(N)]))

Buggy submission (verdict: Runtime Error):
import math
from functools import reduce
N = int(input())
Alist = list(map(int, input().split()))
def gcd(numbers):
    return  reduce(math.gcd, numbers)
print(max([gcd(Alist[:i]+Alist[i+1:]) for i in range(N)]))