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:
//include
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <map>
#include <sstream>
#include <utility>
//マクロとか
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n) + 1; i++)
#define all(vecto) vecto.begin(), vecto.end()
#define max3(a, b, c) max(a, max(b, c))
#define min3(a, b, c) min(a, min(b, c))
using ll = long long;

//自前の関数たち
//最大公約数
ll GCD(ll a, ll b)
{
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}

//最小公倍数
ll LCM(ll a, ll b)
{
    return (a * b) / GCD(a, b);
}

//namespace my
namespace my {
    //配列の最大値or最小値を数値で返す関数
    int max_element(std::vector<int> vec){
        std::sort(vec.begin(), vec.end());
        return vec.at(vec.size() - 1);
    }
    int min_element(std::vector<int> vec){
        std::sort(vec.begin(), vec.end());
        return vec.at(0);
    }
}

//yes,noを出力するやつ
void ans(bool qus)
{
    if (qus == true)
        std::cout << "Yes" << std::endl;
    else
        std::cout << "No" << std::endl;
}

void Ans(bool qust)
{
    if (qust == true)
        std::cout << "YES" << std::endl;
    else
        std::cout << "NO" << std::endl;
}

//std::を省略するやつ
using namespace std;

////////////////////////////////////////////////////////////////////////////////
//スタート


int main(){
    int n, d;
    cin >> n >> d;
    vector<vector<int>> dem(n, vector<int>(d));
    rep(i,n){
        rep(j,d){
            cin >> dem.at(i).at(j);
        }
    }
    int count = 0;
    rep(i, n){
        for (int j = i + 1; j < n; j++){
            double a = 0;
            rep(k,d){
                a += pow((dem.at(i).at(k) - dem.at(j).at(k)), 2);
            }
            double b = sqrt(a);
            if (floor(b) == b){
                count++;
            }
        }
    }
    cout << count << endl;
}

Submission status: Runtime Error

Solution code:
import itertools
n,d=map(int,input().split())
X=[list(map(int,input().split()))for i in range(n)]
ans=0
for v in itertools.combinations(X, 2):
    y=0
    for i in range(d):
        y+=(v[0][i]-v[1][i])*(v[0][i]-v[1][i])
    if(y**0.5).is_integer():
        cnt+=1
print(cnt)

Submission status: Runtime Error

Solution code:
n,d = map(int,input().split())
points = []
for _ in range(n):
  X = tuple(map(int,input().split()))
  points.append(X)
  
ans = 0

import math
def distance(x,y):
  dis = 0
  for i in range(d):
    dis += (x[i]-y[i])**2
  return math.sqrt(dis)

for i in range(n-1):
  for j in range(i+1,n):
    dis = distance(X[i],X[j])
    if dis == int(dis):
      ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
import numpy as np
N,D = map(int,input().split())
X = []
for i in range(N):
    Xi = np.array(list(map(int,input().split())))
    X.append(Xi)
ans = 0
for i in range(N):
    for j in range(i,N):
        if i==j:
            continue
        d = np.linalg.norm(X[i]-X[j])
        if abs(d-int(d)) < 10**(-6):
            ans += 1
print(ans)

Submission status: Runtime Error

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

import numpy as np
p1 = np.array(P)
tmp_index = np.arange(p1.shape[0])
xx, yy = np.meshgrid(tmp_index, tmp_index)
distances = np.linalg.norm(p1[xx]-p1[yy], axis=2)
results = np.reshape(np.tril(distances), (1, N**2))


a = 0
for i in range(0, N**2):
  if(results[0][i]!=0 & results[0][i] == np.int(results[0][i])):
    a += 1
print(a)

Submission status: Runtime Error

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

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

Solution code:
import numpy as np

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

#print(X)

ans = 0

for i in range(N):
  for j in range(i+1, N):
    dist = np.linalg.norm(X[i] - X[j])
    #print(i, j, dist)
    if dist - int(dist) == 0:
      ans += 1

print(ans)

Submission status: Runtime Error

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(N)])
    if tmp in [y**2 for y in range(21)]:
      c +=1
print(c)

Submission status: Runtime Error

Solution code:
from itertools import combinations
N, D = map(int, input().split())
X = []
cnt = 0
for _ in range(N):
  X += list(map(int, input().split()))
print(combinations(N,2))

Submission status: Runtime Error

Solution code:
n,d=map(int,input().split())
x=[list(map(int,input().split()))for _ in range(n)]
ans=0
for i in range(n):
    for j in range(i):
        ans+=(sum((a-b)**2 for a,b in zip(x[i],x[j])**0.5)).is_integer()
