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

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

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

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

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

print(ans)

import math

def abc133_b():
    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):
            sq = 0
            for k in range(D):
                sq += (X[i][k] - X[j][k]) ** 2
            rt = math.floor(math.sqrt(sq) + 0.5)
            if rt * rt == sq: ans += 1
    print(ans)

abc133_b()

Verdicts: Runtime Error

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


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

a = numpy.array(X[0])
b = numpy.array(X[1])
u = b - z
print(numpy.linalg.norm(u))

import numpy as np

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

ret = 0
for i in range(N):
  for j in range(i+1, N):
    a = np.array(X[i])
    b = np.array(X[j])
    u = b - a
    d = np.linalg.norm(u)
    if (d == int(d)):
      ret = ret + 1

print(ret)

import math as ma

def dist(a, b, D):
  r = 0
  for i in range(D):
    r = r + (a[i]-b[i])**2

  return ma.sqrt(r)

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

ret = 0
for i in range(N):
  for j in range(i+1, N):
    d = dist(X[i], X[j], D)
    if (d == int(d)):
      ret = ret + 1

print(ret)

Verdicts: Runtime Error

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 = [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

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
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 as mt

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

xlis = [[0 for _ in range(D)] for _ in range(N)]

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

cnt = 0

for i in range(N):
    for s in range(N):
        res = 0
        if i == s:
            continue
        for l in range(D):
           res += ((xlis[i][l] - xlis[s][l]) ** 2)

        if mt.sqrt(res).is_integer():
            cnt += 1


print(cnt/2)


import math as mt

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

xlis = [[0 for _ in range(D)] for _ in range(N)]

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

cnt = 0

for i in range(N):
    for s in range(N):
        res = 0
        if i == s:
            continue
        for l in range(D):
           res += ((xlis[i][l] - xlis[s][l]) ** 2)

        if mt.sqrt(res).is_integer():
            cnt += 1


print(int(cnt/2))


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):
#!/usr/local/bin/python3
#coding:utf-8
#import numpy as np


def main():

   in0 = input()

   IN = in0.split(' ')

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

   X = np.zeros((N,D))

   for i in range(N):
      in0 = input()
      IN = in0.split(' ')
      for j in range(D):
         X[i,j] = int(IN[j])


   cnt = 0
   for i in range(N-1):
      for k in range(i+1,N):
         dis = 0
         for j in range(D):
            dis = dis + (X[i,j]-X[k,j])**2

         dist = np.sqrt(dis)

         i_dist = int(dist)

         if((dist - i_dist)==0):
            cnt = cnt + 1


   print ("%s" % (cnt))




if __name__ == "__main__":
   main()

#!/usr/local/bin/python3
#coding:utf-8
#import numpy as np


def main():

   in0 = input()

   IN = in0.split(' ')

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

   X = np.zeros((N,D))

   for i in range(N):
      in0 = input()
      IN = in0.split(' ')
      for j in range(D):
         X[i,j] = int(IN[j])


   cnt = 0
   for i in range(N-1):
      for k in range(i+1,N):
         dis = 0
         for j in range(D):
            dis = dis + (X[i,j]-X[(k,j])**2

         dist = np.sqrt(dis)

         i_dist = int(dist)

         if((dist - i_dist)==0):
            cnt = cnt + 1


   print ("%s" % (cnt))




if __name__ == "__main__":
   main()

#!/usr/local/bin/python3
#coding:utf-8
#import numpy as np


def main():

   in0 = input()

   IN = in0.split(' ')

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

   X = np.zeros((N,D))
   
   for i in range(N):
      in0 = input()
      IN = in0.split(' ')
      for j in range(D):
         X[i,j] = int(IN[j])


   cnt = 0
   for i in range(N-1):
      for k in range(i+1,N):
      dis = 0
      for j in range(D):
         dis = dis + (X[i,j]-X[(k,j])**2

      dist = np.sqrt(dis)

      i_dist = int(dist)
      
      if((dist - i_dist)==0):
         cnt = cnt + 1


   print ("%s" % (cnt))




if __name__ == "__main__":
   main()

#!/usr/local/bin/python3
#coding:utf-8
import numpy as np


def main():

   in0 = input()

   IN = in0.split(' ')

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

   X = np.zeros((N,D))

   for i in range(N):
      in0 = input()
      IN = in0.split(' ')
      for j in range(D):
         X[i,j] = int(IN[j])


   cnt = 0
   for i in range(N-1):
      for k in range(i+1,N):
         dis = 0
         for j in range(D):
            dis = dis + (X[i,j]-X[k,j])**2

         dist = np.sqrt(dis)

         i_dist = int(dist)

         if((dist - i_dist)==0):
            cnt = cnt + 1


   print ("%s" % (cnt))




if __name__ == "__main__":
   main()

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):
# ABC133B

import numpy as np

n, d = map(int, input().split())
x = [0] * n
for i in range(n):
    x[i] = list(map(int, input().split()))
x = np.array(x)
count = 0
for i in range(n-1):
    for j in range(i+1, n):
        d = np.sqrt(sum((x[i, :] - x[j, :]) ** 2))
        print(i, j, "** d =", d)
        if d == int(d):
            count += 1
print(count)


# ABC133B

import numpy as np

n, d = map(int, input().split())
x = [0] * n
for i in range(n):
    x[i] = list(map(int, input().split()))
x = np.array(x)
count = 0
for i in range(n-1):
    for j in range(i+1, n):
        d = np.sqrt(sum((x[i, :] - x[j, :]) ** 2))
        # print(i, j, "** d =", d)
        if d == int(d):
            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):
