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 <bits/stdc++.h>
#include <iomanip>
#include <math.h>
//#include <unistd.h>
//#include <stdio.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
const ll INF = 1LL << 60;
const ll mod = 1000000007;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
template<class T> inline bool chmax(T& a, T b){if(a < b){a = b; return true;}return false;}
template<class T> inline bool chmin(T& a, T b){if(a > b){a = b; return true;}return false;}
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}
ll fac[510000], finv[510000], inv[510000];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < 510000; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}


// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
/*
int main() {
    // 前処理
    COMinit();

    // 計算例
    cout << COM(100000, 50000) << endl;
}*/

//printf("%.10f\n", N);
/*
ll fibo(ll n){
    if(memo[n] != 0)return memo[n];
    if(n <= 1)return n;
    else return memo[n] = fibo(n - 1)+ fibo(n - 2);
}*/
/*  vector<ll> vec = {1,2,5,6,8,9,10};
    cout << binary_search(all(vec),5) << endl; -> true*/
/*
    vector<ll> vec = {1,2,5,6,8,9,10};
    auto n = upper_bound(all(vec),4);
    cout << *n << endl; -> 5*/
/*
    cout << fixed << setprecision(15);
*/

int main(){
    ll N;
    vector<bool> pr(1000001,true);
    pr[1] = false;
    pr[0] = false;
    rep(i,1001){
        if(pr[i]){
            for(ll j = i * 2;j <= 1000000;j += i){
                pr[j] = false;
            }
        }
    }
    vector<ll> num(1000001);
    for(ll i = 1;i <= 1000001;i++){
        if(pr[i])num[i] += num[i - 1] + 1;
        else num[i] += num[i - 1];
    }
   /*rep(i,20){
        cout << i << ":" << num[i] << endl;
    }*/
    while(cin >> N){
        cout << num[N] << endl;
    }
}

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


int main(){
	bool work[MAX];
	int num;

	// 初期化
	for(int i = 0; i < MAX; i++){
		if(i < 2){
			work[i] = false;
		}else{
			work[i] = true;
		}
	}

	// エラトネスのふるい
	for(int i = 2; i < sqrt((double)MAX) + 1; i++){
		if(work[i] == true){
			for(int j = i * 2; j < MAX; j += i){
				work[j] = false;
			}
		}
	}

	// 入力
	while( cin >> num){
		int ans = 0;

		// 計算
		for(int i = 0; i <= num; i++){
			if(work[i] == true){
				ans++;
			}
		}
		// 出力
		cout << ans << endl;

	}
	return 0;
}

C++: #include <stdio.h>

int main(){
	long sosuu[] = { 2, 3, 5 }, i, x, y = 3,n=0,z,d=0;
	while (scanf("%d", &n) != EOF){
		z = 0;
		if(d < n)
		{for (i = 3; i < n; i += 2){
			for (x = 0; x < y; x++){
				if (i % sosuu[x] == 0){ break; }
				if (x + 1 == y){ sosuu[y] = i, y++; d = i; }
			}
		}
	}
		for (i = 0; i < n; i++){ if (sosuu[i] > n + 1)break; z++; }printf("%d\n", z);
	}
	return 0;
}

C++: #include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cctype>
#include<list>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<vector>

using namespace std;

#define MAX_N 1000005
const int INF = 0x3f3f3f3f;

int prime[1000000];
int c[MAX_N];

void Prime_creat()
{
    int i,j;
    for(i=2; i<=1000000; i++)
    {
        if(prime[i])
        {
            c[i] = c[i - 1] + 1;
            for(j=i+i; j<=1000000; j+=i)
                prime[j]=0;
        }
        else
        {
            c[i] = c[i - 1];
        }
    }
}

int main()
{
    memset(prime, 1, sizeof(prime));
    Prime_creat();
    int n;

    while(~scanf("%d", &n))
    {
        printf("%d\n", c[n]);
    }

    return 0;
}

C++: #include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>

using namespace std;

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define rep(i,x) for(int i=0;i<(x);++i)
#define rep1(i,x) for(int i=1;i<=(x);++i)
#define rrep(i,x) for(int i=(x)-1;i>=0;--i)
#define rrep1(i,x) for(int i=(x);i>=1;--i)
#define FOR(i,a,x) for(int i=(a);i<(x);++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()

template<typename T>bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<typename T>T get(){T a;cin>>a;return a;}
template<typename T>T rev(T a){reverse(all(a));return a;}
template<typename T>istream&operator>>(istream&is,vector<T>&vec){rep(i,vec.size())is>>vec[i];return is;}
template<typename T>vector<T>&sort(vector<T>&a){sort(all(a));return a;}

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

const int inf = 1e9;
const ll linf = 3e18;

int sum[1000001];
bool prime[1000001];

void sieve()
{
    fill_n(prime, 1000001, true);

    prime[1] = false;

    for (int i = 2; i <= 1000000; ++i) {
        if (!prime[i]) continue;
        sum[i] = 1;
        for (int k = i + i; k <= 1000000; k += i) {
            prime[k] = false;
        }
    }
}

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

    sieve();

    for (int i = 2; i <= 1000000; ++i) sum[i] += sum[i - 1];

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

C++: #include<iostream>
#include<math.h>
using namespace std;
int prime(int x)
{
    int i,j=0,k,l;
    l=sqrt(x);
    for(i=2;i<=l;i++)
    {
        if(x%i==0)
        {
            j=1;
            break;
        }
    }
    if(j==1) return 1;
    else return 0;
}
int main()
{
    int i,s,j;
    while(cin>>i)
    {


    s=0;
    for(j=2;j<=i;j++)
    {
        if((prime(j))==0)
        {
            s+=1;
        }

    }
    cout<<s<<endl;
    }



    return 0;
}

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

int main(){
int n;
int b;
int c;
int d;
while(cin >> n){
int a[n+1];
b=1;
while(b<n+1){
a[b]=0;
b=b+1;}
a[1]=1;
d=0;
b=2;
while(b<n+1){
if(a[b]==0){d=d+1; c=2; while(1){if(c*b>n){break;} a[c*b]=1; c=c+1;}}
b=b+1;}
cout << d <<endl;}


}