Language: C++

int main() {
  std::vector<std::vector<std::pair<int, int>>> edges;
  std::priority_queue<std::pair<int, int>> queue;

  int n, m;
  int a, b, c;
  int q;
  long long fs, fg;

  std::cin >> n >> m;
  edges.resize(n);
  for (int i = 0; i < m; ++i) {
    std::cin >> a >> b >> c;
    edges[a].emplace_back(b, c);
    edges[b].emplace_back(a, c);
  }

  std::vector<long long> distance_s(n);
  std::vector<std::pair<long long, int>> distance_g(n);

  queue.emplace(0, 0);
  while (!queue.empty()) {
    auto p = queue.top();
    queue.pop();
    if (!distance_s[p.second]) {
      distance_s[p.second] = -p.first;
      for (auto& target : edges[p.second]) {
        if (target.first != 0) {
          if (!distance_s[target.first]) {
            queue.emplace(p.first - target.second, target.first);
          }
        }
      }
    }
  }

  queue.emplace(0, n - 1);
  while (!queue.empty()) {
    auto p = queue.top();
    queue.pop();
    if (!distance_g[p.second].first) {
      distance_g[p.second].first = -p.first;
      distance_g[p.second].second = p.second;
      for (auto& target : edges[p.second]) {
        if (target.first != n - 1) {
          if (!distance_g[target.first].first) {
            queue.emplace(p.first - target.second, target.first);
          }
        }
      }
    }
  }

  std::sort(distance_g.begin(), distance_g.end());

  std::cin >> q;
  for (int i = 0; i < q; ++i) {
    int cnt = 0;
    std::cin >> fs >> fg;
    for (auto it = std::lower_bound(distance_g.begin(), distance_g.end(), std::make_pair(fg, 0), [](const auto& a, const auto& b) { return a.first < b.first; }); it != distance_g.end(); ++it) {
      if (distance_s[it->second] <= fs) {
        cnt += 1;
      }
    }
    std::cout << cnt << std::endl;
  }
//   for (int i = 0; i < q; ++i) {
//     int cnt = 0;
//     std::cin >> fs >> fg;
//     for (int j = 0; j < n; ++j) {
//       if (distance_s[j] <= fs && distance_g[j].first >= fg) {
//         cnt += 1;
//       }
//     }
//     std::cout << cnt << std::endl;
//   }
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:2:8: error: 'vector' is not a member of 'std'
    2 |   std::vector<std::vector<std::pair<int, int>>> edges;
      |        ^~~~~~
a.cc:1:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
  +++ |+#include <vector>
    1 | int main() {
a.cc:2:20: error: 'vector' is not a member of 'std'
    2 |   std::vector<std::vector<std::pair<int, int>>> edges;
      |                    ^~~~~~
a.cc:2:20: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
a.cc:2:32: error: 'pair' is not a member of 'std'
    2 |   std::vector<std::vector<std::pair<int, int>>> edges;
      |                                ^~~~
a.cc:1:1: note: 'std::pair' is defined in header '<utility>'; this is probably fixable by adding '#include <utility>'
  +++ |+#include <utility>
    1 | int main() {
a.cc:2:37: error: expected primary-expression before 'int'
    2 |   std::vector<std::vector<std::pair<int, int>>> edges;
      |                                     ^~~
a.cc:3:8: error: 'priority_queue' is not a member of 'std'
    3 |   std::priority_queue<std::pair<int, int>> queue;
      |        ^~~~~~~~~~~~~~
a.cc:1:1: note: 'std::priority_queue' is defined in header '<queue>'; this is probably fixable by adding '#include <queue>'
  +++ |+#include <queue>
    1 | int main() {
a.cc:3:28: error: 'pair' is not a member of 'std'
    3 |   std::priority_queue<std::pair<int, int>> queue;
      |                            ^~~~
a.cc:3:28: note: 'std::pair' is defined in header '<utility>'; this is probably fixable by adding '#include <utility>'
a.cc:3:33: error: expected primary-expression before 'int'
    3 |   std::priority_queue<std::pair<int, int>> queue;
      |                                 ^~~
a.cc:10:8: error: 'cin' is not a member of 'std'
   10 |   std::cin >> n >> m;
      |        ^~~
a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
  +++ |+#include <iostream>
    1 | int main() {
a.cc:11:3: error: 'edges' was not declared in this scope
   11 |   edges.resize(n);
      |   ^~~~~
a.cc:13:10: error: 'cin' is not a member of 'std'
   13 |     std::cin >> a >> b >> c;
      |          ^~~
a.cc:13:10: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:18:8: error: 'vector' is not a member of 'std'
   18 |   std::vector<long long> distance_s(n);
      |        ^~~~~~
a.cc:18:8: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
a.cc:18:15: error: expected primary-expression before 'long'
   18 |   std::vector<long long> distance_s(n);
      |               ^~~~
a.cc:19:8: error: 'vector' is not a member of 'std'
   19 |   std::vector<std::pair<long long, int>> distance_g(n);
      |        ^~~~~~
a.cc:19:8: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
a.cc:19:20: error: 'pair' is not a member of 'std'
   19 |   std::vector<std::pair<long long, int>> distance_g(n);
      |                    ^~~~
a.cc:19:20: note: 'std::pair' is defined in header '<utility>'; this is probably fixable by adding '#include <utility>'
a.cc:19:25: error: expected primary-expression before 'long'
   19 |   std::vector<std::pair<long long, int>> distance_g(n);
      |                         ^~~~
a.cc:21:3: error: 'queue' was not declared in this scope
   21 |   queue.emplace(0, 0);
      |   ^~~~~
a.cc:25:10: error: 'distance_s' was not declared in this scope
   25 |     if (!distance_s[p.second]) {
      |          ^~~~~~~~~~
a.cc:41:10: error: 'distance_g' was not declared in this scope
   41 |     if (!distance_g[p.second].first) {
      |          ^~~~~~~~~~
a.cc:54:8: error: 'sort' is not a member of 'std'
   54 |   std::sort(distance_g.begin(), distance_g.end());
      |        ^~~~
a.cc:54:13: error: 'distance_g' was not declared in this scope
   54 |   std::sort(distance_g.begin(), distance_g.end());
      |             ^~~~~~~~~~
a.cc:56:8: error: 'cin' is not a member of 'std'
   56 |   std::cin >> q;
      |        ^~~
a.cc:56:8: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:59:10: error: 'cin' is not a member of 'std'
   59 |     std::cin >> fs >> fg;
      |          ^~~
a.cc:59:10: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:60:25: error: 'lower_bound' is not a member of 'std'
   60 |     for (auto it = std::lower_bound(distance_g.begin(), distance_g.end(), std::make_pair(fg, 0), [](const auto& a, const auto& b) { return a.first < b.first; }); it != distance_g.end(); ++it) {
      |                         ^~~~~~~~~~~
a.cc:60:80: error: 'make_pair' is not a member of 'std'
   60 |     for (auto it = std::lower_bound(distance_g.begin(), distance_g.end(), std::make_pair(fg, 0), [](const auto& a, const auto& b) { return a.first < b.first; }); it != distance_g.end(); ++it) {
      |                                                                                ^~~~~~~~~
a.cc:60:80: note: 'std::make_pair' is defined in header '<utility>'; this is probably fixable by adding '#include <utility>'
a.cc:61:11: error: 'distance_s' was not declared in this scope
   61 |       if (distance_s[it->second] <= fs) {
      |           ^~~~~~~~~~
a.cc:65:10: error: 'cout' is not a member of 'std'
   65 |     std::cout << cnt << std::endl;
      |          ^~~~
a.cc:65:10: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:65:30: error: 'endl' is not a member of 'std'
   65 |     std::cout << cnt << std::endl;
      |                              ^~~~
a.cc:1:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
  +++ |+#include <ostream>
    1 | int main() {