Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
N = input()
S = input()

n = int(N/2)
s1 = S[:n]
s2 = S[n:]

if s1 == s2:
    print('Yes')
else:
    print('No')

Fixed submission:
N = int(input())
S = input()

n = int(N/2)
s1 = S[:n]
s2 = S[n:]

if s1 == s2:
    print('Yes')
else:
    print('No')

Buggy python submission (verdict: Runtime Error):
S = input()
N = input()
N = int(N/2)
S1 = S[:N]
S2 = S[N:]

if S1 == S2:
    print('Yes')
else:
    print('No')

Fixed submission:
N = int(input())
S = input()

n = int(N/2)
s1 = S[:n]
s2 = S[n:]

if s1 == s2:
    print('Yes')
else:
    print('No')

Buggy python submission (verdict: Runtime Error):
S = input()
N = int(input())
N = int(N/2)
S1 = S[:N]
S2 = S[N:]

if S1 == S2:
    print('Yes')
else:
    print('No')

Fixed submission:
N = int(input())
S = input()

n = int(N/2)
s1 = S[:n]
s2 = S[n:]

if s1 == s2:
    print('Yes')
else:
    print('No')

Buggy python submission (verdict: Runtime Error):
S = input()
N = int(input())
N = int(N/2)
S1 = S[:N]
S2 = S[N:]

if S1 == S2:
    print('Yes')
else:
    print('No')

Fixed submission:
N = int(input())
S = input()

n = int(N/2)
s1 = S[:n]
s2 = S[n:]

if s1 == s2:
    print('Yes')
else:
    print('No')

Buggy python submission (verdict: Runtime Error):
n = int(input())
t = str(input())

if (n !== len(t)): print("No")
else:
	nHalf = int(n / 2)

	if (nHalf == 1):
		print("No")
	elif (n == 0):
		print("No")
	else:
	    if (t[:nHalf] == t[nHalf:]):
	    	print("Yes")
	    else:
	    	print("No")

Fixed submission:
n = int(input())
t = str(input())

if (n != len(t)):
	print("No")
else:
	nHalf = int(n / 2)

	if (nHalf == 1 and n != 2):
		print("No")
	elif (n == 0):
		print("No")
	else:
		if (t[:nHalf] == t[nHalf:]):
			print("Yes")
		else:
			print("No")
Buggy python submission (verdict: Runtime Error):
from itertools import permutations
import numpy as np

def calc_distance(point):
    _point = np.array(list(point))
    x = np.diff(_point, axis=0)
    every_distance = np.linalg.norm(x, axis=1)
    all_distance = np.sum(every_distance)
    return all_distance

n = int(input())
points = [[int(v) for v in input().split(' ')] for _ in range(n)]

sum = 0
for v in permutations(points):
    sum += calc_distance(v)


print(sum / len(list(permutations(points))))


Fixed submission:
from itertools import permutations
import numpy as np

def calc_distance(point):
    _point = np.array(list(point))
    x = np.diff(_point, axis=0)
    every_distance = np.linalg.norm(x, axis=1)
    all_distance = np.sum(every_distance)
    return all_distance

n = int(input())
points = [[int(v) for v in input().split(' ')] for _ in range(n)]

sum = 0
for v in permutations(points):
    sum += calc_distance(v)


print(sum / len(list(permutations(points))))
Buggy python submission (verdict: Runtime Error):
n = int(input())
for i in range(10):
    for j in range(10):
        if n / i == j:
            print('Yes')

print('No')


Fixed submission:
n = int(input())

flag = True
for i in range(1, 10):
    for j in range(1, 10):
        if n / i == j:
            print('Yes')
            flag = False
            break
    else:
        continue
    break

if flag:
    print('No')
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import combinations

n = int(input())
l = [int(v) for v in input().split(' ')]

comb = combinations(l, 3)

sum = 0
for value in comb:
    if value[0] < value[1] + value[2] and value[1] < value[0] + value[2] and value[2] < value[0] + value[1]:
        sum += 1

print(sum)


Fixed submission:
import bisect

