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


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

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

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 sys
import numpy as np

rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
for i in range(n):
  for j in range(i):
    a = sum((li[i] - li[j]) ** 2)**0.5
    if a - a//1 == 0:
      cnt += 1
print(cnt)

import sys
import numpy as np
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))

cnt = 0
for i in range(n):
  for j in range(i):
    a = sum((li[i] - li[j]) ** 2)**0.5
    if a - a//1 == 0:
      cnt += 1
print(cnt)


import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

n, _ = rm()
li = np.array([np.array(rl()) for _ in range(n)])
cnt = 0
for i in range(n):
  for j in range(i):
    a = sum((li[i] - li[j]) ** 2)
    if a - a//1 == 0:
      cnt += 1
print(cnt)









import sys
import numpy as np
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))

n, _ = rm()
li = np.array([np.array(rl()) for _ in range(n)])
cnt = 0
for i in range(n):
  for j in range(i):
    a = sum((li[i] - li[j]) ** 2)**0.5
    if a - a//1 == 0:
      cnt += 1
print(cnt)









Verdicts: Runtime Error

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 as np
n,d = map(int,input().split())
list=[list(map(int,input().split())) for i in range(n)]
arr_list = np.array(list)
count = 0
for i in range(n):
    for j in range(i+1,n):
        if(i != j):
            distance = 0.0
            for k in range(d):
                distance += (arr_list[i][k] - arr_list[j][k])**2
            if(distance > 0):
                result = np.sqrt(distance)
                if(result.is_integer()):
                    print("ans = ", result)
                    count += 1
print(count)

import numpy as np
n,d = map(int,input().split())
list=[list(map(int,input().split())) for i in range(n)]
arr_list = np.array(list)
count = 0
for i in range(n):
    for j in range(i+1,n):
        if(i != j):
            distance = 0.0
            for k in range(d):
                distance += (arr_list[i][k] - arr_list[j][k])**2
            if(distance > 0):
                result = np.sqrt(distance)
                if(result.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 math
N, D = map( int, input().split() )
X = [list(map(int, input().split())) for _ in range(N)]
result = 0

for i in range(N):
    for j in range(i, N):
        if i != j:
            tmp = 0.0
            for k in range(D):
                tmp += abs(X[i][k] - X[j][k]) ** 2
            tmp = math.sqrt(tmp)
            print(tmp)
            if tmp.is_integer():
                result += 1

print(result)


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

for i in range(N):
    for j in range(i, N):
        if i != j:
            tmp = 0.0
            for k in range(D):
                tmp += abs(X[i][k] - X[j][k]) ** 2
            tmp = math.sqrt(tmp)
            print(tmp)
            if tmp.is_integer():
                result += 1

print(result)

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

for i in range(N):
    tmp = 0.0
    for j in range(i, N):
        for k in range(D):
            tmp += (X[i][k] - X[j][k]) ** 2
        tmp = math.sqrt(tmp)
        if tmp.is_integer():
            result += 1

print(result)


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

for i in range(N):
    for j in range(i, N):
        if i != j:
            tmp = 0.0
            for k in range(D):
                tmp += abs(X[i][k] - X[j][k]) ** 2
            tmp = math.sqrt(tmp)
            if tmp.is_integer():
                result += 1

print(result)

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):
def dist(a, b):
  res = 0
  for i in range(D):
    res += (a[i] - b[i]) ** 2
    res = res ** 0.5

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

import math

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):
        tmp = 0
        for k in range(D): 
            tmp +=(X[i][k]-X[j][k])**2
        tmp = math.sqrt(tmp)
        if (tmp.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):
import math
R = lambda : map(int,input().split())
n,d = R()
xs = [list(R()) for _ in range(n)]

def dist(y,z):
    return math.sqrt(sum([(y[i]-z[i])**2 for i in range(d)]))


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

import atexit
import io
import sys

_INPUT_LINES = sys.stdin.read().splitlines()
input = iter(_INPUT_LINES).__next__
_OUTPUT_BUFFER = io.StringIO()
sys.stdout = _OUTPUT_BUFFER


