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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import itertools
import math

def solve():
  N, D = [int(s) for s in input().split() if s]
  X = []
  cnt = 0
  for _ in range(N):
    X.append([int(s) for s in input().split() if s])
    for x1,x2 in itertools.combinations(X,2):
      if dist(x1,x2).is_integer():
        cnt+=1
    print(cnt)

solve()

Submission status: Runtime Error

Solution code:
import itertools
import math

def solve():
    N, D = [int(s) for s in input().split() if s]
    X = []
    cnt = 0
    for _ in range(N):
        X.append([int(s) for s in input().split() if s])
    for x1,x2 in itertools.combinations(X,2):
        if dist(x1,x2).is_integer():
            cnt+=1
    print(cnt)
    
solve()

Submission status: Runtime Error

Solution code:
from numpy import*
x=loadtxt(open(0),skiprows=1)
print(sum(triu([linalg.norm(i-x,2,1)%1==0for i in x],1)))

Submission status: Runtime Error

Solution code:
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(input())
def S(): return list(input())
n,d=IL()
X=[IL() for i in range(n)]
c=0
for i in range(n-1):
    for j in range(i+1,n):
        dis=0
        for k in range(d):
            dis+=(X[i][k]-X[j][k])**2
        if int(dis**0.5)=dis**0.5:
            c+=1
print(c)

Submission status: Runtime Error

Solution code:
#include <iostream>
#include <cmath>
using namespace std;

int n, d, x[11][11];

int main()
{
  cin >> n >> d;
  for (int i = 0; i < n; ++ i)
  {
    for (int j = 0; j < d; ++ j)
    {
      cin >> x[i][j];
    }
  }
  int count = 0;
  for (int i = 0; i < n - 1; ++ i)
  {
    for (int j = i + 1; j < n; ++ j)
    {
      int sum = 0;
      for (int k = 0; k < d; ++ k)
      {
        sum += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
      }
      if (int(sqrt(sum)) * int(sqrt(sum)) == sum) count++;
    }
  }
  cout << count << endl;    
  return 0;
}

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import sys
import re
import numpy as np
from itertools import combinations

def answer(l):
    results = []
    for i, j in combinations(l, 2):
        v_a = np.array(i)
        v_b = np.array(j)
        results.append(np.linalg.norm(v_a - v_b))
    return sum(float.is_integer(i) for i in results)

rows = re.split('\n', sys.stdin.readline())
args = [list(map(int, row.split(' '))) for row in rows][1:]
print(answer(args))

Submission status: Runtime Error

Solution code:
from math import *
N,D = map(int,input().split())
lst = [[int(kk) for kk in input().split()] for aa in range(N)]
tot = 0
c = 0
for a in range(1,N):
	for b in range(a):
      	c = 0
        for i in range(D):
			c += (lst[a][i]-lst[b][i])**2
        if sqrt(c) == int(sqrt(c)):
          	tot += 1
print(tot)

Submission status: Runtime Error

Solution code:
from functools import sqrt
N, D = map(int, input().split(' '))

coordinate_list = list()

# 一行ずつ分解してリストに入れる
for i in range(N):
    coordinate = list(input().split())
    coordinate = list(map(int, coordinate))
    coordinate_list.append(coordinate)

def make_dis_list(D, coordinate_list):
    distance_list = list()
    for i, coordinate in enumerate(coordinate_list):
        for j in range(i+1, N):
            distance_list.append(measure_distance(coordinate, coordinate_list[j], D))
    return distance_list

def measure_distance(a, b, D):
    square_dist = 0
    for i in range(D):
        square_dist += (a[i] - b[i])**2
    return sqrt(square_dist)

def int_counter(nums):
    counter = 0
    for num in nums:
        if int(num) == num: counter += 1
    return counter

distance_list = make_dis_list(D, coordinate_list)
print(int_counter(distance_list))

Submission status: Runtime Error

Solution code:
N,D = map(int,input().split())
lst = [[int(kk) for kk in input().split()] for aa in range(N)]
tot = 0
c = 0
for a in range(N):
	for b in range(a):
      	c = 0
        for i in range(D):
			c += (lst[a][i]-lst[b][i])**2
        if sqrt(c) == int(sqrt(c)):
          	tot += 1
