Buggy python submission (verdict: Runtime Error):
N, D = [int(_) for _ in input().split()]
X = []
for i in range(D):
    X.append([int(_) for _ in input().split()])

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

from math import sqrt

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

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

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

from math import sqrt

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

Buggy python submission (verdict: Runtime Error):
N, D = [int(_) for _ in input().split()]
X = []
for i in range(D):
    X.append([int(_) for _ in input().split()])

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

from math import sqrt
# import numpy

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

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

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

from math import sqrt

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

Buggy python submission (verdict: Runtime Error):
N, D = [int(_) for _ in input().split()]
X = []
for i in range(D):
    X.append([int(_) for _ in input().split()])

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

import math
import numpy

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

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

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

from math import sqrt

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

Buggy python submission (verdict: Runtime Error):
N, D = [int(_) for _ in input().split()]
X = []
for i in range(D):
    X.append([int(_) for _ in input().split()])

import math

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

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

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

from math import sqrt

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