import math
N, D = map(int, input().split())
t = []
for i in range(N):
    t.append(list(map(int, input().split())))
count = 0
sum = 0
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)

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)

import math
N, D = map(int, input().split())
t = []
for i in range(N):
    t.append(list(map(int, input().split())))
count = 0
sum = 0
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)
      if sqrt == int(sqrt):
        count += 1
      sum = 0
      sqrt = 0
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):
    N,D =map(int, input().split())
    all_list = [list(map(int, input().split())) for i in range(N)]
    #>>>4
    count = 0
    for n in range (N):
        for nn in range(N):
            distance = 0
            for d in range(D):
                kou = (all_list[n][d] - all_list[nn][d])**2
                distance += kou
            for s in range(250):
                if distance == s**2:
                    count += 1
                    break
    print(round((count - N) / 2) +)

count = 0
    for n in range (N):
        for nn in range(N):
            distance = 0
            for d in range(D):
                kou = (all_list[n][d] - all_list[nn][d])**2
                distance += kou
            for s in range(250):
                if distance == s**2:
                    count += 1
                    break
    print(round((count - N) / 2))

N,D =map(int, input().split())
all_list = [list(map(int, input().split())) for i in range(N)]
#>>>4
count = 0
for n in range (N):
    for nn in range(n):
        distance = 0
        for d in range(D):
            kou = (all_list[n][d] - all_list[nn][d])**2
            distance += kou
        for s in range(250):
            if distance == s**2:
                count += 1
                break
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):
n = list(map(int, input().rstrip().split(" ")))
ans = 0
coor = []
for a in n[0]:
  coor.append(list(map(int, input().rstrip().split(" "))))
  
def dis(a,b):
  ans = 0
  for i in range(a):
    ans += (a[i] - b[i])**2
  return ans**0.5
  
for a in range(len(coor)):
  for b in range(0,a):
    if coor[a]!=coor[b]:
      if dis(coor[a], coor[b]).is_integer():
        ans += 1
print(ans)

n = list(map(int, input().rstrip().split(" ")))
ans = 0
coor = []
for a in range(n[0]):
  coor.append(list(map(int, input().rstrip().split(" "))))
  
def dis(a,b):
  ans = 0
  for i in range(len(a)):
    ans += (a[i] - b[i])**2
  return ans**0.5
  
for a in range(len(coor)):
  for b in range(0,a):
    if coor[a]!=coor[b]:
      if dis(coor[a], coor[b]).is_integer():
        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 = [list(map(int,input().split())) for _ in range(n)]

ans = 0

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

print(ans)


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

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

ans = 0

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

print(ans)


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

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

ans = 0

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

print(ans)


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

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

ans = 0

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

print(ans)


Verdicts: Wrong Answer

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, d = (int(x) for x in input().split())
X = [[int(x) for x in input().split(" ")] for _ in range(n)]
ans = 0
print(X)
for i in range(n-1):
    for j in range(i+1, n):
        s = 0
        for k in range(d):
            s += (X[i][k] - X[j][k]) ** 2
        if (s ** 0.5).is_integer(): ans += 1
print(ans)


