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:
l,r = map(int,input().split())
x = l%2019
if (l//673 < r//673 or l%673==0) and (l//3 < r//3 or l%3==0):
    ans = 0
else:
    ans = l*(l+1)%2019
print(ans)

Submission status: Wrong Answer

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][k]-za[j][k])**2
            lon=math.sqrt(lon)
        else:
            if lon==int(lon):
                ans+=1
            lon=0
print(ans)

Submission status: Wrong Answer

Solution code:
import math
n,d = map(int,input().split())
dli = [[] for _ in range(n)]
for i in range(n):
    x = list(map(int,input().split()))
    dli[i] = x
cnt = 0
for i in range(n):
    res = 0
    for j in range(d):
        if i == n-1:
            #print((abs(dli[i][j] - dli[0][j]))**2)
            res += abs(dli[i][j] - dli[0][j])**2
        else:
            #print((abs(dli[i][j] - dli[i+1][j]))**2)
            res += abs(dli[i][j] - dli[i+1][j])**2
    if math.sqrt(res).is_integer():
        cnt += 1
    
print(cnt)

Submission status: Wrong Answer

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

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

for i in range(N):
  for j in range(i + 1, N):
    L = []
    for k in range(D):
      L.append((X[i][k] - X[j][k]) ** 2)
    y = sum(L)
    for l in range(y + 1):
      if l ** 2 == y:
        print(l)
        count += 1

print(count)

Submission status: Wrong Answer

Solution code:
n,d = map(int,input().split())
x = [0]*n
for i in range(n):
    x[i] = list(map(int,input().split()))
count = 0
for i in range(n):
    for j in range(n):
        dis2 = 0
        for k in range(d):
            dis2 += (x[i][k]-x[j][k])**2
        dis = float((dis2)**0.5)
        if dis.is_integer() == True:
            count += 1
print(int(count-n))

Submission status: Wrong Answer

Solution code:
from math import sqrt

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

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: Wrong Answer

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
      t=count**(1/2)
      if t.is_integer():
        answer+=1
print(answer)

Submission status: Wrong Answer

Solution code:
import math
n, d = map(int, input().split())
x = []
ans = [i**2 for i in range(1, 100)]
for i in range(n):
    tmp = list(map(int, input().split()))
    x.append(tmp)
cnt = 0
sum_t = 0
for i in range(n):
    for j in range(i+1, n):
        sum_t = 0
        for k in range(d):
            sum_t += (x[i][k]-x[j][k])**2
        if sum_t in ans:
            cnt += 1
print(cnt)

Submission status: Wrong Answer

Solution code:
import math
n, d = map(int, input().split())
x = []
ans = [i**2 for i in range(1, n*d)]
for i in range(n):
    tmp = list(map(int, input().split()))
    x.append(tmp)
cnt = 0
sum_t = 0
for i in range(n):
    for j in range(i+1, n):
        sum_t = 0
        for k in range(d):
            sum_t += (x[i][k]-x[j][k])**2
        if sum_t in ans:
            cnt += 1


print(cnt)

Submission status: Wrong Answer

Solution code:
import math
n, d = map(int, input().split())
x = []
ans = [i**2 for i in range(1, 40)]
for i in range(n):
    tmp = list(map(int, input().split()))
    x.append(tmp)
cnt = 0
sum_t = 0
for i in range(n):
    for j in range(i+1, n):
        sum_t = 0
        for k in range(d):
            sum_t += (x[i][k]-x[j][k])**2
        if sum_t in ans:
            cnt += 1


print(cnt)

Submission status: Wrong Answer

Solution code:
import math
n, d = map(int, input().split())
x = []
ans = [i**2 for i in range(1, 21)]
for i in range(n):
    tmp = list(map(int, input().split()))
    x.append(tmp)
cnt = 0
sum_t = 0
for i in range(n):
    for j in range(i+1, n):
        sum_t = 0
        for k in range(d):
            sum_t += (x[i][k]-x[j][k])**2
        if sum_t in ans:
            cnt += 1