print(ans)

Submission status: Runtime Error

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

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

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

cnt = 0
for i in range(D):
    for j in range(i+1, D):
        tmp = 0.0
        for k in range(D):
            tmp += (x[i][k]-x[j][k])**2
        if(math.sqrt(tmp).is_integer()):
            cnt += 1
print(cnt)

Submission status: Runtime Error

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

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

cnt = 0
for i in range(N):
    if i + 1 == P[i]:
        cnt += 1

if cnt >= N - 2:
    print('YES')
else:
    print('NO')

Submission status: Runtime Error

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

def dist(A, B):
    sums = 0
    for i in range(len(A)):
        sums += (abs(A[i] - B[i])) ** 2
    sums = sums ** 0.5
    return sums

for i in range(N-1):
    for j in range(i+1, N):
#            if isinstance(dist(X[i], X[j]), int):
        if dist(X[i], X[j]).is_integer():
            cnt += 1
print(cnt)

Submission status: Runtime Error

Solution code:
# 当初理解が及ばずできなかったが、後日リベンジできた！
# B問題とは思えない！

def dis(d, x, y): #d次元、2点間の距離の関数
    a = 0
    for i in range(d):
        a += (x[i] - y[i])**2
    return a**0.5
    
n, d = map(int,input().split())

l=[] # n個の座標を2次元リストで取得
for j in range(n):
    b,c=[int(j) for j in input().split()]
    l.append([b,c])

z = []
for e in range(n):
    for f in range(e,n): #重複（逆の組み合わせ）無し
        g = dis(d, l[e], l[f]) #各座標間の距離を関数で取得
        if g == int(g) and g != 0: #距離が整数かつゼロでないか確認
            z.append(g) # 上の条件をpassした値をリスト'z'へappend
            
print(len(z))

Submission status: Runtime Error

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

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


ans = 0
for i in range(n):
    for j in range(i+1, n):
        l = 0
        for k in range(d):
            l += (a[i][k] - a[j][k]) ** 2
        l = sympy.sqrt(l)
        if l.is_Integer: ans += 1

print(ans)

Submission status: Runtime Error

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

    ans = 0
    for i in range(n-1):
        for j in range(i+1,n):
            res = 0
            for k in range(d):
                res += (x[j][k]-x[i][k])**2
            if (res**0.5).is_integer():
                ans += 1
    prnt(ans)

if __name__ == '__main__':
    main()

Submission status: Runtime Error

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

    ans = 0
    for i in range(n-1):
        for j in range(i+1,n):
            res = 0
            for k in range(d):
                res += (j[k]-i[k])**2
            if (res**0.5).is_integer():
                ans += 1
    prnt(ans)

if __name__ == '__main__':
    main()

Submission status: Runtime Error

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

    ans = 0
    for i in range(n-1):
        for j in range(i+1,n):
            res = 0
            for k in range(d):
                res += (j[k]-i[k])**2
            res = math.sqrt(s)
            if res.is_integer():
                ans += 1
    prnt(ans)

if __name__ == '__main__':
    main()

Submission status: Runtime Error

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

    ans = 0
    for i in range(1,x):
        for j in range(x-1):
            res = 0
            for k in range(d):
                res += (j[k]-i[k])**2
            res = math.sqrt(s)
            if res.is_integer():
                ans += 1
    prnt(ans)

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import math

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

for i in range(n-1): #0-n
  for j in range(i+1,n):
    s = 0
    for k in range(d):
      s += (x[i][k]-x[j][k])**2
    a = math.sqrt(s)
    if a.is_integer():
      ans += 1
print(ans)

Submission status: Runtime Error

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

for i in range(n-1): #0-n
  for j in range(i+1,n):
    s = 0
    for k in range(d):
      s += (x[i][k]-x[j][k])**2
    a = math.sqrt(s)
    if a.is_integer():
      ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
N,D = [int(i) for i in input().split()]
for i in range(N):
    lagd.append([int(i) for i in input().split()])
lngs = D - 1
def kyoricac(daone,datwo,d):
    keka = []
    n = 0
    wa = 0
    while n <= d:
        wa = (daone[n] - datwo[n])**2
        keka += [wa]
        n += 1
    wa = sum(keka)
    kaesi = float(wa ** (1/2))
    return kaesi
ans = 0
fst = 1
for i in range(N):
    for n in range(fst,N):
        flag = float(kyoricac(lagd[i],lagd[n],lngs))
        if flag.is_integer() == True:
            ans += 1
    fst += 1
