Go: package main
import (
	"fmt"
	"os"
	"strconv"
	"bufio"
	//"math"
)

var sc = bufio.NewScanner(os.Stdin)

func main(){
	for sc.Scan(){
		n := nextInt()
		fmt.Println(calc(n))
	}
}

func calc(n int)int{
	// エラトステネスで数え上げる
	// 最初から999999まで用意しておいて入力のたびO(1)で出すのとどっちが速いのかはわからん
	eratos := make([]bool, n+1)
	c := 0
	for i:=2; i<len(eratos); i++{
		if eratos[i] == false{
			c++
			for j:=i*i; j<len(eratos); j+=i{
				eratos[j]=true
			}
		}
	}
	return c
}

func next()string{
	return sc.Text()
}

func nextInt()int{
	a, _ := strconv.Atoi(next())
	return a
}

C++: #include <iostream>
#include <vector>

using namespace std;

vector<int> Prime;
void PrimeCalc(int n)
{
	bool IsPrime[1000000];
	for(int i = 0; i < 1000000; ++i)
	{
		IsPrime[i] = true;
	}
	IsPrime[0] = IsPrime[1] = false;
	for(int i = 2; i < n; ++i)
	{
		if(IsPrime[i])
		{
			Prime.push_back(i);
			for(int j = 2 * i; j < n; j += i)
			{
				IsPrime[j] = false;
			}
		}
	}
}

void solve()
{
	int n;
	cin >> n;
	PrimeCalc(n);
	int ans = 0;
	int pos = 0;
	cout << Prime.size() << endl;
}

int main()
{
	solve();
	return(0);
}

C++: /*
Volume0-0009
*/
#include <iostream>
#include <stdlib.h>
#include <string.h>

#define N 1000000
#define TRUE (int)(0==0)
#define FALSE !TRUE

using namespace std;

int main(int argc, char *argv[]){
  int f[N];

  //  memset(f, TRUE, N);
  f[0]=FALSE;
  f[1]=FALSE;
  for (int i=2; i<N; i++)
    f[i] = TRUE;

  for (int i=2; i<N; i++){
    if (f[i] == TRUE ) {
      for (int j=i+i; j<N; j+=i){
	f[j] = FALSE;
      }
    }
  }
  int n;
  while (cin >> n) != NULL){
    int m = 0;
    for (i=1; i<=n; i++){
      if (f[i]){
	m++;
      }
    }
    cout << m;
  }
 
  exit(0);
}

C++: #include <iostream>
#include <cmath>
using namespace std;

bool check(int in){
	for (int i = 3; i<=sqrt(in); i+=2){
		if (i != 5 && i % 5 == 0)	continue;
		if (in % i == 0)
			return false;
	}
	return true;
}

int PrimeNumber(int in, int start){
	int count = 0;
	if (in > 2)	count++;
	for (int i = start; i <=in; i+=2){
		if (check(i))	count++;
	}

	return count;
}

int main(){
	int in;
	int count250000 = PrimeNumber(250000, 3);
	int count500000 = count250000 + PrimeNumber(500000, 250001) -1;
	int count750000 = count500000 + PrimeNumber(750000, 500001) -1;

	while (cin >> in, !cin.eof()){
		if (in <= 250000)
			cout << PrimeNumber(in, 3) << endl;
		else if (in <= 500000)
			cout << count250000 + PrimeNumber(in, 250001)-1 << endl;
		else if (in <= 750000)
			cout << count500000 + PrimeNumber(in, 500001)-1 << endl;
		else
			cout << count750000 + PrimeNumber(in, 750001)-1 << endl;
	}
}

C++: #include <iostream>
using namespace std;

int main(){
	int n,w=0;
	cin >> n;
	for(int j=n;j>1;j--){
		for(int i=2;i<j;++i){
			if(j%i == 0){
				cout << j << "ツづュツづゥ" << i << "=" <<"NA" <<endl;
				break;
			}else{
				cout << j << "ツづュツづゥ" << i << "=" <<"OK" << endl;
			}
			if(i=j-1){
				w++;
			}
		}
	}
	cout << w;	
	return 0;
}

C++: #include<stdio.h>
#define N 1000000

int main() {
	int ipt;
	int root;
	int cnt = 0;
	int A[N];
	for (int i = 1; i <= N; i++) {
		A[i] = i;
	}
	for (int pos = 2; pos*pos <= N; pos++) {
		root = A[pos];
		if (!root)continue;
		for (int k = 2; k*root <= N; k++) {
			A[k*root] = 0;
		}
	}

	while(1) {
		scanf("%d", &ipt);
		for (int i = 2; i <= ipt; i++) {
			if (A[i] != 0)cnt++;
		}
		printf("%d\n", cnt);
		cnt = 0;
	}

	return 0;
}