print(cnt)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a = [i*i for i in range(80)]
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-1):
    for j in range(i+1, n):
        s = 0
        for k in range(d):
            s += (x[i][k]-x[j][k])**2
        if s in a:
            ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
n,d=map(int,input().split())
X=[[int(_) for _ in input().split()] for i in range(n)]
sqr_list=[]
for i in range(70):
    sqr_list.append(i**2)
count=0
for i in range(n-1):
    for j in range(i+1,n):
        sum=0
        for k in range(d):
            sum+=(X[i][k]-X[j][k])**2
        if sum in sqr_list:
            count+=1
print(count)

Submission status: Wrong Answer

Solution code:
from itertools import *
n,d = map(int,input().split())
x = [list(map(int,input().split())) for _ in range(n)]
ans = 0
for a,b in combinations(x,2):
  delta = 0
  for i in range(d):
    delta += (a[i] - b[i])**2
  if (n **0.5).is_integer():
    ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
import math

# 0924 start
inputted = list(map(int, input().split()))
N = inputted[0]
D = inputted[1]

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

calculate = lambda y, z : math.sqrt(sum([(yi - zi) ** 2 for yi, zi in zip(y, z)]))

answer = 0
for i in range(N):
    for j in range(N):
        if i >= j: continue

        distance = calculate(X[i], X[j])
        if distance.is_integer(): answer += 1

print(answer)

Submission status: Wrong Answer

Solution code:
n, d = map(int, input().split())
x = [list(map(int, input().split())) for _ in range(n)]
count = 0
for i in range(n - 1):
  total = 0
  for now_, next_ in zip(x[i], x[i+1]):
    total += abs(now_ - next_) ** 2
  
  for j in range(total + 1):
    if j ** 2 == total:
      count += 1
print(count)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:

n,d = map(int,input().split())
l = []
a = []
count = 0
sum = 0

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

for x in range(1,n):
    for y in range(x+1,n):
        for z in range(d):
#            print((l[x][z]-l[y][z])**2)
            sum += (l[x][z]-l[y][z])**2
            print(sum)
            dis = sum ** 0.5
            dis = int(dis)
            print(dis)
            print("=======")

            if dis % 1 == 0:
                count += 1
print(count)

Submission status: Wrong Answer

Solution code:
import math

n, d = map(int,input().split())
x=[]
ans = 0
y = 0.0

for i in range(n):
    x.append(list(map(int,input().split()))) #リストに加える
print(x)
    
for i in range(n):
    for j in range(i+1,n): #それより前にリストに入っていたものについて
        y = 0.0
        for k in range(d): #次元数だけループ
            y = y + (x[i][k] - x[j][k])**2 #距離を計算
        if math.sqrt(y).is_integer() == True: #距離が整数なら
            ans = ans + 1 #答えに1を加える

print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np

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

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

ans = 0
for n in range(N):
    for i in range(n+1, N-n):
        if np.linalg.norm(X[n]-X[i]).is_integer():
            ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
import math

def solve(N: int, D: int, X: "List[List[int]]"):

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

    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    D = int(next(tokens))  # type: int
    X = [[int(next(tokens)) for _ in range(D)] for _ in range(N)]  # type: "List[List[int]]"
    solve(N, D, X)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
import math

def solve(N: int, D: int, X: "List[List[int]]"):

    count = 0
    for i in range(0, N - 1):
        for j in range(i + 1, N):
            sum = 0
            for k in range(0, D):
                sum += pow(X[i][k] - X[j][k], 2)
            sq = math.sqrt(sum)
            if sq == 0:
                continue
            if int(sq * 10) % 10 == 0:
                count += 1
    print(count)

    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    D = int(next(tokens))  # type: int
    X = [[int(next(tokens)) for _ in range(D)] for _ in range(N)]  # type: "List[List[int]]"
    solve(N, D, X)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
