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


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


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

# -*- coding: utf-8 -*-
import sys
import re
import numpy as np
from itertools import combinations


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

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


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


# -*- coding: utf-8 -*-
import sys
import re
import numpy as np
from itertools import combinations


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

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


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


# -*- coding: utf-8 -*-
import sys
import re
import numpy as np
from itertools import combinations


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

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


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


# -*- coding: utf-8 -*-
import sys
import re
import numpy as np
from itertools import combinations


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

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


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


# -*- coding: utf-8 -*-
import sys
import re
import numpy as np
from itertools import combinations


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

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


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


# -*- coding: utf-8 -*-
import sys
import re
import numpy as np
from itertools import combinations


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

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


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


# -*- coding: utf-8 -*-
import numpy as np
from itertools import combinations


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


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


Verdicts: Wrong Answer

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Accepted