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 = []
for i in range(n):
    xi = [int(i) for i in input().split()]
    x.append(xi)
count = 0
ans = 0
for i in range(n-1):
    for l in range(i+1,n):
        ans = 0
        for j in range(d):
            ans += (x[i][j]-x[l][j])**2

        ans = ans **(1/2)
        print(ans)
        if ans == int(ans):
            count += 1
print(count)
    

n,d = map(int,input().split())
x = []
for i in range(n):
    xi = [int(i) for i in input().split()]
    x.append(xi)
count = 0
ans = 0
for i in range(n-1):
    for l in range(i+1,n):
        ans = 0
        for j in range(d):
            ans += (x[i][j]-x[l][j])**2

        ans = ans **(1/2)
        if ans == int(ans):
            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())
w = [list(map(int,input().split())) for a in range(n)]
c = 0
 
for i in range(n-1):
  for j in range(i+1,n):
    b = 0
    for m in range(d):
      b += (w[i][m]-w[j][m])**2
    if (b**0.5)　== float(int(b**0.5)):
      c += 1
      
print(c)

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

for i in range(n-1):
  for j in range(i+1,n+1):
    b = 0
    for m in range(d):
      b += (x[i][m]-x[j][m])**2
    if (b**0.5)　== float(int(b**0.5)):
      c += 1
      
print(c)

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

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

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

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

n,d = map(int,input().split())
w = [list(map(int,input().split())) for a in range(n)]
c = 0
 
for i in range(n-1):
  for j in range(i+1,n+1):
    b = 0
    for m in range(d):
      b += (w[i][m]-w[j][m])**2
    if (b**0.5)==float(int(b**0.5)):
      c += 1
      
print(c)

n,d = map(int,input().split())
w = [list(map(int,input().split())) for a in range(n)]
c = 0
 
for i in range(n-1):
  for j in range(i+1,n):
    b = 0
    for m in range(d):
      b += (w[i][m]-w[j][m])**2
    if (b**0.5)==float(int(b**0.5)):
      c += 1
      
print(c)

Verdicts: Runtime Error

Runtime Error

Runtime Error

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

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

for i in range(N):
    X[i]=list(map(int,input().split()))
    
for i in range(N):
    for j in range(i+1,N):
        d = 0
        for k in range(D):
            d+=(X[i][k]-X[j][k])**2
        d=d**0.5
        if d.is_integer():
            res+=1
print(res)

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

c=0
for i in range(n-1):
  for j in range(i+1,n):
    c+=(sum((a-b)**2 for a,b in zip(x[i],x[j]))**0.5).is_integer

print(c)

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

c=0
for i in range(n-1):
  for j in range(i+1,n):
    c+=(sum((a-b)**2 for a,b in zip(x[i],x[j]))**0.5).is_integer()

print(c)

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())
li =[]
import math
def dist(a,b):
    li2 = []
    for k in range(D):
        li2.append((a[k]-b[k])**2)
    return math.sqrt(sum(li2))
for _ in range(N):
    X = list(map(int,input().split()))
    li.append(X)
cnt = 0
for i in range(N):
    for j in range(N):
        x = li[i]
        y = li[j]
        dis = dist(x,y)
        if dis == 0:
            pass
        else:
            if dis.is_integer():
                cnt +=1
print(cnt/2)

N,D = map(int,input().split())
li =[]
import math
def dist(a,b):
    li2 = []
    for k in range(D):
        li2.append((a[k]-b[k])**2)
    return math.sqrt(sum(li2))
for _ in range(N):
    X = list(map(int,input().split()))
    li.append(X)
cnt = 0
for i in range(N):
    for j in range(N):
        x = li[i]
        y = li[j]
        dis = dist(x,y)
        if dis == 0:
            pass
        else:
            if dis.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):
n,d = map(int,input().split())
x = [list(map(int,input().split())) for i in range(n)]
count = 0

import numpy as np
for i in range(n-1):
    for j in range(1,n):
        a = np.array(x[i])
        b = np.array(x[j])
        ab = sum(np.power((a-b),2))**0.5
        if ab%1 == 0:
            count += 1
print(count)

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

import numpy as np
for i in range(n-1):
    for j in range(i+1,n):
        a = np.array(x[i])
        b = np.array(x[j])
        ab = sum(np.power((a-b),2))**0.5
        if ab%1 == 0:
            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 = []
