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

Fixed submission:
s = str(input())
l = len(s)
x,y = map(int,input().split())
Fs = []
count = 0
for i in range(l):
    if s[i] == "T":
        Fs.append(count)
        count = 0
    else:
        count+=1
if s[-1] == "F":
    Fs.append(count)
xFs = [Fs[j] for j in range(len(Fs)) if j%2 == 0 and j!=0]
yFs = [Fs[k] for k in range(len(Fs)) if k%2 == 1]
x-=Fs[0]

def part_sum(a,A):
    n = len(a)
    dp = [[0 for i in range(A+1)] for j in range(n+1)]
    dp[0][0]=1
    
    for i in range(n):
        for j in range(A+1):
            if a[i]<=j:
                dp[i+1][j]=dp[i][j-a[i]] or dp[i][j]
            else:
                dp[i+1][j]=dp[i][j]
    return dp[n][A]


if sum(xFs) < abs(x) or sum(yFs) < abs(y):
    print("No")
else:
    sax = (sum(xFs)-abs(x))
    say = (sum(yFs)-abs(y))
    if sax%2 == 0 and say%2 == 0:
        sax = int(sax/2)
        say = int(say/2)
        if part_sum(xFs,sax) == 1 and part_sum(yFs,say) == 1:
            print("Yes")
        else:
            print("No")
    else:
        print("No")

Buggy submission (verdict: Runtime Error):
s = str(input())
l = len(s)
x,y = map(int,input().split())
Fs = []
count = 0
for i in range(l):
    if s[i] == "T":
        Fs.append(count)
        count = 0
    else:
        count+=1
if s[-1] == "F":
    Fs.append(count)
xFs = [Fs[j] for j in range(len(Fs)) if j%2 == 0 and j!=0]
yFs = [Fs[k] for k in range(len(Fs)) if k%2 == 1]
x-=Fs[0]

def part_sum(a,A):
    n = len(a)
    dp = [[0 for i in range(A+1)] for j in range(n+1)]
    dp[0][0]=1
    
    for i in range(n):
        for j in range(A+1):
            if a[i]<=j:
                dp[i+1][j]=dp[i][j-a[i]] or dp[i][j]
            else:
                dp[i+1][j]=dp[i][j]
    return dp[n][A]


if sum(xFs) < abs(x) or sum(yFs) < abs(y):
    print("No")
else:
    if sax%2 == 0 and say%2 == 0:
        sax = int((sum(xFs)-x)/2)
        say = int((sum(yFs)-y)/2)
        if part_sum(xFs,sax) == 1 and part_sum(yFs,say) == 1:
            print("Yes")
        else:
            print("No")
    else:
        print("No")
Problem p03550 (python)

Fixed submission:
N,Z,W = map(int,input().split())
a = list(map(int,input().split()))
A = abs(a[-1]-W)
if N == 1:
    print(A)
else:
    B = abs(a[-2]-a[-1])
    print(max(A,B))

Buggy submission (verdict: Runtime Error):
N,Z,W = map(int,input().split())
a = list(map(int,input().split()))
A = abs(a[-1]-W)
B = abs(a[-2]-a[-1])
print(max(A,B))
Problem p03574 (python)

Fixed submission:
H,W = map(int,input().split())
f = list(list(str(input())) for i in range(H))

for i in range(H):
  for j in range(W):
    if f[i][j] == "#":
      continue
    
    count = 0
    if i > 0 and j > 0:
      if f[i-1][j-1] == "#":
        count+=1
    if i > 0:
      if f[i-1][j] == "#":
        count+=1
    if i > 0 and j < W-1:
      if f[i-1][j+1] == "#":
        count+=1
    if j > 0:
      if f[i][j-1] == "#":
        count+=1
    if j < W-1:
      if f[i][j+1] == "#":
        count+=1
    if i < H-1 and j > 0:
      if f[i+1][j-1] == "#":
        count+=1
    if i < H-1:
      if f[i+1][j] == "#":
        count+=1
    if i < H-1 and j < W-1:
      if f[i+1][j+1] == "#":
        count+=1
    
    f[i][j] = str(count)

