Buggy python submission (verdict: Runtime Error):
import sys
import numpy as np
from scipy.sparse.csgraph import dijkstra
from scipy.sparse import coo_matrix

read = sys.stdin.read
readline = sys.stdin.readline

n, m, s, t, *uvab = map(int, read().split())

s -= 1
t -= 1
u = np.array(uvab[::4], np.int64) - 1
v = np.array(uvab[1::4], np.int64) - 1
a = np.array(uvab[2::4], np.int64)
b = np.array(uvab[3::4], np.int64)

yen_matrix = coo_matrix((a, (u, v)), shape=(n, n))
snuuk_matrix = coo_matrix((b, (u, v)), shape=(n, n))

yen = dijkstra(yen_matrix, directed=False, indices=s, limit=10 ** 15)
snuuk = dijkstra(snuuk_matrix, directed=False, indices=t, limit=10 ** 15)

costs = (yen + snuuk).astype(int)
answer = 10 ** 15 - np.minimum.accumulate(costs[::-1])[::-1]
print(*answer.tolist(), sep='\n')


Fixed submission:
import sys
input = sys.stdin.read
sys.setrecursionlimit(10 ** 7)

import numpy as np
from heapq import heappush, heappop

N,M,S,T, *uvab = map(int,input().split())
graph = [[] for _ in range(N+1)]
for u,v,a,b in zip(*[iter(uvab)]*4):
    graph[u].append((v,a,b))
    graph[v].append((u,a,b))

def dijkstra(start, mode):
    INF = 10 ** 15
    dist = [INF] * (N+1)
    dist[start] = 0
    q = [(0,start)]
    while q:
        d,v = heappop(q)
        if dist[v] < d:
            continue
        for w,*a in graph[v]:
            d1 = d + a[mode]
            if dist[w] > d1:
                dist[w] = d1
                heappush(q, (d1,w))
    return dist

d1 = np.array(dijkstra(S,0))
d2 = np.array(dijkstra(T,1))

d1 += d2
answer = 10 ** 15 - np.minimum.accumulate(d1[::-1])[::-1][1:]
print('\n'.join(map(str, answer.tolist())))

Buggy python submission (verdict: Time Limit Exceeded):
import sys
import numpy as np
from scipy.sparse.csgraph import dijkstra
from scipy.sparse import coo_matrix

read = sys.stdin.read
readline = sys.stdin.readline

n, m, s, t, *uvab = map(int, read().split())
if m == 1:
    from heapq import heappush, heappop

    N, M, S, T = n, m, s, t
    graph = [[] for _ in range(N + 1)]
    for u, v, a, b in zip(*[iter(uvab)] * 4):
        graph[u].append((v, a, b))
        graph[v].append((u, a, b))


    def dijkstra(start, mode):
        INF = 10 ** 15
        dist = [INF] * (N + 1)
        dist[start] = 0
        q = [(0, start)]
        while q:
            d, v = heappop(q)
            if dist[v] < d:
                continue
            for w, *a in graph[v]:
                d1 = d + a[mode]
                if dist[w] > d1:
                    dist[w] = d1
                    heappush(q, (d1, w))
        return dist


    d1 = np.array(dijkstra(S, 0))
    d2 = np.array(dijkstra(T, 1))

    d1 += d2
    answer = 10 ** 15 - np.minimum.accumulate(d1[::-1])[::-1][1:]
    print('\n'.join(answer.astype(str)))
    exit()

s -= 1
t -= 1
u = np.array(uvab[::4], np.int64) - 1
v = np.array(uvab[1::4], np.int64) - 1
a = np.array(uvab[2::4], np.int64)
b = np.array(uvab[3::4], np.int64)

yen_matrix = coo_matrix((a, (u, v)), shape=(n, n))
snuuk_matrix = coo_matrix((b, (u, v)), shape=(n, n))

yen = dijkstra(yen_matrix, directed=False, indices=s)
snuuk = dijkstra(snuuk_matrix, directed=False, indices=t)

costs = (yen + snuuk).astype(int)
answer = 10 ** 15 - np.minimum.accumulate(costs[::-1])[::-1]
print(*answer.tolist(), sep='\n')


Fixed submission:
import sys
input = sys.stdin.read
sys.setrecursionlimit(10 ** 7)

import numpy as np
from heapq import heappush, heappop

N,M,S,T, *uvab = map(int,input().split())
graph = [[] for _ in range(N+1)]
for u,v,a,b in zip(*[iter(uvab)]*4):
    graph[u].append((v,a,b))
    graph[v].append((u,a,b))

def dijkstra(start, mode):
    INF = 10 ** 15
    dist = [INF] * (N+1)
    dist[start] = 0
    q = [(0,start)]
    while q:
        d,v = heappop(q)
        if dist[v] < d:
            continue
        for w,*a in graph[v]:
            d1 = d + a[mode]
            if dist[w] > d1:
                dist[w] = d1
                heappush(q, (d1,w))
    return dist

