stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#include<cstdio>

#include<iostream>

#include<algorithm>

#include<cmath>

#include<cstring>

#include<string>

#include<cstdlib>

#include<ctime>

#include<stack>

#include<queue>

#include<set>

#include<map>

#include<vector>

#define mem(name,value) memset(name,value,sizeof(name))

#define loop(i,from,to) for(int i=from;i<to;i++)

#define loopr(i,from,to) for(int i=from;i>=to;i--)

#define pb push_back

using namespace std;

typedef long long ll;

typedef unsigned long long ull;

typedef pair<int,int> P;

const int INF=0x3f3f3f3f;



const int maxn=1000000+5;

int pr[maxn];

bool is_pr[maxn];



int sieve(int n){

    int p=0;

    loop(i,0,n+1) is_pr[i]=true;

    is_pr[0]=is_pr[1]=false;

    loop(i,2,n+1){

        if(is_pr[i]){

            pr[p++]=i;

            for(int j=2*i;j<=n;j+=i)

                is_pr[j]=false;

        }

    }

    return p;

}



int main()

{

    int n;

    while(cin>>n)

        cout<<sieve(n)<<endl;

}

// Faster C++ solution for the same problem (measured speedup: 5.204802772201241x):
#include<cstdio>

using namespace std;

#define MAX_N 999999+10

int prime[MAX_N];

bool is_prime[MAX_N+1];



int sieve(int n){

    int p=0;

    for(int i=0;i<=n;i++)is_prime[i]=true;

    is_prime[0]=is_prime[1]=false;

    for(int i=2;i<=n;i++){

        if(is_prime[i]){

            prime[p++]=i;

            for(int j=2*i;j<=n;j+=i)is_prime[j]=false;

        }

    }

    return p;

}



int main(){

    int n;

    while(~scanf("%d",&n)){

        printf("%d\n",sieve(n));

    }

}
// Slower C++ solution:
//Author- Simanta Deb Turja

//Team- AUST_HoyeJabe



#include<bits/stdc++.h>

#define pi acos(-1)



typedef unsigned long long ull;

typedef unsigned long ul;

typedef long long ll;

//typedef push_back pb;





using namespace std;



int SieveOfEratosthenes(int n)

{



    bool prime[n+1];

    ull count = 0;

    memset(prime, true, sizeof(prime));



    for (int p=2; p*p<=n; p++)

    {



        if (prime[p] == true)

        {



            for (int i=p*2; i<=n; i += p)

                prime[i] = false;

        }

    }





    for (int p=2; p<=n; p++)

       if (prime[p])

          count++;

 return count;

}



int main()

{

    int n;

    while(cin>>n){

        cout<<SieveOfEratosthenes(n)<<endl;

    }





    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.206915797182599x):
#include<cstdio>

using namespace std;

#define MAX_N 999999+10

int prime[MAX_N];

bool is_prime[MAX_N+1];



int sieve(int n){

    int p=0;

    for(int i=0;i<=n;i++)is_prime[i]=true;

    is_prime[0]=is_prime[1]=false;

    for(int i=2;i<=n;i++){

        if(is_prime[i]){

            prime[p++]=i;

            for(int j=2*i;j<=n;j+=i)is_prime[j]=false;

        }

    }

    return p;

}