@atexit.register
def write():
    sys.__stdout__.write(_OUTPUT_BUFFER.getvalue())

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

def dist(y,z):
    return math.sqrt(sum([(y[i]-z[i])**2 for i in range(d)]))


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

# import atexit
# import io
# import sys
#
# _INPUT_LINES = sys.stdin.read().splitlines()
# input = iter(_INPUT_LINES).__next__
# _OUTPUT_BUFFER = io.StringIO()
# sys.stdout = _OUTPUT_BUFFER
#
#
# @atexit.register

#     sys.__stdout__.write(_OUTPUT_BUFFER.getvalue())

import math
R = lambda : map(int,input().split())
import math

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


def dist(y, z):
    return math.sqrt(sum([(y[i] - z[i]) * (y[i] - z[i]) for i in range(D)]))


count = 0
for i in range(N):
    for j in range(i + 1, N):
        d = dist(Xs[i], Xs[j])
        if int(d) == d:
            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):
num=input()
K,X=[int(s) for s in num.split(" ")]

max=X+(K-1)
min=X-(K-1)

list=[]
for i in range(min,max+1,1):
    list.append(i)

ans=" ".join(map(str,list))

print(ans)

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

Ans_List=[]
for i in range(N):
    for j in range(i+1,N):
        Sum=0
        for k in range(D):
            Sum+=(int(X[i][k])-int(X[j][k]))**2
        Ans_List.append(math.sqrt(Sum))
        
count=0
for i in Ans_List:
    if int(i)==i:
        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)]
ans=0
for i in range(n):
  for j in range(i+1,n):
    tmp=0
    for k in range(d):
      tmp+=abs(x[i][d]-x[j][d])**2
    tmp=tmp**0.5
    if tmp==int(tmp):1
      ans+=1
print(ans)

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

N, D = map(int, input().split())
X = [list(map(int,input().split())) for i in range(N)]
ans = 0
for i in range(N):
  for j in range(i+1,N):
    tmp = 0
    for k in range(D):
      tmp += abs(X[i][k]-X[j][k])**2
    tmp = tmp**0.5
    if tmp == int(tmp):
      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 = map(int, input().split())
p=[]
for _ in range(N):
    p.append(list(map(int, input().split())))

dis=[]
for a in p:
    for b in p:
        n = 0
        for i in range(D):
            n = n + (a[i]-b[i])**2
        if not n==0:
            dis.append(n)
print(len([d for d in dis if int(math.sqrt(d))**2==d])/2)

import math
N, D = map(int, input().split())
p=[]
for _ in range(N):
    p.append(list(map(int, input().split())))

dis=[]
for a in p:
    for b in p:
        n = 0
        for i in range(D):
            n = n + (a[i]-b[i])**2
        if not n==0:
            dis.append(n)
print(len([d for d in dis if int(math.sqrt(d))**2==d])//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):
import math

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

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

print(cnt)


import math

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

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

print(cnt)


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 i in range(N)]
count = 0
for j in range(N-1):
    for k in range(j+1,N):
        L = 0
        for l in range(D):
            L += (X[j][l]-X[k][l])**2
            print(L)
        if math.sqrt(L).is_integer() == True:
            count += 1
print(count)

import math
N,D=map(int,input().split())
X = [list(map(int,input().split())) for i in range(N)]
count = 0
for j in range(N-1):
    for k in range(j+1,N):
        L = 0
        for l in range(D):
            L += (X[j][l]-X[k][l])**2
        if math.sqrt(L).is_integer() == True:
            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=[]
for _ in range(d):
  x+=[list(map(int,input().split()))]
ans=0
for i in range(d):
  for j in range(i+1,d):
    l=0
    for k in range(n):
      l+=(x[i][k]-x[j][k])**2
    l=l**0.5
    if l.is_integer():
      ans+=1
print(ans)

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

n,d=map(int,input().split())
x=[]
for _ in range(n):
  x+=[list(map(int,input().split()))]
ans=0
for i in range(n):
  for j in range(i+1,n):
    l=0
    for k in range(d):
      l+=(x[i][k]-x[j][k])**2
    l=l**0.5
    if l.is_integer():
      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):
