Problem:
 Score : 200 points    Problem Statement 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?      Constraints  All values in input are integers.  2 \leq N \leq 10  1 \leq D \leq 10  -20 \leq X_{ij} \leq 20  No two given points have the same coordinates. That is, if i \neq j , there exists k such that X_{ik} \neq X_{jk} .         Input Input is given from Standard Input in the following format:  N  D  X_{11}  X_{12}  ...  X_{1D}  X_{21}  X_{22}  ...  X_{2D}  \vdots  X_{N1}  X_{N2}  ...  X_{ND}       Output Print the number of pairs (i, j)  (i < j) such that the distance between the i -th point and the j -th point is an integer.        Sample Input 1 3 2
1 2
5 5
-2 8      Sample Output 1 1  The number of pairs with an integer distance is one, as follows:   The distance between the first point and the second point is \sqrt{|1-5|^2 + |2-5|^2} = 5 , which is an integer.  The distance between the second point and the third point is \sqrt{|5-(-2)|^2 + |5-8|^2} = \sqrt{58} , which is not an integer.  The distance between the third point and the first point is \sqrt{|-2-1|^2+|8-2|^2} = 3\sqrt{5} , which is not an integer.        Sample Input 2 3 4
-3 7 8 2
-12 1 10 2
-2 8 9 3      Sample Output 2 2       Sample Input 3 5 1
1
2
3
4
5      Sample Output 3 10

Solution (Python):
import math as m

n, d = map(int, input().split())
lp = []
for i in range(n):
	lp.append(list(map(int, input().split())))

count = 0

for i in range(n-1):
	for j in range(i+1, n):
		acc = 0
		for k in range(d):
			acc += (lp[j][k] - lp[i][k]) ** 2
		
		if m.sqrt(acc).is_integer():
			count += 1

print(count)

Solution (Python):
N, D = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(N)]

cnt = 0
dst = 0

for i in range(N):
    for j in range(i+1, N):
        dst = 0
        for k in range(D):
            dst += (X[i][k] - X[j][k]) ** 2
        x = dst ** 0.5
        if x.is_integer():
            cnt += 1
        
print(cnt)

Solution (Python):
N, D = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(N)]

cnt = 0
dst = 0

for i in range(N):
    for j in range(i+1, N):
        dst = 0
        for k in range(D):
            dst += (X[i][k] - X[j][k]) ** 2
        if int(dst ** 0.5) ** 2 == dst:
            cnt += 1
        
print(cnt)

Solution (Python):
N, D = map(int,input().split())
X = [list(map(int,input().split())) for i in range(N)]
ans = 0
for i in range(N):
    for j in range(i+1,N):
        y = X[i]
        z = X[j]
        l = 0
        for Y, Z in zip(y, z):
            l += (Y-Z)**2
        for k in range(1,8001):
            if l** (1/2) == k:
                ans += 1
                break
print(ans)

Solution (Python):
n, d = map(int, input().split())
l = []
for i in range(n):
    l.append(list(map(int, input().split())))

ans = 0

for i in range(n):
    for j in range(i+1, n):
        left = l[i]
        right = l[j]
        sm = sum(list(map(lambda x,y: pow(x-y, 2), left, right)))

        result = pow(sm, 1/2)
        if result.is_integer():
            ans += 1

print(ans)

Solution (Python):
N, D = map(int,input().split())
K = [list(map(int,input().split()))for x in range(N)]
ans = 0
for i in range(N-1):
  for j in range(i+1,N):
    goukei=0
    for a,b in zip(K[i],K[j]):
      goukei += (a-b)**2
    ans += (goukei**0.5).is_integer()
print(ans)

Solution (Python):
def distance(Y,Z):
    sum = 0
    for y,z in zip(Y,Z):
        tmp = y-z
        tmp = tmp*tmp
        sum += tmp
    return sum**0.5

cnt = 0
N,D = map(int,input().split())
i = 0
X = []
while(i < N):
    X.append(list(map(int,input().split())))
    i += 1
i = 0
while(i < N-1):
    j = i+1
    while(j < N):
        if distance(X[i],X[j]).is_integer():
            cnt += 1
        j += 1
    i += 1
print(cnt)