C++: #include <stdio.h>
#include <math.h>

int main(void){
	int n;
	
	int i,j;
	int count = 0;
	int Flag = 0;
	
	while(scanf("%d",&n) != EOF){
		for(j = 1;j <= n;j += 2){
			for(i = 1;pow(i,2) <= j;i++){
				if(j % i == 0&&i != 1){
					Flag = 1;
					break;
				}
			}
			if(Flag != 1){
				count++;
			}
			Flag = 0;
		}
		printf("%d\n",count);
		count = 0;
	}
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;

vector<int> primes;
bool is_prime[1000100];

void search_prime(int n){
	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]){
			primes.push_back(i);
			for(int j = i * 2; j <= n; j += i)
				is_prime[j] = false;
		}
	}
}

int main() {
	search_prime(1000050);
	int n;
	while(cin >> n){
		if(n == 0 && n == 1){
			cout << "0" << endl;
		}
		else{
			int idx = lower_bound(primes.begin(), primes.end(), n) - primes.begin();
			if(primes[idx] == n)
				idx++;
			cout << idx << endl;
		}
	}
	return 0;
}

C++: #include <iostream>
using namespace std;

#define Max 1000000

int prime [10000000];

int main()
{
	int n, out;
	for (int i = 2; i * i < Max; i++){
		if (prime[i] == 0){
			for (int j = i; j < Max; j += i){
				if (!(j == i)) prime[j] = 1;
			}
		}
	}
	while (cin >> n){
		out = 0;
		for (int i = 0; i <= n; i++){
			if (prime[i] == 0) out++;
		}
		cout << out - 2 << endl;
	}
	return(0);
}

C++: #include <iostream>
using namespace std;

int main() {
	bool isPrime[1000000] = {true};

	for (int i = 0; i < 1000000; i++) {
		isPrime[i] = true;
	}

	isPrime[1] = false;
	for (int i = 2; i < 1000000; i++) {
		if (!isPrime[i])
			continue;

		if (isPrime[i]) {
			int k = 2*i;
			while (k < 1000000) {
				isPrime[k] = false;
				k += i;
			}
		}
	}

	int n;
	while (cin >> n) {
		int sum = 0;
		for (int i = 2; i <= n; i++) {
			if (isPrime[i])
				sum++;
		}
		cout << sum << endl;
	}

	return 0;
}

C++: #include<stdio.h>

int main(){
    int i,j,n;
    int stack[30],sp=0;
    while(scanf("%d",&stack[sp++])!=EOF);
    for(i=0;i<sp-1;i++){
        n=0;
        for(j=2;j<stack[i];j++)
            if(stack[i]%j==0)n++;
        printf("%d\n",n);
    }
    return 0;
}

C++: #include <iostream>
using namespace std;
int main(){
  int NUM = 1000000;
  bool prime[NUM];
  prime[0] = false;prime[1] = false;
  for(int i=2;i<NUM;i++)prime[i] = true;
  for(int i=2;i*i<NUM;i++)
    for(int k=2;i*k<NUM;k++)
      prime[i*k]=false;

	int primeNum[NUM];
	for(int i=0,c=0;i<NUM;i++){
		prime[i]||c++;
		primeNum[i] = c;
	}
	for(int n;cin>>n;cout<<primeNum[n]<<endl);
}

C++: #include "bits/stdc++.h"

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;

#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back

bool isp[1000000]={};


void makeEra(){
    for(int i=2;i<=1000;i++){
        if( isp[i] ){
            for(int j=2;j<=1000000/i;j++){
                isp[i*j]=false;
            }
        }
    }
}


int main(){
    rep(i,1000000)isp[i]=true;
    isp[0]=isp[1]=false;
    makeEra();
    
    int n;
    while(cin>>n){
        int c = 0;
        rep(i,n+1){
            if(isp[i])c++;
        }
        cout<<c<<endl;
    }
}

C++: #include <stdio.h>
#include <math.h>

bool sosuu[1000000];

int main(void)
{
	int n;
	int sq;
	int i,j;
	int count;
	bool flag;
	int m;

	for(i=2;i<=1000;i++)
	{
		for(j=2;j<=int(1000000/i);j++)
			sosuu[i*j]=true;
	}

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

		count=0;
		for(m=2;m<=n;m++)
		{
			if(sosuu[m] == false)
				count++;
		}
		printf("%d\n",count);
	}
	return 0;
}