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 <iostream>
#include<cstring>
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<map>
#include<vector>
#include<stack>
#include <string>
#include<fstream>
#include<ctime>
#include<queue>

using namespace std;
#define LL long long
#define mxn 100010
#define mxe 1000010
#define eps 1e-4
#define inf 0x7fffffff

#include<iostream>
#include<cstdio>
#define INF 999999999;
#include<iostream>
using namespace std;

#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));
	prime[0] = prime[1] = 0;
	for (int i = 2; i<= MAX; i++){
		if (!vis[i]){
			prime[i] = 1;
			for (int j = i + i; j <= MAX; j += i){
				vis[j] = 1;
				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;
}

C++: #include<stdio.h>
int main ()
{
    int n,i,m,sum;
    while(1)
    {
        sum=0;
        scanf("%d",&n);
        for(m=2;m<=n;m++)
        {
            for(i=2;i<=m;i++)
            {
                if(m%i==0 && i<m)
                {
                    break;
                }
                if(i==m)
                {
                    sum=sum+1;
                }
            }
        }
        printf("%d\n",sum);
    }
    return 0;
}

C++: #include <iostream>
#include <math.h>
#include <stdlib.h>

using namespace std;

int main() {

	int n,count;

	while (cin >> n) {
		
		//?´???°????????????????????§?????????
		bool is_prime;

		//2????´???°??????????????????????????????
		count = 1;

		//i??¨????????°????´???°????????????
		for (int i = 3; i <= n; i+=2) {
			cout << "i=" << i << endl;
			is_prime = true;
			//????????°??????????°?????????°??§?????£?????????
			for (int j = 3; j <= sqrt(n); j+=2) {
				if (i == j) {
					break;
				}
				cout << "i=" << i << " j=" << j << " i%j=" << i%j << endl;
				if (i%j == 0) {						//????????????????????????????´???°??§?????????
					is_prime = false;
					break;
				}
			}
			//?????????????????°???????????£???????????°i????´???°
			if (is_prime==true) {
				cout << i << " is prime" << endl;
				count++;
			}
		}

		//??¨???
		cout << count << endl;
	}
	return 0;
}

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

using namespace std;

int main()
{
	int numa[4];
	int numb[4];
	int a, i, j;
	int hit, blow;
	

	while((cin.get()) != istream::traits_type::eof())
	{	
		for(i = 0; i < 4; i++)
		{
			cin >> numa[i];
		}
		
		for(i = 0; i < 4; i++)
		{
			cin >> numb[i];
		}
		
		
		hit = 0;
		
		for(i = 0; i < 4; i++)
		{
			if(numa[i] == numb[i])
			{
				hit = hit + 1;
			}
		}
		
		blow = 0;
		for(i = 0; i < 4; i++)
		{
			for(j = 0; j < 4; j++)
			{
				if(numa[i] == numb[j] && i != j)
				{
					blow = blow + 1;
				}
			}
		}
		
		cout << hit << " " << blow << endl;
	}
		
	return 0;
		
}

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

using namespace std;

int main(){
	int n,i,j,buf,cnt;

	while(cin >> n){
		cnt = 1;

		for(i=3;i<=n;i+=2){
			buf = (int)sqrt((double)i);

			for(j=3;j<=buf;j+=2){
				if((i % j) == 0){
					cnt--;
					break;
				}
			}

			cnt++;
		}

		cout << cnt << endl;
	}

	return 0;
}

C++: #include "bits/stdc++.h"
using namespace std;

int main() {
	static bool Prime[1000000] = {};
	static int Count[1000000] = {};
	for (int i = 2; i < 1000000; i++) {
		Prime[i] = true;
	}
	for (int i = 2; i <= 1000; i++) {
		if (Prime[i]) {
			for (int j = 2; j <= 999999 / i; j++) {
				Prime[i * j] = false;
			}
		}
	}
	for (int i = 2; i < 1000000; i++) {
		Count[i] = Count[i - 1];
		if (Prime[i]) Count[i]++;
	}
	int N;
	while (cin >> N) {
		cout << Count[N] << endl;
	}
}

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

int prime(int data){
	int i;
	if(data == 2){
		return 1;
	}
	if(data%2 == 0){
		return 0;
	}
	for(i = 2;i < data;i++){
		if(data%i == 0){
			return 0;
		}
	}
	return 1;
}

int main(void){
	int data,cnt=0,i;
	while(std::cin >> data){
		for(i=2;i<=data;i++){
			if(prime(i)){
				cnt++;
			}
		}
		std::cout << cnt << std::endl;
	}
}

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(long long int  = (long long int)i*i;j<MAX;j=j*j){
         v[j]=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<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<ctype.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#define MAX 1000000
using namespace std;
int prime[1000009];
void sive()
{
    int i,j,k,c=0;
    prime[0]=1;
    prime[1]=1;
    for(i=2;i*i<=1000009;i++)
    {
        if(prime[i]==0)
        {
            for(j=i+i;j<1000009;j+=i)
            {
                prime[j]=1;
            }
        }
    }
}
int main()
{
    int st,en,i,c=0,co;
    int b[100];
    sive();
     //printf("1");

    while(scanf("%d",&en)==1)
    {
        co=0;
    for(i=2;i<=en;i++)
    {
        if(prime[i]==0)
        //printf("1");
        {
            co++;
        }
    }
            printf("%d\n",co);
    }

    return 0;
}

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

int main() {
	int n;
	while(cin >> n && n != EOF) {
		bool* prime = new bool[n+1];
		int count = 0;
		for(int i = 2; i < n; ++i) {
			prime[i] = true;
		}
		prime[0] = prime[1] = false;
		
		for(int i = 0; i < n; ++i) {
			if(prime[i]) {
				count++;
				for(int j = 2 * i; j < n; j += i) {
					prime[j] = false;
				}
			}
		}
		
		cout << count << endl;
	}
}

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;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++: #include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cstring>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, int> ll_i;
struct edge { int u, v; ll w; };

void sieve(int n, bool a[]) {
	fill(a, a + n, true);
	a[0] = a[1] = false;
	for (int i = 2; i * i < n; i++)
		if (a[i])
			for (int j = i * 2; j < n; j += i)
				a[j] = false;
}

bool a[1000000];
int b[1000000];

int main() {
	sieve(1000000, a);
	for (int i = 1; i < 1000000; i++)
		b[i] = b[i - 1] + (a[i] ? 1 : 0);
	int n;
	while (cin >> n) cout << b[n] << endl;
}