Solution (Python):
import math
N, M = (int(a) for a in input().split())
X = [list(map(int,input().split())) for i in range(N)]
count = 0
for i in range(N-1):
    for j in range(i+1,N):
        sum = 0
        squ = 0
        for k in range(M):
            sum += abs(X[j][k]-X[i][k])**2
        squ = pow(sum,0.5)
        if math.ceil(squ) == math.floor(squ):
            count += 1
print(count)

Solution (Python):
m = list(map(int,input().split()))
l = [list(map(int,input().split())) for i in range(m[0])]

from itertools import combinations
import math

k =list(combinations(l,2))

c=0
for i in range(len(k)):
      dis = 0
      for x in range(m[1]):
          dis = dis + (k[i][0][x] - k[i][1][x])**2
      dis = math.sqrt(dis)
      if dis == int(dis):
          c=c+1
      else:
          c=c      
print(c)

Solution (Python):
N,D = map(int,input().split())
X = [0]+[list(map(int,input().split()))for _ in range(N)]
List = []
ans = 0
for j in range(1,N):
    for i in range(j+1,N+1):
        v = 0
        for k in range(D):
            v+=(X[j][k]-X[i][k])**2
        for l in range(v+1):
            List.append(l**2)
        if v in List:
            ans+=1
      
            
print(ans)

Solution (Python):
import numpy as np
N, D = map(int, input().split())
x = []
m = 0
for _ in range(N):
    x.append(list(map(int, input().split())))
for i in range(N):
    for j in range (i):
        d = np.sqrt(sum((x[i][k]-x[j][k])**2 for k in range(D)))
        if d.is_integer():
            m += 1
print(m)

Solution (Python):

def f_b():
    n, d = map(int, input().split())
    x = []
    stack = []
    c = 0

    for _ in range(n):
        x.append(list(map(int, input().split())))

    for i in range(n):
        xi = x[i]
        for xj in stack:
            d = 0
            for y, z in zip(xi, xj):
                d += (y-z)**2
            if (d**0.5)%1==0:
                c += 1
        stack.append(xi)

    print(c)

if __name__ == "__main__":
    f_b()

Solution (Python):
import numpy as np
n, d = map(int, input().split())
x = np.empty((n, d))
for i in range(n):
    x[i, :] = np.array(list(map(int, input().split())))

count = 0
for i in range(n - 1):
    for j in range(i + 1, n):
        distance = np.linalg.norm(x[i, :] - x[j, :])
        if float(distance).is_integer():
            count += 1
print(count)

Solution (Python):
n, d = list(map(int, input().split()))
x = [list(map(int, input().split())) for _ in range(n)]
ans = 0

for i in range(n-1):
    for j in range(i+1, n):
        tmp = 0
        for a, b in zip(x[i], x[j]):
            tmp += (a-b)**2
        ans += (tmp**0.5).is_integer()

print(ans)

Solution (Python):
import numpy as np
n,d =map(int,input().split())
l=[]
ans=0
for i in range(n):
    l.append(list(map(int,input().split())))
for i in range(n):
    for j in range(i):
        z=0
        for k in range(d):
            z+=(l[i][k]-l[j][k])**2
        if float(np.sqrt(z)).is_integer():
            ans+=1
print(ans)

Solution (Python):
N,D=map(int,input().split())
X=[list(map(int, input().split())) for i in range(N)]
c=0
for i in range(N-1):
  for j in range(i+1,N):
    c += (sum((a-b)**2 for a,b in zip(X[i],X[j]))**0.5).is_integer()
print(c)

Solution (Python):
n,d=map(int,input().split())
w=[]
for i in range(n):
    l=[int(i) for i in input().split()]
    w.append(l)
ans=0
chk=set([int(i)**2 for i in range(0,401,1)])
for i in range(n-1):
    for j in range(i+1,n):
        cnt=0
        for k in range(d):
            cnt+=(w[i][k]-w[j][k])**2
        if cnt in chk:
            ans+=1
print(ans)

Solution (Python):

import math
number = list(map(int,input().split()))
n = number[0]
d = number[1]
number_list = []
for i in range(n):
    number_list.append(list(map(int,input().split())))
count = 0
sum = 0
for i in range(n):
    for j in range(i+1,n):
        for k in range(d):
            sum += (number_list[i][k]-number_list[j][k])**2
        distance = math.sqrt(sum)
        if list(str(distance))[-1] == "0":
            count += 1
        sum = 0
print(count)

