Go: package main

import (
  "fmt"
  "math"
)

func main() {
  const N = 1000000
  var temp [N+1]bool
  for i:=0; i<N+1; i++ {
    temp[i] = true
  }
  temp[0] = false
  temp[1] = false
  for i:=2; i<int(math.Ceil(math.Sqrt(float64(N+1)))); i++{
    if (temp[i]){
      for j:=i*2; j<N+1; j+=i{
        temp[j] =false
      }
    }
  }
  var a int
  var b int
  for _, err := fmt.Scan(&a); err == nil; _, err = fmt.Scan(&a) {
    b = 0
    for i:=0; i<=a; i++{
      if temp[i] {
        b++
      }
    }
    fmt.Println(b)
  }
}

C++: #include <stdio.h>
#include<math.h>
int main()
{
    long long int n,m,i,j,k,l,a[1000000];
    for(i=0;i<100000;i++)
    {
        a[i]=i+1;
    }

    m=sqrt(1000000);

    for(i=2;i<=m;i++)
    {
        for(j=i+1;j<=1000000;j++)
        {
            if(a[j]%i==0) a[j]=0;
        }
    }

    while(scanf("%lld",&n)!=EOF)
    {
        k=0;
        for(i=0;i<n;i++)
        {
            if(a[i]==0)
            {

            }
            else
            {
                k++;
            }
        }
        printf("%lld\n",k-1);
    }
    return 0;
}

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

#define ll (long lon
#define REP(i,n) for(int i = 0;i<(int)n;i++)
#define FOR(i,a,b) for(int i = (a);i < (b);i++)
#define RFOR(i,a,b) for(int i = (a);i>(b);i--)

using namespace std;

int main (void){
    
    int number[40] = {0};
    int answer[40] = {0};
    int i = 0,j = 0,k = 0;
    while(cin >> number[i], i != 30)
    {
        for(k = number[i]; k>1;k--)
            for(int l = k-1;l>0;l--)
            {
                if(k == 2 && l == 1)
                {
                    answer[i]++;
                    break;
                }
                if(k % l == 0)
                    break;
                if(l == 2)
                {
                    answer[i]++;
                }

            }
        i++;
    }
    REP(j,i)
    cout << answer[j]<< endl;
    return 0;
    
}

C++: #ifndef HEADER_H
#define HEADER_H
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<vector>
#include<queue>
#include<string>
#include<string.h>
#include<map>
#include<set>
#include<algorithm>
#include<stack>
#include<ctype.h>
#include<cstdlib>
#include<cmath>

#define F(t,i,s,r) for(t i=s;i<r;i++)
#define FE(t,i,s,r) for(t i=s;i<=r;i++)
#define R(t,i,s,r) for(t i=s;i>r;i--)
#define RE(t,i,s,r) for(t i=s;i>=r;i--)

using namespace std;
//freopen("i.txt", "r", stdin);
//freopen("o.txt","w",stdout);
#endif
#define ll long long
vector<bool>isprime;
void seiveAtkin (ll n) {
	isprime.resize (n + 1, false);
	isprime[2] = true, isprime[3] = true;
	ll lim = ceil (sqrt (n)), num;
	FE (ll, x, 1, lim) {
		FE (ll, y, 1, lim) {
			num = 4 * x*x + y*y;
			if (num <= n && (num % 12 == 1 || num % 12 == 5)) {
				isprime[num] = true;
			}
			num = 3 * x*x + y*y;
			if (num <= n && num % 12 == 7) {
				isprime[num] = true;
			}
			if (x > y) {
				num = 3 * x*x - y*y;
				if (num <= n && num % 12 == 11) {
					isprime[num] = true;
				}
			}
		}

	}
	FE (ll, i, 5, lim) {
		if (isprime[i]) {
			for (ll j = i*i; j <= n; j += i) {
				isprime[j] = false;
			}
		}
	}
}
int main () {
	int n;
	seiveAtkin (999999);
	vector<int>count;
	count.resize (1000000, 0);
	FE (int, i, 1, 999999) {
		count[i] += count[i - 1];
		if (isprime[i]) {
			count[i]++;
		}
	}
	while (cin>>n)
	{
		cout<<	count[n]<<endl;
	}
}

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;
}