Buggy python submission (verdict: Time Limit Exceeded):
import math

ans = []
while True:
	try:
		n = int(raw_input())
		if n < 2:
			ans.append(0)
			continue
		prime_list = range(2, n + 1)
		head = prime_list[0]
		i = 0
		while head < math.sqrt(n):
			for j in range(len(prime_list) - 1, 0, -1):
				if (prime_list[j] % head == 0) & (prime_list[j] != head):
					del prime_list[j]
			i += 1
			head = prime_list[i]
		ans.append(len(prime_list))
	except EOFError:
		break
for num in ans:
	print num

Fixed submission:
MAX = 1000000
prime = [1] * MAX
prime[0], prime[1] = 0, 0
i = 2
while i * i < MAX:
    j = 2
    while i * j < MAX:
        prime[i * j] = 0
        j += 1
    i += 1
for k in range(1, len(prime)):
    prime[k] += prime[k-1]

while True:
    try:
        n = int(raw_input())
        print prime[n]
    except EOFError:
        break

Buggy python submission (verdict: Time Limit Exceeded):
import math

ans = []
while True:
	try:
		n = int(raw_input())
		if n < 2:
			ans.append(0)
			continue
		prime_list = range(3, n + 1, 2)
		prime_list.insert(0, 2)
		head = prime_list[0]
		i = 0
		while head < math.sqrt(n):
			for j in range(len(prime_list) - 1, 0, -1):
				if (prime_list[j] % head == 0) & (prime_list[j] != head):
					del prime_list[j]
			i += 1
			head = prime_list[i]
		ans.append(len(prime_list))
	except EOFError:
		break
for num in ans:
	print num

Fixed submission:
MAX = 1000000
prime = [1] * MAX
prime[0], prime[1] = 0, 0
i = 2
while i * i < MAX:
    j = 2
    while i * j < MAX:
        prime[i * j] = 0
        j += 1
    i += 1
for k in range(1, len(prime)):
    prime[k] += prime[k-1]

while True:
    try:
        n = int(raw_input())
        print prime[n]
    except EOFError:
        break

Buggy python submission (verdict: Time Limit Exceeded):
import math

ans = []
while True:
	try:
		n = int(raw_input())
		isPrime = [False, False]
		for i in range(n - 1):
			isPrime.append(True)
		i = 2
		while i < math.sqrt(n):
			j = i * 2
			while j < len(isPrime):
				isPrime[j] = False
				j += i
			i += 1
		ans.append(isPrime.count(True))
	except EOFError:
		break
for num in ans:
	print num

Fixed submission:
MAX = 1000000
prime = [1] * MAX
prime[0], prime[1] = 0, 0
i = 2
while i * i < MAX:
    j = 2
    while i * j < MAX:
        prime[i * j] = 0
        j += 1
    i += 1
for k in range(1, len(prime)):
    prime[k] += prime[k-1]

while True:
    try:
        n = int(raw_input())
        print prime[n]
    except EOFError:
        break

Buggy python submission (verdict: Time Limit Exceeded):
import math

ans = []
while True:
	try:
		n = int(raw_input())
		isPrime = [False, False]
		for i in range(n - 1):
			isPrime.append(-1)
		i = 2
		while i < math.sqrt(n):
			j = i 
			while j < len(isPrime):
				isPrime[j] = False
				j += i
			isPrime[i] = True
			i = isPrime.index(-1)
		ans.append(isPrime.count(True) + isPrime.count(-1))
	except EOFError:
		break
for num in ans:
	print num

Fixed submission:
MAX = 1000000
prime = [1] * MAX
prime[0], prime[1] = 0, 0
i = 2
while i * i < MAX:
    j = 2
    while i * j < MAX:
        prime[i * j] = 0
        j += 1
    i += 1
for k in range(1, len(prime)):
    prime[k] += prime[k-1]

while True:
    try:
        n = int(raw_input())
        print prime[n]
    except EOFError:
        break

