TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: 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?

Submission attempts (in order):
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)

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 and results[0][i] == np.int64(results[0][i])):
    a += 1
print(a)
    

Verdicts: Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
import math

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

def dist(R,L):
    P=0
    for z in range(D):
        P+=(R[z]-L[z])**2
    return math.sqrt(P)

count=0
for j in range(N-1):
    for k in range(j+1,N):
        print(dist(X[j],X[k]))
        print(math.floor(dist(X[j],X[k])))
        if dist(X[j],X[k])==math.floor(dist(X[j],X[k])):
            count+=1

print(count)


import math

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

def dist(R,L):
    P=0
    for z in range(D):
        P+=(R[z]-L[z])**2
    return math.sqrt(P)

count=0
for j in range(N-1):
    for k in range(j+1,N):
        #print(dist(X[j],X[k]))
        #print(math.floor(dist(X[j],X[k])))
        if dist(X[j],X[k])==math.floor(dist(X[j],X[k])):
            count+=1

print(count)


Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
n, d = map(int, input().split())

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


print(list_N)
score = 0
for i in range(len(list_N)):
    for j in range(i+1, len(list_N)):
        val = 0

        for a, b in zip(list_N[i], list_N[j]):
            val += (a-b)**2

        val = val**0.5
        
        if val.is_integer():
            score += 1

print(score)

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

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


score = 0
for i in range(len(list_N)):
    for j in range(i+1, len(list_N)):
        val = 0

        for a, b in zip(list_N[i], list_N[j]):
            val += (a-b)**2

        val = val**0.5
        
        if val.is_integer():
            score += 1

print(score)

Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
import numpy as np
N, D = map(int, input().split())
X = np.zeros((N,D))
for i in range(N):
  X[i][:] = list(map(int, input().split()))

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

print(n)

import numpy as np

_N, _D, *_X = open(0).read().split()
N = int(_N)
D = int(_D)
X = np.array(list(zip(*[map(int, iter(_X))]*D)))

import itertools

ans = 0

for x, y in itertools.combinations(X, 2):
    d = np.linalg.norm(x - y)

    if d%1 == 0:
        ans += 1

print(ans)

Verdicts: Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
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)

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
        for k in range(D):
            ans = ans + (X[i][k] - X[j][k])**2
        ans = (ans)**0.5
        if ans==int(ans):
            f+=1
print(f)

Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
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)

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)

Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):

N,D = map(int,input().split())
X = [list(map(int,input().split())) for i in range(N)]
count = 0
for i in range(N):
    for j in range(N-i-1):
        J=i+j+1
        dist = 0
        for k in range(D):
            dist+=(X[i][k]-X[J][k])**2
        flag = 0
        for d in range(dist):
            if (dist/(d+1)) == d+1:
                print(d+1)
                flag = 1
        if flag == 1:
            count+=1
print(count)


N,D = map(int,input().split())
X = [list(map(int,input().split())) for i in range(N)]
count = 0
for i in range(N):
    for j in range(N-i-1):
        J=i+j+1
        dist = 0
        for k in range(D):
            dist+=(X[i][k]-X[J][k])**2
        flag = 0
        for d in range(dist):
            if (dist/(d+1)) == d+1:
                flag = 1
        if flag == 1:
            count+=1
print(count)

Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
n,d=map(int,input().split())
x=[list(map(int,input().split())) for _ in range(n)]
p=0
def c(i,j):
  global x
  s=0
  for k in range(d):
    s+=(x[i][k]-x[j][k])**2
  if s**(1/2).is_integer()==True:
    return 1
  else:
    return 0
for i in range(n):
  for j in range(i+1,n):
    p+=c(i,j)
print(p)

n,d=map(int,input().split())
x=[list(map(int,input().split())) for _ in range(n)]
p=0
def c(i,j):
  global x
  s=0
  for k in range(d):
    s+=(x[i][d]-x[j][d])**2
  if s**(1/2).is_integer()==True:
    return 1
  else:
    return 0
for i in range(n):
  for j in range(i+1,n):
    p+=c(i,j)
print(p)

n,d=map(int,input().split())
x=[list(map(int,input().split())) for _ in range(n)]
p=0
def c(i,j):
  global x
  s=0
  for k in range(d):
    s+=(x[i][k]-x[j][k])**2
  if (s**(1/2)).is_integer()==True:
    return 1
  else:
    return 0
for i in range(n):
  for j in range(i+1,n):
    p+=c(i,j)
