Problem p03061 (python)

Fixed submission:
#ABC125C-GCDonBlackboard.py

from sys import stdin
from sys import setrecursionlimit
#import random
from fractions import gcd
from functools import lru_cache

setrecursionlimit(1000000)

input = stdin.readline

N = int(input())
A = list(map(int, input().split()))
#A = [random.randrange(1,10**9) for _ in range(N)]

@lru_cache(maxsize=None)
def L(i):
    if i == 0:
        return 0
    else:
        return gcd(L(i-1),A[i-1])

@lru_cache(maxsize=None)
def R(i):
    if i == N:
        return 0
    else:
        return gcd(R(i+1),A[i])

M = []

for i in range(N):
    M.append(gcd(L(i), R(i+1)))

print(max(M))

Buggy submission (verdict: Runtime Error):
#ABC125C-GCDonBlackboard.py

from sys import stdin
from sys import setrecursionlimit
#import random
from fractions import gcd
from functools import lru_cache

setrecursionlimit(100000)

input = stdin.readline

N = int(input())
A = list(map(int, input().split()))
#A = [random.randrange(1,10**9) for _ in range(N)]

@lru_cache(maxsize=None)
def L(i):
    if i == 0:
        return 0
    else:
        return gcd(L(i-1),A[i-1])

@lru_cache(maxsize=None)
def R(i):
    if i == N:
        return 0
    else:
        return gcd(R(i+1),A[i])

M = []

for i in range(N):
    M.append(gcd(L(i), R(i+1)))

print(max(M))

Buggy submission (verdict: Runtime Error):
#ABC125C-GCDonBlackboard.py

from sys import stdin
from fractions import gcd
#from functools import lru_cache

input = stdin.readline

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

#@lru_cache(maxsize=None)
def L(i):
    if i == 0:
        return 0
    else:
        return gcd(L(i-1),A[i-1])

#@lru_cache(maxsize=None)
def R(i):
    if i == N:
        return 0
    else:
        return gcd(R(i+1),A[i])

M = []

for i in range(N):
    M.append(gcd(L(i), R(i+1)))

print(max(M))

Buggy submission (verdict: Runtime Error):
#ABC125C-GCDonBlackboard.py

from sys import stdin
from fractions import gcd
from functools import reduce
from functools import lru_cache

input = stdin.readline

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

#@lru_cache(maxsize=None)
def L(i):
    if i == 0:
        return 0
    else:
        return gcd(L(i-1),A[i-1])

#@lru_cache(maxsize=None)
def R(i):
    if i == N:
        return 0
    else:
        return gcd(R(i+1),A[i])

M = []

for i in range(N):
    M.append(gcd(L(i), R(i+1)))

print(max(M))

Buggy submission (verdict: Runtime Error):
#ABC125C-GCDonBlackboard.py

from sys import stdin
from fractions import gcd
from functools import reduce
from functools import lru_cache

input = stdin.readline

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

@lru_cache
def L(i):
    if i == 0:
        return 0
    else:
        return gcd(L(i-1),A[i-1])

@lru_cache
def R(i):
    if i == N:
        return 0
    else:
        return gcd(R(i+1),A[i])

M = []

for i in range(N):
    M.append(gcd(L(i), R(i+1)))

print(max(M))

Buggy submission (verdict: Runtime Error):
#ABC125C-GCDonBlackboard.py

from sys import stdin
from fractions import gcd
from functools import reduce
from functools import lru_cache

input = stdin.readline

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

@lru_cache(maxsize=None)
def L(i):
    if i == 0:
        return 0
    else:
        return gcd(L(i-1),A[i-1])

@lru_cache(maxsize=None)
def R(i):
    if i == N:
        return 0
    else:
        return gcd(R(i+1),A[i])

M = []

for i in range(N):
    M.append(gcd(L(i), R(i+1)))

print(max(M))

Buggy submission (verdict: Runtime Error):
#ABC125C-GCDonBlackboard.py

from sys import stdin
from math import gcd
from functools import reduce
from functools import lru_cache

input = stdin.readline

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

@lru_cache(maxsize=None)
def L(i):
    if i == 0:
        return 0
    else:
        return gcd(L(i-1),A[i-1])

@lru_cache(maxsize=None)
def R(i):
    if i == N:
        return 0
    else:
        return gcd(R(i+1),A[i])

M = []

for i in range(N):
    M.append(gcd(L(i), R(i+1)))

print(max(M))