Go: package main

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

func main() {
    var limit = 1000000
    var root = 1000
    var isPrime [1000000]bool
    for i := 0; i < limit; i++ {
        isPrime[i] = true
    }
    isPrime[0] = false
    isPrime[1] = false
    for i := 2; i <= root; i++ {
        if isPrime[i] {
            for j := i * i;j < limit; j+=i {
                isPrime[j] = false
            }
        }
    }
    var primeCnt [1000000]int
    var cnt = 0
    for i := 0; i < limit; i++ {
        if isPrime[i] {
            cnt++
        }
        primeCnt[i] = cnt
    }

    var sc = bufio.NewScanner(os.Stdin)
    for sc.Scan() {
        n, _ := strconv.Atoi(sc.Text())
        fmt.Println(primeCnt[n])
    }
}

C++: #include <iostream>

using namespace std;

int main()
{
    int n;
    long cnt;
    bool flag;

    while (cin >> n) {
        if (n < 2) {
            cout << "0\n";
            continue;
        }
        else if (n == 2) {
            cout << "1\n";
            continue;
        }
        else if (n == 3) {
            cout << "2\n";
            continue;
        }
        
        cnt = 2;
        for (int i = 5; i <= n; i += 2) {
            flag = false;
            for (int j = 3; j * j <= n; j += 2) {
                if (!(i % j)) {
                    flag = true;
                    break;
                }
            }
            if (!flag)
                cnt++;
        }
        cout << cnt << endl;
    }
    
    return 0;
}

C++: #include <stdio.h>

using namespace std;

int calcLimit(int n){
	int limit;
	for(limit=0;limit*limit<=n;limit++);
	return limit-1;
}

int main(){
	int n,count,limit;

	while(scanf("%d",&n)!=EOF){
		count=0;
		int* array = new int[n+1];
		for(int i=1;i<=n;i++)array[i]=0;
		limit = calcLimit(n);
		for(int i=2;i<=limit;i++){
			if(array[i] == 0)
			{
				for(int j=2*i;j<=n;j+=i){
					if(array[j]==0){
						array[j]=1;
						count++;
					}
				}
			}
		}
		printf("%d\n",n-(count+1));
	}

    return 0;
}

C++: #include<iostream>
#include<cmath>
using namespace std;
int main(){
  int n,k,s=1,sosuu[100010]={2};
  for(int i=3;i<=999999;i+=2){
    k=0;
    for(int j=3;j<=sqrt(i);j+=2){
      if(i%j==0){
	k=1;
	break;
      }
    }
    if(k==0){
      sosuu[s]=i;
      s++;
    }
  }
  while(cin>>n){
    int a=0;
    for(a=0;sosuu[a]<=n;a++){
      if(sosuu[a]==999983){
	a++;
	break;
      }
    }
    cout<<a<<endl;   
  }
  return 0;
}

C++: __bowl1 = Array.new
__bowl2 = Array.new
__bowl3 = Array.new
__bowl4 = Array.new
__bowl5 = Array.new

india = gets.chomp.to_i
loop do
  srilanka = gets.chomp.to_i
  __bowl.push(srilanka)
  thai = gets.chomp.to_i
  puts __bowl.pop - thai

  india -= 1
  if india == 0
    break
  end
end

C++: #include <iostream>
#include <list>
#include <algorithm>

int main(){
	int NUM;
	while(std::cin >> NUM){
		std::list<int> numList,primeList;
		for(int i=2;i<=NUM;++i){
			numList.push_back(i);
		}
	
		for(int i=numList.front();i<std::sqrt(NUM);i=numList.front()){
			primeList.push_back(i);
			numList.erase(std::remove_if(numList.begin(),numList.end(),[&](int num){return num%i==0;}),numList.end());
		}
		int cnt=numList.size()+primeList.size();	
		std::printf("%d\n",cnt);
		}
	return 0;
}

C++: #include <iostream>
#include <iomanip>
#include <list>
#include <map>
#include <algorithm>
#include <stack>
#include <string>

using namespace std;


