Language: C++

#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;

#include <vector>
#include<memory>
using namespace std;
struct po {
	int index;
	vector<int> coors;
	po(int _d):coors(_d) {
		index = -1;
	}
	po() {}
};
template<class T>
class axisSorter {
	int k;
public:
	axisSorter(int _k) : k(_k) {}
	bool operator()(const T &a, const T &b) {
		return a.coors[k] < b.coors[k];
	}
};
long long int getdis(const po&l, const po&r) {
	long long int dis = 0;
	for (int i = 0; i < l.coors.size(); ++i) {
		dis += (l.coors[i] - r.coors[i])*(l.coors[i] - r.coors[i]);
	}
	return dis;
}
template<class T, int Dim = 2>
struct kdtree {
public:
	T val;
  shared_ptr<kdtree<T>> ltree, rtree;
	int depth;
	int axis;
	kdtree(const T &p_) :val(p_), ltree(nullptr), rtree(nullptr) {

	}

	kdtree(vector<T>&ps_, const int& l, const int& r, const int depth_ = 0) : ltree(nullptr), rtree(nullptr), depth(depth_), axis(depth%Dim) {
		init(ps_, l, r);
	}
~kdtree() {
}
//??´??????????????????????????°????±??????????
	int query(const T & center, const int r) {
		vector<T>ans;
		bool aok = true;
		for (int i = 0; i < Dim; ++i) {
			int d = center.coors[i] - amin.coors[i];
			num += d*d;
		}
		if (aok) {
			ans.emplace_back(val);
		}
		axisSorter<T> as(axis);
		if (as(val, amax) || val.coors[axis] == amax.coors[axis]) {
			if (rtree != nullptr) {
				vector<T>tans(rtree->query(amin, amax));
				ans.insert(ans.end(), tans.begin(), tans.end());
			}
		}
		if (as(amin, val) || val.coors[axis] == amin.coors[axis]) {
			if (ltree != nullptr) {
				vector<T>tans(ltree->query(amin, amax));
				ans.insert(ans.end(), tans.begin(), tans.end());
			}
		}
		return ans;
	}
//????????????????±??????????
void get_closest(const T& apo,int r, long long int &ans) {
	if (getdis(apo, val) <= r*r)ans++;
	axisSorter<T> as(axis);
	if (as(apo, val) || val.coors[axis] == apo.coors[axis]) {
		if (ltree)ltree->get_closest(apo, r,ans);
		long long int dis = apo.coors[axis] - val.coors[axis];
		if (dis*dis > r*r)return;
		else {
			if (rtree)rtree->get_closest(apo, r,ans);
		}
	}
	else {
		if (rtree)rtree->get_closest(apo,r, ans);
		long long int dis = val.coors[axis] - apo.coors[axis];
		if (dis*dis > r*r)return;
		else {
			if (ltree)ltree->get_closest(apo,r, ans);
		}
	}
}
private:
	void init(vector<T>&ps, const int& l, const int& r) {
		if (l >= r) {
			return;
		}
		const int mid = (l + r) / 2;
		nth_element(ps.begin() + l, ps.begin() + mid, ps.begin() + r, axisSorter<T>(axis));
		val = ps[mid];
		ltree = make_kdtree(ps, l, mid, depth + 1);
		rtree = make_kdtree(ps, mid + 1, r, depth + 1);
	}

};
//[l..r)
template<class T>
unique_ptr<kdtree<T>>make_kdtree(vector<T>&ps_, const int& l, const int& r, const int& depth = 0) {
	if (l >= r)return nullptr;
	else {
		return make_unique<kdtree<T>>(ps_, l, r, depth);
	}
}

int main() {
	while (1) {
		int AN, BN, R; cin >> AN >> BN >> R;
		if (!AN&&!BN)break;
		R *= 4;
		long long int ans = 0;
		vector<po>pos;
		for (int i = 0; i < AN; ++i) {
			int x, y; cin >> x >> y;
			pos.push_back(po{ 2 });
			pos[i].coors[0] = x;
			pos[i].coors[1] = y;
		}
		auto tree(make_kdtree(pos, 0, AN));
		for (int i = 0; i < BN; ++i) {
			int x, y; cin >> x >> y;
			po apo = po{ 2 };
			apo.coors[0] = x;
			apo.coors[1] = y;
			tree->get_closest(apo, R, ans);
		}
		cout << ans << endl;
	}
	

	return 0;
}

Compiler output:
a.cc: In member function 'int kdtree<T, Dim>::query(const T&, int)':
a.cc:55:51: error: 'amin' was not declared in this scope; did you mean 'fmin'?
   55 |                         int d = center.coors[i] - amin.coors[i];
      |                                                   ^~~~
      |                                                   fmin
a.cc:56:25: error: 'num' was not declared in this scope; did you mean 'enum'?
   56 |                         num += d*d;
      |                         ^~~
      |                         enum
a.cc:62:29: error: 'amax' was not declared in this scope; did you mean 'fmax'?
   62 |                 if (as(val, amax) || val.coors[axis] == amax.coors[axis]) {
      |                             ^~~~
      |                             fmax
a.cc:64:60: error: 'amin' was not declared in this scope; did you mean 'fmin'?
   64 |                                 vector<T>tans(rtree->query(amin, amax));
      |                                                            ^~~~
      |                                                            fmin
a.cc:68:24: error: 'amin' was not declared in this scope; did you mean 'fmin'?
   68 |                 if (as(amin, val) || val.coors[axis] == amin.coors[axis]) {
      |                        ^~~~
      |                        fmin
a.cc:70:66: error: 'amax' was not declared in this scope; did you mean 'fmax'?
   70 |                                 vector<T>tans(ltree->query(amin, amax));
      |                                                                  ^~~~
      |                                                                  fmax