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: Runtime Error

Solution code:
N,D = map(int,input().split())
import numpy as np
xlist = [list(map(int,input().split())) for i in range(n)]
xarray = np.array(xlist)
ans = 0
for i in range(n):
  for j in range(i+1,n+1):
    if (xarray[i]-xarray[j])%1!=0:
      ans+=1
print(ans)

Submission status: Runtime Error

Solution code:
N,D = (int(x) for x in input().split())
X = []*N
for i in range(N):
  X[i] = [float(x) for x in input().split()]
count = 0
for i in range(N-1):
  for j in range(i+1,N):
    sq = [(X[i][k]-X[j][k])**2 for k in range(D)]
    if isinstance(sum(sq)**0.5 , int):
      count += 1
print(count)

Submission status: Runtime Error

Solution code:
N,D = (int(x) for x in input().split())
X = []*N
for i in range(N):
  X[i] = [int(x) for x in input().split()]
count = 0
for i in range(N-1):
  for j in range(i+1,N):
    sq = [(X[i][k]-X[j][k])**2 for k in range(D)]
    if isinstance(sum(sq)**0.5 , int):
      count += 1
print(count)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import math

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

Submission status: Runtime Error

Solution code:
import math
N, D = map(int, input().split())
a = []
ans = 0
for _ in range(N):
  tmp = list(map(int, input().split()))
  a.append(tmp)
for n in range(N):
  for m in range(n+1,N):
 	dis = 0
    for d in range(D):
      dis += (a[n][d]-a[m][d])**2
    if math.sqrt(dis) == int(math.sqrt(dis)):
      ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
from math import sqrt
n,d = map(int, input().split())

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

def ds(a,b):
  s = 0
  for i in range(d):
    s += (b[i] - a[i])**2
  return sqrt(s)

ans = 0
for i in range(n):
  for j in range(i+1,n):
    d = ds(vs[i], vs[j])
    if d == int(d):
      ans += 1
      
print(ans)

Submission status: Runtime Error

Solution code:
#! python3
#  solve_133B.py

import math

def dis(Y,Z):
    ans = 0
    for i in range(len(Y)):
        ans += (Y[i] - Z[i])**2
    return math.sqrt(ans)


N,D = map(int,input(().split()))
X = []
ans = 0

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

for i in range(N):
    for j in range(i,N):
       if dis(i,j) % 1 == 0:
           ans += 1

print(ans)

Submission status: Runtime Error

Solution code:
N,D=map(int,input().split())
X=[]
d=[]
for i in range(N):
    X.append(list(map(int,input().split())))
print(X)
for j in range(N):
    for k in range(N):
        for l in range(D):
            if j>k:
                d.append((X[j][l]-X[k][l])**2)
e=[]
for i in range(D+1):
    e.append(0)
for i in range(0,D+1):
    for j in range((len(d)//N)*i,(len(d)//N)*(i+1)):
        e[i]+=d[j]
print(e)
f=0
for i in range(len(e)):
    if (e[i]**(1/2)).is_integer()==True:
        f+=1
print(f)

Submission status: Runtime Error

Solution code:
Thank you for your comment.
When I run the above code, it just displays the text "Loading...." and doesn't jump to the "login" or "home" page.
I'm not sure which part of the code is the cause, but I'm wondering if initState wasn't called

Submission status: Runtime Error

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

def get_distance(p1, p2):
    d2 = 0
    for i in range(D):
        d2 += (p1[i] - p2[i])**2
    return math.sqrt(d2)

count = 0
for i, j in itertools.combinations(range(N), 2):
    if get_distance(X[i], X[j]).is_integer():
        count += 1

print(count)

Submission status: Runtime Error

Solution code:
from itertools import combinations
N, D = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(N)]
data = [0]*5002
i = 1
while i**2<=5001:
    data[i**2]=1
    i += 1
res = 0
for a, b in combinations(X,2):
    temp = 0
    for x, y in zip(a, b):
        temp += (x-y)**2
    if data[temp]:
        res += 1
print(res)

Submission status: Runtime Error

Solution code:
from itertools import combinations
N, D = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(N)]
data = [0]*4001
i = 1
while i**2<=4001:
    data[i**2]=1
    i += 1
