import numpy as np

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

nda=np.empty((0,d),int)

ans=0

for i in range(0,n):

  a=np.array([list(map(int,input().split()))])

  for j in range(i):

    chklen=np.linalg.norm(a-nda[j])

    if chklen==chklen//1:

      ans+=1

  nda=np.append(nda,a,axis=0)

print(ans)
import math

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

a=[0]*n

for i in range(n):

  a[i]=list(map(int,input().split()))

ans=0

for i in range(n-1):

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

    chklen=0

    wk=0

    for k in range(d):

      wk+=abs(a[i][k]-a[j][k])**2

    chklen=math.sqrt(wk)

    if chklen==chklen//1:

      ans+=1

print(ans)
import numpy as np

n, d = list(map(int, input().split()))
nda = np.empty((0, d), int)
ans = 0
for i in range(0, n):
    a = np.array([list(map(int, input().split()))])
    for j in range(i):
        chklen = np.linalg.norm(a - nda[j])
        if chklen == chklen // 1:
            ans += 1
    nda = np.append(nda, a, axis=0)
print(ans)

import math

n, d = list(map(int, input().split()))
a = [0] * n
for i in range(n):
    a[i] = list(map(int, input().split()))
ans = 0
for i in range(n - 1):
    for j in range(i + 1, n):
        chklen = 0
        wk = 0
        for k in range(d):
            wk += abs(a[i][k] - a[j][k]) ** 2
        chklen = math.sqrt(wk)
        if chklen == chklen // 1:
            ans += 1
print(ans)

-import numpy as np +import math -nda = np.empty((0, d), int) +a = [0] * n +for i in range(n): +    a[i] = list(map(int, input().split())) -for i in range(0, n): -    a = np.array([list(map(int, input().split()))]) -    for j in range(i): -        chklen = np.linalg.norm(a - nda[j]) +for i in range(n - 1): +    for j in range(i + 1, n): +        chklen = 0 +        wk = 0 +        for k in range(d): +            wk += abs(a[i][k] - a[j][k]) ** 2 +        chklen = math.sqrt(wk) -    nda = np.append(nda, a, axis=0)