ans = 0
for _ in range(N):
    x = [int(s) for s in input().split()]
    X.append(x)
for i in range(N - 1):
    for j in range(i + 1, N):
        dist = 0
        for d in range(D):
            dist += (X[i][d] - X[j][d]) ** 2
        for n in range(500):
            if n * n == dist:
                ans += 1
                print(n, dist)
                break
print(ans)


from math import sqrt
N, D = map(int, input().split())
X = []
ans = 0
for _ in range(N):
    x = [int(s) for s in input().split()]
    X.append(x)
for i in range(N - 1):
    for j in range(i + 1, N):
        dist = 0
        for d in range(D):
            dist += (X[i][d] - X[j][d]) ** 2
        sqdist = round(sqrt(dist))
        if sqdist ** 2 == dist:
            ans += 1
print(ans)


Verdicts: Wrong Answer

Accepted
Problem: There are N points in a D-dimensional space.  The coordinates of the i-th point are (X_{i1}, X_{i2}, ..., X_{iD}).  The distance between two points with coordinates (y_1, y_2, ..., y_D) and (z_1, z_2, ..., z_D) is \sqrt{(y_1 - z_1)^2 + (y_2 - z_2)^2 + ... + (y_D - z_D)^2}.  How many pairs (i, j) (i < j) are there such that the distance between the i-th point and the j-th point is an integer?

Submission attempts (in order):
import math

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

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

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

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

import math

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

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

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: There are N points in a D-dimensional space.  The coordinates of the i-th point are (X_{i1}, X_{i2}, ..., X_{iD}).  The distance between two points with coordinates (y_1, y_2, ..., y_D) and (z_1, z_2, ..., z_D) is \sqrt{(y_1 - z_1)^2 + (y_2 - z_2)^2 + ... + (y_D - z_D)^2}.  How many pairs (i, j) (i < j) are there such that the distance between the i-th point and the j-th point is an integer?

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

import math

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):
    sq= 0
    for k in range(d):
      sq += (x[i][k]-x[j][k])**2
    if math.sqrt(sq).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):
r=input().split()
N=int(r[0])
D=int(r[1])
d=[[int(s) for s in input().split()] for i in range(N)]
ans=0
for i in range(N-1):
    for j in range(i+1,N):
        dis=0
        for k in range(D):
            dis+=(d[i][k]-d[j][k])**2
        ans_pre=dis**(int(1/2))
        if type(ans_pre)==int or ans_pre.is_integer()==True:
            ans+=1
print(ans)

r=input().split()
N=int(r[0])
D=int(r[1])
d=[[int(s) for s in input().split()] for i in range(N)]
ans=0
for i in range(N-1):
    for j in range(i+1,N):
        dis=0
        for k in range(D):
            dis+=(d[i][k]-d[j][k])**2
        ans_pre=dis**(1/2)
        if type(ans_pre)==int or ans_pre.is_integer()==True:
            ans+=1
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: There are N points in a D-dimensional space.  The coordinates of the i-th point are (X_{i1}, X_{i2}, ..., X_{iD}).  The distance between two points with coordinates (y_1, y_2, ..., y_D) and (z_1, z_2, ..., z_D) is \sqrt{(y_1 - z_1)^2 + (y_2 - z_2)^2 + ... + (y_D - z_D)^2}.  How many pairs (i, j) (i < j) are there such that the distance between the i-th point and the j-th point is an integer?

Submission attempts (in order):
import math

n, d = 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):
        dist = sum(map(lambda v1, v2: (v1 - v2) ** 2, x[i], x[j]))
        print(dist)
        if math.sqrt(dist) == int(math.sqrt(dist)):
            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):
        dist = sum(map(lambda v1, v2: (v1 - v2) ** 2, x[i], x[j]))
        if math.sqrt(dist) == int(math.sqrt(dist)):
            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 sys
import re
import numpy as np
from itertools import combinations
 
 
def answer(l):
    results = []
    for i, j in combinations(l, 2):
        v_a = np.array(i)
        v_b = np.array(j)
        results.append(np.linalg.norm(v_a - v_b))
    return sum(float.is_integer(i) for i in results)
 
rows = re.split('\n', sys.stdin.read())
args = [list(map(int, row.split(' '))) for row in rows][1:]
print(answer(args))

