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

N, D= map(int,input().split())
arr = [list(map(int,input().split())) for _ in range(N)]
count=0
for i in range(N):
    for j in range(i+1,N):
        tmp = 0
        for k in range(D):
            if i != j:
                tmp += (arr[i][k]-arr[j][k])**2
        tmp = tmp**0.5
        if tmp == int(tmp):
            count = count+1
print(count)

Verdicts: Runtime Error

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

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

import math
N,D=map(int,input().split())
X=[]
cnt=0
def distance(x,y):
    d2=[]
    for k in range(D):
        d2.append((X[x][k]-X[y][k])**2)
    return math.sqrt(sum(d2))
for i in range(N):
    X.append(list(map(int,input().split())))
for j in range(N-1):
        for l in range(j+1,N,):
            if float.is_integer(distance(j,l)):
                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):
b

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




def dst(i, j):
    a = pnt[i]
    b = pnt[j]
    ret = 0
    for p, q in zip(a, b):
        ret += (p - q) ** 2
    r = ((ret ** (0.5)))

    return r


ans = 0
for i in range(n):
    for j in range(i + 1, n):
        tmp = dst(i, j)
        if tmp == int(tmp):
            ans = 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())
Xlist = []

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

ans = 0
tmp = 0

for i in range(n-1):
    for j in range(i+1, n):
        for k in range(d):
            tmp += (Xlist[i][k] - Xlist[j][k]) ** 2
        a = int(tmp ** 0.5) ** 2
        print(a)
        print(tmp)

        if a == tmp:
            ans += 1
        tmp = 0

print(ans)

n, d = map(int, input().split())
Xlist = []

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

ans = 0
tmp = 0

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

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):
# -*- coding: utf-8 -*-
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.0
        for k in range(d):
            tmp += pow((x[i][k] - x[j][k]), 2)

        tmp = math.sqrt(tmp)
        print(tmp)
        cnt += tmp.is_integer()

print(cnt)


# -*- coding: utf-8 -*-
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.0
        for k in range(d):
            tmp += pow((x[i][k] - x[j][k]), 2)

        tmp = math.sqrt(tmp)
        cnt += tmp.is_integer()

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 sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readlines
from math import sqrt

def isSquare(n):
    m = int(sqrt(n))
    for x in range(m-2, m+2):
        if x**2 == n:
            return True

def getDistance(xi, xj, dimention):
    d = 0
    for i in range(dimention):
        d += (xi[i] - xj[i])**2
    return d

def main():
    lines = input()

    n, d = list(map(int, lines[0].split()))
    x = []
    for i, xi in enumerate(lines[1:]):
        x.append(list(map(int, xi.split())))

    cnt = 0

    for i, xi in enumerate(x):
        for j, xj in enumerate(x[i+1:]):
            dist = getDistance(xi, xj, d)
            if isSquare(dist):
                print(dist)
                cnt += 1
    print(cnt)

main()

import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readlines
from math import sqrt

def isSquare(n):
    m = int(sqrt(n))
    for x in range(m-2, m+2):
        if x**2 == n:
            return True

def getDistance(xi, xj, dimention):
    d = 0
    for i in range(dimention):
        d += (xi[i] - xj[i])**2
    return d

def main():
    lines = input()

    n, d = list(map(int, lines[0].split()))
    x = []
    for i, xi in enumerate(lines[1:]):
        x.append(list(map(int, xi.split())))

    cnt = 0

    for i, xi in enumerate(x):
        for j, xj in enumerate(x[i+1:]):
            dist = getDistance(xi, xj, d)
            if isSquare(dist):
                cnt += 1
    print(cnt)

main()

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

n,d = map(int,input().split())
x = [0]*n
for i in range(n):
    x[i] = list(map(int,input().split()))
count = 0
for i in range(n):
    for j in range(n):
        dis2 = 0
        for k in range(d):
            dis2 += (x[i][k]-x[j][k])**2
        dis = float((dis2)**0.5)
        if dis.is_integer() == True:
            count += 1
