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 numpy as np

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

for i in range(N):
  for j in range(i+1,N):
    d = 0
    sum = 0
    for k in range(D):
      sum += (X[i][k] - X[j][k])**2
    d = np.sqrt(sum)
    if d // 1 == d:
      print("{} {}".format(i+1,j+1))

Submission status: Wrong Answer

Solution code:
# b.py
n,d = map(int,input().split())
lis = [list(map(int,input().split())) for x in range(n)]
ans = 0
for xli in range(n-1):
    for yli in range(xli,n):
        le = 0
        for x,y in zip(lis[xli],lis[yli]):
            le += (y-x) **2
        print(xli,yli,'xli','yli')
        print((le**0.5)//1,le**0.5,le**0.5==(le**0.5)//1 and xli != yli,'root')
        if le**0.5 == (le**0.5)//1 and xli != yli:
             ans += 1
print(ans)

Submission status: Wrong Answer

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

x_list=[map(int,input().split()) for i in range(n)]

def dst(i,j):
    a=x_list[i]
    b=x_list[j]
    ret=0
    for p,q in zip(a,b):
        ret+=(p-q)**2
    r=int(ret**(0.5))
    if r**2==ret:
        return True
    else:
        return False

count=0
for i in range(n):
    for j in range(i+1,n):
        tmp=dst(i,j)
        if tmp:
            count+=1

print(count)

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)]
count = 0
for j in range(N-1):
    for k in range(j+1,N):
        L = 0
        for l in range(D):
            L += (X[j][l]-X[k][l])**2
            print(L)
        if math.sqrt(L).is_integer() == True:
            count += 1
print(count)

Submission status: Wrong Answer

Solution code:
from math import sqrt
n, d = map(int,input().split())
x = []
for i in range(n):
    xx = list(map(int,input().split()))
    x.append(xx)
sum = 0
count = 0
for i in range(n):
    for j in range(n):
        if i == j:
            break
        for z in range(d):
            sum = sum + (x[i][z]- x[j][z])**2
            if z == d - 1:
                sum = sqrt(sum)
            if sum % 1 == 0:
                count += 1

