Go: package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	for sc.Scan() {
		a, _ := strconv.Atoi(sc.Text())
		fmt.Println(countPrime(a))
	}
}

func countPrime(a int) int {
	primes := make([]bool, a+1)
	n := 0
	for i := 2; i <= a; i++ {
		if primes[i] == false {
			n++
			for j := i * i; j <= a; j += i {
				primes[j] = true
			}
		}
	}
	return n
}

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+1)
    {
        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(void){
	bool a[600001];
	while(!cin.eof()){
		int n;
		cin >> n;

		for(int i = 2; i <= n; i++){
			a[i] = true;
		}

		for(int i = 2; i * i <= n; i++){
			if(!a[i]) continue;
			for(int j = i + 1; j <= n; j++)
				if(!(j % i)){
					a[j] = false;
				}
		}

		int ans = 0;
		for(int i = 2; i <= n; i++)
			if(a[i]){
				ans++;
			}
		cout << ans << endl;
	}
			
	return 0;
}

C++:                                           
#include <iostream>
#include <iomanip>
#include <cmath>


using namespace std;


int main(){
  int n;
  //?´???°???true,                                                                    
  bool flag = false;

  while(cin >> n){
    int cnt=0;
    //cout << n << endl;                                                           
    //    sqrt_n = sqrt(n);                                                        
    for(int i=2;i<=n;i++){
      flag = false;
      //?´???°?????????????????§??????                                                       
      for(int j=2;j<=sqrt(i);j++){
        //      cout << i << " " << j << endl;                                     
        //cout << j << endl;                                                       
        if(i%j==0){
          flag = true;
          //cout << i%j << endl;                                                   
          break;
        }

      }
      if(flag){continue;}

      cnt++;
      //cout << "last: " << i << endl;                                             
    }
    //cout << "cnt: " << cnt << endl;                                              
    cout << cnt << endl;

  }
}

C++: // AOJ 009

#include <iostream>
#define MAX_NUMBER 50 //1000000
using namespace std;

bool isPrime[MAX_NUMBER];

void SetFalseToMultiples (int prime) {
	for (int i = prime*2; i < MAX_NUMBER;i+=prime) {
		isPrime[i] = false;
	}
	return;
}	

int CountPrimes(int n) {
	int count = 0;
	for (int i = 1;i <= n;i++) {
		if (isPrime[i]) count++;
	}
	return count;
}

int main() {
	for (int i = 0;i < MAX_NUMBER;i++) {
		isPrime[i] = true;	
	}
	isPrime[1] = false;
	
	for (int i = 1;i < MAX_NUMBER;i++) {
		if (isPrime[i]) {
			SetFalseToMultiples(i);
		}
	}
	int n;
	while (cin >> n) {
		cout << CountPrimes(n) << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <iomanip>
#include <list>
#include <map>
#include <algorithm>
#include <stack>
#include <string>
#include <vector>

#define MAX 999999

using namespace std;


int main(){
	int n = 0;
	int count;
	bool flag = false;
	vector<int> sosu;
	sosu.push_back(0);
	sosu.push_back(0);
	sosu.push_back(1);

	count = 1;
	for(int i = 3; i <= MAX; i += 2){
		for(int j = 3; j * j <= i; j += 2){
			if(i % j == 0){
				flag = true;
				break;
			}
		}
		if(flag != true){
			count++;
		}
		else{
			flag = false;
		}
		sosu.push_back(count);
		sosu.push_back(count);
	}
	

	while(cin >> n){
		cout << sosu[n] << endl;	
	}

	return 0;
}

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

bool IsPrime(int n)
{
	for (int i = 2; i <= sqrt(n); i++)
	{
		if (n % i == 0) return false;
	}
	return true;
}

int main()
{
	int n;
	while (cin >> n)
	{
		int ans = 0;
		for (int i = 2; i <= n; i++)
		{
			if (IsPrime(i)) ans++;
		}
		cout << ans << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <vector>
#include <math.h>
#include <string>
#include <string.h>
#include <stack>
#include <algorithm>
#include <stdio.h>
using namespace std;

bool a[1000000];

int main()
{
	int n;
	while (cin >> n)
	{
		if (n == 1)
		{
			cout << 0 << endl;
		}
		else
		{
			memset(a, false, sizeof(a));

			int cnt = 0;
			for (int i = 2; i <= n; i++)
			{
				if (a[i] == false)
				{
					cnt++;
					for (int j = 1; i * j <= n; j++)
					{
						a[i * j] = true;
					}
				}
			}
			cout << cnt << endl;
		}
	}

	return 0;
}

C++: /*http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0009&lang=jp*/

#include <iostream>

#define MAX 999999

using namespace std;

int main()
{
    int n;
    static int num_prime[MAX+1];
    static bool not_prime_flag[MAX+1];

    for (int i = 2; i < MAX+1; ++i) {
        if(!not_prime_flag[i]){
            for (int j = 2; i*j < MAX+1; ++j) {
                not_prime_flag[i*j] = true;
            }
        }
        num_prime[i]=num_prime[i-1]+!not_prime_flag[i];
    }
    while (cin>>n){
        cout<<num_prime[n]<<endl;
    }
    return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
	int n, cnt;	

	while(cin >> n){
		bool prime[1000000] = {false};
		prime[1] = true;
		
		// ??¨??????????????????????????????
		for(int j = 2; j*j <= n; j++){
			if(prime[j] == false){
				for(int k = j; k*j <= n; k++){
					prime[j*k] = true;
				}
			}
		}
		cnt = 0;
		for(int i = 1; i <= n; i++){
			if(prime[i] == false) cnt++;
		}
		
		cout << cnt << endl;
	}
}

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

int main(){
  int a;
  int i, j;
  int past=1, a_sqrt;
  int count;
  bool chk[1000000];

  for(i=1; i<1000000; i++) chk[i]=true;
  while(cin>>a){
    count=0;
    if(past>=a){
      for(i=1; i<=a; i++){
        if(chk[i]) count++;
      }
      printf("%d\n", count);
    }
    else {
      printf("%d\n", count);
    }
  }

  return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <set>
#include <functional>

class Mod{
	const int n;
	public:
		Mod(const int _n):n(_n){}
		bool operator()(const int _src){
			return ! (_src % n);
		}
};

const std::vector<int> Eratosthenes(const std::vector<int> src){
	std::vector<int> result,tmp(src);
	while(!tmp.empty()){
		int n(tmp[0]);
		result.push_back(n);
		Mod mod(n);
		std::vector<int>::iterator it= std::remove_if( tmp.begin(), tmp.end(), mod );
		tmp.erase(it,tmp.end());
	}
	return result;
}
static int const MAX(1000000);

int main(int,char**){
	std::vector<int> vec;
	vec.reserve(MAX-MAX/2-MAX/3-MAX/5+MAX/6+MAX/10+MAX/15-MAX/30+3);
	for(int i(3);i<=MAX;i+2){
		if(i!=3 && i%3==0) continue;
		if(i!=5 && i%5==0) continue;
		vec.push_back(i);
	}
	std::vector<int> primes;
	primes.reserve(10000);
	primes =Eratosthenes(vec);
	int n;
	while(std::cin >>n){
		std::vector<int>::const_iterator const it= std::upper_bound(primes.begin(),primes.end(),n);
		int off=it -primes.begin();
		if(n>=2){ ++off; }
		std::cout << off <<std::endl;
	}
	return 0;
}

C++: #include <stdio.h>

int isprime(int n){
    for(int = 2; i * i <= n; i++) {
        if(n % i == 0) return 0;  //素数でない
    }
    return 1; //素数である
}

int main() {
    int n;
    int ans[2] = {};
    while(scanf("%d", &n) != 0) {
        for(int i = n; i >= 5; i--) {
            if(isprime(i) == 1) {
                ans[0] = i;
                if(isprime(i - 2) == 1) {
                    ans[1] = i - 2;
                    break;
                }
            }
        }
        printf("%d %d", ans[0], ans[1]);
    }
}