Language: C++

\#include <iostream>
#include <vector>
#include <array>
#include <algorithm>
#include <limits>
#include <cmath>
#include <numeric>
#include <string>
#include <queue>
#include <cstdio>
#include <unordered_map>
#include <map>

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
#define rep(i, a, b) for(int i = (a); i < (b); ++i )
#define rrep(i, a, b) for(int i = (a); i > (b); --i )
#define REP(i, a, b) for(int i = (a); i <= (b); ++i )
#define RREP(i, a, b) for(int i = (a); i >= (b); --i )
#define llrep(i, a, b) for(ll i = (a); i < (b); ++i )
#define llrrep(i, a, b) for(ll i = (a); i > (b); --i )
#define llREP(i, a, b) for(ll i = (a); i <= (b); ++i )
#define llRREP(i, a, b) for(ll i = (a); i >= (b); --i )
#define ullrep(i, a, b) for(ull i = (a); i < (b); ++i )
#define ullrrep(i, a, b) for(ull i = (a); i > (b); --i )
#define ullREP(i, a, b) for(ull i = (a); i <= (b); ++i )
#define ullRREP(i, a, b) for(ull i = (a); i >= (b); --i )

template<typename T=int>
class UnionFind {
 public:
  explicit UnionFind(unsigned long long n) : rank_(n, 0), p_(n, 0) {
    for (T i = 0; i < n; i++) {
      MakeSet(i);
    }
  }

  void MakeSet(T x) {
    p_[x] = x;
    rank_[x] = 0;
  }

  bool Same(T x, T y) {
    return FindSet(x) == FindSet(y);
  }

  void Link(T x, T y) {
    if (rank_[x] > rank_[y]) {
      p_[y] = x;
    } else {
      p_[x] = y;
      if (rank_[x] == rank_[y]) {
        rank_[y]++;
      }
    }
  }

  void Unite(T x, T y) {
    Link(FindSet(x), FindSet(y));
  }

  T FindSet(T x) {
    if (x != p_[x]) {
      p_[x] = FindSet(p_[x]);
    }
    return p_[x];
  }

 private:
  std::vector<T> rank_, p_;
};

template<typename NumT = ull, typename CostT = ull>
class Dijkstra {
 public:
  Dijkstra(unsigned long long num, CostT max_cost) :
      num_(num),
      max_cost_(max_cost),
      v_(num, std::vector<CostT>(num, max_cost)),
      c_(num, 0),
      d_(num, max_cost),
      p_(num, 0) {
  };

  void ComputeWithQ(NumT start) {
    d_[start] = 0;
    p_[start] = start;
    priority_queue<std::pair<CostT, NumT>> pq;
    pq.push(make_pair(0, start));
    while (!pq.empty()) {
      auto node = pq.top();
      pq.pop();
      auto ni = node.second;
      auto c = -node.first;
      c_[ni] = 1;
      if (d_[ni] < c) {
        continue;
      }
      d_[ni] = c;

      for (int i = 0; i < num_; i++) {
        if (v_[ni][i] == max_cost_) {
          continue;
        }
        if ((c_[i] != 1) && (d_[i] > (v_[ni][i] + d_[ni]))) {
          p_[i] = ni;
          d_[i] = v_[ni][i] + d_[ni];
          pq.push(make_pair(-d_[i], i));
        }
      }
    }
  }

  void Compute(int start) {
    d_[start] = 0;
    p_[start] = start;
    while (true) {
      int m = -1;
      int min_d = max_cost_;
      for (int i = 0; i < num_; i++) {
        if ((c_[i] == 0) && (min_d > d_[i])) {
          min_d = d_[i];
          m = i;
        }
      }
      if (m < 0) {
        break;
      }
      c_[m] = 1;
      for (int i = 0; i < num_; i++) {
        if ((c_[i] == 0) && (d_[i] > (d_[m] + v_[m][i]))) {
          d_[i] = d_[m] + v_[m][i];
          p_[i] = m;
        }
      }
    }
  }

  void Set(NumT s, NumT d, CostT c) {
    v_[s][d] = c;
  }

  CostT Distance(NumT d) {
    return d_[d];
  }

 public:
  NumT num_;
  CostT max_cost_;
  std::vector<std::vector<CostT>> v_;
  std::vector<int> c_;
  std::vector<int> d_;
  std::vector<NumT> p_;
};

int nibutan(int *ary, int ok, int ng) {
  bool is_valid;
  while (std::abs(ok - ng) > 1) {
    int mid = (ok + ng) / 2;
    // is_valid = check(mid);
    if (is_valid) {
      ok = mid;
    } else {
      ng = mid;
    }
  }
  return ok;
}