for i in range(H):
  n = ""
  for j in range(W):
    n+=f[i][j]
  print(n)

Buggy submission (verdict: Runtime Error):
H,W = map(int,input().split())
f = list(str(input()) for i in range(H))

for i in range(H):
  for j in range(W):
    if f[i][j] == "#":
      continue
    
    count = 0
    if i > 0 and j > 0:
      if f[i-1][j-1] == "#":
        count+=1
    if i > 0:
      if f[i-1][j] == "#":
        count+=1
    if i > 0 and j < W-1:
      if f[i-1][j+1] == "#":
        count+=1
    if j > 0:
      if f[i][j-1] == "#":
        count+=1
    if j < W-1:
      if f[i][j+1] == "#":
        count+=1
    if i < H-1 and j > 0:
      if f[i+1][j-1] == "#":
        count+=1
    if i < H-1:
      if f[i+1][j] == "#":
        count+=1
    if i < H-1 and j < W-1:
      if f[i+1][j+1] == "#":
        count+=1
    
    f[i][j] = str(count)
    
for i in range(H):
  print(f[i])
Problem p03633 (python)

Fixed submission:
from functools import reduce
N = int(input())
T = []
for i in range(N):
    T.append(int(input()))

def gcd(m,n):
    if n == 0:
        return m
    return gcd(n,m%n)
    
def lcm(m,n):
    return m * n//gcd(m,n)

print(reduce(lcm,T))

Buggy submission (verdict: Runtime Error):
from functools import reduce
N = int(input())
T = []
for i in range(N):
    T.append(int(input()))
T.sort()

def gcd(m,n):
    if n == 0:
        return m
    return gcd(n,m%n)
    
def lcm(m,n):
    return int(m * n/gcd(m,n))

print(reduce(lcm,T))

Buggy submission (verdict: Runtime Error):
from functools import reduce
N = int(input())
T = []
for i in range(N):
    T.append(int(input()))
T.sort()
ans = 1
def gcd(m,n):
    x = max(m,n)
    y = min(m,n)
    if y == 0:
        return x
    else:
        return gcd(y,x%y)
    
def lcm(m,n):
    return int(m * n/gcd(m,n))

print(reduce(lcm,T))

Buggy submission (verdict: Runtime Error):
N = int(input())
T = []
for i in range(N):
    T.append(int(input()))
T.sort()
ans = 1
def gcd(m,n):
    x = max(m,n)
    y = min(m,n)
    if y == 0:
        return x
    else:
        return gcd(y,x%y)
    
def lcm(m,n):
    return int(m * n/gcd(m,n))

for j in range(N):
    ans = lcm(ans,T[j])
        
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
T = []
for i in range(N):
    T.append(int(input()))
T.sort()
ans = 1
def gcd(m,n):
    x = max(m,n)
    y = min(m,n)
    if x%y == 0:
        return y
    else:
        while x%y!=0:
            z = x%y
            x = y
            y = z
        else:
            return z    
def lcm(m,n):
    return int(m * n/gcd(m,n))

for j in range(N):
    ans = lcm(ans,T[j])
        
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
T = []
for i in range(N):
    T.append(int(input()))
T.sort()
ans = 1
def gcd(m,n):
    x = max(m,n)
    y = min(m,n)
    if x%y == 0:
        return y
    else:
        while x%y!=0:
            z = x%y
            x = y
            y = z
        else:
            return z    
def lcm(m,n):
    return int((m*n)/gcd(m,n))

for j in range(N):
    ans = lcm(ans,T[j])
        
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
T = []
for i in range(N):
    T.append(int(input()))
T.sort()
ans = 1

def gcd(m,n):
    x = max(m,n)
    y = min(m,n)
    if x%y == 0:
        return y
    else:
        while x%y!=0:
            z = x%y
            x = y
            y = z
        else:
            return z
    
def lcm(m,n):
    return int((m*n)/gcd(m,n))

ans = 1
for j in range(N):
    ans = lcm(ans,T[j])
        
print(ans)
Problem p03682 (python)

Fixed submission:
#D問題
def find(A,x):
    p = A[x]
    if p == x:
        return x
    a = find(A,p)
    A[x] = a
    return a