#! python3
#  solve_133B.py

import math

def dis(Y,Z):
    ans = 0
    for i in range(len(Y)):
        ans += (Y[i] - Z[i])**2
    return math.sqrt(ans)


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

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

for i in range(N):
    for j in range(i,N):
       if dis(i,j) % 1 == 0:
           ans += 1

print(ans)

#! python3
#  solve_133B.py

import math



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


def dis(Y,Z):
    ans = 0
    for i in range(D):
        ans += (Y[i] - Z[i])**2
    return math.sqrt(ans)

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

for i in range(N):
    for j in range(i+1,N):
       if dis(X[i],X[j]) % 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())
P = []
for i in range (N):
    P.append(list(map(int, input().split())))
Pi = 0
for i in range(N):
    for j in range(i+1, N):
        Di = 0
        for k in range (D):
            Di += (P[i][k]-P[j][k])**2
        if int(Di**0.5) == dist**0.5:
            Pi += 1
print(Pi)

N,D = map(int,input().split())
    P = []
    for i in range (N):
        P.append(list(map(int, input().split())))
    Pi = 0
    for i in range(N):
        for j in range(i+1, N):
            Di = 0
            for k in range (D):
                Di += (P[i][k]-P[j][k])**2
            if int(Di**0.5) == dist**0.5:
                Pi += 1
    print(Pi)

N,D = map(int,input().split())
P = []
for i in range (N):
    P.append(list(map(int, input().split())))
Pi = 0
for i in range(N):
    for j in range(i+1, N):
        Di = 0
        for k in range (D):
            Di += (P[i][k]-P[j][k])**2
        if int(Di**0.5) == Di**0.5:
            Pi += 1
print(Pi)

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):
# b.py
n,d = map(int,input().split())
lis = [list(map(int,input().split())) for x in range(n)]
ans = 0
for xli in range(n-1):
    for yli in range(xli,n):
        le = 0
        for x,y in zip(lis[xli],lis[yli]):
            le += (y-x) **2
        print(xli,yli,'xli','yli')
        print((le**0.5)//1,le**0.5,le**0.5==(le**0.5)//1 and xli != yli,'root')
        if le**0.5 == (le**0.5)//1 and xli != yli:
             ans += 1
print(ans)


# b.py
n,d = map(int,input().split())
lis = [list(map(int,input().split())) for x in range(n)]
ans = 0
for xli in range(n-1):
    for yli in range(xli,n):
        le = 0
        for x,y in zip(lis[xli],lis[yli]):
            le += (y-x) **2
        #print(xli,yli,'xli','yli')
        #print((le**0.5)//1,le**0.5,le**0.5==(le**0.5)//1 and xli != yli,'root')
        if le**0.5 == (le**0.5)//1 and xli != yli:
             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):
a,b = map(int,input().split())
c = [list(map(int,input().split())) for j in range(a)]
ans = 0
for l in range(a-1):
    for k in range(l+1,a):
        d = [(x-y)**2 for (x, y) in zip(c[l], c[k])]
        g = sum(d)
        if (g**0.5).is_integer:
            ans += 1
print(ans)

a,b = map(int,input().split())
c = [list(map(int,input().split())) for j in range(a)]
ans = 0
for l in range(a-1):
    for k in range(l+1,a):
        d = [(x-y)**2 for (x, y) in zip(c[l], c[k])]
    g = sum(d)
    if (g**0.5).is_integer:
        ans += 1
print(ans)

a,b = map(int,input().split())
c = [list(map(int,input().split())) for j in range(a)]
ans = 0
for l in range(a-1):
    for k in range(l+1,a):
        d = [(x-y)**2 for (x, y) in zip(c[l], c[k])]
        g = sum(d)
        s = g**0.5
        if s.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())
arX = [list(map(int, input().split()))[:D] for n in range(N)]

import math

count = 0
for x in range(len(arX)):
    xp = arX[x]
    for y in range(x, len(arX)):
        if x == y:
            continue
        
        yp = arX[y]
        
        powSum = 0
        for d in range(D):
            powSum += (xp[d] - yp[d]) ** 2
        
        if debug:
            print(x, y, sqPowSum)
            
        sqPowSum = math.sqrt(powSum)
        if sqPowSum == int(sqPowSum):
            count += 1

