Go: package main

// https://ja.wikipedia.org/wiki/%E3%82%A8%E3%83%A9%E3%83%88%E3%82%B9%E3%83%86%E3%83%8D%E3%82%B9%E3%81%AE%E7%AF%A9

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

var scanner = bufio.NewScanner(os.Stdin)

func nextString() string {
	scanner.Scan()
	return scanner.Text()
}

func nextInt() (int, error) {
	return strconv.Atoi(nextString())
}

func main() {
	scanner.Split(bufio.ScanWords)

	for {
		n, err := nextInt()
		if err != nil {
			break
		}
		maybePrime := make([]bool, n+1)
		for i := 0; i <= n; i++ {
			maybePrime[i] = true
		}

		maybePrime[0] = false
		maybePrime[1] = false
		for i := 2; i <= int(math.Sqrt(float64(n)))+1; i++ {
			j := i * 2
			for j <= n {
				maybePrime[j] = false
				j += i
			}
		}

		nPrimes := 0
		for _, p := range maybePrime {
			if p {
				nPrimes++
			}
		}
		// fmt.Println(maybePrime)
		fmt.Println(nPrimes)
	}
}

C++: #include <stdio.h>
#include <string.h>
int main(void){
    int n=999999,a,b,c;
    int x[1000000];
    memset(x,0,sizeof(x));
    for(a=2,c=0;a<=n;a++){
        if(x[a]){x[a]=c;continue;}
        x[a]=++c;
        for(b=a*2;b<=n;b+=a)x[b]=-1;
    }
    while(~scanf("%d",&n)){
        printf("%d\n",x[n]);
    }
    return 0;
}

C++: #include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;
#define NUM 10000000
bool is_prime[NUM];
int dp[NUM];
int main(void) {
    for (int i = 0; i < NUM; i++) {
        is_prime[i] = true;
        dp[i] = 0;
    }
    is_prime[0] = is_prime[1] = false;
    for (int i = 2; i * i < NUM; i++) {
        if (is_prime[i]) {
            for (int j = 2; i * j < NUM; j++) {
                is_prime[i*j] = false;
            }
        }
    }
    for (int i = 1; i < NUM; i++) {
        if (is_prime[i]) dp[i] = dp[i-1] + 1;
        else dp[i] = dp[i-1];
    }
    long long n;
    while (cin >> n) {
        cout << dp[n] << endl;
    }
    return 0;
}

C++: #include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
using namespace std;
typedef pair<int, int> P;

int prime[1000010];
bool isPrime[1000010];
int sum[1000010];
void sieve(int n){
    rep(i, 0, n) isPrime[i] = true;
    int now = 0;
    isPrime[0] = isPrime[1] = false;
    rep(i, 2, n){
        if(isPrime[i]){
            prime[now++] = i;
            for(int j = 2 * i; j < n; j += i) isPrime[j] = false;
        }
    }
    return;
}

signed main(){
    sieve(1000000);
    rep(i, 1, 1000000){
        sum[i] += sum[i - 1];
        if(isPrime[i]) sum[i]++;
    }
    int n;
    while(cin >> n){
        cout << sum[n] << endl;
    }
}

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

