Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import pdb

def eat(n, x):
    ret = 0

    if x == 0:
        return 0, x

    if n == 0:
        x -= 1
        return 1, x

    if allnum[n] <= x:
        x -= allnum[n]
        return pnum[n], x
        
    
    x -= 1 # eat bread
    if x == 0:
        return 0, x

    # eat n-1 beager
    tmp, x = eat(n - 1, x)
    ret += tmp
    if x == 0:
        return ret, x

    # eat patty
    x -= 1
    ret += 1
    if x == 0:
        return ret, x

    # eat n-1 beager
    tmp, x = eat(n - 1, x)
    ret += tmp
    if x == 0:
        return ret, x

    x -= 1 # eat bread
        
    return ret, x


def main():
    tmp = input().split()
    n = int(tmp[0])
    x = int(tmp[1])
    global pnum
    global allnum
    pnum = [1]
    allnum = [1]
    for i  in range(1, 52):
        pnum.append(pnum[i-1] * 2 + 1)
        allnum.append(allnum[i-1] * 2 + 3)

    ans, tmp = eat(n, x)

    print("%d" % ans)

        
if __name__ == '__main__':
    main()


Fixed submission:
import pdb


def main():
    num = int(input())

    ans = ""
    
    if num == 25:
        ans = "Christmas"
    elif num == 24:
        ans = "Christmas Eve"
    elif num == 23:
        ans = "Christmas Eve Eve"
    elif num == 22:
        ans = "Christmas Eve Eve Eve"
        
    print(ans)

        
if __name__ == '__main__':
    main()

Buggy python submission (verdict: Runtime Error):
import pdb
import sys
sys.setrecursionlimit(10000)

def eat(n, x):
    ret = 0

    if x == 0:
        return 0, x

    if n == 0:
        x -= 1
        return 1, x

    if allnum[n] <= x:
        x -= allnum[n]
        return pnum[n], x
        
    
    x -= 1 # eat bread
    if x == 0:
        return 0, x

    # eat n-1 beager
    tmp, x = eat(n - 1, x)
    ret += tmp
    if x == 0:
        return ret, x

    # eat patty
    x -= 1
    ret += 1
    if x == 0:
        return ret, x

    # eat n-1 beager
    tmp, x = eat(n - 1, x)
    ret += tmp
    if x == 0:
        return ret, x

    x -= 1 # eat bread
        
    return ret, x


def main():
    tmp = input().split()
    n = int(tmp[0])
    x = int(tmp[1])
    global pnum
    global allnum
    pnum = [1]
    allnum = [1]
    for i  in range(1, 52):
        pnum.append(pnum[i-1] * 2 + 1)
        allnum.append(allnum[i-1] * 2 + 3)

    ans, tmp = eat(n, x)

    print("%d" % ans)

        
if __name__ == '__main__':
    main()


Fixed submission:
import pdb


def main():
    num = int(input())

    ans = ""
    
    if num == 25:
        ans = "Christmas"
    elif num == 24:
        ans = "Christmas Eve"
    elif num == 23:
        ans = "Christmas Eve Eve"
    elif num == 22:
        ans = "Christmas Eve Eve Eve"
        
    print(ans)

        
if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
line = input()

num = int(line)

if line < 1000:
    print("ABC")
else:
    print("ABD")

Fixed submission:
line = input()

num = int(line)

if num < 1000:
    print("ABC")
else:
    print("ABD")
Buggy python submission (verdict: Runtime Error):
n = int(input())
nums = list(map(int, input().split()))
nums.sort()
max = nums.pop(-1)
print(sum(nums))

if(sum(nums) > max):
    print("yes")
elif(sum(nums) <= max)
    print("no")


Fixed submission:
n = int(input())
lines = [int(x) for x in input().split()]
lines
lines = sorted(lines)
if lines[-1] < sum(lines[:-1]):
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
S = input()
before_number = ""
counter = 0
ans = 0