def union(A, x, y):
    if find(A,x) > find(A,y):
        bx, by = find(A,y), find(A,x)
    else:
        bx, by = find(A,x), find(A,y)
    A[y] = bx
    A[by] = bx

import heapq

N = int(input())

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

XY0.sort()
XY1 = sorted(XY1, key=lambda x: x[1])

E = []
for i,x in enumerate(XY0):
    if i == 0:
        ox = x[0]
        oi = x[2]
    else:
        dx = x[0]-ox
        ox = x[0]
        heapq.heappush(E,[dx,oi,x[2]])
        oi = x[2]

for i,y in enumerate(XY1):
    if i == 0:
        oy = y[1]
        oi = y[2]
    else:
        dy = y[1]-oy
        oy = y[1]
        heapq.heappush(E,[dy,oi,y[2]])
        oi = y[2]



V = [i for i in range(N)]
ans = 0
while E:
    w,s,t = heapq.heappop(E)
    if find(V,s) != find(V,t):
        union(V,s,t)
        ans+=w
        
print(ans)

Buggy submission (verdict: Runtime Error):
#D問題
def find(A,x) -> int:
    p = A[x]
    if p == x:
        return x
    a = find(A,p)
    A[x] = a
    return a

def union(A, x, y):
    if find(A,x) > find(A,y):
        bx, by = find(A,y), find(A,x)
    else:
        bx, by = find(A,x), find(A,y)
    A[y] = bx
    A[by] = bx

import heapq

N = int(input())

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

XY0.sort()
XY1 = sorted(XY1, key=lambda x: x[1])

E = []
for i,x in enumerate(XY0):
    if i == 0:
        ox = x[0]
        oi = x[2]
    else:
        dx = x[0]-ox
        ox = x[0]
        heapq.heappush(E,[dx,oi,x[2]])
        oi = x[2]

for i,y in enumerate(XY1):
    if i == 0:
        oy = y[1]
        oi = y[2]
    else:
        dy = y[1]-oy
        oy = y[1]
        heapq.heappush(E,[dy,oi,y[2]])
        oi = y[2]


uf = UnionFind(N)
V = [i for i in range(N)]
ans = 0
while E:
    w,s,t = heapq.heappop(E)
    if find(V,s) != find(V,t):
        union(V,s,t)
        ans+=w
        
print(ans)
Problem p03722 (python)

Fixed submission:
#D問題
#Bellman-Ford法(最短距離)
def BellmanFord(edges,num_v,source):
    #グラフの初期化
    inf=float("inf")
    dist=[inf for i in range(num_v)]
    dist[source-1]=0
    #辺の緩和
    for i in range(num_v):
        for edge in edges:
            if dist[edge[0]-1] != inf and dist[edge[1]-1] > dist[edge[0]-1] + edge[2]:
                dist[edge[1]-1] = dist[edge[0]-1] + edge[2]
    return dist

N,M = map(int,input().split())
ABC = []
for i in range(M):
    a,b,c = map(int,input().split())
    ABC.append([a,b,-c])
    
Dist = BellmanFord(ABC,N,1)

negative = [False for i in range(N)]
inf = float("inf")
for i in range(N):
    for j in range(M):
        if Dist[ABC[j][0]-1] == inf:
            continue
        if Dist[ABC[j][1]-1] > Dist[ABC[j][0]-1]+ABC[j][2]:
            Dist[ABC[j][1]-1] = Dist[ABC[j][0]-1]+ABC[j][2]
            negative[ABC[j][1]-1] = True
            
        if negative[ABC[j][0]-1] == True:
            negative[ABC[j][1]-1] = True


if negative[N-1]:
    print("inf")
else:
    print(-Dist[-1])

Buggy submission (verdict: Runtime Error):
#D問題
N,M=map(int,input().split())
ABC=[]
for i in range(M):
    a,b,c=map(int,input().split())
    ABC.append([a,b,-c])