print(count)

N, D = map(int, input().split())
arX = [list(map(int, input().split()))[:D] for n in range(N)]

import math

count = 0
for x in range(len(arX)):
    xp = arX[x]
    for y in range(x, len(arX)):
        if x == y:
            continue
        
        yp = arX[y]
        
        powSum = 0
        for d in range(D):
            powSum += (xp[d] - yp[d]) ** 2
        
        #print(x, y, sqPowSum)
            
        sqPowSum = math.sqrt(powSum)
        if sqPowSum == int(sqPowSum):
            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 numpy as np

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

import numpy as np

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

import numpy as np

n,d=map(int,input().split())
arr=[]
for i in range(n):
  arr.append(list(map(int,input().split())))
arr =np.array(arr)
ans=0
for i in range(n):
  for j in range(i,n):
    if j!=i:
      k = np.linalg.norm(arr[i]-arr[j],ord=2)
    else:
      k=0.5
    if k==int(k):
      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):
5 1
1
2
3
4
5

import math
n,d = map(int,input().split())
x = []
for i in range(0,n):
    x.append(list(map(int,input().split())))
def f(a,b):
    s = 0
    for l in range(0,d):
        s+=(a[l]-b[l])**2
    return math.sqrt(s)
count = 0
for j in range(0,n):
    for k in range(0,n):
        if not (j==k):
            if f(x[j],x[k])%1==0:
                count = count + 1

print(int(count/2))

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()))
p = []
ans = 0
for i in n:
  p.append(list(map(int, input().split())))
  for j in range(i):
    s = 0
    for k in d:
      s += (p[i] - p[j]) ** 2
    t = int(s ** 0.5 + 1e-7)
    if t * t == s:
      ans += 1
print(ans)

n, d = list(map(int, input().split()))
p = []
ans = 0
for i in n:
  p.append(list(map(int, input().split())))
  for j in range(i):
    s = 0
    for k in d:
      s += (p[i][k] - p[j][k]) ** 2
    t = int(s ** 0.5 + 1e-7)
    if t * t == s:
      ans += 1
print(ans)

n, d = list(map(int, input().split()))
p = []
ans = 0
for i in range(n):
  p.append(list(map(int, input().split())))
  for j in range(i):
    s = 0
    for k in range(d):
      s += (p[i][k] - p[j][k]) ** 2
    t = int(s ** 0.5 + 1e-7)
    if t * t == s:
      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 = tuple([int(s) for s in input().split()])
x = [[0]*d for i in range(n)]

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

cnt_fit = 0

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

print(cnt_fit)


import math

n, d = tuple([int(s) for s in input().split()])
x = [[0]*d for i in range(n)]

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

cnt_fit = 0

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

print(cnt_fit)


import math

n, d = tuple([int(s) for s in input().split()])
x = [[0]*d for i in range(n)]

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

cnt_fit = 0

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

print(cnt_fit)


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

# N, D = [3, 4]
# X = [
# [-3, 7, 8, 2],
# [-12, 1, 10, 2],
# [-2, 8, 9, 3]
# ]

import math
import numpy

ans = 0
for i in range(N):
    for j in range(i):
        # print(i,j)
        d = [(x[0] - x[1]) ** 2 for x in zip(X[i], X[j])]
        if math.sqrt(sum(d)).is_integer():
            ans += 1
print(ans)

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

# N, D = [3, 4]
# X = [
# [-3, 7, 8, 2],
# [-12, 1, 10, 2],
# [-2, 8, 9, 3]
# ]

from math import sqrt
# import numpy

ans = 0
for i in range(N):
    for j in range(i):
        d = [(x[0] - x[1]) ** 2 for x in zip(X[i], X[j])]
        if sqrt(sum(d)) % 1 == 0:
            ans += 1
print(ans)

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

import math

