sherif-and-the-bombs-7

The Sheriff of the Hackers' community had a very urgent job to do. He needs to diffuse all the bombs placed by Joker.
Joker is extremely clever and cruel. He selected a region of 1000 X 1000 points, chose N center points of the form (X,Y) and placed bombs on every integral point that was on or inside the circular region of radius R around that chosen point.
Then he went to every such point and activated those bombs that lied on or inside at least two such circular regions. 

In order to make an efficient plan for the Bomb Disposal Squad, You need to help the Sheriff to determine the number of active bombs.

INPUT:
The first line of the input contains the N. Next N lines contain 3 space separated integers X Y R as described above.

OUTPUT:
Print the number of active bombs.

CONSTRAINTS:
1 ≤ N ≤ 10
1 ≤ X,Y,R ≤ 1000
NOTE : The search area for the Sheriff is a square with diagonal points (1,1) and (1000,1000)

Problem Statement in native language: http://hck.re/9E2gZN

SAMPLE INPUT
2
5 5 2
3 4 3

SAMPLE OUTPUT
9

Explanation

All of the following 9 points are inside atleast 2 circles
3 5
4 4
4 5
4 6
5 3
5 4
5 5
5 6
6 4

Source: hackerearth | Difficulty: EASY


Solutions:
'''
http://math.stackexchange.com/questions/198764/how-to-know-if-a-point-is-inside-a-circle
'''

t = int(eval(input()))
mat = [ [0 for i in range(0, 1001)] for j in range(0, 1001)]

while(t):
	val = str(input())
	val = val.split(" ")
	x,y,r = int(val[0]), int(val[1]), int(val[2])
	#print("X Y R")
	#print x,y,r

	rSquare = r ** 2
	#print("rSquare %d"% rSquare)
	for i in range(1,1001) :
		for j in range(1,1001) :
			if( ((x-i)*(x-i) + (y-j)*(y-j)) <= rSquare ) :
				mat[i][j] = mat[i][j] + 1
				#print mat[i][j]
	t= t - 1
ans = 0
for i in range(1,1001) :
	for j in range(1,1001) :
		if(mat[i][j] > 1) :
			ans = ans + 1
	
print(ans)


import math
N = int(input())
X,Y,R = [],[],[]
for item in range(N):
	P = input().split()
	X.append(int(P[0]))
	Y.append(int(P[1]))
	R.append(int(P[2]))
# print X,Y,R
count = 0
for x in range(1,1001):
	for y in range(1,1001):
		flag = 0
		for z in range(N):
			dist = (x-X[z])*(x-X[z])+(y-Y[z])*(y-Y[z])-R[z]*R[z]
			if dist <= 0: flag += 1
			if flag >=2:
				count += 1
				break
print(count)