print(p)

Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
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)

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

for i in range(N):
    r1 = X[i]
    for j in range(N-1, -1, -1):
        if i == j:
            break
        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

print(count)

Verdicts: Runtime Error

Accepted
Problem: 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?

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

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



Verdicts: Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
n,d = map(int, input().split())


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


result = 0

for i in range(n-1):
    total = 0
    for k in range(d-1):
        r = (x[i][k] - x[i+k][k]) ** 2
        total += r
    total = total ** 0.5
    if total.is_integer():
        result += 1
print(result)

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


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


result = 0

for i in range(n):
    for j in range(n):
        if i < j:
            dist = 0
            for k in range(d):
                dist += (x[i][k] - x[j][k]) ** 2
            dist = dist ** 0.5
            if dist.is_integer():
                result += 1
print(result)

Verdicts: Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
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)


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
        if tol**(1/2)-int(tol**(1/2))==0:
            out+=1
print(out)


Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
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)

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)


N, D = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(N)]
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)


Verdicts: Runtime Error

Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
import math
n,d = map(int,input().split())
x = [list(map(int(input().split()))) for i in range(n)]
cnt = 0
for i in range(n-1):
    for j in range(i+1,n):
        res = 0
        for z in range(d):
            res += (x[i][z]-x[j][z])**2
        if math.sqrt(res)**2==res:
            cnt += 1
print(cnt)

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

Verdicts: Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
import sys, math

a = [int(i) for i in input().split()]
N = a[0]
D = a[1]
X = []
for i in range(N):
  tmp = [int(i) for i in input().split()]
  X.append(tmp)

if D == 1:
  print(int(N*(N-1)/2))
  sys.exit(0)
count = 0
for n in range(0,N-1):
  result = 0
  for d in range(D):
    result = (X[n][d]-X[n+1][d])**2
  if math.sqrt(result).is_integer():
    count+=1;
print(int(count))

import sys, math

a = [int(i) for i in input().split()]
N = a[0]
D = a[1]
X = []
for i in range(N):
  tmp = [int(i) for i in input().split()]
  X.append(tmp)

if D == 1:
  print(int(N*(N-1)/2))
  sys.exit(0)

count = 0
for n in range(0,N-1):
  for nn in range(n+1,N):
    result = 0
    for d in range(D):
      tmp = (X[n][d]-X[nn][d])**2
      result+=tmp
    result = math.sqrt(result)
    
    if result.is_integer():
      count+=1;
print(int(count))

Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
N,D = map(int,input().split())

k = []

a = 0

for i in range(N):
  k.append(map(int,input().split())
for i in range(N):
  for j in range(D):

    a += (k[i][j]-k[i+1][j])**2
  a = sqrt(a)
  if a%1 == 0:
  ans += 1
print(ans)

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

import math
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):
    now = 0
    dis = 0
    for k in range(D):
      now += (X[i][k]-X[j][k])**2
    dis = math.sqrt(now)
    if dis%1 == 0:
      ans += 1
print(ans)

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
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)

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)

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)

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
import math
n,d=map(int,input().split())
x=[[int(i) for i in input().split()] for i in range(n)] 
ans=0
for i in range(n-1):
    for j in range(i+1,n):
        check = 0
        for k in range(d):
            check += (x[i][k]-x[j][k])**2
        if type(check) is int:
            ans+=1
print(ans)

n,d=map(int,input().split())
x=[[int(i) for i in input().split()] for i in range(n)] 
ans=0
for i in range(n-1):
    for j in range(i+1,n):
        check = 0
        for k in range(d):
            check += (x[i][k]-x[j][k])**2
        if isinstance(check,int):
            ans+=1
print(ans)

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

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
n,b=map(int,input().split())
x=[list(map(int,input().split())) for i in range(n)]

count=1
for i in range(n):
  for j in range(i+1,n):
    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)
    

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)
    

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

count=0
for i in range(n):
  for j in range(i+1,n):
    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)
    

Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
import numpy as np
import math
n,d=[int(i) for i in inpput().split()]
x=[]
for _ in range(n):
  x.append(np.array([int(i) for i in input().split()]))
def dis(x,y):
  return int(np.sum((x-y)**2))
def iss(x):
  a=round(math.sqrt(x))
  return a**2==x
k=0
for i in range(n):
  for j in range(i+1,n):
    if iss(dis(x[i],x[j])):
      k+=1
print(k)