import math

def solve(N: int, D: int, X: "List[List[int]]"):

    count = 0
    for i in range(0, N - 1):
        for j in range(i + 1, N):
            sum = 0
            for k in range(0, D):
                sum += pow(X[i][k] - X[j][k], 2)
            if int(math.sqrt(sum) * 10) % 10 == 0:
                count += 1
    print(count)

    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    D = int(next(tokens))  # type: int
    X = [[int(next(tokens)) for _ in range(D)] for _ in range(N)]  # type: "List[List[int]]"
    solve(N, D, X)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#B
n, d = map(int, input().split())
x = []
for i in range(n):
    x.append(list(map(int, input().split())))
ans=0
for i in range(n):
    for j in range(i + 1, n):
        norm = 0
        for k in range(d):
            dif = abs(x[i][k] - x[j][k])** 2
            norm += dif
        flag=False
        for k in range(norm):
            if k ** 2 == norm:
                flag = True
        if flag:
            ans += 1
print(ans)

Submission status: Wrong Answer

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

def distance(a,b):
    d=0
    for i in range(len(a)):
        d+=abs(a[i]-b[i])**2
    return d
    
def check(a,b):
    f=0
    for i in range(100):
        if distance(a,b)==i**2:
            f+=1
            break
        else:
            f=f
    if f>0:
        return True
    else:
        return False
            
    
for i in range(n):
    for j in range(i+1,n):
        if check(x[i],x[j]):
            ans+=1
print(ans)

Submission status: Wrong Answer

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

def distance(a,b):
    d=0
    for i in range(len(a)):
        d+=abs(a[i]-b[i])**2
    return d
    
def check(a,b):
    f=0
    for i in range(50):
        if distance(a,b)==i**2:
            f+=1
            break
        else:
            f=f
    if f>0:
        return True
    else:
        return False
            
    
for i in range(n):
    for j in range(i+1,n):
        if check(x[i],x[j]):
            ans+=1
print(ans)

Submission status: Wrong Answer

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

def distance(a,b):
    d=0
    for i in range(len(a)):
        d+=abs(a[i]-b[i])**2
    return d
    
def check(a,b):
    f=0
    for i in range(41):
        if distance(a,b)==i**2:
            f+=1
            break
        else:
            f=f
    if f>0:
        return True
    else:
        return False
            
    
for i in range(n):
    for j in range(i+1,n):
        if check(x[i],x[j]):
            ans+=1
print(ans)

Submission status: Wrong Answer

Solution code:
n, d = map(int, input().split())
x = [list(map(int, input().split())) for _ in range(n)]
ans = 0
def check(i, j):
  d2 = 0
  for k in range(d):
    d2 += (x[i][k] * x[j][k]) ** 2
  for j in range(d2 + 1):
    if j ** 2 > d2:
      return False
    if j ** 2 == d2:
      return True
  return False

for i in range(n):
  for j in range(i + 1, n):
    if check(i, j):
      ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
n, d = map(int, input().split())
x = [list(map(int, input().split())) for _ in range(n)]
ans = 0
def check(i, j):
  d2 = 0
  for k in range(d):
    d2 += (x[i][k] * x[j][k]) ** 2
  for j in range(d2):
    if j ** 2 > d2:
      return False
    if j ** 2 == d2:
      return True
  return False

for i in range(n):
  for j in range(i + 1, n):
    if check(i, j):
      ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
import math

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

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

Submission status: Wrong Answer

Solution code:
import math
import itertools
n, d = map(int, input().split())
l=[]
s =[]
for i in range(n):
  l.append(list(map(int, input().split())))
if n != 1:
  p_list = list(itertools.combinations(range(n), 2))
  for a in range(len(p_list)):
    s.append(0)
    for b in range(d):
      s[a] += (l[p_list[a][0]][b] - l[p_list[a][1]][b])**2
else:
  for c in range(n-1):
    s[a] += (l[a] - l[a+1])**2
