Go: package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	var primeCount int
	for sc.Scan() {
		input := nextInt()
		for i := 0; i <= input; i++ {
			if IsPrime(i) {
				primeCount++
			}
		}
		fmt.Printf("%d\n", primeCount)
		primeCount = 0
	}
}

func IsPrime(num int) bool {
	switch {
	case num == 2 || num == 5:
		return true
	case num < 2 || num%2 == 0 || num%5 == 0:
		return false
	}
	sqrt := math.Sqrt(float64(num))
	for i := 3; i <= int(sqrt); i += 2 {
		if num%i == 0 {
			return false
		}
	}
	return true
}

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

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

C++: #include <bits/stdc++.h>
#include <chrono>
using namespace std;

using _i64 = int64_t;
using _u64 = uint64_t;
using _f64 = double;

#define _for(i, start, end) for(_i64 i = (_i64)start; i < (_i64)end; ++i)
#define _rep(i, number) _for(i, 0, number)
#define _foreach(e, data) for(auto& e : data)
#define _all(data) data.begin(), data.end()

template<typename type>
_i64 _size(const type& data) { return static_cast<_i64>(data.size()); }
template<typename type, size_t size>
_i64 _size(const type (&)[size]) { return static_cast<_i64>(size); }

enum _flag : bool { able = true, disable = false };

struct _time {
    _time(_flag flag) { check = flag; if(!check) { return; } gettime(start); }
    ~_time() {
        if(!check) { return; }; gettime(end);
        _i64 elapse = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cout << endl << "Time: " << elapse << " ms" << endl;
    }
    private:
    using _timer = chrono::time_point<chrono::system_clock>;
    _timer start, end; bool check;
    void gettime(_timer& time) { time = chrono::system_clock::now(); }
};

struct _ini { _ini() { ios::sync_with_stdio(false); cin.tie(nullptr); } } _ini;

_i64 _gcd(_i64 a, _i64 b) {
    return (max(a, b) % min(a, b) != 0 ? _gcd(min(a, b), max(a, b) % min(a, b)) : min(a, b));
}

int main() {
    {
        _time time(disable);
        _i64 n;
        vector<_i64> ans(1000000);
        ans[1] = 0; ans[2] = 1; ans[3] = 2; ans[4] = 2;
        for(_i64 i = 5; i < 1000000; i += 6) {
            for(_i64 j = 3; j <= sqrt(i) + DBL_EPSILON; j += 2) {
                if(i % j == 0) { ans[i] = ans[i - 1]; break; }
            }
            if(!ans[i]) { ans[i] = ans[i - 1] + 1; }
            ans[i + 1] = ans[i];
            for(_i64 j = 3; j <= sqrt(i + 2) + DBL_EPSILON; j += 2) {
                if((i + 2) % j == 0) { ans[i + 2] = ans[i + 1]; break; }
            }
            if(!ans[i + 2]) { ans[i + 2] = ans[i + 1] + 1; }
            ans[i + 3] = ans[i + 2];
            ans[i + 4] = ans[i + 3];
            ans[i + 5] = ans[i + 4];
        }
        while(cin >> n) { cout << ans[n] << endl; }
    }
    return 0;
}

C++: //
// エラトステネスの篩
//
// cf.
//   高校数学の美しい物語: エラトスネテスの篩
//     https://mathtrain.jp/eratosthenes
//
// verified
//   AOJ 0009 素数
//     http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0009&lang=jp
//

/*
 
    n 以下の素数をすべて列挙する
 
*/


#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;


vector<bool> isprime;
vector<int> Era(int n) {
    isprime.resize(n, true);
    vector<int> res;
    isprime[0] = false; isprime[1] = false;
    for (int i = 2; i < n; ++i) isprime[i] = true;
    for (int i = 2; i < n; ++i) {
        if (isprime[i]) {
            res.push_back(i);
            for (int j = i*2; j < n; j += i) isprime[j] = false;
        }
    }
    return res;
}


int main() {
    vector<int> primes = Era(1000000);
    int n;
    while (cin >> n) {
        int num = upper_bound(primes.begin(), primes.end(), n) - primes.begin(); // n 以下が何個か
        cout << num << endl;
    }
}

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

