Language: C++

#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define F first
#define S second
#define pb push_back
#define pf push_front

using ll = long long;
using namespace std;

ll M = 1000000007;
typedef pair<int, int> P;

struct edge
{
    int to;
    ll cost;
};
typedef vector<vector<edge>> AdjList;
AdjList graph;

typedef pair<ll, int> P;

long long INF = 10'000'000'000'000;

vector<ll> dist;
vector<int> prever;

void dijkstra(int n, int s)
{
    dist = vector<ll>(n, INF);
    prever = vector<int>(n, -1);
    dist[s] = 0;

    priority_queue<P, vector<P>, greater<P>> que;
    que.push(P(0, s));

    while (!que.empty())
    {
        P p = que.top();
        que.pop();
        int v = p.second;
        if (dist[v] < p.first)
        {
            continue;
        }
        for (int i = 0; i < graph[v].size(); i++)
        {
            edge e = graph[v][i];
            if (dist[e.to] > dist[v] + e.cost)
            {
                dist[e.to] = dist[v] + e.cost;
                prever[e.to] = v;
                que.push(P(dist[e.to], e.to));
            }
        }
    }
}

vector<int> get_path(int t)
{ //頂点tへの最短路
    vector<int> path;
    for (; t != -1; t = prever[t])
    {
        path.push_back(t);
    }

    reverse(path.begin(), path.end());
    return path;
}

int main(void)
{
    int n, m, l;
    cin >> n >> m >> l;
    graph = AdjList(n);
    vector<vector<int>> grid(n, vector<int>(n, 0));
    for (int i = 0; i < m; i++)
    {
        int from, to;
        ll cost;
        cin >> from >> to >> cost;
        from--;
        to--;
        if (cost <= l)
        {
            grid[from][to] = grid[to][from] = cost;
            graph[from].push_back((edge){to, cost});
            graph[to].push_back((edge){from, cost});
        }
    }
    int q;
    cin >> q;
    rep(i, q)
    {
        int s, t;
        cin >> s >> t;
        s--;
        t--;
        dijkstra(n, s);
        vector<int> ans = get_path(t);
        int gas = l;
        int bef = s;
        int cnt = 0;
        if (ans.size() == 1)
        {
            cnt=-1;
        }
        else
        {
            rep(j, ans.size())
            {
                if (grid[bef][ans[j]] > gas)
                {
                    gas = l - grid[bef][ans[j]];
                    cnt++;
                }
                else
                {
                    gas -= grid[bef][ans[j]];
                }
                bef = ans[j];
            }
        }
        cout << cnt << endl;
    }
    return 0;
}

Compiler output:
a.cc:41:23: error: conflicting declaration 'typedef struct std::pair<long long int, int> P'
   41 | typedef pair<ll, int> P;
      |                       ^
a.cc:31:24: note: previous declaration as 'typedef struct std::pair<int, int> P'
   31 | typedef pair<int, int> P;
      |                        ^