int main(){
	int n = 0;
	int count = 0;
	bool flag = false;
	while(cin >> n){
		for(int i = 0; i < n; i++){
			if(i == 2){
				count++;
			}
			else if(i % 2 != 0){
				for(int j = 3; j * j <= i; j += 2){
					if(i % j == 0){
						flag = true;
					}
				}
				if(flag != true){
					count++;
				}
			}
			flag = false;
		}

		cout << count << endl;

	}

	return 0;
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <stdio.h>

#define MAX 1000000

using namespace std;

int main()
{
	char p[MAX]={1,1};
	int n,ans;

	for(int i=2;i*i<=MAX-1;i++){
		if(p[i]==0){
			for(int j=i*2;j<MAX;j+=i) p[j]=1;
		}
	}

	while(cin>>n){
		ans=0;
		for(int i=2;i<n;i++){
			 if(p[i]==0) ans++;
		}
		cout<<ans<<endl;
	}
	return 0;
}

C++: //C++14 (Clang 3.8.0)

#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <string>
using namespace std;

typedef long long ll;
/*
bool is_prime(int n){
    for (int i = 2; i*i<=n;i++){
        if(n%i==0) return false;
    }
    return n!=1;
}
*/
vector<int> divisor(int n){
    vector<int> res;
    for( int i=1;i*i<n;i++){
        if(n%i==0){
            res.push_back(i);
            if(i!=n/i)res.push_back(n/i);
        }
        
    }
    return res;
}
map<int,int> prime_factor(int n){
    map<int,int> res;
    for(int i=2;i*i;i++){
        if(n%i==0){
            res[i]++;
            n=n/i;
        }
    }
    if(n!=1)res[n]=1;
}


const ll MAX_N=1000000;
//ll prime[MAX_N];
bool is_prime[MAX_N];

int sieve(int n){
    
    ll p=0;
    for(ll i=0;i<=n;i++) is_prime[i]=true;
    cout<<n<<endl;
    is_prime[0]=is_prime[1]=false;
    for(ll i=2;i<=n;i++){
        if(is_prime[i]){
            //prime[p++]=i;
            p++;
            for(ll j=i*2;j<=n;j+=i){
                is_prime[j]=false;
            }
        }
    }
    return p;
}

int main(){
    ll a;
    while(scanf("%lld", &a)!=EOF){
        cout<<sieve(a)<<endl;
    }
    return 0;}

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

using namespace std;

constexpr int ceil_sqrt(int x) {
  int ans = 0;
  while (ans*ans < x) { ++ans; }
  return ans;
}

template<int size>
struct Sieve {
  constexpr Sieve(): factor(), primes() {
    factor[0] = factor[1] = 1;
    for (int p = 2; p < size; ++p) {
      primes[p] = primes[p-1] + (factor[p]?0:1);
      if (factor[p]) { continue; }
      for (int n = 2*p; n < size; n += p) {
        factor[n] = p;
      }
    }
  }
  constexpr bool is_prime(int n) const {
    assert(n < size);
    return !(factor[n]);
  }
  int factor[size];
  int primes[size];
};

constexpr int NMAX = 1200000;
constexpr auto sieve = Sieve<NMAX>();

int main() {
  int N = 0;
  while (cin >> N) {
    cout << sieve.primes[N] << endl;
  }
  return 0;
}

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

/*void judge(int n){
	bool arr[1000003];
	for(int i = 2; i < 1000003; i++) arr[i] = true;
}
*/

int main(){
	bool arr[1000003];
	int n,count = 0;
	cin >> n;
	for(int i = 2; i < 1000003; i++) arr[i] = true;

	for(int i = 2; i < sqrt(n); i++){
		if(arr[i]) {
			for(int j = 0; i * (j + 2) <= n; j++) {
				arr[i * (j + 2)] = false;
			}
		}
	}
	for(int i = 2; i <= n; i++){
		if(arr[i]) count++;
	}

	cout << count << "\n";
}

C++: #include<iostream>
#include<vector>
#define MAX 1000000
using namespace std;
int main(){
    vector<int> v(MAX);
    for(int i = 0;i<MAX;i++)
      v[i]=true;

      v[0]=false;
      v[1]=false;
    for(int i = 2;i<MAX;i++){
      if(v[i]==true){
        for(int j = i;j<MAX;j=j*j){
         v[i]=false;
       }
      }
    }
    for(int i = 2;i<MAX;i++)v[i]+=v[i-1];
    while(true){
      int a;
      cin >> a;
      if(cin.eof())return 0;
      cout << v[a]<<endl;
    }
}

C++: #include <iostream>

using namespace std;

int main()
{
    long kazu;
    
    while (cin>>kazu)
    {
        int sosuu=0,kari;
        
        for (int i=1; i<=kazu; i++)
        {
            kari=0;
            
            for (int j=1; j<=i; j++)
            {
                
                if (i%j==0)
                    kari++;
                
            }
            
            if (kari==2)
                sosuu++;
            
        }
        
        
        cout<<sosuu<<endl;
    }
    
}