Solution (Python):
n,d=map(int,input().split())
r=[]
for _ in range(n):r.append(input().split(" "))

count=0
i=0
while i<n-1:
  j=i+1
  while j<n:
    temp=0
    k=0
    while k<d:
      temp+=(int(r[i][k])-int(r[j][k]))**2
      k+=1
    if temp**(1/2)==temp**(1/2)//1:
      count+=1
    j+=1
  i+=1
  
print(count)

Solution (Python):
n, d = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(n)]
ans = 0
for i in range(n):
  for j in range(i+1, n):
    tmp = 0
    for k in range(d):
      tmp += (a[i][k]-a[j][k])**2
    tmp **= 0.5
    if tmp == int(tmp):
      ans += 1
print(ans)

Solution (Python):
N,D=map(int,input().split())
from itertools import combinations
l=[]
ans=0
for i in range(N):
  l.append(list(map(int,input().split())))
for m,n in combinations(l,2):
  sv=0
  for a in range(D):
    sv+=(abs(m[a]-n[a]))**2
  if sv**(1/2)%1==0:
    ans+=1
print(ans)

Solution (Python):
import math

n, d = map(int, input().split())
pts = [list(map(int, input().split())) for _ in range(n)]


def dist2(pt0, pt1):
    d = 0
    for x0, y0 in zip(pt0, pt1):
        d += (x0 - y0)**2
    return d


count = 0
for i in range(n):
    for j in range(i + 1, n):
        d2 = dist2(pts[i], pts[j])
        if int(math.sqrt(d2))**2 == d2:
            count += 1
print(count)

Solution (Python):
n,d = map(int,input().split())
X = [list(map(int,input().split())) for i in range(n)]
number = [i for i in range(1,200)]
square = list(map(lambda i: i**2, number))
count = 0
for i in range(0,n):
  for j in range(0,n):
    distance = 0
    for p in range(0,d):
      distance += (X[j][p]-X[i][p])**2
    if square.count(distance) == 1 and i < j:
      count += 1
print(count)

Solution (Python):

import math
n, d = map(int, input().split())

x = []
for i in range(n):
    x.append(list(map(int, input().split())))



def dist_calc(lis1, lis2):
    sum = 0
    for i in range(len(lis1)):
        sum += (lis1[i]-lis2[i])**2
    return math.sqrt(sum)

count = 0
for i in range(n):
    for j in range(i+1,n):
        if i==j:
            continue
        else:
            dist = dist_calc(x[i],x[j])

            if dist.is_integer() == True:
                count += 1
            else:
                continue

print(count)

Solution (Python):
def distance(a, b):
    d = len(a)
    s = 0
    for i in range(d):
        s += (a[i] - b[i]) ** 2
    return s ** 0.5


n, _ = map(int, input().split())
xs = [list(map(int, input().split()))
      for _ in range(n)]

cnt = 0
for i in range(n):
    for j in range(i + 1, n):
        d = distance(xs[i], xs[j])
        if (d - int(d)) == 0:
            cnt += 1
print(cnt)

Solution (Python):
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)

Solution (Python):
n, d = map(int, input().split())
lst = []
cnt = 0
for i in range(n):
    a = list(map(int, input().split()))
    lst.append(a)
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)

Solution (Python):
import itertools


def calc_dist(p1, p2):
    return sum([(i - j) ** 2 for i, j in zip(p1, p2)])


def is_integer(p1, p2):
    dist = calc_dist(p1, p2)
    if pow(dist, 0.5).is_integer():
        return True
    else:
        return False


def main():
    points = []
    N, D = map(int, input().split())

    for _ in range(N):
        points.append(list(map(int, input().split())))

    cnt = 0
    for pair in list(itertools.combinations(points, 2)):
        if is_integer(pair[0], pair[1]):
            cnt += 1
    print(cnt)


if __name__ == '__main__':
    main()

Solution (Python):
import math


def is_integer(p1, p2):
    total = 0
    for i, j in zip(p1, p2):
        total += (i - j) ** 2
    if math.sqrt(total) * 10 % 10 == 0:
        return True
    else:
        return False


def cnt_integer(points):
    cnt = 0
    size = len(points)

    for i in range(size):
        for j in range(i):
            if is_integer(points[i], points[j]):
                cnt += 1

    return cnt