print(int((count-n)/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(range(n))
for i in range(n):
  x[i] = list(map(int, input().split()))

a = []
for i in range(200):
  a.append(i**2)

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

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

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

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

a = []
for i in range(200):
  a.append(i**2)

ans = 0
for i in range(n-1):
  for j in range(i+1, n):
    dis = 0
    for k in range(d):
      dis = dis + (x[i][k]-x[j][k])**2
    if dis in a:
      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())
import numpy as np
xlist = [list(map(int,input().split())) for i in range(n)]
xarray = np.array(xlist)
ans = 0
for i in range(n):
  for j in range(i+1,n+1):
    if (xarray[i]-xarray[j])%1!=0:
      ans+=1
print(ans)

N,D = map(int,input().split())
import numpy as np
xlist = [list(map(int,input().split())) for i in range(n)]
xarray = np.array(xlist)
ans = 0
for i in range(n):
  for j in range(i+1,n+1):
    if np.linalg.norm(xarray[i]-xarray[j])%1!=0:
      ans+=1
print(ans)

N,D = map(int,input().split())
import numpy as np
xlist = [list(map(int,input().split())) for i in range(n)]
xarray = np.array(xlist)
ans = 0
for i in range(n):
  for j in range(i+1,n):
    if np.linalg.norm(xarray[i]-xarray[j])%1!=0:
      ans+=1
print(ans)

N,D = map(int,input().split())
import numpy as np
xlist = [list(map(int,input().split())) for i in range(n)]
xarray = np.array(xlist)
ans = 0
for i in range(n):
  for j in range(i+1,n):
    if np.linalg.norm(xarray[i]-xarray[j])==int(np.linalg.norm(xarray[i]-xarray[j])):
      ans+=1
print(ans)

n,d = map(int,input().split())
import numpy as np
xlist = [list(map(int,input().split())) for i in range(n)]
xarray = np.array(xlist)
ans = 0
for i in range(n):
  for j in range(i+1,n):
    if np.linalg.norm(xarray[i]-xarray[j])%1!=0:
      ans+=1
print(ans)

n,d = map(int,input().split())
import numpy as np
xlist = [list(map(int,input().split())) for i in range(n)]
xarray = np.array(xlist)
ans = 0
for i in range(n):
  for j in range(i+1,n):
    if np.linalg.norm(xarray[i]-xarray[j]).is_integer():
      ans+=1
print(ans)

Verdicts: Runtime Error

Runtime Error

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 math
from collections import deque


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

points = []

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


def distance(x, y):
    dd = 0
    for xy in zip(x,y):
        dd += (xy[0] - xy[1])**2
    return math.sqrt(dd)

q = deque(points)

result = 0
while len(q) != 0:
    left = q.popleft()
    for right in q:
        d = distance(left, right)
        print(d)
        if d.is_integer():
            result += 1
        else:
            pass

print(result)

import math
from collections import deque


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

points = []

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


def distance(x, y):
    dd = 0
    for xy in zip(x,y):
        dd += (xy[0] - xy[1])**2
    return math.sqrt(dd)

q = deque(points)

result = 0
while len(q) != 0:
    left = q.popleft()
    for right in q:
        d = distance(left, right)
        if d.is_integer():
            result += 1
        else:
            pass

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

n,d=map(int,input().split())
l=[[] for i in range(n)]
for i in range(n):
  l[i]=list(map(int,input().split()))
ans=0
for i in range(n-1):
  for j in range(i+1,n):
    c=0
    for h in range(d):
      c+=(l[i][h]-l[j][h])**2
    if (int(c**(1/2)))**2==c:
      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,m = map(int,input().split())
x = [list(map(int,input().split())) for _ in range(n)]
cnt,tmp = 0,0
for i in range(n-1):
	for j in range(i+1,n):
		tmp = 0
		for M in range(m):
			tmp += (x[i][M] - x[j][M])**2
			#print(tmp)
			if math.sqrt(tmp).is_integer():
				cnt += 1
print(cnt)

import math
n,m = map(int,input().split())
x = [list(map(int,input().split())) for _ in range(n)]
cnt,tmp = 0,0
for i in range(n-1):
	for j in range(i+1,n):
		tmp = 0
		for M in range(m):
			tmp += (x[i][M] - x[j][M])**2
			#print(tmp)
		if math.sqrt(tmp).is_integer():
			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())