import sys
import numpy as np
from itertools import combinations

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

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

import sys
import re
import numpy as np
from itertools import combinations

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

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

import sys
import re
import numpy as np
from itertools import combinations


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

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


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

n, d = map(int, input().split())
coodinates = [[int(x) for x in input().split()] for _ in range(n)]
result = 0
for left in range(n-1):
    for right in range(left+1,n):
        dist = 0
        for i in range(d):
            dist += (coodinates[left][i] - coodinates[right][i])**2
        dist = dist ** 0.5
        result += 1 if dist.is_integer() else 0
print(result)

Verdicts: 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 math
dlst = []

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

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

lst=[1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256, 289, 324, 361, 400, 441, 484, 529, 576, 625, 676, 729, 784, 841, 900, 961, 1024, 1089, 1156, 1225, 1296, 1369, 1444, 1521, 1600, 1681, 1764, 1849, 1936, 2025, 2116, 2209, 2304, 2401, 2500, 2601, 2704, 2809, 2916, 3025, 3136, 3249, 3364, 3481, 3600, 3721, 3844, 3969]
count=0
distance = 0
checklst=[]

for i in range(N):
    for m in range(i+1,N):
        distance = 0
        for j in range(D):
            distance += (dlst[i][j] - dlst[m][j])**2
        judge=math.sqrt(distance)
        if judge.is_integer==True:
            count += 1
print(count)

dlst = []

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

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

lst=[0, 1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256, 289, 324, 361, 400, 441, 484, 529, 576, 625, 676, 729, 784, 841, 900, 961, 1024, 1089, 1156, 1225, 1296, 1369, 1444, 1521, 1600, 1681, 1764, 1849, 1936, 2025, 2116, 2209, 2304, 2401, 2500, 2601, 2704, 2809, 2916, 3025, 3136, 3249, 3364, 3481, 3600, 3721, 3844, 3969]
count=0
distance = 0
checklst=[]

for i in range(N):
    for m in range(N-1):     
        distance = 0
        for j in range(D):
            distance += (dlst[i][j] - dlst[m+1][j])**2
        if (m+1,i) not in checklst:                
            if distance in lst:
                count += 1
                checklst.append((i,m+1))
print(count)

import math
dlst = []

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

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

count=0
distance = 0

for i in range(N-1):
    for m in range(i+1,N):
        distance = 0
        for j in range(D):
            distance += (dlst[i][j] - dlst[m][j])**2
        judge=math.sqrt(distance)
        if judge.is_integer==True:
            count += 1
print(count)

import math
dlst = []

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

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

count=0
distance = 0

for i in range(N-1):
    for m in range(i+1,N):
        distance = 0
        for j in range(D):
            distance += (dlst[i][j] - dlst[m][j])**2
        judge=math.sqrt(distance)
        if judge.is_integer():
            count += 1
print(count)

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):
import itertools
import math

N, D = [int(x) for x in input().strip().split()]
if D == 1:
    print(int(N*(N-1)/2)
else:    
    points = []
    for data in range(N):
        points.append([int(x) for x in input().strip().split()])

    result = 0
    for p1,p2 in itertools.combinations(points, 2):
        distance = 0
        for y,z in zip(p1,p2):
            distance += (y - z) ** 2
        
        distance = math.sqrt(distance)
        if distance.is_integer(): result += 1    
    print(result)

import itertools
import math

N, D = [int(x) for x in input().strip().split()]
if D == 1:
    print(int(N*(N-1)/2))
else:
    points = []
    for data in range(N):
        points.append([int(x) for x in input().strip().split()])

    result = 0
    for p1,p2 in itertools.combinations(points, 2):
        distance = 0
        for y,z in zip(p1,p2):
            distance += (y - z) ** 2
        
        distance = math.sqrt(distance)
        if distance.is_integer(): result += 1    
    print(result)

Verdicts: Runtime Error

Accepted
Problem: There are N points in a D-dimensional space.  The coordinates of the i-th point are (X_{i1}, X_{i2}, ..., X_{iD}).  The distance between two points with coordinates (y_1, y_2, ..., y_D) and (z_1, z_2, ..., z_D) is \sqrt{(y_1 - z_1)^2 + (y_2 - z_2)^2 + ... + (y_D - z_D)^2}.  How many pairs (i, j) (i < j) are there such that the distance between the i-th point and the j-th point is an integer?

Submission attempts (in order):
from math import sqrt
n, d = map(int, input().split())
point = [[int(i) for i in input().split()] for j in range(n)]
count = 0
for i in range(n):
    for j in range(i + 1, n):
        norm = 0
        for pi, pj in zip(point[i], point[j]):
            norm += (pi - pj) ** 2
        if int(sqrt(norm)) == norm:
            count += 1

print(count)

n, d = map(int, input().split())
p = [list(map(int, input().split())) for i in range(n)]
cnt = 0
for i in range(n):
    for j in range(i + 1, n):
        dist = 0
        for k in range(d):
            dist += (p[i][k] - p[j][k])**2
        if int(dist**0.5) == dist**0.5:
            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=[list(map(int,input().split())) for _ in range(n)]
cnt=0
for i in range(n):
  for j in range(i+1,n):
    sum=0
    for k in range(n):
      sum+=(x[i][k]-x[j][k])**2
    z=pow(sum,0.5)
    if math.ceil(z)==math.floor(z):
      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):
  for j in range(i+1,n):
    sum=0
    for k in range(d):
      sum+=(x[i][k]-x[j][k])**2
    z=pow(sum,0.5)
    if math.ceil(z)==math.floor(z):
      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 numpy

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

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