def main():
    points = []
    N, D = map(int, input().split())

    for _ in range(N):
        points.append(list(map(int, input().split())))

    print(cnt_integer(points))


if __name__ == '__main__':
    main()

Solution (Python):
n, d = map(int, input().split())
x = [list(map(int, input().split())) for _ in range(n)]
count = 0

for i in range(n):
    for j in range(i+1, n):
        num = 0
        for k in range(d):
            num += (x[i][k] - x[j][k]) ** 2
        check = pow(num, 0.5)
        if check.is_integer():
            count += 1

print(count)

Solution (Python):
N,D=map(int,input().split())
X=[0 for i in range(N)]
res=0

for i in range(N):
    X[i]=list(map(int,input().split()))
    
for i in range(N):
    for j in range(i+1,N):
        d = 0
        for k in range(D):
            d+=(X[i][k]-X[j][k])**2
        d=d**0.5
        if d.is_integer():
            res+=1
print(res)

Solution (Python):


import math

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


def distance(y, z):
    k = 0
    cc = 0
    for (i, j) in zip(y, z):
        k += (i - j) ** 2
    if math.sqrt(k).is_integer() == True:
        cc += 1
    return(cc)


for i, s in enumerate(x):
    for t in x[i+1:]:
        c += distance(s, t)

print(c)

Solution (Python):
N,D = list(map(int,input().split()))
ans = 0
s = 0
L = []
for i in range(N):
  A = list(map(int,input().split()))
  L.append(A)



for j in range(N):
  
  for k in range(j+1,N):
    s = 0
    
    for l in range(D):
      
      dif = abs(L[j][l]-L[k][l])
      dif2 = dif**2
      
      s = s + dif2
      
    s2 = s**(1/2)
    
    if float.is_integer(s2) == True:
      ans += 1
        
print(ans)

Solution (Python):
import numpy as np
n,d = list(map(int,input().split()))
t = np.array([list(map(int,input().split())) for i in range(n)])
cnt = 0

for i in range(n):
	for h in range(n):
		x = (sum((t[i]-t[h])**2))**0.5
		if x % 1 == 0:
			cnt += 1
			
print(int((cnt-n)/2))

Solution (Python):
from math import sqrt
N, D = map(int, input().split())
X = []
for i in range(N):
  X.append(list(map(int, input().split())))

ans = 0
for i in range(N):
  for j in range(i+1, N):
    distance = sqrt(sum([(X[i][d]-X[j][d])**2 for d in range(D)]))
    if distance.is_integer():
      ans += 1
      
print(ans)

Solution (Python):
n,d = map(int,input().split())
pts = []
for i in range(n):
    pts.append( [ int(i) for i in input().split() ])
def dist(a,b):
    ans = 0
    for i in range(len(a)):
        ans += (a[i]-b[i])**2
    y = int((ans)**0.5)
    if y**2 == ans:
        return True
    else:
        return False
ans = 0
for i in range(n):
    for j in range(i+1,n):
        ans += dist(pts[i],pts[j])
print(ans)

Solution (Python):
from math import sqrt

N, D = map(int, input().split())
L = [list(map(int, input().split())) for _ in range(N)]
cou = 0
for i in range(N):
    for j in range(N):
        ans = 0
        if i == j:
            continue
        for k in range(D):
            ans += abs(L[i][k] - L[j][k]) ** 2
        if sqrt(ans).is_integer():
            cou += 1
print(int(cou/2))

Solution (Python):
import math

N, D = map(int, input().split())
X = []
for i in range(N):
    x = list(map(int, input().split()))
    X.append(x)



ans = 0

for i in range(N):
    for j in range(i + 1, N):
        x = 0
        for k in range(D):
            x += (X[i][k] - X[j][k]) ** 2

        if math.sqrt(x).is_integer():
            ans += 1

print(ans)

Solution (Python):
n,d = map(int,input().split())
lst = [list(map(int,input().split())) for _ in range(n)]
cnt = 0
for i in range(n):
    for j in range(i+1,n):
        if i==j:
            continue
        else:
            dist = 0
            for k in range(d):
                dist += (lst[j][k] - lst[i][k])**2
        if dist**0.5 == int(dist**0.5):
            cnt += 1
print(cnt)

Solution (Python):
import math

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