n = int(input())
l = [int(v) for v in input().split(' ')]
sum = 0
l.sort()
for i in range(n):
    for j in range(n):
        if i < j:
            ab = l[i] + l[j]
            index = bisect.bisect_left(l, ab)
            sum += index - j - 1
print(sum)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
n = int(input())
a = [int(i) for i in input().split(' ')]

sorted_a = sorted(a)
for value in sorted_a:
    print(a.index(value) + 1, end=' ')
print()


Fixed submission:
import sys
input = sys.stdin.readline
n = int(input())
a = [int(i) for i in input().split(' ')]

dict = {}
for i, value in enumerate(a):
    dict[value] = i + 1

a.sort()

for i in a:
    print(dict[i], end=' ')
print()

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [int(i) for i in input().split(' ')]

sorted_a = sorted(a)
for value in sorted_a:
    print(a.index(value) + 1, end=' ')
print()


Fixed submission:
import sys
input = sys.stdin.readline
n = int(input())
a = [int(i) for i in input().split(' ')]

dict = {}
for i, value in enumerate(a):
    dict[value] = i + 1

a.sort()

for i in a:
    print(dict[i], end=' ')
print()
Buggy python submission (verdict: Runtime Error):
from math import gcd
a, b = [int(i) for i in input().split(' ')]
gcd = gcd(a, b)

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

if gcd == 1:
    print(1)
else:
    print(len(factorization(gcd)) + 1)


Fixed submission:
from fractions import gcd
a, b = [int(i) for i in input().split(' ')]
gcd = gcd(a, b)

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

if gcd == 1:
    print(1)
else:
    print(len(factorization(gcd)) + 1)

Buggy python submission (verdict: Runtime Error):
from math import gcd
a, b = [int(i) for i in input().split(' ')]
gcd = gcd(a, b)

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

if gcd == 1:
    print(1)
else:
    print(len(factorization(gcd)) + 1)


Fixed submission:
from fractions import gcd
a, b = [int(i) for i in input().split(' ')]
gcd = gcd(a, b)

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

if gcd == 1:
    print(1)
else:
    print(len(factorization(gcd)) + 1)
Buggy python submission (verdict: Runtime Error):
string = input()

def jadge_humiyasui(string):
    for i, str in enumerate(string):
        if i % 2 == 0:
            label1 = str in ['R', 'U', 'D']
        else:
            label2 = str in ['L', 'U', 'D']

    if label1 & label2:
        print('Yes')
    else:
        print('No')

jadge_humiyasui(string)


Fixed submission:
string = input()

def jadge_humiyasui(string):
    label1 = True
    label2 = True

    for i, str in enumerate(string):
        if i % 2 == 0:
            if str not in ['R', 'U', 'D']:
                label1 = False
        else:
            if str not in ['L', 'U', 'D']:
                label2 = False

    if label1 & label2:
        print('Yes')
    else:
        print('No')

jadge_humiyasui(string)
Buggy python submission (verdict: Runtime Error):
N = int(input())
S = input()
K = int(input())


for i in range(N):
    if S[K - 1] != S[i]:
        S[i] = '*'
        
print(S)


Fixed submission:
N = int(input())
S = input()
K = int(input())

str_list = list(S)

for i in range(N):
    if str_list[K - 1] != str_list[i]:
        str_list[i] = '*'

