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

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

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

print(cnt)

import math

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

cnt = 0
for i in range(N - 1):
    for j in range(i + 1, N):
        dis = 0
        for d in range(D):
            dis += (X[i][d] - X[j][d])**2
        if math.sqrt(dis) == int(math.sqrt(dis)):
            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 as np
ND =  list(map(int,input().split()))
Lis = []
for i in range(ND[0]):
    a =list(map(int,input().split()))
    Lis.append(a)
Lisnp = np.array(Lis)
Count = 0
for k in range(ND[0]):
    for g in range(k):
        u = Lisnp[k] - Lisnp[i]
        norm = np.linalg.norm(u)
        if norm.is_integer():
            Count += 1
print(Count)

import numpy as np
ND =  list(map(int,input().split()))
Lis = []
for i in range(ND[0]):
    a =list(map(int,input().split()))
    Lis.append(a)
Lisnp = np.array(Lis)
Count = 0
for k in range(ND[0]):
    for g in range(k):
        u = Lisnp[k] - Lisnp[g]
        norm = np.linalg.norm(u)
        if norm.is_integer():
            Count += 1
print(Count)

Verdicts: Wrong Answer

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

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

result = 0
for i in range(n):
  for j in range(n-1):
    diff = map(lambda x,y: (x-y)*(x-y), x[i],x[j])
    calc = math.sqrt(sum(diff))
    if calc.is_integer():
      result +=1
print(result)

import math
n, d = map(int, input().split())
x = [[0 for i in range(d)] for j in range(n)]
for i in range(n):
  x[i] = map(int, input().split())
 
result = 0
for i in range(n):
  for j in range(1,n):
    diff = map(lambda x,y: (x-y)*(x-y), x[i],x[j])
    calc = math.sqrt(sum(diff))
    if calc.is_integer():
      result +=1
print(result)

import math
n, d = map(int, input().split())
x = [[0 for i in range(d)] for j in range(n)]
for i in range(n):
  x[i] = map(int, input().split())
 
result = 0
for i in range(n):
  for j in range(1,n):
    diff = map(lambda x: x*x, x[i]-x[j])
    calc = math.sqrt(sum(diff))
    if calc.is_integer():
      result +=1
print(result)


import math
n, d = map(int, input().split())
x = [[0 for i in range(d)] for j in range(n)]
for i in range(n):
  x[i] = list(map(int, input().split()))
result = 0
for i in range(0,n-1):
  for j in range(i+1,n):
    diff = list(map(lambda x,y: pow(x-y,2), x[i], x[j]))
    print(diff)
    calc = math.sqrt(sum(diff))
    if calc.is_integer():
      result +=1
print(result)

import math
n, d = map(int, input().split())
x = [[0 for i in range(d)] for j in range(n)]
for i in range(n):
  x[i] = list(map(int, input().split()))
result = 0
for i in range(0,n-1):
  for j in range(i+1,n):
    diff = list(map(lambda x,y: pow(x-y,2), x[i], x[j]))
    calc = math.sqrt(sum(diff))
    if calc.is_integer():
      result +=1
print(result)


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):
n,d=map(int,input().split())

l=[]
for _ in range(n):
  l1=[map(int,input().split())]
  l.append(l1)

import math

ans=[]
for a in range(n):
  for b in range(n):
    a=0
    for c in range(d):
      D=(l[a][c]-l[b][c])**2
      a+=D
    ans.append(isinstance(math.sqrt(a),int))
      
ans=sum(ans)-n
print(ans)

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

l=[]
for _ in range(n):
  l1=[map(int,input().split())]
  l.append(l1)

import math

ans=[]
for a in range(n):
  for b in range(n):
    a=0
    for c in range(d):
      D=(l[a][c]-l[b][c])**2
      a+=D
    ans.append(isinstance(math.sqrt(a),int))
      
ans=(ans.count(True)-n)//2
print(ans)

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

l=[]
for _ in range(n):
  l1=[map(int,input().split())]
  l.append(l1)

import math

ans=[]
for a in range(n):
  for b in range(n):
    x=0
    for c in range(d):
      D=(l[a][c]-l[b][c])**2
      x+=D
    y=math.sqrt(x)
    ans.append(isinstance(y,int))
      
ans=(ans.count(True)-n)//2
print(ans)

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

