Buggy python submission (verdict: Time Limit Exceeded):
from heapq import heappush, heappop

infi = 10 ** 20
n, m, s = map(int, input().split())
time_graph = [[] for _ in range(n + 1)]
money_graph = [[0] * (n + 1) for _ in range(n + 1)]
for _ in range(m):
    u, v, a, b = map(int, input().split())
    time_graph[v].append((b, u))
    time_graph[u].append((b, v))
    money_graph[u][v] = a
    money_graph[v][u] = a


rate = [(0, 0) for _ in range(n + 1)]
for i in range(1, n + 1):
    c, d = map(int, input().split())
    rate[i] = (c, d)

start = 1

time = [infi] * (n + 1)
time[start] = 0
que = [(0, s, start)]
cnt = 0
visited = set()
used_pair = set()
cnt = 0
while que:
    t_edge, m_edge, edge = heappop(que)
    if (t_edge, m_edge, edge) in used_pair:
        continue
    used_pair.add((t_edge, m_edge, edge))
    if time[edge] > t_edge:
        time[edge] = t_edge
    if not (edge in visited):
        cnt += 1
        visited.add(edge)
    if cnt == n:
        break
    delta_money, delta_time = rate[edge]
    heappush(que, (t_edge + delta_time, m_edge + delta_money, edge))
    for t_newedge, newedge in time_graph[edge]:
        newtime = t_edge + t_newedge
        newmoney = m_edge - money_graph[edge][newedge]
        if newmoney < 0:
            continue
        heappush(que, (newtime, newmoney, newedge))

print(*time[2:], sep="\n")


Fixed submission:
from heapq import heappush, heappop

infi = 10 ** 20
n, m, s = map(int, input().split())

s = min(s, 2500)

edges = [[] for _ in range(51 * 2501 + 1)]
# edge:1-50, max silver=0-2500

for _ in range(m):
    u, v, a, b = map(int, input().split())
    for i in range(a, 2501):
        edges[v + 50 * i].append((b, u + 50 * (i - a)))
        edges[u + 50 * i].append((b, v + 50 * (i - a)))


for edge_num in range(1, n + 1):
    c, d = map(int, input().split())
    # c枚, d分
    for i in range(2501):
        # 点edge_num+ i * 50のところに
        if edge_num + (i + c) * 50 <= 51 * 2501:
            edges[edge_num + i * 50].append((d, edge_num + min((i + c), 2500) * 50))
start = 1 + 50 * s


def dijkstra(edges, start):
    time = [infi] * (51 * 2501 + 1)
    used = [False] * (51 * 2501 + 1)
    # time[i][j] 頂点i, 銀貨jのときの時間
    time[start] = 0
    edgelist = []
    heappush(edgelist, (0, start))
    while edgelist:
        nowtime, nowedge = heappop(edgelist)
        if used[nowedge] is True:
            continue
        used[nowedge] = True
        time[nowedge] = nowtime
        for vt, v in edges[nowedge]:
            if used[v] is True:
                continue
            newtime = nowtime + vt
            heappush(edgelist, (newtime, v))
    return time


time = dijkstra(edges, start)

ans = [infi] * (51)
for i in range(1, 51 * 2501 + 1):
    temp = time[i]
    a = i % 50
    if a == 0:
        a += 50
    ans[a] = min(temp, ans[a])

print(*ans[2 : (n + 1)], sep="\n")

Buggy python submission (verdict: Time Limit Exceeded):
from heapq import heappush, heappop

infi = 10 ** 20
n, m, s = map(int, input().split())
time_graph = [[] for _ in range(n + 1)]
money_graph = [[0] * (n + 1) for _ in range(n + 1)]
for _ in range(m):
    u, v, a, b = map(int, input().split())
    time_graph[v].append((b, u))
    time_graph[u].append((b, v))
    money_graph[u][v] = a
    money_graph[v][u] = a


rate = [(0, 0) for _ in range(n + 1)]
for i in range(1, n + 1):
    c, d = map(int, input().split())
    rate[i] = (c, d)

start = 1

time = [infi] * (n + 1)
time[start] = 0
que = [(0, s, start)]
cnt = 0
visited = set()
cnt = 0
while que:
    t_edge, m_edge, edge = heappop(que)
    if time[edge] > t_edge:
        time[edge] = t_edge
    if not (edge in visited):
        cnt += 1
        visited.add(edge)
    if cnt == n:
        break
    delta_money, delta_time = rate[edge]
    heappush(que, (t_edge + delta_time, m_edge + delta_money, edge))
    for t_newedge, newedge in time_graph[edge]:
        newtime = t_edge + t_newedge
        newmoney = m_edge - money_graph[edge][newedge]
        if newmoney < 0:
            continue
        heappush(que, (newtime, newmoney, newedge))

print(*time[2:], sep="\n")


Fixed submission:
from heapq import heappush, heappop

infi = 10 ** 20
n, m, s = map(int, input().split())