print(tot)

Submission status: Runtime Error

Solution code:
import numpy as np
import itertools

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

d = []
for c in itertools.combinations(X, 2):
    d.append(np.linalg.norm(c[1] - c[0]))

d = np.array(d)
print(len([True for x in d if x.is_integer()]))

Submission status: Runtime Error

Solution code:
import math
N, D = map(int, input().split())
a = []
for i in range(N):
  b = map(int, input().split())
  a += b
print(a)
res = 0
for i in range(N-1):
  j = i + 1
  while(j < N):
    x = []
    y = []
    for k in range(D):
      x.append(a[i * D + k])
      y.append(a[j * D + k])
    tmp = 0
    for k in range(D):
      tmp += (x[k] - y[k]) ** 2
    if tmp = int(tmp ** 0.5) * int(tmp ** 0.5):
      res += 1
    j += 1
print(res)

Submission status: Runtime Error

Solution code:
import math
n, d= (int(c) for c in input().split())

x = []

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

sum_ans = 0
count=0
for j in range(0,n):
    for k in range(j+1,n):
        for n in range(d):
            sum_ans = sum_ans+(int(x[j][n]) - int(x[k][n])) **2
        if math.sqrt(sum_ans)%1==0:
            count=count+1
        sum_ans=0
print(count)

Submission status: Runtime Error

Solution code:
import sys
import re
import numpy as np
from itertools import combinations
 
 
def answer(l):
    results = []
    for i, j in combinations(l, 2):
        v_a = np.array(i)
        v_b = np.array(j)
        results.append(np.linalg.norm(v_a - v_b))
    return sum(float.is_integer(i) for i in results)
 
rows = re.split('\n', sys.stdin.read())
args = [list(map(int, row.split(' '))) for row in rows][1:]
print(answer(args))

Submission status: Runtime Error

Solution code:
import sys
import re
import numpy as np
from itertools import combinations


def answer(l):
    results = []
    for i, j in combinations(l, 2):
        v_a = np.array(i)
        v_b = np.array(j)
        results.append(np.linalg.norm(v_a - v_b))

    return sum(float.is_integer(i) for i in results)


if __name__ == '__main__':
    rows = re.split('\n', sys.stdin.read())
    args = [list(map(int, row.split(' '))) for row in rows][1:]
    print(answer(args))

Submission status: Runtime Error

Solution code:
n,d=map(int,input().split())
x=[]
for i in range(n):
    a=list(map(int,input().split()))
    x.append(a)
import math
c=0
d=0
e=0
for j in range (n-1):
    for k in range(j+1,n):
        for m in range(d):
            d+=float((x[j][m]-x[k][m])*(x[j][m]-x[k][m]))
        c=float(math.sqrt(d))
        if(c.is_integer()=1):
            e+=1
        d=0
print('{0}'.format(e))

Submission status: Runtime Error

Solution code:
d,n=input().split()
d=int(d)
n=int(n)
li=[[] for i in range(d)]
for i in range(d):
  a=input()
  li[i]+=a.split(" ")
  li[i]=[int(n) for n in li[i]]
 
import numpy as np
count=0
for i in range(d):
  for j in range(d):
    j=j+i+1
    if j==d-1:
      break
    vec_a = np.array(li[i])
    vec_b = np.array(li[j])
    result=np.linalg.norm(vec_a - vec_b)
    if result.is_integer():
      count+=1
print(count)

Submission status: Runtime Error

Solution code:
import numpy as np
import math

buf=input().split(" ")

N=int(buf[0])
D=int(buf[1])

arr = np.empty((0,D), int)

for i in range(N):
  buf=input().split(" ")
  buf = [int(s) for s in buf]

  arr=np.append(arr, [buf], axis=0)
  

buf=0
c=0

for i in range(N):
  for j in range(N):
    if i<j:
      for k in range(D):
        buf=math.sqrt(abs((arr[k:i]-arr[k:j])*(arr[k:i]-arr[k:j])))
        if buf.is_integer() == True:
          c=c+1
          
print(c)