while 1 == 1:
    counter1 = S.count("01")
    S = S.replace("01", "")
    ans += counter1
    counter2 = S.count("10")
    S = S.replace("10", "")
    ans += counter2
    if counter1 == 0 and counter2 == 0:
        break

print(ans*2)


Fixed submission:
S = input()
counter0 = int(S.count("0"))
counter1 = int(S.count("1"))
print(min(counter0, counter1)*2)

Buggy python submission (verdict: Time Limit Exceeded):
s = str(input())
s_bef = s
s_len = len(s)
for x in reversed(range(1, s_len)):
    s = s.replace("0" * x + "1" * x, "").replace("1" * x + "0" * x, "")

while len(s_bef) > len(s):
    s_bef, s = s, s.replace("01", "").replace("10", "")
 
print (s_len - len(s))

Fixed submission:
s = str(input())
q = s[0]
for c in s[1:]:
    if len(q) >= 1:
        if q[-1] != c:
            q = q[:-1]
        else:
            q += c
    else:
        q += c
print(len(s) - len(q))

Buggy python submission (verdict: Time Limit Exceeded):
s_origin = str(input())

s = s_origin.replace("00000000001111111111", "")
s = s.replace("11111111110000000000", "")
s = s.replace("000000000111111111", "")
s = s.replace("111111111000000000", "")
s = s.replace("0000000011111111", "")
s = s.replace("1111111100000000", "")
s = s.replace("00000001111111", "")
s = s.replace("11111110000000", "")
s = s.replace("000000111111", "")
s = s.replace("111111000000", "")
s = s.replace("0000011111", "")
s = s.replace("1111100000", "")
s = s.replace("00001111", "")
s = s.replace("11110000", "")
s = s.replace("000111", "")
s = s.replace("111000", "")
s = s.replace("0011", "")
s = s.replace("1100", "")
s = s.replace("01", "")
s_aft = s.replace("10", "")

s_bef = s_origin
while len(s_bef) > len(s_aft):
    s_bef, s_aft = s_aft, s_aft.replace("01", "").replace("10", "")

print (len(s_origin) - len(s_aft))

Fixed submission:
s = str(input())
q = s[0]
for c in s[1:]:
    if len(q) >= 1:
        if q[-1] != c:
            q = q[:-1]
        else:
            q += c
    else:
        q += c
print(len(s) - len(q))
Buggy python submission (verdict: Runtime Error):
def sub():
    N, Vs, Cs = [e for e in input().split(" ")]
    N = int(N)
    Vs = [int(e) for e in Vs.split(" ")]
    Cs = [int(e) for e in Cs.split(" ")]
    ds = [v - c for v, c in zip(Vs, Cs)]
    ds = [d for d in ds if d > 0]
    print(sum(ds))


sub()


Fixed submission:
def sub():
    N, Vs, Cs = [input() for _ in range(3)]
    N = int(N)
    Vs = [int(e) for e in Vs.split(" ")]
    Cs = [int(e) for e in Cs.split(" ")]
    ds = [v - c for v, c in zip(Vs, Cs)]
    ds = [d for d in ds if d > 0]
    print(sum(ds))


sub()
Buggy python submission (verdict: Runtime Error):
import math


def sub():
    N, As = [input() for _ in range(2)]
    N = int(N)
    As = [int(e) for e in As.split(" ")]

    dp = {(-1, 0): 0, (-1, 1): -math.inf}
    for i in range(0, N):
        dp[(i, 0)] = max(dp[(i - 1, 0)] + As[i], dp[(i - 1, 1)] - As[i])
        dp[(i, 1)] = max(dp[(i - 1, 0)] - As[i], dp[(i - 1, 1)] + As[i])
    print("{}".format(dp[(N - 1, 0)]))


sub()