ans = 0
for i in range(5):
    for j in range(i):
        # print(i,j)
        d = X[i] - X[j]
        if math.sqrt(d.dot(d)).is_integer():
            ans += 1
print(ans)

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

# N, D = [3, 4]
# X = [
# [-3, 7, 8, 2],
# [-12, 1, 10, 2],
# [-2, 8, 9, 3]
# ]

from math import sqrt

ans = 0
for i in range(N):
    for j in range(i):
        d = 0
        for k in range(D):
            d += (X[i][k] - X[j][k]) ** 2
        if sqrt(d) % 1 == 0:
            ans += 1
print(ans)

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

# N, D = [3, 4]
# X = [
# [-3, 7, 8, 2],
# [-12, 1, 10, 2],
# [-2, 8, 9, 3]
# ]

from math import sqrt

ans = 0
for i in range(N):
    for j in range(i):
        d = 0
        for k in range(D):
            d += (X[i][k] - X[j][k]) ** 2
        if sqrt(d) % 1 == 0:
            ans += 1
print(ans)

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
n,d=map(int,input().split())
za=[list(map(int,input().split())) for i in range(n)]
ans=0
lon=0
for i in range(n):
    for j in range(i+1,n):
        for k in range(d):
            lon+=(za[i][d]-za[j][d])**2
            lon=math.sqrt(lon)
        else:
            if lon==int(lon):
                ans+=1
            lon=0
print(ans)

import math
n,d=map(int,input().split())
za=[list(map(int,input().split())) for i in range(n)]
ans=0
lon=0
for i in range(n):
    for j in range(i+1,n):
        for k in range(d):
            lon+=(za[i][k]-za[j][k])**2
        else:
            lon=math.sqrt(lon)
            if lon==int(lon):
                ans+=1
            lon=0
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(n) for n in input().split()]
X = []
for i in range(N):
    X.append([int(m) for m in input().split()])

def get_distance(p1, p2):
    d2 = 0
    for i in range(D):
        d2 += (p1[i] - p2[i])**2
    return math.sqrt(d2)

count = 0
for i, j in itertools.combinations(range(N), 2):
    if get_distance(X[i], X[j]).is_integer():
        count += 1

print(count)

import math
import itertools

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

def get_distance(p1, p2):
    d2 = 0
    for i in range(D):
        d2 += (p1[i] - p2[i])**2
    return math.sqrt(d2)

count = 0
for i, j in itertools.combinations(range(N), 2):
    if get_distance(X[i], X[j]).is_integer():
        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 itertools import combinations
sq = [i**2 for i in range(500)]
ans = 0
n,d = map(int,input().split())
a = [list(map(int,input().split())) for i in range(n)]
for (i,j) in combinations(a,2):
  dist2 = 0
  for x in range(d):
    dist2 += i[x]**2 + j[x]**2
  if dist2 in sq:
    ans += 1
print(ans)

from itertools import combinations
sq = [i**2 for i in range(500)]
ans = 0
n,d = map(int,input().split())
a = [list(map(int,input().split())) for i in range(n)]
for (i,j) in combinations(a,2):
  dist2 = 0
  for x in range(d):
    dist2 += (i[x]-j[x])**2
  if dist2 in sq:
    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 itertools
import numpy

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

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

#print(grid)

grid2 = list(itertools.combinations(grid, 2))
for i in grid2:
    x = numpy.array(i[0])
    y = numpy.array(i[1])
  #  print(x, y)
    dis = numpy.linalg.norm(y - x)
    if (isinstance(dis, int)):
        print(dis)


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

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

# print(grid)
cnt = 0
grid2 = list(itertools.combinations(grid, 2))
for i in grid2:
    x = numpy.array(i[0])
    y = numpy.array(i[1])
  #  print(x, y)
    dis = numpy.linalg.norm(y - x)
    # print(dis)
    if (dis.is_integer()):
        #print(dis)
        cnt += 1


import itertools
import numpy

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

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

print(grid)

grid2 = list(itertools.combinations(grid, 2))
for i in grid2:
    x = numpy.array(i[0])
    y = numpy.array(i[1])
  #  print(x, y)
    dis = numpy.linalg.norm(y - x)
    if (isinstance(dis, int)):
        print(dis)


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

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

