QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 128 MB Total points: 100

#10653. Crop circles

Statistics

Many farmers in Byteotia will remember last summer for a long time. And this is not because of exceptionally abundant harvests, or conversely, drought and hail, but because of mysterious circles that appeared in many wheat fields. As a Byteotian expert on all unusual problems, Bytazar decided to investigate the phenomenon of the circles from a scientific perspective. To this end, he carried out meticulous inspections of the fields. He noticed that each circle was created by crushing grain in a circular area. Any two circles touch at most at one point (in particular, one circle cannot be inside another).

Bytazar suspects that these circles are messages sent by non-Byteotian beings. Unfortunately, understanding their language will be very difficult. For now, Bytazar has created a database of circle arrangements and is conducting statistical analysis on them. The more interesting data Bytazar collects, the better. He has asked you to write a program that, for a given arrangement of circles, calculates how many pairs of circles have a common point.

Input

The first line of input contains an integer $n$ ($1 \le n \le 500\,000$), representing the number of circles in the arrangement. Each of the next $n$ lines describes one circle. The $i$-th of these lines contains three integers $x_{i}$, $y_{i}$, $r_{i}$ ($-10^{9} \le x_{i}, y_{i} \le 10^{9}$, $1 \le r_{i} \le 10^{9}$). These denote that the $i$-th circle has its center at $(x_{i}, y_{i})$ and radius $r_{i}$.

Output

Your program should output the number of pairs of circles that have a common point.

Examples

Input 1

4
0 0 5
8 6 5
-6 8 5
2 14 5

Output 1

4

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.