X = [[int(i) for i in input().split()] for _ in range(N)]
count = 0
for i in range(N):
  for j in range(i + 1, N):
    res = sum([(X[i][k] - X[j][k])**2 for k in range(D)])
    if (res**0.5).is_integer:
      count += 1
print(count)

N, D = map(int, input().split())
X = [[int(i) for i in input().split()] for _ in range(N)]
count = 0
for i in range(N):
  for j in range(i + 1, N):
    res = sum([(X[i][k] - X[j][k])**2 for k in range(D)])
    if (res**0.5) % 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):
import math
N, D = map(int, input().split())
a = []
for i in range(N):
  b = map(int, input().split())
  a += b
print(a)
res = 0
for i in range(N-1):
  j = i + 1
  while(j < N):
    x = []
    y = []
    for k in range(D):
      x.append(a[i * D + k])
      y.append(a[j * D + k])
    tmp = 0
    for k in range(D):
      tmp += (x[k] - y[k]) ** 2
    if tmp == int(tmp ** 0.5) * int(tmp ** 0.5):
      res += 1
    j += 1
print(res)
      


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


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

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

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


Verdicts: Wrong Answer

Wrong Answer

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,m = [int(i) for i in input().split()]
table = [[int(i) for i in input().split()] for n in range(n)]

count = 0

for i in range(n):
    for j in range(i+1,n,1):
        distance = 0
        total = 0
        for k in range(m):
            total += (table[i][k] - table[j][k]) ** 2
            print(i,j,k,total)
        distance = math.sqrt(total)
        print(distance)
        if distance.is_integer() == True:
            count += 1

print(count)


import math

n,m = [int(i) for i in input().split()]
table = [[int(i) for i in input().split()] for n in range(n)]

count = 0

for i in range(n):
    for j in range(i+1,n,1):
        distance = 0
        total = 0
        for k in range(m):
            total += (table[i][k] - table[j][k]) ** 2
            print(i,j,k,total)
        distance = math.sqrt(total)
        print(distance)
        if distance.is_integer() == True:
            count += 1

print(count)


import math

n,m = [int(i) for i in input().split()]
table = [[int(i) for i in input().split()] for n in range(n)]

count = 0

for i in range(n):
    for j in range(i+1,n,1):
        distance = 0
        total = 0
        for k in range(m):
            total += (table[i][k] - table[j][k]) ** 2
            print(i,j,k,total)
        distance = math.sqrt(total)
        print(distance)
        if distance.is_integer() == True:
            count += 1

print(count)


import math

n,m = [int(i) for i in input().split()]
table = [[int(i) for i in input().split()] for n in range(n)]

count = 0

for i in range(n):
    for j in range(i+1,n,1):
        distance = 0
        total = 0
        for k in range(m):
            total += (table[i][k] - table[j][k]) ** 2
        distance = math.sqrt(total)
        if distance.is_integer() == True:
            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 numpy as np

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

p = np.zeros(n,d)

for i in range(n):
  p[i] = np.array(list(map(int, input().split())))

cnt = 0
d = 0
for i in range(n):
  for j in range(i+1,n):
    d = np.sqrt((p[i] - p[j]) ** 2)
    if d % 1 == 0:
      cnt += 1

print(cnt)


import numpy as np
 
n, d = map(int, input().split())
 
p = np.zeros((n,d))
 
for i in range(n):
  p[i] = np.array(list(map(int, input().split())))
cnt = 0
d = 0
for i in range(n):
  for j in range(i+1,n):
    d = np.sqrt(np.sum((p[i] - p[j]) ** 2))
    if d % 1 == 0:
      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

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

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

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

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

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

import math

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

Verdicts: Wrong Answer

Runtime Error

Runtime Error

Runtime Error

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

