#C2759. Happy Number Check

    ID: 46110 Type: Default 1000ms 256MiB

Happy Number Check

Happy Number Check

You are given a positive integer n. A happy number is defined by the following process: starting with any positive integer, replace the number with the sum of the squares of its digits, and repeat the process until the number equals 1 (where it will stay) or it loops endlessly in a cycle which does not include 1. If it ends in 1, the number is considered happy; otherwise, it is not.

Your task is to determine whether the given integer is a happy number. For instance, when n = 19, the process eventually reaches 1, so 19 is a happy number.

All formulas used in this problem are expressed in LaTeX. For example, the sum of the squares of the digits of a number n is computed as \(\sum_{i=1}^{k} d_i^2\), where \(d_i\) are the digits of \(n\).

inputFormat

The input consists of a single positive integer n provided via standard input (stdin).

outputFormat

Output "YES" if n is a happy number, otherwise output "NO". The answer should be printed to standard output (stdout).

## sample
19
YES