l=[]
for _ in range(n):
  l1=[map(int,input().split())]
  l.append(l1)

import math

ans=[]
for a in range(n):
  for b in range(n):
    x=0
    for c in range(d):
      D=(l[a][c]-l[b][c])**2
      x+=D
    y=math.sqrt(x)
    ans.append(y.is_integer())
      
ans=(ans.count(True)-n)//2
print(ans)

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

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

import math

ans=[]
for a in range(n):
  for b in range(n):
    x=0
    for c in range(d):
      D=(l[a][c]-l[b][c])**2
      x+=D
    y=math.sqrt(x)
    ans.append(y.is_integer())
      
ans=(ans.count(True)-n)//2
print(ans)

Verdicts: Runtime Error

Runtime Error

Runtime Error

Runtime Error

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

Submission attempts (in order):
n,d = map(int,input().split())
obj = [list(map(int,input().split())) for _ in range(n)]
ans = 0
for i in range(n):
    for j in range(n):
        if i == j:
            pass
        else:
            dis = 0
            for k in range(d):
                dis += (obj[i][k] - obj[j][k])**2
            dis = dis ** 0.5
            if dis == dis // 1:
                ans += 1

print(ans//2

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

print(ans//2)

Verdicts: Runtime Error

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

Submission attempts (in order):
N, D = 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(N):
        if i == j:
            continue
        else:
            tmp = 0
            for k in range(D):
                tmp += (x[i][k] - x[j][k]) ** 2
            dis = tmp ** 0.5
            print(dis)
            if dis.is_integer():
                ans += 1
print(int(ans / 2))

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(N):
        if i == j:
            continue
        else:
            tmp = 0
            for k in range(D):
                tmp += (x[i][k] - x[j][k]) ** 2
            dis = tmp ** 0.5
            if dis.is_integer():
                ans += 1
print(int(ans / 2))

Verdicts: Wrong Answer

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

Submission attempts (in order):
import numpy as np
n,d = map(int,input().split())
ans=0
g=[]
if d==1:
  ans=n*(n-1)//2
  print(ans)
else:
  for _ in range(n):
    for i in range(len(g)):
	    lis = np.array(list(map(int,input().split())))
    	u = g[i]-lis
        z=np.linalg.norm(u)
        if z-int(z)==0:
          ans+=1
    g.append(lis)
print(ans)
  

import numpy as np
n,d = map(int,input().split())
ans=0
g=[]
if d==1:
    for _ in range(n):
        lis = np.array(list(map(int,input().split())))
    ans=n*(n-1)//2
    print(ans)
else:
    for _ in range(n):
        lis = np.array(list(map(int,input().split())))
        for i in range(len(g)):
            u = g[i]-lis
            z=np.linalg.norm(u)
            if z==int(z):
                ans+=1
        g.append(lis)
    print(ans)

Verdicts: Runtime Error

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

Submission attempts (in order):
n,d=[int(x) for x in input().rstrip().split()]
 
l=[]
for i in range(n):
  X=[int(x) for x in input().rstrip().split()]
  l.append(X)
 
ans=0
for i in range(n):
  ni=l[i]
  for j in range(i+1,n):
    nj=l[j]
    now=0
    for s in range(d):
      now+=(ni[s]-nj[s])**2
    now=now**0.5

N,D=[int(x) for x in input().rstrip().split()]
 
l=[]
for i in range(N):
  X=[int(x) for x in input().rstrip().split()]
  l.append(X)
 
ans=0
for i in range(N):
  ni=l[i]
  for j in range(i+1,N):
    nj=l[j]
    now=0
    for s in range(D):
      now+=(ni[s]-nj[s])**2
    now=now**0.5

import math
 
def gooddistance(l1, l2):
    calc = []
    
    for i in range(len(l1)):
        calc.append((l1[i] - l2[i])**2)
 
    if math.sqrt(sum(calc)).is_integer():
        return 1
    else:
        return 0
 
 n, d = map(int, input().split())
lst = [list(map(int, input().split())) for _ in range(n)]
count = 0
 
for i in range(n):
    for j in range(i+1,n):
       count += gooddistance(lst[i],lst[j])
 
 print(count)

import numpy as np
N,D=map(int,input().split())
X=[np.array(input().split(),dtype=np.int64) for _ in range(N)]
ans=0
for i in range(N):
    for j in range(i+1,N):
        d=((X[i]-X[j])*(X[i]-X[j])).sum()
        dd=int(round(d**.5))
        if d==dd*dd:
            ans +=1
print(ans)

Verdicts: Wrong Answer

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())
L=[list(map(int,input().split())) for i in range(N)]
n=0
for i in range(N):
  for j in range(i):
    for k in range(D):
      DD=0
      DD+=(L[i][k]-L[j][k])**2
    if any(n**2==DD for n in range(1,80)):
      n+=1
print(n)

N,D=map(int,input().split())
L=[list(map(int,input().split())) for i in range(N)]
n=0
for i in range(N):
  for j in range(i):
    DD=0
    for k in range(D):
      DD+=(L[i][k]-L[j][k])**2
    if any(n**2==DD for n in range(1,128)):
      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 = [int(i) for i in input().split()]
for i in range(N):
    lagd.append([int(i) for i in input().split()])
lngs = D - 1
def kyoricac(daone,datwo,d):
    keka = []
    n = 0
    wa = 0
    while n <= d:
        wa = (daone[n] - datwo[n])**2
        keka += [wa]
        n += 1
    wa = sum(keka)
    kaesi = float(wa ** (1/2))
    return kaesi
ans = 0
fst = 1
for i in range(N):
    for n in range(fst,N):
        flag = float(kyoricac(lagd[i],lagd[n],lngs))
        if flag.is_integer() == True:
            ans += 1
    fst += 1
print(ans)

N,D = [int(i) for i in input().split()]
lagd = []
for i in range(N):
    lagd.append([int(i) for i in input().split()])
lngs = D - 1
def kyoricac(daone,datwo,d):
    keka = []
    n = 0
    wa = 0
    while n <= d:
        wa = (daone[n] - datwo[n])**2
        keka += [wa]
        n += 1
    wa = sum(keka)
    kaesi = float(wa ** (1/2))
    return kaesi
ans = 0
fst = 1
for i in range(N):
    for n in range(fst,N):
        flag = float(kyoricac(lagd[i],lagd[n],lngs))
        if flag.is_integer() == True:
            ans += 1
    fst += 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):