print(ans)

Submission status: Runtime Error

Solution code:
import numpy as np

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

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

ans = 0

def length_square(a, b):
  y = 0
  for i in range(n):
    y += ((float(a[i])) - float(b[i])) ** 2
  return y

for i in range(n):
  for j in range(i + 1, n):
    #calculate distance between x[i] and x[j] (i < j)
    l_square = length_square(x[i], x[j])
    l = np.sqrt(l_square)
    print(l)
    #decide whether l is int() or not
    if int(l) == l:
      ans += 1
    else:
      pass
      
print(ans)

Submission status: Runtime Error

Solution code:
import numpy as np
n, d  = map(int, input().split())

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

def length_square(a, b):
  #y = 0
  for i in range(n):
    y += (int(a[i]) - int(b[i])) ** 2
    return y

for i in range(n):
  for j in range(i + 1, n):
    #calculate distance between x[i] and x[j] (i < j)
    l_square = length_square(x[i], x[j])
    l = np.sqrt(l_square)
    #print(l)
    #decide whether l is int() or not
    if int(l) == l:
      ans += 1
    else:
      pass

print(ans)

Submission status: Runtime Error

Solution code:
import numpy as np
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):
    #calculate distance between x[i] and x[j] (i < j)
    l_square = np.linalg.norm(nnp.arrey(x[i]) - np.arrey(x[j]))
    l = np.sqrt(l_square)
    if int(l) == l:
      ans += 1
    else:
      pass

print(ans)

Submission status: Runtime Error

Solution code:
import numpy as np
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):
    #calculate distance between x[i] and x[j] (i < j)
    l_square = np.linalg.norm(x[i] - x[j])
    l = np.sqrt(l_square)
    if int(l) == l:
      ans += 1
    else:
      pass

print(ans)

Submission status: Runtime Error

Solution code:
b

Submission status: Runtime Error

Solution code:
yandy
N, D = map(int, input().split())
array = []
for _ in range(N):
    array.append([int(i) for i in input().split()])
 
ans = 0
for i in range(N):
    for j in range(i+1, N):
        s = 0
        for d in range(D):
            s += (array[i][d]-array[j][d]) ** 2
        if s ** (1/2) % 1 == 0:
            ans += 1
 
print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import numpy as np

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

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

Submission status: Runtime Error

Solution code:
import numpy as np

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

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
# ABC 133: B – Good Distance
from itertools import combinations

n, d = [int(s) for s in input().split()]

x = []
for _ in range(n):
    x.append([int(s) for s in input().split()])

pairs = list(combinations(x, 2))
the_number_of_pairs = 0

for i in range(n):
    distance = 0

    for j in range(d):
        distance += (abs(pairs[i][0][j] - pairs[i][1][j])) ** 2
    
    distance = distance ** 0.5

    if distance == int(distance):
        the_number_of_pairs += 1

print(the_number_of_pairs)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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):
    tmp = 0
    for j in range(d):
        tmp += (x[i][j] - x[(i+1)%n][j])**2
    if tmp**(1/2)%1 == 0:
        ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
import math

a = []
b = []
c = []
index1 =  input().split()
N = int(index1[0])
D = int(index1[1])

for i in range(N):
    index = input().split()

    for j in range(D):
        a.append(int(index[j]))
        
for j in range(0, N, 2):
    for i in range(D):
        c.append(a[i + j] - a[i + D + j])

for k in range(D):
    c.append(a[N*D-(D-k)]-a[k])

print(c)

for i in range(0, N*D-1, 2):
   b.append(math.sqrt((c[i])**2 + (c[i+1])**2))
  
print(b)

count = 0
for i in range(N):
    if b[i].is_integer():
        count = count + 1

print(count)

Submission status: Runtime Error

Solution code:
N, D = map(int, input().split())
t = []
count = 0
sum = 0
for i in range(N):
    t.append(list(map(int, input().split())))
for i in range(0, N-1):
    for j in range(i + 1, N):
      for d in range(D):
        sum += pow(t[i][d] - t[j][d], 2)
        sqrt = math.sqrt(sum)
      print(sum)
      print(sqrt)
      if sqrt == int(sqrt):
        count += 1
      sum = 0
      sqrt = 0
print(count)

Submission status: Runtime Error

Solution code:
tmp = list(map(int, input().split()))
n = tmp[0]
d = tmp[1]

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

cnt = 0
for i in range(n):
  for j in range(i+1, n):
    len = 0
    for k in range(d):
      len += (x[i][k] - x[j][k]) ** 2
    len = math.sqrt(len)
