---
# System prepended metadata

title: Good Distance

---

# Good Distance


```
    N,D = map(int,input().split())
    X = [list(map(int,input().split())) for i in range(N)]
    A = [i**2 for i in range(1,128)]
    ans = 0
    for i in range(N-1) :
        for j in range(i+1,N) :
            calc = 0
            for k in range(D) :
                calc += (X[i][k] - X[j][k])**2
            if calc in A :
                ans += 1
    print(ans)
```


