Round Arena
Limits: 2 sec., 512 MiB
This statement was translated automatically from Ukrainian.
Splinter prepared a round training arena of radius \(r\) for the Ninja Turtles to practice with a cord. The center of the arena is located at the origin of coordinates.
Inside the circle, there are \(n\) distinct point targets with integer coordinates \((x_i, y_i)\). No target lies at the center of the circle.
During training, two students stand on two different targets in the arena. Splinter stretches a cord between the edges of the arena so that it passes through both targets where the students are standing — that is, the cord runs along a chord. Then the turtles begin to perform exercises with the cord.
A pair of targets is called balanced if, when two turtles stand on the targets, the distances from the turtles to the respective ends of the cord are equal.
In this example, the pairs of targets \((1, 4)\) and \((3, 5)\) are balanced.
You need to count the number of balanced pairs of targets.
Input
The first line contains a single integer \(r\) — the radius of the arena.
The second line contains a single integer \(n\) — the number of targets.
The next \(n\) lines contain pairs of integers \(x_i\) and \(y_i\) — the coordinates of the \(i\)-th target.
Output
Output a single integer in a single line — the number of balanced pairs of targets.
Constraints
\(1 \le r \le 10^9\),
\(1 \le n \le 4 \cdot 10^5\),
all targets are located at different positions,
all targets are located strictly inside the arena,
no target is located at the center of the arena.
Samples
| Input (stdin) | Output (stdout) |
|---|---|
| 8 5 4 -1 3 3 -3 2 1 4 3 2 | 2 |
Submit a solution
| Element Type | Created | Who | Problem | Compiler | Result | Time (sec.) | Memory (MiB) | # | Actions |
|---|
| Element Type | Created | Who | Problem | Compiler | Result | Time (sec.) | Memory (MiB) | # | Actions |
|---|