res = 0
for a, b in combinations(X,2):
    temp = 0
    for x, y in zip(a, b):
        temp += (x-y)**2
    if data[temp]:
        res += 1
print(res)

Submission status: Runtime Error

Solution code:
import math

N,D=map(int,input().split())
X=[]
for _ in range(N):
  X.append(list(map(int, input().split())))
count=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 math.sqrt(a).is_integer():
      coutn+=1
print(count)

Submission status: Runtime Error

Solution code:
n, d = map(int, input().split())
x_l = [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 += (x_l[j][k] - x_l[i][k]) ** 2
        if tmp**0.5%1 == 0:
            ans += 1

print(ans)

Submission status: Runtime Error

Solution code:
n, d = map(int, input().split())
x_l = [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 += (x_l[j][k] - x_l[i][k]) ** 2
        if tmp**0.5%1 == 0:
            ans += 1

print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import sys
import itertoolsy
N,D = map(int,input().split())
array = [ list(map(int,input().split())) for x in range(N) ]

if not ( 2 <= N <= 10 and 1 <= D <= 10 ): sys.exit()
for I in array:
    if not ( -20 <= min(I) and max(I) <= 20 ): sys.exit()

count = 0
for I in list(itertools.combinations(array,2)):
    tmp_distance = 0
    for J in range(D):
        tmp_distance += abs(I[0][J] - I[1][J]) ** 2
    distance = tmp_distance ** 0.5 
    if distance.is_integer(): count += 1

print(count)

Submission status: Runtime Error

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

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

def distance(a,b):
	dist = 0
         
		for a,b in zip(a,b):
		dist +- (a-b)**2
	
	return int(dist**0.5)**2
         
for pa in points:
	for pb in points:
		print(distance(pa,pb))
         
print(distance(points[0],)

Submission status: Runtime Error

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

points = []
for i in range(n):
  points,append(list(map(int,input().split())))
  
def distance(a,b):
  dist = 0
  for a,b in zip(a,b):
    dist += (a-b)**2
    
    return int(dist ** 0.5) ** 2 == dist
  
  count = 0
  
for pa in points:
  for pb in points:
    print(distance(pa,pb)):
      count += 1
      print(count // 2)

Submission status: Runtime Error

Solution code:
n, d = map(int, input().split())
lst = []
for _ in range(n):
  x = list(map(int, input().split()))
ans = 0
for i in range(n-1):
  for j in range(i+1, n):
    dist = 0
    for k in range(d):
      dist += (lst[i][k] - lst[j][k])**2
    j = 1
    while j**2 <= dist:
      if j**2 == dist:
        ans += 1
        break
      j += 1
print(ans)

Submission status: Runtime Error

Solution code:
#入力:N,M(int:整数)
def input2():
	return map(int,input().split())

#入力:[n1,n2,...nk](int:整数配列)
def input_array():
	return list(map(int,input().split()))
  
def euclid(y,z,d):
	result=0
	for i in range(d):
		result+=(y[i]-z[i])**2
	return math.sqrt(result)


n,d=input2()
X=[input_array() for _ in range(n)]

count=0
for i in range(n):
	for j in range(i+1,n):
		distance=euclid(X[i],X[j],d)
		if (distance%1) == 0:
			count+=1
print(count)

Submission status: Runtime Error

Solution code:
import sys
import numpy as np
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))

cnt = 0
for i in range(n):
  for j in range(i):
    a = sum((li[i] - li[j]) ** 2)**0.5
    if a - a//1 == 0:
      cnt += 1
print(cnt)

Submission status: Runtime Error

Solution code:
import sys
import numpy as np

rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
for i in range(n):
  for j in range(i):
    a = sum((li[i] - li[j]) ** 2)**0.5
    if a - a//1 == 0:
      cnt += 1
print(cnt)

Submission status: Runtime Error

Solution code:
def isinteger(x):
    if isinstance(x, float):
        return x == int(x)


import numpy as np
N,D = list(map(int,input().split()))
 
lis =[list(map(int,input().split())) for i in range(N)]
lis_np = np.array(lis)
counter = 0
for i in range(N-1):
    for j in range(i+1,N):
        kyori = (sum((lis_np[:][i] - lis_np[:][j])**2))**0.5
        if isinteger(kyori):
            counter += 1
print(counter)

Submission status: Runtime Error

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


import numpy as np
N,D = list(map(int,input().split()))
 
lis =[list(map(int,input().split())) for i in range(N)]
lis_np = np.array(lis)
counter = 0
for i in range(N-1):
    for j in range(i+1,N):
        kyori = (sum((lis_np[:][i] - lis_np[:][j])**2))**0.5
        if is_integer(kyori):
            counter += 1
print(counter)

Submission status: Runtime Error

Solution code:
import itertools
import math

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

list_ = list(range(1,  n + 1))
pairs = itertools.permutations(list_, 2)
distance = []
cnt = 0
for p, q in pairs:
    if p < q:
        for i in range(d):
            sum_ += (x[p - 1][i] - x[q - 1][i]) ** 2
            for j in range(int(math.sqrt(sum_)) + 1):
                if j ** 2 == sum_:
                    cnt +=1
print(cnt)

Submission status: Runtime Error

Solution code:
import itertools
import math

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

list_ = list(range(1,  n + 1))
pairs = itertools.permutations(list_, 2)
distance = []
cnt = 0
for p, q in pairs:
    if p < q:
        for i in range(d):
            sum_ += (x[p - 1][i] - x[q - 1][i]) ** 2
            for j in range(int(math.sqrt(sum_)) + 1):
                if j ** 2 == sum_:
                    cnt +=1
print(cnt)

Submission status: Runtime Error

Solution code:
import itertools
import math

n,d = map(int,input().split())
info = []
count = 0
ans = 0
ary = []

while True:
    try:
        listA=list(map(int,input().split()))
        info.append(listA)
        #ここに逐次処理を書けばいいと思う。
    except:
        break;

info = list(itertools.combinations(info, 2))


for i in range(n):
    current = info[i]
    for j in range(d):
        ans += abs(current[1][j] - current[0][j]) ** 2
    ary.append(math.sqrt(ans))
    ans = 0
    # ans = abs(current[0][0] - current[1][0]) ** 2 + abs(current[0][1] - current[1][1]) ** 2
    # print(math.sqrt(ans))

for i in range(len(ary)):
    if ary[i] % 1.0 == 0:
        count += 1

print(count)
print(count)

Submission status: Runtime Error

Solution code:
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
    for k in range(D):
        tmp += ((X[i][k] - X[j][k])** 2)
    tmp = math.sqrt(tmp)
    if tmp.is_integer:
        cnt += 1

print(cnt)

Submission status: Runtime Error

Solution code:
import math
 
def gooddistance(l1, l2):
    calc = []
    
    for i in range(len(l1)):
        calc.append((l1[i] - l2[i])**2)
 
    if math.sqrt(sum(calc)).is_integer():
        return 1
    else:
        return 0
 
 n, d = map(int, input().split())
lst = [list(map(int, input().split())) for _ in range(n)]
count = 0
 
for i in range(n):
    for j in range(i+1,n):
       count += gooddistance(lst[i],lst[j])
 
 print(count)

Submission status: Runtime Error

Solution code:
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    L, R = map(int, readline().split())

    if L - R + 1 >= 2019:
        print(0)
    else:
        A = [i % 2019 for i in range(L, R + 1)]
        A.sort()
        print(A[0] * A[1])

    return


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
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):
  for j in range(i+1,n):
    sum=0
    for k in range(n):
      sum+=(x[i][k]-x[j][k])**2
    z=pow(sum,0.5)
    if math.ceil(z)==math.floor(z):
      cnt+=1
print(cnt)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import numpy as np
from itertools import combinations
N,D=map(int,input().split())
X=[list(map(int,input().split())) for i in range(N)]
count=0
for x,y in combinations(X,2):
    r = np.sqrt(abs(x[0]-y[0])**2 + abs(x[1]-y[1])**2)
    if r.is_integer() == True:
        count += 1
print(count)

Submission status: Runtime Error

Solution code:
N,D = map(int,input().split())
P = []
for i in range (N):
    P.append(list(map(int, input().split())))
Pi = 0
for i in range(N):
    for j in range(i+1, N):
        Di = 0
        for k in range (D):
            Di += (P[i][k]-P[j][k])**2
        if int(Di**0.5) == dist**0.5:
            Pi += 1
print(Pi)

Submission status: Runtime Error

Solution code:
N,D = map(int,input().split())
    P = []
    for i in range (N):
        P.append(list(map(int, input().split())))
    Pi = 0
    for i in range(N):
        for j in range(i+1, N):
            Di = 0
            for k in range (D):
                Di += (P[i][k]-P[j][k])**2
            if int(Di**0.5) == dist**0.5:
                Pi += 1
    print(Pi)

Submission status: Runtime Error

Solution code:
import math

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

Submission status: Runtime Error

Solution code:
import math

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

Submission status: Runtime Error

Solution code:
import math


#vector的なやつ
#a=[input() for in range(n)]

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

Submission status: Runtime Error

Solution code:
import math


#vector的なやつ
#a=[input() for in range(n)]

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

Submission status: Runtime Error

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

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

lis=[False for i in range(16001)]
for i in range(1264):
  lis[i*i]=True
  
ans=0
for i in range(n):
  for j in range(i):
    dis=sum([(x[i][k]-x[j][k])*(x[i][k]-x[j][k]) for k in range(d)])
    print(dis)
    if lis[dis]:
      ans += 1
print(ans)

Submission status: Runtime Error

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

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

lis=[False for i in range(5000)]
for i in range(65):
  lis[i*i]=True
  
ans=0
for i in range(n):
  for j in range(i):
    dis=sum([(x[i][k]-x[j][k])*(x[i][k]-x[j][k]) for k in range(d)])
    #print(dis)
    if lis[dis]:
      ans += 1
print(ans)

Submission status: Runtime Error

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

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

lis=[False for i in range(5000)]
for i in range(65):
  lis[i*i]=True
  
ans=0
for i in range(n):
  for j in range(i):
    dis=sum([(x[i][k]-x[j][k])*(x[i][k]-x[j][k]) for k in range(d)])
    print(dis)
    if lis[dis]:
      ans += 1
print(ans)

Submission status: Runtime Error

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

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

lis=[False for i in range(4000)]
for i in range(63):
  lis[i*i]=True
  
ans=0
for i in range(n):
  for j in range(i):
    dis=sum([(x[i][k]-x[j][k])*(x[i][k]-x[j][k]) for k in range(d)])
    if lis[dis]:
      ans += 1
print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n,d = map(int,input().split())
a = list([input() for i in range(0,d)] for j in range(0,n))
c = 0
r = 0
for i in range(0,n):
  for j in range(i+1,n):
    for k in range(0,d):
      c += (a[i][k]-a[j][k])^2
ans = c^(1/2)
if isinstance(ans,int) == True:
  r += 1
print(r)

Submission status: Runtime Error

Solution code:
N, D = map(int, input().split())
zahyo = [0]*N
for i in range(N):
  zahyo[i] = list(map(int, input().split()))
count = 0
for i in range(N):
  for j in range(i+1, N):
    V = 0
    for k in range(D):
      V += float((zahyo[i][k]-zahyo[j][k])**0.5)
    if V.is_integer():
      count += 1
print(count)

Submission status: Runtime Error

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

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

print(X)

for i in range(1,N):
  for j in range(1,D):
      num += pow(abs(X[i-1][j-1] - X[i][j]) ,2)
      print(X[i-1][j-1],X[i][j])
  if int(math.sqrt(num)):
    print(math.sqrt(num))
    ans += 1

print(ans)

Submission status: Runtime Error

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

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
from collections import deque
from fractions import gcd
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return arr

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#############
# Main Code #
#############
N,D = inputIL()
X  = inputILL(N)

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

Submission status: Runtime Error

Solution code:
import math
n,d=map(int,input().split())
za=[list(map(int,input().split())) for i in range(n)]
ans=0
lon=0
for i in range(n):
    for j in range(i+1,n):
        for k in range(d):
            lon+=(za[i][d]-za[j][d])**2
            lon=math.sqrt(lon)
        else:
            if lon==int(lon):
                ans+=1
            lon=0
print(ans)

Submission status: Runtime Error

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)
#print(x)
list=[]
for j in range(n):
    l=[]
    list.append(l)
