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<cstdio>
using namespace std;
const int N = 1000000;
int IsPrime[N];
int main(){

  IsPrime[0] = 1;
  IsPrime[1] = 1;
  for(int i=2; i<=N;i++){
    if(IsPrime[i]==0){
      for(int j=2*i; j<=N; j+=i)
        IsPrime[j] = 1;
      }
  }
  int max;
  while(~scanf("%d",&max)){
    int count=0;
    for(int i=1; i<max+1; i++)
      if(IsPrime[i]==0) count++;
    printf("%d\n",count);
  }
}

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

int main()
{
	int count=1,n,flag;
	
	while(cin>>n)
	{
		if(n<=1) 
		{
			cout<<0<<endl;
		}

		else{
		for(int i=3;i<=n;i+=2)
		{
			flag=1;
			for(int j=3;j<=sqrt(i);j+=2)
				if(i%j==0)
				{
					flag=0;
					break;
				}
			if(flag==1)
				count++;
		}
		cout<<count<<endl;
		count=1;}
	}
}

C++: #include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>

using namespace std;

bool t[1000000];

int main(){
	memset(t,1,sizeof(t));
	t[0] = t[1] = false;
	for(int i = 2; i < 1000; i++){
		if(t[i])
			for(int j = 2 * i; j < 1000000; j += i){
				t[j] = false;
			}
	}

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

	return 0;
}

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

int status[1000000];

int main()
{
	int t, sq, i, j, count=0;

	scanf("%d",&t);

	sq=sqrt(t);

	for(i=0;i<=t;i+=2)
	{
	    status[i]=1;
	}
    status[1]=1;
    status[2]=0;
	for(i=3;i<=sq;i+=2)
	{
	    if(status[i]==0)
	    {
	        for(j=i*i;j<=t;j+=i)
    	    {
    	        status[j]=1;
    	    }
	    }
	}

	for(i=0;i<=t;i++)
	{
	    if(status[i]==0)
	    {
            count++;
	    }
	}

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

	return 0;
}

C++: #include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <utility>
#include <algorithm>
#include <numeric>
#include <typeinfo>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": #"<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;

void Eratosthenes(int n,vi& primes)
{
	primes.assign(n+1,0);
	repi(i,2,n+1)
		primes[i]=1;
	repi(i,2,n+1){
		if(primes[i]==0)
			continue;
		for(int j=i+i;j<=n;j+=i)
			primes[j]=0;
	}
}

int main()
{
	for(int n;cin>>n;){
		vi primes;
		Eratosthenes(n,primes);
		cout<<count(allof(primes),1)<<endl;
	}
	
	return 0;
}

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