n, d = (int(x) for x in input().split())
X = [[int(x) for x in input().split(" ")] for _ in range(n)]
ans = 0
for i in range(n-1):
    for j in range(i+1, n):
        s = 0
        for k in range(d):
            s += (X[i][k] - X[j][k]) ** 2
        if (s ** 0.5).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
import itertools

a,b=map(int,input().split())
X = [[int(i) for i in input().split()] for i in range(a)] 

c = list(itertools.combinations(X, 2))


def get_distance(x1, y1, x2, y2):
    d = math.sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2)
    return d

ans = 0
for i in range(len(c)):
  C_x1 = c[i][0][0]
  C_x2 = c[i][1][0]
  C_y1 = c[i][0][1]
  C_y2 = c[i][1][1]
  d = get_distance(C_x1,C_y1,C_x2,C_y2)
  if type(d):
    ans = ans+1

print(ans)



import math
import itertools

a,b=map(int,input().split())
X = [[int(i) for i in input().split()] for i in range(a)] 

c = list(itertools.combinations(X, 2))
print(len(c))


ans = 0

for i in range(len(c)):
  d = 0
  for j in range(b):
    d += (c[i][0][j]-c[i][1][j])**2
    if j == b-1:
      d = math.sqrt(d)
      if d.is_integer():
        ans = ans+1

print(ans)



import math
import itertools

a,b=map(int,input().split())
X = [[int(i) for i in input().split()] for i in range(a)] 

c = list(itertools.combinations(X, 2))


ans = 0

for i in range(len(c)):
  d = 0
  for j in range(b):
    d += (c[i][0][j]-c[i][1][j])**2
    if j == b-1:
      d = math.sqrt(d)
      if d.is_integer():
        ans = ans+1

print(ans)

Verdicts: Runtime Error

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_ls = []
cnt = 0
 
for i in range(N):
    X_ls.append(list(map(int, input().split(' '))))
 
for i in range(N - 1):
    for j in range(i+1, N):
        dist_squared, dist = 0, 0
        print(i,j)
        for y, z in zip(X_ls[i], X_ls[j]):
            dist_squared += (y - z) ** 2
        dist = math.sqrt(dist_squared)
        if dist - math.floor(dist) == 0:
            cnt += 1
print(cnt)

import math
N, D = map(int, input().split(' '))
X_ls = []
cnt = 0
 
for i in range(N):
    X_ls.append(list(map(int, input().split(' '))))

for i in range(N - 1):
    for j in range(i+1, N):
        dist_squared, dist = 0, 0
        for y, z in zip(X_ls[i], X_ls[j]):
            dist_squared += (y - z) ** 2
        dist = math.sqrt(dist_squared)
        if dist - math.floor(dist) == 0:
            cnt += 1
print(cnt)

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 _ in range(N):
    X.append(list(map(int, input().split())))

dist = 0
cnt = 0
for i in range(N):
    for j in range(N):
        if j == i:
            continue
        for k in range(D):
            dist += (X[i][k] - X[j][k])**2
        dist = math.sqrt(dist)
        if dist == int(dist):
            cnt += 1
cnt /= 2
print(cnt)

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 X:
    for j in X:
        dist = 0
        for k in range(D):
            dist += (i[k] - i[k])**2
        dist = math.sqrt(dist)
        if dist == int(dist):
            cnt += 1
cnt = (cnt - N)//2
print(cnt)

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 X:
    for j in X:
        dist = 0
        for k in range(D):
            dist += (i[k] - j[k])**2
        dist = math.sqrt(dist)
        if dist == int(dist):
            cnt += 1
cnt = (cnt - N)//2
print(cnt)

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

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)

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

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):
    a = 0
    for d in range(D):
      a += (X[i][d]-X[j][d])**2
    for l in range(a+1):
      if l**2==a:
        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):
import math
n,d = list(map(int,input().split()))
l = [0]*n
print(l)
for i in range(n):
    ipt = list(map(int,input().split()))
    l[i] = ipt
ans = 0
for i in range(n-1):
    for j in range(i+1,n):
        sm = 0
        for k in range(d):
            sm += abs(l[i][k] - l[j][k])**2
        sm = math.sqrt(sm)
        if sm%1 == 0:
            ans += 1
print(ans)

import math
n,d = list(map(int,input().split()))
l = [0]*n
for i in range(n):
    ipt = list(map(int,input().split()))
    l[i] = ipt
