Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(10**7)
n, m, s, t = map(int, input().split())
G1 = [[]for i in range(n+1)]
G2 = [[]for i in range(n+1)]
cost1 = [10**15 ]*(n+1)
cost2 = [10**15 ]*(n+1)
for i in range(m):
    u, v, a, b = map(int,input().split())
    G1[u] += (v,a),
    G1[v] += (u,a),
    G2[u] += (v,b),
    G2[v] += (u,b),
def f1(s, l, c):
    if cost1[s] > c:
        cost1[s] = c
    for v, a in G1[s]:
        if v not in l:
            f1(v, l+[v], c+a)
def f2(t, l, c):
    if cost2[t] > c:
        cost2[t] = c
    for v, b in G2[t]:
        if v not in l:
            f2(v, l+[v], c+b)
f1(s, [s], 0)
f2(t, [t], 0)
ansl = []
ans = 0
for i in range(1, n+1):
    cost = cost1[-i] + cost2[-i]
    m = 10**15 - cost
    if ans < m:
        ans = m
    ansl.append(ans)
for _ in range(n):
    print(ansl.pop())
    

Fixed submission:
from heapq import heappop, heappush
 
 
def dijkstra(costs, s, i):
    q = [(0, s)]
    while q:
        c, v = heappop(q)
        if costs[v] >= 0:
            continue
        costs[v] = c
        for link in links[v]:
            u = link[0]
            if costs[u] == -1:
                heappush(q, (c + link[i], u))
 
 
n, m, s, t = map(int, input().split())
links = [[] for _ in range(n+1)]
for _ in range(m):
    u, v, a, b = map(int, input().split())
    links[u] += (v, a, b),
    links[v] += (u, a, b),

yen_costs = [-1] * (n+1)
snk_costs = [-1] * (n+1)
dijkstra(yen_costs, s, 1)
dijkstra(snk_costs, t, 2)
ansl = []
ans = 0

for i in range(1, n+1):
    cost = yen_costs[-i]+snk_costs[-i]
    m = 10**15 - cost
    if ans < m:
        ans = m
    ansl.append(ans)
for _ in range(n):
    print(ansl.pop())

Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(10**6)
n, m, s, t = map(int, input().split())
G1 = [[]for i in range(n+1)]
G2 = [[]for i in range(n+1)]
cost1 = [10**15 ]*(n+1)
cost2 = [10**15 ]*(n+1)
for i in range(m):
    u, v, a, b = map(int,input().split())
    G1[u] += (v,a),
    G1[v] += (u,a),
    G2[u] += (v,b),
    G2[v] += (u,b),
def f1(s, l, c):
    if cost1[s] > c:
        cost1[s] = c
    for v, a in G1[s]:
        if v not in l:
            f1(v, l+[v], c+a)
def f2(t, l, c):
    if cost2[t] > c:
        cost2[t] = c
    for v, b in G2[t]:
        if v not in l:
            f2(v, l+[v], c+b)
f1(s, [s], 0)
f2(t, [t], 0)
ansl = []
ans = 0
for i in range(1, n+1):
    cost = cost1[-i] + cost2[-i]
    m = 10**15 - cost
    if ans < m:
        ans = m
    ansl.append(ans)
for _ in range(n):
    print(ansl.pop())
    

Fixed submission:
from heapq import heappop, heappush
 
 
def dijkstra(costs, s, i):
    q = [(0, s)]
    while q:
        c, v = heappop(q)
        if costs[v] >= 0:
            continue
        costs[v] = c
        for link in links[v]:
            u = link[0]
            if costs[u] == -1:
                heappush(q, (c + link[i], u))
 
 
n, m, s, t = map(int, input().split())
links = [[] for _ in range(n+1)]
for _ in range(m):
    u, v, a, b = map(int, input().split())
    links[u] += (v, a, b),
    links[v] += (u, a, b),

yen_costs = [-1] * (n+1)
snk_costs = [-1] * (n+1)
dijkstra(yen_costs, s, 1)
dijkstra(snk_costs, t, 2)
ansl = []
ans = 0

for i in range(1, n+1):
    cost = yen_costs[-i]+snk_costs[-i]
    m = 10**15 - cost
    if ans < m:
        ans = m
    ansl.append(ans)
for _ in range(n):
    print(ansl.pop())