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

Fixed submission:
# B - Problem Set
def is_create(dic_d, t):
	for ti in t:
		if not ti in dic_d.keys():
			return False
		elif dic[ti] == 0:
			return False
		else:
			dic[ti] -= 1	
	
	return True


n = int(input())
d = list(map(int, input().split()))
m = int(input())
t = list(map(int, input().split()))

dic = dict()

for di in d:
	if di in dic.keys():
		dic[di] += 1
	else:
		dic[di] = 1

if is_create(dic, t):
	print('YES')
else:
	print('NO')

Buggy submission (verdict: Runtime Error):
# B - Problem Set
n = int(input())
d = list(map(int, input().split()))
m = int(input())
t = list(map(int, input().split()))

dic = dict()

for di in d:
	if di in dic.keys():
		dic[di] += 1
	else:
		dic[di] = 1

for ti in t:
	if not ti in dic.keys():
		print('NO')
		sys.exit()
	elif dic[ti] < 1:
		print('NO')
		sys.exit()
	else:
		dic[ti] -= 1

print('YES')
Problem p03612 (python)

Fixed submission:
import sys
input = sys.stdin.readline

# D - Derangement
def swap(index, swap_with_right):
  global p

  if swap_with_right:
    l = index
    r = index + 1
  else:
    l = index - 1
    r = index

  pl = p[l]
  pr = p[r]
  p[l] = pr
  p[r] = pl


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

p.insert(0, 0)
ans = 0

if p[1] == 1:
  swap(1, True)
  ans += 1

for i in range(2, N+1):
	if i < N:
		if i == p[i] and i+1 == p[i+1]:
			swap(i, True)
			ans += 1
		elif i == p[i]:
			ans += 1
	elif i == p[i]:
		ans += 1

print(ans)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

# D - Derangement
def swap(index, swap_with_right):
  global p

  if swap_with_right:
    l = index
    r = index + 1
  else:
    l = index - 1
    r = index

  pl = p[l]
  pr = p[r]
  p[l] = pr
  p[r] = pl


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

p.insert(0, 0)
ans = 0

if p[1] == 1:
  swap(1, True)
  ans += 1

for i in range(2, N+1):
	if i == p[i] and i+1 == p[i+1]:
		swap(i, True)
		ans += 1
	elif i == p[i]:
		ans += 1

print(ans)

Buggy submission (verdict: Runtime Error):
 D - Derangement
def swap(index, swap_with_right):
  global p

  if swap_with_right:
    l = index
    r = index + 1
  else:
    l = index - 1
    r = index

  pl = p[l]
  pr = p[r]
  p[l] = pr
  p[r] = pl


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

p.insert(0, 0)
ans = 0

if p[1] == 1:
  swap(1, True)
  ans += 1

for i in range(2, N+1):
  if i == p[i]:
    if p[i-1] == i:
      swap(i, True)

    ans += 1

print(ans)
Problem p02641 (python)

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

p = list(map(int,input().split()))

#if x in p == False:
    #print(x)


for i in range(101):
    if ((x-i) in p) == False:
        print(x-i)
        break
    elif ((x+i) in p) ==False:
        print(x+i)
        break

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

s = 0
u = -1
for i in a:
    t = 0
    for j in a:
        if j != i and i % j == 0:
            t += 1
    if j != i and t == 0:
        s += 1
print(s)
Problem p02658 (python)

Fixed submission:
n = int(input())

a = list(map(int,input().split()))

s = 1
for i in a:
    s = s*i
    s = min(s,10**18+1)
if s == 10**18+1:
    print('-1')
else:
    print(s)

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