S = "".join(str_list)
print(S)
Buggy python submission (verdict: Runtime Error):
a , b, c  = map(int, input().split
if c >= (a-b):
    print(c-(a-b))
else:
    print(0)

Fixed submission:
a , b, c  = map(int, input().split())
if c >= (a-b):
    print(c-(a-b))
else:
    print(0)
Buggy python submission (verdict: Runtime Error):
f __name__ == '__main__':
    N, K = map(int, input().split())
    people_hight = list(input().split())
    ok = 0

    for person_hight in people_hight:
        if K <= int(person_hight) :
            ok = ok + 1
    print(ok)


Fixed submission:
if __name__ == '__main__':
    N, K = map(int, input().split())
    people_hight = list(input().split())
    ok = 0

    for person_hight in people_hight:
        if K <= int(person_hight) :
            ok = ok + 1
    print(ok)
Buggy python submission (verdict: Time Limit Exceeded):
if __name__ == '__main__':
    N = int(input())
    order_list = list(map(int, input().split()))
    present_list = list()

    for i in range(1, (N+1)):
        present_list.append(order_list.index(i) + 1)

    print(' ' .join(map(str, present_list)))

Fixed submission:
if __name__ == '__main__':
    N = int(input())
    order_list = list(map(int, input().split()))
    present_list = list(range(1, N+1))
    temp = zip(order_list, present_list)
    temp = sorted(temp)
    order_list, present_list = zip(*temp)
    print(' '.join(map(str,present_list)))

Buggy python submission (verdict: Time Limit Exceeded):
if __name__ == '__main__':
    N = int(input())
    order_list = list(map(int, input().split()))

    for i in range(1, (N+1)):
        print(order_list.index(i) + 1, end=" ")

Fixed submission:
if __name__ == '__main__':
    N = int(input())
    order_list = list(map(int, input().split()))
    present_list = list(range(1, N+1))
    temp = zip(order_list, present_list)
    temp = sorted(temp)
    order_list, present_list = zip(*temp)
    print(' '.join(map(str,present_list)))

Buggy python submission (verdict: Time Limit Exceeded):
if __name__ == '__main__':
    N = int(input())
    order_list = list(map(int, input().split()))
    present_num_list = list(range(1, (N+1)))

    for i in range(1, (N+1)):
        print(order_list.index(i) + 1, end=" ")

Fixed submission:
if __name__ == '__main__':
    N = int(input())
    order_list = list(map(int, input().split()))
    present_list = list(range(1, N+1))
    temp = zip(order_list, present_list)
    temp = sorted(temp)
    order_list, present_list = zip(*temp)
    print(' '.join(map(str,present_list)))
Buggy python submission (verdict: Runtime Error):
n = int(input())
s = input()

if n % 2 != 0: return "No"
else :
  for i in range(n / 2):
    if a[i] != a[i + n / 2]: print "No"
  print "Yes"


Fixed submission:
import sys


def work():
    n = int(input())
    s = sys.stdin.readline()
    if n % 2 == 1: print "No"
    else :
        for i in range(n / 2):
            if s[i] != s[i + n / 2]:
		print "No"
		return
	print "Yes"

work()
Buggy python submission (verdict: Runtime Error):
n = int(input())
s = input()
ans = s[1]
for i in range(1, n):
    if ans[-1] == s[i]:
        continue
    else:
        ans += s[i]
print(len(ans))

Fixed submission:
n = int(input())
s = input()
ans = s[0]
for i in range(1, n):
    if ans[-1] == s[i]:
        continue
    else:
        ans += s[i]
print(len(ans))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
l = sorted(list(map(int, input().split())))
cnt = 0
for i in range(n - 2):
    for j in range(i + 1, n - 1):
        c_max = l[i] + l[j]
        for k in range(j + 1, n):
            if l[k] < c_max:
                cnt += 1
            else:
                break
print(cnt)

Fixed submission:
import bisect

n = int(input())
l = sorted(list(map(int, input().split())))
cnt = 0
for i in range(n-1, 1, -1):
    for j in range(i - 1, 0, -1):
        c = l[i] - l[j]
        index = bisect.bisect_right(l, c, 0, j)
        cnt += j - index
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
l = sorted(list(map(int, input().split())))
cnt = 0
for i in range(n - 2):
    for j in range(i + 1, n - 1):
        c_max = l[i] + l[j]
        for k in range(j + 1, n):
            if l[k] >= c_max:
                c_index = k
                break
        else:
            c_index = n
        cnt += c_index - (j + 1)
print(cnt)


Fixed submission:
import bisect

n = int(input())
l = sorted(list(map(int, input().split())))
cnt = 0
for i in range(n-1, 1, -1):
    for j in range(i - 1, 0, -1):
        c = l[i] - l[j]
        index = bisect.bisect_right(l, c, 0, j)
        cnt += j - index
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
l = list(map(int, input().split()))
cnt = 0
for i in range(n-2):
    for j in range(i+1, n-1):
        for k in range(j+1, n):
            if l[i] < l[j] + l[k] and l[j] < l[i] + l[k] and l[k] < l[i] + l[j]:
                cnt += 1
print(cnt)

Fixed submission:
import bisect

n = int(input())
l = sorted(list(map(int, input().split())))
cnt = 0
for i in range(n-1, 1, -1):
    for j in range(i - 1, 0, -1):
        c = l[i] - l[j]
        index = bisect.bisect_right(l, c, 0, j)
        cnt += j - index
print(cnt)
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
d = set(map(str, input().split()))
for i in range(n, 10*n):
    if len(d & set(str(i))) == 0:
        print(i)
        break

Fixed submission:
ary = list(map(int, input().split()))
if ary.count(5) == 2 and ary.count(7) == 1:
    print('YES')
else:
    print('NO')
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
d = sorted(list({0, 1, 2, 3, 4, 5, 6, 7, 8, 9} - set(map(int, input().split()))))
n = str(n)
ans = ''
for i in n:
    for j in d:
        if j >= int(i):
            ans += str(j)
            break
print(int(ans))

Fixed submission:
n, k = map(int, input().split())
d = set(map(str, input().split()))
for i in range(n, 10*n):
    if len(d & set(str(i))) == 0:
        print(i)
        break

Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
d = sorted(list({0, 1, 2, 3, 4, 5, 6, 7, 8, 9} - set(map(int, input().split()))))
n = str(n)
ans = ''
for i in n:
    for j in d:
        if j >= int(i):
            ans += str(j)
            break
print(int(ans))

Fixed submission:
n, k = map(int, input().split())
d = set(map(str, input().split()))
for i in range(n, 10*n):
    if len(d & set(str(i))) == 0:
        print(i)
        break
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
ans = 0
ls = [n, 0, 0, 0, 0, 0]
while ls[-1] != n:
    ans += 1
    lscp = ls[:]
    ls[0] = lscp[0] - min(a,lscp[0])
    ls[1] = lscp[1] - min(b, lscp[1]) + min(a, lscp[0])
    ls[2] = lscp[2] - min(c, lscp[2]) + min(b, lscp[1])
    ls[3] = lscp[3] - min(d, lscp[3]) + min(c, lscp[2])
    ls[4] = lscp[4] - min(e, lscp[4]) + min(d, lscp[3])
    ls[5] = lscp[5] + min(e, lscp[4])
print(ans)

Fixed submission:
import math
n = int(input())
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
x = min(a, b, c, d, e)
X = math.ceil(n / x)
print(5 + X - 1)
Buggy python submission (verdict: Time Limit Exceeded):
n, q = map(int, input().split())
s = str(input())
ls = [list(map(int, input().split()))  for i in range(q)]
for i in range(q):
    l, r = ls[i][0], ls[i][1]
    ans = s[l - 1: r].count('AC')
    print(ans)

Fixed submission:
n, q = map(int, input().split())
s = str(input())
ls = [list(map(int, input().split())) for i in range(q)]
t = [0] * (n + 1)
for i in range(n):
    t[i + 1] = t[i] + (1 if s[i:i + 2] == 'AC' else 0)
for i in range(q):
    l, r = ls[i][0], ls[i][1]
    ans = t[r - 1] - t[l - 1]
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n, q = map(int, input().split())
s = str(input())
ls = [list(map(int, input().split()))  for i in range(q)]
for i in range(q):
    l, r = ls[i][0], ls[i][1]
    ans = s[l - 1: r].count('AC')
    print(ans)

Fixed submission:
n, q = map(int, input().split())
s = str(input())
ls = [list(map(int, input().split())) for i in range(q)]
t = [0] * (n + 1)
for i in range(n):
    t[i + 1] = t[i] + (1 if s[i:i + 2] == 'AC' else 0)
for i in range(q):
    l, r = ls[i][0], ls[i][1]
    ans = t[r - 1] - t[l - 1]
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
ans = []

for i in range(M):
    tmp = list(map(int, input().split()))
    if i == 0:
        ans = [x for x in range(tmp[0], tmp[1]+1)]
    else:
        cur = [x for x in range(tmp[0], tmp[1]+1)]
        ans = [x for x in cur if x in ans]

print(len(ans))

Fixed submission:
N, M = map(int, input().split())
L = 0
R = 10**5

for i in range(M):
    tmp = list(map(int, input().split()))
    if L<tmp[0]:
        L = tmp[0]
    if R>tmp[1]:
        R = tmp[1]

ans = [x for x in range(L, R+1)]

print(len(ans))
Buggy python submission (verdict: Runtime Error):
from operator import itemgetter

N, M = map(int, input().split())
A = list(map(int, input().split()))
BC =[]

for i in range(M):
    BC.append(list(map(int,input().split())))

A.sort()
BC_sorted = sorted(BC, key=itemgetter(1), reverse=True)
# print(BC_sorted)

cur = 0

for i in range(M):
    if A[cur]>= BC_sorted[i][1]:
        break
    for j in range(BC_sorted[i][0]):
        for k in range(cur, N):
            if A[k] < BC_sorted[i][1]:
                A[k] = BC_sorted[i][1]
                cur = k+1
                break
            elif A[k] > BC_sorted[i][1]:
                cur = k+1
                break
    # print(i, ':', A, 'cur:', cur)


print(sum(A))

Fixed submission:
from operator import itemgetter

N, M = map(int, input().split())
A = list(map(int, input().split()))
BC =[]

for i in range(M):
    BC.append(list(map(int,input().split())))

A.sort()
BC_sorted = sorted(BC, key=itemgetter(1), reverse=True)
# print(BC_sorted)

cur = 0

for i in range(M):
    if cur == N or A[cur]>= BC_sorted[i][1]:
        break
    for j in range(BC_sorted[i][0]):
        for k in range(cur, N):
            if A[k] < BC_sorted[i][1]:
                A[k] = BC_sorted[i][1]
                cur = k+1
                break
            elif A[k] > BC_sorted[i][1]:
                cur = k+1
                break
    # print(i, ':', A, 'cur:', cur)


print(sum(A))

Buggy python submission (verdict: Time Limit Exceeded):
from operator import itemgetter

N, M = map(int, input().split())
A = list(map(int, input().split()))
BC =[]

for i in range(M):
    BC.append(list(map(int,input().split())))

A.sort()
BC_sorted = sorted(BC, key=itemgetter(1), reverse=True)

for i in range(M):
    cnt = BC_sorted[i][0]
    for j in range(cnt):
        for k in range(N):
            if A[k] < BC_sorted[i][1]:
                A[k] = BC_sorted[i][1]
                break


print(sum(A))

Fixed submission:
from operator import itemgetter

N, M = map(int, input().split())
A = list(map(int, input().split()))
BC =[]

for i in range(M):
    BC.append(list(map(int,input().split())))

A.sort()
BC_sorted = sorted(BC, key=itemgetter(1), reverse=True)
# print(BC_sorted)

cur = 0

for i in range(M):
    if cur == N or A[cur]>= BC_sorted[i][1]:
        break
    for j in range(BC_sorted[i][0]):
        for k in range(cur, N):
            if A[k] < BC_sorted[i][1]:
                A[k] = BC_sorted[i][1]
                cur = k+1
                break
            elif A[k] > BC_sorted[i][1]:
                cur = k+1
                break
    # print(i, ':', A, 'cur:', cur)


print(sum(A))
Buggy python submission (verdict: Time Limit Exceeded):
R, G, B, N = map(int, input().split())
colors = [R, G, B]
colors.sort()
ans = 0

for c1 in range(N//colors[2]+1, -1, -1):
    C1 = c1*colors[2] 
    for c2 in range(N//colors[1], -1, -1):
        C2 = c2*colors[1] 
        C3 = (N-C1-C2)/colors[0]
        if C3 >= 0 and C3.is_integer():
            ans += 1

print(ans)

Fixed submission:
R, G, B, N = map(int, input().split())
r, g, b = 0, 0, 0
ans = 0
 
for r in range(N//R+1):
    Rr = R*r
    for g in range(N//G+1):
        Gg = G*g
        Bb = N-Rr-Gg

        if Bb < 0:
            break
        if Bb%B == 0:
            ans += 1
 
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
R, G, B, N = map(int, input().split())
r, g, b = 0, 0, 0
ans = 0

for r in range(N//R+1, -1, -1):
    Rr = R*r
    for g in range(N//G+1, -1, -1):
        Gg = G*g
        b = (N-Rr-Gg)/B
        if b >= 0 and b.is_integer():
            ans += 1

print(ans)

Fixed submission:
R, G, B, N = map(int, input().split())
r, g, b = 0, 0, 0
ans = 0
 
for r in range(N//R+1):
    Rr = R*r
    for g in range(N//G+1):
        Gg = G*g
        Bb = N-Rr-Gg

        if Bb < 0:
            break
        if Bb%B == 0:
            ans += 1
 
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
a, b, bxxa, ab = 0, 0, 0, 0

for i in range(N):
    s = input()
    if s[-1] == 'A':
        a += 1
    if s[0] == 'B':
        b +=1
    if s[0]=='B' and s[-1]=='A'
        bxxa += 1 
    ab += s.count('AB')

if a>b :
    print(ab+b)
elif a==b and bxxa==a:
    print(ab+a-1)
else: 
    print(ab+a)

Fixed submission:
N = int(input())
a, b, bxxa, ab = 0, 0, 0, 0

for i in range(N):
    s = input()
    if s[-1] == 'A':
        a += 1
    if s[0] == 'B':
        b += 1
    if s[0]=='B' and s[-1]=='A':
        bxxa += 1 
    ab += s.count('AB')

if a>b :
    print(ab+b)
elif a!=0 and a==b and bxxa==a:
    print(ab+a-1)
else: 
    print(ab+a)
Buggy python submission (verdict: Runtime Error):
from fractions import gcd
 
N = int(input())
A = list(map(int, input().split()))

max_gcd = 1

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

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

M = []

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

print(max(M))

Fixed submission:
import fractions
 
N = int(input())
A = list(map(int, input().split()))

max_gcd = 1

L, R, M = [0]*(N+1), [0]*(N+1), []

def gcd(a, b):
        if a == 0:
                return b
        elif b == 0:
                return a
        else:
                return fractions.gcd(a,b)

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

print(max(M))

Buggy python submission (verdict: Time Limit Exceeded):
import fractions
import functools

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

max_gcd = 1
for i in range(N):
        tmp_list =[]
        tmp_list.extend(A[:i])
        tmp_list.extend(A[i+1:])
        # print(tmp_list)
        tmp_gcd = functools.reduce(fractions.gcd, tmp_list)
        if max_gcd < tmp_gcd:
                max_gcd = tmp_gcd

print(max_gcd)

Fixed submission:
import fractions
 
N = int(input())
A = list(map(int, input().split()))

max_gcd = 1

L, R, M = [0]*(N+1), [0]*(N+1), []

def gcd(a, b):
        if a == 0:
                return b
        elif b == 0:
                return a
        else:
                return fractions.gcd(a,b)

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

print(max(M))

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

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

def gcd(numbers):
        return reduce(math.gcd, numbers)

max_gcd = 1
for i in range(N):
        tmp_list =[]
        tmp_list.extend(A[:i])
        tmp_list.extend(A[i+1:])
        tmp_gcd = gcd(tmp_list)
        if max_gcd < tmp_gcd:
                max_gcd = tmp_gcd

print(max_gcd)

Fixed submission:
import fractions
 
N = int(input())
A = list(map(int, input().split()))

max_gcd = 1

L, R, M = [0]*(N+1), [0]*(N+1), []

def gcd(a, b):
        if a == 0:
                return b
        elif b == 0:
                return a
        else:
                return fractions.gcd(a,b)

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

print(max(M))