Language: C++

#include <iostream>
#include <vector>
using namespace std;
class priority_nodes {
  public:
    struct Node {
        Node(int n, int refills, int fuel) {
            node = n;
            priority_ = (long long)(refills) << 32;
            priority_ |= 0x7fffffff - fuel;
        }

        int node;
        long long priority_;
        int fuel_remains() const { return 0x7fffffff - (int)(priority_ & 0xffffffff); }
        int refill_count() const { return (int)(priority_ >> 32); }
    };

    void reserve(int n) { nodes.reserve(n); }
    void add(int dest, int refill_count, int fuel_remains) {
        Node n(dest, refill_count, fuel_remains);
        nodes.push_back(n);
    }
    Node extract() {
        auto at = 0;
        auto n = nodes[0];
        for (int i = 1; i < nodes.size(); i++) {
            if (nodes[i].priority_ < n.priority_) {
                n = nodes[i];
                at = i;
            }
        }
        if (at != nodes.size() - 1) {
            nodes[at] = nodes.back();
        }
        nodes.pop_back();
        return n;
    }
    void insert_or_update_if_better(int dest, int refill_count, int fuel_remains) {
        Node n(dest, refill_count, fuel_remains);
        auto itr = find_if(nodes.begin(), nodes.end(), [dest](const auto &n) { return n.node == dest; });
        if (itr == nodes.end()) {
            nodes.push_back(n);
        } else {
            itr->priority_ = n.priority_;
        }
    }

    bool empty() const { return nodes.empty(); }
    void reset(int n) {
        nodes.clear();
        nodes.reserve(n);
    }

  private:
    vector<Node> nodes;
};

static int dist[300][300];
static int best[300][300];
static vector<vector<int>> connected_from;
static priority_nodes open_set;

static int solve(const int s, const int t, const int tanksize) {
    if (dist[s][t] > 0)
        return 0;
    if (best[s][t] > 0)
        return best[s][t];
    if (best[s][t] < 0)
        return -1;

    bool visited[300] = {};

    open_set.reset(300);
    open_set.add(s, 0, tanksize);
    for (;;) {
        if (open_set.empty()) {
            best[s][t] = -1; // cannot reach
            return -1;
        }

        auto n = open_set.extract();
        visited[n.node] = true;
        const auto fuel = n.fuel_remains();
        const auto refills = n.refill_count();
        best[s][n.node] = refills;

        if (n.node == t) {
            return refills;
        }

        for (auto c : connected_from[n.node]) {
            if (visited[c])
                continue;
            if (dist[n.node][c] > fuel) {
                open_set.insert_or_update_if_better(c, refills + 1, tanksize - dist[n.node][c]);
            } else {
                open_set.insert_or_update_if_better(c, refills, fuel - dist[n.node][c]);
            }
        }
    }
}

int main() {
    int cities, m, tank;
    cin >> cities >> m >> tank;
    connected_from = vector<vector<int>>(cities);

    for (int i = 0; i < m; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        a--, b--;
        if (c <= tank) {
            dist[a][b] = c;
            dist[b][a] = c;
            connected_from[a].push_back(b);
            connected_from[b].push_back(a);
        }
    }
    int q;
    cin >> q;
    auto answers = vector<int>(q);
    for (int i = 0; i < q; i++) {
        int s, t;
        cin >> s >> t;
        s--, t--;
        answers[i] = solve(s, t, tank);
    }

    cout << answers[0];
    for (int i = 1; i < q; i++)
        cout << "\n" << answers[i];
    return 0;
}


Compiler output:
a.cc: In member function 'void priority_nodes::insert_or_update_if_better(int, int, int)':
a.cc:41:20: error: 'find_if' was not declared in this scope
   41 |         auto itr = find_if(nodes.begin(), nodes.end(), [dest](const auto &n) { return n.node == dest; });
      |                    ^~~~~~~