Fixed submission:
def sub():
    N, As = [input() for _ in range(2)]
    N = int(N)
    As = [int(e) for e in As.split(" ")]

    dp = {(-1, 0): 0, (-1, 1): -1e10}
    for i in range(0, N):
        dp[(i, 0)] = max(dp[(i - 1, 0)] + As[i], dp[(i - 1, 1)] - As[i])
        dp[(i, 1)] = max(dp[(i - 1, 0)] - As[i], dp[(i - 1, 1)] + As[i])
    print("{}".format(dp[(N - 1, 0)]))


sub()

Buggy python submission (verdict: Runtime Error):
import math
def sub():
    N, As = [input() for _ in range(2)]
    N = int(N)
    As = [int(e) for e in As.split(" ")]
    
    dp = {(-1,0): 0, (-1,1): -math.inf}
    for i in range(0, N):
        dp[(i,0)] = max(dp[(i-1, 0)] + As[i], dp[(i-1,1)] - As[i])
        dp[(i,1)] = max(dp[(i-1, 0)] - As[i], dp[(i-1,1)] + As[i])
    print("{}".format(dp[(N-1,0)]))

sub()


Fixed submission:
def sub():
    N, As = [input() for _ in range(2)]
    N = int(N)
    As = [int(e) for e in As.split(" ")]

    dp = {(-1, 0): 0, (-1, 1): -1e10}
    for i in range(0, N):
        dp[(i, 0)] = max(dp[(i - 1, 0)] + As[i], dp[(i - 1, 1)] - As[i])
        dp[(i, 1)] = max(dp[(i - 1, 0)] - As[i], dp[(i - 1, 1)] + As[i])
    print("{}".format(dp[(N - 1, 0)]))


sub()
Buggy python submission (verdict: Runtime Error):
def sub():
    N, K = [int(e) for e in input().split(" ")]
    ss = [int(e) for e in input()]
    # if len(set(ss)) == 1:
    #     print(len(ss))
    #     return

    dd = [ss[i+1] - ss[i] for i in range(N-1)]
    idd = [0] + [i+1 for i, d in enumerate(dd) if d != 0]
    # print(idd)
    maxScore = 0
    for i in range(len(idd)):
        if ss[i] == 0:
            ni = i + 2*K
            if ni < len(idd):
                score = idd[ni] - idd[i]
            else:
                score = N - idd[i]
            if score > maxScore:
                maxScore = score
        else:
            ni = i + 2*K + 1
            if ni < len(idd):
                score = idd[ni] - idd[i]
            else:
                score = N - idd[i]
            if score > maxScore:
                maxScore = score
        
    print(maxScore)

sub()


Fixed submission:
def sub():
    A, B = [int(e) for e in input().split(" ")]
    N = 0
    for _ in range(2):
        if A > B:
            N = N + A
            A = A -1
        else:
            N = N + B
            B = B - 1
    print("{}".format(N))

sub()
Buggy python submission (verdict: Runtime Error):
def sub():
    N, Hs = [input() for _ in range(2)]
    Hs = [int(e) for e in Hs.split(" ")]
    count = 1
    maxH = Hs[0]
    for i in range(1, N):
        h = Hs[i]
        if h >= maxH:
            count = count + 1
            maxH = h


    print("{}".format(count))

sub()



Fixed submission:
def sub():
    N, Hs = [input() for _ in range(2)]
    Hs = [int(e) for e in Hs.split(" ")]
    count = 1
    maxH = Hs[0]
    for i in range(1, int(N)):
        h = Hs[i]
        if h >= maxH:
            count = count + 1
            maxH = h


    print("{}".format(count))

sub()
Buggy python submission (verdict: Runtime Error):
n, m = map(int, raw_input().split())
lis = map(int, raw_input().split())
lis = sorted(lis)
lol = []
for i in range(1, m):
    lol.append(lis[i] - lis[i-1])
lol = sorted(lol)
ans = lis[-1] - lis[0]
idx = len(lol) - 1
if idx >= 0:
    for i in xrange(n-1):
        ans -= lol[idx]
        idx-=1
print ans

