Problem:
Score: 300 points

Problem Statement

Find the minimum prime number greater than or equal to X.

Notes

A prime number is an integer greater than 1 that cannot be evenly divided by any positive integer except 1 and itself.

For example, 2, 3, and 5 are prime numbers, while 4 and 6 are not.

Constraints

2 \le X \le 10^5

All values in input are integers.

Input

Input is given from Standard Input in the following format:

X

Output

Print the minimum prime number greater than or equal to X.

Sample Input 1

20

Sample Output 1

23

The minimum prime number greater than or equal to 20 is 23.

Sample Input 2

2

Sample Output 2

2

X itself can be a prime number.

Sample Input 3

99992

Sample Output 3

100003

Solution in C++14 (GCC 5.4.1) (judge verdict: Accepted)

#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define ld long double
#define F first
#define S second
#define P pair<int,int>
#define V vector
#define pb push_back
#define mp make_pair
#define endl "\n"
#define db(...) __f(#__VA_ARGS__, __VA_ARGS__)
#define MOD 1000000007  //1e9+7

template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << '\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}

const int N=1000000;
int p[N+1]={0};

void PrimeSieve()
{
    p[0]=0;
    p[1]=0;
    p[2]=1;
    for(int i=3;i<=N;i+=2)
    {
        p[i]=1;
    }
    for(int i=3;i*i<=N;i+=2)
    {
        if(p[i])
        {
            for(int j=i*i;j<=N;j=j+2*i)
            {
                p[j]=0;
            }
        }
    }
    return;
}

void solve()
{
	int a; cin>>a;
	for(int i=a;i<=N;i++){
		if(p[i]){
			cout<<i<<endl;
			return;
		}
	}
}
	
int32_t main()
{
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    //int t; cin>>t;
    //while(t--)
    PrimeSieve();
    solve();
    return 0;
}