negative=[]
#Bellman-Ford法(最短距離)
def BellmanFord(edges,num_v,source):
    #グラフの初期化
    inf=float("inf")
    dist=[inf for i in range(num_v)]
    dist[source-1]=0
    #負閉路の検出
    global negative
    negative=[False for i in range(num_v)]
    #辺の緩和
    for i in range(num_v):
        for edge in edges:
            if edge[0] != inf and dist[edge[1]-1] > dist[edge[0]-1] + edge[2]:
                dist[edge[1]-1] = dist[edge[0]-1] + edge[2]
                negative[i]=True
                if i==num_v-1: return -1
    return dist
ans=BellmanFord(ABC,N,1)
if ans == -1 or negative[-1]:
    print("inf")
else:
    print(-ans[N])
Problem p03738 (python)

Fixed submission:
A = int(input())
B = int(input())
if A > B:
  print("GREATER")
elif A < B:
  print("LESS")
else:
  print("EQUAL")

Buggy submission (verdict: Runtime Error):
A,B = map(int,input().split())
if A > B:
  print("GREATER")
elif A < B:
  print("LESS")
else:
  print("EQUAL")
Problem p03854 (python)

Fixed submission:
#C問題
S=str(input())
Slist=list(S)
Slen=len(Slist)
Srev=Slist[::-1]
kari=""
for i in range(Slen):
    if len(kari) == 5:
        if kari == "maerd":
            kari=Srev[i]
        elif kari == "esare":
            kari=Srev[i]
        else:
            kari+=Srev[i]
    elif len(kari) == 6:
        if kari == "resare":
            kari=Srev[i]
        else:
            kari+=Srev[i]
    elif len(kari) == 7:
        if kari == "remaerd":
            kari=Srev[i]
        else:
            break
    else:
        kari+=Srev[i]
if kari == "esare" or kari == "maerd" or kari == "resare" or kari == "remaerd":
    print("YES")
else:
    print("NO")

Buggy submission (verdict: Runtime Error):
#C問題
S=str(input())
Slist=list(S)
Slen=len(Slist)
Srev=Slist[::-1]
kari=""
for i in range(Slen):
    if len(kari) == 5:
        if kari == "maerd":
            kari=Srev[i]
        elif kari == "esare":
            kari=Slev[i]
        else:
            kari+=Srev[i]
    elif len(kari) == 6:
        if kari == "resare":
            kari=Srev[i]
        else:
            kari+=Srev[i]
    elif len(kari) == 7:
        if kari == "remaerd":
            kari=Srev[i]
        else:
            break
    else:
        kari+=Srev[i]
if kari == "esare" or kari == "maerd" or kari == "resare" or kari == "remaerd":
    print("YES")
else:
    print("NO")
Problem p03972 (python)

Fixed submission:
#C問題
#UnionFind
def find(A,x):
    p = A[x]
    if p == x:
        return x
    a = find(A,p)
    A[x] = a
    return a
 
def union(A, x, y):
    if find(A,x) > find(A,y):
        bx, by = find(A,y), find(A,x)
    else:
        bx, by = find(A,x), find(A,y)
    A[y] = bx
    A[by] = bx

import heapq

W,H = map(int,input().split())
PQ = []
for i in range(W+H+1):
    if i == W+1:
        continue
    pq = int(input())
    heapq.heappush(PQ,[pq,i,i+1])

#print(PQ)
w = W+1
h = H+1
ans = 0
V = [i for i in range(H+W+2)]

while PQ:
    e,s,t = heapq.heappop(PQ)
    if find(V,s) != find(V,t):
        union(V,s,t)
        if s < W: #P
            ans+=(e*h)
            w-=1
        else:#Q
            ans+=(e*w)
            h-=1
            
print(ans)

Buggy submission (verdict: Runtime Error):
#C問題
#UnionFind
def find(A,x):
    p = A[x]
    if p == x:
        return x
    a = find(A,p)
    A[x] = a
    return a
 
def union(A, x, y):
    if find(A,x) > find(A,y):
        bx, by = find(A,y), find(A,x)
    else:
        bx, by = find(A,x), find(A,y)
    A[y] = bx
    A[by] = bx

import heapq

H,W = map(int,input().split())
PQ = []
for i in range(W+H+1):
    if i == W:
        continue
    pq = int(input())
    heapq.heappush(PQ,[pq,i,i+1])


