Language: C++

//                             ¯\_(ツ)_/¯   
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mma,ava,tune=native")
//#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>

#define pb push_back
#define sz(a) ((int)(a).size())
#define all(a) (a).begin(),(a).end()
#define ll long long

using namespace std;

void file(){
	#ifndef ONLINE_JUDGE
    	freopen("in.txt", "r", stdin);
	#endif
}
int tc;

const int N=2e5+5,M=2e6+5,MOD=1e9+7,OO=1e9;
pair<int,int>wa[N];
std::vector<pair<int,pair<int,int>>> g[N];
const int Mx = 50000;
ll dist[N][Mx];
int n,m,s;
void dij(int trgt){
	for(int i=0;i<=n;i++)
		for(int j=0;j<Mx;j++)
			dist[i][j]=1e18;
	priority_queue<pair<ll,pair<int,int>>,vector<pair<ll,pair<int,int>>>,greater<pair<ll,pair<int,int>>>>q;

	q.push({0,{1,s}});
	dist[1][s] = 0;

	while(!q.empty()){
			int u = q.top().second.first;
			int amount = q.top().second.second;
			ll cst = q.top().first;
			q.pop();
			if(u==trgt)return;
			for(auto p : g[u]){
				int v = p.first;
				int a = p.second.first;
				int b = p.second.second;
				if(amount >= a && dist[v][amount-a]>cst+b){
					dist[v][amount-a] = cst+b;
					q.push({dist[v][amount-a],{v,amount-a}});
				}
				int mx_can_get = amount;
				ll cnt = 0;
				while(mx_can_get<Mx){
					mx_can_get+=wa[u].first;
					cnt++;
					if(mx_can_get >= a && dist[v][mx_can_get-a]>cst+wa[u].second*cnt + b){
						dist[v][mx_can_get-a]=cst+wa[u].second*cnt+b;
						q.push({dist[v][mx_can_get-a],{v,mx_can_get-a}});
					}
				}
				
			}
		}
		return;
	
}
int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	//file();
	
	scanf("%d %d %d",&n,&m,&s);
	s = min(s,Mx-1);
	for(int i=0;i<m;i++){
		int u,v,a,b;
		scanf("%d %d %d %d",&u,&v,&a,&b);
		g[u].pb({v,{a,b}});
		g[v].pb({u,{a,b}});
	}
	for(int i=1;i<=n;i++){
		scanf("%d %d",&wa[i].first,&wa[i].second);
	}
	
	for(int i=2;i<=n;i++){
		dij(i);
		ll ans = 1e18;
		for(int j=0;j<Mx;j++)
			ans = min(ans,dist[i][j]);
		printf("%lld\n",ans );
	}
}


Compiler output:
/tmp/ccXnO2qj.o: in function `dij(int)':
a.cc:(.text+0x93): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccXnO2qj.o
a.cc:(.text+0xd1): relocation truncated to fit: R_X86_64_PC32 against symbol `s' defined in .bss section in /tmp/ccXnO2qj.o
a.cc:(.text+0x11b): relocation truncated to fit: R_X86_64_PC32 against symbol `s' defined in .bss section in /tmp/ccXnO2qj.o
/tmp/ccXnO2qj.o: in function `main':
a.cc:(.text+0x585): relocation truncated to fit: R_X86_64_PC32 against symbol `s' defined in .bss section in /tmp/ccXnO2qj.o
a.cc:(.text+0x58f): relocation truncated to fit: R_X86_64_PC32 against symbol `m' defined in .bss section in /tmp/ccXnO2qj.o
a.cc:(.text+0x599): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccXnO2qj.o
a.cc:(.text+0x5c5): relocation truncated to fit: R_X86_64_PC32 against symbol `s' defined in .bss section in /tmp/ccXnO2qj.o
a.cc:(.text+0x5d5): relocation truncated to fit: R_X86_64_PC32 against symbol `s' defined in .bss section in /tmp/ccXnO2qj.o
a.cc:(.text+0x6cb): relocation truncated to fit: R_X86_64_PC32 against symbol `m' defined in .bss section in /tmp/ccXnO2qj.o
a.cc:(.text+0x730): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccXnO2qj.o
a.cc:(.text+0x7d1): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status