#print(list)
for i in range(n):
    for j in range(i+1,n):
        list[i].append(x[j])
#print(list)

count=0
distace=0
for i in range(len(list)):
    #print(i)
    for j in range(len(list[i])):
        #print(len(list[i]))
        #print(j)
        distance=math.sqrt((x[i][0]-list[i][j][0])**2+(x[i][1]-list[i][j][1])**2)
        #print(distance)
        if distance==int(distance):
            count+=1
print(count)

Submission status: Runtime Error

Solution code:

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

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

def dis2(A, B):
  dis = 0
  for i in range(D):
    dis += (A[i] - B[i])**2
  return dis

for i in range(N-1):
  for j in range(i+1, N):
    if math.sqrt(dis2(Ps[i], Ps[j])).is_integer():
      count += 1

print(count)

Submission status: Runtime Error

Solution code:
from math import sqrt

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

for i in range(N - 1):
    dist = 0
    for j in range(i + 1, N):
        for k in range(D):
            dist += (X[i][k] - X[j][k]) ** 2
        if sqrt(dist) % 1 == 0:
            ans += 1
    
print(ans)

Submission status: Runtime Error

Solution code:
n,d=map(int,input().split())
lists=[list(map(int,input().split())) for x in range(n)]
answer=0
for i in range(1,n):
  for j in range(i+1,n+1):
    count=o
    for y in range(d):
      count+=(lists[j-1][y]-lists[i-1][y])**2
    t=count**(1/2)
    if t.is_integer():
      answer+=1
