import java.io.InputStreamReader
import java.lang.Math.pow

fun main(args: Array<String>) {
    problem(InputStreamReader(System.`in`).useLines { block ->
        block.takeWhile {
            it.isNotEmpty()
        }.toList()
    })
}

fun problem(lines: List<String>) {
    val data: List<List<Int>> = lines.subList(1, lines.size).map { it.split(" ").map { it.toInt() } }
    var count = 0
    for (point1Index in 0 until data.size) {
        for (point2Index in (point1Index + 1) until data.size) {
            val point1 = data[point1Index]
            val point2 = data[point2Index]
//            println(point1 + ""+ point2)
            val sums = point2.mapIndexed { index, value ->
                pow(value.toDouble() - point1[index], 2.0)
            }.sum()
            val distance = Math.sqrt(
                sums
            )
            if ((distance == Math.floor(distance)) && !distance.isInfinite()) {
                count++
            }
        }
    }
    println(count)
}



