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

Fixed submission:
import fractions
A, B, C, D = map(int, input().split())

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

C_comp = (B//C) - ((A-1)//C)
D_comp = (B//D) - ((A-1)//D)
CD_comp = (B//lcm(C,D)) - ((A-1)//lcm(C,D))

print((B - A + 1) - (C_comp + D_comp - CD_comp))

Buggy submission (verdict: Runtime Error):
import math
A, B, C, D = map(int, input().split())

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

C_comp = int((B-(B%C))/C) - int(((A-1)-(A-1)%C)/C)
D_comp = int((B-(B%D))/D) - int(((A-1)-(A-1)%D)/D)
CD_comp = int((B-(B%lcm(C,D)))/lcm(C,D)) - int(((A-1)-(A-1)%lcm(C,D))/lcm(C,D))

print((B - A + 1) - (C_comp + D_comp - CD_comp))

Buggy submission (verdict: Runtime Error):
import math
A, B, C, D = map(int, input().split())

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

C_comp = (B//C) - ((A-1)//C)
D_comp = (B//D) - ((A-1)//D)
CD_comp = (B//lcm(C,D)) - ((A-1)//lcm(C,D))

print((B - A + 1) - (C_comp + D_comp - CD_comp))

Buggy submission (verdict: Runtime Error):
import math
A, B, C, D = map(int, input().split())

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

C_comp = B//C - (A-1)//C
D_comp = B//D - (A-1)//D
CD_comp = B//lcm(C,D) - (A-1)//lcm(C,D)

print((B - A + 1) - (C_comp + D_comp - CD_comp))

Buggy submission (verdict: Runtime Error):
import math
A, B, C, D = map(int, input().split())

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

C_comp = B // C - (A-1) // C
D_comp = B // D - (A-1) // D
CD_comp = B // lcm(C,D) - (A-1) // lcm(C,D)

print((B - A + 1) - (C_comp + D_comp - CD_comp))
Problem p03006 (python)

Fixed submission:
import collections

N = int(input())
co = [list(map(int, input().split())) for i in range(N)]

if N > 1:
    tmp = []
    for i in range(N):
        for j in range(N):
            tmp.append((co[i][0]-co[j][0],co[i][1]-co[j][1]))
    c = collections.Counter(tmp)
    print(N - c.most_common()[1][1])
else:
    print("1")

Buggy submission (verdict: Runtime Error):
import collections

N = int(input())
co = [list(map(int, input().split())) for i in range(N)]

tmp = []
for i in range(N):
    for j in range(N):
        tmp.append((co[i][0]-co[j][0],co[i][1]-co[j][1]))
c = collections.Counter(tmp)
print(N - c.most_common()[1][1])
Problem p03007 (python)

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

A.sort()

nminus = len([i for i in A if i < 0])
nplus = N - nminus



if nminus == N:
    M = 2*A[N-1] - np.sum(A)
    print(M)

    caled = A[N-1]
    for i in range(nminus-1):
        print(caled,A[i])
        caled -= A[i]
elif nplus == N:
    M = np.sum(A) - 2*A[0]
    print(M)

    caled = A[0]
    for i in range(N-2):
        print(caled, A[i+1])
        caled -= A[i+1]
    print(A[N-1],caled)
else:
    M = 0
    for i in range(N-1):
        M += abs(A[i])
    M += A[N-1]
    print(M)

    caled = A[0]
    for i in range(nplus-1):
        print(caled,A[nminus+i])
        caled -= A[nminus+i]
    caled_2 = A[N-1]
    for i in range(nminus-1):
        print(caled_2,A[i+1])
        caled_2 -= A[i+1]
    print(caled_2,caled)

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

A.sort()
M = 0
for i in range(N-1):
    M += abs(A[i])
M += A[N-1]
print(M)

nminus = len([i for i in A if i < 0])
nplus = N - nminus

if nplus == 0:
    caled = A[N]
    for i in range(N-1):
        print(caled,A[i])
        caled -= A[i]
elif nminus == 0:
    caled = A[0]
    for i in range(N-2):
        print(caled, A[i+1])
        caled -= A[i+1]
    print(A[N-1],caled)
else:
    caled = A[0]
    for i in range(nplus-1):
        print(caled,A[nminus+i])
        caled -= A[nminus+i]
    caled_2 = A[N-1]
    for i in range(nminus-1):
        print(caled_2,A[i+1])
    print(caled_2,caled)
Problem p03192 (python)

Fixed submission:
N = input()
ans = 0
for i in range(4):
	if N[i] == '2':
		ans += 1
print(ans)

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

i = 1
ans = 1
if N > 1:
	while P >= i**N:
		if P % i**N == 0:
			ans = i
		i += 1
else:
	ans = P
print(ans)
Problem p03260 (python)

Fixed submission:
A,B = map(int, input().split())
if A == 2 or B == 2:
    print("No")
else:
    print("Yes")

Buggy submission (verdict: Runtime Error):
A,B = map(int, input(),split())
if A!=2 and B!=2:
  print('Yes')
else:
  print('No')
Problem p03262 (python)

Fixed submission:
import math
from functools import reduce
import fractions

N,X = map(int, input().split())
x = list(map(int, input().split()))

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

for i in range(len(x)):
    x[i] = abs(x[i]-X)

print(gcd_list(x))

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

N,X = map(int, input().split())
x = list(map(int, input().split()))

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

for i in range(len(x)):
    x[i] = abs(x[i]-X)

print(gcd_list(x))
Problem p03282 (python)

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

a = 1
for i in range(K):
	if int(S[i]) != 1:
		print(int(S[i]))
		a = 0
		break
if a == 1:
	print(a)

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

i = 0
counter = 0
while counter < K:
	counter += int(S[i])**5e15
	i += 1
print(S[i])
Problem p03284 (python)

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

Buggy submission (verdict: Runtime Error):
N,K = map(str, input().split())
if N % K != 0:
  print(1)
else:
  print(0)

Buggy submission (verdict: Runtime Error):
N,K = list(map(str, input().split()))
if N % K != 0:
  print(1)
else:
  print(0)
Problem p03377 (python)

Fixed submission:
A, B, X = map(int, input().split())
if A+B >= X and X >= A:
	print('YES')
else:
	print('NO')

Buggy submission (verdict: Runtime Error):
A, B, C = map(int, input().split())
if X - A <= C:
	print('YES')
else:
	print('NO')
Problem p03385 (python)

Fixed submission:
S = input()
if S == 'abc' or S == 'acb' or S == 'bac' or S =='bca' or S == 'cab' or S == 'cba':
	print('Yes')
else:
	print('No')

Buggy submission (verdict: Runtime Error):
S = input()
if S == abc or S == acb or S == bac or S ==bca or S == cab or S == cba:
	print('Yes')
else:
	print('No')
Problem p03407 (python)

Fixed submission:
a, b, c = map(int,input().split())
if a + b >= c:
	print('Yes')
else:
	print('No')

Buggy submission (verdict: Runtime Error):
a, b, c = int(split.input())
if a == c or b == c or a + b == c:
	print('Yes')
else:
	print('No')

Buggy submission (verdict: Runtime Error):
a = input()
b = input()
c = input()

print(a[0] + b[1] + c[2])
Problem p03433 (python)

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

if N % 500 <= A:
	print('Yes')
else:
	print('No')

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

if N % 500 < A:
	print('Yes')
else:
	print('No')
Problem p03447 (python)

Fixed submission:
x = int(input())
A = int(input())
B = int(input())

print((x - A) % B)

Buggy submission (verdict: Runtime Error):
x = int(input())
A = int(input())
B = int(input()9

print((x - A) % B)

Buggy submission (verdict: Runtime Error):
x = input()
A = input()
B = input()

print((x - A) % B)
Problem p03469 (python)

Fixed submission:
S  = list(input())
S[3] = '8'
s = "".join(S)
print(s)

Buggy submission (verdict: Runtime Error):
S  = input()
S[3] = '8'
print(S)
Problem p03485 (python)

Fixed submission:
import math
n = list(map(int, input().split()))
print(math.ceil((n[0] + n[1])/2))

Buggy submission (verdict: Runtime Error):
n = list(map(int, input().split()))
print(math.ceil((n[0] + n[1])/2))
Problem p03489 (python)

Fixed submission:
N = int(input())
a = list(map(int, input().strip().split()))
a.sort()
i = 0
j = 1
ans = 0

for i in range(N-1):
	if a[i] == a[i+1]:
		j += 1
	else:
		if j >= a[i]:
			ans += j - a[i]
		else:
			ans += j
		j = 1
if a[N-1] != a[N-2]:
	if a[N-1] != 1:
		ans += 1
else:
	if j >= a[i]:
		ans += j - a[i]
	else:
		ans += j
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
a = list(map(int, input().strip().split()))
a.sort()

i = 0
j = 1
ans = 0

for i in range(N-1):
	if a[i] == a[i+1]:
		j += 1
	else:
		if j >= a[i]:
			ans += j - a[i]
		else:
			ans += j
if a[N-1] != A[N-2]:
	if a[N-1] != 1:
		ans += 1
else:
	if j >= a[i]:
		ans += j - a[i]
	else:
		ans += j
Problem p03493 (python)

Fixed submission:
A = input()
print(int(A[0])+int(A[1])+int(A[2]))

Buggy submission (verdict: Runtime Error):
A = input()
print(int(A[0])+int(A[1]+int(A[2]))
Problem p03555 (python)

Fixed submission:
A = input()
G = input()
 
if A[0]+A[1]+A[2] ==G[2]+G[1]+G[0]:
	print('YES')
else:
	print('NO')

Buggy submission (verdict: Runtime Error):
A = int(input())
G = int(input())
 
if A[0]+A[1]+A[2] ==G[2]+G[1]+G[0]:
	print('YES')
else:
	print('NO')
Problem p03573 (python)

Fixed submission:
a,b,c = map(int, input().split())

if a==b:
	print(c)
elif a==c:
	print(b)
else:
	print(a)

Buggy submission (verdict: Runtime Error):
a,b,c = map(int, input().split())
 
if a==b:
	print(c)
if a==c:
	print(b)
else:
	print(a)
a,b,c = map(int, input().split())

if a==b:
	print(c)
elif a==c:
	print(b)
else:
	print(a)

Buggy submission (verdict: Runtime Error):
a,b,c = map(int, input().split())

if a=b:
	print(c)
if a=c:
	print(b)
else:
	print(a)
Problem p03633 (python)

Fixed submission:
def gcd(x, y):
	if x < y:
		x, y = y, x
	if y == 0:
		return x
	z = x % y
	return gcd(y, z) 
	
N=int(input())
prenum = 1
for i in range(N):
	T = int(input())
	lcm = prenum // gcd(prenum, T) * T
	prenum = lcm
print(lcm)

Buggy submission (verdict: Runtime Error):
def gcd(x, y):
	if x < y:
		x, y = y, x
	if y == 0:
		return x
	z = x % y
	return gcd(y, z) 
	
N=int(input())
prenum = 1
for i in range(N):
	T = int(input())
	lcm = prenum / gcd(prenum, T) * T
	prenum = lcm
print(str(lcm))

Buggy submission (verdict: Runtime Error):
def gcd(x, y):
	if x < y:
		x, y = y, x
	if y == 0:
		return x
	z = x % y
	return gcd(y, z) 
	
N=int(input())
prenum = 1
for i in range(N):
	T = int(input())
	lcm = (prenum / gcd(prenum, T)) * T
	prenum = lcm
print(int(lcm))

Buggy submission (verdict: Runtime Error):
def gcd(x, y):
	if x < y:
		x, y = y, x
	if y == 0:
		return x
	z = x % y
	return gcd(y, z) 
	
N=int(input())
prenum = 1
for i in range(N):
	T = int(input())
	lcm = (prenum / gcd(T, prenum)) * T
	prenum = lcm
print(int(lcm))

Buggy submission (verdict: Runtime Error):
def gcd(x, y):
	if x < y:
		x, y = y, x
	if y == 0:
		return x
	z = x % y
	return gcd(y, z) 		
N=int(input())
prenum = 1
for i in range(N):
	T = int(input())
	lcm = (prenum*T) / gcd(T, prenum)
	prenum = lcm
print(int(lcm))
Problem p03657 (python)

Fixed submission:
num = list(map(int, input().split()))
a = num[0]
b = num[1]

if a%3 == 0 or b%3 == 0 or (a+b) %3 ==0 :
	print('Possible')
else:
	print('Impossible')

Buggy submission (verdict: Runtime Error):
num = list(map(int, input().split()))
a = num[0]
b = num[1]
c = num[2]

if a%3 == 0 or b%3 == 0 or (a+b) %3 ==0 :
	print('Possible')
else:
	print('Impossible')
Problem p03719 (python)

Fixed submission:
num = list(map(int, input().split()))
if num[2] >= num[0] and num[2] <= num[1]:
	print('Yes')
else:
	print('No')

Buggy submission (verdict: Runtime Error):
N, K = list(map(int, input().strip().split()))
grid = []
k = 0
j = 0
for i in range(N):
	array = list(map(int, input().strip().split()))
	grid.append(array)
for i in range(N):
	if k < K:
		k += grid[i-1][1]
		j += 1
print(str(grid[j][0])[K-k])
Problem p03721 (python)

Fixed submission:
import numpy as np
N,K = map(int, input().split())
ab = [tuple(map(int, input().split())) for i in range(N)]
ab.sort()
num = 0
for i in range(N):
	num += ab[i][1]
	if num >= K:
		ans = ab[i][0]
		break

print(ans)

Buggy submission (verdict: Runtime Error):
N, K = list(map(int, input().strip().split()))
grid = []
k = 0
j = 0
for i in range(N):
	array = list(map(int, input().strip().split()))
	grid.append(array)
for i in range(N):
	if k < K:
		k += grid[i-1][1]
		j += 1
print(str(grid[j][0])[K-k])
Problem p03759 (python)

Fixed submission:
num = list(map(int, input().split()))
if num[1]-num[0] == num[2]-num[1]:
	print('YES')
else:
	print('NO')

Buggy submission (verdict: Runtime Error):
num = list(map(int, input().split()))
if(num[1]-num[0] = num[2]-num[1]):
    print('Yes')
else
    print('No')

Buggy submission (verdict: Runtime Error):
num = list(map(int, input().split()))
if(b-a = c-b):
print('Yes')

a = num[0] + num[1]
print(int(a/24))
Problem p03773 (python)

Fixed submission:
num = list(map(int, input().split()))
a = num[0] + num[1]
print(int(a%24))

Buggy submission (verdict: Runtime Error):
import math
N=int(input())
if N==1:
	print(1)
else:
	nmax = math.ceil(math.sqrt(N))
	Bdigimin = 10
	for i in range(nmax):
		if N % (i+1) == 0:
			Bdigi = math.floor(math.log10(N/(i+1)))
			if Bdigimin > Bdigi:
				Bdigimin = Bdigi
	print(int(Bdigimin+1))

Buggy submission (verdict: Runtime Error):
import math
N=int(input())
nmax = math.floor(math.sqrt(N))
Bdigimin = 10
for i in range(1,nmax):
	if N % i == 0:
		Bdigi = math.floor(math.log10(N/i))
		if Bdigimin > Bdigi:
			Bdigimin = Bdigi
print(int(Bdigimin+1))

Buggy submission (verdict: Runtime Error):
import math
N=int(input())
nmax = math.floor(math.sqrt(N))
Bdigimin = 10
for i in range(1,nmax):
	if N % i == 0:
		Bdigi = math.floor(math.log10(N/i))
		if Bdigimin > Bdigi:
			Bdigimin = Bdigi
print(int(Bdigimin+1))

Buggy submission (verdict: Runtime Error):
import math
N=int(input())
nmax = math.floor(math.sqrt(N))
Bdigimin = 10
for i in range(1,nmax):
	if N % i == 0:
		Bdigi = math.floor(math.log10(N/i))
		if Bdigimin > Bdigi:
			Bdigimin = Bdigi
print(int(Bdigimin+1))

Buggy submission (verdict: Runtime Error):
import math
N=int(input())
nmax = math.floor(math.sqrt(N))
Bdigimin = 10
for i in range(1,nmax):
	if N % i == 0:
		Bdigi = math.floor(math.log10(N/i))
		if Bdigimin > Bdigi:
			Bdigimin = Bdigi
print(int(Bdigimin+1))

Buggy submission (verdict: Runtime Error):
import math
N=int(input())
nmax = math.floor(math.sqrt(N))
Bdigimax = 1
for i in range(1,nmax):
	if N % i == 0:
		Bdigi = math.floor(math.log10(N/i))
		if Bdigimax < Bdigi:
			Bdigimax = Bdigi
print(int(Bdigimax))
Problem p03826 (python)

Fixed submission:
num = list(map(int, input().split()))
if num[0]*num[1] <= num[2]*num[3]:
	print(num[2]*num[3])
else:
	print(num[0]*num[1])

Buggy submission (verdict: Runtime Error):
num = list(map(int, input().split()))
if num[0]*num[1] <= num[2]*num[3]:
	print(num[2]*num[3])
else:
	pritn(num[0]*num[1])
Problem p03844 (python)

Fixed submission:
data = input().split()
A = int(data[0])
B = int(data[2])
if data[1] == '+':
	S =  A + B
else:
	S = A - B
print(S)

Buggy submission (verdict: Runtime Error):
data = input().split()
A = int(data[0])
B = int(data[2])
if op == '+':
	S =  A + B
else:
	S = A - B
print(S)
Problem p03962 (python)

Fixed submission:
nums = list(map(int, input().split()))
n = 1
if nums[0] != nums[1]:
	n+=1
if nums[1] != nums[2] and nums[0] != nums[2]:
	n+=1
print(n)

Buggy submission (verdict: Runtime Error):
nums = list(map(int, input().split()))
n = 1
if nums[0] != nums[1]:
	n++
if nums[1] != nums[2] and nums[0] != nums[2]:
	n++
print(n)
Problem p04011 (python)

Fixed submission:
N = input()
K = input()
X = input()
Y = input()
if(X < Y):
	tmp = X
	X = Y
	Y = tmp

if(N>K):
	print(K*X+(N-K)*Y)
else:
	print(N*X)

Buggy submission (verdict: Runtime Error):
N = input()
K = input()
X = input()
Y = input()

print(K*X+(N-K)*Y)
Problem p04012 (python)

Fixed submission:
w = input()

if any(w.count(t)%2 for t in w) == 0:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
w = input()

for t in w:
    if any(w.count(t)%2) == 0:
        print('Yes')
    else:
        print('No')
Problem p04029 (python)

Fixed submission:
N = input()
sum = N * (N + 1) / 2 
print(sum)

Buggy submission (verdict: Runtime Error):
N = input()
sum = N*(N+1)/2 
print(sum)
Problem p04043 (python)

Fixed submission:
A, B, C = map(int, input().split())
if (A != 5 and A!=7):
	print('NO')
if (B != 5 and B!=7):
	print('NO')
if (C != 5 and C!=7):
	print('NO')
if(A + B + C != 17):
	print('NO')
else:
	print('YES')

Buggy submission (verdict: Runtime Error):
A, B, C = map(int, raw_input().split())
if (A != 5 and A!=7):
	print('NO')
if (B != 5 and B!=7):
	print('NO')
if (C != 5 and C!=7):
	print('NO')
if(A + B + C != 17):
	print('NO')
else:
	print('YES')
Problem p02787 (python)

Fixed submission:
h, n = map(int, input().split())

ab = [[0, 0] for _ in range(n)]
for i in range(n):
    a, b = map(int, input().split())
    ab[i][0] = a
    ab[i][1] = b

INF = 1 << 60
dp = [INF for _ in range(h+10001)]

dp[0] = 0

for i in range(1, h+10001):
    for j in range(n):
        if(i >= ab[j][0]):
            dp[i] = min(dp[i-ab[j][0]] + ab[j][1], dp[i])

res = INF
for i in range(h, h+10001):
    res = min(res, dp[i])
print(res)

Buggy submission (verdict: Runtime Error):
from numba import jit
import time
import numpy as np
t = time.time()
INF = 1 << 60


@jit
def Nap(h, n, ab, dp):

    for i in range(1, h + 10001):
        val = INF
        for j in range(n):
            if (i >= ab[j][0]):
                val = min(val, dp[i-ab[j][0]] + ab[j][1])
        dp[i] = min(val, dp[i])

    res = INF
    for i in range(h, h+10001):
        res = min(res, dp[i])
    return res


def pri(t):
    print("elapsed time:{:.2f}".format(time.time()-t))


def main():
    h, n = map(int, input().split())
    #ab = [[0, 0] for _ in range(n)]
    ab = np.zeros((n, 2), dtype=int)
    for i in range(n):
        a, b = map(int, input().split())
        ab[i][0] = a
        ab[i][1] = b

    #dp = [INF for _ in range(h+10001)]
    dp = np.full(h+10001, INF, dtype=int)

    dp[0] = 0
    print(Nap(h, n, ab, dp))
    # pri(t)


main()
Problem p03471 (python)

Fixed submission:
n,y=map(int,input().split())

for i in range(n+1):
    for j in range(n+1-i):
        k=n-i-j
        if 10000*i+5000*j+1000*k == y:
            print(i,j,k)
            exit()

print(-1,-1,-1)

Buggy submission (verdict: Runtime Error):
for i in range(n+1):
    for j in range(n+1-i):
        k=n-i-j
        if 10000*i+5000*j+1000*k==y:
            print(i,j,k)
            flag=False
            break

if flag:
    print(-1,-1,-1)

Buggy submission (verdict: Runtime Error):
n,y=map(int,input().split())
t=0
flag=True

for x in range(n+1):
    for k in range(n+1):
        z=n-x-k
        if x+k+z==s:
            print(x,k,z)
            flag=False
            break
if flag:
    print(-1,-1,-1)
Problem p03061 (python)

Fixed submission:
# coding: utf-8
import fractions

n = int(input().rstrip())
numbers = [int(i) for i in input().rstrip().split(" ")]

l_list = [0 for i in range(n)]
l_list[0] = numbers[0]
for i in range(1, n):
    l_list[i] = fractions.gcd(l_list[i-1], numbers[i])

r_list = [0 for i in range(n)]
r_list[n-1] = numbers[n-1]
for i in reversed(range(0, n - 1)):
    r_list[i] = fractions.gcd(r_list[i+1], numbers[i])

ans = 0
for i in range(n):
    l = 0
    if i > 0:
        l = l_list[i - 1]
    r = 0
    if i < n - 1:
        r = r_list[i + 1]
    if l == 0:
        l = r
    if r == 0:
        r = l
    ans = max(ans, fractions.gcd(l, r))
print(ans)

Buggy submission (verdict: Runtime Error):
# coding: utf-8
import math

n = int(input().rstrip())
numbers = [int(i) for i in input().rstrip().split(" ")]

l_list = [numbers[0]]
for i in range(1, n):
    l_list.append(math.gcd(l_list[i - 1], numbers[i]))

r_list = [numbers[len(numbers) - 1]]
for i in reversed(range(0, n - 1)):
    r_list.insert(0, math.gcd(r_list[0], numbers[i]))

ans = 0
for i in range(n):
    l = 0
    if i > 0:
        l = l_list[i - 1]
    r = 0
    if i < n - 1:
        r = r_list[i + 1]
    if l == 0:
        l = r
    if r == 0:
        r = l
    ans = max(ans, math.gcd(l, r))
print(ans)

Buggy submission (verdict: Runtime Error):
# coding: utf-8
import math

n = int(input().rstrip())
numbers = [int(i) for i in input().rstrip().split(" ")]

l_list = [numbers[0]]
for i in range(1, n):
    l_list.append(math.gcd(l_list[i - 1], numbers[i]))

r_list = [numbers[len(numbers) - 1]]
for i in reversed(range(0, n - 1)):
    r_list.insert(0, math.gcd(r_list[0], numbers[i]))

ans = 0
for i in range(n):
    l = 0
    if i > 0:
        l = l_list[i - 1]
    r = 0
    if i < n - 1:
        r = r_list[i + 1]
    if l == 0:
        l = r
    if r == 0:
        r = l
    ans = max(ans, math.gcd(l, r))
print(ans)
Problem p03111 (python)

Fixed submission:
# coding: utf-8

list = [int(i) for i in input().rstrip().split(" ")]

matsu_count = list[0]
require = sorted(list[1:])

matsu_list = sorted([int(input().rstrip()) for i in range(matsu_count)])

def get_mp(matsu:list):
    ans = 0
    for i in range(3):
        ans += abs(matsu[i] - require[i])
    return ans
mp = {}

def get_ans(matsu:list):
    if len(matsu) == 3:
        return get_mp(matsu)
    key = "#".join(map(str, matsu))
    if key in mp:
        return mp[key]
    ans = 80000
    for i in range(len(matsu) - 3 + 1):
        for j in range(i + 1, len(matsu) - 2 + 1):
            for k in range(j + 1, len(matsu) - 1 + 1):
                ans = min(ans, get_mp([matsu[i],matsu[j], matsu[k]]))
    if ans > 0:
        for i in range(len(matsu)):
            for j in range(i + 1, len(matsu)):
                sub_matsu = []
                for k in range(len(matsu)):
                    if k == i or k == j:
                        continue
                    else:
                        sub_matsu.append(matsu[k])
                sub_matsu.append(matsu[i] + matsu[j])
                ans = min(ans, get_ans(sorted(sub_matsu)) + 10)

    mp[key] = ans
    return ans

ans = get_ans(matsu_list)
print(ans)

Buggy submission (verdict: Runtime Error):
# coding: utf-8

list = [int(i) for i in input().rstrip().split(" ")]

matsu_count = list[0]
require = sorted(list[1:])

matsu_list = sorted([int(input().rstrip()) for i in range(matsu_count)])

def get_mp(matsu:list):
    ans = 0
    for i in range(3):
        ans += abs(matsu[i] - require[i])
    return ans
mp = {}
def get_ans(matsu:list):
    if len(matsu) == 3:
        return get_mp(matsu)
    key = "#".join(matsu)
    if key in mp:
        return mp[key]
    ans = 80000
    for i in range(len(matsu) - 3 + 1):
        ans = min(ans, get_mp(matsu[i:]))
    for i in range(len(matsu)):
        for j in range(i + 1, len(matsu)):
            sub_matsu = []
            for k in range(len(matsu)):
                if k == i or k == j:
                    continue
                else:
                    sub_matsu.append(matsu[k])
            sub_matsu.append(matsu[i] + matsu[j])
            ans = min(ans, get_ans(sorted(sub_matsu)) + 10)

    mp[key] = ans
    return ans

ans = get_ans(matsu_list)
print(ans)
Problem p03241 (python)

Fixed submission:
# coding: utf-8
import math

(n, m) = [int(i) for i in input().rstrip().split(" ")]

ans = 0
divList = []
for i in range(1, int(math.sqrt(m)) + 1):
    if m % i == 0:
        j = m / i
        divList.append(i)
        divList.append(j)
divList = sorted(divList)
for i in divList:
    if i < n:
        continue
    ans = m / i
    break

print(int(ans))

Buggy submission (verdict: Runtime Error):
# coding: utf-8
import math

(n, m) = [int(i) for i in input().rstrip().split(" ")]

for i in range(n, math.sqrt(m) + 1):
    if m % i == 0:
        print(int(m / i))
        break
Problem p03693 (python)

Fixed submission:
a = map(int, raw_input().split())
d = a[0] * 100 + a[1] * 10 + a[2]
if d % 4 == 0:
	print "YES"
else:
	print "NO"

Buggy submission (verdict: Runtime Error):
N = input()
a = map(int, raw_input().split())
a.sort()
print a[-1] - a[0]
Problem p02694 (python)

Fixed submission:
X = int(input())
n = 0
money = 100
while(money<X):
  money = money+money//100
  n = n+1
print(n)

Buggy submission (verdict: Runtime Error):
X = int(input())
n = 0
money = 100
while(money<X){
  money = money+money//100
  n = n+1
}
print(n)
Problem p02778 (python)

Fixed submission:
print("x"*len(input()))

Buggy submission (verdict: Runtime Error):
S=input()
print(S.replace("x"))
Problem p02789 (python)

Fixed submission:
a,b=map(int,input().split())
print("Yes" if a==b else "No")

Buggy submission (verdict: Runtime Error):
a,b=int(input().split())
print("Yes" if a==b else "No")