Buggy python submission (verdict: Time Limit Exceeded):
n, m, s, t = map(int, input().split())
E = [[] for i in range(n)]
for i in range(m):
  u, v, a, b = map(int, input().split())
  E[u - 1].append([v - 1, a, b])
  E[v - 1].append([u - 1, a, b])
A = [[10 ** 15, 0] for i in range(n)]
A[s - 1][0] = 0
q_a = [s - 1]
while q_a:
  s_a = sorted([[A[q][0], q] for q in q_a], key=lambda x: x[0])[0][1]
  q_a.remove(s_a)
  A[s_a][1] = 1
  for e in E[s_a]:
    if A[e[0]][1] == 0:
      if A[s_a][0] + e[1] < A[e[0]][0]:
        A[e[0]][0] = A[s_a][0] + e[1]
        if e[0] not in q_a:
          q_a.append(e[0])
B = [[10 ** 15, 0] for i in range(n)]
B[t - 1][0] = 0
q_b = [t - 1]
while q_b:
  s_b = sorted([[B[q][0], q] for q in q_b], key=lambda x: x[0])[0][1]
  q_b.remove(s_b)
  B[s_b][1] = 1
  for e in E[s_b]:
    if B[e[0]][1] == 0:
      if B[s_b][0] + e[2] < B[e[0]][0]:
        B[e[0]][0] = B[s_b][0] + e[2]
        if e[0] not in q_b:
          q_b.append(e[0])
C = [A[i][0] + B[i][0] for i in range(n)]
for i in range(n):
  print(10 ** 15 - min(C[i:]))

Fixed submission:
import heapq
n, m, s, t = map(int, input().split())
E = [[] for _ in range(n)]
A = [0] * m
B = [0] * m
for i in range(m):
  u, v, a, b = map(int, input().split())
  E[u - 1].append([v - 1, i])
  E[v - 1].append([u - 1, i])
  A[i] = a
  B[i] = b
L = [0] * n
Y = [10 ** 15] * n
S = [10 ** 15] * n
def dijkstra(s, D, W):
  Q = [[0, s]]
  D[s] = 0
  pos = 0
  while Q:
    d, q = heapq.heappop(Q)
    for adj, e in E[q]:
      if d + W[e] < D[adj]:
        D[adj] = d + W[e]
        pos += 1
        heapq.heappush(Q, [D[adj], adj])
  return D
dijkstra(s - 1, Y, A)
dijkstra(t - 1, S, B)
for i in range(n):
  L[i] = Y[i] + S[i]
for i in range(n - 2, -1, -1):
  L[i] = min(L[i + 1], L[i])
for i in range(n):
  print(10 ** 15 - L[i])

Buggy python submission (verdict: Time Limit Exceeded):
n, m, s, t = map(int, input().split())
E = [[] for i in range(n)]
for i in range(m):
  u, v, a, b = map(int, input().split())
  E[u - 1].append([v - 1, a, b])
  E[v - 1].append([u - 1, a, b])
A = [[10 ** 15, 0, i] for i in range(n)]
q_a = [a for a in A if (a[1] == 0)]
A[s - 1][0] = 0
while q_a:
  s_a = sorted(q_a, key=lambda x: x[0])[0][2]
  A[s_a][1] = 1
  for e in E[s_a]:
    if A[e[0]][1] == 0:
      A[e[0]][0] = min(A[s_a][0] + e[1], A[e[0]][0])
  q_a = [a for a in A if (a[1] == 0)]
B = [[10 ** 15, 0, i] for i in range(n)]
q_b = [b for b in B if (b[1] == 0)]
B[t - 1][0] = 0
while q_b:
  s_b = sorted(q_b, key=lambda x: x[0])[0][2]
  B[s_b][1] = 1
  for e in E[s_b]:
    if B[e[0]][1] == 0:
      B[e[0]][0] = min(B[s_b][0] + e[2], B[e[0]][0])
  q_b = [b for b in B if (b[1] == 0)]
C = [A[i][0] + B[i][0] for i in range(n)]
for i in range(n):
  print(10 ** 15 - min(C[i:]))

Fixed submission:
import heapq
n, m, s, t = map(int, input().split())
E = [[] for _ in range(n)]
A = [0] * m
B = [0] * m
for i in range(m):
  u, v, a, b = map(int, input().split())
  E[u - 1].append([v - 1, i])
  E[v - 1].append([u - 1, i])
  A[i] = a
  B[i] = b
L = [0] * n
Y = [10 ** 15] * n
S = [10 ** 15] * n
def dijkstra(s, D, W):
  Q = [[0, s]]
  D[s] = 0
  pos = 0
  while Q:
    d, q = heapq.heappop(Q)
    for adj, e in E[q]:
      if d + W[e] < D[adj]:
        D[adj] = d + W[e]
        pos += 1
        heapq.heappush(Q, [D[adj], adj])
  return D
dijkstra(s - 1, Y, A)
dijkstra(t - 1, S, B)
for i in range(n):
  L[i] = Y[i] + S[i]
for i in range(n - 2, -1, -1):
  L[i] = min(L[i + 1], L[i])
for i in range(n):
  print(10 ** 15 - L[i])