template<typename NumT = int, typename CostT = unsigned long long>
class DijkstraQ {
 public:
  DijkstraQ(unsigned long long num, CostT max_cost) :
      adj_(num, std::vector<std::pair<NumT, CostT>>()),
      c_(num, 0), d_(num, max_cost) {}

  void Compute(NumT start) {
    std::priority_queue<std::pair<CostT, NumT>> q;
    d_[start] = 0;
    q.push(std::make_pair(0, start));

    while (!q.empty()) {
      std::pair<CostT, NumT> node = q.top();
      q.pop();
      auto n = node.second;
      auto c = -node.first;
      c_[n] = 1;
      if (c > d_[n]) {
        continue;
      }
      d_[n] = c;

      for (NumT i = 0; i < adj_[n].size(); i++) {
        auto nn = adj_[n][i].first;
        auto nc = adj_[n][i].second;
        if (c_[nn] > 0) {
          continue;
        }
        if (d_[nn] > (c + nc)) {
          d_[nn] = c + nc;
          q.push(std::make_pair(-d_[nn], nn));
        }
      }
    }
  }

  void Set(NumT s, NumT d, CostT c) {
    adj_[s].push_back(std::make_pair(d, c));
  }

  CostT Distance(NumT d) {
    return d_[d];
  }

  std::vector<CostT> d_;
  std::vector<int> c_;
  std::vector<std::vector<std::pair<NumT, CostT>>> adj_;
};

// x >= y
template<typename T>
inline T gcd(T x, T y) { return y ? gcd(y, x % y) : x; }

template<typename T>
inline T lcm(T x, T y) { return (x / gcd(x, y)) * y; }

// return gcd(a, b)
// x, y satisfy ax + by = gcd(a, b)
ll xgcd(ll a, ll b, ll &x, ll &y) {
  if (b == 0) {
    x = 1;
    y = 0;
    return a;
  }
  ll d = xgcd(b, a % b, y, x);
  y -= a / b * x;
  return d;
}

bool check(int *A, int i) {
  return A[i] < 39;
}

int N;
int A[110][110];
int C[110];
int D[110];

class D2Tree {

 public:
  struct node {
    int id, x, y;
  };

  struct tree {
    int location, l, r;
  };

  D2Tree(int n) : v_(n, {-1, -1, -1}), t_(n, {-1, -1, -1}), n_(n), np_(0) {
  }

  int MakeTree(int l, int r, int depth) {
    if (l >= r) {
      return -1;
    }

    int m = (l + r) / 2;
    int t = np_++;

    if (depth % 2 == 0) {
      sort(&v_[l], &v_[r], [&](auto& l, auto& r) { return l.x < r.x; });
    } else {
      sort(&v_[l], &v_[r], [&](auto& l, auto& r) { return l.y < r.y; });
    }

    t_[t].location = m;
    t_[t].l = MakeTree(l, m, depth + 1);
    t_[t].r = MakeTree(m + 1, r, depth + 1);
    return t;
  }

  void find(vector<int> &find_nodes, int ix, int sx, int tx, int sy, int ty, int depth) {
    int x = v_[t_[ix].location].x;
    int y = v_[t_[ix].location].y;
    if ((sx <= x) && (x <= tx) && (sy <= y) && (y <= ty)) {
      find_nodes.push_back(v_[t_[ix].location].id);
    }

    if (depth % 2 == 0) {
      if ((t_[ix].l != -1) && (sx <= x)) {
        find(find_nodes, t_[ix].l, sx, tx, sy, ty, depth + 1);
      }
      if ((t_[ix].r != -1) && (x <= tx)) {
        find(find_nodes, t_[ix].r, sx, tx, sy, ty, depth + 1);
      }
    } else {
      if ((t_[ix].l != -1) && (sy <= y)) {
        find(find_nodes, t_[ix].l, sx, tx, sy, ty, depth + 1);
      }
      if ((t_[ix].r != -1) && (y <= ty)) {
        find(find_nodes, t_[ix].r, sx, tx, sy, ty, depth + 1);
      }
    }
  }

  vector<node> v_;
  vector<tree> t_;
  int n_;
  int np_;
};

int main() {
  int N;
  cin >> N;
  D2Tree d2(N);
  rep(i, 0, N) {
    int x, y;
    cin >> d2.v_[i].x >> d2.v_[i].y;
    d2.v_[i].id = i;
  }

  int q;
  cin >> q;

  d2.MakeTree(0, N, 0);
  vector<int> v;
  v.reserve(N);
  rep(i, 0, q) {
    v.clear();
    int sx, tx, sy, ty;
    cin >> sx >> tx >> sy >> ty;
    d2.find(v, 0, sx, tx, sy, ty, 0);
    sort(v.begin(), v.end());
    for (auto i: v) {
      cout << i << endl;
    }
    cout << endl;
  }
}