goukei = 0
p =[]
z =1
while z**2 <=2000:
  p.append(z**2)
  z +=1
for i in range(len(s)):
  if p.count(s[i]):
    goukei += 1
print(goukei)

Submission status: Wrong Answer

Solution code:
# B
n,d = map(int, input().split())
xi = [list(map(int, input().split())) for i in range(n)]
heihou = [i*i for i in range(41)]
count=0
for i in range(n-1):
    for j in range(i+1, n):
        total = 0
        for k in range(d):
            h = xi[i][k] - xi[j][k]
            hpow = h*h
            total+=hpow
        if total in heihou:
            count+=1
print(count)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
import math

def euclid_distance(x1,x2):
    dist = 0
    for i in range(len(x1)):
        dist += (x1[i] - x2[i])**2
    return dist

def LI():
  return [int(s) for s in input().split()]

# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    cnt = 0
    N,D = LI()
    X = []
    for i in range(N):
        X.append(LI())


    for i in range(N-1):
        for j in range(i+1,N):
            dist = euclid_distance(X[i],X[j])
            for num in range(100):
                if int(dist) == (num**2):
                    cnt += 1
                    continue
    print(cnt)
                
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import math
n,d = map(int,input().split())
x = [list(map(int,input().split())) for _ in range(n)]
def distance(a,b):
  s = 0
  for i in range(d):
    s += (a[i]-b[i])**2
  return math.sqrt(ans)
ans = 0
for i in range(n-1):
  for j in range(i+1,n):
    if distance(x[i],x[j])//1 == distance(x[i],x[j]):
      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)]
Y = []
b = 0
for i in range(N):
    a = 0
    if i != N-1:
        for j in range(D):
            a = a+(X[i+1][j]-X[i][j])**2
        Y.append(a)
    else:
        for k in range(D):
            a = a+(X[i][k]-X[0][k])**2
        Y.append(a)

for k in range(N):
    if math.sqrt(Y[k])-int(math.sqrt(Y[k])) == 0:
        b = b+1
print(b)

Submission status: Wrong Answer

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

def cheak_root(n):
    i=0
    while i<n:
        i+=1
        if i*i==n: return i
    return False

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

for i in range(N):
    for j in range(i+1,N):
        sums=0
        for d in range(D):
            diff=X[i][d]-X[j][d]
            sums=diff*diff
        if cheak_root(sums):ans+=1
print(ans)

Submission status: Wrong Answer

Solution code:
import math
def dis(a,b,D):
  t = 0
  for i in range(D):
    t += (a[i] -b[i])**2
  t = t**0.5
  return t
N,D = map(int,input().split())
X = []
C =[]
for i in range(N):
  X.append(list(map(int,input().split())))
for i in range(N-1):
  for j in range(i+1,N):
    C.append(dis(X[i],X[j],D))
ans = 0
for i in C:
  if math.floor(i) == math.ceil(i):
    ans = 1
print(ans)

Submission status: Wrong Answer

Solution code:
import math
import itertools

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

print(X)
listArray = list(itertools.combinations(X, 2))

print(listArray)
for X in listArray:
    sumX = 0
    for x in range(D):
        subX = X[0][x] - X[1][x]
        sumX += subX**2
     
    if math.sqrt(sumX).is_integer():
        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)]
a = []
b = []
ans = 0
cnt = 0
for i in range(N):
    if i == N - 1:
        a = X[-1]
        b = X[0]
        for i in range(len(a)):
            ans += (b[i]-a[i])**2    
    else:
        a = X[i]
        b = X[i + 1]
        for i in range(len(a)):
            ans += (b[i]-a[i])**2
    ans = ans**0.5
    if ans.is_integer():
        cnt += 1
    ans = 0
print(cnt)

Submission status: Wrong Answer

Solution code:
import numpy as np

N, D = [int(i) for i in input().split()]
X = np.zeros((N,D))
for i in range(N):
    X[i] = [int(i) for i in input().split()]
    