url = "https://atcoder.jp//contests/abc133/tasks/abc133_b"
import itertools
def main():
    n,d = list(map(int, input().split()))
    lis = []
    for i in range(n):
        t = list(map(int, input().split()))
        lis.append(t)
    count = 0
    for i in range(len(lis)):
        for j in range(i+1, len(lis)):
            if i == j:
                continue
            if float.is_integer(ret(lis[i], lis[i+1])):
                count += 1
    print(count)


import math
def ret(a,b):
    retval = 0
    idx = 0
    while True:
        if idx == len(a):
            break
        retval += abs(a[idx]-b[idx])**2
        idx += 1
    return math.sqrt(retval)

if __name__ == '__main__':
    main()



url = "https://atcoder.jp//contests/abc133/tasks/abc133_b"
import itertools
def main():
    n,d = list(map(int, input().split()))
    lis = []
    for i in range(n):
        t = list(map(int, input().split()))
        lis.append(t)
    count = 0
    for i in range(len(lis)):
        for j in range(i+1, len(lis)):
            if i == j:
                continue
            if float.is_integer(ret(lis[i], lis[j])):
                count += 1
    print(count)


import math
def ret(a,b):
    retval = 0
    idx = 0
    while True:
        if idx == len(a):
            break
        retval += abs(a[idx]-b[idx])**2
        idx += 1
    return math.sqrt(retval)

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):
N, D = map(int, input().split())
x = [None for k in range(N)]
for k in range(N):
  a = list(map(int, input().split()))
  x[k] = a
ans = 0
for n in range(N):
  for p in range(n-1):
    wa = 0
    for d in range(D):
      wa += (x[n][d] - x[p][d])**2
    t = wa ** 0.5
    if type(t) is int:
      ans += 1
print(ans)

N, D = map(int, input().split())
x = [None for k in range(N)]
for k in range(N):
  a = list(map(int, input().split()))
  x[k] = a
ans = 0
for n in range(N):
  for p in range(n):
    wa = 0
    for d in range(D):
      wa += (x[n][d] - x[p][d])**2
    t = wa ** 0.5
    if wa == int(t) **2:
      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 numpy as np
