import math

import numpy as np

n, d = list(map(int, input().split()))

a = []

cnt = 0

for x in range(n):

    a.append(list(map(int, input().split())))

for i in range(len(a)):

    for j in range(len(a)):

        if i < j:

            dis = np.array(a[i]) - np.array(a[j])

            if np.linalg.norm(dis).is_integer():

                cnt += 1

print(cnt)
n, d = list(map(int, input().split()))

a = [[int(i) for i in input().split()] for i in range(n)]

ans = 0

def dis(x,y):

    T = []

    for i in range(len(x)):

        T.append((x[i]-y[i])**2)

    return sum(T)

for i in range(n):

    for j in range(i+1,n):

        r = dis(a[i], a[j])

        for k in range(r + 1):

            if k ** 2 == r:

                ans += 1

print(ans)
import math
import numpy as np

n, d = list(map(int, input().split()))
a = []
cnt = 0
for x in range(n):
    a.append(list(map(int, input().split())))
for i in range(len(a)):
    for j in range(len(a)):
        if i < j:
            dis = np.array(a[i]) - np.array(a[j])
            if np.linalg.norm(dis).is_integer():
                cnt += 1
print(cnt)

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


def dis(x, y):
    T = []
    for i in range(len(x)):
        T.append((x[i] - y[i]) ** 2)
    return sum(T)


for i in range(n):
    for j in range(i + 1, n):
        r = dis(a[i], a[j])
        for k in range(r + 1):
            if k**2 == r:
                ans += 1
print(ans)

-import math -import numpy as np +n, d = list(map(int, input().split())) +a = [[int(i) for i in input().split()] for i in range(n)] +ans = 0 -n, d = list(map(int, input().split())) -a = [] -cnt = 0 -for x in range(n): -    a.append(list(map(int, input().split()))) -for i in range(len(a)): -    for j in range(len(a)): -        if i < j: -            dis = np.array(a[i]) - np.array(a[j]) -            if np.linalg.norm(dis).is_integer(): -                cnt += 1 -print(cnt) + +def dis(x, y): +    T = [] +    for i in range(len(x)): +        T.append((x[i] - y[i]) ** 2) +    return sum(T) + + +for i in range(n): +    for j in range(i + 1, n): +        r = dis(a[i], a[j]) +        for k in range(r + 1): +            if k**2 == r: +                ans += 1 +print(ans)