uf = UnionFind(H+W+2)
a = W+1
b = H+1
ans = 0
V = [i for i in range(H+W+2)]

while PQ:
    edge = heapq.heappop(PQ)
    w,s,t = edge[0],edge[1],edge[2]
    if find(V,s) != find(V,t):
        union(V,s,t)
        if s < W+1: #P
            ans+=w*b
            a-=1
        else:#Q
            ans+=w*a
            b-=1
            
print(ans)
Problem p02687 (python)

Fixed submission:
S = input()

if "B" in S:
  print(S.replace("B", "R"))
elif "R" in S:
  print(S.replace("R", "B"))

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

A = 0
B = 0
test = 10**3
for i in range(-test, test):
	a = (X + i**5)**0.2
	if type(a) == float:
		if round(a, 10).is_integer():
			# print(int(a), i)
			A, B = int(a), i
			break
print(A, B)
Problem p03160 (python)

Fixed submission:
import sys
def I():
	return int(sys.stdin.readline().rstrip())


def SL():
	return S().split()


def IL():
	return list(map(int, sys.stdin.readline().rstrip().split()))


N = I()
h_i = IL()
dp = [0 for _ in range(N)]
for i in range(N):
	if i == 0:
		pass
	elif i == 1:
		dp[i] = abs(h_i[i] - h_i[i-1])
	else:
		point_1 = abs(h_i[i] - h_i[i-1]) + dp[i-1]
		point_2 = abs(h_i[i] - h_i[i-2]) + dp[i-2]
		if point_1 <= point_2:
			dp[i] = point_1
		else:
			dp[i] = point_2

print(dp[-1])

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

def LI():
	return list(map(int, sys.stdin.readline().rstrip().split()))

def main():
	N, K = LI()
	h_i = np.array(LI())
	dp = np.full(N, 10**10, dtype=int)
	dp[0] = 0
	for i in range(1, N):
		dp[i:i+K] = np.fmin(dp[i:i+K], dp[i-1] + np.abs(h_i[i:i+K] - h_i[i-1]))
		
	return dp[-1]


if __name__ == "__main__":
	print(main())

Buggy submission (verdict: Runtime Error):
def I():
	return int(sys.stdin.readline().rstrip())


def IL():
	return list(map(int, sys.stdin.readline().rstrip().split()))

  
N = I()
h_i = IL()
dp = [0 for _ in range(N)]
for i in range(N):
	if i == 0:
		pass
	elif i == 1:
		dp[i] = abs(h_i[i] - h_i[i-1])
	else:
		point_1 = abs(h_i[i] - h_i[i-1]) + dp[i-1]
		point_2 = abs(h_i[i] - h_i[i-2]) + dp[i-2]
		if point_1 <= point_2:
			dp[i] = point_1
		else:
			dp[i] = point_2

print(dp[-1])
Problem p03162 (python)

Fixed submission:
import sys
# import numpy as np

def I():
	return int(sys.stdin.readline().rstrip())

def LI():
	return list(map(int, sys.stdin.readline().rstrip().split()))

def main():
	N = I()
	activity = []
	for i in range(N):
		activity.append(LI())
	
	# dp = np.zeros((N, 3), dtype=int)
	dp = [[0, 0, 0] for _ in range(N)]
	dp[0][0] = activity[0][0]
	dp[0][1] = activity[0][1]
	dp[0][2] = activity[0][2]
	for i in range(1, N):
		dp[i][0] = max(dp[i-1][1] + activity[i][0], dp[i-1][2] + activity[i][0])
		dp[i][1] = max(dp[i-1][0] + activity[i][1], dp[i-1][2] + activity[i][1])
		dp[i][2] = max(dp[i-1][0] + activity[i][2], dp[i-1][1] + activity[i][2])
	print(max(dp[-1]))

if __name__ == "__main__":
	main()

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

def I():
	return int(sys.stdin.readline().rstrip())

def LI():
	return list(map(int, sys.stdin.readline().rstrip().split()))