n,d = list(map(int,input().split()))
t = np.array([list(map(int,input().split())) for i in range(n)])
cnt = 0

for i in range(n):
	for h in range(n):
		x = (sum((t[i]-t[h])**2))**0.5
		if x % 1 == 0:
			cnt += 1
	np.delete(t,i,0)
			
print(int(cnt-n))

import numpy as np
n,d = list(map(int,input().split()))
t = np.array([list(map(int,input().split())) for i in range(n)])
cnt = 0

for i in range(n):
	for h in range(n):
		x = (sum((t[i]-t[h])**2))**0.5
		if x % 1 == 0:
			cnt += 1
			
print(int((cnt-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):
import numpy as np

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

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

def distance(p1, p2):
  squares = np.square(np.arange(p1) - np.arange(p2))
  return np.sqrt(squares.sum())

count = 0
for i in range(N):
  for j in range(N):
    if i != j:
      dist = distance(points[i], points[j])
      count += dist.is_integer() * 1

print(count)


import numpy as np

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

points = np.array([list(map(int, input().split())) for _ in range(N)])

def distance(p1, p2):
  squares = np.square(p1 - p2)
  return np.sqrt(squares.sum())

count = 0
for i in range(N):
  for j in range(i+1, N):
    dist = distance(points[i], points[j])
    count += dist.is_integer() * 1

print(count)

Verdicts: Runtime Error

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

Submission attempts (in order):
import numpy as np
N,D=map(int,input().split())
X=[]
dist=[]
Xsumnow=0
Xsumnext=0

for i in range(N):
    X.append([int(j) for j in input().split()])
count=N
for m in range(N):
    for j in range(m+1,N):
        for k in range(D):
            Xsumnow+=abs(X[j][k]-X[m][k])*abs(X[j][k]-X[m][k])
        dist.append(np.sqrt(Xsumnow))
        Xsumnow=0
TrueCounter=0
for l in range(len(dist)):
    if dist[l].is_integer:
        TrueCounter+=1
print(TrueCounter)

import numpy as np
N,D=map(int,input().split())
X=[]
dist=[]
Xsumnow=0
Xsumnext=0

for i in range(N):
    X.append([int(j) for j in input().split()])
count=N
for m in range(N):
    for j in range(m+1,N):
        for k in range(D):
            Xsumnow+=abs(X[j][k]-X[m][k])*abs(X[j][k]-X[m][k])
        dist.append(np.sqrt(Xsumnow))
        Xsumnow=0
TrueCounter=0
for l in range(len(dist)):
    if dist[l].is_integer():
        TrueCounter+=1

print(TrueCounter)

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,math
input = sys.stdin.readline

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

print(X)

for i in range(1,N):
  for j in range(1,D):
      #num += pow(abs(X[i-1][j-1] - X[i][j]) ,2)
      print(X[i-1][j-1],X[i][j])
  #if int(math.sqrt(num)):
    #print(math.sqrt(num))
    #cnt += 1

#print(cnt)

import sys,math
input = sys.stdin.readline

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

print(X)

for i in range(1,N):
  for j in range(1,D):
      num += pow(abs(X[i-1][j-1] - X[i][j]) ,2)
      print(X[i-1][j-1],X[i][j])
  if int(math.sqrt(num)):
    print(math.sqrt(num))
    ans += 1

print(ans)

import sys,math
input = sys.stdin.readline

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

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

print(cnt)

import sys,math
input = sys.stdin.readline

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(N):
    num = 0
    if i < j:
      for k in range(D):
        num += pow(abs(X[i][k] - X[j][k]) ,2)
      if math.floor(math.sqrt(num)) ** 2 == num:
        cnt += 1

print(cnt)

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

n, d = map(int, input().split())
L = [list(map(int, input().split())) for i in range(n)]
ans = 0
for i in range(n-1):
    for j in range(i+1, n):
        
        int_ = 0
        for k in range(d):
            int_ += (L[i][k]-L[j][k])**2
        if int(int_**0.5)==int_**0.5:
            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 numpy as np

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

ans = 0
for i in range(D):
    for j in range(i + 1, D):
        if np.is_integer(np.sqrt(np.sum(X[i] - X[j]) ** 2)):
            ans += 1
print(ans)


import numpy as np

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

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


Verdicts: Runtime Error

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

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

def helper(a, b):
  s = 0
  for i in range(n):
    s += (a[i] - b[i]) ** 2
  a = int(0.5 + (s ** 0.5))
  if a * a == s:
    return 1
  return 0

ans = 0
for i in range(n):
	for j in range(i + 1, n):
		ans += helper(points[i], points[j])
print(ans)

n, d = map(int, input().split())
points = [[]] * n
for i in range(n):
  points[i] = list(map(int, input().split()))
 
def helper(a, b):
  s = 0
  for i in range(d):
    s += (a[i] - b[i]) ** 2
  a = int(0.5 + (s ** 0.5))
  if a * a == s:
    return 1
  return 0
 
ans = 0
for i in range(n):
    for j in range(i + 1, n):
        ans += helper(points[i], points[j])
print(ans)

Verdicts: Runtime Error

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

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

import math

n, d = map(int, input().split())
x = [list(map(int, input().split())) for i in range(n)]
cnt = 0
for i in range(n):
  for j in range(i+1, n):
    a = x[i]
    b = x[j]
    z = 0
    for k in range(d):
      z += (a[k] - b[k]) ** 2
    if math.sqrt(z) % 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 numpy as np
N, D =map(int, input().split())

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

import numpy as np
N, D =map(int, input().split())

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

Verdicts: Wrong Answer

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

Submission attempts (in order):
import math

def colcu (bli,ali,D):
    num = 0
    for i in range(D):
        num += (bli[i] - ali[i]) ** 2
    return math.sqrt(num)

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

an = 0
for i in range(N-1):
 for t in range(i+1,N):
     if colcu(pli[i],pli[t],D).is_integer():
         an += 1
     print(colcu(pli[i],pli[t],D))
print(an)

import math

def colcu (bli,ali,D):
    num = 0
    for i in range(D):
        num += (bli[i] - ali[i]) ** 2
    return math.sqrt(num)

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

an = 0
for i in range(N-1):
 for t in range(i+1,N):
     if colcu(pli[i],pli[t],D).is_integer():
         an += 1
print(an)

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

import math

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

import math

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

import math

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

Verdicts: Runtime Error

Wrong Answer

Wrong Answer

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

Submission attempts (in order):
import numpy as np
from scipy.special import comb
n,d=map(int,input().split())
x=[]
total=0
for i in range(n):
    x.append(list(map(int,input().split())))
for i in range(n):
    for j in range(n):
        if i!=j:
            a=np.array(x[i])
            b=np.array(x[j])
            u=b-a
            print(np.linalg.norm(u))
            if np.linalg.norm(u)==int(np.linalg.norm(u)):
                total+=1
print(total/2)

import numpy as np
from scipy.special import comb
n,d=map(int,input().split())
x=[]
total=0
for i in range(n):
    x.append(list(map(int,input().split())))
for i in range(n):
    for j in range(n):
        if i!=j:
            a=np.array(x[i])
            b=np.array(x[j])
            u=b-a
            if np.linalg.norm(u)==int(np.linalg.norm(u)):
                total+=1
print(int(total/2))

Verdicts: Wrong Answer

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

Submission attempts (in order):
import math
n, a = map(int, input().split())

vc = []

def isqrt(n):
    x = n
    y = (x + 1) // 2
    while y < x:
        x = y
        y = (x + n // x) // 2
    return x

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

cc = 0
for k, i in enumerate(vc):
    if len(vc) < 2:
        break
    print(k)
    for v in vc[k+1:]:
        summ = 0
        for (x, y) in zip(i, v):
            summ += abs(x - y) ** 2


        if isqrt(summ) == math.sqrt(summ):
            print("OK")
            cc += 1


print(cc)

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

vc = []

def isqrt(n):
    x = n
    y = (x + 1) // 2
    while y < x:
        x = y
        y = (x + n // x) // 2
    return x

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

cc = 0
for k, i in enumerate(vc):
    if len(vc) < 2:
        break
    for v in vc[k+1:]:
        summ = 0
        for (x, y) in zip(i, v):
            summ += abs(x - y) ** 2


        if isqrt(summ) == math.sqrt(summ):
            cc += 1


print(cc)

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(list(map(int,input().split())))

cnt=0

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

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

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

cnt=0

for i in range(n-1):
  for j in range(i+1,n):
    s=0
    for k in range(d):
      s+=(x[i][k]-x[j][k])**2
    if int(math.sqrt(s))**2==s:
      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 i in range(n)]
cnt=0
dis=0
if d==1:
    print(n*(n-1)//2)
else:
    for i in range(n-1):
        for j in range(i+1,n):
            distance=0
            dis=0
            for k in range(d):
                dis+=(x[i][k]-x[j][k])**2
            distance=math.sqrt(dis)   
            print(distance) 
            if distance.is_integer()==True:
                cnt+=1
    print(cnt)

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

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

Verdicts: Wrong Answer

Wrong Answer

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

Submission attempts (in order):
N, _ = (int(i) for i in input().split())
data = [int(int(i) for i in input().split()) for i in range(N)]

import numpy as np
from scipy.spatial import distance

distance = distance.cdist(data, data, metric='euclidean')
count = 0
for n in range(0,N):
  for d in range(n+1,N):
    if distance[n][d].is_integer() and distance[n][d] != 0 :
      count+=1
print(count)

N, _ = (int(i) for i in input().split())
data = [[int(i) for i in input().split()] for i in range(N)]

import numpy as np
from scipy.spatial import distance

distance = distance.cdist(data, data, metric='euclidean')
count = 0
for n in range(0,N):
  for d in range(n+1,N):
    if distance[n][d].is_integer() and distance[n][d] != 0 :
      count+=1
print(count)

Verdicts: Runtime Error

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

Submission attempts (in order):
import numpy as np
import math
N ,D =  map(int  , input().split(" "))

x = np.array(input().split(" ") , dtype="int32")
ans = 0
for i in range(N-1):
    x = np.append(x, np.array(input().split(" ") , dtype="int32"))
print(x)
x = x.reshape(N , D)
print(x)
for i in range(N):
    for n in range(i+1 , N):
        dist = np.linalg.norm(x[i] - x[n])
        if math.ceil(dist)==math.floor(dist):
            ans += 1
print(ans)

import numpy as np
import math
N ,D =  map(int  , input().split(" "))

x = np.array(input().split(" ") , dtype="int32")
ans = 0
for i in range(N-1):
    x = np.append(x, np.array(input().split(" ") , dtype="int32"))
x = x.reshape(N , D)
for i in range(N):
    for n in range(i+1 , N):
        dist = np.linalg.norm(x[i] - x[n])
        if math.ceil(dist)==math.floor(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=input().split()
n=int(n)
d=int(d)
def combinations(n, r):
    return math.factorial(n)/(math.factorial(n-r)*math.factorial(r))
x=[]
for i in range(n):
    xa=[int(s) for s in input().split()]
    x.append(xa)
    a=[]
for i in range(n-1):
for j in range(i+1,n):
    t=[]
    for k in range(d):
        c=(x[i][k]-x[j][k])*(x[i][k]-x[j][k])
        t.append(c)
    if k==d-1:
        a.append(sum(t))
answer=list(map(lambda x:pow(x,1/2),a))
count=0
for l in range(n):
    if answer[l].is_integer()==True:
        count=count+1
print(count)

import math
n,d=input().split()
n=int(n)
d=int(d)
def combinations(n, r):
    return math.factorial(n)/(math.factorial(n-r)*math.factorial(r))
x=[]
if d==1:
  count=combinations(n,2)
  count = int(count)
else:
  for i in range(n):
    xa=[int(s) for s in input().split()]
    x.append(xa)
  a=[]
  for i in range(n-1):
    for j in range(i+1,n):
      t=[]
      for k in range(d):
        c=(x[i][k]-x[j][k])*(x[i][k]-x[j][k])
        t.append(c)
        if k==d-1:
          a.append(sum(t))
  answer=list(map(lambda x:pow(x,1/2),a))
  count=0
  for l in range(n):
    if answer[l].is_integer()==True:
      count=count+1
      print(count)
print(count)

import math
n,d=input().split()
n=int(n)
d=int(d)
def combinations(n, r):
    return math.factorial(n)/(math.factorial(n-r)*math.factorial(r))
x=[]
if d==1:
  count=combinations(n,2)
  int(count)
else:
  for i in range(n):
    xa=[int(s) for s in input().split()]
    x.append(xa)
  a=[]
  for i in range(n-1):
    for j in range(i+1,n):
      t=[]
      for k in range(d):
        c=(x[i][k]-x[j][k])*(x[i][k]-x[j][k])
        t.append(c)
        if k==d-1:
          a.append(sum(t))
  answer=list(map(lambda x:pow(x,1/2),a))
  count=0
  for l in range(n):
    if answer[l].is_integer()==True:
      count=count+1
      print(count)
print(count)

import math
n,d=input().split()
n=int(n)
d=int(d)
def combinations(n, r):
    return math.factorial(n)/(math.factorial(n-r)*math.factorial(r))
x=[]
for i in range(n):
    xa=[int(s) for s in input().split()]
    x.append(xa)
    a=[]
for i in range(n-1):
    for j in range(i+1,n):
        t=[]
        for k in range(d):
            c=(x[i][k]-x[j][k])*(x[i][k]-x[j][k])
            t.append(c)
        if k==d-1:
            a.append(sum(t))
answer=list(map(lambda x:pow(x,1/2),a))
count=0
for l in range(len(answer)):
    if answer[l].is_integer()==True:
        count=count+1
print(count)

Verdicts: Runtime Error

Runtime Error

Runtime Error

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

Submission attempts (in order):
N, D = map(int,input().split())
li = []
for _ in range(N):
    li.append(list(map(int,input().split())))

s = 0
c = 0
for n in range(-1,N-1):
    for d in range(D):
        s = s + abs(li[n][d] - li[n+1][d]) ** 2
    if (s**(1/2)).is_interger():
        c += 1
    s = 0

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

s = 0
c = 0
for n1 in range(-1,N-1):
    for n2 in range(n1+1,N-1):
        for d in range(D):
            s = s + abs(li[n1][d] - li[n2][d]) ** 2
        s_float = float(s**(1/2))
        if s_float.is_integer():
            c += 1
        s = 0
print(c)


Verdicts: Runtime Error

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

Submission attempts (in order):
N,D=map(int,input().split())
for i in range(N):
  X[i]=list(map(int,input().split()))
count=0
for i in range(N):
  for j in range(i,N):
    dis=0
    for k in range(D):
      dis += pow(X[i][k],2) + pow(X[j][k],2) 
    dis = sqrt(dis)
    if dis==int(dis):
      count+=1
print(count)

import math
N,D=map(int,input().split())
X=[0]*N
for i in range(N):
  X[i]=list(map(int,input().split()))
count=0
for i in range(N):
  for j in range(i,N):
    dis=0
    for k in range(D):
      dis += pow(X[i][k]-X[j][k],2) 
    dis = math.sqrt(dis)

    if dis==int(dis) and dis!=0:
      count+=1
print(count)

Verdicts: Runtime Error

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

Submission attempts (in order):
import math
z=[]
ans=0
sumsum=0
N,D=(int(x) for x in input().split())
for i in range(N):
    a=input().split()
    print(a)
    z.append(a)
#print(z)

for i in range(N):
    for j in range(i,N):
        for k in range(D):
            sumsum=sumsum+(int(z[i][k])-int(z[j][k]))**2
        if sumsum!=0 and math.sqrt(sumsum)%1==0:
            ans=ans+1
        sumsum=0

print(ans)


import math
z=[]
ans=0
sumsum=0
N,D=(int(x) for x in input().split())
for i in range(N):
    a=input().split()
    #print(a)
    z.append(a)
#print(z)

for i in range(N):
    for j in range(i,N):
        for k in range(D):
            sumsum=sumsum+(int(z[i][k])-int(z[j][k]))**2
        if sumsum!=0 and math.sqrt(sumsum)%1==0:
            ans=ans+1
        sumsum=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 numpy as np


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

for i in range(n-1):
    for j in range(n-i,n,1):
        a=np.array(X[i])
        b=np.array(X[i+1])
        u=b-a
        if u==int(u):
            cnn+=1
print(cnn)

import numpy as np


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

for i in range(n-1):
    for j in range(n-i,n,1):
        a=np.array(X[i])
        b=np.array(X[i+1])
        u=b-a
        u=np.linalg.norm(u)
        if(int(u)==u):
            cnt+=1
print(cnt)


import numpy as np


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


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

        
print(cnt)


Verdicts: Runtime Error

Wrong Answer

Accepted