print(lstMain)

count = 0
for i in range(0, N):
    for j in range(i+1, N):
        y = numpy.array(lstMain[i])
        z = numpy.array(lstMain[j])
        u = z - y
        distance = float(numpy.linalg.norm(u))
        if distance.is_integer():
            count += 1

print(count)

import numpy

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

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

count = 0
for i in range(0, N):
    for j in range(i+1, N):
        y = numpy.array(lstMain[i])
        z = numpy.array(lstMain[j])
        u = z - y
        distance = float(numpy.linalg.norm(u))
        if distance.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):
n,d = map(int,input().split())
count = 0

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

for i in range(d):
  n=0
  for j in range(d) if i < j:
    n += (x[i][j]-x[i+1][j])**2
  if  type(n**0.5) = int:
    count +=1

print(count)

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

for i in range(n-1):
    for j in range(i+1,n):
        d2=0
        for l in range(d):
            d2+=(x[i][l]-x[j][l])**2
        d2=int(d2)
        print(d2)
        for k in range(1,d2//2+2):
            if d2==k**2:
                ans+=1
                #print("{} {} {}".format("ok",d2,k**2))
                break
            else:
                #print("{} {} {}".format("not ok",d2,k**2))
                pass
print(ans)


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


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

                break

print(ans)


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


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

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

row = list()
count = 0
for i in range(N):
  x = [int(_) for _ in input().split()]
  if i == 0:
    row.append(x)
  else:
    for j in len(row):
      dist = 0
      for k in range(D):
        dist += (row[j][k]-x[k])^2
      if (dist**1/2) == int:
      	count += 1
    row.append(x)
      
print(count)

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

row = list()
count = 0
for i in range(N):
  x = [int(_) for _ in input().split()]
  if i == 0:
    row.append(x)
  else:
    for j in range(len(row)):
      dist = 0
      for k in range(D):
        dist += (row[j][k]-x[k])**2
      print((dist**0.5)-int(dist**0.5))
      if (dist**0.5)-int(dist**0.5)==0:
      	count += 1
    row.append(x)
      
print(count)

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

row = list()
count = 0
for i in range(N):
  x = [int(_) for _ in input().split()]
  if i == 0:
    row.append(x)
  else:
    for j in range(len(row)):
      dist = 0
      for k in range(D):
        dist += (row[j][k]-x[k])**2
      if (dist**0.5)-int(dist**0.5)==0:
      	count += 1
    row.append(x)
      
print(count)

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

kaijou = 0
cnt = 0

for i in n:
  for j in n:
    for k in d:
      kaijou += (x[j,k]**2-x[i,k]**2)
    if math.sqrt(kaioju).is_integer() == True:
      cnt += 1

print(cnt-n)
  


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

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

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


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

result=0
for v in itertools.combinations(e, 2):
    calc = sum(np.sqrt(abs((np.array(v[0]) - np.array(v[1])))^2))
    if isinstance(calc, int)==False:
        res=0
    else:
        res=1
    result=result+res

print("{}".format(result))

from itertools import combinations
import numpy as np


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

result=0
for i, j in combinations(vals, 2):
    a = np.array(i)
    b = np.array(j)
    dist = (abs(sum((a-b)**2)))**0.5
    if dist.is_integer():
        result+=1
    

print("{}".format(result))

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
from sys import stdin

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

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

print(ret,flush=True)

from sys import stdin

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

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

print(ret,flush=True)

import numpy as np
from sys import stdin

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

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

print(ret,flush=True)

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())
A=[]
C=0
D=0
E=0
for i in range (1,N+1):
    A.append(i)
