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])
    }
}

Python: A=[
960131, 960137, 960139, 960151, 960173, 960191, 960199, 960217, 960229, 960251, 960259, 960293, 960299, 960329, 960331, 960341, 960353, 960373, 960383, 960389, 960419, 960467, 960493, 960497, 960499, 960521, 960523, 960527, 960569, 960581, 960587, 960593, 960601, 960637, 960643, 960647, 960649, 960667, 960677, 960691, 960703, 960709, 960737, 960763, 960793, 960803, 960809, 960829, 960833, 960863, 960889, 960931, 960937, 960941, 960961, 960977, 960983, 960989, 960991, 961003, 961021, 961033, 961063, 961067, 961069, 961073, 999149, 999169, 999181, 999199, 999217, 999221, 999233, 999239, 999269, 999287, 999307, 999329, 999331, 999359, 999371, 999377, 999389, 999431, 999433, 999437, 999451, 999491, 999499, 999521, 999529, 999541, 999553, 999563, 999599, 999611, 999613, 999623, 999631, 999653, 999667, 999671, 999683, 999721, 999727, 999749, 999763, 999769, 999773, 999809, 999853, 999863, 999883, 999907, 999917, 999931, 999953, 999959, 999961, 999979, 999983]
while True:
    try:
        n=int(input())
        print(A)
    except:
        break

Python: def erato(n):
    s = list(range(n+1))
    s[1] = 0
    for e in s:
        if e:
            for i in range(e*2, n+1, e):
                s[i] = 0
    return s
while True:
    try:
        n = int(input())
        print(len(list(filter(lambda x:x, erato(n)))))
    except:
        break

Python: # -*- coding: utf-8 -*-
from math import sqrt
from bisect import bisect

def inpl(): return tuple(map(int, input().split()))

def primes(N):
    P = [2]
    searched = [False]*(N+1)
    for i in range(3, N+1, 2):
        if searched[i]:
            continue
        P.append(i)
        for j in range(i, N+1, i):
            searched[j] = True
    return P

P = primes(10**6)

try:
    while True:
        print(bisect(P, int(input())))
except:
  pass

Python: def sieve_prime(n): # return prime numbers within [1, n]
  primes = []
  is_prime = [True] * (n+1) # [0, n]
  for i in range(2, n+1):
    if not is_prime[i]:
      continue # need only primes

    primes.append(i)
    for j in range(i*2, n+1, i): # range(i*2, n+1, i) = {i*2, i*3, ...}
      is_prime[j] = False

    """
    Compare the above code with the below one in the view of time complexity
    for j in range(i*2, n+1):
      if j % i == 0:
        is_prime[j] = False
    """
        
  return primes
      
while True:
  try:
    n = int(input())
    print(len(sieve_prime(n))) # because T <= 30, you can simply use sieve_prime every time
  except EOFError:
    break

Python: while t == 0:	
	total = 0
	try:
		n = int(input())
	except:
		break
	else:
	        print(total)

Python: import math

a = [1]*1000000
for i in range(2,1000000):
    for j in range(i+i,1000000)[::i]:
        a[j] = 0

b = [0]*1000000
b[0] = b[1] = 0
for i in range(2,1000000):
    if a[i] == 1:
        b[i] = b[i-1] + 1
    else:
        b[i] = b[i-1]

while True:
    try:
        print(b[int(input())])
    except EOFError:
        break

Python: def Eratosthenes(n):
	N = {i:True for i in range(2,n+1)}
	primeNumbers = []
	for i in range(2,n+1):
		if N[i]:
			primeNumbers.append(i)
			j = i*2
			while j<=n:
				N.update({j:False})
				j += i
	return primeNumbers

while True:
	P = Eratosthenes(999999)
	try:
		n = int(input())
	except EOFError:
		break
	cnt = 0
	for x in P:
		if x>n:
			break
		cnt += 1
	print(cnt)

Python: from sys import stdin

for limit in stdin:
    limit = int(limit)
    arr = [2,3,5,7]
    def PrimeNumber(arr,number):
        for i in arr:
            if (number%i==0):
                return False
        return True

    for i in range(2,limit+1):
        if(PrimeNumber(arr,i)):
            arr.append(i)
            
    count = 0
    for i in arr:
        if (i>limit):
            break
        else:
            count += 1

    print(count)

Python: import sys


def primes(n):
    f = []
    for i in range(n + 1):
        if i > 2 and i % 2 == 0:
            f.append(0)
        else:
            f.append(1)
    i = 3
    while i * i <= n:
        if f[i] == 1:
            j = i * i
            while j <= n:
                f[j] = 0
                j += i + i
        i += 2
    return f[2:]


if __name__ == "__main__":
    ps = primes(100)
    for n in sys.stdin:
        i = int(n)
        if i < 2:
            print(i, 0)
        else:
            print(i, sum(ps[:i - 1]))

Python: import bisect 


def make_prime_numbers(n):
    """n以下の素数を列挙したリストを出力する
    計算量: O(NloglogN)
    入出力例: 30 -> [2, 3, 5, 7, 11, 13, 17, 19, 23, 29]
    """
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n ** 0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(2 * i, n + 1, i):
            is_prime[j] = False
    prime_numbers = [i for i in range(n + 1) if is_prime[i]]
    return prime_numbers


prime_numbers = make_prime_numbers(10 ** 6)
while True:
    try:
        n = int(input())
    except:
        break
    print(bisect.bisect_right(prime_numbers, n))

Python: try:
    while True:
        n = int(input())
        datasets = list(range(2, n+1))
        answers = set([])
        while datasets:
            i = datasets[0]
            datasets = filter(lambda data: data%i != 0, datasets)
            answers.add(i)
        print(len(answers))
except:
    pass

Python: primes = [0, 0] + [1] * 999999
for i in range(2, 1000):
    if primes[i]:
        for j in range(i*i, 1000000, i):
            primes[j] = 0

while True:
    try:
        n = int(input())
    except:
        break
    ans = 0
    while n > 0:
        ans += primes[n]
        n -= 1
    print(ans)

Python: plst = [1 for i in range(1000001)]
slst = [0,0]
plst[0] = plst[1] = 0
count = 0
for i in range(2,1000001):
  if plst[i] == 1:
    count += 1
    for j in range(i * 2,1000001,i):
      plst[j] = 0
  slst.append(count)
while True:
  try:
    print(slst[int(input())])
  except EOFError:
    break

Python: import sys
m=166666;s=[1]*m;t=[1]*m
for i in range(m):
 if s[i]:
  k=6*i+5
  s[i+k::k]=[0]*len(s[i+k::k])
  t[-2-i+k::k]=[0]*len(t[-2-i+k::k])
 if t[i]:
  k=6*i+7
  s[-2-i+k::k]=[0]*len(s[-2-i+k::k])
  t[i+k::k]=[0]*len(t[i+k::k])
for e in map(int,sys.stdin):
 print((e-1,sum(s[:(e+1)//6])+sum(t[:(e-1)//6])+2)[e>3])

Python: # -*- coding: utf-8 -*-
import sys
array=[]
for i in sys.stdin:
    array.append(int(i))
m=max(array)
prime=[1]*(m+1)
prime[0]=prime[1]=0
for i in range(2,int(m**0.5)+1):
    if prime[i] ==1:
        for j in range(i*i,m+1,i):
            prime[j]=0
for i in range(len(array)):
    print(sum(prime[:array[i]+1]))