Language: C++

#include <iostream>
#include <string>
#include <cstring>
#include <stack>
#include <queue>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <stdlib.h>
#include <tuple>
#include <iomanip>
#include <iterator>
#include <stdio.h>
#include <fstream>
#include <time.h>
using namespace std;
const double PI = 3.14159265358979323846;
const long long int MOD = 1000000000 + 7;

struct UnionFind {
    vector<int> parent;

    UnionFind(int N) : parent(N) {
        for (int i = 0; i < N; i++) {
            parent[i] = -1;
        }
    }

    int root(int i) {
        if (parent[i] < 0) {
            return i;
        }
        return (parent[i] = root(parent[i]));
    }

    bool unite(int from, int to) {
        int rx = root(from);
        int ry = root(to);
        if (rx != ry) {
            parent[ry] += parent[rx];
            parent[rx] = ry;

            return true;
        }
        else {
            return false;
        }
    }

    bool same(int x, int y) {
        return root(x) == root(y);
    }

    int treeSize(int x) {


        return -parent[root(x)];
    }
};

long long int modpow(long long int base, long long int pow, long long int mod) {
    if (pow == 1) {
        return base;
    }
    else if (pow == 0) {
        return 1;
    }

    if (pow % 2 == 0) {
        auto temp = modpow(base, pow / 2, mod);
        return (temp * temp) % mod;
    }
    else {
        return (base * modpow(base, pow - 1, mod)) % mod;
    }
}

long long int moddiv(long long int X, long long int Y, long long int mod) {
    auto fermatDiv = modpow(Y, mod - 2, mod);

    return (X * fermatDiv) % mod;
}

long long modCombination(long long left, long long right, long long int mod) {
    long long answer = 1;
    if (left > right) {
        for (long long i = 0; i < right; i++) {
            answer = (answer * (left - i)) % mod;
            answer = moddiv(answer, (i + 1), mod);
        }
    }
    return answer;
}

bool IsPrime(long long N) {
    if (N == 1) {
        return false;
    }
    for (long long i = 2; i * i <= N; i++) {
        if (N % i == 0) {
            return false;
        }
    }


    return true;
}



vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0; // 指数

        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }

        // その結果を push
        res.push_back({ a, ex });
    }

    // 最後に残った数について
    if (N != 1) res.push_back({ N, 1 });
    return res;
}

long long euclid(long long a, long long b) {
    if (a > b) {
        long long temp = b;
        b = a;
        a = temp;
    }
    if (b % a == 0) {
        return a;
    }
    else {
        return euclid(a, b - a);
    }
}

long long gcd(long long a, long long b) {
    if (b > a) {
        long long temp = b;
        b = a;
        a = temp;
    }
    //cout << "a:" << a << "b:" << b << endl;
    long long c = a % b;
    if (c == 0) {
        return b;
    }
    else {
        return gcd(b, c);
    }
}


struct State {
    long long town;
    long long money;
    long long time;

    State(long long _town, long long _money, long long _time) {
        town = _town;
        money = _money;
        time = _time;
    }

    bool operator<(const State& s) const {
        return this->time > s.time;
    }
};

struct Edge {
    long long to, time, money;
    Edge(long long _to, long long _money, long long _time) {
        to = _to;
        time = _time;
        money = _money;
    }
};

int main() {
    long long N, M, S;
    cin >> N >> M >> S;
    vector<vector<Edge>> edges(N + 1);
    for (int i = 0; i < M; i++) {
        long long u, v, a, b;
        cin >> u >> v >> a >> b;
        edges[u].emplace_back(v, a, b);
        edges[v].emplace_back(u, a, b);
    }

    const long long maxMoney = 50 * (N - 1) + 5;

    S = min(S, maxMoney);

    vector<pair<long long, long long>> changes(N + 1);
    for (int i = 1; i <= N; i++) {
        long long c, d;
        cin >> c >> d;
        changes[i] = make_pair(c, d);
    }

    vector<vector<long long>> dp(N + 1, vector<long long>(maxMoney + 1));

    for (int i = 0; i <= N; i++) {
        for (int j = 0; j <= maxMoney; j++) {
            dp[i][j] = LLONG_MAX;
            //cout << i << ":" << j << ":" << dp[i][j] << endl;
        }
    }


    priority_queue<State> Q;
    auto push = [&](long long town, long long money, long long time) {
        //cout << "push" << town << ":" << money << ":" << time << endl;
        if (money < 0) {
            return;
        }
        if (dp[town][money] <= time) {
            return;
        }
        dp[town][money] = time;
        Q.emplace(town, money, time);
    };


    push(1, S, 0);
    while (!Q.empty()) {
        auto state = Q.top();
        Q.pop();
        long long town = state.town, money = state.money, time = state.time;
        //cout << dp[town][money] << ":" << time << endl;
        //cout << town << ":" << money << endl;
        if (dp[town][money] < time) {
            continue;
        }
        //cout << "change money:" << money + changes[town].first << ":" << maxMoney << endl;

        if (money + changes[town].first <= maxMoney) {
            push(town, money + changes[town].first, time + changes[town].second);
        }

        for (auto e : edges[town]) {
            //cout << "move : " << e.to << endl;
            push(e.to, money - e.money, time + e.time);
        }
    }

    for (int i = 2; i <= N; i++) {
        long long answer = LLONG_MAX;

        for (auto time : dp[i]) {
            if (answer > time) {
                answer = time;
            }
        }

        cout << answer << endl;
    }
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:217:24: error: 'LLONG_MAX' was not declared in this scope
  217 |             dp[i][j] = LLONG_MAX;
      |                        ^~~~~~~~~
a.cc:18:1: note: 'LLONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
   17 | #include <fstream>
  +++ |+#include <climits>
   18 | #include <time.h>
a.cc:260:28: error: 'LLONG_MAX' was not declared in this scope
  260 |         long long answer = LLONG_MAX;
      |                            ^~~~~~~~~
a.cc:260:28: note: 'LLONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'