Submission status: Runtime Error

Solution code:
n,d=map(int,input().split())
x=[]
for i in range(n):
    a=list(map(int,input().split()))
    x.append(a)
import math
c=0
d=0
e=0
for j in range (n-1):
    for k in range(j+1,n):
        for m in range(d):
            d+=flout((x[j][m]-x[k][m])*(x[j][m]-x[k][m]))
        c=float(math.sqrt(d))
        if(c.is_integer()=1):
            e+=1
        d=0
print('{0}'.format(e))

Submission status: Runtime Error

Solution code:
import numpy as np


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

for i in range(n-1):
    for j in range(n-i,n,1):
        a=np.array(X[i])
        b=np.array(X[i+1])
        u=b-a
        if u==int(u):
            cnn+=1
print(cnn)

Submission status: Runtime Error

Solution code:
# B problem
import numpy as np
def check_abs(arr, lists):
    ret = 0
    for i, k in lists:
        tmp = ( arr - k ) ** 2
        if (np.sum(tmp) ** 0.5).is_integer():
            ret += 1
    return ret
T = input()
N, D = map(int,T.split())
lists = []
for i in range(N):
    data = input().split()
    tmp = list(map(int, data))
    lists.append(tmp)
tmp2 = np.array(lists)
for i in range(N):
    ress = 0
    arr = tmp2[i]
    np.delete(tmp2, i, 0)
    res = check_abs(arr, tmp2)
    ress += res
print(ress)

Submission status: Runtime Error

Solution code:
import numpy as np

n,d = map(int,input().split())
x = [[int(i) for i in input().split()] for n in range(n)]
count = 0
def distance(m):
    for c in range(d):
        s = list((x[b][c] - x[b+1][c]) ** 2)
        t = sum(s)
        return np.sqrt(t)

for b in range(n - 1):
    if distance(b) == int(distance(b)):
        count += 1
        
print(count)

Submission status: Runtime Error

Solution code:
import math

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

integer_count = 0

point_1 = list(map(int, input().split()))
point_2 = list(map(int, input().split()))

for _ in range(N-2):
    distance = 0
    for i in range(D):
        distance += (point_1(i) - point_2(i)) ** 2
        
    if math.sqrt(distance).is_integer():
        integer_count += 1

print(integer_count)

Submission status: Runtime Error

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