import numpy as np
import math
n,d=[int(i) for i in input().split()]
x=[]
for _ in range(n):
  x.append(np.array([int(i) for i in input().split()]))
def dis(x,y):
  return int(np.sum((x-y)**2))
def iss(x):
  a=round(math.sqrt(x))
  return a**2==x
k=0
for i in range(n):
  for j in range(i+1,n):
    if iss(dis(x[i],x[j])):
      k+=1
print(k)


Verdicts: Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
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)


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)

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)


import numpy as np
def is_square(n):
    for i in range(200):
        if i*i == n:
            return True
    return False
n,d = map(int, input().split())
x = []
for i in range(n):
    x.append(list(map(int,input().split())))

x = np.array(x)

count = 0
for i in range(n):
    for j in range(i+1,n):
        l = x[i] - x[j]
        l = np.square(l)
        l = np.sum(l)
        flag = is_square(l)
        if(flag) :
            count +=1

print(count)

Verdicts: Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
import math
n,d=map(int,input().split())
x=[list(map(int,input().split())) for _ in range(n)]

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

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

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

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

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


Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
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))

from math 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))

Verdicts: Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
n, d = list(map(int, input().rstrip().split()))
a = []
for i in range(0, n):
    b = list(map(int, input().rstrip().split()))
    a.append(b)

print(a)
def nijou(a,n):
    korelist = 0
    for i in range(0, n-1):
        for j in range(i+1, n ):
            c = [x - y for (x, y) in zip(a[i], a[j])]
            kore = 0
            for u in c:
                kore += u**2
            kore1 = kore ** (1/2)
            print(kore1)
            if kore1 - int(kore1) == 0:
                korelist += 1
    return korelist

nijou(a,n)
                    
                

n, d = list(map(int, input().rstrip().split()))
a = []
for i in range(0, n):
    b = list(map(int, input().rstrip().split()))
    a.append(b)


def nijou(a,n):
    korelist = 0
    for i in range(0, n-1):
        for j in range(i+1, n ):
            c = [x - y for (x, y) in zip(a[i], a[j])]
            kore = 0
            for u in c:
                kore += u**2
            kore1 = kore ** (1/2)
            
            if kore1 - int(kore1) == 0:
                korelist += 1
    return korelist

nijou(a,n)
                    
                

n, d = list(map(int, input().rstrip().split()))
a = []
for i in range(0, n):
    b = list(map(int, input().rstrip().split()))
    a.append(b)


def nijou(a,n):
    korelist = 0
    for i in range(0, n-1):
        for j in range(i+1, n ):
            c = [x - y for (x, y) in zip(a[i], a[j])]
            kore = 0
            for u in c:
                kore += u**2
            kore1 = kore ** (1/2)
            if kore1 - int(kore1) == 0:
                korelist += 1
    return print(korelist)

nijou(a,n)

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: 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?

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

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

Verdicts: Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
N, D = [int(i) for i in input().split()]
X = [[int(i) for i in input().split()] for _ in range(N)]
 
ans = 0
for i in range(N):
    for j in range(i+1, N):
        yz = [abs((y - z)**2) for y, z in zip(X[i], X[j])]
        v = math.sqrt(sum(yz))
        if v == int(v):
            ans += 1
            
print(ans)

N, D = [int(i) for i in input().split()]
X = [[int(i) for i in input().split()] for _ in range(N)]
 
ans = 0
for i in range(N):
    for j in range(i+1, N):
        yz = [abs((y - z)**2) for y, z in zip(X[i], X[j])]
        v = math.sqrt(sum(yz))
        if v == int(v):
            ans += 1
            
print(ans)

import math
N, D = [int(i) for i in input().split()]
X = [[int(i) for i in input().split()] for _ in range(N)]
 
ans = 0
for i in range(N):
    for j in range(i+1, N):
        yz = [abs((y - z)**2) for y, z in zip(X[i], X[j])]
        v = math.sqrt(sum(yz))
        if v == int(v):
            ans += 1
            
print(ans)

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: 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?

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

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


Verdicts: Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
from math import sqrt
n,d=map(int,input().split())
l=[list(map(float,input().split())) for i in range(n)]
nums=[i for i in range(n-1)]
fa=[i for i in range(d)]
cnt=0
ans=0
t=[]
for i in nums:
  for j in l[i+1:]:
    cnt=0
    for k in fa:
      cnt+=(l[i][k]-j[k])**2
    cnt=sqrt(cnt)
    print(cnt)
    t.append(cnt)
