Language: C++

#include<bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define eb emplace_back
#define emp emplace
#define ins insert
#define mp make_pair
#define mt make_tuple
#define sz(s) (int)s.size()
#define forp(i,a,b) for( int i=a;i<=b;i++)
#define rep(i,n)    for( int i=0;i<n;i++)
#define ren(i,n)    for( int i=n-1;i>=0;i--)
#define forn(i,a,b) for( int i=a;i>=b;i--)
#define w(t) while(t)
#define sc(a) scanf("%d", &a);
#define on cout<<"\n"
#define os cout <<" "
#define o2(a,b) cout<<a<<" "<<b
#define o(a) cout << a
#define ppr(a) cout << a.first << " " << a.second
#define bitcount __builtin_popcount
#define gcd __gcd
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define mem(n,m) memset(n,m,sizeof(n))
#define pii pair<int,int>
#define tiii tuple<int, int, int>
#define pll pair<long long,long long>
#define sii set<int>
#define sll set<long long>
#define vii vector<int>
#define vll vector<long long>
#define mii map<int,int>
#define mll map<long long, long long>
#define lob lower_bound
#define upb upper_bound
#define ret return
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define ford(container, it) for(auto it = container.begin(); it != container.end(); it++)
#define fors(container, it, a, b) for(auto it = a; it != b; it++)
#define boost ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define MOD   1000000007
#define EPSILON 1e-9
#define PI acos(-1)
#define int long long
#define inf 1e16
#define debug(a) cerr<<#a<<": ";for(auto i:a)cerr<<i<<" ";cerr<<'\n';
#define trace(a) cerr<<#a<<": "<<a<<"\n"
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>


typedef long long  ll;
typedef long double  ldo;
typedef double  db ;
using namespace std;
auto start = std::chrono::system_clock::now();
inline void skj()
{
std::chrono::time_point<std::chrono::system_clock> end;
end = std::chrono::system_clock::now();
std::chrono::duration<double> elapsed_seconds = end - start;
std::time_t end_time = std::chrono::system_clock::to_time_t(end);
cerr<<"Time taken " << elapsed_seconds.count()*1000<<"\n";
}

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//uniform_int_distribution<int> ud(1, 100); use this for random number generator
int csrand(int l=0, int r=1e9){
    uniform_int_distribution<int> uid(l, r);
    return uid(rng);
}
    //custom hash for unordered map
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
inline int binexp(int a,int b,int m)
{
    if(a == 0) {
        ret 0;
    }
    int res=1;
    a%=m;
    while(b)
    {
        if(b&1)
            res=(res*1ll*a)%m;
        a=(a*1ll*a)%m;
        b>>=1;
    }
    return res;
}
inline int binmul(int a, int b, int m) {
    a %= m;
    int res = 0;
    w(b) {
        if(b & 1) {
            res = (res + a) % m;
        }
        a = (a + a) % m;
        b >>= 1;
    }
    ret res;
}
const int N = 55;
vii g[N];
vector<pii> cost[N];
bool visit[N][5005];
int C[N], D[N], dis[N];
inline void solve_me_senpai() {
    int n, m, s;
    cin >> n >> m >> s;
    s = min(s, 5001ll);
    rep(i, m) {
        int u, v, a, b;
        cin >> u >> v >> a >> b;
        g[u].pb(v);
        g[v].pb(u);
        cost[u].pb({a, b});
        cost[v].pb({a, b});
    }
    forp(i, 1, n) {
        cin >> C[i] >> D[i];
        dis[i] = inf;
    }
    dis[1] = 0;
    multiset<pair<int, pii>> ms;
    ms.ins({0, {1, s}});
    w(sz(ms)) {
        auto x = *ms.begin();
        ms.erase(x);
        if(visit[x.ss.ff][x.ss.ss]) {
            continue;
        }
       // cout << x.ss.ff << " " << x.ss.ss << " " << x.ff << "\n";
        visit[x.ss.ff][x.ss.ss] = 1;
        rep(i, sz(g[x.ss.ff])) {
            int it = g[x.ss.ff][i];
            if(x.ss.ss == 5001) {
                if(!visit[it][5001]) {
                    dis[it] = min(dis[it], x.ff + cost[x.ss.ff][i].ss);
                    ms.ins({x.ff + cost[x.ss.ff][i].ss, {it, 5001}});
                }
            } else if(x.ss.ss >= cost[x.ss.ff][i].ff and !visit[it][x.ss.ss - cost[x.ss.ff][i].ff]) {
                dis[it] = min(dis[it], x.ff + cost[x.ss.ff][i].ss);
                ms.ins({x.ff + cost[x.ss.ff][i].ss, {it, x.ss.ss - cost[x.ss.ff][i].ff}});
                //cout << it << " " << x.ss.ff << " " << x.ss.ss << " " << dis[x.ss.ff] + cost[x.ss.ff][i].ss << "*\n";
            }
        }
        if(x.ss.ss == 5001) {
            continue;
        }
        if(!visit[x.ss.ff][min(5001ll, x.ss.ss + C[x.ss.ff])]) {
            ms.ins({x.ff + D[x.ss.ff], {x.ss.ff, min(5001ll, x.ss.ss + C[x.ss.ff])}});
        }
    }
    forp(i, 2, n) cout << dis[i] << "\n";
}
int32_t main()
{
    boost
    int t = 1;
   // cin >> t;
    int a = 1;
    while(t--) {
        //cout << "Case #" << a  << ": ";
        solve_me_senpai();
        a++;
    }
    //skj();
    return 0;
}

Compiler output:
a.cc: In function 'void solve_me_senpai()':
a.cc:145:12: error: reference to 'visit' is ambiguous
  145 |         if(visit[x.ss.ff][x.ss.ss]) {
      |            ^~~~~
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:121:6: note:                 'bool visit [55][5005]'
  121 | bool visit[N][5005];
      |      ^~~~~
a.cc:149:9: error: reference to 'visit' is ambiguous
  149 |         visit[x.ss.ff][x.ss.ss] = 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:121:6: note:                 'bool visit [55][5005]'
  121 | bool visit[N][5005];
      |      ^~~~~
a.cc:153:21: error: reference to 'visit' is ambiguous
  153 |                 if(!visit[it][5001]) {
      |                     ^~~~~
/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:121:6: note:                 'bool visit [55][5005]'
  121 | bool visit[N][5005];
      |      ^~~~~
a.cc:157:59: error: reference to 'visit' is ambiguous
  157 |             } else if(x.ss.ss >= cost[x.ss.ff][i].ff and !visit[it][x.ss.ss - cost[x.ss.ff][i].ff]) {
      |                                                           ^~~~~
/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:121:6: note:                 'bool visit [55][5005]'
  121 | bool visit[N][5005];
      |      ^~~~~
a.cc:166:13: error: reference to 'visit' is ambiguous
  166 |         if(!visit[x.ss.ff][min(5001ll, x.ss.ss + C[x.ss.ff])]) {
      |             ^~~~~
/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:121:6: note:                 'bool visit [55][5005]'
  121 | bool visit[N][5005];
      |      ^~~~~