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<bits/stdc++.h>
#define N 1000000
using namespace std;

bool prime[N+5];
int C[N+5];

void seive(){
    memset(prime,true,sizeof(prime));
    prime[1]=false;
    for(int i=4;i<=N;i+=2) prime[i]=false;
    for(int i=3;i<=sqrt(N);i+=2){
        if(prime[i])
            for(int j=i*i;j<=N;j+=2*i)
                prime[j]=false;
    }
    //for(int i=1;i<N;i++) if(prime[i]) cout<<i<<endl;
    int c=0;
    for(int i=1;i<=N;i++){
        if(prime[i]) c++;
        C[i]=c;
        //cout<<C[i]<<endl;
    }
}

int main(){

    seive();
    int x;
    while(scanf("%d",&x)==1)
        printf("%d\n",C[x]);
}

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

int main(){
    int n, ans = 0;
    bool judge = true;
    while(cin >> n){
        for(int i = 2; i <= n; i++){
            for(int j = 2; j < i; j++){
                if(i % j == 0){
                    judge = false;
                    break;
                }
            }
            if(judge)
                ans++;
            else
                judge = true;
        }
        cout << ans << endl;
        ans = 0;
    }
    return 0;
}

C++: #include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
using namespace std;
int const M=31;
int a,hantei[M];

int main(){
  hantei[0]=hantei[1]=1;
  for(int i=2;i<M;i++){
    if(hantei[i]==0){
      for(int j=2;j*i<M;j++){
	hantei[j*i]=1;
      }
    }
  }
  for(;cin>>a;){
    int count=0;
    for(int i=0;i<=a;i++){
      if(hantei[i]==0)count++;
    }
    cout<<count<<endl;
  }
}

C++: #include <cstdio>
#include <vector>
#include <ctime>

using namespace std;

int main()
{
	int n;
	vector<int> prime;
	
	//unsigned long t = time(NULL);
	for (int i = 3; i < 1000000; i += 2){
		int j;
		for (j = 0; j < prime.size(); j++){
			if (i % prime[j] == 0){
				break;
			}
		}
		if (j >= prime.size()){
			prime.push_back(i);
		}
	}
	//printf("%lu\n", time(NULL) - t);
	while (scanf("%d", &n) != EOF){
		int count;
		
		for (count = 0; prime[count] <= n; count++){//;
			//printf("%d\n", prime[count]);
			;
		}
		if (n >= 2){
			count++;
		}
		printf("%d\n", count);
	}
	
	return 0;
}

C++: #include <iostream>
#include <cmath>
#include <vector>
using namespace std;
// have you mooed today?
bool isprime(int& num)
{
    static int c;
    static int max;
    if(num == 1) return false;
    if(num == 2) return true;
    if(num % 2 == 0) return false;
    max = ceil(sqrt(num));

    for(c=3; c < max+1; c+=2)
        if(num % c ==0) return false;
    return true;
}

int main()
{
    int ans =0;
    int c;
    int buff;
    vector<int> prime;
    for(c=1;c<=999999;c++)
    {
        if(isprime(c)) ans++;
        prime.push_back(ans);
    }
    while(cin >> buff)
    {
        cout << prime[buff -1] << endl;
    }
    return 0;
}

C++: #include <cstdio>
#define MAX 1000000
#define SQRT 1000
#define TRUE 1
#define FALSE 0
using namespace std;

int is_prime[MAX];
int prime_count[MAX];

void solve() {
  int cnt = 0;
  for (int i = 0; i < MAX; i++) {
    is_prime[i] = TRUE;
  }
  is_prime[0] = is_prime[1] = 0;
  for (int i = 2; i < MAX; ++i) {
    if (is_prime[i] == TRUE) {
      if (i < SQRT) {
        for (int j = i * i; j < MAX; j += i) {
          is_prime[j] = FALSE;
        }
      }
      cnt++;
    }
    prime_count[i] = cnt;
  }
}

