Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
N, M = [int(x) for x in input().strip().split()]
G = [[-float('inf')] * N for _ in range(N)]
score = [-float('inf')] * N
score[0] = 0
passed = [False] * N

for m in range(M):
    a, b, c = [int(x) for x in input().strip().split()]
    G[a-1][b-1] = c

updated = [False] * N
updated[0] = True
updated2 = False
for n in range(N):
    for i in range(1, N+1):
        if not updated[i-1]:
            continue
        updated[i-1] = False
        for j in range(1, N+1):
            # print('i={}, j={}'.format(i, j), end='')
            if i == j:
                # print(score)
                continue
            if G[i-1][j-1] != -float('inf') and score[j-1] < score[i-1] + G[i-1][j-1]:
                score[j-1] = score[i-1] + G[i-1][j-1]
                updated[j-1] = True
                if j == N-1:
                    updated2 = True
            else:
                if j == N-1:
                    updated2 = False
            # print(score)

if updated2:
    print('inf')
else:
    print(score[N-1])

Fixed submission:
import sys
input = sys.stdin.readline
N, M = [int(x) for x in input().strip().split()]
score = [-float('inf')] * N
score[0] = 0
passed = [False] * N
edges = [0] * M
for m in range(M):
    edges[m] = tuple([int(x) for x in input().strip().split()])

for n in range(N):
    updated = False
    for (i, j, c) in edges:
        # print('i={}, j={}'.format(i, j), end='')
        if score[j-1] < score[i-1] + c:
            score[j-1] = score[i-1] + c
            if j == N-1:
                updated = True
        # print(score)
    if not updated:
        break

if updated:
    print('inf')
else:
    print(score[N-1])

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
N, M = [int(x) for x in input().strip().split()]
G = [[-float('inf')] * N for _ in range(N)]
score = [-float('inf')] * N
score[0] = 0
passed = [False] * N

for m in range(M):
    a, b, c = [int(x) for x in input().strip().split()]
    G[a-1][b-1] = c

updated = [False] * N
updated[0] = True
updated2 = False
for n in range(N):
    for i in range(1, N+1):
        if not updated[i-1]:
            continue
        updated[i-1] = False
        for j in range(1, N+1):
            # print('i={}, j={}'.format(i, j), end='')
            if i == j:
                # print(score)
                continue
            if G[i-1][j-1] != -float('inf') and score[j-1] < score[i-1] + G[i-1][j-1]:
                score[j-1] = score[i-1] + G[i-1][j-1]
                updated[j-1] = True
                if j == N-1:
                    updated2 = True
            else:
                if j == N-1:
                    updated2 = False
            # print(score)

if updated2:
    print('inf')
else:
    print(score[N-1])

Fixed submission:
import sys
input = sys.stdin.readline
N, M = [int(x) for x in input().strip().split()]
score = [-float('inf')] * N
score[0] = 0
passed = [False] * N
edges = [0] * M
for m in range(M):
    edges[m] = tuple([int(x) for x in input().strip().split()])

for n in range(N):
    updated = False
    for (i, j, c) in edges:
        # print('i={}, j={}'.format(i, j), end='')
        if score[j-1] < score[i-1] + c:
            score[j-1] = score[i-1] + c
            if j == N-1:
                updated = True
        # print(score)
    if not updated:
        break

if updated:
    print('inf')
else:
    print(score[N-1])

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
N, M = [int(x) for x in input().strip().split()]
G = [[-float('inf')] * N for _ in range(N)]
score = [-float('inf')] * N
score[0] = 0
passed = [False] * N

for m in range(M):
    a, b, c = [int(x) for x in input().strip().split()]
    G[a-1][b-1] = c

updated = True
updated2 = False
for n in range(N):
    updated = False
    for i in range(1, N+1):
        for j in range(1, N+1):
            if i == j:
                continue
            if G[i-1][j-1] != -float('inf') and score[j-1] < score[i-1] + G[i-1][j-1]:
                score[j-1] = score[i-1] + G[i-1][j-1]
                updated = True
                if j == N-1:
                    updated2 = True
            else:
                if j == N-1:
                    updated2 = False

if updated2:
    print('inf')
else:
    print(score[N-1])

Fixed submission:
import sys
input = sys.stdin.readline
N, M = [int(x) for x in input().strip().split()]
score = [-float('inf')] * N
score[0] = 0
passed = [False] * N
edges = [0] * M
for m in range(M):
    edges[m] = tuple([int(x) for x in input().strip().split()])

for n in range(N):
    updated = False
    for (i, j, c) in edges:
        # print('i={}, j={}'.format(i, j), end='')
        if score[j-1] < score[i-1] + c:
            score[j-1] = score[i-1] + c
            if j == N-1:
                updated = True
        # print(score)
    if not updated:
        break

if updated:
    print('inf')
else:
    print(score[N-1])