Language: C++

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

typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<ll, pair<ll,ll>> plll;

const ll INF = 1e18;

#define F first
#define S second
#define MP make_pair

priority_queue<plll, vector<plll>, greater<plll>> Q;
vector<pair<int,pll>> graph[60];
int N, M;
map<ll,ll> ans[60];
map<ll,bool> chk[60];
ll S;
ll C[60], D[60];
bool visit[60];
ll remain;

int main()
{
    scanf("%d%d%lld", &N, &M, &S);
    for(int i=1; i<=M; ++i){
        int x, y;
        scanf("%d%d", &x, &y);
        ll c, m;
        scanf("%lld%lld", &c, &m);
        graph[x].push_back(MP(y, MP(m, c)));
        graph[y].push_back(MP(x, MP(m, c)));
    }
    for(int i=1; i<=N; ++i){
        scanf("%lld%lld", &C[i], &D[i]);
    }
    ans[1][S] = 0; Q.push(MP(0, MP(1, S)));
    for(ll i=S+C[1]; ; i+=C[1]){
        ans[1][i] = (i-S)/C[1]*D[1];
        Q.push(MP((i-S)/C[1]*D[1], MP(1, i)));
        if(i > 5000) break;
    }
    remain = N;
    while(!Q.empty() && remain > 0){
        plll T = Q.top(); Q.pop();
        ll min = T.F;
        ll cur = T.S.F;
        ll cost = T.S.S;
        if(visit[cur] == false) --remain;
        visit[cur] = true;
        //printf("%lld %lld %lld\n", cur, min, cost);
        //printf("Heap Size: %lld\n", Q.size());
        if(ans[cur][cost] < min) continue;
        if(ans[cur][cost] == min && chk[cur].find(cost) != chk[cur].find(cost)) continue;
        chk[cur][cost] = true;
        if(cost < 5000){
            for(ll i=cost+C[cur]; ; i+=C[cur]){
                ll tmp = min + (i-cost)/C[cur]*D[cur];
                if(ans[cur].find(i) == ans[cur].end() || ans[cur][i] > tmp){
                    ans[cur][i] = tmp;
                    Q.push(MP(tmp, MP(cur, i)));
                }
                if(i > 5000) break;
            }
        }
        for(auto X : graph[cur]){
            ll nex = X.F;
            ll mi = X.S.F;
            ll co = X.S.S;
            if(cost < co) continue;
            if(ans[nex].find(cost-co) == ans[nex].end() || ans[nex][cost-co] > min+mi){
                ans[nex][cost-co] = min+mi;
                Q.push(MP(min+mi, MP(nex, cost-co)));
            }
        }
    }
    for(int i=2; i<=N; ++i){
        ll a = INF;
        for(auto X : ans[i]){
            a = min(X.S, a);
        }
        printf("%lld\n", a);
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:50:12: error: reference to 'visit' is ambiguous
   50 |         if(visit[cur] == false) --remain;
      |            ^~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:80,
                 from a.cc:1:
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:21:6: note:                 'bool visit [60]'
   21 | bool visit[60];
      |      ^~~~~
a.cc:51:9: error: reference to 'visit' is ambiguous
   51 |         visit[cur] = true;
      |         ^~~~~
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:21:6: note:                 'bool visit [60]'
   21 | bool visit[60];
      |      ^~~~~