~/algor $ cat problems/baxtli-sonmi
Happy number?
Medium
1000 ms
64 MB
47%
A positive integer $n$ is given. We replace it with the sum of the squares of its digits and repeat this. If $1$ appears in the process, $n$ is called a happy number. If $4$ appears, the number will never reach $1$ (the following numbers cycle). Print YES if $n$ is happy, otherwise NO.
Input
One positive integer $n$.
Output
YES or NO.
Note
$1 \le n \le 10^{9}$
Examples
Input #1
19
Output #1
YES
Input #2
2
Output #2
NO