Buggy python submission (verdict: Time Limit Exceeded):
import math

INF = float("inf")

V, E = map(int, input().split())
es = []

for _ in range(E):
    a, b, c = map(int, input().split())
    es.append([a-1, b-1, -c])

d = [INF] * V
d[0] = 0

for _ in range(V - 1):
    updated = False
    for e in es:
        if math.isinf(d[e[0]]):
            continue
        if d[e[1]] > d[e[0]] + e[2]:
            d[e[1]] = d[e[0]] + e[2]
            updated = True
    if not updated:
        break

negative = [False] * V

for _ in range(V):
    for e in es:
        if math.isinf(d[e[0]]):
            continue
        if d[e[1]] > d[e[0]] + e[2]:
            negative[e[1]] = True
            d[e[1]] = d[e[0]] + e[2]
        elif negative[e[1]]:
            d[e[1]] = True
print(-d[V-1] if not negative[V-1] else "inf")


Fixed submission:
import math

INF = float("inf")

V, E = map(int, input().split())
es = []

for _ in range(E):
    a, b, c = map(int, input().split())
    es.append([a-1, b-1, -c])

d = [INF] * V
d[0] = 0
cnt = [0] * V

for _ in range(V):
    updated = False
    for e in es:
        if math.isinf(d[e[0]]):
            continue
        if d[e[1]] > d[e[0]] + e[2]:
            d[e[1]] = d[e[0]] + e[2]
            cnt[e[1]] += 1
            updated = True
    if not updated:
        break

print(-d[V-1] if cnt[V-1] < V else "inf")

Buggy python submission (verdict: Runtime Error):
import math

INF = float("inf")

V, E = map(int, input().split())
es = []

for _ in range(E):
    a, b, c = map(int, input().split())
    es.append([a-1, b-1, -c])

d = [INF] * V
d[1] = 0

for _ in range(V - 1):
    updated = False
    for e in es:
        if math.isinf(d[e[0]]):
            continue
        if d[e[1]] > d[e[0]] + e[2]:
            d[e[1]] = d[e[0]] + e[2]
            updated = True
    if not updated:
        break

negative = [False] * V

for _ in range(V):
    for e in es:
        if math.isinf(d[e[0]]):
            continue
        if d[e[1]] > d[e[0]] + e[2]:
            negative[e[1]] = True
            d[e[1]] = d[e[0]] + e[2]
        elif negative[e[1]]:
            d[e[1]] = True
print(-d[V] if not negative[V] else "inf")


Fixed submission:
import math

INF = float("inf")

V, E = map(int, input().split())
es = []

for _ in range(E):
    a, b, c = map(int, input().split())
    es.append([a-1, b-1, -c])

d = [INF] * V
d[0] = 0
cnt = [0] * V

for _ in range(V):
    updated = False
    for e in es:
        if math.isinf(d[e[0]]):
            continue
        if d[e[1]] > d[e[0]] + e[2]:
            d[e[1]] = d[e[0]] + e[2]
            cnt[e[1]] += 1
            updated = True
    if not updated:
        break

print(-d[V-1] if cnt[V-1] < V else "inf")

Buggy python submission (verdict: Runtime Error):
import math

INF = float("inf")

V, E = map(int, input().split())
es = []

for _ in range(E):
    a, b, c = map(int, input().split())
    es.append([a-1, b-1, -c])

d = [INF] * V
d[1] = 0

updated = False
for _ in range(V - 1):
    for e in es:
        if math.isinf(d[e[0]]):
            continue
        if d[e[1]] > d[e[0]] + e[2]:
            d[e[1]] = d[e[0]] + e[2]
    if not updated:
        break

negative = [False] * V

for _ in range(V):
    for e in es:
        if math.isinf(d[e[0]]):
            continue
        if d[e[1]] > d[e[0]] + e[2]:
            negative[e[1]] = True
            d[e[1]] = d[e[0]] + e[2]
        elif negative[e[1]]:
            d[e[1]] = True
print(-d[V] if not negative[V] else "inf")


Fixed submission:
import math

INF = float("inf")

V, E = map(int, input().split())
es = []

for _ in range(E):
    a, b, c = map(int, input().split())
    es.append([a-1, b-1, -c])

d = [INF] * V
d[0] = 0
cnt = [0] * V

for _ in range(V):
    updated = False
    for e in es:
        if math.isinf(d[e[0]]):
            continue
        if d[e[1]] > d[e[0]] + e[2]:
            d[e[1]] = d[e[0]] + e[2]
            cnt[e[1]] += 1
            updated = True
    if not updated:
        break

print(-d[V-1] if cnt[V-1] < V else "inf")

Buggy python submission (verdict: Time Limit Exceeded):
import math

INF = float("inf")

V, E = map(int, input().split())
edge = []

for _ in range(E):
    a, b, c = map(int, input().split())
    edge.append([a, b, -c])

d = [INF] * (V + 1)
d[1] = 0

for _ in range(V-1):
    update = False
    for e in edge:
        if not math.isinf(d[e[0]]) and d[e[1]] > d[e[0]] + e[2]:
            update = True
            d[e[1]] = d[e[0]] + e[2]
    if not update:
        break

negative = [False] * (V + 1)

for _ in range(V):
    for e in edge:
        if math.isinf(d[e[0]]):
            continue
        if d[e[1]] > d[e[0]] + e[2]:
            negative[e[1]] = True
            d[e[1]] = d[e[0]] + e[2]
        elif negative[e[1]]:
            d[e[1]] = True
print(-d[V] if not negative[V] else "inf")


Fixed submission:
import math

INF = float("inf")

V, E = map(int, input().split())
es = []

for _ in range(E):
    a, b, c = map(int, input().split())
    es.append([a-1, b-1, -c])

d = [INF] * V
d[0] = 0
cnt = [0] * V

for _ in range(V):
    updated = False
    for e in es:
        if math.isinf(d[e[0]]):
            continue
        if d[e[1]] > d[e[0]] + e[2]:
            d[e[1]] = d[e[0]] + e[2]
            cnt[e[1]] += 1
            updated = True
    if not updated:
        break

print(-d[V-1] if cnt[V-1] < V else "inf")