for i in range (0,N):
    A[i]=list(map(int,input().split()))
for i in range (0,N-1):
    for j in range(i,N-1):
        for k in range(0,D):
            B=(A[j][k]-A[j+1][k])**2
            C+=B
        D=C
        C=0
        if ((D)**(1/2))%1 ==  (D)**(1/2):
            E+=1
print(E)









N,D = map(int,input().split())
A=[]
C=0
E=0
Z=0
for i in range (1,N+1):
    A.append(i)
for i in range (0,N):
    A[i]=list(map(int,input().split()))
for i in range (0,N-1):
    for j in range(i,N-1):
        for k in range(0,D):
            B=(A[i][k]-A[j+1][k])**2
            C+=B
        Z=C
        C=0
        if (Z**(1/2))%1==0:
            E+=1
print(E)

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
x =  [int(s) for s in input().split()]
numList = [[int(s) for s in input().split()] for i in range(x[0])]
sum = 0
for i in range(len(numList)):
    for j in range(i+1,len(numList)):
        d = 0
        for k in range(x[1]):
            d += (numList[i][k] - numList[i+1][k]) ** 2
            num = d ** 0.5
        numStr = str(num).split('.')
        if(numStr[len(numStr)-1] == '0'):
            sum += 1
            
print(sum)

import math
x =  [int(s) for s in input().split()]
numList = [[int(s) for s in input().split()] for i in range(x[0])]
sum = 0
for i in range(len(numList)):
    for j in range(i+1,len(numList)):
        d = 0
        for k in range(x[1]):
            d += (numList[i][k] - numList[j][k]) ** 2
        num = d ** 0.5
        numStr = str(num).split('.')
        print(d)
        if(numStr[len(numStr)-1] == '0'):
            sum += 1
            
print(sum)

# coding: utf-8
# Your code here!
import math
x =  [int(s) for s in input().split()]
numList = [[int(s) for s in input().split()] for i in range(x[0])]
sum = 0
for i in range(len(numList)):
    for j in range(i+1,len(numList)):
        d = 0
        for k in range(x[1]):
            d += (numList[i][k] - numList[j][k]) ** 2
        num = d ** 0.5
        numStr = str(num).split('.')
        if(numStr[len(numStr)-1] == '0'):
            sum += 1
            
print(sum)
        
            
            
            

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):
cnt = 0

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

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

import math

cnt = 0

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

for i in range(0, N - 1):
    for j in range(i + 1, N):
        sum = 0
        for k in range(0, D):
            sum += (X[i][k] - X[j][k])**2
        if math.sqrt(sum) == int(math.sqrt(sum)):
            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):
from math import sqrt
n,d = map(int, input().split())

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

def ds(a,b):
  s = 0
  for i in range(d):
    s += (b[i] - a[i])**2
  return sqrt(s)

ans = 0
for i in range(n):
  for j in range(i+1,n):
    d = ds(vs[i], vs[j])
    if d == int(d):
      ans += 1
      
print(ans)

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

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


def ds(a, b):
    s = 0
    for i in range(d):
        s += (b[i] - a[i])**2
    return sqrt(s)


ans = 0
for i in range(n):
    for j in range(i+1, n):
        dist = ds(vs[i], vs[j])
        if dist == int(dist):
            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):
from math import sqrt

N,D = [int(i) for i in input().split()]
XY_l = [[int(i) for i  in input().split()] for _ in range(N)]
ans = 0

for i in range(N):
  for j in range(N):
    if i <= j :
      continue
    S = 0
    for d in range(D):
      S = ((XY_l[i][d]) - (XY_l[j][d]))**2
    if sqrt(S).is_integer():
      ans+=1

print(ans)

from math import sqrt