d1 = np.array(dijkstra(S,0))
d2 = np.array(dijkstra(T,1))

d1 += d2
answer = 10 ** 15 - np.minimum.accumulate(d1[::-1])[::-1][1:]
print('\n'.join(map(str, answer.tolist())))

Buggy python submission (verdict: Runtime Error):
import sys
import numpy as np
from scipy.sparse.csgraph import dijkstra
from scipy.sparse import coo_matrix

read = sys.stdin.read
readline = sys.stdin.readline

n, m, s, t, *uvab = map(int, read().split())
if n == m == 10 ** 5:
    from heapq import heappush, heappop

    N, M, S, T = n, m, s, t
    graph = [[] for _ in range(N + 1)]
    for u, v, a, b in zip(*[iter(uvab)] * 4):
        graph[u].append((v, a, b))
        graph[v].append((u, a, b))


    def dijkstra(start, mode):
        INF = 10 ** 15
        dist = [INF] * (N + 1)
        dist[start] = 0
        q = [(0, start)]
        while q:
            d, v = heappop(q)
            if dist[v] < d:
                continue
            for w, *a in graph[v]:
                d1 = d + a[mode]
                if dist[w] > d1:
                    dist[w] = d1
                    heappush(q, (d1, w))
        return dist


    d1 = np.array(dijkstra(S, 0))
    d2 = np.array(dijkstra(T, 1))

    d1 += d2
    answer = 10 ** 15 - np.minimum.accumulate(d1[::-1])[::-1][1:]
    print('\n'.join(answer.astype(str)))
    exit()
s -= 1
t -= 1
u = np.array(uvab[::4], np.int64) - 1
v = np.array(uvab[1::4], np.int64) - 1
a = np.array(uvab[2::4], np.int64)
b = np.array(uvab[3::4], np.int64)

yen_matrix = coo_matrix((a, (u, v)), shape=(n, n), dtype=float_)
snuuk_matrix = coo_matrix((b, (u, v)), shape=(n, n))

yen = dijkstra(yen_matrix, directed=False, indices=s)
snuuk = dijkstra(snuuk_matrix, directed=False, indices=t)

costs = (yen + snuuk).astype(int)
answer = 10 ** 15 - np.minimum.accumulate(costs[::-1])[::-1]
print(*answer.tolist(), sep='\n')


Fixed submission:
import sys
input = sys.stdin.read
sys.setrecursionlimit(10 ** 7)

import numpy as np
from heapq import heappush, heappop

N,M,S,T, *uvab = map(int,input().split())
graph = [[] for _ in range(N+1)]
for u,v,a,b in zip(*[iter(uvab)]*4):
    graph[u].append((v,a,b))
    graph[v].append((u,a,b))

def dijkstra(start, mode):
    INF = 10 ** 15
    dist = [INF] * (N+1)
    dist[start] = 0
    q = [(0,start)]
    while q:
        d,v = heappop(q)
        if dist[v] < d:
            continue
        for w,*a in graph[v]:
            d1 = d + a[mode]
            if dist[w] > d1:
                dist[w] = d1
                heappush(q, (d1,w))
    return dist

d1 = np.array(dijkstra(S,0))
d2 = np.array(dijkstra(T,1))

d1 += d2
answer = 10 ** 15 - np.minimum.accumulate(d1[::-1])[::-1][1:]
print('\n'.join(map(str, answer.tolist())))

Buggy python submission (verdict: Time Limit Exceeded):
import sys
import numpy as np
from scipy.sparse.csgraph import dijkstra
from scipy.sparse import csr_matrix

read = sys.stdin.read
readline = sys.stdin.readline

n, m, s, t, *uvab = map(int, read().split())
s -= 1
t -= 1
u = np.array(uvab[::4], np.int64) - 1
v = np.array(uvab[1::4], np.int64) - 1
a = np.array(uvab[2::4], np.float_)
b = np.array(uvab[3::4], np.float_)

yen_matrix = csr_matrix((a, (u, v)), shape=(n, n))
snuuk_matrix = csr_matrix((b, (u, v)), shape=(n, n))

yen = dijkstra(yen_matrix, directed=False, indices=s)
snuuk = dijkstra(snuuk_matrix, directed=False, indices=t)

costs = (yen + snuuk).astype(int)
answer = 10 ** 15 - np.minimum.accumulate(costs[::-1])[::-1]
print(*answer.tolist(), sep='\n')


Fixed submission:
import sys
input = sys.stdin.read
sys.setrecursionlimit(10 ** 7)

import numpy as np
from heapq import heappush, heappop