Fixed submission:
n, m = map(int, raw_input().strip().split())
lis = map(int, raw_input().strip().split())
lis = sorted(lis)
lol = []
for i in range(1, m):
    lol.append(lis[i] - lis[i-1])
lol = sorted(lol)
ans = lis[-1] - lis[0]
idx = len(lol) - 1
if idx >= 0:
    for i in xrange(n-1):
        ans -= lol[idx]
        idx-=1
        if idx == -1:
            break
print ans
Buggy python submission (verdict: Runtime Error):
n =int(raw_input())
lis=[]
for i in range(1,26):
    lis.add(4*i)
for i in range(1,15):
    lis.add(7*i)
for i in range(1,20):
    for j in range(1,20):
        lis.add(4*i+7*j)
if n in lis:
    print "Yes"
else:
    print "No"


Fixed submission:
n =int(raw_input())
lis=[]
for i in range(1,26):
    lis.append(4*i)
for i in range(1,15):
    lis.append(7*i)
for i in range(1,20):
    for j in range(1,20):
        lis.append(4*i+7*j)
if n in lis:
    print "Yes"
else:
    print "No"
Buggy python submission (verdict: Runtime Error):
n, m, X, Y = map(int, input().split())
xs = list(map(int, input().split()))
ys = list(map(int, input().split()))
x_max = max(xs)
y_min = min(ys)
if y_min > x_max:
    for z in list(range(x_max, y_min + 1)):
        if (z > X) and (z <= Y):
            print('No War')
            break
    else:
        print('War')
else:
    print(bvv)

Fixed submission:
n, m, X, Y = map(int, input().split())
xs = list(map(int, input().split()))
ys = list(map(int, input().split()))
x_max = max(xs)
y_min = min(ys)
def get_war(x_max, y_min, X, Y):
    if y_min > x_max:
        for z in list(range(x_max+1, y_min + 1)):
            if (z > X) and (z <= Y):
                return 'No War'
            else:
                pass
        else:
            return 'War'
    else:
        return 'War'
print(get_war(x_max, y_min, X, Y))
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
t = input()

def get_yes(s, t):
    s_dup_lists = []
    t_dup_lists = []

    for i, (s1, t1) in enumerate(zip(s, t)):
        for j, (s2, t2) in enumerate(zip(s, t)):
            if (i != j) and (s1 == s2):
                s_dup_lists.append([i, j])
            if (i != j) and (t1 == t2):
                t_dup_lists.append([i, j])
            if s_dup_lists != t_dup_lists:
                return 'No'

    if s_dup_lists == t_dup_lists:
        return 'Yes'
    else:
        return 'No'
print(get_yes(s, t))

Fixed submission:
s = input()
t = input()

s_dict = {}
t_dict = {}
s_drdp = sorted(set(s), key=s.index)
t_drdp = sorted(set(t), key=t.index)
for i, ss in enumerate(s_drdp):
    s_dict[ss] = i
for i, tt in enumerate(t_drdp):
    t_dict[tt] = i

import numpy as np

def s2vec(d, d_dict):
    return d_dict[d]

vecf = np.vectorize(s2vec)
if list(vecf(list(s), s_dict)) == list(vecf(list(t), t_dict)):
    print('Yes')
else:
    print('No')

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
t = input()
s_dup_lists = []
t_dup_lists = []

for i, (s1, t1) in enumerate(zip(s, t)):
    for j, (s2, t2) in enumerate(zip(s, t)):
        if (i != j) and (s1 == s2):
            s_dup_lists.append([i, j])
        if (i != j) and (t1 == t2):
            t_dup_lists.append([i, j])

if s_dup_lists == t_dup_lists:
    print('Yes')
else:
    print('No')

Fixed submission:
s = input()
t = input()

s_dict = {}
t_dict = {}
s_drdp = sorted(set(s), key=s.index)
t_drdp = sorted(set(t), key=t.index)
for i, ss in enumerate(s_drdp):
    s_dict[ss] = i
for i, tt in enumerate(t_drdp):
    t_dict[tt] = i