int main() {
  solve();
  int n;
  while (~scanf("%d", &n)) {
    printf("%d\n", prime_count[n]);
  }
}

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

using namespace std;

#define MAX_VALUE 1000000

int get_numprime( int num );

int main(void)
{
	int num;

	while(1)
	{
		cin >> num;
		if( cin.eof() ) break;
		int result = get_numprime( num );
		cout << result << endl;
	}

	return 0;
}

int get_numprime( int num )
{
	int numprime = 1; // 2はカウント済み

	bool erat[MAX_VALUE] = {0};

	for( int i = 0 ; i < num+1 ; i++ )
	{
		erat[i] = true;
	}
	erat[0] = false; erat[1] = false;
	for( int i = 2 ; i <= num ; i++ )
	{
		if( erat[i] )
		{
			for( int j = i*2 ; j <= num ; j+=i )
			{
				erat[j] = false;
			}
		}
	}
	for( int i = 3 ; i <= num ; i+=2 )
	{
		if( erat[i] ) numprime++;
	}

	return numprime;
}

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

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

int main() {
	vector<int> v = vector<int>(1, 0);
	for (int i = 1; i < 1000000; i++) {
		if (prime(i)) {
			v.push_back(v.back() + 1);
		} else {
			v.push_back(v.back());
		}
	}
	int n;
	while (cin >> n) {
		if (n == 1) {
			cout << 0 << endl;
		} else {
			cout << v[n] + 1 << endl;	
		}
	}
}

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

int main(void){
        int n,i,j,c;
        int *p;
        while(scanf("%d",&n)!=EOF){
                c=0;
                if((p=(int *)malloc(sizeof(int)*(n+1)))==NULL){
                        return 1;
                }
                for(i=0;i<=n;i++){
                        p[i]=i;
                }
                for(i=2;i<=n;i++){
                        if(p[i]!=-1){
                                c++;
                                for(j=i;j<=n;j=j+i){
                                        p[j]=-1;
                                }
                        }
                }
                free(p);
                printf("%d\n",c);
        }
}

C++: #include<stdio.h>

int main(void)
{
	int data,i,j,k=0,l=0,kai=0,s[1000000]={0};

	while(scanf("%d",&data) != EOF)
	{
		if(data<=1)
		   kai=0;
		else
		{
			for(i=2;i<=data;i++)s[i]=i;

		    i=2;
			while(i*2<data)
			{
			  if(s[i] != 0)
			  {  
				 j=2;
				while(j*i<=data)
				{
					s[j*i]=0;
					j+=1;
				}
			  }
			  i+=1;
			}

			
			for(i=2;i<=data;i++)
			{	
				if(s[i]!=0)
				{
					kai+=1;
				}
			}
		}
		printf("%d",kai);
		kai=0;
	}

  return 0;
}

C++: //	created : 16/03/06
// 	autor   : Rp7rf
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <set>
typedef long long ll;
typedef unsigned long long ull;
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 ++)
#define vi vector<int>
#define mp make_pair
#define pb push_back
#define MOD 1000000007
#define INF 1e9
#define MAX 999999
bool prime[MAX];
int cnt[MAX];

void init_prime(){
	rep(i,MAX){
		prime[i] = true;
		
	}
	prime[0] = prime[1] = false;
	int c = 0;
	rep(i,MAX){
		if(prime[i]){
			for(int j = i + i ; j < MAX ; j += i){
				prime[j] = false;
			}
			c++;
		}
		cnt[i] = c;

	}
}

int main(void){
	init_prime();
	int n ;
	while(cin>>n){
		cout<<cnt[n]<<endl;
	}
}

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

int main(){
 int n,i,j,x,counter;
 cin >> n;
 counter = 0;
 
 for (i = 1; i <= n; i++) {
   x = 0;
   
   for (j = 1; j <= i; j++) {
     if (i % j == 0) x++;
   }
   
   if (x == 2) counter++;
 }
 
 cout << counter << endl;
 
 return 0;
}