print(count // 2)

Submission status: Wrong Answer

Solution code:
import math
n, d = map(int, input().split())
x = [[0 for i in range(d)] for j in range(n)]
for i in range(n):
  x[i] = list(map(int, input().split()))
result = 0
for i in range(0,n-1):
  for j in range(i+1,n):
    diff = list(map(lambda x,y: pow(x-y,2), x[i], x[j]))
    print(diff)
    calc = math.sqrt(sum(diff))
    if calc.is_integer():
      result +=1
print(result)

Submission status: Wrong Answer

Solution code:
import math
n, d = map(int, input().split())
x = [[0 for i in range(d)] for j in range(n)]
for i in range(n):
  x[i] = map(int, input().split())
 
result = 0
for i in range(n):
  for j in range(1,n):
    diff = map(lambda x,y: (x-y)*(x-y), x[i],x[j])
    calc = math.sqrt(sum(diff))
    if calc.is_integer():
      result +=1
print(result)

Submission status: Wrong Answer

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

result = 0
for i in range(n):
  for j in range(n-1):
    diff = map(lambda x,y: (x-y)*(x-y), x[i],x[j])
    calc = math.sqrt(sum(diff))
    if calc.is_integer():
      result +=1
print(result)

Submission status: Wrong Answer

Solution code:
from sys import stdin
import numpy as np

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

is_int = 0
for i in range(N-1):
    for j in range(i+1, N):
        l1 = np.array(X[i])
        l2 = np.array(X[j])
        d = (sum((l1-l2)**2))**0.5
        if isinstance(d, int):
            is_int += 1
print(is_int)

Submission status: Wrong Answer

Solution code:
from sys import stdin
import math
import numpy as np


N, D = map(int, input().split())
X = []
for i in range(N):
    xi = [int(x) for x in stdin.readline().rstrip().split()]
    X.append(xi)
    
is_int = 0
for i in range(N-1):
    for j in range(i+1, N):
        l1 = np.array(X[i])
        l2 = np.array(X[j])
        d = math.sqrt(sum((l1-l2)**2))
        if isinstance(d, int):
            is_int += 1
print(is_int)

Submission status: Wrong Answer

Solution code:
import math
import numpy as np

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

is_int = 0
for i in range(N-1):
  for j in range(i+1, N):
    l1 = np.array(X[i])
    l2 = np.array(X[j])
    d = math.sqrt(sum((l1-l2)**2))
    if isinstance(d, int):
      is_int += 1
print(is_int)

Submission status: Wrong Answer

Solution code:
import math
import numpy as np

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

is_int = 0
for i in range(N-1):
  for j in range(i+1, N-i):
    l1 = np.array(X[i])
    l2 = np.array(X[j])
    d = math.sqrt(sum((l1-l2)**2))
    if isinstance(d, int):
      is_int += 1
print(is_int)

Submission status: Wrong Answer

Solution code:
import math
import numpy as np

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

is_int = 0
for i in range(N-1):
    for j in range(N-i):
        l1 = np.array(X[i])
        l2 = np.array(X[j])
        d = math.sqrt(sum((l1-l2)**2))
        if isinstance(d, int):
            is_int += 1
print(is_int)

Submission status: Wrong Answer

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

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

print(grid)
counter = 0

for i in range(n):
    for j in range(i+1,n):
        tmp = 0
        for k in range(d):
            tmp += (grid[i][k] - grid[j][k])**2

        #y^2がkと等しければ整数があることになる
        if int(round(math.sqrt(float(tmp)))**2) == tmp:
            counter += 1


print(counter)

Submission status: Wrong Answer

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

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

#print(grid)
counter = 0

#print(grid[0][0])
for i in range(n):
    for j in range(i+1,n):
        d = 0
        for k in range(d):
            d += (grid[i][k] - grid[j][k])**2
        #y^2がkと等しければ整数があることになる
        if int(round(math.sqrt(float(d)))**2) == d:
            counter += 1


print(counter)

Submission status: Wrong Answer

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

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

print(grid)
counter = 0

#print(grid[0][0])
for i in range(n):
    for j in range(i+1,n):
        d = 0
        for k in range(d):
            d += (grid[i][k] - grid[j][k])**2
        #y^2がkと等しければ整数があることになる
        if int(round(math.sqrt(float(d)))**2) == d:
            counter += 1


print(counter)

Submission status: Wrong Answer

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

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

print(grid)
counter = 0

#print(grid[0][0])
for i in range(1, n):
    tmp = []
    for j in range(d):
        tmp.append((grid[i][j] - grid[i-1][j])**2)

    k = sum(tmp)

    if int(round(math.sqrt(float(k)))**2) == k:
        counter += 1


print(counter)

Submission status: Wrong Answer

Solution code:
import itertools
a=list(map(int,input().split()))
x = [list(map(int,input().split())) for i in range(a[0])]

def dist_sq(lst_1,lst_2):
    s=0
    for i in range(len(lst_1)):
        s+=(lst_1[i]-lst_2[i])**2
    return s

b=[i**2 for i in range(1,21)]
c=list(itertools.combinations([i for i in range(a[0])],2))

length=[]
for i in range(len(c)):
    print(dist_sq(x[c[i][0]],x[c[i][1]]))
    length.append(dist_sq(x[c[i][0]],x[c[i][1]]))
t=0
for i in range(len(length)):
    for j in range(len(b)):
        if length[i]==b[j]:
            t+=1
print(t)

Submission status: Wrong Answer

Solution code:
import math


    
def deffer(A,B):
    sum = 0
    for i in range(len(A)):
        sum += (A[i]-B[i])**2
    sum = math.sqrt(sum)
    return sum


N,D= map(int,input().split())
listA = [list(map(int,input().split())) for i in range(N)]
ans =0
for i in range(N):
    for j in range(i +1,N):
        D = deffer(listA[i],listA[j])
        print(D)
        if D.is_integer():
            ans +=1
            
print(ans)

    
def deffer(A,B):
    sum = 0
    for i in range(len(A)):
        sum += (A[i]-B[i])**2
    sum = math.sqrt(sum)
    print("sum is {}".format(sum))
    return sum

Submission status: Wrong Answer

Solution code:
from math import sqrt


def calc(pos_x, pos_y):
  sum = 0
  for i in range(0, len(pos_x)):
    sum += (pos_x[i] - pos_y[i]) ** 2

  return sqrt(sum).is_integer()


# size, z = map(int, input().split())
# items = []
# for i in range(0, size):
#   items.append(list(map(int, input().split())))

items = []
items.append(list(map(int, "-3 7 8 2".split())))
items.append(list(map(int, "-12 1 10 2".split())))
items.append(list(map(int, "-2 8 9 3".split())))

count = 0

for i in range(0, len(items)):
  for j in range(i + 1, len(items)):
    count += 1 if calc(items[i], items[j]) else 0

print(count)

Submission status: Wrong Answer

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

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

print(cnt)

Submission status: Wrong Answer

Solution code:
import numpy as np
N,D=map(int,input().split())
X=[]
dist=[]
Xsumnow=0
Xsumnext=0

for i in range(N):
    X.append([int(j) for j in input().split()])
count=N
for m in range(N):
    for j in range(m+1,N):
        for k in range(D):
            Xsumnow+=abs(X[j][k]-X[m][k])*abs(X[j][k]-X[m][k])
        dist.append(np.sqrt(Xsumnow))
        Xsumnow=0
TrueCounter=0
for l in range(len(dist)):
    if dist[l].is_integer:
        TrueCounter+=1
print(TrueCounter)

Submission status: Wrong Answer

Solution code:
import numpy as np
N,D=map(int,input().split())
X=[]
dist=[]
Xsumnow=0
Xsumnext=0

for i in range(N):
    X.append([int(j) for j in input().split()])
count=N
while count:
    for j in range(N-count,N-1):
        for k in range(D):
            Xsumnow+=abs(X[j][k]-X[j+1][k])*abs(X[j][k]-X[j+1][k])
        dist.append(np.sqrt(Xsumnow))
        Xsumnow=0
    count=count-1
TrueCounter=0
for l in range(len(dist)):
    if dist[l].is_integer():
        TrueCounter+=1
print(TrueCounter)

Submission status: Wrong Answer

Solution code:
#133

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


count = 0
#距離計算(X_ikとX_jk)(i < J)
for i in range(0,N - 1):
    for j in range(i + 1,N):
        distance = 0;
        for k in range(0, D):
            distance +=  (X[i][k] - X[j][k]) * (X[i][k] - X[j][k])
        for l in range(0,100):
            if(distance == l*l):
                count = count + 1

print(count)

Submission status: Wrong Answer

Solution code:

#133

#入力（1次元）
N, D = list(map(int, input().split()))
#入力（２次元）
X = []
for i in range(0,N):
    X.append(list(map(int, input().split())))


count = 0
#距離計算(X_ikとX_jk)(i < J)
for i in range(0,N - 1):
    for j in range(i + 1,N):
        distance = 0;
        for k in range(0, D):
            distance +=  (X[i][k] - X[j][k]) * (X[i][k] - X[j][k])
        for l in range(0,distance):
            if(distance == l*l):
                count = count + 1

print(count)

Submission status: Wrong Answer

Solution code:
import math
import itertools

a,b=map(int,input().split())
X = [[int(i) for i in input().split()] for i in range(a)] 
#for i in range():
c = list(itertools.combinations(X, 2))
print(len(c))


ans = 0

for i in range(len(c)):
  d = 0
  for j in range(b):
    d += (c[i][0][j]-c[i][1][j])**2
    if j == b-1:
      d = math.sqrt(d)
      if d.is_integer():
        ans = ans+1

print(ans)

Submission status: Wrong Answer

Solution code:
import math
x =  [int(s) for s in input().split()]
numList = [[int(s) for s in input().split()] for i in range(x[0])]
sum = 0
for i in range(len(numList)):
    for j in range(i+1,len(numList)):
        d = 0
        for k in range(x[1]):
            d += (numList[i][k] - numList[j][k]) ** 2
        num = d ** 0.5
        numStr = str(num).split('.')
        print(d)
        if(numStr[len(numStr)-1] == '0'):
            sum += 1
            
print(sum)

Submission status: Wrong Answer

Solution code:
import math
x =  [int(s) for s in input().split()]
numList = [[int(s) for s in input().split()] for i in range(x[0])]
sum = 0
for i in range(len(numList)):
    for j in range(i+1,len(numList)):
        d = 0
        for k in range(x[1]):
            d += (numList[i][k] - numList[i+1][k]) ** 2
            num = d ** 0.5
        numStr = str(num).split('.')
        if(numStr[len(numStr)-1] == '0'):
            sum += 1
            
print(sum)

Submission status: Wrong Answer

Solution code:
import math
x =  [int(s) for s in input().split()]
numList = [[int(s) for s in input().split()] for i in range(x[0])]
sum = 0
for i in range(len(numList)):
    d = 0
    if(i != len(numList)-1):
        for j in range(x[1]):
            d += (numList[i][j]-numList[i+1][j]) ** 2
        num = d ** 0.5
        numStr = str(num).split('.')
        if(numStr[len(numStr)-1] == '0'):
            sum += 1
    elif(i == len(numList)-1):
        for j in range(x[1]):
            d += (numList[i][j]-numList[0][j]) ** 2
        num = d ** 0.5
        numStr = str(num).split('.')
        if(numStr[len(numStr)-1] == '0'):
            sum += 1
print(sum)

Submission status: Wrong Answer

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



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

sq_list = set([])
for i in range(1, 41):
    sq_list.add(i ** 2)


cnt = 0
for i in range(N):
    Y = X[i]
    for j in range(i, N):
        Z = X[j]
        sum_val = 0
        for y, z in zip(Y, Z):
            sum_val += (y - z) ** 2
        if sum_val in sq_list:
            cnt += 1

print(cnt)

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(i+1,N):
        sumD = 0
        for d in range(D):
            sumD += (X[i][d]-X[j][d])**2
        for x in range(64):
            if(sumD==x**2):
                ans += 1
                break
print(ans)

Submission status: Wrong Answer

Solution code:
n,d=map(int,input().split())
ans=0
l=[]
for i in range(n):
  l.append(list(map(int,input().split())))
for i in range(n):
  x=l[i]
  sum=0
  for j in range(i,n):
    y=l[j]
    for k in range(d):
      sum+=(x[k]-y[k])**2
  s=sum**(1/2)
  if s.is_integer():
    ans+=1
  sum=0
print(ans)

Submission status: Wrong Answer

Solution code:
n,d=map(int,input().split())
ans=0
l=[]
for i in range(n):
  l.append(list(map(int,input().split())))
for i in range(n):
  x=l[i]
  sum=0
  for j in range(i+1,n):
    y=l[j]
    for k in range(d):
      sum+=(x[k]-y[k])**2
  s=sum**(1/2)
  if s.is_integer():
    ans+=1
  sum=0
print(ans)

Submission status: Wrong Answer

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

res = 0

for i in range(N):
  for j in range(N):
    if i != j:
      tmp = 0
      for k in range(D):
        tmp += (L[i][k] - L[j][k]) ** 2
        
      if tmp - int(tmp) == 0:
        res += 1
        
print(res)

Submission status: Wrong Answer

Solution code:
N,D =map(int, input().split())
all_list = [list(map(int, input().split())) for i in range(N)]
#>>>4
count = 0
for n in range (N):
    for nn in range(N):
        distance = 0
        for d in range(D):
            kou = (all_list[n][d] - all_list[nn][d])**2
            distance += kou
        for s in range(21):
            if distance == s**2:
                count += 1
                break
print(round((count - N) / 2))

Submission status: Wrong Answer

Solution code:
N,D =map(int, input().split())
all_list = [list(map(int, input().split())) for i in range(N)]
#>>>4
count = 0
for n in range (N):
    for nn in range(N):
        distance = 0
        for d in range(D):
            kou = (all_list[n][d] - all_list[nn][d])**2
            distance += kou
        for s in range(21):
            if distance == s**2:
                count += 1
                break
print(round((count -N) / 2))

Submission status: Wrong Answer

Solution code:
import math
x,y = map(int,input().split())
li = []
while True:
	try:
		li.append(list(map(int,input().split())))
	except:
		break
score = 0
for a in li:
	for b in li:
		num = 0
		for c in a:
			for d in b:
				num += abs(c - d) ** 2
		num = num / 2
		t = math.sqrt(num) - round(math.sqrt(num))
		if t == 0:
			score += 1
print(score)

Submission status: Wrong Answer

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

a = []
for i in range(200):
  a.append(i**2)

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

Submission status: Wrong Answer

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

ans = 0
for i in range(n-1):
  for j in range(i, n):
    dis = 0
    for k in range(d):
      dis = dis + (x[i][k]-x[j][k])**2
    if isinstance(dis**(1/2), int):
      ans += 1
print(ans)

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)]

