Language: C++

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

#define debug(x) cout <<"DEBUG"<<" "<<#x<<":"<<x<<'\n'

//↓0-originか1-originでn回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   //0-origin昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) //1-origin昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  //0-origin降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   //1-origin降順
//rep2 -> 第二引数 m から n 回繰り返し ex) m=5 n=3 なら i=5,i=6,i=7 まで
#define rep2(i,m,n) for(int i = ((int)(m)); i < ((int)(n))+((int)(m)); i++)
#define SIZE(x) ((int)((x).size()))
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii; //2次元配列
typedef vector<ll> vll;
typedef vector<string> vs;
template<class T,class U> inline bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U> inline bool chmin(T &a, const U &b){if(a>b){a=b;return 1;}return 0;}

const ll inf = 1e9+1;
/*GRAPH_TEMPLATE=============================================*/
template<typename T>
class Edge {
public:
    int srch; //searched?探索状態記録「null = -1」
    int to; //辺の行き先
    T cost; //辺の重み
    Edge(int t, T w) : srch(-1), to(t), cost(w) {}
    Edge(int src, int t, T w) : srch(src), to(t), cost(w) {}
};
template<typename T>
using W_Graph = vector<vector<Edge<T>>>;   //重み付きグラフ
using Graph = vector<vector<int>>;         //通常グラフ
template<typename T>
using Matrix = vector<vector<T>>;          //隣接行列
/*FUNCs=================================================*/

/*MAIN==================================================*/
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化

    //MAKE GRAPH
    int n, m, l; cin >> n >> m >> l;
    W_Graph<ll> G(n);
    rep(i, m) {
        int a,b; ll c; cin >> a >> b >> c; a--;b--;
        G[a].emplace_back(b, c);
        G[b].emplace_back(a, c);
    }

    int q, s, t; cin >> q;
    vll min_dist(n);
    vi chargecount(n);
    using TP = tuple<int, ll, int>;        //<ChargeCount, dist, index>
    priority_queue<TP, vector<TP>, greater<TP>> que;
    rep(i,q) {
        //init (queは中身なくなってるのでなにもしない)
        fill(all(min_dist), inf);
        fill(all(chargecount), 0);
        //input
        cin >> s >> t; s--; t--;

        min_dist[s] = 0;
        chargecount[s] = 0;
        que.emplace(chargecount[s], min_dist[s], s);
        while(!que.empty()) {
            int cnt, index; ll dist;
            tie(cnt, dist, index) = que.top(); que.pop();
            if(dist > min_dist[index]) continue;
            for(auto edge : G[index]) {
                int new_dist = dist + edge.cost;
                int new_cnt = cnt;
                if(new_dist > l) {         //   <- POINT!
                    new_dist = edge.cost;
                    new_cnt++;
                }
                if(chmin(min_dist[edge.to], new_dist)) {//更新出来るなら(この経路を採用するなら)
                    chargecount[edge.to] = new_cnt;      //そこまでのcntをchargecoutに
                    que.emplace(new_cost, new_dist, edge.to);
                }
            }
        }
        int answer = chargecount[t];
        cout << (min_dist[t] != inf ? answer : -1) << '\n';
    }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:84:33: error: 'new_cost' was not declared in this scope; did you mean 'new_cnt'?
   84 |                     que.emplace(new_cost, new_dist, edge.to);
      |                                 ^~~~~~~~
      |                                 new_cnt