for v in t:
  if(v.is_integer()):
    ans+=1
print(ans)
    

from math import sqrt
n,d=map(int,input().split())
l=[list(map(float,input().split())) for i in range(n)]
nums=[i for i in range(n-1)]
fa=[i for i in range(d)]
cnt=0
ans=0
t=[]
for i in nums:
  for j in l[i+1:]:
    cnt=0
    for k in fa:
      cnt+=(l[i][k]-j[k])**2
    cnt=sqrt(cnt)
    t.append(cnt)
for v in t:
  if(v.is_integer()):
    ans+=1
print(ans)
    

Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
import math
n, d = [int(i) for i in input().split()]
dot = []
for _ in range(n):
  zahyo = list(map(int, input().split()))
  dot.append(zahyo)
cnt = 0
for i in range(n-1):
  for j in range(i+1, n):
    for k in range(d):
      test += pow(dot[i][k] - dot[j][k], 2)
    test_a = float(math.sqrt(test))
    test_b = int(math.sqrt(test))
    if(test_a == test_b):
      cnt += 1
print(cnt)

import math
n, d = [int(i) for i in input().split()]
dot = []
for _ in range(n):
  zahyo = list(map(int, input().split()))
  dot.append(zahyo)
cnt = 0
for i in range(n-1):
  for j in range(i+1, n):
    test = 0
    for k in range(d):
      test += pow(dot[i][k] - dot[j][k], 2)
    test_a = float(math.sqrt(test))
    test_b = int(math.sqrt(test))
    if(test_a == test_b):
      cnt += 1
print(cnt)

Verdicts: Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
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)

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)

Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
import math


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


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

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


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

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

import math


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


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

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


Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
a,b = input().split(' ')

c = []
for i in range(int(a)):
  c.append(input().split(' '))

count = 0
for j in range(int(a)):
  for k in range(int(a)):
    if j > k:
    ans = 0
    for l in rnage(int(b)):
      ans = ans + (int(c[j][l]) ** 2 - int(c[k][l]) ** 2) ** 0.5

    if ans = int(ans):
      count = count + 1

print(count)

a,b = input().split(' ')
 
c = []
for i in range(int(a)):
  c.append(input().split(' '))

ans = 0
count = 0
for j in range(int(a)):
  for k in range(int(a)):
    if j > k:
        ans = 0
        for l in range(int(b)):
            ans = ans + (int(c[j][l]) - int(c[k][l])) ** 2
        if ans ** 0.5 == round(ans ** 0.5):
            count = count + 1

print(count)

Verdicts: Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
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()

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

import itertools
import math

dist = lambda X,Y: math.sqrt(sum((x-y)**2 for x,y in zip(X,Y)))

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

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
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)

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=abs((arr[i,k]-arr[j,k])*(arr[i,k]-arr[j,k]))+buf
      buf=math.sqrt(buf)
      if buf.is_integer() == True:
        c=c+1
      buf=0
          
print(c)

Verdicts: Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):

def input2():
	return map(int,input().split())


def input_array():
	return list(map(int,input().split()))
  
def euclid(y,z,d):
	result=0
	for i in range(d):
		result+=(y[i]-z[i])**2
	return math.sqrt(result)


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

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

import math


def input2():
	return map(int,input().split())


def input_array():
	return list(map(int,input().split()))

def euclid(y,z,d):
	result=0
	for i in range(d):
		result+=(y[i]-z[i])**2
	return math.sqrt(result)


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

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

Verdicts: Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
import math
import itertools
N, D = map(int, input().split())

count = 0
all_list = []
for _ in range(N):
    p_list = list(map(int, input().split()))
    all_list.append(p_list)

comb_list = list(itertools.combinations(all_list, 2))
for f_list, l_list in comb_list:
    print(f_list)
    diff_list = [(i-j)**2 for i, j in zip(f_list, l_list)]
    dist = math.sqrt(sum(diff_list))
    if dist == int(dist):
        count += 1

import math
import itertools
N, D = map(int, input().split())
 
count = 0
all_list = []
for _ in range(N):
    p_list = list(map(int, input().split()))
    all_list.append(p_list)

comb_list = list(itertools.combinations(all_list, 2))
for f_list, l_list in comb_list:
    diff_list = [(i-j)**2 for i, j in zip(f_list, l_list)]
    dist = math.sqrt(sum(diff_list))
    if dist == int(dist):
        count += 1

print(count)

Verdicts: Wrong Answer

Accepted