s = min(s, 2500)

edges = [[] for _ in range(51 * 2501 + 1)]
# edge:1-50, max silver=0-2500

for _ in range(m):
    u, v, a, b = map(int, input().split())
    for i in range(a, 2501):
        edges[v + 50 * i].append((b, u + 50 * (i - a)))
        edges[u + 50 * i].append((b, v + 50 * (i - a)))


for edge_num in range(1, n + 1):
    c, d = map(int, input().split())
    # c枚, d分
    for i in range(2501):
        # 点edge_num+ i * 50のところに
        if edge_num + (i + c) * 50 <= 51 * 2501:
            edges[edge_num + i * 50].append((d, edge_num + min((i + c), 2500) * 50))
start = 1 + 50 * s


def dijkstra(edges, start):
    time = [infi] * (51 * 2501 + 1)
    used = [False] * (51 * 2501 + 1)
    # time[i][j] 頂点i, 銀貨jのときの時間
    time[start] = 0
    edgelist = []
    heappush(edgelist, (0, start))
    while edgelist:
        nowtime, nowedge = heappop(edgelist)
        if used[nowedge] is True:
            continue
        used[nowedge] = True
        time[nowedge] = nowtime
        for vt, v in edges[nowedge]:
            if used[v] is True:
                continue
            newtime = nowtime + vt
            heappush(edgelist, (newtime, v))
    return time


time = dijkstra(edges, start)

ans = [infi] * (51)
for i in range(1, 51 * 2501 + 1):
    temp = time[i]
    a = i % 50
    if a == 0:
        a += 50
    ans[a] = min(temp, ans[a])

print(*ans[2 : (n + 1)], sep="\n")

Buggy python submission (verdict: Time Limit Exceeded):
from heapq import heappush, heappop

infi = 10 ** 20
n, m, s = map(int, input().split())
time_graph = [[] for _ in range(n + 1)]
money_graph = [[0] * (n + 1) for _ in range(n + 1)]
for _ in range(m):
    u, v, a, b = map(int, input().split())
    time_graph[v].append((b, u))
    time_graph[u].append((b, v))
    money_graph[u][v] = a
    money_graph[v][u] = a


rate = [(0, 0) for _ in range(n + 1)]
for i in range(1, n + 1):
    c, d = map(int, input().split())
    rate[i] = (c, d)

start = 1

time = [infi] * (n + 1)
time[start] = 0
que = [(0, s, start)]
cnt = 0
visited = set()
cnt = 0
while que:
    t_edge, m_edge, edge = heappop(que)
    if time[edge] > t_edge:
        time[edge] = t_edge
    if not (edge in visited):
        cnt += 1
        visited.add(edge)
    if cnt == n:
        break
    delta_money, delta_time = rate[edge]
    heappush(que, (t_edge + delta_time, m_edge + delta_money, edge))
    for t_newedge, newedge in time_graph[edge]:
        newtime = t_edge + t_newedge
        newmoney = m_edge - money_graph[edge][newedge]
        if newmoney < 0:
            continue
        heappush(que, (newtime, newmoney, newedge))

print(*time[2:], sep="\n")


Fixed submission:
from heapq import heappush, heappop

infi = 10 ** 20
n, m, s = map(int, input().split())

s = min(s, 2500)

edges = [[] for _ in range(51 * 2501 + 1)]
# edge:1-50, max silver=0-2500

for _ in range(m):
    u, v, a, b = map(int, input().split())
    for i in range(a, 2501):
        edges[v + 50 * i].append((b, u + 50 * (i - a)))
        edges[u + 50 * i].append((b, v + 50 * (i - a)))


for edge_num in range(1, n + 1):
    c, d = map(int, input().split())
    # c枚, d分
    for i in range(2501):
        # 点edge_num+ i * 50のところに
        if edge_num + (i + c) * 50 <= 51 * 2501:
            edges[edge_num + i * 50].append((d, edge_num + min((i + c), 2500) * 50))
start = 1 + 50 * s


def dijkstra(edges, start):
    time = [infi] * (51 * 2501 + 1)
    used = [False] * (51 * 2501 + 1)
    # time[i][j] 頂点i, 銀貨jのときの時間
    time[start] = 0
    edgelist = []
    heappush(edgelist, (0, start))
    while edgelist:
        nowtime, nowedge = heappop(edgelist)
        if used[nowedge] is True:
            continue
        used[nowedge] = True
        time[nowedge] = nowtime
        for vt, v in edges[nowedge]:
            if used[v] is True:
                continue
            newtime = nowtime + vt
            heappush(edgelist, (newtime, v))
    return time


time = dijkstra(edges, start)

ans = [infi] * (51)
for i in range(1, 51 * 2501 + 1):
    temp = time[i]
    a = i % 50
    if a == 0:
        a += 50
    ans[a] = min(temp, ans[a])

print(*ans[2 : (n + 1)], sep="\n")