Language: C

#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
#include <numeric>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
//#define MOD 998244353
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
typedef vector<tint> vtint;
typedef vector<vint> vvint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=150;
//↑templete
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(auto i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
typedef long long Weight;
struct Edge {
  int src, dst;
  Weight weight;
  Edge(int src, int dst, Weight weight) :
    src(src), dst(dst), weight(weight) { }
};
bool operator < (const Edge &e, const Edge &f) {
  return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
    e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

typedef vector<Weight> Array;
typedef vector<Array> Matrix;
void shortestPath(const Graph &g, int s,
    vector<Weight> &dist, vector<int> &prev) {
  int n = g.size();
  dist.assign(n, INF); dist[s] = 0;
  prev.assign(n, -1);
  priority_queue<Edge> Q; // "e < f" <=> "e.weight > f.weight"
  for (Q.push(Edge(-2, s, 0)); !Q.empty(); ) {
    Edge e = Q.top(); Q.pop();
    if (prev[e.dst] != -1) continue;
    prev[e.dst] = e.src;
    FOR(f,g[e.dst]) {
      if (dist[f->dst] > e.weight+f->weight) {
        dist[f->dst] = e.weight+f->weight;
        Q.push(Edge(f->src, f->dst, e.weight+f->weight));
      }
    }
  }
}
vector<int> buildPath(const vector<int> &prev, int t) {
  vector<int> path;
  for (int u = t; u >= 0; u = prev[u])
    path.push_back(u);
  reverse(path.begin(), path.end());
  return path;
}

unordered_map<int, int> pam;
const int MONEY=2600;
int cnt=0;
inline int num(int idx, int money){
    int number=idx*MONEY*2+money;
    if(pam.find(number)!=pam.end()){
        return pam[number];
    }
    pam[number]=cnt;
    cnt++;
    return pam[number];
}


signed main(){

    int N, M, S;
    cin>>N>>M>>S;

    if(S>MONEY)
        S=MONEY;

    Graph G;
    for(int i=0;i<N*MONEY*3;i++){
        Edges E;
        G.push_back(E);
    }
    vector<tuple<int, int, int, int>> trains;
    vint C, D;
    for(int i=0;i<M;i++){
        int u, v, a, b;
        cin>>u>>v>>a>>b;
        u--, v--;
        trains.eb(u, v, a, b);
    }

    for(int i=0;i<N;i++){
        int c, d;
        cin>>c>>d;
        C.pb(c);
        D.pb(d);
    }

    //ダイクストラ
    for(int u=0;u<N;u++){
        for(int m=0;m<MONEY;m++){
            int s=num(u, m);
            int t=num(u, m+C[u]);
            if(m+C[u]<=MONEY)
                G[s].pb(Edge(s, t, D[u]));
        }
    }

    for(auto t:trains){
        int u, v, a, b;
        tie(u, v, a, b)=t;

        for(int um=0;um<=MONEY;um++){
            if(um-a<0)
                continue;

            int s=num(u, um), t=num(v, um-a);
            G[s].push_back(Edge(s, t, b));
        }
        for(int vm=0;vm<=MONEY;vm++){
            if(vm-a<0)
                continue;

            int s=num(v, vm), t=num(u, vm-a);
            G[s].push_back(Edge(s, t, b));
        }
    }

    vector<Weight> dist;
    vector<int> prev;
    shortestPath(G, num(0, S), dist, prev);

    // for(int d:dist)
    //     cout<<d<<" ";
    // cout<<endl;

    int s=num(0, S);
    for(int dst=1;dst<N;dst++){
        ll ans=INFLL;
        for(int m=0;m<=MONEY;m++){
            int n=num(dst, m);
            if(n<dist.size()){
                ans=min(ans, (ll)dist[n]);
                //cout<<dst<<" "<<m<<" "<<n<<" "<<dist[n]<<endl;
            }
        }
        cout<<ans<<endl;
    }

    return 0;
}


Compiler output:
main.c:3:10: fatal error: iostream: No such file or directory
    3 | #include <iostream>
      |          ^~~~~~~~~~
compilation terminated.