ans = 0
for i in range(n-1):
    for j in range(i+1,n):
        sm = 0
        for k in range(d):
            sm += abs(l[i][k] - l[j][k])**2
        sm = math.sqrt(sm)
        if sm%1 == 0:
            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):
n,d=map(int,input().split())
a=0
l=[]
for i in range(n):
    l.append(list(map(int,input().split())))
    for j in range(i+1,n):
     b=0
     for k in range(d):
        b+=(l[i][k]-l[j][k])**2
        c=b**(1/2)
        if c%1 == 0:
            a+=1
print(a)


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

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

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

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

Verdicts: Runtime Error

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())
point = [list(map(int,input().split())) for _ in range(n)]
count = 0
for i in range(n-1):
  for j in range(i+1,n):
    d = 0
    for k in range(0,d):
      d += pow(point[i][k]-point[j][k],2)
    d = d**0.5
    if int(d)==d: count += 1
print(count)


n,d = map(int,input().split())
point = [list(map(int,input().split())) for _ in range(n)]
count = 0
for i in range(n-1):
  for j in range(i+1,n):
    dis = 0
    for k in range(0,d):
      dis += pow(point[i][k]-point[j][k],2)
    dis = dis**0.5
    if int(dis)==dis: 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):
import sys

if sys.platform =='ios':
    sys.stdin=open('input_file.txt')


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

for i in range(N):
	for j in range(i+1,N):
		for k in range(D):
			a+=(X[i][k]-X[j][k])**2
		if int(a**.5)**2==a:
				cnt+=1
		
			
print(cnt)	
		
		

import sys

if sys.platform =='ios':
    sys.stdin=open('input_file.txt')


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

for i in range(N):
	for j in range(i+1,N):
		for k in range(D):
			a+=(X[i][k]-X[j][k])**2
		if int(a**.5)**2==a:
			cnt+=1
		a=0
		
			
print(cnt)	
		
		

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

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)

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

import numpy as np

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


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
import itertools

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

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

print(listArray)
for X in listArray:
    sumX = 0
    for x in range(D):
        subX = X[0][x] - X[1][x]
        sumX += subX**2
     
    if math.sqrt(sumX).is_integer():
        count += 1
    
print(count)

    

import math
import itertools

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

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

for X in listArray:
    sumX = 0
    for x in range(D):
        subX = X[0][x] - X[1][x]
        sumX += subX**2
     
    if math.sqrt(sumX).is_integer():
        count += 1
    
print(count)

    

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

import sys

def solve():
    n,d = map(int, input().split())
    l = [list(map(int, X.split())) for X in sys.stdin.readlines()]
    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())

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 = [list(map(int, input().split())) for _ in range(n)]
print(x)
cnt = 0
sum_tmp = 0

for i in range(n):
    for j in range(i+1, n):
        for h in range(d):
            sum_tmp += (x[i][h] - x[j][h]) ** 2
            print("test i:",i , "h:", h ,x[i][h])
            print("test j:",j , "h:", h ,x[j][h])
        print(i,math.sqrt(sum_tmp))
        if math.sqrt(sum_tmp).is_integer():
            cnt += 1
        sum_tmp = 0

print(cnt)


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

x = [list(map(int, input().split())) for _ in range(n)]
cnt = 0
sum_tmp = 0

for i in range(n):
    for j in range(i+1, n):
        for h in range(d):
            sum_tmp += (x[i][h] - x[j][h]) ** 2
        if math.sqrt(sum_tmp).is_integer():
            cnt += 1
        sum_tmp = 0

print(cnt)


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

S      = input()
S      = S.split()
N      = int(S[0])
D      = int(S[1])
matrix = np.zeros([N, D])
count  = 0


for i in range(0, N, 1):
    X_vector = input()
    X_vector = X_vector.split()
    for j in range(0, D, 1):
        matrix[i][j] = int(X_vector[j])

for i in range(0, N, 1):
    a_vector = matrix[i]
    for j in range(i+1, N, 1):
        b_vector = matrix[j]
        length = np.linalg.norm(b_vector-a_vector)
        if length.is_integer()):
            count = count + 1
print(count)


import numpy as np

S      = input()
S      = S.split()
N      = int(S[0])
D      = int(S[1])
matrix = np.zeros([N, D])
count  = 0


for i in range(0, N, 1):
    X_vector = input()
    for j in range(0, D, 1):
        matrix[i][j] = int(X_vector[j])