import numpy as np

def s2vec(d, d_dict):
    return d_dict[d]

vecf = np.vectorize(s2vec)
if list(vecf(list(s), s_dict)) == list(vecf(list(t), t_dict)):
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
# coding: utf-8
def get_ln_inputs():
    return input().split()


def get_ln_int_inputs():
    return list(map(int, get_ln_inputs()))


def main():
    n = get_ln_int_inputs()[0]
    a = get_ln_int_inputs()

    ilist = []

    t = n
    while t > 0:
        ilist.append(t)
        t -= 2
    t += 1
    while t < n:
        ilist.append(t)
        t += 2
    
    print(" ".join(str(a[i - 1]) for i in ilist))


main()

Fixed submission:
# coding: utf-8
def get_ln_inputs():
    return input().split()


def get_ln_int_inputs():
    return list(map(int, get_ln_inputs()))


def main():
    p = get_ln_int_inputs()
    print(sum(p) - max(p))


main()
Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
def get_ln_inputs():
    return input().split()


def get_ln_int_inputs():
    return list(map(int, get_ln_inputs()))


def main():
    n = get_ln_int_inputs()[0]
    a = get_ln_int_inputs()
    reverse = n % 2 == 0

    result = list()
    for i in range(n):
        ii = len(result) if i % 2 == 1 else 0
        result.insert(ii, a[i])
    
    if reverse:
        result = result[::-1]

    print(" ".join(str(x) for x in result))


main()

Fixed submission:
# coding: utf-8
def get_ln_inputs():
    return input().split()


def get_ln_int_inputs():
    return list(map(int, get_ln_inputs()))


def main():
    n = get_ln_int_inputs()[0]
    a = get_ln_int_inputs()

    ilist = []

    t = n
    while t > 0:
        ilist.append(t)
        t -= 2
    if t == -1:
        t = 2
    else:
        t = 1
    while t < n:
        ilist.append(t)
        t += 2
    
    print(" ".join(str(a[i - 1]) for i in ilist))


main()

Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
def get_ln_inputs():
    return input().split()


def get_ln_int_inputs():
    return list(map(int, get_ln_inputs()))


def main():
    n = get_ln_int_inputs()[0]
    a = get_ln_int_inputs()
    reverse = n % 2 == 0

    result = list()
    for i in range(n):
        ii = len(result) if i % 2 == 1 else 0
        result.insert(ii, a[i])
    
    if reverse:
        result = result[::-1]

    print(" ".join(list(map(str, result))))


main()

Fixed submission:
# coding: utf-8
def get_ln_inputs():
    return input().split()


def get_ln_int_inputs():
    return list(map(int, get_ln_inputs()))


def main():
    n = get_ln_int_inputs()[0]
    a = get_ln_int_inputs()

    ilist = []

    t = n
    while t > 0:
        ilist.append(t)
        t -= 2
    if t == -1:
        t = 2
    else:
        t = 1
    while t < n:
        ilist.append(t)
        t += 2
    
    print(" ".join(str(a[i - 1]) for i in ilist))


main()
Buggy python submission (verdict: Runtime Error):
# coding: utf-8
def get_ln_inputs():
    return input().split()


def get_ln_int_inputs():
    return list(map(int, get_ln_inputs()))


