Language: C++

import std.algorithm;
import std.array;
import std.ascii;
import std.container;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void log(A...)(A arg) {
    stderr.writeln(arg);
}
int size(T)(in T s) {
    return cast(int)s.length;
}

struct Point {
    int x, y;
    int index;
};
class RangeTree {
    class Node {
        Node parent;
        Node left, right;
        int left_x, right_x;
        Point[] ys;
        override string toString() const {
            return format("([%s,%s] -> %s)", left_x, right_x, ys);
        }
    }
    Node construct(Point[] ps) {
        auto n = new Node;
        n.left_x = ps.front.x;
        n.right_x = ps.back.x;
        if(ps.length <= 1024) {
            n.ys = ps.dup.sort!"a.y < b.y".array;
            return n;
        }
        auto l = construct(ps[0 .. $ / 2]);
        auto r = construct(ps[$ / 2 .. $]);
        l.parent = n;
        r.parent = n;
        n.left = l;
        n.right = r;
        auto li = 0, ri = 0;
        while (true) {
            if (li >= l.ys.length && ri >= r.ys.length) break;
            if (li >= l.ys.length) n.ys ~= r.ys[ri++];
            else if (ri >= r.ys.length) n.ys ~= l.ys[li++];
            else {
                n.ys ~= (l.ys[li].y < r.ys[ri].y ? l.ys[li++] : r.ys[ri++]);
            }
        }
        return n;
    }
    Node root;
    this(Point[] ps) {
        ps.sort!"a.x < b.x";
        this.root = construct(ps);
    }

    /* (sx <= x <= gx && sy <= y <= gy)????????§??????(x, y)??§?±?esult???????????\??§??????. ??¢????????¢?????????????±???¨??¢???*/
    Point[] query(int sx, int sy, int gx, int gy) {
        Point[] result;
        void f(Node cur_root) {
            if (gx < cur_root.left_x || cur_root.right_x < sx) {
                // do nothing
            } else if (sx <= cur_root.left_x && cur_root.right_x <= gx) {
                auto ys = cur_root.ys;
                result ~= ys.assumeSorted!"a.y < b.y".upperBound(Point(0, sy - 1)).lowerBound(Point(0, gy + 1)).array;
            } else {
                if(cur_root.left is null || cur_root.right is null) {
                    foreach (p; cur_root.ys.assumeSorted!"a.y < b.y".upperBound(Point(0, sy - 1)).lowerBound(Point(0, gy + 1))) {
                        if (sx <= p.x && p.x <= gx && sy <= p.y && p.y <= gy) {
                            result ~= p;
                        }
                    }
                } else {
                    f(cur_root.left);
                    f(cur_root.right);
                }
            }
        }
        f(root);
        return result;
    }
}

void main() {
    int AN, BN, R;
    Point[] A, B;
    bool input() {
        scanf("%d %d %d\n", &AN, &BN, &R);
        if (AN == 0 && BN == 0) return false;
        A = new Point[AN];
        B = new Point[BN];
        foreach (i; 0 .. AN) { scanf("%d %d\n", &A[i].x, &A[i].y); }
        foreach (i; 0 .. BN) { scanf("%d %d\n", &B[i].x, &B[i].y); }
        return true;
    }
    void solve() {
        long ans = 0;
        auto tree = new RangeTree(B);
        foreach (a; A) {
            auto ns = tree.query(a.x - 4 * R, a.y - 4 * R, a.x + 4 * R, a.y + 4 * R);
            long dist_sq(in Point a, in Point b) {
                long dx = a.x - b.x;
                long dy = a.y - b.y;
                return dx * dx + dy * dy;
            }
            foreach (n; ns) {
                if (dist_sq(a, n) <= (4*R) * (4*R)) {
                    ans++;
                }
            }
        }
        writeln(ans);
    }
    while (input()) solve();
}

Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import std.algorithm;
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:2:1: error: 'import' does not name a type
    2 | import std.array;
      | ^~~~~~
a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:3:1: error: 'import' does not name a type
    3 | import std.ascii;
      | ^~~~~~
a.cc:3:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:4:1: error: 'import' does not name a type
    4 | import std.container;
      | ^~~~~~
a.cc:4:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:5:1: error: 'import' does not name a type
    5 | import std.conv;
      | ^~~~~~
a.cc:5:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:6:1: error: 'import' does not name a type
    6 | import std.math;
      | ^~~~~~
a.cc:6:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:7:1: error: 'import' does not name a type
    7 | import std.numeric;
      | ^~~~~~
a.cc:7:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:8:1: error: 'import' does not name a type
    8 | import std.range;
      | ^~~~~~
a.cc:8:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:9:1: error: 'import' does not name a type
    9 | import std.stdio;
      | ^~~~~~
