Go: package main

import "fmt"

func main() {
	const MAX = 1000000
	prime := make([]int, MAX, MAX)
	check := make([]int, MAX, MAX)
	count := make([]int, MAX, MAX)

	prime[0] = 1
	prime[1] = 1

	// prime init
	for i := 2; i < MAX; i++ {
		if check[i] == 1 {
			continue
		}

		if prime[i] == 0 {
			for j := i * 2; j < MAX; j += i {
				check[j] = 1
				prime[j] = 1
			}
		}
	}

	for i := 2; i < MAX; i++ {
		cnt := 0

		if prime[i] == 0 {
			cnt = 1
		}

		count[i] = count[i-1] + cnt
	}

	for {
		var input int
		inputCount, _ := fmt.Scanf("%d", &input)
		if inputCount != 1 {
			break
		}

		fmt.Println(count[input])
	}
}

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

int main()
{
	const int N = 1000000;
	vector<bool> vec(N, true);
	double limit = sqrt(N);
	for (int i = 2; i < limit; i++){
		for (int j = 2; i * j < N; j++){
			vec[i * j] = false;
		}
	}
	int n, cnt = 0;
	while (cin >> n){
		for (int i = 2; i <= n; i++){
			if (vec[i])cnt++;
		}
		cout << cnt << endl;
		cnt = 0;
	}
}

C++: #include<iostream>
int fact(int x){
	int sx=0,sy=0;
	for(int i=2;i<x+1;i++){
		if(x%i==0)sx++,sy+=i;
	}
	if(sx==1)return x;
	else return sy+1;
}
int main(){
	int a;
	while(std::cin>>a){
		int n=0;
		for(int i=2;i<a+1;i++){
			if(i==fact(i))n++;
		}
		std::cout<<n<<std::endl;
	}
	
	return 0;
}

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

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

int main() {
	int n;
	while(scanf("%d",&n) != EOF) {
		int cnt=0;
		for(int i=2;i<=n;++i) {
			if(prime(i)) { ++cnt; } 
		}
		printf("%d\n",cnt);
	}
	return 0;
}

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

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

C++: //
//  main.cpp
//  TestCpp
//
//  Created by Shahab Uddin on 05/21/13.
//  Copyright (c) 2013 ___Shahab__. All rights reserved.
//

#include <cstdio>
#include <cmath>

bool isPrime (int p)
{
    if ( p < 2 ) return false;

    if ( p == 2 ) return true;

    int squareRoot = (int) sqrt (p);

    for ( int i = 2; i <= squareRoot; i++ ) {
        if ( p % i == 0 )
            return false;
    }

    return true;
}

int main(int argc, const char * argv[])
{
    int n;

    while ( scanf ("%d", &n) != EOF ) {
        int ans = 0;

        for ( int i = 2; i < n; i++ ) {
            if (isPrime(i)) ans++;
        }

        printf ("%d\n", ans);
    }

    return 0;
}

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

int main(){
	int n;
	int a=0;
	cin >> n;
		for(int i = 0; i < n; ++i){
			for(int j = 2; j <= i; ++j){

				if(i%j == 0){
				if(i==j){
					++a;
				}else{
					break;
				}
				}
		}
	
	}
		cout << a << '\n';
}

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

int count_prime( unsigned int const& n )
{
    if ( n <= 0 || 1000000 <= n ) return -1;
    std::vector<bool> memo_prime( n+1, true );
    for ( unsigned int i = 2; i < n; ++i )
    {
        for ( unsigned int j = 2; i*j <= n; ++j )
        {
            memo_prime.at(i*j) = false;
        }
    }
    memo_prime.at(0) = memo_prime.at(1) = false;
    memo_prime.at(2) = true;
    return std::count( memo_prime.begin(), memo_prime.end(), true );
}

int main()
{
    int n;
    while( std::cin >> n)
        std::cout << count_prime(n) << std::endl;
    return 0;
}

C++: #include<stdio.h>
const int MAX_V=1000000;
int prime[MAX_V+1];
int sum[MAX_V+2];
int main(){
  int i,k,n;
  for(i=2;i<=MAX_V;i++){
    prime[i]=1;
  }
  for(i=2;i*i<=MAX_V;i++){
    if(prime[i]){
      for(k=2*i;k<=MAX_V;k+=i){
        prime[k]=0;
      }
    }
  }
  for(i=0;i<MAX_V+1;i++){
    sum[i+1]+=sum[i]+prime[i];
  }
  while(scanf("%d",&n)!=EOF){
    printf("%d\n",sum[n+1]);
  }
  return 0;
}

