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

Fixed submission:
s=list(input())
out=[]
for i in range(len(s)):
  if s[i]=="1":
    out.append(s[i])
  if s[i]=="0":
    out.append(s[i])
  if len(out)!=0 and s[i]=="B":
    del(out[-1])
print("".join(out))

Buggy submission (verdict: Runtime Error):
s=list(input())
out=[]
for i in range(len(s)):
  if s[i]=="1":
    out.append(s[i])
  elif s[i]=="0":
    out.append(s[i])
  elif len(out)!=0:
    del(s[-1])
for i in range(len(out)):
  print(out[i])
Problem p04044 (python)

Fixed submission:
n,l=map(int,input().split())
moji=[]
for i in range(n):
  moji.append(input())
moji.sort()
print("".join(moji))

Buggy submission (verdict: Runtime Error):
n,l=map(int,input().split())
moji=[]
for i in range(n):
  moji.appned(input())
moji.sort()
print("".join(moji))
Problem p03076 (python)

Fixed submission:
times = [int(input()) for _ in range(5)]
fractions = [10 - t % 10 for t in times if t % 10 != 0]
if fractions:
    fraction = max(fractions)
else:
    fraction = 0
print(sum([(t - t % 10) + ((t % 10 + 9) // 10) * 10 for t in times]) - fraction)

Buggy submission (verdict: Runtime Error):
times = [int(input()) for _ in range(5)]
fraction = max([10 - t % 10 for t in times if t % 10 != 0])
if fraction == 10:
    fraction = 0
print(sum([(t - t % 10) + ((t % 10 + 9) // 10) * 10 for t in times]) - fraction)
Problem p03471 (python)

Fixed submission:
N, Y = [int(k) for k in input().split(' ') if k]
Y //= 1000
x = Y // 10
Y -= x * 10
y = Y // 5
Y -= y * 5
z = Y
if N < x + y + z:
	print(-1, -1, -1)
	exit()
d = N - x - y - z
for dx in range(min(d, x) + 1):
	nx = x - dx
	ny = y + 2 * dx
	nd = N - nx - ny - z
	dy = min(nd // 4, ny)
	ny = ny - dy
	nz = z + dy * 5
	if nx + ny + nz == N:
		print(nx, ny, nz)
		exit()
print(-1, -1, -1)

Buggy submission (verdict: Runtime Error):
N, Y = [int(k) for k in input().split(' ') if k]
Y //= 1000
x = Y // 10
Y -= x * 10
y = Y // 5
Y -= y * 5
z = Y
if N < x + y + z:
	print(-1, -1, -1)
	exit()
checked = []
def find(nx, ny, nz):
	if nx + ny + nz > N:
		return
	if find(nx, ny, nz):
		return
	if nx + ny + nz == N:
		print(nx, ny, nz)
		exit()
	if nx > 0:
		find(nx - 1, ny + 2, nz)
	if ny > 0:
		find(nx, ny - 1, nz + 5)
	checked.append((nx, ny, nz))
find(x, y, z)
print(-1, -1, -1)

Buggy submission (verdict: Runtime Error):
N, Y = [int(k) for k in input().split(' ') if k]
Y //= 1000
x = Y // 10
Y -= x * 10
y = Y // 5
Y -= y * 5
z = Y
if N < x + y + z:
	print(-1, -1, -1)
	exit()
checked = []
def find(a, b, c):
	left = 0
	right = len(checked) - 1
	while left != right:
		if checked[left]
def find(nx, ny, nz):
	if nx + ny + nz > N:
		return
	if find(nx, ny, nz):
		return
	if nx + ny + nz == N:
		print(nx, ny, nz)
		exit()
	if nx > 0:
		find(nx - 1, ny + 2, nz)
	if ny > 0:
		find(nx, ny - 1, nz + 5)
	checked.append((nx, ny, nz))
find(x, y, z)
print(-1, -1, -1)
Problem p03078 (python)

Fixed submission:
X,Y,Z,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

import itertools
AB = [a + b for a, b in itertools.product(A,B)]
AB.sort(reverse=True)
ABC = [ab + c for ab, c in itertools.product(AB[:3000],C)]
ABC.sort(reverse=True)
for i in range(K):
    print(ABC[i])

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

X, Y, Z, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

cnt = 0
result = [0]*200000
for x in range(X):
    for y in range(Y):
        if x * y > K: break
        for z in range(Z):
            if x * y * z > K: break
            result[cnt] = A[x]+B[y]+C[z]
            cnt += 1
result.sort(reverse=True)
for i in range(K):
    print(result[i])

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

X, Y, Z, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

cnt = 0
result = [0]*(X*Y*Z)
for x in range(X):
    for y in range(Y):
        if x * y > K: break
        for z in range(Z):
            if x * y * z > K: break
            result[cnt] = A[x]+B[y]+C[z]
            cnt += 1
result.sort(reverse=True)
for i in range(K):
    print(result[i])

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

X, Y, Z, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

cnt = 0
result = [0]*X*Y*Z
for x in range(X):
    for y in range(Y):
        if x * y > K: break
        for z in range(Z):
            if x * y * z > K: break
            result[cnt] = A[x]+B[y]+C[z]
            cnt += 1
result.sort(reverse=True)
for i in range(K):
    print(result[i])

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

X, Y, Z, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

cnt = 0
result = [0]*K
for x in range(X):
    for y in range(Y):
        if x * y > K: break
        for z in range(Z):
            if x * y * z > K: break
            result[cnt] = A[x]+B[y]+C[z]
            cnt += 1
result.sort(reverse=True)
for i in range(K):
    print(result[i])
Problem p03361 (python)

Fixed submission:
def main():
    input = sys.stdin.readline
    try:
        H,W = map(int,input().split())
        s = [list(input()) for _ in range(H)]
        dir4 = ((0, 1), (0, -1), (1, 0), (-1, 0))
        for i in range(H):
            for j in range(W):
                if s[i][j] == ".": continue
                cnt = 0
                for d in dir4:
                    nx = i + d[0]
                    ny = j + d[1]
                    if not (0 <= nx < H): continue
                    if not (0 <= ny < W): continue
                    if s[nx][ny] == "#": cnt += 1
                if cnt == 0:
                    print("No")
                    exit()
        print("Yes")
        
    finally:
        input = None

import sys; sys.setrecursionlimit(50000)
if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
        H,W = map(int,input().split())
        s = [list(input()) for _ in range(H)]
        dir4 = ((0, 1), (0, -1), (1, 0), (-1, 0))
        for i in range(H):
            for j in range(W):
                if s[i][j] == ".": continue
                cnt = 0
                for d in dir4:
                    nx = i + d[0]
                    ny = j + d[1]
                    if not (0 <= nx < H): continue
                    if not (0 <= ny < W): continue
                    if s[nx][ny] == "#": cnt += 1
                if cnt == 0:
                    print("No")
                    exit()
        print("Yes")
Problem p03449 (python)

Fixed submission:
def main():
    input = sys.stdin.readline
    try:
        N = int(input())
        A1 = list(map(int, input().split()))
        A2 = list(map(int, input().split()))
        
        if N == 1:
            print(A1[0] + A2[0])
            return
        dp = [[0]*2 for _ in range(N-1)]
        dp[0][0] = A1[0] + A1[1]
        dp[0][1] = A1[0] + A2[0]

        for i in range(1, N - 1):
            dp[i][0] = dp[i-1][0] + A1[i+1]
            dp[i][1] = max(dp[i-1][0], dp[i-1][1]) + A2[i]
        
        ans = max(dp[N-2][0], dp[N-2][1]) + A2[N-1]
        print(ans)
        
    finally:
        input = None

import sys; sys.setrecursionlimit(50000)
if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
def main():
    input = sys.stdin.readline
    input = open("stdin.txt").readline
    try:
        N = int(input())
        A1 = list(map(int, input().split()))
        A2 = list(map(int, input().split()))
        
        if N == 1:
            print(A1[0] + A2[0])
            return
        dp = [[0]*2 for _ in range(N-1)]
        dp[0][0] = A1[0] + A1[1]
        dp[0][1] = A1[0] + A2[0]

        for i in range(1, N - 1):
            dp[i][0] = dp[i-1][0] + A1[i+1]
            dp[i][1] = max(dp[i-1][0], dp[i-1][1]) + A2[i]
        
        ans = max(dp[N-2][0], dp[N-2][1]) + A2[N-1]
        print(ans)
        
    finally:
        input = None

import sys; sys.setrecursionlimit(50000)
if __name__ == "__main__":
    main()
Problem p03069 (python)

Fixed submission:
n = int(input())
a = input()
s = a

i = 0
while i<len(s) and s[i] == '.':
  i+=1
j = n-1
while j>=0 and s[j] == '#':
  j-=1

s = s[i:j+1]
r = min(s.count('#'), s.count('.'))

w = s.count('.')
b = 0
c = 0
for i in range(len(s)):
  if s[i] == '#':
    b += 1
  else:
    w -= 1
  r = min(r, w+b)

print(r)

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

i = 0
while i<len(s) and s[i] == '.':
  i+=1
j = n-1
while i>=0 and s[j] == '#':
  j-=1

s = s[i:j+1]
print(min(s.count('#'),s.count('.')))

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

i = 0
while i<len(s) and s[i] == '.':
  i+=1
j = n-1
while i>=0 and s[j] == '#':
  j-=1

s = s[i:j]
print(min(s.count('#'),s.count('.')))
Problem p03231 (python)

Fixed submission:
import fractions

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

l = n * m // fractions.gcd(n,m)

a = l // n
b = l // m

for i in range(0, l, a*b):
    if s[i // a] != t[i // b]:
        print(-1)
        break
else:
    print(l)

Buggy submission (verdict: Runtime Error):
import math

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

l = n * m // math.gcd(n,m)

a = l // n
b = l // m

for i in range(0, l, a*b):
    if s[i // a] != t[i // b]:
        print(-1)
        break
else:
    print(l)
Problem p03145 (python)

Fixed submission:
ab, bc, ca = list(map(int, input().split()))
 
print(int(ab * bc / 2))

Buggy submission (verdict: Runtime Error):
ab, bc, ca = list(map(int, input().split()))

print(int(ab * bc / 2)
Problem p03262 (python)

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

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

def gcd(la, lb):
    if la < lb:
        tmp = a
        la = lb
        lb = tmp

    r = la % lb

    while r != 0:
        la = lb
        lb = r
        r = la % lb

    return lb

ans = 1000000001
for i in range(n):
    v = abs(x - a[i])

    if v < ans:
        ans = v

    g = gcd(v, ans)
    if g < ans:
        ans = g

print(ans)

Buggy submission (verdict: Runtime Error):
import math

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

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

ans = 1000000001
for i in range(n):
    v = abs(x - a[i])

    if v < ans:
        ans = v

    gcd = math.gcd(v, ans)
    if gcd < ans:
        ans = gcd

print(ans)
Problem p03280 (python)

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

print(a[0] * a[1] - (1 * a[0]) - (1 * a[1]) + 1)

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

print(a[0] * a[1] - (1 * a[0]) - (1 * a[1
Problem p03284 (python)

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

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
A = N % K
if A == 0:
    print(0)
else:
    else(1)
Problem p03110 (python)

Fixed submission:
N = int(input())
btc = 380000
ans = 0
for i in range(N):
    x,u = map(str,input().split())
    x = float(x)
    if u=='BTC':
        x *= btc
    ans += x
print(ans)

Buggy submission (verdict: Runtime Error):
N=int(input())
btc=380000
ans=0
for i in range(N):
  x,u=map(str,input().split())
  x = int(x)
  if u=='BTC':
    x *= btc
  ans += x
print(ans)
Problem p03150 (python)

Fixed submission:
S = input()
l = len(S)
OK = False
if S[0:7]=='keyence':
    OK = True
elif S[l-7:]=='keyence':
    OK = True
elif S[l-6:]=='eyence' and S[0]=='k':
    OK = True
elif S[l-5:]=='yence' and S[:2]=='ke':
    OK = True
elif S[l-4:]=='ence' and S[:3]=='key':
    OK = True
elif S[l-3:]=='nce' and S[:4]=='keye':
    OK = True
elif S[l-2:]=='ce' and S[:5]=='keyen':
    OK = True
elif S[l-1:]=='e' and S[:6]=='keyenc':
    OK = True
else:
    OK = False
print('YES' if OK else 'NO')

Buggy submission (verdict: Runtime Error):
if S[0:7]=='keyence':
    OK = True
elif S[l-7:]=='keyence':
    OK = True
elif S[l-6:]=='eyence' and S[0]=='k':
    OK = True
elif S[l-5:]=='yence' and S[:2]=='ke':
    OK = True
elif S[l-4:]=='ence' and S[:3]=='key':
    OK = True
elif S[l-3:]=='nce' and S[:4]=='keye':
    OK = True
elif S[l-2:]=='ce' and S[:5]=='keyen':
    OK = True
elif S[l-1:]=='e' and S[:6]=='keyenc':
    OK = True
else:
    OK = False
print('YES' if OK else 'NO')
Problem p03215 (python)

Fixed submission:
N,K = map(int,input().split())
a = list(map(int,input().split()))
s = []
for i in range(N):
    total = 0
    for j in range(i,N):
        total += a[j]
        s.append(total)
s.sort(reverse=True)
m,n = 1,1
while s[0]>=m:
    n += 1
    m *= 2
for i in range(n)[::-1]:
    t = list(filter(lambda x:x-m>=0,s))
    l = len(t)
    if l>=K:
        break
    else:
        m //= 2
n = i+1
for i in range(n):
    u = list(filter(lambda x:(x//m)%2==1,t))
    l = len(u)
    if l>=K:
        t = u[:]
        if l==K:
            break
    m //= 2
ans = t[0]
for i in range(1,K):
    ans &= t[i]
print(ans)

Buggy submission (verdict: Runtime Error):
N,K = map(int,input().split())
a = list(map(int,input().split()))
s = []
for i in range(N):
    total = 0
    for j in range(i,N):
        total += a[j]
        s.append(total)
s.sort(reverse=True)
m,n = 1,1
while s[0]>=m:
    n += 1
    m *= 2
for i in range(n)[::-1]:
    subs = list(filter(lambda x:x-m>=0,s))
    l = len(subs)
    if l>=K:
        break
    else:
        m //= 2
s = subs[:]
for i in range(n+1):
    subs = list(filter(lambda x:(x//m)%2==1,s))
    l = len(subs)
    if l>=K:
        s = subs[:]
        if l==K:
            break
    m //= 2
ans = s[0]
for i in range(1,K):
    ans &= s[i]
print(ans)

Buggy submission (verdict: Runtime Error):
N,K = map(int,input().split())
a = list(map(int,input().split()))
s = []
for i in range(N):
    total = 0
    for j in range(i,N):
        total += a[j]
        s.append(total)
s.sort(reverse=True)
n = 0
while s[0]>=2**n:
    n += 1
l,m = 0,2**n
for i in range(n)[::-1]:
    subs = list(filter(lambda x:x-(2**i)>=0,s))
    l = len(subs)
    if l>=K:
        s = subs[:]
    else:
        m //= 2
for i in range(n+1):
    subs = list(filter(lambda x:x%(2**m)==1,s))
    l = len(subs)
    if l>=K:
        s = subs[:]
        if l==K:
            break
    m //= 2
ans = s[0]
for i in range(1,K):
    ans &= s[i]
print(ans)
Problem p03231 (python)

Fixed submission:
def gcd(a, b):
    if b==0:
        return a
    else:
        return gcd(b, a%b)
N,M = map(int,input().split())
l = gcd(N,M)
S,T = input(),input()
OK = True
for i in range(l):
    ns = i*(N//l)
    nt = i*(M//l)
    if not S[ns]==T[nt]:
        OK = False
print((N*M)//l if OK else -1)

Buggy submission (verdict: Runtime Error):
def gcd(a, b):
    if b==0:
        return a
    else:
        return gcd(b, a%b)
N,M = map(int,input().split())
S,T = input(),input()
lcm = N*M//gcd(N,M)
s = ['*']*lcm
for i in range(N):
    n = i*(lcm//N)
    if s[n]=='*' or s[n]==S[i]:
        s[n] = S[i]
OK = True
for i in range(M):
    n = i*(lcm//M)
    if not (s[n]=='*' or s[n]==T[i]):
        OK = False
print(lcm if OK else -1)

Buggy submission (verdict: Runtime Error):
def gcd(a, b):
    if b==0:
        return a
    else:
        return gcd(b, a%b)

N,M = map(int,input().split())
S,T = input(),input()
lcm = N*M//gcd(N,M)
s = ['*']*lcm
for i in range(N):
    n = 0 if i==0 else i*(len(s)//N)
    if s[n]=='*' or s[n]==S[i]:
        s[n] = S[i]
OK = True
for i in range(M):
    n = 0 if i==0 else i*(len(s)//M)
    if not (s[n]=='*' or s[n]==T[i]):
        OK = False
print(lcm if OK else -1)
Problem p03262 (python)

Fixed submission:
def gcd(a,b):
    while b:
        a,b = b,a%b
    return a
N,X = map(int,input().split())
x = list(map(int,input().split()))
x.append(X)
x.sort()
ans = x[1]-x[0]
for i in range(N):
    ans = gcd(ans,x[i+1]-x[i])
print(ans)

Buggy submission (verdict: Runtime Error):
import math
N,X = map(int,input().split())
x = list(map(int,input().split()))
x.append(X)
x.sort()
ans = x[1]-x[0]
for i in range(N):
    ans = math.gcd(ans,x[i+1]-x[i])
print(ans)

Buggy submission (verdict: Runtime Error):
from math import gcd
N,X = map(int,input().split())
x = list(map(int,input().split()))
x.append(X)
x.sort()
ans = x[1]-x[0]
for i in range(N-1):
    ans = gcd(ans,x[i+1]-x[i])
print(ans)

Buggy submission (verdict: Runtime Error):
from math import gcd
N,X = map(int,input().split())
x = list(map(int,input().split()))
x.append(X)
x.sort()
ans = x[1]-x[0]
for i in range(N-1):
    ans = gcd(ans,x[i+1]-x[i])
print(ans)
Problem p03361 (python)

Fixed submission:
H,W = map(int,input().split())
s = [input() for i in range(H)]
dx=[0,-1,1,0]
dy=[1,0,0,-1]
flag = True
for i in range(H):
    for j in range(W):
        if s[i][j]=='#':
            cnt = 0
            for k in range(4):
                if 0<=j+dx[k] and j+dx[k]<W and 0<=i+dy[k] and i+dy[k]<H:
                    if s[i+dy[k]][j+dx[k]]=='#':
                        cnt += 1
            if cnt==0:
                flag=False
print('Yes' if flag else 'No')

Buggy submission (verdict: Runtime Error):
H,W = map(int,input().split())
s = [input() for i in range(H)]
dx=[0,-1,1,0]
dy=[1,0,0,-1]
flag = True
for i in range(W):
    for j in range(H):
        if s[i][j]=='#':
            cnt = 0
            for k in range(4):
                if 0<=j+dx[k] and j+dx[k]<H and 0<=i+dy[k] and i+dy[k]<W:
                    if s[i+dy[k]][j+dx[k]]=='#':
                        cnt += 1
            if cnt==0:
                flag=False
print('Yes' if flag else 'No')

Buggy submission (verdict: Runtime Error):
H,W = map(int,input().split())
s = [input() for i in range(H)]
dx=[0,-1,1,0]
dy=[1,0,0,-1]
flag = True
for i in range(W):
    for j in range(H):
        if s[i][j]=='#':
            cnt = 0
            for k in range(4):
                if 0<=j+dx[k] and j+dx[k]<W and 0<=i+dy[k] and i+dy[k]<H:
                    if s[i+dy[k]][j+dx[k]]=='#':
                        cnt += 1
            if cnt==0:
                flag=False
print('Yes' if flag else 'No')
Problem p03386 (python)

Fixed submission:
A,B,K = map(int,input().split())
ans = []
for i in range(A,A+K):
    if i <= B:
        ans.append(i)
for i in range(B-K+1,B+1):
    if not i in ans and A <= i:
        ans.append(i)
for i in ans:
    print(i)

Buggy submission (verdict: Runtime Error):
A,B,K = map(int,input().split())
ans = []
for i in range(A,A+K):
    if i <= B:
        ans.append(i)
for i in range(B-K+1,B+1):
    if not i in ans and A <= i:
        ans.append(i)
for i in ans:
Problem p03607 (python)

Fixed submission:
n = int(input())
ans = set() 

for i in range(n):
    a = int(input())
    if a in ans:
        ans.remove(a)
    else:
        ans.add(a)
print(len(ans))

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

for i in range(n):
    a = int(input())
    if a in ans:
        ans.remove(a)
    else:
        ans.add(a)
print(len(ans))
Problem p03659 (python)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
s = sum(a)
ans = float("inf")
x = 0

for i in range(n-1):
    x += a[i]
    ans = min(ans,abs(s-2*x))

print(ans)

Buggy submission (verdict: Runtime Error):
def search(ans, s, ar, si = 0, ari = 0):
    if si+ari == n:
        if not(ari == 0) and not(si == 0):
            ans.append(abs(sum(s)-sum(ar)))
        return

    s.append(a[si+ari])
    search(ans,s,ar,si+1,ari)
    s.pop()

    ar.append(a[si+ari])
    search(ans,s,ar,si,ari+1)
    ar.pop()

n = int(input())
a = list(map(int,input().split()))
ans = []
s = []
ar = []
search(ans,s,ar)
print(min(ans))
Problem p03722 (python)

Fixed submission:
INF = float('inf')
N,M = map(int,input().split())
edge = []
d = [INF]*N
d[0] = 0
negative = [False for i in range(N)]
for i in range(M):
    a,b,c = map(int,input().split())
    edge.append([a-1,b-1,-c])

for i in range(N):
    for j in range(M):
        if d[edge[j][0]]==INF:
            continue
        d[edge[j][1]] = min(d[edge[j][1]],d[edge[j][0]]+edge[j][2])

ans = d[N-1]

for i in range(N):
    for j in range(M):
        if d[edge[j][0]]==INF:
            continue
        if d[edge[j][1]]>d[edge[j][0]]+edge[j][2]:
            d[edge[j][1]]=d[edge[j][0]]+edge[j][2]
            negative[edge[j][1]] = True
        if negative[edge[j][0]]:
            negative[edge[j][1]] = True
print('inf' if negative[N-1] else -ans)

Buggy submission (verdict: Runtime Error):
INF = float('inf')
N,M = map(int,input().split())
edge = []
d = [INF]*N
d[0] = 0
negative = [False for i in range(N)]
for i in range(M):
    a,b,c = map(int,input().split())
    edge.append([a-1,b-1,-c])

for i in range(N):
    for j in range(M):
        if d[edge[j][0]]==INF:
            continue
        d[edge[j][1]] = min(d[edge[j][1]],d[edge[j][0]]+edge[j][2])

ans = d[N-1]

for i in range(N):
    for j in range(M):
        if d[j]==INF:
            continue
        if d[edge[j][1]]>d[edge[j][0]]+edge[j][2]:
            d[edge[j][1]]=d[edge[j][0]]+edge[j][2]
            negative[edge[j][1]] = True
        if negative[edge[j][0]]:
            negative[edge[j][1]] = True
print('inf' if negative[N-1] else -ans)
Problem p03732 (python)

Fixed submission:
N,W = map(int,input().split())
w_in, v = map(int,input().split())
table = [[] for i in range(4)]
table[0].append(v)
for i in range(N-1):
    w, v = map(int,input().split())
    table[w-w_in].append(v)
for i in range(4):
    table[i].sort(reverse=True)
    for j in range(len(table[i])-1):
            table[i][j+1] += table[i][j]
    table[i].insert(0,0)
ans = 0
for i in range(len(table[0])):
    for j in range(len(table[1])):
        for k in range(len(table[2])):
            for l in range(len(table[3])):
                if w_in*i+(w_in+1)*j+(w_in+2)*k+(w_in+3)*l <= W:
                    ans = max(ans, table[0][i]+table[1][j]+table[2][k]+table[3][l])
print(ans)

Buggy submission (verdict: Runtime Error):
N,W = map(int,input().split())
w_in, v = map(int,input().split())
table = [[] for i in range(4)]
table[0].append(v)
for i in range(N-1):
    w, v = map(int,input().split())
    table[w-w_in].append(v)
for i in range(N):
    table[i].sort(reverse=True)
    for j in range(len(table[i])-1):
            table[i][j+1] += table[i][j]
    table[i].insert(0,0)
ans = 0
for i in range(len(table[0])):
    for j in range(len(table[1])):
        for k in range(len(table[2])):
            for l in range(len(table[3])):
                if w_in*i+(w_in+1)*j+(w_in+2)*k+(w_in+3)*l <= W:
                    ans = max(ans, table[0][i]+table[1][j]+table[2][k]+table[3][l])
print(ans)
Problem p03761 (python)

Fixed submission:
n = int(input())
s = [input() for i in range(n)]
ans = ''
for i in range(97,97+26):
    count=float("inf")
    for j in range(n):
        count=min(count,s[j].count(chr(i)))
    ans += chr(i)*count

print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
s = [input() for i in range(n)]
ans = ''
for i in range(97,97+26):
    count=float("inf")
    for j in range(n):
        count=min(count,a[j].count(chr(i)))
    ans += chr(i)*count

print(ans)
Problem p03854 (python)

Fixed submission:
s = input()
judge = True
while 0<len(s): 
    if s[:5]=='dream':
        s = s[5:]
        if s[:2]=='er' and not s[:5]=='erase':
            s = s[2:]
    elif s[:5]=='erase':
        s = s[5:]
        if s[:1]=='r':
            s = s[1:]
    else:
        judge = False
        break
print('YES' if judge else 'NO')

Buggy submission (verdict: Runtime Error):
s = input()
cs = s
judge = True
while 0<len(cs): 
    if cs[:5]=='dream':
        cs = cs[5:]
        if cs[:2]=='er' and not cs[:5]=='erase':
            cs = cs[2:]
    elif cs[:5]=='erase':
        cs = cs[5:]
        if cs[0]=='r':
            cs = cs[1:]
    else:
        judge = False
        break
print('YES' if judge else 'NO')