a = list(map(int,input().split())

s = 1
for i in a:
    s = s*i
if s > 10**18:
    print('-1')
else:
    print(s)

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

a = list(map(int,input()split())

s = 1
for i in a:
    s = s*i
if s > 10**18:
    print('-1')
else:
    print(s)
Problem p02675 (python)

Fixed submission:
n = input()

m = (n[-1])

if m == '3':
    print('bon')
elif m == '0' or m == '1' or m =='6' or m =='8':
    print('pon')
else:
    print('hon')

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

m = n[-1]

if m == 3:
    print('bon')
elif m == 0,1,6,8:
    print('pon')
else:
    print('hon')
Problem p02687 (python)

Fixed submission:
s = input()
if s == 'ABC':
  print('ARC')
elif s == 'ARC':
  print('ABC')

Buggy submission (verdict: Runtime Error):
s = input()
if s = 'ABC':
	print('ARC')
elif s = 'ARC':
	print('ABC')

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

if s = 'ABC':
  print('ARC')
elif s = 'ARC':
  print('ABC')
Problem p02717 (python)

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

a1 = b
b1 = a

c1 = a1
a2 = c

print(a2,b1,c1)

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

x = [n-k*i for i in range(n//k+2)]
x[-1] = abs(x[-1])
print(min(x))
Problem p02718 (python)

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

x = max(a)
s = 0
for i in a:
    s += i
y = [l for l in a if l >=s/4/m]
if len(y) >=m:
    print('Yes')
else:
    print('No')

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

a = list(map(int,input().split()))

b = [b for b in a if b >= 1/4/m]

if len(b)>= m:
	print(‘Yes’)
else:
	print(‘No’)
Problem p02765 (python)

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

if n >= 10:
  print(r)

else:
  print(r+100*(10-n))

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

if n > =10:
  print(r)

else:
  print(r-100*(10-n))
Problem p02811 (python)

Fixed submission:
k,x = map(int,input().split())

if  500*k >= x:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
k,x = map(int,input().spleit())

if x =< k*500:
  print('Yes')

else:
  print('No')

Buggy submission (verdict: Runtime Error):
k,x = map(int,input().spleit())

if x <= k*500:
    print('Yes')

else:
    print('No')

Buggy submission (verdict: Runtime Error):
k,x = map(int,input().spleit())

if x =< k*500:
    print('Yes')

else:
    print('No')
Problem p02582 (python)

Fixed submission:
s= input()

if 'RRR' in s:
    print(3)
    

elif 'RR' in s:
    print(2)
    
elif 'R' in s:
    print(1)
else:
    print(0)

Buggy submission (verdict: Runtime Error):
for r in S:
  if rrr in S:
    return(3)
  elif rr in S:
    return(2)
  elif: r in S:
    return(1)
  else:
    return(0)
Problem p03777 (python)

Fixed submission:
a,b=input().split()
if a == "H":
    if b == "H":
        print("H")
    else:
        print("D")
if a == "D":
    if b == "H":
        print("D")
    else:
        print("H")

Buggy submission (verdict: Runtime Error):
a,b=input().split()
if a == H:
    if b == H:
        print("H")
    else:
        print("D")
if a == D:
    if b == H:
        print("D")
    else:
        print("H")
Problem p02910 (python)

Fixed submission:
S = input()

odd = S[::2]
even = S[1::2]

if 'L' in odd or 'R' in even:
    print('No')
else:
    print('Yes')

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

odd = S[::2]
even = [1::2]

if 'L' in odd or 'R' in even:
    print('No')
else:
    print('Yes')
Problem p02658 (python)

Fixed submission:
import sys
from functools import reduce


def input():
    return sys.stdin.readline()[:-1]


def mm(a, b):
	ans = a*b
	if ans > 10**18:
		return 0
	else:
		return a*b

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

if 0 in A:
	print(0)
else:
	ans = reduce(mm, A)
	
	if ans == 0:
		print(-1)
	else:
		print(ans)

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

def input():
    return sys.stdin.readline()[:-1]


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

ans = np.prod(A)
if ans > 10**18:
	print(-1)
else:
	print(ans)
Problem p02660 (python)

Fixed submission:
import sys

def input():
    return sys.stdin.readline()[:-1]

N = int(input())

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

def func1(lst, value):
    return [i for i, x in enumerate(lst) if x <= value]

if N == 1:
	print(0)
else:
	
	ans_ = factorization(N)
	nums = []
	index_list = []
	
	ans = 0
	for i in range(1, 100):
		ans += i
		index_list.append(ans)
		
	for a in ans_:
		#nums.append(int(format(a[1], 'b')))
		nums.append(a[1])
		
		#print(nums)
			
	ans = 0
	for i in nums:
		index = func1(index_list, i)
		#print(max(index)+1)
		ans += max(index)+1
	
	print(ans)

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


def input():
    return sys.stdin.readline()[:-1]

N = int(input())

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

def func1(lst, value):
    return [i for i, x in enumerate(lst) if x <= value]


ans_ = np.array(factorization(N))
nums = []
index_list = []

ans = 0
for i in range(1, 100):
	ans += i
	index_list.append(ans)

for a in ans_:
	#nums.append(int(format(a[1], 'b')))
	nums.append(a[1])
	
ans = 0
for i in nums:
	index = func1(index_list, i)
	#print(max(index)+1)
	ans += max(index)+1
	
print(ans)
Problem p02755 (python)

Fixed submission:
import sys

def input():
    return sys.stdin.readline()[:-1]


A, B = map(int, input().split())

A_ = []
B_ = []
end = False
for i in range(1, 1001):
	if i*8//100 == A and i//10 == B:
		print(i)
		end = True
		break
	else:
		continue
if end:
	pass
else:
	print(-1)

Buggy submission (verdict: Runtime Error):
import sys


def input():
    return sys.stdin.readline()[:-1]


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


all_set, mod_ = divmod(N, (A+B))
#print(all_set, mod_)
if mod_ == 0:
	print(all_set*A)
elif mod_ - A >= 0:
	print(all_set*A + A)
else:
	print(all_set*A + mod_)
Problem p02780 (python)

Fixed submission:
import numpy as np

N, K = map(int, input().split())
P_exp = np.array([0] + [(1+i)/2 for i in map(int, input().split())])
E_sum = np.cumsum(P_exp)

print((E_sum[K:]-E_sum[:-K]).max())

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

N, K = map(int, input().split())
P_exp = np.array([(1+i)/2 for i in map(int, input().split())])
E_sum = np.cumsum(P_exp)

print((E_sum[K:]-E_sum[:-K]).max())
Problem p02675 (python)

Fixed submission:
data = ['pon','pon','hon','bon','hon','hon','pon','hon','pon','hon']
n = int(input()) % 10
print(data[n])

Buggy submission (verdict: Runtime Error):
import math

A,B,H,M = map(int,input().split())
angH = 30.0*H+0.5*M
angM = 6.0*M
angD = abs(angH-angM)

if angD > 180.0:
    angD = 360.0-angD
cosD = math.cos(math.radians(angD))
ans2 = A*A + B*B - 2*A*B *cosD
ans = math.sqrt(ans2)
print(ans)
Problem p02850 (python)

Fixed submission:
import sys
def coloring2(color,p):
    global K
    dcolor = 1
    for c in Data[p]:
        if dcolor == color:
            dcolor += 1
        s = str(p)+'_'+str(c)
        Edge[s] = dcolor 
        coloring2(dcolor,c)
        dcolor += 1
    K = max(K,dcolor-1)

sys.setrecursionlimit(10 ** 9)
N = int(input())
Data = [ [] for _ in range(N+1) ]
Edge = {} 
Edge2 = []
for _ in range(N-1):
    a,b = map(int,input().split())
    Data[a].append(b)
    s = str(a)+'_'+str(b)
    Edge[s] = 0
    Edge2.append([a,b])

K = 0
coloring2(0,1)
print(K)
for [a,b] in Edge2:
    s = str(a)+'_'+str(b)
    print(Edge[s])

Buggy submission (verdict: Runtime Error):
def coloring2(color,p):
    global K
    dcolor = 1
    for c in Data[p]:
        if dcolor == color:
            dcolor += 1
        s = str(p)+'_'+str(c)
        Edge[s] = dcolor 
        coloring2(dcolor,c)
        dcolor += 1
    K = max(K,dcolor-1)

N = int(input())
Data = [ [] for _ in range(N+1) ]
Edge = {} 
Edge2 = []
for _ in range(N-1):
    a,b = map(int,input().split())
    Data[a].append(b)
    s = str(a)+'_'+str(b)
    Edge[s] = 0
    Edge2.append([a,b])

K = 0
coloring2(0,Edge2[0][0])
print(K)
for [a,b] in Edge2:
    s = str(a)+'_'+str(b)
    print(Edge[s])

Buggy submission (verdict: Runtime Error):
def coloring2(color,p):
    global K
    dcolor = 1
    for c in Data[p]:
        if dcolor == color:
            dcolor += 1
        s = str(p)+'_'+str(c)
        Edge[s] = dcolor 
        coloring2(dcolor,c)
        dcolor += 1
    K = max(K,dcolor-1)

N = int(input())
Data = [ [] for _ in range(N+1) ]
Edge = {} 
Edge2 = []
for _ in range(N-1):
    a,b = map(int,input().split())
    Data[a].append(b)
    s = str(a)+'_'+str(b)
    Edge[s] = 0
    Edge2.append([a,b])
print(Data)

K = 0
coloring2(0,Edge2[0][0])
print(K)
for [a,b] in Edge2:
    s = str(a)+'_'+str(b)
    print(Edge[s])

Buggy submission (verdict: Runtime Error):
def coloring2(color,p):
    global K
    dcolor = 1
    for c in Data[p]:
        if dcolor == color:
            dcolor += 1
        s = str(p)+'_'+str(c)
        Edge[s] = dcolor 
        coloring2(dcolor,c)
        dcolor += 1
    K = max(K,dcolor-1)

N = int(input())
Data = [ [] for _ in range(N+1) ]
Edge = {} 
Edge2 = []
for _ in range(N-1):
    a,b = map(int,input().split())
    Data[a].append( b )
    s = str(a)+'_'+str(b)
    Edge[s] = 0
    Edge2.append([a,b])
K = 0
coloring2(0,Edge2[0][0])
print(K)
for [a,b] in Edge2:
    s = str(a)+'_'+str(b)
    print(Edge[s])
Problem p02995 (python)

Fixed submission:
def gcd(a, b):
    if b > a:
        _ = b
        b = a
        a = _
    while b:
        a, b = b, a % b
    return a

A,B,C,D = map(int, input().split())

GcdCD = gcd(C,D)
LcmCD = (C*D)//GcdCD

s1 = B- ((B//C)+(B//D)-(B//LcmCD))
s2 = (A-1)-(((A-1)//C)+((A-1)//D)-((A-1)//LcmCD))
if s2 < 0:
    s2 = 0
print(s1-s2)

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

GcdCD = math.gcd(C,D)
LcmCD = (C*D)//GcdCD

s1 = B- ((B//C)+(B//D)-(B//LcmCD))
s2 = (A-1)-(((A-1)//C)+((A-1)//D)-((A-1)//LcmCD))
if s2 < 0:
    s2 = 0
print(s1-s2)
Problem p03035 (python)

Fixed submission:
#!/usr/bin/python3
A,B = map(int,input().split())
x = 0
if A >= 13:
    x = B
elif 6 <= A and A <= 12:
    x = B//2
else:
    x = 0
print(x)

Buggy submission (verdict: Runtime Error):
r,D,x2000 = map(int,raw_input().split())
xi = x2000
for i in range(1,11):
    xi = r * xi - D
    print(xi)

Buggy submission (verdict: Runtime Error):
r,D,x2000 = map(int,input().split())
xi = x2000
for i in range(1,11):
    xi = r * xi - D
    print(xi)
Problem p03044 (python)

Fixed submission:
import sys
def dfs(n,c):
    if Ans[n] == -1:
        Ans[n] = c
        for m,w in Data[n]:
            if w % 2 == 0:
                dfs(m,c)
            else:
                dfs(m,1-c)
    elif Ans[n] == c:
        return
    else:
        return

sys.setrecursionlimit(100000)
N = int(input())
Data = []
Ans  = [-1] * N
for i in range(N):
    Data.append([])
for i in range(N-1):
    u,v,w = map(int,input().split())
    Data[u-1].append([v-1,w])
    Data[v-1].append([u-1,w])
dfs(0,0)

for a in Ans:
    print(a)

Buggy submission (verdict: Runtime Error):
import sys
def dfs(n,c):
    if Ans[n] == -1:
        Ans[n] = c
        for m,w in Data[n]:
            if w % 2 == 0:
                dfs(m,c)
            else:
                dfs(m,1-c)
    elif Ans[n] == c:
        return
    else:
        return

sys.setrecursionlimit(10000)
N = int(input())
Data = []
Ans  = [-1] * N
for i in range(N):
    Data.append([])
for i in range(N-1):
    u,v,w = map(int,input().split())
    Data[u-1].append([v-1,w])
    Data[v-1].append([u-1,w])
dfs(0,0)

for a in Ans:
    print(a)

Buggy submission (verdict: Runtime Error):
def dfs(n,c):
    if Ans[n] == -1:
        Ans[n] = c
        for m,w in Data[n]:
            if w % 2 == 0:
                dfs(m,c)
            else:
                dfs(m,1-c)
    elif Ans[n] == c:
        return
    else:
        return

N = int(input())
Data = []
Ans  = [-1] * N
for i in range(N):
    Data.append([])
for i in range(N-1):
    u,v,w = map(int,input().split())
    Data[u-1].append([v-1,w])
    Data[v-1].append([u-1,w])
dfs(0,0)

for a in Ans:
    print(a)
Problem p03128 (python)

Fixed submission:
N,M = map(int,input().split())
AList = list(map(int,input().split()))
AList.sort(reverse=True)
NList=[0,2,5,5,4,5,6,3,7,6]
CList=[]
minnum = (-1)*(10**10)
dp = [0]*(N+1)

for a in AList:
    u = NList[a]
    if (u in CList) == False:
        CList.append(u)

dp[0] = 0
for n in range(1,N+1):
    max1 = minnum
    for c in CList:
        if c <= n:
            if dp[n-c] == minnum:
                num = minnum
            else:
                num = dp[n-c]+1
            if max1 < num:
                max1 = num
    dp[n] = max1
keta = dp[N]
s = ''
nn = N
for n in range(keta):
    for a in AList:
        if nn >= NList[a] and dp[nn-NList[a]] == dp[nn]-1:
            s += str(a)
            nn -= NList[a]
            break
print(s)

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
AList = list(map(int,input().split()))
AList.sort(reverse=True)
NList=[0,2,5,5,4,5,6,3,7,6]
CList=[]
minnum = (-1)*(10**10)
dp = [0]*(N+1)

for a in AList:
    u = NList[a]
    if (u in CList) == False:
        CList.append(u)

dp[0] = 0
for n in range(1,N+1):
    max1 = minnum
    for c in CList:
        if c <= n:
            if dp[n-c] == minnum:
                num = minnum
            else:
                num = dp[n-c]+1
            if max1 < num:
                max1 = num
    dp[n] = max1

keta = dp[N]
s = ''
nn = N
for n in range(keta):
    for a in AList:
        if dp[nn-NList[a]] == dp[nn]-1:
            s += str(a)
            nn -= NList[a]
            break
print(s)
Problem p03240 (python)

Fixed submission:
import sys
N = int(input())
Data = []
for _ in range(N):
    x,y,h = map(int,input().split())
    Data.append([x,y,h])

Data.sort(key=lambda x:x[2],reverse=True)

for cx in range(101):
    for cy in range(101):
        found = True
        ans   = -1
        for i in range(N):
            x,y,h = Data[i]
            if i == 0:
                # h != 0
                ans = h + abs(x-cx)+abs(y-cy)
            else: 
                diff = ans - abs(x-cx)-abs(y-cy)
                if  diff < 0:
                    if h != 0:
                        found = False
                        break
                else: 
                    if diff != h:
                        found = False
                        break
        if found == True:
            print( '{} {} {}'.format(cx,cy,ans))
            sys.exit()

Buggy submission (verdict: Runtime Error):
import sys
N = int(input())
Data = []
for _ in range(N):
    x,y,h = map(int,input().split())
    if h != 0:
        Data.append([x,y,h])

Data.sort(key=lambda x:x[2],reverse=True)

for cx in range(101):
    for cy in range(101):
        found = True
        ans   = -1
        for i in range(0,N):
            x,y,h = Data[i]
            if i == 0:
                ans = h + abs(x-cx)+abs(y-cy)
            else:
                ph = h + abs(x-cx)+abs(y-cy)
                if ans != ph:
                    found = False
                    break
        if found == True:
            print( '{} {} {}'.format(cx,cy,ans))
            sys.exit()
Problem p03263 (python)

Fixed submission:
H,W = map(int,input().split())
Data = []
for _ in range(H):
    List = list(map(int,input().split()))
    Data.append(List)
Ans = []
for i in range(H-1):
    for j in range(W):
        if Data[i][j] % 2 != 0:
            Data[i][j] -= 1
            Data[i+1][j] += 1
            Ans.append([i,j,i+1,j])
for j in range(W-1):
    if Data[H-1][j] % 2 != 0:
        Data[H-1][j] -= 1
        Data[H-1][j+1] += 1
        Ans.append([H-1,j,H-1,j+1])

print(len(Ans))
for ans in Ans:
    print( "{} {} {} {}".format(ans[0]+1,ans[1]+1,ans[2]+1,ans[3]+1))

Buggy submission (verdict: Runtime Error):
H,W = map(int,input().split())
Data = []
for _ in range(H):
    List = list(map(int,input().split()))
    Data.append(List)
Ans = []
for i in range(H-1):
    for j in range(W):
        if Data[i][j] % 2 != 0:
            Data[i][j] -= 1
            Data[i+1][j] += 1
            Ans.append([i,j,i+1,j])
for j in range(W-1):
    if Data[H-1][j] % 2 != 0:
        Data[H-1][j] -= 1
        Data[H-1][j+1] += 1
        Ans.append([H-1,j,H-1,j+1])

print(len(Ans))
for ans in Ans:
    print( "{} {} {} {}".fo
Problem p03273 (python)

Fixed submission:
H,W = map(int,input().split())
Data1 = []

tbl = str.maketrans({'.':'0','#':'1'})
for _ in range(H):
    s = input().translate(tbl)
    s = list(map(int,list(s)))
    if sum(s) > 0:
        Data1.append(s)

dellist = []
for w in range(W):
    flag = False
    for data in Data1:
        if data[w] == 1:
            flag = True
            break
    if flag == False:
        dellist.append(w)

for i in range(len(dellist)-1,-1,-1):
    for data in Data1:
        data.pop(dellist[i])

for data in Data1:
    for i in range(len(data)):
        if data[i] == 0:
            print('.',end='')
        else:
            print('#',end='')
    print("")

Buggy submission (verdict: Runtime Error):
H,W = map(int,input().split())
Data1 = []

for _ in range(H):
    Data1.append(s)

hdata = {}
wdata = {}

for h in range(H):
    for w in range(W):
        if Data1[h][w] == '#':
            hdata.add(h)
            wdata.add(w)

for h in range(H):
    for w in range(W):
        if h in hdata or w in wdata:
            print(Data[h][w],end='')
Problem p03292 (python)

Fixed submission:
AList = list(map(int,input().split()))
AList.sort()
print(abs(AList[0]-AList[1])+abs(AList[2]-AList[1]))

Buggy submission (verdict: Runtime Error):
AList = list(map(int,input().split()))
AList.sort()
print(abs(AList[0]-AList[1])+abs(AList[2]-AList[1])
Problem p03362 (python)

Fixed submission:
import math
PrimeList = [2]

def calc_prime(N):
    for i in range(3,N+1,2):
        x = int(math.sqrt(i))+1
        j = 0
        prime = True
        while j < len(PrimeList) and PrimeList[j] <= x:
            if i % PrimeList[j] == 0:
                prime = False
                break
            j += 1
        if prime:
            PrimeList.append(i)

calc_prime(55555)
AnsList = []
for p in PrimeList:
    if p % 5 == 1:
        AnsList.append(p)

N = int(input())
for i in range(N):
    print(AnsList[i],end=' ')
print('')

Buggy submission (verdict: Runtime Error):
def calc_prime(N):
    for i in range(3,N+1,2):
        x = int(math.sqrt(i))+1
        j = 0
        prime = True
        while j < len(PrimeList) and PrimeList[j] <= x:
            if i % PrimeList[j] == 0:
                prime = False
                break
            j += 1
        if prime:
            PrimeList.append(i)

calc_prime(55555)
AnsList = []
for p in PrimeList:
    if p % 5 == 1:
        AnsList.append(p)

N = int(input())
for i in range(N):
    print(AnsList[i],end=' ')
print('')
Problem p03415 (python)

Fixed submission:
a1=input() 
a2=input() 
a3=input() 
print(a1[0]+a2[1]+a3[2])

Buggy submission (verdict: Runtime Error):
a1=input() 
a2=input() 
a3=input() 
rint(a1[0]+a2[1]+a3[2])
Problem p03633 (python)

Fixed submission:
def gcm(a,b):
    if a < b:
        a,b = b,a
    while True:
        if a % b == 0:
            return b
        else:
            a,b = b,a % b

def lcm(a,b):
    g = gcm(a,b)
    return a*b//g;

N = int(input())
Data = []
for _ in range(N):
    Data.append(int(input()))
ans = Data[0]
for i in range(1,N):
    ans = lcm(ans,Data[i])
print(ans)

Buggy submission (verdict: Runtime Error):
def gcm(a,b):
    if a < b:
        a,b = b,a
    while True:
        if a % b == 0:
            return b
        else:
            a,b = b,a % b

def lcm(a,b):
    g = gcm(a,b)
    return a*b//g;

N = int(input())
Data = []
for _ in range(N):
    Data.append(int(input()))
ans = Data[0]
for i in range(1,N):
    ans = lcm(ans,Data[i])
print(ans)
def gcm(a,b):
    if a < b:
        a,b = b,a
    while True:
        if a % b == 0:
            return b
        else:
            a,b = b,a % b

def lcm(a,b):
    g = gcm(a,b)
    return a*b//g;

N = int(input())
Data = []
for _ in range(N):
    Data.append(int(input()))
ans = Data[0]
for i in range(1,N):
    ans = lcm(ans,Data[i])
print(ans)