#    print('I=' + str(i) + ' J=' + str(j) + ' LEN=' + str(len))
    if len.is_integer():
      cnt += 1

print (cnt)

Submission status: Runtime Error

Solution code:
from math import sqrt
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):
    xi,xj = x[i],x[j]
  tmp = 0
    for k in range(d):
      tmp += (xi[d]-xj[d]) ** 2
      if sqrt(tmp)%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)]

ans=0

for i in range(n):
    for j in range(i+1, n):
        xi,xj = x[i],x[j]
        tmp = 0
        for k in range(d):
            tmp += (xi[d]-xj[d]) ** 2
        if (tmp ** 0.5)%1==0:
            ans += 1

print(ans)

Submission status: Runtime Error

Solution code:
import sys

def solve():
    n,d = map(int, input().split())
    l = [[int(x) for x in sys.stdin.readlines()] for _ in range(n)]
    count = 0
    for i in range(n):
        Y = l[i]
        for Z in l[i+1:]:
            total = 0
            for y,z in zip(Y,Z):
                total += (y-z)**2
            d = total**0.5
            if d == int(d):
                count += 1
    return count

if __name__ == '__main__':
    print(solve())

Submission status: Runtime Error

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

x=np.array(x)

def dist(x,y):
  diff=x-y
  diff_sq=np.square(diff)
  return(np.sqrt(np.sum(diff_sq)))

ans=0
for N in range(n):
    for i in range(N,n):
        X = dist(x[N], x[i])
 
        if X.is_integer():
            ans += 1
 
print(ans)

Submission status: Runtime Error

Solution code:
import numpy as np
n,d=map(int,input().split())
x=[]

def dist(x,y):
  diff=x-y
  diff_sq=np.square(diff)
  return(np.sqrt(np.sum(diff_sq)))

ans=0
for N in range(n):
    for i in range(N,n):
        X = dist(x[N], x[i])
 
        if X.is_integer():
            ans += 1
 
print(ans)

Submission status: Runtime Error

Solution code:
import numpy as np
n,d=map(int,input().split())
x=[]

def dist(x,y):
  diff=x-y
  diff_sq=np.square(diff)
  return(np.sqrt(np.sum(diff_sq)))

ans=0
for N in range(n):
    for i in range(N,n):
        X = distance(x[N], x[i])
 
        if X.is_integer():
            ans += 1
 
print(ans)

Submission status: Runtime Error

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

count=1
for i in range(i,a):
  for j in range(i+1,a):
    t=0
    for k in range(b):
      t += (x[i][k]-x[j][k])**2
    t = t**(1/2)
    if t.is_integer():
      count += 1
print(count)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

s = 0
c = 0
for n in range(-1,N-1):
    for d in range(D):
        s = s + abs(li[n][d] - li[n+1][d]) ** 2
    if (s**(1/2)).is_interger():
        c += 1
    s = 0

Submission status: Runtime Error

Solution code:
def dis(a,b):
    res = 0
    for i in range(d):
        res += (a[i]- b[i])**2
        res = res**0.5
        return res

n, d = map(int, input().split())
X = [[int(x) for x in input().split()] for i in range(n)]
for  i in range(n-1):
    for j in range(i +1, n):
        if dis(X[i], X[j]).is_integrer():
            ans +=1
print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N, D = int(input())
x = [list(map(int, input().split())) for _ in range(N)]
s = 0
for i in range(N - 1) :
    for j in range(i + 1, N) :
        l = 0.0
        for d in range(D) :
            l += (x[i][d] - x[j][d]) ** 2
        length = l ** (1/2)
        if length.is_integer() :
            s += 1
print(s)

Submission status: Runtime Error

Solution code:
N, D = int(input())
x = [list(map(int, input().split())) for _ in range(N)]
s = 0
for i in range(N - 1) :
    for j in range(i + 1, N) :
        l = 0.0
        for d in range(D) :
            l' += (x[i][d] - x[j][d]) ** 2
        length = l ** (1/2)
        if length.is_integer() :
            s += 1
print(s)

Submission status: Runtime Error

Solution code:
N, D = int(input())
x = [list(map(int, input().split())) for _ in range(N)]
s = 0
for i in range(N - 1) :
    for j in range(i + 1, N) :
        length' = 0.0
        for d in range(D) :
            length' += (x[i][d] - x[j][d]) ** 2
        length = length' ** (1/2)
        if length.is_integer() :
            s += 1
print(s)

Submission status: Runtime Error