int main(){

	int n,count=0;
	while(cin>>n){

		for(int i=2; i<=n; i++){
			int num = 0;
			for(int 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;
const int MAX = 1000000;

int main(){
	bool b[MAX] = {true};
	static int a[MAX] = {0,0};
	int n;
	for(int i = 2;i < MAX;i++){
		if(!b[i]){
			for(int j = 2;i*j < MAX;j++){
				b[i*j] = true;
			}
		}
		a[i] = a[i-1] + !b[i];
	}
	while(cin >> n){
		cout << a[n] << endl;
	}
	return 0;
}

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

int main(){
    vector<int> isprime;
    int n;
    while (cin >> n){
	for (int i = 0; i <= n; i++) isprime.push_back(1);
	
	int prime = 0;
	for (int i = 2; i <= n; i++){
	    if (isprime[i]){
		prime++;
		for (int j = 2; i * j <= n; j++) isprime[i*j] = 0;
	    }
	}
	cout << prime << endl;
	isprime.clear();
    }
    return 0;
}

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

bool isPrime(int x){
  if(x == 0 || x == 1) return false;

  for(int i = 2; i * i <= x; i++){
    if(x % i == 0){
      return false;
    }
  }
  return true;
}

int main(){
  int n;

  while(cin >> n){
    int res = 0;

    for(int i = 2; i <= n; i++){
      if(isPrime(i)){
	res++;
      }
    }

    cout << res << endl;
  }
}

C++: #include <iostream>
#include <vector>
#include <math.h>

bool is_prime(std::vector<int> &primes, int n){
	bool ret = true;
	int max_i = sqrt(n);

	for(int i = 0; i < primes.size(); i++){
		if(primes[i] > max_i){break;}
		if(n % primes[i] == 0){
			ret = false;
			break;
		}
	}
	return ret;
}

int main(int argc, char **argv){
	int n = 0;
	std::vector<int> primes;

	primes.push_back(2);

	while(std::cin >> n){
		int num_primes = 1;
		for(int i = 3; i <= n; i += 2){
			if(is_prime(primes, i)){
				num_primes++;
				if(i > primes.back()){
					primes.push_back(i);
				}
			}
		}

		std::cout << num_primes << std::endl;
	}
	return 0;
}

C++: #include<iostream>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<string>
#include<queue>
#include<complex>
#include<numeric>
#include<bitset>
#define INF 1001001001
#define EPS 0.000001

using namespace std;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef pair<int,int> pint;

int memo[1000000];

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

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

#define max 1000000

int main(){
	bool is_prime[max] = {};
	for (int i = 2; i < max; ++i) {
		is_prime[i] = 1;
	}
	for (int i = 0; i < max; ++i) {
		if (is_prime[i]) {
			for (int j = i; j < max; j += i) {
				is_prime[j] = 0;
			}
		}
	}
	int num_prime[max] = {};
	for (int i = 1; i < max; ++i) {
		num_prime[i] = num_prime[i-1] + is_prime[i];
	}
	int n;
	while (cin >> n) {
		cout << num_prime[n] << endl;
	}
	return 0;
}

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

int main(void){
  int n;
  bool p[1000000];
  p[0] = p[1] = 0;
  p[2] = 1;
  int ans = 0;
  bool flag;
  for(int i = 0; i < 1000000; i++)
    p[i] = false;
  p[2] = true;
  for(int i = 3; i <= 1000000; i += 2){
    flag = true;
    for(int j = 3; j * j <= i; j += 2){
      if(i % j == 0){
	flag = false;
	break;
      }
    }
    if(flag)
      p[i] = true;
  }
  // cout << "end" << endl;
  while(cin >> n){
    int ans = 0;
    for(int i = 2; i <= n; i++){
      if(p[i])
	ans++;
    }
    cout << ans << endl;
  }
  return 0;
}

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

using namespace std;

#define N 100000

int main(){

    bool primes[N];
    int  n; 

    fill(primes, primes + (sizeof primes / sizeof *primes), true);
   
    primes[0] = false;
    primes[1] = false;
    
    for(int i = 2; i < N; ++i){
        if(primes[i]){
            for(int j = i + i; j < N; j += i)primes[j] = false;
        }
    }

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

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

int main()
{
	int N = 0;
	while(cin >> N)
	{
		vector < int > v;
		v.resize(N+1);

		for(int i = 0; i <=N; ++i)
		{
			if(i >= 2)
			{
				v[i] = 1;
			} else {
				v[i] = 0;
			}
		}

		for(int i = 2; i <= sqrt((double)N); ++i)
		{
			for(int j = 0; i*(j+2) <= N; ++j)
			{
				v[i*(j+2)]=0;
			}
		}

		int count = 0;
		for(int i = 0; i <= N; ++i)
		{
			if(v[i]==1)
				count++;
		}

		cout << count << endl;

	}

	return 0;
}