def main():
	N = I()
	a = np.zeros((N,))
	b = np.zeros((N,))
	c = np.zeros((N,))
	for i in range(N):
		a[i], b[i], c[i] = LI()
	
	dp = np.zeros((N, 3), dtype=int)
	dp[0, 0] = a[0]
	dp[0, 1] = b[0]
	dp[0, 2] = c[0]
	for i in range(1, N):
		dp[i, 0] = max(dp[i-1, 1] + a[i], dp[i-1, 2] + a[i])
		dp[i, 1] = max(dp[i-1, 0] + b[i], dp[i-1, 2] + b[i])
		dp[i, 2] = max(dp[i-1, 0] + c[i], dp[i-1, 1] + c[i])
	print(max(dp[-1, :]))

if __name__ == "__main__":
	main()
Problem p03164 (python)

Fixed submission:
import sys
# import numpy as np

def IL():
	return list(map(int, sys.stdin.readline().rstrip().split()))

N, W = IL()
v_list = [0] * N
w_list = [0] * N

for i in range(N):
	w_list[i], v_list[i] = IL()

v_max = 100100
dp = [[sys.maxsize] * (v_max+1) for _ in range(N+1)]
dp[0][0] = 0
for i in range(N):
	for j in range(v_max+1):
		if j >= v_list[i]:
			dp[i+1][j] = min(dp[i][j-v_list[i]] + w_list[i], dp[i][j])
		else:
			dp[i+1][j] = min(dp[i+1][j], dp[i][j])

ans = 0
for j in range(v_max+1):
	if dp[N][j] <= W:
		ans = j

print(ans)

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

def IL():
	return list(map(int, sys.stdin.readline().rstrip().split()))

N, W = IL()
v_list = [0] * N
w_list = [0] * N
v = 0
w_total = 0
for i in range(N):
	w_list[i], v_list[i] = IL()
# dp = np.zeros((N+1, W+1))
dp = [[0] * (W+1) for _ in range(N+1)]
for i in range(N):
	for j in range(W+1):
		if j >= w_list[i]:
			dp[i+1][j] = max(dp[i][j-w_list[i]] + v_list[i], dp[i][j])
		else:
			dp[i+1][j] = dp[i][j]

print(dp[N][W])
Problem p02675 (python)

Fixed submission:
#!/usr/bin/python
# -*- coding: UTF-8 -*-

N = int(input())
if N%10 == 3:
	print('bon')
elif N%10 == 0 or N%10 == 1 or N%10 == 6 or N%10 == 8:
	print('pon')
else:
	print('hon')

Buggy submission (verdict: Runtime Error):
#!/usr/bin/python
# -*- coding: UTF-8 -*-

N = int(input())
if N%10 == 3
	print('bon')
elif N%10 == 0 or N%10 == 1 or N%10 == 6 or N%10 == 8:
	print('pon')
else:
	print('hon')
Problem p02677 (python)

Fixed submission:
import math
a,b,h,m=map(int,input().split())
#1分間に進む分針 360/60=6度
#1時間に進む時針 360/12=30度
#1分間に進む時針 30/60=0.5度
r=abs((h*30+m*0.5)-(m*6))
s=math.sqrt(a**2+b**2-(2*a*b*(math.cos(math.radians(r)))))
print(s)

Buggy submission (verdict: Runtime Error):
import math
a,b,h,m=map(int,input().split())
#1分間に進む分針 360/60=6度
#1時間に進む時針 360/12=30度
#1分間に進む時針 30/60=0.5度
r=abs((h*30+m*0.5)-(m*6))
s1=math.sqrt(a**2+b**2-(2*a*b*(math.cos(math.radians(r)))))
print(s)
Problem p02772 (python)

Fixed submission:
n=int(input())
l=[]
a=[]
b=[]
for i in range(n):
    m=[int(j) for j in input().split()]
    
    for k in m:
        if k%2==0:
            l.append(k)
    
    for p in l:
        if p%3==0 or p%5==0:
            a.append(p)
        else:
            b.append(p)
 
    if len(a)==len(l):
        print("APPROVED")
    else:
        print("DENIED")
    break