for i,pi in enumerate(points):
    if i==n-1:
        break
    for pj in points[i+1:]:
        distance = math.sqrt(sum([(x-y)**2 for x,y in zip(pi,pj)]))
        if distance%1==0:
            ans +=1
print(ans)

Solution (Python):
import math
a=input().split(" ")
N=int(a[0])
D=int(a[1])
vector=[]
for p in range(0,N):
    v=input().split(" ")
    vec=[]
    for q in range(0,D):
        vec.append(int(v[q]))
    vector.append(vec)
count=0
for r in range(0,N):
    for s in range(r+1,N):
        distance2=0
        for t in range(0,D):
            distance2+=(vector[r][t]-vector[s][t])**2
        if math.sqrt(distance2)%1==0:
            count+=1
print(count)

Solution (Python):
n,d=map(int,input().split())
l1=[]
for a in range(n):
    l=list(map(int,input().split()))
    l1.append(l)
count=0
for i in range(n-1):
    for j in range(i+1,n):
        sum2 = 0
        for k in range(d):
            sum2+=(l1[i][k]-l1[j][k])**2
        if (sum2**0.5)%1==0:
            count+=1
print(count)

Solution (Python):
n,d = map(int,input().split())
x=[0 for _ in range(n)]
ans=0

for i in range(n):
    x[i] = list(map(int,input().split()))
for i in range(n-1):
    for j in range(n-1-i):
        j+=i+1
        check=0
        for k in range(d):
            check+=(x[i][k]-x[j][k])*(x[i][k]-x[j][k])
        check=check**(1/2)
        if(check%1==0):
            ans+=1
print(ans)

Solution (Python):
import math
N,D = map(int, input().split())
X = [list(map(int, input().split()))for _ in range(N)]
ans = 0
for i in range(0,N-1):
    for j in range(i+1,N):
        dis = math.sqrt(sum([(X[i][k]-X[j][k])**2 for k in range(D)]))
 
        if dis.is_integer():
            ans += 1
print(ans)

Solution (Python):
n, d = map(int, input().split())
coords = []
for i in range(n):
    x = list(map(int, input().split()))
    coords.append(x)

from math import sqrt

res = 0
for i in range(n):
    for j in range(i + 1, n):
        ci = coords[i]
        cj = coords[j]
        s = 0
        for k in range(d):
            s += (ci[k] - cj[k]) ** 2
        sq = sqrt(s)
        if sq.is_integer():
            res += 1
print(int(res))

Solution (Python):
n,d=map(int,input().split())
x=[]
for _ in range(n):
  x+=[list(map(int,input().split()))]
ans=0
for i in range(n):
  for j in range(i+1,n):
    l=0
    for k in range(d):
      l+=(x[i][k]-x[j][k])**2
    l=l**0.5
    if l.is_integer():
      ans+=1
print(ans)

Solution (Python):
import math

N, D = map(int, input().split())
point_list = list(list(map(int, input().split())) for i in range(N))
tmp = 0
output = 0

for k in range(N - 1):
    X = point_list[k]
    for l in range(k + 1, N):
        Y = point_list[l]
        for i in range(D):
            tmp += (X[i] - Y[i]) ** 2

        if math.sqrt(tmp).is_integer():
           output += 1

        tmp = 0

print(output)

Solution (Python):
import math
N,D = map(int, input().split())
X = [list(map(int, input().split()))for _ in range(N)]
ans = 0
for i in range(0,N-1):
    for j in range(i+1,N):
        dis = math.sqrt(sum([(X[i][k]-X[j][k])**2 for k in range(D)]))

        if dis.is_integer():
            ans += 1
print(ans)

Solution (Python):
n, d = (int(i) for i in input().split())
num = list((list(map(int, input().split())) for j in range(n)))
sum = 0
cnt = 0
for k in range(n - 1) :
  for t in range(k + 1, n) :
    for h in range(d) :
      sum += (num[k][h] - num[t][h])**2
    work = sum**(1 / 2)
    temp = work * 10
    temp = temp % 10
    if temp == 0 :
      cnt += 1
    sum = 0
print(cnt)

Solution (Python):
import math
import itertools

n, d = map(int, input().split())
comb_list = list(range(n))
c = itertools.combinations(comb_list, 2)
l = []
count = 0
for i in range(n):
    array = list(map(int, input().split()))
    l.append(array)