int main(void){
	int n;
	
	int i,j;
	int count = 0;
	int Flag = 0;
	
	while(scanf("%d",&n) != EOF){
		for(j = 2;j <= n;j++){
			for(i = 1;pow(i,2) <= j;i++){
				if(j % i == 0&&i != 1){
					Flag = 1;
					break;
				}
			}
			if(Flag != 1){
				count++;
			}
			Flag = 0;
		}
		printf("%d\n",count);
		count = 0;
	}
	return 0;
}

C++: #include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <stack>
#include <functional>
#include <queue>
#include <cmath>

#define rep(i,j,k) for(int i=j;i<k;i++)
#define drep(n,m) for(int i=0;i<n;i++)for(int j=0;j<m;j++)
#define fi first
#define se second
#define vi vector<int>
#define INF 1000000000
#define MOD 1000000009
#define pb push_back
#define mp make_pair
typedef long long ll;
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

using namespace std;

ll gcd(ll a,ll b){
    if(a<b){
        int t=a;a=b;b=t;
    }
    int c=a%b;
    while(c!=0){
        a=b;
        b=c;
        c=a%b;
    }
    return b;
}

ll lcm(ll a,ll b){
    return a*b/gcd(a,b);
}

bool isPrime(int x){
    if(x==1)return false;
    if(x==2)return true;
    if(x%2==0)return false;
    for(int i=3;i<=sqrt(x);i+=2){
        if(x%i==0)return false;
    }
    return true;
}

int main() {
   vector<int> v(1000000,0),rui(1000000,0);
   rep(i,1,999999)if(isPrime(i))v[i]=1;
   rui[1]=v[1];
   rep(i,2,999999)rui[i]=rui[i-1]+v[i];
   
   int n;
   while(cin>>n){
       cout<<rui[n]<<endl;
   }
   
    
    return 0;
}

C++: #include<stdio.h>
#include<iostream>
#include<string.h>
#include<vector>
#include<math.h>
#include<queue>
#include<algorithm>

using namespace std;

long store[999999];
//long storage[999999];
//int index=1;
bool IsPrime(long prime){
    if(prime==store[prime]){
        /*if(storage[index]!=0){
            storage[index]=storage[index]+1;
            index++;
        }*/
        return true;
    }
    //storage[index]=storage[index-1];
    //index++;
    bool ans=false;
    if(prime==2){
        store[prime]=prime;
        return true;
    }
    if(prime==3){
        store[prime]=prime;
        return true;
    }
    for(long i=2;i<=sqrt(prime);i++){
        if(prime%i==0) {
            return false;
        }
        else ans=true;
    }
    if(ans==true)   store[prime]=prime;
    return ans;
}

int main(){
    long n;

    //memset(storage,0,999999);
    while(scanf("%d",&n)==1){
        memset(store,-1,999999);
        long count=0;
        for(long i=n;i>0;i--){
            /*if(storage[i]!=0){
                count=count+storage[i];
                break;
            }*/
            if(IsPrime(i)==true)    count++;
        }
        printf("%ld\n",count);
    }

    return 0;
}

C++: #include <algorithm>
#include <cstring>
#include <stdio.h>
#include <vector>;
using namespace std;
const int maxn = 1e6+100;
bool prim[maxn];
vector <int> ve;

void get_prim() {
    prim[0] = prim[1] = true;
    for(int i=2;i<maxn;i++) {
        if(prim[i])
            continue;
        ve.push_back(i);
        for(int j=i*2;j<maxn;j+=i) {
            prim[j] = true;
        }
    }
}

int main() {
    int n;
    get_prim();
    while(scanf("%d",&n) != EOF) {
        int pos = lower_bound(ve.begin(),ve.end(),n) - ve.begin();
        if(ve[pos] > n)
            pos--;
        printf("%d\n",pos+1);
    }
    return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
int n;
int max=1;
while(cin>>n){
for(int i=3;i<=n;i+=2){
for(int j=2;j<=i/2+1;j++){
if(i%j==0){max++;goto A;}
}
A:
;
cout<<max<<endl;
max=1;
}
}