Submission attempts (in order):
import math
N, D = map(int, input().split())
X = [list(map(int, input().split())) for x in range(N)]
X.append(X[0])

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

print(cnt)

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

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

print(cnt)

Verdicts: Wrong Answer

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

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

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

cnt = 0

for i in range(N-1):
  for j in range(i+1,N):
    dist2 = 0
    for index in range(D):
      dist2 += (X[i][index] - X[j][index]) ** 2
    dist = math.sqrt(dist2)
    if dist == float(int(dist)):
      cnt += 1

print(cnt)

import math
N, D = map(int, input().split())
X = []

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

cnt = 0

for i in range(N-1):
  for j in range(i+1,N):
    dist2 = 0
    for index in range(D):
      dist2 += (X[i][index] - X[j][index]) ** 2
    dist = math.sqrt(dist2)
    if dist == float(int(dist)):
      cnt += 1

print(cnt)

Verdicts: Runtime Error

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

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

def is_integer_num(n):
    if isinstance(n, int):
        return True
    if isinstance(n, float):
        return n.is_integer()
    return False

final_ans=0

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

for i in range(0,N-1,1):
    for j in range(i+1,N,1):
        res = 0
        for k in range(0,D,1):
            res = res + (X[i][k] - X[j][k]) ** 2
        res = res ** 0.5
        print(res)
        if is_integer_num(res):
            final_ans = final_ans+1
print(final_ans)


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

def is_integer_num(n):
    if isinstance(n, int):
        return True
    if isinstance(n, float):
        return n.is_integer()
    return False

final_ans=0

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

for i in range(0,N-1,1):
    for j in range(i+1,N,1):
        res = 0
        for k in range(0,D,1):
            res = res + (X[i][k] - X[j][k]) ** 2
        res = res ** 0.5
        if is_integer_num(res):
            final_ans = final_ans+1
print(final_ans)


Verdicts: Wrong Answer

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

Submission attempts (in order):
n, d = map(int, input().split())
X = []
for _ in range(n):
    X.append([int(x) for x in input().split()])
ans = 0
for i in range(n - 1):
  for j in range(i + 1, n):
    s = sum((X[i][d] - X[j][d])**2 for d in range(d))
      if (s ** .5).is_integer():
        ans += 1
print(ans)


n, d = map(int, input().split())
X = []
for _ in range(n):
    X.append([int(x) for x in input().split()])
ans = 0
for i in range(n):
  for j in range(i):
    s = sum((X[i][k] - X[j][k])**2 for k in range(d))
    if (s ** .5).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
import numpy as np
N, D = map(int, input().split())
times = int(input())  
n = [list(map(int, input().split())) for i in range(times)]
n = np.array(n)
for j in range(n.shape[0]):
  for i in range(n.shape[0]):
    length = np.linalg.norm(n[i]-n[j])
    aaa = math.modf(length)[0]
    if aaa < 0.00001:
      ans +=1
ans = ans - n.shape[0]
ans = int(ans/2)
print(ans)

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

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

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

Verdicts: Runtime Error

Runtime Error

Runtime Error

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

Submission attempts (in order):
def distance(a_lst, b_lst):
    n = len(a_lst)
    tmp_distance = 0

    for i in range(n):
        a = a_lst[i]
        b = b_lst[i]

        tmp_distance += (a - b) ** 2

    distance = (tmp_distance) ** (1/2)
    return distance


def main():
    n, d = map(int, input().split())
    x_lst = [0] * n
    count = 0

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

    for i in range(n-1):
        a_lst = x_lst[i]

        for j in range(i+1, n):
            b_lst = x_lst[j]

            if distance(a_lst, b_lst) == int(distance(a_lst, b_lst)):
                count += 1

    print(count)

def distance(a_lst, b_lst):
    n = len(a_lst)
    tmp_distance = 0

    for i in range(n):
        a = a_lst[i]
        b = b_lst[i]

        tmp_distance += (a - b) ** 2

    distance = (tmp_distance) ** (1/2)
    return distance


