Language: C++

#include <bits/stdc++.h>
using namespace std;

//////////////////////////////   Begin Macros

#define all(x) (x).begin(), (x).end()
#define rep(i, N) for (int i = 0; i < (int)(N); i++)
#define reprev(i, N) for (int i = (int)(N)-1; i >= 0; i--)
#define rep1(i, N) for (int i = 1; i <= (int)(N); i++)
#define rep1rev(i, N) for (int i = (int)(N); i >= 0; i--)
#define forbe(i, b, e) for (int i = (b); i < (e); i++)
#define forberev(i, b, e) for (int i = (e)-1; i >= (b); i--)
#define forfl(i, f, l) for (int i = (f); i <= (l); i++)
#define forflrev(i, f, l) for (int i = (l); i >= (f); i--)
using ll = long long int;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;

template <typename T>
bool chmax(T &m, const T q)
{
  if (m < q)
  {
    m = q;
    return true;
  }
  else
    return false;
}
template <typename T>
bool chmin(T &m, const T q)
{
  if (m > q)
  {
    m = q;
    return true;
  }
  else
    return false;
}
template <typename T1, typename T2>
pair<T1, T2> operator+(const pair<T1, T2> &l, const pair<T1, T2> &r) { return {l.first + r.first, l.second + r.second}; }
template <typename T1, typename T2>
pair<T1, T2> operator-(const pair<T1, T2> &l, const pair<T1, T2> &r) { return {l.first - r.first, l.second - r.second}; }
template <typename T>
pair<T, T> operator*(const pair<T, T> &l, const T &r) { return {l.first * r, l.second * r}; }
template <typename T>
pair<T, T> operator/(const pair<T, T> &l, const T &r) { return {l.first / r, l.second / r}; }
template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
  for (auto &v : vec)
    is >> v;
  return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec)
{
  os << "[";
  for (auto v : vec)
    os << v << ",";
  os << "]";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, const deque<T> &vec)
{
  os << "deq[";
  for (auto v : vec)
    os << v << ",";
  os << "]";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, const set<T> &vec)
{
  os << "{";
  for (auto v : vec)
    os << v << ",";
  os << "}";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, const unordered_set<T> &vec)
{
  os << "{";
  for (auto v : vec)
    os << v << ",";
  os << "}";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, const multiset<T> &vec)
{
  os << "{";
  for (auto v : vec)
    os << v << ",";
  os << "}";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, const unordered_multiset<T> &vec)
{
  os << "{";
  for (auto v : vec)
    os << v << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &pa)
{
  os << "(" << pa.first << "," << pa.second << ")";
  return os;
}
template <typename TK, typename TV>
ostream &operator<<(ostream &os, const map<TK, TV> &mp)
{
  os << "{";
  for (auto v : mp)
    os << v.first << "=>" << v.second << ",";
  os << "}";
  return os;
}
template <typename TK, typename TV>
ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp)
{
  os << "{";
  for (auto v : mp)
    os << v.first << "=>" << v.second << ",";
  os << "}";
  return os;
}

template <typename T>
void reset(vector<T> &v, const T reset_to)
{
  for (auto &x : v)
    x = reset_to;
}
inline int popcount(const unsigned int x) { return __builtin_popcount(x); }
#define dbg(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ") " << __FILE__ << endl;

ll nC2(ll n)
{
  return n * (n - 1) / 2;
}

const int intinf = numeric_limits<int>::max();
const ll llinf = numeric_limits<ll>::max();
const pii udlr[4] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};

//////////////////////////////   End Macros

#include "Graph.h"

int N, M, S;

vector<ll> dijkstra(const Graph<pli> &g, const int id_start, const ll INF)
{
  using Weight = pli;
  using Pwi = pair<Weight, int>;
  const int n = g.size();
  const int s_max = 50 * 100;
  const int s_init = min(S, s_max);

  vector<vector<ll>> d(s_max + 1, vector<ll>(n, INF));
  forfl(s, 0, s_init) d[s][id_start] = 0;
  vector<vector<bool>> is_used(s_max + 1, vector<bool>(n, false));
  priority_queue<Pwi, vector<Pwi>, greater<Pwi>> que;

  que.push(Pwi({0, s_init}, id_start));
  while (!que.empty())
  {
    const int id_src = que.top().second; // que.top().first >= d[id_src]
    const int s_src = min(que.top().first.second, s_max);
    que.pop();

    if (is_used[s_src][id_src])
      continue;
    for (int s = s_src; s >= 0 and !is_used[s][id_src]; s--)
      is_used[s][id_src] = true;

    for (const auto &edge : g[id_src].edges)
    {
      const int id_dst = edge.id_dst;
      const int s_new = min(s_src + edge.weight.second, s_max);
      const ll d_new = d[s_src][id_src] + edge.weight.first;

      if (!(s_new >= 0 and d[s_new][id_dst] > d_new))
        continue;

      for (int s = s_new; s >= 0 and d[s][id_dst] > d_new; s--)
        d[s][id_dst] = d_new;

      que.push({{d[s_new][id_dst], s_new}, id_dst});
    }
  }

  return d[0];
}

void solve()
{
  cin >> N >> M >> S;
  Graph<pli> g(N);
  rep(i, M)
  {
    int U, V, A, B;
    cin >> U >> V >> A >> B, U--, V--;
    g.add_edge(U, V, {B, -A});
    g.add_edge(V, U, {B, -A});
  }
  rep(i, N)
  {
    int C, D;
    cin >> C >> D;
    g.add_edge(i, i, {D, C});
  }

  vector<ll> ans = dijkstra(g, 0, llinf / 2);
  forbe(i, 1, N) cout << ans[i] << endl;
}

int main()
{
  // srand(time(0));
  cout << fixed << setprecision(15);

  solve();
  return 0;
}


Compiler output:
a.cc:157:10: fatal error: Graph.h: No such file or directory
  157 | #include "Graph.h"
      |          ^~~~~~~~~
compilation terminated.