Language: C++

#pragma GCC optimize ("O3")
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
const ll inf = 3e9;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = 52;
const int M = 2455;

#define int unsigned int

int n, m, s;
ll dist[N][M+10];
bool vis[N][M+10];
   
vector<vector<int>> convert;
vector<vector<int>> v[N];

int32_t main(){_
   
   cin>>n>>m>>s;
   
   for (int i = 0; i < m; ++i)
   {
      int x, y, silver, time;
      cin >> x >> y >> silver >> time;
      v[x].push_back({y, silver, time});
      v[y].push_back({x, silver, time});
   }

   convert.resize(n+1);
   for (int i = 1; i <= n; ++i)
   {
      int c, d;
      cin >> c >> d;
      convert[i] = {c, d};
   }

   for (int i = 0; i < N; ++i)
   {
      for (int j = 0; j <= M; ++j)
      {
         dist[i][j] = 1e18;
      }
   }

   s = (int)min(s*1LL, M*1LL);
   dist[1][s] = 0;

   set<vector<ll>> ms;//function of time
   ms.insert({0, s, 1}); // inserted time, silver coins, vertex

   vector<ll> ans(n+1, inf);
   while(!ms.empty()){
      vector<ll> f = *ms.begin();
      ms.erase(ms.begin());

      ll time = f[0], vertex = f[2], silvers = f[1];

      if (vis[vertex][silvers]){
         continue;
      }

      tr(f);//2500*50
      vis[vertex][silvers] = 1;
      smin(ans[vertex], time);
      for (int i = silvers + convert[vertex][0], ch = time + convert[vertex][1]; i <= M; i += convert[vertex][0], ch += convert[vertex][1])
      {
         if (dist[vertex][i] > ch){
            dist[vertex][i] = ch;
            ms.insert({ch, i, vertex});
         }
      }

      for(auto it: v[vertex]){
         int nxt_vertex = it[0];
         int required_silver = it[1];
         ll update_time = it[2];
         if (silvers >= required_silver){
            if (dist[nxt_vertex][silvers - required_silver] > dist[vertex][silvers] + update_time){
               dist[nxt_vertex][silvers - required_silver] = dist[vertex][silvers] + update_time;
               ms.insert({dist[vertex][silvers] + (ll)update_time, silvers - required_silver, nxt_vertex});
            }
         }
      }

   }

   for (int i = 2; i <= n; ++i)
   {
      cout<<ans[i]<<endl;
   }

   return 0;
}

Compiler output:
In file included from /usr/include/c++/14/string:43,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
                 from a.cc:4:
/usr/include/c++/14/bits/allocator.h: In destructor 'std::_Vector_base<unsigned int, std::allocator<unsigned int> >::_Vector_impl::~_Vector_impl()':
/usr/include/c++/14/bits/allocator.h:182:7: error: inlining failed in call to 'always_inline' 'std::allocator< <template-parameter-1-1> >::~allocator() noexcept [with _Tp = unsigned int]': target specific option mismatch
  182 |       ~allocator() _GLIBCXX_NOTHROW { }
      |       ^
In file included from /usr/include/c++/14/vector:66,
                 from /usr/include/c++/14/functional:64,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53:
/usr/include/c++/14/bits/stl_vector.h:132:14: note: called from here
  132 |       struct _Vector_impl
      |              ^~~~~~~~~~~~