Solution code:
N, D = int(input())
x = [list(map(int, input().split())) for _ in range(N)]
# for _ in range でリストを何行にもわたって書ける
s = 0
for i in range(N - 1) :
    for j in range(i + 1, N) :
        length' = 0.0
        for d in range(D) :
            length' += (x[i][d] - x[j][d]) ** 2
        length = length' ** (1/2)
        if length.is_integer() :
        # 整数かどうか判定
            s += 1
print(s)

Submission status: Runtime Error

Solution code:
import math
N, D = map(int,input().split())
X = [0] * N
for i in range(N):
    X[i] = list(map(int,input().split()))
count = 0
def func(A,B):
    a = 0
    for k in range(D):
        a += (A[k] - B[k])**2
    a = math.sqrt(a)
    return a
for i in range(N):
    for j in range(i,N):
        sum_x = 0
        int_x = 0
        if i == j:
            continue
         sum_x = func(X[i],X[j])
         int_x = int(sum_x)
         if sum_x == int_x:
             count += 1

Submission status: Runtime Error

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

count = 0
for a in range(N):
  for b in range(a+1, N):
  sumX = 0
    for c in range(D):
      sumX += (X[a][c]-X[b][c])**2
  if math.sqrt(sumX)%1 == 0:
    count += 1
print(count)

Submission status: Runtime Error

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

count = 0
for a in range(N):
  for b in range(a+1, N):
  sumX = 0
    for c in range(D):
      sumX += (X[a][c]-X[b][c])**2
    if math.sqrt(sumX)%1 == 0:
      count += 1
print(count)

Submission status: Runtime Error

Solution code:
import math
N, D=map(int, input())
Xs=[list(map(int, input().split())) for _ 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
    dis=math.sqrt(dis)
    if dis==int(dis):
      cnt+=1
print(cnt)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import math

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

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

cnt = 0
for i in range(n-1):
  for j in range(i+1, n):
    dist = 0
    for d in range(D):
      dist += (point[i][d] - point[j][d])**2
    dist = mat.sqrt(dist)
    if int(dist) == dist:
      cnt += 1
print(cnt)

Submission status: Runtime Error

Solution code:
import math
     
n, D = map(int, input().split())
point = []
for _ in range(n):
	x = list(map(int, input().split()))
    point.append(x)
     
cnt = 0
for i in range(n-1):
	for j in range(i+1, n):
		dist = 0
        for d in range(D):
        	dist += (point[i][d] - point[j][d])**2
     
        dist = math.sqrt(dist)
        if int(dist) == dist:
        	cnt += 1
     
print(cnt)

Submission status: Runtime Error

Solution code:
import numpy as np
n,d=map(int,input().split())
v=[]
for i in range(n):
  v.append(np.array(list(map(int,input().split()))))
  
ans=0
for i in range(n-1):
  for j in range(i+1,n):
    dist=np.linalg.norm(v[i]-v[j], ord = 2)
    if int(dist) == dist:
      ans += 1

print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

count = 0
for i in range(n - 1):
    for j in range(i + 1,n):
        tmp = np.square( x_list[i] - x_list[j] ).sum()
        k = 1
        while k * k <= tmp:
            if ( k * k - tmp == 0 ):
                count += 1
            k = k + 1
print(count)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n, d = map(int, input().split())
lst = []
cnt = 0
for i in range(n):
    a = list(map(int, input().split()))
    print(a)
    lst.append(a)
for i in range(n-1):
    for j in range(i+1, n):
        val = 0
        for k in range(d):
            x += (lst[i][k]-lst[j][k]) ** 2
        dist = x ** 0.5
        if dist%1 == 0:
            if dist != 0:
                cnt += 1
print(cnt)

Submission status: Runtime Error

Solution code:
n, d = map(int, input().split())
x = []
cnt = 0
for i in range(n):
    a = list(map(int, input().split()))
    print(a)
    lst.append(a)
for i in range(n-1):
    for j in range(i+1, n):
        val = 0
        for k in range(d):
            x += (lst[i][k]-lst[j][k]) ** 2
        dist = x ** 0.5
        if dist%1 == 0:
            if dist != 0:
                cnt += 1
print(cnt)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n, d = (int(i) for i in input().split())
num = list((list(map(int, input().split())) for j in rage(n)))
sum = 0
cnt = 0
for k in range(n - 1) :
  for h in range(d) :
    sum += (num[k][h] - num[k + 1][n])**2
  if (isinstance(sum **(1 / 2)), int) :
    cnt += 1
  sum = 0
print(sum)