Go: package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	for sc.Scan() {
		input := nextInt()
		fmt.Println(IsPrime(input))
	}
}

func IsPrime(num int) int {
	eratos := make([]bool, num+1)
	c := 0
	for i := 2; i < len(eratos); i++ {
		if eratos[i] == false {
			c++
			eratosCalc(i, eratos)
		}
	}
	return c
}

func eratosCalc(primeNum int, eratos []bool) {
	for i := primeNum * primeNum; i < len(eratos); i += primeNum {
		eratos[i] = true
	}
}

func next() string {
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

C++: // clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
template<typename V> constexpr typename V::value_type sum(const V &v) { return accumulate(all(v), 0); }
void solve();
main { solve(); return 0; }
// clang-format on

template<typename V>
void eratosthenes(V &v) {
  v[0] = v[1] = false;
  loop(i, 2, v.size()) v[i] = true;
  for (int i = 2; i * i < v.size(); i++) {
    if (v[i]) {
      for (int j = i * 2; j < v.size(); j += i) {
        v[j] = false;
      }
    }
  }
}

void solve() {
  vi v(1000000);
  eratosthenes(v);
  loop(i, 1, v.size()) v[i] += v[i - 1];
  int n;
  while (cin >> n) cout << v[n] << endl;
}

C++: #include <cstdio>

int main(){
	int n;
	static bool c[1000000]={true};
	static int t[1000000];t[0] = 0;
	for(int i = 2;i < 1000000;i++){
		for(int j = 2;i*j < 1000000;j++){
			c[i*j-1] = true;
		}
	}
	for(int i = 1;i < 1000000;i++){
		if(c[i])t[i]=t[i-1];
		else t[i] = t[i-1]+1;
	}
	while(scanf("%d", &n)){
		printf("%d\n", t[n-1]);
	}
	return 0;
}

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

int main(){
int n,a;
int pri[999999];
pri[0]=2;
int ans=1;
while(cin>>n){
for(int i=3;i<n+1;i++){
for(int j=0;j<ans;j++){
a=i%pri[j];
if(a==0){
break;}
if(j==ans-1){
pri[ans]=i;
ans++;
break;
}
}}
cout<<ans<<endl;}}

C++: #include <iostream>

using namespace std;

int pri(int n){
	int x = 0;
	int sum;
	
	for(int i = 1;i <= n;i++){
		sum = 0;
		for(int j = 1; j <= i; j++){
			if( i % j == 0) sum += j;
			if(sum == i + 1) x++;
		}
	}
	return x;
}

int main(){
	int n, x;
	while(cin >> n)
	
	cout << pri(n) << endl;
	
	return 0;
}

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

int main()
{
	int count=0,n;
	bitset<1000001> prime;

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

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

bool primes[1000000+1];

void Sieve() {
    for(int i = 2; i < 1000000; i++) {
      primes[i] = true;
    }
    /* 素数でない整数を false にする */;
    primes[1] = false;
    for(int i = 2; i <= 1000; i++) {
        if(primes[i]) {
            int p = i;
            for(int j = p + p; j <= 1000000; j+=p) {
                primes[j] = false;
            }
        }
    }
}

bool IsPrime(int n) {
	return primes[n];
}

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

C++: #include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <queue>
#include <map>
#include <fstream>
#include <array>
#include <utility>
#include <functional>

using namespace std;
typedef long long Int;
#define REP(i , x) for(int i = 0 ; i < x ; ++i)

typedef pair<int, int> P;

bool dp[10000100];

int main()
{
	int N;
	while (cin >> N){
		long ans(0);
		dp[0] = dp[1] = true;
		for (int i = 2; i*i <= N; ++i){
			if (!dp[i]){
				for (int j = 2*i; j <= N; j += i)
					dp[j] = true;
			}
		}
		for (int i = 2; i <= N; ++i){
			ans += !dp[i];
		}
		cout << ans << endl;
	}
}

C++: #include<bits/stdc++.h>
using namespace std;
int n;
const int MAX=1e6+5;
bool shibushi[MAX];
int counts[MAX];
void isprime()
{
	memset(shibushi,true,sizeof(shibushi));
	int c=0;
	counts[1]=0;
	for(int i=2;i<MAX;i++)
	{
		if(shibushi[i])
		{
			counts[i]=++c;
			for(int j=2*i;j<MAX;j+=i)
			shibushi[j]=false;
		}
		else counts[i]=c;
	}
}
int main()
{
	isprime();
	while(cin>>n)
	{
		if(n<=0) cout<<0<<endl;
		else cout<<counts[n]<<endl;
	}
	return 0;
}

C++: #include <cstdio>
#include <algorithm>
using namespace std;

int n;
bool is_composite[1000001];

int main() {
  while (1) {
    if (scanf("%d", &n) != 1) break;

    fill(is_composite, &is_composite[n+1], false);
    
    int cnt = 0;
    for (int i=2; i<=n; i++) {
      if (!is_composite[i]) {
        cnt++;
        for (int j=i+i; j<=n; j+=i) is_composite[j] = true;
      }
    }

    printf("%d\n", cnt);
  }
}

C++: #include <iostream>
using namespace std;
const int MAX_N =1000000;
int main(){
	bool sosu[MAX_N]={};//false:sosu
	for(int i=2;i<MAX_N;i++){
		if(!sosu[i]){
			for(int j=2;j*i<MAX_N;j++){
				sosu[j*i]=true;
			}
		}
	}
	for(int n;cin>>n;){
		int ans=0;
		for(int i=2;i<=n;i++){
			if(!sosu[i])ans++;
		}
		cout<<ans<<endl;
	}
    return 0;
}

C++: #include <iostream>
#include <math.h>
using namespace std;
int main() {
	unsigned long long int i;
	int n, p, cnt,fg;
	while (cin >> n) {
		i = 3;
		cnt = 1;
		fg = 0;	
		
		if ((int)log10(n) == 3) {
			cnt = 168;
			i = 1001;
		}
		else if ((int)log10(n) == 4) {
			cnt = 1229;
			i = 10001;
		}
		else if ((int)log10(n) == 5) {
			cnt = 9592;
			i = 100001;
		}

		if (200000 < n) {
			cnt = 17984;
			i = 200001;
		}
		if (300000 < n) {
			cnt = 25997;
			i = 300001;
		}
		if (400000<n) {
			cnt = 33860;
			i = 400001;
		}
		if (500000 < n) {
			cnt = 41538;
			i = 500001;
		}
		if (600000<n) {
			cnt = 49098;
			i =600001;
		}
		if (700000<n) {
			cnt = 56543;
			i = 700001;
		}
		if (800000<n) {
			cnt = 63951;
			i = 800001;
		}
		if (900000<n) {
			cnt = 71274;
			i = 900001;
		}



		for (; i <= n; i+=2) {
			for (int j = 3; j <= (int)sqrt(i); j += 2) {
				if (i%j == 0) {
					fg = 1;
					break;
				}
			}
			if (fg)
				fg = 0;
			else
				cnt++;
		}
		if (n == 1)
			cnt--;
		cout << cnt << endl;
	}

	return 0;
}

C++: #include<iostream>
using namespace std;
#define rep(i,a) for(int i = 0 ; i < a ; i ++)
#define loop(i,a,b) for(int i = a ; i < b ; i ++)
const int M = (1e6);
bool p[M];
void isPrime(){
  rep(i,M)p[i] = true;
  p[0] = p[1] = false;
  loop(i,2,M){
    if(p[i])
      for(int j = i + i ; j < M ; j += i)
	p[j] = false;
  }
}
int main(void){
  isPrime();
  int n;
  while(cin>>n){
    int res = 0;
    rep(i,n+1)res += p[i];
    cout<<res<<endl;
  }
}