Go: package main
import (
	"fmt"
	"os"
	"strconv"
	"bufio"
	//"math"
)

var sc = bufio.NewScanner(os.Stdin)

func main(){
	for sc.Scan(){
		n := nextInt()
		fmt.Println(calc(n))
	}
}

func calc(n int)int{
	// エラトステネスで数え上げる
	// 最初から999999まで用意しておいて入力のたびO(1)で出すのとどっちが速いのかはわからん
	eratos := make([]bool, n+1)
	c := 0
	for i:=2; i<len(eratos); i++{
		if eratos[i] == false{
			c++
			for j:=i*i; j<len(eratos); j+=i{
				eratos[j]=true
			}
		}
	}
	return c
}

func next()string{
	return sc.Text()
}

func nextInt()int{
	a, _ := strconv.Atoi(next())
	return a
}

C++: /* All men have limits. They learn what they are and learn
   not to exceed them, I ignore mine. -Batman           */

#include <bits/stdc++.h>
//#include <Windows.h>
using namespace std;

void wakwaw(int *x) { 
     x[1] = 0; 
     x[2] = 1; 
     for (int i = 3; i <= 1000000; i += 2) 
         x[i] = 1; 
 
 
     for (int i = 3; i <= 1000; i += 2) { 
         if (x[i] == 0) 
             continue; 
         for (int j = 2; i * j <= 1000000; j++) 
            x[i * j] = 0; 
     } 
 
 
     for (int i = 3; i <= 1000000; i++) 
         x[i] += x[i-1]; 
 } 
 
 
 int main() { 
 
 
     int *arr = new int[1000001]; 
     wakwaw(arr); 
 
 
     int n; 
     while (cin >> n) { 
         cout << arr[n] << endl; 
     } 
 
 
     return 0; 
 }

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

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;

vi prime_count;
void sieve(int max){
    int count = 0;
    vector<bool> table(max + 1, true);
    table[0] = false;
    prime_count.push_back(0);
    table[1] = false;
    prime_count.push_back(0);
    for(int i = 2; i <= max; i++){
        if(table[i]){
            count++;
            for(int j = 2; i * j <= max; j++){
                table[i * j] = false;
            }
        }
        prime_count.push_back(count);
    }
}

int main(){
    int n;
    sieve(10000);
    while(cin>>n){
        cout << prime_count[n] << endl;
    }
}

C++: #include <iostream>
#include <memory.h>
using namespace std;
int main()
{
	bool prime[1000010];
	memset(prime,1,1000010);
	prime[0]=prime[1]=0;
	int i,j,n,sum;
	for (i=2;i<1000000;i++)
	{
		if (prime[i])
		{
			for (j=2;i*j<1000000;j++)
			{
				prime[i*j]=false;
			}
		}
	}
	while(cin>>n)
	{
		sum=0;
		for(i=2;i<=n;i++)
		{
			sum+=prime[i];
		}
		cout<<sum<<endl;

	}	
	return 0;
}

C++: #include<iostream>

using namespace std;

int main(void){
	
	long int n,f,k,i;
	int count;
	bool chk;
	while(scanf("%d",&n)!=EOF){
		count=0;
		for(i=2;i<=n;i++){
		
			chk=0;
			f=i/2;
			k=2;
		
			while(f>=k){
				if((i%k)==0){
					chk=true;
					break;
				}
				k++;
			}
		
			if(chk==false){
				count++;
			}
		}
		cout<<count<<endl;
	}
}

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

int main(){
	int yaku = 0,n,hoge = 0;
	while(cin >> n){
		hoge = 0;
		for(int i = 1;i <= n;i++){
			yaku = 0;
			for(int j = 1;j <= i;j++){
				if(i % j == 0) yaku++;
			}
			if ( yaku == 2)	hoge ++;
		}
		cout <<  hoge << endl;

	}

}

C++: #include<iostream>
#include<algorithm>
using namespace std;
int arr[1000000]={0};
bool isPrime(int n){ 
    if(n<2)
        return false;
    for(int i=2; i*i<=n; i++){
        if(n%i==0)
            return false;
    }   
    return true;
}
void arra(int n, int m){ 
    int c=0;
    if(n>m){
        int memo=m;
        m=n;
        n=memo;
    }   
    for(int i=n+1; i<=m; i++){
        if(isPrime(i)){
            c++;
            //arr[i]=arr[n]+c;
        }   
        arr[i]=arr[n]+c;
    }   
    //arr[m]=arr[n]+c;
}
int main(){
    int n, m=0;
    while(cin>>n){
        if(arr[n]==0){
            arra(n, m); 
        }   
        cout<<arr[n]<<endl;
        m=max(n, m); 
    }   
    return 0;
}

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