a.cc:9:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:10:1: error: 'import' does not name a type
   10 | import std.string;
      | ^~~~~~
a.cc:10:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:11:1: error: 'import' does not name a type
   11 | import std.typecons;
      | ^~~~~~
a.cc:11:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:13:6: error: variable or field 'log' declared void
   13 | void log(A...)(A arg) {
      |      ^~~
a.cc:13:10: error: 'A' was not declared in this scope
   13 | void log(A...)(A arg) {
      |          ^
a.cc:16:10: error: 'T' was not declared in this scope
   16 | int size(T)(in T s) {
      |          ^
a.cc:26:14: error: field 'parent' has incomplete type 'RangeTree::Node'
   26 |         Node parent;
      |              ^~~~~~
a.cc:25:11: note: definition of 'class RangeTree::Node' is not complete until the closing brace
   25 |     class Node {
      |           ^~~~
a.cc:27:14: error: field 'left' has incomplete type 'RangeTree::Node'
   27 |         Node left, right;
      |              ^~~~
a.cc:25:11: note: definition of 'class RangeTree::Node' is not complete until the closing brace
   25 |     class Node {
      |           ^~~~
a.cc:27:20: error: field 'right' has incomplete type 'RangeTree::Node'
   27 |         Node left, right;
      |                    ^~~~~
a.cc:25:11: note: definition of 'class RangeTree::Node' is not complete until the closing brace
   25 |     class Node {
      |           ^~~~
a.cc:29:14: error: expected unqualified-id before '[' token
   29 |         Point[] ys;
      |              ^
a.cc:30:9: error: 'override' does not name a type
   30 |         override string toString() const {
      |         ^~~~~~~~
a.cc:34:5: error: expected ';' at end of member declaration
   34 |     Node construct(Point[] ps) {
      |     ^~~~
      |         ;
a.cc:34:28: error: expected ',' or '...' before 'ps'
   34 |     Node construct(Point[] ps) {
      |                            ^~
a.cc:34:10: error: ISO C++ forbids declaration of 'construct' with no type [-fpermissive]
   34 |     Node construct(Point[] ps) {
      |          ^~~~~~~~~
a.cc:59:5: error: 'Node' does not name a type
   59 |     Node root;
      |     ^~~~
a.cc:60:5: error: expected unqualified-id before 'this'
   60 |     this(Point[] ps) {
      |     ^~~~
a.cc:66:10: error: expected unqualified-id before '[' token
   66 |     Point[] query(int sx, int sy, int gx, int gy) {
      |          ^
a.cc:90:2: error: expected ';' after class definition
   90 | }
      |  ^
      |  ;
a.cc: In member function 'int RangeTree::construct(Point*)':
a.cc:35:22: error: 'Node' does not name a type
   35 |         auto n = new Node;
      |                      ^~~~
a.cc:36:20: error: 'ps' was not declared in this scope
   36 |         n.left_x = ps.front.x;
      |                    ^~
a.cc:42:34: error: expected unqualified-id before '.' token
   42 |         auto l = construct(ps[0 .. $ / 2]);
      |                                  ^
a.cc:43:31: error: '$' was not declared in this scope
   43 |         auto r = construct(ps[$ / 2 .. $]);
      |                               ^
a.cc:43:38: error: expected unqualified-id before '.' token
   43 |         auto r = construct(ps[$ / 2 .. $]);
      |                                      ^
a.cc: At global scope:
a.cc:92:1: error: '::main' must return 'int'
   92 | void main() {
      | ^~~~
a.cc: In function 'int main()':
a.cc:94:10: error: structured binding declaration cannot have type 'Point'
   94 |     Point[] A, B;
      |          ^~
a.cc:94:10: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
a.cc:94:10: error: empty structured binding declaration
a.cc:94:13: error: expected initializer before 'A'
   94 |     Point[] A, B;
      |             ^
a.cc:95:15: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
   95 |     bool input() {
      |               ^~
a.cc:95:15: note: remove parentheses to default-initialize a variable
   95 |     bool input() {
      |               ^~
      |               --
a.cc:95:15: note: or replace parentheses with braces to value-initialize a variable
a.cc:95:18: error: a function-definition is not allowed here before '{' token
   95 |     bool input() {
      |                  ^
a.cc:104:18: error: a function-definition is not allowed here before '{' token
  104 |     void solve() {
      |                  ^
a.cc:122:12: error: 'input' was not declared in this scope; did you mean 'int'?
  122 |     while (input()) solve();
      |            ^~~~~
      |            int
a.cc:122:21: error: 'solve' was not declared in this scope
  122 |     while (input()) solve();
      |                     ^~~~~