#C3268. Is Sum of Primes Prime?

    ID: 46676 Type: Default 1000ms 256MiB

Is Sum of Primes Prime?

Is Sum of Primes Prime?

Given a positive integer \(N\), your task is to generate all prime numbers less than or equal to \(N\) and compute their sum. Let \(S\) be the sum of all these primes. You need to determine if \(S\) is a prime number. If \(S\) is prime, print "Yes"; otherwise, print "No".

Recall that a prime number is a positive integer greater than 1 that has no positive divisors other than 1 and itself.

Example:

  • Input: 10; Primes: 2, 3, 5, 7; Sum: 17 which is prime; Output: Yes
  • Input: 20; Primes: 2, 3, 5, 7, 11, 13, 17, 19; Sum: 77 which is not prime; Output: No

Note: Use the \(O(N \log \log N)\) Sieve of Eratosthenes algorithm for efficiently generating primes when needed.

inputFormat

The input consists of a single integer \(N\) (\(1 \leq N \leq 10^6\)), read from standard input.

outputFormat

Output a single string "Yes" if the sum of all primes less than or equal to \(N\) is prime, otherwise output "No". The output should be printed to standard output.

## sample
10
Yes