bool isprime(int number, std::vector<int> const& primeset)
{
	int maxprime = static_cast<int>(std::sqrt(static_cast<float>(number)));

	typedef std::vector<int>::const_iterator Iter;
	Iter primesetlimit = std::upper_bound(primeset.begin(), primeset.end(), maxprime);
	for (Iter p = primeset.begin(); p != primesetlimit; ++p) {
		if (number % *p == 0) {
			return false;
		}
	}
	return true;
}

int resolve(int number)
{
	if (number < 2) {
		return 0;
	}
	if (number == 2) {
		return 1;
	}
	std::vector<int> primesetExceptTwo;
	for (int i = 3; i <= number; i += 2) {
		if (isprime(i, primesetExceptTwo)) {
			primesetExceptTwo.push_back(i);
		}
	}
	return static_cast<int>(primesetExceptTwo.size()) + 1;
}

int main()
{
	int input;
	while (std::cin >> input) {
		std::cout << resolve(input) << std::endl;
	}

	return 0;
}

C++: #define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

#include <bits/stdc++.h>
using namespace std;

int main(){
  int a[1000010];
  rep(i,1000010) a[i]=1;
  
  rep(i,1000000){
    if(i<2){
      a[i]=0;
      continue;
    }
    if(i==2){
      a[i]=1;
      continue;
    }
    else if(i%2==0){
      a[i]=0;
      continue;
    }
    
    for(int j=3;j*j<=i;j+=2){
      if(i%j==0){
        a[i]=0;
        continue;
      }
    }
  }
  
  int dp[1000010];
  dp[0]=0;
  for(int i=1;i<1000009;i++){
    if(a[i]) dp[i]=dp[i-1]+1;
    else dp[i]=dp[i-1];
  }
  
  int n;
  while(cin>>n){
    cout<<dp[n]<<endl;
  }
  
  return 0;
}

C++: #define _USE_MATH_DEFINES
#include <iostream> 
#include <math.h>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std; 
int main(){
	int N;
	while(cin >> N)
	double p = log2(N);
	while (cin >> N){
		int sum =0;
		cout << N*p << endl;
	}
	return 0;
}

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

int main()
{
    bool notPrime[1000000]={false};
    notPrime[0]=notPrime[1]=true;
    for (unsigned i=3; i<1000000; i+=2) {
        if (!notPrime[i]) {
            for (unsigned j=2; i*j<1000000; j++) {
                notPrime[i*j]=true;
            }
        }
    }
    for (unsigned n, count; cin >> n; cout << count << endl) {
        count=0;
        if (n>=2) {
            count++;
            for (unsigned i=3; i<=n; i+=2) {
                if (!notPrime[i]) {
                    count++;
                }
            }
        }
    }
    return 0;
}

C++: #include <stdio.h>
#include <math.h>
int sosuu(int x){
    int n,m,sosuu;
    sosuu=x-2;
    for(n=2;n<x;n++){//nは素数を調べる。入力された数字まで１からスライドしていく。
        for(m=2;m<n;m++){//mはnが素数かどうか調べる。素数かどうかをnより小さい数字で数えていく。2からなのは2から素数だから。1はふくめない。
            if(n%m==0){//素数じゃなかったら、つまり割り切れてしまったら。
                sosuu--;
            }
           
            if(n%m==0) break;
        }
    }
    if(x==1||x==0) sosuu=0;
    return sosuu;
}

int main ( void ) {
    int s,result;
    while(scanf("%d",&s)!=EOF){
        result = sosuu(s);
        printf("%d\n",result);
    }
    return 0;
}

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

int main(){
    long maxy = (long)sqrt(1000000);
    int prime[maxy];
    //ツエツδ可トツスツテツネツスツづ個づ督づゥツつ「
    
    for(int i = 0; i < maxy; i++){
        prime[i] = 1;
    }
    prime[0] = prime[1] = 0;
    for(int i = 2; i <= (int)maxy; i++){
        if(prime[i] == 1){
            for(int j=i*2; j <= (int)maxy; j+=i){
                prime[j] = 0;
            }        
        }
    }
    int n;
    while(cin >> n){
        int ans = 0;
        for(int i=0; (i <= maxy && i <= n); i++){
            if(prime[i] == 1){
                ans++;
            }
        }
        cout << ans << endl;
    }
    return 0;
}