print(answer)

Submission status: Runtime Error

Solution code:
n,d=map(int,input().split())
lists=[list(map(int,input().split())) for x in range(n)]
answer=0
for i in range(1,n):
  for j in range(i+1,n+1):
    count=o
    for y in range(d):
      count+=(lists[j-1][y]-lists[i-1][y])**2
    t=count**(1/2)
    if t.is_integer():
        answer+=1
print(answer)

Submission status: Runtime Error

Solution code:
n,d=map(int,input().split())
lists=[list(map(int,input().split())) for x in range(n)]
answer=0
for i in range(1,n):
  for j in range(i+1,n+1):
    for y in range(d):
      count=0
      count+=(lists[j-1][y]-lists[i-1][y])**2
      n=count**(1/2)
      if n.is_integer():
        answer+=1
print(answer)

Submission status: Runtime Error

Solution code:
n,d=map(int,input().split())
lists=[list(map(int,input().split())) for x in range(n)]
answer=0
for i in range(1,n):
  for j in range(2,n+1):
    for y in range(d):
      count=0
      count+=(lists[j-1][y]-lists[i-1][y])**2
      n=count**(1/2)
      if n.is_integer():
        answer+=1
print(answer)

Submission status: Runtime Error

Solution code:
n,d=map(int,input().split())
lists=[list(map(int,input().split())) for x in range(n)]
answer=0
for i in range(1,n):
  for j in range(2,n+1):
    for y in range(d):
      count=0
      count+=(lists[j-1][y]-lists[i-1][y])**2
      if is_integer(count**(1/2)):
        answer+=1
