Go: package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	num := make([]bool, 1000000)

	for sc.Scan() {
		var nmpr int

		n, _ := strconv.Atoi(sc.Text())

		lmt := int(math.Sqrt(float64(n)))

		for i := 2; i <= lmt; i++ {
			for j := 2; i*j <= n; j++ {
				if !num[i*j] {
					num[i*j] = true
				}
			}
		}

		for t := 2; t <= n; t++ {
			if !num[t] {
				nmpr++
			}
		}

		fmt.Println(nmpr)
	}

}

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

int prime(int number) {
    int s_num = sqrt(number);
    if (number == 2) {
        return 1; 
    } else if (number % 2 == 0) {
        return 0;
    }
    for (int i = 3; i <= s_num; i += 2) {
        if (number % i == 0) {
            return 0;
        }
    }
    return 1;
}

int main(void) {
    int number;
    int count = 0;
    int max = 1;

    std::vector<int> v(1000000, 0);

    while (std::cin >> number) {
        if (number > max) {
            for (int i = max + 1; i <= number; i++) {
                if (prime(i) == 1) {
                    count++;
                }
                v[i - 1] = count;
                max = number;
            }
        }
        std::cout << v[number - 1] << std::endl;
    }
    return 0;
}

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

#define MAX 1000000 

bool prime_table[MAX];
int head;

int main(){
	int n, i, j;
	int result;
	// make table
	for (i = 0; i < MAX; i++) {
		if(i==0||i==1){
			prime_table[i] = false;
		}else{
			prime_table[i] = true;
		}
	}
	// find prime
	for (i = 2; i < MAX; i++) {
		if(prime_table[i]){
			for (j = i+i; j < MAX; j+=i) {
				prime_table[j] = false;
			}
		}
	}
	
	while(cin >> n){
		result = 0;
		for (i = 0; i < n; i++) {
			if(prime_table[i])
				result++;
		}
		cout << result << endl;
	}
	return 0;
}

C++: #include<iostream>
#include<stdio.h>
#include<windows.h>
#include<conio.h>
#include<String>
#include<time.h>
#include<math.h>

using namespace std;

int main() {

	int c = 0;
	int i = 1;
	unsigned long long a = 0;
	unsigned long long b = 0;
	unsigned long long sosuu[100000] = { 0 };
	char fire = 0;
	int pattara = 0;
	cin >> c;
	cout << 2;
	/*while(i>-1)*/for(int i=0;i<c;i++){
		/*for (int z = 0; z < a;z++){*/
		for (int q = 1; q <= sqrt(i); q++) {
			sosuu[pattara] = i;
			if (sosuu[pattara] % 2 == 0) {
				break;
			}
			if (sosuu[pattara] % q == 0) {
				b += 1;
			}

		}

		/*if (b == 1) {
			fire = _getch();
			pattara++;
			cout << sosuu[pattara - 1] << " " << pattara << endl;

		}*/
		b = 0;
		/*i++;*/
		if (pattara == c){
			break;
		}
	}
	cout << pattara << endl;


	/*system("pause");
	return 0;*/
}

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

int main(){
  bool a[1000000];

  a[0]=a[1]=false;
  for(int i=2;i<1000000;i++){
    a[i]=true;
  }

  for(int i=2;i*i<1000000;i++){
    if(a[i]){
      for(int j=i*i;j<10000000;j+=i){
        a[j]=false;
      }
    }
  }

  int n[1000000];

  int tmp=0;
  for(int i=0;i<1000000;i++){
    if(a[i]){
      tmp++;
    }
    n[i]=tmp;
  }

  while(true){
    int m;
    cin>>m;

    if(cin.eof()){
      break;
    }
    
    cout<<n[m]<<endl;

  }

  return 0;
}

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

using namespace std;

void set_prime_number(bool* array, int num) {

  fill(array, array + num, true);
  array[0] = array[1] = false;
  for (int i = 2; i < num; i++) {
    if (!array[i]) continue;
    for (int j = i * 2; j < num; j += i) {
      array[j] = false;
    }
  }

}

int main() {
  bool prime_number[999999];
  int num;
  int nump=0;
  int j=0;
  int cnt=0;

	while(scanf("%d",&num)!=EOF){
	  set_prime_number(prime_number, num);
	 for (int i = 0; i < num; i++) {
	 if (prime_number[i])cnt++;
	 }
	 printf("%d ",cnt);
	 cnt=0;
	}


  return 0;
}

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


