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



Sample input:
3 2
1 2
5 5
-2 8


Sample output:
1

Submission status: Wrong Answer

Solution code:
import sys 
import numpy as np 

def distance():
    N,D=map(int,input().split())
    y=[]
    ans=0
    for i in range(N):
        x=list(map(int,input().split()))
        y.append(x)
    y=np.array(y)
    y.reshape(N,-1)
    for i in range(N-1):
        for j in range(i+1,N):
            dis=(((y[i]-y[j])**2).sum())**(1/2)
            if dis.is_integer():
                ans+=1
    
    print(ans)

Submission status: Wrong Answer

Solution code:
def issq(n):
    for i in range(2 * n):
        if i * i == n:
            return True
    return False
    

n, d = map(int, 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):
        sqdist = 0
        for k in range(d):
            sqdist = sqdist + ((x[i][k] - x[j][k]) ** 2)
        print(sqdist)
        if issq(sqdist) == True:
            count = count + 1

print(count)

Submission status: Wrong Answer

Solution code:
n, d = map(int, input().split())
x_list = [[int(x) for x in input().split()] for _ in range(n)]
power_list = [i**2 for i in range(100)]
ans = 0

for l in range(~-n):
  for r in range(-~l, n):
    if sum([(y-z)**2 for y, z in zip(x_list[l], x_list[r])]) in power_list:
      ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
dlst = []

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

for i in range(N):
    grid = list(map(int, input().split()))
    dlst.append(grid)

lst=[1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256, 289, 324, 361, 400, 441, 484, 529, 576, 625, 676, 729, 784, 841, 900, 961, 1024, 1089, 1156, 1225, 1296, 1369, 1444, 1521, 1600, 1681, 1764, 1849, 1936, 2025, 2116, 2209, 2304, 2401, 2500, 2601, 2704, 2809, 2916, 3025, 3136, 3249, 3364, 3481, 3600, 3721, 3844, 3969]
count=0
distance = 0
checklst=[]

for i in range(N):
    for m in range(N-1):
        distance = 0
        for j in range(D):
            distance += (dlst[i][j] - dlst[m+1][j])**2
            checklst.append((i,m+1,j))
        if (m+1,i,j) not in checklst:                
            if distance in lst:
                count += 1
                
print(count)

Submission status: Wrong Answer

Solution code:
import math

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

print(X)

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

Submission status: Wrong Answer

Solution code:
dlst = []

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

for i in range(N):
    grid = list(map(int, input().split()))
    dlst.append(grid)

lst=[1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256, 289, 324, 361, 400, 441, 484, 529, 576, 625, 676, 729, 784, 841, 900, 961, 1024, 1089, 1156, 1225, 1296, 1369, 1444, 1521, 1600, 1681, 1764, 1849, 1936, 2025, 2116, 2209, 2304, 2401, 2500, 2601, 2704, 2809, 2916, 3025, 3136, 3249, 3364, 3481, 3600, 3721, 3844, 3969]
count=0
distance = 0
checklst=[]

for i in range(N):
    for m in range(N-1):
        distance = 0
        for j in range(D):
            distance += (dlst[i][j] - dlst[m+1][j])**2
            checklst.append((i,m+1))
        if (m+1,i) not in checklst:                
            if distance in lst:
                count += 1
                
print(count)

Submission status: Wrong Answer

Solution code:
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(N):
        if i == j:
            continue
        else:
            tmp = 0
            for k in range(D):
                tmp += (x[i][k] - x[j][k]) ** 2
            dis = tmp ** 0.5
            print(dis)
            if dis.is_integer():
                ans += 1
print(int(ans / 2))

Submission status: Wrong Answer

Solution code:
dlst = []

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

for i in range(N):
    grid = list(map(int, input().split()))
    dlst.append(grid)

lst=[1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256, 289, 324, 361, 400, 441, 484, 529, 576, 625, 676, 729, 784, 841, 900, 961, 1024, 1089, 1156, 1225, 1296, 1369, 1444, 1521, 1600, 1681, 1764, 1849, 1936, 2025, 2116, 2209, 2304, 2401, 2500, 2601, 2704, 2809, 2916, 3025, 3136, 3249, 3364, 3481, 3600, 3721, 3844, 3969]
count=0
distance = 0
checklst=[]

