Buggy python submission (verdict: Time Limit Exceeded):
import sys
for line in sys.stdin:
    n = int(line.rstrip('\n'))
    primeNumbers = range(1, n+1)
    for i in range(2, n+1):
        if primeNumbers[i-1] > 0:
            j = 2 * i
            while j <= n:
                primeNumbers[j-1] = 0
                j += i
    print sum(1 for primeNumber in primeNumbers if primeNumber > 0) - 1

Fixed submission:
import math
import sys

n = 999999
nums = [1] * (n+1)
nums[:2] = [0,0]
    
cnt = 0
while cnt <= math.sqrt(n):
    flg = nums[cnt]
    if flg == 1:
        k = 2
        while k*cnt <= n:
            nums[k*cnt] = 0
            k += 1
    cnt += 1


for line in sys.stdin:
    n = int(line)
    print sum(nums[:n+1])

Buggy python submission (verdict: Time Limit Exceeded):
import sys
def isPrimeNumber(candidate):
    divisor = 2
    while divisor < candidate:
        if candidate % divisor == 0:
            return False
        else:
            divisor += 1
    return True

for line in sys.stdin:
    primeNumberCount = 0
    n = int(line.rstrip('\n'))
    candidate = 2
    while candidate <= n:
        if isPrimeNumber(candidate):
            primeNumberCount += 1
        candidate += 1
    print primeNumberCount

Fixed submission:
import math
import sys

n = 999999
nums = [1] * (n+1)
nums[:2] = [0,0]
    
cnt = 0
while cnt <= math.sqrt(n):
    flg = nums[cnt]
    if flg == 1:
        k = 2
        while k*cnt <= n:
            nums[k*cnt] = 0
            k += 1
    cnt += 1


for line in sys.stdin:
    n = int(line)
    print sum(nums[:n+1])

Buggy python submission (verdict: Time Limit Exceeded):
import sys
def isPrimeNumber(candidate):
    divisor = 2
    while divisor < candidate:
        if candidate % divisor == 0:
            return False
        else:
            divisor += 1
    return True

for line in sys.stdin:
    primeNumberCount = 0
    n = int(line.rstrip('\n'))
    candidate = 2
    while candidate <= n:
        if isPrimeNumber(candidate):
            primeNumberCount += 1
        candidate += 1
    print primeNumberCount

Fixed submission:
import math
import sys

n = 999999
nums = [1] * (n+1)
nums[:2] = [0,0]
    
cnt = 0
while cnt <= math.sqrt(n):
    flg = nums[cnt]
    if flg == 1:
        k = 2
        while k*cnt <= n:
            nums[k*cnt] = 0
            k += 1
    cnt += 1


for line in sys.stdin:
    n = int(line)
    print sum(nums[:n+1])

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

def isPrimeNumber(candidate):
    divisor = 2
    while divisor <= math.sqrt(candidate):
        if candidate % divisor == 0:
            return False
        else:
            divisor += 1
    return True

for line in sys.stdin:
    primeNumberCount = 0
    n = int(line.rstrip('\n'))
    candidate = 2
    while candidate <= n:
        if isPrimeNumber(candidate):
            primeNumberCount += 1
        candidate += 1
    print primeNumberCount

Fixed submission:
import math
import sys

n = 999999
nums = [1] * (n+1)
nums[:2] = [0,0]
    
cnt = 0
while cnt <= math.sqrt(n):
    flg = nums[cnt]
    if flg == 1:
        k = 2
        while k*cnt <= n:
            nums[k*cnt] = 0
            k += 1
    cnt += 1


for line in sys.stdin:
    n = int(line)
    print sum(nums[:n+1])

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

def isPrimeNumber(candidate):
    divisor = 2
    while divisor <= math.sqrt(candidate):
        if candidate % divisor == 0:
            return False
        else:
            divisor += 1
    return True

for line in sys.stdin:
    primeNumberCount = 0
    n = int(line.rstrip('\n'))
    candidate = 2
    while candidate <= n:
        if isPrimeNumber(candidate):
            primeNumberCount += 1
        candidate += 1
    print primeNumberCount

Fixed submission:
import math
import sys

n = 999999
nums = [1] * (n+1)
nums[:2] = [0,0]
    
cnt = 0
while cnt <= math.sqrt(n):
    flg = nums[cnt]
    if flg == 1:
        k = 2
        while k*cnt <= n:
            nums[k*cnt] = 0
            k += 1
    cnt += 1


for line in sys.stdin:
    n = int(line)
    print sum(nums[:n+1])

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

