Detect Squares
Process a flat operations array `arg1` that encodes Detect Squares operations as triplets `[op, x, y]` in sequence. For each triplet, `op == 0` means `add(x, y)` (insert point `(x, y)`; duplicate points are allowed and count independently), and any other `op` value means `count(x, y)` (return the number of axis-aligned squares that can be formed with `(x, y)` as one corner). Return the sum of all `count` results.