fun main(args: Array<String>) {
    val n = readLine()?.split(" ")?.get(0)?.toInt() ?: 0
    val x = Array(n) {
        it to (readLine()?.split(" ")?.map(String::toInt) ?: listOf())
    }.toList()
    println(
        x.map { xi ->
            x.filter { xi.first < it.first }
                .map {
                    getDist(xi.second, it.second)
                }
        }.flatten()
            .count {
                it.toInt().toDouble() == it
            }
    )
}

fun getDist(a: List<Int>, b: List<Int>): Double {
    val pairs = a.zip(b)
    return Math.sqrt(
        pairs.fold(0) { r, t ->
            val tmp = (t.first - t.second)
            r + tmp * tmp
        }.toDouble()
    )
}