def main():
    n, d = map(int, input().split())
    x_lst = [0] * n
    count = 0

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

    for i in range(n-1):
        a_lst = x_lst[i]

        for j in range(i+1, n):
            b_lst = x_lst[j]

            if distance(a_lst, b_lst) == int(distance(a_lst, b_lst)):
                count += 1

    print(count)


if __name__ == '__main__':
    main()

Verdicts: Wrong Answer

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

Submission attempts (in order):

import numpy as np

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

for i in range(N):
  for j in range(i+1,N):
    d = 0
    sum = 0
    for k in range(D):
      sum += (X[i][k] - X[j][k])**2
    d = np.sqrt(sum)
    if d // 1 == d:
      print("{} {}".format(i+1,j+1))
    


import numpy as np

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



Verdicts: Wrong Answer

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

Submission attempts (in order):
import math
x,y = map(int,input().split())
li = []
while True:
	try:
		li.append(list(map(int,input().split())))
	except:
		break
score = 0
for a in li:
	for b in li:
		num = 0
		for c in a:
			for d in b:
				num += abs(c - d) ** 2
		num = num / 2
		t = math.sqrt(num) - round(math.sqrt(num))
		if t == 0:
			score += 1
print(score)

import numpy as np

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

li = np.array(li)
count = 0

for i in range(n-1):
    for j in range(i+1,n):
         x = np.linalg.norm(li[i]-li[j])
         if float.is_integer(x):
             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):
# -*- coding: utf-8 -*-
import math


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

ans = 0
tmp_targ = 0

for k in range(n):
    list_x[k] = list(map(int, input().split()))

print(list_x)

for l in range(n-1):
    for m in range(l+1,n):
        tmp_targ = 0
        for i1 in range(d):
            tmp_targ += (list_x[l][i1] - list_x[m][i1]) ** 2
        print("targ:{},sqrt:{}".format(tmp_targ,math.sqrt(tmp_targ)))
        if isinstance(math.sqrt(tmp_targ), int) or math.sqrt(tmp_targ).is_integer():
            ans += 1

print(ans)

# -*- coding: utf-8 -*-
import math


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

ans = 0
tmp_targ = 0

for k in range(n):
    list_x[k] = list(map(int, input().split()))

# print(list_x)

for l in range(n-1):
    for m in range(l+1,n):
        tmp_targ = 0
        for i1 in range(d):
            tmp_targ += (list_x[l][i1] - list_x[m][i1]) ** 2
        # print("targ:{},sqrt:{}".format(tmp_targ,math.sqrt(tmp_targ)))
        if isinstance(math.sqrt(tmp_targ), int) or math.sqrt(tmp_targ).is_integer():
            ans += 1

print(ans)

Verdicts: Wrong Answer

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

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

cnt = 0

def distance(x, y):
  ans = 0
  for dd in range(d):
    ans += abs(x[dd] - y[dd]) ** 2
  return math.sqrt(ans)


for i in range(n):
  for j in range(i+1, n):
    if distance(points[i], points[j]):
      cnt += 1

print(cnt)


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

cnt = 0

def distance(x, y):
  ans = 0
  for dd in range(d):
    ans += abs(x[dd] - y[dd]) ** 2
  return math.sqrt(ans)


for i in range(n):
  for j in range(i+1, n):
    if distance(points[i], points[j]).is_integer():
      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())

A=[[int(a) for a in input().split()]for a in range(N)]

def int_test(a,n):
    if a.is_integer():
        n+=1

n=0


for i in range(0,N):

    if i != N:
        for j in range(i+1,N):
            sq=0.0
            for k in range(0,D):
                sq=sq+(A[i][k]-A[j][k])**2

            sq2=math.sqrt(sq)
            print(i,j,k,sq2)
            if sq2.is_integer():
                n+=1
        #else:
    #        for k in range(1,D+1):
        #        sq=sq+(A[N][k]-A[N][k])**2
        #        sq2=math.sqrt(sq)
    #            int_test(sq2,n)
print(n)


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

A=[[int(a) for a in input().split()]for a in range(N)]

def int_test(a,n):
    if a.is_integer():
        n+=1

n=0