print(answer)

Submission status: Runtime Error

Solution code:
import math

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

count_1=0
if d==1:
  for i in range(s):
    T=s[i]-[i+1]
    

print(s)

count=0
for j in range(n-1):
  for k in range(d-1):
    p=(s[j][k]-s[j+1][k])**2+(s[j][k+1]-s[j+1][k+1])**2
    Q=math.sqrt(p)
  if Q%1==0:
    count+=1
for z in range(0,d):
  R=math.sqrt((s[0][z]-s[d-1][z])**2)
  if R&1==0:
    count+=1
print(count)

Submission status: Runtime Error

Solution code:
import math
n,d=map(int,input().split())
cnt=0
dlist=[list(map(int,input().split())) for _ in range(n)]
for i in range(n-1):
    for j in range(i+1:n):
        ans=0
        for k in range(d):
            ans+=(dlist[i][k]-dlist[j][k])**2
        cnt+=math.floor(ans**0.5)==math.ceil(ans**0.5):

print(cnt)

Submission status: Runtime Error

Solution code:
import math
N,D = map(int,input().split())
k = []
ans_2 = 0
ans_1 = 0
for i in range(N):
    k.append(list(map(int,input().split())))
for i in range(0,N):
    for j in range(i+1,N):
        for _ in range(D):
            now += (k[i][_]-k[j][_])**2
        ans_1 = math.sqrt(now)
        if ans_1%1 == 0:
            ans_2 += 1
        now = 0
        ans_1 = 0