for i in range(0, N, 1):
    a_vector = matrix[i]
    for j in range(i+1, N, 1):
        b_vector = matrix[j]
        length = np.linalg.norm(b_vector-a_vector)
        if float(length) / float(length) == 0.0:
            count++

print(count)


import numpy as np

S      = input()
S      = S.split()
N      = int(S[0])
D      = int(S[1])
matrix = np.zeros([N, D])
count  = 0


for i in range(0, N, 1):
    X_vector = input()
    X_vector = X_vector.split()
    for j in range(0, D, 1):
        matrix[i][j] = int(X_vector[j])

for i in range(0, N, 1):
    a_vector = matrix[i]
    for j in range(i+1, N, 1):
        b_vector = matrix[j]
        length = np.linalg.norm(b_vector-a_vector)
        if float(length) / float(length) == 0.0:
            count++

print(count)


import numpy as np

S      = input()
S      = S.split()
N      = int(S[0])
D      = int(S[1])
matrix = np.zeros([N, D])
count  = 0


for i in range(0, N, 1):
    X_vector = input()
    X_vector = X_vector.split()
    for j in range(0, D, 1):
        matrix[i][j] = int(X_vector[j])

for i in range(0, N, 1):
    a_vector = matrix[i]
    for j in range(i+1, N, 1):
        b_vector = matrix[j]
        length = np.linalg.norm(b_vector-a_vector)
        if isinstance(length, int):
            count++
print(count)


import numpy as np

S      = input()
S      = S.split()
N      = int(S[0])
D      = int(S[1])
matrix = np.zeros([N, D])
count  = 0


for i in range(0, N, 1):
    X_vector = input()
    X_vector = X_vector.split()
    for j in range(0, D, 1):
        matrix[i][j] = int(X_vector[j])

for i in range(0, N, 1):
    a_vector = matrix[i]
    for j in range(i+1, N, 1):
        b_vector = matrix[j]
        length = np.linalg.norm(b_vector-a_vector)
        if length.is_integer():
            count = count + 1
print(count)


Verdicts: Runtime Error

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 #math.sqrt(x)

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

ans = 0
for i in range(n):
    for q in range(n):
        sumv = 0
        if i == q:
            continue
        for j in range(d):
            sumv += (x[i][j] - x[q][j]) ** 2

        if math.sqrt(sumv).is_integer() == True:
            ans += 1

print(ans/2)

import math #math.sqrt(x)

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

ans = 0
for i in range(n):
    for q in range(n):
        sumv = 0
        if i == q:
            continue
        for j in range(d):
            sumv += (x[i][j] - x[q][j]) ** 2

        if math.sqrt(sumv).is_integer() == True:
            ans += 1

print(round(ans/2))

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 = [int(i) for i in input().split()]
X=[]
ans=0
for j in range(N):
    X.append([int(i) for i in input().split()])

for i in range(N):
    for j in range(i+1,N):
        y=X[i]
        z=X[j]
        tmp=0
        for k in range(D):
            tmp += (y[k]-z[k])**2
        tmp2 = tmp ** 0.5
        if tmp2.is_integer():
            print(i,j)
            ans+=1   
         
print(ans)

N, D = [int(i) for i in input().split()]
X=[]
ans=0
for j in range(N):
    X.append([int(i) for i in input().split()])

for i in range(N):
    for j in range(i+1,N):
        y=X[i]
        z=X[j]
        tmp=0
        for k in range(D):
            tmp += (y[k]-z[k])**2
        tmp2 = tmp ** 0.5
        if tmp2 - int(tmp2) == 0:
            print(i,j)
            ans+=1   
         
print(ans)

N, D = [int(i) for i in input().split()]
X=[]
ans=0
for j in range(N):
    X.append([int(i) for i in input().split()])

for i in range(N):
    for j in range(i+1,N):
        y=X[i]
        z=X[j]
        tmp=0
        for k in range(D):
            tmp += (y[k]-z[k])**2
        tmp2 = tmp ** 0.5
        if tmp2.is_integer():
            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,D = map(int,input().split())
A = [list(map(int,input().split())) for i in range(N)]

OK = 0
for j in range(N-1):
  print(j)
  num = 0
  for k in range(D):
    num =num+ (A[j][k]-A[j+1][k])**2
    print(num)
  print(num**(1/2).is_integer())
  if num**(1/2).is_integer() == True:
    OK += 1
    print(type(num**(1/2)))
  else:
    None