print(X)

ans = 0
##関数にするのがよい
def dis2(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):
        print("i",i,"j",j)
        print("X[i]",X[i],"X[j]",X[j])
        #それぞれの次元の配列の合計を返す
        R = dis2(X[i],X[j])
        for k in range(R+1):
            #これで整数かどうかをみている
            if k**2 == R:
                ans +=1

print(ans)

Submission status: Wrong Answer

Solution code:
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):
        dis=0
        for k in range(d):
            dis = (L[i][k]-L[j][k])**2
        dis = dis**0.5
        if dis == int(dis):
            ans +=1
print(ans)

Submission status: Wrong Answer

Solution code:
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):
        dis=0
        for k in range(d):
            dis = (L[i][k]-L[j][k])**2
        dis = dis**0.5
        if(dis % 1.0 ==0):
            ans +=1
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline

#+++++
		
def main():
	n, d = map(int, input().split())
	ll=lambda :list(map(int, input().split()))
	xl=[ll() for i in range(n)]
	
	lll= [x**2 for x in range(50)]
	cc=0
	for i, x in enumerate(xl):
		for y in xl[i+1:]:
			a=0
			for xv, yv in zip(x,y):
				a += (xv - yv)**2
			cc+=1 if a in lll else 0
		
	print(cc)
	
	