print(ans_2)

Submission status: Runtime Error

Solution code:
from itertools import combinations
n, d = map(int, input().split())
l = []
count = 0
for i in range(n):
    l.append(list(map(int, input().split())))
for a, b in combinations(l, 2):
    if ((a[0]-b[0])**2+(a[1]-b[1])**2)**(1/2) % 1 == 0:
        count += 1
print(count)

Submission status: Runtime Error

Solution code:
import math
n,d = map(int,input().split())
count = 0
for i in range(n):
  x = list(map(int, input().split()))
for i in range(d):
  n=0
  for j in range(d) if i < j:
    n += (x[i][j]-x[i+1][j])**2
  m = math.sqrt(n)
  if m.is_integer():
    count +=1

print(count)

Submission status: Runtime Error

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

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

for i in range(d):
  n=0
  for j in range(d) if i < j:
    n += (x[i][j]-x[i+1][j])**2
  if  type(n**0.5) = int:
    count +=1

print(count)

Submission status: Runtime Error

Solution code:
def LI(): return list(map(int,input().split()))
N,D = LI()
X = [LI() for _ in range(N)]
ans = 0
for i in range(N):
    for j in range(i+1,N):
        temp = 0
        for k in range(D):
            temp += (X[j][k]-X[i][k])**2
        if temp **0.5%1==0:
        ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
n, d = map(int, input().split())
count = 0
x_list = (list(map(int, input().split())) for _ in range(n))

for i in range(n-1):
    for j in range(i+1, n):
        count += (sum((a-b)**2 for a,b in zip(x_list[i], x_list[j]))**0.5).is_integer
print(count)

Submission status: Runtime Error

Solution code:
n, d = map(int, input().split())
count = 0
x_list = (list(map(int, input().split())) for _ in range(n)))

for i in range(n-1):
    for j in range(i+1, n):
        count += (sum((a-b)**2 for a,b in zip(x_list[i], x_list[j]))**0.5).is_integer
print(count)