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

sys.setrecursionlimit(10**9)

n,m = map(int, (input().split()))


checked= {}
graph = {}
for i in range(m):
    a,b,c = map(int, input().split())

    if a in graph:
        graph[a].append((b,c))
    else:
        graph[a] = []
        graph[a].append((b,c))

ans = -1*float("inf")
def solve(node, current_score):
    global ans
    if node == n:
        if n in graph:
            for tmp in graph[n]:
                if tmp[0] == 1:
                    flag = True
            if not flag:
                if ans < current_score:
                    ans = current_score 
            else:
                print("inf")
                exit()
        else:
            if ans < current_score:
                ans = current_score 

    if node in graph:
        for g in graph[node]:
            solve(g[0], current_score + g[1])


solve(1,0)
print(ans)

Fixed submission:
INF = float("inf")
n, m = map(int, input().split())
edges = [None] * m

# n:node num
# e:edges
# s:start node

d = [INF] * n
d[0] = 0
def Bellmanford(n, e, s):

    # 経路は最大でもN-1回移動すると終わるので（閉路がない限り）その分だけ更新
    for i in range(n):
        # すべての辺についてみていく
        for a,b,c in e:
            # aにたどり着ける（コストがINFではない）かつ、今のところのbまでのコストがa->bで行くときより大きい場合、更新
            if d[a] != INF and d[a] + c < d[b]:
                d[b] = d[a] + c

                # N回目更新した際に、それでも最終地点Nまでのコストが更新されたー＞負の閉路がある
                if i == n-1 and b == n-1:
                    return INF


    return -1 * d[-1]



for i in range(m):
    A, B, C = map(int, input().split())
    edges[i] = (A-1, B-1, -C)

ans = Bellmanford(n, edges, 0)
print(ans)

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


checked= {}
graph = {}
for i in range(m):
    a,b,c = map(int, input().split())

    if a in graph:
        graph[a].append((b,c))
    else:
        graph[a] = []
        graph[a].append((b,c))

ans = -1*float("inf")
def solve(node, current_score):
    global ans
    if node == n:
        if n in graph:
            for tmp in graph[n]:
                if tmp[0] == 1:
                    flag = True
            if not flag:
                if ans < current_score:
                    ans = current_score 
            else:
                print("inf")
                exit()
        else:
            if ans < current_score:
                ans = current_score 

    if node in graph:
        for g in graph[node]:
            solve(g[0], current_score + g[1])


solve(1,0)
print(ans)

Fixed submission:
INF = float("inf")
n, m = map(int, input().split())
edges = [None] * m

# n:node num
# e:edges
# s:start node

d = [INF] * n
d[0] = 0
def Bellmanford(n, e, s):

    # 経路は最大でもN-1回移動すると終わるので（閉路がない限り）その分だけ更新
    for i in range(n):
        # すべての辺についてみていく
        for a,b,c in e:
            # aにたどり着ける（コストがINFではない）かつ、今のところのbまでのコストがa->bで行くときより大きい場合、更新
            if d[a] != INF and d[a] + c < d[b]:
                d[b] = d[a] + c

                # N回目更新した際に、それでも最終地点Nまでのコストが更新されたー＞負の閉路がある
                if i == n-1 and b == n-1:
                    return INF


    return -1 * d[-1]



for i in range(m):
    A, B, C = map(int, input().split())
    edges[i] = (A-1, B-1, -C)

ans = Bellmanford(n, edges, 0)
print(ans)