Go: package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	for sc.Scan() {
		a, _ := strconv.Atoi(sc.Text())
		fmt.Println(countPrime(a))
	}
}

func countPrime(a int) int {
	primes := make([]bool, a+1)
	n := 0
	for i := 2; i <= a; i++ {
		if primes[i] == false {
			n++
			for j := i * i; j <= a; j += i {
				primes[j] = true
			}
		}
	}
	return n
}

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

int main() {

    vector<bool> primes (1000000);
    for (int n = 0; n < 1000000; n++) {
        primes[n] = true;
    }
    primes[0] = false;
    primes[1] = false;

    for (int n = 2; n < 1000000; n++) {
        if (primes[n]) {
            for (int k = 2*n; k < 1000000; k = k+n) {
                primes[k] = false;
            }
        }
    }

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

C++: #include<stdio.h>
#include<math.h>
main(){int i,j,n,p[1000000];scanf("%d",&n);for(i=2;i<=n;i++)p[i]=1;for(i=2;i<n;i++)if(p[i])for(j=2;i*j<=n;j++)p[i*j]=0;j=0;for(i=2;i<=n;i++)j+=p[i];printf("%d\n",j);}

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

#define PRIME_FLG_SIZE 1000000
#define PRIME_SUM_SIZE 1000000

bool primeFlg[PRIME_FLG_SIZE]; //[i]テ」ツ?古ァツエツ?ヲツ閉ーテ」ツ?凝」ツ?ゥテ」ツ??」ツ?凝」ツ?ョテァツョツ。テァツ青?
int primeSum[PRIME_SUM_SIZE]; //[0, i]テ」ツ?ョテゥツ鳴禿」ツ?ォテ・ツュツ佚・ツ慊ィテ」ツ?凖」ツつ凝ァツエツ?ヲツ閉ーテ」ツ?ョテヲツ閉ーテ」ツ?ョテァツョツ。テァツ青?

//テ」ツつィテ」ツδゥテ」ツδ暗」ツつケテ」ツδ?」ツδ催」ツつケテ」ツ?ョテ」ツ?オテ」ツつ凝」ツ??
void erato(){
  fill(primeFlg, primeFlg + PRIME_FLG_SIZE, true);
  primeFlg[0] = primeFlg[1] = false;

  for(int i = 2; i * i < PRIME_FLG_SIZE; i++){
    if(!primeFlg[i]) continue;
    for(int j = i * i; j < PRIME_FLG_SIZE; j += i){
      primeFlg[j] = false;
    }
  }

  fill(primeSum, primeSum + PRIME_SUM_SIZE, 0);

  for(int i = 1; i < PRIME_SUM_SIZE; i++){
    bool isPrime = primeFlg[i];
    primeSum[i] = primeSum[i - 1] + (isPrime ? 1 : 0);
  }
}

int main(){
  erato();

  int n;

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

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

class PrimeNumbers
{
public:
	vector<int> primeNumbers;

	PrimeNumbers()
	{
		this->createPrimeNumbers();
	}
	
	int answer(int N)
	{
		int result = 0;
		for(auto it = this->primeNumbers.begin(); it != this->primeNumbers.end(); it++)
		{
			if(*it <= N)result++;
			else break;
		}
		return result;
	}

	bool checkOf(int n)
	{
		if(n % 2 == 0)return false;

		bool prime = false;
		for(auto it = this->primeNumbers.begin(); it != this->primeNumbers.end(); it++)
		{
			if(n == *it)
			{
				prime = true;
				break;
			}
		}
		return prime;
	}

	void createPrimeNumbers()
	{
		int max_number = 100000;
		this->primeNumbers = vector<int>();
		this->primeNumbers.push_back( 2 );
		for(int i = 3; i < max_number; i += 2)
		{
			bool prime = true;
			for(auto it = this->primeNumbers.begin(); it != this->primeNumbers.end(); it++)
			{
				if(i % *it == 0)
				{
					prime = false;
					break;
				}
			}
			if(prime)
			{
				this->primeNumbers.push_back(i);
			}
		}
	}

};

int main()
{
	int N;
	PrimeNumbers pn = PrimeNumbers();
	while(cin >> N)
	{
		cout << pn.answer(N) << endl;
	}
	return 0;
}

C++: #define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <algorithm>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
using namespace std;
bool dp[1000001] = {};
int sosuu() {
	dp[1] = true;
	for (int i = 2;i <= 1000;++i) {
		if (dp[i] == false) {
			for (int q = 2;q <= 1000000 / i + 1;++q) {
				dp[i*q] = true;
			}
		}
	}
	return 0;
}
int main() {
	sosuu();
	int n = 0;
	while (cin >> n) {
		int count = 0;
		for (int i = 1;i <= n;++i) {
			if (dp[i] == false) count++;
		}
		printf("%d\n", count);
	}
}

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

int main()
{
	long int n,m;
	while(cin>>n){
		long int i;
		int number[n]={0};
		int ans=0;

		for(i=0;i<n;i++){
			if(number[i]==0){
				ans++;
				for(m=i;m<n;m+=i){
					number[i]=1;
				}
			}
		}
		cout<<ans<<endl;
	}
}

C++: #include <iostream>

using namespace std;

int main(){
	int n, x;
	while(cin >> 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++;
				}
			}
		}
		
		cout << x << endl;
	}
	
	return 0;
}

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

