Language: C++

#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<cstring>
#include<vector>
#include<queue>
using namespace std;
#define INT(x) int x; scanf("%d",&x)
#define INPUT(x) scanf("%d",&x)
#define REP1(x,n) for(int x = 0; x < n; x++)
#define REP2(x,s,e) for(int x = s; x <= e; x++)
#define BR printf("\n")
#define INF 2000000000
#define NIL -1

struct Point{
    int x,y,id;
};

bool lessX(const Point &p1, const Point &p2) { return p1.x < p2.x; }
bool lessY(const Point &p1, const Point &p2) { return p1.y < p2.y; }

Point A[500000];

struct Node{
    int id,l,r,x,y;
};

Node T[500000];
int np = 0;

int make2Dtree(int l,int r,int d){
    if (r-l <= 0) return NIL;
    int mid = (l+r)/2;
    int t = np++;
    
    if (d == 0) sort(A+l,A+r,lessX);
    else sort(A+l,A+r,lessY);
    
    T[t].id = A[mid].id;
    T[t].x = A[mid].x;
    T[t].y = A[mid].y;
    T[t].l = make2Dtree(l,mid,(d+1)%2);
    T[t].r = make2Dtree(mid+1,r,(d+1)%2);
    
    return t;
}

void findTree(int i,int xs,int xt,int ys,int yt,int d,vector<int> ans){
    if (d == 0) {
        if(xs <= T[i].x && T[i].l != NIL) findTree(T[i].l,xs,xt,ys,yt,1);
        if (xs <= T[i].x && T[i].x <= xt && ys <= T[i].y && T[i].y <= yt) ans.push_back(T[i].id);
        if(T[i].x <= xt && T[i].r != NIL) findTree(T[i].r,xs,xt,ys,yt,1);
    }else{
        if(ys <= T[i].y && T[i].l != NIL) findTree(T[i].l,xs,xt,ys,yt,0);
        if (xs <= T[i].x && T[i].x <= xt && ys <= T[i].y && T[i].y <= yt) ans.push_back(T[i].id);
        if(T[i].y <= yt && T[i].r != NIL) findTree(T[i].r,xs,xt,ys,yt,0);
    }
}

void in_order(Node T[],int i){
    if (T[i].l != NIL) in_order(T,T[i].l);
    printf("%d\n",T[i].id);
    if (T[i].r != NIL) in_order(T,T[i].r);
}

int main(){
    INT(n);
    REP1(i,n){
        INT(x);INT(y);
        A[i].x = x;
        A[i].y = y;
        A[i].id = i;
    }
    make2Dtree(0,n,0);
    INT(q);
    REP1(i,q){
        vector<int> ans;
        INT(xs);INT(xt);INT(ys);INT(yt);
        findTree(0,xs,xt,ys,yt,0,ans);
        sort(ans.begin(),ans.end());
        int nn = ans.size();
        REP1(j,nn) printf("%d\n",ans[j]);
        BR;
    }
    return 0;
}

Compiler output:
a.cc: In function 'void findTree(int, int, int, int, int, int, std::vector<int>)':
a.cc:52:51: error: too few arguments to function 'void findTree(int, int, int, int, int, int, std::vector<int>)'
   52 |         if(xs <= T[i].x && T[i].l != NIL) findTree(T[i].l,xs,xt,ys,yt,1);
      |                                           ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
a.cc:50:6: note: declared here
   50 | void findTree(int i,int xs,int xt,int ys,int yt,int d,vector<int> ans){
      |      ^~~~~~~~
a.cc:54:51: error: too few arguments to function 'void findTree(int, int, int, int, int, int, std::vector<int>)'
   54 |         if(T[i].x <= xt && T[i].r != NIL) findTree(T[i].r,xs,xt,ys,yt,1);
      |                                           ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
a.cc:50:6: note: declared here
   50 | void findTree(int i,int xs,int xt,int ys,int yt,int d,vector<int> ans){
      |      ^~~~~~~~
a.cc:56:51: error: too few arguments to function 'void findTree(int, int, int, int, int, int, std::vector<int>)'
   56 |         if(ys <= T[i].y && T[i].l != NIL) findTree(T[i].l,xs,xt,ys,yt,0);
      |                                           ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
a.cc:50:6: note: declared here
   50 | void findTree(int i,int xs,int xt,int ys,int yt,int d,vector<int> ans){
      |      ^~~~~~~~
a.cc:58:51: error: too few arguments to function 'void findTree(int, int, int, int, int, int, std::vector<int>)'
   58 |         if(T[i].y <= yt && T[i].r != NIL) findTree(T[i].r,xs,xt,ys,yt,0);
      |                                           ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
a.cc:50:6: note: declared here
   50 | void findTree(int i,int xs,int xt,int ys,int yt,int d,vector<int> ans){
      |      ^~~~~~~~