# print(grid)
cnt = 0
grid2 = list(itertools.combinations(grid, 2))
for i in grid2:
    x = numpy.array(i[0])
    y = numpy.array(i[1])
  #  print(x, y)
    dis = numpy.linalg.norm(y - x)
    # print(dis)
    if (dis.is_integer()):
        #print(dis)
        cnt += 1
print(cnt)

import itertools
import numpy

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

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

# print(grid)
cnt = 0
grid2 = list(itertools.combinations(grid, 2))
for i in grid2:
    x = numpy.array(i[0])
    y = numpy.array(i[1])
  #  print(x, y)
    dis = numpy.linalg.norm(y - x)
    # print(dis)
    if (dis.is_integer()):
        # print(dis)
        cnt += 1

  # print("-------------")
print(cnt)




Verdicts: Wrong Answer

Runtime Error

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):
def issq(n):
    for i in range(2 * n):
        if i * i == n:
            return True
    return False
    

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

count = 0

for i in range(n - 1):
    for j in range(i + 1, n):
        sqdist = 0
        for k in range(d):
            sqdist = sqdist + ((x[i][k] - x[j][k]) ** 2)
        print(sqdist)
        if issq(sqdist) == True:
            count = count + 1

print(count)

def issq(n):
    for i in range(2 * n):
        if i * i == n:
            return True
    return False
    

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

count = 0

for i in range(n - 1):
    for j in range(i + 1, n):
        for k in range(d):
            sqdist = 0
            sqdist = sqdist + (x[i][k] - x[j][k]) ** 2
        if issq(sqdist) == True:
            count = count + 1

print(count)

def issq(n):
    for i in range(2 * n):
        if i * i == n:
            return True
    return False
    

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

count = 0

for i in range(n - 1):
    for j in range(i + 1, n):
        sqdist = 0
        for k in range(d):
            sqdist = sqdist + ((x[i][k] - x[j][k]) ** 2)
        if issq(sqdist) == True:
            count = 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):
def input_from_console():
    n, d = map(int, input().split())
    x_matrix = []
    for i in range(n):
        x = map(int, input().split())
        x_matrix.append(list(x))
    return n, d, x_matrix


def solve(n, d, x_matrix):
    result = 0
    for i in range(n):
        for j in range(n - i -1):
            distance = math.sqrt(sum([(p1 - p2) ** 2 for p1, p2 in zip(x_matrix[i], x_matrix[j + i + 1])]))
            if distance == int(distance):
                result += 1
    return result


def main():
    n, d, x_matrix = input_from_console()
    print(solve(n, d, x_matrix))


if __name__ == "__main__":
    import sys

    if sys.gettrace():  # Check if the python interpreter is in debug mode or not.
        check_cases()
    else:
        main()


import math

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


def solve(n, d, x_matrix):
    result = 0
    for i in range(n):
        for j in range(n - i -1):
            distance = math.sqrt(sum([(p1 - p2) ** 2 for p1, p2 in zip(x_matrix[i], x_matrix[j + i + 1])]))
            if distance == int(distance):
                result += 1
    return result


def main():
    n, d, x_matrix = input_from_console()
    print(solve(n, d, x_matrix))


if __name__ == "__main__":
    import sys

    if sys.gettrace():  # Check if the python interpreter is in debug mode or not.
        check_cases()
    else:
        main()


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())
L=[]
for i in range(n):
    L.append(list(map(int, input().split())))
ans =0

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

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

for i in range(n):
    for j in range(i+1,n):
        dis=0
        for k in range(d):
            dis = (L[i][k]-L[j][k])**2
        dis = dis**0.5
        if(dis % 1.0 ==0):
            ans +=1
print(ans)


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

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

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

for i in range(n):
    for j in range(i+1,n):
        dis=0
        for k in range(d):
            dis += (L[i][k]-L[j][k])**2
        dis = dis**0.5
        if dis % 1.0 ==0:
            ans +=1
print(ans)

