Language: C++

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define PI 3.14159265358979323846264338327950L

struct Node;


struct way{
    Node* to;
    ll cost;
    ll time;
};

struct Node{

    int num;
    int exCost;
    int extime;
    ll minTime = -1;
    set<way*> reachabl;

};


struct compareWay {
    bool operator() (const way* a, const way* b) const{
        return a->time > b->time;
    }
};




int n,m,s;
int u,v,aa,bb;

Node a[50];
ll dp[50][2450];

void solve(){

    cin >> n >> m >> s;

    for (int i = 0; i < m; i++)
    {
        cin >> u >> v >> aa >> bb;
        u--;
        v--;

        way* k = new way();
        k->to = &a[u];
        k->cost = aa;
        k->time = bb;
        a[v].reachabl.insert(k);

        way* f = new way();
        f->to = &a[v];
        f->cost = aa;
        f->time = bb;
        a[u].reachabl.insert(f);
        

    }

    for (int i = 0; i < n; i++)
    {
        cin >> u >> v;

        a[i].num = i;
        a[i].exCost = u;
        a[i].extime = v;


    }
    m = n;

    for (int i = 0; i < 50; i++)
    {
        for (int j = 0; j < 2450; j++)
        {
            dp[i][j] = -1;
        }
        
    }
    

    //dp[0][s] = 0;
    if(s > 2450) s = 2450;
    
    way* t = new way();
    t->to = &a[0];
    t->cost = s;
    t->time = 0;
    
    priority_queue<way, vector<way*>, compareWay> next;

    next.push(t);


    while (!next.empty() && n > 0 )
    {
        way k =  *next.top();
        next.pop();

        //cout << "poped : " << k.to->num << " cost : " << k.time << endl;
        
        if(dp[k.to->num][k.cost] == -1 || k.time < dp[k.to->num][k.cost]){
            dp[k.to->num][k.cost] = k.time;

            if(k.to->minTime == -1){
                k.to->minTime = k.time;
                n--;
            }

            for (auto o : k.to->reachabl)
            {
                
                if(o->cost <= k.cost){
                    way* t = new way();
                    t->to = o->to;
                    t->cost = k.cost - o->cost;
                    t->time = k.time + o->time;
                    //cout << " in reach : " << t->to->num << " with cost " << t->cost  << " a time : " << t->time << endl;
                    next.push(t);
                }
            }

            if(s < 2450){
                way* t = new way();
                t->to = k.to;
                t->cost = k.cost + t->to->exCost;
                if(t->cost > 2450) t->cost = 2450; 
                t->time = k.time + k.to->extime;
                //cout << " in reach : " << t->to->num << " with cost " << t->cost  << " a time : " << t->time << endl;
                next.push(t);
            }
              
        }
    }


    for (int i = 1; i < m; i++ )
    {
        cout << a[i].minTime << endl;
    }
    

}





int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);

    solve();

}

Compiler output:
In file included from /usr/include/c++/14/queue:66,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:157,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_queue.h: In instantiation of 'class std::priority_queue<way, std::vector<way*>, compareWay>':
a.cc:98:51:   required from here
   98 |     priority_queue<way, vector<way*>, compareWay> next;
      |                                                   ^~~~
/usr/include/c++/14/bits/stl_queue.h:520:67: error: static assertion failed: value_type must be the same as the underlying container
  520 |       static_assert(is_same<_Tp, typename _Sequence::value_type>::value,
      |                                                                   ^~~~~
/usr/include/c++/14/bits/stl_queue.h:520:67: note: 'std::integral_constant<bool, false>::value' evaluates to false