int main(){

    int n;

    while(~scanf("%d",&n)){

        printf("%d\n",sieve(n));

    }

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;



const int maxn = 1e6 + 15;

bool is_prime[maxn];

int sieve(int x){

	int res = 0;

	fill(is_prime+2,is_prime+x+1,true);

	for(int i = 2; i <= x; i++) if(is_prime[i]){

		res++;

		for(int j = 2 * i; j <= x; j += i) is_prime[j] = false;

	}

	return res;

}



int main(){

	int n;

	while(scanf("%d", &n) == 1) printf("%d\n", sieve(n));

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.184058036324306x):
#include<cstdio>

using namespace std;

#define MAX_N 999999+10

int prime[MAX_N];

bool is_prime[MAX_N+1];



int sieve(int n){

    int p=0;

    for(int i=0;i<=n;i++)is_prime[i]=true;

    is_prime[0]=is_prime[1]=false;

    for(int i=2;i<=n;i++){

        if(is_prime[i]){

            prime[p++]=i;

            for(int j=2*i;j<=n;j+=i)is_prime[j]=false;

        }

    }

    return p;

}



int main(){

    int n;

    while(~scanf("%d",&n)){

        printf("%d\n",sieve(n));

    }

}
// Slower C++ solution:


#include <bits/stdc++.h>

using namespace std;



void Sieve(int n)

{

	bool prime[n+1];

	int c=0;

	memset(prime, true, sizeof(prime));



	for (int p=2; p<=n; p++)

	{

		if (prime[p] == true)

		{

			for (int i=p*2; i<=n; i += p)

				prime[i] = false;

		}

	}

	for (int p=2; p<=n; p++)

	if (prime[p])

		c++;

		cout<<c<<endl;

}



int main()

{

	int n;

	while(cin>>n){

        Sieve(n);

	}



	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.209937392132071x):
#include<cstdio>

using namespace std;

#define MAX_N 999999+10

int prime[MAX_N];

bool is_prime[MAX_N+1];



int sieve(int n){

    int p=0;

    for(int i=0;i<=n;i++)is_prime[i]=true;

    is_prime[0]=is_prime[1]=false;

    for(int i=2;i<=n;i++){

        if(is_prime[i]){

            prime[p++]=i;

            for(int j=2*i;j<=n;j+=i)is_prime[j]=false;

        }

    }

    return p;

}



int main(){

    int n;

    while(~scanf("%d",&n)){

        printf("%d\n",sieve(n));

    }

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;



void Sieve(int n)

{

	bool prime[n+1];

	int c=0;

	memset(prime, true, sizeof(prime));

	int x=sqrt(n*1.0)+2;



	for (int p=2; p<=x; p++)

	{

		if (prime[p] == true)

		{

			for (int i=p*p; i<=n; i+=p)

				{

				    prime[i] = false;

				}



		}

	}

	for (int p=2; p<=n; p++)

	if (prime[p])

		c++;

		cout<<c<<endl;

}



int main()

{

	int n;

	while(cin>>n){

        Sieve(n);

	}



	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.248429531852101x):
#include<cstdio>

using namespace std;

#define MAX_N 999999+10

int prime[MAX_N];

bool is_prime[MAX_N+1];



int sieve(int n){

    int p=0;

    for(int i=0;i<=n;i++)is_prime[i]=true;

    is_prime[0]=is_prime[1]=false;

    for(int i=2;i<=n;i++){

        if(is_prime[i]){

            prime[p++]=i;

            for(int j=2*i;j<=n;j+=i)is_prime[j]=false;

        }

    }

    return p;

}



int main(){

    int n;

    while(~scanf("%d",&n)){

        printf("%d\n",sieve(n));

    }

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;



void SieveOfEratosthenes(int n)

{

    int c = 0;

    bool prime[n+1];

    memset(prime, true, sizeof(prime));



    for (int p=2; p*p<=n; p++)

    {

        if (prime[p] == true)

        {

            for (int i=p*2; i<=n; i += p)

                prime[i] = false;

        }

    }



    for (int p=2; p<=n; p++)

       if (prime[p]){

            c++;

       }



       cout<<c<<endl;



}



// Driver Program to test above function

int main()

{

    int n;

    while(cin>>n)

    {

        SieveOfEratosthenes(n);

    }



    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.207845210747642x):
#include<cstdio>

using namespace std;

#define MAX_N 999999+10

int prime[MAX_N];

bool is_prime[MAX_N+1];



int sieve(int n){

    int p=0;

    for(int i=0;i<=n;i++)is_prime[i]=true;

    is_prime[0]=is_prime[1]=false;

    for(int i=2;i<=n;i++){

        if(is_prime[i]){

            prime[p++]=i;

            for(int j=2*i;j<=n;j+=i)is_prime[j]=false;

        }

    }

    return p;

}



int main(){

    int n;

    while(~scanf("%d",&n)){

        printf("%d\n",sieve(n));

    }

}
// Slower C++ solution:
#include<cstdio>

#include<string.h>

using namespace std;

int pNum;

bool IsPrime[1000010];

int Prime[1000010];

int GetPrime(int n){

    memset(IsPrime,true,sizeof(IsPrime));

    IsPrime[0]=IsPrime[1]=false;

    pNum=0;

    for(int i=2;i<=n;i++){

        if(IsPrime[i])Prime[++pNum]=i;

        for(int j=1;j<=pNum&&Prime[j]*i<=n;j++){

            IsPrime[Prime[j]*i]=false;

            if(i%Prime[j]==0)break;

        }

    }

    return pNum;

}

int main(){

    int n;

    while(~scanf("%d",&n)){

        printf("%d\n",GetPrime(n));

    }

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 7.437414720944913x):
#include<cstdio>

using namespace std;

#define MAX_N 999999+10

int prime[MAX_N];

bool is_prime[MAX_N+1];



int sieve(int n){

    int p=0;

    for(int i=0;i<=n;i++)is_prime[i]=true;

    is_prime[0]=is_prime[1]=false;

    for(int i=2;i<=n;i++){

        if(is_prime[i]){

            prime[p++]=i;

            for(int j=2*i;j<=n;j+=i)is_prime[j]=false;

        }

    }

    return p;

}



int main(){

    int n;

    while(~scanf("%d",&n)){

        printf("%d\n",sieve(n));

    }

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

int main()

{

    int n;

    while(~scanf("%d",&n))

    {

        int prime[n+1];

        for(int i=0;i<=n;i++)

            prime[i]=1;

            prime[0]=0;

            prime[1]=0;

        for(int i=2;i*i<=n;i++)

             if(prime[i]==1)

        {

            for(int j=2;j*i<=n;j++)

            prime[i*j]=0;

        }

        int c=0;

        for(int i=0;i<=n;i++)

        {

            if(prime[i]==1)

                c++;

        }

        printf("%d\n",c);

    }



}

// Faster C++ solution for the same problem (measured speedup: 5.14060831189931x):
#include<cstdio>

using namespace std;

#define MAX_N 999999+10

int prime[MAX_N];

bool is_prime[MAX_N+1];



int sieve(int n){

    int p=0;

    for(int i=0;i<=n;i++)is_prime[i]=true;

    is_prime[0]=is_prime[1]=false;

    for(int i=2;i<=n;i++){

        if(is_prime[i]){

            prime[p++]=i;

            for(int j=2*i;j<=n;j+=i)is_prime[j]=false;

        }

    }

    return p;

}



int main(){

    int n;

    while(~scanf("%d",&n)){

        printf("%d\n",sieve(n));

    }

}
// Slower C++ solution:
#include<stdio.h>

#include<math.h>

bool flag[1000000];

int main(void)

{

	long long i,j,p,n,count;

	p = (long long)sqrt(1000000.0);

	for(i = 3; i <= p; i = i + 2)

	{

		if(flag[i] == false)

		{

			for(j = i * i; j <= 1000000; j = j + 2 * i)

			{

				flag[j] = true;

				

			}

		}

	}

		

	while((scanf("%lld",&n)) != EOF)

	{

		

		if(n == 1 || n == 0)

			count = 0;

		else

		{

			count = 1;

			for(i = 3; i <= n; i = i + 2)

			{

				if(flag[i] == false)

					count++;

			}

		}

		printf("%lld\n",count);

	}

	



		

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 3.508465580874555x):
#include <cstdio>  

#include <iostream>  

using namespace std;  

int prime[1000005];  

bool is_prime[1000005];  

int seve(int n)  

{  

    int p=0;  

    for(int i=0;i<=n;i++)  

        is_prime[i]=true;  

    is_prime[0]=is_prime[1]=false;  

    for(int i=2;i<=n;i++)  

    {  

        if(is_prime[i])  

        {  

            prime[p++]=i;  

            for(int j=2*i;j<=n;j+=i)  

                is_prime[j]=false;  

        }  

    }  

    return p;  

}  

int main(void)  

{  

    int n;  

    while(scanf("%d",&n)!=EOF)  

    {  

        printf("%d\n",seve(n));  

    }  

    return 0;  

}
// Slower C++ solution:
#include <iostream>

#include <cstdio>

#include <string>

#include <cstring>

#include <cmath>

#include <algorithm>

#include <vector>

#include <queue>

using namespace std;

#define MAX 1000000

#define LMT 1000

unsigned flag[MAX>>6];

int primes[6000000];//5761455

#define ifc(n) (flag[n>>6]&(1<<((n>>1)&31)))

#define isc(n) (flag[n>>6]|=(1<<((n>>1)&31)))



int sieve()

{

    unsigned i, j, k;

    for(i=3; i<LMT; i+=2)

        if(!ifc(i))

            for(j=i*i, k=i<<1; j<MAX; j+=k)

                isc(j);

    return 0;

}



int main()

{

    sieve();

    unsigned int i,L;

    int k=1, count;

    primes[0]=2;

    while(scanf("%d", &L)==1)

    {

        count=1;

        for( i=3; i<=L; i+=2)

        {

            if(ifc(i)==0)

                count++;

        }

        if(L>1)

            printf("%d\n", count);

        else printf("0\n");

    }

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 2.3982806513263943x):
#include <cstdio>  

#include <iostream>  

using namespace std;  

int prime[1000005];  

bool is_prime[1000005];  

int seve(int n)  

{  

    int p=0;  

    for(int i=0;i<=n;i++)  

        is_prime[i]=true;  

    is_prime[0]=is_prime[1]=false;  

    for(int i=2;i<=n;i++)  

    {  

        if(is_prime[i])  

        {  

            prime[p++]=i;  

            for(int j=2*i;j<=n;j+=i)  

                is_prime[j]=false;  

        }  

    }  

    return p;  

}  

int main(void)  

{  

    int n;  

    while(scanf("%d",&n)!=EOF)  

    {  

        printf("%d\n",seve(n));  

    }  

    return 0;  

}
// Slower C++ solution:
#include<iostream>

#include<cstring>

#include<cmath>

using namespace std;



bool prime[1000000];



int main()

{

    int i,j,k,l,m,n;

    int count;

    while(cin>>n)

    {

        memset(prime,0,sizeof(prime));

        prime[1]=1;

        prime[2]=0;



        count=0;



        for(j=2;j*j<=n;j++)

        {

            if(prime[j]==0)

            {

                for(k=2;k*j<=n;k++)

                {

                   prime[j*k]=1;

                }

            }

        }

        for(i=1;i<=n;i++)

        {

            if(prime[i]==0)

            count++;

        }

        cout << count << endl;

    }

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 2.285066948034439x):
#include <cstdio>  

#include <iostream>  

using namespace std;  

int prime[1000005];  

bool is_prime[1000005];  

int seve(int n)  

{  

    int p=0;  

    for(int i=0;i<=n;i++)  

        is_prime[i]=true;  

    is_prime[0]=is_prime[1]=false;  

    for(int i=2;i<=n;i++)  

    {  

        if(is_prime[i])  

        {  

            prime[p++]=i;  

            for(int j=2*i;j<=n;j+=i)  

                is_prime[j]=false;  

        }  

    }  

    return p;  

}  

int main(void)  

{  

    int n;  

    while(scanf("%d",&n)!=EOF)  

    {  

        printf("%d\n",seve(n));  

    }  

    return 0;  

}
// Slower C++ solution:
#include<iostream>

#include<cstring>

#include<math.h>

using namespace std;

const int MAX = 1000000;

int prime(int n)

{

	int ans = 0;

	bool prime[MAX];

	memset(prime, 0, sizeof(prime));

	for (int i = 2; i < n;i++)  

	{ 

		for (int j = 2; j <= n / i; j++)

		{

			if (i*j <= n)

				prime[i*j] = 1;

		}

	}

	for (int i = 2; i <= n; i++)

	{

		if (!prime[i])

			ans++;

	}

	return ans;

}

int main()

{

	int n, m = 0;

	while (cin >> n&&m<30)

	{

		cout << prime(n) << endl;

		m++;

	}

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 2.300028281164102x):
#include <cstdio>  

#include <iostream>  

using namespace std;  

int prime[1000005];  

bool is_prime[1000005];  

int seve(int n)  

{  

    int p=0;  

    for(int i=0;i<=n;i++)  

        is_prime[i]=true;  

    is_prime[0]=is_prime[1]=false;  

    for(int i=2;i<=n;i++)  

    {  

        if(is_prime[i])  

        {  

            prime[p++]=i;  

            for(int j=2*i;j<=n;j+=i)  

                is_prime[j]=false;  

        }  

    }  

    return p;  

}  

int main(void)  

{  

    int n;  

    while(scanf("%d",&n)!=EOF)  

    {  

        printf("%d\n",seve(n));  

    }  

    return 0;  

}
// Slower C++ solution:
#include<cstdio>

#include<string.h>

using namespace std;

int pNum;

bool IsPrime[1000010];

int Prime[1000010];

int GetPrime(int n){

    memset(IsPrime,true,sizeof(IsPrime));

    IsPrime[0]=IsPrime[1]=false;

    pNum=0;

    for(int i=2;i<=n;i++){

        if(IsPrime[i])Prime[++pNum]=i;

        for(int j=1;j<=pNum&&Prime[j]*i<=n;j++){

            IsPrime[Prime[j]*i]=false;

            if(i%Prime[j]==0)break;

        }

    }

    return pNum;

}

int main(){

    int n;

    while(~scanf("%d",&n)){

        printf("%d\n",GetPrime(n));

    }

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.4456074114456001x):
#include <cstdio>  

#include <iostream>  

using namespace std;  

int prime[1000005];  

bool is_prime[1000005];  

int seve(int n)  

{  

    int p=0;  

    for(int i=0;i<=n;i++)  

        is_prime[i]=true;  

    is_prime[0]=is_prime[1]=false;  

    for(int i=2;i<=n;i++)  

    {  

        if(is_prime[i])  

        {  

            prime[p++]=i;  

            for(int j=2*i;j<=n;j+=i)  

                is_prime[j]=false;  

        }  

    }  

    return p;  

}  

int main(void)  

{  

    int n;  

    while(scanf("%d",&n)!=EOF)  

    {  

        printf("%d\n",seve(n));  

    }  

    return 0;  

}
// Slower C++ solution:
#include<stdio.h>

#include<math.h>

bool flag[1000000];

int main(void)

{

	long long i,j,p,n,count;

	p = (long long)sqrt(1000000.0);

	for(i = 3; i <= p; i = i + 2)

	{

		if(flag[i] == false)

		{

			for(j = i * i; j <= 1000000; j = j + 2 * i)

			{

				flag[j] = true;

				

			}

		}

	}

		

	while((scanf("%lld",&n)) != EOF)

	{

		

		if(n == 1 || n == 0)

			count = 0;

		else

		{

			count = 1;

			for(i = 3; i <= n; i = i + 2)

			{

				if(flag[i] == false)

					count++;

			}

		}

		printf("%lld\n",count);

	}

	



		

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 3.508465580874555x):
#include <cstdio>

#include <iostream>

using namespace std;

int prime[1000005];

bool is_prime[1000005];

int seve(int n)

{

    int p=0;

    for(int i=0;i<=n;i++)

        is_prime[i]=true;

    is_prime[0]=is_prime[1]=false;

    for(int i=2;i<=n;i++)

    {

        if(is_prime[i])

        {

            prime[p++]=i;

            for(int j=2*i;j<=n;j+=i)

                is_prime[j]=false;

        }

    }

    return p;

}

int main(void)

{

    int n;

    while(scanf("%d",&n)!=EOF)

    {

        printf("%d\n",seve(n));

    }

    return 0;

}
// Slower C++ solution:
#include <iostream>

#include <cstdio>

#include <string>

#include <cstring>

#include <cmath>

#include <algorithm>

#include <vector>

#include <queue>

using namespace std;

#define MAX 1000000

#define LMT 1000

unsigned flag[MAX>>6];

int primes[6000000];//5761455

#define ifc(n) (flag[n>>6]&(1<<((n>>1)&31)))

#define isc(n) (flag[n>>6]|=(1<<((n>>1)&31)))



int sieve()

{

    unsigned i, j, k;

    for(i=3; i<LMT; i+=2)

        if(!ifc(i))

            for(j=i*i, k=i<<1; j<MAX; j+=k)

                isc(j);

    return 0;

}



int main()

{

    sieve();

    unsigned int i,L;

    int k=1, count;

    primes[0]=2;

    while(scanf("%d", &L)==1)

    {

        count=1;

        for( i=3; i<=L; i+=2)

        {

            if(ifc(i)==0)

                count++;

        }

        if(L>1)

            printf("%d\n", count);

        else printf("0\n");

    }

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 2.3982806513263943x):
#include <cstdio>

#include <iostream>

using namespace std;

int prime[1000005];

bool is_prime[1000005];

int seve(int n)

{

    int p=0;

    for(int i=0;i<=n;i++)

        is_prime[i]=true;

    is_prime[0]=is_prime[1]=false;

    for(int i=2;i<=n;i++)

    {

        if(is_prime[i])

        {

            prime[p++]=i;

            for(int j=2*i;j<=n;j+=i)

                is_prime[j]=false;

        }

    }

    return p;

}

int main(void)

{

    int n;

    while(scanf("%d",&n)!=EOF)

    {

        printf("%d\n",seve(n));

    }

    return 0;

}
// Slower C++ solution:
#include<iostream>

#include<cstring>

#include<cmath>

using namespace std;



bool prime[1000000];



int main()

{

    int i,j,k,l,m,n;

    int count;

    while(cin>>n)

    {

        memset(prime,0,sizeof(prime));

        prime[1]=1;

        prime[2]=0;



        count=0;



        for(j=2;j*j<=n;j++)

        {

            if(prime[j]==0)

            {

                for(k=2;k*j<=n;k++)

                {

                   prime[j*k]=1;

                }

            }

        }

        for(i=1;i<=n;i++)

        {

            if(prime[i]==0)

            count++;

        }

        cout << count << endl;

    }

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 2.285066948034439x):
#include <cstdio>

#include <iostream>

using namespace std;

int prime[1000005];

bool is_prime[1000005];

int seve(int n)

{

    int p=0;

    for(int i=0;i<=n;i++)

        is_prime[i]=true;

    is_prime[0]=is_prime[1]=false;

    for(int i=2;i<=n;i++)

    {

        if(is_prime[i])

        {

            prime[p++]=i;

            for(int j=2*i;j<=n;j+=i)

                is_prime[j]=false;

        }

    }

    return p;

}

int main(void)

{

    int n;

    while(scanf("%d",&n)!=EOF)

    {

        printf("%d\n",seve(n));

    }

    return 0;

}
// Slower C++ solution:
#include<iostream>

#include<cstring>

#include<math.h>

using namespace std;

const int MAX = 1000000;

int prime(int n)

{

	int ans = 0;

	bool prime[MAX];

	memset(prime, 0, sizeof(prime));

	for (int i = 2; i < n;i++)  

	{ 

		for (int j = 2; j <= n / i; j++)

		{

			if (i*j <= n)

				prime[i*j] = 1;

		}

	}

	for (int i = 2; i <= n; i++)

	{

		if (!prime[i])

			ans++;

	}

	return ans;

}

int main()

{

	int n, m = 0;

	while (cin >> n&&m<30)

	{

		cout << prime(n) << endl;

		m++;

	}

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 2.300028281164102x):
#include <cstdio>

#include <iostream>

using namespace std;

int prime[1000005];

bool is_prime[1000005];

int seve(int n)

{

    int p=0;

    for(int i=0;i<=n;i++)

        is_prime[i]=true;

    is_prime[0]=is_prime[1]=false;

    for(int i=2;i<=n;i++)

    {

        if(is_prime[i])

        {

            prime[p++]=i;

            for(int j=2*i;j<=n;j+=i)

                is_prime[j]=false;

        }

    }

    return p;

}

int main(void)

{

    int n;

    while(scanf("%d",&n)!=EOF)

    {

        printf("%d\n",seve(n));

    }

    return 0;

}
// Slower C++ solution:
#include<cstdio>

#include<string.h>

using namespace std;

int pNum;

bool IsPrime[1000010];

int Prime[1000010];

int GetPrime(int n){

    memset(IsPrime,true,sizeof(IsPrime));

    IsPrime[0]=IsPrime[1]=false;

    pNum=0;

    for(int i=2;i<=n;i++){

        if(IsPrime[i])Prime[++pNum]=i;

        for(int j=1;j<=pNum&&Prime[j]*i<=n;j++){

            IsPrime[Prime[j]*i]=false;

            if(i%Prime[j]==0)break;

        }

    }

    return pNum;

}

int main(){

    int n;

    while(~scanf("%d",&n)){

        printf("%d\n",GetPrime(n));

    }

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.4456074114456001x):
#include <cstdio>

#include <iostream>

using namespace std;

int prime[1000005];

bool is_prime[1000005];

int seve(int n)

{

    int p=0;

    for(int i=0;i<=n;i++)

        is_prime[i]=true;

    is_prime[0]=is_prime[1]=false;

    for(int i=2;i<=n;i++)

    {

        if(is_prime[i])

        {

            prime[p++]=i;

            for(int j=2*i;j<=n;j+=i)

                is_prime[j]=false;

        }

    }

    return p;

}

int main(void)

{

    int n;

    while(scanf("%d",&n)!=EOF)

    {

        printf("%d\n",seve(n));

    }

    return 0;

}
// Slower C++ solution:
#include<stdio.h>

#include<math.h>

bool flag[1000000];

int main(void)

{

	long long i,j,p,n,count;

	p = (long long)sqrt(1000000.0);

	for(i = 3; i <= p; i = i + 2)

	{

		if(flag[i] == false)

		{

			for(j = i * i; j <= 1000000; j = j + 2 * i)

			{

				flag[j] = true;

				

			}

		}

	}

		

	while((scanf("%lld",&n)) != EOF)

	{

		

		if(n == 1 || n == 0)

			count = 0;

		else

		{

			count = 1;

			for(i = 3; i <= n; i = i + 2)

			{

				if(flag[i] == false)

					count++;

			}

		}

		printf("%lld\n",count);

	}

	



		

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 3.4694184141776088x):
#include <iostream>

#include<stdio.h>

#include<cstring>

#include<algorithm>

using namespace std;

typedef long long ll;

#define MAX 1000000



bool is_prime[MAX];

ll prime[MAX];



ll found(ll a)

{

    ll p=0;

    for(ll i=0;i<=a;i++)

    {

        is_prime[i]=true;

    }

    is_prime[0]=false;

    is_prime[1]=false;

    for(ll i=2;i<=a;i++)

    {

        if(is_prime[i])

        {

            prime[p++]=i;

            for(ll k=2*i;k<=a;k=k+i)

            {

                is_prime[k]=false;

            }

        }

    }

    return p;

}



int main()

{

    ll n;

    while(cin>>n)

    {

        ll q;

        q=found(n);

        cout<<q<<endl;

    }

    return 0;

}