N,D = [int(i) for i in input().split()]
XY_l = [[int(i) for i  in input().split()] for _ in range(N)]
ans = 0

for i in range(N):
  for j in range(N):
    if i <= j :
      continue
    S = float()
    for d in range(D):
      S += ((XY_l[i][d]) - (XY_l[j][d]))**2
    if sqrt(S).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 sys 
import numpy as np 

def distance():
    N,D=map(int,input().split())
    y=[]
    ans=0
    for i in range(N):
        x=list(map(int,input().split()))
        y.append(x)
    y=np.array(y)
    y.reshape(N,-1)
    for i in range(N-1):
        for j in range(i+1,N):
            dis=(((y[i]-y[j])**2).sum())**(1/2)
            if dis.is_integer():
                ans+=1
    
    print(ans)

import sys 
import numpy as np 

def distance():
    N,D=map(int,input().split())
    y=[]
    ans=0
    for i in range(N):
        x=list(map(int,input().split()))
        y.append(x)
    y=np.array(y)
    y.reshape(N,-1)
    for i in range(N-1):
        for j in range(i+1,N):
            dis=(((y[i]-y[j])**2).sum())**(1/2)
            if dis.is_integer():
                ans+=1
    
    print(ans)

distance()               


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

n,d=map(int,input().split())
l=[list(map(int,input().split())) for i in range(n)]
ans=0
cnt=0
for i in range(n-1):
    for j in range(i+1,n):
        siki=0
        for k in range(d):
            siki+=((l[i][k]-l[j][k])**2)
        han=siki**0.5
        if han%1 == 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):
n,d=map(int,input().split())
a=[]
ans=0
cnt=1

for i in range(n):
  b=list(map(int,input().split()))
  a.append(b)
for i in range(n-1):
  for j in range(i+1,n):
    dist=0
    for k in range(d):
      dist+=(a[i][k]-a[j][k])**2
    while cnt**2>dist:
      if cnt**2==dist:
        ans+=1
print(ans)

n,d=map(int,input().split())
a=[]
ans=0

for i in range(n):
  b=list(map(int,input().split()))
  a.append(b)
for i in range(n-1):
  for j in range(i+1,n):
    cnt=1
    dist=0
    for k in range(d):
      dist+=(a[i][k]-a[j][k])**2
      if cnt**2==dist:
        ans+=1
      cnt+=1
print(ans)

n,d=map(int,input().split())
a=[]
ans=0

for i in range(n):
  b=list(map(int,input().split()))
  a.append(b)
for i in range(n-1):
  for j in range(i+1,n):
    cnt=1
    dist=0
    for k in range(d):
      dist+=(a[i][k]-a[j][k])**2
    while cnt**2<=dist:
      if cnt**2==dist:
        ans+=1
      cnt+=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())
lst = []
for _ in range(n):
  x = list(map(int, input().split()))
ans = 0
for i in range(n-1):
  for j in range(i+1, n):
    dist = 0
    for k in range(d):
      dist += (lst[i][k] - lst[j][k])**2
    j = 1
    while j**2 <= dist:
      if j**2 == dist:
        ans += 1
        break
      j += 1
print(ans)

n, d = map(int, input().split())
lst = []
for _ in range(n):
  x = list(map(int, input().split()))
  lst.append(x)
ans = 0
for i in range(n-1):
  for j in range(i+1, n):
    dist = 0
    for k in range(d):
      dist += (lst[i][k] - lst[j][k])**2
    j = 1
    while j**2 <= dist:
      if j**2 == dist:
        ans += 1
        break
      j += 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):
def dist(a, b):
    res = 0
    for i in range(D):
        res += (a[i] - b[i])**2
    res = res ** 0.5
    return res

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

print(ans)

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

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

print(ans)

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


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

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

res = 0

for i in range(N):
  for j in range(N):
    if i != j:
      tmp = 0
      for k in range(D):
        tmp += (L[i][k] - L[j][k]) ** 2
        
      if tmp - int(tmp) == 0:
        res += 1
        
print(res)

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

res = 0

for i in range(N):
  for j in range(i, N):
    if i != j:
      tmp = 0
      for k in range(D):
        tmp += (L[i][k] - L[j][k]) ** 2
      
      import math
      tmp = math.sqrt(tmp)
      if tmp - int(tmp) == 0:
        res += 1
        
print(res)



Verdicts: Wrong Answer

Accepted