Language: C++

#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const double pi = acos(-1);

const ll MAX_V = 50;
const ll MAX_S = MAX_V*50+5;

struct Edge {
    ll to, a, b;
};

struct Data {
    ll v, s, x;
    bool operator<(const Data& a) const {
        return x > a.x;
    }
};

int main() {
    ll n, m, s;
    cin >> n >> m >> s;
    chmin(s, MAX_S);
    
    vector<vector<Edge>> G(MAX_V);
    rep(i, m) {
        ll u, v, a, b;
        cin >> u >> v >> a >> b;
        u--;  v--;
        G[u].emplace_back(v, a, b);
        G[v].emplace_back(u, a, b);
    }

    vvl dp(MAX_V, vl(MAX_S+10, INF));
    priority_queue<Data> Q;
    auto push = [&](ll v, ll s, ll x) {
        if(s < 0) {
            return;
        }
        if(dp[v][s] <= x) {
            return;
        }
        dp[v][s] = x;
        Q.emplace(v, s, x);
    };
    
    vl c(n), d(n);
    rep(i, n) {
        cin >> c[i] >> d[i];
    }

    push(0, s, 0);
    while(!Q.empty()) {
        Data hoge = Q.top();  Q.pop();
        ll v = hoge.v, s = hoge.s, x = hoge.x;
        if(dp[v][s] != x) {
            continue;
        }
        ll ns = min(s + c[v], MAX_S);
        push(v, ns, x + d[v]);
        for(Edge e : G[v]) {
            push(e.to, s - e.a, x + e.b);
        }
    }

    exrep(i, 1, n-1) {
        ll ans = INF;
        rep(j, MAX_S+10) {
            chmin(ans, dp[i][j]);
        }
        out(ans);
    }

    re0;
}

Compiler output:
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/c++allocator.h:33,
                 from /usr/include/c++/14/bits/allocator.h:46,
                 from /usr/include/c++/14/string:43,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/new_allocator.h: In instantiation of 'void std::__new_allocator<_Tp>::construct(_Up*, _Args&& ...) [with _Up = Edge; _Args = {long long int&, long long int&, long long int&}; _Tp = Edge]':
/usr/include/c++/14/bits/alloc_traits.h:575:17:   required from 'static void std::allocator_traits<std::allocator<_CharT> >::construct(allocator_type&, _Up*, _Args&& ...) [with _Up = Edge; _Args = {long long int&, long long int&, long long int&}; _Tp = Edge; allocator_type = std::allocator<Edge>]'
  575 |           __a.construct(__p, std::forward<_Args>(__args)...);
      |           ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/vector.tcc:117:30:   required from 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::emplace_back(_Args&& ...) [with _Args = {long long int&, long long int&, long long int&}; _Tp = Edge; _Alloc = std::allocator<Edge>; reference = Edge&]'
  117 |             _Alloc_traits::construct(this->_M_impl, this->_M_impl._M_finish,
      |             ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  118 |                                      std::forward<_Args>(__args)...);
      |                                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:59:26:   required from here
   59 |         G[u].emplace_back(v, a, b);
      |         ~~~~~~~~~~~~~~~~~^~~~~~~~~
/usr/include/c++/14/bits/new_allocator.h:191:11: error: new initializer expression list treated as compound expression [-fpermissive]
  191 |         { ::new((void *)__p) _Up(std::forward<_Args>(__args)...); }
      |           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/new_allocator.h:191:11: error: no matching function for call to 'Edge::Edge(long long int&)'
a.cc:38:8: note: candidate: 'Edge::Edge()'
   38 | struct Edge {
      |        ^~~~
a.cc:38:8: note:   candidate expects 0 arguments, 1 provided
a.cc:38:8: note: candidate: 'constexpr Edge::Edge(const Edge&)'
a.cc:38:8: note:   no known conversion for argument 1 from 'long long int' to 'const Edge&'
a.cc:38:8: note: candidate: 'constexpr Edge::Edge(Edge&&)'
a.cc:38:8: note:   no known conversion for argument 1 from 'long long int' to 'Edge&&'
/usr/include/c++/14/bits/new_allocator.h: In instantiation of 'void std::__new_allocator<_Tp>::construct(_Up*, _Args&& ...) [with _Up = Data; _Args = {long long int&, long long int&, long long int&}; _Tp = Data]':
/usr/include/c++/14/bits/alloc_traits.h:575:17:   required from 'static void std::allocator_traits<std::allocator<_CharT> >::construct(allocator_type&, _Up*, _Args&& ...) [with _Up = Data; _Args = {long long int&, long long int&, long long int&}; _Tp = Data; allocator_type = std::allocator<Data>]'
  575 |           __a.construct(__p, std::forward<_Args>(__args)...);
      |           ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/vector.tcc:117:30:   required from 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::emplace_back(_Args&& ...) [with _Args = {long long int&, long long int&, long long int&}; _Tp = Data; _Alloc = std::allocator<Data>; reference = Data&]'
  117 |             _Alloc_traits::construct(this->_M_impl, this->_M_impl._M_finish,
      |             ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  118 |                                      std::forward<_Args>(__args)...);
      |                                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_queue.h:754:18:   required from 'void std::priority_queue<_Tp, _Sequence, _Compare>::emplace(_Args&& ...) [with _Args = {long long int&, long long int&, long long int&}; _Tp = Data; _Sequence = std::vector<Data, std::allocator<Data> >; _Compare = std::less<Data>]'
  754 |           c.emplace_back(std::forward<_Args>(__args)...);
      |           ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:73:18:   required from here
   73 |         Q.emplace(v, s, x);
      |         ~~~~~~~~~^~~~~~~~~
/usr/include/c++/14/bits/new_allocator.h:191:11: error: new initializer expression list treated as compound expression [-fpermissive]
  191 |         { ::new((void *)__p) _Up(std::forward<_Args>(__args)...); }
      |           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/new_allocator.h:191:11: error: no matching function for call to 'Data::Data(long long int&)'
a.cc:42:8: note: candidate: 'Data::Data()'
   42 | struct Data {
      |        ^~~~
a.cc:42:8: note:   candidate expects 0 arguments, 1 provided
a.cc:42:8: note: candidate: 'constexpr Data::Data(const Data&)'
a.cc:42:8: note:   no known conversion for argument 1 from 'long long int' to 'const Data&'
a.cc:42:8: note: candidate: 'constexpr Data::Data(Data&&)'
a.cc:42:8: note:   no known conversion for argument 1 from 'long long int' to 'Data&&'