Problem:
Kenkoooo is planning a trip in Republic of Snuke. In this country, there are n cities and m trains running. The cities are numbered 1 through n, and the i-th train connects City u_i and v_i bidirectionally. Any city can be reached from any city by changing trains.  Two currencies are used in the country: yen and snuuk. Any train fare can be paid by both yen and snuuk. The fare of the i-th train is a_i yen if paid in yen, and b_i snuuk if paid in snuuk.  In a city with a money exchange office, you can change 1 yen into 1 snuuk. However, when you do a money exchange, you have to change all your yen into snuuk. That is, if Kenkoooo does a money exchange when he has X yen, he will then have X snuuk. Currently, there is a money exchange office in every city, but the office in City i will shut down in i years and can never be used in and after that year.  Kenkoooo is planning to depart City s with 10^{15} yen in his pocket and head for City t, and change his yen into snuuk in some city while traveling. It is acceptable to do the exchange in City s or City t.  Kenkoooo would like to have as much snuuk as possible when he reaches City t by making the optimal choices for the route to travel and the city to do the exchange. For each i=0,...,n-1, find the maximum amount of snuuk that Kenkoooo has when he reaches City t if he goes on a trip from City s to City t after i years. You can assume that the trip finishes within the year.

Incorrect submission (verdict: Wrong Answer):
from heapq import heappush, heappop
INF = float("inf")


def Dijkstra(n, s, g, mode):  
    dist = [INF] * n  
    dist[s] = 0  
    hq = [(0, s)]  
    while hq:  
        d, v = heappop(hq)  
        if dist[v] < d:  
            continue
        for w, *a in g[v]:  
            nd = d + a[mode]
            if dist[w] > nd:  
                dist[w] = nd
                heappush(hq, (nd, w))
    return dist


def main():
    n, m, s, t = map(int, input().split())
    s -= 1
    t -= 1
    g = [[] for _ in range(n)]
    for _ in range(m):
        u, v, a, b = map(int, input().split())
        u -= 1
        v -= 1
        g[u].append((v, a, b))
        g[v].append((u, a, b))

    d_yen = Dijkstra(n, s, g, 0)
    d_sunnk = Dijkstra(n, t, g, 1)

    ans = [0] * n
    cost = float("inf")
    for i in range(n-1, -1, -1):
        cost = min(cost, d_yen[i] + d_sunnk[i])
        ans[i-1] = 10 ** 15 - cost
    print(*ans, sep='\n')


if __name__ == "__main__":
    main()


Fixed, accepted submission:
from heapq import heappush, heappop
INF = float("inf")


def Dijkstra(n, s, g, mode):  
    dist = [INF] * n  
    dist[s] = 0  
    hq = [(0, s)]  
    while hq:  
        d, v = heappop(hq)  
        if dist[v] < d:  
            continue
        for w, *a in g[v]:  
            nd = d + a[mode]
            if dist[w] > nd:  
                dist[w] = nd
                heappush(hq, (nd, w))
    return dist


def main():
    n, m, s, t = map(int, input().split())
    s -= 1
    t -= 1
    g = [[] for _ in range(n)]
    for _ in range(m):
        u, v, a, b = map(int, input().split())
        u -= 1
        v -= 1
        g[u].append((v, a, b))
        g[v].append((u, a, b))

    d_yen = Dijkstra(n, s, g, 0)
    d_sunnk = Dijkstra(n, t, g, 1)

    ans = [0] * n
    cost = float("inf")
    for i in range(n-1, -1, -1):
        cost = min(cost, d_yen[i] + d_sunnk[i])
        ans[i] = 10 ** 15 - cost
    print(*ans, sep='\n')


if __name__ == "__main__":
    main()