#+++++

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
		
	ret = main()
	if ret is not None:
		print(ret)

Submission status: Wrong Answer

Solution code:
import numpy as np

def is_integer_distance(np_a):
    return isqrt(np.dot(np_a, np_a))

def isqrt(n):
    x = n
    y = (x + 1) // 2
    while y < x:
        x = y
        y = (x + n // x) // 2
    return x*x == n


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

np_x = np.asarray(x)

count = 0
for i in range(n):
    for j in range(i,n):
        if is_integer_distance(np.subtract(np_x[i], np_x[j])):
            count+=1
        
print count

Submission status: Wrong Answer

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

  #  print(za)
  #x=np.append(x,[za])
  x.append(za)
#  print(i)
#  x[i] =0
  
x =(np.array(x))  
#print(x)
ans = []
for i in range(n-1):
  #print(i)
  u = (x[i]-x[i+1])
  ans.append(np.linalg.norm(u))
  
u= x[-1]-x[0]  
ans.append(np.linalg.norm(u))

#print(ans)
count = 0
for i in ans:
  if i%1==0:
    count+=1
    
    
print(count)

Submission status: Wrong Answer

Solution code:
import numpy

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

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

ans = 0

for i in range(n):
    for j in range(n):
        if i == j:
            continue
        a = numpy.array(l[i])
        b = numpy.array(l[j])
        c = numpy.linalg.norm(b - a)
        if (c.is_integer()):
            ans += 1

print(ans / 2)

Submission status: Wrong Answer

Solution code:
n,d = map(int,input().split(" "))
ar = []
br = []
count = 0
for i in range(40):
    br.append(i ** 2)
for i in range(n):
    l = list(map(int,input().split(" ")))
    ar.append(l)
for i in range(n):
    for j in range(i+1,n):
        c = 0
        for k in range(d):
            c += (ar[i][k] - ar[j][k]) ** 2
        if c in br:
            count += 1
print(count)

Submission status: Wrong Answer

Solution code:
n,d = map(int,input().split(" "))
ar = []
br = []
count = 0
for i in range(20):
    br.append(i ** 2)
for i in range(n):
    l = list(map(int,input().split(" ")))
    ar.append(l)
for i in range(n):
    for j in range(i+1,n):
        c = 0
        for k in range(d):
            c += (ar[i][k] - ar[j][k]) ** 2
        if c in br:
            count += 1
print(count)

Submission status: Wrong Answer

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

sq_list = [ (n+1)**2 for n in range(70)]
cnt = 0
for i in range(N):
    for j in range(i+1, N):
        sq_d = sum([ (X[i][k] - X[j][k])**2 for k in range(D)] )
        if sq_d in sq_list:
            cnt += 1
print(cnt)

Submission status: Wrong Answer

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

sq_list = [ (n+1)**2 for n in range(70)]
cnt = 0
for i in range(N):
    for j in range(i, N):
        sq_d = sum([ (X[i][k] - X[j][k])**2 for k in range(D)] )
        if sq_d in sq_list:
            cnt += 1
print(cnt)

Submission status: Wrong Answer

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

sq_list = [ (n+1)**2 for n in range(20)]
cnt = 0
for i in range(N):
    for j in range(i, N):
        sq_d = sum([ (X[i][k] - X[j][k])**2 for k in range(D)] )
        if sq_d in sq_list:
            cnt += 1
print(cnt)

Submission status: Wrong Answer

Solution code:
N,D = map(int,input().split())
li =[]
import math
def dist(a,b):
    li2 = []
    for k in range(D):
        li2.append((a[k]-b[k])**2)
    return math.sqrt(sum(li2))
for _ in range(N):
    X = list(map(int,input().split()))
    li.append(X)
cnt = 0
for i in range(N):
    for j in range(N):
        x = li[i]
        y = li[j]
        dis = dist(x,y)
        if dis == 0:
            pass
        else:
            if dis.is_integer():
                cnt +=1
print(cnt/2)

Submission status: Wrong Answer

Solution code:
args = input().split()
n = int(args[0])
d = int(args[1])
points = []
for i in range(n):
    points.append([int(p) for p in input().split()])


def isSquare(n):
    for i in range(2, n + 1):
        tmp = 0
        while n % i == 0:
            n = n // i
            tmp += 1
        if tmp % 2 != 0:
            return False
        if n == 1:
            return True

cnt = 0
for i in range(n):
    left = points[i]
    for j in range(i + 1, n):
        right = points[j]
        tmp = []
        for p in range(d):
            tmp.append(left[p] - right[p])
        dis = 0
        for k in tmp:
            dis += k ** 2
        if isSquare(dis):
            cnt += 1
print(cnt)

Submission status: Wrong Answer

Solution code:
import numpy as np

n, d = map(int, input().split())
s = [np.asarray(list(map(int, input().split()))) for i in range(n)]

counter = 0

for i in range(n):
    for j in range(n):
        ans = np.sqrt(np.sum((s[i] - s[j]) ** 2))
        if ans == int(ans):
            counter += 1

print(counter)

Submission status: Wrong Answer

Solution code:
import numpy as np

n, d = map(int, input().split())
s = [np.asarray(list(map(int, input().split()))) for i in range(n)]

counter = 0

for i in range(n):
    for j in range(n):
        ans = np.sum((s[i] - s[j]) ** 2)
        if ans == int(ans):
            counter += 1

print(counter)

Submission status: Wrong Answer

Solution code:
import itertools
import numpy

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

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

#print(grid)

grid2 = list(itertools.combinations(grid, 2))
for i in grid2:
    x = numpy.array(i[0])
    y = numpy.array(i[1])
  #  print(x, y)
    dis = numpy.linalg.norm(y - x)
    if (isinstance(dis, int)):
        print(dis)

Submission status: Wrong Answer

Solution code:
import itertools
import numpy

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

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

print(grid)

grid2 = list(itertools.combinations(grid, 2))
for i in grid2:
    x = numpy.array(i[0])
    y = numpy.array(i[1])
  #  print(x, y)
    dis = numpy.linalg.norm(y - x)
    if (isinstance(dis, int)):
        print(dis)

Submission status: Wrong Answer

Solution code:
import math

n,m = [int(i) for i in input().split()]
table = [[int(i) for i in input().split()] for n in range(n)]

count = 0

for i in range(n):
    for j in range(i+1,n,1):
        distance = 0
        total = 0
        for k in range(m):
            total += (table[i][k] - table[j][k]) ** 2
            print(i,j,k,total)
        distance = math.sqrt(total)
        print(distance)
        if distance.is_integer() == True:
            count += 1

print(count)

Submission status: Wrong Answer

Solution code:
squares = []
for i in range(0, 16001):
	squares.append(i+i)
N, D = map(int, input().split())
X = []
for i in range(0, N):
	X.append(list(map(int, input().split())))
cnt = 0
for i in range(0, N):
	for j in range(i+1, N):
		sqdist = 0
		for k in range(0, D):
			sqdist += (X[i][k]-X[j][k])**2
		if sqdist in squares:
			cnt += 1
print(cnt)

Submission status: Wrong Answer

Solution code:
import numpy as np
def solve(n, d, x):
    x = np.asarray(x)
    ans = 0
    for i in range(n):
        for j in range(i+1, n):
            y = x[i]
            z = x[j]
            d = np.linalg.norm(y-z)
            if int(d)**2 == int(d**2):
                ans += 1
    return ans

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

Submission status: Wrong Answer

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

BL = []
CL = []
for i in range(n - 1):
    for j in range(d):
        x = (AL[i][j] - AL[i + 1][j])**2
        CL.append(x)
    BL.append(CL)
    CL = []
#print(BL)
    
for j in range(d):
    x = (AL[-1][j] - AL[-0][j])**2
    CL.append(x)
BL.append(CL)
#print(BL)

count = 0
for i in range(n):
    x = (sum(BL[i])) ** 0.5
    if x % 1 == 0:
        count += 1
print(count)

Submission status: Wrong Answer

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

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

count=0
sum=0
for i in range(n):
    for k in range(i+1,n):
        for j in range(d):
            sum+=int((a[i][j]-a[k][j])*(a[i][j]-a[k][j]))
        for l in range(sum):
            if sum==l*l:
                count+=1
        sum=0

print(count)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
N=list(map(int,input().split()))
a=['X' for _ in range(int(N[0]))]
A=0
for i in range(int(N[0])):
    a[i]=list(map(int,input().split()))
    for t in range(int(i)):
        if i!=t:
            Y=[]
            for s in range(int(N[1])):
                Y+=[(a[i][s]-a[t][s])**2]
            Z=sum(Y)
            print(Z)
            if (math.sqrt(Z))- int(math.sqrt(Z))==0:
                A+=1
        else:
            continue
print(A)

Submission status: Wrong Answer

Solution code:
import math
N=list(map(int,input().split()))
a=['X' for _ in range(int(N[0]))]
A=0
for i in range(int(N[0])):
    a[i]=list(map(int,input().split()))
    for t in range(int(i)):
        if i!=t:
            for s in range(int(N[1])):
                Y=[(a[i][s]-a[t][s])**2]
                Z=sum(Y)
                if (math.sqrt(Z))- int(math.sqrt(Z))==0:
                    A+=1
        else:
            continue
print(A)

Submission status: Wrong Answer

Solution code:
import math
N=list(map(int,input().split()))
a=['X' for _ in range(int(N[0]))]
A=0
for i in range(int(N[0])):
    a[i]=list(map(int,input().split()))
    for t in range(int(i)):
        if i!=t:
            for s in range(int(N[1])):
                Y=[(a[i][s]-a[t][s])**2]
                Z=sum(Y)
                if (math.sqrt(Z))- int(math.sqrt(Z))==0:
                    A+=1
print(A)