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=list(map(int,input().split()))
a=['X' for _ in range(int(N[0]))]
A=0
for i in range(int(N[0])):
    a[i]=list(map(int,input().split()))
    for t in range(int(i)):
        Y=[(a[i][s]-a[t][s])**2 for s in range(int(N[1]))]
        Z=sum(Y)
        if (math.sqrt(Z)-int(math.sqrt(Z)))==0:
            A+=1
            print(Z,math.sqrt(Z))
print(A)

import math
N=list(map(int,input().split()))
a=['X' for _ in range(int(N[0]))]
A=0
for i in range(int(N[0])):
    a[i]=list(map(int,input().split()))
    for t in range(int(i)):
        if i!=t:
            for s in range(int(N[1])):
                Y=[(a[i][s]-a[t][s])**2]
                Z=sum(Y)
                if (math.sqrt(Z))- int(math.sqrt(Z))==0:
                    A+=1
        else:
            continue
print(A)

import math
N=list(map(int,input().split()))
a=['X' for _ in range(int(N[0]))]
A=0
for i in range(int(N[0])):
    a[i]=list(map(int,input().split()))
    for t in range(int(i)):
        if i!=t:
            Y=[]
            for s in range(int(N[1])):
                Y+=[(a[i][s]-a[t][s])**2]
            Z=sum(Y)
            print(Z)
            if (math.sqrt(Z))- int(math.sqrt(Z))==0:
                A+=1
        else:
            continue
print(A)

import math
N=list(map(int,input().split()))
a=['X' for _ in range(int(N[0]))]
A=0
for i in range(int(N[0])):
    a[i]=list(map(int,input().split()))
    for t in range(int(i)):
        if i!=t:
            for s in range(int(N[1])):
                Y=[(a[i][s]-a[t][s])**2]
                Z=sum(Y)
                if (math.sqrt(Z))- int(math.sqrt(Z))==0:
                    A+=1
        else continue
print(A)

import math
N=list(map(int,input().split()))
a=['X' for _ in range(int(N[0]))]
A=0
for i in range(int(N[0])):
    a[i]=list(map(int,input().split()))
    for t in range(int(i)):
        for s in range(int(N[1])):
            Y=[(a[i][s]-a[t][s])**2]
            Z=sum(Y)
            if (math.sqrt(Z))- int(math.sqrt(Z))==0:
                A+=1
print(A)

import math
N=list(map(int,input().split()))
a=['X' for _ in range(int(N[0]))]
A=0
for i in range(int(N[0])):
    a[i]=list(map(int,input().split()))
    for t in range(int(i)):
        Y=[(a[i][s]-a[t][s])**2 for s in range(int(N[1]))]
        Z=sum(Y)
        if (math.sqrt(Z)) == int(math.sqrt(Z)):
            A+=1
            print(Z,math.sqrt(Z))
print(A)

import math
N=list(map(int,input().split()))
a=['X' for _ in range(int(N[0]))]
A=0
for i in range(int(N[0])):
    a[i]=list(map(int,input().split()))
    for t in range(int(i)):
        if i!=t:
            for s in range(int(N[1])):
                Y=[(a[i][s]-a[t][s])**2]
                Z=sum(Y)
                if (math.sqrt(Z))- int(math.sqrt(Z))==0:
                    A+=1
print(A)

import math
N=list(map(int,input().split()))
a=['X' for _ in range(int(N[0]))]
A=0
for i in range(int(N[0])):
    a[i]=list(map(int,input().split()))
    for t in range(int(i)):
        if i!=t:
            Y=[]
            for s in range(int(N[1])):
                Y+=[(a[i][s]-a[t][s])**2]
            Z=sum(Y)
            if (math.sqrt(Z))- int(math.sqrt(Z))==0:
                A+=1
        else:
            continue
print(A)

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Runtime Error

Wrong Answer

Wrong Answer

Wrong Answer

Accepted