if D == 1:
  print(N * (N-1) // 2)
else:
  A = [0] * D
  count = 0
  sei = 0

  for i in range(0,N):
	  A[i] = list(map(int, input().split()))
    
  for p in range(0,N):
      for q in range(0,N):
          sum = 0
    
          for r in range(0,D):
              sum = sum + (A[p][r]-A[q][r]) ** 2
           
          sum = sum ** 0.5 
          sei = int(sum)
        
          if sum != 0 and sum == sei:
              count = count + 1
      
  print(count // 2)

Submission status: Runtime Error

Solution code:
import math

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

arr = [[0 for i in range(10)] for j in range(10)]

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

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
import sys
import re
import numpy as np
from itertools import combinations


def answer(l):
    results = []
    for i, j in combinations(l, 2):
        v_a = np.array(i)
        v_b = np.array(j)
        results.append(np.linalg.norm(v_a - v_b))

    return sum(float.is_integer(i) for i in results)


if __name__ == '__main__':
    rows = re.split('\n', sys.stdin.read())
    args = [list(map(int, row.split(' '))) for row in rows][1:]
    print(answer(args))

Submission status: Runtime Error

Solution code:
N,D = map(int, input().split())
A = [0] * D
count = 0
sei = 0

for i in range(0,N):
	A[i] = list(map(int, input().split()))
    
for p in range(0,N):
    for q in range(0,N):
        sum = 0
    
        for r in range(0,D):
            sum = sum + (A[p][r]-A[q][r]) ** 2
           
        sum = sum ** 0.5 
        sei = int(sum)
        
        if sum != 0 and sum == sei:
            count = count + 1
      
print(count // 2)

Submission status: Runtime Error

Solution code:
import math
n, d= (int(c) for c in input().split())

x = []

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

sum_ans = 0
count=0
for j in range(0,n-1):
    for k in range(j+1,n-1):
        for n in range(d):
            sum_ans = sum_ans+(x[j][n] - x[k][n]) **2
        if math.sqrt(sum_ans)%1==0:
            count=count+1
        sum_ans=0
print(sum_ans)

Submission status: Runtime Error

Solution code:
import math
n, d= (int(c) for c in input().split())

x = []

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

sum_ans = 0
count=0
for j in range(0,n):
    for k in range(j+1,n):
        for n in range(d):
            sum_ans = sum_ans+(x[j][n] - x[k][n]) **2
        if math.sqrt(sum_ans)%1==0:
            count=count+1
        sum_ans=0
print(sum_ans)

Submission status: Runtime Error

Solution code:
import math
n, d= (int(c) for c in input().split())

x = []

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

sum_ans = 0
count=0
for j in range(0,n):
    for k in range(j+1,n-1):
        for n in range(d):
            sum_ans = sum_ans+(x[j][n] - x[k][n]) **2
        if math.sqrt(sum_ans)%1==0:
            count=count+1
        sum_ans=0
print(sum_ans)

Submission status: Runtime Error

Solution code:
import math

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

array = [[0]*11]*11

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

Submission status: Runtime Error

Solution code:
import numpy as np
nd = list(map(int,input().split()))
l = [input().split() for i in range(nd[0])]
c=0
for i in l:
  ll[c] = [int(n) for n in i]
  c+=1
count = 0
for i in range(nd[0]):
  for i2 in range(nd[0]):
    t=0
    for j in range(nd[1]):
      t = t + (ll[i][j]-ll[i2][j])**2
    if isinstance(np.sqrt(t),int):
      count += 1
print(count)

Submission status: Runtime Error

Solution code:
import numpy as np
import math

N, D = map(int,input().split())
array = [[] for i in range(N)]
for h in range(N):
    x = map(int,input().split())
    x = list(x)
    array[h].append(x)
array = np.array(array)
 # print(array)
count = 0
for r in range(N):
    for t in range(1,N-r):
        ds = array[r]-array[r+t]
        sqsum = 0
        for s in range(D):
            sqsum = sqsum + ds[0,s]*ds[0,s]
        d = math.sqrt(sqsum)
        if d.is_integer(d,int):
            count = count + 1
print(count)

Submission status: Runtime Error

Solution code:
import numpy as np
nd = list(map(int,input().split()))
l = [input().split() for i in range(nd[0])]
ll = [int(n) for n in l]
count = 0
for i in range(nd[0]):
  for i2 in range(nd[0]):
    t=0
    for j in range(nd[1]):
      t = t + (ll[i][j]-ll[i2][j])**2
    if isinstance(np.sqrt(t),int):
      count += 1
print(count)

Submission status: Runtime Error

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

cnt = 0
for i in range(n - 1):
	for j in range(i+1, n):
		hoge = 0
		for num in range(d):
			hoge = hoge + pow(abs(x[i][num] - x[j][num]),2)
			if(hoge == pow(int(math.sqrt(hoge)), 2)):
			cnt = cnt + 1
print(cnt)

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
import sys
import re
import numpy as np
from itertools import combinations


def answer(l):
    results = []
    for i, j in combinations(l, 2):
        v_a = np.array(i)
        v_b = np.array(j)
        results.append(np.linalg.norm(v_a - v_b))

    print(sum(float.is_integer(i) for i in results))


if __name__ == '__main__':
    rows = re.split('\n', sys.stdin.read())
    args = [list(map(int, row.split(' '))) for row in rows][1:]
    print(answer(args))

Submission status: Runtime Error

Solution code:
#入力
n, d = map(int, input().split())
point = [[int(i) for i in input().split()] for j in range(n)]
#点1から計算する
m = 0
for i in range(n):
	for j in range(i+1,n):
		a = 0
		for k in range(d):
			a += (point[i][k]-pont[j][k])**2
		if isinstance(a**0.5, int) 
		m += 1
print(m)

Submission status: Runtime Error

Solution code:
import numpy as np
nd = list(map(int,input().split()))
l = [input().split() for i in range(nd[0])]
count = 0
for i in range(nd[0]):
  for i2 in range(nd[0]):
    t=0
    for j in range(nd[1]):
      t = t + (l[i][j]-l[i2][j])**2
    if isinstance(np.sqrt(t),int):
      count += 1
print(count)

Submission status: Runtime Error

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

cnt = 0
for i in range(n - 1):
    for j in range(i+1, n):
        hoge = 0
        for num in range(d):
            hoge = hoge + pow(abs(x[i][num] - x[j][num]),2)
            if(hoge == pow(int(math.sqrt(hoge)), 2)):
                cnt = cnt + 1
print(cnt)

Submission status: Runtime Error

Solution code:
import numpy as np
nd = list(map(int,input().split()))
l = [input().split() for i in range(nd[0])]
count = 0
for i in range(nd[0]):
  for i2 in range(nd[0]):
    for j in range(nd[1]):
      t = t + (l[i][j]-l[i2][j])**2
    if isinstance(np.sqrt(t),int):
      count += 1
print(count)

Submission status: Runtime Error

Solution code:
import math
n, d= (int(c) for c in input().split())

x = []

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

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

Submission status: Runtime Error

Solution code:
import numpy as np
nd = list(map(int,input().split()))
l = [input().split() for i in range(nd[1])]
count = 0
for i in range(nd[0]):
  for i2 in range(nd[0]):
    for j in range(nd[1]):
      t = t + (l[i][j]-l[i2][j])**2
    if isinstance(np.sqrt(t),int):
      count += 1
print(count)

Submission status: Runtime Error

Solution code:
#入力
n, d = map(int, input().split())
point = [[int(i) for i in input().split()] for n in range(n)]
#点1から計算する
m = 0
for i in range(n):
	for j in range(i+1,n):
		a = 0
		for k in range(d):
			a += (point[i][k]-pont[j][k])**2
		if isinstance(a ** 0.5, int) 
		m += 1
print(m)

Submission status: Runtime Error

Solution code:
N, _ = (int(i) for i in input().split())
data = [int(int(i) for i in input().split()) for i in range(N)]

import numpy as np
from scipy.spatial import distance

distance = distance.cdist(data, data, metric='euclidean')
count = 0
for n in range(0,N):
  for d in range(n+1,N):
    if distance[n][d].is_integer() and distance[n][d] != 0 :
      count+=1
print(count)

Submission status: Runtime Error

Solution code:
#入力
n, d = map(int, input().split())
point = [int(input()) for i in range(n)]
#点1から計算する
m = 0
for i in range(n):
	for j in range(i+1,n):
		a = 0
		for k in range(d):
			a += (point[i][k]-pont[j][k])**2
		if isinstance(a ** 0.5, int) 
		m += 0
print(m)

Submission status: Runtime Error

Solution code:
n, d = [int(s) for s in input().split(" ")]
pts = []
for _ in range(n):
  pts.append([int(s) for s in input().split(" ")])

def dist(x, y):
  sum = 0
  for xx, yy in zip(x, y):
    sum += (xx - yy)**2
  return math.sqrt(sum)

cnt = 0
for i in range(n):
  for j in range(i + 1, n):
    d = dist(pts[i], pts[j])
    if int(d) == d:
      cnt += 1

print("%d" % cnt)

Submission status: Runtime Error

Solution code:
import math
import itertools


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


for n in range(N):
    l = input().split()
    X[n]=[0]*D
    for d in range(D):
        X[n][d] = int(l[d])


count = 0
for y, z in itertools.combinations(X, 2):
    print(f"y={y}, z={z}")
    d = math.sqrt(sum(pow(y[i] - z[i], 2) for i in range(D)))
    if d.is_integer():
        count += 1

print(count)

Submission status: Runtime Error

Solution code:
L,R=map(int,input().split())
M=[]
for i in range(L,R):
    for j in range(i+1,R+1):
        M.append((i%2019)*(j%2019))
print(min(M))

Submission status: Runtime Error

Solution code:
import numpy as np

def sq(x,i):
    if x == 1:
        return i
    else:
        if i > x/2:
            return False
        else:
            if x%i == 0:
                if int(x/i) == i:
                    return i
                else:
                    return sq(x,i+1)
            else:
                return sq(x,i+1)

def Ten(x,i):
    if x/(10**i) > 10:
        return Ten(x/10,i+1)
    else:
        return i

a = input().split(" ")
N = int(a[0])
D = int(a[1])

X = []
count = 0
for i in range(N):
    a = input().split(" ")
    Y = [int(i) for i in a]
    X.append(Y)
X = np.array(X)

for i in range(N-1):
    for j in range(i+1,N):
        Z = X[i]-X[j]
        if 10**Ten(np.dot(Z.T,Z),0) > np.dot(Z.T,Z)/2:
            if sq(np.dot(Z.T,Z),1) != False:
                count += 1
        else:
            if sq(np.dot(Z.T,Z),10**Ten(np.dot(Z.T,Z),0)) != False:
                count += 1
print(count)

Submission status: Runtime Error

Solution code:
import numpy as np
nd = list(map(int,input().split()))
l = [input().split() for i in range(nd[1])]
count = 0
for i in range(nd[1]):
  for i2 in range(nd[1]):
    for j in range(nd[0]):
      t = t + (l[i][j]-l[i2][j])**2
    if isinstance(t,int):
      count += 1
print(count)

Submission status: Runtime Error

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

for i in range(N):
    r1 = X[i]
    for j in range(N):
        t = str(i)+str(j)
        if i == j or t in tmp or str(j)+str(i) in tmp:
            continue

        r2 = X[j]
        ls = [(r1[j] - r2[j])**2 for j in range(D)]
        res = math.sqrt(sum(ls))

        if res % 1 == 0:
            count += 1
        tmp.append(t)

print(count)

Submission status: Runtime Error

Solution code:
import itertools
import math

n,d = map(int,input().split())
x = [[int(i) for i in input().split()] for i in range(n)] 
seq = list(itertools.combinations(range(n),d))
tmp = 0.0
cnt = 0

for i,j in seq:
    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:
def dist(X1,X2):
  d=X1-X2
  d=[x**2 for x in d]
  d=sum(d)
  return d
 
count=int(0)
N,D=map(int,input().split())
X=list(range(N))
for i in range(N):
  X[i]=list(map(int,input().split()))
for i in range(N):
  for j in range(i+1,N):
    d=dist(X[i],X[j])
    if isinstance(d,int):
      count=count+1
print(count)

Submission status: Runtime Error

Solution code:
import numpy as np
nd = list(map(int,input().split()))
l = [input().split() for i in range(nd[1])]
count = 0
for i in range(nd[1]-1):
  for j in range(nd[0]):
    t = t + (l[i][j]-l[i][j])**2
  if isinstance(t,int):
    count += 1
print(count)

Submission status: Runtime Error

Solution code:
import math
n,d = input().split()
n = int(n)
d = int(d)
G = []
for _ in range(0,n):
	a = list(map(int,input().split()))
	G.append(a)
s = 0
count=0
for i in range(0,n-1):
	for j in range(i+1,n):
		s=0
		for k in range(0,d):
			s += (G[j][0]-G[j][1]) * (G[j][0]-G[j][1])
		s = math.sqrt(s)
		if s-int(s)==0:
			count+=1
print(count)

Submission status: Runtime Error

Solution code:
def dist(X1,X2):
  d=X1-X2
  d=[x**2 for x in d]
  d=sum(d)
  return d
 
count=int(0)
N,D=map(int,input().split())
X=list(range(N))
for i in range(N):
  X[i]=list(map(int,input().split()))
for i in range(N):
  for j in range(i+1:N):
    d=dist(X[i],X[j])
    if isinstance(d,int):
      count=count+1
print(count)

Submission status: Runtime Error

Solution code:
import math

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

array = []

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

Submission status: Runtime Error

Solution code:
import math
n,d = input().split()
n = int(n)
d = int(d)
G = []
for _ in range(0,n):
	a = list(map(int,input().split()))
    G.append(a)
s = 0
count=0
for i in range(0,n-1):
	for j in range(i+1,n):
		s=0
		for k in range(0,d):
	        s += (G[j][0]-G[j][1]) * (G[j][0]-G[j][1])
        s = math.sqrt(s)
        if s-int(s)==0:
			count+=1ac

Submission status: Runtime Error

Solution code:
import math
b, c = map(int, input().split())
count  = 0
sum_a = 0
ans = 0
 
dim_b = list(input().split())
while count < b :
  dim_a = list(input().split())
  
  for i in range(int(len(dim_b))):
    sum_a +=  (dim_b[i] - dim_a[i])**2
  
  
  n = math.sqrt(sum_a)
  
  if n.is_integer():
    ans +=1
  
  sum_a = 0
  dim_b = dim_a
  count +=1
  
print(ans)

Submission status: Runtime Error

Solution code:
def dist(X1,X2):
  d=X1-X2
  d=[x**2 for x in d]
  return d=sum(d)

count=int(0)
N,D=map(int,input().split())
X=list(range(N))
for i in range(N):
  X[i]=list(map(int,input().split()))
for i in range(N):
  for j in range(i+1:N):
    d=dist(X[i],X[j])
    if isinstance(d,int):
      count=count+1
print(count)

Submission status: Runtime Error

Solution code:
import numpy as np

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

listA=[] #appendのために宣言が必要
while True:
    try:
        listA.append(list(map(int,input().split())))

    except:
        break;
        #または、quit(),os.exit()をして止める。

count = 0
for i in range(n):
    for j in range(n):
        if(i < j):
            dis = 0
            for k in range(d):
                dis += (listA[i][k]-listA[j][k]) ** 2
            dis = np.sqrt(dis)
            if(dis.is_integer()):
                count += 1


print(count)

Submission status: Runtime Error

Solution code:
import numpy as np

n,d=map(int,input().split())
arr=np.array((n,d))
for i in range(n):
  arr[i]=np.array(list(map(float,input().split())))
ans=0
for i in range(n):
  for j in range(i,n):
    if j!=i:
      k = np.linalg.norm(arr[i]-arr[j],ord=2)
    else:
      k=np.nan
    if k==int(k):
      ans +=1
print(ans)

Submission status: Runtime Error

Solution code:
import math
import numpy as np
N, D = map(int, input().split())
times = int(input())  
n = [list(map(int, input().split())) for i in range(times)]
n = np.array(n)
ans = 0
for j in range(n.shape[0]):
  for i in range(n.shape[0]):
    length = np.linalg.norm(n[i]-n[j])
    aaa = math.modf(length)[0]
    if aaa < 0.00001:
      ans +=1
ans = ans - n.shape[0]
ans = int(ans/2)
print(ans)

Submission status: Runtime Error

Solution code:
import math
import numpy as np
N, D = map(int, input().split())
times = int(input())  
n = [list(map(int, input().split())) for i in range(times)]
n = np.array(n)
for j in range(n.shape[0]):
  for i in range(n.shape[0]):
    length = np.linalg.norm(n[i]-n[j])
    aaa = math.modf(length)[0]
    if aaa < 0.00001:
      ans +=1
ans = ans - n.shape[0]
ans = int(ans/2)
print(ans)

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

cnt = 0
for i in range(0, len(X)):
    sum = 0
    for j in range(0, len(X[i])):
        if i >= (len(X)-1):
            sum += X[i][j] - X[0][j]
        else:
            sum += (X[i][j] - X[i+1][j])**2

    if math.sqrt(sum).is_integer():
        cnt += 1
print(cnt)

Submission status: Runtime Error

Solution code:
N, D = map(int, input().split())
​
# 2次元配列
X = []
for i in range(N):
    array = list(map(int, input().strip().split()))
    X.append(array)
var = 0
for i in range(N-1):
  for k in range(N-1-i):
    s = 0
    for j in range(D):      
      s = s + (X[i+1+k][j] - X[i+k][j])*(X[i+1+k][j] - X[i+k][j])
    if s**0.5 - (int(s**0.5)) ==0:
      var = var+1
print(var)

Submission status: Runtime Error

Solution code:
from sys import stdin

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

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

print(ret,flush=True)

Submission status: Runtime Error

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

Submission status: Runtime Error

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