fun main(arr:Array) { val dic = mutableMapOf() val himo = readLine()!!.toInt() for (i in (1..himo)) { if(i*2*4>himo) { break } dic[i*i] = i } var ans = 0 val flag = mutableMapOf>() for(i in dic.keys) { for(j in dic.keys.filter { it < i }.sortedDescending()) { val key = i - j if(key > j) { break } if(!dic.containsKey(key)) { continue } if(flag.containsKey(dic[i]!!) && flag[dic[i]!!]!!.containsKey(dic[j]!!)) { continue } val requireHimo = (dic[i]!! + dic[j]!! + dic[key]!!) * 4 if(requireHimo > himo) { continue } ans++ for (k in (1..himo)) { val keyI = dic[i]!!*k val keyJ = dic[j]!!*k val keyKey = dic[key]!!*k if(!flag.containsKey(keyI)) { flag[keyI] = mutableMapOf() } if(requireHimo * k > himo) { break } flag[keyI]!![keyJ] = true } } } println(ans) }