for i in range(N):
    for m in range(N-1):     
        distance = 0
        for j in range(D):
            distance += (dlst[i][j] - dlst[m+1][j])**2
        if (m+1,i) not in checklst:                
            if distance in lst:
                count += 1
                checklst.append((i,m+1))
print(count)

Submission status: Wrong Answer

Solution code:
dlst = []

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

for i in range(N):
    grid = list(map(int, input().split()))
    dlst.append(grid)

lst=[0, 1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256, 289, 324, 361, 400, 441, 484, 529, 576, 625, 676, 729, 784, 841, 900, 961, 1024, 1089, 1156, 1225, 1296, 1369, 1444, 1521, 1600, 1681, 1764, 1849, 1936, 2025, 2116, 2209, 2304, 2401, 2500, 2601, 2704, 2809, 2916, 3025, 3136, 3249, 3364, 3481, 3600, 3721, 3844, 3969]
count=0
distance = 0
checklst=[]

for i in range(N):
    for m in range(N-1):     
        distance = 0
        for j in range(D):
            distance += (dlst[i][j] - dlst[m+1][j])**2
        if (m+1,i) not in checklst:                
            if distance in lst:
                count += 1
                checklst.append((i,m+1))
print(count)

Submission status: Wrong Answer

Solution code:
N, D = [int(i) for i in input().split()]
X=[]
ans=0
for j in range(N):
    X.append([int(i) for i in input().split()])

for i in range(N):
    for j in range(i+1,N):
        y=X[i]
        z=X[j]
        tmp=0
        for k in range(D):
            tmp += (y[k]-z[k])**2
        tmp2 = tmp ** 0.5
        if tmp2.is_integer():
            print(i,j)
            ans+=1   
         
print(ans)

Submission status: Wrong Answer

Solution code:
dlst = []

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

for i in range(N):
    grid = list(map(int, input().split()))
    dlst.append(grid)

lst=[1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256, 289, 324, 361, 400, 441, 484, 529, 576, 625, 676, 729, 784, 841, 900, 961, 1024, 1089, 1156, 1225, 1296, 1369, 1444, 1521, 1600, 1681, 1764, 1849, 1936, 2025, 2116, 2209, 2304, 2401, 2500, 2601, 2704, 2809, 2916, 3025, 3136, 3249, 3364, 3481, 3600, 3721, 3844]
count=0
distance = 0
checklst=[]

for i in range(N):
    for m in range(N-1):     
        distance = 0
        for j in range(D):
            distance += (dlst[i][j] - dlst[m+1][j])**2
        if (m+1,i) not in checklst:                
            if distance in lst:
                count += 1
                checklst.append((i,m+1))
print(count)

Submission status: Wrong Answer

Solution code:
N, D = [int(i) for i in input().split()]
X=[]
ans=0
for j in range(N):
    X.append([int(i) for i in input().split()])

for i in range(N):
    for j in range(i+1,N):
        y=X[i]
        z=X[j]
        tmp=0
        for k in range(D):
            tmp += (y[k]-z[k])**2
        tmp2 = tmp ** 0.5
        if tmp2 - int(tmp2) == 0:
            print(i,j)
            ans+=1   
         
print(ans)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import math
n, d = map(int, input().split())

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

cnt = 0
for i in range(n - 1):
    for j in range(i + 1, n):
        tmp = 0.0
        for k in range(d):
            tmp += pow((x[i][k] - x[j][k]), 2)

        tmp = math.sqrt(tmp)
        print(tmp)
        cnt += tmp.is_integer()

print(cnt)

Submission status: Wrong Answer

Solution code:
import math

def is_integer(n):
    try:
        float(n)
    except ValueError:
        return False
    else:
        return float(n).is_integer()

n,d = map(int,input().split())
x = []
for i in range(n):
    x.append([int(j) for j in input().split()])
c = 0
print(x)
for i in range(n-1):
    for j in range(i+1,n):
        dist = 0
        for a in range(d):
            dist += (x[i][a] - x[j][a]) * (x[i][a] - x[j][a])
        if is_integer(math.sqrt(dist)):
            c += 1
print(c)

Submission status: Wrong Answer

Solution code:
import math

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

array = [[0]*10]*10

for i in range(N):
    x = list(map(int, input().split()))
    for j in range(D):
        array[i][j] = x[j];
    