Compiler output:
a.cc:1:1: error: stray '\' in program
    1 | \#include <iostream>
      | ^
a.cc:1:2: error: stray '#' in program
    1 | \#include <iostream>
      |  ^
a.cc:1:3: error: 'include' does not name a type
    1 | \#include <iostream>
      |   ^~~~~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:62,
                 from /usr/include/c++/14/vector:62,
                 from a.cc:2:
/usr/include/c++/14/ext/type_traits.h:164:35: error: 'constexpr const bool __gnu_cxx::__is_null_pointer' redeclared as different kind of entity
  164 |   __is_null_pointer(std::nullptr_t)
      |                                   ^
/usr/include/c++/14/ext/type_traits.h:159:5: note: previous declaration 'template<class _Type> constexpr bool __gnu_cxx::__is_null_pointer(_Type)'
  159 |     __is_null_pointer(_Type)
      |     ^~~~~~~~~~~~~~~~~
/usr/include/c++/14/ext/type_traits.h:164:26: error: 'nullptr_t' is not a member of 'std'
  164 |   __is_null_pointer(std::nullptr_t)
      |                          ^~~~~~~~~
In file included from /usr/include/c++/14/bits/stl_pair.h:60,
                 from /usr/include/c++/14/bits/stl_algobase.h:64:
/usr/include/c++/14/type_traits:295:27: error: 'size_t' has not been declared
  295 |   template <typename _Tp, size_t = sizeof(_Tp)>
      |                           ^~~~~~
/usr/include/c++/14/type_traits:666:33: error: 'nullptr_t' is not a member of 'std'
  666 |     struct is_null_pointer<std::nullptr_t>
      |                                 ^~~~~~~~~
/usr/include/c++/14/type_traits:666:42: error: template argument 1 is invalid
  666 |     struct is_null_pointer<std::nullptr_t>
      |                                          ^
/usr/include/c++/14/type_traits:670:48: error: template argument 1 is invalid
  670 |     struct is_null_pointer<const std::nullptr_t>
      |                                                ^
/usr/include/c++/14/type_traits:674:51: error: template argument 1 is invalid
  674 |     struct is_null_pointer<volatile std::nullptr_t>
      |                                                   ^
/usr/include/c++/14/type_traits:678:57: error: template argument 1 is invalid
  678 |     struct is_null_pointer<const volatile std::nullptr_t>
      |                                                         ^
/usr/include/c++/14/type_traits:984:26: error: 'size_t' has not been declared
  984 |   template<typename _Tp, size_t _Size>
      |                          ^~~~~~
/usr/include/c++/14/type_traits:985:40: error: '_Size' was not declared in this scope
  985 |     struct __is_array_known_bounds<_Tp[_Size]>
      |                                        ^~~~~
/usr/include/c++/14/type_traits:985:46: error: template argument 1 is invalid
  985 |     struct __is_array_known_bounds<_Tp[_Size]>
      |                                              ^
/usr/include/c++/14/type_traits:1429:37: error: 'size_t' is not a member of 'std'
 1429 |     : public integral_constant<std::size_t, alignof(_Tp)>
      |                                     ^~~~~~
/usr/include/c++/14/type_traits:1429:57: error: template argument 1 is invalid
 1429 |     : public integral_constant<std::size_t, alignof(_Tp)>
      |                                                         ^
/usr/include/c++/14/type_traits:1429:57: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1438:37: error: 'size_t' is not a member of 'std'
 1438 |     : public integral_constant<std::size_t, 0> { };
      |                                     ^~~~~~
/usr/include/c++/14/type_traits:1438:46: error: template argument 1 is invalid
 1438 |     : public integral_constant<std::size_t, 0> { };
      |                                              ^
/usr/include/c++/14/type_traits:1438:46: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1440:26: error: 'std::size_t' has not been declared
 1440 |   template<typename _Tp, std::size_t _Size>
      |                          ^~~
/usr/include/c++/14/type_traits:1441:21: error: '_Size' was not declared in this scope
 1441 |     struct rank<_Tp[_Size]>
      |                     ^~~~~
/usr/include/c++/14/type_traits:1441:27: error: template argument 1 is invalid
 1441 |     struct rank<_Tp[_Size]>
      |                           ^
/usr/include/c++/14/type_traits:1442:37: error: 'size_t' is not a member of 'std'
 1442 |     : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
      |                                     ^~~~~~
/usr/include/c++/14/type_traits:1442:65: error: template argument 1 is invalid
 1442 |     : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
      |                                                                 ^
/usr/include/c++/14/type_traits:1442:65: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1446:37: error: 'size_t' is not a member of 'std'
 1446 |     : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
      |                                     ^~~~~~
