import scala.io.StdIn.readLong import scala.math._ def sqrtLong(n: Long): Long = if (n == 0 || n == 1) return n var x0 = n / 2 var x1 = (x0 + n / x0) / 2 while (x1 < x0) x0 = x1 x1 = (x0 + n / x0) / 2 x0 @main def yuki648(): Unit = val n = 2 * readLong val k = sqrtLong(n) if n == k * (k + 1) then println("YES") println(k) else println("NO")