dis = 0
sum_dis = 0
for i in range(N-1):
    for j in range(i+1,N):
        for k in range(D):
            dis += (array[i][k] - array[i][k])**2
        dis = math.sqrt(dis)
        if(type(dis) == int): sum_dis += 1
print(sum_dis)

Submission status: Wrong Answer

Solution code:
import math
from collections import deque

# 2つの入力を空白で分割し、数値化
N, D = map(int, input().split())

points = []

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


def distance(x, y):
    dd = 0
    for xy in zip(x,y):
        dd += (xy[0] - xy[1])**2
    return math.sqrt(dd)

q = deque(points)

result = 0
while len(q) != 0:
    left = q.popleft()
    for right in q:
        d = distance(left, right)
        print(d)
        if d.is_integer():
            result += 1
        else:
            pass

print(result)

Submission status: Wrong Answer

Solution code:
import math
n,d=map(int,input().split())
x=[list(map(int,input().split())) for i in range(n)]
cnt=0
dis=0
if d==1:
    print(n*(n-1)//2)
else:
    for i in range(n-1):
        for j in range(i+1,n):
            distance=0
            dis=0
            for k in range(d):
                dis+=(x[i][k]-x[j][k])**2
            distance=math.sqrt(dis)   
            print(distance) 
            if distance.is_integer()==True:
                cnt+=1
    print(cnt)

Submission status: Wrong Answer

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

result = []
tmp = 0

for i in s:
    for j in s:
        if not(i == j):
            for k in range(d):
                tmp += (i[k] - j [k]) ** 2
            result.append(tmp)
            tmp = 0
result = list(set(result))

result2 = []
for i in result:
    tmp = int(i**0.5)
    if abs(tmp*tmp - i) < 1e-6:
        result2.append(tmp)
    tmp=0

print(len(result2))

Submission status: Wrong Answer

Solution code:
import math
N, D = map( int, input().split() )
X = [list(map(int, input().split())) for _ in range(N)]
result = 0

for i in range(N):
    tmp = 0.0
    for j in range(i, N):
        for k in range(D):
            tmp += (X[i][k] - X[j][k]) ** 2
        tmp = math.sqrt(tmp)
        if tmp.is_integer():
            result += 1

print(result)

Submission status: Wrong Answer

Solution code:
import math
import itertools
N,D=map(int,input().split())
data=[ list(map(int,input().split())) for i in range(N)]
L=list(itertools.combinations(data, 2))
tt=[]
for l in L:
  t=0
  for d in range(D):
    X=l[0][d]-l[1][d]
    XX=X*X
    t=t+XX
  tt.append(t)
ans=0
for ttt in tt:
  if int(math.sqrt(ttt)*10%10)==0:
    ans=ans+1
print(ans)

Submission status: Wrong Answer

Solution code:
import math
n,d=map(int,input().split())
x=[list(map(int,input().split())) for i in range(n)]
cnt=0
dis=0
if d==1:
    print(n*(n-1)//2)
else:
    for i in range(n-1):
        for j in range(i+1,n):
            dis=0
            for k in range(d):
                dis+=(x[i][k]-x[j][k])**2
            distance=math.sqrt(dis)   
            print(distance) 
            if distance.is_integer()==True:
                cnt+=1
    print(cnt)

Submission status: Wrong Answer

Solution code:
def resolve():
    data = []
    n,d = map(int,input().split())
    for _ in range(n):
        x = list(map(int,input().split()))
        data.append(x)
    square =[]
    for i in range(1,100):
        square.append(i*i)
    ans=0
    for i in range(n):
        for j in range(i+1,n):
            k = [abs(l-m)**2 for l,m in zip(data[i],data[j]) ]
            s=sum(k)
            if s in square:
                ans = ans + 1

    print(ans)


if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

Solution code:
import math
N,D=map(int,input().split())
x=[]
for i in range(N):
    y=list(map(int,input().split()))
    x.append(y)

cnt=0
for n in range(N):
    a=[]
    for d in range(D):
        if n == N-1:
            a.append((x[-1][d]-x[0][d])**2)
        else:
            a.append((x[n][d]-x[n+1][d])**2)
    c=math.sqrt(sum([abs(i) for i in a]))
    if c%1==0:
        cnt+=1
print(cnt)

Submission status: Wrong Answer

Solution code:
n , D =map(int,input().split())
import sys
import math

a = [input().split() for l in range(n)]
count = 0
 
for i in range(n):
  for j in range(n):
    if i == j:
      count += 0
    else:
      x = []
      for c in range(D):
        x.append((int(a[i][c]) - int(a[j][c])) ** 2)
      d = math.sqrt(sum(x))
      d = float(d)
      if d.is_integer():
        count += 1
print(count/2)

Submission status: Wrong Answer

Solution code:
import math

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

a = [i**2 for i in range(100)]
n = 1
t = 0
for i in range(N):
    k = i + n
    for j in range(k, N):
        count = 0
        for l in range(D):
            count += (x[i][l] - x[j][l]) ** 2
        n += 1
        if count in a:
            t += 1
    n = 1

print(t)

Submission status: Wrong Answer

Solution code:
import numpy as np
n,d = map(int,input().split())
ans=0
g=[]
if d==1:
    ans=n*(n-1)//2
    print(ans)
else:
    for _ in range(n):
        lis = np.array(list(map(int,input().split())))
        for i in range(len(g)):
            u = g[i]-lis
            z=np.linalg.norm(u)
            if z-int(z)==0:
                ans+=1
        g.append(lis)
print(ans)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/python3
# -*- coding: utf-8 -*-



def main():
  N,D = map(int, input().split())
  Xn = []
  for _ in range(N):
    Xn.append(list(map(int, input().split())))

  ans = 0
  ansset = [i**2 for i in range(101)]
  for i in range(N):
    for j in range(i+1,N):
      sm = 0
      for k in range(D):
        sm += (Xn[i][k]-Xn[j][k])**2
      if sm in ansset:
        ans += 1
  print(ans)


if __name__ == "__main__":
  main()

Submission status: Wrong Answer

Solution code:
n , D =map(int,input().split())
import sys
import math

print(n)
a = [input().split() for l in range(n)]
print(a)
count = 0
 
for i in range(n):
  for j in range(n):
    if i == j:
      count += 0
    else:
      x = []
      for c in range(D):
        x.append((int(a[i][c]) - int(a[j][c])) ** 2)
      d = math.sqrt(sum(x))
      d = float(d)
      if d.is_integer():
        count += 1
print(count/2)

Submission status: Wrong Answer

Solution code:
N,D = map(int, input().split())
X = [[int(i) for i in input().split()] for i in range(N)]
S = set()
ans = 0
for i in range(N):
    for j in range(N):
        for k in range(D):
            S = S | {(X[i][k] - X[j][k])**2}
        sumS = sum(S)**(0.50)
        S = set()
        if i == j:
            ans += 0
        elif sumS.is_integer() == True:
            ans +=1
print(ans//2)

Submission status: Wrong Answer

Solution code:
N,D = map(int, input().split())
X = [[int(i) for i in input().split()] for i in range(N)]
S = set()
ans = 0
for i in range(N):
    for j in range(N):
        for k in range(D):
            S = S | {(X[i][k] - X[j][k])**2}
        sumS = sum(S)**(0.50)
        print(sumS)
        S = set()
        if i == j:
            ans += 0
        elif sumS.is_integer() == True:
            ans +=1
print(ans//2)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import math

# スペース区切りの整数の入力
n,d = map(int, input().split())
list_x = [[0 for i in range(d)] for j in range(n)]

ans = 0
tmp_targ = 0

for k in range(n):
    list_x[k] = list(map(int, input().split()))

print(list_x)

for l in range(n-1):
    for m in range(l+1,n):
        tmp_targ = 0
        for i1 in range(d):
            tmp_targ += (list_x[l][i1] - list_x[m][i1]) ** 2
        print("targ:{},sqrt:{}".format(tmp_targ,math.sqrt(tmp_targ)))
        if isinstance(math.sqrt(tmp_targ), int) or math.sqrt(tmp_targ).is_integer():
            ans += 1
# 出力
print(ans)

Submission status: Wrong Answer

Solution code:
N, D = map(int, input().split())
import math
X = []
for i in range(N):
    array = list(map(int, input().strip().split()))
    X.append(array)
var = 0
for i in range(N-1):
  for k in range(N-1-i):
    s = 0
    for j in range(D):      
      s = s + (X[i+1+k][j] - X[i+k][j])*(X[i+1+k][j] - X[i+k][j])
    if math.sqrt(s) - (int(math.sqrt(s))) ==0:
      var = var+1
print(var)

Submission status: Wrong Answer

Solution code:
n, d = map(int, input(). split())
cube_list = []
x_list = []
count = 0
for i in range(50):
    cube_list.append(i*i)
for i in range(n):
    x = list(map(int, input(). split()))
    x_list.append(x)
for i in range(n-1):
    for j in range(n-i-1):
        cube_sum = 0
        for k in range(d):
            cube_sum += (x_list[i][k]-x_list[i+j+1][k])**2
        if cube_sum in cube_list:
            count += 1
print(count)

Submission status: Wrong Answer

Solution code:
import math
import itertools
N, D = map(int, input().split())

count = 0
all_list = []
for _ in range(N):
    p_list = list(map(int, input().split()))
    all_list.append(p_list)

comb_list = list(itertools.combinations(all_list, 2))
for f_list, l_list in comb_list:
    print(f_list)
    diff_list = [(i-j)**2 for i, j in zip(f_list, l_list)]
    dist = math.sqrt(sum(diff_list))
    if dist == int(dist):
        count += 1

Submission status: Wrong Answer

Solution code:
import numpy as np
from sys import stdin

N,D=[int(x) for x in stdin.readline().rstrip().split()]
data = [stdin.readline().rstrip().split() for _ in range(N)]

ret=0
for i in range(N-1):
    for j in range(i+1,N,1):
        a=[ int(x) for x in data[i]]
        b=[ int(x) for x in data[j]]
        u = np.array(b) - np.array(a)
        if np.linalg.norm(u).is_integer:
            ret+=1
            # print(a,end=" ")
            # print(b)

print(ret,flush=True)

Submission status: Wrong Answer

Solution code:
N,D = map(int, input().split())
X = [[int(i) for i in input().split()] for i in range(N)]
S = set()
ans = 0
for i in range(N):
    for j in range(N):
        for k in range(D):
            S = S | {(X[i][k] - X[j][k])**2}
        sumS = sum(S)**(0.5)
        S = set()
        if i == j:
            ans += 0
        elif sumS.is_integer() == True:
            ans +=1
print(ans//2)

Submission status: Wrong Answer

Solution code:
import math
N, D = map(int, input().split())

array = [[0]*10]*10
dis = 0
sum_dis = 0
for i in range(N-1):
    for j in range(i+1,N):
        for k in range(D):
            dis += (array[i][k] - array[i][k])**2
        dis = math.sqrt(dis)
        if(type(dis) == int): sum_dis += 1
print(sum_dis)

Submission status: Wrong Answer

Solution code:
N, D = map(int, input().split())
X = []

def is_integer_num(n):
    if isinstance(n, int):
        return True
    if isinstance(n, float):
        return n.is_integer()
    return False

final_ans=0

for i in range(0,N,1):
    X.append(list(map(int, input().split())))

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

Submission status: Wrong Answer

Solution code:
import math
N,D=map(int,input().split())
X=[]
cnt=0
def distance(x,y):
    d2=[]
    for k in range(D):
        d2.append((X[x][k]-X[y][k])**2)
    return math.sqrt(sum(d2))
for i in range(N):
    X.append(list(map(int,input().split())))
for j in range(N-2):
    for l in (j+1,N-1):
        if float.is_integer(distance(j,l)):
            cnt+=1 
print(cnt)

Submission status: Wrong Answer

Solution code:
import math
n,d=map(int,input().split())
x=[[int(i)for i in input().split()] for j in range(n)]
ct=0
for i in x:
  for j in x:
    if i!=j:
      tmp=0
      for k in range(d):
        tmp+=(i[k]-j[k])**2
      tmp=math.sqrt(tmp)
      if tmp%1==0:
        ct+=1
print(ct)

Submission status: Wrong Answer

Solution code:
import math #math.sqrt(x)

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

ans = 0
for i in range(n):
    sumv = 0
    for j in range(d):
        if i == n - 1:
            sumv += (abs(x[i][j] - x[1][j])) ** 2
        else:
            sumv += (abs(x[i][j] - x[i + 1][j])) ** 2
            
    if math.sqrt(sumv).is_integer() == True:
        ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
import math
n,d=map(int,input().split())
x=[list(map(int,input().split())) for i in range(n)]
cnt=0
dis=0
if d==1:
    print(n*(n-1)//2)
else:
    for i in range(n-1):
        for j in range(i+1,n):
            for k in range(d):
                dis+=(x[i][k]-x[j][k])**2
            distance=math.sqrt(dis)    
            if distance.is_integer()==True:
                cnt+=1
    print(cnt)

Submission status: Wrong Answer

Solution code:
import math
z=[]
ans=0
sumsum=0
N,D=(int(x) for x in input().split())
for i in range(N):
    a=input().split()
    print(a)
    z.append(a)
#print(z)

for i in range(N):
    for j in range(i,N):
        for k in range(D):
            sumsum=sumsum+(int(z[i][k])-int(z[j][k]))**2
        if sumsum!=0 and math.sqrt(sumsum)%1==0:
            ans=ans+1
        sumsum=0

print(ans)

Submission status: Wrong Answer

Solution code:
N, D = [int(i) for i in input().split()]
X=[]
ans=0
for j in range(N):
    X.append([int(i) for i in input().split()])

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

tmp2 = tmp ** 0.5
if tmp2.is_integer :
    ans+=1            
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
N, D = [int(i) for i in input().split()]

list_coord = list()
for i in range(N):
  list_coord.append([int(i) for i in input().split()])
arr_coord = np.array(list_coord)

cnt = 0
for i in range(N):
    for j in range(N-i-1):
        a = np.array(list_coord[i])
        b = np.array(list_coord[N-j-1])
        dist = (abs(np.sum((a-b)**2)))**0.5
        print(a, b, dist)
        if dist.is_integer():
            cnt+=1
            
print(cnt)

Submission status: Wrong Answer

Solution code:
import math
N, D = map( int, input().split() )
X = [list(map(int, input().split())) for _ in range(N)]
result = 0

for i in range(N):
    tmp = 0.0
    for j in range(D):
        if i == N-1:
            tmp += (X[i][j] - X[0][j]) ** 2
        else:
            tmp += (X[i][j] - X[i+1][j]) ** 2
    tmp = math.sqrt(tmp)
    if tmp.is_integer():
        result += 1

print(result)

Submission status: Wrong Answer

Solution code:
N,D = map(int,input().split())
lst = [list(map(int,input().split())) for i in range(N)]
count = 0
for j in range(N-1):
    for i in range(j,N-1):
        a = 0
        for d in range(D):
            #print(lst[i],lst[i+1])
            a+= (abs(lst[i][d] - lst[i+1][d]))**2
        if (a**0.5 % 1 == 0):
            count+=1
        
print(count)

Submission status: Wrong Answer

Solution code:
import sys
import math

input = sys.stdin.readline


def main():
    n, d = [int(i) for i in input().split()]
    ps = [[int(i) for i in input().split()] for _ in range(n)]
    cnt = 0
    for i in range(n):
        hoge = 0 if i == n - 1 else i + 1
        hige = math.sqrt(sum([(ps[i][j] - ps[hoge][j]) ** 2 for j in range(d)]))
        if hige % 1 == 0:
            cnt += 1
    print(cnt)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
N,D = map(int,input().split())

row = list()
count = 0
for i in range(N):
  x = [int(_) for _ in input().split()]
  if i == 0:
    row.append(x)
  else:
    for j in range(len(row)):
      dist = 0
      for k in range(D):
        dist += (row[j][k]-x[k])**2
      print((dist**0.5)-int(dist**0.5))
      if (dist**0.5)-int(dist**0.5)==0:
      	count += 1
    row.append(x)
      
print(count)

Submission status: Wrong Answer

Solution code:
N, D = [int(i) for i in input().split()]
X=[]
ans=0
for j in range(N):
    X.append([int(i) for i in input().split()])

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

tmp2 = tmp ** 0.5
if tmp2.is_integer :
    ans+=1            
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
n,d = map(int,input().split())
list=[list(map(int,input().split())) for i in range(n)]
arr_list = np.array(list)
count = 0
for i in range(n):
    for j in range(i+1,n):
        if(i != j):
            distance = 0.0
            for k in range(d):
                distance += (arr_list[i][k] - arr_list[j][k])**2
            if(distance > 0):
                result = np.sqrt(distance)
                if(result.is_integer()):
                    print("ans = ", result)
                    count += 1
print(count)

Submission status: Wrong Answer

Solution code:
import math
n, d = map(int, input().split())
data = []
tmp1 = 0
tmp2 = 0
for i in range(n):
    data.append(list(map(int, input().split())))
for i1 in data:
    for i2 in data:
        if i1 != i2:
            for t in range(len(i1)):
                tmp1 += abs(i1[t] - i2[t])
                #print(abs(i1[t]-i2[t]))
            if math.sqrt(tmp1).is_integer():
                tmp2+=1
                #print(i2, i1)
            tmp1 = 0
if len(i1) == 2:
    print(int(tmp2/2))
else:
    print(tmp2)

Submission status: Wrong Answer

Solution code:
import math
n,d = map(int,input().split())
count = 0
alllist = []
for i in range(n):
    alist = list(map(int,input().split()))
    alllist.append(alist)


for i in range(n-1):
    for j in range(i+1,n):
        count1 = 0
        for s in range(d):
            count1 += (alllist[i][s]-alllist[j][s])**2
        if math.sqrt(count1) == int(math.sqrt(count1)):
            count += 1
        print(count1)
print(count)

Submission status: Wrong Answer

Solution code:
N, D = map(int, input().split())
X = []

def is_integer_num(n):
    if isinstance(n, int):
        return True
    if isinstance(n, float):
        return n.is_integer()
    return False

final_ans=0

for i in range(0,N,1):
    X.append(list(map(int, input().split())))

for i in range(0,N-1,1):
    for j in range(i+1,N,1):
        res = 0
        for k in range(0,D,1):
            res = res + (X[i][k] - X[j][k]) ** 2
        res = res ** 1/2
        if is_integer_num(res):
            final_ans = final_ans+1
print(final_ans)

Submission status: Wrong Answer

Solution code:
import math

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


all_list = []

for i in range(n):
    x = input()
    x = x.split(' ')

    # x = list(x)
    # print(x)
    x = [float(v) for v in x] # to float

    all_list.append(x)  # list of list

# print(all_list)

cnt = 0

for i in range(n):
    target = all_list[i]

    for j in range(n - (i + 1)):
        target2 = all_list[j + i + 1]

        sum_1 = [u ** 2 + v ** 2 for u, v in zip(target, target2)]
        sum_2 = sum(sum_1)
        dis = math.sqrt(sum_2)

        # print('---')
        # print(target)
        # print(target2)

        if dis.is_integer():
            cnt += 1

print(cnt)

Submission status: Wrong Answer

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

cnt = 0
for i in range(N):
    for j in range(i+1,N):
        r = 0
        for d in range(D):
            r += (X[i][d] - X[j][d]) ** 2
        for n in range(1,100):
            if r == n ** 2:
                cnt += 1

print(cnt)

Submission status: Wrong Answer

Solution code:
n,d=map(int,input().split())
a=[]
ans=0

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

Submission status: Wrong Answer

Solution code:
import math
N, D = map( int, input().split() )
X = [list(map(int, input().split())) for _ in range(N)]
result = 0

for i in range(N):
    tmp = 0.0
    for j in range(D):
        if i == N-1:
            tmp += (X[i][j] - X[0][j]) ** 2
        else:
            tmp += (X[i][j] - X[i+1][j]) ** 2
    tmp = math.sqrt(tmp)
    if tmp % 1 == 0:
        result += 1

print(result)

Submission status: Wrong Answer

Solution code:
import math

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

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

ans = 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]) * (X[i][k] - X[j][k])
        for z in range(100):
            if d == z**2:
                ans += 1
                break

print(ans)

Submission status: Wrong Answer

Solution code:
import math
n,d=map(int,input().split())
x=[[int(i)for i in input().split()] for j in range(n)]
ct=0

for i in x:
  for j in x:
    if i!=j:
      tmp=0
      for k in range(d):
        tmp+=math.sqrt(abs(i[k]**2-j[k]**2))
      if isinstance(tmp,int):
        ct+=1
print(ct)

Submission status: Wrong Answer

Solution code:
import numpy as np

N, D = (int(i) for i in input().split())
X = [[int(i) for i in input().split()] for i in range(N)]
print([D, N])
print(X)

ret = 0
for i in range(N):
  for j in range(i+1, N):
    a = np.array(X[i])
    b = np.array(X[j])
    u = b - a
    d = np.linalg.norm(u)
    if (d == int(d)):
      ret = ret + 1

print(ret)