Fast query on the number of elements in a quarter plane
A 2D Fenwick tree can solve this in $O(\log^2 N)$ time and $O(N^2)$ space for both update and query, when your coordinates are integers and $N$ is the size of the maximum coordinate.
Fenwick trees are nice for competitive programming because they have a really compact implementation, for example in C++:
typedef unsigned long long uw;
uw lsb(uw x) { return x &amp; -x; }
uw  up(uw x) { return x + lsb(x); }
uw  dn(uw x) { return x - lsb(x); }

template&lt;class T&gt; struct Fenwick2D {
  uw n; std::vector&lt;std::vector&lt;T&gt;&gt; b;
  Fenwick2D(uw n) : n(n), b(n+1, std::vector&lt;T&gt;(n+1)) { }

  void increase(uw x, uw y_, T v) {
    for (; x &lt;= n; x = up(x))
      for (uw y = y_; y &lt;= n; y = up(y))
        b[x][y] += v;
  }

  T prefix_sum(uw x, uw y_) {
    T s = 0;
    for (; x &gt;= 1; x = dn(x))
      for (uw y = y_; y &gt;= 1; y = dn(y))
        s += b[x][y];
    return s;
  }
};

And this shows your example from the question:
int main(int argc, char** argv) {
    Fenwick2D&lt;int&gt; fw(4);
    fw.increase(1, 1, 1);
    fw.increase(2, 2, 1);
    fw.increase(1, 2, 1);
    fw.increase(3, 2, 1);
    std::cout &lt;&lt; fw.prefix_sum(1, 1) &lt;&lt; &quot;\n&quot;;
    std::cout &lt;&lt; fw.prefix_sum(2, 2) &lt;&lt; &quot;\n&quot;;
    std::cout &lt;&lt; fw.prefix_sum(3, 3) &lt;&lt; &quot;\n&quot;;
    return 0;
}

This data structure is more general than your problem as well. In general it can increase any grid element $g_{x,y}$ by value $v$ (which decreases for negative $v$), and ask the value of the lower quadrant prefix sum $\sum_{i\leq x}\sum_{j\leq y} g_{i,j}$ for any $x, y$. Note that this means you can get area sums as well using 4 queries by the inclusion-exclusion principle.