count_dummy=0
for i in range(N):
    for j in range(i+1,N):
        dist = (np.sum((X[i] - X[j])**2))**0.5
        if dist.is_integer():
            count_dummy+=1
            
count_dummy

Submission status: Wrong Answer

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

ans = 0
for i in range(N):
  for j in range(i+1, N):
    dist_sq = 0
    for x, y in zip(X[i], X[j]):
      dist_sq += (x - y) ** 2

    dist = dist_sq ** 0.5
    print(i, j, dist)

    if dist - int(dist) == 0:
      ans += 1

print(ans)

Submission status: Wrong Answer

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

for j in range(N):
  for k in range(j+1,N):
    tmp=sum([(X[j][l]-X[k][l])**2 for l in range(D)])
    if tmp in [y**2 for y in range(21)]:
      c +=1
print(c)

Submission status: Wrong Answer

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

total_d = 0
count=0
for i in range(N):
    if i == N-1:
        for j in range(D):
            d = abs(X[i][j]-X[0][j])
            total_d += d**2
        #print(total_d**(1/2))
        if (total_d**(1/2)).is_integer():
            count+=1
        else:
            total_d = 0
        
    else:
        for j in range(D):
            d = abs(X[i][j]-X[i+1][j])
            total_d += d**2
        #print(total_d**(1/2))
        if (total_d**(1/2)).is_integer():
            count+=1
        else:
            total_d = 0
        
print(count)

Submission status: Wrong Answer

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

def is_square(n):
    res=n**0.5
    return res.is_integer()
  
  
cnt=0
for j in range(n-1):
    dist = 0
    for i in range(d):
        dist += (dis[j][i]-dis[j+1][i])**2
    if is_square(dist) == True: cnt+=1

dist = 0
for i in range(d):
    dist += (dis[0][i]-dis[-1][i])**2
if is_square(dist) == True: cnt+=1
print(cnt)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,d = map(int,input().split())
x = []
for i in range(n):
    xi = [int(i) for i in input().split()]
    x.append(xi)
count = 0
ans = 0
for i in range(n-1):
    for l in range(i+1,n):
        ans = 0
        for j in range(d):
            ans += (x[i][j]-x[l][j])**2

        ans = ans **(1/2)
        print(ans)
        if ans == int(ans):
            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)]

cnt=0
for i in range(n):
    for j in range(i+1,n):
        sum=0
        for k in range(d):
            sum += (x[i][k]-x[j][k])**2
        route = sum**0.5
        if route.is_integer:
            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)]

cnt=0
for i in range(n):
    for j in range(i+1,n):
        sum=0
        for k in range(d):
            sum += (x[i][k]-x[j][k])**2
            route = sum**0.5
            if route.is_integer:
              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)]

cnt=0
for i in range(n):
    for j in range(i+1,n):
        for k in range(d):
            sum=0
            sum += (x[i][k]-x[j][k])**2
            route = sum**0.5
            if route.is_integer:
                cnt += 1
print(cnt)

Submission status: Wrong Answer

Solution code:
from math import sqrt
n, d = map(int, input().split())
point = [[int(i) for i in input().split()] for j in range(n)]
count = 0
for i in range(n):
    for j in range(i + 1, n):
        norm = 0
        for pi, pj in zip(point[i], point[j]):
            norm += (pi - pj) ** 2
        if int(sqrt(norm)) == norm:
            count += 1

print(count)

Submission status: Wrong Answer

Solution code:
n,d=map(int,input().split())
l=[list(map(int,input().split())) for _ in range(n)]
cnt=0

for i in range(n-1):
  for i2 in range(i+1,n):
    distance = 0
    for j in range(d):
      distance+=(abs(l[i][j])-abs(l[i2][j]))**2
    
    if (distance**0.5).is_integer():
      cnt+=1
      
print(cnt)

Submission status: Wrong Answer