def main():
    get_ln_inputs()
    rates = get_ln_int_inputs()

    colors = list()
    for _ in range(8):
        colors.append(0)

    free_colors = 0
    for rate in rates:
        if rate >= 3200:
            free_colors += 1
        else:
            colors[rate // 400] = 1
    fixed_colors = sum(colors)

    print(str(fixed_colors) + " " + str(fixed_colors + free_colors))


main()

Fixed submission:
# coding: utf-8
def get_ln_inputs():
    return input().split()


def get_ln_int_inputs():
    return list(map(int, get_ln_inputs()))


def main():
    if int("".join(get_ln_inputs())) % 4 == 0:
        print("YES")
    else:
        print("NO")


main()
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
x =[int(i) for i in input().split()]
c = n//2 - 1

for i in range(0,n):
    temp = x.copy()
    temp.pop(i)
    temp.sort()
    print(temp[c])
    

Fixed submission:
n = int(input())
x =[int(i) for i in input().split()]
c = n//2 - 1
y = x.copy()
y.sort()

for i in range(0,n):
    if y[c] >= x[i]:
        print(y[c+1])
    else:
        print(y[c])
Buggy python submission (verdict: Time Limit Exceeded):
n, k = [int(i) for i in input().split()]
ans = 0
for a in range(k,n+1):
    ans += n - a
    for b in range(1,a):
        if a % b >= k:
            ans += 1

print(ans)

Fixed submission:
def max(a,b):
    if a > b:
        return a
    else:
        return b
n, k = [int(i) for i in input().split()]
ans = 0


for b in range(1,n+1):
    p = n // b
    r = n % b
    ans += p * max(0,b-k)+max(0,r-k+1)
if k == 0:
    ans -= n
    
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n, k = [int(i) for i in input().split()]
ans = 0
for a in range(1,n+1):
    for b in range(1,n+1):
        if a % b >= k:
            ans += 1

print(ans)

Fixed submission:
def max(a,b):
    if a > b:
        return a
    else:
        return b
n, k = [int(i) for i in input().split()]
ans = 0


for b in range(1,n+1):
    p = n // b
    r = n % b
    ans += p * max(0,b-k)+max(0,r-k+1)
if k == 0:
    ans -= n
    
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = str(input()).split()
b = str(input()).split()
c = [a,b]
def max(x,y):
    if x > y:
    return x
    else:
    return y 
def mp(v,w):
    if v == 0 and w == 0:
        return int(c[v][w])
    elif v == 0:
        return mp(v,(w - 1)) + int(c[v][w])
    elif w == 0:
        return mp((v - 1),w) + int(c[v][w])
    else:
        return max(mp(v,(w - 1)),mp((v - 1),w)) + int(c[v][w])
print(mp(1,(n-1)))

Fixed submission:
x = int(input())
a = int(input())
b = int(input())
sub = x - a
while sub >= b:
    sub -= b
print(sub)

Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())
c = int(input())
x = int(input())
answer = 0
for i in range(0,(a + 1)):
    for j in range(0,(b + 1)):
        for k in range(0,(c + 1)):
            if x == 500 * i + 100 * j + 50 * k:
                answer += 1
print(answer)

Fixed submission:
x = int(input())
a = int(input())
b = int(input())
sub = x - a
while sub >= b:
    sub -= b
print(sub)
Buggy python submission (verdict: Runtime Error):
a = str(input()).split
if ( int(a[0]) * int(a[1]) ) % 2 == 1:
    print('0dd')
else:
    print('Even')
    

Fixed submission:
a = str(input()).split()
if ( int(a[0]) * int(a[1]) ) % 2 == 1:
    print('Odd')
else:
    print('Even')
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
proba = 0
if K == 1:
    print(1)
else:
    for n in range(0, N+1):
        for ii in range(17):
            if n * (2 ** ii) >= K:
                proba += (1 / N) * (2 ** (-ii))
                break
            
	print(proba)

Fixed submission:
N, K = map(int, input().split())
proba = 0
for n in range(0, N+1):
    for ii in range(18):
        if n * (2 ** ii) >= K:
            proba += (1 / N) * (0.5 ** ii)
            break

print(proba)
Buggy python submission (verdict: Runtime Error):
S = input()
print(min(len(re.findall('0', S)), len(re.findall('1', S))) * 2 if len(S) > 1 else 0)