/usr/include/c++/14/type_traits:1446:65: error: template argument 1 is invalid
 1446 |     : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
      |                                                                 ^
/usr/include/c++/14/type_traits:1446:65: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1451:32: error: 'size_t' was not declared in this scope
 1451 |     : public integral_constant<size_t, 0> { };
      |                                ^~~~~~
/usr/include/c++/14/type_traits:64:1: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
   63 | #include <bits/version.h>
  +++ |+#include <cstddef>
   64 | 
/usr/include/c++/14/type_traits:1451:41: error: template argument 1 is invalid
 1451 |     : public integral_constant<size_t, 0> { };
      |                                         ^
/usr/include/c++/14/type_traits:1451:41: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1453:26: error: 'size_t' has not been declared
 1453 |   template<typename _Tp, size_t _Size>
      |                          ^~~~~~
/usr/include/c++/14/type_traits:1454:23: error: '_Size' was not declared in this scope
 1454 |     struct extent<_Tp[_Size], 0>
      |                       ^~~~~
/usr/include/c++/14/type_traits:1454:32: error: template argument 1 is invalid
 1454 |     struct extent<_Tp[_Size], 0>
      |                                ^
/usr/include/c++/14/type_traits:1455:32: error: 'size_t' was not declared in this scope
 1455 |     : public integral_constant<size_t, _Size> { };
      |                                ^~~~~~
/usr/include/c++/14/type_traits:1455:32: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
/usr/include/c++/14/type_traits:1455:40: error: '_Size' was not declared in this scope
 1455 |     : public integral_constant<size_t, _Size> { };
      |                                        ^~~~~
/usr/include/c++/14/type_traits:1455:45: error: template argument 1 is invalid
 1455 |     : public integral_constant<size_t, _Size> { };
      |                                             ^
/usr/include/c++/14/type_traits:1455:45: error: template argument 2 is invalid
/usr/include/c++/14/type_traits:1457:42: error: 'size_t' has not been declared
 1457 |   template<typename _Tp, unsigned _Uint, size_t _Size>
      |                                          ^~~~~~
/usr/include/c++/14/type_traits:1458:23: error: '_Size' was not declared in this scope
 1458 |     struct extent<_Tp[_Size], _Uint>
      |                       ^~~~~
/usr/include/c++/14/type_traits:1458:36: error: template argument 1 is invalid
 1458 |     struct extent<_Tp[_Size], _Uint>
      |                                    ^
/usr/include/c++/14/type_traits:1463:32: error: 'size_t' was not declared in this scope
 1463 |     : public integral_constant<size_t, 0> { };
      |                                ^~~~~~
/usr/include/c++/14/type_traits:1463:32: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
/usr/include/c++/14/type_traits:1463:41: error: template argument 1 is invalid
 1463 |     : public integral_constant<size_t, 0> { };
      |                                         ^
/usr/include/c++/14/type_traits:1463:41: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1857:26: error: 'size_t' does not name a type
 1857 |       { static constexpr size_t __size = sizeof(_Tp); };
      |                          ^~~~~~
/usr/include/c++/14/type_traits:1857:26: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
/usr/include/c++/14/type_traits:1859:14: error: 'size_t' has not been declared
 1859 |     template<size_t _Sz, typename _Tp, bool = (_Sz <= _Tp::__size)>
      |              ^~~~~~
/usr/include/c++/14/type_traits:1859:48: error: '_Sz' was not declared in this scope
 1859 |     template<size_t _Sz, typename _Tp, bool = (_Sz <= _Tp::__size)>
      |                                                ^~~
/usr/include/c++/14/type_traits:1860:14: error: no default argument for '_Tp'
 1860 |       struct __select;
      |              ^~~~~~~~
/usr/include/c++/14/type_traits:1862:14: error: 'size_t' has not been declared
 1862 |     template<size_t _Sz, typename _Uint, typename... _UInts>
      |              ^~~~~~
/usr/include/c++/14/type_traits:1863:23: error: '_Sz' was not declared in this scope
 1863 |       struct __select<_Sz, _List<_Uint, _UInts...>, true>
      |                       ^~~
/usr/include/c++/14/type_traits:1863:57: error: template argument 1 is invalid
 1863 |       struct __select<_Sz, _List<_Uint, _UInts...>, true>
      |                                                         ^
/usr/include/c++/14/type_traits:1866:14: error: 'size_t' has not been declared
 1866 |     template<size_t _Sz, typename _Uint, typename... _UInts>
      |              ^~~~~~
/usr/include/c++/14/type_traits:1867:23: error: '_Sz' was not declared in this scope
 1867 |       struct __select<_Sz, _List<_Uint, _UInts...>, false>
      |