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 <iostream>
#include <cstdio>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <stack>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <cctype>
#include <complex>
#include <string>
#include <sstream>

using namespace std;

#define all(c) c.begin(),c.end()
#define rall(c) c.rbegin(),c.rend()
#define rep(i,n) for(int i=0;i<(n);i++)
#define tr(it,container) for(typeof(container.begin()) it = container.begin(); \
                                                  it != container.end(); ++it)
#define mp(a,b) make_pair((a),(b))
#define eq ==


const int N = 1000010;
bool isPrime[N];

void sieve(){
    for(int i=2;i<N;i++) isPrime[i] = true;
    for(int i=2;i*i<N;i++){
        if(not isPrime[i]) continue;
        for(int j=i*i;j<N;j+=i){
            isPrime[j] = false;
        }
    }
}

int main(){
    vector<int> C(N);
    sieve();
    C[0] = 0;
    for(int i=1;i<N;i++){
        if(isPrime[C[i]]){
            C[i] = C[i-1] + 1;
        }else{
            C[i] = C[i-1];
        }
    }
    int n;
    while(cin >> n){
        cout << C[n] << endl;
    }
    return 0;
}

C++: #include <iostream>
using namespace std;
const int MAX_V = 1000000; // 100????????§?´???°??¨?????????
int prime[MAX_V+1]; // 1????´???°???0????´???°??§?????? 
int pcount[MAX_V+1];
int main() {
    int i, k, v,a,sum=0;
    for(i = 2; i <= MAX_V; i++) {
        prime[i] = 1; // 2??\????´???°??¨??????
    } 
    for(i = 2; i*i <= MAX_V; i++) {
        if(prime[i]) {
            for(k = 2 * i; k <= MAX_V; k += i) {
                prime[k] = 0; // ?´???°2?????\????????°?´???°??§?????? 
            }
            
        } 
        
    }
    pcount[0]=0;
    pcount[1]=0;
    for(i=2;i<MAX_V;i++){
        if(prime[i]){
            sum++;
        }
        pcount[i]=sum;
    }
    while(scanf("%d",&a) != EOF) {
        printf("%d\n",pcount[a]);
    } 

    return 0; 
    
}

C++: import java.util.Scanner;

class Main {
	
	public static void main(String[] a) {
	
		String input;
		int datasetCount = 0;
		
		
		Scanner stdin = new Scanner(System.in);
		while (++datasetCount <= 30) {
			int primes = 0;
			input = stdin.nextLine();
			try {
				int n = Integer.parseUnsignedInt(input);
				
				if (n > 999999)
					break;
				
				for (int i = 2; i <= n; ++i) {
					
					if (isPrime(i))
						++primes;
					
				}
				
				System.out.print(primes);
				
				
			} catch (NumberFormatException nfe) {
				break;
			}
		}
		stdin.close();
	}
	
	
	private static boolean isPrime(int i) {
	
		for (int div = 2; div <= Math.sqrt(i); ++div) {
			if (i % div == 0)
				return false;
		}
		return true;
	}
}

C++: #include <iostream>
#include <cmath>
#define rep(i,N) for(int i = 0; i<(int)(N); i++)
#define REP(i,k,N) for(int i = k; i<(int)(N); i++)
using namespace std;
const int MAX_N = 10000010;
bool d[MAX_N];
int main(){
        int n;
        while(cin >> n) {
                rep(i,MAX_N) d[i]=true;
                for(int i = 2; i< sqrt(n+1); i++) {
                        if(d[i]) {
                                for(int j = 2; i*j<n+1; j++) {
                                        d[i*j]=false;
                                }
                        }
                }
                int ans = 0;
                REP(i,2,n+1){
                        if(d[i]) ans++;
                }
                cout << ans << endl;
        }

        return 0;
}

C++: main(){int i,j,n;char p[1000000];while(scanf("%d",&n)!=-1){for(i=2;i<=n;i++)p[i]=1;for(i=2;i<n;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++: #pragma  warning (disable:4996)
#include<iostream>
#include<cstdio>
#include<queue>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm>
#define MAX 1000000
using namespace std;
int amount[MAX];
int vis[MAX];
int prime[MAX];
int main(){
	//memset(vis, 0, sizeof(vis));
	//memset(prime, 0, sizeof(prime));
	fill(prime, prime + MAX, 1);
	prime[0] = prime[1] = 0;
	for (int i = 2; i*i <= MAX; i++){
		if (prime[i]){

			for (int j = i + i; j <= MAX; j += i){

				prime[j] = 0;
			}
		}
	}
	int sum = 0;
	for (int i = 0; i <= MAX; i++){
		if (prime[i]){
			sum++;
		}
		amount[i] = sum;
	}
	int n;
	while (cin >> n){
		cout << amount[n] << endl;
	}
	return 0;
}

C++: #include<iostream>
#include<math.h>
main(){int i,j,n,p[1000000];std::cin>>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];std::cout<<j<<"\n";}

C++: #include<stdio.h>



int main(){
	int n,i,j;
	bool c[100000];
	int data[100000];
	int count;
	c[0]=c[1]=0;
	for(i=2;i<100000;i++){
		c[i]=1;
	}

	while((scanf("%d",&n)!=EOF)&&(n!=0)){
		
		count=0;
		for(i=0;i*i<=n;i++){
			data[i]=count;
			if(c[i]==1){
				count++;
				for(j=i+1;j<=n;j++){
					if(j%i==0){
						c[j]=0;
					}
				}
			}
		}

		printf("%d",data[n]);
	}
	return 0;
}

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>
#include <vector>
using namespace std;

bool a[1000000] ;
int main(){
    a[0] = 1 ;
    a[1] = 1 ;
    vector<int> v ;
    for(int i=2;i<1000000/2;i++){
        if ( a[i] == 0 ){
            v.push_back(i);
            for(int j=i+i;j<1000000;j+=i){
                a[j] = 1 ;
            }
        }
    }

    int x ;
    while(cin >> x){
        long long c = 0 ;
        for(int i=0;i<v.size();i++){
            if ( v[i] > x ) break;
            c++;
        }
        cout << c << endl;
    }



    return 0 ;
}

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

int prime[1000000];


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


void get_prime(int max_num) {
  int primecount = 1;
  prime[2] = primecount;
  for (int i = 3; i <= max_num; i += 2) {
    if (isPrime(i))
      prime[i] = ++primecount;
    else
      prime[i] = primecount;
  }
}


int main () {
  int ns[31];
  int i = 0, max_num;
  while (std::cin >> ns[i]) {
    max_num = std::max(max_num, ns[i]);
    if (ns[i] % 2 == 0)
      ns[i] --;
    i ++;
  }
  get_prime(max_num);
  for (int j = 0; j < i; j ++) {
    std::cout << prime[ns[j]] << std::endl;
  }
  return 0;
}