print(OK)

import math
N,D = map(int,input().split())
X = [list(map(int,input().split())) for i in range(N)]
a = []
for l in range(N-1):
    for j in range(l+1,N):
        b = 0
        for k in range(D):
            b += (X[l][k]- X[j][k])**2
        a.append(math.sqrt(b))
c = 0
for m in range(len(a)):
    if len(str(a[m])) <=5:
        c += 1
print(c)

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 copy
import math

n, d = map(int, input().split())
x = [list(map(int, input().split())) for _ in range(n)]
y = copy.deepcopy(x)
cnt = 0
inside = 0
for nx, i in enumerate(x[:]):
  # print(i)
  for ny, j in enumerate(y[:]):
    # print(j)
    inside = 0
    if nx != ny:
      for item in range(d):
        inside += (i[item] - j[item]) ** 2
        # print('inside = %d' % inside)
      root = math.sqrt(inside)
      if root.is_integer():
        cnt += 1
print(cnt)

import copy
import math

n, d = map(int, input().split())
x = [list(map(int, input().split())) for _ in range(n)]
y = copy.deepcopy(x)
cnt = 0
inside = 0
for nx, i in enumerate(x[:]):
  # print(i)
  for ny, j in enumerate(y[:]):
    # print(j)
    inside = 0
    if nx != ny:
      for item in range(d):
        inside += (i[item] - j[item]) ** 2
        # print('inside = %d' % inside)
      root = math.sqrt(inside)
      if root.is_integer():
        cnt += 1
print(int(cnt / 2))

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):
# -*- coding: utf-8 -*-
# 
import math
import sys
import itertools
import numpy as np



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


x = [[int(i) for i in input().split()] for i in range(n)] 
print(x)
answer = 0
for j in range(n):
    for i in range(j):
        dist2 = 0
        for k in range(d):
            dist2 += (x[i][k]-x[j][k]) * (x[i][k]-x[j][k])
            print(dist2)
        dist = math.sqrt(dist2)
        print(dist)

        if round(dist)*dist == dist2:
            answer += 1

print(answer)


# -*- coding: utf-8 -*-
# 
import math
import sys
import itertools
import numpy as np



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


x = [[int(i) for i in input().split()] for i in range(n)] 
#print(x)
answer = 0
for j in range(n):
    for i in range(j):
        dist2 = 0
        for k in range(d):
            dist2 += (x[i][k]-x[j][k]) * (x[i][k]-x[j][k])
#            print(dist2)
        dist = math.sqrt(dist2)
#        print(dist)

        if round(dist)*dist == dist2:
            answer += 1

print(answer)


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())
l=[]
for i in range(n):
  l.append(list(map(int, input().split())))
count = 0
for i in range(n):
  for j in range(i+1,n):
    distance_a = 0
    for k in range(d):
      distance_k= l[i][k]-l[j][k]
      distance_a +=distance_k**2
    distance = np.sqrt(distance_a)
    if distance = int:
      count += 1
print(count)
    
    
      

import numpy as np
n,d = map(int, input().split())
l=[]
for i in range(n):
  l.append(list(map(int, input().split())))
count = 0
for i in range(n):
  for j in range(i+1,n):
    distance_a = 0
    for k in range(d):
      distance_k= l[i][k]-l[j][k]
      distance_a +=distance_k**2
    distance = np.sqrt(distance_a)
    distance_int =int(distance)
    if distance == distance_int:
      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):
N, D = map(int, input().split())
X = []
count = 0
for n in range(N):
  temp = list(map(int, input().split()))
  X.append(temp)
for i in range(N):
  for j in range(i + 1, N):
    sums = 0
    for d in range(D):
      sums += (X[i][d] - X[j][d]) ** 2
    for n in range(sums):
      if n * n == sums or sums == 1:
        count += 1
    print("{} {}".format(sums, count))
print(count)

N, D = map(int, input().split())
X = []
count = 0
for n in range(N):
  temp = list(map(int, input().split()))
  X.append(temp)
for i in range(N):
  for j in range(i + 1, N):
    sums = 0
    for d in range(D):
      sums += (X[i][d] - X[j][d]) ** 2
    for n in range(sums):
      if n * n == sums or sums == 1:
        count += 1
print(count)

Verdicts: Wrong Answer

Accepted