Buggy python submission (verdict: Time Limit Exceeded):
import math

ans = []
while True:
	try:
		n = int(raw_input())
		isPrime = [-1] * (n + 1)
		isPrime[0], isPrime[1] = False, False
		i = 2
		while i * i < n:
			j = i 
			while j < len(isPrime):
				isPrime[j] = False
				j += i
			isPrime[i] = True
			i = isPrime.index(-1)
		ans.append(isPrime.count(True) + isPrime.count(-1))
	except EOFError:
		break
for num in ans:
	print num

Fixed submission:
MAX = 1000000
prime = [1] * MAX
prime[0], prime[1] = 0, 0
i = 2
while i * i < MAX:
    j = 2
    while i * j < MAX:
        prime[i * j] = 0
        j += 1
    i += 1
for k in range(1, len(prime)):
    prime[k] += prime[k-1]

while True:
    try:
        n = int(raw_input())
        print prime[n]
    except EOFError:
        break

Buggy python submission (verdict: Time Limit Exceeded):
import math

ans = []
while True:
	try:
		n = int(raw_input())
		isPrime = [-1] * (n + 1)
		isPrime[0], isPrime[1] = False, False
		#isPrime[2] = True
		i = 2
		while i * i < n:
			for j in range(i, n+1, i):
				isPrime[j] = False
			isPrime[i] = True
			i = isPrime.index(-1)
			print isPrime
		ans.append(isPrime.count(True) + isPrime.count(-1))
	except EOFError:
		break
for num in ans:
	print num

Fixed submission:
MAX = 1000000
prime = [1] * MAX
prime[0], prime[1] = 0, 0
i = 2
while i * i < MAX:
    j = 2
    while i * j < MAX:
        prime[i * j] = 0
        j += 1
    i += 1
for k in range(1, len(prime)):
    prime[k] += prime[k-1]

while True:
    try:
        n = int(raw_input())
        print prime[n]
    except EOFError:
        break

Buggy python submission (verdict: Runtime Error):
import math

ans = []
while True:
	try:
		n = int(raw_input())
		isPrime = [-1] * (n + 1)
		isPrime[0], isPrime[1] = False, False
		i = 2
		while i * i < n:
			for j in range(i, n+i, i):
				isPrime[j] = False
			isPrime[i] = True
			i = isPrime.index(-1)
		ans.append(isPrime.count(True) + isPrime.count(-1))
	except EOFError:
		break
for num in ans:
	print num

Fixed submission:
MAX = 1000000
prime = [1] * MAX
prime[0], prime[1] = 0, 0
i = 2
while i * i < MAX:
    j = 2
    while i * j < MAX:
        prime[i * j] = 0
        j += 1
    i += 1
for k in range(1, len(prime)):
    prime[k] += prime[k-1]

while True:
    try:
        n = int(raw_input())
        print prime[n]
    except EOFError:
        break

Buggy python submission (verdict: Time Limit Exceeded):
import math

ans = []
while True:
	try:
		n = int(raw_input())
		isPrime = [-1] * (n + 1)
		isPrime[0], isPrime[1] = False, False
		i = 2
		while i * i <= n:
			j = 2
			while j * i <= n:
			#for j in range(i, n+1 ,i):
				#print "%d,"%(j),
				isPrime[j * i] = False
				j += 1

			isPrime[i] = True
			i = isPrime.index(-1)
		ans.append(isPrime.count(True) + isPrime.count(-1))
	except EOFError:
		break
for num in ans:
	print num

Fixed submission:
MAX = 1000000
prime = [1] * MAX
prime[0], prime[1] = 0, 0
i = 2
while i * i < MAX:
    j = 2
    while i * j < MAX:
        prime[i * j] = 0
        j += 1
    i += 1
for k in range(1, len(prime)):
    prime[k] += prime[k-1]

while True:
    try:
        n = int(raw_input())
        print prime[n]
    except EOFError:
        break