N,M,S,T, *uvab = map(int,input().split())
graph = [[] for _ in range(N+1)]
for u,v,a,b in zip(*[iter(uvab)]*4):
    graph[u].append((v,a,b))
    graph[v].append((u,a,b))

def dijkstra(start, mode):
    INF = 10 ** 15
    dist = [INF] * (N+1)
    dist[start] = 0
    q = [(0,start)]
    while q:
        d,v = heappop(q)
        if dist[v] < d:
            continue
        for w,*a in graph[v]:
            d1 = d + a[mode]
            if dist[w] > d1:
                dist[w] = d1
                heappush(q, (d1,w))
    return dist

d1 = np.array(dijkstra(S,0))
d2 = np.array(dijkstra(T,1))

d1 += d2
answer = 10 ** 15 - np.minimum.accumulate(d1[::-1])[::-1][1:]
print('\n'.join(map(str, answer.tolist())))

Buggy python submission (verdict: Time Limit Exceeded):
import sys
import numpy as np
from scipy.sparse.csgraph import dijkstra
from scipy.sparse import csr_matrix

read = sys.stdin.read
readline = sys.stdin.readline

n, m, s, t, *uvab = map(int, read().split())
s -= 1
t -= 1
u = np.array(uvab[::4], np.int64) - 1
v = np.array(uvab[1::4], np.int64) - 1
a = np.array(uvab[2::4], np.int64)
b = np.array(uvab[3::4], np.int64)

yen_matrix = csr_matrix((a, (u, v)), shape=(n, n))
snuuk_matrix = csr_matrix((b, (u, v)), shape=(n, n))

yen = dijkstra(yen_matrix, directed=False, indices=s)
snuuk = dijkstra(snuuk_matrix, directed=False, indices=t)

costs = (yen + snuuk).astype(int)
answer = 10 ** 15 - np.minimum.accumulate(costs[::-1])[::-1]
print(*answer.tolist(), sep='\n')


Fixed submission:
import sys
input = sys.stdin.read
sys.setrecursionlimit(10 ** 7)

import numpy as np
from heapq import heappush, heappop

N,M,S,T, *uvab = map(int,input().split())
graph = [[] for _ in range(N+1)]
for u,v,a,b in zip(*[iter(uvab)]*4):
    graph[u].append((v,a,b))
    graph[v].append((u,a,b))

def dijkstra(start, mode):
    INF = 10 ** 15
    dist = [INF] * (N+1)
    dist[start] = 0
    q = [(0,start)]
    while q:
        d,v = heappop(q)
        if dist[v] < d:
            continue
        for w,*a in graph[v]:
            d1 = d + a[mode]
            if dist[w] > d1:
                dist[w] = d1
                heappush(q, (d1,w))
    return dist

d1 = np.array(dijkstra(S,0))
d2 = np.array(dijkstra(T,1))

d1 += d2
answer = 10 ** 15 - np.minimum.accumulate(d1[::-1])[::-1][1:]
print('\n'.join(map(str, answer.tolist())))

Buggy python submission (verdict: Time Limit Exceeded):
import sys
import numpy as np
from scipy.sparse.csgraph import dijkstra
from scipy.sparse import csr_matrix

read = sys.stdin.read
readline = sys.stdin.readline

n, m, s, t, *uvab = map(int, read().split())
u = np.array(uvab[::4], np.int64)
v = np.array(uvab[1::4], np.int64)
a = np.array(uvab[2::4], np.int64)
b = np.array(uvab[3::4], np.int64)

yen_matrix = csr_matrix((a, (u, v)), shape=(n + 1, n + 1))
snuuk_matrix = csr_matrix((b, (u, v)), shape=(n + 1, n + 1))

yen = dijkstra(yen_matrix, directed=False, indices=s)
snuuk = dijkstra(snuuk_matrix, directed=False, indices=t)

costs = (yen[1:] + snuuk[1:]).astype(int)
answer = 10 ** 15 - np.minimum.accumulate(costs[::-1])[::-1]
print('\n'.join(map(str, answer.tolist())))


Fixed submission:
import sys
input = sys.stdin.read
sys.setrecursionlimit(10 ** 7)

import numpy as np
from heapq import heappush, heappop

N,M,S,T, *uvab = map(int,input().split())
graph = [[] for _ in range(N+1)]
for u,v,a,b in zip(*[iter(uvab)]*4):
    graph[u].append((v,a,b))
    graph[v].append((u,a,b))

def dijkstra(start, mode):
    INF = 10 ** 15
    dist = [INF] * (N+1)
    dist[start] = 0
    q = [(0,start)]
    while q:
        d,v = heappop(q)
        if dist[v] < d:
            continue
        for w,*a in graph[v]:
            d1 = d + a[mode]
            if dist[w] > d1:
                dist[w] = d1
                heappush(q, (d1,w))
    return dist

