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

Fixed submission:
N = int(input())
if N == 1:
  print("Hello World")
elif N == 2:
  A,B = [int(input()) for i in range(2)]
  print(A+B)

Buggy submission (verdict: Runtime Error):
import math as m
N,M = map(int,input().split())
# N == 1 の処理
if N == 1:
    print(M)
    exit()
# Mの素数判定
judge = "prime"
for i in range(m.floor(pow(M,1/2)),1,-1):
    if M % i == 0:
        judge = "conposite"
        break
if judge == "prime":
    print(1)
    exit()
for i in range(M // N,0,-1):
    if M % i == 0:
        print(i)
        exit()
Problem p03264 (python)

Fixed submission:
k = int(input())
m = (k-1)/2
n = (k-1)/2 + 1
if k % 2 == 0:
  print(int((k/2)**2))
else :
  print(int(m*n))

Buggy submission (verdict: Runtime Error):
x1,y1,x2,y2 = map(int,input().split())
x3 = x2+y1-y2
y3 = -x1+x2+y2
x4 = x1+y1-y2
y4 = -x1+x2+y1
print(x3,y3,x4,y4)
Problem p03280 (python)

Fixed submission:
A,B = map(int,input().split())
S = (A-1)*(B-1)
print(S)

Buggy submission (verdict: Runtime Error):
A = int(input())
B = int(input())
S = (A-1)*(B-1)
print(S)
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 = int(input())
# N = 4n+7m 
if (N % 4 == 0) or (N % 7 == 0) or (N % 7 == 4):
  print("Yes")
else:
  print("No")

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

K=input(':')

N=int(N)

K=int(K)

if N%K==0 :
    print(0)

else :
    print(1)
Problem p03285 (python)

Fixed submission:
N = int(input())
m = 0
for i in range(15):
  n = N-7*m
  if n < 0:
    print("No")
    break
  elif n % 4 == 0:
    print("Yes")
    break
  elif m == 14:
    print("No")
  m += 1

Buggy submission (verdict: Runtime Error):
N = int(input())
# N = 4n+7m 
if N % 4 == 0 or N % 7 ==　0 or N % 7 == 4:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
N = int(input())
# N = 4n+7m 
if N % 4 == 0 or N % 7 ==0 or N % == 4:
  print("Yes")
else:
  print("No")
Problem p03290 (python)

Fixed submission:
import math as m
D,G = map(int, input().split())
info = [list(map(int, input().split())) for i in range(D)]
def bfs(list_hoge=[[0,[]]],depth=0):
    queue = []
    for e in list_hoge:
        for b in [0,1]:
            if b == 0:
                score = e[0]
                copy = e[1][:]
                queue.append([score,copy])
            elif b == 1:
                score = e[0] + 100*(depth+1)*info[depth][0] + info[depth][1]
                copy = e[1][:]
                copy.append(depth)
                queue.append([score,copy])
    list_hoge = queue[:]
    if depth == len(info)-1:
        return list_hoge
    return bfs(list_hoge,depth+1)
res = bfs()
ans = float("inf")
for e in res:
    solved = 0
    for i in range(len(e[1])):
        solved += info[e[1][i]][0]
    if e[0] >= G:
        if solved < ans:
            ans = solved
        continue
    for i in range(D-1,-1,-1):
        if not i in e[1]:
            nec = G-e[0]
            haiten = 100*(i+1)
            add_solve = m.ceil(nec/haiten)
            total_solved = solved + m.ceil(nec/haiten)
            if add_solve >= info[i][0]:
                break
            if total_solved < ans:
                ans = total_solved
print(ans)

Buggy submission (verdict: Runtime Error):
import math as m
from fractions import gcd
D,G = map(int,input().split())
info = [list(map(int,input().split())) for i in range(D)]
a = info[0][0]
L = []
for i in range(1,D):
    b = info[i][0]
    lcm = (a * b) // gcd(a,b)
    a = lcm
for i in range(1,D+1):
    p = info[i-1][0]
    c = info[i-1][1]
    L.append([lcm*100*i + c, i, p, c])
goal = G
count = 0
# 見かけの点数でソート
L.sort()
# 見かけの点数が大きい順から問題を解いていく
# i番目を全問解いた見かけのiscoreについて　
# goal - iscore >= 0 ならば i番目を解くことは確定
for i in range(D-1,-1,-1):
    iscore = 100 * L[i][1] * L[i][2] + L[i][3]
    if goal - iscore >= 0:
        goal -= iscore
        count += L[i][2]
        if goal == 0:
            break
# goal - iscore < 0 ならば　
# i番目をj問解いたscore_jが goal - score_j <= 0 となるような 最小のjをメモ
# まだ解いていない他の問題についても同様にjをメモ(存在しない場合もあり)　これらのうち最小のjを採用する
    elif goal - iscore < 0:
        adopt = 100
        for k in range(i,-1,-1):
            score = 100 * L[k][1] * L[k][2] + L[k][3]
            if goal - score <= 0:
                j = min(m.ceil(goal/(100 * L[k][1])),L[k][2])
                if j < adopt:
                    adopt = j
        count += adopt
        break
print(count)
Problem p03331 (python)

Fixed submission:
N = int(input())
ans = N
for i in range(1,N):
    A,B = 0,0
    A_str = list(str(i))
    B_str = list(str(N-i))
    for e in A_str:
        A += int(e)
    for e in B_str:
        B += int(e)
    if A + B < ans:
        ans = A + B       
print(ans)

Buggy submission (verdict: Runtime Error):
def degit_sum(n):
    s = list(str(n))
    s = [int(e) for e in s]
    return sum(s)

N = int(input())
degit = len(str(N))
if N % pow(10,degit-1) == 0:
    degit -= 1
A = pow(10,degit-1)
B = N - A
ans = degit_sum(A) + degit_sum(B)
print(ans)
Problem p03340 (python)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
r = 0; sum_ = 0; res = 0; ans = 0
for l in range(N+1):
    for i in range(r,N):
        if res ^ A[i] == sum_ + A[i]:
            r += 1
            res += A[i]
            sum_ += A[i]
        else:
            break
    length = r - l
    ans += length
    if length == 0:
        r += 1
    else:
        res -= A[l]
        sum_ -= A[l]

print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
l=0; r=0; res=0; sum_=0; ans=[]
for _ in range(10**6)
    if l == N and r == N:
        break
    note = r
    for i in range(r,N):
        if res ^ A[i] == sum_ + A[i]:
            r += 1
            res += A[i]
            sum_ += A[i]
        else:
            break
    length = r - l
    f = note == r
    if f is False:
        for i in range(l,r+1):
            for j in range(i+1,r+1):
                ans.append((i,j))
    if length == 0:
        r += 1
    else:
        res -= A[l]
        sum_ -= A[l]
    l += 1
ans = len(list(set((ans))))
print(ans)
Problem p03341 (python)

Fixed submission:
N = int(input())
S = list(input())
count_E = S.count("E")
count_W = 0
ans = count_E
for i in range(N):
    if S[i] == "E":
        count_E -= 1
    if S[i-1] == "W" and i != 0:
        count_W += 1
    if count_E + count_W < ans :
        ans = count_E + count_W
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
S = list(input())
count_E = S.count("E")
count_W = 0
count = count_E + count_W
ans = count + 1
for e in range S:
    if e == "E":
        count_E -= 1
    elif e == "W":
        count_W += 1
    if count < ans :
        ans = count
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
S = list(input())
count_E = S.count("E")
count_W = 0
count = count_E + count_W
ans = count + 1
for e in range S:
    if e == "E":
        count_E -= 1
    elif e == "w":
        count_W += 1
    if count < ans :
        ans = count
print(ans)
Problem p03361 (python)

Fixed submission:
H,W = map(int,input().split())
L = []
for i in range(H):
    l = list(input())
    L.append(l)

def judge(list,i,j):
    if i != 0:
        top = list[i-1][j]
    else:
        top = "."
    if j != 0:
        left = list[i][j-1]
    else:
        left = "."
    if i != H-1:
        bottom = list[i+1][j]
    else:
        bottom = "."
    if j != W-1:
        right = list[i][j+1]
    else:
        right = "."
    return top == "#" or left == "#" or bottom == "#" or right == "#"

for i in range(H):
    for j in range(W):
        if L[i][j] == "#" and judge(L,i,j) is False:
            print("No")
            exit()
print("Yes")

Buggy submission (verdict: Runtime Error):
H,W = map(int,input().split())
L = []
for i in range(H):
    l = list(input())
    L.append(l)

def judge(list,i,j):
    if i != 0:
        top = list[i-1][j]
    else:
        top = "."
    if j != 0:
        left = list[i][j-1]
    else:
        left = "."
    if i != H-1:
        bottom = list[i+1][j]
    else:
        bottom = "."
    if j != W-1:
        right = list[i][j+1]
    else:
        right = "."
    return top == "#" or left == "#" or bottom == "#" or right == "#"

for i in range(H):
    for j in range(W):
        if L[i][i] == "#" and judge(L,i,j) is False:
            print("No")
            exit()
print("Yes")

Buggy submission (verdict: Runtime Error):
H,W = map(int,input().split())
L = []
for i in range(H):
    l = list(input())
    L.append(l)

def judge(list,i,j):
    if i != 0:
        top = list[i-1][j]
    else:
        top = "."
    if j != 0:
        left = list[i][j-1]
    else:
        left = "."
    if i != W-1:
        bottom = list[i+1][j]
    else:
        bottom = "."
    if j != H-1:
        right = list[i][j+1]
    else:
        right = "."
    return top == "#" or left == "#" or bottom == "#" or right == "#"

for i in range(W):
    for j in range(H):
        if L[i][i] == "#" and judge(L,i,j) is False:
            print("No")
            exit()
print("Yes")
Problem p03386 (python)

Fixed submission:
A,B,K = map(int,input().split())
if B - A + 1 <= 2 * K:
    l = list(range(A,B + 1))
else:
    l1 = list(range(A,A + K))
    l2 = list(range(B - K + 1,B + 1))
    l = l1 + l2
for e in l:
    print(e)

Buggy submission (verdict: Runtime Error):
A,B,K = map(int,input().split())
l = list(range(A,B+1)) 
if B-A+1 <= 2*(K+1):
  for e in l:
    print(e)
elif B-A+1 > 2*(K+1):
  del l[K:-K]
  for e in l:
    print(e)

Buggy submission (verdict: Runtime Error):
A,B,K = map(int,input().split())
l = list(range(A,B+1)) 
if B-A+1 <= 2*K:
  for e in l:
    print(e)
elif B-A+1 > 2*K:
  del l[K:-K]
  for e in l:
    print(e)

Buggy submission (verdict: Runtime Error):
A,B,K = map(int,input().split())
l = list(range(A,B+1))
del l[K:-K]
for e in l:
  print(e)
Problem p03403 (python)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
A.insert(0,0)
A.append(0)
cost = 0
for i in range(N+1):
    cost += abs(A[i+1]-A[i])
for i in range(1,N+1):
    sub = abs(A[i] - A[i+1]) + abs(A[i] - A[i-1]) - abs(A[i+1] - A[i-1])
    print(cost - sub)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
A.insert(0,0)
A.append(0)
cost = 0
for i in range(N+1):
    cost += abs(A[i+1]-A[i])
for i in range(1,N+1):
    if A[i-1] <= A[i] <= A[i+1] or A[i+1] <= A[i] <= A[i-1]:
        sub = 0
    elif A[i-1] < A[i+1] < A[i]:
        sub = 2*(A[i]-A[i+1])
    elif A[i] < A[i-1] < A[i+1]:
        sub = 2*(A[i-1]-A[i])
    elif A[i+1] < A[i-1] < A[i]:
        sub = 2*(A[i] -A[i-1])
    elif A[i] < A[i+1]< A[i-1]:
        sub = 2*(A[i+1]-A[i])
    print(cost - sub)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
A.insert(0,0)
A.append(0)
cost = [abs(A[i+1] - A[i]) for i in range(N+1)]
for i in range(1,N+1):
    if A[i-1] <= A[i] <= A[i+1] or A[i+1] <= A[i] <= A[i-1]:
        sub = 0
    elif A[i-1] < A[i+1] < A[i]:
        sub = 2*(A[i]-A[i+1])
    elif A[i] < A[i-1] < A[i+1]:
        sub = 2*(A[i-1]-A[i])
    elif A[i+1] < A[i-1] < A[i]:
        sub = 2*(A[i] -A[i-1])
    elif A[i] < A[i+1]< A[i-1]:
        sub = 2*(A[i+1]-A[i])
    print(sum(cost) - sub)
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 = map(int,input(),split())
if A+2*B>=C:
  print("Yes")
else :
  print("No")
Problem p03455 (python)

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

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

Fixed submission:
a,b = map(int,input().split())
x = (a+b)/2
if (a+b)%2 == 0:
  print(int(x))
else:
  print(int(x)+1)

Buggy submission (verdict: Runtime Error):
a,b = map(int,input().split())
x = (a+b)/2
if (a+b) % 2 = 0:
  print(int(x))
else:
  print(int(x)+1)

Buggy submission (verdict: Runtime Error):
a,b = map(int,input().split())
x = (a+b)/2
if (a+b)%2 = 0:
  print(int(x))
else :
  print(int(x)+1)

Buggy submission (verdict: Runtime Error):
a,b = map(int,input().split())
x = (a+b)/2
if (a+b)%2 = 0:
  print(int(x))
else:
  print(int(x)+1)
Problem p03504 (python)

Fixed submission:
import itertools
N,C = map(int,input().split())
imos = [0]*(10**6)
info = [list(map(int,input().split())) for i in range(N)]
info = sorted(info,key=lambda x:(x[2],x[0]))
note = -1
before_t = -1
for i in range(N):
    s,t,c = info[i]
    s -= 1
    if c == note and s < before_t:
        s = before_t
    imos[s] += 1
    imos[t] -= 1
    note = c
    before_t = t
acc_sum = list(itertools.accumulate(imos))
ans = max(acc_sum)
print(ans)

Buggy submission (verdict: Runtime Error):
import itertools
N,C = map(int,input().split())
imos = [0]*(50)
info = [list(map(int,input().split())) for i in range(N)]
info = sorted(info,key=lambda x:(x[2],x[0]))
note = -1
before_t = -1
for i in range(N):
    s,t,c = info[i]
    s -= 1
    if c == note and s < before_t:
        s = before_t
    imos[s] += 1
    imos[t] -= 1
    note = c
    before_t = t
acc_sum = list(itertools.accumulate(imos))
ans = max(acc_sum)
print(ans)

Buggy submission (verdict: Runtime Error):
import itertools
N,C = map(int,input().split())
imos = [0]*(50)
info = [list(map(int,input().split())) for i in range(N)]
info = sorted(info,key=lambda x:(x[2],x[0]))
note = -1
before_t = -1
for i in range(N):
    s,t,c = info[i]
    s -= 1
    if c == note and s < before_t:
        s = before_t
    imos[s] += 1
    imos[t] -= 1
    note = c
    before_t = t
print(imos)
acc_sum = list(itertools.accumulate(imos))
ans = max(acc_sum)
print(ans)
Problem p03543 (python)

Fixed submission:
N = input()
if N[0] == N[1] == N[2]:
  print("Yes")
elif N[1] == N[2] == N[3]:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
N = int(input())
if N[0] == N[1] == N[2] and N[1] == N[2] == N[3]:
  print("Yes")
else:
  print("No")
Problem p03564 (python)

Fixed submission:
N,K = [int(input()) for i in range(2)]
p = 1
for i in range(N):
  p = min(2*p,p+K)
print(p)

Buggy submission (verdict: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int main() {
    int N,K;
    cin >> N >> K;
    // 初期値とKを比較 小さい方を足す
    int num = 1;
    for (int i = 0; i < N; i++) {
        if (num <= K) {
            num *= 2;
        }
        else {
            num += K;
        }
    }
    cout << num << endl;
}
Problem p03569 (python)

Fixed submission:
from collections import deque

s = input()

ns = ""

for s_i in s:
    if s_i != "x":
        ns += s_i

if ns != ns[::-1]:
    print(-1)
    exit()

if ns == "":
    print(0)
    exit()

if len(ns) % 2 == 1:
    cnt = -1
    for i,s_i in enumerate(s):
        if s_i != "x":
            cnt += 1
        if cnt == len(ns)//2:
            note = i
            break
    left = deque(s[:note][::-1] + "@")
    right = deque(s[note+1:] + "@")
else:
    cnt = -1
    f = 1
    for i,s_i in enumerate(s):
        if s_i != "x":
            cnt += 1
        if cnt == len(ns)//2 - 1 and f:
            l = i
            f = 0
        if cnt == len(ns)//2:
            r = i
            break
    left = deque(s[:l][::-1] + "@")
    right = deque(s[r+1:] + "@")

ans = 0

while left or right:
    if left[0] == right[0]:
        left.popleft()
        right.popleft()
    elif left[0] == "x":
        left.popleft()
        ans += 1
    elif right[0] == "x":
        right.popleft()
        ans += 1

print(ans)

Buggy submission (verdict: Runtime Error):
from collections import deque

s = input()

ns = ""

for s_i in s:
    if s_i != "x":
        ns += s_i

if ns != ns[::-1]:
    print(-1)
    exit()

if len(ns) % 2 == 1:
    cnt = -1
    for i,s_i in enumerate(s):
        if s_i != "x":
            cnt += 1
        if cnt == len(ns)//2:
            note = i
            break
    left = deque(s[:note][::-1] + "@")
    right = deque(s[note+1:] + "@")
else:
    cnt = -1
    f = 1
    for i,s_i in enumerate(s):
        if s_i != "x":
            cnt += 1
        if cnt == len(ns)//2 - 1 and f:
            l = i
            f = 0
        if cnt == len(ns)//2:
            r = i
            break
    left = deque(s[:l][::-1] + "@")
    right = deque(s[r+1:] + "@")

ans = 0

while left or right:
    if left[0] == right[0]:
        left.popleft()
        right.popleft()
    elif left[0] == "x":
        left.popleft()
        ans += 1
    elif right[0] == "x":
        right.popleft()
        ans += 1

print(ans)

Buggy submission (verdict: Runtime Error):
from collections import deque

s = input()

ns = ""

for s_i in s:
    if s_i != "x":
        ns += s_i

if ns != ns[::-1]:
    print(-1)
    exit()

if len(ns) % 2 == 1:
    cnt = -1
    for i,s_i in enumerate(s):
        if s_i != "x":
            cnt += 1
        if cnt == len(ns)//2:
            note = i
            break
    left = deque(s[:note][::-1] + "@")
    right = deque(s[note+1:] + "@")
else:
    cnt = -1
    f = 1
    for i,s_i in enumerate(s):
        if s_i != "x":
            cnt += 1
        if cnt == len(ns)//2 - 1 and f:
            l = i
            f = 0
        if cnt == len(ns)//2:
            r = i
            break
    left = deque(s[:l][::-1] + "@")
    right = deque(s[r+1:] + "@")

ans = 0

while left or right:
    print(left,right)
    if left[0] == right[0]:
        left.popleft()
        right.popleft()
    elif left[0] == "x":
        left.popleft()
        ans += 1
    elif right[0] == "x":
        right.popleft()
        ans += 1

print(ans)
Problem p03611 (python)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
l = [0]*(10**5)
for e in A:
    if e == 0:
        l[0] += 1
        l[1] += 1
    elif e == 99999:
        l[99999] += 1
        l[99998] += 1
    else:
        l[e-1] += 1
        l[e] += 1
        l[e+1] += 1
print(max(l))

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
count_list = []
if len(list(set(A))) == 1:
    print(1)
else:
    for i in range(min(A) + 1,max(A)):
        count = A.count(i-1) + A.count(i) + A.count(i+1)
        count_list.append(count)
    print(max(count_list))

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
count_list = []
if len(list(set(A))) == 1:
    print("1")
else:
    for i in range(min(A) + 1,max(A)):
        count = A.count(i-1) + A.count(i) + A.count(i+1)
        count_list.append(count)
    print(max(count_list))
Problem p03623 (python)

Fixed submission:
x,a,b = map(int,input().split())
A = abs(x-a)
B = abs(x-b)
if A<B:
  print("A")
else:
  print("B")

Buggy submission (verdict: Runtime Error):
x,a,b = map(int,input().split())
A = abs(x-a)
B = abs(x-b)
if A<B:
  print("A")
else;
  print("B")
Problem p03633 (python)

Fixed submission:
from functools import reduce
from fractions import gcd
N = int(input())
T = [int(input()) for i in range(N)]
def lcm(x,y):
    return (x * y) // gcd(x,y)
ans = reduce(lcm,T)
print(ans)

Buggy submission (verdict: Runtime Error):
import fractions
N = int(input())
T = [int(input()) for i in range(N)]
T = list(set(T))
pro = T[0]
for i in range(1,len(T)):
    gcd = fractions.gcd(pro,T[i])
    lcm = (pro * T[i]) // gcd
    pro = lcm
print(lcm)

Buggy submission (verdict: Runtime Error):
import fractions
N = int(input())
T = [int(input()) for i in range(N)]
T = list(set(T))
pro = T[0]
for i in range(1,N):
    gcd = fractions.gcd(pro,T[i])
    lcm = (pro * T[i]) // gcd
    pro = lcm
print(lcm)

Buggy submission (verdict: Runtime Error):
import fractions
N = int(input())
T = [int(input()) for i in range(N)]
pro = T[0]
for i in range(1,N):
    gcd = fractions.gcd(pro,T[i])
    lcm = (pro * T[i]) // gcd
    pro = lcm
print(lcm)
Problem p03693 (python)

Fixed submission:
r,g,b = map(int,input().split())
if (10*g + b) % 4 == 0:
  print("YES")
else:
  print("NO")

Buggy submission (verdict: Runtime Error):
r,g,b = map(int,input().split())
if (10*g + b) % 4 = 0:
  print("YES")
else:
  print("NO")

Buggy submission (verdict: Runtime Error):
r,g,b = map(int,input().split())
if (10*g + b) % 4 = 0:
  print("YES")
else:
  print("No")
Problem p03722 (python)

Fixed submission:
inf = float('inf')

N,M = map(int,input().split())
info = []
for _ in range(M):
    a,b,c = map(int,input().split())
    a -= 1; b -= 1
    info.append((a,b,c))
 
dist = [-inf for _ in range(N)]
dist[0] = 0
for i in range(N):
    for v,nv,w in info:
        if dist[nv] < dist[v] + w:
            dist[nv] = dist[v] + w
            if i == N-1 and nv == N-1:
                print("inf")
                exit()
ans = dist[N-1]
print(ans)

Buggy submission (verdict: Runtime Error):
inf = float('inf')

# distの初期化: dist = [inf for _ in range(N)]; dist[start] = 0
# True - >正常に更新, False -> 負閉路有り
def bellmanford(dist,edges,N):
    for i in range(N):
        for v ,nv, w in edges:
            if dist[nv] > dist[v] + w:
                dist[nv] = dist[v] + w
                # 頂点数Nなら更新は高々N-1回で済む
                # N回目に更新を行うなら負閉路があるということ
                if i == N-1 nv == N-1:
                    return False
    return True

N,M = map(int,input().split())
info = []
for _ in range(M):
    a,b,c = map(int,input().split())
    a -= 1; b -= 1; c = -c
    info.append((a,b,c))
 
dist = [inf for _ in range(N)]
dist[0] = 0

flag = bellmanford(dist,info,N)
ans = -dist[N-1] if flag is True else "inf"
print(ans)
Problem p03732 (python)

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

N,W = map(int,input().split())
info = []
for i in range(N):
    w,v = map(int,input().split())
    if i == 0:
        w1 = w
    w = w - (w1-1)
    info.append((w,v))
# dp[i][j][k]
# dp[i][j][k] = max(dp[i-1][j][k],dp[i-1][j-w][k-1])
# dp[0][j][0] = 0
# ans = max(dp[N][j][k] w1*k + j <= W)
dp = [[[0]*(N+1) for _ in range(400)] for _ in range(N+1)]
for i in range(1,N+1):
    w = info[i-1][0]; v = info[i-1][1]
    for j in range(400):
        for k in range(1,N+1):
            dp[i][j][k] = dp[i-1][j][k]
            if j - w >= 0:
                if dp[i][j][k] < dp[i-1][j-w][k-1] + v:
                    dp[i][j][k] = dp[i-1][j-w][k-1] + v
ans = -1
for j in range(400):
    for k in range(N+1):
        if not((w1-1)*k + j <= W):
            continue
        if dp[N][j][k] > ans:
            ans = dp[N][j][k]
print(ans)

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

def main():
    N,W = map(int,input().split())
    info = []
    for i in range(N):
        w,v = map(int,input().split())
        if i == 0:
            w1 = w
        w = w - (w1-1)
        info.append((w,v))
    # dp[i][j][k]
    # dp[i][j][k] = max(dp[i-1][j][k],dp[i-1][j-w][k-1])
    # dp[0][j][0] = 0
    # ans = max(dp[N][j][k] w1*k + j <= W)
    dp = [[[0]*(N+1) for _ in range(400)] for _ in range(N+1)]
    for i in range(1,N+1):
        w = info[i-1][0]; v = info[i-1][1]
        for j in range(400):
            for k in range(1,N+1):
                dp[i][j][k] = dp[i-1][j][k]
                if j - w >= 0:
                    if dp[i][j][k] < dp[i-1][j-w][k-1] + v:
                        dp[i][j][k] = dp[i-1][j-w][k-1] + v

    ans = -1
    for k in range(N+1):
        for j in range(W-(w1-1)*k + 1):
            if dp[N][j][k] > ans:
                ans = dp[N][j][k]
    print(ans)

main()
Problem p03817 (python)

Fixed submission:
x = int(input())
if x % 11 == 0:
    r = 0
elif x % 11 <= 6:
    r = 1
else:
    r = 2
ans = 2 * (x // 11) + r
print(ans)

Buggy submission (verdict: Runtime Error):
x = int(input())
t = x // 11
x -= 11 * t
ans = t * 2
if x <= 5:
    ans += 1
elif 5 < x < 11:
    ans += 2
print(ans)za