for line in sys.stdin:
    count = 0
    n = int(line)
    
    nums = range(2, n+1)
    
    while True:
        if len(nums) == 1:
            count += 1
            break
        else:
            count += 1
            nums = [ for x in nums[1:] if x % nums[0] != 0 ]
    print count

Fixed submission:
import math
import sys

n = 999999
nums = [1] * (n+1)
nums[:2] = [0,0]
    
cnt = 0
while cnt <= math.sqrt(n):
    flg = nums[cnt]
    if flg == 1:
        k = 2
        while k*cnt <= n:
            nums[k*cnt] = 0
            k += 1
    cnt += 1


for line in sys.stdin:
    n = int(line)
    print sum(nums[:n+1])

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

for line in sys.stdin:
    count = 0
    n = int(line)
    
    nums = range(2, n+1)
    
    while True:
        if len(nums) == 1:
            count += 1
            break
        else:
            count += 1
            m = nums[0]
            numsCandidate = [1:]
            nums = [ for x in numsCandidate if x % m != 0 ]
    print count

Fixed submission:
import math
import sys

n = 999999
nums = [1] * (n+1)
nums[:2] = [0,0]
    
cnt = 0
while cnt <= math.sqrt(n):
    flg = nums[cnt]
    if flg == 1:
        k = 2
        while k*cnt <= n:
            nums[k*cnt] = 0
            k += 1
    cnt += 1


for line in sys.stdin:
    n = int(line)
    print sum(nums[:n+1])

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

for line in sys.stdin:
    count = 0
    n = int(line)
    
    nums = range(2, n+1)
    
    while True:
        if len(nums) == 0:
            break
        if len(nums) == 1:
            count += 1
            break
        else:
            count += 1
            m = nums[0]
            numsCandidate = nums[1:]
            nums = [ for x in numsCandidate if x % m != 0 ]
    print count

Fixed submission:
import math
import sys

n = 999999
nums = [1] * (n+1)
nums[:2] = [0,0]
    
cnt = 0
while cnt <= math.sqrt(n):
    flg = nums[cnt]
    if flg == 1:
        k = 2
        while k*cnt <= n:
            nums[k*cnt] = 0
            k += 1
    cnt += 1


for line in sys.stdin:
    n = int(line)
    print sum(nums[:n+1])

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

for line in sys.stdin:
    count = 0
    n = int(line)
    
    nums = range(2, n+1)
    
    while True:
        if len(nums) == 0:
            break
        elif len(nums) == 1:
            count += 1
            break
        else:
            count += 1
            m = nums[0]
            numsCandidate = nums[1:]
            nums = [ x  for x in numsCandidate if x % m != 0 ]
    print count

Fixed submission:
import math
import sys

n = 999999
nums = [1] * (n+1)
nums[:2] = [0,0]
    
cnt = 0
while cnt <= math.sqrt(n):
    flg = nums[cnt]
    if flg == 1:
        k = 2
        while k*cnt <= n:
            nums[k*cnt] = 0
            k += 1
    cnt += 1


for line in sys.stdin:
    n = int(line)
    print sum(nums[:n+1])

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

for line in sys.stdin:
    n = int(line)

    nums = [1] * (n+1)
    nums[:2] = [0,0]
    
    cnt = 0
    while cnt <= math.sqrt(n):
        flg = nums[cnt]
        if flg == 1:
            k = 2
            while k*cnt <= n:
                nums[k*cnt] = 0
                k += 1
        cnt += 1
    print sum(nums)

Fixed submission:
import math
import sys

n = 999999
nums = [1] * (n+1)
nums[:2] = [0,0]
    
cnt = 0
while cnt <= math.sqrt(n):
    flg = nums[cnt]
    if flg == 1:
        k = 2
        while k*cnt <= n:
            nums[k*cnt] = 0
            k += 1
    cnt += 1


for line in sys.stdin:
    n = int(line)
    print sum(nums[:n+1])

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

nums = [1] * 1000000
nums[:2] = [0,0]
    
cnt = 0
while cnt <= math.sqrt(n):
    flg = nums[cnt]
    if flg == 1:
        k = 2
        while k*cnt <= n:
            nums[k*cnt] = 0
            k += 1
    cnt += 1


for line in sys.stdin:
    n = int(line)
    print sum(nums[:n+1])

Fixed submission:
import math
import sys

n = 999999
nums = [1] * (n+1)
nums[:2] = [0,0]
    
cnt = 0
while cnt <= math.sqrt(n):
    flg = nums[cnt]
    if flg == 1:
        k = 2
        while k*cnt <= n:
            nums[k*cnt] = 0
            k += 1
    cnt += 1


for line in sys.stdin:
    n = int(line)
    print sum(nums[:n+1])