Solution code:
n,d=map(int,input().split())
l=[list(map(int,input().split())) for _ in range(n)]
cnt=0

for i in range(n):
  for i2 in range(i+1,n):
    distance = 0
    for j in range(d):
      distance+=(abs(l[i][j])-abs(l[i2][j]))**2
    
    if (distance**0.5).is_integer():
      cnt+=1
      
print(cnt)

Submission status: Wrong Answer

Solution code:
import math
n,d=map(int,input().split())
l=[list(map(int,input().split())) for _ in range(n)]
cnt=0

for i in range(n):
  for i2 in range(i+1,n):
    distance = 0
    for j in range(d):
      distance+=(abs(l[i][j])-abs(l[i2][j]))**2
    
    if float.is_integer(math.sqrt(distance)):
      cnt+=1
      
print(cnt)

Submission status: Wrong Answer

Solution code:
#133 b
import itertools
n,d=map(int,input().split())
N=[i for i in range(n)]
k=[i*i for i in range(100)]
x=[]
for i in range(n):
    a=list(map(int,input().split()))
    x.append(a)
ans=0
kumi=itertools.combinations(N,2)

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

Submission status: Wrong Answer

Solution code:
#133 b
import itertools
n,d=map(int,input().split())
N=[i for i in range(n)]
k=[i*i for i in range(2,100)]
x=[]
for i in range(n):
    a=list(map(int,input().split()))
    x.append(a)
ans=0
kumi=itertools.combinations(N,2)

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

Submission status: Wrong Answer

Solution code:
#133 b
import itertools
n,d=map(int,input().split())
N=[i for i in range(n)]
k=[i*i for i in range(1,100)]
x=[]
for i in range(n):
    a=list(map(int,input().split()))
    x.append(a)
ans=0
kumi=itertools.combinations(N,2)

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import numpy

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

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

print(lstMain)

count = 0
for i in range(0, N):
    for j in range(i+1, N):
        y = numpy.array(lstMain[i])
        z = numpy.array(lstMain[j])
        u = z - y
        distance = float(numpy.linalg.norm(u))
        if distance.is_integer():
            count += 1

print(count)

Submission status: Wrong Answer

Solution code:

n,d = map(int,input().split())
l = []
a = []
count = 0
sum = 0

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

for x in range(1,n):
    for y in range(x+1,n):
        for z in range(d):
            sum += (l[x][z]-l[y][z])**2
            dis = sum ** 0.5

            if dis % 1 ==0:
                count += 1
print(count)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,d=map(int,input().split())
l=[list(map(int,input().split())) for i in range(n)]
ans=0
cnt=0
for i in range(n-1):
    for j in range(i+1,n):
        for k in range(d):
            siki=((l[i][k]-l[j][k])**2)
            ans+=siki
        flag=False
        for o in range(ans):
            if o*o==ans:
                flag=True
        if flag:
        	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)]
cnt = 0
for i in range(n-1):
    for j in range(i+1,n-1):
        s = 0
        for k in range(d):
            s += (x[i][k] - x[j][k])**2
        if math.sqrt(s) % 1 == 0:
            cnt += 1
print(cnt)

Submission status: Wrong Answer

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

for i in range (n-1):
    for j in range(d):
        ans+=((l[i][j])-(l[i+1][j]))**2
    if float.is_integer(math.sqrt(ans))==True:
        cnt+=1
print(cnt)

Submission status: Wrong Answer

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

for i in range (n-1):
    for k in range(n-i-1):
        for j in range(d):
            ans+=((l[i][j])-(l[i+1+k][j]))**2
        if float.is_integer(math.sqrt(ans))==True:
            cnt+=1
print(cnt)

Submission status: Wrong Answer

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

ans=0
s=0
for i in range(N):
  for j in range(i+1,N):
    s=0
    for d in range(D):
      s+=(l[i][d]-l[j][d])**2
      if s**(1/2)%1==0:
        ans+=1
print(ans)