for i, j in c:
    sum = 0
    for k in range(d):
        sum += (l[i][k] - l[j][k])**2
    if math.sqrt(sum) % 1 == 0:
        count += 1

print(count)

Solution (Python):
import itertools
import math
N, D = map(int, input().split())
cnt = 0
lst = []
for i in range(N):
    lst.append(list(map(int, input().split())))
for x, y in itertools.combinations(lst, 2):
    leng = 0
    for d in range(D):
        leng += (x[d] - y[d])**2
    leng = math.sqrt(leng)       
    if leng == int(leng):
        cnt += 1
print(cnt)

Solution (Python):
import math
from itertools import combinations
N,D = map(int,input().split())
X = [list(map(float, input().split())) for i in range(N)]
counter = [(sum([(a-b)**2 for a, b in zip(x0,x1)])**0.5).is_integer() for x0,x1 in combinations(X, 2)]
print(sum(counter))

Solution (Python):
import math
from itertools import combinations
N,D = map(int,input().split())
X = [list(map(float, input().split())) for i in range(N)]
counter = 0
for x0,x1 in combinations(X, 2):
    if math.sqrt(sum([(a-b)**2 for a, b in zip(x0,x1)])).is_integer():
        counter+=1
print(counter)

Solution (Python):
import math
from itertools import combinations
N,D = map(int,input().split())
X = [list(map(float, input().split())) for i in range(N)]
counter = 0
for x0,x1 in combinations(X, 2):
    if x0 == x1:
      continue
    if math.sqrt(sum([(a-b)**2 for a, b in zip(x0,x1)])).is_integer():
            counter+=1
print(counter)

Solution (Python):
import math
from itertools import product
N,D = map(int,input().split())
X = [list(map(float, input().split())) for i in range(N)]
counter = 0
for x0,x1 in product(X, repeat=2):
    if x0 == x1:
      continue
    if math.sqrt(sum([(a-b)**2 for a, b in zip(x0,x1)])).is_integer():
            counter+=1