C++: #include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define INF INT_MAX/3
#define ALL(a) (a).begin(),(a).end()
#define CLR(a) memset(a,0,sizeof(a))

typedef long long int ll;

using namespace std;

int main(){
    vector<int> primes;
    primes.PB(2);
    FOR(i,3,1000000){
	bool flg = true;
	for(int j=0;primes[j]*primes[j]<=i;j++){
	    if(i % primes[j] == 0 ) {
	    flg = false;
	    break;
	    }
	}
	if(flg) primes.PB(i);
	i++;
    }

    int n;
    while(true){
	cin >> n;
	if(cin.eof())break;
	int res = upper_bound(ALL(primes),n) - primes.begin();
	cout << res << endl;
    }

    return 0;
}

C++: #include <iostream>
#include <stdio.h>
#include <algorithm>
#include <functional>

using namespace std;

#define MAXN 1000016

int isprime[MAXN];

void sieve(int n)
{
	int i, j, num, p = 0;
	fill(isprime, isprime + MAXN + 1, 1);
	for (i = 2, num = 1; i <= n; i++)
	{
		if (isprime[i])
		{
			isprime[i] = num++;
			for (j = 2 * i; j <= n; j += i)
				isprime[j] = 0;
		}
	}
}

int main()
{
	int n;
	sieve(MAXN);
	while (scanf("%d", &n) != EOF)
	{
		if (n == 1)
		{
			printf("0\n");
			continue;
		}
		while (!isprime[n])
		{
			n--;
		}
		printf("%d\n", isprime[n]);
	}
	return 0;
}

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

long length;
long prime[1000000];
bool isPrime(long n)
{
    bool isprimep = true;
    for(int i=0; i < length-1; i++)
        {
            if (!(n % prime[i]))
                {
                    isprimep = false;
                    break;
                }
        }
    return isprimep;
}

int main(void)
{
    long num;

    while(cin >> num)
    {
        length = 0;
        for (int n = 2; n <= num; n++)
        {
            if (isPrime(n))
            {
                prime[length] = n;
                length++;
            }
        }
        cout << length << endl;
    }
    return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<queue>
#include<cstring>
#include<cmath>
#include<cstdio>
#include<cstdlib>
using namespace std;
#define REP(i,a,n) for(int i = a ; i < n ; i++)
#define rep(i,n) REP(i,0,n)

typedef long long ll;

const int N = 1000000;  //MAXPRIME
const int M = 1000; //SQRT(N)
const int K = 600000;   //NUMBER OF PRIMES, CHOOSE 9/8 * N / LOG(N)

vector<int> iterativeSieve(){
  static int p[K],table[M];
  REP(i,2,M) p[i] = i;
  for(int i=2;i*i<M;i++)
    if(p[i])
      for(int j=i*i;j<M;j+=i)
        p[j] = 0;
  p[0] = p[1] = 0;

  int num = remove(p,p+M,0) - p;
  for(int m=M;m<N;m+=M){
    for(int x=m;x<m+M;x++)
      table[x-m] = x;
    for(int i=0,j;p[i]*p[i]<m+M;i++){
      if(p[i] >= m) j = p[i] * p[i];
      else if(m % p[i] == 0) j = m;
      else j = m - (m % p[i]) + p[i];
      for(;j<m+M;j+=p[i]) table[j-m] = 0;
    }
    num = remove_copy(table,table+M,p+num,0) - p;
  }
  return vector<int>(p,p+num);
}

int main(){
  vector<int> p = iterativeSieve();
  int n;
  while(cin>>n){
    cout<<upper_bound(p.begin(),p.end(),n) - p.begin()<<endl;
  }
}

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, 1, sizeof(prime));
	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){
				//vis[j] = 1;
				prime[j] = 0;
			}
		}
	}
	
	int n, m;
	while (cin >> n>>m){
		if (n==m) cout <<0 << endl;
		else {

		}
	}
	return 0;
}