Buggy submission (verdict: Runtime Error):
n=int(input())
l=[]
a=[]
b=[]
for i in range(n):
    m=[int(j) for j in input().split()]
    
    for k in m:
        if k%2==0:
            l.append(k)
    
    for p in l:
        if p%3==0 or p%5==0:
            a.append(p)
        else:
            b.append(p)

    if len(a)==len(l):
        print("APPROVED")
    else:
        print("DENIDE")
Problem p03251 (python)

Fixed submission:
def answer(n, m, x, y, x_array, y_array):
    max_x = x
    for i in range(n):
        if x_array[i] > max_x:
            max_x = x_array[i]


    min_y = y
    for i in range(m):
        if y_array[i] < min_y:
            min_y = y_array[i]

    if max_x < min_y:
        return "No War"
    else:
        return "War"


[n, m, x, y] = list(map(int, input().split()))
x_array = list(map(int, input().split()))
y_array = list(map(int, input().split()))
    
print(answer(n, m, x, y, x_array, y_array))

Buggy submission (verdict: Runtime Error):
def answer(n, m, x, y, x_array, y_array):
    max_x = x
    for i in range n:
        if x_array[i] > max:
            max_x = x_array[i]


    min_y = y
    for i in range m:
        if y_array[i] < min:
            min_y = y_array[i]

    if max_x < min_y:
        return "No War"
    else:
        return "War"


[n, m, x, y] = list(map(int, input().split()))
x_array = list(map(int, input().split()))
y_array = list(map(int, input().split()))
    
print(answer(n, m, x, y, x_array, y_array))
Problem p02675 (python)

Fixed submission:
n=int(input())
p=n%10
if(p==2 or p==4 or p==5 or p==7 or p==9):
  print("hon")
elif(p==3):
  print("bon")
else:
  print("pon")

Buggy submission (verdict: Runtime Error):
n=int(input())
p=n%10
if(p==2||p==4||p==5||p==7||p==9):
  print("hon")
elif(p==3):
  print("pon")
else:
  print("bon")
Problem p02713 (python)

Fixed submission:
k = int(input())
sum = 0
def gcd(p,q):
  if p%q == 0:
    return q
  return gcd(q,p%q)
  
for i in range(1,k+1):
   for j in range(1,k+1):
      for k in range(1,k+1):
        sum += gcd(gcd(i,j),k)

print(sum)

Buggy submission (verdict: Runtime Error):
k = int(input())
sum = 0
def gcd(p,q):
  if p%q == 0:
    return q
  retrun gcd(q,p%q)
for i in range(1,k+1):
   for j in range(1,k+1):
      for k in range(1,k+1):
        sum += gcd(gcd(i,j),k)

print(sum)
Problem p03455 (python)

Fixed submission:
a, b = [int(e) for e in input().split()]
if (a * b) % 2:
    print('Odd')
else:
    print('Even')

Buggy submission (verdict: Runtime Error):
a, b = input().split()
if (a * b) % 2:
    print('Odd')
else:
    print('Even')
Problem p03455 (python)

Fixed submission:
a,b=map(int,input().split())
if(a*b)%2:
   print("Odd")
else:
   print("Even")

Buggy submission (verdict: Runtime Error):
a,b=map(int,input().split())
if(a*b)%2:
print("Odd")
else:
print("Even")
Problem p03160 (python)

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

dp=[0]*n
dp[0]=0
dp[1]=abs(h[1]-h[0])

for i in range(2,n):
    dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]))

print(dp[n-1])

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

dp=[0]*n
dp[0]=0
dp[1]=abs(h[1]-h[0])

for i in range(2,n):
    dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]))

print(dp[n-1])

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

dp=[0]*n
dp[0]=0
dp[1]=abs(h[1]-h[2])

for i in range(2,n):
    dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]))

print(dp[n-1])

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

dp=[0]*n
dp[0]=0
dp[1]=abs(h[1]-h[2])

for i in range(2,n):
    dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]))

print(dp[n-1])
Problem p02719 (python)

Fixed submission:
N, K = map(int, raw_input().split())

N = N % K

print min(N, abs(K-N))

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

ave = sum(A)/N

c = 0
for i in range(N):
    if A[i] >= ave:
        c += 1

if c >= M:
    print "Yes"
else:
    print "No"