print(counter//2)

Solution (Python):
import math
N,D = map(int,input().split())
X = [list(map(float, input().split())) for i in range(N)]
counter = 0
for i, x0 in enumerate(X): 
    for x1 in X[i+1:]:
        if math.sqrt(sum([(a-b)**2 for a, b in zip(x0,x1)])).is_integer():
            counter+=1
print(counter)

Solution (Python):
import math
N, D = map(int,input().split())
X=[]
for i in range(N):
    X.append(list(map(int,input().split())))
cnt = 0
for i in range(N-1):
    for j in range(i+1,N):
        nijo = 0
        for k in range(D):
            nijo += (X[i][k]-X[j][k])**2 
        cnt += int(math.sqrt(nijo)==int(math.sqrt(nijo)))
print(cnt)

Solution (Python):
import numpy as np
n,d=map(int,input().split())
x=np.array([list(map(int,input().split())) for _ in range(n)])
cnt=0
for i in range(n):
    for j in range(i+1,n):
        dist=np.linalg.norm(x[i]-x[j])
        if dist==int(dist):
            cnt+=1
print(cnt)

Solution (Python):
from math import sqrt
n,d=map(int,input().split())
X=[[int(i)for i in input().split()]for _ in range(n)]
c=0
for i in range(n-1):
    for j in range(i+1,n):
        a=0
        for k in range(d):
            a+=(X[i][k]-X[j][k])**2
        if sqrt(a)==int(sqrt(a)):
            c+=1
print(c)

Solution (Python):
import math
N,D = map(int,input().split())
X = [list(map(float, input().split())) for i in range(N)]
counter = 0
for i in range(N): 
    for j in range(i+1, N):
        if math.sqrt(sum([(a-b)**2 for a, b in zip(X[i],X[j])])).is_integer():
            counter+=1
print(counter)

Solution (Python):
N,D = list(map(int,input().split()))
X = []
for n in range(N):
    X.append(list(map(int,input().split())))


cnt = 0

for i in range(N):
    for j in range(i+1,N):
        d = 0
        for k in range(D):
            d += (X[i][k]-X[j][k])**2
        d = d**0.5
        if d.is_integer() :
            cnt += 1

print(cnt)

Solution (Python):
import numpy as np

N,D = list(map(int,input().split()))
X = []
for n in range(N):
    X.append(list(map(int,input().split())))


cnt = 0

for i in range(N):
    for j in range(i+1,N):
        d = 0
        for k in range(D):
            d += (X[i][k]-X[j][k])**2
        d = d**0.5
        if d.is_integer() :
            cnt += 1

print(cnt)

Solution (Python):
import numpy as np

N,D = list(map(int,input().split()))
X = []
for n in range(N):
    X.append(list(map(int,input().split())))


vec = np.array(X)

cnt = 0
for i in range(N):
    for j in range(i+1,N):
        dist = np.linalg.norm(vec[i]-vec[j])
        if dist.is_integer():
            cnt += 1
print(cnt)

Solution (Python):

N,D = map(int, input().split())
count=0

inputs = [list(map(int, input().split())) for i in range(N)]

for i in range(len(inputs)-1):
    for j in range(i+1, len(inputs)):
        temp= 0
        for k in range(D):
            temp += (inputs[i][k]-inputs[j][k])**2
        temp = temp**(1/2)
        if int(temp) == temp:
            count+=1
print(count)

Solution (Python):
n,d= map(int,input().split())
l = []
a = 0
def dis(l1,l2):
    c = 0
    for i in range(0,len(l1)):
        c = c+(l1[i]-l2[i])**2
    return c**0.5

for _ in range(n):
    l.append(list(map(int,input().split())))
for i in range(0,n-1):
    for j in range(i+1,n):
        if float(dis(l[i],l[j])).is_integer() == True:
            a = a + 1
print(a)

Solution (Python):
n,d = map(int,input().split())
w = [list(map(int,input().split())) for a in range(n)]
c = 0
 
for i in range(n-1):
  for j in range(i+1,n):
    b = 0
    for m in range(d):
      b += (w[i][m]-w[j][m])**2
    if (b**0.5)==float(int(b**0.5)):
      c += 1
      
print(c)

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

n, d = map(int, input().split())
x_list = [input().split() for _ in range(n)]
ans = 0
for i in range(n):
  for j in range(i+1, n):
    R = dis2(x_list[i], x_list[j])
    for k in range(R+1):
      if k**2 == R:
        ans += 1
        continue

print(ans)

Solution (Python):
import numpy as np
n, d = map(int, input().split())
x = []
for i in range(n):
	x.append(np.array(list(map(int, input().split()))))

c = 0
for i in range(n-1):
	for j in range(i+1, n):
		if np.linalg.norm(x[i]-x[j]).is_integer():
			c += 1
print(c)

Solution (Python):
import numpy as np
n,d = map(int,input().split())
x = []
for i in range(n):
    x.append(np.array(list(map(int, input().split()))))
    
count = 0
for i in range(n-1):
  for k in range(i+1,n):
    if (np.linalg.norm(x[i]-x[k]))%1 == 0:
      count += 1
      
print(count)

Solution (Python):
import math
n,d=map(int,input().split())
L=[]
for i in range(n):
   L.append(list(map(int,input().split())))
c=0
for j in range(n):
    for k in range(j+1,n):
        s=pow(sum([(L[j][m]-L[k][m])**2 for m in range(d)]),0.5)
        if math.ceil(s)==math.floor(s):
            c+=1
print(c)

Solution (Python):
from math import sqrt
n, d = map(int, input().split())
lst = []
cnt = 0
for i in range(n):
    a = tuple(map(int, input().split()))
    lst.append(a)
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
        length = sqrt(x)
        if length%1 == 0:
            if length != 0:
                cnt += 1
print(cnt)

Solution (Python):
N,D=map(int,input().split())
a=[input().split() for i in range(N)]
c=0
for i in range(N-1):
  for j in range(i+1,N):
    b=0
    for m in range(D):
      b+=(int(a[i][m])-int(a[j][m]))**2
    if b**0.5==float(int(b**0.5)):
                    c+=1
print(c)

Solution (Python):
import numpy as np
n,d = [int(i) for i in input().split()]

l = []
for i in range(n):
    dots = [int(i) for i in input().split()]
    l.append(dots)
    
ans = 0
for i in range(len(l)):
    m = np.array(l.pop())
    for j in l:
        j = np.array(j) - m
        dist = np.sum(j**2)
        if np.sqrt(dist).is_integer():
            ans += 1
print(ans)

Solution (Python):
from math import sqrt
from numpy import array 
import numpy as np

N,D = map(int,input().split())
Xlist = array([list(map(int,input().split())) for a in range(N)])
counter = 0
for j in range(N):
    for i in range(j):
        dis = sqrt(np.sum(np.power(Xlist[i]-Xlist[j],2)))
        if dis==int(dis):
            counter += 1

print(counter)

Solution (Python):
import sys
input = sys.stdin.readline
from math import floor, sqrt
n,d = map(int, input().split())
l = []
for _ in range(n):
	l.append(tuple(map(int, input().split())))
ans = 0
for i in range(n - 1):
	for j in range(i + 1, n):
		s = 0
		for k in range(d):
			s += (l[i][k] - l[j][k]) ** 2
		x = sqrt(s)
		if floor(x) == x:
			ans += 1
print(ans)

Solution (Python):
N, D = map(int, input().split())
X = [[int(i) for i in input().split()] for _ in range(N)]
count = 0
for i in range(N):
  for j in range(i + 1, N):
    res = sum([(X[i][k] - X[j][k])**2 for k in range(D)])
    if (res**0.5) % 1 == 0:
      count += 1
print(count)

Solution (Python):
n,d = map(int, input().split())


x = []
for i in range(n):
    x.append(list(map(int, input().split())))


result = 0

for i in range(n):
    for j in range(n):
        if i < j:
            dist = 0
            for k in range(d):
                dist += (x[i][k] - x[j][k]) ** 2
            dist = dist ** 0.5
            if dist.is_integer():
                result += 1
print(result)

Solution (Python):
n, d = map(int, raw_input().split())
x = []
comb = []
for j in range(n):
    x.append(map(int, raw_input().split()))
    comb.append(j+1)

import itertools
x_comb = list(itertools.combinations(comb,2))

import numpy as np

c = 0

for i in range(len(x_comb)):
    if np.linalg.norm(np.array(x[x_comb[i][0]-1])-np.array(x[x_comb[i][1]-1])).is_integer() == True:
        c +=1

print(c)

Solution (Python):
import numpy as np

N, D = map(int, input().split())
X = np.array([list(map(int, input().split())) for _ in range(N)])
ans = 0
Dist = 0

for i in range(N - 1):
    for j in range(i + 1, N):
        Dist = np.sum((X[i] - X[j]) ** 2)
        for k in range(1, Dist // 2 + 2):
            if k ** 2 == Dist:
                ans += 1
print(ans)

Solution (Python):
import numpy as np

N, D=map(int, input().split())
a=np.zeros((N, D))
for i in range(N):
  a[i, :]=list(map(int, input().split()))
  
counter=0
for i in range(N-1):
  for j in range(i+1, N):
    temp=pow(np.sum((a[i]-a[j])**2), 1/2)
    if temp-int(temp)==0:
      counter+=1
      
print(int(counter))

Solution (Python):
import numpy as np
X = []

N, D = map(int, input().split())
X = np.array([list(map(int, input().split())) for _ in range(N)])
ans = 0

for i in range(N - 1):
    for j in range(i + 1, N):
        if np.sqrt(np.sum((X[i] - X[j]) ** 2)).is_integer() == True:
            ans += 1

print(ans)

Solution (Python):
import numpy as np
X = []

N, D = map(int, input().split())
for i in range(N):
    X = np.append(X, np.array(list(map(int, input().split()))))
X = np.reshape(X, (N, D))
ans = 0

for i in range(N - 1):
    for j in range(i + 1, N):
        if np.sqrt(np.sum((X[i] - X[j]) ** 2)).is_integer() == True:
            ans += 1

print(ans)

Solution (Python):
import math
N,D=map(int,input().split())
l=[]
anss=0
for i in range(N):
  a=list(map(int,input().split()))
  l.append(a)
for i in range(N):
  for j in range(i+1,N):
    ans=0
    for k in range(D):
      ans+=(l[i][k]-l[j][k])**2
    if (ans**0.5)%1==0:
      anss+=1
print(anss)

Solution (Python):
import math
n,d = map(int,input().split())
x = [list(map(int,input().split())) for i in range(n)]
cnt = 0
for k in range(n):
  for i in range(n):
    a = 0
    if i > k:
      for j in range(d):
        a += abs(x[k][j]-x[i][j])**2
      b = math.sqrt(a)
      if int(b)**2 == a:
        cnt += 1
print(cnt)