Problem: There are N points in a D-dimensional space.  The coordinates of the i-th point are (X_{i1}, X_{i2}, ..., X_{iD}).  The distance between two points with coordinates (y_1, y_2, ..., y_D) and (z_1, z_2, ..., z_D) is \sqrt{(y_1 - z_1)^2 + (y_2 - z_2)^2 + ... + (y_D - z_D)^2}.  How many pairs (i, j) (i < j) are there such that the distance between the i-th point and the j-th point is an integer?

Submission attempts (in order):
n, d = map(int, input().split())
lst = []
length = 0
cnt = 0
for i in range(n):
	a = map(int, input().split())
	lst.append(list(a))
for i in range(1, n):
	for j in range(i, n):
		for k in range(d):
			length += (lst[i][k]-lst[j-1][k])**2
			length = length ** 0.5
			print(length, length%1)
		if length%1 == 0:
			print("AAA")
			if length != 0:
				print(length)
				cnt += 1
		length = 0
print(cnt)
        

n, d = map(int, input().split())
lst = []
for i in range(n):
	a = map(int, input().split())
	lst.append(list(a))
for i in range(1, n):
	for j in range(d):
		print(lst[i][j])

n, d = map(int, input().split())
x = []
cnt = 0
for i in range(n):
    a = list(map(int, input().split()))
    print(a)
    lst.append(a)
for i in range(n-1):
    for j in range(i+1, n):
        val = 0
        for k in range(d):
            x += (lst[i][k]-lst[j][k]) ** 2
        dist = x ** 0.5
        if dist%1 == 0:
            if dist != 0:
                cnt += 1
print(cnt)

n, d = map(int, input().split())
x = []
cnt = 0
for i in range(n):
    a = list(map(int, input().split()))
    print(a)
    x.append(a)
for i in range(n):
    val = 0
    for j in range(d):
        if i != n-1:
            val += x[i+1][j]-x[i][j]
        else:
            val += x[i][j]-x[0][j]
    if abs(val) ** 0.5 % 1 == 0:
        cnt += 1
print(cnt)

n, d = map(int, input().split())
x = []
cnt = 0
for i in range(n):
    a = list(map(int, input().split()))
    print(a)
    x.append(a)
for i in range(n):
    for j in range(i+1, n):
        val = 0
        for k in range(d):
            val += (x[i][k]-x[j][k]) ** 2
        dist = val ** 0.5
        if dist%1 == 0:
            if dist != 0:
                cnt += 1
print(cnt)

n, d = map(int, input().split())
lst = []
length = 0
cnt = 0
for i in range(n):
	a = map(int, input().split())
	lst.append(list(a))
for i in range(1, n):
	for j in range(i, n):
		for k in range(d):
			length += (lst[i][k]-lst[j-1][k])**2
		if length%1 == 0:
			cnt += 1
print(cnt)
        

n, d = map(int, input().split())
lst = []
cnt = 0
for i in range(n):
    a = list(map(int, input().split()))
    print(a)
    lst.append(a)
for i in range(n-1):
    for j in range(i+1, n):
        val = 0
        for k in range(d):
            x += (lst[i][k]-lst[j][k]) ** 2
        dist = x ** 0.5
        if dist%1 == 0:
            if dist != 0:
                cnt += 1
print(cnt)

n, d = map(int, input().split())
lst = []
length = 0
cnt = 0
for i in range(n):
    a = map(int, input().split())
    lst.append(list(a))
for i in range(1, n):
    for j in range(i, n):
        for k in range(d):
            length += (lst[i][k]-lst[j-1][k])**2
            length = length ** 0.5
            if length%1 == 0:
                if length != 0:
                    cnt += 1
        length = 0
print(cnt)

n, d = map(int, input().split())
lst = []
cnt = 0
lst = [list(map(int, input().split())) for i in range(n)]

for i in range(n-1):
    for j in range(i+1, n):
        x = 0
        for k in range(d):
            x += (lst[i][k]-lst[j][k]) ** 2
        dist = x ** 0.5
        if dist%1 == 0:
            if dist != 0:
                cnt += 1
print(cnt)

Verdicts: Wrong Answer

Wrong Answer

Runtime Error

Wrong Answer

Wrong Answer

Wrong Answer

Runtime Error

Wrong Answer

Accepted