using namespace std;

int main() {
	vector<int> prime_num{ 2, 3 };
	int n;

	while (cin >> n){
		int result;
		if (n <= 1) {
			result = 0;
		}
		else if (n == 2){
			result = 1;
		}
		else if (n < prime_num.back()){
			result = count_if(prime_num.begin(), prime_num.end(), [n](int a){return a <= n; });
		}
		else {
			for (int i = prime_num.back() + 2; i <= n; i += 2) {
				if (all_of(prime_num.begin(), prime_num.end(), [i](int a){return (i % a) != 0; })) {
					prime_num.push_back(i);
				}
			}
			result = prime_num.size();
		}

		cout << result << endl;
	}

	return 0;
}

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

using namespace std;
using ull = unsigned long long;
using ll = long long;
using lli = long long int;
using ld = long double;
using pa = pair<int,int>;
using ppa = pair<pa,int>;
#define SORT(v, n) sort(v, v+n);
#define ALL(v) v.begin(),v.end()
#define VSORT(v) sort(ALL(v))
#define GRESORT(v) sort(ALL(v),greater<ll>())
#define REVERSE(v) reverse(ALL(v))
#define overlap(v) v.erase(unique(ALL(v)),v.end())
#define debug(x) cout << #x << ": " << x << endl
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i = (b-1); i >= a; i--)
#define rrep(i,n) RFOR(i,0,n)
#define INF INT_MAX
#define SUP INT_MIN
#define mins(a,b) a = min(a,b)
#define maxs(a,b) a = max(a,b)

//4??????
//int dy[]={0, 1, 0, -1};
//int dx[]={1, 0, -1, 0};

//8??????
//int dy[]={0,0,1,-1,1,1,-1,-1};
//int dx[]={1,-1,0,0,1,-1,1,-1};

const ll MOD = 1000000007;

ll pow_mod(ll a,ll b,ll mod){
    ll tmp = 1;
    a %= mod;
    if(b > 0){
        tmp = pow_mod(a, b/2, mod);
        if(b % 2) tmp = (((tmp*tmp)%mod)*a)%mod;
        else tmp = (tmp*tmp)%mod;
    }
    return tmp;
}

int mm = 999999+1;
vector<bool> d(mm,true);

void hoge(){ FOR(i,2,mm) for(int j = 2; i*j <= mm; j++) d[i*j] = false; }

void solve() {
    vector<int> dp(mm,INF);
    int val;
    int m = 2;
    dp[m] = 1;
    d[0] = d[1] = dp[0] = dp[1] = 0;
    hoge();
    while(cin >> val){
        if(dp[val] == INF){
            FOR(i,m+1,val+1){
                dp[i] = dp[i-1] + (d[i] ? 1 : 0);
            }

            m = val;
        }
        cout << dp[val] << endl;
    }
}

int main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);

    solve();

    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>

int	main(){
	int	i,	k,	x,	cnt[1000001],	data[1000000];
	cnt[0]	=	0;
	data[0]	=	0;
	data[1]	=	0;
	for(i	=	2;	i	<=	1000000;	i++){
		data[i]	=	1;
	}
	for(i	=	2;	i	*	i	<=	1000000;	i++){
		if(data[i]){
			for(k	=	2	*	i;	k	<=	1000000;	k	+=	i){
				data[k]	=	0;
			}
		}
	}
	for(i	=	0;	i	<=	1000000;	i++){
		cnt[i	+	1]	=	cnt[i]	+	data[i];
	}
	while(scanf("%d",	&x)	!=	EOF){
		printf("%d\n",	cnt[x	+	1]);
	}
	return	0;
}

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

int judgeprime(long num){
  int primeflag=1,i;

  if(num%2==0){primeflag=0;}
  else for(i=3;i<sqrt(num);i+=2){

    if( num%i==0 ){
      primeflag=0;
      break;
    }

  }

  if(num==0||num==1||num==4){primeflag=0;}
  else if(num==2){primeflag=1;}

  return primeflag;

}

int main(void){
  long i,num;
  int much;

  while( scanf("%ld",&num) != -1 ){

    much=0;

    for(i=1;i<=num;i++){
      much+=judgeprime(i);
    }

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

  }

  return 0;  
}
04:57:02 ~/programming/AOJ 
$