Fixed submission:
A, B, C = map(int, input().split())
print(C if A * C < B else B //A)
Buggy python submission (verdict: Runtime Error):
S = input()
print(min(len(re.findall('0', S)), len(re.findall('1', S))) * 2 if len(S) > 1 else 0)

Fixed submission:
S = input()
import re
if len(S) > 1:
    print(min(len(re.findall('0', S)), len(re.findall('1', S))) * 2)
else:
    print(0)
Buggy python submission (verdict: Runtime Error):
from math import gcd

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



# L[0] = 0
# L[i] (i=1, ..., N)にはA_1, ..., A_iの最大公約数が格納されている

L = []
L.append(A[0])

for i in range(N):
    L.append(gcd(L[i], A[i]))

#  for i in range(N+1):
    #  print(L[i])


# R[N+1] = 0
# R[i] (i=N, N-1, ..., 1)にはA_i, ..., A_Nの最大公約数が格納されている

R = [0] * (N+2)
# R = [0, 0, 0, ... , 0] (0がN+2個)
R[N+1] = A[N-1]

for i in range(N, 0, -1):
    R[i] = gcd(A[i-1], R[i+1])

#  for i in range(N+1, -1, -1):
    #  print(R[i])



# M[i] (i=0, ..., N-1)にはA_(i+1)を除いた整数の最大公約数が格納されている

M = []
for i in range(N):
    M.append(gcd(L[i], R[i+2]))

print(max(M))


Fixed submission:
from fractions import gcd

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



# L[0] = 0
# L[i] (i=1, ..., N)にはA_1, ..., A_iの最大公約数が格納されている

L = []
L.append(0)

for i in range(N):
    L.append(gcd(L[i], A[i]))

#  for i in range(N+1):
    #  print(L[i])


# R[N+1] = 0
# R[i] (i=N, N-1, ..., 1)にはA_i, ..., A_Nの最大公約数が格納されている

R = [0] * (N+2)
# R = [0, 0, 0, ... , 0] (0がN+2個)

for i in range(N, 0, -1):
    R[i] = gcd(A[i-1], R[i+1])

#  for i in range(N+1, -1, -1):
    #  print(R[i])



# M[i] (i=0, ..., N-1)にはA_(i+1)を除いた整数の最大公約数が格納されている

M = []
for i in range(N):
    M.append(gcd(L[i], R[i+2]))

print(max(M))

Buggy python submission (verdict: Runtime Error):
from math import gcd

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



# L[0] = 0
# L[i] (i=1, ..., N)にはA_1, ..., A_iの最大公約数が格納されている

L = []
L.append(0)

for i in range(N):
    L.append(gcd(L[i], A[i]))

#  for i in range(N+1):
    #  print(L[i])


# R[N+1] = 0
# R[i] (i=N, N-1, ..., 1)にはA_i, ..., A_Nの最大公約数が格納されている

R = [0] * (N+2)
# R = [0, 0, 0, ... , 0] (0がN+2個)

for i in range(N, 0, -1):
    R[i] = gcd(A[i-1], R[i+1])

#  for i in range(N+1, -1, -1):
    #  print(R[i])



# M[i] (i=0, ..., N-1)にはA_(i+1)を除いた整数の最大公約数が格納されている

M = []
for i in range(N):
    M.append(gcd(L[i], R[i+2]))

print(max(M))






Fixed submission:
from fractions import gcd

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



# L[0] = 0
# L[i] (i=1, ..., N)にはA_1, ..., A_iの最大公約数が格納されている

L = []
L.append(0)

for i in range(N):
    L.append(gcd(L[i], A[i]))

#  for i in range(N+1):
    #  print(L[i])


# R[N+1] = 0
# R[i] (i=N, N-1, ..., 1)にはA_i, ..., A_Nの最大公約数が格納されている

R = [0] * (N+2)
# R = [0, 0, 0, ... , 0] (0がN+2個)

for i in range(N, 0, -1):
    R[i] = gcd(A[i-1], R[i+1])

#  for i in range(N+1, -1, -1):
    #  print(R[i])



# M[i] (i=0, ..., N-1)にはA_(i+1)を除いた整数の最大公約数が格納されている

M = []
for i in range(N):
    M.append(gcd(L[i], R[i+2]))

print(max(M))