Verdicts: Runtime Error

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 numpy as np
N,D = map(int,input().split())
XD = [list(map(int,input().split()))  for i in range(N)]
dis = 0
count = 0
for i in range(N):
    for j in range(N-i):
        if j == 0:
            continue
        for k in range(D):
            dis = (abs(XD[i][k]-XD[j+i][k]))**2
        if int(np.sqrt(dis)) == np.sqrt(dis):
            count += 1
        dis = 0

print(count)


import numpy as np
N,D = map(int,input().split())
XD = [list(map(int,input().split()))  for i in range(N)]
dis = 0
count = 0
for i in range(N):
    for j in range(N-i):
        if j == 0:
            continue
        for k in range(D):
            dis += (abs(XD[i][k]-XD[j+i][k]))**2
        if int(np.sqrt(dis)) == np.sqrt(dis):
            count += 1
        dis = 0

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())
lists=[list(map(int,input().split())) for x in range(n)]
answer=0
for i in range(1,n):
  for j in range(i+1,n+1):
    count=o
    for y in range(d):
      count+=(lists[j-1][y]-lists[i-1][y])**2
    t=count**(1/2)
    if t.is_integer():
        answer+=1
print(answer)

n,d=map(int,input().split())
lists=[list(map(int,input().split())) for x in range(n)]
answer=0
for i in range(1,n):
  for j in range(2,n+1):
    for y in range(d):
      count=0
      count+=(lists[j-1][y]-lists[i-1][y])**2
      n=count**(1/2)
      if n.is_integer():
        answer+=1
print(answer)

n,d=map(int,input().split())
lists=[list(map(int,input().split())) for x in range(n)]
answer=0
for i in range(1,n):
  for j in range(i+1,n+1):
    for y in range(d):
      count=0
      count+=(lists[j-1][y]-lists[i-1][y])**2
      n=count**(1/2)
      if n.is_integer():
        answer+=1
print(answer)

n,d=map(int,input().split())
lists=[list(map(int,input().split())) for x in range(n)]
answer=0
for i in range(1,n):
  for j in range(i+1,n+1):
    for y in range(d):
      count=0
      count+=(lists[j-1][y]-lists[i-1][y])**2
      t=count**(1/2)
      if t.is_integer():
        answer+=1
print(answer)

n,d=map(int,input().split())
lists=[list(map(int,input().split())) for x in range(n)]
answer=0
for i in range(1,n):
  for j in range(2,n+1):
    for y in range(d):
      count=0
      count+=(lists[j-1][y]-lists[i-1][y])**2
      if is_integer(count**(1/2)):
        answer+=1
print(answer)
        

n,d=map(int,input().split())
lists=[list(map(int,input().split())) for x in range(n)]
answer=0
for i in range(1,n):
  for j in range(i+1,n+1):
    count=o
    for y in range(d):
      count+=(lists[j-1][y]-lists[i-1][y])**2
    t=count**(1/2)
    if t.is_integer():
      answer+=1
print(answer)

n,d=map(int,input().split())
l=[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):
    sum=0
    for dd in range(d):
      sum+=(l[i][dd]-l[j][dd])**2
    if sum**0.5==int(sum**0.5):
      cnt+=1
print(cnt)

Verdicts: Runtime Error

Runtime Error

Runtime Error

Wrong Answer

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 sys
import math
N,D=map(int,sys.stdin.readline().split())
x=[]
count=0
for i in range(N):
    x.append(map(int,sys.stdin.readline().split()))
for i in range(N):
    for j in range(n-1):
        if j>=i:
            k=j+1
        else:
            k=j
        diff=math.sqrt(sum([(a-b)**2 for a,b in x[i],x[k]]))
        if diff-int(diff)==0:
            count+=1
print(count)


import sys
import math
N,D=map(int,sys.stdin.readline().split())
x=[]
count=0
for i in range(N):
    x.append(list(map(int,sys.stdin.readline().split())))

for i in range(N):
    for j in range(i+1,N):

        diff=math.sqrt(sum([(a-b)**2 for a,b in zip(x[i],x[j])]))

        if diff-int(diff)==0:
            count+=1
print(count)


Verdicts: Runtime Error

Accepted