for i in range(0,N):

    if i != N:
        for j in range(i+1,N):
            sq=0.0
            for k in range(0,D):
                sq=sq+(A[i][k]-A[j][k])**2

            sq2=math.sqrt(sq)
            #print(i,j,k,sq2)
            if sq2.is_integer():
                n+=1

print(n)


Verdicts: Wrong Answer

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

Submission attempts (in order):
N, D = map(int,input().split())
K = [list(map(int,input().split()))for x in range(N)]
ans = 0
for i in range(N-1):
  for j in range(i+1,N):
    goukei=0
    for a,b in zip(K[i],K[j]):
      goukei += (a-b)**2
    ans += (goukei**0.5).is_integer()
print(K)

N, D = map(int,input().split())
K = [list(map(int,input().split()))for x in range(N)]
ans = 0
for i in range(N-1):
  for j in range(i+1,N):
    goukei=0
    for a,b in zip(K[i],K[j]):
      goukei += (a-b)**2
    ans += (goukei**0.5).is_integer()
print(ans)

Verdicts: Wrong Answer

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

Submission attempts (in order):

N, D = map(int, input().split())
Ps = []
count = 0

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

def dis2(A, B):
  dis = 0
  for i in range(D):
    dis += (A[i] - B[i])**2
  return dis

for i in range(N-1):
  for j in range(i+1, N):
    if math.sqrt(dis2(Ps[i], Ps[j])).is_integer():
      count += 1

print(count)

import math

N, D = map(int, input().split())
Ps = []
count = 0

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

def dis2(A, B):
  dis = 0
  for i in range(D):
    dis += (A[i] - B[i])**2
  return dis

for i in range(N-1):
  for j in range(i+1, N):
    if math.sqrt(dis2(Ps[i], Ps[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):
N,D = map(int, input().split())

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

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


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

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

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

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

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

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, readline().rstrip().split())
m=[]
for _ in range(n):
    arr=list(map(int, readline().rstrip().split()))
    m.append(arr)
ans=0
for i in range(n-1):
    for j in range(i+1,n):
        a = 0
        for k in range(d):
            a += (m[i][k] - m[j][k])**2
        x = int(a**(1/2))
        if x*2 == a:
            ans+=1
print(ans)
        
        

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

n,d=map(int, input().rstrip().split())
m=[]
for _ in range(n):
    arr=list(map(int, input().rstrip().split()))
    m.append(arr)
ans=0
for i in range(n-1):
    for j in range(i+1,n):
        a = 0
        for k in range(d):
            a += (m[i][k] - m[j][k])**2
        x = int(a**(1/2))
        if x**2 == a:
            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 = (int(i) for i in input().split())
num = list((list(map(int, input().split())) for j in rage(n)))
sum = 0
cnt = 0
for k in range(n - 1) :
  for h in range(d) :
    sum += (num[k][h] - num[k + 1][n])**2
  if (isinstance(sum **(1 / 2)), int) :
    cnt += 1
  sum = 0
print(sum)

n, d = (int(i) for i in input().split())
num = list((list(map(int, input().split())) for j in range(n)))
sum = 0
cnt = 0
for k in range(n - 1) :
  for t in range(k + 1, n) :
    for h in range(d) :
      sum += (num[k][h] - num[t][h])**2
    work = sum**(1 / 2)
    temp = work * 10
    temp = temp % 10
    if temp == 0 :
      cnt += 1
    sum = 0
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):
print(5.0 == 5)

import math
import itertools
N, D = map(int, input().split())

nums = []
for _ in range(N):
    nums.append(list(map(int, input().split())))

com = itertools.combinations(nums, 2)
ans =0
for c in com: 
    d = 0
    for y, z in zip(c[0], c[1]):
        d += abs(y - z) ** 2
    d = math.sqrt(d)
    ans += 1 if d == int(d) else 0

print(ans)



Verdicts: Wrong Answer

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

Submission attempts (in order):
import math
import itertools


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


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


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

print(count)


import math
import itertools


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


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


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

print(count)


Verdicts: Runtime Error

Accepted