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.

An axis-aligned square has four sides parallel to the axes. When counting squares for query point (qx, qy), consider every point (qx, py) on the same vertical line: with side length s = |qy - py| > 0, valid opposite corners are (qx + s, qy) and (qx + s, py) on the right, and (qx - s, qy) and (qx - s, py) on the left. The number of squares contributed by that vertical pair is the product of the frequencies of the two opposite corners.

Examples
Input: [1,2,3]
Output: 0
Hints

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.