Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p03266 (python)

Fixed submission:
n, k = map(int, input().split())
candidOdd = 0
candidEven = 0
candidEven2 = 0
for i in range(1, n+1):
    if k % 2 == 1:
        if i % k == 0:
            candidOdd += 1
    else:
        if i % k == 0:
            candidEven += 1
        elif i % k == (k/2):
            candidEven2 += 1
print(candidOdd**3 + candidEven**3 + candidEven2**3)

Buggy submission (verdict: Runtime Error):
n, k = map(int, input())
candidOdd = 0
candidEven = 0
candidEven2 = 0
for i in range(1, n+1):
    if k % 2 == 1:
        if i % k == 0:
            candidOdd += 1
    else:
        if i % k == 0:
            candidEven += 1
        elif i % k == (k/2):
            candidEven2 += 1
print(candidOdd**3 + candidEven**3 + candidEven2**3)
Problem p03309 (python)

Fixed submission:
from math import ceil
n = int(input())
arr = list(map(int, input().split()))
B = []
for i in range(n):
    B.append(arr[i] - (i+1))
B.sort()
b1 = B[n//2]
b2 = B[n//2]
if n > 1:
	b2 = B[int(ceil(n/2))]
ans1, ans2 = 0, 0
for i in range(n):
    ans1 += abs(arr[i]-(b1+i+1))
    ans2 += abs(arr[i]-(b2+i+1))
print (min(ans1, ans2))

Buggy submission (verdict: Runtime Error):
from math import ceil
n = int(input())
arr = list(map(int, input().split()))
B = []
for i in range(n):
    B.append(arr[i] - (i+1))
B.sort()
b1 = B[n//2]
b2 = B[int(ceil(n/2))]
ans1, ans2 = 0, 0
for i in range(n):
    ans1 += abs(arr[i]-(b1+i+1))
    ans2 += abs(arr[i]-(b2+i+1))
print (min(ans1, ans2))
Problem p03361 (python)

Fixed submission:
import sys
sys.setrecursionlimit(3000)
h, w = map(int, raw_input().split())
s = [[c for c in raw_input()] for i in range(h)]
def isValid(i, j):
    if i < 0 or i >= h or j < 0 or j >= w:
        return False
    return True
    
def dfs(s, i, j):
    if not isValid(i, j) or s[i][j] == "0" or s[i][j] == ".":
        return 0
    if s[i][j] == "#":
        s[i][j] = "0"
        a = dfs(s, i+1, j)
        b = dfs(s, i-1, j)
        c = dfs(s, i, j+1)
        d = dfs(s, i, j-1)
        return 1 + a + b + c + d

for i in range(h):
    for j in range(w):
        if s[i][j] == "#":
            ccs = dfs(s, i, j)
            #print ccs
            if ccs == 1:
                print "No"
                exit()
print "Yes"

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(2000)
h, w = map(int, raw_input().split())
s = [[c for c in raw_input()] for i in range(h)]
def isValid(i, j):
    if i < 0 or i >= h or j < 0 or j >= w:
        return False
    return True
    
def dfs(s, i, j):
    if not isValid(i, j) or s[i][j] == "0" or s[i][j] == ".":
        return 0
    if s[i][j] == "#":
        s[i][j] = "0"
        a = dfs(s, i+1, j)
        b = dfs(s, i-1, j)
        c = dfs(s, i, j+1)
        d = dfs(s, i, j-1)
        return 1 + a + b + c + d

for i in range(h):
    for j in range(w):
        if s[i][j] == "#":
            ccs = dfs(s, i, j)
            #print ccs
            if ccs == 1:
                print "No"
                exit()
print "Yes"

Buggy submission (verdict: Runtime Error):
h, w = map(int, raw_input().split())
s = [[c for c in raw_input()] for i in range(h)]
def isValid(i, j):
    if i < 0 or i >= h or j < 0 or j >= w:
        return False
    return True
    
def dfs(s, i, j):
    if not isValid(i, j) or s[i][j] == "0" or s[i][j] == ".":
        return 0
    if s[i][j] == "#":
        s[i][j] = "0"
        a = dfs(s, i+1, j)
        b = dfs(s, i-1, j)
        c = dfs(s, i, j+1)
        d = dfs(s, i, j-1)
        return 1 + a + b + c + d

for i in range(h):
    for j in range(w):
        if s[i][j] == "#":
            ccs = dfs(s, i, j)
            #print ccs
            if ccs == 1:
                print "No"
                exit()
print "Yes"
Problem p03480 (python)

Fixed submission:
s = raw_input()
length = len(s)
if length == 1:
    print 1
    exit()
T = []
for i in range(length-1):
    if s[i] != s[i+1]:
    	T.append(max(i+1, length-(i+1)))
if len(T) == 0:
    print length
else:
    print min(T)

Buggy submission (verdict: Runtime Error):
s = raw_input()
length = len(s)

T = []
for i in range(length-1):
    if s[i] != s[i+1]:
    	T.append(max(i+1, length-(i+1)))
print min(T)

Buggy submission (verdict: Runtime Error):
s = raw_input()
length = len(s)

T = []
for i in range(length-1):
    if s[i] != s[i+1]:
    	T.append(max(i+1, length-(i+1)))
print min(T)
Problem p03503 (python)

Fixed submission:
n = int(input())

F = []
P = []
for i in range(n):
    F.append(list(map(int, input().split())))
for i in range(n):
    P.append(list(map(int, input().split())))
ans = -10**9
for i in range(1, 1 << (10)):
    C = [0]*n
    for j in range(10):
        if i & 2**j:
            for k in range(n):
                if F[k][j]:
                    C[k] += 1
    current = 0
    for k in range(n):
        current += P[k][C[k]]
    ans = max(current, ans)
print (ans)

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

F = []
P = []
for i in range(n):
    F.append(list(map(int, input().split())))
for i in range(n):
    P.append(list(map(int, input().split())))
ans = -10**9
for i in range(1, 1 << (10)):
    C = [0]*11
    for j in range(10):
        if i & 2**j:
            for k in range(n):
                if F[k][j]:
                    C[k] += 1
    current = 0
    for k in range(n):
        current += P[k][C[k]]
    ans = max(current, ans)
print (ans)
Problem p03612 (python)

Fixed submission:
n = int(input())
arr = list(map(int, input().split()))
ans = 0
for i in range(n-1):
    if arr[i] == i + 1:
        ans += 1
        arr[i+1], arr[i] = arr[i], arr[i+1]
if arr[n-1] == n:
    ans += 1
print (ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
arr = list(map(int, input().split()))
ans = 0
for i in range(n):
    if arr[i] == i + 1:
        ans += 1
        arr[i+1], arr[i] = arr[i], arr[i+1]
if arr[n-1] == n:
    ans += 1
print (ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
arr = list(map(int, input().split()))
ans = 0
for i in range(n):
    if arr[i] == i + 1:
        ans += 1
        arr[i+1], arr[i] = arr[i], arr[i+1]
print (ans)
Problem p03645 (python)

Fixed submission:
from queue import Queue
n, m = map(int, input().split())
adj = [[] for i in range(n+1)]
for i in range(m):
    a, b = map(int, input().split())
    adj[a].append(b)
    adj[b].append(a)
def bfs():
    queue = Queue()
    queue.put(1)
    distance = [10**6]*(n+1)
    distance[1] = 0
    while not queue.empty():
        u = queue.get()
        if u == n and distance[u] == 2:
            print ("POSSIBLE")
            return
        for a in adj[u]:
            if distance[u] + 1 <= 2 and distance[a] > distance[u] + 1:
                distance[a] = distance[u] + 1
                queue.put(a)
    print ("IMPOSSIBLE")
    return
bfs()

Buggy submission (verdict: Runtime Error):
4 3
1 4
4 5
2 3
Problem p02947 (python)

Fixed submission:
import collections
import math


n = int(input())

inputlist = []

for i in range(n):
    inputlist.append("".join(sorted(list(input()))))

counter = collections.Counter(inputlist)

counter = dict(counter)
valuelist = list(map(int, counter.values()))

ans = 0

for i in valuelist:
    if i == 1:
        continue
    if i == 2:
        ans += 1
        continue
    temp = math.factorial(i)
    temp /= math.factorial(i-2)
    temp = int(temp / 2)
    ans += temp

print(ans)

Buggy submission (verdict: Runtime Error):
import collections
import math


n = int(input())

inputlist = []

for i in range(n):
    inputlist.append("".join(sorted(list(input()))))

counter = collections.Counter(inputlist)

counter = dict(counter)
valuelist = list(map(int, counter.values()))

ans = 0

for i in valuelist:
    if i == 1:
        continue
    if i == 2:
        ans += 1
        continue
    ans += math.factorial(i) / 2 / math.factorial(i-2)

print(int(ans))

Buggy submission (verdict: Runtime Error):
import collections
import numpy as np


def fav(n):
    fav = np.zeros(n+1, dtype=int)

    fav[0] = 1
    for i in range(1, n+1):
        fav[i] = fav[i-1] * i

    return fav


def comb(a, b, fav):
    if a == 0 and b == 0:
        return 1
    if a < 0 or a < b or b < 0:
        return 0

    return int(fav[a] / fav[b] / fav[a-b])


n = int(input())

inputlist = []

for i in range(n):
    inputlist.append("".join(sorted(list(input()))))

counter = collections.Counter(inputlist)

counter = dict(counter)
valuelist = list(map(int, counter.values()))

fav = fav(max(valuelist)+1)

ans = 0

for i in valuelist:
    if i == 1:
        continue
    if i == 2:
        ans += 1
        continue
    ans += comb(i, 2, fav)

print(ans)

Buggy submission (verdict: Runtime Error):
import math
import collections


n = int(input())

inputlist = []

for i in range(n):
    inputlist.append("".join(sorted(list(input()))))

counter = collections.Counter(inputlist)

counter = dict(counter)

valuelist = list(map(int, counter.values()))

ans = 0

for i in valuelist:
    if i == 1:
        continue
    if i == 2:
        ans += 1
        continue
    if i == 3:
        ans += 3
        continue

    ans += math.factorial(i) / math.factorial(2) / math.factorial(i - 2)

print(ans)
Problem p02995 (python)

Fixed submission:
def gcd(x, y):
    if x < y:
        tmp = y
        y = x
        x = tmp
    while y != 0:
        x = x % y
        temp = y
        y = x
        x = temp
    return int(x)

def lcm(x, y):
    return int(x * y / gcd(x, y))

a, b, c, d = map(int, input().split())

x = lcm(c, d)

A = a-1 - (a - 1) // c - (a - 1) // d + (a - 1) // x
B = b - b // c - b // d + b // x

print(int(B - A))

Buggy submission (verdict: Runtime Error):
import math

def lcm(x, y):
    return x * y / math.gcd(x, y)

a, b, c, d = map(int, input().split())

x = int(lcm(c, d))

A = a-1 - (a - 1) // c - (a - 1) // d + (a - 1) // x
B = b - b // c - b // d + b // x

print(int(B - A))
Problem p03007 (python)

Fixed submission:
import numpy as np

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

A = np.array(A)

A = np.sort(A)

B = np.copy(A)
if n == 2:
    print(A[1] - A[0])
    print(A[1], A[0])

elif A[0] <= 0 and A[n-1] >= 0:
    for i in range(n-1):
        A[i] = min(A[i], -A[i])

    print(np.sum(A[:-1]) * -1 + A[n-1])

    k = n - 2
    a = B[0]
    while B[k] >= 0:
        print(a, B[k])
        a = a - B[k]
        k -= 1
        if k == 0:
            break

    b = B[n-1]

    while k != 0:
        print(b, B[k])
        b = b - B[k]
        k -= 1

    print(b, a)

elif A[n-1] < 0:
    A[n-1] = A[n-1] - A[n-2]
    A[n-2] = 0
    for i in range(n-1):
        A[i] = min(A[i], -A[i])

    print(np.sum(A[:-1]) * -1 + A[n-1])

    a = B[n-1]
    for i in range(n-1):
        print(a, B[i])
        a = a - B[i]

else:
    A[0] = A[0] - A[1]
    A[1] = 0
    for i in range(n-1):
        A[i] = min(A[i], -A[i])

    print(np.sum(A[:-1]) * -1 + A[n-1])

    k = n - 2
    a = B[0]
    while B[k] >= 0:
        print(a, B[k])
        a = a - B[k]
        k -= 1
        if k == 0:
            break

    b = B[n-1]

    while k != 0:
        print(b, B[k])
        b = b - B[k]
        k -= 1

    print(b, a)

Buggy submission (verdict: Runtime Error):
import numpy as np

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

A = np.array(A)

A = np.sort(A)

B = np.copy(A)

if A[0] <= 0 and A[n-1] >= 0:
    for i in range(n-1):
        A[i] = min(A[i], -A[i])

    print(np.sum(A[:-1]) * -1 + A[n-1])

    k = n - 2
    a = B[0]
    while B[k] >= 0:
        print(a, B[k])
        a = a - B[k]
        k -= 1
        if k == 0:
            break

    b = B[n-1]

    while k != 0:
        print(b, B[k])
        b = b - B[k]
        k -= 1

    print(b, a)

elif A[n-1] < 0:
    A[n-1] = A[n-1] - A[n-2]
    A[n-2] = 0
    for i in range(n-1):
        A[i] = min(A[i], -A[i])

    print(np.sum(A[:-1]) * -1 + A[n-1])

    a = B[n-1]
    for i in range(n-1):
        print(a, B[i])
        a = a - B[i]

else:
    A[0] = A[0] - A[1]
    A[1] = 0
    for i in range(n-1):
        A[i] = min(A[i], -A[i])

    print(np.sum(A[:-1]) * -1 + A[n-1])

    k = n - 2
    a = B[0]
    while B[k] >= 0:
        print(a, B[k])
        a = a - B[k]
        k -= 1
        if k == 0:
            break

    b = B[n-1]

    while k != 0:
        print(b, B[k])
        b = b - B[k]
        k -= 1

    print(b, a)
Problem p03000 (python)

Fixed submission:
n,x=map(int,input().split())
L=list(map(int,input().split()))
c=0
s=0
while(s<=x):
    if c == n:
        c+=1
        break
    s+=L[c]
    c+=1

print(c)

Buggy submission (verdict: Runtime Error):
n,x=map(int,input().split())
L=list(map(int,input().split()))
c=0
s=0
while(s<=x):
    s+=L[c]
    c+=1
print(c)
Problem p03001 (python)

Fixed submission:
w,h,x,y=map(int,input().split())
flg=0
if w/2==x and h/2==y: flg=1
print(str(w*h/2)+" "+str(flg))

Buggy submission (verdict: Runtime Error):
w,h,x,y=map(int,input().split())
flg=0
if w//2==x: flg+=1
if h//2==y: flg+=1
if h/w==y/x: flg+=1
if w*(y-h)==-h*x: flg+=1
print(str(w*h/2)+" "+str(1-flg%2))
Problem p02640 (python)

Fixed submission:
import sys
x,y = input().split()
x=int(x)
y=int(y)
for c in range(0, x+1):
    t = x - c
    if 2*c+4*t==y:
        print("Yes")
        sys.exit()
print("No")

Buggy submission (verdict: Runtime Error):
x,y = input().split()
x=int(x)
y=int(y)
for c in range(1, x):
    t = x - c
    if 2*c+4*t==y:
        print("Yes")
        sys.exit()
print("No")
Problem p02714 (python)

Fixed submission:
N=int(input())
S=input()
r = len(S.replace("G", "").replace("B", ""))
g = len(S.replace("R", "").replace("B", ""))
b = N - r - g

ans = r * g
ans = ans * b

for i in range( N ):
    for j in range(i, int((N+i)/2 + 1)):
        k = 2 * j - i
        if k < N:
            s = S[i] + S[j] + S[k]
            if ("R" in s) & ("G" in s) & ("B" in s):
                ans -= 1

print(ans)

Buggy submission (verdict: Runtime Error):
N=int(input())
S=input()
r = len(S.replace("G", "").replace("B", ""))
g = len(S.replace("R", "").replace("B", ""))
b = N - r - g

ans = r * g
ans = ans * b

for i in range( N ):
    for j in range(i, int((N+i)/2 + 1)):
        k = 2 * j - i
            if k < N:
                s = S[i] + S[j] + S[k]
                if ("R" in s) & ("G" in s) & ("B" in s):
                    ans -= 1

print(ans)
Problem p02775 (python)

Fixed submission:
S=input()[::-1]
ans=0
#支払う枚数
array = list(map(int, S))
L=len(array)
for i,n in enumerate(array):
    if n< 5 :
        ans+=n
    elif n > 5:
        ans+= 10-n
        if i <L-1:
            array[i+1] +=1
        else:
            ans +=1
    else:
        ans+=5
        if i < L-1:
            if array[i+1] >=5:
                array[i+1] +=1
                
print( ans)

Buggy submission (verdict: Runtime Error):
S=input()[::-1]
ans=0
#支払う枚数
array = list(map(int, S))
L=len(array)
for i,n in enumerate(array):
    if n<= 5 :
        ans+=n
    elif n > 5:
        ans+= 10-n
        if i <L-1:
            array[i+1] +=1
        else:
            ans +=1
    else:
        ans+=5
        if < L-1:
            if array[i+1] >=5:
                array[i+1] +=1
                
print( ans)

Buggy submission (verdict: Runtime Error):
S=input()
paynum=0
payout=0
change=0
changenum=0
num=0
#支払う枚数
array = list(map(int, S))
array.reverse()
print(array)
for i in array:  
    if i <= 5 :
        paynum = paynum + i
        payout = payout + i *( 10 ** num)
    else:
        if num+1 <len(S):
            array[num+1] = array[num+1]+1
        else:
            paynum = paynum + 1
            payout = payout + 1*(10**(num+1))
    num= num+1

#お釣り
change = payout - N
tmp= str(change)
array2 = list(map(int, tmp))
changenum= sum(array2)
print( changenum + paynum)
Problem p02730 (python)

Fixed submission:

s  = input()
a = s[:int(len(s)/2)]
b = s[:-int(len(s)/2 + 1)]
flag = 0
if s == s[::-1]:
    if a == a[::-1]:
        if b == b[::-1]:
            flag = 1

if flag:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
s  = input()
a = s[:len(s)/2 -1]
b = s[len(s)+3/2-1:]
flag = 0
if s == s[::-1]:
    if a == a[::-1]:
        if b == b[::-1]:
            flag = 1

if flag:
    print('Yes')
else:
    print('No')
Problem p02963 (python)

Fixed submission:
import math
S = int(input())

if int(math.sqrt(S))**2 == S:
    a = d = int(math.sqrt(S))
else:
    a = d = int(math.sqrt(S)) + 1

bc = a*d - S

if bc == 0:
    b = c = 0
else:
    for i in range(int(math.sqrt(bc)),0,-1):
        if bc % i == 0:
            b = i
            c = bc//i
            break

print(0,0,a,b,c,d)

Buggy submission (verdict: Runtime Error):
import math
S = int(input())

if int(math.sqrt(S))**2 == S:
    a = d = int(math.sqrt(S))
else:    
    a = d = int(math.sqrt(S)) + 1

bc = a*d - S

for i in range(int(math.sqrt(bc)),0,-1):
    if bc % i == 0:
        b = i
        c = bc//i
        break

print(0,0,a,b,c,d)
Problem p02972 (python)

Fixed submission:
N = int(input())
a = list(map(int,input().split()))

b = [0 for i in range(N)]

def check(i):
    cnt = 0
    n = i
    while n <= N:
        cnt += b[n-1]
        n += i
    return cnt

for i in range(N-1,-1,-1):
    if (a[i] + check(i+1))%2 == 1:
        b[i] = 1

ans = []
cnt = 0
for i in range(N):
    if b[i] == 1:
        cnt += 1
        ans.append(i+1)

print(cnt)
L = [str(int(i)) for i in ans]
print(' '.join(L))

Buggy submission (verdict: Runtime Error):
import bisect
N = int(input())

c = []
for i in range(N):
    n = int(input())
    index = bisect.bisect_left(c,n)
    if index == 0:
        c.append(n)
    else:
        c[index-1] = n
    c.sort()
    #print(c)

print(len(c))
Problem p03000 (python)

Fixed submission:
N,X = map(int,input().split())
L = list(map(int,input().split()))

cnt = 0
D = 0
while D <= X and cnt < len(L):
    D += L[cnt]
    cnt += 1

if D <= X:
    cnt += 1

print(cnt)

Buggy submission (verdict: Runtime Error):
N,X = map(int,input().split())
L = list(map(int,input().split()))

cnt = 0
D = 0
while D <= X:
    D += L[cnt]
    cnt += 1

print(cnt)
Problem p03005 (python)

Fixed submission:
N,K = map(int,input().split())
if K == 1:
    print(0)
else:
    print(N-K)

Buggy submission (verdict: Runtime Error):
N = int(input())

if N == 1:
    print(1)
else:
    point = []
    for i in range(N):
        x,y = map(int,input().split())
        point.append([x,y])

    vec = []
    for i in range(N):
        for j in range(i+1,N,1):
            vec.append([point[i][0]-point[j][0],point[i][1]-point[j][1]])

    N2 = len(vec)
    check = [0 for i in range(N2)]

    for i in range(N2):
        for j in range(N2):
            minus = [-vec[j][0],-vec[j][1]]
            if vec[i] == vec[j] or vec[i] == minus:
                check[i] += 1

    print(N-max(check))
Problem p03006 (python)

Fixed submission:
N = int(input())

if N == 1:
    print(1)
else:
    point = []
    for i in range(N):
        x,y = map(int,input().split())
        point.append([x,y])

    vec = []
    for i in range(N):
        for j in range(i+1,N,1):
            vec.append([point[i][0]-point[j][0],point[i][1]-point[j][1]])

    N2 = len(vec)
    check = [0 for i in range(N2)]

    for i in range(N2):
        for j in range(N2):
            minus = [-vec[j][0],-vec[j][1]]
            if vec[i] == vec[j] or vec[i] == minus:
                check[i] += 1

    print(N-max(check))

Buggy submission (verdict: Runtime Error):
N = int(input())

point = []
for i in range(N):
    x,y = map(int,input().split())
    point.append([x,y])

vec = []
for i in range(N):
    for j in range(i+1,N,1):
        vec.append([point[i][0]-point[j][0],point[i][1]-point[j][1]])

N2 = len(vec)
check = [0 for i in range(N2)]

for i in range(N2):
    for j in range(N2):
        minus = [-vec[j][0],-vec[j][1]]
        if vec[i] == vec[j] or vec[i] == minus:
            check[i] += 1
            
if N == 10:
    print(1)
else:
    print(N-max(check))
Problem p03032 (python)

Fixed submission:
N,K = map(int,input().split())
V = list(map(int,input().split()))

value = max_value = 0
for j in range(K//2+1):
    for i in range(K-j+1):
        if K-j >= N:
            value = V
        else:
            if i == K-j:
                value = V[:K-j]
            else:
                value = V[:i]+V[-(K-j-i):]
        value.sort()
        # print(i,j,value)


        jj = min(len(value)-1,j)
        if value[jj] <= 0:
            s = sum(value[jj:])
        else:
            s = sum([i for i in value if i>0])

        if  s > max_value:
            max_value = s
print(max_value)

Buggy submission (verdict: Runtime Error):
N,K = map(int,input().split())
V = list(map(int,input().split()))

value = max_value = 0
for j in range(K//2):
    for i in range(K-j+1):
        if i == K-j:
            value = V[:K-j]
        else:
            value = V[:i]+V[-(K-j-i):]
        value.sort()
        
        if value[j] > 0:
            s = sum([i for i in value if i>0])
        else:
            s = sum(value[j:])
                
        if  s > max_value:
            max_value = s

print(max_value)
Problem p03047 (python)

Fixed submission:
N,K = map(int,input().split())
print(N-K+1)

Buggy submission (verdict: Runtime Error):
import math
N = int(input())
cnt = 0
for i in range(1,int(math.sqrt(N))+1):
	if N % i == 0:		
		if N / i == i:
			cnt += i-1
		else:
			cnt += N/i-1
print(int(cnt))
Problem p03059 (python)

Fixed submission:
A,B,T = map(int,input().split())
print(int(((T+0.5)//A)*B))

Buggy submission (verdict: Runtime Error):
import fractions
N = int(input())
l = list(map(int,input().split()))

if len(l) == 2:
    memo = max(l)
else:
    memo = 1
    for i in range(N):
        g = fractions.gcd(*(l[:i]+l[i+1:]))
        if g > memo:
            memo = g

print(memo)
Problem p03061 (python)

Fixed submission:
import fractions

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

L = [0]
R = [0]

gl = 0
gr = 0
for i in range(N):
    gl = fractions.gcd(gl,l[i])
    L.append(gl)
    gr = fractions.gcd(gr,l[N-1-i])
    R.append(gr)

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

print(max(M))

Buggy submission (verdict: Runtime Error):
import fractions

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

L = [0]
R = [0]

gl = 0
gr = 0
for i in range(N):
    gl = fractions.gcd(gl,l[i])
    L.appenzad(gl)
    gr = fractions.gcd(gr,l[N-1-i])
    R.append(gr)

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

print(max(M))

Buggy submission (verdict: Runtime Error):
import fractions

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

L = [0]
R = [0]

gl = 0
gr = 0
for i in range(N):
    gl = fractions.gcd(gl,l[i])
    L.appenzad(gl)
    gr = fractions.gcd(gr,l[N-1-i])
    R.append(gr)

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

print(max(M))

Buggy submission (verdict: Runtime Error):
import fractions
N = int(input())
l = list(map(int,input().split()))

if len(l) == 2:
    memo = max(l)
else:
    memo = 1
    for i in range(N):
        g = fractions.gcd(*(l[:i]+l[i+1:]))
        if g > memo:
            memo = g

print(memo)

Buggy submission (verdict: Runtime Error):
import fractions
import sys

sys.setrecursionlimit(1000000)

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

g_list = []

if len(l) == 2:
  g_list.append(max(l[0],l[1]))
  
else:
    g = fractions.gcd(l[1],l[2])
    for j in range(3,N):
        if j != i:
            g = fractions.gcd(g,l[j])
    g_list.append(g)

    g = fractions.gcd(l[0],l[2])
    for j in range(3,N):
        if j != i:
            g = fractions.gcd(g,l[j])
    g_list.append(g)

    for i in range(N):
        g = fractions.gcd(l[0],l[1])
        for j in range(N):
            if j != i:
                g = fractions.gcd(g,l[j])
        g_list.append(g)

print(max(g_list))

Buggy submission (verdict: Runtime Error):
import fractions
N = int(input())
l = list(map(int,input().split()))

g_list = []

if len(l) == 2:
  g_list.append(max(l[0],l[1]))
  
else:
    g = fractions.gcd(l[1],l[2])
    for j in range(3,N):
        if j != i:
            g = fractions.gcd(g,l[j])
    g_list.append(g)

    g = fractions.gcd(l[0],l[2])
    for j in range(3,N):
        if j != i:
            g = fractions.gcd(g,l[j])
    g_list.append(g)

    for i in range(N):
        g = fractions.gcd(l[0],l[1])
        for j in range(N):
            if j != i:
                g = fractions.gcd(g,l[j])
        g_list.append(g)

print(max(g_list))