vector<int> primes;
bool is_prime[1000100];

void search_prime(int n){
	for(int i = 0; i <= n; ++i)
		is_prime[i] = true;
	is_prime[0] = is_prime[1] = false;
	for(int i = 2; i <= n; ++i){
		if(is_prime[i]){
			primes.push_back(i);
			for(int j = i * 2; j <= n; j += i)
				is_prime[j] = false;
		}
	}
}

int main() {
	search_prime(1000050);
	int n;
	while(cin >> n){
		if(n == 0 && n == 1){
			cout << "0" << endl;
		}
		else{
			int idx = lower_bound(primes.begin(), primes.end(), n) - primes.begin();
			if(primes[idx] != n)
				idx--;
			cout << idx << endl;
		}
	}
	return 0;
}

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

using namespace std;

#define REP(a, i, n) for (int i = a; i <= n; ++i)

bool isPrime(int n) {
    if (n == 1) return false;
    if (n == 2) return true;
    if (n % 2 == 0) return false;
    if (n == 3) return true;
    if (n % 3 == 0) return false;

    for (int i = 5; i <= sqrt(n); i += 2) {
        if (n % i == 0) {
            return false;
        }
    }
    return true;
}

//  n よりも小さい素数の数は何個存在するか
int main() {
    int n; // 10000
    scanf("%d", &n);

    int cnt = 0;
    REP(1, i, n) {
        if (isPrime(i)) cnt++;
    }

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

    return 0;
}

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

std::vector<int> PRIMES;

void init_primes(int max)
{
  if (max < 2) return;
  std::set<int> candidate;
  PRIMES.push_back(2);
  for (int i = 3; i < max; i+=2) {
    candidate.insert(i);
  }
  for (int i = 3; i < sqrt(max); i+=2) {
    std::set<int>::iterator it = candidate.find(i);
    if (it != candidate.end()) {
      PRIMES.push_back(i);
      int del_num = i;
      while (del_num < max) {
        it = candidate.find(del_num);
        if (it != candidate.end()) candidate.erase(it);
        del_num += i;
      }
    }
  }
  for (std::set<int>::iterator it = candidate.begin();
       it != candidate.end(); ++it) {
    PRIMES.push_back(*it);
  }
}

int main()
{
  const int max = 100000;
  init_primes(max);
  int i;
  while (std::cin >> i) {
    std::vector<int>::iterator it = PRIMES.begin();
    int n = 0;
    while (*it <= i) {
      n++;
      it++;
    }
    std::cout << n << std::endl;
  }
}

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

using namespace std;

int main() {
  int n;

  while(1) {
    cin >> n;
    if(cin.eof()) break;
    int m = (int)sqrt(n);
    
    vector<bool> h(n+1, true);
    h[0] = false;
    h[1] = false;

    for(int i = 2; i <= m; i++) {
      if(h.at(i)) {
	for(int s = 2; s*i < h.size(); s++) {
	  if(h.at(s*i))
	    h[s*i] = false;
	}
      }
    }
    
    int ans=0;
    for(auto f : h) {
      if(f)
	ans++;
    }
    cout << ans << endl;
  }
  
  return 0;
}

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

int main(){
	int n;
	int a=0;
	cin >> n;
		for(int i = 1; i <= n; ++i){
			for(int j = 2; j <= i; ++j){

				if(i%j == 0){
				if(i==j){
					++a;
				}else{
					break;
				}
				}
		}
	
	}
		cout << a << '\n';
}