Buggy python submission (verdict: Time Limit Exceeded):
#coding: UTF-8

def is_prime(target_num):
    if target_num  == 2:
        return True
    elif target_num % 2 == 0:
        return False
    for i in range(3, target_num / 2 + 1, 2):
        if target_num % i == 0:
            return False
    return True

def count_prime_numbers(target_num):
    prime_count = 0
    for i in range(2, target_num + 1):
        if is_prime(i):
            prime_count += 1
    return prime_count

while True:
    try:
        input_str = raw_input()
    except EOFError:
        break
    
    print count_prime_numbers(int(input_str))

Fixed submission:
max_n = 999999
prime_list = [1] * (max_n + 1)

# 0, 1は素数ではない
prime_list[0:2] = [0, 0]

# 
for i in range(2, int(max_n**0.5) + 1):
    if prime_list[i] == 1:
        prime_list[i**2::i] = [0] * len(prime_list[i**2::i])

while True:
    try:
        n = int(input())
        print(sum(prime_list[:n + 1]))

    except EOFError:
        break

Buggy python submission (verdict: Time Limit Exceeded):
#coding: UTF-8

prime_number_list = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41]

def is_prime(target_num):
    if target_num in prime_number_list:
        return True
    elif target_num % 2 == 0:
        return False
    for i in range(3, target_num / 2 + 1, 2):
        if target_num % i == 0:
            return False
    return True

def count_prime_numbers(target_num):
    prime_count = 0
    for i in range(2, target_num + 1):
        if is_prime(i):
            prime_count += 1
    return prime_count

while True:
    try:
        input_str = raw_input()
    except EOFError:
        break
    
    print count_prime_numbers(int(input_str))

Fixed submission:
max_n = 999999
prime_list = [1] * (max_n + 1)

# 0, 1は素数ではない
prime_list[0:2] = [0, 0]

# 
for i in range(2, int(max_n**0.5) + 1):
    if prime_list[i] == 1:
        prime_list[i**2::i] = [0] * len(prime_list[i**2::i])

while True:
    try:
        n = int(input())
        print(sum(prime_list[:n + 1]))

    except EOFError:
        break

Buggy python submission (verdict: Time Limit Exceeded):
#coding: UTF-8

def is_prime(target_num):
    i = 2
    while i * i <= target_num:
        if target_num % i == 0:
            return False
        i += 1
    return True

def count_prime_numbers(target_num):
    prime_count = 0
    for i in range(2, target_num + 1):
        if is_prime(i):
            prime_count += 1
    return prime_count

while True:
    try:
        input_str = raw_input()
    except EOFError:
        break
    
    print count_prime_numbers(int(input_str))

Fixed submission:
max_n = 999999
prime_list = [1] * (max_n + 1)

# 0, 1は素数ではない
prime_list[0:2] = [0, 0]

# 
for i in range(2, int(max_n**0.5) + 1):
    if prime_list[i] == 1:
        prime_list[i**2::i] = [0] * len(prime_list[i**2::i])

while True:
    try:
        n = int(input())
        print(sum(prime_list[:n + 1]))

    except EOFError:
        break

Buggy python submission (verdict: Time Limit Exceeded):
#coding: UTF-8

prime_number_list = []

def is_prime(target_num):
    if target_num in prime_number_list:
        return True
    i = 2
    while i * i <= target_num:
        if target_num % i == 0:
            return False
        i += 1
    return True

def count_prime_numbers(target_num_list):
    prime_count = 0
    counted_num = 0
    prime_count_map = {}
    for i in range(2, target_num_list[len(target_num_list) - 1] + 1):
        if is_prime(i):
            prime_number_list.append(i)
            prime_count += 1
        if i >= target_num_list[counted_num]:
            prime_count_map[target_num_list[counted_num]] = prime_count
            counted_num += 1
    return prime_count_map

input_list = []
sorted_input_list = []
while True:
    try:
        input_str = raw_input()
    except EOFError:
        break
    input_list.append(int(input_str))
    sorted_input_list.append(int(input_str))

sorted_input_list.sort()

prime_counts = count_prime_numbers(sorted_input_list)

for i in input_list:
    print prime_counts[i]

Fixed submission:
max_n = 999999
prime_list = [1] * (max_n + 1)

# 0, 1は素数ではない
prime_list[0:2] = [0, 0]

# 
for i in range(2, int(max_n**0.5) + 1):
    if prime_list[i] == 1:
        prime_list[i**2::i] = [0] * len(prime_list[i**2::i])

while True:
    try:
        n = int(input())
        print(sum(prime_list[:n + 1]))

    except EOFError:
        break

Buggy python submission (verdict: Runtime Error):
#coding: UTF-8

from bisect import bisect_right

# 指定した数以下の素数の個数を返却する
# 素数判定はエラストテネスのふるい

# 要素1000000のリスト（素数かどうかのリスト）を準備
max_number = 1000000
prime_flag_list = [True] * max_number

# 0、1は素数でない
prime_flag_list[0] = False
prime_flag_list[1] = False

# 2の倍数（2を除く）は素数でない
prime_flag_list[4::2] = [False] * len(prime_flag_list[4::2])

# 3以上の数について、素数ならその倍数を振るい落とす
for i in range(3, int(max_number**0.5) + 1, 2):
    prime_flag_list[i*i::i] = [False] * len(prime_flag_list[i*i::i])

# フラグの立ったままの箇所は素数なので、そこだけ取り出す
prime_list = [i for i in range(2, max_number) if prime_flag_list[i]]

while True:
    try:
        input = int(raw_input())
    except EOFError:
        break
        
    # 素数リスト（ソート済み）の中に、入力した数値を入れるとしたら何項目目になるかを
    # bisectで求める
    print bisect.bisect_right(prime_list, input)

Fixed submission:
max_n = 999999
prime_list = [1] * (max_n + 1)

# 0, 1は素数ではない
prime_list[0:2] = [0, 0]

# 
for i in range(2, int(max_n**0.5) + 1):
    if prime_list[i] == 1:
        prime_list[i**2::i] = [0] * len(prime_list[i**2::i])

while True:
    try:
        n = int(input())
        print(sum(prime_list[:n + 1]))

    except EOFError:
        break