Buggy python submission (verdict: Time Limit Exceeded):
import heapq
def dijkstra(G, s):
    dist = [float("inf")]*len(G)
    q = []
    dist[s] = 0
    heapq.heapify(q)
    heapq.heappush(q, [0, s])
    while 0 < len(q):
        pre_cost, p = heapq.heappop(q)
        if dist[p] < pre_cost:
            continue
        for v, d in G[p]:
            if dist[v] > dist[p] + d:
                dist[v] = dist[p] + d
                heapq.heappush(q, [dist[v], v])
    return dist
def main():
    n, m, s, t = map(int, input().split())
    s, t = s-1, t-1
    G_y = [[] for _ in range(n)]
    G_s = [[] for _ in range(n)]
    f = [True]*n
    for _ in range(m):
        u, v, a, b = map(int, input().split())
        u, v = u-1, v-1
        G_y[u].append([v, a])
        G_y[v].append([u, a])
        G_s[u].append([v, b])
        G_s[v].append([u, b])
    cost_y = dijkstra(G_y, s)
    cost_s = dijkstra(G_s, t)
    cost = [[cost_y[i] + cost_s[i], i] for i in range(n)]
    cost.sort()
    x = 0
    for i in range(n):
        while not f[cost[x][1]]:
            x += 1
        print(10**15 - cost[x][0])
        f[i] = False

if __name__ == "__main__":
    main()


Fixed submission:
import heapq
def dijkstra(G, s):
    dist = [float("inf")]*len(G)
    q = []
    dist[s] = 0
    heapq.heapify(q)
    heapq.heappush(q, [0, s])
    while 0 < len(q):
        pre_cost, p = heapq.heappop(q)
        if dist[p] < pre_cost:
            continue
        for v, d in G[p]:
            if dist[v] > dist[p] + d:
                dist[v] = dist[p] + d
                heapq.heappush(q, [dist[v], v])
    return dist
import sys
input = sys.stdin.readline
def main():
    n, m, s, t = map(int, input().split())
    s, t = s-1, t-1
    G_y = [[] for _ in range(n)]
    G_s = [[] for _ in range(n)]
    f = [True]*n
    for _ in range(m):
        u, v, a, b = map(int, input().split())
        u, v = u-1, v-1
        G_y[u].append([v, a])
        G_y[v].append([u, a])
        G_s[u].append([v, b])
        G_s[v].append([u, b])
    cost_y = dijkstra(G_y, s)
    cost_s = dijkstra(G_s, t)
    cost = [[cost_y[i] + cost_s[i], i] for i in range(n)]
    cost.sort()
    x = 0
    for i in range(n):
        while not f[cost[x][1]]:
            x += 1
        print(10**15 - cost[x][0])
        f[i] = False

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import heapq
def dijkstra(G, s):
    dist = [float("inf")]*len(G)
    q = []
    dist[s] = 0
    heapq.heapify(q)
    heapq.heappush(q, [0, s])
    while 0 < len(q):
        pre_cost, p = heapq.heappop(q)
        if dist[p] < pre_cost:
            continue
        for v, d in G[p]:
            if dist[v] > dist[p] + d:
                dist[v] = dist[p] + d
                heapq.heappush(q, [dist[v], v])
    return dist
def main():
    n, m, s, t = map(int, input().split())
    s, t = s-1, t-1
    G_y = [[] for _ in range(n)]
    G_s = [[] for _ in range(n)]
    f = [True]*n
    for _ in range(m):
        u, v, a, b = map(int, input().split())
        u, v = u-1, v-1
        G_y[u].append([v, a])
        G_y[v].append([u, a])
        G_s[u].append([v, b])
        G_s[v].append([u, b])
    cost_y = dijkstra(G_y, s)
    cost_s = dijkstra(G_s, t)
    cost = [[cost_y[i] + cost_s[i], i] for i in range(n)]
    cost.sort()
    x = 0
    for i in range(n):
        while not f[cost[x][1]]:
            x += 1
        print(pow(10, 15) - cost[x][0])
        f[i] = False

if __name__ == "__main__":
    main()


Fixed submission:
import heapq
def dijkstra(G, s):
    dist = [float("inf")]*len(G)
    q = []
    dist[s] = 0
    heapq.heapify(q)
    heapq.heappush(q, [0, s])
    while 0 < len(q):
        pre_cost, p = heapq.heappop(q)
        if dist[p] < pre_cost:
            continue
        for v, d in G[p]:
            if dist[v] > dist[p] + d:
                dist[v] = dist[p] + d
                heapq.heappush(q, [dist[v], v])
    return dist
import sys
input = sys.stdin.readline
def main():
    n, m, s, t = map(int, input().split())
    s, t = s-1, t-1
    G_y = [[] for _ in range(n)]
    G_s = [[] for _ in range(n)]
    f = [True]*n
    for _ in range(m):
        u, v, a, b = map(int, input().split())
        u, v = u-1, v-1
        G_y[u].append([v, a])
        G_y[v].append([u, a])
        G_s[u].append([v, b])
        G_s[v].append([u, b])
    cost_y = dijkstra(G_y, s)
    cost_s = dijkstra(G_s, t)
    cost = [[cost_y[i] + cost_s[i], i] for i in range(n)]
    cost.sort()
    x = 0
    for i in range(n):
        while not f[cost[x][1]]:
            x += 1
        print(10**15 - cost[x][0])
        f[i] = False

if __name__ == "__main__":
    main()