Buggy python submission (verdict: Time Limit Exceeded):
class SegmentTree():
    def __init__(self, array, f, ti):
        """
        Parameters
        ----------
        array : list
            to construct segment tree from
        f : func
            binary operation of the monoid
        ti : 
            identity element of the monoid
        """
        self.f = f
        self.ti = ti
        self.n = n = 2**(len(array).bit_length())
        self.dat = dat = [ti] * n + array + [ti] * (n - len(array))
        for i in range(n - 1, 0, -1):  # build
            dat[i] = f(dat[i << 1], dat[i << 1 | 1])

    def update(self, p, v):  # set value at position p (0-indexed)
        f, n, dat = self.f, self.n, self.dat
        p += n
        dat[p] = v
        while p > 1:
            p >>= 1
            dat[p] = f(dat[p << 1], dat[p << 1 | 1])

    def query(self, l, r):  # result on interval [l, r) (0-indexed)
        f, ti, n, dat = self.f, self.ti, self.n, self.dat
        res = ti
        l += n
        r += n
        while l < r:
            if l & 1:
                res = f(res, dat[l])
                l += 1
            if r & 1:
                r -= 1
                res = f(dat[r], res)
            l >>= 1
            r >>= 1
        return res


def gcd(x, y):
    if x * y == 0:
        return x + y
    elif x > y:
        return gcd(y, x)
    else:
        return gcd(y % x, x)


N = int(input())
A = [int(_) for _ in input().split()]
ST = SegmentTree(array=A, f=gcd, ti=0)
ans = 0
for i in range(N):
    ans = max(ans, gcd(ST.query(0, i), ST.query(i + 1, N)))
print(ans)


Fixed submission:
import itertools
N = int(input())
A = [int(_) for _ in input().split()]
gcd = lambda x, y: gcd(y, x % y) if x % y else y
L = list(itertools.accumulate(A, func=gcd))
R = list(itertools.accumulate(A[::-1], func=gcd))[::-1]
ans = max(R[1], L[-2])
for i in range(1, N - 1):
    ans = max(ans, gcd(L[i - 1], R[i + 1]))
print(ans)
# https://img.atcoder.jp/abc125/editorial.pdf

Buggy python submission (verdict: Time Limit Exceeded):
import math
N = int(input())
A = [int(_) for _ in input().split()]


def gcd(x, y):
    if x < y:
        return gcd(y, x)
    elif y == 0:
        return x
    else:
        return gcd(y, x % y)


class SegmentTree():
    def m(self, v1, v2):  # ***monoid***
        return gcd(v1, v2)

    def __init__(self, array):
        m = self.m
        e = self.e = 0  # ***identity element***
        size = self.size = 10**6  # ***limit for array size***
        n = self.n = len(array)
        dat = self.dat = [e] * n + array + [e] * (2 * size - 2 * n)
        for i in range(n - 1, 0, -1):  # build
            dat[i] = m(dat[i << 1], dat[i << 1 | 1])

    def modify(self, p, v):  # set value at position p (0-indexed)
        m, n, dat = self.m, self.n, self.dat
        p += n
        dat[p] = v
        while p > 1:
            dat[p >> 1] = m(dat[p], dat[p ^ 1])
            p >>= 1

    def query(self, l, r):  # result on interval [l, r) (0-indexed)
        m, e, n, dat = self.m, self.e, self.n, self.dat
        res = e
        l += n
        r += n
        while l < r:
            if l & 1:
                res = m(res, dat[l])
                l += 1
            if r & 1:
                r -= 1
                res = m(res, dat[r])
            l >>= 1
            r >>= 1
        return res


ST = SegmentTree(A)
ans = 0
for i, a in enumerate(A):
    ST.modify(i, ST.e)
    ans = max(ans, ST.query(0, N))
    ST.modify(i, a)
print(ans)


Fixed submission:
import itertools
N = int(input())
A = [int(_) for _ in input().split()]
gcd = lambda x, y: gcd(y, x % y) if x % y else y
L = list(itertools.accumulate(A, func=gcd))
R = list(itertools.accumulate(A[::-1], func=gcd))[::-1]
ans = max(R[1], L[-2])
for i in range(1, N - 1):
    ans = max(ans, gcd(L[i - 1], R[i + 1]))
print(ans)
# https://img.atcoder.jp/abc125/editorial.pdf

Buggy python submission (verdict: Runtime Error):
import math
N = int(input())
A = [int(_) for _ in input().split()]


class SegmentTree():
    def m(self, v1, v2):  # ***monoid***
        return math.gcd(v1, v2)

    def __init__(self, array):
        m = self.m
        e = self.e = 0  # ***identity element***
        size = self.size = 10**6  # ***limit for array size***
        n = self.n = len(array)
        dat = self.dat = [e] * n + array + [e] * (2 * size - 2 * n)
        for i in range(n - 1, 0, -1):  # build
            dat[i] = m(dat[i << 1], dat[i << 1 | 1])

    def modify(self, p, v):  # set value at position p (0-indexed)
        m, n, dat = self.m, self.n, self.dat
        p += n
        dat[p] = v
        while p > 1:
            dat[p >> 1] = m(dat[p], dat[p ^ 1])
            p >>= 1

    def query(self, l, r):  # result on interval [l, r) (0-indexed)
        m, e, n, dat = self.m, self.e, self.n, self.dat
        res = e
        l += n
        r += n
        while l < r:
            if l & 1:
                res = m(res, dat[l])
                l += 1
            if r & 1:
                r -= 1
                res = m(res, dat[r])
            l >>= 1
            r >>= 1
        return res


ST = SegmentTree(A)
ans = 0
for i, a in enumerate(A):
    ST.modify(i, ST.e)
    ans = max(ans, ST.query(0, N))
    ST.modify(i, a)
print(ans)


Fixed submission:
import itertools
N = int(input())
A = [int(_) for _ in input().split()]
gcd = lambda x, y: gcd(y, x % y) if x % y else y
L = list(itertools.accumulate(A, func=gcd))
R = list(itertools.accumulate(A[::-1], func=gcd))[::-1]
ans = max(R[1], L[-2])
for i in range(1, N - 1):
    ans = max(ans, gcd(L[i - 1], R[i + 1]))
print(ans)
# https://img.atcoder.jp/abc125/editorial.pdf

Buggy python submission (verdict: Runtime Error):
import itertools
N = int(input())
A = [int(_) for _ in input().split()]
gcd = lambda x, y: gcd(y, x % y) if x % y else y
G = list(itertools.accumulate(A, func=gcd))
g = G[-1]
if G[0] == g:
    ans = list(itertools.accumulate(A[1:], func=gcd))[-1]
else:
    for i in range(1, N - 1):
        if G[i] == g:
            ans = max(
                gcd(G[i - 1],
                    list(itertools.accumulate(A[i + 1:], func=gcd))[-1]),
                G[-2])
            break
print(ans)


Fixed submission:
import itertools
N = int(input())
A = [int(_) for _ in input().split()]
gcd = lambda x, y: gcd(y, x % y) if x % y else y
L = list(itertools.accumulate(A, func=gcd))
R = list(itertools.accumulate(A[::-1], func=gcd))[::-1]
ans = max(R[1], L[-2])
for i in range(1, N - 1):
    ans = max(ans, gcd(L[i - 1], R[i + 1]))
print(ans)
# https://img.atcoder.jp/abc125/editorial.pdf