d1 = np.array(dijkstra(S,0))
d2 = np.array(dijkstra(T,1))

d1 += d2
answer = 10 ** 15 - np.minimum.accumulate(d1[::-1])[::-1][1:]
print('\n'.join(map(str, answer.tolist())))

Buggy python submission (verdict: Time Limit Exceeded):
import sys
import numpy as np
from scipy.sparse.csgraph import dijkstra
from scipy.sparse import csr_matrix
from operator import itemgetter

read = sys.stdin.read
readline = sys.stdin.readline

n, m, s, t, *uvab = map(int, read().split())
u = np.array(uvab[::4], np.int64)
v = np.array(uvab[1::4], np.int64)
a = np.array(uvab[2::4], np.int64)
b = np.array(uvab[3::4], np.int64)

yen_matrix = csr_matrix((a, (u, v)), shape=(n + 1, n + 1))
snuuk_matrix = csr_matrix((b, (u, v)), shape=(n + 1, n + 1))

yen = dijkstra(yen_matrix, directed=False, indices=s)[1:]
snuuk = dijkstra(snuuk_matrix, directed=False, indices=t)[1:]

costs = (yen + snuuk).astype(int)
costs = sorted(zip(range(1, n + 1), costs.tolist()), key=itemgetter(1), reverse=True)

money = 10 ** 15
city, cost = costs.pop()
for i in range(n):
    if city <= i:
        while True:
            city, cost = costs.pop()
            if city > i:
                break
    print(money - cost)


Fixed submission:
import sys
input = sys.stdin.read
sys.setrecursionlimit(10 ** 7)

import numpy as np
from heapq import heappush, heappop

N,M,S,T, *uvab = map(int,input().split())
graph = [[] for _ in range(N+1)]
for u,v,a,b in zip(*[iter(uvab)]*4):
    graph[u].append((v,a,b))
    graph[v].append((u,a,b))

def dijkstra(start, mode):
    INF = 10 ** 15
    dist = [INF] * (N+1)
    dist[start] = 0
    q = [(0,start)]
    while q:
        d,v = heappop(q)
        if dist[v] < d:
            continue
        for w,*a in graph[v]:
            d1 = d + a[mode]
            if dist[w] > d1:
                dist[w] = d1
                heappush(q, (d1,w))
    return dist

d1 = np.array(dijkstra(S,0))
d2 = np.array(dijkstra(T,1))

d1 += d2
answer = 10 ** 15 - np.minimum.accumulate(d1[::-1])[::-1][1:]
print('\n'.join(map(str, answer.tolist())))

Buggy python submission (verdict: Runtime Error):
import sys
import numpy as np
from scipy.sparse.csgraph import shortest_path
from scipy.sparse import csr_matrix
from operator import itemgetter

read = sys.stdin.read
readline = sys.stdin.readline

n, m, s, t, *uvab = map(int, read().split())
u = np.array(uvab[::4], np.int64)
v = np.array(uvab[1::4], np.int64)
a = np.array(uvab[2::4], np.int64)
b = np.array(uvab[3::4], np.int64)

yen_matrix = csr_matrix((a, (u, v)), shape=(n + 1, n + 1))
snuuk_matrix = csr_matrix((b, (u, v)), shape=(n + 1, n + 1))

yen = shortest_path(yen_matrix, directed=False, indices=s)[1:]
snuuk = shortest_path(snuuk_matrix, directed=False, indices=t)[1:]

costs = (yen + snuuk).astype(int)
costs = sorted(zip(range(1, n + 1), costs.tolist()), key=itemgetter(1), reverse=True)

money = 10 ** 15
city, cost = costs.pop()
for i in range(n):
    if city <= i:
        while True:
            city, cost = costs.pop()
            if city > i:
                break
    print(money - cost)


Fixed submission:
import sys
input = sys.stdin.read
sys.setrecursionlimit(10 ** 7)

import numpy as np
from heapq import heappush, heappop

N,M,S,T, *uvab = map(int,input().split())
graph = [[] for _ in range(N+1)]
for u,v,a,b in zip(*[iter(uvab)]*4):
    graph[u].append((v,a,b))
    graph[v].append((u,a,b))

def dijkstra(start, mode):
    INF = 10 ** 15
    dist = [INF] * (N+1)
    dist[start] = 0
    q = [(0,start)]
    while q:
        d,v = heappop(q)
        if dist[v] < d:
            continue
        for w,*a in graph[v]:
            d1 = d + a[mode]
            if dist[w] > d1:
                dist[w] = d1
                heappush(q, (d1,w))
    return dist

d1 = np.array(dijkstra(S,0))
d2 = np.array(dijkstra(T,1))

d1 += d2
answer = 10 ** 15 - np.minimum.accumulate(d1[::-1])[::-1][1:]
print('\n'.join(map(str, answer.tolist())))