Go: package main

import (
	"bufio"
	"os"
	"strconv"
	"fmt"
)

var scanner = bufio.NewScanner(os.Stdin)

func nextInt() int {
	i, e := strconv.Atoi(scanner.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func check(n int) int {
	eratos := make([]bool, n+1)
	cnt := 0
	for i := 2; i < len(eratos); i++ {
		if !eratos[i] {
			cnt++
			for j := i*i; j < len(eratos); j += i {
				eratos[j] = true
			}
		}
	}
	return cnt
}

func main() {
	for scanner.Scan() {
		n := nextInt()
		fmt.Println(check(n))
	}
}

C++: #include <cmath>
#include <cstdio>
 
inline bool fermat_test(int n) {
    if (n < 2) {
        return false;
    } else if (n == 2) {
        return true;
    } else {
        return (static_cast<int>(std::pow(2, n - 1)) % n) == 1;
    }
}
 
inline bool prime_test(int n) {
    if (n < 2) {
        return false;
    } else if (n == 2) {
        return true;
    } else {
        for (int i = 3; i < static_cast<int>(std::sqrt(n)); i += 2) {
            if ((n %= i) == 0) {
                return false;
            }
        }
    }
    return true;
}

unsigned short v[999999];

int main() {
    int n;
    v[3] = 2;
    while (~scanf("%d", &n)) {
        for (int i = 5; i <= n; i += 2) {
            if (v[i] > 0)
                continue;
 
            v[i] = v[i - 2] + (fermat_test(i) && prime_test(i));
        }
        printf("%d\n", v[n % 2 == 0 ? n - 1 : n]);
    }
}

C++: #include <math.h>
#include <iostream>
#include <ios>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <string>

#define YES "YES"
#define NO "NO"
#define space ' '

using namespace std;

void init();
void func();

int main(void)
{
	
	func();

	return 0;
}


#define MAXIMUM 1000000
bool table[MAXIMUM];
int cnt[MAXIMUM];
bool not = true;
bool prime = false;

void init()
{
		table[0] = not;
	table[1] = not;
	for (int i = 2; i < MAXIMUM; i++)
	{
		if (table[i] == prime)
		{
			for (int j = i * 2; j < MAXIMUM; j += i)
			{
				table[j] = not;
			}
		}
	}
	for (int i = 1; i < MAXIMUM; i++)
	{
		if (table[i] == prime)
		{
			cnt[i] = cnt[i - 1] + 1;
		}
		else
		{
			cnt[i] = cnt[i - 1];
		}
	}

}

void func()
{
	
	int n;

	init();

	while (cin >> n, !cin.eof())
	{
		cout << cnt[n] << endl;
	}

}

C++: #include <iostream>

int main(void)
{
    int input;
    while(std::cin >> input){
        bool* table = new bool[input + 1]();
        for(int i=0; i <= input; ++i){
            if(i < 2){
                table[i] = true;
                continue;
            }
            if(table[i] == false){
                for(int j=2;i * j <= input;++j){
                    table[i * j] = true;
                }
            }
        }
        int count = 0;
        for(int i=0;i <= input;++i){
            if(table[i] == false){
                ++count;
            }
        }
        std::cout << count << std::endl;
        delete[] table;
    }
    return 0;
}

C++: #include <iostream>
#define N 100000
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

int main(void)
{
    bool a[N+1];
    int prime[N], n;
    rep(i,N)
    {
        a[i] = true;
    }
    a[0] = a[1] = false;
    for(int i=2;i*i<=N;i++)
    {
        if(a[i])
        {
            prime[i] = prime[i-1] + 1;
            for(int j=i*i;j<N;j+=i)
                a[j] = false;
        }
        else
            prime[i] = prime[i-1];
    }

    while(cin >> n)
    {
        cout << prime[n] << endl;
    }
    
    return 0;
}

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

int main(){
	int i, j, n, num = 0, count = 0;

	while(cin >> n){
		count = 0;
		for(i = 2; i <= n; i++){
			num = 0;
			for(j = 1; j <= i; j++){
				if(i % j == 0) num ++;
			}
			if(num == 2) count ++;
 		}
		cout << count << endl;
	}

	return 0;
}

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

bool IsPrime(int x) {
  return true;  /* ダミー: 全て素数と判定 */
}

int main(void){
   int count = 0, n;
   cin >> n; /* n個整数を読む */
   for(int i = 0; i < n; i++) {
       int p;
       cin >> p;
       if(IsPrime(p)) {
         bool IsPrime(int n) {
    for(int i = 2; i*i <= n; i++) {
        if(n % i == 0) {
            return false;
        }
    }
    return true;
}


       }
   }
   cout << count << endl;
   return 0;
}

C++: #include <iostream>
using namespace std;
#define MAX 1000000
/// http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=666933#1
int main(){
    bool num[MAX];
    for(int i =2; i<MAX; i++) num[i] =true;

    for(int i=2; i*i < MAX; i++){
        for(int j=i; i*j <MAX;j++){
            num[i*j] =false;
        }
    }
    for(int n, count =0; cin >> n; cout << count <<endl, count=0){
        for(int i=2; i<=n; i++){
            if(num[i]) count++;
        }
    }
}

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

class Era{
    public:
    vector<int>prime;
    vector<int>imos;
    Era(int num = 0){
        if(num < 2)return;
        prime = vector<int>(num + 1, 1);
        prime[0] = 0;
        prime[1] = 0;
        for(int i = 2; i * i <= num; i++){
            if(prime[i] == 0)continue;
            for(int j = i + i; j <= num; j += i){
                prime[j] = 0;
            }
        }
        imos = vector<int>(num + 1, 0);
        for(int i = 1; i <= num; i++){
            imos[i] = imos[i - 1] + prime[i];
        }
    }
};

int main(){

    Era era(1000000);
    for(int x; cin >> x;)cout << era.imos[x] << endl;
    
    return 0;
}

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

int main(){
	bool p[MAX+1];
	int n, ans;

	for(int i=0 ; i<=MAX ; i++){
		p[i] = (i<=1)? false : true ;
	}

	for(int i=2 ; i<=sqrt(MAX)+1 ; i++){
		if(p[i]){
			for(int j=i*2 ; j<=MAX ; j+=i){
				p[j] = false;
			}
		}
	}

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

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

#define N 1000000L
bool num[N];

void furui(void){
  long int i;
  int divide;
  int rt = 1000;
  for(i = 0L; i < N; i++){
    num[i] = true;
  }
  num[0L] = false;
  num[1L] = false;
  for(divide = 2; divide <= rt; divide++){
    if(num[divide] == false) continue;
    for( i = (long int) divide; i < N; i+= divide){
      num[i] = false;
    }
    num[divide] = true;
  }
}

int main(void){
  int c, i, j;
  long int k;
  char buf[7];
  long int n;
  long int count;

  furui();

  for(j = 0; j < 30; j++){
    for(i = 0; ;i++){
      c = getchar();
      if(c == EOF || c == '\n'){
        buf[i] = '\0';
        break;
      }
      buf[i] = c;
    }
    n = atol(buf);
    count = 0L;
    for(k = 1L; k <= n; k++){
      if(num[k] == true) count++;
    }
    std::cout << count << std::endl;
    if(c == EOF) break;
  }
  return 0;
}

C++: #include <iostream>
#include <vector>
using namespace std;
int main( void )
{
	int n;
	cin >> n;
	
	vector <bool> p(n, true);
	p[2] = true;
	for ( int i = 3; i * i < n; i += 2 )
	{
		if ( p[i] )
		{
			for ( int j = i+2; j < n; j += i )
			{
				p[j] = false;
			}
		}
	}

	int kotae = 1;
	for ( int i = 3; i < n; i += 2 )
	{
		if ( p[i] )
			kotae++;
	}

	cout << kotae << endl;

	return 0;
}

C++: #include <iostream>

int main() {
	// Prime Data Set
	char p[1000000] = {0};
	p[1] = 1;
	for( int i=2; i<500000; i++) if(!p[i]) for( int j=i+i; j<1000000; j+=i) p[j] = 1;
	
	int n;
	int sum;
	while( std::cin >> n) {
		sum = 0;
		for( int i=1; i<n; i++) {
			if(!p[i]) sum++;
		}
		std::cout << sum << std::endl;
	}
}

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

int main()
{
	int count=0,n;
	bitset<1000000> prime;
	prime.reset();

	while(cin>>n)
	{
		prime[0]=1;
		prime[1]=1;
		for(int i=2;i<=sqrt(n);i++)
			if(prime[i]==0)
				for(int j=i+1;j<=n;j++)
					if(j%i==0)
						prime[j]=1;
		for(int i=2;i<=n;i++)
			if(prime[i]==0)
				count++;
		cout<<count<<endl;
		count=0;
		prime.reset();
	}
}