Problem p03061 (python)

Fixed submission:
# import bisect
# import copy
from fractions import gcd


# import math
# import numpy as np
# from collections import Counter, deque
# from functools import reduce
# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product
import sys
sys.setrecursionlimit(10**9)


def resolve():
    N = int(input())
    A = list(map(int, input().split()))

    # A[0:i]の最大公約数
    L=[0]*N
    for i in range(1,N):
        L[i]=gcd(L[i - 1], A[i - 1])

    # A[i:]の最大公約数
    R=[0]*(N+1)
    for i in reversed(range(N)):
        R[i]=gcd(R[i + 1], A[i])


    maxgcd = 0
    for i in range(N):
        maxgcd = max(maxgcd, gcd(L[i], R[i + 1]))

    print(maxgcd)


resolve()

Buggy submission (verdict: Runtime Error):
# import bisect
# import copy
from fractions import gcd


# import math
# import numpy as np
# from collections import Counter, deque
# from functools import reduce
# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product
import sys
sys.setrecursionlimit(10**3)


def resolve():
    N = int(input())
    A = list(map(int, input().split()))

    # A[0:i]の最大公約数
    def L(i):
        if i == 0:
            return 0
        return gcd(L(i - 1), A[i - 1])

    # A[i:]の最大公約数
    def R(i):
        if i == N:
            return 0
        return gcd(R(i + 1), A[i])

    maxgcd = 0
    for i in range(N):
        maxgcd = max(maxgcd, gcd(L(i), R(i + 1)))

    print(maxgcd)


resolve()

Buggy submission (verdict: Runtime Error):
# import bisect
# import copy
from fractions import gcd


# import math
# import numpy as np
# from collections import Counter, deque
# from functools import reduce
# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product

def resolve():
    N = int(input())
    A = list(map(int, input().split()))

    # A[0:i]の最大公約数
    def L(i):
        if i == 0:
            return 0
        return gcd(L(i - 1), A[i - 1])

    # A[i:]の最大公約数
    def R(i):
        if i == N:
            return 0
        return gcd(R(i + 1), A[i])

    maxgcd = 0
    for i in range(N):
        maxgcd = max(maxgcd, gcd(L(i), R(i + 1)))

    print(maxgcd)


resolve()

Buggy submission (verdict: Runtime Error):
# import bisect
# import copy
from fractions import gcd


# import math
# import numpy as np
# from collections import Counter, deque
# from functools import reduce
# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product

def resolve():
    N = int(input())
    A = list(map(int, input().split()))

    # A[0:i]の最大公約数
    def L(i):
        if i == 0:
            return 0
        return gcd(L(i - 1), A[i - 1])

    # A[i:]の最大公約数
    def R(i):
        if i == N:
            return 0
        return gcd(R(i + 1), A[i])

    maxgcd = 0
    for i in range(N):
        maxgcd = max(maxgcd, gcd(L(i), R(i + 1)))

    print(maxgcd)


resolve()

Buggy submission (verdict: Runtime Error):
import fractions

n = int(input())
A = list(map(int, input().split()))
for i in range(0, n):
  for j in range(i + 1, n):
    g = fractions.gcd(A[i], A[j])
print(max(g))